Prev: 6F54 Up: Map Next: 7028
6F8D: Handler: Car Type 2 (Driving Left)
Used by the routine at Handler_Cars.
Handles a car driving left across the screen. When it reaches the left boundary it turns around and drives right at ground level until reaching the right edge, then reinitialises.
Handler_CarType2 6F8D LD IX,$DAC8 IX=Sprite02_3Wide_X_Position.
6F91 LD HL,$720B HL=CarSpeed (car speed).
If the room is being initialised, set up the car.
6F94 LD A,($5FBB) Jump to Handler_CarType2_Initialise if *RespawnFlag is set.
6F97 OR A
6F98 JR NZ,Handler_CarType2_Initialise
If the car crash timer is active, handle the crash animation.
6F9A LD A,($7208) Jump to Handler_Car_Type1_0 if *CarCrashTimer is active.
6F9D OR A
6F9E JP NZ,Handler_Car_Type1_0
Check which road the car is on.
6FA1 LD A,(IX+$01) A=*IX+01 (car Y position).
6FA4 CP $90 Jump to Handler_CarType2_DriveRight if on the upper road.
6FA6 JR Z,Handler_CarType2_DriveRight
Car is on the lower road (Y=A0) — driving left.
6FA8 LD A,(IX+$00) A=*IX+00 (car X position).
6FAB SUB (HL) A-=*HL (subtract speed).
6FAC CP $68 Jump to Handler_CarType2_TurnAround if at the left boundary (turn around).
6FAE JR C,Handler_CarType2_TurnAround
This entry point is used by the routine at Handler_CarType3.
Update positions and set driving left frames.
Handler_CarType2_UpdateLeft 6FB0 LD (IX+$00),A Write A to *IX+00 (front X).
6FB3 ADD A,$10 A+=10.
6FB5 LD (IX+$04),A Write A to *IX+04 (rear X).
6FB8 LD (IX+$01),$A0 Write A0 to *IX+01 (front Y: lower road).
6FBC LD (IX+$05),$A0 Write A0 to *IX+05 (rear Y: lower road).
Sprite ID Sprite
1E udg44763-56x4
6FC0 LD (IX+$03),$1E Write 1E to *IX+03 (front frame: driving left).
Sprite ID Sprite
1F udg44795-56x4
6FC4 LD (IX+$07),$1F Write 1F to *IX+07 (rear frame: driving left).
6FC8 JP Handler_Car_Type1_2 Jump to Handler_Car_Type1_2.
Car is on the upper road (Y=90) — driving right.
Handler_CarType2_DriveRight 6FCB LD A,(IX+$00) A=*IX+00 (car X position).
6FCE ADD A,(HL) A+=*HL (add speed).
6FCF CP $DE Jump to Handler_CarType2_Initialise if at the right edge (reinitialise).
6FD1 JR NC,Handler_CarType2_Initialise
This entry point is used by the routine at Handler_CarType3.
Update positions and set driving right frames.
Handler_CarType2_UpdateRight 6FD3 LD (IX+$00),A Write A to *IX+00 (front X).
6FD6 ADD A,$10 A+=10.
6FD8 LD (IX+$04),A Write A to *IX+04 (rear X).
6FDB LD (IX+$01),$90 Write 90 to *IX+01 (front Y: upper road).
6FDF LD (IX+$05),$90 Write 90 to *IX+05 (rear Y: upper road).
Sprite ID Sprite
1C udg44699-56x4
6FE3 LD (IX+$03),$1C Write 1C to *IX+03 (front frame: driving right).
Sprite ID Sprite
1D udg44731-56x4
6FE7 LD (IX+$07),$1D Write 1D to *IX+07 (rear frame: driving right).
6FEB JP Handler_Car_Type1_1 Jump to Handler_Car_Type1_1.
Car reached the left boundary — turn around. Pick a new random speed and colour, then start driving right from the left boundary.
Handler_CarType2_TurnAround 6FEE PUSH HL Stash HL on the stack.
6FEF CALL GenerateRandomNumber Call GenerateRandomNumber.
6FF2 POP HL Restore HL from the stack.
6FF3 AND %00000011 Keep only bits 0-1 (random speed 00-03).
6FF5 INC A Increment the random number by one (speed 01-04).
6FF6 LD (HL),A Write the new speed to *HL.
Pick a new colour, rejecting BLUE.
PickCarColour 6FF7 PUSH HL Stash HL on the stack.
6FF8 CALL GenerateRandomNumber Call GenerateRandomNumber.
6FFB POP HL Restore HL from the stack.
6FFC AND %00000011 Keep only bits 0-1 (random colour from BLACK,BLUE,RED,MAGENTA).
6FFE CP $01 Jump to PickCarColour if the colour is BLUE (pick again).
7000 JR Z,PickCarColour
7002 LD (IX+$02),A Write A to *IX+02 (front colour).
7005 LD (IX+$06),A Write A to *IX+06 (rear colour).
7008 LD A,$68 A=68 (left boundary X position).
700A JR Handler_CarType2_UpdateRight Jump to Handler_CarType2_UpdateRight.
Initialise car type 2 — start from the right edge driving left with a random speed and colour.
Handler_CarType2_Initialise 700C PUSH HL Stash HL on the stack.
700D CALL GenerateRandomNumber Call GenerateRandomNumber.
7010 POP HL Restore HL from the stack.
7011 AND %00000011 Keep only bits 0-1 (random speed 00-03).
7013 INC A Increment the random speed by one (speed 01-04).
7014 LD (HL),A Write the new speed to *HL.
Pick a colour, using the range 04-07 (bright colours).
7015 PUSH HL Stash HL on the stack.
7016 CALL GenerateRandomNumber Call GenerateRandomNumber.
7019 POP HL Restore HL from the stack.
701A AND %00000011 Keep only bits 0-1.
701C ADD A,$04 A+=04 (bright colour range).
701E LD (IX+$02),A Write A to *IX+02 (front colour).
7021 LD (IX+$06),A Write A to *IX+06 (rear colour).
7024 LD A,$DE A=DE (right edge X position).
7026 JR Handler_CarType2_UpdateLeft Jump to Handler_CarType2_UpdateLeft.
Prev: 6F54 Up: Map Next: 7028