Optimization on noodle

This commit is contained in:
neauoire 2021-04-06 10:45:53 -07:00
parent 6bd58375f7
commit 5dc0245c9e
9 changed files with 156 additions and 163 deletions

View File

@ -26,14 +26,11 @@ Read more in the [Uxambly Guide](https://wiki.xxiivv.com/site/uxambly.html).
( devices ) ( devices )
|0100 ;Console { pad 8 char 1 byte 1 short 2 } |0110 ;Console { vector 2 pad 6 char 1 byte 1 short 2 }
|0200 ^RESET JMP
|0204 ,ERROR JMP2
|0208 ,FRAME JMP2
( program ) ( program )
@RESET |0200
,text1 ,print-label JSR2 ,text1 ,print-label JSR2
,text2 ,print-label JSR2 ,text2 ,print-label JSR2
@ -54,9 +51,6 @@ RTN
@text1 [ Welcome 20 to 20 UxnVM 0a00 ] @text1 [ Welcome 20 to 20 UxnVM 0a00 ]
@text2 [ Hello 20 World 0a00 ] @text2 [ Hello 20 World 0a00 ]
@FRAME BRK
@ERROR BRK
``` ```
## TODOs ## TODOs

View File

@ -28,7 +28,7 @@ else
fi fi
echo "Assembling.." echo "Assembling.."
./bin/assembler projects/software/nasu.usm bin/boot.rom ./bin/assembler projects/software/noodle.usm bin/boot.rom
echo "Running.." echo "Running.."
if [ "${2}" = '--cli' ]; if [ "${2}" = '--cli' ];

View File

@ -4,12 +4,11 @@
( devices ) ( 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 } |0110 ;Console { vector 2 pad 6 char 1 byte 1 short 2 }
( program ) ( program )
|0200 @RESET |0200
,text1 ,print-label JSR2 ,text1 ,print-label JSR2
,text2 ,print-label JSR2 ,text2 ,print-label JSR2

View File

@ -11,16 +11,11 @@
( devices ) ( devices )
|0100 ;System { vector 2 pad 6 r 2 g 2 b 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 } |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 } |0130 ;Sprite { vector 2 pad 6 x 2 y 2 addr 2 color 1 }
|0140 ;Controller { vector 2 p1 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 ( theme ) #0daf =System.r #02ff =System.g #035f =System.b
( vectors ) ,FRAME =Screen.vector ( vectors ) ,FRAME =Screen.vector

View File

@ -3,13 +3,8 @@
%RTN { JMP2r } %RTN { JMP2r }
%8+ { #0008 ADD2 } %8+ { #0008 ADD2 }
%8* { #0030 SFT2 } %8* { #0030 SFT2 }
%MOD2 { #03 AND }
;cursor { x 2 y 2 }
|0100 ;System { vector 2 pad 6 r 2 g 2 b 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 } |0130 ;Sprite { vector 2 pad 6 x 2 y 2 addr 2 color 1 }
|0140 ;Controller { vector 2 button 1 } |0140 ;Controller { vector 2 button 1 }
|0150 ;Keys { vector 2 key 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 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 0008 0808 0808 0800 0030 1008 0810 3000 0000 0032 4c00 0000 3c42 99a1 a199 423c
] ]
;text { body 2 }

View File

@ -3,19 +3,14 @@
%RTN { JMP2r } %RTN { JMP2r }
%++ { #0001 ADD2 } %++ { #0001 ADD2 }
%-- { #0001 SUB2 } %-- { #0001 SUB2 }
%8+ { #0008 ADD2 }
%ABS2 { DUP2 #000f SFT2 #ffff SWP2 SWP POP MUL2? }
;color { byte 1 } ;color { byte 1 }
;pointer { x 2 y 2 } ;pointer { x 2 y 2 }
;circle { xc 2 yc 2 x 2 y 2 r 2 d 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 } |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 } |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 } |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 } |0160 ;Mouse { vector 2 x 2 y 2 state 1 chord 1 }
( program ) ( program )
@ -23,17 +18,24 @@
|0200 |0200
( theme ) #03fd =System.r #0ef3 =System.g #0bf2 =System.b ( theme ) #03fd =System.r #0ef3 =System.g #0bf2 =System.b
( vectors ) ,on-screen =Screen.vector
( vectors ) ,on-mouse =Mouse.vector ( vectors ) ,on-mouse =Mouse.vector
BRK 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 @on-mouse
( clear )
~circle.xc ~circle.yc ~circle.r #00 ,draw-circle JSR2
,draw-cursor JSR2 ,draw-cursor JSR2
( clear ) ~circle.xc ~circle.yc ~circle.r #00 ,draw-circle JSR2
~Mouse.state #00 EQU ^$no-touch JNZ ~Mouse.state #00 EQU ^$no-touch JNZ
~Mouse.x DUP2 =circle.xc ~Mouse.x DUP2 =circle.xc
~Mouse.y DUP2 =circle.yc ~Mouse.y DUP2 =circle.yc
@ -41,9 +43,6 @@ BRK
( release ) #00 =Mouse.state ( release ) #00 =Mouse.state
$no-touch $no-touch
( draw )
~circle.xc ~circle.yc ~circle.r #0001 ADD2 #03 ,draw-circle JSR2
BRK BRK
@draw-cursor ( -- ) @draw-cursor ( -- )

View File

@ -22,11 +22,8 @@
} }
|0100 ;System { vector 2 pad 6 r 2 g 2 b 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 } |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 } |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 } |0160 ;Mouse { vector 2 x 2 y 2 state 1 chord 1 }
( program ) ( program )
@ -53,42 +50,17 @@
~Screen.width #0002 DIV2 =center.x ~Screen.width #0002 DIV2 =center.x
~Screen.height #0002 DIV2 =center.y ~Screen.height #0002 DIV2 =center.y
( draw hor line )
#0000 =Screen.x ~center.y =Screen.y
#0000 ~Screen.width ( from/to )
$draw-hor
( draw ) #01 =Screen.color
( incr ) SWP2 #0002 ADD2 DUP2 =Screen.x SWP2
OVR2 OVR2 LTH2 ^$draw-hor JNZ
POP2 POP2
( draw ver line )
~center.x =Screen.x #0000 =Screen.y
#0000 ~Screen.height ( from/to )
$draw-ver
( draw ) #02 =Screen.color
( incr ) SWP2 #0002 ADD2 DUP2 =Screen.y SWP2
OVR2 OVR2 LTH2 ^$draw-ver JNZ
POP2 POP2
( draw blending modes )
#0020 =Sprite.x #0020 =Sprite.y ,icon_icn =Sprite.addr
#00 #10
$draw-blends
( move ) OVR #00 SWP #0008 MUL2 #0020 ADD2 =Sprite.x
( draw ) OVR =Sprite.color
( incr ) SWP #01 ADD SWP
DUP2 LTH ^$draw-blends JNZ
POP POP
,update-theme JSR2 ,update-theme JSR2
,draw-background JSR2
,draw-window JSR2 ,draw-window JSR2
BRK BRK
@on-mouse @on-mouse
~Mouse.state #00 EQU ,$no-touch JNZ2 ,draw-cursor JSR2
~Mouse.state #00 NEQ ,$no-skip JNZ2 BRK $no-skip
~Mouse.y ~window.y1 SUB2 STEP8 ~Mouse.y ~window.y1 SUB2 STEP8
@ -118,10 +90,6 @@ BRK
,update-theme JSR2 ,update-theme JSR2
,draw-window JSR2 ,draw-window JSR2
$no-touch
,draw-cursor JSR2
BRK BRK
@update-theme @update-theme
@ -141,6 +109,38 @@ BRK
RTN RTN
@draw-background
( draw hor line )
#0000 =Screen.x ~center.y =Screen.y
#0000 ~Screen.width ( from/to )
$draw-hor
( draw ) #01 =Screen.color
( incr ) SWP2 #0002 ADD2 DUP2 =Screen.x SWP2
OVR2 OVR2 LTH2 ^$draw-hor JNZ
POP2 POP2
( draw ver line )
~center.x =Screen.x #0000 =Screen.y
#0000 ~Screen.height ( from/to )
$draw-ver
( draw ) #02 =Screen.color
( incr ) SWP2 #0002 ADD2 DUP2 =Screen.y SWP2
OVR2 OVR2 LTH2 ^$draw-ver JNZ
POP2 POP2
( draw blending modes )
#0020 =Sprite.x #0020 =Sprite.y ,icon_icn =Sprite.addr
#00 #10
$draw-blends
( move ) OVR #00 SWP #0008 MUL2 #0020 ADD2 =Sprite.x
( draw ) OVR =Sprite.color
( incr ) SWP #01 ADD SWP
DUP2 LTH ^$draw-blends JNZ
POP POP
RTN
@draw-window @draw-window
~window.x1 ~window.w ADD2 =window.x2 ~window.x1 ~window.w ADD2 =window.x2

