Browse code

Added color tables to nasu

neauoire authored on 17/04/2021 05:42:00
Showing 2 changed files
1 1
new file mode 100644
2 2
Binary files /dev/null and b/projects/pictures/daria10x10.chr differ
... ...
@@ -8,7 +8,8 @@
8 8
 	1 2 3  - select brush
9 9
 
10 10
 	TODO:
11
-		Color selector, RGB sliders
11
+		Save/load/rename
12
+		Select paint color for 2-bit mode
12 13
 )
13 14
 
14 15
 %RTN   { JMP2r }
... ...
@@ -41,6 +42,7 @@
41 42
 
42 43
 ;bankview { x 2 y 2 mode 1 addr 2 selection 1 }
43 44
 ;tileview { x 2 y 2 addr 2 }
45
+;colorview { x1 2 y1 2 x2 2 y2 2 }
44 46
 ;blendview { x1 2 y1 2 x2 2 y2 2 }
45 47
 ;rect { x1 2 y1 2 x2 2 y2 2 }
46 48
 ;mouse { x 2 y 2 }
... ...
@@ -69,14 +71,15 @@
69 71
 	( vectors ) ,on-transfer =File.vector
70 72
 
71 73
 	~Screen.width 2/ #008a SUB2 =bankview.x 
72
-	~Screen.height 2/ #002f SUB2 =bankview.y 
74
+	~Screen.height 2/ #003f SUB2 =bankview.y 
73 75
 	BANK =settings.page
74 76
 
75 77
 	~Screen.width 2/ #0002 ADD2 =tileview.x 
76
-	~Screen.height 2/ #002f SUB2 =tileview.y 
78
+	~Screen.height 2/ #003f SUB2 =tileview.y 
77 79
 	BANK #0448 ADD2 =tileview.addr
78 80
 
79
-	~Screen.width 2/ #0061 ADD2 ~Screen.height 2/ #0068 SUB2 #0020 #0020 SIZE-TO-RECT ,blendview SET-RECT
81
+	~Screen.width 2/ #0002 ADD2 ~Screen.height 2/ #0048 ADD2 #0020 #0020 SIZE-TO-RECT ,colorview SET-RECT
82
+	~Screen.width 2/ #0061 ADD2 ~Screen.height 2/ #0048 ADD2 #0020 #0020 SIZE-TO-RECT ,blendview SET-RECT
80 83
 
81 84
 	#01 =settings.blending
82 85
 
... ...
@@ -84,6 +87,7 @@
84 87
 	,filepath2 =File.name #0800 =File.length BANK #0800 ADD2 =File.load
85 88
 	,filepath3 =File.name #1000 =File.length BANK #1000 ADD2 =File.load
86 89
 	,filepath4 =File.name #1000 =File.length BANK #2000 ADD2 =File.load
90
+	,filepath5 =File.name #1000 =File.length BANK #2800 ADD2 =File.load
87 91
 
88 92
 	,redraw JSR2
89 93
 
... ...
@@ -126,7 +130,7 @@ BRK
126 130
 			,redraw JSR2
127 131
 		$no-number
128 132
 		~Controller.key #20 NEQ ^$no-space JNZ
129
-			~settings.depth #00 EQU =settings.depth
133
+			,toggle-depth JSR2
130 134
 			,redraw JSR2
131 135
 		$no-space
132 136
 	$no-key
... ...
@@ -154,7 +158,7 @@ BRK
154 158
 				( save ) ,filepath1  =File.name #0800 =File.length ~settings.page =File.save
155 159
 			$no-save-click
156 160
 			~Mouse.x ~bankview.x SUB2 8/ #0005 NEQ2 ^$no-toggle-depth JNZ
157
-				( toggle ) ~settings.depth #00 EQU =settings.depth
161
+				,toggle-depth JSR2
158 162
 			$no-toggle-depth
159 163
 				( release ) #00 =Mouse.state
160 164
 				,redraw JSR2 ,$click-end JMP2
... ...
@@ -165,6 +169,11 @@ BRK
165 169
 		~Mouse.y DUP2 ~blendview.y1 GTH2 ROT ROT ~blendview.y2 LTH2 #0101 EQU2
166 170
 		#0101 EQU2 ,on-touch-blendview JNZ2
167 171
 
172
+		( bankview )
173
+		~Mouse.x DUP2 ~colorview.x1 GTH2 ROT ROT ~colorview.x2 LTH2 #0101 EQU2
174
+		~Mouse.y DUP2 ~colorview.y1 GTH2 ROT ROT ~colorview.y2 LTH2 #0101 EQU2
175
+		#0101 EQU2 ,on-touch-colorview JNZ2
176
+
168 177
 		( bankview )
