Browse code

Optimized various drawing routines in left

neauoire authored on 31/03/2021 18:20:32
Showing 2 changed files
... ...
@@ -59,7 +59,7 @@
59 59
 
60 60
 @RESET
61 61
 	
62
-	( theme ) #ed0f =System.r #3d0f =System.g #3d0f =System.b
62
+	( theme ) #e0fa =System.r #30fa =System.g #30fa =System.b
63 63
 
64 64
 	( load file )
65 65
 	,filepath ,load-file JSR2
... ...
@@ -75,8 +75,7 @@ BRK
75 75
 @FRAME
76 76
 
77 77
 	( ctrl )
78
-
79
-	~Controller #00 EQU ~lock #00 NEQ #0000 NEQ2 ,ctrl-end JNZ2
78
+	~Controller #00 EQU ~lock #00 NEQ #0000 NEQ2 ,$ctrl-end JNZ2
80 79
 		( lock ) #04 =lock
81 80
 
82 81
 		( alt + arrow )
... ...
@@ -93,7 +92,7 @@ BRK
93 92
 			POP
94 93
 			,clamp-selection JSR2 
95 94
 			,redraw JSR2
96
-			,ctrl-end JMP2
95
+			,$ctrl-end JMP2
97 96
 		$no-alt
98 97
 
99 98
 		( ctrl + arrow )
... ...
@@ -109,7 +108,7 @@ BRK
109 108
 				( jump line ) ,goto-lineend JSR2 $no-cright
110 109
 			POP
111 110
 			,redraw JSR2
112
-			,ctrl-end JMP2
111
+			,$ctrl-end JMP2
113 112
 		$no-ctrl
114 113
 
115 114
 		( arrow )
... ...
@@ -136,11 +135,11 @@ BRK
136 135
 			,redraw JSR2 
137 136
 		$no-arrow
138 137
 
139
-	@ctrl-end
138
+	$ctrl-end
140 139
 
141 140
 	( keys )
142 141
 
143
-	~Keys #00 EQU ,no-keys JNZ2
142
+	~Keys #00 EQU ,$no-keys JNZ2
144 143
 
145 144
 		~Keys #08 NEQ ^$no-backspace JNZ
146 145
 			( erase )
... ...
@@ -152,7 +151,7 @@ BRK
152 151
 				~selection.to ~selection.from SUB2 ++ ,shift-left JSR2
153 152
 			$erase-end
154 153
 			~selection.from -- =selection.from
155
-			,$keys-end JMP2
154
+			^$keys-end JMP
156 155
 		$no-backspace
157 156
 
158 157
 		( insert )
... ...
@@ -161,19 +160,19 @@ BRK
161 160
 		~selection.from ++ =selection.from
162 161
 
163 162
 		$keys-end
164
-			~selection.from ++ =selection.to
165
-			( release ) #00 =Keys
166
-			,redraw JSR2
163
+		~selection.from ++ =selection.to
164
+		( release ) #00 =Keys
165
+		,redraw JSR2
167 166
 
168
-	@no-keys
167
+	$no-keys
169 168
 
170 169
 	( mouse )
171 170
 
172
-	~Mouse.state #00 EQU ,touch-end JNZ2
171
+	~Mouse.state #00 EQU ^$touch-end JNZ
173 172
 		~Mouse.x #0010 LTH2 ,touch-linebar JNZ2
174 173
 		~Mouse.x ~Screen.width 8- LTH2 ,touch-body JNZ2
175 174
 		,touch-scrollbar JMP2
176
-	@touch-end
175
+	$touch-end
177 176
 
178 177
 	~Mouse.state =touch.state
179 178
 
... ...
@@ -183,62 +182,65 @@ BRK
183 182
 
184 183
 BRK 
185 184
 
