starting on sprites
This commit is contained in:
parent
eb5daa1684
commit
2a420f6f4f
6
bun.c
6
bun.c
|
@ -42,7 +42,7 @@
|
||||||
// linked as raw bytes in assembler
|
// linked as raw bytes in assembler
|
||||||
extern unsigned char far coolbun[];
|
extern unsigned char far coolbun[];
|
||||||
|
|
||||||
unsigned char *coolbunArea;
|
unsigned char *coolbunArea = 0;
|
||||||
|
|
||||||
#define BLTCON0( \
|
#define BLTCON0( \
|
||||||
minterm, aChan, bChan, cChan, dChan, shift \
|
minterm, aChan, bChan, cChan, dChan, shift \
|
||||||
|
@ -62,7 +62,9 @@ void setupBun(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void teardownBun(void) {
|
void teardownBun(void) {
|
||||||
FreeMem(coolbunArea, COOL_BUN_MEMORY_SIZE);
|
if (coolbunArea) {
|
||||||
|
FreeMem(coolbunArea, COOL_BUN_MEMORY_SIZE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void bun_offRightSide(
|
void bun_offRightSide(
|
||||||
|
|
76
main.c
76
main.c
|
@ -36,10 +36,31 @@ void *copperlistSpritePointers[8];
|
||||||
#define offsetof(s, m) &((struct s *)0)->m
|
#define offsetof(s, m) &((struct s *)0)->m
|
||||||
uint16_t custom_color = (uint16_t)offsetof(Custom, color);
|
uint16_t custom_color = (uint16_t)offsetof(Custom, color);
|
||||||
uint16_t custom_sprite = (uint16_t)offsetof(Custom, sprpt);
|
uint16_t custom_sprite = (uint16_t)offsetof(Custom, sprpt);
|
||||||
|
uint16_t custom_sprite_control = (uint16_t)offsetof(Custom, spr);
|
||||||
|
|
||||||
|
uint16_t chip spriteData[200];
|
||||||
|
|
||||||
|
uint16_t spritePositionsEachLine[256][2];
|
||||||
|
|
||||||
|
void calculageSpritePositionsEachLine() {
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < 255; ++i) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#define SPRPOS(x, y) (((y & 0xff) << 8) + ((x & 0x1fe) >> 1))
|
||||||
|
#define SPRCTL(x, y, height) ( \
|
||||||
|
((height & 0xff) << 8) + \
|
||||||
|
((y & 0x100) >> 6) + \
|
||||||
|
((height & 0x100) >> 7) + \
|
||||||
|
(x & 1) \
|
||||||
|
)
|
||||||
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
uint16_t *copperlist, *currentCopperlist, result;
|
uint16_t *copperlist, *currentCopperlist, result;
|
||||||
int i, y, plane;
|
int i, x, y, height, plane;
|
||||||
|
|
||||||
struct BunRenderer bunRenderer;
|
struct BunRenderer bunRenderer;
|
||||||
|
|
||||||
|
@ -50,12 +71,31 @@ int main(void) {
|
||||||
colors[2] = 0x0fff;
|
colors[2] = 0x0fff;
|
||||||
colors[3] = 0x000f;
|
colors[3] = 0x000f;
|
||||||
|
|
||||||
|
printf("%p\n", &spriteData);
|
||||||
printf("setting up, i haven't crashed...yet.\n");
|
printf("setting up, i haven't crashed...yet.\n");
|
||||||
|
|
||||||
|
x = 150;
|
||||||
|
y = 100;
|
||||||
|
height = y + 98;
|
||||||
|
|
||||||
|
printf("%d, %d, %d\n", x, y, height);
|
||||||
|
|
||||||
|
spriteData[0] = SPRPOS(x, y);
|
||||||
|
spriteData[1] = SPRCTL(x, y, height);
|
||||||
|
|
||||||
|
printf("%0x %0x\n", spriteData[0], spriteData[1]);
|
||||||
|
|
||||||
|
for (i = 2; i < 198; ++i) {
|
||||||
|
spriteData[i] = 0xffff;
|
||||||
|
}
|
||||||
|
|
||||||
|
spriteData[198] = 0x0000;
|
||||||
|
spriteData[199] = 0x0000;
|
||||||
|
|
||||||
setupScreen(&screenSetup, SCREEN_WIDTH, SCREEN_HEIGHT, 3);
|
setupScreen(&screenSetup, SCREEN_WIDTH, SCREEN_HEIGHT, 3);
|
||||||
setupInitialCurrentScreen(&screenSetup, ¤tScreen);
|
setupInitialCurrentScreen(&screenSetup, ¤tScreen);
|
||||||
|
|
||||||
setupBunRenderer(&bunRenderer, &screenSetup, ¤tScreen);
|
//setupBunRenderer(&bunRenderer, &screenSetup, ¤tScreen);
|
||||||
|
|
||||||
// blitter copy the first bitplane row down to the second
|
// blitter copy the first bitplane row down to the second
|
||||||
|
|
||||||
|
@ -87,7 +127,31 @@ int main(void) {
|
||||||
*(currentCopperlist++) = custom_color + 6;
|
*(currentCopperlist++) = custom_color + 6;
|
||||||
*(currentCopperlist++) = 0x00F;
|
*(currentCopperlist++) = 0x00F;
|
||||||
|
|
||||||
|
// sprites
|
||||||
|
*(currentCopperlist++) = custom_color + 34;
|
||||||
|
*(currentCopperlist++) = 0xF0F;
|
||||||
|
|
||||||
|
*(currentCopperlist++) = custom_color + 36;
|
||||||
|
*(currentCopperlist++) = 0xFF0;
|
||||||
|
|
||||||
|
*(currentCopperlist++) = custom_color + 38;
|
||||||
|
*(currentCopperlist++) = 0x00F;
|
||||||
|
|
||||||
|
*(currentCopperlist++) = custom_sprite;
|
||||||
|
*(currentCopperlist++) = ((uint32_t)&spriteData >> 16);
|
||||||
|
|
||||||
|
*(currentCopperlist++) = custom_sprite + 2;
|
||||||
|
*(currentCopperlist++) = ((uint32_t)&spriteData & 0xffff);
|
||||||
|
|
||||||
for (y = 0; y < 256; ++y) {
|
for (y = 0; y < 256; ++y) {
|
||||||
|
if (y > 100) {
|
||||||
|
*(currentCopperlist++) = custom_sprite_control;
|
||||||
|
*(currentCopperlist++) = SPRPOS(60 + y, y);
|
||||||
|
|
||||||
|
*(currentCopperlist++) = custom_sprite_control + 2;
|
||||||
|
*(currentCopperlist++) = SPRCTL(60 + y, y, 0);
|
||||||
|
}
|
||||||
|
|
||||||
*(currentCopperlist++) = 1 + (31 << 1) + ((44 + y) << 8);
|
*(currentCopperlist++) = 1 + (31 << 1) + ((44 + y) << 8);
|
||||||
*(currentCopperlist++) = 0xFFFE;
|
*(currentCopperlist++) = 0xFFFE;
|
||||||
*(currentCopperlist++) = custom_color;
|
*(currentCopperlist++) = custom_color;
|
||||||
|
@ -102,6 +166,7 @@ int main(void) {
|
||||||
endCopperlist(currentCopperlist);
|
endCopperlist(currentCopperlist);
|
||||||
|
|
||||||
for (i = 0; i < 200; ++i) {
|
for (i = 0; i < 200; ++i) {
|
||||||
|
/*
|
||||||
swapCurrentScreenBuffer(&screenSetup, ¤tScreen);
|
swapCurrentScreenBuffer(&screenSetup, ¤tScreen);
|
||||||
|
|
||||||
for (plane = 0; plane < 2; ++plane) {
|
for (plane = 0; plane < 2; ++plane) {
|
||||||
|
@ -116,13 +181,14 @@ int main(void) {
|
||||||
WaitBlit();
|
WaitBlit();
|
||||||
}
|
}
|
||||||
|
|
||||||
renderBunFrame(i, &bunRenderer);
|
//renderBunFrame(i, &bunRenderer);
|
||||||
|
|
||||||
updateDisplayInCopperList(
|
updateDisplayInCopperList(
|
||||||
&screenSetup,
|
&screenSetup,
|
||||||
¤tScreen,
|
¤tScreen,
|
||||||
copperlistBitplanePointers
|
copperlistBitplanePointers
|
||||||
);
|
);
|
||||||
|
*/
|
||||||
|
|
||||||
WaitTOF();
|
WaitTOF();
|
||||||
}
|
}
|
||||||
|
@ -135,6 +201,10 @@ int main(void) {
|
||||||
|
|
||||||
giveBackSystem();
|
giveBackSystem();
|
||||||
|
|
||||||
|
for (i = 10; i < 50; ++i) {
|
||||||
|
printf("%x ", copperlist[i]);
|
||||||
|
}
|
||||||
|
|
||||||
teardownScreen(&screenSetup);
|
teardownScreen(&screenSetup);
|
||||||
|
|
||||||
freeCopperlist(copperlist);
|
freeCopperlist(copperlist);
|
||||||
|
|
|
@ -20,7 +20,7 @@ uint16_t * prepareNewCopperlist(void) {
|
||||||
|
|
||||||
void setCopperlist(uint16_t *copperlist) {
|
void setCopperlist(uint16_t *copperlist) {
|
||||||
custom.cop1lc = copperlist;
|
custom.cop1lc = copperlist;
|
||||||
//custom.copjmp1 = 1;
|
custom.copjmp1 = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void freeCopperlist(uint16_t *copperlist) {
|
void freeCopperlist(uint16_t *copperlist) {
|
||||||
|
|
|
@ -111,7 +111,7 @@ _takeOverSystem:
|
||||||
MOVE.W #INTF_SETCLR|INTF_INTEN|INTF_COPER|INTF_VERTB,intena(A0) ; enable master interrupt, copper, and VBR
|
MOVE.W #INTF_SETCLR|INTF_INTEN|INTF_COPER|INTF_VERTB,intena(A0) ; enable master interrupt, copper, and VBR
|
||||||
|
|
||||||
MOVE.W #$7FFF,dmacon(a0)
|
MOVE.W #$7FFF,dmacon(a0)
|
||||||
MOVE.W #DMAF_SETCLR|DMAF_MASTER|DMAF_COPPER|DMAF_RASTER|DMAF_BLITTER,dmacon(A0)
|
MOVE.W #DMAF_SETCLR|DMAF_MASTER|DMAF_COPPER|DMAF_RASTER|DMAF_BLITTER|DMAF_SPRITE,dmacon(A0)
|
||||||
MOVEM.L (SP)+,A2/A6
|
MOVEM.L (SP)+,A2/A6
|
||||||
RTS
|
RTS
|
||||||
|
|
||||||
|
@ -147,7 +147,6 @@ NewLevel3VBI:
|
||||||
MOVEM.L (SP)+,D0-A6
|
MOVEM.L (SP)+,D0-A6
|
||||||
RTE
|
RTE
|
||||||
|
|
||||||
|
|
||||||
_giveBackSystem:
|
_giveBackSystem:
|
||||||
MOVE.L A6,-(SP)
|
MOVE.L A6,-(SP)
|
||||||
LEA _custom,A0
|
LEA _custom,A0
|
||||||
|
@ -307,7 +306,6 @@ _addDisplayToCopperlist:
|
||||||
MOVE.L A1,D0
|
MOVE.L A1,D0
|
||||||
MOVEM.L (SP)+,A2-A4/D2-D4
|
MOVEM.L (SP)+,A2-A4/D2-D4
|
||||||
|
|
||||||
|
|
||||||
RTS
|
RTS
|
||||||
|
|
||||||
; @stack *copperlist
|
; @stack *copperlist
|
||||||
|
|
Loading…
Reference in New Issue