( uxnemu basic.rom input.bas ) |00 @System/vector $2 &expansion $2 &wst $1 &rst $1 &metadata $2 &r $2 &g $2 &b $2 &debug $1 &state $1 |10 @Console/vector $2 &read $5 &type $1 &write $1 &error $1 |20 @Screen/vector $2 &width $2 &height $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1 |80 @Controller/vector $2 &button $1 &key $1 |90 @Mouse/vector $2 &x $2 &y $2 &state $1 &chord $1 |a0 @File/vector $2 &success $1 &success-lb $1 &stat $2 &delete $1 &append $1 &name $2 &length $2 &read $2 &write $2 |c0 @DateTime/year $2 &month $1 &day $1 &hour $1 &minute $1 &second $1 &dotw $1 &doty $2 &isdst $1 |000 @input/buf $3f &cap $1 @variables/buf $34 @src/buf $3f &cap $1 @bind/buf $10 &cap $1 &addr $2 |100 @on-reset ( -> ) ( | meta ) ;meta #06 DEO2 ( | theme ) #e0f1 .System/r DEO2 #e0ee .System/g DEO2 #f04a .System/b DEO2 ( | size ) #0270 .Screen/width DEO2 #0180 .Screen/height DEO2 ( | Init variables ) .Screen/width DEI2 LIT "W variables/ .Screen/height DEI2 LIT "H variables/ theme/ random/ font/ ;src/on-console .Console/vector DEO2 ;on-control .Controller/vector DEO2 .src/buf LDZ ?&soft font/ BRK &soft ( -> ) prg/ ;src/buf load/do BRK @meta 00 &body ( name ) "TinyBASIC 0a ( details ) "A 20 "BASIC 20 "interpreter 0a ( author ) "By 20 "Devine 20 "Lu 20 "Linvega 0a ( date ) "25 20 "Aug 20 "2025 $2 @on-control ( -> ) .Controller/key DEI input/listen BRK ( @|helpers ) @cmds/find ( str* -- str* fn* ) walk-blank STH2k walk-text ;&lut-end ;&lut &>lf LDA2k LDA2 STH2kr str/seg ?{ INC2 INC2 GTH2k ?&>lf POP2 POP2 POP2r #0000 JMP2r } POP2r NIP2 LDA2 #0004 ADD2 JMP2r @cmds/ ( -- ) .Screen/x DEI2 ;&lut-nohelp ;&lut [ LIT2r 0000 ] &>lp STHkr #03 AND ?{ font/ } STHk2r #0003 AND2 #60 SFT2 #0020 ADD2 .Screen/x DEO2 LDA2k LDA2 font/ INC2 INC2 INCr GTH2k ?&>lp POP2 POP2 POP2r .Screen/x DEO2 font/ font/ ;dict/manual font/ font/ !font/ @cmds/ ( cmd* -- ) #0002 SUB2 LDA2 font/ font/ !font/ @walk-text ( str* -- str* ) &>w LDAk #20 GTH ?{ JMP2r } INC2 !&>w @walk-blank ( str* -- str* ) &>w LDAk ?{ JMP2r } LDAk LIT ", EQU ?&skip LDAk #20 GTH ?&end &skip INC2 LDAk ?&>w &end JMP2r @walk-expr ( str* -- str* number* ) walk-number SWP2 walk-blank LDAk STH SWP2 STHr math/find ORAk ?walk-arithmetic POP2 JMP2r @walk-arithmetic ( str* number* fn* -- str* number* ) &>w ,&fn STR2 ,&a STR2 INC2 walk-number ,&b STR2 [ LIT2 &a $2 ] [ LIT2 &b $2 ] [ LIT2 &fn $2 ] JSR2 SWP2 walk-blank LDAk STH SWP2 STHr math/find ORAk ?&>w POP2 JMP2r @walk-number ( str* -- str* num* ) walk-blank LDAk [ LIT "$ ] EQU ?walk-hex LDAk chr/isuc ?walk-var LDAk chr/isdc ?walk-dec #0000 ( ! ) OVR2 ;dict/number !font/ @walk-var ( str* -- val* ) INC2k SWP2 LDA !variables/get @walk-dec ( str* -- val* ) [ LIT2r 0000 ] &>wn LIT2r 000a MUL2r LITr 00 LDAk #30 SUB STH ADD2r INC2 LDAk #30 SUB #0a LTH ?&>wn STH2r JMP2r @walk-hex ( str* -- val* ) ( walk $ ) INC2 [ LIT2r 0000 ] &>wh LITr 40 SFT2r LITr 00 LDAk chr/hex STH ADD2r INC2 LDAk chr/hex INC ?&>wh STH2r JMP2r ( @|Compiler ) @prg/ ( -- ) ;&mem #4000 mem/ dict/ !variables/ @prg/get-line ( id* -- line* ) #20 SFT2 ;&mem ADD2 JMP2r @prg/ ( str* -- ) walk-number /get-line DUP2 ;&cap LTH2 ?{ POP2 POP2 ( ! ) ;dict/overflow ;dict/line !font/ } STH2 walk-blank LDAk ?{ ( | erase line ) POP2 #0000 STH2kr INC2r INC2r STA2 #0000 STH2r STA2 JMP2r } ( | insert line ) cmds/find STH2kr INC2r INC2r STA2 walk-blank ;dict/ptr LDA2 STH2r STA2 !dict/ @prg/next-instr ( addr* -- addr* ) #0004 ADD2 JMP2r @prg/ ( addr* -- ) ;&cap SWP2 [ LIT2r 0000 ] &>l ( skip empty ) LDA2k ORA ?{ /next-instr !&continue } ( check overflow ) INC2r ORAkr STHr ?{ POP2 POP2 POP2r ( ! ) ;dict/infinite ;dict/loop !font/ } ( body* ) INC2k INC2 LDA2 ( body* fn* ) OVR2 LDA2 JSR2 &continue GTH2k ?&>l POP2 POP2 POP2r JMP2r @prg/ ( -- ) ;&cap ;&mem ( >> ) @prg/ ( to* from* -- ) &>ld LDA2k #0000 EQU2 ?{ DUP2 / } #0004 ADD2 GTH2k ?&>ld POP2 POP2 JMP2r @prg/ ( -- ) ;&cap ;&mem &>ls LDA2k #0000 EQU2 ?{ DUP2 DUP2 ;&mem SUB2 #02 SFT2 file/ } #0004 ADD2 GTH2k ?&>ls POP2 POP2 JMP2r @prg/ ( line* -- ) DUP2 ;&mem SUB2 #02 SFT2 !font/ @prg/ ( -- ) #0000 ;dict/ptr LDA2 SUB2 font/ ;dict/bytes-free font/ !font/ ( @|Math ) @math/add ADD2 JMP2r &sub SUB2 JMP2r &mul MUL2 JMP2r &and AND2 JMP2r &ora ORA2 JMP2r <h #8000 STH2k ADD2 SWP2 STH2r ADD2 GTH2 #00 SWP JMP2r >h #8000 STH2k ADD2 SWP2 STH2r ADD2 LTH2 #00 SWP JMP2r &equ EQU2 #00 SWP JMP2r &neq NEQ2 #00 SWP JMP2r &mod DIV2k MUL2 SUB2 JMP2r &div ORAk #00 EQU ?{ /sign STH2k MUL2 SWP2 /sign STH2k MUL2 MUL2r SWP2 DIV2 STH2r MUL2 JMP2r } INC2 DIV2 ( ! ) OVR2 ;dict/zdiv !font/ &sign DUP2 #0f SFT2 #ffff MUL2 #0001 ORA2 JMP2r @math/find ( char -- fn* ) STH ;&lut &>l LDAk STHkr EQU ?{ INC2 INC2 INC2 LDAk ?&>l } INC2 LDA2 POPr JMP2r ( @|LibHypervisor ) @run =dict/run =dict/help-run ( | body ) POP2 variables/ ;prg/mem !prg/ @list =dict/list =dict/help-list ( | body ) walk-blank LDAk ?&single POP2 prg/ !font/ &single ( str* -- ) walk-expr STH2 walk-blank LDAk ?&range POP2 STH2r prg/get-line prg/ !font/ &range ( str* . from* -- ) walk-expr prg/get-line INC2 NIP2 STH2r prg/get-line prg/ !font/ @clear =dict/clear =dict/help-clear ( | body ) ( no params ) POP2 theme/ !prg/ ( @|LibCore ) @rem =dict/rem =dict/help-rem ( | body ) ( no params ) POP2 !prg/next-instr @let =dict/let =dict/help-let ( | body ) &>w walk-blank LDAk ?{ POP2 !prg/next-instr } LDAk ,&var STR INC2 walk-blank LDAk [ LIT "= ] EQU ?{ ( ! ) ;dict/variable font/ !prg/next-instr } INC2 walk-expr [ LIT &var $1 ] variables/ !&>w @if =dict/if =dict/help-if ( | body ) walk-expr ORA ?{ POP2 !prg/next-instr } !str/ @goto =dict/goto =dict/help-goto ( | body ) walk-expr DUP2 prg/get-line LDA2 ORA ?{ POP2 NIP2 #f000 ( ! ) SWP2 ;dict/line !font/ } NIP2 NIP2 !prg/get-line @end =dict/end =dict/help-end ( | body ) POP2 ( replace addr* ) POP2 #fff0 JMP2r ( @|LibSubroutines ) @gosub =dict/gosub =dict/help-gosub ( | body ) walk-expr DUP2 prg/get-line LDA2 ORA ?{ POP2 NIP2 #f000 ( ! ) SWP2 ;dict/line !font/ } NIP2 SWP2 #0004 ADD2 gosub/ !prg/get-line @return =dict/return =dict/help-return ( | body ) POP2 POP2 !gosub/pop ( @|LibIO ) @print =dict/print =dict/help-print ( | body ) [ LIT2 01 _&lb ] STR &>w walk-blank / LDAk ?&>w POP2 [ LIT2 00 &lb $1 ] EQU ?{ font/ } !prg/next-instr & ( str* -- str* ) LDAk LIT "; NEQ ?{ INC2 [ LIT2 00 _&lb ] STR !font/ } LDAk [ LIT "" ] NEQ ?{ INC2 !font/ } LDAk [ LIT "# ] NEQ ?{ INC2 walk-expr NIP !font/ } LDAk cixp ?{ walk-expr !font/ } LDAk #00 EQU ?{ ( ! ) ;dict/print !font/ } JMP2r @input =dict/input =dict/help-input ( | body ) variables/ ( replace addr* ) bind/ #fff0 JMP2r ( @|LibSystem ) @load =dict/load =dict/help-load &do ( str* -- ) walk-blank src/ ;src/buf file/exists ?{ ( ! ) ;src/buf ;dict/file !font/ } prg/ dict/ input/ ;src/buf .File/name DEO2 #0001 .File/length DEO2 [ LIT2r =&b LITr -File/read ] .File/success-lb &>s DEO2kr DEIk ?{ POPr POP2r POP prg/ font/ !prg/next-instr } [ LIT &b $1 ] input/listen !&>s @save =dict/save =dict/help-save ( | body ) walk-blank .File/name DEO2 #0001 .File/length DEO2 prg/ !prg/next-instr ( @|LibDraw ) @color =dict/color =dict/help-color ( | body ) LDAk #00 EQU ?{ walk-expr .System/r DEO2 walk-expr .System/g DEO2 walk-expr .System/b DEO2 } POP2 !prg/next-instr @cls =dict/cls =dict/help-cls ( | body ) POP2 #0020 ;font/anchor STA2 font/ !prg/next-instr @draw =dict/draw =dict/help-draw ( | body ) ( x ) walk-expr ( > ) ORAk #00 EQU ?{ DUP2 .Screen/x DEO2 DUP2 ;font/anchor STA2 } POP2 ( y ) walk-expr ( > ) ORAk #00 EQU ?{ DUP2 .Screen/y DEO2 } POP2 POP2 font/ !prg/next-instr @mode =dict/mode =dict/help-mode ( | body ) walk-expr NIP2 NIP ;font/color STA !prg/next-instr @sprite =dict/sprite =dict/help-sprite ( | body ) walk-expr icn/ walk-expr icn/ walk-expr icn/ walk-expr icn/ POP2 !prg/next-instr @pict =dict/pict =dict/help-pict ( | body ) walk-blank icn/ !prg/next-instr @help =dict/help =meta/body ( | body ) walk-blank LDAk ?{ POP2 !cmds/ } cmds/find ORAk ?{ NIP2 ;dict/command !font/ } NIP2 !cmds/ @poke =dict/poke =dict/help-poke ( | body ) walk-expr #30 SFT2 ;font/sprites ADD2 STH2 &>w walk-blank LDAk ?{ POP2 POP2r !prg/next-instr } walk-expr STH2kr INC2r INC2r STA2 !&>w ( @|buffers ) @src/on-console ( -> ) [ LIT2 0a -Console/read ] DEI NEQk ?{ POP2 ;&buf load/do BRK } / POP BRK @src/ ( c -- ) [ LIT &ptr -&buf ] DUP .&cap NEQ ?{ POP2 ( ! ) ;dict/overflow ;dict/path !font/ } INCk ,&ptr STR STZ JMP2r @src/ ( str* -- ) [ LIT2 -&buf _&ptr ] STR &>w LDAk DUP ?{ / POP2 JMP2r } / INC2 !&>w @dict/ ( str* -- ) ( | TODO: Find and alloc ) LDAk ?{ ( String is empty ) POP2 JMP2r } &>w LDAk DUP #1f GTH ?{ POP POP2 #00 !/ } / INC2 !&>w @dict/ ( byte -- ) [ LIT2 &ptr =&mem ] DUP2 ;&cap NEQ2 ?{ POP2 ( ! ) ;dict/overflow ;dict/line !font/ } INC2k ,&ptr STR2 STA JMP2r @dict/ ( -- ) ;&mem ,&ptr LDR2 OVR2 SUB2 !mem/ @gosub/ ( line* -- ) [ LIT2 &ptr =&mem ] ( OF ) DUP2 ;&cap NEQ2 ?{ POP2 ( ! ) ;dict/overflow ;dict/gosub !font/ } INC2k INC2 ,&ptr STR2 STA2 JMP2r @gosub/pop ( -- line* ) ,&ptr LDR2 ( UF ) DUP2 ;&mem NEQ2 ?{ POP2 #f000 ( ! ) ;dict/underflow ;dict/gosub !font/ } #0002 SUB2 DUP2 ,&ptr STR2 LDA2 JMP2r @input/listen ( char -- ) DUP #08 EQU ?&erase DUP #0a EQU ?&parse DUP #0d EQU ?&parse #20 LTHk NIP ?&end #7e GTHk NIP ?&end DUP / DUP / &end POP JMP2r @input/erase ( c -- ) POP ( | handle cap ) [ LIT2 -&buf _&ptr ] LDR NEQ ?{ JMP2r } /pop ( | handle draw ) [ LIT2 00 -Screen/auto ] DEO font/ .Screen/x DEI2k ( clamp ) #0020 GTH2k [ JMP SWP2 POP2 ] ROT DEO2 [ LIT2 00 -Screen/sprite ] DEO [ LIT2 01 -Screen/auto ] DEO !font/ @input/ ( -- ) .bind/addr LDZ ?/ ;&buf LDAk #20 LTH ?{ LDAk chr/isdc ?prg/ !str/ } POP2 JMP2r @input/ ( -- ) ;&buf &>wb walk-blank walk-expr bind/assoc ?{ POP2 !bind/ } LDAk ?&>wb POP2 JMP2r @input/parse ( c -- ) POP font/ / ( >> ) @input/ ( -- ) #0000 .&buf DUP ,&ptr STR STZ2 JMP2r @input/ ( char -- ) [ LIT2 00 &ptr -&buf ] ( cap ) DUP .&cap NEQ ?{ POP2 JMP2r } INCk ,&ptr STR STZ2 JMP2r @input/pop ( -- ) [ LIT2 00 _&ptr ] LDR #01 SUB DUP ,&ptr STR STZ JMP2r @input/ ( char -- ) font/ !font/ @variables/ ( -- ) ;&buf #0034 !mem/ @variables/ ( value* uc -- ) [ LIT "A ] SUB ( ! ) DUP #1a LTH ?{ POP POP2 ( ! ) ;dict/variable !font/ } DUP ADD .&buf ADD STZ2 JMP2r @variables/get ( uc -- value* ) DUP LIT "R NEQ ?{ POP !random/generate } [ LIT "A ] SUB DUP ADD .&buf ADD LDZ2 JMP2r @variables/ ( str* -- ) &>w walk-blank LDAk chr/isuc #00 EQU ?{ LDAk bind/ } INC2 LDAk ?&>w POP2 JMP2r @bind/ ( var -- ) [ LIT &ptr -&buf ] DUP .&cap NEQ ?{ POP ( ! ) ;dict/overflow ;dict/line !font/ } INCk ,&ptr STR STZ JMP2r @bind/pop ( -- var ) [ LIT &queue -&buf ] ( OF ) DUP ,&ptr LDR LTH ?{ POP #00 JMP2r } INCk ,&queue STR LDZ JMP2r @bind/assoc ( value* -- left ) /pop variables/ ( diff ) ,&ptr LDR ,&queue LDR SUB JMP2r @bind/ ( addr* -- ) #0004 ADD2 .&addr STZ2 ;&on-mouse .Mouse/vector DEO2 ;&on-control .Controller/vector DEO2 JMP2r @bind/ ( -- ) [ LIT2 01 -Screen/auto ] DEO #0000 .Mouse/vector DEO2 ;on-control .Controller/vector DEO2 .&addr LDZ2 #0000 .&addr STZ2 !prg/ @bind/on-mouse ( -> ) cursor/ [ LIT &last $1 ] .Mouse/state DEI DUP ,&last STR #0001 EQU2 ?{ BRK } ( | x ) .Mouse/x DEI2 /assoc ?{ cursor/ / BRK } ( | y ) .Mouse/y DEI2 /assoc ?{ cursor/ / BRK } BRK @bind/on-control ( -> ) [ LIT2 00 -Controller/button ] DEI DUP ?{ POP2 .Controller/key DEI DUP ?{ POP BRK } input/listen BRK } /assoc ?{ / } BRK ( @|Icon ) @icn/ ( src* -- ) DUP2 file/exists ?{ ( ! ) ;dict/file !font/ } DUP2 .File/name DEO2 #0008 .File/length DEO2 /read-size ,&height STR ,&width STR .Screen/x DEI2 ,&anchor STR2 ;&mem .Screen/addr DEO2 ( | draw ) [ LIT2 01 -Screen/auto ] DEO [ LIT2 &height $1 00 ] [ LIT2r =font/color ] LDAr [ LITr -Screen/sprite ] &>v [ LIT2 &anchor $2 ] .Screen/x DEO2 [ LIT2 &width $1 00 ] &>h ;&mem .File/read DEO2 DEOkr INC GTHk ?&>h POP2 font/ INC GTHk ?&>v POP2 POP2r JMP2r @icn/ ( short* -- ) [ LIT2 &ptr =&mem ] INC2k INC2 STH2k ,&ptr STR2 STA2 STH2r ;&cap NEQ2 ?{ ;&mem DUP2 .Screen/addr DEO2 ,&ptr STR2 ;font/color LDA .Screen/sprite DEO } JMP2r @icn/read-size ( str* -- w h ) str/cap #000a SUB2 LDA2k /read-byte STH #0003 ADD2 LDA2 /read-byte STHr SWP JMP2r @icn/read-byte ( a b -- byte ) chr/hex SWP chr/hex #40 SFT ORA JMP2r ( @|draw ) @ ( -- ) #0000 .Screen/x DEO2 #0000 .Screen/y DEO2 [ LIT2 82 -Screen/pixel ] DEO ( | left ) #0018 .Screen/x DEO2 #0000 .Screen/y DEO2 [ LIT2 90 -Screen/pixel ] DEO ( | top ) #0000 .Screen/x DEO2 #0018 .Screen/y DEO2 [ LIT2 a0 -Screen/pixel ] DEO ( | right ) .Screen/width DEI2 #0018 SUB2 .Screen/x DEO2 #0000 .Screen/y DEO2 [ LIT2 80 -Screen/pixel ] DEO ( | bottom ) #0000 .Screen/x DEO2 .Screen/height DEI2 #0018 SUB2 .Screen/y DEO2 [ LIT2 80 -Screen/pixel ] DEO ( | resume ) [ LIT2 01 -Screen/auto ] DEO #0020 .Screen/x DEO2 #0018 .Screen/y DEO2 !font/ @logo/ ( -- ) [ LIT2 46 -Screen/auto ] DEO ;&sprite .Screen/addr DEO2 [ LIT2 05 -Screen/sprite ] DEOk DEOk DEOk DEOk DEOk DEO JMP2r ( @|font ) @font/ ( -- ) logo/ [ LIT2 01 -Screen/auto ] DEO / / ;dict/varvara / / ;dict/guide / prg/ !/ @font/ ( -- ) / ;dict/ready / !/ @font/ ( line* id* -- ) OVR2 LDA2 ORA ?{ POP2 POP2 JMP2r } / / LDA2k #0004 SUB2 LDA2 / / INC2 INC2 LDA2 / !/ @font/ ( str* name* -- ) ;dict/error / LIT "< / / LIT "> / LIT ": / / / / ;hash-icn .Screen/addr DEO2 [ LIT2 05 -Screen/sprite ] DEO .Screen/x DEI2k #0008 SUB2 ROT DEO2 JMP2r @font/ ( str* -- str* ) &>wdq LDAk [ LIT "" ] EQU ?{ LDAk / INC2 LDAk ?&>wdq } INC2 JMP2r @font/ ( str* -- ) &>wds LDAk DUP ?{ POP POP2 JMP2r } / INC2 !&>wds @font/ ( char -- ) DUP #0a NEQ ?{ POP !/ } #00 SWP #30 SFT2 ;&sprites ADD2 .Screen/addr DEO2 [ LIT2 &color 09 -Screen/sprite ] DEO JMP2r @font/ ( short* -- ) OVR #80 AND #00 EQU ?/ [ LIT "- ] / #7fff AND2 #8000 SWP2 SUB2 @font/ ( short* -- ) [ LIT2 01 -Screen/auto ] DEO #00 ,&z STR #2710 / #03e8 / #0064 / #000a / NIP #30 ADD !/ @font/ ( a* b* -- ) DIV2k DUPk [ LIT &z $1 ] EQU ?{ DUP #30 ADD / #ff ,&z STR } POP MUL2 SUB2 JMP2r @font/ ( -- ) [ LIT2 &anchor 0020 ] .Screen/x DEO2 .Screen/y DEI2k #0008 ADD2 STH2k ROT DEO2 STH2r .Screen/height DEI2 #0018 SUB2 LTH2 ?{ ! } JMP2r @font/ ( -- ) / / ( >> ) @font/ ( -- ) ;fill-icn .Screen/addr DEO2 [ LIT2 01 -Screen/sprite ] DEO .Screen/x DEI2k #0008 SUB2 ROT DEO2 JMP2r @font/ ( -- ) ;fill-icn .Screen/addr DEO2 [ LIT2 02 -Screen/sprite ] DEO .Screen/x DEI2k #0008 SUB2 ROT DEO2 JMP2r @font/ ( -- ) .Screen/x DEI2k #0008 ADD2 ROT DEO2 JMP2r @cursor/ ( -- ) [ LIT2 12 -Screen/auto ] DEO #40 ;fill-icn !/ @cursor/ ( -- ) / [ LIT2 16 -Screen/auto ] DEO #c1 ;&down-chr .Mouse/state DEI ?{ POP2 ;&up-chr } .Mouse/x DEI2 ,&x STR2 .Mouse/y DEI2 ,&y STR2 ( >> ) @cursor/ ( color addr* -- ) .Screen/addr DEO2 [ LIT2 &x $2 ] #0004 SUB2 .Screen/x DEO2 [ LIT2 &y $2 ] #0004 SUB2 .Screen/y DEO2 .Screen/sprite DEOk DEO JMP2r ( @|theme ) @theme/ ( -- ) ;&path .File/name DEO2 #0002 .File/length DEO2 ;&r .File/read DEO2 ;&g .File/read DEO2 ;&b .File/read DEO2 .File/success DEI2 ORA ?{ JMP2r } LIT2 &r $2 .System/r DEO2 LIT2 &g $2 .System/g DEO2 LIT2 &b $2 .System/b DEO2 JMP2r &path ".theme $1 ( @|random ) @random/ ( -- ) ( ) [ LIT2 00 -DateTime/second ] DEI ( ) [ LIT2 00 -DateTime/minute ] DEI #60 SFT2 EOR2 ( ) [ LIT2 00 -DateTime/hour ] DEI #c0 SFT2 EOR2 ,&x STR2 ( ) [ LIT2 00 -DateTime/hour ] DEI #04 SFT2 ( ) [ LIT2 00 -DateTime/day ] DEI DUP2 ADD2 EOR2 ( ) [ LIT2 00 -DateTime/month ] DEI #60 SFT2 EOR2 ( ) .DateTime/year DEI2 #a0 SFT2 EOR2 ,&y STR2 JMP2r @random/generate ( -- number* ) ( ) [ LIT2 &x $2 ] ( ) DUP2 #50 SFT2 EOR2 ( ) DUP2 #03 SFT2 EOR2 ( ) [ LIT2 &y $2 ] DUP2 ,&x STR2 ( ) DUP2 #01 SFT2 EOR2 EOR2 ( ) ,&y STR2k POP JMP2r @file/ ( line* id* -- ) / #20 / LDA2k #0004 SUB2 LDA2 / #20 / INC2 INC2 LDA2 / #0a !/ @file/ ( str* -- ) &>w LDAk DUP ?{ POP POP2 JMP2r } / INC2 !&>w @file/ ( short* -- ) [ LIT2r ff00 ] &>read #000a DIV2k STH2k MUL2 SUB2 STH2r INCr ORAk ?&>read POP2 &>write NIP #30 ADD / OVRr ADDr STHkr ?&>write POP2r JMP2r @file/ ( byte -- ) ,&b STR ;&b .File/write DEO2 JMP2r @file/exists ( -- t ) .File/name DEO2 #0001 .File/length DEO2 ;&b .File/stat DEO2 [ LIT &b $1 ] chr/hex INC JMP2r ( @|stdlib ) @cixp ( c -- f ) DUP chr/isuc ?{ DUP chr/isdc ?{ LIT "$ NEQ JMP2r } } POP #00 JMP2r @chr/isuc ( c -- f ) [ LIT "A ] SUB #1a LTH JMP2r @chr/isdc ( c -- f ) [ LIT "0 ] SUB #0a LTH JMP2r @chr/hex ( char -- ) ( dec ) [ LIT "0 ] SUB DUP #09 GTH [ JMP JMP2r ] ( hex ) #27 SUB DUP #0a SUB #05 GTH [ JMP JMP2r ] ( nil ) POP #ff JMP2r @str/cap ( str* -- end* ) LDAk ?{ INC2 JMP2r } INC2 !/cap @str/ ( str* -- ) cmds/find ORAk ?{ ( | TODO: weird? this should be POP2 ) NIP2 ( ! ) ;dict/command !font/ } JMP2 @str/seg ( a* b* -- bool ) STH2 &>ws LDAk LDAkr STHr NEQ ?&e INC2r INC2 LDAk ?&>ws &e POP2r LDA #00 EQU JMP2r @mem/ ( src* len* -- ) ,&lclr STR2 ,&aclr STR2 ;&clr .System/expansion DEO2 JMP2r &clr 00 &lclr $2 0000 &aclr $2 00 ( @|assets ) @cmds/lut [ =run =list =clear =rem =let =if =goto =end =gosub =return =print =input =save =load =color =cls =draw =mode =sprite =pict &lut-nohelp =help =poke &lut-end ] @math/lut [ "+ =&add "- =&sub "* =&mul "/ =&div "& =&and "| =&ora "< =<h "> =>h "= =&equ "! =&neq "% =&mod $3 ] @dict/varvara "SUNFLOWER 20 "BASIC 20 $1 &guide "TYPE 20 ""HELP" 20 "FOR 20 "INFO 20 7f 20 $1 &bytes-free 20 "BYTES 20 "FREE 0a $1 &manual "TYPE 20 ""HELP 20 "PRINT" 20 "FOR 20 "PRINT 20 "DETAILS $1 &ready "READY. $1 &help "HELP $1 &error "ERROR $1 &infinite "INFINITE $1 &line "LINE $1 &path "PATH $1 &file "FILE $1 &loop "LOOP $1 &zdiv "DIV-BY-ZERO $1 &underflow "UNDERFLOW $1 &overflow "OVERFLOW $1 &number "NUMBER $1 &variable "VARIABLE $1 &command "COMMAND $1 &run "RUN $1 &help-run 7f "RUN 20 "Begin 20 "evaluation 20 "from 20 "smallest 20 "line 20 "number. $1 &list "LIST $1 &help-list 7f "LIST 20 20 20 20 20 20 20 2020 "Print 20 "entire 20 "program. 0a ( > ) 7f "LIST 20 "12 20 20 20 20 2020 "Print 20 "line 20 "12 0a ( > ) 7f "LIST 20 "20, 20 "30 2020 "Print 20 "lines 20 "20 20 "to 20 "30. $1 &clear "CLEAR $1 &help-clear 7f "CLEAR 2020 "Erase 20 "entire 20 "program. $1 &rem "REM $1 &help-rem 7f "REM 20 "This 20 "is 20 "a 20 "comment.. 2020 "Leave 20 "remark. $1 &let "LET $1 &help-let 7f "LET 20 "X=12, 20 "Y=A+1 2020 "Assign 20 "expression 20 "to 20 "variable. $1 &if "IF $1 &help-if 7f "IF 20 "A>B 20 "PRINT 20 "C 2020 "Evaluate 20 "only 20 "when 20 "not 20 "zero. $1 &goto "GOTO $1 &help-goto 7f "GOTO 20 "A+1 2020 "Continue 20 "evaluation 20 "at 20 "line. $1 &end "END $1 &help-end 7f "END 2020 "Terminate 20 "evaluation. $1 &gosub "GOSUB $1 &help-gosub 7f "GOSUB 20 "A+1 2020 "Evaluate 20 "subroutine 20 "until 20 "RETURN. $1 &return "RETURN $1 &help-return 7f "RETURN 2020 "Continue 20 "evaluation 20 "from 20 "subroutine. $1 &print "PRINT $1 &help-print 7f "PRINT 20 ""A 20 "string" 20 "A+1 2020 "Display 20 "text 20 "with 20 "linebreak. 0a ( > ) 7f "PRINT 20 ""A 20 "string"; 20 20 20 2020 "Display 20 "text. $1 &input "INPUT $1 &help-input 7f "INPUT 20 "X, 20 "Y 2020 "Pause 20 "evaluation 20 "until 20 "user 20 "input. $1 &load "LOAD $1 &help-load 7f "LOAD 20 "input.bas 2020 "Load 20 "basic 20 "file. $1 &save "SAVE $1 &help-save 7f "SAVE 20 "output.bas 2020 "Save 20 "basic 20 "file. $1 &color "COLOR $1 &help-color 7f "COLOR 20 "$50f2, 20 "$b0f9, 20 "$a0f8 2020 "Set 20 "interface 20 "colors. $1 &cls "CLS $1 &help-cls 7f "CLR 2020 "Clear 20 "screen. $1 &draw "DRAW $1 &help-draw 7f "DRAW 20 "32, 20 "48 2020 "Set 20 "drawing 20 "position. $1 &mode "MODE $1 &help-mode 7f "MODE 20 "2 2020 "Set 20 "drawing 20 "mode. $1 &sprite "SPRITE $1 &help-sprite 7f "SPRITE 20 "$1c1c, 20 "$087f, 20 "$0814, 20 "$2241 2020 "Paint 20 "8x8 20 "sprite. $1 &pict "PICT $1 &help-pict 7f "PICT 20 "image20x20.icn 2020 "Paint 20 "1-bit 20 "image. $1 &poke "POKE $1 &help-poke 7f "POKE 20 "$10, 20 "$1234, 20 "$4567, 20 ".. 2020 "Set 20 "data 20 "at 20 "$10. $1 @fill-icn [ ffff ffff ffff ffff ] @hash-icn [ aa55 aa55 aa55 aa55 ] @cursor/up-chr [ 0000 0000 0814 1417 0000 0000 0008 0808 0000 0000 0000 00c0 0000 0000 0000 0000 1010 2010 1008 0700 0f0f 1f0f 0f07 0000 2010 1010 2020 c000 c0e0 e0e0 c0c0 0000 ] &down-chr [ 0000 0000 0000 0817 0000 0000 0000 0008 0000 0000 0000 00c0 0000 0000 0000 0000 1010 2010 1008 0700 0f0f 1f0f 0f07 0000 2010 1010 2020 c000 c0e0 e0e0 c0c0 0000 ] @font/sprites ( atari8 ) $100 [ 0000 0000 0000 0000 6060 6060 6000 6000 6666 6600 0000 0000 006c fe6c 6cfe 6c00 183e 603c 067c 1800 0066 6c18 3066 4600 386c 3870 decc 7600 6060 6000 0000 0000 1c30 3030 3030 1c00 380c 0c0c 0c0c 3800 0066 3cff 3c66 0000 0018 187e 1818 0000 0000 0000 0030 3060 0000 007e 0000 0000 0000 0000 0018 1800 0306 0c18 3060 c000 3c66 6e76 6666 3c00 1838 1818 1818 7e00 3c66 060c 1830 7e00 7e0c 180c 0666 3c00 0c1c 3c6c 7e0c 0c00 7e60 7c06 0666 3c00 3c60 607c 6666 3c00 7e06 0c18 3030 3000 3c66 663c 6666 3c00 3c66 663e 060c 3800 0018 1800 0018 1800 0018 1800 1818 3000 0c18 3060 3018 0c00 0000 7e00 007e 0000 3018 0c06 0c18 3000 3c66 060c 1800 1800 3c66 6e6a 6e60 3e00 183c 6666 7e66 6600 7c66 667c 6666 7c00 3c66 6060 6066 3c00 786c 6666 666c 7800 7e60 607c 6060 7e00 7e60 607c 6060 6000 3e60 606e 6666 3e00 6666 667e 6666 6600 3c18 1818 1818 3c00 3e06 0606 0666 3c00 666c 7870 786c 6600 6060 6060 6060 7e00 c6ee fed6 c6c6 c600 6676 7e7e 6e66 6600 3c66 6666 6666 3c00 7c66 667c 6060 6000 3c66 6666 766c 3600 7c66 667c 6c66 6600 3c66 603c 0666 3c00 7e18 1818 1818 1800 6666 6666 6666 3e00 6666 6666 663c 1800 c6c6 c6d6 feee c600 6666 3c18 3c66 6600 6666 663c 1818 1800 7e06 0c18 3060 7e00 3c30 3030 3030 3c00 c060 3018 0c06 0300 3c0c 0c0c 0c0c 3c00 1038 6cc6 0000 0000 0000 0000 0000 fe00 0060 3018 0000 0000 0000 3c06 3e66 3e00 6060 7c66 6666 7c00 0000 3c60 6060 3c00 0606 3e66 6666 3e00 0000 3c66 7e60 3c00 1c30 7c30 3030 3000 0000 3e66 663e 067c 6060 7c66 6666 6600 1800 3818 1818 3c00 1800 1818 1818 1870 6060 666c 786c 6600 3818 1818 1818 3c00 0000 ecfe d6c6 c600 0000 7c66 6666 6600 0000 3c66 6666 3c00 0000 7c66 6666 7c60 0000 3e66 6666 3e06 0000 7c66 6060 6000 0000 3e60 3c06 7c00 0018 7e18 1818 0e00 0000 6666 6666 3e00 0000 6666 663c 1800 0000 c6c6 d67c 6c00 0000 663c 183c 6600 0000 6666 663e 067c 0000 7e0c 1830 7e00 1c30 3060 3030 1c00 1818 1818 1818 1818 380c 0c06 0c0c 3800 0000 60f2 9e0c 0000 1038 7cfe 7c38 1000 ] $2 @logo/sprite [ 0000 0000 0000 0303 0000 0000 0000 00e0 0000 1818 3c7e 7e7e 0000 0000 0000 0007 0000 0000 0000 c0c0 0101 0100 0000 0000 f8fc feff ff7f 3f1f ffff ffff ffff c300 1f3f 7fff fffe fcf8 8080 8000 0000 0000 0007 0f3f 3f0f 0700 fefe fcfc fcfc fefe 0000 4200 0042 3c00 7f7f 3f3f 3f3f 7f7f 00e0 f0fc fcf0 e000 0000 0000 0001 0101 1f3f 7fff fffe fcf8 00c3 ffff ffff ffff f8fc feff ff7f 3f1f 0000 0000 0080 8080 0303 0000 0000 0000 e000 0000 0000 0000 7e7e 7e3c 1818 191b 0700 0000 0000 e0c0 c0c0 0000 0000 0000 0000 0000 0000 0000 0007 0300 0000 0000 1e9c d878 3810 0810 0000 0000 0000 0000 0000 0000 0000 0000 ] ( @|Buffers ) @gosub/mem $40 &cap $2 @icn/mem $8 &cap @prg/mem $4000 &cap @dict/mem |eff8 @dict/cap