From 7374d8cad0c2f1424ca36ccfe994a15c877a911a Mon Sep 17 00:00:00 2001 From: John Bintz Date: Mon, 27 May 2024 16:50:56 -0400 Subject: [PATCH] yeah it kinda works --- main | Bin 9940 -> 9536 bytes main.c | 388 ++++++++---------------------------------------- screen.c | 1 + screen.h | 5 +- system/system.h | 1 + system/system.s | 18 +++ 6 files changed, 85 insertions(+), 328 deletions(-) diff --git a/main b/main index 0235b9887fc7affb1ee47a429374469955ded489..a245d7e76fe56a205f5edd15aa81ece3b45cac32 100755 GIT binary patch delta 4421 zcmZu#4{Vdi6@T}|aU91#lob zzrlMt>qv-v8qq--OHdFOlQqch3B|T<(rk>e2T8~Ed?D)MH1;5SAlih=fJT(O{Sg=% z=E6zA98Zj04;VNaP@m>1b`QiUU@!;S43~sUb`LNJh}>bbO>hQy--+Z{j~VU)mOZ{4 z-Xq%B)qoDVlUxt=IL0=MrHxaOcf30~^0vKY55B%R+#Y_L#O#go5Ws$oGEXR5QkF7{ z@?MHF5~duDh27;aXfB;AAEl{#jl8eMCgi%$i9$PNYB82`X~bz04DJ!Lww(<3SMc`P zv1nNAk9y=S!YlF(`O-*;j1DR^)8*);v#O=m>X~>P7F`Y7D1R5J<3-_Y3mcHpP95qE zHWl*5A+RYUVOrs!{LAvHddhD}^AjVPSWWD5iz8N1~M^rrnZD zB`Wgl2@tD-qrz$GASNo|R69o~^)W)LZ_zvDpK+AnMy~rTrcUK3WgJVOBx=K@W6^|* z=-vMvbc#4S2hYNapjvqXp$4Fb#cIOY91xD>P&D{VAshg7-@ylizVRmzQcXWbNEy~v zM?M0MG&}jfNa(NseJb1S&Go5VgR?Fk zS6ka30~UE4Qwc;wM33Gxw)ciCz)*a4KC*J%*#4YUjM^@ZBw}aYpex5gMFCyI+dLS2 zT6Gd06wE^7y{_Ksb37;#(K&}Uc7-7zB7OaR8)a3&&lR}$Izi>z+DZ5YM<*^mMrU2} zgrtwUZFAI*B^+(UhT`tewEk-fTB|EeZ zYNtm}H#bFm&ZHX7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*oNC9k$`{W&wi6JLzhk2NuA?Y2TJp2pLp2Nfmur#PBeC$&}&Pd!{PjC zsmOCDz`m#Vm*zy$Mqp}7I-@u^>!cqP10f5@4JrpYK_aLC#AY2MArlBQ&tcX%jDjwK z4uaZ1_?wt(vci5GMc9ZvPirQ@{rR diff --git a/main.c b/main.c index 4d0ef5a..7fdeefd 100644 --- a/main.c +++ b/main.c @@ -9,27 +9,16 @@ #include -#include "blitter.h" -#include "copper.h" +#include "system/blitter.h" +#include "system/copper.h" +#include "system/system.h" + #include "screen.h" #include "types.h" -#include "system.h" extern struct Custom far custom; extern unsigned char far coolbun[]; -void writeSomethingToScreen(struct ScreenSetup *screenSetup) { - *(screenSetup->memoryStart) = 255; - *(screenSetup->memoryStart + 8) = 0xAA; - *(screenSetup->memoryStart + 16) = 0xF0; - *(screenSetup->memoryStart + SCREEN_WIDTH * SCREEN_HEIGHT / 8 + 4) = 255; -} - -// [ ] increase the size of the bun area -// [ ] ensure the area has the correct data -// [ ] fix existing edge writes to work -// [ ] change non-edge write to use only bun area - #define COOL_BUN_WIDTH (32) #define COOL_BUN_WIDTH_BYTES (COOL_BUN_WIDTH / 8) #define COOL_BUN_HEIGHT (32) @@ -50,24 +39,6 @@ unsigned char *coolbunArea; unsigned char *scratchArea; struct ScreenSetup screenSetup; -void clearScratchArea() { - custom.bltcon0 = 0xf0 + (1 << 8); - custom.bltcon1 = 0; - - custom.bltadat = 0x0000; - custom.bltafwm = 0xffff; - custom.bltalwm = 0xffff; - - custom.bltdpt = scratchArea; - - custom.bltamod = 0; - custom.bltdmod = 0; - - custom.bltsize = (4) + (32 << 6); - - WaitBlit(); -} - void bun_offRightSide(int plusXValue, int y) { uint8_t i, plane = 0; uint8_t shift = plusXValue & 15; @@ -75,51 +46,24 @@ void bun_offRightSide(int plusXValue, int y) { uint16_t bltalwm; for (plane = 0; plane < 2; ++plane) { - clearScratchArea(); - // step 2: copy bun to scratch area that aligns right edge to word edge - // right shift so it's ascending. custom.bltcon0 = 0xc0 + (1 << 8) + (1 << 10) + (shift << 12); custom.bltcon1 = (shift << 12); custom.bltadat = 0xffff; - custom.bltafwm = 0xffff; + custom.bltbpt = coolbunArea + plane * COOL_BUN_PLANE_SIZE; + custom.bltdpt = screenSetup.memoryStart + plane * screenSetup.nextBitplaneAdvance + (y * screenSetup.width + screenSetup.width - COOL_BUN_WIDTH) / 8 + wordShift * 2; - bltalwm = 0xffff; - for (i = 0; i < shift; ++i) { - bltalwm -= (1 << i); + custom.bltafwm = 0xffff; + bltalwm = 0x0000; + for (i = 0; i < 15 - shift; ++i) { + bltalwm += (1 << (15 - i)); } custom.bltalwm = bltalwm; - custom.bltbpt = coolbunArea + (plane * COOL_BUN_WIDTH_BYTES * COOL_BUN_HEIGHT); - custom.bltdpt = scratchArea + 2 + (wordShift * 2); - - custom.bltamod = 0; custom.bltbmod = wordShift * 2; - custom.bltdmod = SCRATCH_AREA_WIDTH_BYTES - 4 + (wordShift * 2); + custom.bltdmod = (screenSetup.width - COOL_BUN_WIDTH) / 8 + wordShift * 2; - // TODO: [ ] handle a scroll larger than 16px - custom.bltsize = (2 - wordShift) + (32 << 6); - - WaitBlit(); - - // step 3: copy the cropped bun image to the main screen, already left - // aligned and with no fear of wraparound - // since buns are the back layer, we shouldn't need to preserve the - // background, so no c channel needed. - // - // y repeats go here. all buns are x aligned for simplicity. - custom.bltcon0 = 0xf0 + (1 << 8) + (1 << 11); - custom.bltcon1 = 0; - - custom.bltapt = scratchArea + 2 + (wordShift * 2); - custom.bltafwm = 0xffff; - custom.bltalwm = 0xffff; - custom.bltdpt = screenSetup.memoryStart + 30 + (wordShift * 2) + (screenSetup.nextBitplaneAdvance * plane) + (screenSetup.width / 8 * y); - - custom.bltamod = 4 + (wordShift * 2); - custom.bltdmod = (screenSetup.width / 8) - 4 + (wordShift * 2); - - custom.bltsize = (2 - wordShift) + (32 << 6); + custom.bltsize = 2 - wordShift + (COOL_BUN_HEIGHT << 6); WaitBlit(); } @@ -131,65 +75,34 @@ void bun_offLeftSide(int minusXValue, int y) { uint8_t wordShift = (minusXValue >> 4); uint8_t i; uint16_t bltalwm; - /** - * This is a three step process, repeated for each bitplane: - * - * * clean out the scratch plane - * * copy the bun graphic shifted left so that the third blit... - * * can pick up just that area and stamp it down. - */ + + // y can't be 0 otherwise we will corrupt memory for now + if (y == 0) return; for (plane = 0; plane < 2; ++plane) { - // step 1: clear the scratch area - // no modifications here! - clearScratchArea(); - - // step 2: copy the bun image to the scratch area in a way that aligns - // the cutoff point to a word edge. this requires a left shift, so - // it's descending. + // shift left, so desccending custom.bltcon0 = 0xc0 + (1 << 8) + (1 << 10) + (shift << 12); custom.bltcon1 = (1 << 1) + (shift << 12); + // a has a mask we're shifting custom.bltadat = 0xffff; - custom.bltafwm = 0xffff; + // b has bun data + custom.bltbpt = coolbunArea + 2 + ((COOL_BUN_HEIGHT - 1) * 4) + plane * COOL_BUN_PLANE_SIZE; - bltalwm = 0xffff; - for (i = 0; i < shift; ++i) { - bltalwm -= (1 << (15 - i)); + // d is the part on screen + custom.bltdpt = screenSetup.memoryStart + screenSetup.nextBitplaneAdvance * plane + (screenSetup.width * (y + COOL_BUN_HEIGHT - 1) / 8) + 2 - wordShift * 2; + + custom.bltafwm = 0xffff; + bltalwm = 0x0000; + for (i = 0; i < 15 - shift; ++i) { + bltalwm += (1 << i); } custom.bltalwm = bltalwm; - // TODO: [ ] handle a scroll larger than 16px - custom.bltbpt = coolbunArea + 2 + ((COOL_BUN_HEIGHT - 1) * COOL_BUN_WIDTH_BYTES) + (plane * COOL_BUN_WIDTH_BYTES * COOL_BUN_HEIGHT); - custom.bltdpt = scratchArea + 4 - (wordShift * 2) + ((COOL_BUN_HEIGHT - 1) * SCRATCH_AREA_WIDTH_BYTES); - - custom.bltamod = 0; custom.bltbmod = wordShift * 2; - custom.bltdmod = SCRATCH_AREA_WIDTH_BYTES - 4 + (wordShift * 2); + custom.bltdmod = screenSetup.width / 8 - 4 + wordShift * 2; - // TODO: [ ] handle a scroll larger than 16px - custom.bltsize = (2 - wordShift) + (32 << 6); - - WaitBlit(); - - // step 3: copy the cropped bun image to the main screen, already left - // aligned and with no fear of wraparound - // since buns are the back layer, we shouldn't need to preserve the - // background, so no c channel needed. - // - // y repeats go here. all buns are x aligned for simplicity. - custom.bltcon0 = 0xf0 + (1 << 8) + (1 << 11); - custom.bltcon1 = 0; - - custom.bltapt = scratchArea + 2; - custom.bltafwm = 0xffff; - custom.bltalwm = 0xffff; - custom.bltdpt = screenSetup.memoryStart + (screenSetup.nextBitplaneAdvance * plane) + (screenSetup.width / 8 * y); - - custom.bltamod = 4 + (wordShift * 2); - custom.bltdmod = (screenSetup.width / 8) - 4 + (wordShift * 2); - - custom.bltsize = (2 - wordShift) + (32 << 6); + custom.bltsize = 2 - wordShift + (COOL_BUN_HEIGHT << 6); WaitBlit(); } @@ -205,29 +118,40 @@ void bun_anywhere(int x, int y) { // buns will never interfere with a background so they don't need a mask // they do need the scratch area though - custom.bltcon0 = 0xf0 + (1 << 8) + (1 << 11) + (shift << 12); - custom.bltcon1 = 0; + custom.bltcon0 = 0xc0 + (1 << 8) + (1 << 10) + (shift << 12); + custom.bltcon1 = (shift << 12); + + custom.bltadat = 0xffff; + custom.bltbpt = coolbunArea + plane * COOL_BUN_PLANE_SIZE; + custom.bltdpt = screenSetup.memoryStart + WORD_ALIGNED_BYTE_POSITION(screenSetup.width, x, y) + screenSetup.nextBitplaneAdvance * plane; - custom.bltapt = coolbunArea + (COOL_BUN_HEIGHT * COOL_BUN_WIDTH_BYTES * plane); - custom.bltdpt = scratchArea + 2; // custom.bltdpt = screenSetup.memoryStart; custom.bltafwm = 0xffff; - custom.bltalwm = 0xffff; - custom.bltamod = 0; - custom.bltdmod = 4 - (needsExtraWord * 2); - custom.bltsize = (2 + needsExtraWord) + (32 << 6); + if (needsExtraWord) { + custom.bltalwm = 0x0000; + } else { + custom.bltalwm = 0xffff; + } + custom.bltbmod = -(needsExtraWord * 2); + custom.bltdmod = (screenSetup.width / 8) - COOL_BUN_WIDTH_BYTES - (needsExtraWord * 2); + custom.bltsize = (2 + needsExtraWord) + (COOL_BUN_HEIGHT << 6); WaitBlit(); + } +} - custom.bltcon0 = 0xf0 + (1 << 8) + (1 << 11); - custom.bltcon1 = 0; - custom.bltapt = scratchArea + 2; - custom.bltdpt = screenSetup.memoryStart + WORD_ALIGNED_BYTE_POSITION(screenSetup.width, x, y) + (screenSetup.nextBitplaneAdvance * plane); - custom.bltamod = 2; - custom.bltdmod = 40 - 6; - custom.bltsize = (3) + (32 << 6); +void renderBun(int x, int y) { + if (x < -31) return; + if (x > screenSetup.width + 31) return; + if (y < 1) return; + if (y > screenSetup.height - COOL_BUN_HEIGHT - 1) return; - WaitBlit(); + if (x < 0) { + bun_offLeftSide(-x, y); + } else if (x > screenSetup.width - COOL_BUN_WIDTH) { + bun_offRightSide(x - (screenSetup.width - COOL_BUN_WIDTH), y); + } else { + bun_anywhere(x, y); } } @@ -279,199 +203,21 @@ int main(void) { currentCopperlist = addColorsToCopperlist(currentCopperlist, colors, 16); endCopperlist(currentCopperlist); - custom.bltcon0 = 0xc0 + (1 << 10) + (1 << 8); - custom.bltcon1 = (8 << 12); - custom.bltadat = 0xffff; - custom.bltafwm = 0x00ff; - custom.bltalwm = 0x0000; - custom.bltbpt = coolbunArea; - custom.bltdpt = screenSetup.memoryStart + (40 * 10 + 36); - - custom.bltbmod = -2; - custom.bltdmod = 40 - 6; - - custom.bltsize = (3) + (32 << 6); - - WaitBlit(); - - custom.bltcon0 = 0xc0 + (1 << 10) + (1 << 8); - custom.bltcon1 = (15 << 12); - custom.bltadat = 0xffff; - custom.bltafwm = 0x0001; - custom.bltalwm = 0x0000; - custom.bltbpt = coolbunArea; - custom.bltdpt = screenSetup.memoryStart + (40 * 45 + 36); - - custom.bltbmod = -2; - custom.bltdmod = 40 - 6; - - custom.bltsize = (3) + (32 << 6); - - WaitBlit(); - - custom.bltcon0 = 0xc0 + (1 << 10) + (1 << 8); - custom.bltcon1 = (8 << 12); - custom.bltadat = 0xffff; - custom.bltafwm = 0x00ff; - custom.bltalwm = 0x0000; - custom.bltbpt = coolbunArea; - custom.bltdpt = screenSetup.memoryStart + (40 * 80 + 38); - - custom.bltbmod = 0; - custom.bltdmod = 40 - 4; - - custom.bltsize = (2) + (32 << 6); - - WaitBlit(); - /* - - for (bunPosition = -31; bunPosition < screenSetup.width + 31; ++bunPosition) { + for (i = -31; i < screenSetup.width - 1; ++i) { + y = WaitBOF(250); for (plane = 0; plane < 2; ++plane) { - custom.bltcon0 = 0xf0 + (1 << 11); + custom.bltcon0 = 0xc0 + (1 << 8); custom.bltcon1 = 0; custom.bltadat = 0x0000; - custom.bltdpt = screenSetup.memoryStart; custom.bltafwm = 0xffff; custom.bltalwm = 0xffff; - custom.bltsize = (20) + (256 << 6); + custom.bltdpt = screenSetup.memoryStart + (45 * screenSetup.width) / 8 + plane * screenSetup.nextBitplaneAdvance; + custom.bltdmod = 0; + custom.bltsize = 20 + (COOL_BUN_MEMORY_SIZE << 6); WaitBlit(); } - if (bunPosition < 0) { - //bun_offLeftSide(abs(bunPosition), 100); - } else if (bunPosition >= screenSetup.width) { - //bun_offRightSide(bunPosition - screenSetup.width - 1, 100); - } else { - bun_anywhere(bunPosition, 100); - } - - WaitTOF(); - WaitTOF(); - } - - - /* - for (i = 0; i < 32; ++i) { - for (plane = 0; plane < 2; ++plane) { - custom.bltcon0 = 0xf0 + (1 << 8); - custom.bltcon1 = 0; - custom.bltadat = 0x0000; - custom.bltdpt = screenSetup.memoryStart; - custom.bltafwm = 0x0000; - custom.bltalwm = 0x0000; - custom.bltsize = (20) + (256 << 6); - WaitBlit(); - } - - bun_offLeftSide(i, 100); - bun_offRightSide(i, 100); - - WaitTOF(); - WaitTOF(); - } - - /* - // left shift this over 8 so it's "against the edge" - custom.bltcon0 = 0xc0 + (1 << 8) + (1 << 10) + (1 << 11) + (0 << 12); - custom.bltcon1 = (1 << 1) + (0 << 12); - custom.bltafwm = 0xffff; - custom.bltalwm = 0xffff; - custom.bltapt = coolbunScratchArea + 4 + (32 * 8); - custom.bltbpt = coolbunScratchArea + 4 + (31 * 8); - custom.bltdpt = screenSetup.memoryStart + 2 + (32 * 40); - custom.bltamod = -4; - custom.bltbmod = 4; - custom.bltdmod = 40 - 4; - custom.bltsize = (2) + (32 << 6); - - WaitBlit(); - - /* - // left shift this over 8 so it's "against the edge" - custom.bltcon0 = 0xc0 + (1 << 8) + (1 << 10) + (1 << 11) + (abs(x) << 12); - custom.bltcon1 = (1 << 1) + (abs(x) << 12); - custom.bltafwm = 0xffff; - custom.bltalwm = 0xffff; - custom.bltapt = coolbunScratchArea + 2 + (32 * 8) + 4; - custom.bltbpt = coolbunScratchArea + 2 + 4 + (31 * 8); - custom.bltdpt = screenSetup.memoryStart + 4 + (31 * 40); - custom.bltamod = -6; - custom.bltbmod = 2; - custom.bltdmod = 40 - 6; - custom.bltsize = (1) + (32 << 6); - - WaitBlit(); -*/ - - WaitTOF(); - - /* - for (x = -15; x < 0; ++x) { - custom.bltcon0 = 0xf0 + (1 << 8); - custom.bltcon1 = 0; - custom.bltadat = 0xffff; - - result = 0xffff; - - for (i = 0; i < abs(x); ++i) { - result -= (1 << (15 - i)); - } - - custom.bltafwm = result; - - custom.bltalwm = 0xffff; - custom.bltdpt = coolbunScratchArea + 2 + (32 * 8); - custom.bltsize = (2) + (1 << 6); - - WaitBlit(); - - // left shift this over 8 so it's "against the edge" - custom.bltcon0 = 0xc0 + (1 << 8) + (1 << 10) + (1 << 11) + (abs(x) << 12); - custom.bltcon1 = (1 << 1) + (abs(x) << 12); - custom.bltafwm = 0xffff; - custom.bltalwm = 0xffff; - custom.bltapt = coolbunScratchArea + 2 + (32 * 8) + 4; - custom.bltbpt = coolbunScratchArea + 2 + 4 + (31 * 8); - custom.bltdpt = screenSetup.memoryStart + 4 + (31 * 40); - custom.bltamod = -6; - custom.bltbmod = 2; - custom.bltdmod = 40 - 6; - custom.bltsize = (3) + (32 << 6); - - WaitBlit(); - - WaitTOF(); - } - - /* - - for (x = 15; x < 17; ++x) { - for (plane = 0; plane < COOL_BUN_PLANES; ++plane) { - blitShiftRight = x & 15; - memoryXOffset = (x >> 3) & 0xfffe; - - blitWidth = (blitShiftRight > 0) ? 6 : 4; - - custom.bltcon0 = 0xf0 + (1 << 8) + (1 << 11) + (blitShiftRight << 12); - custom.bltcon1 = 0; - custom.bltapt = coolbunScratchArea + 2 + (COOL_BUN_PLANE_SIZE * plane); - - custom.bltdpt = screenSetup.memoryStart + memoryXOffset + screenSetup.nextBitplaneAdvance * plane; - custom.bltafwm = 0xffff; - custom.bltalwm = 0xffff; - custom.bltamod = 8 - blitWidth; - custom.bltdmod = 40 - blitWidth; - custom.bltsize = (blitWidth / 2) + (32 << 6); - - WaitBlit(); - } - - WaitTOF(); - } - */ - - for (i = 0; i < 100; ++i) { - WaitTOF(); + renderBun(i, 45); } giveBackSystem(); @@ -480,16 +226,6 @@ int main(void) { freeCopperlist(copperlist); - for (y = 0; y < 32; ++y) { - for (x = 0; x < SCRATCH_AREA_WIDTH_BYTES; ++x) { - printf("%d ", scratchArea[y * SCRATCH_AREA_WIDTH_BYTES + x]); - } - - printf("\n"); - } - - printf("%d\n", 16 & 15); - FreeMem(coolbunArea, COOL_BUN_MEMORY_SIZE); FreeMem(scratchArea, SCRATCH_AREA_MEMORY_SIZE); diff --git a/screen.c b/screen.c index 76ff954..c17fa07 100644 --- a/screen.c +++ b/screen.c @@ -30,4 +30,5 @@ void prepareScreen( screenSetup->height = height; screenSetup->bitplanes = bitplanes; screenSetup->nextBitplaneAdvance = width * height / 8; + screenSetup->currentBuffer = 0; } diff --git a/screen.h b/screen.h index 597622e..728d6b9 100644 --- a/screen.h +++ b/screen.h @@ -9,13 +9,14 @@ struct ScreenSetup { short int bitplanes; unsigned char *memoryStart; short int nextBitplaneAdvance; -}; + short int currentBuffer; +}; #define SCREEN_WIDTH (320) #define SCREEN_HEIGHT (256) -#define TOTAL_SCREEN_SETUP_SIZE(s) ((s->width / 8) * s->height * s->bitplanes) +#define TOTAL_SCREEN_SETUP_SIZE(s) ((s->width / 8) * s->height * s->bitplanes * 2) void allocateScreenMemory(struct ScreenSetup *screenSetup); void freeScreenMemory(struct ScreenSetup *screenSetup); diff --git a/system/system.h b/system/system.h index f9c868b..91e9549 100644 --- a/system/system.h +++ b/system/system.h @@ -17,5 +17,6 @@ extern void giveBackSystem(void); extern void setUpDisplay(struct ScreenSetup *); extern void myWaitBlit(void); +extern uint16_t WaitBOF(uint16_t line); #endif diff --git a/system/system.s b/system/system.s index 6d75809..3831408 100644 --- a/system/system.s +++ b/system/system.s @@ -6,6 +6,7 @@ XDEF _addColorsToCopperlist XDEF _endCopperlist XDEF _myWaitBlit + XDEF _WaitBOF XREF _custom @@ -243,6 +244,23 @@ _myWaitBlit: .done: RTS +_WaitBOF: + MOVE.W 6(A7),D1 + ROL.W #8,D1 + + MOVE.L $dff004,D0 + AND.L #$1ff00,D0 + CMP.L D1,D0 + BNE.B _WaitBOF + +.loop2: + MOVE.L $dff004,D0 + AND.L #$1ff00,D0 + CMP.L D1,D0 + BEQ.B .loop2 + + RTS + CNOP 0,4 OldView dc.l 0 OldCopper dc.l 0