mirror of https://git.sr.ht/~rabbits/uxn
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
83 lines
1.6 KiB
83 lines
1.6 KiB
( usage: uxncli console.rom foo "bar baz" |
|
| Prints Welcome to Uxn!, and listens for incoming stdin events on enter. ) |
|
|
|
|10 @Console &vector $2 &read $1 &pad $4 &type $1 &write $1 &error $1 |
|
|
|
|000 |
|
|
|
@arg $40 |
|
@std $40 |
|
|
|
|100 |
|
|
|
@on-reset ( -> ) |
|
;Dict/hello <print-str> |
|
.Console/type DEI ?{ |
|
( | no arguments ) |
|
;on-std .Console/vector DEO2 |
|
BRK } |
|
;on-arg .Console/vector DEO2 |
|
BRK |
|
|
|
@on-arg ( -> ) |
|
[ LIT2 02 -Console/type ] DEI NEQ ?{ |
|
.Console/read DEI [ LIT2 00 &ptr -arg ] INCk ,&ptr STR |
|
STZ2 |
|
BRK } |
|
;arg ;Dict/yousent <print-result> |
|
[ LIT2 -arg _&ptr ] STR |
|
[ LIT2 04 -Console/type ] DEI NEQ ?{ ;on-std .Console/vector DEO2 } |
|
BRK |
|
|
|
@on-std ( -> ) |
|
[ LIT2 0a -Console/read ] DEI EQU ?{ |
|
.Console/read DEI [ LIT2 00 &ptr -std ] INCk ,&ptr STR |
|
STZ2 |
|
BRK } |
|
;std DUP2 ;Dict/yousaid <print-result> |
|
;Dict/quit scmp ?{ |
|
[ LIT2 -std _&ptr ] STR |
|
BRK } |
|
( quit ) #800f DEO |
|
BRK |
|
|
|
@<print-result> ( buf* name* -- ) |
|
<print-str> |
|
[ LIT2 "" 18 ] DEO |
|
<print-str>/ |
|
[ LIT2 "" 18 ] DEO |
|
[ LIT2 00 -Console/type ] DEI DUP ADD ;Types ADD2 LDA2 <print-str>/ |
|
#0a18 DEO |
|
JMP2r |
|
|
|
@<print-str> ( str* -- ) |
|
LDAk #18 DEO |
|
INC2 & LDAk ?<print-str> |
|
POP2 JMP2r |
|
|
|
@scmp ( a* b* -- f ) |
|
STH2 |
|
&l ( a* b* -- f ) |
|
LDAk LDAkr STHr NEQk ?&d |
|
DUP EOR EQUk ?&d |
|
POP2 INC2 INC2r !&l |
|
|
|
&d ( a* c1 c2 b* -- f ) |
|
NIP2 POP2r EQU JMP2r |
|
|
|
( |
|
@|assets ) |
|
|
|
@Types =Dict/arg-none =Dict/arg-stdin =Dict/arg-data =Dict/arg-spacer =Dict/arg-end |
|
|
|
@Dict |
|
&hello "Welcome 20 "to 20 "Uxn! 0a $1 |
|
&yousaid "You 20 "said: 20 $1 |
|
&yousent "You 20 "sent: 20 $1 |
|
&quit "quit $1 |
|
&arg-none "<none> $1 |
|
&arg-stdin "<stdin> $1 |
|
&arg-data "<data> $1 |
|
&arg-spacer "<spacer> $1 |
|
&arg-end "<end> $1 |
|
|
|
|