Browse code

Starting drum rack

neauoire authored on 28/04/2021 03:53:39
Showing 2 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,456 @@
1
+( a blank file )
2
+
3
+%RTN { JMP2r }
4
+%8+ { #0008 ADD2 }
5
+%8/ { #0008 DIV2 }
6
+%2/ { #0002 DIV2 }
7
+%2* { #0002 MUL2 }
8
+%8* { #0008 MUL2 }
9
+%++ { #0001 ADD2 }
10
+%TOS { #00 SWP }
11
+%MOD { DUP2 DIV MUL SUB }
12
+
13
+%PAD-WIDTH { #0030 }
14
+%PAD-HEIGHT { #0020 }
15
+%STATE-LENGTH { #04 }
16
+
17
+( devices )
18
+
19
+|00 @System     [ &vector $2 &pad      $6 &r      $2 &g     $2 &b      $2 ]
20
+|10 @Console    [ &pad    $8 &char     $1 &byte   $1 &short $2 &string $2 ]
21
+|20 @Screen     [ &vector $2 &width    $2 &height $2 &pad   $2 &x      $2 &y     $2 &addr   $2 &color $1 ]
22
+|30 @Audio0     [ &vector $2 &position $2 &output $1 &pad   $3 &adsr   $2 &length $2 &addr  $2 &volume $1 &pitch $1 ]
23
+|40 @Audio1     [ &vector $2 &position $2 &output $1 &pad   $3 &adsr   $2 &length $2 &addr  $2 &volume $1 &pitch $1 ]
24
+|50 @Audio2     [ &vector $2 &position $2 &output $1 &pad   $3 &adsr   $2 &length $2 &addr  $2 &volume $1 &pitch $1 ]
25
+|60 @Audio3     [ &vector $2 &position $2 &output $1 &pad   $3 &adsr   $2 &length $2 &addr  $2 &volume $1 &pitch $1 ]
26
+|70 @Midi       [ &vector $2 &channel  $1 &note   $1 &velocity $1 ]
27
+|80 @Controller [ &vector $2 &button   $1 &key    $1 ]
28
+|90 @Mouse      [ &vector $2 &x        $2 &y      $2 &state $1 &chord $1 ]
29
+|a0 @File       [ &vector $2 &success  $2 &offset $2 &pad   $2 &name  $2 &length $2 &load $2 &save $2 ]
30
+|b0 @DateTime   [ &year   $2 &month    $1 &day    $1 &hour $1 &minute $1 &second $1 &dotw $1 &doty $2 &isdst $1 ]
31
+
32
+( variables )
33
+
34
+|0000
35
+
36
+@selection $1
37
+@last $1
38
+@color $1
39
+@center      [ &x $2 &y $2 ]
40
+@pointer     [ &x $2 &y $2 ]
41
+@rect [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 ]
42
+@frame [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 ]
43
+@label [ &x $2 &y $2 &color $1 &addr $2 ]
44
+
45
+@state [ ( addr length )
46
+	$4 $4 $4 $4
47
+	$4 $4 $4 $4
48
+	$4 $4 $4 $4
49
+	$4 $4 $4 $4
50
+]
51
+
52
+( program )
53
+
54
+|0100 ( -> )
55
+	
56
+	( theme ) 
57
+	#0fe5 .System/r DEO2 
58
+	#0fc5 .System/g DEO2 
59
+	#0f25 .System/b DEO2
60
+
61
+	( vectors )
62
+	;on-control .Controller/vector DEO2
63
+	;on-mouse .Mouse/vector DEO2
64
+	;on-frame .Screen/vector DEO2
65
+	;on-midi .Midi/vector DEO2
66
+
67
+	( store location/length )
68
+	#88 .Audio0/volume DEO #011c .Audio0/adsr DEO2
69
+	#88 .Audio1/volume DEO #011c .Audio1/adsr DEO2
70
+	#88 .Audio2/volume DEO #011c .Audio2/adsr DEO2
71
+	#88 .Audio3/volume DEO #111c .Audio3/adsr DEO2
72
+
73
+	;load-samples JSR2
74
+
75
+	( find center )
76
+	.Screen/width DEI2 2/ .center/x POK2
77
+	.Screen/height DEI2 2/ .center/y POK2
78
+
79
+	( place views )
80
+	.center/x PEK2 PAD-WIDTH 2* SUB2 .frame/x1 POK2
81
+	.center/y PEK2 PAD-HEIGHT 2/ SUB2 .frame/y1 POK2
82
+	.center/x PEK2 PAD-WIDTH 2* ADD2 .frame/x2 POK2
83
+	.center/y PEK2 PAD-HEIGHT 2* ADD2 .frame/y2 POK2
84
+
85
+	;draw-pads JSR2
86
+
87
+BRK
88
+
89
+@on-frame ( -> )
90
+	
91
+	.frame/y2 PEK2 .Screen/y DEO2
92
+
93
+	.center/x PEK2 PAD-WIDTH 2* SUB2 .Screen/x DEO2
94
+	.Audio0/output DEI #04 SFT TOS #0008 MUL2 ;meter ADD2 .Screen/addr DEO2
95
+	#21 .Screen/color DEO
96
+
97
+	.center/x PEK2 PAD-WIDTH 2* SUB2 #0008 ADD2 .Screen/x DEO2
98
+	.Audio1/output DEI #04 SFT TOS #0008 MUL2 ;meter ADD2 .Screen/addr DEO2
99
+	#21 .Screen/color DEO
100
+
101
+	.center/x PEK2 PAD-WIDTH 2* SUB2 #0010 ADD2 .Screen/x DEO2
102
+	.Audio2/output DEI #04 SFT TOS #0008 MUL2 ;meter ADD2 .Screen/addr DEO2
103
+	#21 .Screen/color DEO
104
+
105
+	.center/x PEK2 PAD-WIDTH 2* SUB2 #0018 ADD2 .Screen/x DEO2
106
+	.Audio3/output DEI #04 SFT TOS #0008 MUL2 ;meter ADD2 .Screen/addr DEO2
107
+	#21 .Screen/color DEO
108
+
109
+	( TODO: draw in mixer )
110
+	( TODO: draw global )
111
+
112
+BRK
113
+
114
+@on-mouse ( -> )
115
+
116
+	;draw-cursor JSR2 
117
+
118
+	.Mouse/state DEI #00 NEQ ,&on-touch JNZ BRK &on-touch
119
+
120
+	( x ) .Mouse/x DEI2 .center/x PEK2 PAD-WIDTH 2* SUB2 SUB2 PAD-WIDTH DIV2 SWP POP
121
+	( y ) .Mouse/y DEI2 .center/y PEK2 PAD-HEIGHT 2* SUB2 SUB2 PAD-HEIGHT DIV2 SWP POP #04 MUL ADD
122
+	DUP #b0 SWP
123
+	;play-pad JSR2
124
+
125
+	( select ) DUP .selection POK ;draw-editor JSR2
126
+
127
+	( release ) #00 .Mouse/state DEO
128
+
129
+BRK
130
+
131
+@on-midi ( -> )
132
+	
133
+	.Midi/note DEI #00 NEQ ,&note-on JNZ BRK &note-on
134
+
135
+	.Midi/channel DEI #90 NEQ ,&no-drum JNZ 
136
+		.Midi/note DEI DUP #80 ADD SWP #10 MOD ;play-pad JSR2
137
+		BRK
138
+	&no-drum
139
+
140
+	;pad-addr #0008 ADD2 GET2 .Audio0/addr DEO2
141
+	#0008 .Audio0/length DEO2
142
+	.Midi/note DEI .Audio0/pitch DEO
143
+
144
+BRK
145
+
146
+@on-control ( -> )
147
+
148
+	.Controller/key DEI #00 NEQ ,&key-down JNZ BRK &key-down
149
+
150
+	.Controller/key DEI 
151
+	DUP #31 NEQ ,&no-0 JNZ #b0 #00 ;play-pad JSR2 &no-0
152
+	DUP #32 NEQ ,&no-1 JNZ #b0 #01 ;play-pad JSR2 &no-1
153
+	DUP #33 NEQ ,&no-2 JNZ #b0 #02 ;play-pad JSR2 &no-2
154
+	DUP #34 NEQ ,&no-3 JNZ #b0 #03 ;play-pad JSR2 &no-3
155
+	DUP #71 NEQ ,&no-4 JNZ #b0 #04 ;play-pad JSR2 &no-4
156
+	DUP #77 NEQ ,&no-5 JNZ #b0 #05 ;play-pad JSR2 &no-5
157
+	DUP #65 NEQ ,&no-6 JNZ #b0 #06 ;play-pad JSR2 &no-6
158
+	DUP #72 NEQ ,&no-7 JNZ #b0 #07 ;play-pad JSR2 &no-7
159
+	DUP #61 NEQ ,&no-8 JNZ #b0 #08 ;play-pad JSR2 &no-8
160
+	DUP #73 NEQ ,&no-9 JNZ #b0 #09 ;play-pad JSR2 &no-9
161
+	DUP #64 NEQ ,&no-a JNZ #b0 #0a ;play-pad JSR2 &no-a
162
+	DUP #66 NEQ ,&no-b JNZ #b0 #0b ;play-pad JSR2 &no-b
163
+	DUP #7a NEQ ,&no-c JNZ #b0 #0c ;play-pad JSR2 &no-c
164
+	DUP #78 NEQ ,&no-d JNZ #b0 #0d ;play-pad JSR2 &no-d
165
+	DUP #63 NEQ ,&no-e JNZ #b0 #0e ;play-pad JSR2 &no-e
166
+	DUP #76 NEQ ,&no-f JNZ #b0 #0f ;play-pad JSR2 &no-f
167
+	POP
168
+
169
+BRK
170
+
171
+@load-samples ( -- )
172
+
173
+	#00 #10
174
+	&loop
175
+		( name ) OVR TOS #0019 MUL2 ;pad-path ADD2 .File/name DEO2
176
+		( length ) OVR TOS #0002 MUL2 ;pad-length ADD2 GET2 .File/length DEO2
177
+		( load ) OVR TOS #0002 MUL2 ;pad-addr ADD2 GET2 .File/load DEO2
178
+		( incr ) SWP #01 ADD SWP
179
+		DUP2 LTH ,&loop JNZ
180
+	POP2
181
+	
182
+RTN
183
+
184
+@play-pad ( note pad -- )
185
+	
186
+	STH
187
+	( unseslect last )
188
+	.last PEK #01 ;draw-pad JSR2
189
+	DUPr STHr .last POK 
190
+
191
+	( highlight )
192
+	DUPr STHr #02 ;draw-pad JSR2
193
+
194
+	( length )
195
+	DUPr STHr TOS #0002 MUL2 ;pad-addr ADD2 DUP2 GET2 SWP2 #0002 ADD2 GET2 SWP2 SUB2 
196
+	DUPr STHr #04 DIV #10 MUL .Audio0/length ADD DEO2	
197
+
198
+	( addr )
199
+	DUPr STHr TOS #0002 MUL2 ;pad-addr ADD2 GET2
200
+	DUPr STHr #04 DIV #10 MUL .Audio0/addr ADD DEO2
201
+
202
+	( pitch )
203
+	DUPr STHr #04 DIV #10 MUL .Audio0/pitch ADD DEO
204
+
205
+	DUPr STHr #04 DIV ;draw-mixer JSR2
206
+
207
+	POPr
208
+
209
+RTN
210
+
211
+@draw-editor ( pad -- )
212
+
213
+	( get state )
214
+
215
+	.frame/y2 PEK2 #0008 ADD2 .Screen/y DEO2
216
+
217
+	.frame/x1 PEK2 .Screen/x DEO2
218
+	DUP #02 MUL TOS ;pad-addr ADD2 GET2
219
+	( addr ) #21 ;draw-short JSR2
220
+
221
+	.frame/x1 PEK2 #0028 ADD2 .Screen/x DEO2
222
+	DUP #02 MUL TOS ;pad-length ADD2 GET2
223
+	( addr ) #21 ;draw-short JSR2
224
+
225
+	POP
226
+
227
+RTN
228
+
229
+@draw-mixer ( mixer -- )
230
+
231
+	;cursor .Screen/addr DEO2
232
+
233
+	( y ) DUP TOS #0002 SUB2 PAD-HEIGHT MUL2 .center/y PEK2 ADD2 
234
+	( x ) .center/x PEK2 PAD-WIDTH 2* ADD2 
235
+	SWP2 
236
+	.Screen/y DEO2
237
+	.Screen/x DEO2
238
+
239
+	#23 .Screen/color DEO
240
+
241
+	POP
242
+
243
+	( once/repeat interface )
244
+	( draw ADSR knobs )
245
+
246
+RTN
247
+
248
+@draw-pads ( -- )
249
+	
250
+	#00 #10
251
+	&loop
252
+		OVR #01 ;draw-pad JSR2
253
+		SWP #01 ADD SWP
254
+		DUP2 LTH ,&loop JNZ
255
+	POP2
256
+
257
+RTN
258
+
259
+@draw-pad ( pad color -- )
260
+	
261
+	STH STH
262
+
263
+	DUPr STHr 
264
+
265
+	DUP #04 DIV SWP #04 MOD TOS PAD-WIDTH MUL2 ( center ) .center/x PEK2 ADD2 PAD-WIDTH #0002 MUL2 SUB2
266
+	ROT TOS PAD-HEIGHT MUL2 ( center ) .center/y PEK2 ADD2 PAD-HEIGHT #0002 MUL2 SUB2
267
+
268
+	( draw outline )
269
+	OVR2 OVR2 
270
+	OVR2 PAD-WIDTH #0002 SUB2 ADD2 
271
+	OVR2 PAD-HEIGHT #0002 SUB2 ADD2 
272
+	OVRr STHr ;line-rect JSR2
273
+
274
+	( draw name )
275
+	OVR2 #0002 ADD2 
276
+	OVR2 #0002 ADD2 
277
+	#20 OVRr STHr ADD 
278
+	;pad-name DUPr STHr TOS #0005 MUL2 ADD2 
279
+	;draw-label-left JSR2
280
+
281
+	POP2 POP2
282
+
283
+	POPr POPr
284
+
285
+RTN
286
+
287
+@draw-cursor ( -- )
288
+	
289
+	( clear last cursor )
290
+	;clear .Screen/addr DEO2 
291
+	.pointer/x PEK2 .Screen/x DEO2 
292
+	.pointer/y PEK2 .Screen/y DEO2 
293
+	#30 .Screen/color DEO
294
+	( record pointer positions )
295
+	.Mouse/x DEI2 .pointer/x POK2 
296
+	.Mouse/y DEI2 .pointer/y POK2
297
+	( draw new cursor )
298
+	;cursor .Screen/addr DEO2 
299
+	.pointer/x PEK2 .Screen/x DEO2 
300
+	.pointer/y PEK2 .Screen/y DEO2 
301
+	( colorize on state )
302
+	#31 [ .Mouse/state DEI #00 NEQ ] ADD .Screen/color DEO
303
+
304
+RTN
305
+
306
+@draw-short ( addr color -- )
307
+
308
+	STH SWP 
309
+	DUP #04 SFT TOS 8* ;font-hex ADD2 .Screen/addr DEO2
310
+	( draw ) DUPr STHr .Screen/color DEO
311
+	#0f AND TOS 8* ;font-hex ADD2 .Screen/addr DEO2
312
+	.Screen/x DEI2 8+ .Screen/x DEO2
313
+	( draw ) DUPr STHr .Screen/color DEO
314
+	DUP #04 SFT TOS 8* ;font-hex ADD2 .Screen/addr DEO2
315
+	.Screen/x DEI2 8+ .Screen/x DEO2
316
+	( draw ) DUPr STHr .Screen/color DEO
317
+	#0f AND TOS 8* ;font-hex ADD2 .Screen/addr DEO2
318
+	.Screen/x DEI2 8+ .Screen/x DEO2
319
+	( draw ) STHr .Screen/color DEO
320
+
321
+RTN
322
+
323
+@line-rect ( x1 y1 x2 y2 color -- )
324
+
325
+	( load ) .color POK DUP2 STH2 .rect/y2 POK2 .rect/x2 POK2 DUP2 STH2 .rect/y1 POK2 .rect/x1 POK2
326
+	STH2r #0001 ADD2 STH2r
327
+	&ver
328
+		( save ) OVR2 .Screen/y DEO2
329
+		( draw ) .rect/x1 PEK2 .Screen/x DEO2 .color PEK DUP .Screen/color DEO
330
+		( draw ) .rect/x2 PEK2 .Screen/x DEO2 .Screen/color DEO
331
+		( incr ) SWP2 ++ SWP2
332
+		OVR2 OVR2 LTS2 ,&ver JNZ
333
+	POP2 POP2
334
+	.rect/x1 PEK2 #0001 ADD2 .rect/x2 PEK2 #0001 SUB2
335
+	&hor
336
+		( save ) OVR2 .Screen/x DEO2
337
+		( draw ) .rect/y1 PEK2 .Screen/y DEO2 .color PEK DUP .Screen/color DEO
338
+		( draw ) .rect/y2 PEK2 .Screen/y DEO2 .Screen/color DEO
339
+		( incr ) SWP2 ++ SWP2
340
+		OVR2 OVR2 ++ LTS2 ,&hor JNZ
341
+	POP2 POP2
342
+
343
+RTN
344
+
345
+@draw-label-left ( x y color addr -- )
346
+	
347
+	( load ) .label/addr POK2 .label/color POK .Screen/y DEO2 .Screen/x DEO2
348
+	.label/addr PEK2
349
+	&loop
350
+		( draw ) DUP2 GET #00 SWP #0008 MUL2 ;font ADD2 .Screen/addr DEO2 .label/color PEK .Screen/color DEO
351
+		( incr ) #0001 ADD2
352
+		( incr ) .Screen/x DEI2 #0007 ADD2 .Screen/x DEO2
353
+		DUP2 GET #00 NEQ ,&loop JNZ
354
+	POP2
355
+
356
+RTN
357
+
358
+@pad-name [
359
+	"PAD1 $1 "SYN1 $1 "SYN2 $1 "CYM1 $1 ( short )
360
+	"HHAT $1 "OHAT $1 "CHAT $1 "RIDE $1
361
+	"SID1 $1 "SNR1 $1 "SNR2 $1 "SID2 $1 ( long )
362
+	"BDR1 $1 "KCK1 $1 "KCK2 $1 "BDR2 $1 ]
363
+
364
+@pad-addr [
365
+	4000 4400 4800 4c00
366
+	5000 5800 6000 6800
367
+	7000 7800 8000 8800
368
+	9000 b000 d000 f000 $2 ]
369
+
370
+@pad-length [
371
+	0800 0800 0800 0800
372
+	0800 0800 0800 0800
373
+	0800 0800 0800 0800
374
+	0800 0800 0800 0800 $2 ]
375
+
376
+@pad-path [
377
+	"projects/sounds/pad1.ss8 $1 "projects/sounds/syn1.ss8 $1
378
+	"projects/sounds/syn2.ss8 $1 "projects/sounds/cym1.ss8 $1
379
+	"projects/sounds/hhat.ss8 $1 "projects/sounds/ohat.ss8 $1
380
+	"projects/sounds/chat.ss8 $1 "projects/sounds/ride.ss8 $1
381
+	"projects/sounds/sid1.ss8 $1 "projects/sounds/snr1.ss8 $1
382
+	"projects/sounds/snr2.ss8 $1 "projects/sounds/sid2.ss8 $1
383
+	"projects/sounds/bdr1.ss8 $1 "projects/sounds/kck1.ss8 $1
384
+	"projects/sounds/kck2.ss8 $1 "projects/sounds/bdr2.ss8 $1 ]
385
+
386
+@clear  [ 
387
+	0000 0000 0000 0000 ]
388
+
389
+@cursor [ 
390
+	80c0 e0f0 f8e0 1000 ]
391
+
392
+@meter [
393
+	0000 0000 0000 0000
394
+	0000 0000 0000 0070 
395
+	0000 0000 0000 007e
396
+	0000 0000 0000 707e
397
+	0000 0000 0070 7e7e
398
+	0000 0000 007e 7e7e
399
+	0000 0000 707e 7e7e
400
+	0000 0000 7e7e 7e7e
401
+	0000 0070 7e7e 7e7e
402
+	0000 007e 7e7e 7e7e
403
+	0000 707e 7e7e 7e7e
404
+	0000 7e7e 7e7e 7e7e
405
+	0070 7e7e 7e7e 7e7e
406
+	007e 7e7e 7e7e 7e7e
407
+	707e 7e7e 7e7e 7e7e
408
+	7e7e 7e7e 7e7e 7e7e ]
409
+
410
+@font-hex ( 0-F )
411
+[
412
+	007c 8282 8282 827c 0030 1010 1010 1010
413
+	007c 8202 7c80 80fe 007c 8202 1c02 827c
414
+	000c 1424 4484 fe04 00fe 8080 7c02 827c
415
+	007c 8280 fc82 827c 007c 8202 1e02 0202
416
+	007c 8282 7c82 827c 007c 8282 7e02 827c
417
+	007c 8202 7e82 827e 00fc 8282 fc82 82fc
418
+	007c 8280 8080 827c 00fc 8282 8282 82fc
419
+	007c 8280 f080 827c 007c 8280 f080 8080
420
+]
421
+
422
+@font ( spectrum-zx font )
423
+[
424
+	0000 0000 0000 0000 0000 2400 7e3c 0000 0000 2400 3c42 0000 0000 6c7c 7c38 1000
425
+	0010 387c 7c38 1000 0038 387c 6c10 3800 0010 387c 7c10 3800 0000 0018 1800 0000
426
+	007e 4242 4242 7e00 0000 1824 2418 0000 0018 2442 4224 1800 001e 063a 4a48 3000
427
+	0038 446c 107c 1000 000c 0808 0838 3800 003e 2222 2266 6600 0000 0822 0022 0800
428
+	0000 1018 1c18 1000 0000 0818 3818 0800 0008 1c00 001c 0800 0028 2828 2800 2800
429
+	003e 4a4a 3a0a 0a00 000c 3046 620c 3000 0000 0000 0000 ffff 0010 3800 3810 0038
430
+	0008 1c2a 0808 0800 0008 0808 2a1c 0800 0000 0804 7e04 0800 0000 1020 7e20 1000
431
+	0000 4040 7e00 0000 0000 0024 6624 0000 0000 1038 7c00 0000 0000 007c 3810 0000
432
+	0000 0000 0000 0000 0008 0808 0800 0800 0014 1400 0000 0000 0024 7e24 247e 2400
433
+	0008 1e28 1c0a 3c08 0042 0408 1020 4200 0030 4832 4c44 3a00 0008 1000 0000 0000
434
+	0004 0808 0808 0400 0010 0808 0808 1000 0000 1408 3e08 1400 0000 0808 3e08 0800
435
+	0000 0000 0008 0810 0000 0000 3c00 0000 0000 0000 0000 0800 0000 0204 0810 2000
436
+	003c 464a 5262 3c00 0018 2808 0808 3e00 003c 4202 3c40 7e00 003c 421c 0242 3c00
437
+	0008 1828 487e 0800 007e 407c 0242 3c00 003c 407c 4242 3c00 007e 0204 0810 1000
438
+	003c 423c 4242 3c00 003c 4242 3e02 3c00 0000 0008 0000 0800 0000 0800 0008 0810
439
+	0000 0810 2010 0800 0000 003e 003e 0000 0000 1008 0408 1000 003c 4202 0c00 0800
440
+	003c 425a 5442 3c00 0018 2442 7e42 4200 007c 427c 4242 7c00 003c 4240 4042 3c00
441
+	0078 4442 4244 7800 007e 407c 4040 7e00 003e 4040 7c40 4000 003c 4240 4e42 3c00
442
+	0042 427e 4242 4200 003e 0808 0808 3e00 0002 0202 4242 3c00 0044 4870 4844 4200
443
+	0040 4040 4040 7e00 0042 665a 4242 4200 0042 6252 4a46 4200 003c 4242 4242 3c00
444
+	007c 4242 7c40 4000 003c 4242 524a 3c00 007c 4242 7c44 4200 003c 403c 0242 3c00
445
+	00fe 1010 1010 1000 0042 4242 4242 3c00 0042 4242 4224 1800 0042 4242 5a66 4200
446
+	0042 2418 1824 4200 0082 4428 1010 1000 007e 0408 1020 7e00 000c 0808 0808 0c00
447
+	0040 2010 0804 0200 0018 0808 0808 1800 0008 1422 0000 0000 0000 0000 0000 7e00
448
+	0008 0400 0000 0000 0000 1c02 1e22 1e00 0020 203c 2222 3c00 0000 1e20 2020 1e00
449
+	0002 021e 2222 1e00 0000 1c22 3c20 1e00 000c 101c 1010 1000 0000 1c22 221e 021c
450
+	0020 202c 3222 2200 0008 0018 0808 0400 0008 0008 0808 4830 0020 2428 3028 2400
451
+	0010 1010 1010 0c00 0000 6854 5454 5400 0000 5864 4444 4400 0000 3844 4444 3800
452
+	0000 7844 4478 4040 0000 3c44 443c 0406 0000 2c30 2020 2000 0000 3840 3804 7800
453
+	0010 103c 1010 0c00 0000 4444 4444 3800 0000 4444 2828 1000 0000 4454 5454 2800
454
+	0000 4428 1028 4400 0000 4444 443c 0438 0000 7c08 1020 7c00 000c 0810 1008 0c00
455
+	0008 0808 0808 0800 0030 1008 0810 3000 0000 0032 4c00 0000 3c42 99a1 a199 423c
456
+]
... ...
@@ -25,7 +25,7 @@
25 25
 
26 26
 |0000
27 27
 
28
-@last $1
28
+@last-note $1
29 29
 @octave $1
30 30
 @addr $1
31 31
 @color $1
... ...
@@ -74,7 +74,7 @@
74 74
 	.wave-view/y1 PEK2 #0020 ADD2 .wave-view/y2 POK2
75 75
 
76 76
 	( default settings )
77
-	#ff .last POK
77
+	#ff .last-note POK
78 78
 	#048c .Audio0/adsr DEO2
79 79
 	#88 .Audio0/volume DEO
80 80
 	;sine-wave .Audio0/addr DEO2
... ...
@@ -108,7 +108,7 @@ BRK
108 108
 	;draw-cursor JSR2 
109 109
 	.Mouse/state DEI #00 NEQ ,&no-touch JNZ BRK &no-touch
110 110
 	( wave-view )
111
-	.Mouse/x DEI2 DUP2 .wave-view/x1 PEK2 GTH2 ROT ROT .wave-view/x2 PEK2 LTH2 #0101 EQU2
111
+	.Mouse/x DEI2 DUP2 .wave-view/x1 PEK2 GTH2 ROT ROT .wave-view/x2 PEK2 #0001 ADD2 LTH2 #0101 EQU2
112 112
 	.Mouse/y DEI2 DUP2 .wave-view/y1 PEK2 GTH2 ROT ROT .wave-view/y2 PEK2 LTH2 #0101 EQU2
113 113
 	#0101 EQU2 ;on-touch-wave-view JNZ2
114 114
 	( adsr-view )
... ...
@@ -144,7 +144,7 @@ BRK
144 144
 		BRK
145 145
 	&no-mod
146 146
 
147
-	.Mouse/x DEI2 .octave-view/x1 PEK2 SUB2 8/ DUP2 SWP POP .last POK ;notes ADD2 GET ;play JSR2
147
+	.Mouse/x DEI2 .octave-view/x1 PEK2 SUB2 8/ DUP2 SWP POP .last-note POK ;notes ADD2 GET ;play JSR2
148 148
 
149 149
 	( release ) #00 .Mouse/state DEO
150 150
 	;draw-octave JSR2
... ...
@@ -188,21 +188,21 @@ BRK
188 188
 
189 189
 	.Controller/key DEI
190 190
 	DUP #61 NEQ ,&no-c JNZ
191
-		#00 .last POK ;notes GET ;play JSR2 &no-c
191
+		#00 .last-note POK ;notes GET ;play JSR2 &no-c
192 192
 	DUP #73 NEQ ,&no-d JNZ
193
-		#01 .last POK ;notes ++ GET ;play JSR2 &no-d
193
+		#01 .last-note POK ;notes ++ GET ;play JSR2 &no-d
194 194
 	DUP #64 NEQ ,&no-e JNZ
195
-		#02 .last POK ;notes #0002 ADD2 GET ;play JSR2 &no-e
195
+		#02 .last-note POK ;notes #0002 ADD2 GET ;play JSR2 &no-e
196 196
 	DUP #66 NEQ ,&no-f JNZ
197
-		#03 .last POK ;notes #0003 ADD2 GET ;play JSR2 &no-f
197
+		#03 .last-note POK ;notes #0003 ADD2 GET ;play JSR2 &no-f
198 198
 	DUP #67 NEQ ,&no-g JNZ
199
-		#04 .last POK ;notes #0004 ADD2 GET ;play JSR2 &no-g
199
+		#04 .last-note POK ;notes #0004 ADD2 GET ;play JSR2 &no-g
200 200
 	DUP #68 NEQ ,&no-a JNZ
201
-		#05 .last POK ;notes #0005 ADD2 GET ;play JSR2 &no-a
201
+		#05 .last-note POK ;notes #0005 ADD2 GET ;play JSR2 &no-a
202 202
 	DUP #6a NEQ ,&no-b JNZ
203
-		#06 .last POK ;notes #0006 ADD2 GET ;play JSR2 &no-b
203
+		#06 .last-note POK ;notes #0006 ADD2 GET ;play JSR2 &no-b
204 204
 	DUP #6b NEQ ,&no-c2 JNZ
205
-		#07 .last POK ;notes #0007 ADD2 GET ;play JSR2 &no-c2
205
+		#07 .last-note POK ;notes #0007 ADD2 GET ;play JSR2 &no-c2
206 206
 	POP
207 207
 
208 208
 	.Controller/button DEI #f0 AND
... ...
@@ -250,13 +250,13 @@ RTN
250 250
 	
251 251
 	.octave-view/x1 PEK2 .octave-view/y1 PEK2
252 252
 
253
-	OVR2 OVR2 ;keys-left-icns #21 .last PEK #00 EQU ADD ;draw-key JSR2
254
-	OVR2 8+ OVR2 ;keys-middle-icns #21 .last PEK #01 EQU ADD ;draw-key JSR2
255
-	OVR2 #0010 ADD2 OVR2 ;keys-right-icns #21 .last PEK #02 EQU ADD ;draw-key JSR2
256
-	OVR2 #0018 ADD2 OVR2 ;keys-left-icns #21 .last PEK #03 EQU ADD ;draw-key JSR2
257
-	OVR2 #0020 ADD2 OVR2 ;keys-middle-icns #21 .last PEK #04 EQU ADD ;draw-key JSR2
258
-	OVR2 #0028 ADD2 OVR2 ;keys-middle-icns #21 .last PEK #05 EQU ADD ;draw-key JSR2
259
-	SWP2 #0030 ADD2 SWP2 ;keys-right-icns #21 .last PEK #06 EQU ADD ;draw-key JSR2
253
+	OVR2 OVR2 ;keys-left-icns #21 .last-note PEK #00 EQU ADD ;draw-key JSR2
254
+	OVR2 8+ OVR2 ;keys-middle-icns #21 .last-note PEK #01 EQU ADD ;draw-key JSR2
255
+	OVR2 #0010 ADD2 OVR2 ;keys-right-icns #21 .last-note PEK #02 EQU ADD ;draw-key JSR2
256
+	OVR2 #0018 ADD2 OVR2 ;keys-left-icns #21 .last-note PEK #03 EQU ADD ;draw-key JSR2
257
+	OVR2 #0020 ADD2 OVR2 ;keys-middle-icns #21 .last-note PEK #04 EQU ADD ;draw-key JSR2
258
+	OVR2 #0028 ADD2 OVR2 ;keys-middle-icns #21 .last-note PEK #05 EQU ADD ;draw-key JSR2
259
+	SWP2 #0030 ADD2 SWP2 ;keys-right-icns #21 .last-note PEK #06 EQU ADD ;draw-key JSR2
260 260
 
261 261
 	;arrow-icns .Screen/addr DEO2
262 262
 	.octave-view/x1 PEK2 #0040 ADD2 .Screen/x DEO2
... ...
@@ -340,9 +340,9 @@ RTN
340 340
 	( range )
341 341
 	.wave-view/x1 PEK2 .Screen/x DEO2
342 342
 	.wave-view/y1 PEK2 #0010 SUB2 .Screen/y DEO2
343
-	.Audio0/addr DEI2 ;draw-short JSR2
343
+	.Audio0/addr DEI2 #22 ;draw-short JSR2
344 344
 	.wave-view/x2 PEK2 #0020 SUB2 .Screen/x DEO2
345
-	.Audio0/length DEI2 ;draw-short JSR2
345
+	.Audio0/length DEI2 #22 ;draw-short JSR2
346 346
 
347 347
 RTN
348 348
 
... ...
@@ -381,24 +381,24 @@ RTN
381 381
 
382 382
 RTN
383 383
 
384
-@draw-short ( short -- )
384
+@draw-short ( short* color -- )
385 385
 
386
-	.addr POK2
387
-	;font-hex #00 ;addr GET #f0 AND #04 SFT #08 MUL ADD2 .Screen/addr DEO2
388
-	( draw ) #22 .Screen/color DEO
386
+	STH SWP 
387
+	DUP #04 SFT TOS #0008 MUL2 ;font-hex ADD2 .Screen/addr DEO2
388
+	( draw ) DUPr STHr .Screen/color DEO
389
+	#0f AND TOS #0008 MUL2 ;font-hex ADD2 .Screen/addr DEO2
389 390
 	.Screen/x DEI2 8+ .Screen/x DEO2
390
-	;font-hex #00 ;addr GET #0f AND #08 MUL ADD2 .Screen/addr DEO2
391
-	( draw ) #22 .Screen/color DEO
391
+	( draw ) DUPr STHr .Screen/color DEO
392
+	DUP #04 SFT TOS #0008 MUL2 ;font-hex ADD2 .Screen/addr DEO2
392 393
 	.Screen/x DEI2 8+ .Screen/x DEO2
393
-	;font-hex #00 ;addr ++ GET #f0 AND #04 SFT #08 MUL ADD2 .Screen/addr DEO2
394
-	( draw ) #22 .Screen/color DEO
394
+	( draw ) DUPr STHr .Screen/color DEO
395
+	#0f AND TOS #0008 MUL2 ;font-hex ADD2 .Screen/addr DEO2
395 396
 	.Screen/x DEI2 8+ .Screen/x DEO2
396
-	;font-hex #00 ;addr ++ GET #0f AND #08 MUL ADD2 .Screen/addr DEO2
397
-	( draw ) #22 .Screen/color DEO
397
+	( draw ) STHr .Screen/color DEO
398 398
 
399 399
 RTN
400 400
 
401
-@fill-rect ( x1 y1 x2 y2 color -- )
401
+@fill-rect ( x1* y1* x2* y2* color -- )
402 402
 	
403 403
 	.color POK
404 404
 	( x1 x2 y1 y2 ) ROT2 SWP2