![]() |
Routines |
| Prev: 28207 | Up: Map | Next: 28435 |
|
Used by the routine at Handler_Cars.
Handles a car driving right across the screen. The car is made up of two sprites (16 pixels apart) representing the front and back.
When the car reaches the right edge it is reinitialised from a random position.
|
||||
| Handler_Car_Type1 | 28253 | LD IX,56008 | IX=Sprite02_3Wide_X_Position. | |
| 28257 | LD A,(24507) | Call InitialiseCar if *RespawnFlag is set/ the room is being initialised. | ||
| 28260 | OR A | |||
| 28261 | CALL NZ,InitialiseCar | |||
|
If the car crash timer is active, handle the crash animation.
|
||||
| 28264 | LD A,(29192) | A=*CarCrashTimer. | ||
| 28267 | OR A | Jump to Handler_CarType1_Drive if the crash timer is zero (car is driving normally). | ||
| 28268 | JR Z,Handler_CarType1_Drive | |||
|
This entry point is used by the routines at Handler_CarType2 and Handler_CarType3.
|
||||
| Handler_Car_Type1_0 | 28270 | CP 1 | Jump to Handler_CarType1_CrashEnd if the crash timer has reached 1 (crash ending). | |
| 28272 | JR Z,Handler_CarType1_CrashEnd | |||
|
Car is crashing — decrement the timer and cycle through crash animation frames.
|
||||
| 28274 | DEC A | Decrement the crash timer. | ||
| 28275 | LD (29192),A | Write A to *CarCrashTimer. | ||
| 28278 | AND %00000010 | Keep only bit 1 (alternates between 0 and 2). | ||
| 28280 | ADD A,32 | A+=32 (crash frame base). | ||
| 28282 | EX AF,AF' | Stash the frame in shadow AF. | ||
|
If the car is on the lower road (Y=160), use a different frame set.
|
||||
| 28283 | LD A,(IX+1) | Load A with the car's Y position (from *IX+1). | ||
| 28286 | CP 160 | Jump to Handler_CarType1_SetCrashFrame if the car is not on the lower road. | ||
| 28288 | JR NZ,Handler_CarType1_SetCrashFrame | |||
| 28290 | EX AF,AF' | Retrieve the crash frame from shadow AF. | ||
| 28291 | ADD A,2 | A+=2 (offset to left-facing crash frames). | ||
| 28293 | JR Handler_CarType1_StoreCrashFrame | Jump to Handler_CarType1_StoreCrashFrame. | ||
| Handler_CarType1_SetCrashFrame | 28295 | EX AF,AF' | Retrieve the crash frame from shadow AF. | |
| Handler_CarType1_StoreCrashFrame | 28296 | LD (IX+3),A | Write A to *IX+3 (front sprite frame). | |
| 28299 | INC A | Increment A for the rear sprite. | ||
| 28300 | LD (IX+7),A | Write A to *IX+7 (rear sprite frame). | ||
| 28303 | JR Handler_CarCheckPercyCollision | Jump to Handler_CarCheckPercyCollision. | ||
|
Crash animation finished — clear the timer.
|
||||
| Handler_CarType1_CrashEnd | 28305 | XOR A | Write 0 to *CarCrashTimer. | |
| 28306 | LD (29192),A | |||
| 28309 | JR Handler_CarCheckPercyCollision | Jump to Handler_CarCheckPercyCollision. | ||
|
Car is driving normally — move it to the right.
|
||||
| Handler_CarType1_Drive | 28311 | LD HL,29196 | HL=CarSpeed2 (car speed). | |
| 28314 | LD A,(IX+0) | A=*IX+0 (car X position). | ||
| 28317 | ADD A,(HL) | A+=*HL (add speed). | ||
| 28318 | CP 222 | Call InitialiseCar to reinitialise the car if it's at the right edge. | ||
| 28320 | CALL NC,InitialiseCar | |||
|
Update both sprite X positions (16 apart).
|
||||
| 28323 | LD (IX+0),A | Write A to *IX+0 (front X). | ||
| 28326 | ADD A,16 | A+=16. | ||
| 28328 | LD (IX+4),A | Write A to *IX+4 (rear X). | ||
|
Set the driving right frames.
|
||||
| 28331 | LD (IX+3),28 | Write 28 to *IX+3 (front frame: driving right). | ||
| 28335 | LD (IX+7),29 | Write 29 to *IX+7 (rear frame: driving right). | ||
|
Set the car colour for both sprites.
|
||||
| 28339 | LD A,(29194) | Write *CarColour to;
|
||
| 28342 | LD (IX+2),A | |||
| 28345 | LD (IX+6),A | |||
|
This entry point is used by the routine at Handler_CarType2.
Set the Y positions for the wheels/underside sprites.
|
||||
| Handler_Car_Type1_1 | 28348 | LD (IX+33),160 | Write 160 to *IX+33 (front underside Y). | |
| 28352 | LD (IX+37),160 | Write 160 to *IX+37 (rear underside Y). | ||
|
Set the X positions for the underside sprites (offset by 3 and 24 from the car's X).
|
||||
| 28356 | LD A,(IX+0) | A=*IX+0. | ||
| 28359 | ADD A,3 | A+=3. | ||
| 28361 | LD (IX+32),A | Write A to *IX+32 (front underside X). | ||
| 28364 | ADD A,21 | A+=21. | ||
| 28366 | LD (IX+36),A | Write A to *IX+36 (rear underside X). | ||
|
Animate the wheels — cycle through frames 16-19.
|
||||
| 28369 | LD HL,29197 | HL=CarWheelAnimation (wheel animation counter). | ||
| 28372 | LD A,(HL) | A=*HL. | ||
| 28373 | INC A | Increment the counter. | ||
| 28374 | AND %00000011 | Keep only bits 0-1 (cycle 0-3). | ||
| 28376 | LD (HL),A | Write back to *HL. | ||
| 28377 | ADD A,16 | A+=16 (wheel frame base). | ||
| 28379 | LD (IX+35),A | Write A to *IX+35 (front wheel frame). | ||
|
Offset the rear wheel animation by 2 for visual variety.
|
||||
| 28382 | LD A,(HL) | A=*HL. | ||
| 28383 | ADD A,2 | A+=2. | ||
| 28385 | AND %00000011 | Keep only bits 0-1. | ||
| 28387 | ADD A,16 | A+=16 (wheel frame base). | ||
| 28389 | LD (IX+39),A | Write A to *IX+39 (rear wheel frame). | ||
|
This entry point is used by the routine at Handler_CarType2.
Check if Percy's egg has hit the car.
|
||||
| Handler_Car_Type1_2 | 28392 | LD A,(24489) | A=*EggDropFlag. | |
| 28395 | OR A | Call CheckCarEggCollision if the egg is active. | ||
| 28396 | CALL NZ,CheckCarEggCollision | |||
|
Check if the car has collided with Percy.
|
||||
| Handler_CarCheckPercyCollision | 28399 | LD IX,56000 | IX=Percy_X_Position. | |
| 28403 | LD IY,56012 | IY=Sprite03_3Wide_X_Position. | ||
|
This entry point is used by the routine at Handler_Cars.
|
||||
| Handler_CarCheckPercyCollision_Test | 28407 | CALL CheckSpriteCollision | Call CheckSpriteCollision. | |
| 28410 | RET C | Return if no collision. | ||
|
Car hit Percy — knock him backward.
|
||||
| Handler_CarKnockBackPercy | 28411 | LD HL,56000 | HL=Percy_X_Position (Percy's X position). | |
| 28414 | LD A,(HL) | A=*HL. | ||
| 28415 | SUB 20 | A-=20 (knock back distance). | ||
| 28417 | JR C,Handler_CarKnockBackPercy_LeftEdge | Jump to Handler_CarKnockBackPercy_LeftEdge if the result underflowed (Percy at the left edge). | ||
| Handler_Car_Type1_3 | 28419 | LD (HL),A | Write the new X position to *HL. | |
| 28420 | INC HL | Advance to Percy's Y position. | ||
| 28421 | LD (HL),120 | Write 120 to *HL (set Percy's Y position after knockback). | ||
| 28423 | LD (24487),A | Write A to *FallingState (set the falling state). | ||
| 28426 | RET | Return. | ||
|
Percy was too close to the left edge — adjust position rightward.
|
||||
| Handler_CarKnockBackPercy_LeftEdge | 28427 | LD A,(HL) | A=*HL. | |
| 28428 | ADD A,10 | A+=10. | ||
| 28430 | JR Handler_Car_Type1_3 | Jump to Handler_Car_Type1_3. | ||
|
Alternate entry point for car initialisation.
|
||||
| InitialiseCar_Alternate | 28432 | CALL InitialiseCar | Call InitialiseCar. | |
| Prev: 28207 | Up: Map | Next: 28435 |