Browse code

(boot.rom) Scrolling support

neauoire authored on 27/11/2021 19:38:12
Showing 1 changed files
... ...
@@ -99,8 +99,8 @@ BRK
99 99
 	#41 .Mouse/state DEI #01 = + .Screen/sprite DEO
100 100
 
101 101
 	( select choice )
102
-	.Mouse/y DEI2 
103
-		10// NIP #01 - ;select-file JSR2
102
+	.Mouse/y DEI2 .browser/y LDZ2 --
103
+		10// NIP ;select-file JSR2
104 104
 
105 105
 	.Mouse/state DEI #00 = ,&no-click JCN
106 106
 		.browser/sel LDZ ;run-file JSR2
... ...
@@ -180,6 +180,8 @@ RTN
180 180
 		POP RTN
181 181
 		&has-changed
182 182
 
183
+	DUP ;scroll-browser JSR2
184
+
183 185
 	.browser/x LDZ2 #0018 -- .browser/y LDZ2 [ .browser/sel LDZ TOS 10** ++ ] 
184 186
 	#0010 #0010 
185 187
 		;hand-icn #00 ;draw-icn JSR2
... ...
@@ -201,6 +203,29 @@ RTN
201 203
 
202 204
 RTN
203 205
 
206
+( Scroll the browser to accomodate off-screen line items )
207
+@scroll-browser ( id -- )
208
+	( Check whether the selection moved up or down )
209
+	.browser/last LDZ OVR SWP SUB #80 AND ,&negative JCN
210
+
211
+	&positive ( The selection moved down )
212
+	( Calculate the id currently at the bottom of the screen )
213
+	.Screen/height DEI2 .browser/y LDZ2 #0010 ++ -- 10// NIP
214
+	GTH ,&scroll-up JCN [ RTN ]
215
+	&scroll-up
216
+		.browser/y LDZ2k #0010 -- ROT STZ2
217
+		RTN
218
+
219
+	&negative ( The selection moved up )
220
+	( Calculate the id currently at the top of the screen )
221
+	( TODO make a macro constant for y initial pos )
222
+	#0010 .browser/y LDZ2 -- 10// NIP
223
+
224
+	LTH ,&scroll-down JCN [ RTN ]
225
+	&scroll-down
226
+		.browser/y LDZ2k #0010 ++ ROT STZ2 ( Decrement y by 0x10 )
227
+		RTN
228
+
204 229
 @run-file ( id -- )
205 230
 
206 231
 	SEL-ENTRY LDA2
... ...
@@ -236,11 +261,13 @@ RTN
236 261
 	.browser/y LDZ2 .Screen/y DEO2
237 262
 	SEL-ENTRY ;dir/entries
238 263
 	&outer ( selected-entry* this-entry* )
264
+		.Screen/y DEI2 #0010 LTH2 ,&inc JCN ( Don't draw anything in the first row )
239 265
 		EQU2k #0c * #01 + STH
240 266
 		LDA2k ORAk #00 = ,&end JCN
267
+		,&clear JSR
241 268
 		STHr ,&draw-one JSR
242 269
 		.browser/x LDZ2 .Screen/x DEO2
243
-		.Screen/y DEI2 #0010 ++ .Screen/y DEO2
270
+		&inc .Screen/y DEI2 #0010 ++ .Screen/y DEO2
244 271
 		INC2 INC2 ,&outer JMP
245 272
 	&end
246 273
 	POP2 POP2 POP2 POPr
... ...
@@ -261,6 +288,20 @@ RTN
261 288
 	POP2 POPr
262 289
 RTN
263 290
 
291
+	&clear ( -- )
292
+	.Screen/x DEI2k ( Stash the current x pos )
293
+	#ff00
294
+	&clear-loop
295
+		#00 .Screen/sprite DEO
296
+		.Screen/y DEI2k #0008 ++ ROT DEO2
297
+		#00 .Screen/sprite DEO
298
+		.Screen/y DEI2k #0008 -- ROT DEO2
299
+		.Screen/x DEI2k #0008 ++ ROT DEO2
300
+		INC NEQk ,&clear-loop JCN
301
+	POP2
302
+	ROT DEO2
303
+RTN
304
+
264 305
 @draw-time ( -- )
265 306
 
266 307
 	.DateTime/day DEI