-
Notifications
You must be signed in to change notification settings - Fork 0
/
Earshaver_album_track10.asm
4878 lines (4577 loc) · 92.9 KB
/
Earshaver_album_track10.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
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
; Earshaver 1-bit Album, by Shiru. 2023.
;
; 01_adventure_time.1tm
; 02_traffic_lights.1tm
; 03_perfect_shitstorm.1tm
; 04_alphabeard.1tm
; 05_ear_shaver.1tm
; 06_spinning_bits.1tm
; 07_facemelter.1tm
; 08_burning_bright.1tm
; 09_balls_of_steel.1tm
; 10_kinda_loud.1tm
; 11_noise_in_my_head.1tm
;
; Originally for ZX Spectrum.
; Simple changeover to Microbee by dave.
; Microbee speaker hangs off port 2. Bit 6 drives the speaker.
;
; Assembly with SJASMPLUS.
; sjasmplus %1.asm
;
; Load into MAME/MESS with standard Microbee 32k ROM.
; Devices --> Quickload --> mount --> Select *.COM file.
; CP/M .COM files for Microbee loads in at $100 in memory, and will autoplay.
;
output "Earshaver_album_track10.com"
org $100
begin
ld hl,music_data
call play
ret
;music data format
;two bytes absolute pointer to drumParam table, then song data follows
;row length and flags byte
;%Frrrrrrr
; r=row length 0..127, F is special event flag
; 00=end of song data
;if F flag is set, check the lowest bit, it is engine change or drum pointer
; RD00EEE1 is engine change
; R=phase reset flag (always set for engines 0 and 5)
; E=engine number*2 (0,2,4,6,8,10,12,14)
; D=drum flag, if set, the drum param pointer follows
; xxxxxxx0 is drum pointer, this is LSB, MSB follows
;two note fields follows after the speed byte and optional bytes:
;$00 empty field, $01 rest note, otherwise MSB/LSB word of the divider/duty/phase
;drum param table follows, entries always aligned to 2 byte (lowest bit is zero):
; 2 byte pointer to the sample data, complete with added offset in frames
; 1 byte frames to be played (may vary depending on the offset)
; 1 byte volume 0..3 *3
; 1 byte pitch 0..8 *3
OP_NOP=$00
OP_XORA=$af
OP_RLCD=$02
OP_SBCAA=$9f
play:
di
push iy
exx
push hl
exx
ld c,(hl)
inc hl
ld b,(hl)
inc hl
ld (drumParam),bc
push hl ;put song ptr to stack
;hl acc1
;de add1
;bc sample counter
;hl' acc2
;de' add2
;b' squeeker output acc
;c' always 64
;a' phaser output bit
ld ix,0 ;ModPhase lfo's, ixh=ch1 ixl=ch2
ld hl,0 ;acc2
ld de,0 ;add2
ld b,0 ;squeker output acc
ld c,64 ;output bit mask
ld a, 64
exx
ld hl,0 ;acc1
ld de,0 ;add1
; xor a
ld a, 64
ex af,af' ;phaser output bit
playRow:
ex (sp),hl ;get song ptr, store acc1
loopRow:
ld a,(hl) ;row length and flags
inc hl
or a
jp nz,setRowLen
ld a,(hl) ;go loop
inc hl
ld h,(hl)
ld l,a
jp loopRow
setRowLen:
push af ;row length
jp p,readNotes
ld a,(hl)
inc hl
bit 0,a
jp nz,engineChange
ld c,a
jp drumCall
engineChange:
push af
push hl
ld (phaseReset1),a ;>=128 means it uses phase reset
ld (phaseReset2),a
ld hl,engineList
and $3e
add a,l
ld l,a
jr nc,$+3
inc h
ld a,(hl)
inc hl
ld h,(hl)
ld l,a
ld (engineJump),hl
pop hl
pop af
and $40
jr z,readNotes
ld c,(hl)
inc hl
drumCall:
call playDrum
readNotes:
pop af
and $7f
ld b,a ;row time*256/4 for better time resolution
ld c,0
srl b
rr c
srl b
rr c
ld a,(hl) ;ch1
inc hl
or a
jr z,skipCh1
dec a
jp nz,noteCh1
;mute ch1
ld (tt_duty1),a ;reset duty1
ld (ttev_duty1),a
ld (ttqn_duty1),a
ld (sq_duty1),a
ld (mod_mute1),a ;nop
ld (mod_alt1),a
pop de ;get acc1 off the stack
ld d,a ;reset add1
ld e,a
push de ;put acc1 back to the stack, now it is zero
jp skipCh1
noteCh1:
inc a
ld d,a
rra ;duty1 for squeeker
rra
rra
and $0e
add a,a
inc a
ld (sq_duty1),a
ld a,d
and $f0 ;duty1 for tritone
cp $80
jr nz,$+5 ;reset phase for ModPhase's non-zero W
ld ixh,$80
ld (tt_duty1),a
ld (ttev_duty1),a
ld (ttqn_duty1),a
add a,a
ld (mod_alt1),a
ld a,OP_SBCAA
ld (mod_mute1),a
jp z,noPhase1 ;phase reset
phaseReset1=$+1
ld a,0 ;
rla ;
jr nc,noPhase1 ;
ld a,d ;
and $f0 ;
sub $80 ;to keep compatibility
ex (sp),hl ;set phase
ld h,a ;
ld l,0 ;
ex (sp),hl ;
noPhase1:
ld a,d
and $0f
ld d,a ;add1 msb
ld e,(hl) ;add1 lsb
inc hl
skipCh1:
ld a,(hl) ;ch2
inc hl
or a
jr z,skipCh2
dec a
jp nz,noteCh2
;mute ch2
ld (tt_duty2),a ;reset duty2
ld (ttev_duty2),a
ld (ttln_duty2),a
ld (sq_duty2),a
ld (mod_mute2),a ;nop
exx
ld h,a ;reset acc2
ld l,a
ld d,a ;reset add2
ld e,a
exx
add a,a
ld (mod_alt2),a
jp skipCh2
noteCh2:
inc a
exx
ld d,a
rra ;duty2 for squeeker
rra
rra
and $0e
add a,a
inc a
ld (sq_duty2),a
ld a,d
and $f0 ;duty2 for tritone
cp $80
jp nz,$+5 ;reset phase for ModPhase's non-zero W
ld ixl,$80
ld (tt_duty2),a
ld (ttev_duty2),a
ld (ttln_duty2),a
ld (mod_alt2),a
ld a,OP_SBCAA
ld (mod_mute2),a
jp z,noPhase2 ;phase reset
phaseReset2=$+1
ld a,0 ;
rla ;
jr nc,noPhase2 ;
ld a,d ;
and $f0 ;
sub $80 ;to keep compatibility
ld h,a ;set phase
ld l,0 ;
noPhase2:
ld a,d
and $0f
ld d,a ;add2 msb
exx
ld a,(hl)
inc hl
exx
ld e,a ;add2 lsb
exx
skipCh2:
ex (sp),hl ;get acc1, store song ptr
engineJump=$+1
jp 0
;Engine 1: EarthShaker-alike
soundLoopES:
add hl,de ;11
jr nc,soundLoopES1S ;7/12-+
xor a ;4 |
out ($02),a ;11 |
jp soundLoopES1 ;10---+-32t
soundLoopES1S:
jp $+3 ;10 |
jp $+3 ;10---+-32t
soundLoopES1:
exx ;4
add hl,de ;11
jr nc,soundLoopES2S ;7/12
ld a,c ;4
out ($02),a ;11
jp soundLoopES2 ;10
soundLoopES2S:
jp $+3 ;10
jp $+3 ;10
soundLoopES2:
exx ;4
dec bc ;6
ld a,b ;4
or c ;4
jr nz,soundLoopES ;12=120t
; in a,($02) ;check keyboard
; cpl
; and $1f
jp playRow
jp stopPlayer
;Engine 2: Tritone-alike with two tone channels of uneven volume (33/87t)
soundLoopTT:
add hl,de ;11
ld a,h ;4
tt_duty1=$+1
cp $80 ;7
sbc a,a ;4
and 64 ;7
exx ;4
add hl,de ;11
out ($02),a ;11
ld a,h ;4
tt_duty2=$+1
cp $80 ;7
sbc a,a ;4
and 64 ;7
out ($02),a ;11
exx ;4
dec bc ;6
ld a,b ;4
or c ;4
jp nz,soundLoopTT ;10=120t
; in a,($02) ;check keyboard
; cpl
; and $1f
jp playRow
jp stopPlayer
;Engine 3: Tritone-alike with two tone channels with even volumes (mostly, 58/62t)
soundLoopTTEV:
add hl,de ;11
ld a,h ;4
ttev_duty1=$+1
cp $80 ;7
sbc a,a ;4
and 64 ;7
out ($02),a ;11
exx ;4
add hl,de ;11
ld a,h ;4
ttev_duty2=$+1
cp $80 ;7
sbc a,a ;4
and 64 ;7
exx ;4
dec bc ;6
out ($02),a ;11
ld a,b ;4
or c ;4
jp nz,soundLoopTTEV ;10=120t
; in a,($02) ;check keyboard
; cpl
; and $1f
jp playRow
jp stopPlayer
;Engine 4: Tritone-alike quiet tone channel, loud noise channel
soundLoopTTLN:
add hl,de ;11
rlc h ;8
ld a,h ;4
exx ;4
and c ;4
add hl,de ;11
out ($02),a ;11
ld a,h ;4
ttln_duty2=$+1
cp $80 ;7
sbc a,a ;4
and c ;4
out ($02),a ;11
exx ;4
ld a,r ;9 to align to 120t
dec bc ;6
ld a,b ;4
or c ;4
jp nz,soundLoopTTLN ;10=120t
; in a,($02) ;check keyboard
; cpl
; and $1f
jp playRow
jp stopPlayer
;Engine 5: Tritone-alike quiet noise channel, loud tone channel
soundLoopTTQN:
add hl,de ;11
ld a,h ;4
ttqn_duty1=$+1
cp $80 ;7
sbc a,a ;4
exx ;4
and c ;4
add hl,de ;11
out ($02),a ;11
rlc h ;8
ld a,h ;4
and c ;4
out ($02),a ;11
exx ;4
ld a,r ;9 to align to 120t
dec bc ;6
ld a,b ;4
or c ;4
jp nz,soundLoopTTQN ;10=120t
; in a,($02) ;check keyboard
; cpl
; and $1f
jp playRow
jp stopPlayer
;Engine 6: Phaser-alike, single channel, two oscillators controlled directly
soundLoopPHA:
ex af,af' ;4
add hl,de ;11
jr c,$+4 ;7/12-+
jr $+4 ;7/12 |
xor 64 ;7 -+19t
exx ;4
add hl,de ;11
jr c,$+4 ;7/12-+
jr $+4 ;7/12 |
xor 64 ;7 -+19t
out ($02),a ;11
exx ;4
ex af,af' ;4
ld a,r ;9 to align to 120t
dec bc ;6
ld a,b ;4
or c ;4
jp nz,soundLoopPHA ;10=120t
; in a,($02) ;check keyboard
; cpl
; and $1f
jp playRow
jp stopPlayer
;Engine 7: Squeeker-alike, two tone channels with duty control
soundLoopSQ:
ld a,c ;correct the loop counter for the double 8-bit counter
dec bc
inc b
ld c,a
soundLoopSQ1:
add hl,de ;11
sbc a,a ;4
sq_duty1=$+1
and 8*2 ;7 (0..7 duty*2+1)
exx ;4
add a,b ;4
ld b,a ;4
add hl,de ;11
sbc a,a ;4
sq_duty2=$+1
and 8*2 ;7
add a,b ;4
ld b,$ff ;7
add a,b ;4
sbc a,b ;4
ld b,a ;4
sbc a,a ;4
and c ;4
out ($02),a ;11
exx ;4
nop ;4
dec c ;4 double 8-bit loop counter
jp nz,soundLoopSQ1 ;10=120t
dec b ;Sqeeker-like engines are much forgiving for floating loop times,
jp nz,soundLoopSQ1 ;so this is an acceptable compromise to fit the average loop time into 120t
; in a,($02) ;check keyboard
; cpl
; and $1f
jp playRow
jp stopPlayer
;Engine 8: CrossPhase, another PWM modulation engine similar to Phaser1, single channel, two oscillators controlled directly
soundLoopCPA:
add hl,de ;11
ld a,h ;4
exx ;4
add hl,de ;11
cp h ;4
exx ;4
sbc a,a ;4
and 64 ;7
out ($02),a ;11
jr $+2 ;12
jr $+2 ;12
jr $+2 ;12
dec bc ;6
ld a,b ;4
or c ;4
jp nz,soundLoopCPA ;10=120t
; in a,($02) ;check keyboard
; cpl
; and $1f
jp playRow
jp stopPlayer
;Engine 9: ModPhase, PWM modulation engine, two tone channels of uneven volume with a mod alteration control
soundLoopMOD:
ld a,c ;correct the loop counter for the double 8-bit counter
dec bc
inc b
ld c,a
soundLoopMOD1:
add hl,de ;11
ld a,h ;4
mod_alt1=$+1
xor 0 ;7
cp ixh ;8
mod_mute1=$
sbc a,a ;4
exx ;4
add hl,de ;11
out ($02),a ;11
ld a,h ;4
mod_alt2=$+1
xor 0 ;7
cp ixl ;8
mod_mute2=$
sbc a,a ;4
out ($02),a ;11
exx ;4
nop ;4
nop ;4
dec c ;4 double 8-bit loop counter
jp nz,soundLoopMOD1 ;10=120t
inc ixh
inc ixl
dec b
jp nz,soundLoopMOD1
; in a,($02) ;check keyboard
; cpl
; and $1f
jp playRow
jp stopPlayer
stopPlayer:
pop hl ;song pointer/acc1 word, not needed anymore
pop hl ;restore HL'
exx
pop iy
ei
ret
engineList:
;engines 1,6,8 use the W column/top bits for phase reset, all others use it as duty cycle
dw soundLoopES ;1 EarthShaker-alike
dw soundLoopTT ;2 Tritone-alike with uneven volumes
dw soundLoopTTEV ;3 Tritone-alike with equal volumes
dw soundLoopTTLN ;4 Tritone-alike with quiet tone channel, loud noise channel
dw soundLoopTTQN ;5 Tritone-alike with quiet noise channel, loud tone channel
dw soundLoopPHA ;6 Phaser-alike (single channel)
dw soundLoopSQ ;7 Squeeker-alike
dw soundLoopCPA ;8 CrossPhase
dw soundLoopMOD ;9 ModPhase
;C=drum param number
playDrum:
push de
push hl
ld b,0
ld h,b
ld l,c
srl c
add hl,hl ;C already *2, another *2
add hl,bc ;+1 to have *5
drumParam=$+1
ld bc,0
add hl,bc
ld a,(hl) ;drum sample pointer, complete with precalculated offset
ld (drumPtr+0),a
inc hl
ld a,(hl)
ld (drumPtr+1),a
inc hl
ld a,(hl) ;frames to be played
ld (drumFrames),a
inc hl
ld a,(hl) ;volume*3
ld (drumVolume),a
inc hl
ld a,(hl) ;pitch*8
ld (drumPitch),a
drumVolume=$+1
ld a,0
ld hl,volTable
add a,l
ld l,a
jr nc,$+3
inc h
ld a,(hl)
inc hl
ld (drumVol01),a
ld (drumVol11),a
ld (drumVol21),a
ld (drumVol31),a
ld (drumVol41),a
ld (drumVol51),a
ld (drumVol61),a
ld (drumVol71),a
ld a,(hl)
inc hl
ld (drumVol02),a
ld (drumVol12),a
ld (drumVol22),a
ld (drumVol32),a
ld (drumVol42),a
ld (drumVol52),a
ld (drumVol62),a
ld (drumVol72),a
ld a,(hl)
ld (drumVol03),a
ld (drumVol13),a
ld (drumVol23),a
ld (drumVol33),a
ld (drumVol43),a
ld (drumVol53),a
ld (drumVol63),a
ld (drumVol73),a
drumPitch=$+1
ld a,0
ld hl,pitchTable
add a,l
ld l,a
jr nc,$+3
inc h
ld a,(hl)
inc hl
ld (drumShift0),a
ld a,(hl)
inc hl
ld (drumShift1),a
ld a,(hl)
inc hl
ld (drumShift2),a
ld a,(hl)
inc hl
ld (drumShift3),a
ld a,(hl)
inc hl
ld (drumShift4),a
ld a,(hl)
inc hl
ld (drumShift5),a
ld a,(hl)
inc hl
ld (drumShift6),a
ld a,(hl)
ld (drumShift7),a
drumPtr=$+1
ld hl,0
drumFrames=$+1
ld b,0
ld c,0
ld d,1
drumLoop:
;bit 0
ld a,(hl) ;7
and d ;4
jr nz,$+4 ;7/12-+
jr z,$+4 ;7/12 |
ld a,64 ;7 -+19t
out ($02),a ;11
drumVol01=$
nop ;4
out ($02),a ;11
drumVol02=$
nop ;4
out ($02),a ;11
drumShift0=$+1
rlc d ;8
nop ;4
drumVol03=$
nop ;4
out ($02),a ;11
nop ;4
nop ;4
dec c ;4
jp $+3 ;10=120t
;bit 1
ld a,(hl) ;7
and d ;4
jr nz,$+4 ;7/12-+
jr z,$+4 ;7/12 |
ld a,64 ;7 -+19t
out ($02),a ;11
drumVol11=$
nop ;4
out ($02),a ;11
drumVol12=$
nop ;4
out ($02),a ;11
drumShift1=$+1
rlc d ;8
nop ;4
drumVol13=$
nop ;4
out ($02),a ;11
nop ;4
nop ;4
dec c ;4
jp $+3 ;10=120t
;bit 2
ld a,(hl) ;7
and d ;4
jr nz,$+4 ;7/12-+
jr z,$+4 ;7/12 |
ld a,64 ;7 -+19t
out ($02),a ;11
drumVol21=$
nop ;4
out ($02),a ;11
drumVol22=$
nop ;4
out ($02),a ;11
drumShift2=$+1
rlc d ;8
nop ;4
drumVol23=$
nop ;4
out ($02),a ;11
nop ;4
nop ;4
dec c ;4
jp $+3 ;10=120t
;bit 3
ld a,(hl) ;7
and d ;4
jr nz,$+4 ;7/12-+
jr z,$+4 ;7/12 |
ld a,64 ;7 -+19t
out ($02),a ;11
drumVol31=$
nop ;4
out ($02),a ;11
drumVol32=$
nop ;4
out ($02),a ;11
drumShift3=$+1
rlc d ;8
nop ;4
drumVol33=$
nop ;4
out ($02),a ;11
nop ;4
nop ;4
dec c ;4
jp $+3 ;10=120t
;bit 4
ld a,(hl) ;7
and d ;4
jr nz,$+4 ;7/12-+
jr z,$+4 ;7/12 |
ld a,64 ;7 -+19t
out ($02),a ;11