Prev: 8401 Up: Map Next: 858C
852A: CPU driver
This runs the game loop while driving the car.
cpu_driver 852A LD HL,($A26C) Get road position
852D PUSH HL Subtract centre value. Carry flag will be set if we're on the right hand side of the road
852E LD DE,$0105
8531 SBC HL,DE
8533 POP HL
8534 LD A,$09 Set input ACCELERATE + RIGHT
8536 JR NC,cd_check_speed Jump cd_check_speed if we're on the left
8538 LD DE,$00F5 Subtract "ideal road position"? value. Carry will be set if we're on the right of it.
853B SBC HL,DE
853D LD A,$0A Set input ACCELERATE + LEFT
853F JR C,cd_check_speed Jump cd_check_speed if we're on the right
8541 LD A,$08 Set input ACCELERATE
cd_check_speed 8543 LD C,A Move input into C for the moment
8544 LD HL,($A24A) Calculate (speed - 150)
8547 LD DE,$0096
854A SBC HL,DE
854C LD A,($A253) Load gear
854F SBC A,$00 Set gear to low if speed < 150, otherwise high
8551 JR NZ,cd_set_input
8553 SET 4,C Set input GEAR
cd_set_input 8555 LD A,C Set user input
8556 LD ($A0D5),A
8559 CALL read_map Call read_map
855C CALL spawn_cars Call spawn_cars
855F CALL cycle_counters Call cycle_counters
8562 CALL main_loop_10 Call main_loop_10
8565 CALL scroll_horizon Call scroll_horizon
8568 CALL main_loop_12 Call main_loop_12
856B CALL main_loop_13 Call main_loop_13
856E CALL main_loop_14 Call main_loop_14
8571 CALL tunnel_setup Call tunnel_setup
8574 CALL spawn_hazards Call spawn_hazards
8577 CALL main_loop_18 Call main_loop_18
857A CALL main_loop_20 Call main_loop_20
857D CALL draw_hazards Call draw_hazards
8580 CALL move_hero_car Call move_hero_car
8583 CALL check_collisions Call check_collisions
8586 CALL main_loop_23 Call main_loop_23
8589 JP main_loop_24 Exit via main_loop_24
Prev: 8401 Up: Map Next: 858C