uxn

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

commit 743eaef47a468d94f780f885d2c1d4f72aeb6a50
parent 276e5086db208753a339b8c3c60d7007481487bc
Author: neauoire <aliceffekt@gmail.com>
Date:   Wed, 21 Apr 2021 11:12:42 -0700

Ported some of the examples to the new accessors

Diffstat:
MREADME.md | 4++--
Mprojects/examples/dev.console.usm | 4++--
Mprojects/examples/dev.controller.buttons.usm | 28++++++++++++++--------------
Mprojects/examples/dev.controller.keys.usm | 26+++++++++++++-------------
Mprojects/examples/dev.file.usm | 186++++++-------------------------------------------------------------------------
Dprojects/examples/dev.mouse-old.usm | 141-------------------------------------------------------------------------------
Mprojects/examples/dev.mouse.usm | 30+++++++++++++++---------------
Msrc/assembler.c | 13++++++++++---
Msrc/uxn.c | 12++++++------
9 files changed, 76 insertions(+), 368 deletions(-)

diff --git a/README.md b/README.md @@ -41,14 +41,14 @@ BRK @print ( addr -- ) &loop - ( send ) DUP2 GET .Console/char IOW + ( send ) DUP2 GET .Console/char DEO ( incr ) #0001 ADD2 ( loop ) DUP2 GET #00 NEQ ,&loop JNZ POP2 RTN -@hello-word [ 48 65 6c 6c 6f 20 57 6f 72 6c 64 21 ] +@hello-word "hello 20 "World! ``` ## TODOs diff --git a/projects/examples/dev.console.usm b/projects/examples/dev.console.usm @@ -17,11 +17,11 @@ BRK @print ( addr -- ) &loop - ( send ) DUP2 GET .Console/char IOW + ( send ) DUP2 GET .Console/char DEO ( incr ) #0001 ADD2 ( loop ) DUP2 GET #00 NEQ ,&loop JNZ POP2 RTN -@hello-word [ 48 65 6c 6c 6f 20 57 6f 72 6c 64 21 ] +@hello-word "hello 20 "World! diff --git a/projects/examples/dev.controller.buttons.usm b/projects/examples/dev.controller.buttons.usm @@ -1,7 +1,7 @@ ( dev/controller/buttons ) -%=>SC/ADDR { .Screen/addr IOW2 } -%->SC/COLR { .Screen/color IOW } +%=>SC/ADDR { .Screen/addr DEO2 } +%->SC/COLR { .Screen/color DEO } %++ { #0001 ADD2 } %-- { #0001 SUB2 } %2/ { #0002 DIV2 } @@ -23,16 +23,16 @@ |0100 ( -> ) ( theme ) - #0daf .System/r IOW2 - #02ff .System/g IOW2 - #035f .System/b IOW2 + #0daf .System/r DEO2 + #02ff .System/g DEO2 + #035f .System/b DEO2 ( vectors ) - ;on-frame .Screen/vector IOW2 + ;on-frame .Screen/vector DEO2 ( set origin ) - .Screen/width IOR2 2/ .Screen/x IOW2 - .Screen/height IOR2 2/ .Screen/y IOW2 + .Screen/width DEI2 2/ .Screen/x DEO2 + .Screen/height DEI2 2/ .Screen/y DEO2 ;default_icn =>SC/ADDR #31 ->SC/COLR @@ -46,7 +46,7 @@ BRK ;default_icn =>SC/ADDR ( hold ctrl key to change slime color ) - .Controller/button IOR #0f AND + .Controller/button DEI #0f AND DUP #01 NEQ ,&no-ctrl JNZ #25 .slime POK &no-ctrl DUP #02 NEQ ,&no-alt JNZ #2f .slime POK &no-alt POP @@ -54,22 +54,22 @@ BRK ( clear ) #30 ->SC/COLR ( detect movement ) - .Controller/button IOR #f0 AND + .Controller/button DEI #f0 AND DUP #04 SFT #01 AND #01 NEQ ,&no-up JNZ ( move ) - .Screen/y IOR2 -- .Screen/y IOW2 + .Screen/y DEI2 -- .Screen/y DEO2 ;up_icn =>SC/ADDR &no-up DUP #05 SFT #01 AND #01 NEQ ,&no-down JNZ ( move ) - .Screen/y IOR2 ++ .Screen/y IOW2 + .Screen/y DEI2 ++ .Screen/y DEO2 ;down_icn =>SC/ADDR &no-down DUP #06 SFT #01 AND #01 NEQ ,&no-left JNZ ( move ) - .Screen/x IOR2 -- .Screen/x IOW2 + .Screen/x DEI2 -- .Screen/x DEO2 ;left_icn =>SC/ADDR &no-left DUP #07 SFT #01 AND #01 NEQ ,&no-right JNZ ( move ) - .Screen/x IOR2 ++ .Screen/x IOW2 + .Screen/x DEI2 ++ .Screen/x DEO2 ;right_icn =>SC/ADDR &no-right POP diff --git a/projects/examples/dev.controller.keys.usm b/projects/examples/dev.controller.keys.usm @@ -15,11 +15,11 @@ |0100 ( -> ) ( theme ) - #0f73 .System/r IOW2 - #0fe3 .System/g IOW2 - #0fc3 .System/b IOW2 + #0f73 .System/r DEO2 + #0fe3 .System/g DEO2 + #0fc3 .System/b DEO2 - ( vectors ) ;on-button .Controller/vector IOW2 + ( vectors ) ;on-button .Controller/vector DEO2 ;draw-cursor JSR2 @@ -27,19 +27,19 @@ BRK @on-button ( -> ) - .Controller/key IOR #00 NEQ ,&skip JNZ BRK &skip + .Controller/key DEI #00 NEQ ,&skip JNZ BRK &skip - .Controller/key IOR #0d NEQ ,&no-return JNZ - ( draw ) #20 .Screen/color IOW - ( reset ) #0000 .Screen/x IOW2 - ( incr ) .Screen/y IOR2 8+ .Screen/y IOW2 + .Controller/key DEI #0d NEQ ,&no-return JNZ + ( draw ) #20 .Screen/color DEO + ( reset ) #0000 .Screen/x DEO2 + ( incr ) .Screen/y DEI2 8+ .Screen/y DEO2 ;draw-cursor JSR2 BRK &no-return - ;font #00 .Controller/key IOR 8* ADD2 .Screen/addr IOW2 - ( draw ) #21 .Screen/color IOW - ( incr ) .Screen/x IOR2 8+ .Screen/x IOW2 + ;font #00 .Controller/key DEI 8* ADD2 .Screen/addr DEO2 + ( draw ) #21 .Screen/color DEO + ( incr ) .Screen/x DEI2 8+ .Screen/x DEO2 ;draw-cursor JSR2 @@ -47,7 +47,7 @@ BRK @draw-cursor ( -- ) - ;cursor .Screen/addr IOW2 #22 .Screen/color IOW + ;cursor .Screen/addr DEO2 #22 .Screen/color DEO RTN diff --git a/projects/examples/dev.file.usm b/projects/examples/dev.file.usm @@ -4,16 +4,6 @@ %STEP8 { #0033 SFT2 } %++ { #01 ADD } -%->MS/STAT { .Mouse/state IOW } -%<-MS/STAT { .Mouse/state IOR } -%->SC/COLR { .Screen/color IOW } -%=>SC/ADDR { .Screen/addr IOW2 } -%=>SC/X { .Screen/x IOW2 } -%=>SC/Y { .Screen/y IOW2 } -%<=SC/X { .Screen/x IOR2 } -%<=MS/X { .Mouse/x IOR2 } -%<=MS/Y { .Mouse/y IOR2 } - %MEMORY { #1000 } ( devices ) @@ -29,178 +19,30 @@ |0000 -@loadbtn [ &x $2 &y $2 ] -@output [ &x $2 &y $2 ] -@pointer [ &x $2 &y $2 ] -@label [ &x $2 &y $2 &color $1 &addr $2 ] - ( init ) |0100 ( -> ) ( theme ) - #804b .System/r IOW2 - #804b .System/g IOW2 - #e0bb .System/b IOW2 - - ( vectors ) - ;on-mouse .Mouse/vector IOW2 - - #0020 .loadbtn/x STR - #0020 .loadbtn/y STR - #0020 .output/x STR - #0030 .output/y STR + #804b .System/r DEO2 + #804b .System/g DEO2 + #e0bb .System/b DEO2 - .loadbtn/x LDR .loadbtn/y LDR #26 ;load_txt ;draw-label JSR2 + ( load file ) + #0100 .File/length DEO2 + ;srcpath .File/name DEO2 + MEMORY .File/load DEO2 - ;draw-file JSR2 + .File/success DEI2 #0000 NEQ2 ;on-success JNZ2 BRK -@on-mouse ( -> ) - - .loadbtn/x LDR .loadbtn/y LDR #26 ;load_txt ;draw-label JSR2 - .loadbtn/x LDR #0028 ADD2 .loadbtn/y LDR #23 ;srcpath ;draw-label JSR2 - - <-MS/STAT #00 EQU ,&touch-end JNZ - - <=MS/Y STEP8 .loadbtn/y LDR NEQ2 ,&no-touch-load JNZ - .loadbtn/x LDR .loadbtn/y LDR #27 ;load_txt ;draw-label JSR2 - ;srcpath #0100 ;load-file JSR2 - ( release ) #00 ->MS/STAT - &no-touch-load - - &touch-end - - ;draw-cursor JSR2 - -BRK - -@draw-file ( -- ) - - #00 #10 - &ver - ( pos-y ) OVR #00 SWP #0008 MUL2 .output/y LDR ADD2 =>SC/Y - #00 #10 - &hor - ( pos-x ) OVR #00 SWP #0008 MUL2 .output/x LDR ADD2 =>SC/X - ( get x,y ) SWP2 OVR STH SWP2 OVR STHr - ( get id ) #10 MUL ADD - ( get data ) #00 SWP MEMORY ADD2 PEK2 - ( get sprite ) #20 SUB #00 SWP #0008 MUL2 ;font ADD2 =>SC/ADDR - ( draw ) #2d ->SC/COLR - ( incr ) SWP ++ SWP - DUP2 NEQ ,&hor JNZ - POP2 - ( incr ) SWP ++ SWP - DUP2 NEQ ,&ver JNZ - POP2 - -RTN - -@load-file ( path length -- ) +@on-success ( -> ) - .File/length IOW2 .File/name IOW2 MEMORY .File/load IOW2 - .File/success IOR2 #0000 EQU2 ,&no-success JNZ - - ;draw-file JSR2 - .output/x LDR .output/y LDR #0088 ADD2 #23 ;done_txt ;draw-label JSR2 - ( release ) #00 ->MS/STAT + ;srcpath .Console/string DEO2 + ;dstpath .Console/string DEO2 - &no-success - -RTN - -@draw-cursor ( -- ) - - ( clear last cursor ) - ;clear_icn =>SC/ADDR - .pointer/x LDR =>SC/X - .pointer/y LDR =>SC/Y - #30 ->SC/COLR - - ( record pointer positions ) - <=MS/X .pointer/x STR <=MS/Y .pointer/y STR - - ( draw new cursor ) - ;cursor_icn =>SC/ADDR - .pointer/x LDR =>SC/X - .pointer/y LDR =>SC/Y - #32 <-MS/STAT #00 NEQ ADD ->SC/COLR - -RTN - -@draw-label ( x y color addr -- ) - - ( load ) .label/addr STR .label/color POK =>SC/Y =>SC/X - .label/addr LDR - &loop - ( draw ) DUP2 PEK2 #20 SUB #00 SWP #0008 MUL2 ;font ADD2 =>SC/ADDR .label/color PEK ->SC/COLR - ( incr ) #0001 ADD2 - ( incr ) <=SC/X #0008 ADD2 =>SC/X - DUP2 PEK2 #00 NEQ ,&loop JNZ - POP2 - -RTN - -@clear_icn [ 0000 0000 0000 0000 ] -@cursor_icn [ 80c0 e0f0 f8e0 1000 ] - -@done_txt [ 4c4f 4144 2053 5543 4345 5353 2100 ] ( LOAD SUCCESS! ) -@load_txt [ 4c4f 4144 00 ] ( LOAD ) -@save_txt [ 5341 5645 00 ] ( SAVE ) - -@srcpath [ 5245 4144 4d45 2e6d 6400 ] ( README.md ) -@dstpath [ 6269 6e2f 6578 706f 7274 2e6d 6400 ] ( bin/export.md ) +BRK -@font ( specter8-frag font ) -[ - 0000 0000 0000 0000 0008 0808 0800 0800 - 0014 1400 0000 0000 0024 7e24 247e 2400 - 0008 1e28 1c0a 3c08 0000 2204 0810 2200 - 0030 4832 4c44 3a00 0008 1000 0000 0000 - 0004 0808 0808 0400 0020 1010 1010 2000 - 0000 2214 0814 2200 0000 0808 3e08 0800 - 0000 0000 0000 0810 0000 0000 3e00 0000 - 0000 0000 0000 0800 0000 0204 0810 2000 - 003c 464a 5262 3c00 0018 0808 0808 1c00 - 003c 4202 3c40 7e00 003c 421c 0242 3c00 - 000c 1424 447e 0400 007e 407c 0242 3c00 - 003c 407c 4242 3c00 007e 0204 0810 1000 - 003c 423c 4242 3c00 003c 4242 3e02 3c00 - 0000 0010 0000 1000 0000 1000 0010 1020 - 0000 0810 2010 0800 0000 003e 003e 0000 - 0000 1008 0408 1000 003c 420c 1000 1000 - 003c 4232 4a42 3c00 003c 4242 7e42 4200 - 007c 427c 4242 7c00 003c 4240 4042 3c00 - 007c 4242 4242 7c00 007e 4078 4040 7e00 - 007e 4078 4040 4000 003c 4240 4642 3c00 - 0042 427e 4242 4200 001c 0808 0808 1c00 - 007e 0202 0242 3c00 0042 4478 4442 4200 - 0040 4040 4040 7e00 0042 665a 4242 4200 - 0042 6252 4a46 4200 003c 4242 4242 3c00 - 007c 4242 7c40 4000 003c 4242 4244 3a00 - 007c 4242 7c44 4200 003e 403c 0242 3c00 - 007e 0808 0808 1000 0042 4242 4244 3a00 - 0042 4242 4224 1800 0042 4242 5a66 4200 - 0042 423c 4242 4200 0042 423e 0242 3c00 - 007e 020c 3040 7e00 000c 0808 0808 0c00 - 0040 2010 0804 0200 0030 1010 1010 3000 - 0008 1400 0000 0000 0000 0000 0000 7e00 - 0008 0400 0000 0000 0000 3c02 3e42 3a00 - 0040 407c 4242 7c00 0000 3c42 4042 3c00 - 0002 023e 4242 3e00 0000 3c42 7e40 3e00 - 0000 3e40 7840 4000 0000 3c42 3e02 3c00 - 0040 405c 6242 4200 0008 0018 0808 0400 - 0008 0018 0808 4830 0040 4244 7844 4200 - 0010 1010 1010 0c00 0000 6c52 5252 5200 - 0000 5c62 4242 4200 0000 3c42 4242 3c00 - 0000 7c42 427c 4040 0000 3e42 423e 0202 - 0000 5c62 4040 4000 0000 3e40 3c02 7c00 - 0008 7e08 0808 1000 0000 4242 4244 3a00 - 0000 4242 4224 1800 0000 5252 5252 2e00 - 0000 4224 1824 4200 0000 4242 3e02 7c00 - 0000 7e02 3c40 7e00 000c 0810 1008 0c00 - 0008 0808 0808 0800 0030 1008 0810 3000 - 0000 0032 4c00 0000 3c42 99a1 a199 423c -] +@srcpath "README.md $1 +@dstpath "bin/export.md $1 diff --git a/projects/examples/dev.mouse-old.usm b/projects/examples/dev.mouse-old.usm @@ -1,140 +0,0 @@ -( Dev/Mouse ) - -%RTN { JMP2r } -%8+ { #0008 ADD2 } -%++ { #0001 ADD2 } -%-- { #0001 SUB2 } - -;touch1 { xc 2 yc 2 r 2 } -;touch2 { xc 2 yc 2 r 2 } - -;color { byte 1 } -;addr { short 2 } -;pointer { x 2 y 2 } -;circle { xc 2 yc 2 x 2 y 2 r 2 d 2 } - -( devices ) - -|0100 ;System { vector 2 pad 6 r 2 g 2 b 2 } -|0120 ;Screen { vector 2 width 2 height 2 pad 2 x 2 y 2 addr 2 color 1 } -|0160 ;Mouse { vector 2 x 2 y 2 state 1 chord 1 } - -( program ) - -|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 ) ~touch1.xc ~touch1.yc ~touch1.r #00 ,draw-circle JSR2 - ( clear ) ~touch2.xc ~touch2.yc ~touch2.r #00 ,draw-circle JSR2 - - ~touch1.r ++ =touch1.r - ~touch2.r ++ =touch2.r - - ( draw ) ~touch1.xc ~touch1.yc ~touch1.r #03 ,draw-circle JSR2 - ( draw ) ~touch2.xc ~touch2.yc ~touch2.r #02 ,draw-circle JSR2 - - ~touch1.xc ~touch1.yc #23 ,touch1.r #0001 ADD2 ,draw-byte JSR2 - ~touch2.xc ~touch2.yc #28 ,touch2.r #0001 ADD2 ,draw-byte JSR2 - -BRK - -@on-mouse - - ,draw-cursor JSR2 - - ~Mouse.state #01 NEQ ,$no-touch1 JNZ2 - ( clear ) ~touch1.xc ~touch1.yc ~touch1.r #00 ,draw-circle JSR2 - ( update ) ~Mouse.x =touch1.xc ~Mouse.y =touch1.yc #0000 =touch1.r - ( release ) #00 =Mouse.state - $no-touch1 - ~Mouse.state #10 NEQ ,$no-touch2 JNZ2 - ( clear ) ~touch2.xc ~touch2.yc ~touch2.r #00 ,draw-circle JSR2 - ( update ) ~Mouse.x =touch2.xc ~Mouse.y =touch2.yc #0000 =touch2.r - ( release ) #00 =Mouse.state - $no-touch2 - -BRK - -@draw-cursor ( -- ) - - ( 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 ) - ,cursor_icn =Screen.addr - ~pointer.x =Screen.x - ~pointer.y =Screen.y - #31 ~Mouse.state #00 NEQ ADD =Screen.color - -RTN - -@draw-circle ( xc yc r color ) - - ( load ) =color =circle.r =circle.yc =circle.xc - #0000 =circle.x ~circle.r =circle.y - ~circle.r #0002 MUL2 #0003 SUB2 =circle.d - ( draw ) ,$seg JSR2 - $loop - ( incr ) ~circle.x ++ =circle.x - ~circle.d #0000 #0001 ADD2 LTS2 ^$else JNZ - ( decr ) ~circle.y -- =circle.y - ~circle.x ~circle.y SUB2 #0004 MUL2 ~circle.d ADD2 #000a ADD2 =circle.d - ,$end JMP2 - $else - ~circle.x #0004 MUL2 ~circle.d ADD2 #0006 ADD2 =circle.d - $end - ( draw ) ,$seg JSR2 - ~circle.y ~circle.x #0001 SUB2 GTS2 ^$loop JNZ - RTN - $seg - ~circle.xc ~circle.x ADD2 =Screen.x ~circle.yc ~circle.y ADD2 =Screen.y ~color =Screen.color - ~circle.xc ~circle.x SUB2 =Screen.x ~circle.yc ~circle.y ADD2 =Screen.y ~color =Screen.color - ~circle.xc ~circle.x ADD2 =Screen.x ~circle.yc ~circle.y SUB2 =Screen.y ~color =Screen.color - ~circle.xc ~circle.x SUB2 =Screen.x ~circle.yc ~circle.y SUB2 =Screen.y ~color =Screen.color - ~circle.xc ~circle.y ADD2 =Screen.x ~circle.yc ~circle.x ADD2 =Screen.y ~color =Screen.color - ~circle.xc ~circle.y SUB2 =Screen.x ~circle.yc ~circle.x ADD2 =Screen.y ~color =Screen.color - ~circle.xc ~circle.y ADD2 =Screen.x ~circle.yc ~circle.x SUB2 =Screen.y ~color =Screen.color - ~circle.xc ~circle.y SUB2 =Screen.x ~circle.yc ~circle.x SUB2 =Screen.y ~color =Screen.color - -RTN - -@draw-byte ( x y color addr -- ) - - =addr STH - =Screen.y - =Screen.x - ,font_hex #00 ~addr PEK2 #04 SFT #0008 MUL2 ADD2 =Screen.addr - STHr DUP STH =Screen.color - ,font_hex #00 ~addr PEK2 #0f AND #0008 MUL2 ADD2 =Screen.addr - ~Screen.x 8+ =Screen.x - STHr =Screen.color - -RTN - -@clear_icn [ 0000 0000 0000 0000 ] -@cursor_icn [ 80c0 e0f0 f8e0 1000 ] - -@font_hex -[ - 003c 464a 5262 3c00 0018 0808 0808 1c00 - 003c 4202 3c40 7e00 003c 421c 0242 3c00 - 000c 1424 447e 0400 007e 407c 0242 3c00 - 003c 407c 4242 3c00 007e 0204 0810 1000 - 003c 423c 4242 3c00 003c 4242 3e02 3c00 - 003c 4242 7e42 4200 007c 427c 4242 7c00 - 003c 4240 4042 3c00 007c 4242 4242 7c00 - 007e 4078 4040 7e00 007e 4078 4040 4000 -] -\ No newline at end of file diff --git a/projects/examples/dev.mouse.usm b/projects/examples/dev.mouse.usm @@ -22,11 +22,11 @@ |0100 ( -> ) ( theme ) - #03fd .System/r IOW2 - #0ef3 .System/g IOW2 - #0bf2 .System/b IOW2 + #03fd .System/r DEO2 + #0ef3 .System/g DEO2 + #0bf2 .System/b DEO2 - ( vectors ) ;on-mouse .Mouse/vector IOW2 + ( vectors ) ;on-mouse .Mouse/vector DEO2 BRK @@ -39,23 +39,23 @@ BRK @draw-cursor ( -- ) ( clear last cursor ) - ;clear .Screen/addr IOW2 - .pointer/x PEK2 .Screen/x IOW2 - .pointer/y PEK2 .Screen/y IOW2 - #30 .Screen/color IOW + ;clear .Screen/addr DEO2 + .pointer/x PEK2 .Screen/x DEO2 + .pointer/y PEK2 .Screen/y DEO2 + #30 .Screen/color DEO ( record pointer positions ) - .Mouse/x IOR2 .pointer/x POK2 - .Mouse/y IOR2 .pointer/y POK2 + .Mouse/x DEI2 .pointer/x POK2 + .Mouse/y DEI2 .pointer/y POK2 ( draw new cursor ) - ;cursor .Screen/addr IOW2 - .pointer/x PEK2 .Screen/x IOW2 - .pointer/y PEK2 .Screen/y IOW2 + ;cursor .Screen/addr DEO2 + .pointer/x PEK2 .Screen/x DEO2 + .pointer/y PEK2 .Screen/y DEO2 ( colorize on state ) - .Mouse/state IOR #00 NEQ - #31 ADD .Screen/color IOW + .Mouse/state DEI #00 NEQ + #31 ADD .Screen/color DEO RTN diff --git a/src/assembler.c b/src/assembler.c @@ -41,7 +41,7 @@ Program p; char ops[][4] = { "BRK", "LIT", "NOP", "POP", "DUP", "SWP", "OVR", "ROT", - "EQU", "NEQ", "GTH", "LTH", "GTS", "LTS", "IOR", "IOW", + "EQU", "NEQ", "GTH", "LTH", "GTS", "LTS", "DEI", "DEO", "PEK", "POK", "GET", "PUT", "JMP", "JNZ", "JSR", "STH", "ADD", "SUB", "MUL", "DIV", "AND", "ORA", "EOR", "SFT" }; @@ -76,11 +76,10 @@ pushshort(Uint16 s, int lit) } void -pushtext(char *s, int lit) +pushword(char *s) { int i = 0; char c; - if(lit) pushbyte(0x21, 0); while((c = s[i++])) pushbyte(c, 0); } @@ -210,12 +209,14 @@ walktoken(char *w) switch(w[0]) { case '[': return 0; case ']': return 0; + case '\'': return 1; case '.': return 2; /* zero-page: LIT addr-lb */ case ',': return 2; /* relative: LIT addr-rel */ case ':': return 2; /* absolute: addr-hb addr-lb */ case ';': return 3; /* absolute: LIT addr-hb addr-lb */ case '$': return shex(w + 1); case '#': return slen(w + 1) == 4 ? 3 : 2; + case '"': return slen(w + 1); } if((m = findmacro(w))) { int i, res = 0; @@ -249,6 +250,12 @@ parsetoken(char *w) } else if(findopcode(w) || scmp(w, "BRK", 4)) { pushbyte(findopcode(w), 0); return 1; + } else if(w[0] == '"') { + pushword(w + 1); + return 1; + } else if(w[0] == '\'') { + pushbyte((Uint8)w[1], 0); + return 1; } else if(w[0] == '#') { if(slen(w + 1) == 1) pushbyte((Uint8)w[1], 1); diff --git a/src/uxn.c b/src/uxn.c @@ -46,8 +46,8 @@ void op_gth(Uxn *u) { Uint8 a = pop8(u->src), b = pop8(u->src); push8(u->src, b void op_lth(Uxn *u) { Uint8 a = pop8(u->src), b = pop8(u->src); push8(u->src, b < a); } void op_gts(Uxn *u) { Uint8 a = pop8(u->src), b = pop8(u->src); push8(u->src, (Sint8)b > (Sint8)a); } void op_lts(Uxn *u) { Uint8 a = pop8(u->src), b = pop8(u->src); push8(u->src, (Sint8)b < (Sint8)a); } -void op_ior(Uxn *u) { Uint8 a = pop8(u->src); push8(u->src, devpeek8(&u->dev[a >> 4], a)); } -void op_iow(Uxn *u) { Uint8 a = pop8(u->src), b = pop8(u->src); devpoke8(&u->dev[a >> 4], a, b); } +void op_dei(Uxn *u) { Uint8 a = pop8(u->src); push8(u->src, devpeek8(&u->dev[a >> 4], a)); } +void op_deo(Uxn *u) { Uint8 a = pop8(u->src), b = pop8(u->src); devpoke8(&u->dev[a >> 4], a, b); } /* Memory */ void op_pek(Uxn *u) { Uint8 a = pop8(u->src); push8(u->src, mempeek8(u->ram.dat, a)); } void op_pok(Uxn *u) { Uint8 a = pop8(u->src); Uint8 b = pop8(u->src); mempoke8(u->ram.dat, a, b); } @@ -80,8 +80,8 @@ void op_gth16(Uxn *u) { Uint16 a = pop16(u->src), b = pop16(u->src); push8(u->sr void op_lth16(Uxn *u) { Uint16 a = pop16(u->src), b = pop16(u->src); push8(u->src, b < a); } void op_gts16(Uxn *u) { Uint16 a = pop16(u->src), b = pop16(u->src); push8(u->src, (Sint16)b > (Sint16)a); } void op_lts16(Uxn *u) { Uint16 a = pop16(u->src), b = pop16(u->src); push8(u->src, (Sint16)b < (Sint16)a); } -void op_ior16(Uxn *u) { Uint8 a = pop8(u->src); push16(u->src, devpeek16(&u->dev[a >> 4], a)); } -void op_iow16(Uxn *u) { Uint8 a = pop8(u->src); Uint16 b = pop16(u->src); devpoke16(&u->dev[a >> 4], a, b); } +void op_dei16(Uxn *u) { Uint8 a = pop8(u->src); push16(u->src, devpeek16(&u->dev[a >> 4], a)); } +void op_deo16(Uxn *u) { Uint8 a = pop8(u->src); Uint16 b = pop16(u->src); devpoke16(&u->dev[a >> 4], a, b); } /* Memory(16-bits) */ void op_pek16(Uxn *u) { Uint8 a = pop8(u->src); push16(u->src, mempeek16(u->ram.dat, a)); } void op_pok16(Uxn *u) { Uint8 a = pop8(u->src); Uint16 b = pop16(u->src); mempoke16(u->ram.dat, a, b); } @@ -103,12 +103,12 @@ void op_sft16(Uxn *u) { Uint16 a = pop16(u->src), b = pop16(u->src); push16(u->s void (*ops[])(Uxn *u) = { op_brk, op_lit, op_nop, op_pop, op_dup, op_swp, op_ovr, op_rot, - op_equ, op_neq, op_gth, op_lth, op_gts, op_lts, op_ior, op_iow, + op_equ, op_neq, op_gth, op_lth, op_gts, op_lts, op_dei, op_deo, op_pek, op_pok, op_get, op_put, op_jmp, op_jnz, op_jsr, op_sth, op_add, op_sub, op_mul, op_div, op_and, op_ora, op_eor, op_sft, /* 16-bit */ op_brk, op_lit16, op_nop, op_pop16, op_dup16, op_swp16, op_ovr16, op_rot16, - op_equ16, op_neq16, op_gth16, op_lth16, op_gts16, op_lts16, op_ior16, op_iow16, + op_equ16, op_neq16, op_gth16, op_lth16, op_gts16, op_lts16, op_dei16, op_deo16, op_pek16, op_pok16, op_get16, op_put16, op_jmp16, op_jnz16, op_jsr16, op_sth16, op_add16, op_sub16, op_mul16, op_div16, op_and16, op_ora16, op_eor16, op_sft16 };