uxn

Varvara Ordinator, written in ANSI C(SDL2)
git clone https://git.eamoncaddigan.net/uxn.git
Log | Files | Refs | README | LICENSE

commit c1c0f8f2bc629fe197ad2ad7e78516d9e90f47d9
parent 131157cd53a88f671081213d4146b97ced974466
Author: neauoire <aliceffekt@gmail.com>
Date:   Sat, 10 Apr 2021 12:19:38 -0700

Improved picture example

Diffstat:
Mbuild.sh | 2+-
Mprojects/examples/blank.usm | 32++++++++------------------------
Mprojects/examples/gui.picture.usm | 59+++++++++++++++++++++++++++++++++++++++++++++++++++++++----
Aprojects/pictures/zerotwo2020.chr | 0
Msrc/ppu.c | 2+-
5 files changed, 65 insertions(+), 30 deletions(-)

diff --git 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 @@ -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 @@ -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 Binary files differ. diff --git a/src/ppu.c b/src/ppu.c @@ -130,7 +130,7 @@ putchr(Ppu *p, Uint8 *layer, Uint16 x, Uint16 y, Uint8 *sprite, Uint8 color) for(h = 0; h < 8; h++) { Uint8 ch1 = ((sprite[v] >> (7 - h)) & 0x1) * color; Uint8 ch2 = ((sprite[v + 8] >> (7 - h)) & 0x1) * color; - putpixel(p, layer, x + h, y + v, (ch1 - ch2 + color / 4) & 0x3); + putpixel(p, layer, x + h, y + v, (((ch1 + ch2 * 2) + color - 1) & 0x3)); } }