Split directory entries into strings on load.

This commit is contained in:
Andrew Alderwick 2021-11-09 07:06:19 +00:00
parent 198c28b106
commit 9b061bb9ef
1 changed files with 46 additions and 47 deletions

View File

@ -18,6 +18,8 @@
%DEBUG { ;print-hex/byte JSR2 #0a .Console/write DEO } %DEBUG { ;print-hex/byte JSR2 #0a .Console/write DEO }
%DEBUG2 { ;print-hex/short JSR2 #0a .Console/write DEO } %DEBUG2 { ;print-hex/short JSR2 #0a .Console/write DEO }
%SEL-ENTRY { ;dir/entries #00 .browser/sel LDZ DUP2 ADD2 ADD2 }
( devices ) ( devices )
|00 @System &vector $2 &wst $1 &rst $1 &pad $4 &r $2 &g $2 &b $2 &debug $1 &halt $1 |00 @System &vector $2 &wst $1 &rst $1 &pad $4 &r $2 &g $2 &b $2 &debug $1 &halt $1
@ -137,17 +139,34 @@ BRK
#1000 .File/length DEO2 #1000 .File/length DEO2
;dir/data .File/read DEO2 ;dir/data .File/read DEO2
( count lines ) ( separate into lines )
LITr 00 #00 ;dir/data STH2k
;dir/data
&while &while
LDAk #0a ! ,&no-lb JCN LDAk #0a ! ,&no-lb JCN
INCr STAk
&no-lb STH2r ;add-entry JSR2
INC2 LDAk ,&while JCN INC2 STH2k ,&while JMP
POP2 &no-lb INC2 LDAk ,&while JCN
STHr #02 - ;dir/lines STA POP2r POP2 POP
RTN
@add-entry ( line* -- )
DUP2 ;filter-entry JSR2 ,&ignored JCN
( just add entry to end for now, FIXME sort entries )
;dir/entries
#00 ;dir/lines LDA DUP2 ADD2
ADD2
STA2
;dir/lines LDAk INC ROT ROT STA
#0000
&ignored
POP2
RTN
@filter-entry ( line* -- ignore-flag )
POP2 #00
RTN RTN
@select-file ( id -- ) @select-file ( id -- )
@ -179,21 +198,8 @@ RTN
@run-file ( id -- ) @run-file ( id -- )
STH SEL-ENTRY LDA2
( count lines ) #0005 ++ DUP2 ;print-string JSR2
LITr 00
;dir/data
&while
LDAk #0a ! ,&no-lb JCN
INCr
&no-lb
EQUkr STHr ,&end JCN
INC2 LDAk ,&while JCN
&end
POP2r
DUP2 INC2 ;close-path JSR2
#0006 ++ DUP2 ;print-string JSR2
#0a .Console/write DEO #0a .Console/write DEO
DUP2 ;check-rom JSR2 ,&valid JCN DUP2 ;check-rom JSR2 ,&valid JCN
@ -204,19 +210,6 @@ RTN
RTN RTN
@close-path ( addr* -- )
&while
LDAk #0a ! ,&no-lb JCN
STH2k #00 STH2r STA
,&end JMP
&no-lb
INC2 LDAk ,&while JCN
&end
POP2
RTN
@print-string ( addr* -- ) @print-string ( addr* -- )
&loop &loop
@ -234,28 +227,33 @@ RTN
@draw-browser ( -- ) @draw-browser ( -- )
( line counter ) #00 STH
.browser/x LDZ2 .Screen/x DEO2 .browser/x LDZ2 .Screen/x DEO2
.browser/y LDZ2 .Screen/y DEO2 .browser/y LDZ2 .Screen/y DEO2
;dir/data SEL-ENTRY ;dir/entries
&outer ( selected-entry* this-entry* )
EQU2k #0c * #01 + STH
LDA2k ORAk #00 = ,&end JCN
STHr ,&draw-one JSR
.browser/x LDZ2 .Screen/x DEO2
.Screen/y DEI2 #0010 ++ .Screen/y DEO2
INC2 INC2 ,&outer JMP
&end
POP2 POP2 POP2 POPr
RTN
&draw-one ( line* color -- )
STH
&loop &loop
LDAk #0a ! ,&no-lb JCN
.browser/x LDZ2 .Screen/x DEO2
.Screen/y DEI2 #0010 ++ .Screen/y DEO2
( incr line counter ) INCr
,&skip JMP
&no-lb
( top-addr ) LDAk #20 - TOS #0010 MUL2 ;font ++ .Screen/addr DEO2 ( top-addr ) LDAk #20 - TOS #0010 MUL2 ;font ++ .Screen/addr DEO2
( top-draw ) #01 [ .browser/sel LDZ STHkr = #0c * + ] .Screen/sprite DEO ( top-draw ) STHkr .Screen/sprite DEO
( bottom-addr ) .Screen/addr DEI2 #0008 ++ .Screen/addr DEO2 ( bottom-addr ) .Screen/addr DEI2 #0008 ++ .Screen/addr DEO2
( next-y ) .Screen/y DEI2 #0008 ++ .Screen/y DEO2 ( next-y ) .Screen/y DEI2 #0008 ++ .Screen/y DEO2
( bottom-draw ) #01 [ .browser/sel LDZ STHkr = #0c * + ] .Screen/sprite DEO ( bottom-draw ) STHkr .Screen/sprite DEO
( prev-y ) .Screen/y DEI2 #0008 -- .Screen/y DEO2 ( prev-y ) .Screen/y DEI2 #0008 -- .Screen/y DEO2
( move ) .Screen/x DEI2 #0008 ++ .Screen/x DEO2 ( move ) .Screen/x DEI2 #0008 ++ .Screen/x DEO2
&skip &skip
INC2 LDAk ,&loop JCN INC2 LDAk ,&loop JCN
POP2 POPr POP2 POPr
RTN RTN
@draw-time ( -- ) @draw-time ( -- )
@ -407,4 +405,5 @@ include projects/assets/msx01x02.tal
@dir @dir
&path ". $1 &path ". $1
&lines $1 &lines $1
&entries $100
&data &data