![]() |
Routines |
| Prev: 6E5D | Up: Map | Next: 6F54 |
|
Used by the routine at Handler_Car_Type1.
Initialises a car with random speed, colour and position. The car starts at Y=90 (upper road) with the possibility of appearing at different X positions.
|
||||||||
| InitialiseCar | 6F13 | CALL GenerateRandomNumber | Call GenerateRandomNumber. | |||||
| 6F16 | AND %00000011 | Keep only bits 0-1 (random speed 00-03). | ||||||
| 6F18 | INC A | Increment (speed 01-04). | ||||||
| 6F19 | LD ($720C),A | Write A to *CarSpeed2. | ||||||
|
Set a random appearance delay if the room is valid.
|
||||||||
| 6F1C | LD A,($5FC5) | A=*CurrentRoom. | ||||||
| 6F1F | OR A | Jump to InitialiseCar_PickColour if the room number is zero. | ||||||
| 6F20 | JR Z,InitialiseCar_PickColour | |||||||
| 6F22 | CALL GenerateRandomNumber | Call GenerateRandomNumber. | ||||||
| 6F25 | AND %00011111 | Keep only bits 0-4. | ||||||
| 6F27 | OR %00000001 | Set bit 0 (ensure odd value). | ||||||
| 6F29 | LD ($720E),A | Write A to *CarAppearanceDelay. | ||||||
|
Pick a random colour, but reject colour 01 (blue).
|
||||||||
| InitialiseCar_PickColour | 6F2C | CALL GenerateRandomNumber | Call GenerateRandomNumber. | |||||
| 6F2F | AND %00000011 | Keep only bits 0-1 (random colour 00-03). | ||||||
| 6F31 | CP $01 | Jump to InitialiseCar_PickColour if the colour is BLUE (pick again). | ||||||
| 6F33 | JR Z,InitialiseCar_PickColour | |||||||
| 6F35 | LD ($720A),A | Write A to *CarColour. | ||||||
|
Clear the crash timer and set the car on the upper road.
|
||||||||
| 6F38 | XOR A | Write 00 to *CarCrashTimer. | ||||||
| 6F39 | LD ($7208),A | |||||||
| 6F3C | LD (IX+$01),$90 | Write 90 to *IX+01 (front Y: upper road). | ||||||
| 6F40 | LD (IX+$05),$90 | Write 90 to *IX+05 (rear Y: upper road). | ||||||
| 6F44 | LD (IX+$22),$07 | Write 07 to *IX+22 (front wheel colour: white). | ||||||
| 6F48 | LD (IX+$26),$07 | Write 07 to *IX+26 (rear wheel colour: white). | ||||||
|
If the car's X position is past 64 reset it to the left.
|
||||||||
| 6F4C | LD A,(IX+$00) | Load A with the car's X position (from *IX+00). | ||||||
| 6F4F | CP $64 | Return if the car's X position is less than 64 (position is valid). | ||||||
| 6F51 | RET C | |||||||
| 6F52 | XOR A | A=00 (reset X position to the left edge). | ||||||
| 6F53 | RET | Return. | ||||||
| Prev: 6E5D | Up: Map | Next: 6F54 |