In which John learns about the playfield hardware and sprite priorities

This commit is contained in:
John Bintz 2024-09-12 08:26:53 -04:00
parent a73506a27b
commit 3a42da655b
4 changed files with 56 additions and 23 deletions

7
bun.c
View File

@ -310,6 +310,13 @@ void calculateBunPositions(
bunPositions[current][0] = x; bunPositions[current][0] = x;
bunPositions[current][1] = y; bunPositions[current][1] = y;
// for the blitter video
/*
if (frame == 0) {
printf("%d,%d\n", bunPositions[current][0], bunPositions[current][1]);
}
*/
} }
} }

BIN
main

Binary file not shown.

25
main.c
View File

@ -27,6 +27,9 @@ extern struct CIA far ciaa;
#define SCRATCH_AREA_HEIGHT_ROWS (34) #define SCRATCH_AREA_HEIGHT_ROWS (34)
#define SCRATCH_AREA_MEMORY_SIZE (SCRATCH_AREA_WIDTH_BYTES * SCRATCH_AREA_HEIGHT_ROWS) #define SCRATCH_AREA_MEMORY_SIZE (SCRATCH_AREA_WIDTH_BYTES * SCRATCH_AREA_HEIGHT_ROWS)
// change to 0 to not render sprites
#define RENDER_SPRITES (1)
volatile short *dbg = (volatile short *)0x100; volatile short *dbg = (volatile short *)0x100;
unsigned char *scratchArea; unsigned char *scratchArea;
@ -143,6 +146,7 @@ int main(void) {
*(currentCopperlist++) = custom_color + 4; *(currentCopperlist++) = custom_color + 4;
*(currentCopperlist++) = 0xfff; *(currentCopperlist++) = 0xfff;
if (RENDER_SPRITES) {
for (i = 0; i < 8; ++i) { for (i = 0; i < 8; ++i) {
spriteDataPointer = (uint32_t)&SpriteData; spriteDataPointer = (uint32_t)&SpriteData;
spriteDataPointer += ((256 + 2) * 4) * i; spriteDataPointer += ((256 + 2) * 4) * i;
@ -153,11 +157,16 @@ int main(void) {
*(currentCopperlist++) = custom_sprite + 2 + i * 4; *(currentCopperlist++) = custom_sprite + 2 + i * 4;
*(currentCopperlist++) = (spriteDataPointer & 0xffff); *(currentCopperlist++) = (spriteDataPointer & 0xffff);
} }
} else {
printf("Skipping render\n");
currentCopperlist = setUpEmptySpritesInCopperlist(currentCopperlist);
}
*(currentCopperlist++) = custom_color; *(currentCopperlist++) = custom_color;
*(currentCopperlist++) = 0x3a6; *(currentCopperlist++) = 0x3a6;
for (y = 0; y < 256; ++y) { for (y = 0; y < 256; ++y) {
if (RENDER_SPRITES) {
for (i = 0; i < 8; ++i) { for (i = 0; i < 8; ++i) {
// set sprite color // set sprite color
*(currentCopperlist++) = custom_color + 32 + ( *(currentCopperlist++) = custom_color + 32 + (
@ -176,6 +185,9 @@ int main(void) {
*(currentCopperlist++) = custom_sprite_control + i * 8 + 2; *(currentCopperlist++) = custom_sprite_control + i * 8 + 2;
*(currentCopperlist++) = *(currentSpriteCopperlist++); *(currentCopperlist++) = *(currentSpriteCopperlist++);
} }
} else {
printf("Skipping render\n");
}
for (i = 3; i < 8; ++i) { for (i = 3; i < 8; ++i) {
*(currentCopperlist++) = custom_color + (i * 2); *(currentCopperlist++) = custom_color + (i * 2);
@ -188,6 +200,19 @@ int main(void) {
endCopperlist(currentCopperlist); endCopperlist(currentCopperlist);
/*
copperlist debugging
for (i = 0; i < 20; ++i) {
printf(
"%x %x %x %x\n",
*(copperlist + (i * 4)),
*(copperlist + (i * 4) + 1),
*(copperlist + (i * 4) + 2),
*(copperlist + (i * 4) + 3)
);
}
*/
takeOverSystem(); takeOverSystem();
setCopperlist(copperlist); setCopperlist(copperlist);

View File

@ -360,7 +360,8 @@ _setUpDisplay:
MOVE.W D0,bplcon0(A1) MOVE.W D0,bplcon0(A1)
MOVE.W #0,bplcon1(A1) MOVE.W #0,bplcon1(A1)
MOVE.W #0,bplcon2(A1) ; sprites always on top
MOVE.W #$0020,bplcon2(A1)
MOVE.W #0,bpl1mod(A1) MOVE.W #0,bpl1mod(A1)
MOVE.W #0,bpl2mod(A1) MOVE.W #0,bpl2mod(A1)
MOVE.W #$2c81,diwstrt(A1) MOVE.W #$2c81,diwstrt(A1)