diff --git a/build.sh b/build.sh index 48cff29..b3063de 100755 --- a/build.sh +++ b/build.sh @@ -32,7 +32,7 @@ else fi echo "Assembling.." -./bin/assembler projects/examples/dev.controller.keys.usm bin/boot.rom +./bin/assembler projects/software/noodle.usm bin/boot.rom echo "Running.." if [ "${2}" = '--cli' ]; diff --git a/projects/examples/dev.time.usm b/projects/examples/dev.time.usm index 1ef72df..c24cb4a 100644 --- a/projects/examples/dev.time.usm +++ b/projects/examples/dev.time.usm @@ -23,11 +23,11 @@ |0200 ( theme ) #0ff8 =System.r #0f08 =System.g #0f08 =System.b - ( vectors ) ,FRAME =Screen.vector + ( vectors ) ,on-frame =Screen.vector BRK -@FRAME +@on-frame #00 =DateTime.refresh diff --git a/projects/examples/gui.animation.usm b/projects/examples/gui.animation.usm new file mode 100644 index 0000000..799c55b --- /dev/null +++ b/projects/examples/gui.animation.usm @@ -0,0 +1,63 @@ +( GUI Animation ) + +;dvd { x 2 y 2 dx 1 dy 1 } + +|0100 ;System { vector 2 pad 6 r 2 g 2 b 2 } +|0120 ;Screen { vector 2 width 2 height 2 pad 2 x 2 y 2 addr 2 color 1 } + +( program ) + +|0200 + + ( theme ) #4cfd =System.r #4cf3 =System.g #dcf2 =System.b + ( vectors ) ,on-frame =Screen.vector + ( init ) ~Screen.width #0002 DIV2 =dvd.x + ( init ) ~Screen.height #0002 DIV2 =dvd.y + +BRK + +@on-frame ( -> ) + + ( clear ) #20 ,draw-dvd JSR2 + ( hit-right ) ~dvd.x ~Screen.width #0020 SUB2 EQU2 + ( hit-left ) ~dvd.x #0000 EQU2 + #0000 EQU2 ^$no-flipx JNZ + ~dvd.dx #00 EQU =dvd.dx $no-flipx + ( hit-bottom ) ~dvd.y ~Screen.height #0010 SUB2 EQU2 + ( hit-top ) ~dvd.y #0000 EQU2 + #0000 EQU2 ^$no-flipy JNZ + ~dvd.dy #00 EQU =dvd.dy $no-flipy + ( incr ) ~dvd.x #0001 #00 ~dvd.dx #00 EQU #fffe MUL2 ADD2 ADD2 =dvd.x + ( incr ) ~dvd.y #0001 #00 ~dvd.dy #00 EQU #fffe MUL2 ADD2 ADD2 =dvd.y + ( draw ) #21 ,draw-dvd JSR2 + +BRK + +@draw-dvd ( color -- ) + + ( stash color ) STH + ,dvd_icn =Screen.addr + ~dvd.y ~dvd.y #0010 ADD2 + $ver + OVR2 =Screen.y + ~dvd.x ~dvd.x #0020 ADD2 + $hor + OVR2 =Screen.x + ( draw ) DUPr STHr =Screen.color + ( next ) ~Screen.addr #0008 ADD2 =Screen.addr + ( incr ) SWP2 #0008 ADD2 SWP2 + OVR2 OVR2 LTH2 ^$hor JNZ + POP2 POP2 + ( incr ) SWP2 #0008 ADD2 SWP2 + OVR2 OVR2 LTH2 ^$ver JNZ + POP2 POP2 + ( destroy color ) POPr + +JMP2r + +@dvd_icn [ + 001f 3f38 3838 787f 00fe fe7e 7777 e3c3 + 000f 1f3b 7b77 e7c7 00fc fe8f 8707 0efc + 7f00 000f ff7f 0700 0301 00ff f0f8 ff00 + 8700 00ff 7f7f ff00 f000 00e0 fcfc 8000 +] \ No newline at end of file diff --git a/projects/examples/gui.picture.usm b/projects/examples/gui.picture.usm index dad158c..d5fc1fd 100644 --- a/projects/examples/gui.picture.usm +++ b/projects/examples/gui.picture.usm @@ -27,6 +27,8 @@ #0128 #0010 #0080 #0080 #2e ,pict_medium ,draw-picture JSR2 #0020 #00d0 #0020 #0020 #25 ,pict_small ,draw-picture JSR2 + #0010 #0010 #0020 #0010 #25 ,dvd_icn ,draw-picture JSR2 + BRK @on-mouse @@ -78,6 +80,17 @@ RTN RTN +@dvd_icn [ + 001f 3f38 3838 787f + 00fe fe7e 7777 e3c3 + 000f 1f3b 7b77 e7c7 + 00fc fe8f 8707 0efc + 7f00 000f ff7f 0700 + 0301 00ff f0f8 ff00 + 8700 00ff 7f7f ff00 + f000 00e0 fcfc 8000 +] + @clear_icn [ 0000 0000 0000 0000 ] @pointer_icn [ 80c0 e0f0 f8e0 1000 ] diff --git a/src/ppu.c b/src/ppu.c index 369c76a..9b21bee 100644 --- a/src/ppu.c +++ b/src/ppu.c @@ -50,19 +50,6 @@ drawpixel(Ppu *p, Uint16 x, Uint16 y, Uint8 color) p->output[y * p->width + x] = p->colors[color]; } -void -drawchr(Ppu *p, Uint16 x, Uint16 y, Uint8 *sprite, Uint8 alpha) -{ - Uint8 v, h; - for(v = 0; v < 8; v++) - for(h = 0; h < 8; h++) { - Uint8 ch1 = ((sprite[v] >> h) & 0x1); - Uint8 ch2 = (((sprite[v + 8] >> h) & 0x1) << 1); - if(!alpha || (alpha && ch1 + ch2 != 0)) - drawpixel(p, x + 7 - h, y + v, ch1 + ch2); - } -} - void putpixel(Ppu *p, Uint8 *layer, Uint16 x, Uint16 y, Uint8 color) { @@ -142,9 +129,20 @@ drawppu(Ppu *p) Uint16 x, y; for(y = 0; y < p->ver; ++y) for(x = 0; x < p->hor; ++x) { + Uint8 v, h; Uint16 key = (y * p->hor + x) * 16; - drawchr(p, x * 8 + p->pad, y * 8 + p->pad, &p->bg[key], 0); - drawchr(p, x * 8 + p->pad, y * 8 + p->pad, &p->fg[key], 1); + for(v = 0; v < 8; v++) + for(h = 0; h < 8; h++) { + Uint8 *sprite = &p->fg[key]; + Uint8 ch1 = ((sprite[v] >> h) & 0x1); + Uint8 ch2 = (((sprite[v + 8] >> h) & 0x1) << 1); + if(ch1 + ch2 == 0) { + sprite = &p->bg[key]; + ch1 = ((sprite[v] >> h) & 0x1); + ch2 = (((sprite[v + 8] >> h) & 0x1) << 1); + } + drawpixel(p, x * 8 + p->pad + 7 - h, y * 8 + p->pad + v, ch1 + ch2); + } } }