186
-@touch-scrollbar
187
-
188
-	~Mouse.y #0008 GTH2 ^$no-up JNZ
189
-		( decr ) ~scroll.y #00 ~scroll.y #0000 NEQ2 SUB2 =scroll.y
190
-		^$end JMP
191
-	$no-up 
192
-	~Mouse.y ~Screen.height 8- LTH2 ^$no-down JNZ
193
-		( incr ) ~scroll.y ++ =scroll.y
194
-		^$end JMP
195
-	$no-down 
196
-	~Mouse.y 8- =scroll.y
197
-	$end
198
-	,redraw JSR2 
199
-	,touch-end JMP2
200
-
201
-RTN
202
-
203
-@touch-linebar
204
-
205
-	~Mouse.y 8/ ~scroll.y ADD2 =position.y #0000 =position.x 
185
+@touch-linebar ( -- )
186
+	
187
+	#0000 =position.x
188
+	~Mouse.y 8/ ~scroll.y ADD2 =position.y 
206 189
 	,find-selection JSR2 DUP2 =selection.from ++ =selection.to
190
+	,goto-linestart JSR2
207 191
 	,redraw JSR2 
208
-	,touch-end JMP2
192
+	,draw-cursor JSR2
209 193
 
210
-RTN
194
+BRK
211 195
 
212
-@touch-body
196
+@touch-body ( -- )
213 197
 	
214 198
 	~Mouse.y 8/ ~scroll.y ADD2 =position.y
215 199
 	~Mouse.x ~textarea.x1 SUB2 #0007 ADD2 #0007 DIV2 =position.x
216
-
217
-	~Mouse.chord #01 NEQ ^$no-chord-cut JNZ
218
-		,cut JSR2
219
-		( release ) #00 DUP =Mouse.state =Mouse.chord
220
-		^$end JMP
221
-	$no-chord-cut
222
-	~Mouse.chord #10 NEQ ^$no-chord-paste JNZ
223
-		,paste JSR2
224
-		( release ) #00 DUP =Mouse.state =Mouse.chord
225
-		^$end JMP
226
-	$no-chord-paste
227
-
228
-	~Mouse.state #11 EQU ^$end JNZ
200
+	( chords )
201
+	~Mouse.chord #00 EQU ^$no-chords JNZ
202
+		~Mouse.chord
203
+		DUP #01 NEQ ^$no-chord-cut JNZ
204
+			,cut JSR2 ( release ) #00 DUP =Mouse.state =Mouse.chord $no-chord-cut
205
+		DUP #10 NEQ ^$no-chord-paste JNZ
206
+			,paste JSR2 ( release ) #00 DUP =Mouse.state =Mouse.chord $no-chord-paste
207
+		POP
208
+		,redraw JSR2
209
+		BRK
210
+	$no-chords
211
+	( drag )
229 212
 	~Mouse.state ~touch.state NEQ ~Controller #0f AND #02 NEQ #0101 EQU2 ^$no-drag JNZ
230 213
 		( on drag )
231 214
 		,find-selection JSR2 ++ =selection.to
232 215
 		,clamp-selection JSR2
233 216
 		^$end JMP
234 217
 	$no-drag
235
-		( on click )
236
-		,find-selection JSR2 DUP2 =selection.from ++ =selection.to
218
+	( on click )
219
+	,find-selection JSR2 DUP2 =selection.from ++ =selection.to 
237 220
 	$end
221
+	~Mouse.state =touch.state
222
+	,draw-cursor JSR2
238 223
 	,redraw JSR2
239
-	,touch-end JMP2
240 224
 
241
-RTN
225
+BRK
226
+
227
+@touch-scrollbar ( -- )
228
+
229
+	~Mouse.y #0008 GTH2 ^$no-up JNZ
230
+		( decr ) ~scroll.y #00 ~scroll.y #0000 NEQ2 SUB2 =scroll.y
231
+		^$end JMP
232
+	$no-up 
233
+	~Mouse.y ~Screen.height 8- LTH2 ^$no-down JNZ
234
+		( incr ) ~scroll.y ++ =scroll.y
235
+		^$end JMP
236
+	$no-down 
237
+	~Mouse.y 8- =scroll.y
238
+	$end
239
+	~Mouse.state =touch.state
240
+	,draw-cursor JSR2
241
+	,redraw JSR2 
242
+
243
+BRK
242 244
 
