( 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 |ff00 @halt |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 ) #f01e .System/r DEO2 #d0ee .System/g DEO2 #40af .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/ ;input/on-console .Console/vector DEO2 ;input/on-control .Controller/vector DEO2 ( | make output ) [ LIT &made 01 ] ?{ ;prg/mem prg/ BRK } ( | expect path ) .src/buf LDZ ?&soft [ LIT2 00 -Console/type ] DEI EQU ?{ ( override ) ;src/on-console .Console/vector DEO2 } font/ BRK &soft ( -> ) prg/ ;src/buf file/ BRK @meta 00 &body "TinyBASIC 0a ( details ) "A 20 "BASIC 20 "interpreter 0a ( author ) "By 20 "Devine 20 "Lu 20 "Linvega 0a ( date ) "12 20 "Dec 20 "2025 $2 ( @|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 !prg/next-instr @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/ ( str* -- ) LDAk ?{ POP2 !cmds/ } cmds/find ORAk ?{ ;dict/command !font/ } ( draw one ) NIP2 #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 STH2 &>w walk-blank LDAk math/find ORAk ?{ POP2 STH2r JMP2r } STH2 INC2 walk-number STH2r STH2r ROT2 ROT2 JSR2 STH2 !&>w @walk-number ( str* -- str* num* ) walk-blank LDAk [ LIT "$ ] EQU ?walk-hex LDAk chr/isuc ?walk-var LDAk chr/isdc ?walk-dec ( advance ) INC2 #0000 ( ! ) OVR2 ;dict/number !font/ @walk-var ( str* -- str* val* ) INC2k LDAk LIT ". NEQ ?{ INC2 walk-expr STH POP SWP2 LDA STHr ADD !variables/get } SWP2 LDA !variables/get @walk-dec ( str* -- 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* -- 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 ( | erase line ) walk-blank LDAk ?{ POP2 STH2r #0004 !mem/ } ( | insert line ) cmds/find ORAk ?{ POP2 POP2r ( ! ) ;dict/command !font/ } ( | compile line ) ( cmd* ) STH2kr INC2r INC2r STA2 ( exp* ) walk-blank dict/push-str STH2r STA2 JMP2r @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/ ( name* -- ) .File/name DEO2 #0001 .File/length DEO2 ;&cap ;&mem &>ls LDA2k #0000 EQU2 ?{ DUP2 DUP2 ;&mem SUB2 #02 SFT2 file/ } /next-instr GTH2k ?&>ls POP2 POP2 JMP2r @prg/ ( name* -- ) #00 ;on-reset/made STA .input/buf ;input/ptr STA variables/ .File/name DEO2 ;dict/ptr LDA2 #0100 SUB2 .File/length DEO2 #0100 .File/write DEO2 #01 ;on-reset/made STA JMP2r @prg/ ( line* -- ) DUP2 ;&mem SUB2 #02 SFT2 !font/ @prg/ ( -- ) #0000 ;dict/ptr LDA2 SUB2 font/ ;dict/bytes-free font/ !font/ @prg/ ( -- ) ;&cap ;&mem ( >> ) @prg/ ( to* from* -- ) ( MIN ) ;&mem GTH2k [ JMP SWP2 ] POP2 ,&from STR2 ( MAX ) ;&cap LTH2k [ JMP SWP2 ] POP2 ,&to STR2 ;&on-screen .Screen/vector DEO2 JMP2r @prg/on-screen ( -> ) [ LIT2 &to $2 ] [ LIT2 &from $2 ] &>lo LDA2k #0000 EQU2 ?{ DUP2 / /next-instr ,&from STR2 POP2 BRK } /next-instr GTH2k ?&>lo POP2 POP2 font/ #0000 .Screen/vector DEO2 BRK ( @|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/ !prg/next-instr &single ( str* -- ) walk-expr STH2 walk-blank LDAk ?&range POP2 STH2r prg/get-line prg/ font/ !prg/next-instr &range ( str* . from* -- ) walk-expr prg/get-line INC2 NIP2 STH2r prg/get-line prg/ font/ !prg/next-instr @clear =dict/clear =dict/help-clear ( | body ) POP2 POP2 ;halt theme/ !prg/ ( @|LibCore ) @rem =dict/rem =dict/help-rem ( | body ) POP2 !prg/next-instr @let =dict/let =dict/help-let ( | body ) &>w walk-blank LDAk ?{ POP2 !prg/next-instr } variables/assign !&>w @if =dict/if =dict/help-if ( | body ) walk-expr ORA ?{ POP2 !prg/next-instr } !str/ @goto =dict/goto =dict/help-goto ( | body ) NIP2 walk-expr NIP2 !prg/get-line @end =dict/end =dict/help-end ( | body ) POP2 POP2 ;halt JMP2r ( @|LibSubroutines ) @gosub =dict/gosub =dict/help-gosub ( | body ) SWP2 prg/next-instr gosub/ walk-expr NIP2 !prg/get-line @return =dict/return =dict/help-return ( | body ) POP2 POP2 !gosub/pop @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 JMP2r } LDAk [ LIT "" ] NEQ ?{ INC2 !font/ } LDAk [ LIT "# ] NEQ ?{ INC2 walk-expr NIP !font/ } walk-expr !font/ @input =dict/input =dict/help-input ( | body ) &>w walk-blank LDAk chr/islc ?{ LDAk bind/ } INC2 LDAk ?&>w POP2 font/ ( replace addr* ) bind/ ;halt JMP2r @load =dict/load =dict/help-load ( | body ) file/ !prg/next-instr @save =dict/save =dict/help-save ( | body ) walk-blank prg/ !prg/next-instr @make =dict/make =dict/help-make ( | body ) walk-blank prg/ !prg/next-instr @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 #03ff AND2 .Screen/x DEO2 DUP2 ;font/anchor STA2 } POP2 ( y ) walk-expr ( > ) ORAk #00 EQU ?{ DUP2 #03ff AND2 .Screen/y DEO2 } POP2 POP2 !prg/next-instr @mode =dict/mode =dict/help-mode ( | body ) walk-expr NIP2 NIP ;font/color STA !prg/next-instr @pict =dict/pict =dict/help-pict ( | body ) walk-blank / !prg/next-instr @poke =dict/poke =dict/help-poke ( | body ) walk-expr #007f AND2 #30 SFT2 ;font/sprites ADD2 STH2 &>w walk-blank LDAk ?{ POP2 POP2r !prg/next-instr } walk-expr STH2kr INC2r INC2r STA2 !&>w @help =dict/help =meta/body ( | body ) walk-blank cmds/ !prg/next-instr ( @|Buffers ) @src/on-console ( -> ) [ LIT2 0a -Console/read ] DEI NEQk ?{ POP2 ;&buf file/ ;input/on-console .Console/vector DEO2 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/push-str ( str* -- ptr* ) LDAk ?{ POP2 #fffe JMP2r } [ LIT2r =dict/ptr ] LDA2r &>w LDAk DUP #1f GTH ?{ POP POP2 #00 / STH2r JMP2r } / 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 ;halt ( ! ) ;dict/underflow ;dict/gosub !font/ } #0002 SUB2 DUP2 ,&ptr STR2 LDA2 JMP2r @input/on-control ( -> ) .Controller/button DEI2 ( | Handlers ) DUP2 [ LIT2 01 "v ] NEQ2 ?{ POP2 snarf/ BRK } DUP #7f NEQ ?{ POP2 / font/ BRK } / ( | Recall history ) #10 NEQ ?{ ;history/buf / } BRK @input/on-console ( -> ) .Console/read DEI / BRK @input/ ( src* -- ) &>ws LDAk DUP ?{ POP POP2 JMP2r } / INC2 !&>ws @input/ ( 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/ DUP2 history/ !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/ @history/ ( str* -- ) ;&buf ,&ptr STR2 &>w LDAk DUP ?{ / POP2 JMP2r } / INC2 !&>w @history/ ( byte -- ) #00 [ LIT2 &ptr =&buf ] INC2k ,&ptr STR2 STA2 JMP2r @variables/ ( -- ) ;&buf #0034 !mem/ @variables/get ( uc -- value* ) DUP LIT "R NEQ ?{ POP !random/generate } [ LIT "A ] SUB ( outside ) DUP #1a LTH ?{ POP #0000 JMP2r } DUP ADD .&buf ADD LDZ2 JMP2r @variables/assign ( str* -- str* ) LDAk ,&v STR INC2 LDAk [ LIT ". ] NEQ ?{ INC2 walk-expr ,&v LDR ADD ,&v STR POP } walk-blank LDAk [ LIT ": ] EQU ?{ ( ! ) DUP2 ;dict/variable !font/ } INC2 walk-expr [ LIT &v $1 ] ( >> ) @variables/ ( value* uc -- ) [ LIT "A ] SUB ( outside ) DUP #1a LTH ?{ POP POP2 JMP2r } DUP ADD .&buf ADD STZ2 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* -- ) prg/next-instr .&addr STZ2 ;&on-mouse .Mouse/vector DEO2 ;&on-console .Console/vector DEO2 ;&on-control .Controller/vector DEO2 JMP2r @bind/ ( -- ) [ LIT2 01 -Screen/auto ] DEO #0000 .Mouse/vector DEO2 ;input/on-control .Controller/vector DEO2 ;src/on-console .Console/vector DEO2 .&addr LDZ2 #0000 .&addr STZ2 .&buf DUP ,&ptr STR ,&queue STR !prg/ @bind/on-console ( -> ) [ LIT2 00 -Console/read ] DEI /assoc ?{ / } BRK @bind/on-mouse ( -> ) cursor/ .Mouse/state DEI ?{ BRK } ( | x ) .Mouse/x DEI2 /assoc ?{ cursor/ / BRK } ( | y ) .Mouse/y DEI2 /assoc ?{ cursor/ / BRK } BRK @bind/on-control ( -> ) ( | Handle button ) .Controller/button DEI DUP ?&on-button POP ( | Handle key ) .Controller/key DEI input/ BRK @bind/on-button ( button -> ) #00 SWP .&addr LDZ ?{ POP2 BRK } /assoc ?{ / } BRK ( @|Icon ) @pict/ ( src* -- ) DUP2 file/exists ?{ ( ! ) ;dict/file !font/ } DUP2 .File/name DEO2 ( | depth ) DUP2 /read-depth .File/length DEO2 ;font/color LDA .Screen/sprite ORA2 STH2 ( | size ) /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 ] &>v [ LIT2 &anchor $2 ] .Screen/x DEO2 [ LIT2 &width $1 00 ] &>h ;&mem .File/read DEO2 [ LIT2 00 -File/success-lb ] DEI EQU ?&ended DEOkr INC GTHk ?&>h &ended POP2 .Screen/y DEI2 #0008 ADD2 .Screen/y DEO2 INC GTHk ?&>v POP2 POP2r JMP2r @pict/read-size ( str* -- w h ) str/cap #000a SUB2 LDA2k /read-byte STH #0003 ADD2 LDA2 /read-byte STHr SWP JMP2r @pict/read-byte ( a b -- byte ) chr/hex SWP chr/hex #40 SFT ORA JMP2r @pict/read-depth ( str* -- length* mask* ) str/cap #0004 SUB2 LDA2 [ LIT2 "ch ] EQU2 ?&2bit #0000 #0008 JMP2r &2bit ( str* -- length* mask* ) #8000 #0010 JMP2r ( @|Draw ) @ ( -- ) #0000 .Screen/x DEO2 #0000 .Screen/y DEO2 [ LIT2 80 -Screen/pixel ] DEO ( | left ) #0018 .Screen/x DEO2 #0000 .Screen/y DEO2 [ LIT2 93 -Screen/pixel ] DEO ( | top ) #0000 .Screen/x DEO2 #0018 .Screen/y DEO2 [ LIT2 a3 -Screen/pixel ] DEO ( | right ) .Screen/width DEI2 #0018 SUB2 .Screen/x DEO2 #0000 .Screen/y DEO2 [ LIT2 83 -Screen/pixel ] DEO ( | bottom ) #0000 .Screen/x DEO2 .Screen/height DEI2 #0018 SUB2 .Screen/y DEO2 [ LIT2 83 -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 01 -Screen/sprite ] DEOk DEOk DEOk DEOk DEOk DEO JMP2r @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 01 -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 01 -Screen/sprite ] DEO JMP2r @font/ ( short* -- ) OVR #80 AND #00 EQU ?/ [ LIT "- ] / #7fff AND2 #8000 SWP2 SUB2 @font/ ( short* -- ) [ LIT2 01 -Screen/auto ] DEO [ LIT2 00 _&z ] STR #2710 / #03e8 / #0064 / #000a / NIP #30 ADD !/ @font/ ( a* b* -- ) DIV2k DUPk [ LIT &z $1 ] EQU ?{ DUP #30 ADD / [ LIT2 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 00 -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 #c2 ;&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 ( @|Misc ) @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 @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 @snarf/ ;&path !file/ &path ".snarf $1 @file/ ( str* -- ) .File/name DEO2 #0001 .File/length DEO2 ;&b .File/read &>s DEO2k .File/success-lb DEI ?{ POP POP2 JMP2r } [ LIT &b $1 ] input/ !&>s @file/exists ( -- t ) .File/name DEO2 #0001 .File/length DEO2 ;&b .File/read DEO2 .File/success-lb DEI JMP2r @file/ ( str* -- ) walk-blank src/ ;src/buf /exists ?{ ( ! ) ;src/buf ;dict/file !font/ } prg/ dict/ input/ ;src/buf / prg/ !font/ @file/ ( line* id* -- ) / ;&ws .File/write DEO2 LDA2k #0004 SUB2 LDA2 / ;&ws .File/write DEO2 INC2 INC2 LDA2 / ;&lb .File/write DEO2 JMP2r @file/ ( byte -- ) ,&b STR ;&b .File/write DEO2 JMP2r &lb 0a &ws 20 @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 ( @|Utils ) @chr/isuc ( c -- f ) [ LIT "A ] SUB #1a LTH JMP2r @chr/islc ( c -- f ) [ LIT "A ] SUB #19 GTH 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 ?{ 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 =poke =pict &lut-nohelp =help =make &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 &make "MAKE $1 &help-make 7f "MAKE 20 "output.rom 2020 "Make 20 "rom 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 &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 "from 20 "$80. $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 @history/buf $40 @pict/mem $10 @prg/mem $4000 &cap @dict/mem |eff8 @dict/cap