![]() |
Routines |
| Prev: 91BB | Up: Map | Next: 930C |
|
Drive the rover: refill the fuel gauge, read the controls and stop the rover at craters in the terrain ahead.
|
||||||||
|
Refill the tank, then steer from the controls.
|
||||||||
| Handler_MoonRover | 91E2 | LD A,($5E6C) | Jump to Handler_MoonRover_DrawSprite if PlayerInactive is set. | |||||
| 91E5 | AND A | |||||||
| 91E6 | JR NZ,Handler_MoonRover_DrawSprite | |||||||
| 91E8 | LD HL,$9000 | Write 9000 to FuelLevel_1. | ||||||
| 91EB | LD ($608E),HL | |||||||
| 91EE | LD A,H | Fetch the high fuel byte. | ||||||
| 91EF | LD HL,$1040 | HL=1040 (gauge position). | ||||||
| 91F2 | CALL DrawGauge | Call DrawGauge. | ||||||
|
Read the controls and speed the rover up if LEFT or RIGHT is held.
|
||||||||
| 91F5 | CALL HandlerControls | Call HandlerControls. | ||||||
| 91F8 | BIT 0,A | Jump to Handler_MoonRover_AccelerateRight if RIGHT is pressed. | ||||||
| 91FA | JP Z,Handler_MoonRover_AccelerateRight | |||||||
| 91FD | BIT 1,A | Jump to Handler_MoonRover_AccelerateLeft if LEFT is pressed. | ||||||
| 91FF | JP Z,Handler_MoonRover_AccelerateLeft | |||||||
|
Neither direction is held, so ease the speed back towards zero.
|
||||||||
| 9202 | LD A,(IX+$05) | Jump to Handler_MoonRover_Loop if the horizontal speed is zero. | ||||||
| 9205 | AND A | |||||||
| 9206 | JR Z,Handler_MoonRover_Loop | |||||||
| 9208 | JP P,Handler_MoonRover_Decelerate | Jump to Handler_MoonRover_Decelerate if the rover is moving right. | ||||||
| 920B | ADD A,$01 | Add 01 to the speed. | ||||||
| 920D | JR Handler_MoonRover_Loop | Jump to Handler_MoonRover_Loop. | ||||||
| Handler_MoonRover_Decelerate | 920F | SUB $01 | Subtract 01 from the speed. | |||||
| Handler_MoonRover_Loop | 9211 | LD (IX+$05),A | Write the speed to *IX+05. | |||||
|
Look ahead under the wheels for blocking terrain.
|
||||||||
| 9214 | LD HL,($607A) | Fetch Jetman_Position. | ||||||
| 9217 | BIT 7,(IX+$05) | Jump to Handler_MoonRover_LookLeft if the rover is moving left. | ||||||
| 921B | JP NZ,Handler_MoonRover_LookLeft | |||||||
| 921E | LD DE,$FFF8 | DE=FFF8. | ||||||
| Handler_MoonRover_LookAhead | 9221 | ADD HL,DE | Add the look-ahead offset. | |||||
| 9222 | SRA H | Divide the world position by 08. | ||||||
| 9224 | RR L | |||||||
| 9226 | SRA H | |||||||
| 9228 | RR L | |||||||
| 922A | SRA H | |||||||
| 922C | RR L | |||||||
| 922E | LD A,H | Fetch the high byte. | ||||||
| 922F | AND %00000011 | Keep only bits 0-1. | ||||||
| 9231 | LD H,A | Write it back to H. | ||||||
|
Scan the cells ahead of the rover and stop it at an empty cell or a crater.
|
||||||||
| 9232 | LD B,$06 | Set a cell counter in B for 06 loops. | ||||||
| 9234 | EX DE,HL | Switch the index into DE. | ||||||
| Handler_MoonRover_TestTerrain | 9235 | LD HL,$7000 | HL=TerrainData_Active. | |||||
| 9238 | ADD HL,DE | Point HL at that terrain cell. | ||||||
| 9239 | LD A,(HL) | Jump to Handler_MoonRover_Stop if the cell is empty. | ||||||
| 923A | AND A | |||||||
| 923B | JR Z,Handler_MoonRover_Stop | |||||||
| 923D | AND %00001000 | Keep only bit 3. | ||||||
| 923F | JR NZ,Handler_MoonRover_Stop | Jump to Handler_MoonRover_Stop if it is a crater. | ||||||
|
Step on to the next cell, wrapping the index.
|
||||||||
| 9241 | INC DE | Move onto the next cell. | ||||||
| 9242 | LD A,D | Fetch the high byte. | ||||||
| 9243 | AND %00000011 | Keep only bits 0-1. | ||||||
| 9245 | LD D,A | Write it back to D. | ||||||
| 9246 | DJNZ Handler_MoonRover_TestTerrain | Decrease the cell counter by one and loop back to Handler_MoonRover_TestTerrain until the scan is done. | ||||||
| 9248 | JR Handler_MoonRover_PickFrame | Jump to Handler_MoonRover_PickFrame. | ||||||
|
Stop the rover: it has reached an empty cell or a crater.
|
||||||||
| Handler_MoonRover_Stop | 924A | LD (IX+$05),$00 | Write 00 to the horizontal speed. | |||||
| 924E | JR Handler_MoonRover_ApplySpeed | Jump to Handler_MoonRover_ApplySpeed. | ||||||
|
Pick a facing frame from the fine X.
|
||||||||
| Handler_MoonRover_PickFrame | 9250 | LD A,(IX+$05) | Jump to Handler_MoonRover_ApplySpeed if the horizontal speed is zero. | |||||
| 9253 | AND A | |||||||
| 9254 | JR Z,Handler_MoonRover_ApplySpeed | |||||||
| 9256 | JP M,Handler_MoonRover_FineX | Jump to Handler_MoonRover_FineX if the rover is moving left. | ||||||
| 9259 | LD A,(IX+$02) | Fetch the low byte of the world X. | ||||||
| 925C | RRA | Rotate it right. | ||||||
| 925D | AND %00000011 | Keep only bits 0-1. | ||||||
|
Sprite IDs begin at 16 ("Lunar Rover: Right Frame 1").
|
||||||||
| 925F | ADD A,$16 | Add 16 for the right-facing frames. | ||||||
| 9261 | LD (IX+$00),A | Write it to the actor type. | ||||||
|
Move the rover along the planet and draw its sprite.
|
||||||||
| Handler_MoonRover_ApplySpeed | 9264 | CALL ApplyJetmanSpeed | Call ApplyJetmanSpeed. | |||||
| Handler_MoonRover_DrawSprite | 9267 | CALL DrawSpritePair | Call DrawSpritePair. | |||||
|
While Jetman is inactive, step the inactive counter and hand over to Handler_RoverFrames_Tint.
|
||||||||
| 926A | LD A,($5E6C) | Jump to Handler_MoonRover_ColourLights if PlayerInactive is zero. | ||||||
| 926D | AND A | |||||||
| 926E | JR Z,Handler_MoonRover_ColourLights | |||||||
| 9270 | INC A | Increment PlayerInactive by one. | ||||||
| 9271 | LD ($5E6C),A | |||||||
| 9274 | JP Handler_RoverFrames_Tint | Jump to Handler_RoverFrames_Tint. | ||||||
|
Colour the rover lights, body and banner.
|
||||||||
| Handler_MoonRover_ColourLights | 9277 | CALL ColouriseRoverLights | Call ColouriseRoverLights. | |||||
| 927A | LD DE,$BC9E | DE=Graphic_Moon_Rover_Attributes. | ||||||
| 927D | CALL WriteSpriteAttributes | Call WriteSpriteAttributes. | ||||||
| 9280 | CALL ColouriseBanner | Call ColouriseBanner. | ||||||
|
Leave the rover if SPACE has just been pressed.
|
||||||||
| 9283 | CALL TestSpaceKey | Call TestSpaceKey. | ||||||
| 9286 | CALL NZ,Handler_MoonRover_Leave | Call Handler_MoonRover_Leave if SPACE is pressed. | ||||||
|
Queue a jingle only when the tune buffer has finished and the random number allows it.
|
||||||||
| 9289 | LD A,($FF54) | Return if Tune_Pointer is not Tune_Buffer_End. | ||||||
| 928C | CP $51 | |||||||
| 928E | RET NZ | |||||||
| 928F | LD A,($5E40) | Fetch RandomNumber. | ||||||
| 9292 | AND %01111111 | Keep only bits 0-6. | ||||||
| 9294 | RET NZ | Return if the result is not zero. | ||||||
|
Choose a tune from the table using the game timer and queue it.
|
||||||||
| 9295 | LD A,($5E42) | Fetch GameTimer. | ||||||
| 9298 | AND %00001110 | Keep only bits 1-3. | ||||||
| 929A | LD C,A | Convert that index into BC. | ||||||
| 929B | LD B,$00 | |||||||
| 929D | LD HL,$9DB0 | Point HL at the matching entry in Jetman_Tune_Table. | ||||||
| 92A0 | ADD HL,BC | |||||||
| 92A1 | LD E,(HL) | Fetch the tune pointer. | ||||||
| 92A2 | INC HL | |||||||
| 92A3 | LD D,(HL) | |||||||
| 92A4 | JP QueueTune | Jump to QueueTune. | ||||||
|
Pick a left-facing frame from the fine X.
|
||||||||
| Handler_MoonRover_FineX | 92A7 | LD A,(IX+$02) | Fetch the low byte of the world X. | |||||
| 92AA | RRA | Rotate it right. | ||||||
| 92AB | AND %00000011 | Keep only bits 0-1. | ||||||
|
Sprite IDs begin at 12 ("Lunar Rover: Left Frame 4").
|
||||||||
| 92AD | ADD A,$12 | Add 12 for the left-facing frames. | ||||||
| 92AF | LD (IX+$00),A | Write it to the actor type. | ||||||
| 92B2 | JR Handler_MoonRover_ApplySpeed | Jump to Handler_MoonRover_ApplySpeed. | ||||||
|
Look further ahead when the rover is moving left.
|
||||||||
| Handler_MoonRover_LookLeft | 92B4 | LD DE,$FFF0 | DE=FFF0. | |||||
| 92B7 | JP Handler_MoonRover_LookAhead | Jump to Handler_MoonRover_LookAhead. | ||||||
|
Accelerate left, but cap the speed at E8.
|
||||||||
| Handler_MoonRover_AccelerateLeft | 92BA | LD A,(IX+$05) | Jump to Handler_MoonRover_SubtractSpeed if the horizontal speed is positive. | |||||
| 92BD | AND A | |||||||
| 92BE | JP P,Handler_MoonRover_SubtractSpeed | |||||||
| 92C1 | CP $E8 | Jump to Handler_MoonRover_Loop if the speed is already below E8. | ||||||
| 92C3 | JP C,Handler_MoonRover_Loop | |||||||
| Handler_MoonRover_SubtractSpeed | 92C6 | SUB $02 | Subtract 02 from the speed. | |||||
| 92C8 | JP Handler_MoonRover_Loop | Jump to Handler_MoonRover_Loop. | ||||||
|
Accelerate right, but cap the speed at 28.
|
||||||||
| Handler_MoonRover_AccelerateRight | 92CB | LD A,(IX+$05) | Jump to Handler_MoonRover_AddSpeed if the horizontal speed is negative. | |||||
| 92CE | AND A | |||||||
| 92CF | JP M,Handler_MoonRover_AddSpeed | |||||||
| 92D2 | CP $28 | Jump to Handler_MoonRover_Loop if the speed is already at least 28. | ||||||
| 92D4 | JP NC,Handler_MoonRover_Loop | |||||||
| Handler_MoonRover_AddSpeed | 92D7 | ADD A,$02 | Add 02 to the speed. | |||||
| 92D9 | JP Handler_MoonRover_Loop | Jump to Handler_MoonRover_Loop. | ||||||
|
Leave the rover and restore Jetman on foot.
|
||||||||
| Handler_MoonRover_Leave | 92DC | CALL SoundsDropItem | Call SoundsDropItem. | |||||
| 92DF | LD HL,$607A | Copy the 0E bytes of rover state from Jetman_Position back out of the Jetman slot to Rover_Position. | ||||||
| 92E2 | LD DE,$6092 | |||||||
| 92E5 | LD BC,$000E | |||||||
| 92E8 | LDIR | |||||||
|
Screen column 78 is standing beside the rover. Type 16 and above is facing right: walking frames 09 (left) and 0D (right), parked rover frames 1A and 22.
|
||||||||
| 92EA | LD (IX+$01),$78 | Write 78 to *IX+01. | ||||||
| 92EE | LD A,(IX+$00) | Jump to Handler_MoonRover_StandingFrame if the actor type is at least 16. | ||||||
| 92F1 | CP $16 | |||||||
| 92F3 | JR NC,Handler_MoonRover_StandingFrame | |||||||
|
When facing left, walk with type 09 and park the rover as type 1A.
|
||||||||
| 92F5 | LD (IX+$00),$09 | Write 09 to the actor type. | ||||||
| 92F9 | LD A,$1A | A=1A. | ||||||
|
Write the parked rover's type and finish by clearing the banner colour.
|
||||||||
| Handler_MoonRover_WriteType | 92FB | LD ($6090),A | Write A to Rover_Slot. | |||||
| 92FE | CALL PositionAndDrawSprite | Call PositionAndDrawSprite. | ||||||
| 9301 | JP ClearBannerColour | Jump to ClearBannerColour. | ||||||
|
When facing right, walk with type 0D and park the rover as type 22.
|
||||||||
| Handler_MoonRover_StandingFrame | 9304 | LD (IX+$00),$0D | Write 0D to the actor type. | |||||
| 9308 | LD A,$22 | A=22. | ||||||
| 930A | JR Handler_MoonRover_WriteType | Jump to Handler_MoonRover_WriteType. | ||||||
| Prev: 91BB | Up: Map | Next: 930C |