uxn

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

commit 82d1c276f9f26ec2faa7d0c29e6e3491be81dce5
parent c92b2009a3cccacbaa49d180c25d3cf8f1e70e07
Author: neauoire <aliceffekt@gmail.com>
Date:   Mon, 15 Mar 2021 15:27:43 -0700

Automated pop on cond?

Diffstat:
Mbuild.sh | 2+-
Mprojects/examples/dev.keys.usm | 26+++++++++++++-------------
Mprojects/examples/dev.mouse.usm | 22+++++++++++-----------
Mprojects/examples/dev.screen.usm | 14+++++++-------
Aprojects/examples/gui.editor.usm | 234+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mprojects/examples/gui.hover.usm | 18+++++++++---------
Mprojects/examples/gui.label.usm | 10+++++-----
Mprojects/examples/gui.picture.usm | 4++--
Mprojects/examples/gui.shapes.usm | 14+++++++-------
Dprojects/examples/win.editor.usm | 234-------------------------------------------------------------------------------
Mprojects/software/left.usm | 116++++++++++++++++++++++++++++++++++++++++----------------------------------------
Mprojects/software/nasu.usm | 70+++++++++++++++++++++++++++++++++++-----------------------------------
Aprojects/tests/cond.usm | 25+++++++++++++++++++++++++
Mprojects/tests/jump.usm | 2+-
Mprojects/tests/loop.usm | 8++++----
Muxn.c | 9++++++---
16 files changed, 418 insertions(+), 390 deletions(-)