243 245
 @load-file ( path )
244 246
 
... ...
@@ -267,7 +269,7 @@ RTN
267 269
 
268 270
 RTN
269 271
 
270
-@shift-left ( length )
272
+@shift-left ( length -- )
271 273
 
272 274
 	=i
273 275
 	~selection.from -- =j ( start -> end )
... ...
@@ -279,7 +281,7 @@ RTN
279 281
 
280 282
 RTN
281 283
 
282
-@shift-right ( length )
284
+@shift-right ( length -- )
283 285
 
284 286
 	=i
285 287
 	~document.eof =j ( end -> start )
... ...
@@ -291,7 +293,7 @@ RTN
291 293
 
292 294
 RTN
293 295
 
294
-@follow-selection
296
+@follow-selection ( -- )
295 297
 
296 298
 	~position.y ~scroll.y GTH2 ^$no-up JNZ
297 299
 		~position.y =scroll.y RTN
... ...
@@ -302,14 +304,14 @@ RTN
302 304
 
303 305
 RTN
304 306
 
305
-@clamp-selection
307
+@clamp-selection ( -- )
306 308
 
307 309
 	~selection.from ~selection.to LTH2 RTN?
308 310
 	~selection.from ++ =selection.to
309 311
 
310 312
 RTN
311 313
 
312
-@goto-linestart
314
+@goto-linestart ( -- )
313 315
 
314 316
 	$loop
315 317
 		~selection.from -- PEK2 #0a EQU RTN?
... ...
@@ -322,7 +324,7 @@ RTN
322 324
 
323 325
 RTN
324 326
 
325
-@goto-lineend
327
+@goto-lineend ( -- )
326 328
 	
327 329
 	$loop
328 330
 		~selection.from PEK2 #0a EQU RTN?
... ...
@@ -335,7 +337,7 @@ RTN
335 337
 
336 338
 RTN
337 339
 
338
-@find-wordstart
340
+@find-wordstart ( -- )
339 341
 
340 342
 	~selection.to =j
341 343
 	$loop
... ...
@@ -349,7 +351,7 @@ RTN
349 351
 
350 352
 RTN
351 353
 
352
-@find-wordend
354
+@find-wordend ( -- )
353 355
 	
354 356
 	~selection.to =j
355 357
 	$loop
... ...
@@ -405,7 +407,7 @@ RTN
405 407
 
406 408
 RTN
407 409
 
408
-@cut
410
+@cut ( -- )
409 411
 
410 412
 	,copy JSR2
411 413
 	~selection.to ~selection.from SUB2 ,shift-left JSR2
... ...
@@ -413,7 +415,7 @@ RTN
413 415
 
414 416
 RTN
415 417
 
416
-@copy ( selection )
418
+@copy ( -- )
417 419
 	
418 420
 	#0000 =i ( start )
419 421
 	~selection.to ~selection.from SUB2 =j ( end )
... ...
@@ -425,7 +427,7 @@ RTN
425 427
 
426 428
 RTN
427 429
 
428
-@paste
430
+@paste ( -- )
429 431
 	
430 432
 	~clip.len ,shift-right JSR2
431 433
 	#0000 =i ( start )
... ...
@@ -465,10 +467,20 @@ RTN
465 467
 
466 468
 	( save/load icons )
467 469
 	~Screen.height 8- =Sprite.y
468
-	~Screen.width #0018 SUB2 =Sprite.x
470
+
471
+	~Screen.width #0030 SUB2 =Sprite.x
472
+	,eye_icn =Sprite.addr
473
+	#02 =Sprite.color
474
+
475
+	~Screen.width #0028 SUB2 =Sprite.x
476
+	,name_icn =Sprite.addr
477
+	#02 =Sprite.color
478
+
479
+	~Screen.width #0020 SUB2 =Sprite.x
469 480
 	,load_icn =Sprite.addr
