Browse code

Improved piano example

neauoire authored on 09/07/2021 18:38:45
Showing 7 changed files
... ...
@@ -148,11 +148,8 @@ RTN
148 148
 	.pointer/y LDZ2 .Screen/y DEO2 
149 149
 	#30 .Screen/color DEO
150 150
 	( record pointer positions )
151
-	.Mouse/x DEI2 .pointer/x STZ2 
152
-	.Mouse/y DEI2 .pointer/y STZ2
153
-	( draw new cursor )
154
-	.pointer/x LDZ2 .Screen/x DEO2 
155
-	.pointer/y LDZ2 .Screen/y DEO2 
151
+	.Mouse/x DEI2 DUP2 .pointer/x STZ2 .Screen/x DEO2 
152
+	.Mouse/y DEI2 DUP2 .pointer/y STZ2 .Screen/y DEO2 
156 153
 	( colorize on state )
157 154
 	#31 [ .Mouse/state DEI #00 NEQ ] ADD .Screen/color DEO
158 155
 
... ...
@@ -497,11 +497,8 @@ RTN
497 497
 	.pointer/y LDZ2 .Screen/y DEO2 
498 498
 	#30 .Screen/color DEO
499 499
 	( record pointer positions )
500
-	.Mouse/x DEI2 .pointer/x STZ2 
501
-	.Mouse/y DEI2 .pointer/y STZ2
502
-	( draw new cursor )
503
-	.pointer/x LDZ2 .Screen/x DEO2 
504
-	.pointer/y LDZ2 .Screen/y DEO2 
500
+	.Mouse/x DEI2 DUP2 .pointer/x STZ2 .Screen/x DEO2 
501
+	.Mouse/y DEI2 DUP2 .pointer/y STZ2 .Screen/y DEO2 
505 502
 	( colorize on state )
506 503
 	#33 [ .Mouse/state DEI #00 ! ] - .Screen/color DEO
507 504
 
... ...
@@ -114,12 +114,8 @@ BRK
114 114
 	#30 .Screen/color DEO
115 115
 
116 116
 	( record pointer positions )
117
-	.Mouse/x DEI2 .pointer/x STZ2 
118
-	.Mouse/y DEI2 .pointer/y STZ2
119
-
120
-	( draw new cursor )
121
-	.pointer/x LDZ2 .Screen/x DEO2 
122
-	.pointer/y LDZ2 .Screen/y DEO2 
117
+	.Mouse/x DEI2 DUP2 .pointer/x STZ2 .Screen/x DEO2
118
+	.Mouse/y DEI2 DUP2 .pointer/y STZ2 .Screen/y DEO2 
123 119
 
124 120
 	( colorize on state )
125 121
 	#32 [ .Mouse/state DEI #00 ! ] + .Screen/color DEO
... ...
@@ -6,7 +6,7 @@
6 6
 %<< { LTH2 } %>> { GTH2 } %== { EQU2 } %!! { NEQ2 }
7 7
 
8 8
 %RTN  { JMP2r }
