this is as optimized as the code will reasonably get
we just need to blit less stuff
This commit is contained in:
parent
331b76e798
commit
686125592a
88
bun.c
88
bun.c
|
@ -92,7 +92,7 @@ void bun_offRightSide(
|
|||
uint8_t i, plane = 0;
|
||||
uint8_t shift = plusXValue & 15;
|
||||
uint8_t wordShift = (plusXValue >> 4);
|
||||
uint16_t bltalwm;
|
||||
uint16_t bltalwm, bltcon0, bltcon1, bltdmod, bltsize;
|
||||
|
||||
bunClear->memoryStartOffsetBytes = (y * screenSetup->byteWidth) +
|
||||
screenSetup->byteWidth - COOL_BUN_WIDTH_BYTES +
|
||||
|
@ -106,9 +106,17 @@ void bun_offRightSide(
|
|||
bltalwm += (1 << (15 - i));
|
||||
}
|
||||
|
||||
bltcon0 = BLTCON0(0xc0, 0, 1, 0, 1, shift);
|
||||
bltcon1 = BLTCON1(bunClear->direction, shift);
|
||||
|
||||
bltdmod = screenSetup->byteWidth - COOL_BUN_WIDTH_BYTES +
|
||||
wordShift * 2;
|
||||
|
||||
bltsize = bunClear->widthWords + (bunClear->heightRows << 6);
|
||||
|
||||
for (plane = 0; plane < 2; ++plane) {
|
||||
custom.bltcon0 = BLTCON0(0xc0, 0, 1, 0, 1, shift);
|
||||
custom.bltcon1 = BLTCON1(bunClear->direction, shift);
|
||||
custom.bltcon0 = bltcon0;
|
||||
custom.bltcon1 = bltcon1;
|
||||
|
||||
custom.bltadat = 0xffff;
|
||||
custom.bltbpt = coolbunPlaneStarts[BUN_OFF_LEFT_SIDE][plane];
|
||||
|
@ -119,10 +127,9 @@ void bun_offRightSide(
|
|||
custom.bltalwm = bltalwm;
|
||||
|
||||
custom.bltbmod = wordShift * 2;
|
||||
custom.bltdmod = screenSetup->byteWidth - COOL_BUN_WIDTH_BYTES +
|
||||
wordShift * 2;
|
||||
custom.bltdmod = bltdmod;
|
||||
|
||||
custom.bltsize = bunClear->widthWords + (bunClear->heightRows << 6);
|
||||
custom.bltsize = bltsize;
|
||||
|
||||
WaitBlit();
|
||||
}
|
||||
|
@ -139,7 +146,7 @@ void bun_offLeftSide(
|
|||
uint8_t shift = minusXValue & 15;
|
||||
uint8_t wordShift = (minusXValue >> 4);
|
||||
uint8_t i;
|
||||
uint16_t bltalwm;
|
||||
uint16_t bltalwm, bltcon0, bltcon1, bltdmod, bltsize;
|
||||
|
||||
// y can't be 0 otherwise we will corrupt memory for now
|
||||
if (y == 0) return;
|
||||
|
@ -155,10 +162,16 @@ void bun_offLeftSide(
|
|||
bltalwm += (1 << i);
|
||||
}
|
||||
|
||||
bltcon0 = BLTCON0(0xc0, 0, 1, 0, 1, shift);
|
||||
bltcon1 = BLTCON1(bunClear->direction, shift);
|
||||
bltdmod = screenSetup->byteWidth - 4 + wordShift * 2;
|
||||
|
||||
bltsize = bunClear->widthWords + (bunClear->heightRows << 6);
|
||||
|
||||
for (plane = 0; plane < 2; ++plane) {
|
||||
// shift left, so descending
|
||||
custom.bltcon0 = BLTCON0(0xc0, 0, 1, 0, 1, shift);
|
||||
custom.bltcon1 = BLTCON1(bunClear->direction, shift);
|
||||
custom.bltcon0 = bltcon0;
|
||||
custom.bltcon1 = bltcon1;
|
||||
|
||||
// a has a mask we're shifting
|
||||
custom.bltadat = 0xffff;
|
||||
|
@ -172,9 +185,9 @@ void bun_offLeftSide(
|
|||
custom.bltalwm = bltalwm;
|
||||
|
||||
custom.bltbmod = wordShift * 2;
|
||||
custom.bltdmod = screenSetup->byteWidth - 4 + wordShift * 2;
|
||||
custom.bltdmod = bltdmod;
|
||||
|
||||
custom.bltsize = bunClear->widthWords + (bunClear->heightRows << 6);
|
||||
custom.bltsize = bltsize;
|
||||
|
||||
WaitBlit();
|
||||
}
|
||||
|
@ -190,6 +203,7 @@ void bun_anywhere(
|
|||
uint8_t plane;
|
||||
uint8_t shift = x & 15;
|
||||
uint8_t needsExtraWord = shift != 0;
|
||||
uint16_t bltcon0, bltcon1, bltalwm, bltbmod, bltdmod, bltsize;
|
||||
|
||||
bunClear->memoryStartOffsetBytes = WORD_ALIGNED_BYTE_POSITION(screenSetup->width, x, y);
|
||||
|
||||
|
@ -197,13 +211,23 @@ void bun_anywhere(
|
|||
bunClear->widthWords = 2 + needsExtraWord;
|
||||
bunClear->direction = BLITTER_ASCENDING;
|
||||
|
||||
for (plane = 0; plane < 2; ++plane) {
|
||||
// if we extend the bun area by a word, we only need one write
|
||||
// buns will never interfere with a background so they don't need a mask
|
||||
bltcon0 = BLTCON0(0xc0, 0, 1, 0, 1, shift);
|
||||
bltcon1 = BLTCON1(bunClear->direction, shift);
|
||||
|
||||
// buns will never interfere with a background so they don't need a mask
|
||||
// they do need the scratch area though
|
||||
custom.bltcon0 = BLTCON0(0xc0, 0, 1, 0, 1, shift);
|
||||
custom.bltcon1 = BLTCON1(bunClear->direction, shift);
|
||||
if (needsExtraWord) {
|
||||
bltalwm = 0x0000;
|
||||
} else {
|
||||
bltalwm = 0xffff;
|
||||
}
|
||||
|
||||
bltbmod = -(needsExtraWord * 2);
|
||||
bltdmod = screenSetup->byteWidth - COOL_BUN_WIDTH_BYTES - (needsExtraWord * 2);
|
||||
bltsize = bunClear->widthWords + (bunClear->heightRows << 6);
|
||||
|
||||
for (plane = 0; plane < 2; ++plane) {
|
||||
custom.bltcon0 = bltcon0;
|
||||
custom.bltcon1 = bltcon1;
|
||||
|
||||
custom.bltadat = 0xffff;
|
||||
custom.bltbpt = coolbunPlaneStarts[BUN_ANYWHERE][plane];
|
||||
|
@ -212,15 +236,11 @@ void bun_anywhere(
|
|||
|
||||
// custom.bltdpt = screenSetup.memoryStart;
|
||||
custom.bltafwm = 0xffff;
|
||||
if (needsExtraWord) {
|
||||
custom.bltalwm = 0x0000;
|
||||
} else {
|
||||
custom.bltalwm = 0xffff;
|
||||
}
|
||||
custom.bltalwm = bltalwm;
|
||||
|
||||
custom.bltbmod = -(needsExtraWord * 2);
|
||||
custom.bltdmod = screenSetup->byteWidth - COOL_BUN_WIDTH_BYTES - (needsExtraWord * 2);
|
||||
custom.bltsize = bunClear->widthWords + (bunClear->heightRows << 6);
|
||||
custom.bltbmod = bltbmod;
|
||||
custom.bltdmod = bltdmod;
|
||||
custom.bltsize = bltsize;
|
||||
|
||||
WaitBlit();
|
||||
}
|
||||
|
@ -242,7 +262,7 @@ void renderBun(
|
|||
if (x < -31) return;
|
||||
if (x > screenSetup->width + 31) return;
|
||||
if (y < 1) return;
|
||||
if (y > screenSetup->height- COOL_BUN_HEIGHT - 1) return;
|
||||
if (y > screenSetup->height - COOL_BUN_HEIGHT - 1) return;
|
||||
|
||||
if (x < 0) {
|
||||
bun_offLeftSide(
|
||||
|
@ -370,22 +390,30 @@ void clearCurrentBuns(
|
|||
) {
|
||||
int bun, plane;
|
||||
struct BunClear *currentBunClear;
|
||||
uint16_t bltcon0, bltcon1, bltdmod, bltsize;
|
||||
|
||||
if (!hasBunClear[bunRenderer->currentScreen->currentBuffer]) return;
|
||||
|
||||
bltcon0 = 0xc0 + (1 << 8);
|
||||
|
||||
for (bun = 0; bun < BUN_COUNT; ++bun) {
|
||||
currentBunClear = &bunClearForScreen[bunRenderer->currentScreen->currentBuffer][bun];
|
||||
|
||||
bltcon1 = BLTCON1(currentBunClear->direction, 0);
|
||||
bltdmod = bunRenderer->screenSetup->byteWidth - (currentBunClear->widthWords * 2);
|
||||
bltsize = currentBunClear->widthWords + (currentBunClear->heightRows << 6);
|
||||
|
||||
for (plane = 0; plane < 2; ++plane) {
|
||||
custom.bltcon0 = 0xc0 + (1 << 8);
|
||||
custom.bltcon1 = BLTCON1(currentBunClear->direction, 0);
|
||||
custom.bltcon0 = bltcon0;
|
||||
custom.bltcon1 = bltcon1;
|
||||
custom.bltadat = 0x0000;
|
||||
custom.bltafwm = 0xffff;
|
||||
custom.bltalwm = 0xffff;
|
||||
custom.bltdpt = bunRenderer->currentScreen->planes[plane] +
|
||||
currentBunClear->memoryStartOffsetBytes;
|
||||
custom.bltdmod = bunRenderer->screenSetup->byteWidth - (currentBunClear->widthWords * 2);
|
||||
custom.bltsize = currentBunClear->widthWords + (currentBunClear->heightRows << 6);
|
||||
custom.bltdmod = bltdmod;
|
||||
custom.bltsize = bltsize;
|
||||
|
||||
WaitBlit();
|
||||
}
|
||||
}
|
||||
|
|
56
main.c
56
main.c
|
@ -64,6 +64,37 @@ extern uint16_t chip SpriteCopperlist[];
|
|||
extern uint16_t chip SpriteData[];
|
||||
extern uint16_t chip MaskBitplane[];
|
||||
|
||||
void renderTopaz(void) {
|
||||
int plane;
|
||||
|
||||
uint16_t bltcon0, bltcmod;
|
||||
uint8_t *bltbpt;
|
||||
|
||||
bltcon0 = 0xca + (1 << 8) + (1 << 9) + (1 << 10) + (1 << 11);
|
||||
bltcmod = screenSetup.byteWidth - 32;
|
||||
bltbpt = TopazBitplanes;
|
||||
|
||||
for (plane = 0; plane < 3; ++plane) {
|
||||
custom.bltcon0 = bltcon0;
|
||||
custom.bltcon1 = 0;
|
||||
custom.bltafwm = 0xffff;
|
||||
custom.bltalwm = 0xffff;
|
||||
custom.bltapt = MaskBitplane;
|
||||
custom.bltbpt = bltbpt;
|
||||
custom.bltcpt = currentScreen.planes[plane];
|
||||
custom.bltdpt = currentScreen.planes[plane];
|
||||
custom.bltamod = 0;
|
||||
custom.bltbmod = 0;
|
||||
custom.bltcmod = bltcmod;
|
||||
custom.bltdmod = bltcmod;
|
||||
custom.bltsize = 16 + (256 << 6);
|
||||
|
||||
bltbpt += 32 * 256;
|
||||
|
||||
WaitBlit();
|
||||
}
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
uint16_t *copperlist, *currentCopperlist, *currentCopperColors, result, *currentSpriteCopperlist;
|
||||
uint32_t spriteDataPointer;
|
||||
|
@ -78,7 +109,6 @@ int main(void) {
|
|||
colors[2] = 0x0fff;
|
||||
colors[3] = 0x000f;
|
||||
|
||||
printf("%x\n", &SpriteData);
|
||||
printf("setting up, i haven't crashed...yet.\n");
|
||||
|
||||
setupScreen(&screenSetup, SCREEN_WIDTH, SCREEN_HEIGHT, 3);
|
||||
|
@ -101,7 +131,7 @@ int main(void) {
|
|||
¤tScreen,
|
||||
&copperlistBitplanePointers
|
||||
);
|
||||
currentCopperlist = setUpEmptySpritesInCopperlist(currentCopperlist);
|
||||
//currentCopperlist = setUpEmptySpritesInCopperlist(currentCopperlist);
|
||||
|
||||
currentCopperColors = CopperColors;
|
||||
currentSpriteCopperlist = SpriteCopperlist;
|
||||
|
@ -198,26 +228,11 @@ int main(void) {
|
|||
|
||||
renderBunFrame(i, &bunRenderer);
|
||||
|
||||
renderTopaz();
|
||||
|
||||
/*
|
||||
*/
|
||||
|
||||
for (plane = 0; plane < 3; ++plane) {
|
||||
custom.bltcon0 = 0xca + (1 << 8) + (1 << 9) + (1 << 10) + (1 << 11);
|
||||
custom.bltcon1 = 0;
|
||||
custom.bltafwm = 0xffff;
|
||||
custom.bltalwm = 0xffff;
|
||||
custom.bltapt = MaskBitplane;
|
||||
custom.bltbpt = TopazBitplanes + (plane * 32 * 256);
|
||||
custom.bltcpt = currentScreen.planes[plane];
|
||||
custom.bltdpt = currentScreen.planes[plane];
|
||||
custom.bltamod = 0;
|
||||
custom.bltbmod = 0;
|
||||
custom.bltcmod = screenSetup.byteWidth - 32;
|
||||
custom.bltdmod = screenSetup.byteWidth - 32;
|
||||
custom.bltsize = 16 + (256 << 6);
|
||||
|
||||
WaitBlit();
|
||||
}
|
||||
|
||||
/*
|
||||
*(SpriteData) = SPRPOS(250, 44);
|
||||
|
@ -230,7 +245,6 @@ int main(void) {
|
|||
copperlistBitplanePointers
|
||||
);
|
||||
|
||||
|
||||
WaitTOF();
|
||||
|
||||
if ((ciaa.ciapra >> 6) != 3) break;
|
||||
|
@ -255,8 +269,6 @@ int main(void) {
|
|||
}
|
||||
*/
|
||||
|
||||
printf("%x %x", SPRPOS(250, 44), SPRCTL(250, 44, 44 + 256));
|
||||
|
||||
freeCopperlist(copperlist);
|
||||
|
||||
teardownBunRenderer();
|
||||
|
|
Loading…
Reference in New Issue