470 481
 	#02 =Sprite.color
471
-	~Screen.width #0010 SUB2 =Sprite.x
482
+
483
+	~Screen.width #0018 SUB2 =Sprite.x
472 484
 	,save_icn =Sprite.addr
473 485
 	#02 =Sprite.color
474 486
 
... ...
@@ -495,7 +507,6 @@ RTN
495 507
 
496 508
 	~mouse.x ~Mouse.x NEQ2
497 509
 	~mouse.y ~Mouse.y NEQ2
498
-
499 510
 	#0000 EQU2 RTN? ( Return if unchanged )
500 511
 
501 512
 	( clear last cursor )
... ...
@@ -512,7 +523,7 @@ RTN
512 523
 	~mouse.x =Sprite.x
513 524
 	~mouse.y =Sprite.y
514 525
 	,cursor_icn =Sprite.addr
515
-	#13 =Sprite.color
526
+	#1f ~Mouse.state #01 EQU #0a MUL SUB =Sprite.color
516 527
 
517 528
 RTN
518 529
 
... ...
@@ -555,12 +566,12 @@ RTN
555 566
 			( draw line number )
556 567
 			#0000 =Sprite.x
557 568
 			~scroll.y ~Sprite.y 8/ ADD2 DUP2 SWP POP =k 
558
-			~position.y EQU2 #03 MUL =l
569
+			~position.y EQU2 #05 MUL =l
559 570
 			,font_hex #00 ~k #f0 AND #04 SFT #08 MUL ADD2 =Sprite.addr
560
-			#06 ~l ADD =Sprite.color
571
+			#04 ~l ADD =Sprite.color
561 572
 			#0008 =Sprite.x
562 573
 			,font_hex #00 ~k #0f AND #08 MUL ADD2 =Sprite.addr
563
-			#06 ~l ADD =Sprite.color
574
+			#04 ~l ADD =Sprite.color
564 575
 
565 576
 			#0010 =Sprite.x
566 577
 			( incr ) ~Sprite.y 8+ =Sprite.y
... ...
@@ -586,29 +597,32 @@ RTN
586 597
 
587 598
 RTN
588 599
 
589
-@draw-scrollbar
590
-		
591
-	~Screen.width 8- =Sprite.x
592
-	#0000 =Sprite.y
593
-	,scrollbar_bg =Sprite.addr
600
+@draw-scrollbar ( -- )
601
+	
602
+	,scrollbar_icn ( keeping a copy on stack )
594 603
 
595
-	$loop
596
-	( draw ) #08 =Sprite.color
597
-	( incr ) ~Sprite.y 8+ =Sprite.y
598
-	~Sprite.y ~Screen.height LTH2 ^$loop JNZ
604
+	~Screen.width 8- =Sprite.x 
605
+	#0008 =Sprite.y
606
+	DUP2 =Sprite.addr
599 607
 
600
-	#0000 =Sprite.y
601
-	,arrowup_icn =Sprite.addr
602
-	( draw ) #08 =Sprite.color
608
+	#0008 ~Screen.height 8-
609
+	$loop
610
+		( draw ) #01 =Sprite.color
611
+		( incr ) SWP2 8+ DUP2 =Sprite.y SWP2
612
+		OVR2 OVR2 LTH2 ^$loop JNZ
613
+	POP2 POP2
603 614
 
604
-	( at )
605 615
 	~scroll.y 8+ =Sprite.y
606
-	,scrollbar_fg =Sprite.addr
607
-	( draw ) #08 =Sprite.color
616
+	DUP2 #0008 ADD2 =Sprite.addr
617
+	( draw ) #01 =Sprite.color
618
+
619
+	#0000 =Sprite.y
620
+	DUP2 #0010 ADD2 =Sprite.addr
621
+	( draw ) #04 =Sprite.color
608 622
 
609 623
 	~Screen.height 8- =Sprite.y
610
-	,arrowdown_icn =Sprite.addr
611
-	( draw ) #08 =Sprite.color
624
+	#0018 ADD2 =Sprite.addr
625
+	( draw ) #04 =Sprite.color
612 626
 
