uxn

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

commit c91bf304e62344302a01d381c06a8ca6134db8bd
parent 47866bbe87760ff9fa8e1cccdbc4764ccd0338f4
Author: neauoire <aliceffekt@gmail.com>
Date:   Sun, 28 Mar 2021 11:20:36 -0700

Ported all examples

Diffstat:
Mbuild.sh | 2+-
Mprojects/examples/dev.console.usm | 7++++---
Mprojects/examples/dev.controller.usm | 10+++++++---
Mprojects/examples/dev.keys.usm | 14+++++++++++---
Mprojects/examples/dev.mouse.usm | 10+++++++---
Mprojects/examples/dev.screen.usm | 16++++++++++------
Mprojects/examples/dev.time.usm | 8+++++---
Dprojects/examples/gui.editor.usm | 228-------------------------------------------------------------------------------
Mprojects/examples/gui.hover.usm | 9++++++---
Mprojects/examples/gui.label.usm | 10+++++++---
Mprojects/examples/gui.picture.usm | 10+++++++---
Mprojects/examples/gui.shapes.usm | 10+++++++---
Msrc/emulator.c | 1-
13 files changed, 72 insertions(+), 263 deletions(-)

diff --git a/build.sh b/build.sh @@ -28,7 +28,7 @@ else fi echo "Assembling.." -./bin/assembler projects/software/neralie.usm bin/boot.rom +./bin/assembler projects/software/noodle.usm bin/boot.rom echo "Running.." if [ "${2}" = '--cli' ]; diff --git a/projects/examples/dev.console.usm b/projects/examples/dev.console.usm @@ -5,12 +5,13 @@ ( devices ) |0100 ;Console { pad 8 char 1 byte 1 short 2 } -|01F0 .RESET .FRAME .ERROR ( vectors ) -|01F8 [ 13fd 1ef3 1bf2 ] ( palette ) +|0200 ,RESET JMP2 +|0204 ,ERROR JMP2 +|0208 ,FRAME JMP2 ( program ) -|0200 @RESET +@RESET ,text1 ,print-label JSR2 ,text2 ,print-label JSR2 diff --git a/projects/examples/dev.controller.usm b/projects/examples/dev.controller.usm @@ -14,10 +14,14 @@ |0110 ;Screen { width 2 height 2 pad 4 y 2 x 2 color 1 } |0120 ;Sprite { pad 8 x 2 y 2 addr 2 color 1 } |0130 ;Controller { p1 1 } -|01F0 .RESET .FRAME .ERROR ( vectors ) -|01F8 [ 0daf 02ff 035f ] ( palette ) +|01F0 ;System { pad 8 r 2 g 2 b 2 } +|0200 ,RESET JMP2 +|0204 ,ERROR JMP2 +|0208 ,FRAME JMP2 -|0200 @RESET +@RESET + + ( theme ) #0daf =System.r #02ff =System.g #035f =System.b ( set origin ) ~Screen.width 2/ =Sprite.x diff --git a/projects/examples/dev.keys.usm b/projects/examples/dev.keys.usm @@ -12,12 +12,20 @@ |0120 ;Sprite { pad 8 x 2 y 2 addr 2 color 1 } |0130 ;Controller { buttons 1 } |0140 ;Keys { key 1 } -|01F0 .RESET .FRAME .ERROR ( vectors ) -|01F8 [ 0daf 02ff 035f ] ( palette ) +|01F0 ;System { pad 8 r 2 g 2 b 2 } +|0200 ,RESET JMP2 +|0204 ,ERROR JMP2 +|0208 ,FRAME JMP2 -|0200 @RESET BRK +@RESET + + ( theme ) #127f =System.r #34e7 =System.g #56c4 =System.b + +BRK @FRAME + + ( theme ) #0daf =System.r #02ff =System.g #035f =System.b ( update cursor ) #02 ~cursor.blink #01 EQU ADD =Sprite.color diff --git a/projects/examples/dev.mouse.usm b/projects/examples/dev.mouse.usm @@ -13,10 +13,14 @@ |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 } |0150 ;Mouse { x 2 y 2 state 1 chord 1 } -|01F0 .RESET .FRAME .ERROR ( vectors ) -|01F8 [ 13fd 1ef3 1bf2 ] ( palette ) +|01F0 ;System { pad 8 r 2 g 2 b 2 } +|0200 ,RESET JMP2 +|0204 ,ERROR JMP2 +|0208 ,FRAME JMP2 -|0200 @RESET +@RESET + + ( theme ) #13fd =System.r #1ef3 =System.g #1bf2 =System.b BRK diff --git a/projects/examples/dev.screen.usm b/projects/examples/dev.screen.usm @@ -25,10 +25,14 @@ |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 } |0150 ;Mouse { x 2 y 2 state 1 chord 1 } -|01F0 .RESET .FRAME .ERROR ( vectors ) -|01F8 @Red [ 127f ] @Green [ 34e7 ] @Blue [ 56c4 ] ( palette ) +|01F0 ;System { pad 8 r 2 g 2 b 2 } +|0200 ,RESET JMP2 +|0204 ,ERROR JMP2 +|0208 ,FRAME JMP2 -|0200 @RESET +@RESET + + ( theme ) #127f =System.r #34e7 =System.g #56c4 =System.b #00a0 =window.w #0050 =window.h @@ -151,9 +155,9 @@ RTN ~window.x1 #0050 ADD2 ~window.y1 #0020 ADD2 ~window.x1 #0080 ADD2 #00 ,theme.g1 ~selection ADD PEK2 #0004 MUL2 #01 ,draw-slider JSR2 ~window.x1 #0050 ADD2 ~window.y1 #0030 ADD2 ~window.x1 #0080 ADD2 #00 ,theme.b1 ~selection ADD PEK2 #0004 MUL2 #01 ,draw-slider JSR2 - ~window.x1 #0008 ADD2 =Sprite.x ~window.y1 =Sprite.y ,Red ,draw-short JSR2 - ~window.x1 #0030 ADD2 =Sprite.x ~window.y1 =Sprite.y ,Green ,draw-short JSR2 - ~window.x1 #0058 ADD2 =Sprite.x ~window.y1 =Sprite.y ,Blue ,draw-short JSR2 + ~window.x1 #0008 ADD2 =Sprite.x ~window.y1 =Sprite.y ~System.r ,draw-short JSR2 + ~window.x1 #0030 ADD2 =Sprite.x ~window.y1 =Sprite.y ~System.g ,draw-short JSR2 + ~window.x1 #0058 ADD2 =Sprite.x ~window.y1 =Sprite.y ~System.b ,draw-short JSR2 ~window.x1 #0050 ADD2 =Sprite.x ~window.y1 #0040 ADD2 =Sprite.y diff --git a/projects/examples/dev.time.usm b/projects/examples/dev.time.usm @@ -4,12 +4,14 @@ |0100 ;Console { pad 8 char 1 byte 1 short 2 } |0190 ;Time { year 2 month 1 day 1 hour 1 minute 1 second 1 dow 1 doy 2 isdst 1 get 1 } -|01F0 .RESET .FRAME .ERROR ( vectors ) -|01F8 [ 13fd 1ef3 1bf2 ] ( palette ) +|01F0 ;System { pad 8 r 2 g 2 b 2 } +|0200 ,RESET JMP2 +|0204 ,ERROR JMP2 +|0208 ,FRAME JMP2 ( program ) -|0200 @RESET BRK +@RESET BRK @FRAME #00 =Time.get diff --git a/projects/examples/gui.editor.usm b/projects/examples/gui.editor.usm @@ -1,228 +0,0 @@ -( app/hex ) - -%RTN { JMP2r } - -;label { x 2 y 2 color 1 addr 2 } -;pixel { x 1 y 1 } -;window { x1 2 y1 2 x2 2 y2 2 } -;pointer { x 2 y 2 sprite 2 } -;editor { x1 2 y1 2 addr 2 } -;rect { x1 2 y1 2 x2 2 y2 2 } -;color { byte 1 } - -|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 { buttons 1 } -|0150 ;Mouse { x 2 y 2 state 1 chord 1 } -|01F0 .RESET .FRAME .ERROR ( vectors ) -|01F8 [ 0fcf 0fc4 0fc4 ] ( palette ) - -|0200 @RESET - - #0030 =window.x1 #0030 =window.y1 #0090 =window.x2 #0090 =window.y2 - - ~window.x1 #0010 ADD2 =editor.x1 - ~window.y1 #0010 ADD2 =editor.y1 - - ( starting addr ) - ,pattern =editor.addr - - ,draw-window JSR2 - ,draw-editor JSR2 - -BRK - -@FRAME - - ~Controller.buttons #00 EQU ^$no-ctrl JNZ - - ~Controller.buttons #10 EQU ^$no-ctrl-up JNZ - ~editor.addr #0001 ADD2 =editor.addr - ,draw-window JSR2 - ,draw-editor JSR2 - $no-ctrl-up - - ~Controller.buttons #20 EQU ^$no-ctrl-down JNZ - ~editor.addr #0001 SUB2 =editor.addr - ,draw-window JSR2 - ,draw-editor JSR2 - $no-ctrl-down - - $no-ctrl - - ~Mouse.state #00 EQU ^$no-click JNZ - - ( load ) ~editor.addr ~Mouse.y ~editor.y1 SUB2 #0008 DIV2 ADD2 PEK2 - ( mask ) #01 #07 ~Mouse.x ~editor.x1 SUB2 #0008 DIV2 SWP POP SUB #40 SFT SFT - ORA - ( save ) ~editor.addr ~Mouse.y ~editor.y1 SUB2 #0008 DIV2 ADD2 POK2 - - ,draw-window JSR2 - ,draw-editor JSR2 - - $no-click - - ,draw-cursor JSR2 - -BRK - -@draw-window - - ( desktop ) #0000 #0000 ~Screen.width ~Screen.height #03 ~editor.addr ,tile-rect JSR2 - ( outline ) ~window.x1 #0001 SUB2 ~window.y1 #0001 SUB2 ~window.x2 ~window.y2 #01 ,line-rect JSR2 - ( background ) ~window.x1 ~window.y1 ~window.x2 ~window.y2 #02 ,fill-rect JSR2 - ( label ) ~window.x1 ~window.y1 #04 ,window_name ,draw-label-left JSR2 - -RTN - -@draw-editor - - ~editor.x1 =Sprite.x - ~editor.y1 =Sprite.y - ~editor.addr =Sprite.addr - - #00 =pixel.y - $ver - #00 =pixel.x - ~editor.x1 =Sprite.x - $hor - ( get bit ) - ,cell0_icn #00 - ~editor.addr #00 ~pixel.y ADD2 PEK2 #07 ~pixel.x SUB SFT #01 AND ( get bit ) - #0008 MUL2 ADD2 =Sprite.addr ( add *8 ) - ( draw ) #08 =Sprite.color - ( incr ) ~Sprite.x #0008 ADD2 =Sprite.x - ( incr ) ~pixel.x #01 ADD =pixel.x - ~Sprite.x ~editor.x1 #0040 ADD2 LTH2 ,$hor JNZ2 - ( incr ) ~Sprite.y #0008 ADD2 =Sprite.y - ( incr ) ~pixel.y #01 ADD =pixel.y - ~Sprite.y ~editor.y1 #0040 ADD2 LTH2 ,$ver JNZ2 - ~editor.addr =Sprite.addr - ~window.y1 =Sprite.y - ~window.x2 #0008 SUB2 =Sprite.x - ( draw ) #01 =Sprite.color - -RTN - -@draw-label-left ( x y color addr ) - - ( load ) =label.addr =label.color =Sprite.y =Sprite.x - ~label.addr - $loop NOP - ( draw ) DUP2 PEK2 #00 SWP #0008 MUL2 ,font ADD2 =Sprite.addr ~label.color =Sprite.color - ( incr ) #0001 ADD2 - ( incr ) ~Sprite.x #0007 ADD2 =Sprite.x - DUP2 PEK2 #00 NEQ ^$loop MUL JMP - POP2 - -RTN - -@fill-rect ( x1 y1 x2 y2 color ) - - ( load ) =color =rect.y2 =rect.x2 DUP2 =Screen.y =rect.y1 DUP2 =Screen.x =rect.x1 - $ver NOP - ~rect.x1 =Screen.x - $hor NOP - ( draw ) ~color =Screen.color - ( incr ) ~Screen.x #0001 ADD2 =Screen.x - ~Screen.x ~rect.x2 LTH2 ^$hor MUL JMP - ( incr ) ~Screen.y #0001 ADD2 =Screen.y - ~Screen.y ~rect.y2 LTH2 ^$ver MUL JMP - -RTN - -@line-rect ( x1 y1 x2 y2 color ) - - ( load ) =color =rect.y2 =rect.x2 DUP2 =Screen.y =rect.y1 DUP2 =Screen.x =rect.x1 - $hor NOP - ( incr ) ~Screen.x #0001 ADD2 =Screen.x - ( draw ) ~rect.y1 =Screen.y ~color =Screen.color - ( draw ) ~rect.y2 =Screen.y ~color =Screen.color - ~Screen.x ~rect.x2 LTH2 ^$hor MUL JMP - ~rect.y1 =Screen.y - $ver NOP - ( draw ) ~rect.x1 =Screen.x ~color =Screen.color - ( draw ) ~rect.x2 =Screen.x ~color =Screen.color - ( incr ) ~Screen.y #0001 ADD2 =Screen.y - ~Screen.y ~rect.y2 #0001 ADD2 LTH2 ^$ver MUL JMP - -RTN - -@tile-rect ( x1 y1 x2 y2 color addr ) - - =Sprite.addr =color =rect.y2 =rect.x2 DUP2 =Sprite.y =rect.y1 DUP2 =Sprite.x =rect.x1 - $ver NOP - ~rect.x1 =Sprite.x - $hor NOP - ( draw ) ~color =Sprite.color - ( incr ) ~Sprite.x #0008 ADD2 =Sprite.x - ~Sprite.x ~rect.x2 LTH2 ^$hor MUL JMP - ( incr ) ~Sprite.y #0008 ADD2 =Sprite.y - ~Sprite.y ~rect.y2 LTH2 ^$ver MUL JMP - -RTN - -@draw-cursor - - ( clear last cursor ) - ,clear_icn =Sprite.addr - ~pointer.x =Sprite.x - ~pointer.y =Sprite.y - #10 =Sprite.color - - ( record pointer positions ) - ~Mouse.x =pointer.x ~Mouse.y =pointer.y - - ( draw new cursor ) - ,cursor_icn =Sprite.addr - ~pointer.x =Sprite.x - ~pointer.y =Sprite.y - #11 =Sprite.color - -RTN - -@pattern [ 0000 0000 0000 0000 ] -@clear_icn [ 0000 0000 0000 0000 ] -@cursor_icn [ 80c0 e0f0 f8e0 1000 ] -@cell0_icn [ 7c82 8282 8282 7c00 ] -@cell1_icn [ 7cfe fefe fefe 7c00 ] - -@window_name [ Editor 00 ] - -@font ( spectrum-zx font ) -[ - 0000 0000 0000 0000 0000 2400 7e3c 0000 0000 2400 3c42 0000 0000 6c7c 7c38 1000 - 0010 387c 7c38 1000 0038 387c 6c10 3800 0010 387c 7c10 3800 0000 0018 1800 0000 - 007e 4242 4242 7e00 0000 1824 2418 0000 0018 2442 4224 1800 001e 063a 4a48 3000 - 0038 446c 107c 1000 000c 0808 0838 3800 003e 2222 2266 6600 0000 0822 0022 0800 - 0000 1018 1c18 1000 0000 0818 3818 0800 0008 1c00 001c 0800 0028 2828 2800 2800 - 003e 4a4a 3a0a 0a00 000c 3046 620c 3000 0000 0000 0000 ffff 0010 3800 3810 0038 - 0008 1c2a 0808 0800 0008 0808 2a1c 0800 0000 0804 7e04 0800 0000 1020 7e20 1000 - 0000 4040 7e00 0000 0000 0024 6624 0000 0000 1038 7c00 0000 0000 007c 3810 0000 - 0000 0000 0000 0000 0008 0808 0800 0800 0014 1400 0000 0000 0024 7e24 247e 2400 - 0008 1e28 1c0a 3c08 0042 0408 1020 4200 0030 4832 4c44 3a00 0008 1000 0000 0000 - 0004 0808 0808 0400 0010 0808 0808 1000 0000 1408 3e08 1400 0000 0808 3e08 0800 - 0000 0000 0008 0810 0000 0000 3c00 0000 0000 0000 0000 0800 0000 0204 0810 2000 - 003c 464a 5262 3c00 0018 2808 0808 3e00 003c 4202 3c40 7e00 003c 421c 0242 3c00 - 0008 1828 487e 0800 007e 407c 0242 3c00 003c 407c 4242 3c00 007e 0204 0810 1000 - 003c 423c 4242 3c00 003c 4242 3e02 3c00 0000 0008 0000 0800 0000 0800 0008 0810 - 0000 0810 2010 0800 0000 003e 003e 0000 0000 1008 0408 1000 003c 4202 0c00 0800 - 003c 425a 5442 3c00 0018 2442 7e42 4200 007c 427c 4242 7c00 003c 4240 4042 3c00 - 0078 4442 4244 7800 007e 407c 4040 7e00 003e 4040 7c40 4000 003c 4240 4e42 3c00 - 0042 427e 4242 4200 003e 0808 0808 3e00 0002 0202 4242 3c00 0044 4870 4844 4200 - 0040 4040 4040 7e00 0042 665a 4242 4200 0042 6252 4a46 4200 003c 4242 4242 3c00 - 007c 4242 7c40 4000 003c 4242 524a 3c00 007c 4242 7c44 4200 003c 403c 0242 3c00 - 00fe 1010 1010 1000 0042 4242 4242 3c00 0042 4242 4224 1800 0042 4242 5a66 4200 - 0042 2418 1824 4200 0082 4428 1010 1000 007e 0408 1020 7e00 000c 0808 0808 0c00 - 0040 2010 0804 0200 0018 0808 0808 1800 0008 1422 0000 0000 0000 0000 0000 7e00 - 0008 0400 0000 0000 0000 1c02 1e22 1e00 0020 203c 2222 3c00 0000 1e20 2020 1e00 - 0002 021e 2222 1e00 0000 1c22 3c20 1e00 000c 101c 1010 1000 0000 1c22 221e 021c - 0020 202c 3222 2200 0008 0018 0808 0400 0008 0008 0808 4830 0020 2428 3028 2400 - 0010 1010 1010 0c00 0000 6854 5454 5400 0000 5864 4444 4400 0000 3844 4444 3800 - 0000 7844 4478 4040 0000 3c44 443c 0406 0000 2c30 2020 2000 0000 3840 3804 7800 - 0010 103c 1010 0c00 0000 4444 4444 3800 0000 4444 2828 1000 0000 4454 5454 2800 - 0000 4428 1028 4400 0000 4444 443c 0438 0000 7c08 1020 7c00 000c 0810 1008 0c00 - 0008 0808 0808 0800 0030 1008 0810 3000 0000 0032 4c00 0000 3c42 99a1 a199 423c -] - -@ERROR BRK diff --git a/projects/examples/gui.hover.usm b/projects/examples/gui.hover.usm @@ -13,11 +13,14 @@ |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 } |0150 ;Mouse { x 2 y 2 state 1 chord 1 } +|01F0 ;System { pad 8 r 2 g 2 b 2 } +|0200 ,RESET JMP2 +|0204 ,ERROR JMP2 +|0208 ,FRAME JMP2 -|01F0 .RESET .FRAME .ERROR ( vectors ) -|01F8 [ 0f0f 0fff 0ff0 ] ( palette ) +@RESET -|0200 @RESET + ( theme ) #0f0f =System.r #0fff =System.g #0ff0 =System.b #0020 #0030 #0060 #0060 =r1.y2 =r1.x2 =r1.y1 =r1.x1 #0058 #0050 #0090 #0080 =r2.y2 =r2.x2 =r2.y1 =r2.x1 diff --git a/projects/examples/gui.label.usm b/projects/examples/gui.label.usm @@ -9,10 +9,14 @@ |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 } -|01F0 .RESET .FRAME .ERROR ( vectors ) -|01F8 [ 0f0f 0fff 0ff0 ] ( palette ) +|01F0 ;System { pad 8 r 2 g 2 b 2 } +|0200 ,RESET JMP2 +|0204 ,ERROR JMP2 +|0208 ,FRAME JMP2 -|0200 @RESET +@RESET + + ( theme ) #0f0f =System.r #0fff =System.g #0ff0 =System.b ( find screen center ) ~Screen.width #0002 DIV2 =center.x diff --git a/projects/examples/gui.picture.usm b/projects/examples/gui.picture.usm @@ -5,11 +5,15 @@ ;pict { x 2 y 2 width 2 height 2 color 1 addr 2 } |0120 ;Sprite { pad 8 x 2 y 2 addr 2 color 1 } -|01F0 .RESET .FRAME .ERROR ( vectors ) -|01F8 [ 0ffc 0f0b 0f03 ] ( palette ) +|01F0 ;System { pad 8 r 2 g 2 b 2 } +|0200 ,RESET JMP2 +|0204 ,ERROR JMP2 +|0208 ,FRAME JMP2 -|0200 @RESET +@RESET + ( theme ) #0ffc =System.r #0f0b =System.g #0f03 =System.b + #0000 #0000 #0100 #0100 #01 ,pict_large ,draw-picture JSR2 #0098 #0060 #0080 #0080 #01 ,pict_medium ,draw-picture JSR2 #0020 #0090 #0020 #0020 #0a ,pict_small ,draw-picture JSR2 diff --git a/projects/examples/gui.shapes.usm b/projects/examples/gui.shapes.usm @@ -15,10 +15,14 @@ |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 } -|01F0 .RESET .FRAME .ERROR ( vectors ) -|01F8 [ 13fd 1ef3 1bf2 ] ( palette ) +|01F0 ;System { pad 8 r 2 g 2 b 2 } +|0200 ,RESET JMP2 +|0204 ,ERROR JMP2 +|0208 ,FRAME JMP2 -|0200 @RESET +@RESET + + ( theme ) #13fd =System.r #1ef3 =System.g #1bf2 =System.b #0010 #0020 #0040 #0060 #01 ,fill-rect JSR2 #0020 #0030 #0050 #0070 #02 ,fill-rect JSR2 diff --git a/src/emulator.c b/src/emulator.c @@ -424,7 +424,6 @@ datetime_poke(Uxn *u, Uint16 ptr, Uint8 b0, Uint8 b1) Uint8 *m = u->ram.dat; time_t seconds = time(NULL); struct tm *t = localtime(&seconds); - (void)b0; t->tm_year += 1900; m[ptr + 0] = (t->tm_year & 0xff00) >> 8; m[ptr + 1] = t->tm_year & 0xff;