Browse code

Added zoom

neauoire authored on 19/03/2021 18:29:46
Showing 3 changed files
1 1
new file mode 100644
2 2
Binary files /dev/null and b/projects/font.bit differ
3 3
new file mode 100644
4 4
Binary files /dev/null and b/projects/picture.bit differ
... ...
@@ -8,12 +8,12 @@
8 8
 		- Only draw-canvas target tile
9 9
 		- Resize buttons
10 10
 		- Zoom
11
-		- Erase
11
+		- Clear all button
12 12
 		- Toggle guides
13
-		- Set eye option
14 13
 		- Complete save/load
15 14
 		- Limit size
16 15
 		- Draw point inbetween
16
+		- Pixel cleanup brush
17 17
 )
18 18
 
19 19
 %RTN   { JMP2r }
... ...
@@ -27,6 +27,7 @@
27 27
 ;center { x 2 y 2 }
28 28
 ;toolbar { x1 2 y1 2 x2 2 y2 2 }
29 29
 ;cursor { x 2 y 2 x0 2 y0 2 size 1 patt 1 drag 1 zoom 1 }
30
+;zoom { x 2 y 2 }
30 31
 ;rect { x1 2 y1 2 x2 2 y2 2 }
31 32
 ;color { byte 1 }
32 33
 ;pos { x 2 y 2 }
... ...
@@ -36,7 +37,7 @@
36 37
 |0100 @RESET 
37 38
 	
38 39
 	( load file )
39
-	( ,filepath ,load-file JSR2 )
40
+	,filepath ,load-file JSR2
40 41
 
41 42
 	( find screen center )
42 43
 	~Screen.width #0002 DIV2 =center.x
... ...
@@ -46,7 +47,7 @@
46 47
 	( default brush )
47 48
 	#04 =cursor.size
48 49
 
49
-	#0026 =canvas.w #001a =canvas.h ( 380x260 )
50
+	#0020 =canvas.w #0010 =canvas.h ( 380x260 )
50 51
 
51 52
 	( center canvas )
52 53
 	~center.x ~canvas.w 8* 2/ SUB2 =canvas.x1 
... ...
@@ -54,7 +55,7 @@
54 55
 
55 56
 	,draw-background JSR2
56 57
 	,fit-canvas JSR2
57
-	
58
+
58 59
 	( fit toolbar )
59 60
 	~toolbar.x1 #0010 ADD2 =toolbar.x2
60 61
 	~toolbar.y1 #0040 ADD2 =toolbar.y2
... ...
@@ -137,6 +138,24 @@ BRK
137 138
 
138 139
 	$no-touch
139 140
 
141
+	,$no-ctrl ~Controller #00 EQU JMP2?
142
+
143
+		,$no-ctrl-up ~Controller #10 EQU JMP2?
144
+			~zoom.y ++ =zoom.y
145
+		$no-ctrl-up
146
+		,$no-ctrl-down ~Controller #20 EQU JMP2?
147
+			~zoom.y -- =zoom.y
148
+		$no-ctrl-down
149
+		,$no-ctrl-left ~Controller #40 EQU JMP2?
150
+			~zoom.x ++ =zoom.x
151
+		$no-ctrl-left
152
+		,$no-ctrl-right ~Controller #80 EQU JMP2?
153
+			~zoom.x -- =zoom.x
154
+		$no-ctrl-right
155
+		,draw-canvas JSR2
156
+
157
+	$no-ctrl
158
+
140 159
 	~Mouse.x =cursor.x0
141 160
 	~Mouse.y =cursor.y0
142 161
 
... ...
@@ -148,12 +167,33 @@ BRK
148 167
 
149 168
 RTN
150 169
 
170
+@fit-canvas
171
+	
172
+	~canvas.w 8* ~canvas.x1 ADD2 =canvas.x2 
173
+	~canvas.h 8* ~canvas.y1 ADD2 =canvas.y2 
174
+	~canvas.x1 -- ~canvas.y1 -- ~canvas.x2 ~canvas.y2 #01 ,line-rect JSR2
175
+	,draw-canvas JSR2
176
+
177
+RTN
178
+
151 179
 @paint ( x y )
152 180
 	
153 181
 	,erase ~Mouse.state #10 EQU JMP2?
154 182
 
155 183
 	#0003 SUB2 =pos.y #0003 SUB2 =pos.x ( cursor offset )
156 184
 
185
+	( trim if zoomed )
186
+	,$no-zoom ~cursor.zoom #01 NEQ JMP2?
187
+		~pos.x 8/ ~zoom.x ADD2 #0003 SUB2 =pos.x
188
+		~pos.y 8/ ~zoom.y ADD2 #0003 SUB2 =pos.y
189
+	$no-zoom
190
+
191
+	( center zoom on paint )
192
+	,$no-follow ~cursor.zoom JMP2?
193
+		~pos.x ~canvas.w 2/ SUB2 #0003 ADD2 =zoom.x
194
+		~pos.y ~canvas.h 2/ SUB2 #0003 ADD2 =zoom.y
195
+	$no-follow
196
+
157 197
 	#00 =px.x #00 =px.y 
158 198
 	$ver
159 199
 		#00 =px.x
... ...
@@ -178,6 +218,18 @@ RTN
178 218
 