9
-%TOS  { #00 SWP }
9
+%TOS  { #00 SWP } %TOB { SWP POP }
10 10
 %MOD  { DUP2 / * - }
11 11
 %LTS2 { #8000 ++ SWP2 #8000 ++ >> }
12 12
 %GTS2 { #8000 ++ SWP2 #8000 ++ << }
... ...
@@ -80,8 +80,8 @@
80 80
 	( default settings )
81 81
 	#ff .last-note STZ
82 82
 	#041c .Audio0/adsr DEO2
83
-	#88 .Audio0/volume DEO
84
-	;piano-pcm .Audio0/addr DEO2
83
+	#dd .Audio0/volume DEO
84
+	;sin-pcm .Audio0/addr DEO2
85 85
 	#0100 .Audio0/length DEO2
86 86
 
87 87
 	( inital drawing ) 
... ...
@@ -185,8 +185,8 @@ BRK
185 185
 
186 186
 @on-touch-octave-view ( -> )
187 187
 
188
-	.Mouse/x DEI2 .octave-view/x1 LDZ2 -- 8// SWP POP #09 ! ,&no-mod JCN
189
-		.Mouse/y DEI2 .octave-view/y1 LDZ2 -- 8// SWP POP 
188
+	.Mouse/x DEI2 .octave-view/x1 LDZ2 -- 8// TOB #09 ! ,&no-mod JCN
189
+		.Mouse/y DEI2 .octave-view/y1 LDZ2 -- 8// TOB 
190 190
 		DUP #00 ! ,&no-incr JCN
191 191
 			.octave LDZ #03 = ,&no-incr JCN
192 192
 			.octave LDZ #01 + .octave STZ &no-incr
... ...
@@ -199,7 +199,7 @@ BRK
199 199
 		BRK
200 200
 	&no-mod
201 201
 
202
-	.Mouse/x DEI2 .octave-view/x1 LDZ2 -- 8// SWP POP #06 > ,&no-key JCN
202
+	.Mouse/x DEI2 .octave-view/x1 LDZ2 -- 8// TOB #06 > ,&no-key JCN
203 203
 		.Mouse/x DEI2 .octave-view/x1 LDZ2 -- 8// ;notes ++ LDA .octave LDZ #0c * + ;play JSR2
204 204
 		( release ) #00 .Mouse/state DEO
205 205
 		;draw-octave JSR2
... ...
@@ -209,7 +209,7 @@ BRK
209 209
 
210 210
 @on-touch-adsr-view ( -> )
211 211
 
212
-	.Mouse/x DEI2 .adsr-view/x1 LDZ2 -- 8// SWP POP #03 /
212
+	.Mouse/x DEI2 .adsr-view/x1 LDZ2 -- 8// TOB #03 /
213 213
 	DUP #00 ! ,&no-a JCN
214 214
 		.Audio0/adsr DEI
215 215
 		#10 .Mouse/state DEI #10 = #e0 * + +
... ...
@@ -359,7 +359,9 @@ RTN
359 359
 		#02 /
360 360
 		TOS 4// .wave-view/y1 LDZ2 ++ .Screen/y DEO2
361 361
 		.Screen/x DEI2 #0001 ++ .Screen/x DEO2
362
-		( draw ) OVR .Audio0/length DEI2 SWP POP > #02 * #01 + .Screen/color DEO
362
+		( draw ) OVR 
363
+			.Audio0/length DEI2 TOB > 
364
+			.Audio0/length DEI2 #0100 !! #0101 == #02 * #01 + .Screen/color DEO
363 365
 		( incr ) INCR
364 366
 		LTHk ,&loop JCN
365 367
 	POP2
... ...
@@ -111,12 +111,8 @@ RTN
111 111
 	#30 .Screen/color DEO
112 112
 
113 113
 	( record pointer positions )
114
-	.Mouse/x DEI2 .pointer/x STZ2 
115
-	.Mouse/y DEI2 .pointer/y STZ2
116
-
117
-	( draw new cursor )
118
-	.pointer/x LDZ2 .Screen/x DEO2 
119
-	.pointer/y LDZ2 .Screen/y DEO2 
114
+	.Mouse/x DEI2 DUP2 .pointer/x STZ2 .Screen/x DEO2
115
+	.Mouse/y DEI2 DUP2 .pointer/y STZ2 .Screen/y DEO2 
120 116
 
121 117
 	( colorize on state )
122 118
 	#31 [ .Mouse/state DEI #00 NEQ ] ADD .Screen/color DEO
... ...
@@ -250,12 +250,9 @@ RTN
250 250
 	#30 .Screen/color DEO
251 251
 
252 252
 	( record pointer positions )
253
-	.Mouse/x DEI2 .pointer/x STZ2 
254
-	.Mouse/y DEI2 .pointer/y STZ2
253
+	.Mouse/x DEI2 DUP2 .pointer/x STZ2 .Screen/x DEO2 
254
+	.Mouse/y DEI2 DUP2 .pointer/y STZ2 .Screen/y DEO2
255 255
 
256
-	( draw new cursor )
257
-	.pointer/x LDZ2 .Screen/x DEO2
258
-	.pointer/y LDZ2 .Screen/y DEO2
259 256
 	#33 .Mouse/state DEI #00 NEQ #02 MUL SUB .Screen/color DEO
260 257
 
261 258
 RTN
... ...
@@ -110,8 +110,8 @@ inspect(Ppu *p, Uint8 *stack, Uint8 wptr, Uint8 rptr, Uint8 *memory)
110 110
 	/* return pointer */
111 111
 	puticn(p, &p->fg, 0x8, y + 0x10, font[(rptr >> 4) & 0xf], 0x2, 0, 0);
112 112
 	puticn(p, &p->fg, 0x10, y + 0x10, font[rptr & 0xf], 0x2, 0, 0);
113
-	for(i = 0; i < 0x40; ++i) { /* memory */
114
-		x = ((i % 8) * 3 + 1) * 8, y = (i / 8 + 1) * 8 + p->height - 0x50, b = memory[i];
113
+	for(i = 0; i < 0x20; ++i) { /* memory */
114
+		x = ((i % 8) * 3 + 1) * 8, y = 0x38 + (i / 8 + 1) * 8, b = memory[i];
115 115
 		puticn(p, &p->fg, x, y, font[(b >> 4) & 0xf], 3, 0, 0);
116 116
 		puticn(p, &p->fg, x + 8, y, font[b & 0xf], 3, 0, 0);
117 117
 	}