Browse code

Improving noodle

neauoire authored on 24/03/2021 23:30:52
Showing 3 changed files
... ...
@@ -28,7 +28,7 @@ else
28 28
 fi
29 29
 
30 30
 echo "Assembling.."
31
-./bin/assembler projects/software/left.usm bin/boot.rom
31
+./bin/assembler projects/software/noodle.usm bin/boot.rom
32 32
 
33 33
 echo "Running.."
34 34
 if [ "${2}" = '--cli' ]; 
... ...
@@ -36,8 +36,10 @@
36 36
 ( variables )
37 37
 
38 38
 ;center { x 2 y 2 }
39
-;toolbar { x1 2 y1 2 x2 2 y2 2 }
40
-;cursor { x 2 y 2 x0 2 y0 2 size 1 patt 1 drag 1 mirror 1 oper 2 }
39
+;toolpane { x1 2 y1 2 x2 2 y2 2 }
40
+;pattpane { x1 2 y1 2 x2 2 y2 2 }
41
+;sizepane { x1 2 y1 2 x2 2 y2 2 }
42
+;cursor { x 2 y 2 x0 2 y0 2 tool 1 size 1 patt 1 drag 1 mirror 1 oper 2 }
41 43
 ;zoom { active 1 x 2 y 2 }
42 44
 ;rect { x1 2 y1 2 x2 2 y2 2 }
43 45
 ;line { x0 2 y0 2 x 2 y 2 sx 2 sy 2 dx 2 dy 2 e1 2 e2 2 }
... ...
@@ -68,6 +70,8 @@
68 70
 
69 71
 	( default brush )
70 72
 	#04 =cursor.size
73
+	#00 =cursor.patt
74
+	#00 =cursor.tool
71 75
 
72 76
 	( load file )
73 77
 	,filepath ,load-file JSR2
... ...
@@ -75,7 +79,6 @@
75 79
 	( find screen center )
76 80
 	~Screen.width #0002 DIV2 =center.x
77 81
 	~Screen.height #0002 DIV2 =center.y
78
-	#0010 =toolbar.x1 #0010 =toolbar.y1
79 82
 
80 83
 	( center canvas )
81 84
 	~center.x ~canvas.w 8* 2/ SUB2 =canvas.x1 
... ...
@@ -84,10 +87,22 @@
84 87
 	,draw-background JSR2
85 88
 	,fit-canvas JSR2
86 89
 
87
-	( fit toolbar )
88
-	~toolbar.x1 #0010 ADD2 =toolbar.x2
89
-	~toolbar.y1 #0040 ADD2 =toolbar.y2
90
-	,draw-toolbar JSR2
90
+	( setup panes )
91
+	#0010 =toolpane.x1 #0010 =toolpane.y1
92
+	#0010 =pattpane.x1 ~Screen.height #0018 SUB2 =pattpane.y1
93
+	~Screen.width #0050 SUB2 =sizepane.x1 #0010 =sizepane.y1
94
+
95
+	~toolpane.x1 #0020 ADD2 =toolpane.x2
96
+	~toolpane.y1 #0008 ADD2 =toolpane.y2
97
+	,draw-toolpane JSR2
98
+
99
+	~pattpane.x1 #0040 ADD2 =pattpane.x2
100
+	~pattpane.y1 #0008 ADD2 =pattpane.y2
101
+	,draw-pattpane JSR2
102
+
103
+	~sizepane.x1 #0040 ADD2 =sizepane.x2
104
+	~sizepane.y1 #0008 ADD2 =sizepane.y2
105
+	,draw-sizepane JSR2
91 106
 
92 107
 BRK
93 108
 
... ...
@@ -101,7 +116,9 @@ BRK
101 116
 		~canvas.x1 -- ~canvas.y1 -- ~canvas.x2 ~canvas.y2 #10 ,line-rect JSR2
102 117
 		,draw-background JSR2
103 118
 		,fit-canvas JSR2
104
-		,draw-toolbar JSR2
119
+		,draw-toolpane JSR2
120
+		,draw-pattpane JSR2
121
+		,draw-sizepane JSR2
105 122
 		#00 =cursor.drag
106 123
 	$no-release
107 124
 
... ...
@@ -125,43 +142,55 @@ BRK
125 142
 			,$touch-end JMP2
