Browse code

Split directory entries into strings on load.

Andrew Alderwick authored on 09/11/2021 07:06:19
Showing 1 changed files
... ...
@@ -18,6 +18,8 @@
18 18
 %DEBUG  { ;print-hex/byte JSR2 #0a .Console/write DEO }
19 19
 %DEBUG2 { ;print-hex/short JSR2 #0a .Console/write DEO }
20 20
 
21
+%SEL-ENTRY { ;dir/entries #00 .browser/sel LDZ DUP2 ADD2 ADD2 }
22
+
21 23
 ( devices )
22 24
 
23 25
 |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
137 139
 	#1000 .File/length DEO2
138 140
 	;dir/data .File/read DEO2
139 141
 
140
-	( count lines )
141
-	LITr 00
142
-	;dir/data
142
+	( separate into lines )
143
+	#00 ;dir/data STH2k
143 144
 	&while
144 145
 		LDAk #0a ! ,&no-lb JCN
145
-			INCr
146
-			&no-lb
147
-		INC2 LDAk ,&while JCN
146
+		STAk
147
+		STH2r ;add-entry JSR2
148
+		INC2 STH2k ,&while JMP
149
+		&no-lb INC2 LDAk ,&while JCN
150
+	POP2r POP2 POP
151
+RTN
152
+
153
+@add-entry ( line* -- )
154
+	DUP2 ;filter-entry JSR2 ,&ignored JCN
155
+
156
+	( just add entry to end for now, FIXME sort entries )
157
+	;dir/entries
158
+		#00 ;dir/lines LDA DUP2 ADD2
159
+		ADD2
160
+	STA2
161
+	;dir/lines LDAk INC ROT ROT STA
162
+	#0000
163
+
164
+	&ignored
148 165
 	POP2
149
-	STHr #02 - ;dir/lines STA
166
+RTN
150 167
 
168
+@filter-entry ( line* -- ignore-flag )
169
+	POP2 #00
151 170
 RTN
152 171
 
153 172
 @select-file ( id -- )
... ...
@@ -179,21 +198,8 @@ RTN
179 198
 
180 199
 @run-file ( id -- )
181 200
 
182
-	STH
183
-	( count lines )
184
-	LITr 00
185
-	;dir/data
186
-	&while
187
-		LDAk #0a ! ,&no-lb JCN
188
-			INCr
189
-			&no-lb
190
-		EQUkr STHr ,&end JCN
191
-		INC2 LDAk ,&while JCN
192
-	&end
193
-	POP2r
194
-
195
-	DUP2 INC2 ;close-path JSR2
196
-	#0006 ++ DUP2 ;print-string JSR2
201
+	SEL-ENTRY LDA2
202
+	#0005 ++ DUP2 ;print-string JSR2
197 203
 	#0a .Console/write DEO
198 204
 
199 205
 	DUP2 ;check-rom JSR2 ,&valid JCN
... ...
@@ -204,19 +210,6 @@ RTN
204 210
 
205 211
 RTN
206 212
 
207
-@close-path ( addr* -- )
208
-
209
-	&while
210
-		LDAk #0a ! ,&no-lb JCN
211
-			STH2k #00 STH2r STA
212
-			,&end JMP
213
-			&no-lb
214
-		INC2 LDAk ,&while JCN
215
-	&end
216
-	POP2
217
-
218
-RTN
219
-
220 213
 @print-string ( addr* -- )
221 214
 
222 215
 	&loop
... ...
@@ -234,28 +227,33 @@ RTN
234 227
 
235 228
 @draw-browser ( -- )
236 229
 
237
-	( line counter ) #00 STH
238 230
 	.browser/x LDZ2 .Screen/x DEO2
239 231
 	.browser/y LDZ2 .Screen/y DEO2
240
-	;dir/data
232
+	SEL-ENTRY ;dir/entries
233
+	&outer ( selected-entry* this-entry* )
234
+		EQU2k #0c * #01 + STH
235
+		LDA2k ORAk #00 = ,&end JCN
236
+		STHr ,&draw-one JSR
237
+		.browser/x LDZ2 .Screen/x DEO2
238
+		.Screen/y DEI2 #0010 ++ .Screen/y DEO2
239
+		INC2 INC2 ,&outer JMP
240
+	&end
241
+	POP2 POP2 POP2 POPr
242
+RTN
243
+
244
+	&draw-one ( line* color -- )
245
+	STH
241 246
 	&loop
242
-		LDAk #0a ! ,&no-lb JCN
243
-			.browser/x LDZ2 .Screen/x DEO2
244
-			.Screen/y DEI2 #0010 ++ .Screen/y DEO2
245
-			( incr line counter ) INCr
246
-			,&skip JMP
247
-			&no-lb
248 247
 		( top-addr ) LDAk #20 - TOS #0010 MUL2 ;font ++ .Screen/addr DEO2
249
-		( top-draw ) #01 [ .browser/sel LDZ STHkr = #0c * + ] .Screen/sprite DEO
248
+		( top-draw ) STHkr .Screen/sprite DEO
250 249
 		( bottom-addr ) .Screen/addr DEI2 #0008 ++ .Screen/addr DEO2
251 250
 		( next-y ) .Screen/y DEI2 #0008 ++ .Screen/y DEO2
252
-		( bottom-draw ) #01 [ .browser/sel LDZ STHkr = #0c * + ] .Screen/sprite DEO
251
+		( bottom-draw ) STHkr .Screen/sprite DEO
253 252
 		( prev-y ) .Screen/y DEI2 #0008 -- .Screen/y DEO2
254 253
 		( move ) .Screen/x DEI2 #0008 ++ .Screen/x DEO2
255 254
 		&skip
256 255
 		INC2 LDAk ,&loop JCN
257 256
 	POP2 POPr
258
-
259 257
 RTN
260 258
 
261 259
 @draw-time ( -- )
... ...
@@ -407,4 +405,5 @@ include projects/assets/msx01x02.tal
407 405
 @dir
408 406
 	&path ". $1
409 407
 	&lines $1
408
+	&entries $100
410 409
 	&data