Chase H.Q. | Routines |
Prev: 83CD | Up: Map | Next: 852A |
This is called the "main loop" because it does all of the driving of the primary game functions, but it's really a subroutine of the boostrap / uber main loop above.
|
||||||||
main_loop | 8401 | CALL load_stage | Call load_stage | |||||
8404 | LD A,($8007) | Jump to ml_not_credits if we're not on the end screen (stage 6) | ||||||
8407 | CP $06 | |||||||
8409 | JR NZ,ml_not_credits | |||||||
Run the end screen.
|
||||||||
ml_run_end_screen | 840B | CALL $5C00 | Call the end screen animation routine | |||||
840E | LD HL,$8007 | Reset (wanted) stage to 1 | ||||||
8411 | LD (HL),$01 | |||||||
8413 | PUSH HL | Call load_stage | ||||||
8414 | CALL load_stage | |||||||
8417 | POP HL | |||||||
8418 | LD (HL),$06 | Set (wanted) stage to 6 [not sure why] | ||||||
841A | RET | Return | ||||||
Run the main game loop.
|
||||||||
ml_not_credits | 841B | CALL run_pregame_screen | Call run_pregame_screen | |||||
841E | LD HL,$5D1D | Address of stage_set_up_data | ||||||
8421 | CALL set_up_stage | Call set_up_stage | ||||||
8424 | LD HL,$A13B | Cycle start_speech_cycle 3,2,1 then repeat | ||||||
8427 | LD A,(HL) | |||||||
8428 | DEC A | |||||||
8429 | JR NZ,ml_store_start_speech | |||||||
842B | LD A,$03 | |||||||
ml_store_start_speech | 842D | LD (HL),A | ||||||
Choose the startup speech sample.
|
||||||||
842E | ADD A,A | start_speech = (A << 2) OR 2 -- The number of leading zeroes are used to encode a delay | ||||||
842F | ADD A,A | |||||||
8430 | OR $02 | |||||||
8432 | LD ($A26B),A | |||||||
8435 | LD A,($A139) | Test 128K mode flag | ||||||
8438 | AND A | |||||||
8439 | LD A,$FF | Set hazards[0].used to $FF -- I suspect this keeps the perp spawned | ||||||
843B | LD ($A188),A | |||||||
843E | LD HL,$81DD | Address of start_stage_chatter | ||||||
8441 | CALL Z,start_chatter | Call start_chatter if not in 128K mode (priority $FF) | ||||||
ml_loop | 8444 | CALL drive_sfx | Call drive_sfx | |||||
8447 | CALL keyscan | Call keyscan | ||||||
844A | CALL tick | Call tick | ||||||
844D | CALL check_user_input | Call check_user_input | ||||||
8450 | CALL read_map | Call read_map | ||||||
8453 | CALL handle_perp_caught | Call handle_perp_caught | ||||||
8456 | CALL move_hero_car | Call move_hero_car | ||||||
8459 | CALL spawn_cars | Call spawn_cars | ||||||
845C | CALL cycle_counters | Call cycle_counters | ||||||
845F | CALL play_engine_or_siren_sfx_hook | Call play_engine_or_siren_sfx_hook | ||||||
8462 | CALL build_height_table | Call build_height_table | ||||||
8465 | CALL scroll_horizon | Call scroll_horizon | ||||||
8468 | CALL play_engine_or_siren_sfx_hook | Call play_engine_or_siren_sfx_hook | ||||||
846B | CALL layout_road | Call layout_road | ||||||
846E | CALL play_engine_or_siren_sfx_hook | Call play_engine_or_siren_sfx_hook | ||||||
8471 | CALL draw_road | Call draw_road | ||||||
8474 | CALL play_engine_or_siren_sfx_hook | Call play_engine_or_siren_sfx_hook | ||||||
8477 | CALL layout_objects | Call layout_objects | ||||||
847A | CALL prepare_tunnel | Call prepare_tunnel | ||||||
847D | CALL spawn_hazards | Call spawn_hazards | ||||||
8480 | CALL drive_helicopter | Call drive_helicopter | ||||||
8483 | CALL choose_dirt_and_stones | Call choose_dirt_and_stones | ||||||
8486 | CALL play_engine_or_siren_sfx_hook | Call play_engine_or_siren_sfx_hook | ||||||
8489 | CALL draw_hazards | Call draw_hazards | ||||||
848C | CALL layout_dirt_and_stones | Call layout_dirt_and_stones | ||||||
848F | CALL play_engine_or_siren_sfx_hook | Call play_engine_or_siren_sfx_hook | ||||||
8492 | CALL move_helicopter | Call move_helicopter | ||||||
8495 | CALL check_collisions | Call check_collisions | ||||||
8498 | CALL play_engine_or_siren_sfx_hook | Call play_engine_or_siren_sfx_hook | ||||||
849B | CALL draw_everything_else | Call draw_everything_else | ||||||
849E | CALL play_engine_or_siren_sfx_hook | Call play_engine_or_siren_sfx_hook | ||||||
84A1 | CALL animate_hero_car | Call animate_hero_car | ||||||
84A4 | CALL speed_score | Call speed_score | ||||||
84A7 | CALL update_scoreboard | Call update_scoreboard | ||||||
84AA | CALL calc_overtake_bonus | Call calc_overtake_bonus | ||||||
84AD | CALL play_engine_or_siren_sfx_hook | Call play_engine_or_siren_sfx_hook | ||||||
84B0 | CALL drive_chatter | Call drive_chatter | ||||||
84B3 | CALL draw_smash_bar | Call smash_bar_etc | ||||||
84B6 | CALL transition | Call transition | ||||||
84B9 | CALL play_engine_or_siren_sfx_hook | Call play_engine_or_siren_sfx_hook | ||||||
84BC | CALL draw_screen | Call draw_screen | ||||||
84BF | CALL exit_fork | Call exit_fork | ||||||
84C2 | LD A,($8000) | Is test mode enabled? | ||||||
84C5 | AND A | If not, goto not_test_mode | ||||||
84C6 | JR Z,ml_not_test_mode | |||||||
Test mode handling
|
||||||||
ml_handle_test_mode | 84C8 | LD A,$F7 | Read keys 1/2/3/4/5 | |||||
84CA | IN A,($FE) | |||||||
84CC | CPL | Change to active high | ||||||
84CD | AND $1F | Mask off just keys | ||||||
84CF | JR Z,ml_not_test_mode | If none are set then jump | ||||||
84D1 | EX AF,AF' | Bank key flags | ||||||
84D2 | LD BC,$0804 | Effect 8 (bip), Priority 4 | ||||||
84D5 | CALL start_sfx | Call start_sfx | ||||||
84D8 | CALL silence_audio_hook | Call silence_audio_hook | ||||||
84DB | EX AF,AF' | Unbank key flags | ||||||
84DC | RRA | Is bit 0 set? (key 1 to restart the level) | ||||||
84DD | JP C,main_loop | Restart level if so | ||||||
84E0 | LD HL,$8007 | HL = &wanted_stage_number | ||||||
84E3 | RRA | Is bit 1 set? (key 2 to load the next level) | ||||||
84E4 | JR NC,ml_check_for_3 | Jump if NOT | ||||||
84E6 | INC (HL) | wanted_stage_number++ | ||||||
84E7 | JP main_loop | Loop to main_loop | ||||||
ml_check_for_3 | 84EA | RRA | Is bit 2 set? (key 3 to load the end screen) | |||||
84EB | JR NC,ml_increment_credits | Jump if NOT | ||||||
84ED | LD (HL),$06 | wanted_stage_number = 6 | ||||||
84EF | JP main_loop | Loop to main_loop | ||||||
ml_increment_credits | 84F2 | LD HL,$A13D | Increment credits unless maxed out at 9 | |||||
84F5 | LD A,(HL) | |||||||
84F6 | CP $09 | |||||||
84F8 | JR Z,ml_not_test_mode | |||||||
84FA | INC (HL) | |||||||
ml_not_test_mode | 84FB | LD A,($A231) | Load transition_control | |||||
84FE | AND A | Jump to ml_loop if non-zero | ||||||
84FF | JP NZ,ml_loop | |||||||
Play speech when we see a 1-bit shift out of start_speech.
|
||||||||
8502 | LD HL,$A26B | Address of start_speech | ||||||
8505 | SRL (HL) | Shift the counter right | ||||||
8507 | JR NC,ml_check_quit | Jump if no carry | ||||||
8509 | LD A,(HL) | Load speech sample index | ||||||
850A | LD (HL),$00 | Zero start_speech | ||||||
850C | CALL play_speech_hook | Call play_speech_hook | ||||||
850F | JP ml_loop | Loop to ml_loop | ||||||
ml_check_quit | 8512 | LD A,($A26A) | Loop to ml_loop if quit_state is zero | |||||
8515 | AND A | |||||||
8516 | JP Z,ml_loop | |||||||
Quitting the game is in progress.
|
||||||||
8519 | DEC A | Decrement quit_state | ||||||
851A | JP NZ,escape_scene | Jump to escape_scene if non-zero | ||||||
851D | LD A,$02 | quit_state = 2 | ||||||
851F | LD ($A26A),A | |||||||
8522 | LD A,$08 | Forward transition | ||||||
8524 | CALL setup_transition | Call setup_transition | ||||||
8527 | JP ml_loop | Loop to ml_loop |
Prev: 83CD | Up: Map | Next: 852A |