169 178
 		~Mouse.x ~bankview.x GTH2 ~Mouse.x ~bankview.x #0080 ADD2 LTH2 #0101 EQU2
170 179
 		~Mouse.y ~bankview.y GTH2 ~Mouse.y ~bankview.y #0080 ADD2 LTH2 #0101 EQU2
... ...
@@ -268,6 +277,42 @@ BRK
268 277
 
269 278
 BRK 
270 279
 
280
+@on-touch-colorview ( -> )
281
+	
282
+	( channel ) ~Mouse.y ~colorview.y1 SUB2 8/ SWP POP STH
283
+	( rgb ) ~Mouse.x ~colorview.x1 SUB2 8/ SWP POP
284
+	DUP #01 NEQ ^$no-red JNZ
285
+		DUPr STHr ,System.r ,set-color JSR2 $no-red
286
+	DUP #02 NEQ ^$no-green JNZ 
287
+		DUPr STHr ,System.g ,set-color JSR2 $no-green
288
+	DUP #03 NEQ ^$no-blue JNZ 
289
+		DUPr STHr ,System.b ,set-color JSR2 $no-blue
290
+	POP POPr
291
+	( release ) #00 =Mouse.state
292
+	,redraw JSR2
293
+
294
+BRK
295
+
296
+@set-color ( color rgb -- )
297
+	
298
+	STH2
299
+	DUP #00 NEQ ^$no-red0 JNZ
300
+		DUP2r STH2r PEK2 DUP #04 SFT #01 ADD ~Mouse.state #10 EQU #fe MUL ADD #40 SFT SWP #0f AND ADD DUP2r STH2r POK2
301
+		$no-red0
302
+	DUP #01 NEQ ^$no-red1 JNZ
303
+		DUP2r STH2r PEK2 DUP #0f AND #01 ADD ~Mouse.state #10 EQU #fe MUL ADD #0f AND SWP #f0 AND ADD DUP2r STH2r POK2
304
+		$no-red1
305
+	DUP #02 NEQ ^$no-red2 JNZ
306
+		DUP2r STH2r #0001 ADD2 PEK2 DUP #04 SFT #01 ADD ~Mouse.state #10 EQU #fe MUL ADD #40 SFT SWP #0f AND ADD DUP2r STH2r #0001 ADD2 POK2
307
+		$no-red2
308
+	DUP #03 NEQ ^$no-red3 JNZ
309
+		DUP2r STH2r #0001 ADD2 PEK2 DUP #0f AND #01 ADD ~Mouse.state #10 EQU #fe MUL ADD #0f AND SWP #f0 AND ADD DUP2r STH2r #0001 ADD2 POK2
310
+		$no-red3
311
+	POP
312
+	POP2r
313
+
314
+RTN
315
+
271 316
 @select-tile ( pos -- )
272 317
 
273 318
 	( x y ) DUP #0f AND SWP #04 SFT
... ...
@@ -279,6 +324,14 @@ BRK
279 324
 
280 325
 RTN
281 326
 
327
+@toggle-depth ( -- )
328
+	
329
+	~bankview.selection
330
+	~settings.depth #00 EQU =settings.depth
331
+	,select-tile JSR2
332
+
333
+RTN
334
+
282 335
 @op_shiftup
283 336
 	
284 337
 	~tileview.addr PEK2
... ...
@@ -312,6 +365,7 @@ RTN
312 365
 	,draw-bankview JSR2
313 366
 	,draw-tileview JSR2
314 367
 	,draw-blendview JSR2
368
+	,draw-colorview JSR2
315 369
 
316 370
 RTN
317 371
 
... ...
@@ -330,7 +384,7 @@ RTN
330 384
 	~bankview.y #0010 SUB2 =Screen.y
331 385
 
332 386
 	~bankview.x #0028 ADD2 =Screen.x
333
-	,depth_icn #00 ~settings.depth 8* ADD2 =Screen.addr
387
+	,depth_icns #00 ~settings.depth 8* ADD2 =Screen.addr
334 388
 	#23 =Screen.color
335 389
 
336 390
 	~bankview.x #0068 ADD2 =Screen.x
... ...
@@ -507,8 +561,6 @@ RTN
507 561
 
508 562
 @draw-blendview ( -- )
509 563
 
