Prev: 28253 Up: Map Next: 28500
28435: Initialise Car
Used by the routine at Handler_Car_Type1.
Initialises a car with random speed, colour and position. The car starts at Y=144 (upper road) with the possibility of appearing at different X positions.
Input
IX Pointer to car sprite data
InitialiseCar 28435 CALL GenerateRandomNumber Call GenerateRandomNumber.
28438 AND %00000011 Keep only bits 0-1 (random speed 0-3).
28440 INC A Increment (speed 1-4).
28441 LD (29196),A Write A to *CarSpeed2.
Set a random appearance delay if the room is valid.
28444 LD A,(24517) A=*CurrentRoom.
28447 OR A Jump to InitialiseCar_PickColour if the room number is zero.
28448 JR Z,InitialiseCar_PickColour
28450 CALL GenerateRandomNumber Call GenerateRandomNumber.
28453 AND %00011111 Keep only bits 0-4.
28455 OR %00000001 Set bit 0 (ensure odd value).
28457 LD (29198),A Write A to *CarAppearanceDelay.
Pick a random colour, but reject colour 1 (blue).
InitialiseCar_PickColour 28460 CALL GenerateRandomNumber Call GenerateRandomNumber.
28463 AND %00000011 Keep only bits 0-1 (random colour 0-3).
28465 CP 1 Jump to InitialiseCar_PickColour if the colour is BLUE (pick again).
28467 JR Z,InitialiseCar_PickColour
28469 LD (29194),A Write A to *CarColour.
Clear the crash timer and set the car on the upper road.
28472 XOR A Write 0 to *CarCrashTimer.
28473 LD (29192),A
28476 LD (IX+1),144 Write 144 to *IX+1 (front Y: upper road).
28480 LD (IX+5),144 Write 144 to *IX+5 (rear Y: upper road).
28484 LD (IX+34),7 Write 7 to *IX+34 (front wheel colour: white).
28488 LD (IX+38),7 Write 7 to *IX+38 (rear wheel colour: white).
If the car's X position is past 100 reset it to the left.
28492 LD A,(IX+0) Load A with the car's X position (from *IX+0).
28495 CP 100 Return if the car's X position is less than 100 (position is valid).
28497 RET C
28498 XOR A A=0 (reset X position to the left edge).
28499 RET Return.
Prev: 28253 Up: Map Next: 28500