Prev: 6D9E Up: Map Next: 6E2F
6DAB: Handler: Cars
Used by the routine at Run_Main_Loop_Body.
Dispatches to the appropriate car handler based on the current room, then manages the car movement and crash animation. Cars move left across the screen and are randomised when they go off-screen. When hit by Percy's egg, a crash animation plays using frames 24-27 before the car resets.
Check if respawning; if so, reset the car state.
Handler_Cars 6DAB LD A,($5FBB) Jump to Dispatch_Car_Handler if *RespawnFlag is unset.
6DAE OR A
6DAF JR Z,Dispatch_Car_Handler
6DB1 XOR A Write 00 to;
6DB2 LD ($7208),A
6DB5 LD ($7209),A
Dispatch to the correct car handler based on the current room.
Dispatch_Car_Handler 6DB8 LD A,($5FC5) Jump to Handler_CarType3 if *CurrentRoom is equal to 02.
6DBB CP $02
6DBD JP Z,Handler_CarType3
6DC0 CP $01 Jump to Handle_Car_Movement if the current room is equal to 01, else jump to Check_Room_09.
6DC2 JR NZ,Check_Room_09
6DC4 JR Handle_Car_Movement
Check_Room_09 6DC6 CP $09 Return if the current room is less than 09.
6DC8 RET C
6DC9 CP $09 Jump to Handler_CarType2 if the current room is equal to 09.
6DCB JP Z,Handler_CarType2
Handle_Car_Movement 6DCE CALL Handler_Car_Type1 Call Handler_Car_Type1.
6DD1 LD IX,$DAD0 Point IX at Sprite04_3Wide_X_Position (car sprite data).
6DD5 LD A,($5FBB) Call Randomise_Car_Position if *RespawnFlag is set to randomise the car.
6DD8 OR A
6DD9 CALL NZ,Randomise_Car_Position
Check if the car is in the crash animation.
6DDC LD A,($7209) Jump to Move_Car if *CarCrashCounter is zero, indicating there's been no crash.
6DDF OR A
6DE0 JR Z,Move_Car
6DE2 CP $01 Jump to Crash_Animation_Done if the crash counter is equal to 01 (crash animation complete).
6DE4 JR Z,Crash_Animation_Done
Crash animation is playing; update the explosion frames.
6DE6 DEC A Decrement the crash counter and write it back to *CarCrashCounter.
6DE7 LD ($7209),A
6DEA AND %00000010 Mask and add 24 to select the front crash frame.
6DEC ADD A,$24
6DEE LD (IX+$03),A Write the frame to *IX+03 (front sprite).
6DF1 INC A Increment by one for the rear crash frame and write to *IX+07.
6DF2 LD (IX+$07),A
6DF5 JR Check_Car_Percy_Collision Jump to Check_Car_Percy_Collision.
Crash animation complete; reset the crash counter.
Crash_Animation_Done 6DF7 XOR A Write 00 to *CarCrashCounter to clear it.
6DF8 LD ($7209),A
6DFB JR Check_Car_Percy_Collision Jump to Check_Car_Percy_Collision.
No crash; move the car left across the screen.
Move_Car 6DFD LD HL,$720B Point HL at CarSpeed.
6E00 LD A,(IX+$00) Load the car's X position from *IX+00.
6E03 SUB (HL) Subtract the car speed; if the car has gone off-screen (carry set), call Randomise_Car_Position to randomise a new car.
6E04 CALL C,Randomise_Car_Position
6E07 LD (IX+$00),A Write the updated X position to *IX+00 (front X).
6E0A ADD A,$10 Set the rear X position to the front X plus 10.
6E0C LD (IX+$04),A
Sprite ID Sprite
1E udg44763-56x4
6E0F LD (IX+$03),$1E Set the front sprite frame to 1E (car front).
Sprite ID Sprite
1F udg44795-56x4
6E13 LD (IX+$07),$1F Set the rear sprite frame to 1F (car rear).
Check if Percy's egg has hit the car.
6E17 LD BC,$7209 Point BC at CarCrashCounter and HL at Sprite04_3Wide_X_Position.
6E1A LD HL,$DAD0
6E1D LD A,($5FA9) Call CheckCarEggCollision_Test if *EggDropFlag is non-zero to check for an egg collision with the car.
6E20 OR A
6E21 CALL NZ,CheckCarEggCollision_Test
Check if the car has collided with Percy.
Check_Car_Percy_Collision 6E24 LD IX,$DAC0 Point IX at Percy_X_Position.
6E28 LD IY,$DAD0 Point IY at Sprite04_3Wide_X_Position (car sprite data).
6E2C JP Handler_CarCheckPercyCollision_Test Jump to Handler_CarCheckPercyCollision_Test to check if the car has collided with Percy.
Prev: 6D9E Up: Map Next: 6E2F