-
Notifications
You must be signed in to change notification settings - Fork 1
/
sfx.asm
106 lines (90 loc) · 1.38 KB
/
sfx.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
;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
;
.module SFX
initsfx:
call framesync
call mute_ay
ld hl,AFXFRAME
ld (irqsnd),hl
ld hl,soundbank
call INIT_AFX
ret
; haha this is cheeky.
;
longplay:
ld (droneframe),a ; prevent drone from taking over for the duration of this effect
ld a,b
jp AFXPLAYON3
initdrone:
ld a,(level) ; level is 0..7 incl
rlca
rlca ; 0 .. 16
ld b,a
ld a,40 ; 40 .. 24
sub b
ld (dronerate),a
xor a
ld (dronetype),a
ld (droneframe),a
ret
drone:
ld a,(droneframe)
and a
jr z,_dronetime
dec a
ld (droneframe),a
ret
_dronetime:
ld a,(dronerate)
ld (droneframe),a
ld a,(dronetype)
xor 1
ld (dronetype),a
add a,15
jp AFXPLAYON3
droneframe:
.byte 0
dronerate:
.byte 0
dronetype:
.byte 0
resettone:
ld hl,newtone+15
ld de,newtone
ld bc,15
ldir
ret
generatetone:
push af
dec a ; effect number in A
call updatetone
ld h,0
ld l,a
add hl,hl
ld bc,soundbank+1
add hl,bc
ld c,(hl)
inc hl
ld b,(hl)
add hl,bc ;the effect address is obtained in hl
ld de,newtone
ex de,hl
ld bc,15
ldir
pop af
jp AFXPLAY
updatetone:
ld de,12
ld hl,(newtonep1)
sbc hl,de
ld (newtonep1),hl
ld hl,(newtonep2)
sbc hl,de
ld (newtonep2),hl
ld hl,(newtonep3)
sbc hl,de
ld (newtonep3),hl
ld hl,(newtonep4)
sbc hl,de
ld (newtonep4),hl
ret