Prev: 6E2F Up: Map Next: 6F13
6E5D: Handler: Car Type 1 (Driving Right)
Used by the routine at Handler_Cars.
Handles a car driving right across the screen. The car is made up of two sprites (10 pixels apart) representing the front and back.
When the car reaches the right edge it is reinitialised from a random position.
Handler_Car_Type1 6E5D LD IX,$DAC8 IX=Sprite02_3Wide_X_Position.
6E61 LD A,($5FBB) Call InitialiseCar if *RespawnFlag is set/ the room is being initialised.
6E64 OR A
6E65 CALL NZ,InitialiseCar
If the car crash timer is active, handle the crash animation.
6E68 LD A,($7208) A=*CarCrashTimer.
6E6B OR A Jump to Handler_CarType1_Drive if the crash timer is zero (car is driving normally).
6E6C JR Z,Handler_CarType1_Drive
This entry point is used by the routines at Handler_CarType2 and Handler_CarType3.
Handler_Car_Type1_0 6E6E CP $01 Jump to Handler_CarType1_CrashEnd if the crash timer has reached 01 (crash ending).
6E70 JR Z,Handler_CarType1_CrashEnd
Car is crashing — decrement the timer and cycle through crash animation frames.
6E72 DEC A Decrement the crash timer.
6E73 LD ($7208),A Write A to *CarCrashTimer.
6E76 AND %00000010 Keep only bit 1 (alternates between 00 and 02).
6E78 ADD A,$20 A+=20 (crash frame base).
6E7A EX AF,AF' Stash the frame in shadow AF.
If the car is on the lower road (Y=A0), use a different frame set.
6E7B LD A,(IX+$01) Load A with the car's Y position (from *IX+01).
6E7E CP $A0 Jump to Handler_CarType1_SetCrashFrame if the car is not on the lower road.
6E80 JR NZ,Handler_CarType1_SetCrashFrame
6E82 EX AF,AF' Retrieve the crash frame from shadow AF.
6E83 ADD A,$02 A+=02 (offset to left-facing crash frames).
6E85 JR Handler_CarType1_StoreCrashFrame Jump to Handler_CarType1_StoreCrashFrame.
Handler_CarType1_SetCrashFrame 6E87 EX AF,AF' Retrieve the crash frame from shadow AF.
Handler_CarType1_StoreCrashFrame 6E88 LD (IX+$03),A Write A to *IX+03 (front sprite frame).
6E8B INC A Increment A for the rear sprite.
6E8C LD (IX+$07),A Write A to *IX+07 (rear sprite frame).
6E8F JR Handler_CarCheckPercyCollision Jump to Handler_CarCheckPercyCollision.
Crash animation finished — clear the timer.
Handler_CarType1_CrashEnd 6E91 XOR A Write 00 to *CarCrashTimer.
6E92 LD ($7208),A
6E95 JR Handler_CarCheckPercyCollision Jump to Handler_CarCheckPercyCollision.
Car is driving normally — move it to the right.
Handler_CarType1_Drive 6E97 LD HL,$720C HL=CarSpeed2 (car speed).
6E9A LD A,(IX+$00) A=*IX+00 (car X position).
6E9D ADD A,(HL) A+=*HL (add speed).
6E9E CP $DE Call InitialiseCar to reinitialise the car if it's at the right edge.
6EA0 CALL NC,InitialiseCar
Update both sprite X positions (10 apart).
6EA3 LD (IX+$00),A Write A to *IX+00 (front X).
6EA6 ADD A,$10 A+=10.
6EA8 LD (IX+$04),A Write A to *IX+04 (rear X).
Set the driving right frames.
6EAB LD (IX+$03),$1C Write 1C to *IX+03 (front frame: driving right).
6EAF LD (IX+$07),$1D Write 1D to *IX+07 (rear frame: driving right).
Set the car colour for both sprites.
6EB3 LD A,($720A) Write *CarColour to;
  • *IX+02 (front colour)
  • *IX+06 (rear colour)
6EB6 LD (IX+$02),A
6EB9 LD (IX+$06),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 6EBC LD (IX+$21),$A0 Write A0 to *IX+21 (front underside Y).
6EC0 LD (IX+$25),$A0 Write A0 to *IX+25 (rear underside Y).
Set the X positions for the underside sprites (offset by 03 and 18 from the car's X).
6EC4 LD A,(IX+$00) A=*IX+00.
6EC7 ADD A,$03 A+=03.
6EC9 LD (IX+$20),A Write A to *IX+20 (front underside X).
6ECC ADD A,$15 A+=15.
6ECE LD (IX+$24),A Write A to *IX+24 (rear underside X).
Animate the wheels — cycle through frames 10-13.
6ED1 LD HL,$720D HL=CarWheelAnimation (wheel animation counter).
6ED4 LD A,(HL) A=*HL.
6ED5 INC A Increment the counter.
6ED6 AND %00000011 Keep only bits 0-1 (cycle 00-03).
6ED8 LD (HL),A Write back to *HL.
6ED9 ADD A,$10 A+=10 (wheel frame base).
6EDB LD (IX+$23),A Write A to *IX+23 (front wheel frame).
Offset the rear wheel animation by 02 for visual variety.
6EDE LD A,(HL) A=*HL.
6EDF ADD A,$02 A+=02.
6EE1 AND %00000011 Keep only bits 0-1.
6EE3 ADD A,$10 A+=10 (wheel frame base).
6EE5 LD (IX+$27),A Write A to *IX+27 (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 6EE8 LD A,($5FA9) A=*EggDropFlag.
6EEB OR A Call CheckCarEggCollision if the egg is active.
6EEC CALL NZ,CheckCarEggCollision
Check if the car has collided with Percy.
Handler_CarCheckPercyCollision 6EEF LD IX,$DAC0 IX=Percy_X_Position.
6EF3 LD IY,$DACC IY=Sprite03_3Wide_X_Position.
This entry point is used by the routine at Handler_Cars.
Handler_CarCheckPercyCollision_Test 6EF7 CALL CheckSpriteCollision Call CheckSpriteCollision.
6EFA RET C Return if no collision.
Car hit Percy — knock him backward.
Handler_CarKnockBackPercy 6EFB LD HL,$DAC0 HL=Percy_X_Position (Percy's X position).
6EFE LD A,(HL) A=*HL.
6EFF SUB $14 A-=14 (knock back distance).
6F01 JR C,Handler_CarKnockBackPercy_LeftEdge Jump to Handler_CarKnockBackPercy_LeftEdge if the result underflowed (Percy at the left edge).
Handler_Car_Type1_3 6F03 LD (HL),A Write the new X position to *HL.
6F04 INC HL Advance to Percy's Y position.
6F05 LD (HL),$78 Write 78 to *HL (set Percy's Y position after knockback).
6F07 LD ($5FA7),A Write A to *FallingState (set the falling state).
6F0A RET Return.
Percy was too close to the left edge — adjust position rightward.
Handler_CarKnockBackPercy_LeftEdge 6F0B LD A,(HL) A=*HL.
6F0C ADD A,$0A A+=0A.
6F0E JR Handler_Car_Type1_3 Jump to Handler_Car_Type1_3.
Alternate entry point for car initialisation.
InitialiseCar_Alternate 6F10 CALL InitialiseCar Call InitialiseCar.
Prev: 6E2F Up: Map Next: 6F13