126 143
 		$no-drag
127 144
 
128
-		( in toolbar )
129
-		,$no-touch-toolbar ~Mouse.x CLN2r ~toolbar.x1 GTH2 STH2r ~toolbar.x2 LTH2 #0101 NEQ2 JMP2?
130
-		,$no-touch-toolbar ~Mouse.y CLN2r ~toolbar.y1 GTH2 STH2r ~toolbar.y2 LTH2 #0101 NEQ2 JMP2?
145
+		( in sizepane )
146
+		,$no-touch-sizepane ~Mouse.x CLN2r ~sizepane.x1 GTH2 STH2r ~sizepane.x2 LTH2 #0101 NEQ2 JMP2?
147
+		,$no-touch-sizepane ~Mouse.y CLN2r ~sizepane.y1 GTH2 STH2r ~sizepane.y2 LTH2 #0101 NEQ2 JMP2?
131 148
 			( release ) #00 =Mouse.state
132
-			,$no-touch-size ~Mouse.x ~toolbar.x1 SUB2 8/ #0000 NEQ2 JMP2?
133
-				~Mouse.y ~toolbar.y1 SUB2 8/ SWP POP =cursor.size
134
-				( draw ) ,draw-toolbar JSR2
135
-				,$touch-end JMP2
136
-			$no-touch-size
137
-			,$no-touch-brush ~Mouse.x ~toolbar.x1 SUB2 8/ #0001 NEQ2 JMP2?
138
-				~Mouse.y ~toolbar.y1 SUB2 8/ SWP POP =cursor.patt
139
-				( draw ) ,draw-toolbar JSR2
140
-				,$touch-end JMP2
141
-			$no-touch-brush
142
-		$no-touch-toolbar
149
+			#01 =cursor.tool
150
+			~Mouse.x ~sizepane.x1 SUB2 8/ SWP POP =cursor.size
151
+			( draw ) ,draw-sizepane JSR2
152
+			( draw ) ,draw-toolpane JSR2
153
+			,$touch-end JMP2
154
+		$no-touch-sizepane
155
+
156
+		( in pattpane )
157
+		,$no-touch-pattpane ~Mouse.x CLN2r ~pattpane.x1 GTH2 STH2r ~pattpane.x2 LTH2 #0101 NEQ2 JMP2?
158
+		,$no-touch-pattpane ~Mouse.y CLN2r ~pattpane.y1 GTH2 STH2r ~pattpane.y2 LTH2 #0101 NEQ2 JMP2?
159
+			( release ) #00 =Mouse.state
160
+			~Mouse.x ~pattpane.x1 SUB2 8/ SWP POP =cursor.patt
161
+			( draw ) ,draw-pattpane JSR2
162
+			,$touch-end JMP2
163
+		$no-touch-pattpane
164
+
165
+		( in toolpane )
166
+		,$no-touch-toolpane ~Mouse.x CLN2r ~toolpane.x1 GTH2 STH2r ~toolpane.x2 LTH2 #0101 NEQ2 JMP2?
167
+		,$no-touch-toolpane ~Mouse.y CLN2r ~toolpane.y1 GTH2 STH2r ~toolpane.y2 LTH2 #0101 NEQ2 JMP2?
168
+			( release ) #00 =Mouse.state
169
+			~Mouse.x ~toolpane.x1 SUB2 8/ SWP POP =cursor.tool
170
+			( draw ) ,draw-toolpane JSR2
171
+			,$touch-end JMP2
172
+		$no-touch-toolpane
143 173
 
144 174
 		( in canvas )
145 175
 		,$no-touch-canvas ~Mouse.x CLN2r ~canvas.x1 GTS2 STH2r ~canvas.x2 LTS2 #0101 NEQ2 JMP2?
146 176
 		,$no-touch-canvas ~Mouse.y CLN2r ~canvas.y1 GTS2 STH2r ~canvas.y2 LTS2 #0101 NEQ2 JMP2?
147 177
 
148 178
 			( set cursor operation )
