-
Notifications
You must be signed in to change notification settings - Fork 1
/
bonuses.asm
183 lines (144 loc) · 3.21 KB
/
bonuses.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
.module BONUSES
displayBonuses:
ld a,1 ; no discernable pause
ld (_eobdp),a
ld hl,bonusdefs
ld bc,bonuscount * 256 + 1 ; b = bonus count, c = initial bonus number
-: push bc
push hl
call _checkAndDisplay
pop hl
ld de,6
add hl,de
pop bc
ld a,c ; bonus number in c, bcd
add a,1 ; inc/dec don't affect carry properly, needed for daa
daa
ld c,a
djnz {-}
ld a,(_eobdp) ; if any bonuses were hit we pause here a second or 2
ld b,a
jp waitframes
_checkAndDisplay:
ld a,(hl) ; score if bonus achieved
ld (_bonus),a
inc hl
ld a,(hl) ; value to use in compare function
push af
inc hl
ld a,(hl) ; address of compare fn
ld (_comparer+1),a
inc hl
ld a,(hl)
ld (_comparer+2),a
inc hl
ld a,(hl) ; hl - data address to check
inc hl
ld h,(hl)
ld l,a
pop af ; recover value
_comparer:
call 0
ret nz ; no points to add
_displayBonus:
ld a,50 ; delay after showinf the bonuses
ld (_eobdp),a
ld a,c
ld de,bonustext+14
call _bcdout
ld a,8
ld hl,dfile+$0ee
ld bc,$1407 ; 20 across, 7 high
call _drrect
ld a,0
ld hl,dfile+$110
ld bc,$1205 ; 18 across, 5 high
call _drrect
ld hl,bonustext
ld de,dfile+$132
ld bc,16
ldir
ld a,(_bonus)
ld de,dfile+$17b
call _bcdout
ld a,ZEROZ
ld (dfile+$17d),a
ld b,8
call waitframes
ld a,(_bonus)
-: sub 1 ; inc/dec don't affect carry properly, needed for daa
daa
push af
ld de,dfile+$17b
call _bcdout
ld bc,1
call addscore
ld a,18
call AFXPLAY
call framesync
call framesync
pop af
and a
jr nz,{-}
ret
_bcdout:
push af
srl a
srl a
srl a
srl a
add a,ZEROZ
ld (de),a
inc de
pop af
and $0f
add a,ZEROZ
ld (de),a
ret
_drrect:
push hl
push bc ; preserve B
call _drline
pop bc
pop hl
ld de,33
add hl,de
dec c
jr nz,_drrect
ret
_drline:
ld (hl),a
inc hl
djnz _drline
ret
; a is value to check against, (hl) is variable
; i.e. if lives > 4
; a = 4, hl = lives
; 4 - (hl) results in z set if lives = 4, c set if lives > 4
_byteEQ:
cp (hl)
ret z ; return with z if bonus is coming
_nope:
or $ff ; nz if no bonus
ret
_yep:
xor a
ret
_byteGT:
cp (hl)
jr c,_yep
jr _nope
_byteGTE:
cp (hl)
jr z,_yep
jr c,_yep
jr _nope
_byteLT:
cp (hl)
jr z,_nope
jr c,_nope
jr _yep
_byteLTE:
cp (hl)
jr c,_nope
jr _yep