diff --git a/src/main/kc/include/mega65-viciv.h b/src/main/kc/include/mega65-viciv.h index 00c742b4a..5cf81ecc6 100644 --- a/src/main/kc/include/mega65-viciv.h +++ b/src/main/kc/include/mega65-viciv.h @@ -241,7 +241,7 @@ struct MEGA65_VICIV { char SPRPTRADR_LOLO; // $D06D SPRPTRADR sprite pointer address (bits 15 - 8) char SPRPTRADR_LOHI; - // $D06E.0-6 SPRPTRBNK sprite pointer address (bits 22 - 16) + // $D06E.0-6 SPRPTRADR sprite pointer address (bits 22 - 16) // 0-6 sprite pointer address (bits 22 - 16) // 7 SPRPTR16 16-bit sprite pointer mode (allows sprites to be located on any 64 byte boundary in chip RAM) char SPRPTRADR_HILO; @@ -371,3 +371,7 @@ const char VICIV_PALEMU = 0x20; const char VICIV_VFAST = 0x40; // 7 VIC-IV:ALPHEN Alpha compositor enable const char VICIV_ALPHEN = 0x80; + +// $D06E.0-6 SPRPTRADR sprite pointer address (bits 22 - 16) +// 7 SPRPTR16 16-bit sprite pointer mode (allows sprites to be located on any 64 byte boundary in chip RAM) +const char VICIV_SPRPTR16 = 0x80; diff --git a/src/test/kc/examples/mega65/Thaw_5000.sid b/src/test/kc/examples/mega65/Thaw_5000.sid new file mode 100644 index 000000000..63deba0b9 Binary files /dev/null and b/src/test/kc/examples/mega65/Thaw_5000.sid differ diff --git a/src/test/kc/examples/mega65/sine-plotter.c b/src/test/kc/examples/mega65/camelot-1536dots.c similarity index 78% rename from src/test/kc/examples/mega65/sine-plotter.c rename to src/test/kc/examples/mega65/camelot-1536dots.c index a7929763d..6b1485242 100644 --- a/src/test/kc/examples/mega65/sine-plotter.c +++ b/src/test/kc/examples/mega65/camelot-1536dots.c @@ -1,6 +1,6 @@ // A pretty simple double sine plotter -#pragma target(mega65_remote) +#pragma target(mega65) #include #include #include <6502.h> @@ -35,6 +35,39 @@ void lpoke(__zp unsigned long addr, char val) { } } +// Address of the screen +char * const SCREEN = 0xc800; +// // Absolute address of graphics buffer 1 +char * const GRAPHICS1 = 0xa000; +// // Absolute address of graphics buffer 2 +char * const GRAPHICS2 = 0x7000; + +// SID tune at an absolute address +__address(0x5000) char MUSIC[] = kickasm(resource "Thaw_5000.sid") {{ + .const music = LoadSid("Thaw_5000.sid") + .fill music.size, music.getData(i) +}}; +// Pointer to the music init routine +void()* musicInit = (void()*) MUSIC; +// Pointer to the music play routine +void()* musicPlay = (void()*) MUSIC+3; + + +__align(0x40) char SPRITES[0xc0] = kickasm(resource "camelot-sprites.png") {{ + .var pic = LoadPicture("camelot-sprites.png", List().add($000000, $ffffff)) + .for (var s=0; s<3; s++) { + .for (var y=0; y<21; y++) { + .for (var x=0;x<3; x++) { + .byte pic.getSinglecolorByte(s*3+x,y) + } + } + .byte 0 + } +}}; + +// The sprite pointers +unsigned int SPRITE_PTRS[8]; + void main() { // Avoid interrupts SEI(); @@ -53,9 +86,33 @@ void main() { // Enable 48MHz fast mode VICIV->CONTROLB |= VICIV_FAST; VICIV->CONTROLC |= VICIV_VFAST; + // Initialize graphics graphics_mode(); + // Show sprites + VICIV->SPRPTRADR_LOLO = LOBYTE(SPRITE_PTRS); + VICIV->SPRPTRADR_LOHI = HIBYTE(SPRITE_PTRS); + VICIV->SPRPTRADR_HILO = VICIV_SPRPTR16; + SPRITE_PTRS[0] = toSpritePtr(SPRITES+0x40); + SPRITE_PTRS[1] = toSpritePtr(SPRITES+0x80); + SPRITE_PTRS[2] = toSpritePtr(SPRITES+0x00); + VICIV->SPRITES_ENABLE = 7; + VICIV->SPRITES_PRIORITY = 0xff; + SPRITES_COLOR[0] = DARK_GREY; + SPRITES_COLOR[1] = DARK_GREY; + SPRITES_COLOR[2] = DARK_GREY; + SPRITES_YPOS[0] = 0xe3; + SPRITES_YPOS[2] = 0xe3; + SPRITES_YPOS[4] = 0xe3; + SPRITES_XPOS[0] = 46; + SPRITES_XPOS[2] = 46+24; + SPRITES_XPOS[4] = 25; + *SPRITES_XMSB = 3; + // Initialize plotter init_plot(); + // Initialize SID + asm { lda #0 } + (*musicInit)(); // Main loop for(;;) { @@ -79,6 +136,9 @@ void main() { memset_dma(graphics_render, 0x00, 40*25*8); // Render some dots render_dots(); + //Play SID + (*musicPlay)(); + } } @@ -158,14 +218,6 @@ unsigned int SINX2[SINX2_SIZE+256] = kickasm {{ .fillword 547+256, round(60+60*sin(toRadians(360*i/547))) }}; - -// Address of the screen -char * const SCREEN = 0xc000; -// // Absolute address of graphics buffer 1 -char * const GRAPHICS1 = 0x6000; -// // Absolute address of graphics buffer 2 -char * const GRAPHICS2 = 0xa000; - void graphics_mode(void) { // 16-bit text mode VICIV->CONTROLC = VICIV_CHR16; diff --git a/src/test/kc/examples/mega65/camelot-sprites.aseprite b/src/test/kc/examples/mega65/camelot-sprites.aseprite new file mode 100644 index 000000000..c30efbea7 Binary files /dev/null and b/src/test/kc/examples/mega65/camelot-sprites.aseprite differ diff --git a/src/test/kc/examples/mega65/camelot-sprites.png b/src/test/kc/examples/mega65/camelot-sprites.png new file mode 100644 index 000000000..856029a04 Binary files /dev/null and b/src/test/kc/examples/mega65/camelot-sprites.png differ