149
-			,add-pixel =cursor.oper
150
-			,$no-oper ~Mouse.state #01 EQU JMP2?
151
-				,remove-pixel =cursor.oper
152
-			$no-oper
153
-
154
-			( paint line )
155
-			~cursor.x0 ~canvas.x1 SUB2 ~cursor.y0 ~canvas.y1 SUB2 ~Mouse.x ~canvas.x1 SUB2 ~Mouse.y ~canvas.y1 SUB2 #01 ,paint-line JSR2
179
+			,add-pixel ,$no-oper ~Mouse.state #01 EQU JMP2? POP2 ,remove-pixel $no-oper =cursor.oper
156 180
 
157
-			( paint fill )
158
-			~Mouse.x ~canvas.x1 SUB2 ~Mouse.y ~canvas.y1 SUB2 ,paint JSR2
181
+			,$no-touch-pen ~cursor.tool #00 NEQ JMP2?
182
+				~cursor.x0 ~canvas.x1 SUB2 ~cursor.y0 ~canvas.y1 SUB2 ~Mouse.x ~canvas.x1 SUB2 ~Mouse.y ~canvas.y1 SUB2 #01 ,paint-line JSR2
183
+				,$touch-end JMP2
184
+			$no-touch-pen
159 185
 
160
-			,$no-mirror-mode ~cursor.mirror #00 EQU JMP2?
161
-				~Mouse.x ~canvas.x1 SUB2 ~canvas.w 8* SWP2 SUB2 ~Mouse.y ~canvas.y1 SUB2 ,paint JSR2
162
-			$no-mirror-mode
163
-			,$touch-end JMP2
186
+			,$no-touch-brush ~cursor.tool #01 NEQ JMP2?
187
+				~Mouse.x ~canvas.x1 SUB2 ~Mouse.y ~canvas.y1 SUB2 ,paint JSR2
188
+				,$touch-end JMP2
189
+			$no-touch-brush
164 190
 
191
+			( unknown tool )
192
+			#aa =Console.byte
193
+			
165 194
 		$no-touch-canvas
166 195
 
167 196
 		( background interface )
... ...
@@ -213,7 +242,7 @@ BRK
213 242
 			( mirror ) ~cursor.mirror #00 EQU =cursor.mirror $no-mkey
214 243
 		DUP 
215 244
 			DUP #30 GTH SWP #39 LTH #0101 NEQ2 ,$no-numkey ROT JMP2?
216
-			( size ) ~Keys #31 SUB =cursor.size ,draw-toolbar JSR2 $no-numkey
245
+			( size ) ~Keys #31 SUB =cursor.size ,draw-sizepane JSR2 $no-numkey
217 246
 		POP
218 247
 		
219 248
 		( release ) #00 =Keys
... ...
@@ -258,6 +287,37 @@ RTN
258 287
 
259 288
 RTN
260 289
 
290
+@paint-line ( x1 y1 x2 y2 color )
291
+	
292
+	( load ) =color =line.y0 =line.x0 =line.y =line.x
293
+	~line.x0 ~line.x SUB2 ABS2 =line.dx
294
+	~line.y0 ~line.y SUB2 ABS2 #0000 SWP2 SUB2 =line.dy
295
+	#ffff #00 ~line.x ~line.x0 LTS2 #0002 MUL2 ADD2 =line.sx 
296
+	#ffff #00 ~line.y ~line.y0 LTS2 #0002 MUL2 ADD2 =line.sy 
297
+	~line.dx ~line.dy ADD2 =line.e1
298
+	$loop
299
+		( paint ) ~line.x ~line.y ~cursor.oper JSR2
300
+		,$end ~line.x ~line.x0 EQU2 ~line.y ~line.y0 EQU2 #0101 EQU2 JMP2?
301
+		~line.e1 #0002 MUL2 =line.e2
302
+		,$skipy ~line.e2 ~line.dy LTS2 JMP2?
303
+			~line.e1 ~line.dy ADD2 =line.e1
304
+			~line.x ~line.sx ADD2 =line.x
305
+		$skipy
306
+		,$skipx ~line.e2 ~line.dx GTS2 JMP2?
307
+			~line.e1 ~line.dx ADD2 =line.e1
308
+			~line.y ~line.sy ADD2 =line.y
309
+		$skipx
310
+		,$loop JMP2
311
+
312
+	$end
313
+
314
+	,draw-canvas JSR2
315
+	,draw-toolpane JSR2
316
+	,draw-pattpane JSR2
317
+	,draw-sizepane JSR2
318
+
319
+RTN
320
+
261 321
 @paint ( x y )
