![]() |
Routines |
| Prev: 36028 | Up: Map | Next: 36442 |
|
Read the controls, spend fuel when flying, and update Jetman's facing and animation.
|
||||||||
|
Face Jetman from LEFT/ RIGHT, or coast the current horizontal speed toward a rest.
|
||||||||
| Handler_JetmanMovement | 36102 | CALL HandlerControls | Call HandlerControls. | |||||
| 36105 | BIT 1,A | Jump to FaceJetmanLeft if LEFT is pressed. | ||||||
| 36107 | JP Z,FaceJetmanLeft | |||||||
| 36110 | BIT 0,A | Jump to FaceJetmanRight if RIGHT is pressed. | ||||||
| 36112 | JP Z,FaceJetmanRight | |||||||
| 36115 | LD A,(IX+5) | Jump to Handler_JetmanMovement_Read if the horizontal speed is zero. | ||||||
| 36118 | AND A | |||||||
| 36119 | JR Z,Handler_JetmanMovement_Read | |||||||
| 36121 | JP P,Handler_JetmanMovement_CoastRight | Jump to Handler_JetmanMovement_CoastRight if Jetman is moving right. | ||||||
|
Coast a leftward speed back toward rest.
|
||||||||
| 36124 | ADD A,2 | Add 2 to the speed. | ||||||
| 36126 | CP 208 | Jump to Handler_JetmanMovement_Grounded if it is now less than 208. | ||||||
| 36128 | JR C,Handler_JetmanMovement_Grounded | |||||||
| 36130 | CP 224 | Jump to Handler_JetmanMovement_Grounded if it is at least 224. | ||||||
| 36132 | JR NC,Handler_JetmanMovement_Grounded | |||||||
| 36134 | ADD A,16 | Add a further 16 to leave the mid-band. | ||||||
| 36136 | JR Handler_JetmanMovement_Grounded | Jump to Handler_JetmanMovement_Grounded. | ||||||
|
Coast a rightward speed back toward rest.
|
||||||||
| Handler_JetmanMovement_CoastRight | 36138 | ADD A,254 | Decrease the speed by 2. | |||||
| 36140 | CP 64 | Jump to Handler_JetmanMovement_Grounded if it is now at least 64. | ||||||
| 36142 | JR NC,Handler_JetmanMovement_Grounded | |||||||
| 36144 | CP 48 | Jump to Handler_JetmanMovement_Grounded if it is less than 48. | ||||||
| 36146 | JP C,Handler_JetmanMovement_Grounded | |||||||
| 36149 | SUB 16 | Subtract a further 16 to leave the mid-band. | ||||||
|
This entry point is used by the routines at FaceJetmanRight and FaceJetmanLeft.
|
||||||||
| Handler_JetmanMovement_Grounded | 36151 | LD (IX+5),A | Write the speed to *IX+5. | |||||
|
Read the thrust keys while any fuel remains.
|
||||||||
| Handler_JetmanMovement_Read | 36154 | CALL HandlerControls | Call HandlerControls. | |||||
| 36157 | LD B,A | Stash the controls in B. | ||||||
| 36158 | LD A,(24719) | Jump to Handler_JetmanMovement_Gravity if FuelLevel_2 is zero. | ||||||
| 36161 | AND A | |||||||
| 36162 | JR Z,Handler_JetmanMovement_Gravity | |||||||
| 36164 | BIT 3,B | Jump to ApplyJetmanUpwardThrust if UP is pressed. | ||||||
| 36166 | JP Z,ApplyJetmanUpwardThrust | |||||||
| 36169 | BIT 2,B | Jump to ClearJetmanThrust if DOWN is pressed. | ||||||
| 36171 | JP Z,ClearJetmanThrust | |||||||
|
Apply gravity when Jetman is not thrusting.
|
||||||||
| Handler_JetmanMovement_Gravity | 36174 | LD B,0 | Clear the fuel-spend base. | |||||
| 36176 | LD A,(IX+6) | Jump to Handler_JetmanMovement_ThrustStep if the vertical thrust is negative. | ||||||
| 36179 | AND A | |||||||
| 36180 | JP M,Handler_JetmanMovement_ThrustStep | |||||||
| 36183 | CP 64 | Jump to Handler_JetmanMovement_Loop if the downward thrust is already at least 64. | ||||||
| 36185 | JR NC,Handler_JetmanMovement_Loop | |||||||
|
The gravity step is 8 (signed +8). Upward thrust uses the opposite 248.
|
||||||||
| Handler_JetmanMovement_ThrustStep | 36187 | LD C,8 | Set the downward step to 8. | |||||
|
This entry point is used by the routine at ApplyJetmanUpwardThrust.
|
||||||||
| Handler_JetmanMovement_AddThrust | 36189 | ADD A,C | Add the step to the vertical thrust. | |||||
| 36190 | LD (IX+6),A | |||||||
|
Convert the thrust into a Y offset and test for the ground or a crater.
|
||||||||
| Handler_JetmanMovement_Loop | 36193 | LD A,(IX+6) | Fetch the vertical thrust. | |||||
| 36196 | SRA A | Divide it by 16. | ||||||
| 36198 | SRA A | |||||||
| 36200 | SRA A | |||||||
| 36202 | SRA A | |||||||
| 36204 | ADD A,(IX+4) | Add it to Jetman's Y position. | ||||||
| 36207 | CP 64 | Jump to ClearJetmanThrust if Jetman is above the play area. | ||||||
| 36209 | JP C,ClearJetmanThrust | |||||||
| 36212 | CP 176 | Jump to Handler_JetmanMovement_WriteY if Jetman is still above the ground line. | ||||||
| 36214 | JR C,Handler_JetmanMovement_WriteY | |||||||
|
Check the terrain beneath Jetman's new position.
|
||||||||
| 36216 | CALL ReadTerrainCell | Call ReadTerrainCell. | ||||||
| 36219 | LD A,D | Jump to Handler_JetmanMovement_ClampThrust if the first terrain cell is empty. | ||||||
| 36220 | AND A | |||||||
| 36221 | JR Z,Handler_JetmanMovement_ClampThrust | |||||||
| 36223 | LD A,E | Jump to Handler_JetmanMovement_ClampThrust if the second terrain cell is empty. | ||||||
| 36224 | AND A | |||||||
| 36225 | JR Z,Handler_JetmanMovement_ClampThrust | |||||||
| 36227 | LD A,E | Jump to LandJetman if neither cell has bit 3 set (a crater). | ||||||
| 36228 | OR D | |||||||
| 36229 | BIT 3,A | |||||||
| 36231 | JP Z,LandJetman | |||||||
|
When the cell is empty or a crater, snap to the ground line at Y=175 and give a small upward thrust of 224 (signed -32).
|
||||||||
| Handler_JetmanMovement_ClampThrust | 36234 | LD (IX+6),224 | Write 224 to the vertical thrust. | |||||
| 36238 | LD A,175 | A=175. | ||||||
| Handler_JetmanMovement_WriteY | 36240 | LD (IX+4),A | Write the Y position to *IX+4. | |||||
|
Spend fuel from the horizontal speed, then redraw the gauge.
|
||||||||
| Handler_JetmanMovement_FuelFromSpeed | 36243 | LD A,(IX+5) | Jump to Handler_JetmanMovement_HalveSpeed if the horizontal speed is positive. | |||||
| 36246 | AND A | |||||||
| 36247 | JP P,Handler_JetmanMovement_HalveSpeed | |||||||
| 36250 | NEG | Negate it so the spend uses the magnitude. | ||||||
| Handler_JetmanMovement_HalveSpeed | 36252 | SRA A | Halve the speed. | |||||
| 36254 | ADD A,B | Add the fuel-spend base. | ||||||
| 36255 | SLA A | Double the result. | ||||||
| 36257 | LD C,A | Store the spend in BC. | ||||||
| 36258 | LD B,0 | |||||||
| 36260 | LD HL,(24718) | Fetch the current fuel from FuelLevel_1. | ||||||
| 36263 | LD A,H | Jump to Handler_JetmanMovement_AfterFuel if the fuel has already run out. | ||||||
| 36264 | OR L | |||||||
| 36265 | JR Z,Handler_JetmanMovement_AfterFuel | |||||||
| 36267 | AND A | Reset the carry flag. | ||||||
|
Subtract the fuel expenditure from the current fuel level.
See Infinite Fuel.
|
||||||||
| Handler_JetmanMovement_SpendFuel | 36268 | SBC HL,BC | Subtract the spend from the fuel. | |||||
| 36270 | LD A,H | Jump to Handler_JetmanMovement_AfterFuel if the high fuel byte is not zero. | ||||||
| 36271 | AND A | |||||||
| 36272 | JR NZ,Handler_JetmanMovement_AfterFuel | |||||||
|
Queue a tune and empty the tank when the fuel is used up.
|
||||||||
| 36274 | LD DE,47661 | DE=Tune_Out_Of_Fuel. | ||||||
| 36277 | CALL QueueTune | Call QueueTune. | ||||||
| 36280 | LD HL,0 | HL=0000. | ||||||
|
Store the remaining fuel and redraw the gauge.
|
||||||||
| Handler_JetmanMovement_AfterFuel | 36283 | LD (24718),HL | Write the remaining fuel to FuelLevel_1. | |||||
| 36286 | LD A,H | Fetch the high fuel byte. | ||||||
| 36287 | LD HL,4160 | HL=4160 (gauge position). | ||||||
| 36290 | CALL DrawGauge | Call DrawGauge. | ||||||
|
Walk the 0-based sprite index: keep bits 2-7 (facing and flying/ walking) and merge bits 0-1 from the frame timer.
|
||||||||
| Handler_JetmanMovement_Animate | 36293 | CALL ApplyJetmanSpeed | Call ApplyJetmanSpeed. | |||||
| 36296 | LD A,(24130) | Fetch GameTimer. | ||||||
| 36299 | AND %00000011 | Keep only bits 0-1. | ||||||
| 36301 | LD C,A | Stash the frame bits. | ||||||
| 36302 | LD A,(IX+0) | Fetch the actor type. | ||||||
| 36305 | DEC A | Decrease it to a 0-based sprite index. | ||||||
| 36306 | AND %11111100 | Keep only bits 2-7. | ||||||
| 36308 | OR C | Merge in the frame bits. | ||||||
| 36309 | INC A | Restore the 1-based sprite ID. | ||||||
| 36310 | LD (IX+0),A | Write it back to *IX+0. | ||||||
|
Draw Jetman and fire the laser when FIRE is held.
|
||||||||
| Handler_JetmanMovement_Draw | 36313 | CALL DrawSprite | Call DrawSprite. | |||||
| 36316 | CALL ColouriseSprite | Call ColouriseSprite. | ||||||
| 36319 | CALL HandlerControls | Call HandlerControls. | ||||||
| 36322 | BIT 4,A | Call Handler_LaserBeam if FIRE is pressed. | ||||||
| 36324 | CALL Z,Handler_LaserBeam | |||||||
|
Queue a flying jingle on some frames.
|
||||||||
| 36327 | LD A,(65364) | Jump to Handler_JetmanMovement_RefillFromRover if Tune_Pointer is not Tune_Buffer_End. | ||||||
| 36330 | CP 81 | |||||||
| 36332 | JR NZ,Handler_JetmanMovement_RefillFromRover | |||||||
| 36334 | LD A,(24128) | Fetch RandomNumber. | ||||||
| 36337 | AND %01111111 | Keep only bits 0-6. | ||||||
| 36339 | JR NZ,Handler_JetmanMovement_RefillFromRover | Jump to Handler_JetmanMovement_RefillFromRover if the result is not zero. | ||||||
|
Pick a jingle from the table using the game timer and queue it.
|
||||||||
| 36341 | LD A,(24130) | Fetch GameTimer. | ||||||
| 36344 | AND %00001110 | Keep only bits 1-3. | ||||||
| 36346 | LD C,A | Convert that index into BC. | ||||||
| 36347 | LD B,0 | |||||||
| 36349 | LD HL,40368 | Point HL at the matching entry in Jetman_Tune_Table. | ||||||
| 36352 | ADD HL,BC | |||||||
| 36353 | LD E,(HL) | Fetch the tune pointer. | ||||||
| 36354 | INC HL | |||||||
| 36355 | LD D,(HL) | |||||||
| 36356 | CALL QueueTune | Call QueueTune. | ||||||
|
Refill the tank when Jetman is beside the rover, then take a platform (action key) or board (SPACE).
|
||||||||
| Handler_JetmanMovement_RefillFromRover | 36359 | LD A,(IX+4) | Fetch Jetman's Y position. | |||||
| 36362 | CP 168 | Return if it is less than 168. | ||||||
| 36364 | RET C | |||||||
|
Return unless the rover is on this screen and within reach.
|
||||||||
| 36365 | LD HL,(24698) | Fetch Jetman_Position. | ||||||
| 36368 | LD DE,(24722) | Fetch Rover_Position. | ||||||
| 36372 | AND A | Subtract the rover position from Jetman's. | ||||||
| 36373 | SBC HL,DE | |||||||
| 36375 | LD DE,12 | Add a 12 tolerance. | ||||||
| 36378 | ADD HL,DE | |||||||
| 36379 | LD A,H | Fetch the high byte of the gap. | ||||||
| 36380 | AND %00011111 | Keep only bits 0-4. | ||||||
| 36382 | RET NZ | Return if the rover is not on this screen. | ||||||
| 36383 | LD A,L | Return if the low byte is at least 24. | ||||||
| 36384 | CP 24 | |||||||
| 36386 | RET NC | |||||||
|
Refill the fuel tank.
|
||||||||
| 36387 | LD HL,36864 | Write 36864 to FuelLevel_1. | ||||||
| 36390 | LD (24718),HL | |||||||
|
Bit 0 of Jetman's flags is set while he is carrying an item.
|
||||||||
| 36393 | BIT 0,(IX+8) | Return if Jetman is already carrying an item. | ||||||
| 36397 | RET NZ | |||||||
| 36398 | CALL TestActionKey | Jump to Handler_JetmanMovement_TestSpace if the action key is not pressed. | ||||||
| 36401 | JR Z,Handler_JetmanMovement_TestSpace | |||||||
| 36403 | LD HL,24816 | HL=World_Slot_4. | ||||||
| 36406 | LD A,(HL) | Return if world slot 4 is already in use. | ||||||
| 36407 | AND A | |||||||
| 36408 | RET NZ | |||||||
|
Type 46 is the platform Jetman now carries.
|
||||||||
| 36409 | LD (HL),46 | Write type 46 to the slot. | ||||||
| 36411 | LD DE,7 | Move to the colour byte. | ||||||
| 36414 | ADD HL,DE | |||||||
| 36415 | LD (HL),67 | Write INK:MAGENTA, PAPER:BLACK (BRIGHT) to the colour. | ||||||
| 36417 | INC HL | Set bit 0 of the slot flags. | ||||||
| 36418 | SET 0,(HL) | |||||||
| 36420 | INC HL | Write 0 to *HL+2. | ||||||
| 36421 | INC HL | |||||||
| 36422 | LD (HL),0 | |||||||
| 36424 | SET 0,(IX+8) | Set bit 0 of Jetman's flags. | ||||||
| 36428 | JP SoundsTakeObject | Jump to SoundsTakeObject. | ||||||
|
Board the rover if SPACE is pressed.
|
||||||||
| Handler_JetmanMovement_TestSpace | 36431 | CALL TestSpaceKey | Return if SPACE is not pressed. | |||||
| 36434 | RET Z | |||||||
| 36435 | CALL PositionAndDrawSprite | Call PositionAndDrawSprite. | ||||||
| 36438 | CALL BoardMoonRover | Call BoardMoonRover. | ||||||
| 36441 | RET | Return. | ||||||
| Prev: 36028 | Up: Map | Next: 36442 |