From c1c0f8f2bc629fe197ad2ad7e78516d9e90f47d9 Mon Sep 17 00:00:00 2001 From: neauoire Date: Sat, 10 Apr 2021 12:19:38 -0700 Subject: [PATCH] Improved picture example --- build.sh | 2 +- projects/examples/blank.usm | 32 +++++------------ projects/examples/gui.picture.usm | 58 +++++++++++++++++++++++++++--- projects/pictures/zerotwo2020.chr | Bin 0 -> 16384 bytes src/ppu.c | 2 +- 5 files changed, 64 insertions(+), 30 deletions(-) create mode 100644 projects/pictures/zerotwo2020.chr diff --git a/build.sh b/build.sh index 5f7b817..ba05efd 100755 --- a/build.sh +++ b/build.sh @@ -32,7 +32,7 @@ else fi echo "Assembling.." -./bin/assembler projects/examples/dev.mouse.usm bin/boot.rom +./bin/assembler projects/examples/gui.mouse.usm bin/boot.rom echo "Running.." if [ "${2}" = '--cli' ]; diff --git a/projects/examples/blank.usm b/projects/examples/blank.usm index 261d8d9..b9d4b70 100644 --- a/projects/examples/blank.usm +++ b/projects/examples/blank.usm @@ -4,31 +4,15 @@ ( devices ) -|0100 ;Console { pad 8 char 1 byte 1 short 2 string 2 } -|0110 ;Screen { width 2 height 2 pad 4 x 2 y 2 color 1 } -|0120 ;Sprite { pad 8 x 2 y 2 addr 2 color 1 } -|0130 ;Controller { p1 1 } -|0140 ;Keys { key 1 } -|0150 ;Mouse { x 2 y 2 state 1 chord 1 } -|0160 ;File { pad 8 name 2 length 2 load 2 save 2 } +|0100 ;System { vector 2 pad 6 r 2 g 2 b 2 } +|0110 ;Console { vector 2 pad 6 char 1 byte 1 short 2 string 2 } +|0120 ;Screen { vector 2 width 2 height 2 pad 2 x 2 y 2 addr 2 color 1 } |0130 ;Audio { wave 2 envelope 2 pad 4 volume 1 pitch 1 play 1 value 2 delay 2 finish 1 } +|0140 ;Controller { vector 2 player1 1 player2 1 player3 1 player4 1 } +|0150 ;Keyboard { vector 2 key 1 } +|0160 ;Mouse { vector 2 x 2 y 2 state 1 chord 1 } +|0170 ;File { vector 2 pad 6 name 2 length 2 load 3 save 2 } |01a0 ;DateTime { year 2 month 1 day 1 hour 1 minute 1 second 1 dotw 1 doty 2 isdst 1 refresh 1 } -|01F0 ;System { pad 8 r 2 g 2 b 2 } -( vectors ) +|0200 -|0200 ^RESET JMP -|0204 ,ERROR JMP2 -|0208 ,FRAME JMP2 - -@RESET - -BRK - -@FRAME - -BRK - -@ERROR - -BRK diff --git a/projects/examples/gui.picture.usm b/projects/examples/gui.picture.usm index 900b949..84dcaa6 100644 --- a/projects/examples/gui.picture.usm +++ b/projects/examples/gui.picture.usm @@ -2,6 +2,7 @@ %RTN { JMP2r } +;pointer { x 2 y 2 sprite 2 } ;pict { x 2 y 2 width 2 height 2 color 1 addr 2 } |0100 ;System { vector 2 pad 6 r 2 g 2 b 2 } @@ -10,19 +11,61 @@ |0140 ;Controller { vector 2 button 1 } |0150 ;Keys { vector 2 key 1 } |0160 ;Mouse { vector 2 x 2 y 2 state 1 chord 1 } +|0170 ;File { pad 8 name 2 length 2 load 2 save 2 } ( program ) |0200 - ( theme ) #0ffc =System.r #0f0b =System.g #0f03 =System.b + ( theme ) #ac52 =System.r #a362 =System.g #b253 =System.b + ( vectors ) ,on-mouse =Mouse.vector + + ( load ) - #0000 #0000 #0100 #0100 #21 ,pict_large ,draw-picture JSR2 - #0098 #0060 #0080 #0080 #21 ,pict_medium ,draw-picture JSR2 - #0020 #0090 #0020 #0020 #2a ,pict_small ,draw-picture JSR2 + #0000 #0000 #0100 #0100 #2c ,pict_large ,draw-picture JSR2 + + ( load ) ,filepath =File.name #4000 =File.length ,img =File.load + ( draw ) #0080 #0020 #0100 #0100 #41 ,img ,draw-chr JSR2 + + #0128 #0010 #0080 #0080 #2e ,pict_medium ,draw-picture JSR2 + #0020 #00d0 #0020 #0020 #25 ,pict_small ,draw-picture JSR2 BRK +@on-mouse + + ( clear last cursor ) + ,clear_icn =Screen.addr + ~pointer.x =Screen.x + ~pointer.y =Screen.y + #30 =Screen.color + + ( record pointer positions ) + ~Mouse.x =pointer.x ~Mouse.y =pointer.y + + ( draw new cursor ) + ,pointer_icn =Screen.addr + ~pointer.x =Screen.x + ~pointer.y =Screen.y + #33 =Screen.color + +BRK + +@draw-chr ( x y width height color addr ) + + DUP2 =Screen.addr =pict.addr =pict.color =pict.height =pict.width DUP2 =Screen.y =pict.y =pict.x + $ver + ~pict.x =Screen.x + $hor + ( draw ) ~pict.color =Screen.color + ( incr ) ~Screen.x #0008 ADD2 =Screen.x + ( incr ) ~Screen.addr #0010 ADD2 =Screen.addr + ~Screen.x ~pict.width ~pict.x ADD2 LTH2 ^$hor JNZ + ( incr ) ~Screen.y #0008 ADD2 =Screen.y + ~Screen.y ~pict.height ~pict.y ADD2 LTH2 ^$ver JNZ + +RTN + @draw-picture ( x y width height color addr ) DUP2 =Screen.addr =pict.addr =pict.color =pict.height =pict.width DUP2 =Screen.y =pict.y =pict.x @@ -38,6 +81,9 @@ BRK RTN +@clear_icn [ 0000 0000 0000 0000 ] +@pointer_icn [ 80c0 e0f0 f8e0 1000 ] + @pict_small [ ff80 8080 8080 8088 ffff fffc f8f9 f1f4 ffff 0010 c721 2120 ffff 3f0f 0717 c343 @@ -312,3 +358,7 @@ RTN 1081 4182 0500 0000 aa25 512a 44aa 0000 0254 0992 4984 0000 9452 4925 5289 0000 ] + +@filepath [ projects/pictures/zerotwo2020.chr 00 ] + +|3000 @img \ No newline at end of file diff --git a/projects/pictures/zerotwo2020.chr b/projects/pictures/zerotwo2020.chr new file mode 100644 index 0000000000000000000000000000000000000000..f75783c228163d78f8d08f8ecad484dd0738a725 GIT binary patch literal 16384 zcmdU0Z*WxCb-!=lqPK)ayO^1>1chDMIOJ2cptQ)f%3Ey3;1*YWE7K3w+PJnm(-vjw zwo0q=o{((ehC%9Nn&39gLOmWlLuVlMhcd0l`y{zp+&Y!o$)q&nWS@`|snaz3gs8Pb zt9|{Q`)4Iq5|a4iz!~)JJNKS@?z#7zd+s^+Exvzm!EB4iGXOt3KTg^AXE|0bl?wT+ zMem;L*bKnyeZNfa0F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ixel(p, layer, x + h, y + v, (ch1 - ch2 + color / 4) & 0x3); + putpixel(p, layer, x + h, y + v, (((ch1 + ch2 * 2) + color - 1) & 0x3)); } }