179 219
 	#0003 SUB2 =pos.y #0003 SUB2 =pos.x ( cursor offset )
180 220
 
221
+	( trim if zoomed )
222
+	,$no-zoom ~cursor.zoom #01 NEQ JMP2?
223
+		~pos.x 8/ ~zoom.x ADD2 #0003 SUB2 =pos.x
224
+		~pos.y 8/ ~zoom.y ADD2 #0003 SUB2 =pos.y
225
+	$no-zoom
226
+
227
+	( center zoom on paint )
228
+	,$no-follow ~cursor.zoom JMP2?
229
+		~pos.x ~canvas.w 2/ SUB2 #0003 ADD2 =zoom.x
230
+		~pos.y ~canvas.h 2/ SUB2 #0003 ADD2 =zoom.y
231
+	$no-follow
232
+	
181 233
 	#00 =px.x #00 =px.y 
182 234
 	$ver
183 235
 		#00 =px.x
... ...
@@ -246,6 +298,16 @@ RTN
246 298
 
247 299
 RTN
248 300
 
301
+@get-pixel ( x y )
302
+
303
+	SWP POP #07 AND =px.y
304
+	SWP POP #07 AND =px.x
305
+	( get tile ) ~pix.x 8/ ~pix.y 8/ ~canvas.w MUL2 ADD2 8*
306
+	( add addr ) ,data ADD2
307
+	#00 ~px.y ADD2 LDR #07 ~px.x SUB SHR #01 AND
308
+
309
+RTN
310
+
249 311
 @add-pixel ( x y )
250 312
 
251 313
 	=pix.y =pix.x
... ...
@@ -278,6 +340,8 @@ RTN
278 340
 
279 341
 @draw-canvas
280 342
 	
343
+	,draw-canvas-zoom ~cursor.zoom #01 EQU JMP2?
344
+
281 345
 	~canvas.y1 =Sprite.y
282 346
 	,data =Sprite.addr
283 347
 	$ver
... ...
@@ -292,6 +356,26 @@ RTN
292 356
 
293 357
 RTN
294 358
 
359
+@draw-canvas-zoom
360
+	
361
+	~zoom.y =pix.y
362
+	~canvas.y1 =Sprite.y
363
+	,data =Sprite.addr
364
+	$ver
365
+		~canvas.x1 =Sprite.x 
366
+		~zoom.x =pix.x
367
+		$hor
368
+			( incr ) ,bigpixel_icn #0008 #00 ~pix.x ~pix.y ,get-pixel JSR2 MUL2 ADD2 =Sprite.addr
369
+			( draw ) #09 =Sprite.color
370
+			( incr ) ~Sprite.x 8+ =Sprite.x
371
+			( incr ) ~pix.x ++ =pix.x
372
+		,$hor ~Sprite.x ~canvas.x2 NEQ2 JMP2?
373
+		( incr ) ~Sprite.y 8+ =Sprite.y
374
+		( incr ) ~pix.y ++ =pix.y
375
+	,$ver ~Sprite.y ~canvas.y2 NEQ2 JMP2?
376
+
377
+RTN
378
+
295 379
 @draw-cursor
296 380
 
297 381
 	~cursor.x ~Mouse.x NEQU2
... ...
@@ -415,6 +499,8 @@ RTN
415 499
 
416 500
 RTN
417 501
 
502
+( Generics )
503
+
418 504
 @line-rect ( x1 y1 x2 y2 color )
419 505
 
420 506
 	( load ) =color =rect.y2 =rect.x2 DUP2 =Screen.y =rect.y1 DUP2 =Screen.x =rect.x1
... ...
@@ -446,15 +532,6 @@ RTN
446 532
 
447 533
 RTN
448 534
 
449
-@fit-canvas
450
-	
451
-	~canvas.w 8* ~canvas.x1 ADD2 =canvas.x2 
452
-	~canvas.h 8* ~canvas.y1 ADD2 =canvas.y2 
453
-	~canvas.x1 -- ~canvas.y1 -- ~canvas.x2 ~canvas.y2 #01 ,line-rect JSR2
454
-	,draw-canvas JSR2
455
-
456
-RTN
457
-
458 535
 @size_icn    
459 536
 	[ 0000 0010 0000 0000 ]
460 537
     [ 0000 1038 1000 0000 ]
... ...
@@ -490,6 +567,10 @@ RTN
490 567
 	[ 3048 8484 4834 0200 ]
491 568
 	[ 3245 8284 4834 0200 ]
492 569
 
570
+@bigpixel_icn 
571
+	[ 5580 0080 0080 0080 ]
572
+	[ 55ff 7fff 7fff 7fff ]
573
+
493 574
 @brush_pointer  [ 80c0 e0f0 f8e0 1000 ]
494 575
 @brush_hand     [ 4040 4070 f8f8 f870 ]
495 576
 
... ...
@@ -500,7 +581,7 @@ RTN
500 581
 @save_icn       [ fe82 8282 848a f400 ]
501 582
 
502 583
 @blank_icn      [ 0000 0000 0000 0000 ]
503
-@filepath       [ noodle-io.bit 00 ]
584
+@filepath       [ projects/picture.bit 00 ]
504 585
 
505 586
 @font_hex
506 587
 [