From d8cd73115a1325e56dff9047d06698a8bdebe90f Mon Sep 17 00:00:00 2001 From: jespergravgaard Date: Sun, 4 Apr 2021 21:52:03 +0200 Subject: [PATCH] Added camelot 1536 dots source code. --- src/main/kc/include/mega65-viciv.h | 6 +- src/test/kc/examples/mega65/Thaw_5000.sid | Bin 0 -> 2918 bytes .../{sine-plotter.c => camelot-1536dots.c} | 70 +++++++++++++++--- .../examples/mega65/camelot-sprites.aseprite | Bin 0 -> 680 bytes .../kc/examples/mega65/camelot-sprites.png | Bin 0 -> 414 bytes 5 files changed, 66 insertions(+), 10 deletions(-) create mode 100644 src/test/kc/examples/mega65/Thaw_5000.sid rename src/test/kc/examples/mega65/{sine-plotter.c => camelot-1536dots.c} (78%) create mode 100644 src/test/kc/examples/mega65/camelot-sprites.aseprite create mode 100644 src/test/kc/examples/mega65/camelot-sprites.png 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 0000000000000000000000000000000000000000..63deba0b91548bdbec403bc1bb85c1684fc22c68 GIT binary patch literal 2918 zcma)7eQXow8GrBmap#ZNmoIaC)&WXz>a-4tz+p}6gpVezN3H~(1Xi(vTE#GtW=+dR zo5W`ai?0}hMkxWVassqTRxe?jDBf~YhRQ^`!ERl&NvKU3o7%FelKV%cN^9&r@7aio zY0_TjeV^~&J@4~8my=qW))SU=6Cx4GKp6bt+7jCNBTE0*+7fzc@6ImwcVB9Mv7_t7 z4)@CSo9o*=_r0rX{k3k`z3b(j9j|oVSKsGKj6oEnpj!&YC5AORzYN|jGWp6YrC|NG z4V&E!+uTpDYpk?dts}!E^=nYdL8*k)Bq$Z2_~82W&u<&F&(ILR4Dt6MStz9+8D`NQ zuZFrBP|VT?!k6A^5K1vzbt#pu)Nfph&y@@OB0)|Ml9|DEaD8f__Epj%#l@NDFUpM< zBaOrC&C4K|lkZVz)hua-;P%qwWzcvv2x;?d5Q6QS)izLqpq4{SRx2PDK|G}yF3Ez+ z6SgYrAX5&X%9<%t;rjHO1i2)Sq_S->Ic3`xi%f1rKVKkSGu@kBp?nXlV$V7lNwsek zdwv1RK1hYO?k389P{$x`nH__m=h;j%jAoTO&_bgbBq(Y-8a=nCWvw*S=n?SAA&(RD zQQ9E05j15wq1i)NI;BaM;~~$J){&IbrVK&qTw9~(A>{&Kpsc(Dql_{JqeMx9GJz;= z?Pg{Sv}uIV^PCQAm1x}vBY0PFH-l}^Z;TnzYhRM5vzlG4r0r3Cv^Uck&4B@CVREf& z&^UvoQ=1`epd|}{Co{PgP&?TKsXw$*-lX$4blyBOYRMb_+^U=fZ5qt7uogn?y_h;KCn^vLi)AYP7q$rbi(Wo@I9&S#i^QDr0&DC+i4>B_Nx1# zXAjK<-(Z@=K5X^3Y;)hX?WJ#&$AB3iHYTHXLHh04E>PPM@CCp$)ID@?_CWB;7JOT9 zZU)&I9Hv3T40b2(nxRUYg#XE~1cS^BzGA4UtE2DO2R=hEA%$X*P)vT_#gsFC<{9Su zOc!&68Df6L%rI%j!B(=H*dMZ|Se5;ZEjBb5UNMXsZW|UFw;RtI?-;$N*G)G~<>r|A zbMv#@Z@D%6FZnf=_bsi~udL^6o9vbXt>C;P>g*6gg&jqQipNX-Ra!gmoLIbIXyL}i z#)m#~YfC>`E|l-^{N<6CAN5zQsA*W!zm|XEN_}F(l_vM5$<6P!{^PmMUBS?S4)Il? zyR$EFwDTu{b3eY=Hhw*I`~A}z|FQ3%?yn!68~xqiMNu5Nb_Y*_UyID#zX|8aWV7}4 z_12|U<6<-6MJr=v^p6*QSeynYsanmDEXxvNCc-NEjIqGQnhS`*76=6NAbLzqO;KNlC5CSvXGYqtwcTkma3kV1@s60y zenP_N6DCG3OblGuj;w*RqRwdKP=zM+z`tALSCc=zI(9XD>+SOi4q@L11 zA>noZTu?xA3q){B0a9v>g%^-!Qc7Z

SnuUzW9>&)Rt=E7R>X9pas)W}X+ayoJeH z2+0!E^LCQ8BhTAq-fow0+nXgCZ@EgTpoJ88(%r??MGmeKsk*YxnNBqMnm%2R)yQbJcC5x`-KMQ6d+UV$4$@ICet^ ztNK<=MXCpC4)&t&D%@4n-#1Xzhl;+(jv+*!H~jxR;COF;?}LDT1gxQe{()K@(0>d? z1Wd$ARTc&A>(GWp%@-MUVFZ7^>BYpl=7>FYtFCk z4IigH4F60nBM+06q>@yT8d6K@bjhnrev|^FLbt8fZ4G1t`g+M@=<6rnLF;-7u|juR SMX1vgq~X6@9)x&M4*v%i#HVQh literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..c30efbea790b258fe7ad292fea08b674ec3b792a GIT binary patch literal 680 zcmZ3%#K7=iDI<{tUwFIfS6qY zY$cL)RY10+f&f&6A4!IRA;VnzKLf+8^hhA-Y{>v5^Zivpq-`6J%!%6yB&SZD3M5T6 zDuHCdl1)Hz)}0|I@F1KHf58+v{Z-?H*1t#nV4+ymqT>&9}|b#IL?cj;y=7 z{vPAcb$i-xe}B7k%?tO_YmJ-uF9pr?4^v-lzv{o({4+f1zg&NbvZw6coBpUd?d{{o zXT8JruYQPx$SV=@dR9J=0SJ4u~APCEP{{Jt#hqjC*h@98nnTMT4NM&HO0ML8yy#uhZfsD8@ zvgoY;9f4+*NzMnVZnZ^7K^e+3!kF*uAW3?@AdW^ZR(n=kEZ+*E%}pwM3PJ; zw79cPVviA*wg+XRK4Ha@zqyi?()!q}6_tgW&@<*1TJ&^ZC0P}7o*-OASTyT(8f=J0 z&tc0U-D%{h;nY8VJZfg$z2rbqx|p9Ts@9$3iX{xUf$Fv9qbs8jzhlim(cTtH?Se(8 zY(Zzosn+a07*qo IM6N<$g5S))jQ{`u literal 0 HcmV?d00001