262 322
 
263 323
 	#0003 SUB2 =pt0.y #0003 SUB2 =pt0.x ( cursor offset )
... ...
@@ -290,7 +350,9 @@ RTN
290 350
 		,$ver ~px.y #08 LTH JMP2?
291 351
 
292 352
 	,draw-canvas JSR2
293
-	,draw-toolbar JSR2
353
+	,draw-toolpane JSR2
354
+	,draw-pattpane JSR2
355
+	,draw-sizepane JSR2
294 356
 
295 357
 RTN
296 358
 
... ...
@@ -379,7 +441,9 @@ RTN
379 441
 	
380 442
 	,draw-background JSR2
381 443
 	,draw-canvas JSR2
382
-	,draw-toolbar JSR2
444
+	,draw-toolpane JSR2
445
+	,draw-pattpane JSR2
446
+	,draw-sizepane JSR2
383 447
 		
384 448
 RTN
385 449
 
... ...
@@ -446,13 +510,14 @@ RTN
446 510
 	~Mouse.x =cursor.x 
447 511
 	~Mouse.y =cursor.y
448 512
 
449
-	( draw new cursor )
513
+	( draw size cursor )
514
+	,$outside-canvas ~cursor.tool #01 NEQ JMP2?
450 515
 	,$outside-canvas ~Mouse.x CLN2r ~canvas.x1 GTH2 STH2r ~canvas.x2 LTH2 #0101 NEQ2 JMP2?
451 516
 	,$outside-canvas ~Mouse.y CLN2r ~canvas.y1 GTH2 STH2r ~canvas.y2 LTH2 #0101 NEQ2 JMP2?	
452
-		( do not draw size in toolbar )
517
+		( do not draw size in toolpane )
453 518
 		,$outside-canvas
454
-		~Mouse.x CLN2r ~toolbar.x1 GTH2 STH2r ~toolbar.x2 LTH2 #0101 EQU2 
455
-		~Mouse.y CLN2r ~toolbar.y1 GTH2 STH2r ~toolbar.y2 LTH2 #0101 EQU2 
519
+		~Mouse.x CLN2r ~toolpane.x1 GTH2 STH2r ~toolpane.x2 LTH2 #0101 EQU2 
520
+		~Mouse.y CLN2r ~toolpane.y1 GTH2 STH2r ~toolpane.y2 LTH2 #0101 EQU2 
456 521
 		#0101 EQU2 JMP2?
457 522
 		( do not draw size when holding alt )
458 523
 		,$outside-canvas ~Controller #02 EQU JMP2?
... ...
@@ -471,34 +536,54 @@ RTN
471 536
 
472 537
 RTN
473 538
 
474
-@draw-toolbar
539
+@draw-toolpane
475 540
 	
476
-	~toolbar.x1 -- ~toolbar.y1 -- ~toolbar.x2 ~toolbar.y2 #00 ,line-rect JSR2
477
-	~toolbar.x1 #0002 SUB2 ~toolbar.y1 #0002 SUB2 ~toolbar.x2 ~toolbar.y2 #01 ,line-rect JSR2
541
+	~toolpane.x1 -- ~toolpane.y1 -- ~toolpane.x2 ~toolpane.y2 #00 ,line-rect JSR2
542
+	~toolpane.x1 #0002 SUB2 ~toolpane.y1 #0002 SUB2 ~toolpane.x2 ~toolpane.y2 #01 ,line-rect JSR2
478 543
 
479
-	~toolbar.x1 =Sprite.x
480
-	~toolbar.y1 =Sprite.y
481
-	,size_icn =Sprite.addr
544
+	~toolpane.x1 =Sprite.x
545
+	~toolpane.y1 =Sprite.y
546
+	,tool_icn =Sprite.addr
547
+
548
+	$tools
549
+		( draw ) #01 ~Sprite.x ~pattpane.x1 SUB2 8/ SWP POP ~cursor.tool EQU #02 MUL ADD =Sprite.color
550
+		( incr ) ~Sprite.x 8+ =Sprite.x
551
+		( incr ) ~Sprite.addr 8+ =Sprite.addr
552
+		,$tools ~Sprite.x ~toolpane.x2 LTH2 JMP2?
482 553
 
