Prev: 6F13 Up: Map Next: 6F8D
6F54: 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 6F54 LD HL,$DAC8 HL=Sprite02_3Wide_X_Position.
6F57 LD BC,$7208 BC=CarCrashTimer (crash timer).
This entry point is used by the routine at Handler_Cars.
CheckCarEggCollision_Test 6F5A LD A,(HL) A=*HL.
6F5B PUSH AF Stash the original X position on the stack.
6F5C ADD A,$05 A+=05 (offset to centre of car).
6F5E LD (HL),A Write the adjusted position to *HL.
6F5F PUSH HL Copy HL to IX.
6F60 POP IX
6F62 LD IY,$DAE0 IY=Egg_X_Position (egg sprite data).
6F66 PUSH BC Stash BC on the stack.
6F67 CALL CheckEggCollision Call CheckEggCollision.
6F6A POP BC Restore BC from the stack.
6F6B JR C,CheckCarEggCollision_Miss Jump to CheckCarEggCollision_Miss if no collision.
Egg hit the car — restore the original X position and start the crash.
6F6D POP AF Restore the original X position from the stack.
6F6E LD (HL),A Write it back to *HL.
6F6F CALL GenerateRandomNumber Call GenerateRandomNumber.
6F72 OR %00010000 Set bit 4 (ensure a minimum crash duration).
6F74 LD (BC),A Write A to *BC (crash timer).
6F75 LD A,$0F Call AddToScore to add 0F points to the score.
6F77 CALL AddToScore
Play a short random sound burst — used as a hit sound effect by multiple routines.
PlayHitSound 6F7A LD B,$00 B=00 (loop 0100 times).
PlayHitSound_Loop 6F7C CALL GenerateRandomNumber Call GenerateRandomNumber.
6F7F AND %00011000 Keep only bits 3-4.
6F81 OR %00000001 Set bit 0 (border colour: blue).
6F83 OUT ($FE),A Send to the speaker.
6F85 NOP No operation.
6F86 NOP
6F87 DJNZ PlayHitSound_Loop Decrease B by one and loop back to PlayHitSound_Loop until done.
6F89 RET Return.
No collision — restore the original X position and return.
CheckCarEggCollision_Miss 6F8A POP AF Restore the original X position from the stack.
6F8B LD (HL),A Write it back to *HL.
6F8C RET Return.
Prev: 6F13 Up: Map Next: 6F8D