Prev: 28075 Up: Map Next: 28253
28207: Randomise Car Position
Used by the routine at Handler_Cars.
Generates random parameters for a new car entering from the right side of the screen. Sets a random movement speed, random sprite active flags, and resets the car to the bottom of the screen. Clamps the X position to a maximum of 222.
Input
IX Pointer to car sprite data
Randomise_Car_Position 28207 CALL GenerateRandomNumber Generate a random car speed of 1-4 and write to *CarSpeed.
28210 AND %00000011
28212 INC A
28213 LD (29195),A
28216 CALL GenerateRandomNumber Generate a random sprite active value of 4-7 and write to both *IX+2 and *IX+6.
28219 AND %00000011
28221 ADD A,4
28223 LD (IX+2),A
28226 LD (IX+6),A
28229 LD (IX+1),160 Set both Y positions (*IX+1 and *IX+5) to 160 (bottom of screen).
28233 LD (IX+5),160
28237 XOR A Write 0 to *CarCrashCounter to clear it.
28238 LD (29193),A
28241 LD A,(IX+0) Load the car X position from *IX+0.
28244 CP 222 Return if the car X position is less than 222.
28246 LD A,222
28248 RET C
28249 LD (IX+0),A Otherwise clamp the X position to 222 and return.
28252 RET
Prev: 28075 Up: Map Next: 28253