![]() |
Routines |
| Prev: 8CBC | Up: Map | Next: 8E5A |
|
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 | 8D06 | CALL HandlerControls | Call HandlerControls. | |||||
| 8D09 | BIT 1,A | Jump to FaceJetmanLeft if LEFT is pressed. | ||||||
| 8D0B | JP Z,FaceJetmanLeft | |||||||
| 8D0E | BIT 0,A | Jump to FaceJetmanRight if RIGHT is pressed. | ||||||
| 8D10 | JP Z,FaceJetmanRight | |||||||
| 8D13 | LD A,(IX+$05) | Jump to Handler_JetmanMovement_Read if the horizontal speed is zero. | ||||||
| 8D16 | AND A | |||||||
| 8D17 | JR Z,Handler_JetmanMovement_Read | |||||||
| 8D19 | JP P,Handler_JetmanMovement_CoastRight | Jump to Handler_JetmanMovement_CoastRight if Jetman is moving right. | ||||||
|
Coast a leftward speed back toward rest.
|
||||||||
| 8D1C | ADD A,$02 | Add 02 to the speed. | ||||||
| 8D1E | CP $D0 | Jump to Handler_JetmanMovement_Grounded if it is now less than D0. | ||||||
| 8D20 | JR C,Handler_JetmanMovement_Grounded | |||||||
| 8D22 | CP $E0 | Jump to Handler_JetmanMovement_Grounded if it is at least E0. | ||||||
| 8D24 | JR NC,Handler_JetmanMovement_Grounded | |||||||
| 8D26 | ADD A,$10 | Add a further 10 to leave the mid-band. | ||||||
| 8D28 | JR Handler_JetmanMovement_Grounded | Jump to Handler_JetmanMovement_Grounded. | ||||||
|
Coast a rightward speed back toward rest.
|
||||||||
| Handler_JetmanMovement_CoastRight | 8D2A | ADD A,$FE | Decrease the speed by 02. | |||||
| 8D2C | CP $40 | Jump to Handler_JetmanMovement_Grounded if it is now at least 40. | ||||||
| 8D2E | JR NC,Handler_JetmanMovement_Grounded | |||||||
| 8D30 | CP $30 | Jump to Handler_JetmanMovement_Grounded if it is less than 30. | ||||||
| 8D32 | JP C,Handler_JetmanMovement_Grounded | |||||||
| 8D35 | SUB $10 | Subtract a further 10 to leave the mid-band. | ||||||
|
This entry point is used by the routines at FaceJetmanRight and FaceJetmanLeft.
|
||||||||
| Handler_JetmanMovement_Grounded | 8D37 | LD (IX+$05),A | Write the speed to *IX+05. | |||||
|
Read the thrust keys while any fuel remains.
|
||||||||
| Handler_JetmanMovement_Read | 8D3A | CALL HandlerControls | Call HandlerControls. | |||||
| 8D3D | LD B,A | Stash the controls in B. | ||||||
| 8D3E | LD A,($608F) | Jump to Handler_JetmanMovement_Gravity if FuelLevel_2 is zero. | ||||||
| 8D41 | AND A | |||||||
| 8D42 | JR Z,Handler_JetmanMovement_Gravity | |||||||
| 8D44 | BIT 3,B | Jump to ApplyJetmanUpwardThrust if UP is pressed. | ||||||
| 8D46 | JP Z,ApplyJetmanUpwardThrust | |||||||
| 8D49 | BIT 2,B | Jump to ClearJetmanThrust if DOWN is pressed. | ||||||
| 8D4B | JP Z,ClearJetmanThrust | |||||||
|
Apply gravity when Jetman is not thrusting.
|
||||||||
| Handler_JetmanMovement_Gravity | 8D4E | LD B,$00 | Clear the fuel-spend base. | |||||
| 8D50 | LD A,(IX+$06) | Jump to Handler_JetmanMovement_ThrustStep if the vertical thrust is negative. | ||||||
| 8D53 | AND A | |||||||
| 8D54 | JP M,Handler_JetmanMovement_ThrustStep | |||||||
| 8D57 | CP $40 | Jump to Handler_JetmanMovement_Loop if the downward thrust is already at least 40. | ||||||
| 8D59 | JR NC,Handler_JetmanMovement_Loop | |||||||
|
The gravity step is 08 (signed +08). Upward thrust uses the opposite F8.
|
||||||||
| Handler_JetmanMovement_ThrustStep | 8D5B | LD C,$08 | Set the downward step to 08. | |||||
|
This entry point is used by the routine at ApplyJetmanUpwardThrust.
|
||||||||
| Handler_JetmanMovement_AddThrust | 8D5D | ADD A,C | Add the step to the vertical thrust. | |||||
| 8D5E | LD (IX+$06),A | |||||||
|
Convert the thrust into a Y offset and test for the ground or a crater.
|
||||||||
| Handler_JetmanMovement_Loop | 8D61 | LD A,(IX+$06) | Fetch the vertical thrust. | |||||
| 8D64 | SRA A | Divide it by 10. | ||||||
| 8D66 | SRA A | |||||||
| 8D68 | SRA A | |||||||
| 8D6A | SRA A | |||||||
| 8D6C | ADD A,(IX+$04) | Add it to Jetman's Y position. | ||||||
| 8D6F | CP $40 | Jump to ClearJetmanThrust if Jetman is above the play area. | ||||||
| 8D71 | JP C,ClearJetmanThrust | |||||||
| 8D74 | CP $B0 | Jump to Handler_JetmanMovement_WriteY if Jetman is still above the ground line. | ||||||
| 8D76 | JR C,Handler_JetmanMovement_WriteY | |||||||
|
Check the terrain beneath Jetman's new position.
|
||||||||
| 8D78 | CALL ReadTerrainCell | Call ReadTerrainCell. | ||||||
| 8D7B | LD A,D | Jump to Handler_JetmanMovement_ClampThrust if the first terrain cell is empty. | ||||||
| 8D7C | AND A | |||||||
| 8D7D | JR Z,Handler_JetmanMovement_ClampThrust | |||||||
| 8D7F | LD A,E | Jump to Handler_JetmanMovement_ClampThrust if the second terrain cell is empty. | ||||||
| 8D80 | AND A | |||||||
| 8D81 | JR Z,Handler_JetmanMovement_ClampThrust | |||||||
| 8D83 | LD A,E | Jump to LandJetman if neither cell has bit 3 set (a crater). | ||||||
| 8D84 | OR D | |||||||
| 8D85 | BIT 3,A | |||||||
| 8D87 | JP Z,LandJetman | |||||||
|
When the cell is empty or a crater, snap to the ground line at Y=AF and give a small upward thrust of E0 (signed -20).
|
||||||||
| Handler_JetmanMovement_ClampThrust | 8D8A | LD (IX+$06),$E0 | Write E0 to the vertical thrust. | |||||
| 8D8E | LD A,$AF | A=AF. | ||||||
| Handler_JetmanMovement_WriteY | 8D90 | LD (IX+$04),A | Write the Y position to *IX+04. | |||||
|
Spend fuel from the horizontal speed, then redraw the gauge.
|
||||||||
| Handler_JetmanMovement_FuelFromSpeed | 8D93 | LD A,(IX+$05) | Jump to Handler_JetmanMovement_HalveSpeed if the horizontal speed is positive. | |||||
| 8D96 | AND A | |||||||
| 8D97 | JP P,Handler_JetmanMovement_HalveSpeed | |||||||
| 8D9A | NEG | Negate it so the spend uses the magnitude. | ||||||
| Handler_JetmanMovement_HalveSpeed | 8D9C | SRA A | Halve the speed. | |||||
| 8D9E | ADD A,B | Add the fuel-spend base. | ||||||
| 8D9F | SLA A | Double the result. | ||||||
| 8DA1 | LD C,A | Store the spend in BC. | ||||||
| 8DA2 | LD B,$00 | |||||||
| 8DA4 | LD HL,($608E) | Fetch the current fuel from FuelLevel_1. | ||||||
| 8DA7 | LD A,H | Jump to Handler_JetmanMovement_AfterFuel if the fuel has already run out. | ||||||
| 8DA8 | OR L | |||||||
| 8DA9 | JR Z,Handler_JetmanMovement_AfterFuel | |||||||
| 8DAB | AND A | Reset the carry flag. | ||||||
|
Subtract the fuel expenditure from the current fuel level.
See Infinite Fuel.
|
||||||||
| Handler_JetmanMovement_SpendFuel | 8DAC | SBC HL,BC | Subtract the spend from the fuel. | |||||
| 8DAE | LD A,H | Jump to Handler_JetmanMovement_AfterFuel if the high fuel byte is not zero. | ||||||
| 8DAF | AND A | |||||||
| 8DB0 | JR NZ,Handler_JetmanMovement_AfterFuel | |||||||
|
Queue a tune and empty the tank when the fuel is used up.
|
||||||||
| 8DB2 | LD DE,$BA2D | DE=Tune_Out_Of_Fuel. | ||||||
| 8DB5 | CALL QueueTune | Call QueueTune. | ||||||
| 8DB8 | LD HL,$0000 | HL=0000. | ||||||
|
Store the remaining fuel and redraw the gauge.
|
||||||||
| Handler_JetmanMovement_AfterFuel | 8DBB | LD ($608E),HL | Write the remaining fuel to FuelLevel_1. | |||||
| 8DBE | LD A,H | Fetch the high fuel byte. | ||||||
| 8DBF | LD HL,$1040 | HL=1040 (gauge position). | ||||||
| 8DC2 | 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 | 8DC5 | CALL ApplyJetmanSpeed | Call ApplyJetmanSpeed. | |||||
| 8DC8 | LD A,($5E42) | Fetch GameTimer. | ||||||
| 8DCB | AND %00000011 | Keep only bits 0-1. | ||||||
| 8DCD | LD C,A | Stash the frame bits. | ||||||
| 8DCE | LD A,(IX+$00) | Fetch the actor type. | ||||||
| 8DD1 | DEC A | Decrease it to a 0-based sprite index. | ||||||
| 8DD2 | AND %11111100 | Keep only bits 2-7. | ||||||
| 8DD4 | OR C | Merge in the frame bits. | ||||||
| 8DD5 | INC A | Restore the 1-based sprite ID. | ||||||
| 8DD6 | LD (IX+$00),A | Write it back to *IX+00. | ||||||
|
Draw Jetman and fire the laser when FIRE is held.
|
||||||||
| Handler_JetmanMovement_Draw | 8DD9 | CALL DrawSprite | Call DrawSprite. | |||||
| 8DDC | CALL ColouriseSprite | Call ColouriseSprite. | ||||||
| 8DDF | CALL HandlerControls | Call HandlerControls. | ||||||
| 8DE2 | BIT 4,A | Call Handler_LaserBeam if FIRE is pressed. | ||||||
| 8DE4 | CALL Z,Handler_LaserBeam | |||||||
|
Queue a flying jingle on some frames.
|
||||||||
| 8DE7 | LD A,($FF54) | Jump to Handler_JetmanMovement_RefillFromRover if Tune_Pointer is not Tune_Buffer_End. | ||||||
| 8DEA | CP $51 | |||||||
| 8DEC | JR NZ,Handler_JetmanMovement_RefillFromRover | |||||||
| 8DEE | LD A,($5E40) | Fetch RandomNumber. | ||||||
| 8DF1 | AND %01111111 | Keep only bits 0-6. | ||||||
| 8DF3 | 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.
|
||||||||
| 8DF5 | LD A,($5E42) | Fetch GameTimer. | ||||||
| 8DF8 | AND %00001110 | Keep only bits 1-3. | ||||||
| 8DFA | LD C,A | Convert that index into BC. | ||||||
| 8DFB | LD B,$00 | |||||||
| 8DFD | LD HL,$9DB0 | Point HL at the matching entry in Jetman_Tune_Table. | ||||||
| 8E00 | ADD HL,BC | |||||||
| 8E01 | LD E,(HL) | Fetch the tune pointer. | ||||||
| 8E02 | INC HL | |||||||
| 8E03 | LD D,(HL) | |||||||
| 8E04 | 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 | 8E07 | LD A,(IX+$04) | Fetch Jetman's Y position. | |||||
| 8E0A | CP $A8 | Return if it is less than A8. | ||||||
| 8E0C | RET C | |||||||
|
Return unless the rover is on this screen and within reach.
|
||||||||
| 8E0D | LD HL,($607A) | Fetch Jetman_Position. | ||||||
| 8E10 | LD DE,($6092) | Fetch Rover_Position. | ||||||
| 8E14 | AND A | Subtract the rover position from Jetman's. | ||||||
| 8E15 | SBC HL,DE | |||||||
| 8E17 | LD DE,$000C | Add a 0C tolerance. | ||||||
| 8E1A | ADD HL,DE | |||||||
| 8E1B | LD A,H | Fetch the high byte of the gap. | ||||||
| 8E1C | AND %00011111 | Keep only bits 0-4. | ||||||
| 8E1E | RET NZ | Return if the rover is not on this screen. | ||||||
| 8E1F | LD A,L | Return if the low byte is at least 18. | ||||||
| 8E20 | CP $18 | |||||||
| 8E22 | RET NC | |||||||
|
Refill the fuel tank.
|
||||||||
| 8E23 | LD HL,$9000 | Write 9000 to FuelLevel_1. | ||||||
| 8E26 | LD ($608E),HL | |||||||
|
Bit 0 of Jetman's flags is set while he is carrying an item.
|
||||||||
| 8E29 | BIT 0,(IX+$08) | Return if Jetman is already carrying an item. | ||||||
| 8E2D | RET NZ | |||||||
| 8E2E | CALL TestActionKey | Jump to Handler_JetmanMovement_TestSpace if the action key is not pressed. | ||||||
| 8E31 | JR Z,Handler_JetmanMovement_TestSpace | |||||||
| 8E33 | LD HL,$60F0 | HL=World_Slot_4. | ||||||
| 8E36 | LD A,(HL) | Return if world slot 4 is already in use. | ||||||
| 8E37 | AND A | |||||||
| 8E38 | RET NZ | |||||||
|
Type 2E is the platform Jetman now carries.
|
||||||||
| 8E39 | LD (HL),$2E | Write type 2E to the slot. | ||||||
| 8E3B | LD DE,$0007 | Move to the colour byte. | ||||||
| 8E3E | ADD HL,DE | |||||||
| 8E3F | LD (HL),$43 | Write INK:MAGENTA, PAPER:BLACK (BRIGHT) to the colour. | ||||||
| 8E41 | INC HL | Set bit 0 of the slot flags. | ||||||
| 8E42 | SET 0,(HL) | |||||||
| 8E44 | INC HL | Write 00 to *HL+02. | ||||||
| 8E45 | INC HL | |||||||
| 8E46 | LD (HL),$00 | |||||||
| 8E48 | SET 0,(IX+$08) | Set bit 0 of Jetman's flags. | ||||||
| 8E4C | JP SoundsTakeObject | Jump to SoundsTakeObject. | ||||||
|
Board the rover if SPACE is pressed.
|
||||||||
| Handler_JetmanMovement_TestSpace | 8E4F | CALL TestSpaceKey | Return if SPACE is not pressed. | |||||
| 8E52 | RET Z | |||||||
| 8E53 | CALL PositionAndDrawSprite | Call PositionAndDrawSprite. | ||||||
| 8E56 | CALL BoardMoonRover | Call BoardMoonRover. | ||||||
| 8E59 | RET | Return. | ||||||
| Prev: 8CBC | Up: Map | Next: 8E5A |