Prev: 9005 Up: Map Next: 907B
9020: Initialise Jetman
Respawn Jetman beside the parked rover: copy the default actor into Jetman_Slot, set the start delay, take a life and refill the tank, unless PlayerInactive is already set.
Copy the default actor into Jetman_Slot if the rover is parked.
InitialiseJetman 9020 LD A,($5E6C) Return if PlayerInactive is already set.
9023 AND A
9024 RET NZ
9025 LD A,($6090) Fetch the rover type from Rover_Slot.
Rover sprite IDs begin at 1A. Continue only when the type is in the 10 rover frames 1A-29.
9028 SUB $1A Subtract 1A.
902A CP $10 Return if that is not a rover frame.
902C RET NC
Copy the default Jetman actor into the live slot.
902D LD HL,$9D5A Copy the default 18-byte Jetman data from Jetman_Default_Data to the Jetman slot at Jetman_Slot.
9030 LD DE,$6078
9033 LD BC,$0018
9036 LDIR
9038 LD HL,($6092) Fetch Rover_Position.
903B LD BC,($6182) Fetch AlienBase_WorldX.
903F CALL Handler_Missile_CompareWorldX Call Handler_Missile_CompareWorldX.
9042 LD HL,($6092) Fetch Rover_Position again.
9045 JR NC,InitialiseJetman_OffsetLeft Jump to InitialiseJetman_OffsetLeft if the rover is outside the 1000 range of AlienBase_WorldX.
Offset Jetman 40 to the right of the rover. The left-hand path at InitialiseJetman_OffsetLeft uses FFC0.
9047 LD BC,$0040 Set the offset in BC to 0040.
Set the terrain scroll position from the offset world X.
InitialiseJetman_Scroll 904A CALL MaskWorldX Call MaskWorldX.
904D LD A,L Fetch the low byte of the masked position.
904E AND %11111000 Keep only bits 3-7.
9050 LD L,A Write it back to L.
9051 LD ($607A),HL Write the position to Jetman_Position.
Hold a longer start delay in a 2UP game.
9054 LD A,$40 A=40.
9056 LD HL,$5E00 HL=GameOptions.
9059 BIT 0,(HL) Jump to InitialiseJetman_WriteDelay if this is a 1UP game.
905B JR Z,InitialiseJetman_WriteDelay
905D ADD A,$3F Add 3F to the delay.
InitialiseJetman_WriteDelay 905F LD ($5E67),A Write the delay to GameDelayTimer.
InitialiseJetman_ReadLives 9062 LD A,($5EA1) Fetch ActivePlayer_Lives.
InitialiseJetman_DecreaseLives 9065 DEC A Decrease the lives counter by one.
InitialiseJetman_WriteLives 9066 LD ($5EA1),A Write it back to ActivePlayer_Lives.
9000 is a full tank.
9069 LD HL,$9000 Fill FuelLevel_1.
906C LD ($608E),HL
Clear PlayerInactive so Jetman is in play.
906F XOR A Write 00 to PlayerInactive.
9070 LD ($5E6C),A
9073 JP DisplayPlayerLives Jump to DisplayPlayerLives.
Offset Jetman 40 to the left of the rover.
InitialiseJetman_OffsetLeft 9076 LD BC,$FFC0 Set the offset in BC to FFC0 (-40).
9079 JR InitialiseJetman_Scroll Jump to InitialiseJetman_Scroll.
Prev: 9005 Up: Map Next: 907B