uxn

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

commit 5dc0245c9ec0863e86cb08e86828bcf6c80439c4
parent 6bd58375f71cec3250e2637d104f2831a131b9ca
Author: neauoire <aliceffekt@gmail.com>
Date:   Tue,  6 Apr 2021 10:45:53 -0700

Optimization on noodle

Diffstat:
MREADME.md | 10++--------
Mbuild.sh | 2+-
Mprojects/examples/dev.console.usm | 3+--
Mprojects/examples/dev.controller.usm | 7+------
Mprojects/examples/dev.keys.usm | 7-------
Mprojects/examples/dev.mouse.usm | 21++++++++++-----------
Mprojects/examples/dev.screen.usm | 122++++++++++++++++++++++++++++++++++++++++----------------------------------------
Mprojects/examples/dev.time.usm | 4----
Mprojects/software/noodle.usm | 143++++++++++++++++++++++++++++++++++++++++++++-----------------------------------
9 files changed, 156 insertions(+), 163 deletions(-)

diff --git a/README.md b/README.md @@ -26,14 +26,11 @@ Read more in the [Uxambly Guide](https://wiki.xxiivv.com/site/uxambly.html). ( devices ) -|0100 ;Console { pad 8 char 1 byte 1 short 2 } -|0200 ^RESET JMP -|0204 ,ERROR JMP2 -|0208 ,FRAME JMP2 +|0110 ;Console { vector 2 pad 6 char 1 byte 1 short 2 } ( program ) -@RESET +|0200 ,text1 ,print-label JSR2 ,text2 ,print-label JSR2 @@ -54,9 +51,6 @@ RTN @text1 [ Welcome 20 to 20 UxnVM 0a00 ] @text2 [ Hello 20 World 0a00 ] - -@FRAME BRK -@ERROR BRK ``` ## TODOs diff --git a/build.sh b/build.sh @@ -28,7 +28,7 @@ else fi echo "Assembling.." -./bin/assembler projects/software/nasu.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 @@ -4,12 +4,11 @@ ( devices ) -|0100 ;System { vector 2 pad 6 r 2 g 2 b 2 } |0110 ;Console { vector 2 pad 6 char 1 byte 1 short 2 } ( program ) -|0200 @RESET +|0200 ,text1 ,print-label JSR2 ,text2 ,print-label JSR2 diff --git a/projects/examples/dev.controller.usm b/projects/examples/dev.controller.usm @@ -11,16 +11,11 @@ ( devices ) |0100 ;System { vector 2 pad 6 r 2 g 2 b 2 } -|0110 ;Console { pad 8 char 1 byte 1 short 2 } |0120 ;Screen { vector 2 width 2 height 2 pad 2 x 2 y 2 color 1 } |0130 ;Sprite { vector 2 pad 6 x 2 y 2 addr 2 color 1 } |0140 ;Controller { vector 2 p1 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 } -|0180 ;Audio { ch1adsr 2 ch2adsr 2 ch3adsr 2 ch4adsr 2 ch1vol 1 ch1pitch 1 ch2vol 1 ch2pitch 1 ch3vol 1 ch3pitch 1 ch4vol 1 ch4pitch 1 } -|0200 @RESET +|0200 ( theme ) #0daf =System.r #02ff =System.g #035f =System.b ( vectors ) ,FRAME =Screen.vector diff --git a/projects/examples/dev.keys.usm b/projects/examples/dev.keys.usm @@ -3,13 +3,8 @@ %RTN { JMP2r } %8+ { #0008 ADD2 } %8* { #0030 SFT2 } -%MOD2 { #03 AND } - -;cursor { x 2 y 2 } |0100 ;System { vector 2 pad 6 r 2 g 2 b 2 } -|0110 ;Console { pad 8 char 1 byte 1 short 2 } -|0120 ;Screen { vector 2 width 2 height 2 pad 2 x 2 y 2 color 1 } |0130 ;Sprite { vector 2 pad 6 x 2 y 2 addr 2 color 1 } |0140 ;Controller { vector 2 button 1 } |0150 ;Keys { vector 2 key 1 } @@ -92,5 +87,3 @@ RTN 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 ] - -;text { body 2 } diff --git a/projects/examples/dev.mouse.usm b/projects/examples/dev.mouse.usm @@ -3,19 +3,14 @@ %RTN { JMP2r } %++ { #0001 ADD2 } %-- { #0001 SUB2 } -%8+ { #0008 ADD2 } -%ABS2 { DUP2 #000f SFT2 #ffff SWP2 SWP POP MUL2? } ;color { byte 1 } ;pointer { x 2 y 2 } ;circle { xc 2 yc 2 x 2 y 2 r 2 d 2 } |0100 ;System { vector 2 pad 6 r 2 g 2 b 2 } -|0110 ;Console { pad 8 char 1 byte 1 short 2 } |0120 ;Screen { vector 2 width 2 height 2 pad 2 x 2 y 2 color 1 } |0130 ;Sprite { vector 2 pad 6 x 2 y 2 addr 2 color 1 } -|0140 ;Controller { vector 2 button 1 } -|0150 ;Keys { vector 2 key 1 } |0160 ;Mouse { vector 2 x 2 y 2 state 1 chord 1 } ( program ) @@ -23,17 +18,24 @@ |0200 ( theme ) #03fd =System.r #0ef3 =System.g #0bf2 =System.b + ( vectors ) ,on-screen =Screen.vector ( vectors ) ,on-mouse =Mouse.vector BRK +@on-screen + + ( clear ) ~circle.xc ~circle.yc ~circle.r #00 ,draw-circle JSR2 + ( draw ) ~circle.xc ~circle.yc ~circle.r #0001 ADD2 #03 ,draw-circle JSR2 + +BRK + @on-mouse - ( clear ) - ~circle.xc ~circle.yc ~circle.r #00 ,draw-circle JSR2 - ,draw-cursor JSR2 + ( clear ) ~circle.xc ~circle.yc ~circle.r #00 ,draw-circle JSR2 + ~Mouse.state #00 EQU ^$no-touch JNZ ~Mouse.x DUP2 =circle.xc ~Mouse.y DUP2 =circle.yc @@ -41,9 +43,6 @@ BRK ( release ) #00 =Mouse.state $no-touch - ( draw ) - ~circle.xc ~circle.yc ~circle.r #0001 ADD2 #03 ,draw-circle JSR2 - BRK @draw-cursor ( -- ) diff --git a/projects/examples/dev.screen.usm b/projects/examples/dev.screen.usm @@ -22,11 +22,8 @@ } |0100 ;System { vector 2 pad 6 r 2 g 2 b 2 } -|0110 ;Console { pad 8 char 1 byte 1 short 2 } |0120 ;Screen { vector 2 width 2 height 2 pad 2 x 2 y 2 color 1 } |0130 ;Sprite { vector 2 pad 6 x 2 y 2 addr 2 color 1 } -|0140 ;Controller { vector 2 button 1 } -|0150 ;Keys { vector 2 key 1 } |0160 ;Mouse { vector 2 x 2 y 2 state 1 chord 1 } ( program ) @@ -53,6 +50,67 @@ ~Screen.width #0002 DIV2 =center.x ~Screen.height #0002 DIV2 =center.y + ,update-theme JSR2 + ,draw-background JSR2 + ,draw-window JSR2 + +BRK + +@on-mouse + + ,draw-cursor JSR2 + + ~Mouse.state #00 NEQ ,$no-skip JNZ2 BRK $no-skip + + ~Mouse.y ~window.y1 SUB2 STEP8 + + DUP2 #0010 NEQ2 ^$no-touch-red JNZ + ~Mouse.x ~window.x1 #0050 ADD2 LTH2 ^$no-touch-red JNZ + ~Mouse.x ~window.x1 #008c ADD2 GTH2 ^$no-touch-red JNZ + ( get new value ) ~Mouse.x ~window.x1 SUB2 #0050 SUB2 #0004 DIV2 S2B ,theme.r1 #00 ~selection ADD2 POK2 + $no-touch-red + DUP2 #0020 NEQ2 ^$no-touch-green JNZ + ~Mouse.x ~window.x1 #0050 ADD2 LTH2 ^$no-touch-green JNZ + ~Mouse.x ~window.x1 #008c ADD2 GTH2 ^$no-touch-green JNZ + ( get new value ) ~Mouse.x ~window.x1 SUB2 #0050 SUB2 #0004 DIV2 S2B ,theme.g1 #00 ~selection ADD2 POK2 + $no-touch-green + DUP2 #0030 NEQ2 ^$no-touch-blue JNZ + ~Mouse.x ~window.x1 #0050 ADD2 LTH2 ^$no-touch-blue JNZ + ~Mouse.x ~window.x1 #008c ADD2 GTH2 ^$no-touch-blue JNZ + ( get new value ) ~Mouse.x ~window.x1 SUB2 #0050 SUB2 #0004 DIV2 S2B ,theme.b1 #00 ~selection ADD2 POK2 + $no-touch-blue + DUP2 #0040 NEQ2 ^$no-touch-radio JNZ + ~Mouse.x ~window.x1 #0050 ADD2 LTH2 ^$no-touch-radio JNZ + ~Mouse.x ~window.x1 #008c ADD2 GTH2 ^$no-touch-radio JNZ + ~Mouse.x ~window.x1 SUB2 #0050 SUB2 STEP8 2/ #0008 DIV2 S2B =selection + $no-touch-radio + + POP2 + + ,update-theme JSR2 + ,draw-window JSR2 + +BRK + +@update-theme + + #0108 PEK2 #0f AND ~theme.r1 #40 SFT ADD #0108 POK2 + #010a PEK2 #0f AND ~theme.g1 #40 SFT ADD #010a POK2 + #010c PEK2 #0f AND ~theme.b1 #40 SFT ADD #010c POK2 + #0108 PEK2 #f0 AND ~theme.r2 ADD #0108 POK2 + #010a PEK2 #f0 AND ~theme.g2 ADD #010a POK2 + #010c PEK2 #f0 AND ~theme.b2 ADD #010c POK2 + #0109 PEK2 #0f AND ~theme.r3 #40 SFT ADD #0109 POK2 + #010b PEK2 #0f AND ~theme.g3 #40 SFT ADD #010b POK2 + #010d PEK2 #0f AND ~theme.b3 #40 SFT ADD #010d POK2 + #0109 PEK2 #f0 AND ~theme.r4 ADD #0109 POK2 + #010b PEK2 #f0 AND ~theme.g4 ADD #010b POK2 + #010d PEK2 #f0 AND ~theme.b4 ADD #010d POK2 + +RTN + +@draw-background + ( draw hor line ) #0000 =Screen.x ~center.y =Screen.y #0000 ~Screen.width ( from/to ) @@ -81,64 +139,6 @@ DUP2 LTH ^$draw-blends JNZ POP POP - ,update-theme JSR2 - ,draw-window JSR2 - -BRK - -@on-mouse - - ~Mouse.state #00 EQU ,$no-touch JNZ2 - - ~Mouse.y ~window.y1 SUB2 STEP8 - - DUP2 #0010 NEQ2 ^$no-touch-red JNZ - ~Mouse.x ~window.x1 #0050 ADD2 LTH2 ^$no-touch-red JNZ - ~Mouse.x ~window.x1 #008c ADD2 GTH2 ^$no-touch-red JNZ - ( get new value ) ~Mouse.x ~window.x1 SUB2 #0050 SUB2 #0004 DIV2 S2B ,theme.r1 #00 ~selection ADD2 POK2 - $no-touch-red - DUP2 #0020 NEQ2 ^$no-touch-green JNZ - ~Mouse.x ~window.x1 #0050 ADD2 LTH2 ^$no-touch-green JNZ - ~Mouse.x ~window.x1 #008c ADD2 GTH2 ^$no-touch-green JNZ - ( get new value ) ~Mouse.x ~window.x1 SUB2 #0050 SUB2 #0004 DIV2 S2B ,theme.g1 #00 ~selection ADD2 POK2 - $no-touch-green - DUP2 #0030 NEQ2 ^$no-touch-blue JNZ - ~Mouse.x ~window.x1 #0050 ADD2 LTH2 ^$no-touch-blue JNZ - ~Mouse.x ~window.x1 #008c ADD2 GTH2 ^$no-touch-blue JNZ - ( get new value ) ~Mouse.x ~window.x1 SUB2 #0050 SUB2 #0004 DIV2 S2B ,theme.b1 #00 ~selection ADD2 POK2 - $no-touch-blue - DUP2 #0040 NEQ2 ^$no-touch-radio JNZ - ~Mouse.x ~window.x1 #0050 ADD2 LTH2 ^$no-touch-radio JNZ - ~Mouse.x ~window.x1 #008c ADD2 GTH2 ^$no-touch-radio JNZ - ~Mouse.x ~window.x1 SUB2 #0050 SUB2 STEP8 2/ #0008 DIV2 S2B =selection - $no-touch-radio - - POP2 - - ,update-theme JSR2 - ,draw-window JSR2 - - $no-touch - - ,draw-cursor JSR2 - -BRK - -@update-theme - - #0108 PEK2 #0f AND ~theme.r1 #40 SFT ADD #0108 POK2 - #010a PEK2 #0f AND ~theme.g1 #40 SFT ADD #010a POK2 - #010c PEK2 #0f AND ~theme.b1 #40 SFT ADD #010c POK2 - #0108 PEK2 #f0 AND ~theme.r2 ADD #0108 POK2 - #010a PEK2 #f0 AND ~theme.g2 ADD #010a POK2 - #010c PEK2 #f0 AND ~theme.b2 ADD #010c POK2 - #0109 PEK2 #0f AND ~theme.r3 #40 SFT ADD #0109 POK2 - #010b PEK2 #0f AND ~theme.g3 #40 SFT ADD #010b POK2 - #010d PEK2 #0f AND ~theme.b3 #40 SFT ADD #010d POK2 - #0109 PEK2 #f0 AND ~theme.r4 ADD #0109 POK2 - #010b PEK2 #f0 AND ~theme.g4 ADD #010b POK2 - #010d PEK2 #f0 AND ~theme.b4 ADD #010d POK2 - RTN @draw-window diff --git a/projects/examples/dev.time.usm b/projects/examples/dev.time.usm @@ -15,12 +15,8 @@ ( devices ) |0100 ;System { vector 2 pad 6 r 2 g 2 b 2 } -|0110 ;Console { pad 8 char 1 byte 1 short 2 } |0120 ;Screen { vector 2 width 2 height 2 pad 2 x 2 y 2 color 1 } |0130 ;Sprite { vector 2 pad 6 x 2 y 2 addr 2 color 1 } -|0140 ;Controller { vector 2 button 1 } -|0150 ;Keys { vector 2 key 1 } -|0160 ;Mouse { vector 2 x 2 y 2 state 1 chord 1 } |0180 ;Audio { ch1adsr 2 ch2adsr 2 ch3adsr 2 ch4adsr 2 ch1vol 1 ch1pitch 1 ch2vol 1 ch2pitch 1 ch3vol 1 ch3pitch 1 ch4vol 1 ch4pitch 1 } |01a0 ;Time { year 2 month 1 day 1 hour 1 minute 1 second 1 dow 1 doy 2 isdst 1 get 1 } diff --git a/projects/software/noodle.usm b/projects/software/noodle.usm @@ -62,12 +62,15 @@ ( program ) -|0200 @RESET +|0200 ( theme ) #e0fa =theme.r0 #30fa =theme.g0 #30fa =theme.b0 ( normal mode ) #00fe =theme.r1 #00f3 =theme.g1 #00f3 =theme.b1 ( presentation mode ) - ( vectors ) ,FRAME =Screen.vector + ( vectors ) ,on-screen =Screen.vector + ( vectors ) ,on-key =Keys.vector + ( vectors ) ,on-button =Controller.vector + ( vectors ) ,on-mouse =Mouse.vector ~theme.r0 =System.r ~theme.g0 =System.g ~theme.b0 =System.b @@ -93,10 +96,23 @@ BRK -@FRAME ( -- ) +@on-screen ( -- ) + + ~document.edit #01 NEQ ^$no-edit JNZ + #0008 =Sprite.x + ~Screen.height #0010 SUB2 =Sprite.y + ,path.name #01 ~timer #04 DIV #03 AND #03 MUL ADD ,draw-label JSR2 + $clear + #00 =Sprite.color + ~Sprite.x 8+ DUP2 =Sprite.x + ~Screen.width LTH2 ^$clear JNZ + ( blink ) ~timer #01 ADD =timer + $no-edit - ~document.edit #01 EQU ,on-rename JNZ2 +BRK +@on-mouse + ,draw-cursor JSR2 ( release drag ) @@ -262,79 +278,80 @@ BRK $no-touch - ~Controller.button #00 EQU ,$no-ctrl JNZ2 - ~Controller.button #f0 AND - DUP #04 SFT #01 AND #01 NEQ ^$no-up JNZ - ( move ) ~zoom.y -- =zoom.y $no-up - DUP #05 SFT #01 AND #01 NEQ ^$no-down JNZ - ( move ) ~zoom.y ++ =zoom.y $no-down - DUP #06 SFT #01 AND #01 NEQ ^$no-left JNZ - ( move ) ~zoom.x -- =zoom.x $no-left - DUP #07 SFT #01 AND #01 NEQ ^$no-right JNZ - ( move ) ~zoom.x ++ =zoom.x $no-right - #00 EQU #04 JNZ ,draw-canvas JSR2 - $no-ctrl - - ~Keys.key #00 EQU ,$no-keys JNZ2 - ~Keys.key - DUP #20 NEQ ^$no-space JNZ - ( toggle zoom ) ~zoom.active #00 EQU =zoom.active ,redraw JSR2 $no-space - DUP #08 NEQ ^$no-backspace JNZ - ( erase ) ,clear JSR2 $no-backspace - DUP #71 NEQ ^$no-qkey JNZ - ( tool0 ) #00 =brush.tool ,draw-toolpane JSR2 $no-qkey - DUP #77 NEQ ^$no-wkey JNZ - ( tool0 ) #01 =brush.tool ,draw-toolpane JSR2 $no-wkey - DUP #65 NEQ ^$no-ekey JNZ - ( tool0 ) #02 =brush.tool ,draw-toolpane JSR2 $no-ekey - DUP #72 NEQ ^$no-rkey JNZ - ( tool0 ) #03 =brush.tool ,draw-toolpane JSR2 $no-rkey - DUP #74 NEQ ^$no-tkey JNZ - ( tool0 ) #04 =brush.tool ,draw-toolpane JSR2 $no-tkey - DUP - DUP #30 GTH SWP #39 LTH #0101 NEQ2 ^$no-numkey JNZ - ( size ) ~Keys.key #31 SUB =brush.size ,draw-sizepane JSR2 $no-numkey - POP - ( release ) #00 =Keys - $no-keys - ~Mouse.x =cursor.x0 ~Mouse.y =cursor.y0 ~Mouse.state =brush.last BRK -@on-rename ( -- ) - - ~Keys.key #00 EQU ,$no-keys JNZ2 +@on-button + + ( if in renaming mode ) + ~document.edit #01 NEQ ,$no-edit JNZ2 ( enter ) - ~Keys.key #0d NEQ ^$no-enter JNZ + ~Controller.button #08 NEQ ^$no-edit-enter JNZ #00 =document.edit - ,redraw JSR2 BRK - $no-enter + ,redraw JSR2 + BRK + $no-edit-enter ( backspace ) - ~Keys.key #08 NEQ ^$no-backspace JNZ - ~path.length #00 EQU ^$end JNZ + ~Controller.button #04 NEQ ^$no-edit-backspace JNZ + ~path.length #00 EQU ^$edit-end JNZ ~path.length #01 SUB =path.length - ^$end JMP - $no-backspace + #00 ,path.name #00 ~path.length ADD2 POK2 + BRK + $no-edit-backspace + $edit-end + BRK + $no-edit + + ~Controller.button #f0 AND + DUP #04 SFT #01 AND #01 NEQ ^$no-up JNZ + ( move ) ~zoom.y -- =zoom.y $no-up + DUP #05 SFT #01 AND #01 NEQ ^$no-down JNZ + ( move ) ~zoom.y ++ =zoom.y $no-down + DUP #06 SFT #01 AND #01 NEQ ^$no-left JNZ + ( move ) ~zoom.x -- =zoom.x $no-left + DUP #07 SFT #01 AND #01 NEQ ^$no-right JNZ + ( move ) ~zoom.x ++ =zoom.x $no-right + #00 EQU #04 JNZ ,draw-canvas JSR2 + +BRK + +@on-key + + ( if in renaming mode ) + ~document.edit #01 NEQ ,$no-edit JNZ2 ( default ) - ~path.length #1f EQU ^$end JNZ + ~path.length #1f EQU ^$edit-end JNZ ~Keys.key ,path.name #00 ~path.length ADD2 POK2 ~path.length #01 ADD =path.length - $end + $edit-end #00 ,path.name #00 ~path.length ADD2 POK2 - #00 =Keys.key - $no-keys - ( draw ) - #0008 =Sprite.x ~Screen.height #0010 SUB2 =Sprite.y - ,path.name #01 ~timer #04 DIV #03 AND #03 MUL ADD ,draw-label JSR2 - $clear - #00 =Sprite.color - ~Sprite.x 8+ DUP2 =Sprite.x - ~Screen.width LTH2 ^$clear JNZ - ( blink timer ) - ~timer #01 ADD =timer + ( release ) #00 =Keys.key + BRK + $no-edit + + ~Keys.key + DUP #20 NEQ ^$no-space JNZ + ( toggle zoom ) ~zoom.active #00 EQU =zoom.active ,redraw JSR2 $no-space + DUP #08 NEQ ^$no-backspace JNZ + ( erase ) ,clear JSR2 $no-backspace + DUP #71 NEQ ^$no-qkey JNZ + ( tool0 ) #00 =brush.tool ,draw-toolpane JSR2 $no-qkey + DUP #77 NEQ ^$no-wkey JNZ + ( tool0 ) #01 =brush.tool ,draw-toolpane JSR2 $no-wkey + DUP #65 NEQ ^$no-ekey JNZ + ( tool0 ) #02 =brush.tool ,draw-toolpane JSR2 $no-ekey + DUP #72 NEQ ^$no-rkey JNZ + ( tool0 ) #03 =brush.tool ,draw-toolpane JSR2 $no-rkey + DUP #74 NEQ ^$no-tkey JNZ + ( tool0 ) #04 =brush.tool ,draw-toolpane JSR2 $no-tkey + DUP + DUP #30 GTH SWP #39 LTH #0101 NEQ2 ^$no-numkey JNZ + ( size ) ~Keys.key #31 SUB =brush.size ,draw-sizepane JSR2 $no-numkey + POP + ( release ) #00 =Keys.key BRK