Browse code

Removed a few extra globals

neauoire authored on 04/05/2021 17:24:00
Showing 1 changed files
... ...
@@ -10,12 +10,9 @@
10 10
 %<< { LTH2 } %>> { GTH2 } %== { EQU2 } %!! { NEQ2 }  
11 11
 
12 12
 %TOB { SWP POP } %TOS { #00 SWP }
13
-
14 13
 %RTN { JMP2r }
15
-
16 14
 %MOD { DUP2 / * - }
17
-%LTS2  { #8000 ++ SWP2 #8000 ++ >> }
18
-%GTS2  { #8000 ++ SWP2 #8000 ++ << }
15
+%LTS2  { #8000 ++ SWP2 #8000 ++ >> } %GTS2  { #8000 ++ SWP2 #8000 ++ << }
19 16
 
20 17
 %PAD-WIDTH { #0030 }
21 18
 %PAD-HEIGHT { #0020 }
... ...
@@ -39,20 +36,20 @@
39 36
 
40 37
 |0000
41 38
 
42
-@piano [ &last $1 &octave $1 ]
43
-@pads  [ &last $1 ]
39
+@center   [ &x $2 &y $2 ]
40
+@pointer  [ &x $2 &y $2 ]
41
+@piano    [ &last $1 &octave $1 ]
42
+@pads     [ &last $1 ]
43
+@pad-view [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 ]
44
+@mix-view [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 ]
45
+@oct-view [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 ]
46
+@wav-view [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 ]
47
+
48
+@frame       [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 ]
44 49
 
50
+( TODO: remove )
45 51
 @color $1
46
-@center      [ &x $2 &y $2 ]
47
-@pointer     [ &x $2 &y $2 ]
48
-@knob        [ &x $2 &y $2 &value $1 ]
49 52
 @rect        [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 ]
50
-@frame       [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 ]
51
-@label       [ &x $2 &y $2 &color $1 &addr $2 ]
52
-@pad-view    [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 ]
53
-@mix-view    [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 ]
54
-@oct-view    [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 ]
55
-@wav-view    [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 ]
56 53
 
57 54
 @modes [ $1 $1 $1 $1 ] ( single/repeat )
58 55
 
... ...
@@ -89,8 +86,6 @@
89 86
 	#01 .modes POK
90 87
 	#01 .piano/octave POK
91 88
 
92
-	;load-samples JSR2
93
-
94 89
 	( find center )
95 90
 	.Screen/width DEI2 #0002 // .center/x POK2
96 91
 	.Screen/height DEI2 #0002 // .center/y POK2
... ...
@@ -137,6 +132,16 @@
137 132
 	.wav-view/y2 PEK2 #0002 ++
138 133
 	#01 ;line-rect JSR2
139 134
 
135
+	( load samples )
136
+	#00 #10
137
+	&load-samples
138
+		( name ) OVR TOS #0019 ** ;pad-path ++ .File/name DEO2
139
+		( length ) OVR #04 / #10 * .Audio0/length + DEI2 .File/length DEO2
140
+		( load ) OVR TOS #0002 ** ;pad-addr ++ LDA2 .File/load DEO2
141
+		( incr ) SWP #01 + SWP
142
+		DUP2 < ,&load-samples JNZ
143
+	POP2
144
+
140 145
 	( initial draw )
141 146
 
142 147
 	#00 #10
... ...
@@ -177,7 +182,7 @@ BRK
177 182
 
178 183
 	;draw-cursor JSR2 
179 184
 
180
-	.Mouse/state DEI #00 ! ,&on-touch JNZ BRK &on-touch
185
+	.Mouse/state DEI #00 ! #01 JNZ [ BRK ]
181 186
 
182 187
 	.Mouse/x DEI2 DUP2 .pad-view/x1 PEK2 >> ROT ROT .pad-view/x2 PEK2 #0001 ++ << #0101 ==
183 188
 	.Mouse/y DEI2 DUP2 .pad-view/y1 PEK2 >> ROT ROT .pad-view/y2 PEK2 << #0101 ==
... ...
@@ -252,7 +257,7 @@ BRK
252 257
 
253 258
 	( channel ) .Mouse/y DEI2 .mix-view/y1 PEK2 -- PAD-HEIGHT // TOB STH
254 259
 	( knob ) .Mouse/x DEI2 .mix-view/x1 PEK2 -- #0010 // TOB
255
-
260
+	( adsr )
256 261
 	DUP #00 ! ,&no-a JNZ
257 262
 		.Audio0/adsr [ DUPr STHr #10 * + ] DEI
258 263
 		#10 .Mouse/state DEI #10 = #e0 * + +
... ...
@@ -269,12 +274,12 @@ BRK
269 274
 		.Audio0/adsr [ DUPr STHr #10 * + ] #01 + DEI
270 275
 		DUP #f0 AND STH #01 .Mouse/state DEI #10 = #0e * + + #0f AND STHr +
271 276
 		.Audio0/adsr [ DUPr STHr #10 * + ] #01 + DEO &no-r
272
-
277
+	( modes )
273 278
 	DUP #04 ! ,&no-repeat JNZ
274 279
 		.modes [ DUPr STHr + ] PEK 
275 280
 		#00 =
276 281
 		.modes [ DUPr STHr + ] POK &no-repeat
277
-
282
+	( volume )
278 283
 	DUP #05 ! ,&no-left JNZ
279 284
 		.Audio0/volume [ DUPr STHr #10 * + ] DEI 
280 285
 		#10 .Mouse/state DEI #10 = #e0 * + +
... ...
@@ -309,45 +314,18 @@ BRK
309 314
 
310 315
 	.Mouse/x DEI2 .oct-view/x1 PEK2 -- #0008 // TOB #06 GTH ,&no-key JNZ
311 316
 		.Mouse/x DEI2 .oct-view/x1 PEK2 -- #0008 // 
312
-
313 317
 		( set pitch of pad )
314
-		DUP2 ;notes ++ LDA .pads/last PEK SWP .piano/octave PEK #02 - #0c * + ;set-pitch JSR2
315
-
318
+		DUP2 ;notes ++ LDA .pads/last PEK SWP .piano/octave PEK #02 - #0c * + 
319
+		( save ) SWP TOS ;pad-pitch ++ STA 
316 320
 		( record last note )
317 321
 		TOB .piano/last POK 
318 322
 		.pads/last PEK ;play-pad JSR2
319
-
320 323
 		( release ) #00 .Mouse/state DEO
321 324
 		;draw-octave JSR2
322 325
 	&no-key
323 326
 
324 327
 BRK
325 328
 
326
-@set-pitch ( pad pitch -- )
327
-	
328
-	SWP TOS ;pad-pitch ++ STA
329
-
330
-RTN
331
-
332
-@play ( pitch -- )
333
-	
334
-	DUP .piano/octave PEK .modes PEK * + .Audio0/pitch DEO
335
-
336
-RTN
337
-
338
-@load-samples ( -- )
339
-
340
-	#00 #10
341
-	&loop
342
-		( name ) OVR TOS #0019 ** ;pad-path ++ .File/name DEO2
343
-		( length ) OVR #04 / #10 * .Audio0/length + DEI2 .File/length DEO2
344
-		( load ) OVR TOS #0002 ** ;pad-addr ++ LDA2 .File/load DEO2
345
-		( incr ) SWP #01 + SWP
346
-		DUP2 < ,&loop JNZ
347
-	POP2
348
-	
349
-RTN
350
-
351 329
 @play-pad ( note pad -- )
352 330
 	
353 331
 	( unselect last )
... ...
@@ -368,8 +346,10 @@ RTN
368 346
 
369 347
 @draw-waveform ( pad -- )
370 348
 	
349
+	( stash address )
371 350
 	#02 * #00 SWP ;pad-addr ++ LDA2 STH2
372 351
 
352
+	( clear )
373 353
 	.wav-view/x1 PEK2 #0002 ++
374 354
 	.wav-view/y1 PEK2
375 355
 	.wav-view/x2 PEK2 #0002 --
... ...
@@ -394,7 +374,6 @@ RTN
394 374
 		( incr ) SWP #01 + SWP
395 375
 		DUP2 < ,&loop JNZ
396 376
 	POP2
397
-
398 377
 	POP2r
399 378
 
400 379
 RTN
... ...
@@ -405,79 +384,26 @@ RTN
405 384
 
406 385
 	( adsr )
407 386
 	DUP2 .mix-view/x1 PEK2 SWP2
408
-		.Audio0/adsr [ DUPr STHr #10 * + ] DEI #04 SFT
409
-		;draw-knob JSR2
387
+		.Audio0/adsr [ DUPr STHr #10 * + ] DEI #04 SFT ;draw-knob JSR2
410 388
 	DUP2 .mix-view/x1 PEK2 #0010 ++ SWP2
411
-		.Audio0/adsr [ DUPr STHr #10 * + ] DEI #0f AND
412
-		;draw-knob JSR2
389
+		.Audio0/adsr [ DUPr STHr #10 * + ] DEI #0f AND ;draw-knob JSR2
413 390
 	DUP2 .mix-view/x1 PEK2 #0020 ++ SWP2
414
-		.Audio0/adsr [ DUPr STHr #10 * + ] #01 + DEI #04 SFT
415
-		;draw-knob JSR2
391
+		.Audio0/adsr [ DUPr STHr #10 * + ] #01 + DEI #04 SFT ;draw-knob JSR2
416 392
 	DUP2 .mix-view/x1 PEK2 #0030 ++ SWP2
417
-		.Audio0/adsr [ DUPr STHr #10 * + ] #01 + DEI #0f AND
418
-		;draw-knob JSR2
393
+		.Audio0/adsr [ DUPr STHr #10 * + ] #01 + DEI #0f AND ;draw-knob JSR2
419 394
 	( once/repeat )
420 395
 	DUP2 .mix-view/x1 PEK2 #0040 ++ SWP2
421 396
 		.modes [ DUPr STHr + ] PEK ;draw-switch JSR2
422 397
 	( volume )
423 398
 	DUP2 .mix-view/x1 PEK2 #0050 ++ SWP2
424
-		.Audio0/volume [ DUPr STHr #10 * + ] DEI #04 SFT
425
-		;draw-knob JSR2
399
+		.Audio0/volume [ DUPr STHr #10 * + ] DEI #04 SFT ;draw-knob JSR2
426 400
 	DUP2 .mix-view/x1 PEK2 #0060 ++ SWP2
427
-		.Audio0/volume [ DUPr STHr #10 * + ] DEI #0f AND
428
-		;draw-knob JSR2
401
+		.Audio0/volume [ DUPr STHr #10 * + ] DEI #0f AND ;draw-knob JSR2
429 402
 	POP2
430 403
 	POPr
431 404
 
432 405
 RTN
433 406
 
434
-@draw-knob ( x* y* value -- )
435
-
436
-	( load ) .knob/value POK .knob/y POK2 .knob/x POK2
437
-
438
-	.knob/x PEK2 .Screen/x DEO2
439
-	.knob/y PEK2 .Screen/y DEO2 ;knob-icns .Screen/addr DEO2 #21 .Screen/color DEO
440
-	.knob/x PEK2 #0008 ++ .Screen/x DEO2 ;knob-icns #0008 ++ .Screen/addr DEO2 #21 .Screen/color DEO
441
-	.knob/y PEK2 #0008 ++ .Screen/y DEO2 ;knob-icns #0018 ++ .Screen/addr DEO2 #21 .Screen/color DEO
442
-	.knob/x PEK2 .Screen/x DEO2 ;knob-icns #0010 ++ .Screen/addr DEO2 #21 .Screen/color DEO
443
-	.knob/x PEK2 #00 #00 .knob/value PEK ;knob-offsetx ++ LDA ++ .Screen/x DEO2
444
-	.knob/y PEK2 #00 #00 .knob/value PEK ;knob-offsety ++ LDA ++ .Screen/y DEO2
445
-	;knob-icns #0020 ++ .Screen/addr DEO2
446
-	#25 .Screen/color DEO
447
-	.knob/x PEK2 #0004 ++ .Screen/x DEO2
448
-	.knob/y PEK2 #0010 ++ .Screen/y DEO2
449
-	;font-hex #00 .knob/value PEK #08 * ++ .Screen/addr DEO2
450
-	#21 .Screen/color DEO
451
-
452
-RTN
453
-
454
-@draw-switch ( x* y* value -- )
455
-	
456
-	STH 
457
-
458
-	.Screen/y DEO2
459
-	.Screen/x DEO2
460
-
461
-	DUPr STHr #20 * #00 SWP ;switch-icns ++ ( keep in stack )
462
-
463
-	DUP2 .Screen/addr DEO2
464
-	#21 DUPr STHr + .Screen/color DEO
465
-
466
-	.Screen/x DEI2 #0008 ++ .Screen/x DEO2
467
-	DUP2 #0008 ++ .Screen/addr DEO2
468
-	#21 DUPr STHr + .Screen/color DEO
469
-
470
-	.Screen/y DEI2 #0008 ++ .Screen/y DEO2
471
-	.Screen/x DEI2 #0008 -- .Screen/x DEO2
472
-	DUP2 #0010 ++ .Screen/addr DEO2
473
-	#21 DUPr STHr + .Screen/color DEO
474
-
475
-	.Screen/x DEI2 #0008 ++ .Screen/x DEO2
476
-	#0018 ++ .Screen/addr DEO2
477
-	#21 STHr + .Screen/color DEO
478
-
479
-RTN
480
-
481 407
 @draw-pad ( pad color -- )
482 408
 	
483 409
 	STH STH
... ...
@@ -496,9 +422,9 @@ RTN
496 422
 	( draw name )
497 423
 	OVR2 #0002 ++ 
498 424
 	OVR2 #0002 ++ 
499
-	#20 OVRr STHr + 
500 425
 	;pad-name DUPr STHr TOS #0005 ** ++ 
501
-	;draw-label-left JSR2
426
+	#20 OVRr STHr + 
427
+	;draw-label JSR2
502 428
 
503 429
 	( draw note )
504 430
 	OVR2 #0003 ++ .Screen/x DEO2
... ...
@@ -606,7 +532,51 @@ RTN
606 532
 
607 533
 RTN
608 534
 
609
-@draw-short ( addr color -- )
535
+@draw-knob ( x* y* value -- )
536
+
537
+	( load ) STH .Screen/y DEO2  .Screen/x DEO2
538
+	;knob-icns .Screen/addr DEO2 
539
+	( draw ) #21 .Screen/color DEO
540
+	.Screen/x DEI2 #0008 ++ .Screen/x DEO2 
541
+	;knob-icns #0008 ++ .Screen/addr DEO2 
542
+	( draw ) #21 .Screen/color DEO
543
+	.Screen/y DEI2 #0008 ++ .Screen/y DEO2 
544
+	;knob-icns #0018 ++ .Screen/addr DEO2 
545
+	( draw ) #21 .Screen/color DEO
546
+	.Screen/x DEI2 #0008 -- .Screen/x DEO2 
547
+	;knob-icns #0010 ++ .Screen/addr DEO2 
548
+	( draw ) #21 .Screen/color DEO
549
+	.Screen/x DEI2 #0004 ++ .Screen/x DEO2
550
+	.Screen/y DEI2 #0008 ++ .Screen/y DEO2
551
+	;font-hex #00 DUPr STHr #08 * ++ .Screen/addr DEO2
552
+	( draw ) #21 .Screen/color DEO
553
+	.Screen/x DEI2 #0004 -- #00 #00 DUPr STHr ;knob-offsetx ++ LDA ++ .Screen/x DEO2
554
+	.Screen/y DEI2 #0010 -- #00 #00 STHr ;knob-offsety ++ LDA ++ .Screen/y DEO2
555
+	;knob-icns #0020 ++ .Screen/addr DEO2
556
+	( draw ) #25 .Screen/color DEO
557
+
558
+RTN
559
+
560
+@draw-switch ( x* y* value -- )
561
+	
562
+	STH .Screen/y DEO2 .Screen/x DEO2
563
+	DUPr STHr #20 * #00 SWP ;switch-icns ++
564
+	DUP2 .Screen/addr DEO2
565
+	( draw ) #21 DUPr STHr + .Screen/color DEO
566
+	.Screen/x DEI2 #0008 ++ .Screen/x DEO2
567
+	DUP2 #0008 ++ .Screen/addr DEO2
568
+	( draw ) #21 DUPr STHr + .Screen/color DEO
569
+	.Screen/y DEI2 #0008 ++ .Screen/y DEO2
570
+	.Screen/x DEI2 #0008 -- .Screen/x DEO2
571
+	DUP2 #0010 ++ .Screen/addr DEO2
572
+	( draw ) #21 DUPr STHr + .Screen/color DEO
573
+	.Screen/x DEI2 #0008 ++ .Screen/x DEO2
574
+	#0018 ++ .Screen/addr DEO2
575
+	( draw ) #21 STHr + .Screen/color DEO
576
+
577
+RTN
578
+
579
+@draw-short ( addr* color -- )
610 580
 
611 581
 	STH SWP 
612 582
 	DUP #04 SFT TOS #0008 ** ;font-hex ++ .Screen/addr DEO2
... ...
@@ -623,7 +593,7 @@ RTN
623 593
 
624 594
 RTN
625 595
 
626
-@line-rect ( x1 y1 x2 y2 color -- )
596
+@line-rect ( x1* y1* x2* y2* color -- )
627 597
 
628 598
 	( load ) .color POK DUP2 STH2 .rect/y2 POK2 .rect/x2 POK2 DUP2 STH2 .rect/y1 POK2 .rect/x1 POK2
629 599
 	STH2r #0001 ++ STH2r
... ...
@@ -645,16 +615,18 @@ RTN
645 615
 
646 616
 RTN
647 617
 
648
-@draw-label-left ( x y color addr -- )
618
+@draw-label ( x* y* addr* color -- )
649 619
 	
650
-	( load ) .label/addr POK2 .label/color POK .Screen/y DEO2 .Screen/x DEO2
651
-	.label/addr PEK2
620
+	( load ) STH STH2 .Screen/y DEO2 .Screen/x DEO2
621
+	STH2r
652 622
 	&loop
653
-		( draw ) DUP2 LDA #00 SWP #0030 -- #0008 ** ;font-num-uc ++ .Screen/addr DEO2 .label/color PEK .Screen/color DEO
623
+		DUP2 LDA #00 SWP #0030 -- #0008 ** ;font-num-uc ++ .Screen/addr DEO2 
624
+		( draw ) DUPr STHr .Screen/color DEO
654 625
 		( incr ) #0001 ++
655 626
 		( incr ) .Screen/x DEI2 #0008 ++ .Screen/x DEO2
656 627
 		DUP2 LDA #00 ! ,&loop JNZ
657 628
 	POP2
629
+	POPr
658 630
 
659 631
 RTN
660 632
 
... ...
@@ -739,8 +711,7 @@ RTN
739 711
 	001f 204f 5f5f 4f40
740 712
 	00f8 04f2 fafa f202
741 713
 	4040 4040 4020 1f00
742
-	0202 0202 0204 f800
743
-]
714
+	0202 0202 0204 f800 ]
744 715
 
745 716
 @knob-icns [
746 717
 	0003 0c10 2020 4040
... ...
@@ -758,18 +729,12 @@ RTN
758 729
 	00 00 01 02 03 05 06 07 ]
759 730
 
760 731
 @font-notes [
761
-	003e 4140 4040 413e
762
-	40ae 4100 4040 413e
763
-	007e 4141 4141 417e
764
-	40ae 4101 4141 417e
765
-	003e 4140 7c40 413e
766
-	003f 4040 7e40 4040
767
-	40af 4000 7e40 4040
768
-	003e 4140 5f41 413e
769
-	40ae 4100 5f41 413e
770
-	003e 4141 7f41 4141
771
-	40ae 4101 7f41 4141
772
-	007e 4141 7e41 417e
732
+	003e 4140 4040 413e 40ae 4100 4040 413e
733
+	007e 4141 4141 417e 40ae 4101 4141 417e
734
+	003e 4140 7c40 413e 003f 4040 7e40 4040
735
+	40af 4000 7e40 4040 003e 4140 5f41 413e
736
+	40ae 4100 5f41 413e 003e 4141 7f41 4141
737
+	40ae 4101 7f41 4141 007e 4141 7e41 417e
773 738
 ]
774 739
 
775 740
 @font-hex ( 0-F )