| Chase H.Q. | Routines |
| Prev: 9BA7 | Up: Map | Next: 9CC2 |
|
This function handles timed events. When 15s or less remain then Nancy warns that our heroes are running of time. When they do run out of time, and sufficient credits remain, a 10s coundown timer and restart query are presented along with a tick-tock sound effect. If restart is initiated the game is part reset and continues.
It is a five state machine. 0: count the time down every 15 frames, warn at 15 seconds left, and at zero suppress the player's input and move to state 1. 1: wait for the hero car to stop, then move to state 2. 2: if there are credits left, take one, show the 10 second continue countdown and move to state 3. 3: tick the countdown with the bip-bow effect twice a second; FIRE resets the mission and restarts, and running out quits. 4: the quit is already under way, so do nothing.
Used by the routine at main_loop.
|
||||
| check_time_up | 9BCF | LD A,($A230) | Return if perp_caught_phase > 0 | |
| 9BD2 | AND A | |||
| 9BD3 | RET NZ | |||
| 9BD4 | LD A,($A231) | Return if transition_control == 4 -- don't check while transitions are running | ||
| 9BD7 | CP $04 | |||
| 9BD9 | RET Z | |||
| 9BDA | LD HL,$A17E | Point HL at time_bcd | ||
| 9BDD | LD A,($A229) | Jump to tick_check_time_up if time_up_state was 1 - out of time | ||
| 9BE0 | DEC A | |||
| 9BE1 | JR Z,tick_check_time_up | |||
| 9BE3 | DEC A | Jump to tick_check_credits if time_up_state was 2 - show "TIME UP" message | ||
| 9BE4 | JR Z,tick_check_credits | |||
| 9BE6 | DEC A | Jump to tick_check_restart if time_up_state was 3 - show "CONTINUE" message & run countdown | ||
| 9BE7 | JR Z,tick_check_restart | |||
| 9BE9 | DEC A | Return if it was 4 - countdown elapsed | ||
| 9BEA | RET Z | |||
|
Otherwise it's zero?
|
||||
| 9BEB | LD A,(HL) | A = time_bcd | ||
| 9BEC | AND A | Set flags | ||
| 9BED | JR NZ,tick_update_remaining_time | Jump to tick_update_remaining_time if non-zero | ||
|
Out of time.
|
||||
| 9BEF | INC A | time_up_state = 1 | ||
| 9BF0 | LD ($A229),A | |||
| 9BF3 | LD A,$93 | user_input_mask = $93 (allow only Quit, Fire, Left, Right to force stop) | ||
| 9BF5 | LD ($A16F),A | |||
| 9BF8 | RET | Return | ||
| tick_update_remaining_time | 9BF9 | DEC HL | Decrement the 1/16th sec counter | |
| 9BFA | DEC (HL) | |||
| 9BFB | RET NZ | Return if not zero | ||
| 9BFC | LD (HL),$0F | Reset time_sixteenths to 15 | ||
| 9BFE | INC HL | Decrement time_bcd [POKE $9C01 for Infinite time] | ||
| 9BFF | LD A,(HL) | |||
| 9C00 | SUB $01 | |||
| 9C02 | DAA | |||
| 9C03 | LD (HL),A | |||
| 9C04 | CP $15 | Return if <> 15s remain | ||
| 9C06 | RET NZ | |||
| 9C07 | LD HL,$98FC | Nancy berating us running out of time message | ||
| 9C0A | JP start_chatter | Exit via start_chatter (Bug? Priority is 21) | ||
| tick_check_time_up | 9C0D | LD A,(HL) | Is time_bcd zero? Jump to time_up if so | |
| 9C0E | AND A | |||
| 9C0F | JR Z,tick_time_is_up | |||
| 9C11 | XOR A | time_up_state = 0 | ||
| 9C12 | LD ($A229),A | |||
| 9C15 | DEC A | user_input_mask = $FF (allow all keys) | ||
| 9C16 | LD ($A16F),A | |||
| 9C19 | JR tick_update_remaining_time | Loop back to tick_update_remaining_time | ||
| tick_time_is_up | 9C1B | LD HL,$8D07 | Point at "TIME UP" message | |
| 9C1E | CALL setup_overlay_messages | Call setup_overlay_messages | ||
| 9C21 | LD HL,($A24A) | Return if speed > 0 | ||
| 9C24 | LD A,H | |||
| 9C25 | OR L | |||
| 9C26 | RET NZ | |||
| 9C27 | LD A,$02 | time_up_state = 2 | ||
| 9C29 | LD ($A229),A | |||
| 9C2C | LD A,$04 | Index of "Your time's up" speech sample | ||
| 9C2E | JP play_speech_hook | Exit via play_speech_hook | ||
| tick_check_credits | 9C31 | LD A,($A231) | Return if transition_control is non-zero | |
| 9C34 | AND A | |||
| 9C35 | RET NZ | |||
| 9C36 | LD HL,$A13D | Exit via check_user_input_quit_key if no credits remain | ||
| 9C39 | LD A,(HL) | |||
| 9C3A | AND A | |||
| 9C3B | JP Z,check_user_input_quit_key | |||
| 9C3E | DEC (HL) | Decrement credits [POKE $9C3E for Infinite credits] | ||
| 9C3F | ADD A,$B0 | Turn it into ASCII and poke it into the "CREDIT x" string | ||
| 9C41 | LD ($8D8C),A | |||
| 9C44 | LD A,$03 | time_up_state = 3 | ||
| 9C46 | LD ($A229),A | |||
| 9C49 | LD HL,$0115 | HL = $0115 | ||
| 9C4C | LD ($9C85),HL | Self modify 'LD HL' @ 9C84 to load HL | ||
| 9C4F | RET | Return | ||
| tick_check_restart | 9C50 | LD HL,$A0D5 | Is fire pressed? | |
| 9C53 | BIT 4,(HL) | |||
| 9C55 | JR Z,tick_print_continue | Jump if not (?) | ||
|
Resetting mission code.
|
||||
| 9C57 | XOR A | Reset time_up_state to zero | ||
| 9C58 | LD ($A229),A | |||
| 9C5B | LD HL,$A232 | Reset smash_level to zero | ||
| 9C5E | LD (HL),A | |||
| 9C5F | INC HL | |||
| 9C60 | LD (HL),A | Reset smash_counter to zero | ||
| 9C61 | DEC A | |||
| 9C62 | LD ($A16F),A | Set user input mask to allow everything through | ||
| 9C65 | LD A,$03 | |||
| 9C67 | LD ($A252),A | gear_lockout = 3 | ||
| 9C6A | LD ($A231),A | transition_control = 3 -- Flag set to zero when attributes have been set | ||
| 9C6D | LD ($A170),A | turbos = 3 | ||
| 9C70 | LD A,$60 | Set remaining time to 60 (BCD) [doesn't affect stuff if altered?!] | ||
| 9C72 | LD ($A17E),A | |||
| 9C75 | LD HL,$8006 | Increment retry_count | ||
| 9C78 | INC (HL) | |||
|
This entry point is used by the routines at run_pregame_screen and load_stage_128k.
|
||||
| play_start_noise | 9C79 | LD A,$05 | Index of start noise sample | |
| 9C7B | JP play_speech_hook | Exit via play_speech_hook | ||
| tick_print_continue | 9C7E | LD HL,$8D18 | Print "CONTINUE THIS MISSION" messages | |
| 9C81 | CALL setup_overlay_messages | Call setup_overlay_messages | ||
| 9C84 | LD HL,$0000 | <self modified> | ||
| 9C87 | DEC H | H-- | ||
| 9C88 | JR NZ,tick_set_digits | |||
| 9C8A | LD H,$06 | H = 6 | ||
| 9C8C | DEC L | L-- | ||
| 9C8D | LD A,L | A = L | ||
| 9C8E | RRA | Set carry to even/odd seconds | ||
| 9C8F | LD BC,$0801 | Effect 8 (bip), Priority 1 | ||
| 9C92 | JR NC,tick_play_sfx | Jump if carry clear (even seconds) | ||
| 9C94 | INC B | Effect 9 (bow) | ||
| tick_play_sfx | 9C95 | CALL start_sfx | Call start_sfx | |
| 9C98 | LD A,L | A = L | ||
| 9C99 | AND A | Set flags | ||
| 9C9A | JR NZ,tick_set_digits | |||
| 9C9C | INC A | A++ | ||
| 9C9D | LD ($A26A),A | quit_state = A (A is 1) | ||
| 9CA0 | LD A,$04 | time_up_state = 4 | ||
| 9CA2 | LD ($A229),A | |||
| tick_set_digits | 9CA5 | LD ($9C85),HL | Self modify 'LD HL' @ 9C84 to load HL | |
| 9CA8 | LD A,L | A = L | ||
| 9CA9 | SRL A | A >>= 1 | ||
| 9CAB | LD DE,$8D7C | Load address of nn in "TIME nn" | ||
| 9CAE | CP $0A | CP 10 | ||
| 9CB0 | JR NZ,tick_less_than_10 | |||
| 9CB2 | LD A,$31 | A = '1' | ||
| 9CB4 | LD L,$00 | L = $00 | ||
| 9CB6 | JR tick_write_digits | Write the digits out | ||
| tick_less_than_10 | 9CB8 | LD L,A | L = A | |
| 9CB9 | LD A,$20 | A = ' ' | ||
| tick_write_digits | 9CBB | LD (DE),A | *DE = A | |
| 9CBC | LD A,L | A = L + $B0 | ||
| 9CBD | ADD A,$B0 | |||
| 9CBF | INC DE | DE++ | ||
| 9CC0 | LD (DE),A | *DE = A | ||
| 9CC1 | RET | Return | ||
| Prev: 9BA7 | Up: Map | Next: 9CC2 |