... | ... |
@@ -1,5 +1,7 @@ |
1 | 1 |
( |
2 | 2 |
app/noodle : illustration program |
3 |
+ |
|
4 |
+ alt-click - drag canvas |
|
3 | 5 |
|
4 | 6 |
TODO |
5 | 7 |
- Only draw-canvas when mouse has changed |
... | ... |
@@ -14,8 +16,9 @@ |
14 | 16 |
%8- { #0008 SUB2 } %8+ { #0008 ADD2 } |
15 | 17 |
%MOD8 { #0007 AND2 } |
16 | 18 |
|
17 |
-;toolbar { x 2 y 2 } |
|
18 |
-;cursor { x 2 y 2 } |
|
19 |
+;center { x 2 y 2 } |
|
20 |
+;toolbar { x1 2 y1 2 x2 2 y2 2 } |
|
21 |
+;cursor { x 2 y 2 x0 2 y0 2 size 1 drag 1 } |
|
19 | 22 |
;rect { x1 2 y1 2 x2 2 y2 2 } |
20 | 23 |
;color { byte 1 } |
21 | 24 |
;pos { x 2 y 2 } |
... | ... |
@@ -25,13 +28,24 @@ |
25 | 28 |
|
26 | 29 |
|0100 @RESET |
27 | 30 |
|
28 |
- #0038 =toolbar.x #0098 =toolbar.y |
|
31 |
+ ( load file ) |
|
32 |
+ ( ,filepath ,load-file JSR2 ) |
|
33 |
+ |
|
34 |
+ ( find screen center ) |
|
35 |
+ ~Screen.width #0002 DIV2 =center.x |
|
36 |
+ ~Screen.height #0002 DIV2 =center.y |
|
37 |
+ |
|
38 |
+ #0010 =canvas.x1 #0016 =canvas.y1 |
|
39 |
+ #0026 =canvas.w #001a =canvas.h ( 380x260 ) |
|
40 |
+ #0010 =toolbar.x1 #0010 =toolbar.y1 |
|
29 | 41 |
|
30 |
- #0010 =canvas.x1 #0020 =canvas.y1 |
|
31 |
- #0026 =canvas.w #0010 =canvas.h ,fit JSR2 |
|
42 |
+ ,draw-background JSR2 |
|
43 |
+ |
|
44 |
+ ,fit-canvas JSR2 |
|
32 | 45 |
|
33 | 46 |
,draw-titlebar JSR2 |
34 |
- ,draw-toolbar JSR2 |
|
47 |
+ |
|
48 |
+ ,fit-toolbar JSR2 |
|
35 | 49 |
|
36 | 50 |
BRK |
37 | 51 |
|
... | ... |
@@ -39,31 +53,75 @@ BRK |
39 | 53 |
|
40 | 54 |
,draw-cursor JSR2 |
41 | 55 |
|
42 |
- ,$no-touch ~Mouse.state #01 NEQ JMP2? |
|
56 |
+ ( release drag ) |
|
57 |
+ ,$no-release ~Mouse.state #00 EQU ~cursor.drag #01 EQU #0101 NEQ2 JMP2? |
|
58 |
+ #0000 #0000 ~Screen.width ~Screen.height #00 ,fill-rect JSR2 |
|
59 |
+ ~canvas.x1 -- ~canvas.y1 -- ~canvas.x2 ~canvas.y2 #10 ,line-rect JSR2 |
|
60 |
+ ,draw-background JSR2 |
|
61 |
+ ,fit-canvas JSR2 |
|
62 |
+ ,draw-titlebar JSR2 |
|
63 |
+ ,fit-toolbar JSR2 |
|
64 |
+ #00 =cursor.drag |
|
65 |
+ #aa =Console.byte |
|
66 |
+ $no-release |
|
67 |
+ |
|
68 |
+ ,$no-touch ~Mouse.state #00 EQU JMP2? |
|
69 |
+ |
|
70 |
+ ( drag ) |
|
71 |
+ ,$no-drag ~Controller #02 NEQ JMP2? |
|
72 |
+ ~canvas.x1 -- ~canvas.y1 -- ~canvas.x2 ~canvas.y2 #10 ,line-rect JSR2 |
|
73 |
+ ~canvas.x1 ~Mouse.x ~cursor.x0 SUB2 ADD2 =canvas.x1 |
|
74 |
+ ~canvas.y1 ~Mouse.y ~cursor.y0 SUB2 ADD2 =canvas.y1 |
|
75 |
+ ~canvas.w 8* ~canvas.x1 ADD2 =canvas.x2 |
|
76 |
+ ~canvas.h 8* ~canvas.y1 ADD2 =canvas.y2 |
|
77 |
+ ~canvas.x1 -- ~canvas.y1 -- ~canvas.x2 ~canvas.y2 #13 ,line-rect JSR2 |
|
78 |
+ #01 =cursor.drag |
|
79 |
+ ,$touch-end JMP2 |
|
80 |
+ $no-drag |
|
81 |
+ |
|
82 |
+ ( in toolbar ) |
|
83 |
+ ,$no-touch-toolbar ~Mouse.x CLN2r ~toolbar.x1 GTH2 STH2r ~toolbar.x2 LTH2 #0101 NEQ2 JMP2? |
|
84 |
+ ,$no-touch-toolbar ~Mouse.y CLN2r ~toolbar.y1 GTH2 STH2r ~toolbar.y2 LTH2 #0101 NEQ2 JMP2? |
|
85 |
+ ,$no-touch-size ~Mouse.x ~toolbar.x1 SUB2 8/ #0000 NEQ2 JMP2? |
|
86 |
+ ~Mouse.y ~toolbar.y1 SUB2 8/ SWP POP =cursor.size |
|
87 |
+ #00 =Mouse.state |
|
88 |
+ ,draw-toolbar JSR2 |
|
89 |
+ ,$touch-end JMP2 |
|
90 |
+ $no-touch-size |
|
91 |
+ $no-touch-toolbar |
|
92 |
+ |
|
93 |
+ ( in canvas ) |
|
94 |
+ ,$no-touch-canvas ~Mouse.x CLN2r ~canvas.x1 GTH2 STH2r ~canvas.x2 LTH2 #0101 NEQ2 JMP2? |
|
95 |
+ ,$no-touch-canvas ~Mouse.y CLN2r ~canvas.y1 GTH2 STH2r ~canvas.y2 LTH2 #0101 NEQ2 JMP2? |
|
96 |
+ ~Mouse.x ~canvas.x1 SUB2 ~Mouse.y ~canvas.y1 SUB2 ,paint JSR2 |
|
97 |
+ ,$touch-end JMP2 |
|
98 |
+ $no-touch-canvas |
|
99 |
+ |
|
100 |
+ $touch-end |
|
43 | 101 |
|
44 |
- ,$no-paint ~Mouse.x CLN2r ~canvas.x1 GTH2 STH2r ~canvas.x2 LTH2 #0101 NEQ2 JMP2? |
|
45 |
- ,$no-paint ~Mouse.y CLN2r ~canvas.y1 GTH2 STH2r ~canvas.y2 LTH2 #0101 NEQ2 JMP2? |
|
102 |
+ $no-touch |
|
46 | 103 |
|
47 |
- ~Mouse.x ~canvas.x1 SUB2 ~Mouse.y ~canvas.y1 SUB2 ,paint JSR2 |
|
104 |
+ ~Mouse.x =cursor.x0 |
|
105 |
+ ~Mouse.y =cursor.y0 |
|
48 | 106 |
|
49 |
- ,draw-canvas JSR2 |
|
107 |
+BRK |
|
50 | 108 |
|
51 |
- $no-paint |
|
109 |
+@load-file ( path ) |
|
52 | 110 |
|
53 |
- $no-touch |
|
111 |
+ =File.name #8000 =File.length ,data =File.load |
|
54 | 112 |
|
55 |
-BRK |
|
113 |
+RTN |
|
56 | 114 |
|
57 | 115 |
@paint ( x y ) |
58 | 116 |
|
59 |
- #0004 SUB2 =pos.y #0004 SUB2 =pos.x |
|
117 |
+ #0004 SUB2 =pos.y #0004 SUB2 =pos.x ( cursor offset ) |
|
60 | 118 |
|
61 | 119 |
#00 =px.x #00 =px.y |
62 | 120 |
$ver |
63 | 121 |
#00 =px.x |
64 | 122 |
$hor |
65 |
- ( get bit ) |
|
66 |
- ,size1_icn #00 ~px.y ADD2 LDR #07 ~px.x SUB SHR #01 AND ( get bit ) |
|
123 |
+ ( addr ) ,size0_icn #00 ~cursor.size 8* ADD2 |
|
124 |
+ ( byte ) #00 ~px.y ADD2 LDR #07 ~px.x SUB SHR #01 AND |
|
67 | 125 |
|
68 | 126 |
#00 EQU ,$no-pixel ROT JMP2? |
69 | 127 |
~pos.x #00 ~px.x ADD2 ~pos.y #00 ~px.y ADD2 ,add-pixel JSR2 |
... | ... |
@@ -74,8 +132,10 @@ BRK |
74 | 132 |
( incr ) ~px.y #01 ADD =px.y |
75 | 133 |
,$ver ~px.y #08 LTH JMP2? |
76 | 134 |
|
77 |
-RTN |
|
135 |
+ ,draw-canvas JSR2 |
|
136 |
+ ,draw-toolbar JSR2 |
|
78 | 137 |
|
138 |
+RTN |
|
79 | 139 |
|
80 | 140 |
@add-pixel ( x y ) |
81 | 141 |
|
... | ... |
@@ -103,8 +163,6 @@ RTN |
103 | 163 |
( incr ) ~Sprite.y 8+ =Sprite.y |
104 | 164 |
,$ver ~Sprite.y ~canvas.y2 LTH2 JMP2? |
105 | 165 |
|
106 |
- ,draw-toolbar JSR2 |
|
107 |
- |
|
108 | 166 |
RTN |
109 | 167 |
|
110 | 168 |
@line-rect ( x1 y1 x2 y2 color ) |
... | ... |
@@ -124,12 +182,26 @@ RTN |
124 | 182 |
|
125 | 183 |
RTN |
126 | 184 |
|
185 |
+@fill-rect ( x1 y1 x2 y2 color ) |
|
186 |
+ |
|
187 |
+ ( load ) =color =rect.y2 =rect.x2 DUP2 =Screen.y =rect.y1 DUP2 =Screen.x =rect.x1 |
|
188 |
+ $ver |
|
189 |
+ ~rect.x1 =Screen.x |
|
190 |
+ $hor |
|
191 |
+ ( draw ) ~color =Screen.color |
|
192 |
+ ( incr ) ~Screen.x ++ =Screen.x |
|
193 |
+ ,$hor ~Screen.x ~rect.x2 LTH2 JMP2? |
|
194 |
+ ( incr ) ~Screen.y ++ =Screen.y |
|
195 |
+ ,$ver ~Screen.y ~rect.y2 LTH2 JMP2? |
|
196 |
+ |
|
197 |
+RTN |
|
198 |
+ |
|
127 | 199 |
@draw-cursor |
128 | 200 |
|
129 | 201 |
~cursor.x ~Mouse.x NEQU2 |
130 | 202 |
~cursor.y ~Mouse.y NEQU2 |
131 | 203 |
|
132 |
- #0000 EQU2 RTN? ( Return if unchanged ) |
|
204 |
+ #0000 EQU2 ~Mouse.state #00 NEQ #0101 EQU2 RTN? ( Return if unchanged ) |
|
133 | 205 |
|
134 | 206 |
( clear last cursor ) |
135 | 207 |
~cursor.x =Sprite.x |
... | ... |
@@ -144,14 +216,14 @@ RTN |
144 | 216 |
( draw new cursor ) |
145 | 217 |
~cursor.x =Sprite.x |
146 | 218 |
~cursor.y =Sprite.y |
147 |
- ,brush_pointer =Sprite.addr |
|
219 |
+ ,brush_pointer #00 ~Controller #02 EQU #0008 MUL2 ADD2 =Sprite.addr |
|
148 | 220 |
#13 =Sprite.color |
149 | 221 |
|
150 | 222 |
RTN |
151 | 223 |
|
152 | 224 |
@draw-titlebar |
153 | 225 |
|
154 |
- ~canvas.x1 ~canvas.y2 #06 ,filepath |
|
226 |
+ ~canvas.x1 #0001 SUB2 ~canvas.y2 #06 ,filepath |
|
155 | 227 |
( load ) =label.addr =label.color =Sprite.y =Sprite.x |
156 | 228 |
~label.addr |
157 | 229 |
$loop NOP |
... | ... |
@@ -163,7 +235,7 @@ RTN |
163 | 235 |
|
164 | 236 |
RTN |
165 | 237 |
|
166 |
-@fit |
|
238 |
+@fit-canvas |
|
167 | 239 |
|
168 | 240 |
~canvas.w 8* ~canvas.x1 ADD2 =canvas.x2 |
169 | 241 |
~canvas.h 8* ~canvas.y1 ADD2 =canvas.y2 |
... | ... |
@@ -172,33 +244,88 @@ RTN |
172 | 244 |
|
173 | 245 |
RTN |
174 | 246 |
|
247 |
+@fit-toolbar |
|
248 |
+ |
|
249 |
+ ~toolbar.x1 #0010 ADD2 =toolbar.x2 |
|
250 |
+ ~toolbar.y1 #0040 ADD2 =toolbar.y2 |
|
251 |
+ ,draw-toolbar JSR2 |
|
252 |
+ |
|
253 |
+RTN |
|
254 |
+ |
|
175 | 255 |
@draw-toolbar |
176 | 256 |
|
177 |
- ~toolbar.x -- ~toolbar.y -- ~toolbar.x #0010 ADD2 ~toolbar.y #0050 ADD2 #02 ,line-rect JSR2 |
|
178 |
- ~toolbar.x #0002 SUB2 ~toolbar.y #0002 SUB2 ~toolbar.x #0010 ADD2 ++ ~toolbar.y #0050 ADD2 ++ #01 ,line-rect JSR2 |
|
257 |
+ ~toolbar.x1 -- ~toolbar.y1 -- ~toolbar.x2 ~toolbar.y2 #02 ,line-rect JSR2 |
|
258 |
+ ~toolbar.x1 #0002 SUB2 ~toolbar.y1 #0002 SUB2 ~toolbar.x2 ++ ~toolbar.y2 ++ #01 ,line-rect JSR2 |
|
179 | 259 |
|
180 |
- ~toolbar.x =Sprite.x |
|
181 |
- ~toolbar.y =Sprite.y |
|
260 |
+ ~toolbar.x1 =Sprite.x |
|
261 |
+ ~toolbar.y1 =Sprite.y |
|
182 | 262 |
,size0_icn =Sprite.addr |
183 | 263 |
|
184 | 264 |
( draw brush sizes ) |
185 | 265 |
|
186 | 266 |
$sizes |
187 |
- ( draw ) #09 =Sprite.color |
|
267 |
+ |
|
268 |
+ ( draw ) #09 ~Sprite.y ~toolbar.y1 SUB2 8/ SWP POP ~cursor.size EQU #02 MUL ADD =Sprite.color |
|
188 | 269 |
( incr ) ~Sprite.y 8+ =Sprite.y |
189 | 270 |
( incr ) ~Sprite.addr 8+ =Sprite.addr |
190 |
- ,$sizes ~Sprite.y ~toolbar.y #0040 ADD2 LTH2 JMP2? |
|
271 |
+ ,$sizes ~Sprite.y ~toolbar.y1 #0040 ADD2 LTH2 JMP2? |
|
191 | 272 |
|
192 | 273 |
( draw brush tools ) |
193 | 274 |
|
194 |
- ~toolbar.x 8+ =Sprite.x |
|
195 |
- ~toolbar.y =Sprite.y |
|
275 |
+ ~toolbar.x1 8+ =Sprite.x |
|
276 |
+ ~toolbar.y1 =Sprite.y |
|
196 | 277 |
|
197 | 278 |
$brushes |
198 | 279 |
( draw ) #09 =Sprite.color |
199 | 280 |
( incr ) ~Sprite.y 8+ =Sprite.y |
200 | 281 |
( incr ) ~Sprite.addr 8+ =Sprite.addr |
201 |
- ,$brushes ~Sprite.y ~toolbar.y #0040 ADD2 LTH2 JMP2? |
|
282 |
+ ,$brushes ~Sprite.y ~toolbar.y1 #0040 ADD2 LTH2 JMP2? |
|
283 |
+ |
|
284 |
+RTN |
|
285 |
+ |
|
286 |
+@draw-background |
|
287 |
+ |
|
288 |
+ ( draw hor line ) |
|
289 |
+ #0000 =Screen.x ~center.y =Screen.y |
|
290 |
+ #0000 ~Screen.width ( from/to ) |
|
291 |
+ $draw-hor NOP |
|
292 |
+ ( draw ) #01 =Screen.color |
|
293 |
+ ( incr ) SWP2 #0002 ADD2 DUP2 =Screen.x SWP2 |
|
294 |
+ OVR2 OVR2 LTH2 ^$draw-hor SWP JMP? |
|
295 |
+ POP2 POP2 |
|
296 |
+ |
|
297 |
+ ( draw ver line ) |
|
298 |
+ ~center.x =Screen.x #0000 =Screen.y |
|
299 |
+ #0000 ~Screen.height ( from/to ) |
|
300 |
+ $draw-ver NOP |
|
301 |
+ ( draw ) #01 =Screen.color |
|
302 |
+ ( incr ) SWP2 #0002 ADD2 DUP2 =Screen.y SWP2 |
|
303 |
+ OVR2 OVR2 LTH2 ^$draw-ver SWP JMP? |
|
304 |
+ POP2 POP2 |
|
305 |
+ |
|
306 |
+ ( draw save/load icons ) |
|
307 |
+ ~Screen.width #0018 SUB2 =Sprite.x |
|
308 |
+ ~Screen.height #0010 SUB2 =Sprite.y |
|
309 |
+ ,load_icn =Sprite.addr |
|
310 |
+ #01 =Sprite.color |
|
311 |
+ ~Screen.width #0010 SUB2 =Sprite.x |
|
312 |
+ ,save_icn =Sprite.addr |
|
313 |
+ #01 =Sprite.color |
|
314 |
+ |
|
315 |
+ ( draw width ) |
|
316 |
+ ~Screen.width #0040 SUB2 =Sprite.x |
|
317 |
+ ,font_hex ~canvas.w #f0 AND #04 SHR #08 MUL ADD2 =Sprite.addr |
|
318 |
+ ( draw ) #02 =Sprite.color |
|
319 |
+ ~Sprite.x 8+ =Sprite.x |
|
320 |
+ ,font_hex ~canvas.w #0f AND #08 MUL ADD2 =Sprite.addr |
|
321 |
+ ( draw ) #02 =Sprite.color |
|
322 |
+ ~Sprite.x 8+ =Sprite.x |
|
323 |
+ ( draw height ) |
|
324 |
+ ,font_hex ~canvas.h #f0 AND #04 SHR #08 MUL ADD2 =Sprite.addr |
|
325 |
+ ( draw ) #02 =Sprite.color |
|
326 |
+ ~Sprite.x 8+ =Sprite.x |
|
327 |
+ ,font_hex ~canvas.h #0f AND #08 MUL ADD2 =Sprite.addr |
|
328 |
+ ( draw ) #02 =Sprite.color |
|
202 | 329 |
|
203 | 330 |
RTN |
204 | 331 |
|
... | ... |
@@ -223,9 +350,23 @@ RTN |
223 | 350 |
|
224 | 351 |
@mode_guideson [ 0000 0082 4438 0000 ] |
225 | 352 |
@mode_zoomin [ 3245 8284 4834 0200 ] |
353 |
+@load_icn [ feaa d6aa d4aa f400 ] |
|
354 |
+@save_icn [ fe82 8282 848a f400 ] |
|
226 | 355 |
|
227 |
-@blank_icn [ 0000 0000 0000 0000 ] |
|
228 |
-@filepath [ projects/drawings/wtf.chr 00 ] |
|
356 |
+@blank_icn [ 0000 0000 0000 0000 ] |
|
357 |
+@filepath [ noodle-io.bit 00 ] |
|
358 |
+ |
|
359 |
+@font_hex ( 0-F TODO: should pull from @font instead.. ) |
|
360 |
+[ |
|
361 |
+ 003c 464a 5262 3c00 0018 0808 0808 1c00 |
|
362 |
+ 003c 4202 3c40 7e00 003c 421c 0242 3c00 |
|
363 |
+ 000c 1424 447e 0400 007e 407c 0242 3c00 |
|
364 |
+ 003c 407c 4242 3c00 007e 0204 0810 1000 |
|
365 |
+ 003c 423c 4242 3c00 003c 4242 3e02 3c00 |
|
366 |
+ 003c 4242 7e42 4200 007c 427c 4242 7c00 |
|
367 |
+ 003c 4240 4042 3c00 007c 4242 4242 7c00 |
|
368 |
+ 007e 4078 4040 7e00 007e 4078 4040 4000 |
|
369 |
+] |
|
229 | 370 |
|
230 | 371 |
@font ( specter8-frag font ) |
231 | 372 |
[ |
... | ... |
@@ -280,8 +421,8 @@ RTN |
280 | 421 |
|
281 | 422 |
] |
282 | 423 |
|
283 |
-|8000 ;canvas { w 2 h 2 x1 2 y1 2 x2 2 y2 2 } |
|
284 |
-|9000 @data |
|
424 |
+|2000 ;canvas { w 2 h 2 x1 2 y1 2 x2 2 y2 2 } |
|
425 |
+|3000 @data [ ] |
|
285 | 426 |
|
286 | 427 |
|F000 @ERROR BRK |
287 | 428 |
|