Prev: 41921 Up: Map Next: 42170
41983: Handler: Held Object
While Rover_Slot is a rover frame, test action to let Jetman take this object off the rover and clear RoverCargoFlag.
Input
IX Actor slot
Handler_HeldObject 41983 LD A,(24720) Fetch Rover_Slot.
41986 SUB 26 Subtract 26.
41988 CP 16 Jump to Handler_HeldObject_CycleFromUp if that is not a rover frame.
41990 JR NC,Handler_HeldObject_CycleFromUp
Let Jetman take the object off the rover when the action key is pressed beside it.
41992 BIT 1,(IX+8) Jump to Handler_HeldObject_Loop if bit 1 of the actor flags is set.
41996 JR NZ,Handler_HeldObject_Loop
41998 CALL TestActionKey Call TestActionKey.
42001 JR Z,Handler_HeldObject_Loop Jump to Handler_HeldObject_Loop if the action key is not pressed.
42003 CALL TestJetmanAction_ComparePosition Call TestJetmanAction_ComparePosition.
42006 JR NC,Handler_HeldObject_Loop Jump to Handler_HeldObject_Loop if the object is out of range.
Take the object: clear RoverCargoFlag and mark Jetman as carrying.
42008 XOR A Write 0 to RoverCargoFlag.
42009 LD (24227),A
42012 LD A,(24704) Fetch Jetman_Flags.
42015 OR %00000001 Set bit 0.
42017 LD (24704),A Write it back.
Mark the object as held by Jetman and play the pickup sound.
42020 LD A,(IX+8) Fetch the actor flags.
42023 AND %11110000 Keep only bits 4-7.
42025 OR %00000011 Set bits 0-1.
42027 LD (IX+8),A Write the flags back.
42030 CALL SoundsTakeObject Call SoundsTakeObject.
Hang the object off the rover.
Handler_HeldObject_Loop 42033 LD A,(24720) Fetch Rover_Slot.
42036 CP 34 Jump to Handler_HeldObject_OnFootOffset if the rover type is below 34.
42038 JR C,Handler_HeldObject_OnFootOffset
42040 LD BC,65524 Set the offset in BC to 65524 (-12).
Handler_HeldObject_FetchRoverX 42043 LD HL,(24722) Fetch Rover_Position.
Place the object at the base X plus the offset, above the rover Y, and draw it.
Handler_HeldObject_WriteX 42046 ADD HL,BC Add the offset.
42047 LD (IX+2),L Write the low byte as the object world X.
42050 LD (IX+3),H Write the high byte.
42053 LD A,(24724) Fetch the rover Y.
42056 SUB 22 Subtract 22.
42058 LD (IX+4),A Write it as the object Y.
42061 JP DrawCurrentActor_Draw Jump to DrawCurrentActor_Draw.
Handler_HeldObject_OnFootOffset 42064 LD BC,18 Set the offset in BC to 0018.
42067 JR Handler_HeldObject_FetchRoverX Jump to Handler_HeldObject_FetchRoverX.
Handler_HeldObject_AdvanceFrame 42069 CALL Handler_HeldObject_NextFrame Call Handler_HeldObject_NextFrame.
42072 JR Handler_HeldObject_PickOffset Jump to Handler_HeldObject_PickOffset.
Cycle the held-object frame from UP.
Handler_HeldObject_CycleFromUp 42074 CALL Handler_PlayerShot Call Handler_PlayerShot.
42077 LD A,(24130) Fetch GameTimer.
42080 AND %00000001 Keep only bit 0.
42082 JR NZ,Handler_HeldObject_PickOffset Jump to Handler_HeldObject_PickOffset if this is an odd frame.
42084 CALL HandlerControls Call HandlerControls.
42087 LD D,A Stash the controls in D.
42088 BIT 3,D Jump to Handler_HeldObject_AdvanceFrame if UP is pressed.
42090 JR Z,Handler_HeldObject_AdvanceFrame
42092 CALL Handler_HeldObject_PreviousFrame Call Handler_HeldObject_PreviousFrame.
Type 22 and above is seated facing right; hang the object on the left.
Handler_HeldObject_PickOffset 42095 LD A,(24696) Fetch Jetman_Slot.
42098 CP 22 Jump to Handler_HeldObject_ClearBit3 if Jetman's type is less than 22.
42100 JR C,Handler_HeldObject_ClearBit3
42102 LD A,8 A=8.
42104 CALL Handler_HeldObject_CopyFlagBit Call Handler_HeldObject_CopyFlagBit.
42107 LD BC,65524 Set the offset in BC to 65524 (-12).
Handler_HeldObject_FetchJetmanX 42110 LD HL,(24698) Fetch Jetman_Position.
42113 JR Handler_HeldObject_WriteX Jump to Handler_HeldObject_WriteX.
Hang the object on the right when the type is below 22.
Handler_HeldObject_ClearBit3 42115 LD A,0 A=0.
42117 CALL Handler_HeldObject_CopyFlagBit Call Handler_HeldObject_CopyFlagBit.
42120 LD BC,18 Set the offset in BC to 0018.
42123 JR Handler_HeldObject_FetchJetmanX Jump to Handler_HeldObject_FetchJetmanX.
Advance the low three bits of the actor type.
Handler_HeldObject_NextFrame 42125 LD A,(IX+0) Fetch the actor type.
42128 LD C,A Stash it in C.
42129 AND %00000111 Keep only bits 0-2.
42131 CP 7 Return if those bits are already 7.
42133 RET Z
42134 INC A Increase the frame by one.
Write the new frame back into the low three bits of the type.
Handler_HeldObject_MergeType 42135 LD B,A Stash the new frame in B.
42136 LD A,C Copy the original type into A.
42137 AND %11111000 Keep only bits 3-7.
42139 OR B Merge the new frame back in.
42140 LD (IX+0),A Write it to the actor type.
42143 RET Return.
Step the low three bits of the actor type back.
Handler_HeldObject_PreviousFrame 42144 LD A,(IX+0) Fetch the actor type.
42147 LD C,A Stash it in C.
42148 AND %00000111 Keep only bits 0-2.
42150 RET Z Return if the frame is already zero.
42151 DEC A Decrease the frame by one.
42152 JR Handler_HeldObject_MergeType Jump to Handler_HeldObject_MergeType.
XOR A with the actor flags and write bit 3 of the result to bit 3 of the actor type.
Handler_HeldObject_CopyFlagBit 42154 XOR (IX+8) XOR A with the actor flags.
42157 AND %00001000 Keep only bit 3.
42159 LD C,A Stash that bit in C.
42160 LD A,(IX+0) Fetch the actor type.
42163 AND %11110111 Reset bit 3.
42165 OR C Merge the flag bit back in.
42166 LD (IX+0),A Write it to the actor type.
42169 RET Return.
Prev: 41921 Up: Map Next: 42170