-
Notifications
You must be signed in to change notification settings - Fork 0
/
falling.asm
2964 lines (2821 loc) · 42.4 KB
/
falling.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
output "falling.com"
org $100
wave1 equ 0
wave2 equ $800
wave3 equ $1000
wave4 equ $1800
wave5 equ $2000
wave6 equ $2800
wave7 equ $3000
wave8 equ $3800
wave9 equ $4000
wave10 equ $4800
wave11 equ $5000
wave12 equ $5800
wave13 equ $6000
wave14 equ $6800
wave15 equ $7000
wave16 equ $7800
wave17 equ $8000
wave18 equ $8800
wave19 equ $9000
wave20 equ $9800
wave21 equ $a000
wave22 equ $a800
wave23 equ $b000
wave24 equ $b800
wave25 equ $c000
wave26 equ $c800
wave27 equ $d000
wave28 equ $d800
wave29 equ $e000
wave30 equ $e800
wave31 equ $f000
wave32 equ $f800
kick equ $1
hhat equ $40
rest equ 0
noise equ $75
a0 equ $17
ais0 equ $19
b0 equ $1a
c1 equ $1c
cis1 equ $1d
d1 equ $1f
dis1 equ $21
e1 equ $23
f1 equ $25
fis1 equ $27
g1 equ $2a
gis1 equ $2c
a1 equ $2f
ais1 equ $32
b1 equ $34
c2 equ $38
cis2 equ $3b
d2 equ $3e
dis2 equ $42
e2 equ $46
f2 equ $4a
fis2 equ $4f
g2 equ $53
gis2 equ $58
a2 equ $5d
ais2 equ $63
b2 equ $69
c3 equ $6f
cis3 equ $76
d3 equ $7d
dis3 equ $84
e3 equ $8c
f3 equ $94
fis3 equ $9d
g3 equ $a7
gis3 equ $b0
a3 equ $bb
ais3 equ $c6
b3 equ $d2
c4 equ $de
cis4 equ $ec
d4 equ $fa
dis4 equ $108
e4 equ $118
f4 equ $129
fis4 equ $13a
g4 equ $14d
gis4 equ $161
a4 equ $176
ais4 equ $18c
b4 equ $1a4
c5 equ $1bd
cis5 equ $1d7
d5 equ $1f3
dis5 equ $211
e5 equ $230
f5 equ $252
fis5 equ $275
g5 equ $29a
gis5 equ $2c2
a5 equ $2ec
ais5 equ $318
b5 equ $348
c6 equ $379
cis6 equ $3ae
d6 equ $3e6
dis6 equ $422
e6 equ $461
f6 equ $4a3
fis6 equ $4ea
g6 equ $535
gis6 equ $584
a6 equ $5d8
ais6 equ $631
b6 equ $68f
c7 equ $6f3
cis7 equ $75d
d7 equ $7cd
;test code
begin
ld hl,music_data
call play
ret
;wtbeep 0.1
;experimental beeper engine for ZX Spectrum
;by utz 11'2016 * www.irrlichtproject.de
play
di
ld e,(hl)
inc hl
ld d,(hl)
inc hl
ld (mLoopVar),de
ld (seqpntr),hl
exx
ld c,0 ;timer lo
push hl ;preserve HL' for return to BASIC
ld (oldSP),sp
ld ix,0
ld iy,0
;*******************************************************************************
rdseq
seqpntr equ $+1
ld sp,0
xor a
pop de ;pattern pointer to DE
or d
ld (seqpntr),sp
jr nz,rdptn0
mLoopVar equ $+1
ld sp,0 ;get loop point ;comment out to disable looping
jr rdseq+3 ;comment out to disable looping
;*******************************************************************************
exit
oldSP equ $+1
ld sp,0
pop hl
exx
ei
ret
;*******************************************************************************
rdptn0
ld (ptnpntr),de
readPtn
; in a,($fe) ;read kbd
; cpl
; and $1f
; jr nz,exit
ptnpntr equ $+1
ld sp,0
;jr $
pop af ;timer + ctrl
jr z,rdseq
ld b,a ;timer ($ ticks)
jr c,_noUpd1
ex af,af'
ld h,mixAlgo/256
pop de
ld a,d
and $f8
ld l,a
ld a,(hl)
ld (algo1),a
inc l
ld a,(hl)
ld (algo1+1),a
inc l
ld a,(hl)
ld (algo1+2),a
inc l
ld a,(hl)
ld (algo1+3),a
inc l
ld a,(hl)
ld (algo1+4),a
ld hl,0
ld a,d
and $7
ld d,a
ex af,af'
_noUpd1
jp pe,_noUpd2
exx
ex af,af'
ld h,mixAlgo/256
pop bc
ld a,b
and $f8
ld l,a
ld a,(hl)
ld (algo2),a
inc l
ld a,(hl)
ld (algo2+1),a
inc l
ld a,(hl)
ld (algo2+2),a
inc l
ld a,(hl)
ld (algo2+3),a
inc l
ld a,(hl)
ld (algo2+4),a
ld hl,0
ld a,b
and $7
ld b,a
ex af,af'
exx
_noUpd2
jp m,_noUpd3
exx
pop de
ld a,d
ex af,af'
ld a,d
and $7
ld d,a
ld (fdiv3),de
ex af,af'
and $f8
ld e,a
ld d,mixAlgo/256
ld a,(de)
ld (algo3),a
inc e
ld a,(de)
ld (algo3+1),a
inc e
ld a,(de)
ld (algo3+2),a
inc e
ld a,(de)
ld (algo3+3),a
inc e
ld a,(de)
ld (algo3+4),a
ld de,0
exx
_noUpd3
pop af
jp po,_noSweepReset
ld iy,0 ;reset sweep registers
ld ixh,0
_noSweepReset
jp c,drum1
jr z,drum2
dec sp
drumRet
ld (ptnpntr),sp
fdiv3 equ $+1
ld sp,0
;*******************************************************************************
playNote
add hl,de ;11
ld a,h ;4
algo1
ds 5 ;20
sla a
sla a
; out ($fe),a ;11___64
; and 33
; ld ($6800), a
and 64 ; microbee
OUT (2),A ; microbee
exx ;4
add hl,bc ;11
ld a,h ;4
algo2
ds 5 ;20
; inc bc ;6 ;timing
; out ($fe),a ;11___56
; and 33
sla a
sla a
; ld ($6800), a
and 64 ; microbee
OUT (2),A ; microbee
ex de,hl ;4
add hl,sp ;11
ld a,h ;4
algo3
ds 5 ;20
; nop ;4 ;timing
; nop ;4
ex de,hl ;4
; out ($fe),a ;11___64
; and 33
sla a
sla a
; ld ($6800), a
and 64 ; microbee
OUT (2),A ; microbee
exx ;4
dec c ;4
jp nz,playNote ;10
;184
inc iyl ;update sweep counters
ld a,iyl
rrca
rrca
ld iyh,a
rrca
ld ixh,a
dec b
jp nz,playNote
jp readPtn
;*******************************************************************************
drum2 ;noise
ld (hlRest),hl
ld (bcRest),bc
ld b,a
ex af,af'
ld a,b
ld hl,1 ;$1 (snare) <- 1011 -> $1237 (hat)
rrca
jr c,setVol
ld hl,$1237
setVol
and $7f
ld (dvol),a
ld bc,$a803 ;length
sloop
add hl,hl ;11
sbc a,a ;4
xor l ;4
ld l,a ;4
dvol equ $+1
cp $80 ;7 ;volume
sbc a,a ;4
; or $7 ;7 ;border
; out ($fe),a ;11
; and 33
sla a
sla a
and 64 ; microbee
OUT (2),A ; microbee
; ld ($6800), a
djnz sloop ;13/8
dec c ;4
jr nz,sloop ;12
jr drumEnd
drum1 ;kick
ld (deRest),de
ld (bcRest),bc
ld (hlRest),hl
ld d,a ;A = start_pitch<<1
ld e,0 ;B = 0
ld h,e
ld l,e
ex af,af'
srl d ;set start pitch
rl e
ld c,$3 ;length
xlllp
add hl,de
jr c,_noUpd
ld a,e
_slideSpeed equ $+1
sub $10 ;speed
ld e,a
sbc a,a
add a,d
ld d,a
_noUpd
ld a,h
; or $7 ;border
; and 33
sla a
sla a
and 64 ; microbee
OUT (2),A ; microbee
; ld ($6800), a
; out ($fe),a
djnz xlllp
dec c
jr nz,xlllp
;45680 (/224 = 248.3)
deRest equ $+1
ld de,0
drumEnd
hlRest equ $+1
ld hl,0
bcRest equ $+1
ld bc,0
ld c,6 ;adjust timer
jp drumRet
;*******************************************************************************
align 256
mixAlgo
ds 8 ;00 50% square
daa ;02 32% square
and h
ds 6
rlca ;01 25% square
and h
ds 6
daa ;03 19% square
cpl
and h
ds 5
inc a ;04 12.5% square
inc a
xor h
rrca
ds 4
inc a ;05 6.25% square
xor h
rrca
ds 5
add a,iyl ;06 duty sweep (fast) (cpl, dec a is not needed, but makes for a nicer attack env)
cpl
dec a
or h
ds 3
add a,iyh ;07 duty sweep (slow)
cpl
dec a
or h
ds 3
add a,ixh ;08 duty sweep (very slow, start lo)
cpl
dec a
and h
ds 3
add a,ixh ;09 duty sweep (very slow, start hi)
and h
ds 5
add a,iyh ;0a duty sweep (slow) + oct
rlca
xor h
ds 4
add a,iyh ;0b duty sweep (slow) - oct
rrca
xor h
ds 4
add a,iyl ;0c duty sweep (fast) - oct
rrca
xor h
ds 4
daa ;0d vowel 1
rlca
cpl
xor h
ds 4
daa ;0e vowel 2
rlca
rlca
cpl
xor h
ds 3
daa ;0f vowel 3
cpl
xor h
ds 5
rrca ;10 vowel 4
rrca
sbc a,a
and h
rlca
ds 3
rlca ;11 vowel 5
rlca
xor h
rlca
ds 4
rrca ;12 vowel 6
sbc a,a
and h
rlca
ds 4
cpl ;13 rasp 1
daa
sbc a,a
rlca
and h
ds 3
rlca ;14 rasp 2
rlca
sbc a,a
and h
ds 4
daa ;15 phat rasp
rrca
rrca
cpl
or h
ds 3
daa ;16 phat 2
rrca
rrca
cpl
and h
ds 3
daa ;17 phat 3
rlca
rlca
cpl
and h
ds 3
daa ;18 phat 4
rlca
cpl
and h
ds 4
daa ;19 phat 5
rrca
rrca
cpl
xor h
ds 3
cpl ;1a phat 6
daa
sbc a,a
rlca
xor h
ds 3
rlca ;1b phat 7
rlca
sbc a,a
and h
rlca
ds 3
rlc h ;1c noise 1
and h
ds 5
rlc h ;1e noise 2
sbc a,a
or h
ds 4
rlc h ;1d noise 3
ds 6
rlc h ;1f noise 4
or h
xor l
ds 5
align 256
;compiled music data
music_data
dw .loop
dw .pattern1
.loop:
dw .pattern2
dw 0
.pattern1
dw #500,#382f,#0,#0,#701
dw #585
db 0
dw #584,#388d
db 0
dw #585
db 0
dw #584,#382f
db 0
dw #585
db 0
dw #505,#288d
db 0
dw #585
db 0
dw #504,#3870,#2800,#701
dw #585
db 0
dw #585
db 0
dw #585
db 0
dw #504,#382f,#2870
db 0
dw #585
db 0
dw #504,#3870,#2800
db 0
dw #585
db 0
dw #585,#701
dw #585
db 0
dw #504,#382f,#2870
db 0
dw #585
db 0
dw #504,#3870,#2800
db 0
dw #585
db 0
dw #584,#382f
db 0
dw #585
db 0
dw #504,#386a,#2870,#701
dw #585
db 0
dw #504,#382f,#2800
db 0
dw #585
db 0
dw #504,#3870,#286a
db 0
dw #585
db 0
dw #505,#2800
db 0
dw #585
db 0
dw #504,#3025,#2870,#701
dw #585
db 0
dw #504,#308d,#2800
db 0
dw #585
db 0
dw #584,#3025
db 0
dw #585
db 0
dw #505,#288d
db 0
dw #585
db 0
dw #504,#3070,#2800,#701
dw #585
db 0
dw #585
db 0
dw #585
db 0
dw #504,#3025,#2870
db 0
dw #585
db 0
dw #504,#3070,#2800
db 0
dw #585
db 0
dw #585,#701
dw #585
db 0
dw #504,#3025,#2870
db 0
dw #585
db 0
dw #504,#306a,#2800
db 0
dw #585
db 0
dw #584,#3070
db 0
dw #585
db 0
dw #505,#286a,#701
dw #585
db 0
dw #504,#3025,#2870
db 0
dw #585
db 0
dw #505,#2800
db 0
dw #585
db 0
dw #585
db 0
dw #585
db 0
dw #584,#301f,#701
dw #585
db 0
dw #584,#308d
db 0
dw #585
db 0
dw #584,#301f
db 0
dw #585
db 0
dw #505,#288d
db 0
dw #585
db 0
dw #504,#3070,#2800,#701
dw #585
db 0
dw #585
db 0
dw #585
db 0
dw #504,#301f,#2870
db 0
dw #585
db 0
dw #504,#3070,#2800
db 0
dw #585
db 0
dw #585,#701
dw #585
db 0
dw #504,#301f,#2870
db 0
dw #585
db 0
dw #504,#3070,#2800
db 0
dw #585
db 0
dw #584,#301f
db 0
dw #585
db 0
dw #504,#306a,#2870,#701
dw #585
db 0
dw #504,#301f,#2800
db 0
dw #585
db 0
dw #504,#3070,#286a
db 0
dw #585
db 0
dw #505,#2800
db 0
dw #585
db 0
dw #504,#3025,#2870,#701
dw #585
db 0
dw #504,#3070,#2800
db 0
dw #585
db 0
dw #584,#3025
db 0
dw #585
db 0
dw #505,#2870
db 0
dw #585
db 0
dw #504,#306a,#2800,#701
dw #585
db 0
dw #585
db 0
dw #585
db 0
dw #504,#3070,#286a
db 0
dw #585
db 0
dw #505,#2800
db 0
dw #585
db 0
dw #504,#302a,#2870,#701
dw #585
db 0
dw #504,#3070,#2800
db 0
dw #585
db 0
dw #584,#302a
db 0
dw #585
db 0
dw #505,#2870
db 0
dw #585
db 0
dw #500,#306a,#3854,#2800,#8140
dw #581,#383f
db 0
dw #581,#3835,#8140
dw #581,#382f
db 0
dw #500,#3070,#382a,#286a,#8140
dw #581,#381f
db 0
dw #501,#381a,#2800,#8140
dw #581,#3817
db 0
dw #580,#382f,#382f,#501
dw #581,#3800
db 0
dw #580,#388d,#382f
db 0
dw #581,#3800
db 0
dw #580,#382f,#382f,#c40
dw #581,#3800
db 0
dw #501,#382f,#288d,#c40
dw #581,#3800
db 0
dw #500,#3870,#382f,#2800,#205
dw #581,#3800
db 0
dw #581,#382f
db 0
dw #581,#3800
db 0
dw #500,#382f,#382f,#2870,#c40
dw #581,#3800
db 0
dw #500,#3870,#382f,#2800,#c40
dw #581,#3800
db 0
dw #581,#382f,#c40
dw #581,#3800
db 0
dw #500,#382f,#382f,#2870
db 0
dw #581,#3800
db 0
dw #500,#3870,#382f,#2800,#501
dw #581,#3800
db 0
dw #580,#382f,#382f,#c40
dw #581,#3800
db 0
dw #500,#386a,#382f,#2870,#205
dw #581,#3800
db 0
dw #500,#382f,#382f,#2800
db 0
dw #581,#3800
db 0
dw #500,#3870,#382f,#286a,#c40
dw #581,#3800
db 0
dw #501,#382f,#2800,#c40
dw #581,#3800
db 0
dw #500,#3025,#3825,#2870,#501
dw #581,#3800
db 0
dw #500,#308d,#3825,#2800
db 0