( gui/terminal ) %+ { ADD } %- { SUB } %* { MUL } %/ { DIV } %< { LTH } %> { GTH } %= { EQU } %! { NEQ } %++ { ADD2 } %-- { SUB2 } %** { MUL2 } %// { DIV2 } %<< { LTH2 } %>> { GTH2 } %== { EQU2 } %!! { NEQ2 } %HALT { #010f DEO } %EMIT { #18 DEO } %PRINT { ;print-str JSR2 #0a EMIT } %DEBUG { ;print-hex/byte JSR2 #0a EMIT } %DEBUG2 { ;print-hex JSR2 #0a EMIT } %2* { #10 SFT } %2/ { #01 SFT } %2** { #10 SFT2 } %2// { #01 SFT2 } %4* { #20 SFT } %4/ { #02 SFT } %4** { #20 SFT2 } %4// { #02 SFT2 } %8* { #30 SFT } %8/ { #03 SFT } %8** { #30 SFT2 } %8// { #03 SFT2 } %10* { #40 SFT } %10/ { #04 SFT } %10** { #40 SFT2 } %10// { #04 SFT2 } %20* { #50 SFT } %20/ { #05 SFT } %20** { #50 SFT2 } %20// { #05 SFT2 } %2MOD { #01 AND } %2MOD2 { #0001 AND2 } %4MOD { #03 AND } %4MOD2 { #0003 AND2 } %8MOD { #07 AND } %8MOD2 { #0007 AND2 } %10MOD { #0f AND } %10MOD2 { #000f AND2 } %MOD { DIVk MUL SUB } %MOD2 { DIV2k MUL2 SUB2 } %AUTO-NONE { #00 .Screen/auto DEO } %AUTO-X { #01 .Screen/auto DEO } %AUTO-Y { #02 .Screen/auto DEO } %AUTO-XY { #03 .Screen/auto DEO } %AUTO-ADDR { #04 .Screen/auto DEO } %AUTO-XADDR { #05 .Screen/auto DEO } %AUTO-YADDR { #06 .Screen/auto DEO } %AUTO-XYADDR { #07 .Screen/auto DEO } %RELEASE-MOUSE { #0096 DEO } %RTN { JMP2r } %WIDTH { #40 } %HEIGHT { #20 } %PAD { #0018 } ( devices ) |00 @System &vector $2 &wst $1 &rst $1 &eaddr $2 &ecode $1 &pad $1 &r $2 &g $2 &b $2 &debug $1 &halt $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 |a0 @File &vector $2 &success $2 &stat $2 &delete $1 &append $1 &name $2 &length $2 &read $2 &write $2 |b0 @DateTime [ &year $2 &month $1 &day $1 &hour $1 &minute $1 &second $1 &dotw $1 &doty $2 &isdst $1 ] ( variables ) |0000 @buffer $80 @path $40 @frame $1 ( init ) |0100 ( -> ) ( theme ) #05f5 .System/r DEO2 #0cf5 .System/g DEO2 #0af5 .System/b DEO2 ( vectors ) ;on-button .Controller/vector DEO2 ( resize ) #00 WIDTH 8** PAD 2** ++ .Screen/width DEO2 #00 HEIGHT 8** PAD 2** ++ .Screen/height DEO2 #04 ;draw-input JSR2 LIT '. .path STZ ;clear JSR2 BRK @on-button ( -> ) .Controller/key DEI DUP #00 ! ,&no-null JCN POP BRK &no-null DUP #0d ! ,&no-enter JCN #00 ;draw-input JSR2 ;validate JSR2 #01 ;draw-input JSR2 .frame LDZk INC SWP STZ &no-enter DUP #08 ! ,&no-backspace JCN #00 ;draw-input JSR2 ;buffer ;spop JSR2 #04 ;draw-input JSR2 .frame LDZk INC SWP STZ &no-backspace DUP STHk #1f > STHr #7b < #0101 !! ,&no-valid JCN ;buffer ;slen JSR2 #007f >> ,&no-valid JCN STHk ;buffer STHr ;sput JSR2 #04 ;draw-input JSR2 .frame LDZk INC SWP STZ &no-valid POP BRK @clear ( -- ) PAD .Screen/x DEO2 PAD .Screen/y DEO2 ;&blank-icn .Screen/addr DEO2 AUTO-X HEIGHT #00 &ver WIDTH #00 &hor #03 .Screen/sprite DEO INC GTHk ,&hor JCN POP2 PAD .Screen/x DEO2 .Screen/y DEI2k #0008 ++ ROT DEO2 INC GTHk ,&ver JCN POP2 AUTO-NONE RTN &blank-icn 8000 0000 0000 0000 @validate ( -- ) ;clear JSR2 PAD .Screen/x DEO2 PAD .Screen/y DEO2 ;get-cmd JSR2 ;commands-func ++ LDA2 JSR2 ;buffer #0080 ;mclr JSR2 JMP2r @get-cmd ( -- cmd* ) ;commands/end ;commands &loop LDA2k ;buffer ;scmp-seg JSR2 #00 = ,&continue JCN NIP2 ;commands -- RTN &continue INC2 INC2 GTH2k ,&loop JCN &end POP2 ;commands -- RTN @cmd-ls "ls $1 &docs "list_folder_content $1 &func ;path .File/name DEO2 #8000 .File/length DEO2 ;view .File/read DEO2 ;view #01 ;draw-tx JSR2 RTN @cmd-cp "cp $1 &docs "copy_file_to_name $1 &func RTN @cmd-mv "mv $1 &docs "move_file_to_name $1 &func RTN @cmd-rm "rm $1 &docs "remove_file $1 &func ;buffer #0003 ++ .File/name DEO2 #01 .File/delete DEO ;&remove-txt #01 ;draw-str JSR2 ;buffer #0003 ++ #01 ;draw-str JSR2 RTN &remove-txt "removed_file: $1 @cmd-tx "tx $1 &docs "display_file_as_text $1 &func ;buffer #0003 ++ .File/name DEO2 #8000 .File/length DEO2 ;view .File/read DEO2 .File/success DEI2 #0000 >> ,&valid JCN ;&error-txt #02 ;draw-str JSR2 RTN &valid ;view #01 ;draw-tx JSR2 RTN &error-txt "unknown_file $1 @cmd-hx "hx $1 &docs "display_file_as_hex $1 &func ;buffer #0003 ++ .File/name DEO2 #8000 .File/length DEO2 ;view .File/read DEO2 .File/success DEI2 #0000 >> ,&valid JCN ;&error-txt #02 ;draw-str JSR2 RTN &valid AUTO-YADDR .File/success DEI2 #0000 &loop DUP2 ;view ++ LDA #01 ;draw-hex JSR2 ( make shorts ) DUP2 #0001 AND2 #0000 == ,&no-short JCN .Screen/x DEI2k #0008 ++ ROT DEO2 &no-short ( make lines ) DUP2 #000f AND2 #000f !! ,&no-lines JCN .Screen/y DEI2k #0010 ++ ROT DEO2 PAD .Screen/x DEO2 .Screen/y DEI2 .Screen/height DEI2 PAD -- #0010 -- >> ,&end JCN &no-lines INC2 GTH2k ,&loop JCN &end POP2 POP2 RTN &error-txt "unknown_file $1 @cmd-do "do $1 &docs "run_file_as_rom $1 &func ( release inputs ) #0000 .Controller/button DEO2 ;buffer #0003 ++ DUP2 ;check-rom JSR2 ,&valid JCN PAD .Screen/x DEO2 PAD .Screen/y DEO2 ;&invalid-txt #02 ;draw-str JSR2 #01 ;draw-str JSR2 RTN &valid ;load-rom JSR2 RTN &invalid-txt "invalid_rom: $1 @cmd-tm "tm $1 &docs "display_time $1 &func #00 .DateTime/month DEI 4* ;month-txt ++ #01 ;draw-str JSR2 #20 #01 ;draw-char JSR2 .DateTime/day DEI #01 ;draw-dec JSR2 #20 #01 ;draw-char JSR2 #00 .DateTime/dotw DEI 4* ;week-txt ++ #01 ;draw-str JSR2 #20 #01 ;draw-char JSR2 .DateTime/hour DEI #01 ;draw-dec JSR2 LIT ': #01 ;draw-char JSR2 .DateTime/minute DEI #01 ;draw-dec JSR2 LIT ': #01 ;draw-char JSR2 .DateTime/second DEI #01 ;draw-dec JSR2 RTN @cmd-?? "-- $1 &docs "display_commands $1 &func ;&help-txt #01 ;draw-tx JSR2 PAD #0010 ++ .Screen/y DEO2 ;commands/end ;commands &loop PAD .Screen/x DEO2 ( name ) LDA2k #08 ;draw-str JSR2 PAD #0020 ++ .Screen/x DEO2 ( docs ) DUP2 ;commands -- ;commands-docs ++ LDA2 #01 ;draw-str JSR2 .Screen/y DEI2k #0010 ++ ROT DEO2 INC2 INC2 GTH2k ,&loop JCN &end POP2 POP2 RTN &help-txt "Commands: $1 @commands :cmd-ls :cmd-cp :cmd-mv :cmd-rm :cmd-hx :cmd-tx :cmd-do :cmd-tm &end :cmd-?? @commands-docs :cmd-ls/docs :cmd-cp/docs :cmd-mv/docs :cmd-rm/docs :cmd-hx/docs :cmd-tx/docs :cmd-do/docs :cmd-tm/docs &end :cmd-??/docs @commands-func :cmd-ls/func :cmd-cp/func :cmd-mv/func :cmd-rm/func :cmd-hx/func :cmd-tx/func :cmd-do/func :cmd-tm/func &end :cmd-??/func ( gui ) @draw-input ( color -- ) AUTO-YADDR STH PAD .Screen/x DEO2 .Screen/height DEI2 PAD -- .Screen/y DEO2 ( flower ) ;flowers-icn #00 .frame LDZ #06 MOD 20** ++ .Screen/addr DEO2 #81 .Screen/sprite DEOk DEO .Screen/y DEI2 #0010 -- .Screen/y DEO2 .Screen/x DEI2 #0008 ++ .Screen/x DEO2 #20 #00 ;draw-char JSR2 ;buffer STHkr ;draw-str JSR2 ;cursor-icn .Screen/addr DEO2 STHr .Screen/sprite DEOk DEO .Screen/y DEI2 #0010 -- .Screen/y DEO2 .Screen/x DEI2 #0008 ++ .Screen/x DEO2 JMP2r @draw-tx ( str* color -- ) AUTO-YADDR .Screen/x DEI2 ,&anchor STR2 STH &while ( outside view ) .Screen/x DEI2 .Screen/width DEI2 PAD -- #0010 -- >> ,&lb JCN ( linebreak ) LDAk #0a ! ,&no-lb JCN &lb LIT2 &anchor $2 .Screen/x DEO2 .Screen/y DEI2k #0010 ++ STH2k ROT DEO2 STH2r .Screen/height DEI2 PAD -- #0010 -- >> ,&end JCN ,&skip JMP &no-lb LDAk STHkr ,draw-char JSR &skip INC2 LDAk ,&while JCN &end POP2 POPr RTN @draw-dec ( byte color -- ) STH DUP #0a DIV LIT '0 + STHkr ,draw-char JSR #0a MOD LIT '0 + STHr ,draw-char JSR RTN @draw-hex ( byte color -- ) STH DUP #04 SFT ,&parse JSR STHkr ,draw-char JSR #0f AND ,&parse JSR STHr ,draw-char JSR RTN &parse ( value -- char ) DUP #09 > ,&above JCN #30 + RTN &above #09 - #60 + RTN RTN @draw-str ( str* color -- ) AUTO-YADDR STH &while LDAk STHkr ,draw-char JSR INC2 LDAk ,&while JCN POP2 POPr RTN @draw-char ( char color -- ) SWP [ #20 - #00 SWP #40 SFT2 ;font ++ ] .Screen/addr DEO2 .Screen/sprite DEOk DEO .Screen/y DEI2 #0010 -- .Screen/y DEO2 .Screen/x DEI2 #0008 ++ .Screen/x DEO2 RTN ( utils ) @slen ( str* -- len* ) DUP2 ,scap JSR SWP2 -- RTN @scap ( str* -- str-end* ) ( clamp ) LDAk #00 ! JMP RTN &while INC2 LDAk ,&while JCN RTN @sput ( str* char -- ) ROT ROT ,scap JSR STA RTN @spop ( str* -- ) ( clamp ) LDAk #00 ! JMP RTN #00 ROT ROT ,scap JSR #0001 -- STA RTN @scmp ( a* b* -- flag ) STH2 &loop LDAk LDAkr STHr = ,¬-diff JCN POP2 POP2r #00 RTN ¬-diff LDAk LDAkr STHr #0000 !! ,¬-end JCN POP2 POP2r #01 RTN ¬-end INC2 INC2r ,&loop JMP POP2 POP2r #00 RTN @scmp-seg ( a* b* -- flag ) STH2 &loop LDAk LDAkr STHr = ,¬-diff JCN POP2 POP2r #00 RTN ¬-diff INC2k LDA #00 ! ,&continue JCN POP2 POP2r #01 RTN &continue INC2 INC2r ,&loop JMP POP2 POP2r #00 RTN @mclr ( addr* len* -- ) OVR2 ++ SWP2 &loop STH2k #00 STH2r STA INC2 GTH2k ,&loop JCN POP2 POP2 JMP2r @print-hex ( value* -- ) SWP ,&byte JSR &byte ( byte -- ) STHk #04 SFT ,&parse JSR #18 DEO STHr #0f AND ,&parse JSR #18 DEO JMP2r &parse ( byte -- char ) DUP #09 GTH ,&above JCN #30 ADD JMP2r &above #57 ADD JMP2r JMP2r @print-str ( string* -- ) #0001 SUB2 &while INC2 LDAk DUP #18 DEO ,&while JCN POP2 JMP2r ~projects/library/check-rom.tal ~projects/library/load-rom.tal @week-txt "Sun $1 "Mon $1 "Tue $1 "Wed $1 "Thu $1 "Fri $1 "Sat $1 @month-txt "Jan $1 "Feb $1 "Mar $1 "Apr $1 "May $1 "Jun $1 "Jul $1 "Aug $1 "Sep $1 "Oct $1 "Nov $1 "Dec $1 @cursor-icn aa55 aa55 aa55 aa55 aa55 aa55 aa55 aa55 aa55 aa55 aa55 aa55 aa55 aa55 aa55 aa55 @flowers-icn ( by elioat ) 0000 0020 1408 0810 40a0 4205 0200 40a0 0810 103c 7e7e 3c18 4205 0234 7e7e 3c18 0000 0020 100c 0818 0040 a042 0522 5024 0008 083c 7e7e 3c18 0a04 002c 7e7e 3c18 0000 0000 0000 000c 0000 0000 0000 0000 1c10 083c 7e7e 3c18 0000 002c 7e7e 3c18 0000 0000 0000 0004 0000 0000 0002 0502 0810 103c 7e7e 3c18 0000 0034 7e7e 3c18 0000 0000 0000 0010 0000 0000 0020 5225 080c 083c 7e7e 3c18 0200 002c 7e7e 3c18 0000 0000 0800 1800 0000 040a 2450 240a 1010 103c 7e7e 3c18 0400 0034 7e7e 3c18 @font ( terminus01x02 ) 0000 0000 0000 0000 0000 0000 0000 0000 0000 183c 3c3c 1818 1800 1818 0000 0000 0066 6666 2400 0000 0000 0000 0000 0000 0000 006c 6cfe 6c6c 6cfe 6c6c 0000 0000 1818 7cc6 c2c0 7c06 0686 c67c 1818 0000 0000 0000 c2c6 0c18 3060 c686 0000 0000 0000 386c 6c38 76dc cccc cc76 0000 0000 0030 3030 6000 0000 0000 0000 0000 0000 0000 0c18 3030 3030 3030 180c 0000 0000 0000 3018 0c0c 0c0c 0c0c 1830 0000 0000 0000 0000 0066 3cff 3c66 0000 0000 0000 0000 0000 0018 187e 1818 0000 0000 0000 0000 0000 0000 0000 0018 1818 3000 0000 0000 0000 0000 00fe 0000 0000 0000 0000 0000 0000 0000 0000 0000 1818 0000 0000 0000 0000 0206 0c18 3060 c080 0000 0000 0000 386c c6c6 d6d6 c6c6 6c38 0000 0000 0000 1838 7818 1818 1818 187e 0000 0000 0000 7cc6 060c 1830 60c0 c6fe 0000 0000 0000 7cc6 0606 3c06 0606 c67c 0000 0000 0000 0c1c 3c6c ccfe 0c0c 0c1e 0000 0000 0000 fec0 c0c0 fc06 0606 c67c 0000 0000 0000 3860 c0c0 fcc6 c6c6 c67c 0000 0000 0000 fec6 0606 0c18 3030 3030 0000 0000 0000 7cc6 c6c6 7cc6 c6c6 c67c 0000 0000 0000 7cc6 c6c6 7e06 0606 0c78 0000 0000 0000 0000 1818 0000 0018 1800 0000 0000 0000 0000 1818 0000 0018 1830 0000 0000 0000 0006 0c18 3060 3018 0c06 0000 0000 0000 0000 007e 0000 7e00 0000 0000 0000 0000 0060 3018 0c06 0c18 3060 0000 0000 0000 7cc6 c60c 1818 1800 1818 0000 0000 0000 007c c6c6 dede dedc c07c 0000 0000 0000 1038 6cc6 c6fe c6c6 c6c6 0000 0000 0000 fc66 6666 7c66 6666 66fc 0000 0000 0000 3c66 c2c0 c0c0 c0c2 663c 0000 0000 0000 f86c 6666 6666 6666 6cf8 0000 0000 0000 fe66 6268 7868 6062 66fe 0000 0000 0000 fe66 6268 7868 6060 60f0 0000 0000 0000 3c66 c2c0 c0de c6c6 663a 0000 0000 0000 c6c6 c6c6 fec6 c6c6 c6c6 0000 0000 0000 3c18 1818 1818 1818 183c 0000 0000 0000 1e0c 0c0c 0c0c cccc cc78 0000 0000 0000 e666 666c 7878 6c66 66e6 0000 0000 0000 f060 6060 6060 6062 66fe 0000 0000 0000 c6ee fefe d6c6 c6c6 c6c6 0000 0000 0000 c6e6 f6fe dece c6c6 c6c6 0000 0000 0000 7cc6 c6c6 c6c6 c6c6 c67c 0000 0000 0000 fc66 6666 7c60 6060 60f0 0000 0000 0000 7cc6 c6c6 c6c6 c6d6 de7c 0c0e 0000 0000 fc66 6666 7c6c 6666 66e6 0000 0000 0000 7cc6 c660 380c 06c6 c67c 0000 0000 0000 7e7e 5a18 1818 1818 183c 0000 0000 0000 c6c6 c6c6 c6c6 c6c6 c67c 0000 0000 0000 c6c6 c6c6 c6c6 c66c 3810 0000 0000 0000 c6c6 c6c6 d6d6 d6fe ee6c 0000 0000 0000 c6c6 6c7c 3838 7c6c c6c6 0000 0000 0000 6666 6666 3c18 1818 183c 0000 0000 0000 fec6 860c 1830 60c2 c6fe 0000 0000 0000 3c30 3030 3030 3030 303c 0000 0000 0000 0080 c0e0 7038 1c0e 0602 0000 0000 0000 3c0c 0c0c 0c0c 0c0c 0c3c 0000 0000 1038 6cc6 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 00ff 0000 3030 1800 0000 0000 0000 0000 0000 0000 0000 0000 0078 0c7c cccc cc76 0000 0000 0000 e060 6078 6c66 6666 667c 0000 0000 0000 0000 007c c6c0 c0c0 c67c 0000 0000 0000 1c0c 0c3c 6ccc cccc cc76 0000 0000 0000 0000 007c c6fe c0c0 c67c 0000 0000 0000 386c 6460 f060 6060 60f0 0000 0000 0000 0000 0076 cccc cccc cc7c 0ccc 7800 0000 e060 606c 7666 6666 66e6 0000 0000 0000 1818 0038 1818 1818 183c 0000 0000 0000 0606 000e 0606 0606 0606 6666 3c00 0000 e060 6066 6c78 786c 66e6 0000 0000 0000 3818 1818 1818 1818 183c 0000 0000 0000 0000 00ec fed6 d6d6 d6c6 0000 0000 0000 0000 00dc 6666 6666 6666 0000 0000 0000 0000 007c c6c6 c6c6 c67c 0000 0000 0000 0000 00dc 6666 6666 667c 6060 f000 0000 0000 0076 cccc cccc cc7c 0c0c 1e00 0000 0000 00dc 7666 6060 60f0 0000 0000 0000 0000 007c c660 380c c67c 0000 0000 0000 1030 30fc 3030 3030 361c 0000 0000 0000 0000 00cc cccc cccc cc76 0000 0000 0000 0000 0066 6666 6666 3c18 0000 0000 0000 0000 00c6 c6d6 d6d6 fe6c 0000 0000 0000 0000 00c6 6c38 3838 6cc6 0000 0000 0000 0000 00c6 c6c6 c6c6 c67e 060c f800 0000 0000 00fe cc18 3060 c6fe 0000 0000 0000 0e18 1818 7018 1818 180e 0000 0000 0000 1818 1818 0018 1818 1818 0000 0000 0000 7018 1818 0e18 1818 1870 0000 0000 @view