483
-	( draw brush sizes )
554
+RTN
484 555
 
485
-	$sizes
486
-		( draw ) #01 ~Sprite.y ~toolbar.y1 SUB2 8/ SWP POP ~cursor.size EQU #02 MUL ADD =Sprite.color
487
-		( incr ) ~Sprite.y 8+ =Sprite.y
556
+@draw-pattpane
557
+	
558
+	~pattpane.x1 -- ~pattpane.y1 -- ~pattpane.x2 ~pattpane.y2 #00 ,line-rect JSR2
559
+	~pattpane.x1 #0002 SUB2 ~pattpane.y1 #0002 SUB2 ~pattpane.x2 ~pattpane.y2 #01 ,line-rect JSR2
560
+
561
+	~pattpane.x1 =Sprite.x
562
+	~pattpane.y1 =Sprite.y
563
+	,patt_icn =Sprite.addr
564
+
565
+	$patterns
566
+		( draw ) #01 ~Sprite.x ~pattpane.x1 SUB2 8/ SWP POP ~cursor.patt EQU #02 MUL ADD =Sprite.color
567
+		( incr ) ~Sprite.x 8+ =Sprite.x
488 568
 		( incr ) ~Sprite.addr 8+ =Sprite.addr
489
-		,$sizes ~Sprite.y ~toolbar.y1 #0040 ADD2 LTH2 JMP2?
569
+		,$patterns ~Sprite.x ~pattpane.x2 LTH2 JMP2?
570
+
571
+RTN
572
+
573
+@draw-sizepane
490 574
 
491
-	( draw brush patterns )
575
+	~sizepane.x1 -- ~sizepane.y1 -- ~sizepane.x2 ~sizepane.y2 #00 ,line-rect JSR2
576
+	~sizepane.x1 #0002 SUB2 ~sizepane.y1 #0002 SUB2 ~sizepane.x2 ~sizepane.y2 #01 ,line-rect JSR2
492 577
 
493
-	~toolbar.x1 8+ =Sprite.x
494
-	~toolbar.y1 =Sprite.y
495
-	,pattern_icn =Sprite.addr
578
+	~sizepane.x1 =Sprite.x
579
+	~sizepane.y1 =Sprite.y
580
+	,size_icn =Sprite.addr
496 581
 
497 582
 	$patterns
498
-		( draw ) #01 ~Sprite.y ~toolbar.y1 SUB2 8/ SWP POP ~cursor.patt EQU #02 MUL ADD =Sprite.color
499
-		( incr ) ~Sprite.y 8+ =Sprite.y
583
+		( draw ) #01 ~Sprite.x ~sizepane.x1 SUB2 8/ SWP POP ~cursor.size EQU #02 MUL ADD =Sprite.color
584
+		( incr ) ~Sprite.x 8+ =Sprite.x
500 585
 		( incr ) ~Sprite.addr 8+ =Sprite.addr
501
-		,$patterns ~Sprite.y ~toolbar.y1 #0040 ADD2 LTH2 JMP2?
586
+		,$patterns ~Sprite.x ~sizepane.x2 LTH2 JMP2?
502 587
 
503 588
 RTN
504 589
 
... ...
@@ -553,32 +638,6 @@ RTN
553 638
 
554 639
 ( Generics )
555 640
 
556
-@paint-line ( x1 y1 x2 y2 color )
557
-	
558
-	( load ) =color =line.y0 =line.x0 =line.y =line.x
559
-	~line.x0 ~line.x SUB2 ABS2 =line.dx
560
-	~line.y0 ~line.y SUB2 ABS2 #0000 SWP2 SUB2 =line.dy
561
-	#ffff #00 ~line.x ~line.x0 LTS2 #0002 MUL2 ADD2 =line.sx 
562
-	#ffff #00 ~line.y ~line.y0 LTS2 #0002 MUL2 ADD2 =line.sy 
563
-	~line.dx ~line.dy ADD2 =line.e1
564
-	$loop
565
-		( paint ) ~line.x ~line.y ~cursor.oper JSR2
566
-		,$end ~line.x ~line.x0 EQU2 ~line.y ~line.y0 EQU2 #0101 EQU2 JMP2?
567
-		~line.e1 #0002 MUL2 =line.e2
568
-		,$skipy ~line.e2 ~line.dy LTS2 JMP2?
569
-			~line.e1 ~line.dy ADD2 =line.e1
570
-			~line.x ~line.sx ADD2 =line.x
571
-		$skipy
572
-		,$skipx ~line.e2 ~line.dx GTS2 JMP2?
573
-			~line.e1 ~line.dx ADD2 =line.e1
574
-			~line.y ~line.sy ADD2 =line.y
575
-		$skipx
576
-		,$loop JMP2
577
-
578
-	$end
579
-
580
-RTN
581
-
582 641
 @line-rect ( x1 y1 x2 y2 color )
