-
Notifications
You must be signed in to change notification settings - Fork 0
/
phasersq.asm
746 lines (573 loc) · 14.3 KB
/
phasersq.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
;PHASER SQUEEK - UTZ
;converted over to Aquarius by Bushy.
;Assembled to $e000 with Pasmo Assembler.
;
;
;Load in Binary file : "phasersq.bin"
;at memory $E000
;usr Execution at $0000
;Then back at basic, run X=USR(0)
;
;---------------
;Phase Squeek aka TOUPEE (Totally Overpowered, Utterly Pointless Extreme Engine)
;version 0.1
;ZX Spectrum beeper engine
;by utz 08'2016 * www.irrlichtproject.de
; out ($fc),a ;11 ; Aquarius
; out ($fe),a ;11 ; ZX
; AND $21 ; VZ
; ld ($6800), a ; VZ
; out (2),a ;11 ; MICROBEE
; org $4000 ; Aquarius 4k cassette/cartridge
; org $c000 ; Aquarius lower 8k cartridge
org $e000 ; Aquarius upper 8k cartridge
; org $100 ; Microbee
; org $8000 ; VZ
; org $4000 ; ZX Spectrum
db 98, 117, 115, 104
db 121, 156, 50, 176
db 48, 108, 50, 100
db 50, 168, 183, 112
; include "freqtab.asm" ;note name equates, can be omitted
noise equ $2175
rest equ 0
a0 equ $ec
ais0 equ $fa
b0 equ $109
c1 equ $118
cis1 equ $129
d1 equ $13b
dis1 equ $14d
e1 equ $161
f1 equ $176
fis1 equ $18d
g1 equ $1a4
gis1 equ $1bd
a1 equ $1d8
ais1 equ $1f4
b1 equ $211
c2 equ $231
cis2 equ $252
d2 equ $275
dis2 equ $29b
e2 equ $2c2
f2 equ $2ed
fis2 equ $319
g2 equ $348
gis2 equ $37a
a2 equ $3af
ais2 equ $3e7
b2 equ $423
c3 equ $461
cis3 equ $4a4
d3 equ $4eb
dis3 equ $536
e3 equ $585
f3 equ $5d9
fis3 equ $632
g3 equ $690
gis3 equ $6f4
a3 equ $75e
ais3 equ $7ce
b3 equ $845
c4 equ $8c3
cis4 equ $948
d4 equ $9d6
dis4 equ $a6b
e4 equ $b0a
f4 equ $bb2
fis4 equ $c64
g4 equ $d21
gis4 equ $de9
a4 equ $ebc
ais4 equ $f9d
b4 equ $108a
c5 equ $1186
cis5 equ $1291
d5 equ $13ab
dis5 equ $14d7
e5 equ $1614
f5 equ $1764
fis5 equ $18c8
g5 equ $1a41
gis5 equ $1bd1
a5 equ $1d79
ais5 equ $1f39
b5 equ $2114
c6 equ $230c
cis6 equ $2521
d6 equ $2757
dis6 equ $29ae
e6 equ $2c28
f6 equ $2ec8
fis6 equ $3190
g6 equ $3483
gis6 equ $37a2
a6 equ $3af1
ais6 equ $3e72
b6 equ $4229
c7 equ $4618
cis7 equ $4a43
d7 equ $4ead
dis7 equ $535b
e7 equ $5850
f7 equ $5d90
fis7 equ $6321
g7 equ $6906
gis7 equ $6f44
a7 equ $75e2
init
_skip
di
exx
push hl ;preserve HL' for return to BASIC
ld (oldSP),sp
ld hl,musicData
ld (seqpntr),hl
;******************************************************************
rdseq
seqpntr equ $+1
ld sp,0
xor a
pop bc ;pattern pointer to DE
or b
ld (seqpntr),sp
jr nz,rdptn0
;jp exit ;uncomment to disable looping
ld sp,loop ;get loop point
jr rdseq+3
;******************************************************************
rdptn0
ld (ptnpntr),bc
rdptn
ptnpntr equ $+1
ld sp,0
pop af ;global ctrl (F) and method (A)
jr z,rdseq
jr c,_noFxUpdate0
pop bc ;fx table pointer
ld (fxPointer),bc
_noFxUpdate0
jp pe,_ctrl_3 ;no updates for this row
ld (globalMethod),a
jp m,_ctrl_2 ;no updates for ch1
pop af ;ch1 ctrl (F) and method (A)
ld (method1),a
jr c,_noF1Update0
pop hl ;frequency ch1 op1
ld (freq1A),hl
pop hl ;frequency ch1 op2
ld (freq1B),hl
_noF1Update0
jr z,_noDuty1Update0
pop de ;duties ch1 op1/2
_noDuty1Update0
jp pe,_noSID1Update0
pop bc ;SID/ES ch1 op1
ld (sid1A),bc
pop bc ;SID/ES ch1 op2
ld (sid1B),bc
_noSID1Update0
jp m,_noPhase1Update0
pop hl ;phase ch1
ld ix,0
_noPhase1Update0
_ctrl_2:
pop af ;ch2 ctrl (F) and method (A)
ld (method2),a
exx
jr c,_noF2Update1
pop hl ;freq ch2 op1
ld (freq2A),hl
pop hl ;freq ch2 op2
ld (freq2B),hl
_noF2Update1
jr z,_noDuty2Update1
pop de ;duties ch2 op1/2
_noDuty2Update1
ld a,0
jp po,_setNoise2
ld a,$cb
_setNoise2
ld (noise2),a ;a=0 - noise disabled, a=$cb - noise enabled
jp m,_noPhase2Update1
pop hl ;phase ch2
ld iy,0
_noPhase2Update1
exx
_ctrl_3:
pop af ;drum ctrl (F) and speed
jp z,drum1
jp m,drum2
ld c,0 ;set speed (length counter) lo-byte
ex af,af'
drumret
ld (ptnpntr),sp
;*******************************************************************************
playNote
freq1A equ $+1
ld sp,0 ;10
add hl,sp ;11
ld a,d ;4
sid1A
shaker1A equ $+1 ;add a,n = c6, adc a,n = c6
adc a,0 ;7
ld d,a ;4
add a,h ;4
sbc a,a ;4
ld b,a ;4
freq1B equ $+1
ld sp,0 ;10
add ix,sp ;15
ld a,e ;4
sid1B
shaker1B equ $+1
adc a,0 ;7
ld e,a ;4
add a,ixh ;4
sbc a,a ;4
method1
xor b ;4 ;xor = a8, or = b0, and = a0
ld b,a ;4 ;preserve output state ch1
exx ;4
freq2A equ $+1
ld sp,0 ;10
add hl,sp ;11
noise2
rlc h ;8 ;rlc h = cb 04 - noise enable
;nop,inc b = 00 04 - noise disable
ld a,d ;4
add a,h ;4
sbc a,a ;4
ld b,a ;4
freq2B equ $+1
ld sp,0 ;10
add iy,sp ;15
ld a,e ;4
add a,iyh ;8
sbc a,a ;4
method2
xor b ;4
exx ;4
globalMethod
xor b ;4 ;combine with state ch1
ret c ;5 ;timing
out ($fc),a ;11 ; Aquarius
; out ($fe),a ;11 ; ZX
; AND $21 ; VZ
; ld ($6800), a ; VZ
; out (2),a ;11 ; MICROBEE
dec c ;4 ;timer
jp nz,playNote ;10
;232
;*******************************************************************************
updateTimer
fxPointer equ $+1
ld sp,0
pop af ;global ctrl (F) and method (A)
jr z,stopFx
jp pe, noUpdate3a ;no updates for this row
jr nc,_noFxPntrReset2
exx
pop bc ;fx table pointer reset
ld (fxPointer),bc
exx
jp updateTimer
_noFxPntrReset2
ld (globalMethod),a
jp m,ctrl3 ;no updates for ch1
pop af ;ch1 ctrl (F) and method (A)
ld (method1),a
jr c,_noF1Update2
pop hl ;frequency ch1 op1
ld (freq1A),hl
pop hl ;frequency ch1 op2
ld (freq1B),hl
_noF1Update2
jr z,_noDuty1Update2
pop de ;duties ch1 op1/2
_noDuty1Update2
jp pe,_noSID1Update2
exx
pop bc ;SID/ES ch1 op1
ld (sid1A),bc
pop bc ;SID/ES ch1 op2
ld (sid1B),bc
exx
_noSID1Update2
jp m,_noPhase1Update2
pop hl ;phase ch1
ld ix,0
_noPhase1Update2:
ctrl3:
pop af ;ch2 ctrl (F) and method (A)
ld (method2),a
exx
jr c,_noF2Update3
pop hl ;freq ch2 op1
ld (freq2A),hl
pop hl ;freq ch2 op2
ld (freq2B),hl
_noF2Update3
jr z,_noDuty2Update3
pop de ;duties ch2 op1/2
_noDuty2Update3
ld a,0
jp po,_setNoise3
ld a,$cb
_setNoise3
ld (noise2),a ;a=0 - noise disabled, a=$cb - noise enabled
jp m,_noPhase2Update3
pop hl ;phase ch2
ld iy,0
_noPhase2Update3
exx
noUpdate3a
ld (fxPointer),sp
stopFx:
ex af,af'
dec a
jp z,rdptn
ex af,af'
jp playNote
;*******************************************************************************
drum2
ld (HLrestore),hl
ex af,af'
ld hl,hat1
ld b,hat1end-hat1
jr drentry
drum1
ld (HLrestore),hl
ex af,af'
ld hl,kick1 ;10
ld b,kick1end-kick1 ;7
drentry
xor a ;4
_s2
; xor BORDER ;7
ld c,(hl) ;7
inc hl ;6
_s1
out ($fc),a ;11 ; Aquarius
; out ($fe),a ;11 ; ZX
; AND $21 ; VZ
; ld ($6800), a ; VZ
; out (2),a ;11 ; MICROBEE
dec c ;4
jr nz,_s1 ;12/7
djnz _s2 ;13/8
ld c,$16 ;7 ;correct frame length
HLrestore equ $+1
ld hl,0
jp drumret ;10
kick1 ;27*16*4 + 27*32*4 + 27*64*4 + 27*128*4 + 27*256*4 = 53568, + 20*33 = 53568 -> -231 loops -> C = $19
ds 4,$10
ds 4,$20
ds 4,$40
ds 4,$80
ds 4,0
kick1end
hat1
db 16,3,12,6,9,20,4,8,2,14,9,17,5,8,12,4,7,16,13,22,5,3,16,3,12,6,9,20,4,8,2,14,9,17,5,8,12,4,7,16,13,22,5,3
db 12,8,1,24,6,7,4,9,18,12,8,3,11,7,5,8,3,17,9,15,22,6,5,8,11,13,4,8,12,9,2,4,7,8,12,6,7,4,19,22,1,9,6,27,4,3,11
db 5,8,14,2,11,13,5,9,2,17,10,3,7,19,4,3,8,2,9,11,4,17,6,4,9,14,2,22,8,4,19,2,3,5,11,1,16,20,4,7
db 8,9,4,12,2,8,14,3,7,7,13,9,15,1,8,4,17,3,22,4,8,11,4,21,9,6,12,4,3,8,7,17,5,9,2,11,17,4,9,3,2
db 22,4,7,3,8,9,4,11,8,5,9,2,6,2,8,8,3,11,5,3,9,6,7,4,8
hat1end
;*******************************************************************************
exit
oldSP equ $+1
ld sp,0
pop hl
exx
ei
ret
;*******************************************************************************
musicData
; include "music.asm"
mdseq
dw mdb_Patterns_intro
dw mdb_Patterns_intro
dw mdb_Patterns_intro
dw mdb_Patterns_intro
dw mdb_Patterns_pattern1
dw mdb_Patterns_pattern1
dw mdb_Patterns_pattern1
dw mdb_Patterns_pattern1a
dw mdb_Patterns_pattern1
dw mdb_Patterns_pattern1
dw mdb_Patterns_pattern1
dw mdb_Patterns_pattern1a
dw mdb_Patterns_pattern1
dw mdb_Patterns_pattern1
dw mdb_Patterns_pattern1
dw mdb_Patterns_pattern1a
dw mdb_Patterns_pattern1
dw mdb_Patterns_pattern1
dw mdb_Patterns_pattern1
dw mdb_Patterns_pattern1b
loop
dw mdb_Patterns_pattern2
dw mdb_Patterns_pattern2x
dw mdb_Patterns_pattern2y
dw mdb_Patterns_pattern2a
dw mdb_Patterns_pattern2
dw mdb_Patterns_pattern2z
dw mdb_Patterns_pattern2y
dw mdb_Patterns_pattern2a1
dw mdb_Patterns_pattern2
dw mdb_Patterns_pattern2x
dw mdb_Patterns_pattern2y
dw mdb_Patterns_pattern2a
dw mdb_Patterns_pattern2
dw mdb_Patterns_pattern2z
dw mdb_Patterns_pattern2y
dw mdb_Patterns_pattern2b
dw 0
mdb_Patterns_intro
dw $b000, mdb_FxTables_fx0, $b000, 0, 0, $4040, $c6, $c6, 0, $b000, 0, 0, $4040, 0, $740
dw $b085, $700
dw $b085, $780
dw $b085, $700
dw $b080, mdb_FxTables_snare1, $b0c4, noise, 0, $700
dw $b085, $700
dw $b080, mdb_FxTables_fx0, $b0c0, rest, 0, $780
dw $b085, $700
db $40
mdb_Patterns_pattern1
dw $b001, $a8c0, rest, rest, $ce, $c6, $b0c1, $740
dw $b085, $700
dw $b001, $a8c4, c1, c1, $b0c1, $780
dw $b085, $700
dw $b000, mdb_FxTables_snare1, $a8c4, rest, rest, $b0c4, noise, 0, $700
dw $b085, $700
dw $b000, mdb_FxTables_fx0, $a8c4, c1, c1, $b0c0, rest, 0, $780
dw $b085, $700
db $40
mdb_Patterns_pattern1a
dw $b001, $a8c4, c1, c1, $b0c1, $740
dw $b001, $a8c4, d1, d1, $b0c1, $700
dw $b001, $a8c4, dis1, dis1, $b0c1, $700
dw $b001, $a8c4, f1, f1, $b0c1, $740
dw $b000, mdb_FxTables_snare1, $a8c4, c1, c1, $b0c4, noise, 0, $700
dw $b001, $a8c4, d1, d1, $b0c5, $700
dw $b000, mdb_FxTables_fx0, $a8c4, dis1, dis1, $b0c0, rest, 0, $780
dw $b001, $a8c4, f1, f1, $b0c1, $700
db $40
mdb_Patterns_pattern1b
dw $b001, $a8c4, g1, g1, $b0c1, $740
dw $b001, $a8c4, f1, f1, $b0c1, $700
dw $b001, $a8c4, dis1, dis1, $b0c1, $700
dw $b001, $a8c4, d1, d1, $b0c1, $740
dw $b000, mdb_FxTables_snare1, $a8c4, g1, g1, $b0c4, noise, 0, $700
dw $b001, $a8c4, f1, f1, $b0c5, $700
dw $b000, mdb_FxTables_fx0, $a8c4, dis1, dis1, $b0c0, rest, 0, $780
dw $b001, $a8c4, d1, d1, $b0c1, $700
db $40
mdb_Patterns_pattern2
dw $b000, mdb_FxTables_arp1, $a840, rest, rest, $c6, $c6, 0, $b000, rest, c3, $4010, 0, $740
dw $b085, $700
dw $b001, $a8c4, c1, c1, $b0c1, $780
dw $b085, $700
dw $b000, mdb_FxTables_snare1, $a8c4, rest, rest, $b0c4, noise, c3, $700
dw $b085, $700
dw $b000, mdb_FxTables_fx0, $a8c4, c1, c1, $b0c0, rest, c3, $780
dw $b085, $700
db $40
mdb_Patterns_pattern2x
dw $b000, mdb_FxTables_arp2, $a844, rest, rest, 0, $b000, rest, dis3, $4010, 0, $740
dw $b085, $700
dw $b001, $a8c4, c1, c1, $b0c1, $780
dw $b085, $700
dw $b000, mdb_FxTables_snare1, $a8c4, rest, rest, $b0c4, noise, dis3, $700
dw $b085, $700
dw $b000, mdb_FxTables_fx0, $a8c4, c1, c1, $b0c0, rest, dis3, $780
dw $b085, $700
db $40
mdb_Patterns_pattern2y
dw $b000, mdb_FxTables_arp1, $a844, rest, rest, 0, $b000, rest, f3, $4010, 0, $740
dw $b085, $700
dw $b001, $a8c4, c1, c1, $b0c1, $780
dw $b085, $700
dw $b000, mdb_FxTables_snare1, $a8c4, rest, rest, $b0c4, noise, f3, $700
dw $b085, $700
dw $b000, mdb_FxTables_fx0, $a8c4, c1, c1, $b0c0, rest, f3, $780
dw $b085, $700
db $40
mdb_Patterns_pattern2a
dw $b000, mdb_FxTables_arp1, $a8c4, rest, c1, $b000, rest, dis3, $4010, 0, $740
dw $b001, $a8c4, rest, d1, $b0c1, $700
dw $b001, $a8c4, rest, dis1, $b0c1, $700
dw $b001, $a8c4, rest, f1, $b0c1, $740
dw $b000, mdb_FxTables_snare1, $a8c4, c1, c1, $b0c4, noise, dis3, $700
dw $b001, $a8c4, d1, d1, $b0c5, $700
dw $b000, mdb_FxTables_fx0, $a8c4, dis1, dis1, $b0c0, rest, dis3, $780
dw $b001, $a8c4, f1, f1, $b0c1, $780
db $40
mdb_Patterns_pattern2z
dw $b000, mdb_FxTables_arp2, $a844, rest, rest, 0, $b000, rest, ais2, $4010, 0, $740
dw $b085, $700
dw $b001, $a8c4, c1, c1, $b0c1, $780
dw $b085, $700
dw $b000, mdb_FxTables_snare1, $a8c4, rest, rest, $b0c4, noise, ais2, $700
dw $b085, $700
dw $b000, mdb_FxTables_fx0, $a8c4, c1, c1, $b0c0, rest, ais2, $780
dw $b085, $700
db $40
mdb_Patterns_pattern2a1
dw $b000, mdb_FxTables_arp1, $a8c4, rest, c1, $b000, rest, c3, $4010, 0, $740
dw $b001, $a8c4, rest, d1, $b0c1, $700
dw $b001, $a8c4, rest, dis1, $b0c1, $700
dw $b001, $a8c4, rest, f1, $b0c1, $740
dw $b000, mdb_FxTables_snare1, $a8c4, c1, c1, $b0c4, noise, c3, $700
dw $b001, $a8c4, d1, d1, $b0c5, $700
dw $b000, mdb_FxTables_fx0, $a8c4, dis1, dis1, $b0c0, rest, c3, $780
dw $b001, $a8c4, f1, f1, $b0c1, $780
db $40
mdb_Patterns_pattern2b
dw $b000, mdb_FxTables_arp1, $a8c4, rest, g1, $b000, rest, c3, $4010, 0, $740
dw $b001, $a8c4, rest, f1, $b0c1, $700
dw $b001, $a8c4, rest, dis1, $b0c1, $700
dw $b001, $a8c4, rest, d1, $b0c1, $740
dw $b000, mdb_FxTables_snare1, $a8c4, g1, g1, $b0c4, noise, c3, $700
dw $b001, $a8c4, f1, f1, $b0c5, $700
dw $b000, mdb_FxTables_fx0, $a8c4, dis1, dis1, $b0c0, rest, c3, $780
dw $b001, $a8c4, d1, d1, $b0c1, $780
db $40
mdb_FxTables_fx0
dw $40
mdb_FxTables_snare1
dw $b080, $b085, $4010
dw $b084
dw $b080, $b085, $3010
dw $b084
dw $b080, $b085, $2010
dw $b084
dw $b084
dw $b084
dw $b080, $b085, $1810
dw $b084
dw $b084
dw $b084
dw $b080, $b085, $1010
dw $b084
dw $b080, $b085, $810
dw $b080, $b085, $410
dw $40
mdb_FxTables_arp1
dw $b080, $b0c0, 0, c3
dw $b080, $b0c0, 0, c3
dw $b080, $b0c0, 0, dis3
dw $b080, $b0c0, 0, dis3
dw $b080, $b0c0, 0, g3
dw $b080, $b0c0, 0, g3
dw $1, mdb_FxTables_arp1
mdb_FxTables_arp2
dw $b080, $b0c0, 0, c3
dw $b080, $b0c0, 0, c3
dw $b080, $b0c0, 0, dis3
dw $b080, $b0c0, 0, dis3
dw $b080, $b0c0, 0, f3
dw $b080, $b0c0, 0, f3
dw $1, mdb_FxTables_arp2