-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRAGE_DEMO.asm
1402 lines (1343 loc) · 14.8 KB
/
RAGE_DEMO.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
;Pytha Beeper Engine
;by utz 06'2017 * www.irrlichtproject.de
;2 channels of tone, triangle/rectangle/saw/noise waveforms
USE_LOOP equ 1
USE_DRUMS equ 1
;include "equates.h"
loop_point_patch equ $8023
noise equ $1237
rest equ $0
c0 equ $83
cis0 equ $8a
d0 equ $93
dis0 equ $9b
e0 equ $a4
f0 equ $ae
fis0 equ $b9
g0 equ $c4
gis0 equ $cf
a0 equ $dc
ais0 equ $e9
b0 equ $f6
c1 equ $105
cis1 equ $115
d1 equ $125
dis1 equ $136
e1 equ $149
f1 equ $15c
fis1 equ $171
g1 equ $187
gis1 equ $19e
a1 equ $1b7
ais1 equ $1d1
b1 equ $1ed
c2 equ $20a
cis2 equ $229
d2 equ $24a
dis2 equ $26d
e2 equ $292
f2 equ $2b9
fis2 equ $2e2
g2 equ $30e
gis2 equ $33d
a2 equ $36e
ais2 equ $3a2
b2 equ $3da
c3 equ $414
cis3 equ $452
d3 equ $494
dis3 equ $4da
e3 equ $524
f3 equ $572
fis3 equ $5c5
g3 equ $61c
gis3 equ $679
a3 equ $6dc
ais3 equ $744
b3 equ $7b3
c4 equ $828
cis4 equ $8a4
d4 equ $928
dis4 equ $9b3
e4 equ $a47
f4 equ $ae4
fis4 equ $b89
g4 equ $c39
gis4 equ $cf3
a4 equ $db8
ais4 equ $e89
b4 equ $f66
c5 equ $1051
cis5 equ $1149
d5 equ $1250
dis5 equ $1367
e5 equ $148e
f5 equ $15c7
fis5 equ $1713
g5 equ $1872
gis5 equ $19e6
a5 equ $1b70
ais5 equ $1d12
b5 equ $1ecc
c6 equ $20a1
cis6 equ $2292
d6 equ $24a0
dis6 equ $26ce
e6 equ $291c
f6 equ $2b8e
fis6 equ $2e25
g6 equ $30e4
gis6 equ $33cc
a6 equ $36e0
ais6 equ $3a24
b6 equ $3d99
c7 equ $4142
cis7 equ $4524
d7 equ $4940
dis7 equ $4d9b
e7 equ $5239
f7 equ $571c
fis7 equ $5c4b
g7 equ $61c7
gis7 equ $6798
a7 equ $6dc1
org $100
di
ld c,$02
exx
push hl ;preserve HL' for return to BASIC
ld (oldSP),sp
ld hl,music_data
ld e,(hl) ;extra addition, read loop point
inc hl
ld d,(hl)
inc hl
ld (mloop),de
ld (seqpntr),hl
ld ixl,0 ;timer lo
ld c,02
;*******************************************************************************
read_seq
seqpntr equ $+1
ld sp,0
xor a
pop iy
or iyh
ld (seqpntr),sp
jr nz,read_ptn0
IF USE_LOOP = 1
mloop equ $+1
ld sp,mloop ;get loop point
jr read_seq+3
ENDIF
;*******************************************************************************
exit
oldSP equ $+1
ld sp,0
pop hl
exx
ei
ret
;*******************************************************************************
read_ptn0
ld sp,iy ;set pattern pointer
read_ptn
; in a,($fe) ;read kbd
; cpl
; and $1f
; jr nz,exit
pop af ;flags|speed
jp m,read_seq
ld ixh,a ;speed
IF USE_DRUMS = 1
jp pe,drum
ENDIF
drum_return
jr z,no_ch1_reload
ex af,af' ;load data ch1
pop af
jr c,note_only_ch1
ld b,a ;offset
ld hl,0
ld a,h
jr nz,set_mod_ch1 ;if Z then disable modulator
ld a,4 ;inc b
set_mod_ch1
ld (mod_enable1),a
jp po,set_noise1
ld hl,$04cb ;rlc h = noise enable
set_noise1
ld (noise1),hl
pop hl ;waveform
ld (waveform1),hl
note_only_ch1
ld hl,0
pop de ;freq divider
ex af,af'
no_ch1_reload
exx
jr c,no_ch2_reload
pop af ;load data ch2
jr c,note_only_ch2
ld b,a ;offset
ld hl,0
ld a,h
jr nz,set_mod_ch2 ;if Z then disable modulator
ld a,4 ;inc b
set_mod_ch2
ld (mod_enable2),a
jp po,set_noise2
ld hl,$04cb ;rlc h = noise enable
set_noise2
ld (noise2),hl
pop hl ;waveform
ld (waveform2),hl
note_only_ch2
ld hl,0
pop de ;freq divider
no_ch2_reload
;*******************************************************************************
;TODO update release with new (correct) timing, update equates.h, update demo song
sound_loop
exx ;4
add hl,de ;11 ;ch1 accu
ld a,h ;4
add a,b ;4 ;apply modulator
or h ;4
rlca ;4
waveform1
sbc a,a ;4 ;replace with rrca for saw wave
xor h ;4 ;replace with nop for saw/square wave
rrca ;4
out ($2),a ;11__64
rrca ;4
out (c),a ;12__16
noise1
ds 2 ;8 ;noise w/ rlc h
rrca ;4
nop ;4
exx ;4
out (c),a ;12__32
_ch2
add hl,de ;11 ;ch2 accu
ld a,h ;4
add a,b ;4 ;apply modulator
or h ;4
ret c ;5 ;timing
rlca ;4
waveform2
sbc a,a ;4 ;replace with rrca for saw wave
xor h ;4 ;replace with nop for saw/square wave
rrca ;4
out ($2),a ;12__64
rrca ;4
out (c),a ;12__16
noise2
ds 2 ;8 ;noise w/ rlc h
rrca ;4
dec ixl ;8
out (c),a ;12__32
jp nz,sound_loop ;10
;216
mod_enable2
inc b ;replace this with nop to disable modulation
exx
mod_enable1
inc b ;replace this with nop to disable modulation
exx
dec ixh
jp nz,sound_loop
exx
jp read_ptn
;*******************************************************************************
IF USE_DRUMS = 1
drum
ex af,af'
ld (deRest),de
ld (hlRest),hl
ld (bcRest),bc
pop de
ld a,d
rlca
jr c,drum2
drum1 ;kick,
ld d,a ;D = start pitch
ld a,e
ld (slideSpeed),a
ld e,0
ld h,e
ld l,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
; and $ff ;border
out (2),a
djnz xlllp
dec c
jr nz,xlllp
;45680 (/224 = 203.9)
ld ixl,$34 ;correct speed offset
drum_end
deRest equ $+1
ld de,0
hlRest equ $+1
ld hl,0
bcRest equ $+1
ld bc,0
ex af,af'
jp drum_return
drum2 ;noise
rlca
ld a,e
ld (dvol),a
ld hl,1 ;$1 (snare) <- 1011 -> $1237 (hat)
jr z,d2init
ld hl,$1237
d2init
ld bc,$ff03 ;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
; and $ff ;7 ;border
out ($2),a ;11
djnz sloop ;13/7 : 65 * 256 * B : B=3 -> 49920 (/224 = 222.8)
dec c ;4
jr nz,sloop ;12 : (16 - 6) * B : B=3 -> +30
; +load/wrap
;49903 w/ b=$ff (/224 = 222.8)
ld ixl,$21 ;correct speed offset
jr drum_end
ENDIF
;*******************************************************************************
;*******************************************************************************
music_data
musicData
dw .sequence
db 1
dw 2
db 0
db 0
dw 1
db 128
db 0
dw 2
db 128
db 0
dw 1
db 0
db 0
dw 0
db 2
db 1
dw 2
db 0
db 0
dw 1
db 8
db 0
dw 0
db 8
.sequence
db $fd,0
db 137
db 20
db 149
db 20
db 137
db 20
db 149
db 20
db 137
db 20
db 149
db 20
db 137
db 20
db 149
db 20
db 133
db 20
db 145
db 20
db 133
db 20
db 145
db 20
db 135
db 20
db 147
db 20
db 135
db 20
db 147
db 20
db 137
db 20
db 149
db 20
db 137
db 20
db 149
db 20
db 137
db 20
db 149
db 20
db 137
db 20
db 149
db 20
db 133
db 20
db 145
db 20
db 133
db 20
db 145
db 20
db 135
db 20
db 147
db 20
db 135
db 20
db 147
db 16
db 118
db $fe
db 1
db 118
db 137
db 16
db 120
db 149
db 16
db 118
db 137
db 16
db 120
db 149
db 16
db 118
db 137
db 16
db 120
db 149
db 16
db 118
db 137
db 16
db 120
db 149
db 16
db 118
db 133
db 16
db 120
db 145
db 16
db 118
db 133
db 16
db 120
db 145
db 16
db 118
db 135
db 16
db 120
db 147
db 16
db 118
db 135
db 16
db 120
db 147
db 16
db 118
db 137
db 16
db 120
db 149
db 16
db 118
db 137
db 16
db 120
db 149
db 16
db 118
db 137
db 16
db 120
db 149
db 16
db 118
db 137
db 16
db 120
db 149
db 16
db 118
db 133
db 16
db 120
db 145
db 16
db 118
db 133
db 16
db 120
db 145
db 16
db 118
db 135
db 12
db 122
db $fe
db 1
db 122
db 147
db 16
db 123
db 135
db 16
db 124
db 147
db 16
db 118
db $fd,2
db 216
db 201
db 16
db 121
db 156
db 213
db 16
db 125
db $fc
db 201
db 16
db 121
db 156
db 213
db 16
db 118
db $fc
db 201
db 16
db 121
db 156
db 213
db 16
db 125
db 154
db 201
db 16
db 121
db 152
db 213
db 16
db 118
db $fc
db 197
db 16
db 121
db $fe
db 209
db 16
db 125
db $fe
db 197
db 16
db 121
db $fe
db 209
db 16
db 118
db $fd,0
db 156
db 199
db 16
db 121
db 154
db 211
db 16
db 125
db $fd,8
db 144
db 199
db 16
db 121
db 142
db 211
db 16
db 118
db $fd,4
db 228
db 201
db 16
db 121
db 168
db 213
db 16
db 125
db $fc
db 201
db 16
db 121
db 168
db 213
db 16
db 118
db $fc
db 201
db 16
db 121
db 168
db 213
db 16
db 125
db 166
db 201
db 16
db 121
db 164
db 213
db 16
db 118
db $fc
db 197
db 16
db 121
db $fe
db 209
db 16
db 125
db $fe
db 197
db 16
db 121
db $fe
db 209
db 16
db 118
db $fd,6
db 220
db 199
db 16
db 119
db $fd,8
db 144
db 211
db 16
db 125
db $fd,6
db 159
db 199
db 16
db 119
db $fd,8
db 147
db 211
db 16
db 118
db $fd,2
db 216
db 201
db 16
db 121
db 156
db 213
db 16
db 125
db $fc
db 201
db 16
db 121
db 156
db 213
db 16
db 118
db $fc
db 201
db 16
db 121
db 156
db 213
db 16
db 125
db 154
db 201
db 16
db 121
db 152
db 213
db 16
db 118
db $fc
db 197
db 16
db 121
db $fe
db 209
db 16
db 125
db $fe
db 197
db 16
db 121
db $fe
db 209
db 16
db 118
db $fd,0
db 156
db 199
db 16
db 121
db 154
db 211
db 16
db 125
db $fd,8
db 144
db 199
db 16
db 121
db 142
db 211
db 16
db 118
db $fd,4
db 228
db 201
db 16
db 121
db 168
db 213
db 16
db 125
db $fc
db 201
db 16
db 121
db 168
db 213
db 16
db 118
db $fc
db 201
db 16
db 121
db 168
db 213
db 16
db 125
db 166
db 201
db 16
db 121
db 164
db 213
db 16
db 118
db $fc
db 197
db 16
db 121
db $fd,14
db 220
db 209
db 16
db 125
db 154
db 197
db 16
db 121
db 152
db 209
db 12
db 119
db $fe
db 1
db 119
db $fd,12
db 208
db 211
db 16
db 120
db $fe
db 16
db 125
db 147
db 215
db 16
db 120
db $fe
db 16
db 118
db 152
db 201
db 16
db 120
db $fe
db 213
db 16
db 118
db $fe
db 201
db 16
db 120
db $fe
db 213
db 16
db 118
db $fe
db 201
db 16
db 120
db $fe
db 213
db 16
db 118
db $fe
db 201
db 16
db 120
db $fe
db 213
db 16
db 118
db $fe
db 201
db 16
db 120
db $fe
db 213
db 16
db 118
db $fe
db 201
db 16
db 120
db $fe
db 213
db 16
db 118
db $fe
db 201
db 16
db 120
db $fe
db 213
db 16
db 118
db 154
db 201
db 16
db 120
db 151
db 213
db 16
db 118
db $fe
db 199
db 16
db 120
db $fe
db 211
db 16
db 118
db $fe
db 199
db 16
db 120
db $fe
db 211
db 16
db 118
db $fe
db 199
db 16
db 120
db $fe
db 211
db 16
db 118
db 147
db 199
db 16
db 120
db 151
db 211
db 16
db 118
db $fe
db 199
db 16
db 120
db $fe
db 211
db 16
db 118
db $fe
db 199
db 16
db 120
db $fe
db 211
db 16
db 118
db $fe
db 199
db 16
db 120
db $fe
db 211
db 16
db 118
db 215
db 199
db 16
db 118
db $fe
db 211
db 16
db 118
db 149
db 197
db 16
db 120
db $fe
db 209
db 16
db 118
db $fe
db 197
db 16
db 120
db $fe
db 209
db 16
db 118
db $fe
db 197
db 16