View File

@ -15,12 +15,8 @@
( devices ) ( devices )
|0100 ;System { vector 2 pad 6 r 2 g 2 b 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 } |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 } |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 } |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 } |01a0 ;Time { year 2 month 1 day 1 hour 1 minute 1 second 1 dow 1 doy 2 isdst 1 get 1 }

View File

@ -62,12 +62,15 @@
( program ) ( program )
|0200 @RESET |0200
( theme ) ( theme )
#e0fa =theme.r0 #30fa =theme.g0 #30fa =theme.b0 ( normal mode ) #e0fa =theme.r0 #30fa =theme.g0 #30fa =theme.b0 ( normal mode )
#00fe =theme.r1 #00f3 =theme.g1 #00f3 =theme.b1 ( presentation 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 ~theme.r0 =System.r ~theme.g0 =System.g ~theme.b0 =System.b
@ -93,9 +96,22 @@
BRK BRK
@FRAME ( -- ) @on-screen ( -- )
~document.edit #01 EQU ,on-rename JNZ2 ~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
BRK
@on-mouse
,draw-cursor JSR2 ,draw-cursor JSR2
@ -262,7 +278,33 @@ BRK
$no-touch $no-touch
~Controller.button #00 EQU ,$no-ctrl JNZ2 ~Mouse.x =cursor.x0
~Mouse.y =cursor.y0
~Mouse.state =brush.last
BRK
@on-button
( if in renaming mode )
~document.edit #01 NEQ ,$no-edit JNZ2
( enter )
~Controller.button #08 NEQ ^$no-edit-enter JNZ
#00 =document.edit
,redraw JSR2
BRK
$no-edit-enter
( backspace )
~Controller.button #04 NEQ ^$no-edit-backspace JNZ
~path.length #00 EQU ^$edit-end JNZ
~path.length #01 SUB =path.length
#00 ,path.name #00 ~path.length ADD2 POK2
BRK
$no-edit-backspace
$edit-end
BRK
$no-edit
~Controller.button #f0 AND ~Controller.button #f0 AND
DUP #04 SFT #01 AND #01 NEQ ^$no-up JNZ DUP #04 SFT #01 AND #01 NEQ ^$no-up JNZ
( move ) ~zoom.y -- =zoom.y $no-up ( move ) ~zoom.y -- =zoom.y $no-up
@ -273,9 +315,23 @@ BRK
DUP #07 SFT #01 AND #01 NEQ ^$no-right JNZ DUP #07 SFT #01 AND #01 NEQ ^$no-right JNZ
( move ) ~zoom.x ++ =zoom.x $no-right ( move ) ~zoom.x ++ =zoom.x $no-right
#00 EQU #04 JNZ ,draw-canvas JSR2 #00 EQU #04 JNZ ,draw-canvas JSR2
$no-ctrl
~Keys.key #00 EQU ,$no-keys JNZ2 BRK
@on-key
( if in renaming mode )
~document.edit #01 NEQ ,$no-edit JNZ2
( default )
~path.length #1f EQU ^$edit-end JNZ
~Keys.key ,path.name #00 ~path.length ADD2 POK2
~path.length #01 ADD =path.length
$edit-end
#00 ,path.name #00 ~path.length ADD2 POK2
( release ) #00 =Keys.key
BRK
$no-edit
~Keys.key ~Keys.key
DUP #20 NEQ ^$no-space JNZ DUP #20 NEQ ^$no-space JNZ
( toggle zoom ) ~zoom.active #00 EQU =zoom.active ,redraw JSR2 $no-space ( toggle zoom ) ~zoom.active #00 EQU =zoom.active ,redraw JSR2 $no-space
@ -295,46 +351,7 @@ BRK
DUP #30 GTH SWP #39 LTH #0101 NEQ2 ^$no-numkey JNZ DUP #30 GTH SWP #39 LTH #0101 NEQ2 ^$no-numkey JNZ
( size ) ~Keys.key #31 SUB =brush.size ,draw-sizepane JSR2 $no-numkey ( size ) ~Keys.key #31 SUB =brush.size ,draw-sizepane JSR2 $no-numkey
POP POP
( release ) #00 =Keys ( release ) #00 =Keys.key
$no-keys
~Mouse.x =cursor.x0
~Mouse.y =cursor.y0
~Mouse.state =brush.last
BRK
@on-rename ( -- )
~Keys.key #00 EQU ,$no-keys JNZ2
( enter )
~Keys.key #0d NEQ ^$no-enter JNZ
#00 =document.edit
,redraw JSR2 BRK
$no-enter
( backspace )
~Keys.key #08 NEQ ^$no-backspace JNZ
~path.length #00 EQU ^$end JNZ
~path.length #01 SUB =path.length
^$end JMP
$no-backspace
( default )
~path.length #1f EQU ^$end JNZ
~Keys.key ,path.name #00 ~path.length ADD2 POK2
~path.length #01 ADD =path.length
$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
BRK BRK