Browse code

Moved noodle to its own repo

neauoire authored on 20/05/2021 22:17:40
Showing 3 changed files
... ...
@@ -42,7 +42,7 @@ then
42 42
 fi
43 43
 
44 44
 echo "Assembling.."
45
-./bin/uxnasm projects/demos/piano.usm bin/boot.rom
45
+./bin/uxnasm projects/examples/devices/screen.usm bin/boot.rom
46 46
 
47 47
 echo "Running.."
48 48
 if [ "${2}" = '--cli' ]; 
49 49
new file mode 100644
50 50
Binary files /dev/null and b/projects/pictures/pc98.chr differ
51 51
deleted file mode 100644
... ...
@@ -1,1009 +0,0 @@
1
-(
2
-	app/noodle : illustration program
3
-	
4
-	right-click - erase
5
-	alt-click - drag canvas
6
-	arrows - move zoom
7
-	space - toogle zoom
8
-	backspace - blank canvas
9
-	1-8 - select brush size
10
-
11
-	TODO
12
-		- Pixel cleanup brush
13
-		- Don't zoom move beyond image width
14
-)
15
-
16
-%RTN   { JMP2r }
17
-%ABS2 { DUP2 #000f SFT2 EQU #04 JCN #ffff MUL2 }
18
-%LTS2  { #8000 ADD2 SWP2 #8000 ADD2 GTH2 }
19
-%GTS2  { #8000 ADD2 SWP2 #8000 ADD2 LTH2 }
20
-%CLN2r { DUP2 STH2 }
21
-%STEP8 { #0033 SFT2 }
22
-%MOD8 { #0007 AND2  }
23
-%SFL { #40 SFT SFT }
24
-%++ { #0001 ADD2 } %-- { #0001 SUB2 }
25
-%2/ { #0001 SFT2 }
26
-%8/ { #0003 SFT2 } %8* { #0030 SFT2 }
27
-%8+ { #0008 ADD2 }
28
-%FILESIZE { .canvas/w LDZ2 .canvas/h LDZ2 MUL2 #0008 MUL2 }
29
-
30
-( devices )
31
-
32
-|00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ]
33
-|10 @Console [ &vector $2 &pad $6 &char $1 &byte $1 &short $2 &string $2 ]
34
-|20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &color $1 ]
35
-|80 @Controller [ &vector $2 &button $1 &key $1 ]
36
-|90 @Mouse [ &vector $2 &x $2 &y $2 &state $1 &chord $1 ]
37
-|a0 @File [ &vector $2 &success $2 &offset $2 &pad $2 &name $2 &length $2 &load $2 &save $2 ]
38
-
39
-( variables )
40
-
41
-|0000
42
-
43
-@cursor [ &x $2 &y $2 &x0 $2 &y0 $2 &dx $2 &dy $2 ]
44
-@brush [ &tool $1 &size $1 &patt $1 &drag $1 &last $1 &oper $2 ]
45
-@zoom [ &active $1 &x $2 &y $2 ]
46
-@toolpane [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 ]
47
-@pattpane [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 ]
48
-@sizepane [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 ]
49
-@viewpane [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 ]
50
-@canvas [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 &w $2 &h $2 ]
51
-@rect [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 ]
52
-@line [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 &sx $2 &sy $2 &dx $2 &dy $2 &e1 $2 &e2 $2 ]
53
-@origin [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 ]
54
-@color [ &byte $1 ]
55
-@pt0 [ &x $2 &y $2 ]
56
-@pt1 [ &x $2 &y $2 ]
57
-@pt2 [ &x $2 &y $2 ] ( paint-rect )
58
-@px [ &x $1 &y $1 ]
59
-@document [ &state $1 &edit $1 &presentation $1 ]
60
-@path [ &length $1 &name $20 ]
61
-@timer [ &byte $1 ]
62
-@theme [ &r0 $2 &g0 $2 &b0 $2 &r1 $2 &g1 $2 &b1 $2 ]
63
-
64
-( program )
65
-
66
-|0100
67
-	
68
-	( theme )
69
-	#e0fa .theme/r0 STZ2 #30fa .theme/g0 STZ2 #30fa .theme/b0 STZ2 ( normal mode )
70
-	#00fe .theme/r1 STZ2 #00f3 .theme/g1 STZ2 #00f3 .theme/b1 STZ2 ( presentation mode )
71
-	( vectors ) ;on-screen .Screen/vector DEO2
72
-	( vectors ) ;on-button .Controller/vector DEO2
73
-	( vectors ) ;on-mouse .Mouse/vector DEO2
74
-
75
-	.theme/r0 LDZ2 .System/r DEO2 .theme/g0 LDZ2 .System/g DEO2 .theme/b0 LDZ2 .System/b DEO2
76
-
77
-	( default canvas )
78
-	#002a .canvas/w STZ2 #0018 .canvas/h STZ2
79
-
80
-	( default brush )
81
-	#04 .brush/size STZ #00 .brush/patt STZ #00 .brush/tool STZ
82
-
83
-	( load file )
84
-	;untitled_txt ;path/name ;strcpy JSR2
85
-
86
-	( setup panes )
87
-	#0010 .toolpane/x1 STZ2 #0010 .toolpane/y1 STZ2 .toolpane/x1 LDZ2 #0028 ADD2 .toolpane/x2 STZ2 .toolpane/y1 LDZ2 #0008 ADD2 .toolpane/y2 STZ2
88
-	#0040 .sizepane/x1 STZ2 #0010 .sizepane/y1 STZ2 .sizepane/x1 LDZ2 #0040 ADD2 .sizepane/x2 STZ2 .sizepane/y1 LDZ2 #0008 ADD2 .sizepane/y2 STZ2
89
-	.Screen/width DEI2 #0078 SUB2 .viewpane/x1 STZ2 #0010 .viewpane/y1 STZ2 .viewpane/x1 LDZ2 #0020 ADD2 .viewpane/x2 STZ2 .viewpane/y1 LDZ2 #0008 ADD2 .viewpane/y2 STZ2
90
-	.Screen/width DEI2 #0050 SUB2 .pattpane/x1 STZ2 #0010 .pattpane/y1 STZ2 .pattpane/x1 LDZ2 #0040 ADD2 .pattpane/x2 STZ2 .pattpane/y1 LDZ2 #0008 ADD2 .pattpane/y2 STZ2
91
-
92
-	( ready. )
93
-	;center JSR2
94
-	;clear JSR2
95
-
96
-	( load default file )
97
-	;path/name ;load-file JSR2
98
-
99
-BRK
100
-
101
-@on-screen ( -> )
102
-	
103
-	.document/edit LDZ #01 NEQ ,&no-edit JCN
104
-		#0008 .Screen/x DEO2
105
-		.Screen/height DEI2 #0010 SUB2 .Screen/y DEO2
106
-		;path/name #01 .timer LDZ #04 DIV #03 AND #03 MUL ADD ;draw-label JSR2
107
-		&clear
108
-			#20 .Screen/color DEO
109
-			.Screen/x DEI2 8+ DUP2 .Screen/x DEO2
110
-			.Screen/width DEI2 LTH2 ,&clear JCN
111
-		( blink ) .timer LDZ #01 ADD .timer STZ
112
-	&no-edit
113
-
114
-BRK
115
-
116
-@on-mouse ( -> )
117
-	
118
-	;draw-cursor JSR2
119
-
120
-	( release drag )
121
-	.Mouse/state DEI #00 EQU .brush/drag LDZ #01 EQU #0101 NEQ2 ,&no-release JCN
122
-		.origin/x1 LDZ2 #0002 SUB2 .origin/y1 LDZ2 #0002 SUB2 .origin/x2 LDZ2 #0002 ADD2 .origin/y2 LDZ2 #0002 ADD2 #00 ;fill-rect JSR2
123
-		.canvas/x1 LDZ2 -- .canvas/y1 LDZ2 -- .canvas/x2 LDZ2 .canvas/y2 LDZ2 #10 ;line-rect JSR2
124
-		;draw-background JSR2
125
-		;fit-canvas JSR2
126
-		;draw-foreground JSR2
127
-		#00 .brush/drag STZ
128
-	&no-release
129
-
130
-	( operations on release line/rect )
131
-	.Mouse/state DEI .brush/last LDZ EQU ;&no-touch-change JCN2
132
-	.Mouse/x DEI2 CLN2r .canvas/x1 LDZ2 GTS2 STH2r .canvas/x2 LDZ2 LTS2 #0101 NEQ2 ;&no-touch-change JCN2
133
-	.Mouse/y DEI2 CLN2r .canvas/y1 LDZ2 GTS2 STH2r .canvas/y2 LDZ2 LTS2 #0101 NEQ2 ;&no-touch-change JCN2
134
-		.Mouse/state DEI #00 EQU ,&no-touch-ondown JCN
135
-			( on down )
136
-			.Mouse/x DEI2 .cursor/dx STZ2
137
-			.Mouse/y DEI2 .cursor/dy STZ2
138
-		&no-touch-ondown
139
-		.Mouse/state DEI ,&no-touch-onup JCN
140
-			( on up )
141
-			.brush/tool LDZ #02 NEQ ,&no-touch-line JCN
142
-				.cursor/dx LDZ2 .canvas/x1 LDZ2 SUB2 .cursor/dy LDZ2 .canvas/y1 LDZ2 SUB2 .Mouse/x DEI2 .canvas/x1 LDZ2 SUB2 .Mouse/y DEI2 .canvas/y1 LDZ2 SUB2 ;paint-line JSR2
143
-				;&touch-end JMP2
144
-			&no-touch-line
145
-			.brush/tool LDZ #03 NEQ ,&no-touch-rect JCN
146
-				.cursor/dx LDZ2 .canvas/x1 LDZ2 SUB2 .cursor/dy LDZ2 .canvas/y1 LDZ2 SUB2 .Mouse/x DEI2 .canvas/x1 LDZ2 SUB2 .Mouse/y DEI2 .canvas/y1 LDZ2 SUB2 ;paint-rect JSR2
147
-				;&touch-end JMP2
148
-			&no-touch-rect
149
-		&no-touch-onup
150
-	&no-touch-change
151
-
152
-	.Mouse/state DEI #00 EQU ;&no-touch JCN2
153
-
154
-		( drag )
155
-		.Controller/button DEI #02 NEQ ;&no-drag JCN2
156
-			.brush/drag LDZ ,&no-drag-start JCN
157
-				.canvas/x1 LDZ2 .origin/x1 STZ2
158
-				.canvas/y1 LDZ2 .origin/y1 STZ2
159
-				.canvas/x2 LDZ2 .origin/x2 STZ2
160
-				.canvas/y2 LDZ2 .origin/y2 STZ2
161
-			&no-drag-start
162
-			.canvas/x1 LDZ2 -- .canvas/y1 LDZ2 -- .canvas/x2 LDZ2 .canvas/y2 LDZ2 #10 ;line-rect JSR2
163
-			.canvas/x1 LDZ2 .Mouse/x DEI2 .cursor/x0 LDZ2 SUB2 ADD2 .canvas/x1 STZ2
164
-			.canvas/y1 LDZ2 .Mouse/y DEI2 .cursor/y0 LDZ2 SUB2 ADD2 .canvas/y1 STZ2
165
-			.canvas/w LDZ2 8* .canvas/x1 LDZ2 ADD2 .canvas/x2 STZ2
166
-			.canvas/h LDZ2 8* .canvas/y1 LDZ2 ADD2 .canvas/y2 STZ2
167
-			.canvas/x1 LDZ2 -- .canvas/y1 LDZ2 -- .canvas/x2 LDZ2 .canvas/y2 LDZ2 #13 ;line-rect JSR2
168
-			#01 .brush/drag STZ
169
-			;&touch-end JMP2
170
-		&no-drag
171
-
172
-		( in sizepane )
173
-		.Mouse/x DEI2 CLN2r .sizepane/x1 LDZ2 GTH2 STH2r .sizepane/x2 LDZ2 LTH2 #0101 NEQ2 ,&no-touch-sizepane JCN
174
-		.Mouse/y DEI2 CLN2r .sizepane/y1 LDZ2 GTH2 STH2r .sizepane/y2 LDZ2 LTH2 #0101 NEQ2 ,&no-touch-sizepane JCN
175
-			( release ) #00 .Mouse/state DEO
176
-			#01 .brush/tool STZ
177
-			.Mouse/x DEI2 .sizepane/x1 LDZ2 SUB2 8/ SWP POP .brush/size STZ
178
-			( draw ) ;draw-sizepane JSR2
179
-			( draw ) ;draw-toolpane JSR2
180
-			;&touch-end JMP2
181
-		&no-touch-sizepane
182
-
183
-		( in pattpane )
184
-		.Mouse/x DEI2 CLN2r .pattpane/x1 LDZ2 GTH2 STH2r .pattpane/x2 LDZ2 LTH2 #0101 NEQ2 ,&no-touch-pattpane JCN
185
-		.Mouse/y DEI2 CLN2r .pattpane/y1 LDZ2 GTH2 STH2r .pattpane/y2 LDZ2 LTH2 #0101 NEQ2 ,&no-touch-pattpane JCN
186
-			( release ) #00 .Mouse/state DEO
187
-			.Mouse/x DEI2 .pattpane/x1 LDZ2 SUB2 8/ SWP POP .brush/patt STZ
188
-			( draw ) ;draw-pattpane JSR2
189
-			;&touch-end JMP2
190
-		&no-touch-pattpane
191
-
192
-		( in toolpane )
193
-		.Mouse/x DEI2 CLN2r .toolpane/x1 LDZ2 GTH2 STH2r .toolpane/x2 LDZ2 LTH2 #0101 NEQ2 ,&no-touch-toolpane JCN
194
-		.Mouse/y DEI2 CLN2r .toolpane/y1 LDZ2 GTH2 STH2r .toolpane/y2 LDZ2 LTH2 #0101 NEQ2 ,&no-touch-toolpane JCN
195
-			( release ) #00 .Mouse/state DEO
196
-			.Mouse/x DEI2 .toolpane/x1 LDZ2 SUB2 8/ SWP POP .brush/tool STZ
197
-			( draw ) ;draw-toolpane JSR2
198
-			;&touch-end JMP2
199
-		&no-touch-toolpane
200
-
201
-		( in viewpane )
202
-		.Mouse/x DEI2 CLN2r .viewpane/x1 LDZ2 GTH2 STH2r .viewpane/x2 LDZ2 LTH2 #0101 NEQ2 ;&no-touch-viewpane JCN2
203
-		.Mouse/y DEI2 CLN2r .viewpane/y1 LDZ2 GTH2 STH2r .viewpane/y2 LDZ2 LTH2 #0101 NEQ2 ;&no-touch-viewpane JCN2
204
-			( release ) #00 .Mouse/state DEO
205
-			( clear ) .canvas/x1 LDZ2 #0002 SUB2 .canvas/y1 LDZ2 #0002 SUB2 .canvas/x2 LDZ2 #0002 ADD2 .canvas/y2 LDZ2 #0002 ADD2 #00 ;fill-rect JSR2
206
-			;draw-background JSR2
207
-			.Mouse/x DEI2 .viewpane/x1 LDZ2 SUB2 8/ SWP POP
208
-			DUP ,&no-incwidth JCN
209
-				.canvas/w LDZ2 ++ .canvas/w STZ2
210
-			&no-incwidth
211
-			DUP #01 NEQ ,&no-decwidth JCN
212
-				.canvas/w LDZ2 -- .canvas/w STZ2
213
-			&no-decwidth
214
-			DUP #02 NEQ ,&no-incheight JCN
215
-				.canvas/h LDZ2 ++ .canvas/h STZ2
216
-			&no-incheight
217
-			DUP #03 NEQ ,&no-decheight JCN
218
-				.canvas/h LDZ2 -- .canvas/h STZ2
219
-			&no-decheight
220
-			POP
221
-			;fit-canvas JSR2
222
-			;redraw JSR2
223
-			;&touch-end JMP2
224
-		&no-touch-viewpane
225
-
226
-		( in canvas )
227
-		.Mouse/x DEI2 CLN2r .canvas/x1 LDZ2 GTS2 STH2r .canvas/x2 LDZ2 LTS2 #0101 NEQ2 ;&no-touch-canvas JCN2
228
-		.Mouse/y DEI2 CLN2r .canvas/y1 LDZ2 GTS2 STH2r .canvas/y2 LDZ2 LTS2 #0101 NEQ2 ;&no-touch-canvas JCN2
229
-
230
-			( set cursor operation )
231
-			;add-pixel .Mouse/state DEI #01 EQU ;&no-oper JCN2 POP2 ;remove-pixel &no-oper .brush/oper STZ2
232
-
233
-			.brush/tool LDZ ,&no-touch-pen JCN
234
-				.cursor/x0 LDZ2 .canvas/x1 LDZ2 SUB2 .cursor/y0 LDZ2 .canvas/y1 LDZ2 SUB2 .Mouse/x DEI2 .canvas/x1 LDZ2 SUB2 .Mouse/y DEI2 .canvas/y1 LDZ2 SUB2 ;paint-line JSR2
235
-				;&touch-end JMP2
236
-			&no-touch-pen
237
-
238
-			.brush/tool LDZ #01 NEQ ,&no-touch-brush JCN
239
-				.Mouse/x DEI2 .canvas/x1 LDZ2 SUB2 .Mouse/y DEI2 .canvas/y1 LDZ2 SUB2 ;paint-brush JSR2
240
-				;&touch-end JMP2
241
-			&no-touch-brush
242
-
243
-			.brush/tool LDZ #04 NEQ ,&no-touch-zoom JCN
244
-				.zoom/active LDZ #00 EQU .zoom/active STZ
245
-				( release ) #00 .Mouse/state DEO
246
-				.Mouse/x DEI2 .canvas/x1 LDZ2 SUB2 .canvas/w LDZ2 2/ SUB2 .zoom/x STZ2
247
-				.Mouse/y DEI2 .canvas/y1 LDZ2 SUB2 .canvas/h LDZ2 2/ SUB2 .zoom/y STZ2
248
-				;redraw JSR2
249
-				;&touch-end JMP2
250
-			&no-touch-zoom
251
-
252
-		&no-touch-canvas
253
-
254
-		( background interface )
255
-		.Mouse/y DEI2 STEP8 .Screen/height DEI2 #0010 SUB2 NEQ2 ,&no-touch-background JCN
256
-			.Mouse/x DEI2 .Screen/width DEI2 #0028 SUB2 SUB2 8/ SWP POP
257
-			DUP ,&no-eye-button JCN
258
-				;present JSR2
259
-				( release ) #00 .Mouse/state DEO
260
-			&no-eye-button
261
-			DUP #01 NEQ ,&no-rename-button JCN
262
-				;rename JSR2
263
-				#01 .document/edit STZ
264
-				( release ) #00 .Mouse/state DEO
265
-			&no-rename-button
266
-			DUP #02 NEQ ,&no-load-button JCN
267
-				;path/name ;load-file JSR2
268
-				;draw-canvas JSR2
269
-				( release ) #00 .Mouse/state DEO
270
-			&no-load-button
271
-			DUP #03 NEQ ,&no-save-button JCN
272
-				;path/name ;save-file JSR2
273
-				( release ) #00 .Mouse/state DEO
274
-			&no-save-button
275
-			POP
276
-		&no-touch-background
277
-
278
-		( jump label )
279
-		&touch-end
280
-
281
-	&no-touch
282
-
283
-	.Mouse/x DEI2 .cursor/x0 STZ2
284
-	.Mouse/y DEI2 .cursor/y0 STZ2
285
-	.Mouse/state DEI .brush/last STZ
286
-
287
-BRK
288
-
289
-@on-button ( -> )
290
-
291
-	( if in renaming mode )
292
-	.document/edit LDZ #01 NEQ ;&no-edit JCN2
293
-	.Controller/key DEI #00 EQU ;&no-edit JCN2
294
-		( enter )
295
-		.Controller/key DEI #0d NEQ ,&no-edit-enter JCN
296
-			#00 .document/edit STZ
297
-			;redraw JSR2
298
-			BRK
299
-			&no-edit-enter
300
-		( backspace )
301
-		.Controller/key DEI #08 NEQ ,&no-edit-backspace JCN
302
-			.path/length LDZ #00 EQU ,&edit-end JCN
303
-			.path/length LDZ #01 SUB .path/length STZ
304
-			#00 ;path/name #00 .path/length LDZ ADD2 STA
305
-			BRK
306
-			&no-edit-backspace
307
-		( default )
308
-		.path/length LDZ #1f EQU ,&edit-end JCN
309
-			.Controller/key DEI ;path/name #00 .path/length LDZ ADD2 STA
310
-			.path/length LDZ #01 ADD .path/length STZ
311
-		&edit-end
312
-		#00 ;path/name #00 .path/length LDZ ADD2 STA
313
-		BRK
314
-	&no-edit
315
-	
316
-	( control zoom )
317
-	.zoom/active LDZ #00 EQU ,&skip-zoom JCN
318
-		.Controller/button DEI #f0 AND
319
-			DUP #04 SFT #01 AND #01 NEQ ,&no-up JCN
320
-				( move ) .zoom/y LDZ2 -- .zoom/y STZ2 &no-up
321
-			DUP #05 SFT #01 AND #01 NEQ ,&no-down JCN
322
-				( move ) .zoom/y LDZ2 ++ .zoom/y STZ2 &no-down
323
-			DUP #06 SFT #01 AND #01 NEQ ,&no-left JCN
324
-				( move ) .zoom/x LDZ2 -- .zoom/x STZ2 &no-left
325
-			DUP #07 SFT #01 AND #01 NEQ ,&no-right JCN
326
-				( move ) .zoom/x LDZ2 ++ .zoom/x STZ2 &no-right
327
-		#00 EQU #04 JCN ;draw-canvas JSR2
328
-	&skip-zoom
329
-
330
-	.Controller/key DEI
331
-	DUP #20 NEQ ,&no-space JCN
332
-		( toggle zoom ) .zoom/active LDZ #00 EQU .zoom/active STZ ;redraw JSR2 &no-space
333
-	DUP #08 NEQ ,&no-backspace JCN
334
-		( erase ) ;clear JSR2 &no-backspace
335
-	DUP #71 NEQ ,&no-qkey JCN
336
-		( tool0 ) #00 .brush/tool STZ ;draw-toolpane JSR2 &no-qkey
337
-	DUP #77 NEQ ,&no-wkey JCN
338
-		( tool0 ) #01 .brush/tool STZ ;draw-toolpane JSR2 &no-wkey
339
-	DUP #65 NEQ ,&no-ekey JCN
340
-		( tool0 ) #02 .brush/tool STZ ;draw-toolpane JSR2 &no-ekey
341
-	DUP #72 NEQ ,&no-rkey JCN
342
-		( tool0 ) #03 .brush/tool STZ ;draw-toolpane JSR2 &no-rkey
343
-	DUP #74 NEQ ,&no-tkey JCN
344
-		( tool0 ) #04 .brush/tool STZ ;draw-toolpane JSR2 &no-tkey
345
-	DUP
346
-		DUP #30 GTH SWP #39 LTH #0101 NEQ2 ,&no-numkey JCN
347
-		( size ) .Controller/key DEI #31 SUB .brush/size STZ ;draw-sizepane JSR2 &no-numkey
348
-	POP
349
-
350
-BRK
351
-
352
-@center ( -- )
353
-	
354
-	( clear old )
355
-	.canvas/x1 LDZ2 #0002 SUB2 .canvas/y1 LDZ2 #0002 SUB2 .canvas/x2 LDZ2 #0002 ADD2 .canvas/y2 LDZ2 #0002 ADD2 #00 ;fill-rect JSR2
356
-
357
-	;draw-background JSR2
358
-
359
-	.Screen/width DEI2 #0002 DIV2 .canvas/w LDZ2 8* 2/ SUB2 .canvas/x1 STZ2
360
-	.Screen/height DEI2 #0002 DIV2 .canvas/h LDZ2 8* 2/ SUB2 .canvas/y1 STZ2
361
-
362
-	;fit-canvas JSR2
363
-	;draw-foreground JSR2
364
-
365
-RTN
366
-
367
-@rename
368
-	
369
-	;untitled_txt ;path/name ;strcpy JSR2
370
-	#00 .path/length STZ
371
-
372
-RTN
373
-
374
-@clear ( -- )
375
-	
376
-	;data FILESIZE ;data ADD2
377
-	&loop
378
-		( write ) OVR2 #00 ROT ROT STA
379
-		( incr ) SWP2 #0001 ADD2 SWP2
380
-		OVR2 OVR2 LTH2 ,&loop JCN
381
-	POP2 POP2
382
-	;redraw JSR2
383
-
384
-RTN
385
-
386
-@present
387
-
388
-	.document/presentation LDZ #00 EQU .document/presentation STZ
389
-
390
-	.document/presentation LDZ
391
-	DUP ,&skip0 JCN
392
-		.theme/r0 LDZ2 .System/r DEO2 .theme/g0 LDZ2 .System/g DEO2 .theme/b0 LDZ2 .System/b DEO2
393
-	&skip0
394
-	DUP #01 NEQ ,&skip1 JCN
395
-		.theme/r1 LDZ2 .System/r DEO2 .theme/g1 LDZ2 .System/g DEO2 .theme/b1 LDZ2 .System/b DEO2
396
-	&skip1
397
-	POP
398
-
399
-	.toolpane/x1 LDZ2 #0002 SUB2 .toolpane/y1 LDZ2 #0002 SUB2 .toolpane/x2 LDZ2 ++ .toolpane/y2 LDZ2 ++ #00 ;fill-rect JSR2
400
-	.pattpane/x1 LDZ2 #0002 SUB2 .pattpane/y1 LDZ2 #0002 SUB2 .pattpane/x2 LDZ2 ++ .pattpane/y2 LDZ2 ++ #00 ;fill-rect JSR2
401
-	.sizepane/x1 LDZ2 #0002 SUB2 .sizepane/y1 LDZ2 #0002 SUB2 .sizepane/x2 LDZ2 ++ .sizepane/y2 LDZ2 ++ #00 ;fill-rect JSR2
402
-	.viewpane/x1 LDZ2 #0002 SUB2 .viewpane/y1 LDZ2 #0002 SUB2 .viewpane/x2 LDZ2 ++ .viewpane/y2 LDZ2 ++ #00 ;fill-rect JSR2
403
-
404
-	( clear panes )
405
-	;redraw JSR2
406
-
407
-RTN
408
-
409
-@fit-canvas
410
-	
411
-	.canvas/w LDZ2 8* .canvas/x1 LDZ2 ADD2 .canvas/x2 STZ2
412
-	.canvas/h LDZ2 8* .canvas/y1 LDZ2 ADD2 .canvas/y2 STZ2
413
-	.canvas/x1 LDZ2 -- .canvas/y1 LDZ2 -- .canvas/x2 LDZ2 .canvas/y2 LDZ2 #01 ;line-rect JSR2
414
-	;draw-canvas JSR2
415
-
416
-RTN
417
-
418
-@paint-line ( x1 y1 x2 y2 -- )
419
-	
420
-	( load ) .line/y1 STZ2 .line/x1 STZ2 .line/y2 STZ2 .line/x2 STZ2
421
-
422
-	( trim if zoomed )
423
-	.zoom/active LDZ #01 NEQ ,&no-zoom JCN
424
-		.line/x1 LDZ2 8/ .zoom/x LDZ2 ADD2 .line/x1 STZ2
425
-		.line/y1 LDZ2 8/ .zoom/y LDZ2 ADD2 .line/y1 STZ2
426
-		.line/x2 LDZ2 8/ .zoom/x LDZ2 ADD2 .line/x2 STZ2
427
-		.line/y2 LDZ2 8/ .zoom/y LDZ2 ADD2 .line/y2 STZ2
428
-	&no-zoom
429
-
430
-	.line/x1 LDZ2 .line/x2 LDZ2 SUB2 ABS2 .line/dx STZ2
431
-	.line/y1 LDZ2 .line/y2 LDZ2 SUB2 ABS2 #0000 SWP2 SUB2 .line/dy STZ2
432
-	#ffff #00 .line/x2 LDZ2 .line/x1 LDZ2 LTS2 #0002 MUL2 ADD2 .line/sx STZ2
433
-	#ffff #00 .line/y2 LDZ2 .line/y1 LDZ2 LTS2 #0002 MUL2 ADD2 .line/sy STZ2
434
-	.line/dx LDZ2 .line/dy LDZ2 ADD2 .line/e1 STZ2
435
-	&loop
436
-		( paint ) .line/x2 LDZ2 .line/y2 LDZ2 .brush/oper LDZ2 JSR2
437
-		.line/x2 LDZ2 .line/x1 LDZ2 EQU2 .line/y2 LDZ2 .line/y1 LDZ2 EQU2 #0101 EQU2 ,&end JCN
438
-		.line/e1 LDZ2 #0002 MUL2 .line/e2 STZ2
439
-		.line/e2 LDZ2 .line/dy LDZ2 LTS2 ,&skipy JCN
440
-			.line/e1 LDZ2 .line/dy LDZ2 ADD2 .line/e1 STZ2
441
-			.line/x2 LDZ2 .line/sx LDZ2 ADD2 .line/x2 STZ2
442
-		&skipy
443
-		.line/e2 LDZ2 .line/dx LDZ2 GTS2 ,&skipx JCN
444
-			.line/e1 LDZ2 .line/dx LDZ2 ADD2 .line/e1 STZ2
445
-			.line/y2 LDZ2 .line/sy LDZ2 ADD2 .line/y2 STZ2
446
-		&skipx
447
-		;&loop JMP2
448
-	&end
449
-
450
-	;draw-canvas JSR2
451
-	;draw-foreground JSR2
452
-
453
-RTN
454
-
455
-@paint-rect ( x1 y1 x2 y2 -- )
456
-
457
-	( load ) .rect/y2 STZ2 .rect/x2 STZ2 .rect/y1 STZ2 .rect/x1 STZ2
458
-
459
-	( trim if zoomed )
460
-	.zoom/active LDZ #01 NEQ ,&no-zoom JCN
461
-		.rect/x1 LDZ2 8/ .zoom/x LDZ2 ADD2 .rect/x1 STZ2
462
-		.rect/y1 LDZ2 8/ .zoom/y LDZ2 ADD2 .rect/y1 STZ2
463
-		.rect/x2 LDZ2 8/ .zoom/x LDZ2 ADD2 #0001 ADD2 .rect/x2 STZ2
464
-		.rect/y2 LDZ2 8/ .zoom/y LDZ2 ADD2 #0001 ADD2 .rect/y2 STZ2
465
-	&no-zoom
466
-
467
-	.rect/x1 LDZ2 .pt2/x STZ2
468
-	.rect/y1 LDZ2 .pt2/y STZ2
469
-
470
-	&ver
471
-		.rect/x1 LDZ2 .pt2/x STZ2
472
-		&hor
473
-			.pt2/x LDZ2 SWP POP .px/x STZ .pt2/y LDZ2 SWP POP .px/y STZ
474
-			;patternize JSR2 #00 EQU ,&no-pixel JCN
475
-				( draw ) .pt2/x LDZ2 .pt2/y LDZ2 .brush/oper LDZ2 JSR2 &no-pixel
476
-			( incr ) .pt2/x LDZ2 ++ .pt2/x STZ2
477
-			.pt2/x LDZ2 .rect/x2 LDZ2 LTS2 ,&hor JCN
478
-		.pt2/y LDZ2 ++ .pt2/y STZ2
479
-		.pt2/y LDZ2 .rect/y2 LDZ2 LTS2 ,&ver JCN
480
-
481
-	;draw-canvas JSR2
482
-	;draw-foreground JSR2
483
-	
484
-RTN
485
-
486
-@paint-brush ( x y -- )
487
-
488
-	#0003 SUB2 .pt0/y STZ2 #0003 SUB2 .pt0/x STZ2 ( cursor offset )
489
-
490
-	( trim if zoomed )
491
-	.zoom/active LDZ #01 NEQ ,&no-zoom JCN
492
-		.pt0/x LDZ2 8/ .zoom/x LDZ2 ADD2 #0003 SUB2 .pt0/x STZ2
493
-		.pt0/y LDZ2 8/ .zoom/y LDZ2 ADD2 #0003 SUB2 .pt0/y STZ2
494
-	&no-zoom
495
-
496
-	#00 .px/x STZ #00 .px/y STZ
497
-	&ver
498
-		#00 .px/x STZ
499
-		&hor
500
-			( addr ) ;size_icns #00 .brush/size LDZ 8* ADD2
501
-			( byte ) #00 .px/y LDZ ADD2 LDA #07 .px/x LDZ SUB SFT #01 AND
502
-			#00 EQU ,&no-pixel JCN
503
-			;patternize JSR2 #00 EQU ,&no-pixel JCN
504
-				.pt0/x LDZ2 #00 .px/x LDZ ADD2 .pt0/y LDZ2 #00 .px/y LDZ ADD2 .brush/oper LDZ2 JSR2 &no-pixel
505
-			( incr ) .px/x LDZ #01 ADD .px/x STZ
506
-			.px/x LDZ #08 LTH ,&hor JCN
507
-		( incr ) .px/y LDZ #01 ADD .px/y STZ
508
-		.px/y LDZ #08 LTH ,&ver JCN
509
-
510
-	;draw-canvas JSR2
511
-	;draw-foreground JSR2
512
-
513
-RTN
514
-
515
-@patternize ( -- )
516
-
517
-	.brush/patt LDZ ,&noplain JCN
518
-		#01 RTN &noplain
519
-
520
-	.brush/patt LDZ #01 NEQ ,&notone1 JCN
521
-		.pt0/x LDZ2 #00 .px/x LDZ ADD2 .pt0/y LDZ2 #00 .px/y LDZ ADD2 ADD2 #0001 AND2 #0000 EQU2
522
-		.pt0/x LDZ2 #00 .px/x LDZ ADD2 .pt0/y LDZ2 #00 .px/y LDZ ADD2 SUB2 #0001 AND2 #0000 EQU2
523
-		#0101 EQU2
524
-		RTN &notone1
525
-
526
-	.brush/patt LDZ #02 NEQ ,&notone2 JCN
527
-		.pt0/x LDZ2 #00 .px/x LDZ ADD2 .pt0/y LDZ2 #00 .px/y LDZ ADD2 ADD2 #0003 AND2 #0000 EQU2
528
-		.pt0/x LDZ2 #00 .px/x LDZ ADD2 .pt0/y LDZ2 #00 .px/y LDZ ADD2 SUB2 #0003 AND2 #0000 EQU2
529
-		#0101 EQU2
530
-		RTN &notone2
531
-
532
-	.brush/patt LDZ #03 NEQ ,&notone3 JCN
533
-		.pt0/x LDZ2 #00 .px/x LDZ ADD2 .pt0/y LDZ2 #00 .px/y LDZ ADD2 ADD2 #0005 AND2 #0000 EQU2
534
-		.pt0/x LDZ2 #00 .px/x LDZ ADD2 .pt0/y LDZ2 #00 .px/y LDZ ADD2 SUB2 #0005 AND2 #0000 EQU2
535
-		#0101 EQU2
536
-		RTN &notone3
537
-
538
-	.brush/patt LDZ #04 NEQ ,&notone4 JCN
539
-		.pt0/x LDZ2 #00 .px/x LDZ ADD2 .pt0/y LDZ2 #00 .px/y LDZ ADD2 ADD2 #0003 AND2 #0000 EQU2 RTN &notone4
540
-
541
-	.brush/patt LDZ #05 NEQ ,&notone5 JCN
542
-		.pt0/x LDZ2 #00 .px/x LDZ ADD2 .pt0/y LDZ2 #00 .px/y LDZ ADD2 SUB2 #0003 AND2 #0000 EQU2 RTN &notone5
543
-
544
-	.brush/patt LDZ #06 NEQ ,&notone6 JCN
545
-		.pt0/x LDZ2 #00 .px/x LDZ ADD2 #0001 AND2 SWP POP RTN &notone6
546
-
547
-	.brush/patt LDZ #07 NEQ ,&notone7 JCN
548
-		.pt0/y LDZ2 #00 .px/y LDZ ADD2 #0001 AND2 SWP POP RTN &notone7
549
-
550
-	#00
551
-
552
-RTN
553
-
554
-@get-pixel ( x y -- b )
555
-
556
-	SWP POP #07 AND .px/y STZ
557
-	SWP POP #07 AND .px/x STZ
558
-	( get tile ) .pt1/x LDZ2 8/ .pt1/y LDZ2 8/ .canvas/w LDZ2 MUL2 ADD2 8*
559
-	( add addr ) ;data ADD2
560
-	#00 .px/y LDZ ADD2 LDA #07 .px/x LDZ SUB SFT #01 AND
561
-
562
-RTN
563
-
564
-@add-pixel ( x y -- )
565
-
566
-	.pt1/y STZ2 .pt1/x STZ2
567
-	( get tile addr ) ;data .pt1/x LDZ2 8/ .pt1/y LDZ2 8/ .canvas/w LDZ2 MUL2 ADD2 8* .pt1/y LDZ2 MOD8 ADD2 ADD2
568
-	( load ) DUP2 LDA
569
-	( mask ) #01 #07 .pt1/x LDZ2 MOD8 SWP POP SUB SFL ORA
570
-	( save ) ROT ROT STA
571
-
572
-RTN
573
-
574
-@remove-pixel ( x y -- )
575
-
576
-	.pt1/y STZ2 .pt1/x STZ2
577
-	( get tile addr ) ;data .pt1/x LDZ2 8/ .pt1/y LDZ2 8/ .canvas/w LDZ2 MUL2 ADD2 8* .pt1/y LDZ2 MOD8 ADD2 ADD2
578
-	( load ) DUP2 LDA
579
-	( mask ) #01 #07 .pt1/x LDZ2 MOD8 SWP POP SUB SFL #ff EOR AND
580
-	( save ) ROT ROT STA
581
-
582
-RTN
583
-
584
-( file )
585
-
586
-@load-file ( path -- )
587
-
588
-	.File/name DEO2 FILESIZE .File/length DEO2 ;data .File/load DEO2
589
-	.File/name DEI2 ;path/name ;strcpy JSR2
590
-	;draw-canvas JSR2
591
-
592
-RTN
593
-
594
-@save-file ( path -- )
595
-
596
-	.File/name DEO2 FILESIZE .File/length DEO2 ;data .File/save DEO2
597
-
598
-RTN
599
-
600
-( Drawing )
601
-
602
-@redraw ( -- )
603
-	
604
-	;draw-background JSR2
605
-	;draw-canvas JSR2
606
-	;draw-foreground JSR2
607
-		
608
-RTN
609
-
610
-@draw-canvas ( -- )
611
-	
612
-	.zoom/active LDZ #01 EQU ;draw-canvas-zoom JCN2
613
-
614
-	.canvas/y1 LDZ2 .Screen/y DEO2
615
-	;data .Screen/addr DEO2
616
-	&ver
617
-		.canvas/x1 LDZ2 .Screen/x DEO2
618
-		&hor
619
-			( draw ) #29 .Screen/color DEO
620
-			( incr ) .Screen/x DEI2 8+ .Screen/x DEO2
621
-			( incr ) .Screen/addr DEI2 8+ .Screen/addr DEO2
622
-		.Screen/x DEI2 .canvas/x2 LDZ2 NEQ2 ,&hor JCN
623
-		( incr ) .Screen/y DEI2 8+ .Screen/y DEO2
624
-	.Screen/y DEI2 .canvas/y2 LDZ2 NEQ2 ,&ver JCN
625
-
626
-RTN
627
-
628
-@draw-canvas-zoom ( -- )
629
-	
630
-	.zoom/y LDZ2 .pt1/y STZ2
631
-	.canvas/y1 LDZ2 .Screen/y DEO2
632
-	;data .Screen/addr DEO2
633
-	&ver
634
-		.canvas/x1 LDZ2 .Screen/x DEO2
635
-		.zoom/x LDZ2 .pt1/x STZ2
636
-		&hor
637
-			( incr ) ;bigpixel_icn #0008 #00 .pt1/x LDZ2 .pt1/y LDZ2 ;get-pixel JSR2 MUL2 ADD2 .Screen/addr DEO2
638
-			( draw ) #29 .Screen/color DEO
639
-			( incr ) .Screen/x DEI2 8+ .Screen/x DEO2
640
-			( incr ) .pt1/x LDZ2 ++ .pt1/x STZ2
641
-		.Screen/x DEI2 .canvas/x2 LDZ2 NEQ2 ,&hor JCN
642
-		( incr ) .Screen/y DEI2 8+ .Screen/y DEO2
643
-		( incr ) .pt1/y LDZ2 ++ .pt1/y STZ2
644
-	.Screen/y DEI2 .canvas/y2 LDZ2 NEQ2 ,&ver JCN
645
-
646
-RTN
647
-
648
-@draw-cursor ( -- )
649
-
650
-	;blank_icn .Screen/addr DEO2
651
-	( clear brush size )
652
-	.cursor/x LDZ2 #0003 SUB2 .Screen/x DEO2 .cursor/y LDZ2 #0003 SUB2 .Screen/y DEO2 #30 .Screen/color DEO
653
-	( clear last cursor )
654
-	.cursor/x LDZ2 .Screen/x DEO2 .cursor/y LDZ2 .Screen/y DEO2 #30 .Screen/color DEO
655
-	( record cursor positions )
656
-	.Mouse/x DEI2 .cursor/x STZ2 .Mouse/y DEI2 .cursor/y STZ2
657
-	( draw size cursor )
658
-	.brush/tool LDZ #01 NEQ ;&outside-canvas JCN2
659
-	( do not draw size when holding alt )
660
-	.Controller/button DEI #02 EQU ;&outside-canvas JCN2
661
-	.Mouse/x DEI2 CLN2r .canvas/x1 LDZ2 GTH2 STH2r .canvas/x2 LDZ2 LTH2 #0101 NEQ2 ;&outside-canvas JCN2
662
-	.Mouse/y DEI2 CLN2r .canvas/y1 LDZ2 GTH2 STH2r .canvas/y2 LDZ2 LTH2 #0101 NEQ2 ;&outside-canvas JCN2	
663
-	( do not draw size in toolpane )
664
-	.Mouse/x DEI2 CLN2r .toolpane/x1 LDZ2 GTH2 STH2r .toolpane/x2 LDZ2 LTH2 #0101 EQU2 .Mouse/y DEI2 CLN2r .toolpane/y1 LDZ2 GTH2 STH2r .toolpane/y2 LDZ2 LTH2 #0101 EQU2 #0101 EQU2 ;&outside-canvas JCN2
665
-	.Mouse/x DEI2 CLN2r .sizepane/x1 LDZ2 GTH2 STH2r .sizepane/x2 LDZ2 LTH2 #0101 EQU2 .Mouse/y DEI2 CLN2r .sizepane/y1 LDZ2 GTH2 STH2r .sizepane/y2 LDZ2 LTH2 #0101 EQU2 #0101 EQU2 ;&outside-canvas JCN2
666
-	.Mouse/x DEI2 CLN2r .pattpane/x1 LDZ2 GTH2 STH2r .pattpane/x2 LDZ2 LTH2 #0101 EQU2 .Mouse/y DEI2 CLN2r .pattpane/y1 LDZ2 GTH2 STH2r .pattpane/y2 LDZ2 LTH2 #0101 EQU2 #0101 EQU2 ;&outside-canvas JCN2
667
-		.cursor/x LDZ2 #0003 SUB2 .Screen/x DEO2 .cursor/y LDZ2 #0003 SUB2 .Screen/y DEO2
668
-		;brush_icns #00 .brush/size LDZ 8* ADD2 .Screen/addr DEO2
669
-		#31 .Mouse/state DEI #02 MUL ADD .Screen/color DEO
670
-		.Mouse/state DEI #00 EQU ,&outside-canvas JCN RTN
671
-	&outside-canvas
672
-	( draw new cursor )
673
-	.cursor/x LDZ2 .Screen/x DEO2 .cursor/y LDZ2 .Screen/y DEO2
674
-	;pointers_icn #00 .Controller/button DEI #02 EQU 8* ADD2 .Screen/addr DEO2
675
-	#3f .Mouse/state DEI #01 EQU #0a MUL SUB .Screen/color DEO
676
-
677
-RTN
678
-
679
-@draw-toolpane ( -- )
680
-
681
-	.document/presentation LDZ #00 EQU ,&skip JCN RTN &skip
682
-
683
-	( frame ) 	
684
-	.toolpane/x1 LDZ2 -- .toolpane/y1 LDZ2 -- .toolpane/x2 LDZ2 .toolpane/y2 LDZ2 #00 ;line-rect JSR2
685
-	.toolpane/x1 LDZ2 #0002 SUB2 .toolpane/y1 LDZ2 #0002 SUB2 .toolpane/x2 LDZ2 .toolpane/y2 LDZ2 #01 ;line-rect JSR2
686
-
687
-	.toolpane/x1 LDZ2 .Screen/x DEO2 .toolpane/y1 LDZ2 .Screen/y DEO2 ;tool_icns .Screen/addr DEO2
688
-
689
-	&loop
690
-		( draw ) #21 .Screen/x DEI2 .toolpane/x1 LDZ2 SUB2 8/ SWP POP .brush/tool LDZ EQU #02 MUL ADD .Screen/color DEO
691
-		( incr ) .Screen/x DEI2 8+ .Screen/x DEO2
692
-		( incr ) .Screen/addr DEI2 8+ .Screen/addr DEO2
693
-		.Screen/x DEI2 .toolpane/x2 LDZ2 LTH2 ,&loop JCN
694
-
695
-	.zoom/active LDZ #01 NEQ ,&no-zoom JCN
696
-		.Screen/x DEI2 #0008 SUB2 .Screen/x DEO2
697
-		;tool_icns #0028 ADD2 .Screen/addr DEO2
698
-		#21 #04 .brush/tool LDZ EQU #02 MUL ADD .Screen/color DEO
699
-		&no-zoom
700
-
701
-RTN
702
-
703
-@draw-pattpane ( -- )
704
-
705
-	.document/presentation LDZ #00 EQU ,&skip JCN RTN &skip
706
-
707
-	( frame ) 	
708
-	.pattpane/x1 LDZ2 -- .pattpane/y1 LDZ2 -- .pattpane/x2 LDZ2 .pattpane/y2 LDZ2 #00 ;line-rect JSR2
709
-	.pattpane/x1 LDZ2 #0002 SUB2 .pattpane/y1 LDZ2 #0002 SUB2 .pattpane/x2 LDZ2 .pattpane/y2 LDZ2 #01 ;line-rect JSR2
710
-
711
-	.pattpane/x1 LDZ2 .Screen/x DEO2 .pattpane/y1 LDZ2 .Screen/y DEO2 ;patt_icns .Screen/addr DEO2
712
-
713
-	&loop
714
-		( draw ) #21 .Screen/x DEI2 .pattpane/x1 LDZ2 SUB2 8/ SWP POP .brush/patt LDZ EQU #02 MUL ADD .Screen/color DEO
715
-		( incr ) .Screen/x DEI2 8+ .Screen/x DEO2
716
-		( incr ) .Screen/addr DEI2 8+ .Screen/addr DEO2
717
-		.Screen/x DEI2 .pattpane/x2 LDZ2 LTH2 ,&loop JCN
718
-
719
-RTN
720
-
721
-@draw-sizepane ( -- )
722
-
723
-	.document/presentation LDZ #00 EQU ,&skip JCN RTN &skip
724
-
725
-	( frame )
726
-	.sizepane/x1 LDZ2 -- .sizepane/y1 LDZ2 -- .sizepane/x2 LDZ2 .sizepane/y2 LDZ2 #00 ;line-rect JSR2
727
-	.sizepane/x1 LDZ2 #0002 SUB2 .sizepane/y1 LDZ2 #0002 SUB2 .sizepane/x2 LDZ2 .sizepane/y2 LDZ2 #01 ;line-rect JSR2
728
-
729
-	.sizepane/x1 LDZ2 .Screen/x DEO2 .sizepane/y1 LDZ2 .Screen/y DEO2 ;size_icns .Screen/addr DEO2
730
-
731
-	&loop
732
-		( draw ) #21 .Screen/x DEI2 .sizepane/x1 LDZ2 SUB2 8/ SWP POP .brush/size LDZ EQU #02 MUL ADD .Screen/color DEO
733
-		( incr ) .Screen/x DEI2 8+ .Screen/x DEO2
734
-		( incr ) .Screen/addr DEI2 8+ .Screen/addr DEO2
735
-		.Screen/x DEI2 .sizepane/x2 LDZ2 LTH2 ,&loop JCN
736
-
737
-RTN
738
-
739
-@draw-viewpane ( -- )
740
-	
741
-	.document/presentation LDZ #00 EQU ,&skip JCN RTN &skip
742
-
743
-	( frame )
744
-	.viewpane/x1 LDZ2 -- .viewpane/y1 LDZ2 -- .viewpane/x2 LDZ2 .viewpane/y2 LDZ2 #00 ;line-rect JSR2
745
-	.viewpane/x1 LDZ2 #0002 SUB2 .viewpane/y1 LDZ2 #0002 SUB2 .viewpane/x2 LDZ2 .viewpane/y2 LDZ2 #01 ;line-rect JSR2
746
-
747
-	.viewpane/x1 LDZ2 .Screen/x DEO2 .viewpane/y1 LDZ2 .Screen/y DEO2 ;view_icns .Screen/addr DEO2
748
-
749
-	&loop
750
-		( draw ) #21 .Screen/color DEO
751
-		( incr ) .Screen/x DEI2 8+ .Screen/x DEO2
752
-		( incr ) .Screen/addr DEI2 8+ .Screen/addr DEO2
753
-		.Screen/x DEI2 .viewpane/x2 LDZ2 LTH2 ,&loop JCN
754
-
755
-RTN
756
-
757
-@draw-foreground
758
-	
759
-	;draw-toolpane JSR2
760
-	;draw-pattpane JSR2
761
-	;draw-sizepane JSR2
762
-	;draw-viewpane JSR2
763
-
764
-RTN
765
-
766
-@draw-background
767
-	
768
-	( draw hor line )
769
-	#0000 .Screen/width DEI2 .Screen/height DEI2 #0002 DIV2 .document/presentation LDZ #00 EQU ;line-horizontal-dotted JSR2
770
-	( draw ver line )
771
-	.Screen/width DEI2 #0002 DIV2 #0000 .Screen/height DEI2 .document/presentation LDZ #00 EQU ;line-vertical-dotted JSR2
772
-
773
-	.document/presentation LDZ #01 EQU ;&skip-size JCN2
774
-		( draw size )
775
-		#0010 .Screen/y DEO2
776
-		( draw width )
777
-		.Screen/width DEI2 #00a0 SUB2 .Screen/x DEO2 ;font_hex .canvas/w LDZ2 #f0 AND #04 SFT #08 MUL ADD2 .Screen/addr DEO2
778
-		( draw ) #21 .Screen/color DEO
779
-		.Screen/x DEI2 8+ .Screen/x DEO2 ;font_hex .canvas/w LDZ2 #0f AND #08 MUL ADD2 .Screen/addr DEO2
780
-		( draw ) #21 .Screen/color DEO
781
-		( draw height )
782
-		.Screen/x DEI2 8+ .Screen/x DEO2 ;font_hex .canvas/h LDZ2 #f0 AND #04 SFT #08 MUL ADD2 .Screen/addr DEO2
783
-		( draw ) #21 .Screen/color DEO
784
-		.Screen/x DEI2 8+ .Screen/x DEO2 ;font_hex .canvas/h LDZ2 #0f AND #08 MUL ADD2 .Screen/addr DEO2
785
-		( draw ) #21 .Screen/color DEO
786
-	&skip-size
787
-
788
-	( draw save/load/guides icons )
789
-	.Screen/height DEI2 #0010 SUB2 .Screen/y DEO2
790
-	.Screen/width DEI2 #0028 SUB2 .Screen/x DEO2
791
-	;eye_icn #00 .document/presentation LDZ #08 MUL ADD2 .Screen/addr DEO2
792
-	#23 .Screen/color DEO
793
-	.Screen/x DEI2 8+ .Screen/x DEO2
794
-	;filestate_icn .Screen/addr DEO2
795
-	#23 .Screen/color DEO
796
-	.Screen/x DEI2 8+ .Screen/x DEO2
797
-	;load_icn .Screen/addr DEO2
798
-	#23 .Screen/color DEO
799
-	.Screen/x DEI2 8+ .Screen/x DEO2
800
-	;save_icn .Screen/addr DEO2
801
-	#23 .Screen/color DEO
802
-	
803
-	#0008 .Screen/x DEO2
804
-	;path/name #01 ;draw-label JSR2
805
-
806
-RTN
807
-
808
-( Generics )
809
-
810
-@line-rect ( x1 y1 x2 y2 color -- )
811
-
812
-	( load ) .color STZ DUP2 STH2 .rect/y2 STZ2 .rect/x2 STZ2 DUP2 STH2 .rect/y1 STZ2 .rect/x1 STZ2
813
-	STH2r STH2r
814
-	&ver
815
-		( save ) OVR2 .Screen/y DEO2
816
-		( draw ) .rect/x1 LDZ2 .Screen/x DEO2 .color LDZ DUP .Screen/color DEO
817
-		( draw ) .rect/x2 LDZ2 .Screen/x DEO2 .Screen/color DEO
818
-		( incr ) SWP2 ++ SWP2
819
-		OVR2 OVR2 LTS2 ,&ver JCN
820
-	POP2 POP2
821
-	.rect/x1 LDZ2 .rect/x2 LDZ2
822
-	&hor
823
-		( save ) OVR2 .Screen/x DEO2
824
-		( draw ) .rect/y1 LDZ2 .Screen/y DEO2 .color LDZ DUP .Screen/color DEO
825
-		( draw ) .rect/y2 LDZ2 .Screen/y DEO2 .Screen/color DEO
826
-		( incr ) SWP2 ++ SWP2
827
-		OVR2 OVR2 ++ LTS2 ,&hor JCN
828
-	POP2 POP2
829
-
830
-RTN
831
-
832
-@fill-rect ( x1 y1 x2 y2 color -- )
833
-	
834
-	.color STZ
835
-	( x1 x2 y1 y2 ) ROT2 SWP2
836
-	&ver
837
-		( save ) OVR2 .Screen/y DEO2
838
-		STH2 STH2 OVR2 OVR2
839
-		&hor
840
-			( save ) OVR2 .Screen/x DEO2
841
-			( draw ) .color LDZ .Screen/color DEO
842
-			( incr ) SWP2 ++ SWP2
843
-			OVR2 OVR2 LTS2 ,&hor JCN
844
-		POP2 POP2 STH2r STH2r
845
-		( incr ) SWP2 ++ SWP2
846
-		OVR2 OVR2 LTS2 ,&ver JCN
847
-	POP2 POP2 POP2 POP2
848
-
849
-RTN
850
-
851
-@draw-label ( addr color -- )
852
-	
853
-	.color STZ
854
-	&loop
855
-		DUP2 LDA #00 SWP #0008 MUL2 ;font ADD2 .Screen/addr DEO2
856
-		( draw ) .color LDZ #20 ADD .Screen/color DEO
857
-		( incr ) #0001 ADD2
858
-		( incr ) .Screen/x DEI2 8+ .Screen/x DEO2
859
-		( loop ) DUP2 LDA ,&loop JCN
860
-	POP2
861
-
862
-RTN
863
-
864
-@line-horizontal-dotted ( x0 x1 y color -- )
865
-	
866
-	.color STZ .Screen/y DEO2 OVR2 .Screen/x DEO2
867
-	&draw-hor
868
-		( draw ) .color LDZ .Screen/color DEO
869
-		( incr ) SWP2 #0002 ADD2 DUP2 .Screen/x DEO2 SWP2
870
-		OVR2 OVR2 LTH2 ,&draw-hor JCN
871
-	POP2 POP2
872
-
873
-RTN
874
-
875
-@line-vertical-dotted ( x y0 y1 color -- )
876
-	
877
-	.color STZ STH2 SWP2 .Screen/x DEO2 STH2r OVR2 .Screen/y DEO2
878
-	&draw-ver
879
-		( draw ) .color LDZ .Screen/color DEO
880
-		( incr ) SWP2 #0002 ADD2 DUP2 .Screen/y DEO2 SWP2
881
-		OVR2 OVR2 LTH2 ,&draw-ver JCN
882
-	POP2 POP2
883
-
884
-RTN
885
-
886
-@strcpy ( src* dst* -- )
887
-
888
-	&loop
889
-		( copy src->dst ) OVR2 OVR2 SWP2 LDA ROT ROT STA
890
-		( incr dst ) ++
891
-		( incr src ) SWP2 ++ SWP2
892
-		OVR2 LDA ,&loop JCN
893
-	#00 ROT ROT STA POP2
894
-	
895
-RTN
896
-
897
-@size_icns
898
-	[ 0000 0010 0000 0000 ]
899
-	[ 0000 1038 1000 0000 ]
900
-	[ 0000 3838 3800 0000 ]
901
-	[ 0010 387c 3810 0000 ]
902
-	[ 0038 7c7c 7c38 0000 ]
903
-	[ 1038 7cfe 7c38 1000 ]
904
-	[ 387c fefe fe7c 3800 ]
905
-	[ 7cfe fefe fefe 7c00 ]
906
-
907
-@patt_icns
908
-	[ fefe fefe fefe fe00 ]
909
-	[ fed6 aad6 aad6 fe00 ]
910
-	[ fe92 82d6 8292 fe00 ]
911
-	[ fe82 92aa 9282 fe00 ]
912
-	[ fea6 ca92 a6ca fe00 ]
913
-	[ feca a692 caa6 fe00 ]
914
-	[ feaa aaaa aaaa fe00 ]	
915
-	[ fe82 fe82 fe82 fe00 ]
916
-
917
-@tool_icns
918
-	[ c0e0 5028 140a 0400 ]
919
-	[ e0d0 a844 2212 0c00 ]
920
-	[ c0b8 4848 7804 0200 ]
921
-	[ 44ba 4444 44ba 4400 ]
922
-	[ 3048 8484 4834 0200 ] ( zoom )
923
-	[ 3245 8284 4834 0200 ] ( zoom out )
924
-
925
-@view_icns
926
-	[ ee92 8a84 8a92 ee00 ]
927
-	[ f68a 92a2 928a f600 ]
928
-	[ fe82 8244 aa92 ee00 ]
929
-	[ fe82 92aa 4482 fe00 ]
930
-
931
-@brush_icns
932
-	[ 0000 0010 0000 0000 ]
933
-	[ 0000 1028 1000 0000 ]
934
-	[ 0000 3828 3800 0000 ]
935
-	[ 0010 2844 2810 0000 ]
936
-	[ 0038 4444 4438 0000 ]
937
-	[ 1028 4482 4428 1000 ]
938
-	[ 3844 8282 8244 3800 ]
939
-	[ 7c82 8282 8282 7c00 ]
940
-	[ 7cfe fefe fefe 7c00 ]
941
-
942
-@bigpixel_icn
943
-	[ 5580 0080 0080 0080 ]
944
-	[ 55ff 7fff 7fff 7fff ]
945
-
946
-@pointers_icn
947
-	[ 80c0 e0f0 f8e0 1000 ]
948
-	[ 2020 20b8 7c7c 3838 ]
949
-
950
-@eye_icn
951
-	[ 0038 4492 2810 0000 ] ( open )
952
-	[ 0000 0082 4438 0000 ] ( closed )
953
-
954
-@filestate_icn  [ 1054 28c6 2854 1000 ]
955
-@load_icn       [ feaa d6aa d4aa f400 ]
956
-@save_icn       [ fe82 8282 848a f400 ]
957
-
958
-@blank_icn      [ 0000 0000 0000 0000 ]
959
-@untitled_txt   [ "untitled.bit 00 ]
960
-
961
-@font_hex ( 0-F TODO: should pull from @font instead.. )
962
-[
963
-	003c 464a 5262 3c00 0018 0808 0808 1c00
964
-	003c 4202 3c40 7e00 003c 421c 0242 3c00
965
-	000c 1424 447e 0400 007e 407c 0242 3c00
966
-	003c 407c 4242 3c00 007e 0204 0810 1000
967
-	003c 423c 4242 3c00 003c 4242 3e02 3c00
968
-	003c 4242 7e42 4200 007c 427c 4242 7c00
969
-	003c 4240 4042 3c00 007c 4242 4242 7c00
970
-	007e 4078 4040 7e00 007e 4078 4040 4000
971
-]
972
-
973
-@font ( spectrum-zx font )
974
-[
975
-	0000 0000 0000 0000 0000 2400 7e3c 0000 0000 2400 3c42 0000 0000 6c7c 7c38 1000
976
-	0010 387c 7c38 1000 0038 387c 6c10 3800 0010 387c 7c10 3800 0000 0018 1800 0000
977
-	007e 4242 4242 7e00 0000 1824 2418 0000 0018 2442 4224 1800 001e 063a 4a48 3000
978
-	0038 446c 107c 1000 000c 0808 0838 3800 003e 2222 2266 6600 0000 0822 0022 0800
979
-	0000 1018 1c18 1000 0000 0818 3818 0800 0008 1c00 001c 0800 0028 2828 2800 2800
980
-	003e 4a4a 3a0a 0a00 000c 3046 620c 3000 0000 0000 0000 ffff 0010 3800 3810 0038
981
-	0008 1c2a 0808 0800 0008 0808 2a1c 0800 0000 0804 7e04 0800 0000 1020 7e20 1000
982
-	0000 4040 7e00 0000 0000 0024 6624 0000 0000 1038 7c00 0000 0000 007c 3810 0000
983
-	0000 0000 0000 0000 0008 0808 0800 0800 0014 1400 0000 0000 0024 7e24 247e 2400
984
-	0008 1e28 1c0a 3c08 0042 0408 1020 4200 0030 4832 4c44 3a00 0008 1000 0000 0000
985
-	0004 0808 0808 0400 0010 0808 0808 1000 0000 1408 3e08 1400 0000 0808 3e08 0800
986
-	0000 0000 0008 0810 0000 0000 3c00 0000 0000 0000 0000 0800 0000 0204 0810 2000
987
-	003c 464a 5262 3c00 0018 2808 0808 3e00 003c 4202 3c40 7e00 003c 421c 0242 3c00
988
-	0008 1828 487e 0800 007e 407c 0242 3c00 003c 407c 4242 3c00 007e 0204 0810 1000
989
-	003c 423c 4242 3c00 003c 4242 3e02 3c00 0000 0008 0000 0800 0000 0800 0008 0810
990
-	0000 0810 2010 0800 0000 003e 003e 0000 0000 1008 0408 1000 003c 4202 0c00 0800
991
-	003c 425a 5442 3c00 0018 2442 7e42 4200 007c 427c 4242 7c00 003c 4240 4042 3c00
992
-	0078 4442 4244 7800 007e 407c 4040 7e00 003e 4040 7c40 4000 003c 4240 4e42 3c00
993
-	0042 427e 4242 4200 003e 0808 0808 3e00 0002 0202 4242 3c00 0044 4870 4844 4200
994
-	0040 4040 4040 7e00 0042 665a 4242 4200 0042 6252 4a46 4200 003c 4242 4242 3c00
995
-	007c 4242 7c40 4000 003c 4242 524a 3c00 007c 4242 7c44 4200 003c 403c 0242 3c00
996
-	00fe 1010 1010 1000 0042 4242 4242 3c00 0042 4242 4224 1800 0042 4242 5a66 4200
997
-	0042 2418 1824 4200 0082 4428 1010 1000 007e 0408 1020 7e00 000c 0808 0808 0c00
998
-	0040 2010 0804 0200 0018 0808 0808 1800 0008 1422 0000 0000 0000 0000 0000 7e00
999
-	0008 0400 0000 0000 0000 1c02 1e22 1e00 0020 203c 2222 3c00 0000 1e20 2020 1e00
1000
-	0002 021e 2222 1e00 0000 1c22 3c20 1e00 000c 101c 1010 1000 0000 1c22 221e 021c
1001
-	0020 202c 3222 2200 0008 0018 0808 0400 0008 0008 0808 4830 0020 2428 3028 2400
1002
-	0010 1010 1010 0c00 0000 6854 5454 5400 0000 5864 4444 4400 0000 3844 4444 3800
1003
-	0000 7844 4478 4040 0000 3c44 443c 0406 0000 2c30 2020 2000 0000 3840 3804 7800
1004
-	0010 103c 1010 0c00 0000 4444 4444 3800 0000 4444 2828 1000 0000 4454 5454 2800
1005
-	0000 4428 1028 4400 0000 4444 443c 0438 0000 7c08 1020 7c00 000c 0810 1008 0c00
1006
-	0008 0808 0808 0800 0030 1008 0810 3000 0000 0032 4c00 0000 3c42 99a1 a199 423c
1007
-]
1008
-
1009
-|2100 @data