583 642
 
584 643
 	( load ) =color =rect.y2 =rect.x2 DUP2 =Screen.y =rect.y1 DUP2 =Screen.x =rect.x1
... ...
@@ -620,8 +679,8 @@ RTN
620 679
 	[ 387c fefe fe7c 3800 ]
621 680
 	[ 7cfe fefe fefe 7c00 ]
622 681
 
623
-@pattern_icn 
624
-	[ fe82 baba ba82 fe00 ]
682
+@patt_icn 
683
+	[ fefe fefe fefe fe00 ]
625 684
 	[ fed6 aad6 aad6 fe00 ]
626 685
 	[ fe92 82d6 8292 fe00 ]
627 686
 	[ fe82 92aa 9282 fe00 ]
... ...
@@ -630,6 +689,17 @@ RTN
630 689
 	[ feaa aaaa aaaa fe00 ]	
631 690
 	[ fe82 fe82 fe82 fe00 ]
632 691
 
692
+@tool_icn 
693
+	[ c0e0 5028 140a 0400 ]
694
+	[ e0d0 a844 2212 0c00 ]
695
+	[ c0b8 4848 7804 0200 ]
696
+	[ 44ba 4444 44ba 4400 ]
697
+	[ 3844 8282 8244 3800 ]
698
+	[ fe82 8282 8282 fe00 ]
699
+	[ 80c0 e0f0 f8e0 1000 ]
700
+	[ 0202 0438 4080 8000 ]
701
+	[ 0204 0810 2040 8000 ]
702
+
633 703
 @brush_view 
634 704
 	[ 0000 0010 0000 0000 ]
635 705
 	[ 0000 1028 1000 0000 ]
... ...
@@ -409,6 +409,14 @@ audio_poke(Uxn *u, Uint16 ptr, Uint8 b0, Uint8 b1)
409 409
 	return b1;
410 410
 }
411 411
 
412
+Uint8
413
+midi_poke(Uxn *u, Uint16 ptr, Uint8 b0, Uint8 b1)
414
+{
415
+	(void)u;
416
+	printf("%04x - %02x,%02x\n", ptr, b0, b1);
417
+	return b1;
418
+}
419
+
412 420
 Uint8
413 421
 system_poke(Uxn *u, Uint16 ptr, Uint8 b0, Uint8 b1)
414 422
 {
... ...
@@ -487,13 +495,13 @@ main(int argc, char **argv)
487 495
 	devmouse = portuxn(&u, "mouse", ppnil);
488 496
 	portuxn(&u, "file", file_poke);
489 497
 	portuxn(&u, "audio", audio_poke);
490
-	portuxn(&u, "empty", ppnil);
491
-	portuxn(&u, "empty", ppnil);
492
-	portuxn(&u, "empty", ppnil);
493
-	portuxn(&u, "empty", ppnil);
494
-	portuxn(&u, "empty", ppnil);
495
-	portuxn(&u, "empty", ppnil);
496
-	portuxn(&u, "empty", ppnil);
498
+	portuxn(&u, "midi", ppnil);
499
+	portuxn(&u, "---", ppnil);
500
+	portuxn(&u, "---", ppnil);
501
+	portuxn(&u, "---", ppnil);
502
+	portuxn(&u, "---", ppnil);
503
+	portuxn(&u, "---", ppnil);
504
+	portuxn(&u, "---", ppnil);
497 505
 	portuxn(&u, "system", system_poke);
498 506
 
499 507
 	/* Write screen size to dev/screen */