diff --git a/build.sh b/build.sh @@ -20,5 +20,5 @@ cc -std=c89 -DDEBUG -Wall -Wno-unknown-pragmas -Wpedantic -Wshadow -Wextra -Werr # cc uxn.c emulator.c -std=c89 -Os -DNDEBUG -g0 -s -Wall -Wno-unknown-pragmas -L/usr/local/lib -lSDL2 -o bin/emulator # run -./bin/assembler projects/examples/dev.controller.usm bin/boot.rom +./bin/assembler projects/software/left.usm bin/boot.rom ./bin/emulator bin/boot.rom diff --git a/projects/examples/dev.keys.usm b/projects/examples/dev.keys.usm @@ -42,7 +42,7 @@ RTN @blink-cursor - ,skip ~timer #10 LTH JMP2? POP2 + ,skip ~timer #10 LTH JMP2? #00 =timer ~blink #00 EQU =blink ,cursor =Sprite.addr @@ -61,9 +61,9 @@ RTN $hor ( draw ) ~color =Sprite.color ( incr ) ~Sprite.x #0008 ADD2 =Sprite.x - ,$hor ~Sprite.x ~rect.x2 LTH2 JMP2? POP2 + ,$hor ~Sprite.x ~rect.x2 LTH2 JMP2? ( incr ) ~Sprite.y #0008 ADD2 =Sprite.y - ,$ver ~Sprite.y ~rect.y2 LTH2 JMP2? POP2 + ,$ver ~Sprite.y ~rect.y2 LTH2 JMP2? RTN @@ -75,9 +75,9 @@ RTN $hor ( draw ) ~color =Screen.color ( incr ) ~Screen.x #0001 ADD2 =Screen.x - ,$hor ~Screen.x ~rect.x2 LTH2 JMP2? POP2 + ,$hor ~Screen.x ~rect.x2 LTH2 JMP2? ( incr ) ~Screen.y #0001 ADD2 =Screen.y - ,$ver ~Screen.y ~rect.y2 LTH2 JMP2? POP2 + ,$ver ~Screen.y ~rect.y2 LTH2 JMP2? RTN @@ -88,13 +88,13 @@ RTN ( incr ) ~Screen.x #0001 ADD2 =Screen.x ( draw ) ~rect.y1 =Screen.y ~color =Screen.color ( draw ) ~rect.y2 =Screen.y ~color =Screen.color - ,$hor ~Screen.x ~rect.x2 LTH2 JMP2? POP2 + ,$hor ~Screen.x ~rect.x2 LTH2 JMP2? ~rect.y1 =Screen.y $ver ( draw ) ~rect.x1 =Screen.x ~color =Screen.color ( draw ) ~rect.x2 =Screen.x ~color =Screen.color ( incr ) ~Screen.y #0001 ADD2 =Screen.y - ,$ver ~Screen.y ~rect.y2 #0001 ADD2 LTH2 JMP2? POP2 + ,$ver ~Screen.y ~rect.y2 #0001 ADD2 LTH2 JMP2? RTN @@ -105,14 +105,14 @@ RTN $loop ( draw ) DUP2 LDR #00 SWP #0008 MUL2 ,font ADD2 =Sprite.addr ~textarea.color =Sprite.color ( detect linebreaks ) - DUP2 LDR #0d NEQ ,$no-return ROT JMP2? POP2 + DUP2 LDR #0d NEQ ,$no-return ROT JMP2? ~textarea.x1 =Sprite.x ( incr ) ~Sprite.y #0008 ADD2 =Sprite.y ( decr ) ~Sprite.x #0008 SUB2 =Sprite.x $no-return ( incr ) #0001 ADD2 ( incr ) ~Sprite.x #0008 ADD2 =Sprite.x - DUP2 LDR #00 NEQ ,$loop ROT JMP2? POP2 + DUP2 LDR #00 NEQ ,$loop ROT JMP2? POP2 RTN @@ -120,10 +120,10 @@ RTN @do-textarea ( ,blink-cursor JSR2 ) - ,do-textarea-end ~Keys #00 EQU JMP2? POP2 ( skip on no key ) + ,do-textarea-end ~Keys #00 EQU JMP2? ( skip on no key ) ( backspace ) - ,any-key ~Keys #08 NEQ JMP2? POP2 - ,input-end ~textarea.cursor #00 EQU JMP2? POP2 + ,any-key ~Keys #08 NEQ JMP2? + ,input-end ~textarea.cursor #00 EQU JMP2? ( decr ) ~textarea.cursor #01 SUB =textarea.cursor #00 ~textarea.addr #00 ~textarea.cursor ADD2 STR ,input-end JMP2 @@ -142,7 +142,7 @@ RTN @do-cursor - ,skip-drag ~Mouse.state #01 NEQ JMP2? POP2 + ,skip-drag ~Mouse.state #01 NEQ JMP2? ~mouse.x =textarea.x1 ~mouse.y =textarea.y1 ,redraw-window JSR2 ,redraw JSR2 diff --git a/projects/examples/dev.mouse.usm b/projects/examples/dev.mouse.usm @@ -22,23 +22,23 @@ BRK ,draw-cursor JSR2 ( reset timer -> move cat tail ) - ,no-click ~Mouse.state #00 EQU JMP2? POP2 + ,no-click ~Mouse.state #00 EQU JMP2? #50 =timer @no-click ( detect click ) - ,no-click12 ~Mouse.state #11 NEQ JMP2? POP2 + ,no-click12 ~Mouse.state #11 NEQ JMP2? #0058 #0040 #01 ,mouse12_text ,draw-label JSR2 #10 ,cursor_icn ~pointer.x ~pointer.y ,draw-sprite JSR2 ~color ,mouse12_icn #0048 #0040 ,draw-sprite JSR2 ,end-click JMP2 @no-click12 - ,no-click1 ~Mouse.state #01 NEQ JMP2? POP2 + ,no-click1 ~Mouse.state #01 NEQ JMP2? #0058 #0040 #01 ,mouse1_text ,draw-label JSR2 #12 ,cursor_icn ~pointer.x ~pointer.y ,draw-sprite JSR2 ~color ,mouse1_icn #0048 #0040 ,draw-sprite JSR2 ,end-click JMP2 @no-click1 - ,no-click2 ~Mouse.state #10 NEQ JMP2? POP2 + ,no-click2 ~Mouse.state #10 NEQ JMP2? #0058 #0040 #01 ,mouse2_text ,draw-label JSR2 #13 ,cursor_icn ~pointer.x ~pointer.y ,draw-sprite JSR2 ~color ,mouse2_icn #0048 #0040 ,draw-sprite JSR2 @@ -91,18 +91,18 @@ RTN @animate-polycat ( tail ) - ~timer #50 NEQ ,animate-polycat-tail-next0 ROT JMP2? POP2 + ~timer #50 NEQ ,animate-polycat-tail-next0 ROT JMP2? ,polycat #00c0 ADD2 ~cat.x #0008 ADD2 ~cat.y #0010 ADD2 ,draw-sprite-chr JSR2 @animate-polycat-tail-next0 - ~timer #58 NEQ ,animate-polycat-tail-next1 ROT JMP2? POP2 + ~timer #58 NEQ ,animate-polycat-tail-next1 ROT JMP2? ,polycat #00d0 ADD2 ~cat.x #0008 ADD2 ~cat.y #0010 ADD2 ,draw-sprite-chr JSR2 @animate-polycat-tail-next1 - ~timer #60 NEQ ,animate-polycat-tail-next2 ROT JMP2? POP2 + ~timer #60 NEQ ,animate-polycat-tail-next2 ROT JMP2? ,polycat #00b0 ADD2 ~cat.x #0008 ADD2 ~cat.y #0010 ADD2 ,draw-sprite-chr JSR2 @animate-polycat-tail-next2 ( look-at ) - ~pointer.x ~cat.x #0008 ADD2 GTH2 ,animate-polycat-right ROT JMP2? POP2 - ~pointer.y ~cat.y #0008 ADD2 GTH2 ,animate-polycat-left-down ROT JMP2? POP2 + ~pointer.x ~cat.x #0008 ADD2 GTH2 ,animate-polycat-right ROT JMP2? + ~pointer.y ~cat.y #0008 ADD2 GTH2 ,animate-polycat-left-down ROT JMP2? ,polycat #0040 ADD2 ~cat.x ~cat.y #0008 ADD2 ,draw-sprite-chr JSR2 ,polycat #0050 ADD2 ~cat.x #0008 ADD2 ~cat.y #0008 ADD2 ,draw-sprite-chr JSR2 RTN @@ -111,7 +111,7 @@ RTN ,polycat #0030 ADD2 ~cat.x #0008 ADD2 ~cat.y #0008 ADD2 ,draw-sprite-chr JSR2 RTN @animate-polycat-right - ~pointer.y ~cat.y #0008 ADD2 GTH2 ,animate-polycat-right-down ROT JMP2? POP2 + ~pointer.y ~cat.y #0008 ADD2 GTH2 ,animate-polycat-right-down ROT JMP2? ,polycat #0060 ADD2 ~cat.x ~cat.y #0008 ADD2 ,draw-sprite-chr JSR2 ,polycat #0070 ADD2 ~cat.x #0008 ADD2 ~cat.y #0008 ADD2 ,draw-sprite-chr JSR2 RTN @@ -130,7 +130,7 @@ RTN ( draw ) DUP2 LDR #00 SWP #0008 MUL2 ,font ADD2 =Sprite.addr ~label.color =Sprite.color ( incr ) #0001 ADD2 ( incr ) ~Sprite.x #0008 ADD2 =Sprite.x - DUP2 #0001 ADD2 LDR #00 NEQ ,$loop ROT JMP2? POP2 + DUP2 #0001 ADD2 LDR #00 NEQ ,$loop ROT JMP2? POP2 RTN diff --git a/projects/examples/dev.screen.usm b/projects/examples/dev.screen.usm @@ -15,7 +15,7 @@ $draw-hor NOP ( draw ) #01 =Screen.color ( incr ) SWP2 #0002 ADD2 DUP2 =Screen.x SWP2 - OVR2 OVR2 LTH2 ^$draw-hor SWP JMPS? POP + OVR2 OVR2 LTH2 ^$draw-hor SWP JMPS? POP2 POP2 ( draw ver line ) @@ -24,7 +24,7 @@ $draw-ver NOP ( draw ) #02 =Screen.color ( incr ) SWP2 #0002 ADD2 DUP2 =Screen.y SWP2 - OVR2 OVR2 LTH2 ^$draw-ver SWP JMPS? POP + OVR2 OVR2 LTH2 ^$draw-ver SWP JMPS? POP2 POP2 ( draw blending modes ) @@ -34,7 +34,7 @@ ( move ) OVR #00 SWP #0008 MUL2 #0020 ADD2 =Sprite.x ( draw ) OVR =Sprite.color ( incr ) SWP #01 ADD SWP - DUP2 LTH ^$draw-blends SWP JMPS? POP + DUP2 LTH ^$draw-blends SWP JMPS? POP POP BRK @@ -42,16 +42,16 @@ BRK @FRAME ( update colors every 40 frames ) - ~timer #40 NEQ ,skip1 ROT JMP2? POP2 + ~timer #40 NEQ ,skip1 ROT JMP2? #0fac #fffa STR2 #f0bb #fffc STR2 #f053 #fff8 STR2 @skip1 - ~timer #80 NEQ ,skip2 ROT JMP2? POP2 + ~timer #80 NEQ ,skip2 ROT JMP2? #00fc #fffc STR2 #f0bb #fff8 STR2 #f053 #fffa STR2 @skip2 - ~timer #c0 NEQ ,skip3 ROT JMP2? POP2 + ~timer #c0 NEQ ,skip3 ROT JMP2? #000f #fff8 STR2 #0f0f #fffa STR2 #ff00 #fffc STR2 @skip3 - ~timer #00 NEQ ,skip4 ROT JMP2? POP2 + ~timer #00 NEQ ,skip4 ROT JMP2? #f0ac #fff8 STR2 #f0bb #fffa STR2 #f053 #fffc STR2 @skip4 ~timer #01 ADD =timer diff --git a/projects/examples/gui.editor.usm b/projects/examples/gui.editor.usm @@ -0,0 +1,233 @@ +( app/hex ) + +;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 } +;addr { short 2 } + +|0100 @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 + + ,no-ctrl ~Controller.buttons #00 EQU JMP2? + + ,no-ctrl-up ~Controller.buttons #10 EQU JMP2? + ~editor.addr #0001 ADD2 =editor.addr + ,draw-window JSR2 + ,draw-editor JSR2 + @no-ctrl-up + + ,no-ctrl-down ~Controller.buttons #20 EQU JMP2? + ~editor.addr #0001 SUB2 =editor.addr + ,draw-window JSR2 + ,draw-editor JSR2 + @no-ctrl-down + + @no-ctrl + + ,no-click ~Mouse.state #00 EQU JMP2? + + ( load ) ~editor.addr ~Mouse.y ~editor.y1 SUB2 #0008 DIV2 ADD2 LDR + ( mask ) #01 #07 ~Mouse.x ~editor.x1 SUB2 #0008 DIV2 SWP POP SUB ROL + XOR + ( save ) ~editor.addr ~Mouse.y ~editor.y1 SUB2 #0008 DIV2 ADD2 STR + + ,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 LDR #07 ~pixel.x SUB ROR #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 + ,$hor ~Sprite.x ~editor.x1 #0040 ADD2 LTH2 JMP2? + ( incr ) ~Sprite.y #0008 ADD2 =Sprite.y + ( incr ) ~pixel.y #01 ADD =pixel.y + ,$ver ~Sprite.y ~editor.y1 #0040 ADD2 LTH2 JMP2? + ~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 LDR #00 SWP #0008 MUL2 ,font ADD2 =Sprite.addr ~label.color =Sprite.color + ( incr ) #0001 ADD2 + ( incr ) ~Sprite.x #0007 ADD2 =Sprite.x + DUP2 LDR #00 NEQ ^$loop MUL JMPS + 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 JMPS + ( incr ) ~Screen.y #0001 ADD2 =Screen.y + ~Screen.y ~rect.y2 LTH2 ^$ver MUL JMPS + +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 JMPS + ~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 JMPS + +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 JMPS + ( incr ) ~Sprite.y #0008 ADD2 =Sprite.y + ~Sprite.y ~rect.y2 LTH2 ^$ver MUL JMPS + +RTN + +@draw-cursor + + ~pointer.x ~Mouse.x NEQU2 + ~pointer.y ~Mouse.y NEQU2 + + #0000 EQU2 BRK? ( Return if unchanged ) + + ( 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 +] + +|d000 @ERROR BRK + +|FF10 ;Screen { width 2 height 2 pad 4 x 2 y 2 color 1 } +|FF20 ;Sprite { pad 8 x 2 y 2 addr 2 color 1 } +|FF30 ;Controller { buttons 1 } +|FF50 ;Mouse { x 2 y 2 state 1 chord 1 } + +|FFF0 .RESET .FRAME .ERROR ( vectors ) +|FFF8 [ 0fcf 0fc4 0fc4 ] ( palette ) +\ No newline at end of file diff --git a/projects/examples/gui.hover.usm b/projects/examples/gui.hover.usm @@ -28,22 +28,22 @@ BRK ( matrix comparison ) ~Mouse.x ~r1.x1 GTH2 ~Mouse.x ~r1.x2 LTH2 #0101 EQU2 ~Mouse.y ~r1.y1 GTH2 ~Mouse.y ~r1.y2 LTH2 #0101 EQU2 - #0101 NEQ2 ,$draw1 ROT JMP2? POP2 #02 =color ,hand_icn =pointer.sprite + #0101 NEQ2 ,$draw1 ROT JMP2? #02 =color ,hand_icn =pointer.sprite $draw1 ~r1.x1 ~r1.y1 ~r1.x2 ~r1.y2 ~color ,line-rect JSR2 #01 =color ( 2-step comparison ) - ,$draw2 ~Mouse.x ~r2.x1 GTH2 ~Mouse.x ~r2.x2 LTH2 #0101 NEQ2 JMP2? POP2 - ,$draw2 ~Mouse.y ~r2.y1 GTH2 ~Mouse.y ~r2.y2 LTH2 #0101 NEQ2 JMP2? POP2 + ,$draw2 ~Mouse.x ~r2.x1 GTH2 ~Mouse.x ~r2.x2 LTH2 #0101 NEQ2 JMP2? + ,$draw2 ~Mouse.y ~r2.y1 GTH2 ~Mouse.y ~r2.y2 LTH2 #0101 NEQ2 JMP2? #03 =color ,hand_icn =pointer.sprite $draw2 ~r2.x1 ~r2.y1 ~r2.x2 ~r2.y2 ~color ,line-rect JSR2 #01 =color ( 4-step comparison ) - ,$draw3 ~Mouse.x ~r3.x1 LTH2 JMP2? POP2 - ,$draw3 ~Mouse.x ~r3.x2 GTH2 JMP2? POP2 - ,$draw3 ~Mouse.y ~r3.y1 LTH2 JMP2? POP2 - ,$draw3 ~Mouse.y ~r3.y2 GTH2 JMP2? POP2 + ,$draw3 ~Mouse.x ~r3.x1 LTH2 JMP2? + ,$draw3 ~Mouse.x ~r3.x2 GTH2 JMP2? + ,$draw3 ~Mouse.y ~r3.y1 LTH2 JMP2? + ,$draw3 ~Mouse.y ~r3.y2 GTH2 JMP2? #02 =color ,hand_icn =pointer.sprite $draw3 ~r3.x1 ~r3.y1 ~r3.x2 ~r3.y2 ~color ,line-rect JSR2 @@ -77,13 +77,13 @@ RTN ( incr ) ~Screen.x #0001 ADD2 =Screen.x ( draw ) ~rect.y1 =Screen.y ~color =Screen.color ( draw ) ~rect.y2 =Screen.y ~color =Screen.color - ,$hor ~Screen.x ~rect.x2 LTH2 JMP2? POP2 + ,$hor ~Screen.x ~rect.x2 LTH2 JMP2? ~rect.y1 =Screen.y $ver ( draw ) ~rect.x1 =Screen.x ~color =Screen.color ( draw ) ~rect.x2 =Screen.x ~color =Screen.color ( incr ) ~Screen.y #0001 ADD2 =Screen.y - ,$ver ~Screen.y ~rect.y2 #0001 ADD2 LTH2 JMP2? POP2 + ,$ver ~Screen.y ~rect.y2 #0001 ADD2 LTH2 JMP2? RTN diff --git a/projects/examples/gui.label.usm b/projects/examples/gui.label.usm @@ -16,7 +16,7 @@ $draw-ver ( draw ) #02 =Screen.color ( incr ) ~Screen.y #0002 ADD2 =Screen.y - ,$draw-ver ~Screen.y ~Screen.height LTH2 JMP2? POP2 + ,$draw-ver ~Screen.y ~Screen.height LTH2 JMP2? ~center.x ~center.y #0010 SUB2 #0c ,text1 ,draw-label-left JSR2 ~center.x ~center.y #0c ,text2 ,draw-label-middle JSR2 @@ -34,7 +34,7 @@ BRK ( draw ) DUP2 LDR #00 SWP #0008 MUL2 ,font ADD2 =Sprite.addr ~label.color =Sprite.color ( incr ) #0001 ADD2 ( incr ) ~Sprite.x #0008 ADD2 =Sprite.x - DUP2 LDR #00 NEQ ,$loop ROT JMP2? POP2 + DUP2 LDR #00 NEQ ,$loop ROT JMP2? POP2 RTN @@ -48,7 +48,7 @@ RTN ( draw ) DUP2 LDR #00 SWP #0008 MUL2 ,font ADD2 =Sprite.addr ~label.color =Sprite.color ( incr ) #0001 ADD2 ( incr ) ~Sprite.x #0008 ADD2 =Sprite.x - DUP2 LDR #00 NEQ ,$loop ROT JMP2? POP2 + DUP2 LDR #00 NEQ ,$loop ROT JMP2? POP2 RTN @@ -62,7 +62,7 @@ RTN ( draw ) DUP2 LDR #00 SWP #0008 MUL2 ,font ADD2 =Sprite.addr ~label.color =Sprite.color ( incr ) #0001 ADD2 ( incr ) ~Sprite.x #0008 ADD2 =Sprite.x - DUP2 LDR #00 NEQ ,$loop ROT JMP2? POP2 + DUP2 LDR #00 NEQ ,$loop ROT JMP2? POP2 RTN @@ -72,7 +72,7 @@ RTN #0000 ( counter ) $loop ( incr ) #0001 ADD2 OVR2 OVR2 ADD2 - LDR #00 NEQ ,$loop ROT JMP2? POP2 + LDR #00 NEQ ,$loop ROT JMP2? SWP2 POP2 RTN diff --git a/projects/examples/gui.picture.usm b/projects/examples/gui.picture.usm @@ -19,9 +19,9 @@ BRK ( draw ) ~pict.color =Sprite.color ( incr ) ~Sprite.x #0008 ADD2 =Sprite.x ( incr ) ~Sprite.addr #0008 ADD2 =Sprite.addr - ,$hor ~Sprite.x ~pict.width ~pict.x ADD2 LTH2 JMP2? POP2 + ,$hor ~Sprite.x ~pict.width ~pict.x ADD2 LTH2 JMP2? ( incr ) ~Sprite.y #0008 ADD2 =Sprite.y - ,$ver ~Sprite.y ~pict.height ~pict.y ADD2 LTH2 JMP2? POP2 + ,$ver ~Sprite.y ~pict.height ~pict.y ADD2 LTH2 JMP2? RTN diff --git a/projects/examples/gui.shapes.usm b/projects/examples/gui.shapes.usm @@ -33,13 +33,13 @@ BRK ( incr ) ~Screen.x #0001 ADD2 =Screen.x ( draw ) ~rect.y1 =Screen.y ~color =Screen.color ( draw ) ~rect.y2 =Screen.y ~color =Screen.color - ,$hor ~Screen.x ~rect.x2 LTH2 JMP2? POP2 + ,$hor ~Screen.x ~rect.x2 LTH2 JMP2? ~rect.y1 =Screen.y $ver ( draw ) ~rect.x1 =Screen.x ~color =Screen.color ( draw ) ~rect.x2 =Screen.x ~color =Screen.color ( incr ) ~Screen.y #0001 ADD2 =Screen.y - ,$ver ~Screen.y ~rect.y2 #0001 ADD2 LTH2 JMP2? POP2 + ,$ver ~Screen.y ~rect.y2 #0001 ADD2 LTH2 JMP2? RTN @@ -51,9 +51,9 @@ RTN $hor ( draw ) ~color =Screen.color ( incr ) ~Screen.x #0001 ADD2 =Screen.x - ,$hor ~Screen.x ~rect.x2 LTH2 JMP2? POP2 + ,$hor ~Screen.x ~rect.x2 LTH2 JMP2? ( incr ) ~Screen.y #0001 ADD2 =Screen.y - ,$ver ~Screen.y ~rect.y2 LTH2 JMP2? POP2 + ,$ver ~Screen.y ~rect.y2 LTH2 JMP2? RTN @@ -66,9 +66,9 @@ RTN ( draw ) ~pict.color =Sprite.color ( incr ) ~Sprite.x #0008 ADD2 =Sprite.x ( incr ) ~Sprite.addr #0008 ADD2 =Sprite.addr - ,$hor ~Sprite.x ~pict.width ~pict.x ADD2 LTH2 JMP2? POP2 + ,$hor ~Sprite.x ~pict.width ~pict.x ADD2 LTH2 JMP2? ( incr ) ~Sprite.y #0008 ADD2 =Sprite.y - ,$ver ~Sprite.y ~pict.height ~pict.y ADD2 LTH2 JMP2? POP2 + ,$ver ~Sprite.y ~pict.height ~pict.y ADD2 LTH2 JMP2? RTN @@ -79,7 +79,7 @@ RTN ( draw ) DUP2 LDR #00 SWP #0008 MUL2 ,font ADD2 =Sprite.addr ~label.color =Sprite.color ( incr ) #0001 ADD2 ( incr ) ~Sprite.x #0008 ADD2 =Sprite.x - DUP2 LDR #00 NEQ ,$loop ROT JMP2? POP2 + DUP2 LDR #00 NEQ ,$loop ROT JMP2? POP2 RTN diff --git a/projects/examples/win.editor.usm b/projects/examples/win.editor.usm @@ -1,233 +0,0 @@ -( app/hex ) - -;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 } -;addr { short 2 } - -|0100 @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 - - ,no-ctrl ~Controller.buttons #00 EQU JMP2? POP2 - - ,no-ctrl-up ~Controller.buttons #10 EQU JMP2? POP2 - ~editor.addr #0001 ADD2 =editor.addr - ,draw-window JSR2 - ,draw-editor JSR2 - @no-ctrl-up - - ,no-ctrl-down ~Controller.buttons #20 EQU JMP2? POP2 - ~editor.addr #0001 SUB2 =editor.addr - ,draw-window JSR2 - ,draw-editor JSR2 - @no-ctrl-down - - @no-ctrl - - ,no-click ~Mouse.state #00 EQU JMP2? POP2 - - ( load ) ~editor.addr ~Mouse.y ~editor.y1 SUB2 #0008 DIV2 ADD2 LDR - ( mask ) #01 #07 ~Mouse.x ~editor.x1 SUB2 #0008 DIV2 SWP POP SUB ROL - XOR - ( save ) ~editor.addr ~Mouse.y ~editor.y1 SUB2 #0008 DIV2 ADD2 STR - - ,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 LDR #07 ~pixel.x SUB ROR #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 - ,$hor ~Sprite.x ~editor.x1 #0040 ADD2 LTH2 JMP2? POP2 - ( incr ) ~Sprite.y #0008 ADD2 =Sprite.y - ( incr ) ~pixel.y #01 ADD =pixel.y - ,$ver ~Sprite.y ~editor.y1 #0040 ADD2 LTH2 JMP2? POP2 - ~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 LDR #00 SWP #0008 MUL2 ,font ADD2 =Sprite.addr ~label.color =Sprite.color - ( incr ) #0001 ADD2 - ( incr ) ~Sprite.x #0007 ADD2 =Sprite.x - DUP2 LDR #00 NEQ ^$loop MUL JMPS - 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 JMPS - ( incr ) ~Screen.y #0001 ADD2 =Screen.y - ~Screen.y ~rect.y2 LTH2 ^$ver MUL JMPS - -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 JMPS - ~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 JMPS - -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 JMPS - ( incr ) ~Sprite.y #0008 ADD2 =Sprite.y - ~Sprite.y ~rect.y2 LTH2 ^$ver MUL JMPS - -RTN - -@draw-cursor - - ~pointer.x ~Mouse.x NEQU2 - ~pointer.y ~Mouse.y NEQU2 - - #0000 EQU2 BRK? ( Return if unchanged ) - - ( 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 -] - -|d000 @ERROR BRK - -|FF10 ;Screen { width 2 height 2 pad 4 x 2 y 2 color 1 } -|FF20 ;Sprite { pad 8 x 2 y 2 addr 2 color 1 } -|FF30 ;Controller { buttons 1 } -|FF50 ;Mouse { x 2 y 2 state 1 chord 1 } - -|FFF0 .RESET .FRAME .ERROR ( vectors ) -|FFF8 [ 0fcf 0fc4 0fc4 ] ( palette ) -\ No newline at end of file diff --git a/projects/software/left.usm b/projects/software/left.usm @@ -46,62 +46,62 @@ BRK ( ctrl ) - ,ctrl-end ~Controller #00 EQU ~lock #00 NEQ #0000 NEQ2 JMP2? POP2 + ,ctrl-end ~Controller #00 EQU ~lock #00 NEQ #0000 NEQ2 JMP2? ( lock ) #04 =lock - ,no-ctrl-up ~Controller #10 NEQ JMP2? POP2 - ( clamp ) ,no-ctrl-up ~position.y #0000 EQU2 JMP2? POP2 + ,no-ctrl-up ~Controller #10 NEQ JMP2? + ( clamp ) ,no-ctrl-up ~position.y #0000 EQU2 JMP2? ,find-lineoffset JSR2 =position.x ~position.y #0001 SUB2 =position.y ,find-selection JSR2 DUP2 =selection.from #0001 ADD2 =selection.to ,clamp-selection JSR2 ,follow-selection JSR2 ,redraw JSR2 ,ctrl-end JMP2 @no-ctrl-up - ,no-ctrl-down ~Controller #20 NEQ JMP2? POP2 + ,no-ctrl-down ~Controller #20 NEQ JMP2? ,find-lineoffset JSR2 =position.x ~position.y #0001 ADD2 =position.y ,find-selection JSR2 DUP2 =selection.from #0001 ADD2 =selection.to ,clamp-selection JSR2 ,follow-selection JSR2 ,redraw JSR2 ,ctrl-end JMP2 @no-ctrl-down - ,no-ctrl-left ~Controller #40 NEQ JMP2? POP2 - ( clamp ) ,no-ctrl-left ~selection.from ,document.body EQU2 JMP2? POP2 + ,no-ctrl-left ~Controller #40 NEQ JMP2? + ( clamp ) ,no-ctrl-left ~selection.from ,document.body EQU2 JMP2? ~selection.from #0001 SUB2 DUP2 =selection.from #0001 ADD2 =selection.to ,clamp-selection JSR2 ,follow-selection JSR2 ,redraw JSR2 ,ctrl-end JMP2 @no-ctrl-left - ,no-ctrl-right ~Controller #80 NEQ JMP2? POP2 + ,no-ctrl-right ~Controller #80 NEQ JMP2? ~selection.from #0001 ADD2 DUP2 =selection.from #0001 ADD2 =selection.to ,clamp-selection JSR2 ,follow-selection JSR2 ,redraw JSR2 ,ctrl-end JMP2 @no-ctrl-right ( alt ) - ,no-alt ~Controller #0f AND #02 NEQ JMP2? POP2 - ,no-aup ~Controller #04 ROR #01 NEQ JMP2? POP2 + ,no-alt ~Controller #0f AND #02 NEQ JMP2? + ,no-aup ~Controller #04 ROR #01 NEQ JMP2? ,find-wordstart JSR2 =selection.to ,clamp-selection JSR2 ,redraw JSR2 ,ctrl-end JMP2 @no-aup - ,no-adown ~Controller #04 ROR #02 NEQ JMP2? POP2 + ,no-adown ~Controller #04 ROR #02 NEQ JMP2? ,find-wordend JSR2 =selection.to ,clamp-selection JSR2 ,redraw JSR2 ,ctrl-end JMP2 @no-adown - ,no-aleft ~Controller #04 ROR #04 NEQ JMP2? POP2 + ,no-aleft ~Controller #04 ROR #04 NEQ JMP2? ~selection.to #0001 SUB2 =selection.to ,clamp-selection JSR2 ,redraw JSR2 ,ctrl-end JMP2 @no-aleft - ,no-aright ~Controller #04 ROR #08 NEQ JMP2? POP2 + ,no-aright ~Controller #04 ROR #08 NEQ JMP2? ~selection.to #0001 ADD2 =selection.to ,clamp-selection JSR2 ,redraw JSR2 ,ctrl-end JMP2 @no-aright @no-alt ( ctrl ) - ,no-ctrl ~Controller #0f AND #01 NEQ JMP2? POP2 - ,no-cup ~Controller #04 ROR #01 NEQ JMP2? POP2 + ,no-ctrl ~Controller #0f AND #01 NEQ JMP2? + ,no-cup ~Controller #04 ROR #01 NEQ JMP2? #0004 ,scroll-up JSR2 ,redraw JSR2 ,ctrl-end JMP2 @no-cup - ,no-cdown ~Controller #04 ROR #02 NEQ JMP2? POP2 + ,no-cdown ~Controller #04 ROR #02 NEQ JMP2? #0004 ,scroll-down JSR2 ,redraw JSR2 ,ctrl-end JMP2 @no-cdown - ,no-cleft ~Controller #04 ROR #04 NEQ JMP2? POP2 + ,no-cleft ~Controller #04 ROR #04 NEQ JMP2? ,goto-linestart JSR2 ,redraw JSR2 ,ctrl-end JMP2 @no-cleft - ,no-cright ~Controller #04 ROR #08 NEQ JMP2? POP2 + ,no-cright ~Controller #04 ROR #08 NEQ JMP2? ,goto-lineend JSR2 ,redraw JSR2 ,ctrl-end JMP2 @no-cright @no-ctrl @@ -110,11 +110,11 @@ BRK ( keys ) - ,no-keys ~Keys #00 EQU JMP2? POP2 + ,no-keys ~Keys #00 EQU JMP2? - ,$no-backspace ~Keys #08 NEQ JMP2? POP2 + ,$no-backspace ~Keys #08 NEQ JMP2? ( erase ) - ,$erase-multiple ~selection.to ~selection.from SUB2 #0001 NEQ2 JMP2? POP2 + ,$erase-multiple ~selection.to ~selection.from SUB2 #0001 NEQ2 JMP2? ~selection.to ~selection.from SUB2 ,shift-left JSR2 ,$erase-end JMP2 $erase-multiple @@ -139,28 +139,28 @@ BRK ( mouse ) - ,no-change ~Mouse.state ~touch.state EQU JMP2? POP2 + ,no-change ~Mouse.state ~touch.state EQU JMP2? #0000 =Sprite.x ~Screen.height #0008 SUB2 =Sprite.y ,mouse00icn =Sprite.addr - ,nobutton1 ~Mouse.state #01 NEQ JMP2? POP2 ,mouse01icn =Sprite.addr @nobutton1 - ,nobutton2 ~Mouse.state #10 NEQ JMP2? POP2 ,mouse10icn =Sprite.addr @nobutton2 - ,nobutton3 ~Mouse.state #11 NEQ JMP2? POP2 ,mouse11icn =Sprite.addr @nobutton3 + ,nobutton1 ~Mouse.state #01 NEQ JMP2? ,mouse01icn =Sprite.addr @nobutton1 + ,nobutton2 ~Mouse.state #10 NEQ JMP2? ,mouse10icn =Sprite.addr @nobutton2 + ,nobutton3 ~Mouse.state #11 NEQ JMP2? ,mouse11icn =Sprite.addr @nobutton3 #01 =Sprite.color @no-change - ,touch-end ~Mouse.state #00 EQU JMP2? POP2 + ,touch-end ~Mouse.state #00 EQU JMP2? - ,touch-linebar ~Mouse.x #0010 LTH2 JMP2? POP2 - ,touch-body ~Mouse.x ~Screen.width #0008 SUB2 LTH2 JMP2? POP2 + ,touch-linebar ~Mouse.x #0010 LTH2 JMP2? + ,touch-body ~Mouse.x ~Screen.width #0008 SUB2 LTH2 JMP2? ,touch-scrollbar JMP2 @touch-end ~Mouse.state =touch.state - ( unlock ) ,skip-unlock ~lock #00 EQU JMP2? POP2 ~lock #01 SUB =lock @skip-unlock + ( unlock ) ,skip-unlock ~lock #00 EQU JMP2? ~lock #01 SUB =lock @skip-unlock ,draw-cursor JSR2 @@ -168,11 +168,11 @@ BRK @touch-scrollbar - ,$no-up ~Mouse.y #0008 GTH2 JMP2? POP2 + ,$no-up ~Mouse.y #0008 GTH2 JMP2? ( decr ) ~scroll.y #00 ~scroll.y #0000 NEQ2 SUB2 =scroll.y ^$end JMPS $no-up - ,$no-down ~Mouse.y ~Screen.height #0008 SUB2 LTH2 JMP2? POP2 + ,$no-down ~Mouse.y ~Screen.height #0008 SUB2 LTH2 JMP2? ( incr ) ~scroll.y #0001 ADD2 =scroll.y ^$end JMPS $no-down @@ -197,20 +197,20 @@ RTN ~Mouse.y #0008 DIV2 ~scroll.y ADD2 =position.y ~Mouse.x ~textarea.x1 SUB2 #0007 ADD2 #0007 DIV2 =position.x - ,$no-chord-cut ~Mouse.chord #01 NEQ JMP2? POP2 + ,$no-chord-cut ~Mouse.chord #01 NEQ JMP2? ,cut JSR2 ( release ) #00 DUP =Mouse.state =Mouse.chord ^$end JMPS $no-chord-cut - ,$no-chord-paste ~Mouse.chord #10 NEQ JMP2? POP2 + ,$no-chord-paste ~Mouse.chord #10 NEQ JMP2? ,paste JSR2 ( release ) #00 DUP =Mouse.state =Mouse.chord ^$end JMPS $no-chord-paste - ,$end ~Mouse.state #11 EQU JMP2? POP2 + ,$end ~Mouse.state #11 EQU JMP2? - ,$no-drag ~Mouse.state ~touch.state NEQ ~Controller #0f AND #02 NEQ #0101 EQU2 JMP2? POP2 + ,$no-drag ~Mouse.state ~touch.state NEQ ~Controller #0f AND #02 NEQ #0101 EQU2 JMP2? ( on drag ) ,find-selection JSR2 #0001 ADD2 =selection.to ,clamp-selection JSR2 @@ -237,7 +237,7 @@ RTN @scroll-up ( length ) - DUP2 ~scroll.y LTH2 ,$clamp ROT JMP2? POP2 + DUP2 ~scroll.y LTH2 ,$clamp ROT JMP2? #0000 =scroll.y POP2 RTN $clamp ~scroll.y SWP2 SUB2 =scroll.y @@ -277,10 +277,10 @@ RTN @follow-selection - ,$no-up ~position.y ~scroll.y GTH2 JMP2? POP2 + ,$no-up ~position.y ~scroll.y GTH2 JMP2? ~position.y =scroll.y RTN $no-up - ,$no-down ~position.y ~Screen.height #0010 SUB2 #0008 DIV2 ~scroll.y ADD2 LTH2 JMP2? POP2 + ,$no-down ~position.y ~Screen.height #0010 SUB2 #0008 DIV2 ~scroll.y ADD2 LTH2 JMP2? ~position.y ~Screen.height #0010 SUB2 #0008 DIV2 SUB2 =scroll.y RTN $no-down @@ -324,9 +324,9 @@ RTN ~selection.to =j $loop NOP ( decr ) ~j #0001 SUB2 =j - ,$end ~j LDR #20 EQU JMP2? POP2 - ,$end ~j LDR #0a EQU JMP2? POP2 - ,$end ~j LDR #0d EQU JMP2? POP2 + ,$end ~j LDR #20 EQU JMP2? + ,$end ~j LDR #0a EQU JMP2? + ,$end ~j LDR #0d EQU JMP2? ~j ,document.body GTH2 ^$loop MUL JMPS $end ( return ) ~j #0001 SUB2 @@ -338,9 +338,9 @@ RTN ~selection.to =j $loop NOP ( incr ) ~j #0001 ADD2 =j - ,$end ~j LDR #20 EQU JMP2? POP2 - ,$end ~j LDR #0a EQU JMP2? POP2 - ,$end ~j LDR #0d EQU JMP2? POP2 + ,$end ~j LDR #20 EQU JMP2? + ,$end ~j LDR #0a EQU JMP2? + ,$end ~j LDR #0d EQU JMP2? ~j ,document.body GTH2 ^$loop MUL JMPS $end ( return ) ~j #0001 ADD2 @@ -352,8 +352,8 @@ RTN #0000 =j $loop NOP ( incr ) ~j #0001 ADD2 =j - ,$end ~selection.from ~j SUB2 LDR #0a EQU JMP2? POP2 - ,$end ~selection.from ~j SUB2 LDR #0d EQU JMP2? POP2 + ,$end ~selection.from ~j SUB2 LDR #0a EQU JMP2? + ,$end ~selection.from ~j SUB2 LDR #0d EQU JMP2? ~selection.from ~j SUB2 ,document.body GTH2 ^$loop MUL JMPS $end ( return ) ~j @@ -364,8 +364,8 @@ RTN ,document.body =j #0000 =pt.y $loop NOP - ,$end ~pt.y ~position.y #0001 SUB2 GTH2 JMP2? POP2 - ,$no-space ~j LDR #0a NEQ ~j LDR #0d NEQ #0101 EQU2 JMP2? POP2 + ,$end ~pt.y ~position.y #0001 SUB2 GTH2 JMP2? + ,$no-space ~j LDR #0a NEQ ~j LDR #0d NEQ #0101 EQU2 JMP2? ( incr ) ~pt.y #0001 ADD2 =pt.y $no-space ( incr ) ~j #0001 ADD2 =j @@ -380,8 +380,8 @@ RTN ,find-line JSR2 ( find line ) #0000 =pt.x $loop NOP - ,$end ~j ~pt.x ADD2 LDR #0a EQU JMP2? POP2 - ,$end ~j ~pt.x ADD2 LDR #0d EQU JMP2? POP2 + ,$end ~j ~pt.x ADD2 LDR #0a EQU JMP2? + ,$end ~j ~pt.x ADD2 LDR #0d EQU JMP2? ( incr ) ~pt.x #0001 ADD2 =pt.x ~pt.x ~position.x #0001 SUB2 LTH2 ^$loop MUL JMPS $end @@ -425,17 +425,17 @@ RTN ,document.body =selection.from #0000 =pt.x #0000 =pt.y $loop - ,$no-space ~selection.from LDR #0a NEQ ~selection.from LDR #0d NEQ #0101 EQU2 JMP2? POP2 + ,$no-space ~selection.from LDR #0a NEQ ~selection.from LDR #0d NEQ #0101 EQU2 JMP2? ( incr ) ~pt.y #0001 ADD2 =pt.y #0000 =pt.x $no-space - ,$no-reached ~pt.y ~position.y #0001 SUB2 GTH2 ~pt.x ~position.x #0001 SUB2 GTH2 #0101 NEQ2 JMP2? POP2 + ,$no-reached ~pt.y ~position.y #0001 SUB2 GTH2 ~pt.x ~position.x #0001 SUB2 GTH2 #0101 NEQ2 JMP2? ~selection.from #0001 ADD2 =selection.to RTN $no-reached ( incr ) ~pt.x #0001 ADD2 =pt.x ( incr ) ~selection.from #0001 ADD2 =selection.from - ,$loop ~selection.from LDR #00 NEQ JMP2? POP2 + ,$loop ~selection.from LDR #00 NEQ JMP2? RTN @@ -507,8 +507,8 @@ RTN ( scroll to position ) #0000 =j ( j is linebreaks ) $find-offset NOP - ,$find-offset-end ~scroll.y ~j EQU2 JMP2? POP2 - ,$no-break ~textarea.addr LDR #0a NEQ ~textarea.addr LDR #0d NEQ #0101 EQU2 JMP2? POP2 + ,$find-offset-end ~scroll.y ~j EQU2 JMP2? + ,$no-break ~textarea.addr LDR #0a NEQ ~textarea.addr LDR #0d NEQ #0101 EQU2 JMP2? ( incr ) ~j #0001 ADD2 =j $no-break ( incr ) ~textarea.addr #0001 ADD2 =textarea.addr @@ -520,7 +520,7 @@ RTN $loop - ,$end ~Sprite.y ~Screen.height #0010 SUB2 GTH2 JMP2? POP2 + ,$end ~Sprite.y ~Screen.height #0010 SUB2 GTH2 JMP2? ( get character ) ,font #00 ~i LDR #20 SUB #0008 MUL2 ADD2 =Sprite.addr @@ -530,7 +530,7 @@ RTN ~i ~selection.to LTH2 #0101 EQU2 #05 MUL ADD ~i ~selection.from EQU2 ADD =Sprite.color - ,$no-linebreak ~i LDR #0a NEQ ~i LDR #0d NEQ #0101 EQU2 JMP2? POP2 + ,$no-linebreak ~i LDR #0a NEQ ~i LDR #0d NEQ #0101 EQU2 JMP2? ( draw linebreak ) ,linebreak_icn =Sprite.addr ( draw ) #02 @@ -542,7 +542,7 @@ RTN ( incr ) ~Sprite.x #0008 ADD2 =Sprite.x ,font =Sprite.addr #01 =Sprite.color - ,$fill-clear ~Sprite.x ~Screen.width #0008 SUB2 LTH2 JMP2? POP2 + ,$fill-clear ~Sprite.x ~Screen.width #0008 SUB2 LTH2 JMP2? ( draw line number ) @@ -562,7 +562,7 @@ RTN ( incr ) ~i #0001 ADD2 =i ( incr ) ~Sprite.x #0007 ADD2 =Sprite.x - ,$loop ~i LDR #00 NEQ JMP2? POP2 + ,$loop ~i LDR #00 NEQ JMP2? $end diff --git a/projects/software/nasu.usm b/projects/software/nasu.usm @@ -34,28 +34,28 @@ BRK ( keyboard controls ) - ,no-key ~KEYS #00 EQU JMP2? POP2 + ,no-key ~KEYS #00 EQU JMP2? - ,no-key ~KEYS #31 LTH JMP2? POP2 - ,no-key ~KEYS #33 GTH JMP2? POP2 + ,no-key ~KEYS #31 LTH JMP2? + ,no-key ~KEYS #33 GTH JMP2? ( select ) ~KEYS #31 SUB =bankview.mode ( release ) #00 =KEYS ,redraw JSR2 @no-key - ,no-ctrl ~CTRL.buttons #00 EQU JMP2? POP2 + ,no-ctrl ~CTRL.buttons #00 EQU JMP2? - ,no-ctrl-up ~CTRL.buttons #10 EQU JMP2? POP2 + ,no-ctrl-up ~CTRL.buttons #10 EQU JMP2? ~tileview.addr #0080 ADD2 =tileview.addr @no-ctrl-up - ,no-ctrl-down ~CTRL.buttons #20 EQU JMP2? POP2 + ,no-ctrl-down ~CTRL.buttons #20 EQU JMP2? ~tileview.addr #0080 SUB2 =tileview.addr @no-ctrl-down - ,no-ctrl-left ~CTRL.buttons #40 EQU JMP2? POP2 + ,no-ctrl-left ~CTRL.buttons #40 EQU JMP2? ~tileview.addr #0008 ADD2 =tileview.addr @no-ctrl-left - ,no-ctrl-right ~CTRL.buttons #80 EQU JMP2? POP2 + ,no-ctrl-right ~CTRL.buttons #80 EQU JMP2? ~tileview.addr #0008 SUB2 =tileview.addr @no-ctrl-right ~tileview.addr #0800 DIV2 #0800 MUL2 =bankview.addr @@ -65,28 +65,28 @@ BRK ( mouse controls ) - ,click-end ~MOUS.state #00 EQU JMP2? POP2 + ,click-end ~MOUS.state #00 EQU JMP2? ( toolbar ) - ,no-toolbar-click ~MOUS.y ~bankview.y #0010 SUB2 SUB2 #0008 DIV2 #0000 NEQ2 JMP2? POP2 + ,no-toolbar-click ~MOUS.y ~bankview.y #0010 SUB2 SUB2 #0008 DIV2 #0000 NEQ2 JMP2? ( brush ) - ,no-brush-click ~MOUS.x ~bankview.x SUB2 #0008 DIV2 #000d LTH2 JMP2? POP2 - ,no-brush-click ~MOUS.x ~bankview.x SUB2 #0008 DIV2 #000f GTH2 JMP2? POP2 + ,no-brush-click ~MOUS.x ~bankview.x SUB2 #0008 DIV2 #000d LTH2 JMP2? + ,no-brush-click ~MOUS.x ~bankview.x SUB2 #0008 DIV2 #000f GTH2 JMP2? ( select ) ~mouse.x ~bankview.x SUB2 #0008 DIV2 #000d SUB2 SWP POP =bankview.mode ( release ) #00 =MOUS.state ,redraw JSR2 ,click-end JMP2 @no-brush-click - ,no-load-click ~MOUS.x ~tileview.x SUB2 #0008 DIV2 #000e NEQU2 JMP2? POP2 + ,no-load-click ~MOUS.x ~tileview.x SUB2 #0008 DIV2 #000e NEQU2 JMP2? ( load ) ,filename =FILE.name #0800 =FILE.length ~bankview.addr =FILE.load ( release ) #00 =MOUS.state ,redraw JSR2 ,click-end JMP2 @no-load-click - ,no-save-click ~MOUS.x ~tileview.x SUB2 #0008 DIV2 #000f NEQU2 JMP2? POP2 + ,no-save-click ~MOUS.x ~tileview.x SUB2 #0008 DIV2 #000f NEQU2 JMP2? ( save ) ,filename =FILE.name #0800 =FILE.length ~bankview.addr =FILE.save ( release ) #00 =MOUS.state ,redraw JSR2 ,click-end JMP2 @@ -98,9 +98,9 @@ BRK ~MOUS.x ~bankview.x GTH2 ~MOUS.x ~bankview.x #0080 ADD2 LTH2 #0101 EQU2 ~MOUS.y ~bankview.y GTH2 ~MOUS.y ~bankview.y #0080 ADD2 LTH2 #0101 EQU2 - #0101 NEQ2 ,no-bank-click ROT JMP2? POP2 + #0101 NEQ2 ,no-bank-click ROT JMP2? - ,not-copy-mode ~bankview.mode #01 NEQ JMP2? POP2 + ,not-copy-mode ~bankview.mode #01 NEQ JMP2? #00 =i @copy-loop NOP ( load ) ~tileview.addr ~i ADD LDR @@ -113,7 +113,7 @@ BRK ,redraw JSR2 ,click-end JMP2 @not-copy-mode - ,not-erase-mode ~bankview.mode #02 NEQ JMP2? POP2 + ,not-erase-mode ~bankview.mode #02 NEQ JMP2? #00 =i @erase-loop NOP #00 @@ -137,7 +137,7 @@ BRK ~MOUS.x ~tileview.x GTH2 ~MOUS.x ~tileview.x #0080 ADD2 LTH2 #0101 EQU2 ~MOUS.y ~tileview.y GTH2 ~MOUS.y ~tileview.y #0080 ADD2 LTH2 #0101 EQU2 - #0101 NEQ2 ,no-tile-click ROT JMP2? POP2 + #0101 NEQ2 ,no-tile-click ROT JMP2? ~MOUS.x ~tileview.x SUB2 #0008 DIV2 #0008 MUL2 #0040 DIV2 ~MOUS.y ~tileview.y SUB2 #0008 DIV2 #0008 MUL2 #0040 DIV2 #0002 MUL2 ADD2 @@ -145,11 +145,11 @@ BRK ~tileview.addr ADD2 =addr ( addr offset ) ~MOUS.x ~tileview.x SUB2 ~MOUS.x ~tileview.x SUB2 #0040 DIV2 #0040 MUL2 SUB2 =pos.x ~MOUS.y ~tileview.y SUB2 ~MOUS.y ~tileview.y SUB2 #0040 DIV2 #0040 MUL2 SUB2 =pos.y - ,no-fill-mode ~bankview.mode #01 NEQ JMP2? POP2 + ,no-fill-mode ~bankview.mode #01 NEQ JMP2? ( fill row ) #ff ~addr ~pos.y #0008 DIV2 ADD2 STR ,redraw JSR2 ,click-end JMP2 @no-fill-mode - ,no-erase-mode ~bankview.mode #02 NEQ JMP2? POP2 + ,no-erase-mode ~bankview.mode #02 NEQ JMP2? ( erase row ) #00 ~addr ~pos.y #0008 DIV2 ADD2 STR ,redraw JSR2 ,click-end JMP2 @no-erase-mode @@ -163,15 +163,15 @@ BRK ( operations ) - ,no-operations ~MOUS.y ~tileview.y SUB2 #0008 DIV2 #000c NEQ2 JMP2? POP2 + ,no-operations ~MOUS.y ~tileview.y SUB2 #0008 DIV2 #000c NEQ2 JMP2? - ,no-move-up ~MOUS.x ~tileview.x SUB2 #0008 DIV2 #0011 NEQ2 JMP2? POP2 + ,no-move-up ~MOUS.x ~tileview.x SUB2 #0008 DIV2 #0011 NEQ2 JMP2? ,op_shiftup JSR2 ( release ) #00 =MOUS.state ,redraw JSR2 ,click-end JMP2 @no-move-up - ,no-move-down ~MOUS.x ~tileview.x SUB2 #0008 DIV2 #0012 NEQ2 JMP2? POP2 + ,no-move-down ~MOUS.x ~tileview.x SUB2 #0008 DIV2 #0012 NEQ2 JMP2? ,op_shiftdown JSR2 ( release ) #00 =MOUS.state ,redraw JSR2 ,click-end JMP2 @@ -265,7 +265,7 @@ RTN ( draw ) #02 =SPRT.color ~SPRT.addr #0008 ADD2 =SPRT.addr ( incr ) ~i #01 ADD =i - ,$guides ~i #10 LTH JMP2? POP2 + ,$guides ~i #10 LTH JMP2? ( body ) @@ -276,17 +276,17 @@ RTN ~bankview.x =SPRT.x $hor ( draw ) #01 =SPRT.color - ,$no-highlight ~SPRT.addr ~tileview.addr LTH2 JMP2? POP2 - ,$no-highlight ~SPRT.addr ~tileview.addr #0018 ADD2 GTH2 JMP2? POP2 + ,$no-highlight ~SPRT.addr ~tileview.addr LTH2 JMP2? + ,$no-highlight ~SPRT.addr ~tileview.addr #0018 ADD2 GTH2 JMP2? ( draw ) #0c =SPRT.color $no-highlight ( incr ) ~SPRT.x #0008 ADD2 =SPRT.x ( incr ) ~SPRT.addr #0008 ADD2 =SPRT.addr ( incr ) ~pt.x #01 ADD =pt.x - ,$hor ~pt.x #10 LTH JMP2? POP2 + ,$hor ~pt.x #10 LTH JMP2? ( incr ) ~pt.y #01 ADD =pt.y ( incr ) ~SPRT.y #0008 ADD2 =SPRT.y - ,$ver ~pt.y #10 LTH JMP2? POP2 + ,$ver ~pt.y #10 LTH JMP2? RTN @@ -333,7 +333,7 @@ RTN $line-hor ( draw ) #03 =SCRN.color ( incr ) ~SCRN.x #0002 ADD2 =SCRN.x - ~SCRN.x ~tileview.x #0082 ADD2 LTH2 ,$line-hor ROT JMP2? POP2 + ~SCRN.x ~tileview.x #0082 ADD2 LTH2 ,$line-hor ROT JMP2? ( line ver ) ~tileview.y =SCRN.y @@ -341,7 +341,7 @@ RTN $line-ver ( draw ) #03 =SCRN.color ( incr ) ~SCRN.y #0002 ADD2 =SCRN.y - ~SCRN.y ~tileview.y #0081 ADD2 LTH2 ,$line-ver ROT JMP2? POP2 + ~SCRN.y ~tileview.y #0081 ADD2 LTH2 ,$line-ver ROT JMP2? ( rewind ) ~tileview.addr #0018 SUB2 =tileview.addr @@ -358,7 +358,7 @@ RTN ( draw ) #02 =SPRT.color ( incr ) ~i #01 ADD =i ( incr ) ~SPRT.y #0008 ADD2 =SPRT.y - ,$bytes ~i #08 LTH JMP2? POP2 + ,$bytes ~i #08 LTH JMP2? ( operations ) @@ -381,10 +381,10 @@ RTN ( incr ) ~SPRT.x #0008 ADD2 =SPRT.x ( incr ) ~SPRT.addr #0008 ADD2 =SPRT.addr ( incr ) ~pt.x #01 ADD =pt.x - ,$tiles-hor ~pt.x #02 LTH JMP2? POP2 + ,$tiles-hor ~pt.x #02 LTH JMP2? ( incr ) ~pt.y #01 ADD =pt.y ( incr ) ~SPRT.y #0008 ADD2 =SPRT.y - ,$tiles-ver ~pt.y #02 LTH JMP2? POP2 + ,$tiles-ver ~pt.y #02 LTH JMP2? RTN @@ -401,11 +401,11 @@ RTN ( draw ) #01 =SPRT.color ( incr ) ~SPRT.x #0008 ADD2 =SPRT.x ( incr ) ~pt.x #01 ADD =pt.x - ,$hor ~pt.x #08 LTH JMP2? POP2 + ,$hor ~pt.x #08 LTH JMP2? ( incr ) ~SPRT.y #0008 ADD2 =SPRT.y ( incr ) ~pt.y #01 ADD =pt.y ~SPRT.x #0040 SUB2 =SPRT.x - ,$ver ~pt.y #08 LTH JMP2? POP2 + ,$ver ~pt.y #08 LTH JMP2? RTN diff --git a/projects/tests/cond.usm b/projects/tests/cond.usm @@ -0,0 +1,24 @@ +( tests/cond ) + +|0100 @RESET + + #00 #d0 + $loop NOP + ( incr ) SWP #01 ADD SWP + DUP2 LTH ^$loop SWP JMPS? + POP =Console.byte + +BRK + +@routine + + +RTN + +|c000 @FRAME +|d000 @ERROR + +|FF00 ;Console { pad 8 char 1 byte 1 short 2 } + +|FFF0 .RESET .FRAME .ERROR ( vectors ) +|FFF8 [ 13fd 1ef3 1bf2 ] ( palette ) +\ No newline at end of file diff --git a/projects/tests/jump.usm b/projects/tests/jump.usm @@ -23,7 +23,7 @@ BRK #33 =Console.byte - ,skip1 #12 #34 LTH JMP2? POP2 + ,skip1 #12 #34 LTH JMP2? #ff =Console.byte @skip1 diff --git a/projects/tests/loop.usm b/projects/tests/loop.usm @@ -25,7 +25,7 @@ RTN $loop ~b #01 ADD =b - ,$loop ~b #d0 LTH JMP2? POP2 + ,$loop ~b #d0 LTH JMP2? ~b =Console.byte RTN @@ -34,7 +34,7 @@ RTN $loop NOP ~c #01 ADD =c - ~c #d0 LTH ^$loop SWP JMPS? POP + ~c #d0 LTH ^$loop SWP JMPS? ~c =Console.byte RTN @@ -44,7 +44,7 @@ RTN #00 #d0 $loop NOP ( incr ) SWP #01 ADD SWP - DUP2 LTH ^$loop SWP JMPS? POP + DUP2 LTH ^$loop SWP JMPS? POP =Console.byte RTN @@ -54,7 +54,7 @@ RTN #0000 #0d00 $loop NOP ( incr ) SWP2 #0001 ADD2 SWP2 - OVR2 OVR2 LTH2 ^$loop SWP JMPS? POP + OVR2 OVR2 LTH2 ^$loop SWP JMPS? POP2 =Console.short RTN diff --git a/uxn.c b/uxn.c @@ -138,13 +138,14 @@ lituxn(Uxn *u, Uint8 instr) int opcuxn(Uxn *u, Uint8 instr) { - Uint8 op = instr & 0x1f; + Uint8 op = instr & 0x1f, fcond; setflag(&u->status, FLAG_SHORT, (instr >> 5) & 1); setflag(&u->status, FLAG_SIGN, (instr >> 6) & 1); setflag(&u->status, FLAG_COND, (instr >> 7) & 1); + fcond = getflag(&u->status, FLAG_COND); if(getflag(&u->status, FLAG_SHORT)) op += 32; - if(u->wst.ptr < opr[op][0]) + if(u->wst.ptr < opr[op][0] || (fcond && u->wst.ptr < 1)) return haltuxn(u, "Working-stack underflow", op); if(u->wst.ptr + opr[op][1] - opr[op][0] >= 255) return haltuxn(u, "Working-stack overflow", instr); @@ -152,8 +153,10 @@ opcuxn(Uxn *u, Uint8 instr) return haltuxn(u, "Return-stack underflow", op); if(u->rst.ptr + opr[op][3] - opr[op][2] >= 255) return haltuxn(u, "Return-stack overflow", instr); - if(!getflag(&u->status, FLAG_COND) || (getflag(&u->status, FLAG_COND) && pop8(&u->wst))) + if(!fcond || (fcond && pop8(&u->wst))) (*ops[op])(u); + else if(opr[op][0] >= opr[op][1]) + u->wst.ptr -= opr[op][0] - opr[op][1]; return 1; }