~rabbits/uxn

uxn/projects/software/noodle.usm -rw-r--r-- 28.4 KiB
bcf95cbaneauoire Merge branch 'master' of git.sr.ht:~rabbits/uxn 8 hours ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
( 
	app/noodle : illustration program
	
	right-click - erase
	alt-click - drag canvas
	arrows - move zoom
	space - toogle zoom
	backspace - blank canvas
	1-8 - select brush size

	TODO
		- Pixel cleanup brush
		- Don't zoom move beyond image width
)

%RTN   { JMP2r }
%ABS2 { DUP2 #000f SFT2 EQU #04 JNZ #ffff MUL2 }
%CLN2r { DUP2 STH2 }
%STEP8 { #0033 SFT2 }
%MOD8 { #0007 AND2  }
%SFL { #40 SFT SFT }
%++ { #0001 ADD2 } %-- { #0001 SUB2 }
%2/ { #0001 SFT2 }
%8/ { #0003 SFT2 } %8* { #0030 SFT2 }
%8+ { #0008 ADD2 }
%FILESIZE { ~canvas.w ~canvas.h MUL2 #0008 MUL2 }

( variables )

;cursor { x 2 y 2 x0 2 y0 2 dx 2 dy 2 }
;brush { tool 1 size 1 patt 1 drag 1 last 1 oper 2 }
;zoom { active 1 x 2 y 2 }
;toolpane { x1 2 y1 2 x2 2 y2 2 }
;pattpane { x1 2 y1 2 x2 2 y2 2 }
;sizepane { x1 2 y1 2 x2 2 y2 2 }
;viewpane { x1 2 y1 2 x2 2 y2 2 }
;canvas { x1 2 y1 2 x2 2 y2 2 w 2 h 2 }
;rect { x1 2 y1 2 x2 2 y2 2 }
;line { x1 2 y1 2 x2 2 y2 2 sx 2 sy 2 dx 2 dy 2 e1 2 e2 2 }
;origin { x1 2 y1 2 x2 2 y2 2 }
;color { byte 1 }
;pt0 { x 2 y 2 }
;pt1 { x 2 y 2 }
;pt2 { x 2 y 2 } ( paint-rect )
;px { x 1 y 1 }
;document { state 1 edit 1 presentation 1 }
;path { length 1 name 20 }
;timer { byte 1 }
;theme { r0 2 g0 2 b0 2 r1 2 g1 2 b1 2 }

( devices )

|0100 ;System { vector 2 pad 6 r 2 g 2 b 2 }
|0110 ;Console { vector 2 pad 6 char 1 byte 1 short 2 string 2 }
|0120 ;Screen { vector 2 width 2 height 2 pad 2 x 2 y 2 addr 2 color 1 }
|0140 ;Controller { vector 2 button 1 key 1 }
|0160 ;Mouse  { vector 2 x 2 y 2 state 1 chord 1 }
|0170 ;File { vector 2 success 2 offset 2 pad 2 name 2 length 2 load 2 save 2 }

( program )

|0200
	
	( theme ) 
	#e0fa =theme.r0 #30fa =theme.g0 #30fa =theme.b0 ( normal mode )
	#00fe =theme.r1 #00f3 =theme.g1 #00f3 =theme.b1 ( presentation mode )
	( vectors ) ,on-screen =Screen.vector
	( vectors ) ,on-button =Controller.vector
	( vectors ) ,on-mouse =Mouse.vector

	~theme.r0 =System.r ~theme.g0 =System.g ~theme.b0 =System.b

	( default canvas )
	#002a =canvas.w #0018 =canvas.h

	( default brush )
	#04 =brush.size #00 =brush.patt #00 =brush.tool

	( load file )
	,untitled_txt ,path.name ,strcpy JSR2

	( setup panes )
	#0010 =toolpane.x1 #0010 =toolpane.y1 ~toolpane.x1 #0028 ADD2 =toolpane.x2 ~toolpane.y1 #0008 ADD2 =toolpane.y2
	#0040 =sizepane.x1 #0010 =sizepane.y1 ~sizepane.x1 #0040 ADD2 =sizepane.x2 ~sizepane.y1 #0008 ADD2 =sizepane.y2
	~Screen.width #0078 SUB2 =viewpane.x1 #0010 =viewpane.y1 ~viewpane.x1 #0020 ADD2 =viewpane.x2 ~viewpane.y1 #0008 ADD2 =viewpane.y2
	~Screen.width #0050 SUB2 =pattpane.x1 #0010 =pattpane.y1 ~pattpane.x1 #0040 ADD2 =pattpane.x2 ~pattpane.y1 #0008 ADD2 =pattpane.y2

	( ready. )
	,center JSR2
	,clear JSR2

	( load default file )
	,path.name ,load-file JSR2

BRK

@on-screen ( -> )
	
	~document.edit #01 NEQ ^$no-edit JNZ
		#0008 =Screen.x 
		~Screen.height #0010 SUB2 =Screen.y
		,path.name #01 ~timer #04 DIV #03 AND #03 MUL ADD ,draw-label JSR2
		$clear
			#20 =Screen.color
			~Screen.x 8+ DUP2 =Screen.x
			~Screen.width LTH2 ^$clear JNZ
		( blink ) ~timer #01 ADD =timer
	$no-edit

BRK

@on-mouse ( -> )
	
	,draw-cursor JSR2

	( release drag )
	~Mouse.state #00 EQU ~brush.drag #01 EQU #0101 NEQ2 ^$no-release JNZ
		~origin.x1 #0002 SUB2 ~origin.y1 #0002 SUB2 ~origin.x2 #0002 ADD2 ~origin.y2 #0002 ADD2 #00 ,fill-rect JSR2
		~canvas.x1 -- ~canvas.y1 -- ~canvas.x2 ~canvas.y2 #10 ,line-rect JSR2
		,draw-background JSR2
		,fit-canvas JSR2
		,draw-foreground JSR2
		#00 =brush.drag
	$no-release

	( operations on release line/rect )
	~Mouse.state ~brush.last EQU ,$no-touch-change JNZ2
	~Mouse.x CLN2r ~canvas.x1 GTS2 STH2r ~canvas.x2 LTS2 #0101 NEQ2 ,$no-touch-change JNZ2
	~Mouse.y CLN2r ~canvas.y1 GTS2 STH2r ~canvas.y2 LTS2 #0101 NEQ2 ,$no-touch-change JNZ2
		~Mouse.state #00 EQU ^$no-touch-ondown JNZ
			( on down )
			~Mouse.x =cursor.dx
			~Mouse.y =cursor.dy
		$no-touch-ondown
		~Mouse.state #00 NEQ ^$no-touch-onup JNZ
			( on up )
			~brush.tool #02 NEQ ^$no-touch-line JNZ
				~cursor.dx ~canvas.x1 SUB2 ~cursor.dy ~canvas.y1 SUB2 ~Mouse.x ~canvas.x1 SUB2 ~Mouse.y ~canvas.y1 SUB2 ,paint-line JSR2
				,$touch-end JMP2
			$no-touch-line
			~brush.tool #03 NEQ ^$no-touch-rect JNZ
				~cursor.dx ~canvas.x1 SUB2 ~cursor.dy ~canvas.y1 SUB2 ~Mouse.x ~canvas.x1 SUB2 ~Mouse.y ~canvas.y1 SUB2 ,paint-rect JSR2
				,$touch-end JMP2
			$no-touch-rect
		$no-touch-onup
	$no-touch-change

	~Mouse.state #00 EQU ,$no-touch JNZ2

		( drag )
		~Controller.button #02 NEQ ,$no-drag JNZ2
			~brush.drag #00 NEQ ^$no-drag-start JNZ
				~canvas.x1 =origin.x1
				~canvas.y1 =origin.y1
				~canvas.x2 =origin.x2
				~canvas.y2 =origin.y2
			$no-drag-start
			~canvas.x1 -- ~canvas.y1 -- ~canvas.x2 ~canvas.y2 #10 ,line-rect JSR2
			~canvas.x1 ~Mouse.x ~cursor.x0 SUB2 ADD2 =canvas.x1
			~canvas.y1 ~Mouse.y ~cursor.y0 SUB2 ADD2 =canvas.y1
			~canvas.w 8* ~canvas.x1 ADD2 =canvas.x2 
			~canvas.h 8* ~canvas.y1 ADD2 =canvas.y2 
			~canvas.x1 -- ~canvas.y1 -- ~canvas.x2 ~canvas.y2 #13 ,line-rect JSR2
			#01 =brush.drag
			,$touch-end JMP2
		$no-drag

		( in sizepane )
		~Mouse.x CLN2r ~sizepane.x1 GTH2 STH2r ~sizepane.x2 LTH2 #0101 NEQ2 ^$no-touch-sizepane JNZ
		~Mouse.y CLN2r ~sizepane.y1 GTH2 STH2r ~sizepane.y2 LTH2 #0101 NEQ2 ^$no-touch-sizepane JNZ
			( release ) #00 =Mouse.state
			#01 =brush.tool
			~Mouse.x ~sizepane.x1 SUB2 8/ SWP POP =brush.size
			( draw ) ,draw-sizepane JSR2
			( draw ) ,draw-toolpane JSR2
			,$touch-end JMP2
		$no-touch-sizepane

		( in pattpane )
		~Mouse.x CLN2r ~pattpane.x1 GTH2 STH2r ~pattpane.x2 LTH2 #0101 NEQ2 ^$no-touch-pattpane JNZ
		~Mouse.y CLN2r ~pattpane.y1 GTH2 STH2r ~pattpane.y2 LTH2 #0101 NEQ2 ^$no-touch-pattpane JNZ
			( release ) #00 =Mouse.state
			~Mouse.x ~pattpane.x1 SUB2 8/ SWP POP =brush.patt
			( draw ) ,draw-pattpane JSR2
			,$touch-end JMP2
		$no-touch-pattpane

		( in toolpane )
		~Mouse.x CLN2r ~toolpane.x1 GTH2 STH2r ~toolpane.x2 LTH2 #0101 NEQ2 ^$no-touch-toolpane JNZ
		~Mouse.y CLN2r ~toolpane.y1 GTH2 STH2r ~toolpane.y2 LTH2 #0101 NEQ2 ^$no-touch-toolpane JNZ
			( release ) #00 =Mouse.state
			~Mouse.x ~toolpane.x1 SUB2 8/ SWP POP =brush.tool
			( draw ) ,draw-toolpane JSR2
			,$touch-end JMP2
		$no-touch-toolpane

		( in viewpane )
		~Mouse.x CLN2r ~viewpane.x1 GTH2 STH2r ~viewpane.x2 LTH2 #0101 NEQ2 ,$no-touch-viewpane JNZ2
		~Mouse.y CLN2r ~viewpane.y1 GTH2 STH2r ~viewpane.y2 LTH2 #0101 NEQ2 ,$no-touch-viewpane JNZ2
			( release ) #00 =Mouse.state
			( clear ) ~canvas.x1 #0002 SUB2 ~canvas.y1 #0002 SUB2 ~canvas.x2 #0002 ADD2 ~canvas.y2 #0002 ADD2 #00 ,fill-rect JSR2
			,draw-background JSR2
			~Mouse.x ~viewpane.x1 SUB2 8/ SWP POP
			DUP #00 NEQ ^$no-incwidth JNZ
				~canvas.w ++ =canvas.w
			$no-incwidth
			DUP #01 NEQ ^$no-decwidth JNZ
				~canvas.w -- =canvas.w
			$no-decwidth
			DUP #02 NEQ ^$no-incheight JNZ
				~canvas.h ++ =canvas.h
			$no-incheight
			DUP #03 NEQ ^$no-decheight JNZ
				~canvas.h -- =canvas.h
			$no-decheight
			POP
			,fit-canvas JSR2
			,redraw JSR2
			,$touch-end JMP2
		$no-touch-viewpane

		( in canvas )
		~Mouse.x CLN2r ~canvas.x1 GTS2 STH2r ~canvas.x2 LTS2 #0101 NEQ2 ,$no-touch-canvas JNZ2
		~Mouse.y CLN2r ~canvas.y1 GTS2 STH2r ~canvas.y2 LTS2 #0101 NEQ2 ,$no-touch-canvas JNZ2

			( set cursor operation )
			,add-pixel ~Mouse.state #01 EQU ,$no-oper JNZ2 POP2 ,remove-pixel $no-oper =brush.oper

			~brush.tool #00 NEQ ^$no-touch-pen JNZ
				~cursor.x0 ~canvas.x1 SUB2 ~cursor.y0 ~canvas.y1 SUB2 ~Mouse.x ~canvas.x1 SUB2 ~Mouse.y ~canvas.y1 SUB2 ,paint-line JSR2
				,$touch-end JMP2
			$no-touch-pen

			~brush.tool #01 NEQ ^$no-touch-brush JNZ
				~Mouse.x ~canvas.x1 SUB2 ~Mouse.y ~canvas.y1 SUB2 ,paint-brush JSR2
				,$touch-end JMP2
			$no-touch-brush

			~brush.tool #04 NEQ ^$no-touch-zoom JNZ
				~zoom.active #00 EQU =zoom.active
				( release ) #00 =Mouse.state
				~Mouse.x ~canvas.x1 SUB2 ~canvas.w 2/ SUB2 =zoom.x
				~Mouse.y ~canvas.y1 SUB2 ~canvas.h 2/ SUB2 =zoom.y
				,redraw JSR2
				,$touch-end JMP2
			$no-touch-zoom

		$no-touch-canvas

		( background interface )
		~Mouse.y STEP8 ~Screen.height #0010 SUB2 NEQ2 ^$no-touch-background JNZ
			~Mouse.x ~Screen.width #0028 SUB2 SUB2 8/ SWP POP
			DUP #00 NEQ ^$no-eye-button JNZ
				,present JSR2
				( release ) #00 =Mouse.state
			$no-eye-button
			DUP #01 NEQ ^$no-rename-button JNZ
				,rename JSR2
				#01 =document.edit
				( release ) #00 =Mouse.state
			$no-rename-button
			DUP #02 NEQ ^$no-load-button JNZ
				,path.name ,load-file JSR2
				,draw-canvas JSR2
				( release ) #00 =Mouse.state
			$no-load-button
			DUP #03 NEQ ^$no-save-button JNZ
				,path.name ,save-file JSR2
				( release ) #00 =Mouse.state
			$no-save-button
			POP
		$no-touch-background

		( jump label )
		$touch-end

	$no-touch

	~Mouse.x =cursor.x0
	~Mouse.y =cursor.y0
	~Mouse.state =brush.last

BRK

@on-button ( -> )

	( if in renaming mode )
	~document.edit #01 NEQ ,$no-edit JNZ2
	~Controller.key #00 EQU ,$no-edit JNZ2
		( enter )
		~Controller.key #0d NEQ ^$no-edit-enter JNZ
			#00 =document.edit
			,redraw JSR2
			BRK
			$no-edit-enter
		( backspace )
		~Controller.key #08 NEQ ^$no-edit-backspace JNZ
			~path.length #00 EQU ^$edit-end JNZ
			~path.length #01 SUB =path.length
			#00 ,path.name #00 ~path.length ADD2 POK2
			BRK
			$no-edit-backspace
		( default )
		~path.length #1f EQU ^$edit-end JNZ
			~Controller.key ,path.name #00 ~path.length ADD2 POK2
			~path.length #01 ADD =path.length
		$edit-end
		#00 ,path.name #00 ~path.length ADD2 POK2
		BRK
	$no-edit
	
	( control zoom )
	~zoom.active #00 EQU ^$skip-zoom JNZ
		~Controller.button #f0 AND
			DUP #04 SFT #01 AND #01 NEQ ^$no-up JNZ
				( move ) ~zoom.y -- =zoom.y $no-up
			DUP #05 SFT #01 AND #01 NEQ ^$no-down JNZ
				( move ) ~zoom.y ++ =zoom.y $no-down
			DUP #06 SFT #01 AND #01 NEQ ^$no-left JNZ
				( move ) ~zoom.x -- =zoom.x $no-left
			DUP #07 SFT #01 AND #01 NEQ ^$no-right JNZ
				( move ) ~zoom.x ++ =zoom.x $no-right
		#00 EQU #04 JNZ ,draw-canvas JSR2
	$skip-zoom

	~Controller.key 
	DUP #20 NEQ ^$no-space JNZ
		( toggle zoom ) ~zoom.active #00 EQU =zoom.active ,redraw JSR2 $no-space 
	DUP #08 NEQ ^$no-backspace JNZ
		( erase ) ,clear JSR2 $no-backspace
	DUP #71 NEQ ^$no-qkey JNZ
		( tool0 ) #00 =brush.tool ,draw-toolpane JSR2 $no-qkey
	DUP #77 NEQ ^$no-wkey JNZ
		( tool0 ) #01 =brush.tool ,draw-toolpane JSR2 $no-wkey
	DUP #65 NEQ ^$no-ekey JNZ
		( tool0 ) #02 =brush.tool ,draw-toolpane JSR2 $no-ekey
	DUP #72 NEQ ^$no-rkey JNZ
		( tool0 ) #03 =brush.tool ,draw-toolpane JSR2 $no-rkey
	DUP #74 NEQ ^$no-tkey JNZ
		( tool0 ) #04 =brush.tool ,draw-toolpane JSR2 $no-tkey
	DUP 
		DUP #30 GTH SWP #39 LTH #0101 NEQ2 ^$no-numkey JNZ
		( size ) ~Controller.key #31 SUB =brush.size ,draw-sizepane JSR2 $no-numkey
	POP

BRK

@center ( -- )
	
	( clear old ) 
	~canvas.x1 #0002 SUB2 ~canvas.y1 #0002 SUB2 ~canvas.x2 #0002 ADD2 ~canvas.y2 #0002 ADD2 #00 ,fill-rect JSR2

	,draw-background JSR2

	~Screen.width #0002 DIV2 ~canvas.w 8* 2/ SUB2 =canvas.x1 
	~Screen.height #0002 DIV2 ~canvas.h 8* 2/ SUB2 =canvas.y1

	,fit-canvas JSR2
	,draw-foreground JSR2

RTN

@rename
	
	,untitled_txt ,path.name ,strcpy JSR2
	#00 =path.length

RTN

@clear ( -- )
	
	,data FILESIZE ,data ADD2
	$loop
		( write ) OVR2 #00 ROT ROT POK2
		( incr ) SWP2 #0001 ADD2 SWP2
		OVR2 OVR2 LTH2 ^$loop JNZ
	POP2 POP2
	,redraw JSR2

RTN

@present

	~document.presentation #00 EQU =document.presentation

	~document.presentation 
	DUP #00 NEQ ^$skip0 JNZ
		~theme.r0 =System.r ~theme.g0 =System.g ~theme.b0 =System.b 
	$skip0
	DUP #01 NEQ ^$skip1 JNZ
		~theme.r1 =System.r ~theme.g1 =System.g ~theme.b1 =System.b 
	$skip1
	POP

	~toolpane.x1 #0002 SUB2 ~toolpane.y1 #0002 SUB2 ~toolpane.x2 ++ ~toolpane.y2 ++ #00 ,fill-rect JSR2
	~pattpane.x1 #0002 SUB2 ~pattpane.y1 #0002 SUB2 ~pattpane.x2 ++ ~pattpane.y2 ++ #00 ,fill-rect JSR2
	~sizepane.x1 #0002 SUB2 ~sizepane.y1 #0002 SUB2 ~sizepane.x2 ++ ~sizepane.y2 ++ #00 ,fill-rect JSR2
	~viewpane.x1 #0002 SUB2 ~viewpane.y1 #0002 SUB2 ~viewpane.x2 ++ ~viewpane.y2 ++ #00 ,fill-rect JSR2

	( clear panes )
	,redraw JSR2

RTN

@fit-canvas
	
	~canvas.w 8* ~canvas.x1 ADD2 =canvas.x2 
	~canvas.h 8* ~canvas.y1 ADD2 =canvas.y2 
	~canvas.x1 -- ~canvas.y1 -- ~canvas.x2 ~canvas.y2 #01 ,line-rect JSR2
	,draw-canvas JSR2

RTN

@paint-line ( x1 y1 x2 y2 -- )
	
	( load ) =line.y1 =line.x1 =line.y2 =line.x2

	( trim if zoomed )
	~zoom.active #01 NEQ ^$no-zoom JNZ
		~line.x1 8/ ~zoom.x ADD2 =line.x1
		~line.y1 8/ ~zoom.y ADD2 =line.y1
		~line.x2 8/ ~zoom.x ADD2 =line.x2
		~line.y2 8/ ~zoom.y ADD2 =line.y2
	$no-zoom

	~line.x1 ~line.x2 SUB2 ABS2 =line.dx
	~line.y1 ~line.y2 SUB2 ABS2 #0000 SWP2 SUB2 =line.dy
	#ffff #00 ~line.x2 ~line.x1 LTS2 #0002 MUL2 ADD2 =line.sx 
	#ffff #00 ~line.y2 ~line.y1 LTS2 #0002 MUL2 ADD2 =line.sy 
	~line.dx ~line.dy ADD2 =line.e1
	$loop
		( paint ) ~line.x2 ~line.y2 ~brush.oper JSR2
		~line.x2 ~line.x1 EQU2 ~line.y2 ~line.y1 EQU2 #0101 EQU2 ^$end JNZ
		~line.e1 #0002 MUL2 =line.e2
		~line.e2 ~line.dy LTS2 ^$skipy JNZ
			~line.e1 ~line.dy ADD2 =line.e1
			~line.x2 ~line.sx ADD2 =line.x2
		$skipy
		~line.e2 ~line.dx GTS2 ^$skipx JNZ
			~line.e1 ~line.dx ADD2 =line.e1
			~line.y2 ~line.sy ADD2 =line.y2
		$skipx
		,$loop JMP2
	$end

	,draw-canvas JSR2
	,draw-foreground JSR2

RTN

@paint-rect ( x1 y1 x2 y2 -- )

	( load ) =rect.y2 =rect.x2 =rect.y1 =rect.x1

	( trim if zoomed )
	~zoom.active #01 NEQ ^$no-zoom JNZ
		~rect.x1 8/ ~zoom.x ADD2 =rect.x1
		~rect.y1 8/ ~zoom.y ADD2 =rect.y1
		~rect.x2 8/ ~zoom.x ADD2 #0001 ADD2 =rect.x2
		~rect.y2 8/ ~zoom.y ADD2 #0001 ADD2 =rect.y2
	$no-zoom

	~rect.x1 =pt2.x
	~rect.y1 =pt2.y

	$ver
		~rect.x1 =pt2.x
		$hor
			~pt2.x SWP POP =px.x ~pt2.y SWP POP =px.y
			,patternize JSR2 #00 EQU ^$no-pixel JNZ
				( draw ) ~pt2.x ~pt2.y ~brush.oper JSR2 $no-pixel
			( incr ) ~pt2.x ++ =pt2.x
			~pt2.x ~rect.x2 LTS2 ^$hor JNZ
		~pt2.y ++ =pt2.y
		~pt2.y ~rect.y2 LTS2 ^$ver JNZ

	,draw-canvas JSR2
	,draw-foreground JSR2
	
RTN

@paint-brush ( x y -- )

	#0003 SUB2 =pt0.y #0003 SUB2 =pt0.x ( cursor offset )

	( trim if zoomed )
	~zoom.active #01 NEQ ^$no-zoom JNZ
		~pt0.x 8/ ~zoom.x ADD2 #0003 SUB2 =pt0.x
		~pt0.y 8/ ~zoom.y ADD2 #0003 SUB2 =pt0.y
	$no-zoom

	#00 =px.x #00 =px.y 
	$ver
		#00 =px.x
		$hor
			( addr ) ,size_icns #00 ~brush.size 8* ADD2
			( byte ) #00 ~px.y ADD2 PEK2 #07 ~px.x SUB SFT #01 AND 
			#00 EQU ^$no-pixel JNZ
			,patternize JSR2 #00 EQU ^$no-pixel JNZ
				~pt0.x #00 ~px.x ADD2 ~pt0.y #00 ~px.y ADD2 ~brush.oper JSR2 $no-pixel
			( incr ) ~px.x #01 ADD =px.x
			~px.x #08 LTH ^$hor JNZ
		( incr ) ~px.y #01 ADD =px.y
		~px.y #08 LTH ^$ver JNZ

	,draw-canvas JSR2
	,draw-foreground JSR2

RTN

@patternize ( -- )

	~brush.patt #00 NEQ ^$noplain JNZ
		#01 RTN $noplain

	~brush.patt #01 NEQ ^$notone1 JNZ
		~pt0.x #00 ~px.x ADD2 ~pt0.y #00 ~px.y ADD2 ADD2 #0001 AND2 #0000 EQU2 
		~pt0.x #00 ~px.x ADD2 ~pt0.y #00 ~px.y ADD2 SUB2 #0001 AND2 #0000 EQU2 
		#0101 EQU2
		RTN $notone1

	~brush.patt #02 NEQ ^$notone2 JNZ
		~pt0.x #00 ~px.x ADD2 ~pt0.y #00 ~px.y ADD2 ADD2 #0003 AND2 #0000 EQU2 
		~pt0.x #00 ~px.x ADD2 ~pt0.y #00 ~px.y ADD2 SUB2 #0003 AND2 #0000 EQU2 
		#0101 EQU2
		RTN $notone2

	~brush.patt #03 NEQ ^$notone3 JNZ
		~pt0.x #00 ~px.x ADD2 ~pt0.y #00 ~px.y ADD2 ADD2 #0005 AND2 #0000 EQU2 
		~pt0.x #00 ~px.x ADD2 ~pt0.y #00 ~px.y ADD2 SUB2 #0005 AND2 #0000 EQU2 
		#0101 EQU2
		RTN $notone3

	~brush.patt #04 NEQ ^$notone4 JNZ
		~pt0.x #00 ~px.x ADD2 ~pt0.y #00 ~px.y ADD2 ADD2 #0003 AND2 #0000 EQU2 RTN $notone4

	~brush.patt #05 NEQ ^$notone5 JNZ
		~pt0.x #00 ~px.x ADD2 ~pt0.y #00 ~px.y ADD2 SUB2 #0003 AND2 #0000 EQU2 RTN $notone5

	~brush.patt #06 NEQ ^$notone6 JNZ
		~pt0.x #00 ~px.x ADD2 #0001 AND2 SWP POP RTN $notone6

	~brush.patt #07 NEQ ^$notone7 JNZ
		~pt0.y #00 ~px.y ADD2 #0001 AND2 SWP POP RTN $notone7

	#00

RTN

@get-pixel ( x y -- b )

	SWP POP #07 AND =px.y
	SWP POP #07 AND =px.x
	( get tile ) ~pt1.x 8/ ~pt1.y 8/ ~canvas.w MUL2 ADD2 8*
	( add addr ) ,data ADD2
	#00 ~px.y ADD2 PEK2 #07 ~px.x SUB SFT #01 AND

RTN

@add-pixel ( x y -- )

	=pt1.y =pt1.x
	( get tile addr ) ,data ~pt1.x 8/ ~pt1.y 8/ ~canvas.w MUL2 ADD2 8* ~pt1.y MOD8 ADD2 ADD2 
	( load ) DUP2 PEK2
	( mask ) #01 #07 ~pt1.x MOD8 SWP POP SUB SFL ORA
	( save ) ROT ROT POK2

RTN

@remove-pixel ( x y -- )

	=pt1.y =pt1.x
	( get tile addr ) ,data ~pt1.x 8/ ~pt1.y 8/ ~canvas.w MUL2 ADD2 8* ~pt1.y MOD8 ADD2 ADD2 
	( load ) DUP2 PEK2
	( mask ) #01 #07 ~pt1.x MOD8 SWP POP SUB SFL #ff EOR AND
	( save ) ROT ROT POK2

RTN

( file )

@load-file ( path -- )

	=File.name FILESIZE =File.length ,data =File.load
	~File.name ,path.name ,strcpy JSR2
	,draw-canvas JSR2

RTN

@save-file ( path -- )

	=File.name FILESIZE =File.length ,data =File.save

RTN

( Drawing )

@redraw ( -- )
	
	,draw-background JSR2
	,draw-canvas JSR2
	,draw-foreground JSR2
		
RTN

@draw-canvas ( -- )
	
	~zoom.active #01 EQU ,draw-canvas-zoom JNZ2

	~canvas.y1 =Screen.y
	,data =Screen.addr
	$ver
		~canvas.x1 =Screen.x 
		$hor
			( draw ) #29 =Screen.color
			( incr ) ~Screen.x 8+ =Screen.x
			( incr ) ~Screen.addr 8+ =Screen.addr
		~Screen.x ~canvas.x2 NEQ2 ^$hor JNZ
		( incr ) ~Screen.y 8+ =Screen.y
	~Screen.y ~canvas.y2 NEQ2 ^$ver JNZ

RTN

@draw-canvas-zoom ( -- )
	
	~zoom.y =pt1.y
	~canvas.y1 =Screen.y
	,data =Screen.addr
	$ver
		~canvas.x1 =Screen.x 
		~zoom.x =pt1.x
		$hor
			( incr ) ,bigpixel_icn #0008 #00 ~pt1.x ~pt1.y ,get-pixel JSR2 MUL2 ADD2 =Screen.addr
			( draw ) #29 =Screen.color
			( incr ) ~Screen.x 8+ =Screen.x
			( incr ) ~pt1.x ++ =pt1.x
		~Screen.x ~canvas.x2 NEQ2 ^$hor JNZ
		( incr ) ~Screen.y 8+ =Screen.y
		( incr ) ~pt1.y ++ =pt1.y
	~Screen.y ~canvas.y2 NEQ2 ^$ver JNZ

RTN

@draw-cursor ( -- )

	,blank_icn =Screen.addr
	( clear brush size )
	~cursor.x #0003 SUB2 =Screen.x ~cursor.y #0003 SUB2 =Screen.y #30 =Screen.color
	( clear last cursor )
	~cursor.x =Screen.x ~cursor.y =Screen.y #30 =Screen.color
	( record cursor positions )
	~Mouse.x =cursor.x ~Mouse.y =cursor.y
	( draw size cursor )
	~brush.tool #01 NEQ ,$outside-canvas JNZ2
	( do not draw size when holding alt )
	~Controller.button #02 EQU ,$outside-canvas JNZ2
	~Mouse.x CLN2r ~canvas.x1 GTH2 STH2r ~canvas.x2 LTH2 #0101 NEQ2 ,$outside-canvas JNZ2
	~Mouse.y CLN2r ~canvas.y1 GTH2 STH2r ~canvas.y2 LTH2 #0101 NEQ2 ,$outside-canvas JNZ2	
	( do not draw size in toolpane )
	~Mouse.x CLN2r ~toolpane.x1 GTH2 STH2r ~toolpane.x2 LTH2 #0101 EQU2 ~Mouse.y CLN2r ~toolpane.y1 GTH2 STH2r ~toolpane.y2 LTH2 #0101 EQU2 #0101 EQU2 ,$outside-canvas JNZ2
	~Mouse.x CLN2r ~sizepane.x1 GTH2 STH2r ~sizepane.x2 LTH2 #0101 EQU2 ~Mouse.y CLN2r ~sizepane.y1 GTH2 STH2r ~sizepane.y2 LTH2 #0101 EQU2 #0101 EQU2 ,$outside-canvas JNZ2
	~Mouse.x CLN2r ~pattpane.x1 GTH2 STH2r ~pattpane.x2 LTH2 #0101 EQU2 ~Mouse.y CLN2r ~pattpane.y1 GTH2 STH2r ~pattpane.y2 LTH2 #0101 EQU2 #0101 EQU2 ,$outside-canvas JNZ2
		~cursor.x #0003 SUB2 =Screen.x ~cursor.y #0003 SUB2 =Screen.y
		,brush_icns #00 ~brush.size 8* ADD2 =Screen.addr
		#31 ~Mouse.state #02 MUL ADD =Screen.color
		~Mouse.state #00 EQU ^$outside-canvas JNZ RTN
	$outside-canvas
	( draw new cursor )
	~cursor.x =Screen.x ~cursor.y =Screen.y
	,pointers_icn #00 ~Controller.button #02 EQU 8* ADD2 =Screen.addr
	#3f ~Mouse.state #01 EQU #0a MUL SUB =Screen.color

RTN

@draw-toolpane ( -- )

	~document.presentation #00 EQU ^$skip JNZ RTN $skip

	( frame )	
	~toolpane.x1 -- ~toolpane.y1 -- ~toolpane.x2 ~toolpane.y2 #00 ,line-rect JSR2
	~toolpane.x1 #0002 SUB2 ~toolpane.y1 #0002 SUB2 ~toolpane.x2 ~toolpane.y2 #01 ,line-rect JSR2

	~toolpane.x1 =Screen.x ~toolpane.y1 =Screen.y ,tool_icns =Screen.addr

	$loop
		( draw ) #21 ~Screen.x ~toolpane.x1 SUB2 8/ SWP POP ~brush.tool EQU #02 MUL ADD =Screen.color
		( incr ) ~Screen.x 8+ =Screen.x
		( incr ) ~Screen.addr 8+ =Screen.addr
		~Screen.x ~toolpane.x2 LTH2 ^$loop JNZ

	~zoom.active #01 NEQ ^$no-zoom JNZ
		~Screen.x #0008 SUB2 =Screen.x
		,tool_icns #0028 ADD2 =Screen.addr
		#21 #04 ~brush.tool EQU #02 MUL ADD =Screen.color
		$no-zoom

RTN

@draw-pattpane ( -- )

	~document.presentation #00 EQU ^$skip JNZ RTN $skip

	( frame )	
	~pattpane.x1 -- ~pattpane.y1 -- ~pattpane.x2 ~pattpane.y2 #00 ,line-rect JSR2
	~pattpane.x1 #0002 SUB2 ~pattpane.y1 #0002 SUB2 ~pattpane.x2 ~pattpane.y2 #01 ,line-rect JSR2

	~pattpane.x1 =Screen.x ~pattpane.y1 =Screen.y ,patt_icns =Screen.addr

	$loop
		( draw ) #21 ~Screen.x ~pattpane.x1 SUB2 8/ SWP POP ~brush.patt EQU #02 MUL ADD =Screen.color
		( incr ) ~Screen.x 8+ =Screen.x
		( incr ) ~Screen.addr 8+ =Screen.addr
		~Screen.x ~pattpane.x2 LTH2 ^$loop JNZ

RTN

@draw-sizepane ( -- )

	~document.presentation #00 EQU ^$skip JNZ RTN $skip

	( frame )
	~sizepane.x1 -- ~sizepane.y1 -- ~sizepane.x2 ~sizepane.y2 #00 ,line-rect JSR2
	~sizepane.x1 #0002 SUB2 ~sizepane.y1 #0002 SUB2 ~sizepane.x2 ~sizepane.y2 #01 ,line-rect JSR2

	~sizepane.x1 =Screen.x ~sizepane.y1 =Screen.y ,size_icns =Screen.addr

	$loop
		( draw ) #21 ~Screen.x ~sizepane.x1 SUB2 8/ SWP POP ~brush.size EQU #02 MUL ADD =Screen.color
		( incr ) ~Screen.x 8+ =Screen.x
		( incr ) ~Screen.addr 8+ =Screen.addr
		~Screen.x ~sizepane.x2 LTH2 ^$loop JNZ

RTN

@draw-viewpane ( -- )
	
	~document.presentation #00 EQU ^$skip JNZ RTN $skip

	( frame )
	~viewpane.x1 -- ~viewpane.y1 -- ~viewpane.x2 ~viewpane.y2 #00 ,line-rect JSR2
	~viewpane.x1 #0002 SUB2 ~viewpane.y1 #0002 SUB2 ~viewpane.x2 ~viewpane.y2 #01 ,line-rect JSR2

	~viewpane.x1 =Screen.x ~viewpane.y1 =Screen.y ,view_icns =Screen.addr

	$loop
		( draw ) #21 =Screen.color
		( incr ) ~Screen.x 8+ =Screen.x
		( incr ) ~Screen.addr 8+ =Screen.addr
		~Screen.x ~viewpane.x2 LTH2 ^$loop JNZ

RTN

@draw-foreground
	
	,draw-toolpane JSR2
	,draw-pattpane JSR2
	,draw-sizepane JSR2
	,draw-viewpane JSR2

RTN

@draw-background
	
	( draw hor line )
	#0000 ~Screen.width ~Screen.height #0002 DIV2 ~document.presentation #00 EQU ,line-horizontal-dotted JSR2
	( draw ver line )
	~Screen.width #0002 DIV2 #0000 ~Screen.height ~document.presentation #00 EQU ,line-vertical-dotted JSR2

	~document.presentation #01 EQU ,$skip-size JNZ2
		( draw size )
		#0010 =Screen.y
		( draw width )
		~Screen.width #00a0 SUB2 =Screen.x ,font_hex ~canvas.w #f0 AND #04 SFT #08 MUL ADD2 =Screen.addr
		( draw ) #21 =Screen.color
		~Screen.x 8+ =Screen.x ,font_hex ~canvas.w #0f AND #08 MUL ADD2 =Screen.addr
		( draw ) #21 =Screen.color
		( draw height )
		~Screen.x 8+ =Screen.x ,font_hex ~canvas.h #f0 AND #04 SFT #08 MUL ADD2 =Screen.addr
		( draw ) #21 =Screen.color
		~Screen.x 8+ =Screen.x ,font_hex ~canvas.h #0f AND #08 MUL ADD2 =Screen.addr
		( draw ) #21 =Screen.color
	$skip-size

	( draw save/load/guides icons )
	~Screen.height #0010 SUB2 =Screen.y
	~Screen.width #0028 SUB2 =Screen.x
	,eye_icn #00 ~document.presentation #08 MUL ADD2 =Screen.addr
	#23 =Screen.color
	~Screen.x 8+ =Screen.x
	,filestate_icn =Screen.addr
	#23 =Screen.color
	~Screen.x 8+ =Screen.x
	,load_icn =Screen.addr
	#23 =Screen.color
	~Screen.x 8+ =Screen.x
	,save_icn =Screen.addr
	#23 =Screen.color
	
	#0008 =Screen.x
	,path.name #01 ,draw-label JSR2

RTN

( Generics )

@line-rect ( x1 y1 x2 y2 color -- )

	( load ) =color DUP2 STH2 =rect.y2 =rect.x2 DUP2 STH2 =rect.y1 =rect.x1
	STH2r STH2r
	$ver
		( save ) OVR2 =Screen.y
		( draw ) ~rect.x1 =Screen.x ~color DUP =Screen.color 
		( draw ) ~rect.x2 =Screen.x =Screen.color
		( incr ) SWP2 ++ SWP2
		OVR2 OVR2 LTS2 ^$ver JNZ
	POP2 POP2
	~rect.x1 ~rect.x2
	$hor
		( save ) OVR2 =Screen.x
		( draw ) ~rect.y1 =Screen.y ~color DUP =Screen.color 
		( draw ) ~rect.y2 =Screen.y =Screen.color
		( incr ) SWP2 ++ SWP2
		OVR2 OVR2 ++ LTS2 ^$hor JNZ
	POP2 POP2

RTN

@fill-rect ( x1 y1 x2 y2 color -- )
	
	=color
	( x1 x2 y1 y2 ) ROT2 SWP2
	$ver
		( save ) OVR2 =Screen.y
		STH2 STH2 OVR2 OVR2 
		$hor
			( save ) OVR2 =Screen.x
			( draw ) ~color =Screen.color
			( incr ) SWP2 ++ SWP2
			OVR2 OVR2 LTS2 ^$hor JNZ
		POP2 POP2 STH2r STH2r
		( incr ) SWP2 ++ SWP2
		OVR2 OVR2 LTS2 ^$ver JNZ
	POP2 POP2 POP2 POP2

RTN

@draw-label ( addr color -- )
	
	=color 
	$loop
		DUP2 PEK2 #00 SWP #0008 MUL2 ,font ADD2 =Screen.addr
		( draw ) ~color #20 ADD =Screen.color
		( incr ) #0001 ADD2
		( incr ) ~Screen.x 8+ =Screen.x
		( loop ) DUP2 PEK2 #00 NEQ ^$loop JNZ
	POP2

RTN

@line-horizontal-dotted ( x0 x1 y color -- )
	
	=color =Screen.y OVR2 =Screen.x
	$draw-hor
		( draw ) ~color =Screen.color
		( incr ) SWP2 #0002 ADD2 DUP2 =Screen.x SWP2
		OVR2 OVR2 LTH2 ^$draw-hor JNZ
	POP2 POP2

RTN

@line-vertical-dotted ( x y0 y1 color -- )
	
	=color STH2 SWP2 =Screen.x STH2r OVR2 =Screen.y
	$draw-ver
		( draw ) ~color =Screen.color
		( incr ) SWP2 #0002 ADD2 DUP2 =Screen.y SWP2
		OVR2 OVR2 LTH2 ^$draw-ver JNZ
	POP2 POP2

RTN

@strcpy ( src* dst* -- )

	$loop
		( copy src->dst ) OVR2 OVR2 SWP2 PEK2 ROT ROT POK2
		( incr dst ) ++
		( incr src ) SWP2 ++ SWP2
		OVR2 PEK2 #00 NEQ ^$loop JNZ
	#00 ROT ROT POK2 POP2
	
RTN

@size_icns    
	[ 0000 0010 0000 0000 ]
	[ 0000 1038 1000 0000 ]
	[ 0000 3838 3800 0000 ]
	[ 0010 387c 3810 0000 ]
	[ 0038 7c7c 7c38 0000 ]
	[ 1038 7cfe 7c38 1000 ]
	[ 387c fefe fe7c 3800 ]
	[ 7cfe fefe fefe 7c00 ]

@patt_icns 
	[ fefe fefe fefe fe00 ]
	[ fed6 aad6 aad6 fe00 ]
	[ fe92 82d6 8292 fe00 ]
	[ fe82 92aa 9282 fe00 ]
	[ fea6 ca92 a6ca fe00 ]
	[ feca a692 caa6 fe00 ]
	[ feaa aaaa aaaa fe00 ]	
	[ fe82 fe82 fe82 fe00 ]

@tool_icns 
	[ c0e0 5028 140a 0400 ]
	[ e0d0 a844 2212 0c00 ]
	[ c0b8 4848 7804 0200 ]
	[ 44ba 4444 44ba 4400 ]
	[ 3048 8484 4834 0200 ] ( zoom )
	[ 3245 8284 4834 0200 ] ( zoom out )

@view_icns 
	[ ee92 8a84 8a92 ee00 ]
	[ f68a 92a2 928a f600 ]
	[ fe82 8244 aa92 ee00 ]
	[ fe82 92aa 4482 fe00 ]

@brush_icns 
	[ 0000 0010 0000 0000 ]
	[ 0000 1028 1000 0000 ]
	[ 0000 3828 3800 0000 ]
	[ 0010 2844 2810 0000 ]
	[ 0038 4444 4438 0000 ]
	[ 1028 4482 4428 1000 ]
	[ 3844 8282 8244 3800 ]
	[ 7c82 8282 8282 7c00 ]
	[ 7cfe fefe fefe 7c00 ]

@bigpixel_icn 
	[ 5580 0080 0080 0080 ]
	[ 55ff 7fff 7fff 7fff ]

@pointers_icn
	[ 80c0 e0f0 f8e0 1000 ]
	[ 4040 4070 f8f8 f870 ]

@eye_icn
	[ 0038 4492 2810 0000 ] ( open )
	[ 0000 0082 4438 0000 ] ( closed )

@filestate_icn  [ 1054 28c6 2854 1000 ]
@load_icn       [ feaa d6aa d4aa f400 ]
@save_icn       [ fe82 8282 848a f400 ]

@blank_icn      [ 0000 0000 0000 0000 ]
@untitled_txt   [ untitled.bit 00 ]

@font_hex ( 0-F TODO: should pull from @font instead.. ) 
[
	003c 464a 5262 3c00 0018 0808 0808 1c00
	003c 4202 3c40 7e00 003c 421c 0242 3c00
	000c 1424 447e 0400 007e 407c 0242 3c00
	003c 407c 4242 3c00 007e 0204 0810 1000
	003c 423c 4242 3c00 003c 4242 3e02 3c00
	003c 4242 7e42 4200 007c 427c 4242 7c00 
	003c 4240 4042 3c00 007c 4242 4242 7c00 
	007e 4078 4040 7e00 007e 4078 4040 4000
]

@font ( spectrum-zx font ) 
[
	0000 0000 0000 0000 0000 2400 7e3c 0000 0000 2400 3c42 0000 0000 6c7c 7c38 1000
	0010 387c 7c38 1000 0038 387c 6c10 3800 0010 387c 7c10 3800 0000 0018 1800 0000
	007e 4242 4242 7e00 0000 1824 2418 0000 0018 2442 4224 1800 001e 063a 4a48 3000
	0038 446c 107c 1000 000c 0808 0838 3800 003e 2222 2266 6600 0000 0822 0022 0800
	0000 1018 1c18 1000 0000 0818 3818 0800 0008 1c00 001c 0800 0028 2828 2800 2800
	003e 4a4a 3a0a 0a00 000c 3046 620c 3000 0000 0000 0000 ffff 0010 3800 3810 0038
	0008 1c2a 0808 0800 0008 0808 2a1c 0800 0000 0804 7e04 0800 0000 1020 7e20 1000
	0000 4040 7e00 0000 0000 0024 6624 0000 0000 1038 7c00 0000 0000 007c 3810 0000
	0000 0000 0000 0000 0008 0808 0800 0800 0014 1400 0000 0000 0024 7e24 247e 2400
	0008 1e28 1c0a 3c08 0042 0408 1020 4200 0030 4832 4c44 3a00 0008 1000 0000 0000
	0004 0808 0808 0400 0010 0808 0808 1000 0000 1408 3e08 1400 0000 0808 3e08 0800
	0000 0000 0008 0810 0000 0000 3c00 0000 0000 0000 0000 0800 0000 0204 0810 2000
	003c 464a 5262 3c00 0018 2808 0808 3e00 003c 4202 3c40 7e00 003c 421c 0242 3c00
	0008 1828 487e 0800 007e 407c 0242 3c00 003c 407c 4242 3c00 007e 0204 0810 1000
	003c 423c 4242 3c00 003c 4242 3e02 3c00 0000 0008 0000 0800 0000 0800 0008 0810
	0000 0810 2010 0800 0000 003e 003e 0000 0000 1008 0408 1000 003c 4202 0c00 0800
	003c 425a 5442 3c00 0018 2442 7e42 4200 007c 427c 4242 7c00 003c 4240 4042 3c00
	0078 4442 4244 7800 007e 407c 4040 7e00 003e 4040 7c40 4000 003c 4240 4e42 3c00
	0042 427e 4242 4200 003e 0808 0808 3e00 0002 0202 4242 3c00 0044 4870 4844 4200
	0040 4040 4040 7e00 0042 665a 4242 4200 0042 6252 4a46 4200 003c 4242 4242 3c00
	007c 4242 7c40 4000 003c 4242 524a 3c00 007c 4242 7c44 4200 003c 403c 0242 3c00
	00fe 1010 1010 1000 0042 4242 4242 3c00 0042 4242 4224 1800 0042 4242 5a66 4200
	0042 2418 1824 4200 0082 4428 1010 1000 007e 0408 1020 7e00 000c 0808 0808 0c00
	0040 2010 0804 0200 0018 0808 0808 1800 0008 1422 0000 0000 0000 0000 0000 7e00
	0008 0400 0000 0000 0000 1c02 1e22 1e00 0020 203c 2222 3c00 0000 1e20 2020 1e00
	0002 021e 2222 1e00 0000 1c22 3c20 1e00 000c 101c 1010 1000 0000 1c22 221e 021c
	0020 202c 3222 2200 0008 0018 0808 0400 0008 0008 0808 4830 0020 2428 3028 2400
	0010 1010 1010 0c00 0000 6854 5454 5400 0000 5864 4444 4400 0000 3844 4444 3800
	0000 7844 4478 4040 0000 3c44 443c 0406 0000 2c30 2020 2000 0000 3840 3804 7800
	0010 103c 1010 0c00 0000 4444 4444 3800 0000 4444 2828 1000 0000 4454 5454 2800
	0000 4428 1028 4400 0000 4444 443c 0438 0000 7c08 1020 7c00 000c 0810 1008 0c00
	0008 0808 0808 0800 0030 1008 0810 3000 0000 0032 4c00 0000 3c42 99a1 a199 423c
]

|2100 @data