Prev: 36869 Up: Map Next: 36987
36896: 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 36896 LD A,(24172) Return if PlayerInactive is already set.
36899 AND A
36900 RET NZ
36901 LD A,(24720) Fetch the rover type from Rover_Slot.
Rover sprite IDs begin at 26. Continue only when the type is in the 16 rover frames 26-41.
36904 SUB 26 Subtract 26.
36906 CP 16 Return if that is not a rover frame.
36908 RET NC
Copy the default Jetman actor into the live slot.
36909 LD HL,40282 Copy the default 24-byte Jetman data from Jetman_Default_Data to the Jetman slot at Jetman_Slot.
36912 LD DE,24696
36915 LD BC,24
36918 LDIR
36920 LD HL,(24722) Fetch Rover_Position.
36923 LD BC,(24962) Fetch AlienBase_WorldX.
36927 CALL Handler_Missile_CompareWorldX Call Handler_Missile_CompareWorldX.
36930 LD HL,(24722) Fetch Rover_Position again.
36933 JR NC,InitialiseJetman_OffsetLeft Jump to InitialiseJetman_OffsetLeft if the rover is outside the 4096 range of AlienBase_WorldX.
Offset Jetman 64 to the right of the rover. The left-hand path at InitialiseJetman_OffsetLeft uses 65472.
36935 LD BC,64 Set the offset in BC to 0064.
Set the terrain scroll position from the offset world X.
InitialiseJetman_Scroll 36938 CALL MaskWorldX Call MaskWorldX.
36941 LD A,L Fetch the low byte of the masked position.
36942 AND %11111000 Keep only bits 3-7.
36944 LD L,A Write it back to L.
36945 LD (24698),HL Write the position to Jetman_Position.
Hold a longer start delay in a 2UP game.
36948 LD A,64 A=64.
36950 LD HL,24064 HL=GameOptions.
36953 BIT 0,(HL) Jump to InitialiseJetman_WriteDelay if this is a 1UP game.
36955 JR Z,InitialiseJetman_WriteDelay
36957 ADD A,63 Add 63 to the delay.
InitialiseJetman_WriteDelay 36959 LD (24167),A Write the delay to GameDelayTimer.
InitialiseJetman_ReadLives 36962 LD A,(24225) Fetch ActivePlayer_Lives.
InitialiseJetman_DecreaseLives 36965 DEC A Decrease the lives counter by one.
InitialiseJetman_WriteLives 36966 LD (24225),A Write it back to ActivePlayer_Lives.
36864 is a full tank.
36969 LD HL,36864 Fill FuelLevel_1.
36972 LD (24718),HL
Clear PlayerInactive so Jetman is in play.
36975 XOR A Write 0 to PlayerInactive.
36976 LD (24172),A
36979 JP DisplayPlayerLives Jump to DisplayPlayerLives.
Offset Jetman 64 to the left of the rover.
InitialiseJetman_OffsetLeft 36982 LD BC,65472 Set the offset in BC to 65472 (-64).
36985 JR InitialiseJetman_Scroll Jump to InitialiseJetman_Scroll.
Prev: 36869 Up: Map Next: 36987