-
Notifications
You must be signed in to change notification settings - Fork 1
/
vkiller_scc.asm
335 lines (271 loc) · 7.6 KB
/
vkiller_scc.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
; -----------------------------------------------------------
; Code for hooking in calls to the nemesis 3 SCC player
output vkiller_patch00038.bin
org 04038h
call music_update_shim
output vkiller_patch010ac.bin
org 050ach
pop af
ld e, a ; save song index for later
push af
nop
call music_start_shim
nop
nop
nop
; disable R800 mode
; R800 mode causes the PSG drums to sound inconsistent/weird
; output vkiller_patch01db2.bin
; nop
; nop
; nop
output vkiller_patch01c8a.bin
org 05c8ah
music_update_shim:
di
; read keyboard
in a, (0aah)
and 0f0h
or 3
out (0aah), a
in a, (0a9h)
bit 4, a
jr nz, skip_give_cheat
; give full health + various items
ld a, 020h
ld (0c415h), a
ld a, 2
ld (0c416h), a
ld a, 018h
ld (0c431h), a
ld a, 0ffh
ld (0c700h), a
ld a, 081h
ld (0c702h), a
ld a, (0c701h)
or 0FEh
ld (0c701h), a
jp end_cheats
skip_give_cheat:
bit 6, a
jr nz, end_cheats
; invincible
ld a, 0ffh
ld (0c434h), a
end_cheats:
ld a, 16
ld (07000h), a
call music_update
ld (07000h),a
ret
music_start_shim:
ld a, 0ffh
ld (0e600h), a ; game master detected = TRUE (enables F5 continue)
ld a, e
cp 08dh
jr nz, not_ending
ld a, 1
call 04107h ; prevent gfx corruption in ending titles
ld a, e
not_ending:
di
ld a, 16
ld (07000h), a
call music_start
ld (hl), a
ret
initialize:
xor a
call 0509fh
jp 05dabh
; -----------------------------------------------------------
; hook to initialize music player on game boot
output vkiller_patch00099.bin
call initialize
; -----------------------------------------------------------
; The code below lives in nemesis 3 SCC player mapper banks
output vkiller_patch21ee8.bin
org 07ee8h
write_psg:
cp 4
ret z
cp 5
ret z
cp 10
ret z
cp 7
jr nz, not_register_seven
; if the game is paused, don't write PSG ch7
; this is to prevent interference with the game paused jingle
ld a, (0f080h)
and 2
ret nz ; paused
; combine vkiller player bits with our own bits
push de
push hl
ld a, e
or 00100100b
ld e, a
ld hl, 0c097h
ld a, (hl)
or 00011011b
and e
ld (hl), a ; write combined bits back to vkiller state
pop hl
pop de
ld e, a
ld a, 7
not_register_seven:
out (0A0h), a ; set register
push af
ld a, e
out (0A1h), a ; write value
pop af
ret
map_slots:
; map music data using konami SCC mapper
ld a, 17
ld (09000h), a
ld a, 18
ld (0b000h), a
ret
music_start:
di
call map_slots
; interpret the command
ld a, e
cp 0xfa ; 0xfa and higher = commands: fade out, pause, etc.
jr nc, music_start_command
or a
jr z, music_stop
and 0x80 ; 0x80 and higher = start song
jr z, music_start_skip ; anything else = play SFX etc
; start playing a new song
ld a,e
and 07fh
add a, 6
jr music_start_call
music_stop:
; clear music player state
push bc
push de
ld hl, 0ee00h
ld de, 0ee01h
ld bc, 00280h
ld (hl), 0
ldir
pop de
pop bc
ld a, 081h
jr music_start_call
music_start_command:
and 07h
ld d, 0
ld e, a
ld hl, command_convert_table
add hl, de
ld a, (hl)
music_start_call:
push bc
call 06003h ; nemesis 3 song start function
call 06180h ; initialize some state which fixes boss music cutting out
pop bc
music_start_skip:
di
ld a, 14
ld (09000h), a
ld (0f0f2h), a
ld a, 15
ld (0b000h), a
ld (0f0f3h), a
ld a, (0f0f1h)
ld hl, 07000h
ret
music_update:
push bc
push de
push hl
push ix
push iy
call map_slots
call 06006h ; nemesis 3 song update function
; set a flag which vkiller uses to know whether music is playing
ld a,(0eec0h)
ld (0c0a7h), a
ram_not_initialised:
ld a, 14
ld (09000h), a
ld a, 15
ld (0b000h), a
ld a, (0f0f1h)
pop iy
pop ix
pop hl
pop de
pop bc
ret
command_convert_table:
db 0 ; 0f8h = ?
db 0 ; 0f9h = ?
db 0 ; 0fah = ?
db 082h ; 0fbh = pause (hourglass)
db 081h ; 0fch = unpause (hourglass)
db 082h ; 0fdh = pause (F1)
db 081h ; 0feh = unpause (F1)
db 084h ; 0ffh = fade out
end_of_program:
assert end_of_program < 0c000h
; -----------------------------------------------------------
; Disable SCC player PSG channel used for vkiller SFX
;output vkiller_patch203ad.bin
;org 063adh
;nop
;nop
;nop
;output vkiller_patch203b9.bin
;org 063b9h
;nop
;nop
;nop
;output vkiller_patch203c52.bin
;org 063c52h
;nop
;nop
;nop
;----------------------------------------------
; when SCC player is paused, pause ALL channels
; (original version keeps one channel playing (the SFX channel?)
output vkiller_patch20399.bin
ret nz
nop
nop
;--------------------------------------------------
; disable vampire killer PSG music-only channels
;output vkiller_patch1c9aa.bin ; doesnt actually work!
;nop
;nop
;nop
;output vkiller_patch1c9b3.bin ; doesnt actually work!
;nop
;nop
;nop
;output vkiller_patch1c9bc.bin
;nop
;nop
;nop
;------------------------------------------------
; stop vkiller music playing
output vkiller_patch010c6.bin
jp 05131h
;-------------------------------------------------
; Data to make Game Master 2 work
;
; This is a header at the start of the rom that contains the RC code
; and information about how to change the starting stage and number
; of lives.
; when we expand the vampire killer ROM to 256K, Game Master 2 no
; longer recognizes the game. to fix this we need to change
; the format of this header
output vkiller_patch00010.bin
db 043h, 044h, 007h, 044h, 0B8h, 000h, 0C0h, 004h
db 000h, 011h, 0C3h, 010h, 0C4h, 005h, 0C4h, 000h