613 627
 RTN
614 628
 
... ...
@@ -692,15 +706,26 @@ RTN
692 706
 	0000 0032 4c00 0000 3c42 99a1 a199 423c
693 707
 ]
694 708
 
709
+( interface )
710
+@eye_icn
711
+	[ 0038 4492 2810 0000 ] ( open )
712
+	[ 0000 0082 4438 0000 ] ( closed )
713
+
714
+@scrollbar_icn
715
+	[ aa55 aa55 aa55 aa55 ] ( bg )
716
+	[ ffff ffff ffff ffff ] ( fg )
717
+	[ 0010 387c fe10 1010 ] ( up )
718
+	[ 0010 1010 fe7c 3810 ] ( down )
719
+
720
+@name_icn       [ 1054 28c6 2854 1000 ]
721
+@load_icn       [ feaa d6aa d4aa f400 ]
722
+@save_icn       [ fe82 8282 848a f400 ]
723
+
695 724
 @linebreak_icn [ 003e 7474 3414 1400 ]
725
+
696 726
 @blank_icn     [ 0000 0000 0000 0000 ]
697 727
 @cursor_icn    [ 80c0 e0f0 f8e0 1000 ]
698
-@scrollbar_bg  [ aa55 aa55 aa55 aa55 ]
699
-@scrollbar_fg  [ ffff ffff ffff ffff ]
700
-@arrowup_icn   [ 0010 387c fe10 1010 ]
701
-@arrowdown_icn [ 0010 1010 fe7c 3810 ]
702
-@load_icn      [ feaa d6aa d4aa f400 ]
703
-@save_icn      [ fe82 8282 848a f400 ]
728
+
704 729
 @filepath1     [ projects/examples/gui.hover.usm 00 ]
705 730
 @filepath      [ projects/software/noodle.usm 00 ]
706 731
 
... ...
@@ -74,7 +74,7 @@
74 74
 	~theme.r0 =System.r ~theme.g0 =System.g ~theme.b0 =System.b
75 75
 
76 76
 	( default canvas )
77
-	#002a =canvas.w #001a =canvas.h
77
+	#002a =canvas.w #0018 =canvas.h
78 78
 
79 79
 	( default brush )
80 80
 	#04 =brush.size #00 =brush.patt #00 =brush.tool
... ...
@@ -792,7 +792,7 @@ RTN
792 792
 	( draw save/load/guides icons )
793 793
 	~Screen.height #0010 SUB2 =Sprite.y
794 794
 	~Screen.width #0028 SUB2 =Sprite.x
795
-	,eye #00 ~document.presentation #08 MUL ADD2 =Sprite.addr
795
+	,eye_icn #00 ~document.presentation #08 MUL ADD2 =Sprite.addr
796 796
 	#03 =Sprite.color
797 797
 	~Sprite.x 8+ =Sprite.x
798 798
 	,filestate_icn =Sprite.addr
... ...
@@ -941,14 +941,15 @@ RTN
941 941
 	[ 80c0 e0f0 f8e0 1000 ]
942 942
 	[ 4040 4070 f8f8 f870 ]
943 943
 
944
-@eye
944
+@eye_icn
945 945
 	[ 0038 4492 2810 0000 ] ( open )
946 946
 	[ 0000 0082 4438 0000 ] ( closed )
947 947
 
948
+@filestate_icn  [ 1054 28c6 2854 1000 ]
948 949
 @load_icn       [ feaa d6aa d4aa f400 ]
949 950
 @save_icn       [ fe82 8282 848a f400 ]
951
+
950 952
 @blank_icn      [ 0000 0000 0000 0000 ]
951
-@filestate_icn  [ 1054 28c6 2854 1000 ] ( TODO, add to background! )
952 953
 @untitled_txt   [ untitled.bit 00 ]
953 954
 
954 955
 @font_hex ( 0-F TODO: should pull from @font instead.. )