Prev: 28435 Up: Map Next: 28557
28500: Check Car Egg Collision
Used by the routine at Handler_Car_Type1.
Checks if Percy's egg has hit the car. If so, starts the crash animation and awards points.
Input
IX Pointer to car sprite data
CheckCarEggCollision 28500 LD HL,56008 HL=Sprite02_3Wide_X_Position.
28503 LD BC,29192 BC=CarCrashTimer (crash timer).
This entry point is used by the routine at Handler_Cars.
CheckCarEggCollision_Test 28506 LD A,(HL) A=*HL.
28507 PUSH AF Stash the original X position on the stack.
28508 ADD A,5 A+=5 (offset to centre of car).
28510 LD (HL),A Write the adjusted position to *HL.
28511 PUSH HL Copy HL to IX.
28512 POP IX
28514 LD IY,56032 IY=Egg_X_Position (egg sprite data).
28518 PUSH BC Stash BC on the stack.
28519 CALL CheckEggCollision Call CheckEggCollision.
28522 POP BC Restore BC from the stack.
28523 JR C,CheckCarEggCollision_Miss Jump to CheckCarEggCollision_Miss if no collision.
Egg hit the car — restore the original X position and start the crash.
28525 POP AF Restore the original X position from the stack.
28526 LD (HL),A Write it back to *HL.
28527 CALL GenerateRandomNumber Call GenerateRandomNumber.
28530 OR %00010000 Set bit 4 (ensure a minimum crash duration).
28532 LD (BC),A Write A to *BC (crash timer).
28533 LD A,15 Call AddToScore to add 15 points to the score.
28535 CALL AddToScore
Play a short random sound burst — used as a hit sound effect by multiple routines.
PlayHitSound 28538 LD B,0 B=0 (loop 256 times).
PlayHitSound_Loop 28540 CALL GenerateRandomNumber Call GenerateRandomNumber.
28543 AND %00011000 Keep only bits 3-4.
28545 OR %00000001 Set bit 0 (border colour: blue).
28547 OUT (254),A Send to the speaker.
28549 NOP No operation.
28550 NOP
28551 DJNZ PlayHitSound_Loop Decrease B by one and loop back to PlayHitSound_Loop until done.
28553 RET Return.
No collision — restore the original X position and return.
CheckCarEggCollision_Miss 28554 POP AF Restore the original X position from the stack.
28555 LD (HL),A Write it back to *HL.
28556 RET Return.
Prev: 28435 Up: Map Next: 28557