510
-	~blendview.x1 #0002 SUB2 ~blendview.y1 #0002 SUB2 ~blendview.x2 ++ ~blendview.y2 ++ #03 ,line-rect JSR2
511
-
512 564
 	~tileview.addr =Screen.addr
513 565
 	#00 #10
514 566
 	$loop
... ...
@@ -520,8 +572,8 @@ RTN
520 572
 		DUP2 LTH ^$loop JNZ
521 573
 	POP2
522 574
 
523
-	~blendview.x1 =Screen.x
524
-	~blendview.y1 #0010 SUB2 =Screen.y
575
+	~blendview.x1 #0019 SUB2 =Screen.x
576
+	~blendview.y1 #0018 ADD2 =Screen.y
525 577
 
526 578
 	( get blending ) ~settings.blending
527 579
 	( get depth ) ~settings.depth #20 MUL
... ...
@@ -529,6 +581,47 @@ RTN
529 581
 
530 582
 RTN
531 583
 
584
+@draw-colorview ( -- )
585
+	
586
+	~colorview.y1 #18 ADD =Screen.y
587
+	~colorview.x1 #08 ADD =Screen.x
588
+	~System.r ,draw-color-code JSR2
589
+	~colorview.y1 #18 ADD =Screen.y
590
+	~colorview.x1 #10 ADD =Screen.x
591
+	~System.g ,draw-color-code JSR2
592
+	~colorview.y1 #18 ADD =Screen.y
593
+	~colorview.x1 #18 ADD =Screen.x
594
+	~System.b ,draw-color-code JSR2	
595
+
596
+	~colorview.x1 =Screen.x
597
+	,full_icn =Screen.addr
598
+
599
+	#00 #04
600
+	$loop
601
+		OVR ~colorview.y1 ROT #00 SWP #0008 MUL2 ADD2 =Screen.y
602
+		OVR #20 ADD =Screen.color
603
+		SWP #01 ADD SWP
604
+		DUP2 LTH ^$loop JNZ
605
+	POP2
606
+
607
+RTN
608
+
609
+@draw-color-code ( color* -- )
610
+	
611
+	DUP ,font_hex ROT #0f AND #08 MUL #00 SWP ADD2 =Screen.addr
612
+	( draw ) #22 =Screen.color
613
+	~colorview.y1 #10 ADD =Screen.y
614
+	,font_hex ROT #04 SFT #08 MUL #00 SWP ADD2 =Screen.addr
615
+	( draw ) #22 =Screen.color
616
+	~colorview.y1 #08 ADD =Screen.y
617
+	DUP ,font_hex ROT #0f AND #08 MUL #00 SWP ADD2 =Screen.addr
618
+	( draw ) #22 =Screen.color
619
+	~colorview.y1 =Screen.y
620
+	,font_hex ROT #04 SFT #08 MUL #00 SWP ADD2 =Screen.addr
621
+	( draw ) #22 =Screen.color
622
+
623
+RTN
624
+
532 625
 @draw-cursor
533 626
 
534 627
 	( clear last cursor )
... ...
@@ -601,6 +694,7 @@ RTN
601 694
 
602 695
 RTN
603 696
 
697
+@full_icn      [ 0038 7cfe fefe 7c38 ]
604 698
 @tool_selector [ 80c0 e0f0 f8e0 1000 ]
605 699
 @tool_hand     [ 4040 4070 f8f8 f870 ]
606 700
 @tool_eraser   [ 2050 b87c 3e1c 0800 ]
... ...
@@ -608,10 +702,12 @@ RTN
608 702
 	0000 0000 0000 0000
609 703
 	7cfe fefe fefe 7c00
610 704
 ]
611
-@depth_icn [
705
+
706
+@depth_icns [
612 707
 	00fe 8282 fe82 82fe
613 708
 	00fe 9292 fe92 92fe
614 709
 ]
710
+
615 711
 @load_icn      [ feaa d6aa d4aa f400 ]
616 712
 @save_icn      [ fe82 8282 848a f400 ]
617 713
 @moveup_icn    [ 0010 387c fe10 1000 ]
... ...
@@ -620,6 +716,7 @@ RTN
620 716
 @filepath2     [ projects/pictures/cibo.bit 00 ]
621 717
 @filepath3     [ projects/pictures/zerotwo10x10.chr 00 ]
622 718
 @filepath4     [ projects/fonts/katahira8.bit 00 ]
719
+@filepath5     [ projects/pictures/daria10x10.chr 00 ]
623 720
 
624 721
 @font_hex ( 0-F ) 
625 722
 [