uxn

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

commit 14bf95ba390f9cb84c23ed084b69787efe253e06
parent 94f6627145ea769fa7500b1851b62580937c51d0
Author: neauoire <aliceffekt@gmail.com>
Date:   Tue,  5 Dec 2023 11:55:46 -0800

(console.tal) Improved example

Diffstat:
Mprojects/examples/devices/console.tal | 103++++++++++++++++++++++++++++++++++++++-----------------------------------------
1 file changed, 49 insertions(+), 54 deletions(-)

diff --git a/projects/examples/devices/console.tal b/projects/examples/devices/console.tal @@ -10,90 +10,86 @@ @on-reset ( -> ) ;on-argument .Console/vector DEO2 + .Console/type DEI ?{ ;on-stdin .Console/vector DEO2 } ;dict/hello <print-str> - .Console/type DEI ?&has-arg BRK - &has-arg ( -> ) - ;dict/queue <print-str> - BRK @on-argument ( -> ) - .Console/type DEI ?&>no-argend - ;on-stdin .Console/vector DEO2 - BRK &>no-argend - .Console/read DEI .buf skey ?&eval + .Console/read DEI .buf skey ?{ BRK } + <print-type> + ;dict/yousent <print-str> + LIT "" #18 DEO + ;buf <print-str>/ + LIT "" #18 DEO + #0a18 DEO + ;buf sclr/ .Console/type DEI #04 NEQ ?{ + ;dict/argend <print-str> + ;on-stdin .Console/vector DEO2 } BRK - &eval ( -> ) - <print-type> - ;dict/yousent <print-str> - LIT "" #18 DEO - ;buf <print-str> - LIT "" #18 DEO - #0a18 DEO - ;buf sclr .Console/type DEI #04 NEQ ?&>no-close - ;dict/argend <print-str> - ;on-stdin .Console/vector DEO2 &>no-close - BRK @on-stdin ( -> ) - .Console/read DEI .buf skey ?&eval - BRK - &eval ( -> ) - <print-type> - ;buf ;dict/quit scmp ?&quit - ;dict/yousaid <print-str> - LIT "" #18 DEO - ;buf <print-str> - LIT "" #18 DEO - #0a18 DEO - ;buf sclr BRK + .Console/read DEI .buf skey ?{ BRK } + ;buf ;dict/quit scmp ?&quit + <print-type> + ;dict/yousaid <print-str> + LIT "" #18 DEO + ;buf <print-str>/ + LIT "" #18 DEO + #0a18 DEO + ;buf sclr/ BRK &quit ( buf* -> ) - #010f DEO + #800f DEO BRK @<print-type> ( -- ) - [ LIT2 00 -Console/type ] DEI #01 GTH DUP ADD ;types ADD2 LDA2 !<print-str> + [ LIT2 00 -Console/type ] DEI #01 GTH DUP ADD ;types ADD2 + ( ) LDA2 !<print-str>/ ( @|stdlib ) @<print-str> ( str* -- ) - !& - &while ( -- ) + &w ( -- ) LDAk #18 DEO - INC2 & LDAk ?&while + INC2 & LDAk ?&w POP2 JMP2r -@skey ( key buf -- proc ) - OVR #20 LTH ?&eval - #00 SWP sput #00 JMP2r - &eval POP2 #01 JMP2r - @sclr ( str* -- ) - !& - &while ( -- ) + &w ( -- ) STH2k #00 STH2r STA - INC2 & LDAk ?&while + INC2 & LDAk ?&w POP2 JMP2r +@skey ( key buf -- proc ) + OVR #20 LTH ?{ + #00 SWP sput #00 JMP2r } + POP2 #01 JMP2r + @scap ( str* -- end* ) - !& - &while ( -- ) - INC2 & LDAk ?&while + &w ( -- ) + INC2 & LDAk ?&w JMP2r @sput ( chr str* -- ) - scap INC2k #00 ROT ROT STA - STA + scap/ STA JMP2r @scmp ( a* b* -- f ) STH2 - &loop ( -- ) - LDAk LDAkr STHr ANDk #00 EQU ?&e - NEQk ?&e - POP2 INC2 INC2r !&loop - &e NIP2 POP2r EQU JMP2r + &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 + +@<phex> ( short* -- ) + SWP <phex>/b + &b ( -- ) + DUP #04 SFT <phex>/c + &c ( -- ) + #0f AND DUP #09 GTH #27 MUL ADD [ LIT "0 ] ADD #18 DEO + JMP2r ( @|assets ) @@ -109,5 +105,4 @@ &arg "(arg) $1 &quit "quit $1 &argend "(argend) 0a $1 - &queue "(queue) 0a $1