Prev: 83CD Up: Map Next: 852A
8401: Main loop
Used by the routines at bootstrap and handle_perp_caught.
main_loop 8401 CALL load_stage Call load_stage
8404 LD A,($8007) Are we on the end screen (stage 6)? Jump ml_not_credits if not so
8407 CP $06
8409 JR NZ,ml_not_credits
Run the end screen.
ml_run_end_screen 840B CALL $5C00 Call bitmap_horizon [which is data in earlier stages, must be end screen anim]
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 setup_game_data
8421 CALL setup_game Call setup_game
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 * 4) OR 2
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 hazard_0 = $FF -- I suspect this keeps the perp spawned
843B LD ($A188),A
843E LD HL,$81DD Address of start_chatter
8441 CALL Z,chatter Call 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 engine_sfx_play_hook Call engine_sfx_play_hook
8462 CALL main_loop_10 Call main_loop_10
8465 CALL scroll_horizon Call scroll_horizon
8468 CALL engine_sfx_play_hook Call engine_sfx_play_hook
846B CALL main_loop_12 Call main_loop_12
846E CALL engine_sfx_play_hook Call engine_sfx_play_hook
8471 CALL main_loop_13 Call main_loop_13
8474 CALL engine_sfx_play_hook Call engine_sfx_play_hook
8477 CALL main_loop_14 Call main_loop_14
847A CALL tunnel_setup Call tunnel_setup
847D CALL spawn_hazards Call spawn_hazards
8480 CALL helicopter Call helicopter
8483 CALL main_loop_18 Call main_loop_18
8486 CALL engine_sfx_play_hook Call engine_sfx_play_hook
8489 CALL draw_hazards Call draw_hazards
848C CALL main_loop_20 Call main_loop_20
848F CALL engine_sfx_play_hook Call engine_sfx_play_hook
8492 CALL move_helicopter Call move_helicopter
8495 CALL check_collisions Call check_collisions
8498 CALL engine_sfx_play_hook Call engine_sfx_play_hook
849B CALL main_loop_23 Call main_loop_23
849E CALL engine_sfx_play_hook Call engine_sfx_play_hook
84A1 CALL main_loop_24 Call main_loop_24
84A4 CALL speed_score Call speed_score
84A7 CALL update_scoreboard Call update_scoreboard
84AA CALL calc_overtake_bonus Call overtake_bonus
84AD CALL engine_sfx_play_hook Call engine_sfx_play_hook
84B0 CALL drive_chatter Call drive_chatter
84B3 CALL draw_smash_bar Call smash_bar_etc
84B6 CALL transition Call transition
84B9 CALL engine_sfx_play_hook Call engine_sfx_play_hook
84BC CALL draw_screen Call draw_screen
84BF CALL road_handling_setup Call road_handling_setup
84C2 LD A,($8000) Is test mode enabled?
84C5 AND A If not, goto not_test_mode
84C6 JR Z,not_test_mode
Test mode handling
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,not_test_mode If none are set then jump
84D1 EX AF,AF'
84D2 LD BC,$0804
84D5 CALL start_sfx
84D8 CALL silence_audio_hook Call silence_audio_hook
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,main_loop_0 Jump if NOT
84E6 INC (HL) wanted_stage_number++
84E7 JP main_loop Exit via load_stage
main_loop_0 84EA RRA Is bit 2 set? (key 3 to load the end screen)
84EB JR NC,main_loop_1 Jump if NOT
84ED LD (HL),$06 wanted_stage_number = 6
84EF JP main_loop Exit via load_stage
main_loop_1 84F2 LD HL,$A13D Increment credits unless maxed out at 9
84F5 LD A,(HL)
84F6 CP $09
84F8 JR Z,not_test_mode
not_test_mode 84FB LD A,($A231) A = transition_control
84FE AND A Jump to ml_loop if non-zero
84FF JP NZ,ml_loop
Play once we have a 1-bit shifted out.
8502 LD HL,$A26B Address of start_speech
8505 SRL (HL) Shift the counter right
8507 JR NC,main_loop_2 Jump if no carry
8509 LD A,(HL) Load it
850A LD (HL),$00 Zero it
850C CALL play_speech_hook Call play_speech_hook
850F JP ml_loop Loop to ml_loop
main_loop_2 8512 LD A,($A26A) A = quit_state
8515 AND A Jump to ml_loop if not quitting
8516 JP Z,ml_loop
Quit 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
8524 CALL setup_transition Call setup_transition
8527 JP ml_loop Loop
Prev: 83CD Up: Map Next: 852A