![]() |
Routines |
| Prev: 28210 | Up: Map | Next: 28354 |
|
Used by the routine at HandlerAccelerate.
Counts down the bounce, steers the car, uses up fuel and updates the temperature and the gauges.
|
||||
|
Count down the bounce; the sound is only made while this is not zero.
|
||||
| HandlerSteering | 28227 | LD A,(24133) | Fetch the bounce counter (BounceCounter). | |
| 28230 | AND A | Jump to HandlerSteering_Steer if the bounce is over. | ||
| 28231 | JR Z,HandlerSteering_Steer | |||
| 28233 | DEC A | Count down the bounce. | ||
| 28234 | LD (24133),A | Write the bounce counter back to BounceCounter. | ||
| 28237 | JR Z,HandlerSteering_StoreSound | Jump to HandlerSteering_StoreSound if the counter is now zero. | ||
| 28239 | LD A,2 | A=2. | ||
| HandlerSteering_StoreSound | 28241 | LD (24135),A | Write A to SoundStore. | |
|
Steer the car.
|
||||
| HandlerSteering_Steer | 28244 | CALL ReadInputLR | Read the steering keys using ReadInputLR. | |
| 28247 | LD HL,(24080) | Point HL at the direction (Player_Direction). | ||
| 28250 | LD E,24 | Set the amount to turn by, 24. | ||
| 28252 | BIT 1,A | Jump to HandlerSteering_TurnLeft if left is pressed. | ||
| 28254 | JP Z,HandlerSteering_TurnLeft | |||
| 28257 | BIT 0,A | Jump to HandlerSteering_TurnRight if right is pressed. | ||
| 28259 | JP Z,HandlerSteering_TurnRight | |||
| 28262 | LD E,0 | Set the amount to turn by to 0 as the car is going straight on. | ||
| 28264 | JR HandlerFuel | Jump to HandlerFuel. | ||
|
This instruction is never used.
|
||||
| 28266 | LD E,24 | E=24. | ||
|
Turn right.
|
||||
| HandlerSteering_TurnRight | 28268 | LD D,0 | Clear the high byte of the amount to turn by. | |
| 28270 | ADD HL,DE | Add the amount to turn by to the direction. | ||
| 28271 | LD (24080),HL | Write the direction back to Player_Direction. | ||
| 28274 | JR HandlerFuel | Jump to HandlerFuel. | ||
|
This instruction is never used.
|
||||
| 28276 | LD E,24 | E=24. | ||
|
Turn left.
|
||||
| HandlerSteering_TurnLeft | 28278 | LD D,0 | Clear the high byte of the amount to turn by. | |
| 28280 | AND A | Take the amount to turn by away from the direction. | ||
| 28281 | SBC HL,DE | |||
| 28283 | LD (24080),HL | Write the direction back to Player_Direction. | ||
|
Don't "use fuel" on every frame. This routine uses the last two bits of the GameTimer (i.e. a number between 0-3) to only process every fourth frame.
|
||||
| HandlerFuel | 28286 | LD A,(24105) | Fetch the game timer (GameTimer). | |
| 28289 | AND %00000011 | Keep only bits 0-1. | ||
| 28291 | JR NZ,HandlerTemperatureGauge | If the result is not zero then jump to HandlerTemperatureGauge. | ||
|
Handles "using" fuel.
|
||||
| 28293 | LD A,(24077) | Fetch the speed of the car (Speed). | ||
| 28296 | LD C,A | Use the speed as the amount of fuel to use, in C. | ||
| 28297 | LD B,0 | Clear the high byte of the amount of fuel to use. | ||
| 28299 | LD HL,(24074) | Fetch the fuel (Fuel_LSB). | ||
|
A higher speed uses more fuel.
|
||||
| 28302 | SBC HL,BC | HL=HL (fuel) - BC (speed). | ||
| 28304 | JR C,FuelSkipWrite | If there's "carry" (i.e. if the player has run out of fuel) jump to FuelSkipWrite. | ||
| 28306 | LD (24074),HL | Write HL to Fuel_LSB. | ||
| FuelSkipWrite | 28309 | CP 176 | If the current speed is more than 176 (top speed) jump to TemperatureMaxSpeed. | |
| 28311 | JR NC,TemperatureMaxSpeed | |||
| 28313 | CP 96 | Compare current speed with 96. | ||
|
Handle the temperature gauge.
|
||||
| HandlerTemperatureGauge | 28315 | LD A,(24076) | Fetch the temperature (Temperature). | |
| 28318 | JR C,TemperatureDrop | If there's carry set (this could be either from 28313 or 28289) then jump to TemperatureDrop. | ||
| DrawTemperatureGauge | 28320 | LD HL,20834 | Set the screen location of the temperature gauge, 20834. | |
| 28323 | CALL DrawGaugeLine | Draw the temperature gauge using DrawGaugeLine. | ||
|
Handle the fuel gauge.
|
||||
| 28326 | LD A,(24075) | Fetch the fuel level (Fuel_MSB). | ||
| 28329 | LD HL,20770 | Set the screen location of the fuel gauge, 20770. | ||
| 28332 | JP DrawGaugeLine | Draw the fuel gauge using DrawGaugeLine. | ||
|
Handle the temperature gauge at maximum speed.
|
||||
| TemperatureMaxSpeed | 28335 | LD A,(24076) | Fetch the temperature (Temperature). | |
|
Check if the temperature is already at the upper limit.
|
||||
| 28338 | CP 192 | If the current temperature is more than 192 jump to DrawTemperatureGauge. | ||
| 28340 | JR NC,DrawTemperatureGauge | |||
|
Go ahead and increase the temperature...
|
||||
| 28342 | INC A | Increase the temperature by one. | ||
| UpdateTemperature | 28343 | LD (24076),A | Write the new temperature back to Temperature. | |
| 28346 | JR DrawTemperatureGauge | Jump to DrawTemperatureGauge. | ||
|
Handles dropping the temperature gauge.
|
||||
| TemperatureDrop | 28348 | AND A | If the current temperature is at zero jump to DrawTemperatureGauge. | |
| 28349 | JR Z,DrawTemperatureGauge | |||
| 28351 | DEC A | Decrease the temperature by one. | ||
| 28352 | JR UpdateTemperature | Jump to UpdateTemperature. | ||
| Prev: 28210 | Up: Map | Next: 28354 |