![]() |
Routines |
| Prev: 28062 | Up: Map | Next: 28207 |
|
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 36-39 before the car resets.
|
||||||||
|
Check if respawning; if so, reset the car state.
|
||||||||
| Handler_Cars | 28075 | LD A,(24507) | Jump to Dispatch_Car_Handler if *RespawnFlag is unset. | |||||
| 28078 | OR A | |||||||
| 28079 | JR Z,Dispatch_Car_Handler | |||||||
| 28081 | XOR A | Write 0 to; | ||||||
| 28082 | LD (29192),A | |||||||
| 28085 | LD (29193),A | |||||||
|
Dispatch to the correct car handler based on the current room.
|
||||||||
| Dispatch_Car_Handler | 28088 | LD A,(24517) | Jump to Handler_CarType3 if *CurrentRoom is equal to 2. | |||||
| 28091 | CP 2 | |||||||
| 28093 | JP Z,Handler_CarType3 | |||||||
| 28096 | CP 1 | Jump to Handle_Car_Movement if the current room is equal to 1, else jump to Check_Room_09. | ||||||
| 28098 | JR NZ,Check_Room_09 | |||||||
| 28100 | JR Handle_Car_Movement | |||||||
| Check_Room_09 | 28102 | CP 9 | Return if the current room is less than 9. | |||||
| 28104 | RET C | |||||||
| 28105 | CP 9 | Jump to Handler_CarType2 if the current room is equal to 9. | ||||||
| 28107 | JP Z,Handler_CarType2 | |||||||
| Handle_Car_Movement | 28110 | CALL Handler_Car_Type1 | Call Handler_Car_Type1. | |||||
| 28113 | LD IX,56016 | Point IX at Sprite04_3Wide_X_Position (car sprite data). | ||||||
| 28117 | LD A,(24507) | Call Randomise_Car_Position if *RespawnFlag is set to randomise the car. | ||||||
| 28120 | OR A | |||||||
| 28121 | CALL NZ,Randomise_Car_Position | |||||||
|
Check if the car is in the crash animation.
|
||||||||
| 28124 | LD A,(29193) | Jump to Move_Car if *CarCrashCounter is zero, indicating there's been no crash. | ||||||
| 28127 | OR A | |||||||
| 28128 | JR Z,Move_Car | |||||||
| 28130 | CP 1 | Jump to Crash_Animation_Done if the crash counter is equal to 1 (crash animation complete). | ||||||
| 28132 | JR Z,Crash_Animation_Done | |||||||
|
Crash animation is playing; update the explosion frames.
|
||||||||
| 28134 | DEC A | Decrement the crash counter and write it back to *CarCrashCounter. | ||||||
| 28135 | LD (29193),A | |||||||
| 28138 | AND %00000010 | Mask and add 36 to select the front crash frame. | ||||||
| 28140 | ADD A,36 | |||||||
| 28142 | LD (IX+3),A | Write the frame to *IX+3 (front sprite). | ||||||
| 28145 | INC A | Increment by one for the rear crash frame and write to *IX+7. | ||||||
| 28146 | LD (IX+7),A | |||||||
| 28149 | JR Check_Car_Percy_Collision | Jump to Check_Car_Percy_Collision. | ||||||
|
Crash animation complete; reset the crash counter.
|
||||||||
| Crash_Animation_Done | 28151 | XOR A | Write 0 to *CarCrashCounter to clear it. | |||||
| 28152 | LD (29193),A | |||||||
| 28155 | JR Check_Car_Percy_Collision | Jump to Check_Car_Percy_Collision. | ||||||
|
No crash; move the car left across the screen.
|
||||||||
| Move_Car | 28157 | LD HL,29195 | Point HL at CarSpeed. | |||||
| 28160 | LD A,(IX+0) | Load the car's X position from *IX+0. | ||||||
| 28163 | SUB (HL) | Subtract the car speed; if the car has gone off-screen (carry set), call Randomise_Car_Position to randomise a new car. | ||||||
| 28164 | CALL C,Randomise_Car_Position | |||||||
| 28167 | LD (IX+0),A | Write the updated X position to *IX+0 (front X). | ||||||
| 28170 | ADD A,16 | Set the rear X position to the front X plus 16. | ||||||
| 28172 | LD (IX+4),A | |||||||
|
||||||||
| 28175 | LD (IX+3),30 | Set the front sprite frame to 30 (car front). | ||||||
|
||||||||
| 28179 | LD (IX+7),31 | Set the rear sprite frame to 31 (car rear). | ||||||
|
Check if Percy's egg has hit the car.
|
||||||||
| 28183 | LD BC,29193 | Point BC at CarCrashCounter and HL at Sprite04_3Wide_X_Position. | ||||||
| 28186 | LD HL,56016 | |||||||
| 28189 | LD A,(24489) | Call CheckCarEggCollision_Test if *EggDropFlag is non-zero to check for an egg collision with the car. | ||||||
| 28192 | OR A | |||||||
| 28193 | CALL NZ,CheckCarEggCollision_Test | |||||||
|
Check if the car has collided with Percy.
|
||||||||
| Check_Car_Percy_Collision | 28196 | LD IX,56000 | Point IX at Percy_X_Position. | |||||
| 28200 | LD IY,56016 | Point IY at Sprite04_3Wide_X_Position (car sprite data). | ||||||
| 28204 | JP Handler_CarCheckPercyCollision_Test | Jump to Handler_CarCheckPercyCollision_Test to check if the car has collided with Percy. | ||||||
| Prev: 28062 | Up: Map | Next: 28207 |