From 686125592aaeda0e4e99c63eccb3b15b5be4bbff Mon Sep 17 00:00:00 2001 From: John Bintz Date: Thu, 13 Jun 2024 09:01:22 -0400 Subject: [PATCH] this is as optimized as the code will reasonably get we just need to blit less stuff --- bun.c | 88 +++++++++++++++++++++++++++++++++++++-------------------- main | Bin 77068 -> 77192 bytes main.c | 56 +++++++++++++++++++++--------------- 3 files changed, 92 insertions(+), 52 deletions(-) diff --git a/bun.c b/bun.c index 228f8b2..20ed093 100644 --- a/bun.c +++ b/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(); } } diff --git a/main b/main index ee124a79616b3e38ebfde0708000b6b750eae649..d6fc5e44b32bcde55b18eb7a977240866ff90b8f 100755 GIT binary patch delta 2640 zcma)8e@q+K9sl0h*u*i|P?K1Mz|FXhV-BBvb`p|U;V>?{Q4}a;8B|fmp^QusTP&6$ z7J2m}hsqt2WQN(jP3k+I~bkgYtsa9E&+V3h|}`d&vA0aZi6mcwV5S>3ww|8M#4o zOH%yj_{KxATrM(!Uc&gc)UFa;kudJ4{R6&job{gCv}ih1yHrdV%Z0YfkUngD`ywA= zrZ*z!O@Cxna-!|Ny~>e7?1|17dr!5^ar671=NxCR!ivPDH*_<1oYc&wx+5*}0F^2v zbjibHl7|@rN%DZH4YDz`2lIW?#kIbCjDD<;y;GsmL_kuAc^G^N{lhqHhddEf!TAzv zUszi&lz=m(y=r=k327bXRGO}Kx2I@r8k1i@WkR8io6yRF1qnl~JqL|3u zr7acln#ba@bB<@!JRIVRmaxR^;(%CBX89Tv_GzarK}i(%N>tj>-ZtmIt3$ZH{-{tA zI7Y=u3RSeKN7+N_r|KXda`?P(C|sE z-})r;wszVYWy2|L(i&sK`_2{fX&aBDy09rdzG-NM<0*E;uKP)VcXQ`D+SmQ+%pW9l z>(y0q$_tHAUZ7Y|paw5s^#Nj-E5!whaMnS`M8;#ipE*v^da~6>ByyITCJK9Ce5eJ- z*uYL_2B}=2u=YlA?F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@@ -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();