Chase H.Q. | Routines |
Prev: F0FE | Up: Map | Next: F491 |
This is relocated to $8014/load_stage onwards during init (926 bytes long).
|
||||
page_in_stage_128k | F220 | LD A,($8007) | Load wanted_stage_number | |
F223 | LD HL,$A13A | Address of current_stage_number | ||
F226 | CP (HL) | Return if the stage is already loaded | ||
F227 | RET Z | |||
F228 | LD (HL),A | wanted_stage_number = current_stage_number | ||
Copy the stage data from the correct bank and address to $5C00..$76EF.
|
||||
F229 | ADD A,A | Point HL at stage_data_locations[current_stage_number] | ||
F22A | LD B,$00 | |||
F22C | LD C,A | |||
F22D | LD HL,$8037 | |||
F230 | ADD HL,BC | |||
F231 | LD A,(HL) | Load paging flags byte | ||
F232 | INC HL | HL++ | ||
F233 | LD H,(HL) | HL = Source data address (B is zero) | ||
F234 | LD L,B | |||
F235 | LD BC,$7FFD | 128K: Page in required bank | ||
F238 | OUT (C),A | |||
F23A | LD DE,$5C00 | Destination $5C00..$76EF (from the horizon backdrop to just before the turbo icons) | ||
F23D | LD BC,$1AF0 | Bytes to copy (worst case) | ||
F240 | LDIR | Copy | ||
F242 | JP $8208 | Exit via relocated reset_paging_128k | ||
Pairs of (top byte of source data address, paging flags).
|
||||
stage_data_locations | F245 | DEFW $C001 | Level 1. Source = $C000, Paging = bank 1 | |
F247 | DEFW $E001 | Level 2. Source = $E000, Paging = bank 1 | ||
F249 | DEFW $C006 | Level 3. Source = $C000, Paging = bank 6 | ||
F24B | DEFW $E006 | Level 4. Source = $E000, Paging = bank 6 | ||
F24D | DEFW $C007 | Level 5. Source = $C000, Paging = bank 7 | ||
F24F | DEFW $E007 | Level 6. Source = $E000, Paging = bank 7 | ||
$8045 once relocated.
|
||||
start_siren_hook_128k | F251 | LD A,$8C | Store $8C to channel A fine pitch | |
F253 | LD ($A213),A | |||
F256 | LD A,$0E | Store 14 to channel A volume (4-bit) | ||
F258 | LD ($A21B),A | |||
F25B | SUB $02 | Store 12 to channel B volume | ||
F25D | LD ($A21C),A | |||
F260 | LD A,$AA | Self modify 'LD A,x' @ F271 (in this position) | ||
F262 | LD ($8066),A | |||
F265 | LD ($A239),A | var_a239 = $AA | ||
F268 | RET | Return | ||
engine_sfx_play_hook_128k | F269 | LD A,($A239) | var_a239 (initialised to $AA above) | |
F26C | AND A | Return if zero | ||
F26D | RET Z | |||
F26E | LD A,($A213) | Load channel A fine pitch | ||
F271 | LD B,$AA | jump on 50-50 alternating pattern? -- could be flipping between string sets? | ||
F273 | RLC B | |||
F275 | JR C,f27f_128k | |||
Decreasing case
|
||||
F277 | SUB $03 | A -= 3 | ||
F279 | CP $5A | Jump if A >= $5A | ||
F27B | JR NC,f28b_128k | |||
F27D | JR f285_128k | Jump | ||
Increasing case
|
||||
f27f_128k | F27F | ADD A,$03 | A += 3 | |
F281 | CP $8C | Jump if A < $8C | ||
F283 | JR C,f28b_128k | |||
Arrive here if A is outside of $5A..$8B
|
||||
f285_128k | F285 | EX AF,AF' | ||
F286 | LD A,B | Store B (rotating pattern) | ||
F287 | LD ($8066),A | |||
F28A | EX AF,AF' | |||
Arrive here if A is $5A..$8B
|
||||
f28b_128k | F28B | LD ($A213),A | Update channel A fine pitch | |
F28E | SUB $04 | and store 4 less to channel B fine pitch | ||
F290 | LD ($A215),A | |||
F293 | LD A,($A21A) | Set mixer to enable tone A & B | ||
F296 | AND $3C | |||
F298 | LD ($A21A),A | |||
F29B | JR write_registers_hook_128k | Jump | ||
silence_audio_hook_128k | F29D | LD A,$3F | Initialise mixer to $3F (all noise and tone off) | |
F29F | LD ($A21A),A | |||
writing the full register set?
|
||||
write_registers_hook_128k | F2A2 | LD HL,$A21E | Address of sound register value(s) -- other values must be earlier | |
F2A5 | LD A,$0B | Select AY-3-8912 sound chip register 11: envelope fine duration | ||
F2A7 | LD C,$FD | |||
write_registers_hook_loop | F2A9 | LD B,$FF | ||
F2AB | OUT (C),A | |||
F2AD | LD B,$BF | Write to the register from (HL), then decrement B and HL | ||
F2AF | OUTD | |||
F2B1 | DEC A | Next register down | ||
F2B2 | JP P,sub_809D | Loop to write_registers_hook_loop while +ve | ||
F2B5 | RET | Return | ||
f2b6_128k | F2B6 | LD HL,($A24A) | Get speed value | |
F2B9 | RR H | A = speed / 2 (top half) | ||
F2BB | LD A,L | A = speed / 2 (bottom half) | ||
F2BC | RRA | |||
F2BD | CPL | L = ~A | ||
F2BE | LD L,A | |||
F2BF | LD A,($A253) | Jump if in low gear | ||
F2C2 | AND A | |||
F2C3 | JR Z,page_in_stage_128k_0 | |||
F2C5 | SLA L | |||
F2C7 | RL H | |||
page_in_stage_128k_0 | F2C9 | SLA L | ||
F2CB | RL H | |||
F2CD | SLA L | |||
F2CF | RL H | |||
F2D1 | LD A,($A23B) | A = tunnel_sfx | ||
F2D4 | AND A | Set flags | ||
F2D5 | LD DE,$0190 | -- base tone value? | ||
F2D8 | LD A,$0F | |||
F2DA | JR Z,page_in_stage_128k_1 | Jump if tunnel_sfx was zero | ||
F2DC | LD DE,$0258 | -- base tone value? | ||
F2DF | LD A,$0C | Volume = 12 | ||
page_in_stage_128k_1 | F2E1 | ADD HL,DE | -- speed value + base tone? | |
F2E2 | LD ($A217),HL | Set channel C pitch (both fine and course) | ||
F2E5 | LD ($A21D),A | Set channel C volume | ||
F2E8 | LD A,($A21A) | Set mixer to enable tone C | ||
F2EB | AND $3B | |||
F2ED | LD ($A21A),A | |||
F2F0 | RET | Return | ||
turbo_sfx_play_hook_128k | F2F1 | LD A,$3C | Set noise pitch (5-bit) [$3C is > 5-bit...] | |
F2F3 | LD ($A219),A | |||
F2F6 | LD ($A23A),A | var_a23a = $3C -- Copy of it? | ||
F2F9 | RET | Return | ||
engine_sfx_setup_hook_128k | F2FA | LD A,($A23A) | Jump if var_a23a is zero | |
F2FD | AND A | |||
F2FE | JR Z,f2b6_128k | |||
F300 | DEC A | Decrement noise pitch | ||
F301 | RET Z | Return if zero | ||
F302 | LD HL,$A219 | Address of noise pitch register soft copy | ||
F305 | DEC (HL) | Decrement in-place | ||
F306 | JR Z,f31f_128k | Jump if zero | ||
F308 | LD A,(HL) | Increment noise pitch register soft copy by 10 | ||
F309 | ADD A,$0A | |||
F30B | LD L,A | |||
F30C | LD H,$00 | |||
F30E | LD ($A217),HL | Set channel C pitch (both fine and course) | ||
F311 | LD A,($A21A) | Set mixer to enable tone C and noise C | ||
F314 | AND $1B | |||
F316 | LD ($A21A),A | |||
F319 | LD A,$0D | Set channel C volume to 13 | ||
F31B | LD ($A21D),A | |||
F31E | RET | Return | ||
f31f_128k | F31F | LD A,($A21A) | Set mixer to disable tone C and noise C | |
F322 | OR $24 | |||
F324 | LD ($A21A),A | |||
F327 | XOR A | var_a23a = 0 | ||
F328 | LD ($A23A),A | |||
F32B | JP load_stage_7 | Exit via f2b6_128k | ||
Relocated to $8122
"Giddy up boy!"
|
||||
speech_samples_table | F32E | DEFW $0A8C | length | |
F330 | DEFW $C000 | address | ||
"Let's go Mr. Driver!"
|
||||
F332 | DEFW $14E6 | length | ||
F334 | DEFW $CA8C | address | ||
"Hold on man!"
|
||||
F336 | DEFW $0A5A | length | ||
F338 | DEFW $DF72 | address | ||
"Your time's up"
|
||||
F33A | DEFW $0ABE | length | ||
F33C | DEFW $E9CC | address | ||
Start noise
|
||||
F33E | DEFW $0ADC | length | ||
F340 | DEFW $F48A | address | ||
play_speech_128k | F342 | EX AF,AF' | Bank input index (sample indices are 1..5) | |
F343 | CALL load_stage_6 | Call silence_audio_hook_128k | ||
F346 | LD A,$04 | 128K: Map RAM bank 4 to $C000; Map normal screen; Map ROM 0 | ||
F348 | LD BC,$7FFD | |||
F34B | OUT (C),A | |||
F34D | LD C,$FD | |||
F34F | LD HL,$FFBF | |||
F352 | LD D,$08 | |||
F354 | EXX | |||
F355 | EX AF,AF' | Unbank input index | ||
F356 | ADD A,A | HL = $F32A + A*4 -- i.e. it's 1-indexed speech_samples_table | ||
F357 | ADD A,A | |||
F358 | LD HL,$811E | |||
F35B | LD C,A | |||
F35C | LD B,$00 | |||
F35E | ADD HL,BC | |||
F35F | LD E,(HL) | DE = wordat(HL); HL += 2 -- read length | ||
F360 | INC HL | |||
F361 | LD D,(HL) | |||
F362 | INC HL | |||
F363 | LD A,(HL) | HL = wordat(HL) -- read address | ||
F364 | INC HL | |||
F365 | LD H,(HL) | |||
F366 | LD L,A | |||
plsp_f367_128k | F367 | LD C,$02 | C = 2 -- iterations (two nibbles) | |
F369 | LD A,(HL) | A = *HL -- read a sample (or two?) | ||
F36A | RRA | A = A ROR 4 | ||
F36B | RRA | |||
F36C | RRA | |||
F36D | RRA | |||
plsp_f36e_loop | F36E | AND $0F | A &= 15 | |
F370 | EX AF,AF' | |||
F371 | EXX | |||
F372 | LD B,H | B = H which is $FF | ||
F373 | LD A,D | A = D which is 8 -- register 8: Channel A volume | ||
F374 | OUT (C),A | C is $FD | ||
F376 | LD B,L | B = L which is $BF | ||
F377 | EX AF,AF' | A = value loaded above | ||
F378 | OUT (C),A | Write to register | ||
F37A | EX AF,AF' | Bank it again | ||
F37B | INC A | 8 -> 9 -- register 9: Channel B volume | ||
F37C | LD B,H | B = $FF | ||
F37D | OUT (C),A | C is $FD | ||
F37F | LD B,L | B = L which is $BF | ||
F380 | EX AF,AF' | A = value loaded above | ||
F381 | OUT (C),A | Write to register | ||
F383 | EX AF,AF' | Bank it again | ||
F384 | INC A | 9 -> 10 -- register 9: Channel C volume | ||
F385 | LD B,H | B = $FF | ||
F386 | OUT (C),A | C is $FD | ||
F388 | LD B,L | B = L which is $BF | ||
F389 | EX AF,AF' | A = value loaded above | ||
F38A | OUT (C),A | Write to register | ||
F38C | EXX | |||
F38D | LD B,$13 | Delay loop (lower value => higher frequency) | ||
page_in_stage_128k_2 | F38F | DJNZ page_in_stage_128k_2 | ||
F391 | LD A,(HL) | Load next nibble (same byte, but next nibble) | ||
F392 | DEC C | Decrement nibble counter | ||
F393 | JR NZ,plsp_f36e_loop | Loop plsp_f36e_loop | ||
F395 | INC HL | Advance to next byte of sample data | ||
F396 | DEC DE | Decrement sample data counter | ||
F397 | LD A,D | Loop to plsp_f367_128k while sample data remains | ||
F398 | OR E | |||
F399 | JP NZ,$815B | |||
F39C | JP $8208 | Exit via relocated reset_paging_128k | ||
plsp_f39f_128k | F39F | LD A,($8E4A) | -- frame delay? | |
F3A2 | CP $2A | Return if A < 42 | ||
F3A4 | RET C | |||
F3A5 | CALL silence_audio_hook | Call silence_audio_hook | ||
F3A8 | XOR A | var_a239 = 0 | ||
F3A9 | LD ($A239),A | |||
F3AC | INC A | A = 1 | ||
F3AD | LD ($A23A),A | Load var_a23a -- copy of noise pitch | ||
F3B0 | LD ($8E4A),A | Self modify 8E49 | ||
F3B3 | LD HL,$C006 | |||
plsp_f3b6_128k | F3B6 | LD ($81C6),HL | Self modify 'CALL xxxx' @ $81C5 ($F3D1 before relocation - below) | |
F3B9 | LD HL,$B000 | Copy 4096 bytes from $B000 to $F000 (preserving registers for later) | ||
F3BC | LD DE,$F000 | |||
F3BF | LD BC,$1000 | |||
F3C2 | PUSH HL | |||
F3C3 | PUSH DE | |||
F3C4 | PUSH BC | |||
F3C5 | LDIR | |||
F3C7 | LD ($81CE),SP | Self modify 'LD SP,xxxx' @ 81CD ($F3D9 here - below) | ||
F3CB | LD SP,$A214 | new sp | ||
F3CE | CALL $81D6 | Call relocated f3e2_128k | ||
F3D1 | CALL $0000 | Self modified by plsp_f3b6_128k | ||
F3D4 | PUSH AF | Preserve ? | ||
F3D5 | CALL $81D6 | Call relocated f3e2_128k | ||
F3D8 | POP AF | Restore ? | ||
F3D9 | LD SP,$0000 | Restore SP - self modified by F3C7 above | ||
F3DC | POP BC | Copy 4096 bytes from $B000 to $F000 | ||
F3DD | POP HL | |||
F3DE | POP DE | |||
F3DF | LDIR | Copy | ||
F3E1 | RET | Return | ||
f3e2_128k | F3E2 | LD HL,$C000 | HL = $C000 | |
F3E5 | LD B,$04 | 4 iterations | ||
F3E7 | LD E,L | E = 0 | ||
f3e8_loop | F3E8 | PUSH BC | Preserve iterations | |
F3E9 | LD D,$B0 | DE = $B000 | ||
F3EB | LD BC,$1000 | 4096 bytes | ||
F3EE | PUSH BC | Preserve | ||
F3EF | PUSH HL | |||
F3F0 | LDIR | Copy | ||
F3F2 | LD A,$03 | A = 3 | ||
F3F4 | CALL engine_sfx_setup_0 | Jump into engine_sfx_setup with engine speed setup | ||
F3F7 | POP HL | Retrieve from stack | ||
F3F8 | POP BC | |||
F3F9 | PUSH BC | |||
F3FA | PUSH HL | |||
F3FB | LD D,$B0 | DE = $B000 | ||
f3fd_loop | F3FD | LD A,(DE) | A = *DE | |
F3FE | LDI | Transfer a byte | ||
F400 | DEC HL | HL[-1] = A | ||
F401 | LD (HL),A | |||
F402 | INC HL | |||
F403 | JP PE,$81F1 | Loop if (parity even) to f3fd_loop | ||
F406 | CALL $8208 | Call relocated reset_paging_128k | ||
F409 | POP DE | Restore | ||
F40A | POP BC | |||
F40B | LD H,$B0 | HL = $B000 | ||
F40D | LDIR | Copy | ||
F40F | LD H,D | H = D | ||
F410 | POP BC | Restore iterations | ||
F411 | DJNZ f3e8_loop | Loop to f3e8_loop | ||
F413 | RET | Return | ||
reset_paging_128k | F414 | XOR A | 128K: Set paging register to default | |
F415 | LD BC,$7FFD | |||
F418 | OUT (C),A | |||
F41A | RET | Return | ||
attract_mode_hook_128k | F41B | LD HL,$C000 | HL = $C000 | |
page_in_stage_128k_3 | F41E | CALL $81AA | Call relocated plsp_f3b6_128k (speech) | |
F421 | AND A | Return if A is zero | ||
F422 | RET Z | |||
F423 | LD HL,$5D2B | HL -> attract_data | ||
F426 | CALL setup_game | Call setup_game | ||
F429 | LD A,$02 | var or self modify or ..? | ||
F42B | LD ($825E),A | |||
F42E | LD HL,$0190 | Set speed to $190 | ||
F431 | LD ($A24A),HL | |||
f434_128k_loop | F434 | CALL cpu_driver | Call cpu_driver | |
F437 | LD A,($8001) | Load attract_cycle | ||
F43A | AND A | Set flags | ||
F43B | LD DE,$8296 | -> enter_for_options_messages | ||
F43E | JR Z,f44b_key_check | Jump to f44b_key_check | ||
F440 | CALL keyscan | Call keyscan | ||
F443 | AND $10 | Was FIRE pressed? | ||
F445 | JP NZ,play_start_noise | Jump to play_start_noise if so | ||
F448 | LD DE,$8285 | -> press_gear_messages | ||
f44b_key_check | F44B | LD A,$BF | Read port $BFFE -- ENTER, L, K, J, H | |
F44D | IN A,($FE) | |||
F44F | CPL | Complement the value returned to change it from to active-high | ||
F450 | RRA | ?Shift out lsb | ||
F451 | LD HL,$C009 | |||
F454 | JR C,page_in_stage_128k_3 | ?Jump if ENTER was pressed | ||
F456 | EX DE,HL | |||
F457 | LD A,$F0 | |||
F459 | RRCA | -- why load A then shift? self modified? | ||
F45A | LD ($824C),A | |||
F45D | JR NC,page_in_stage_128k_4 | |||
F45F | LD A,(HL) | |||
F460 | CALL print_message | Call print_message | ||
page_in_stage_128k_4 | F463 | LD A,($A231) | If transition_control != 0 jump | |
F466 | AND A | |||
F467 | JR NZ,f488_128k | |||
F469 | LD A,$00 | -- smells like self modified | ||
F46B | AND A | |||
F46C | JP M,$820F | |||
F46F | DEC A | A-- | ||
F470 | LD ($825E),A | self modifying? | ||
F473 | JP P,attract_mode_1 | |||
F476 | LD A,$08 | Transition type? | ||
F478 | CALL setup_transition | Call setup_transition | ||
F47B | JR f488_128k | |||
f47d_128k | F47D | LD HL,$82AD | -- must be messages ptr below ($8208+165 means ?) | |
F480 | JR NZ,f485_128k | |||
F482 | LD HL,$830F | -- must be messages ptr below ($8208+263 means ?) | ||
f485_128k | F485 | CALL message_printing_related | Call message_printing_related | |
f488_128k | F488 | CALL transition | Call transition | |
F48B | CALL draw_screen | Call draw_screen | ||
F48E | JP $8228 | Loop to f434_128k_loop |
Prev: F0FE | Up: Map | Next: F491 |