Prev: A3C1 Up: Map Next: A4BA
A3FF: 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 A3FF LD A,($6090) Fetch Rover_Slot.
A402 SUB $1A Subtract 1A.
A404 CP $10 Jump to Handler_HeldObject_CycleFromUp if that is not a rover frame.
A406 JR NC,Handler_HeldObject_CycleFromUp
Let Jetman take the object off the rover when the action key is pressed beside it.
A408 BIT 1,(IX+$08) Jump to Handler_HeldObject_Loop if bit 1 of the actor flags is set.
A40C JR NZ,Handler_HeldObject_Loop
A40E CALL TestActionKey Call TestActionKey.
A411 JR Z,Handler_HeldObject_Loop Jump to Handler_HeldObject_Loop if the action key is not pressed.
A413 CALL TestJetmanAction_ComparePosition Call TestJetmanAction_ComparePosition.
A416 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.
A418 XOR A Write 00 to RoverCargoFlag.
A419 LD ($5EA3),A
A41C LD A,($6080) Fetch Jetman_Flags.
A41F OR %00000001 Set bit 0.
A421 LD ($6080),A Write it back.
Mark the object as held by Jetman and play the pickup sound.
A424 LD A,(IX+$08) Fetch the actor flags.
A427 AND %11110000 Keep only bits 4-7.
A429 OR %00000011 Set bits 0-1.
A42B LD (IX+$08),A Write the flags back.
A42E CALL SoundsTakeObject Call SoundsTakeObject.
Hang the object off the rover.
Handler_HeldObject_Loop A431 LD A,($6090) Fetch Rover_Slot.
A434 CP $22 Jump to Handler_HeldObject_OnFootOffset if the rover type is below 22.
A436 JR C,Handler_HeldObject_OnFootOffset
A438 LD BC,$FFF4 Set the offset in BC to FFF4 (-0C).
Handler_HeldObject_FetchRoverX A43B LD HL,($6092) Fetch Rover_Position.
Place the object at the base X plus the offset, above the rover Y, and draw it.
Handler_HeldObject_WriteX A43E ADD HL,BC Add the offset.
A43F LD (IX+$02),L Write the low byte as the object world X.
A442 LD (IX+$03),H Write the high byte.
A445 LD A,($6094) Fetch the rover Y.
A448 SUB $16 Subtract 16.
A44A LD (IX+$04),A Write it as the object Y.
A44D JP DrawCurrentActor_Draw Jump to DrawCurrentActor_Draw.
Handler_HeldObject_OnFootOffset A450 LD BC,$0012 Set the offset in BC to 0012.
A453 JR Handler_HeldObject_FetchRoverX Jump to Handler_HeldObject_FetchRoverX.
Handler_HeldObject_AdvanceFrame A455 CALL Handler_HeldObject_NextFrame Call Handler_HeldObject_NextFrame.
A458 JR Handler_HeldObject_PickOffset Jump to Handler_HeldObject_PickOffset.
Cycle the held-object frame from UP.
Handler_HeldObject_CycleFromUp A45A CALL Handler_PlayerShot Call Handler_PlayerShot.
A45D LD A,($5E42) Fetch GameTimer.
A460 AND %00000001 Keep only bit 0.
A462 JR NZ,Handler_HeldObject_PickOffset Jump to Handler_HeldObject_PickOffset if this is an odd frame.
A464 CALL HandlerControls Call HandlerControls.
A467 LD D,A Stash the controls in D.
A468 BIT 3,D Jump to Handler_HeldObject_AdvanceFrame if UP is pressed.
A46A JR Z,Handler_HeldObject_AdvanceFrame
A46C CALL Handler_HeldObject_PreviousFrame Call Handler_HeldObject_PreviousFrame.
Type 16 and above is seated facing right; hang the object on the left.
Handler_HeldObject_PickOffset A46F LD A,($6078) Fetch Jetman_Slot.
A472 CP $16 Jump to Handler_HeldObject_ClearBit3 if Jetman's type is less than 16.
A474 JR C,Handler_HeldObject_ClearBit3
A476 LD A,$08 A=08.
A478 CALL Handler_HeldObject_CopyFlagBit Call Handler_HeldObject_CopyFlagBit.
A47B LD BC,$FFF4 Set the offset in BC to FFF4 (-0C).
Handler_HeldObject_FetchJetmanX A47E LD HL,($607A) Fetch Jetman_Position.
A481 JR Handler_HeldObject_WriteX Jump to Handler_HeldObject_WriteX.
Hang the object on the right when the type is below 16.
Handler_HeldObject_ClearBit3 A483 LD A,$00 A=00.
A485 CALL Handler_HeldObject_CopyFlagBit Call Handler_HeldObject_CopyFlagBit.
A488 LD BC,$0012 Set the offset in BC to 0012.
A48B JR Handler_HeldObject_FetchJetmanX Jump to Handler_HeldObject_FetchJetmanX.
Advance the low three bits of the actor type.
Handler_HeldObject_NextFrame A48D LD A,(IX+$00) Fetch the actor type.
A490 LD C,A Stash it in C.
A491 AND %00000111 Keep only bits 0-2.
A493 CP $07 Return if those bits are already 07.
A495 RET Z
A496 INC A Increase the frame by one.
Write the new frame back into the low three bits of the type.
Handler_HeldObject_MergeType A497 LD B,A Stash the new frame in B.
A498 LD A,C Copy the original type into A.
A499 AND %11111000 Keep only bits 3-7.
A49B OR B Merge the new frame back in.
A49C LD (IX+$00),A Write it to the actor type.
A49F RET Return.
Step the low three bits of the actor type back.
Handler_HeldObject_PreviousFrame A4A0 LD A,(IX+$00) Fetch the actor type.
A4A3 LD C,A Stash it in C.
A4A4 AND %00000111 Keep only bits 0-2.
A4A6 RET Z Return if the frame is already zero.
A4A7 DEC A Decrease the frame by one.
A4A8 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 A4AA XOR (IX+$08) XOR A with the actor flags.
A4AD AND %00001000 Keep only bit 3.
A4AF LD C,A Stash that bit in C.
A4B0 LD A,(IX+$00) Fetch the actor type.
A4B3 AND %11110111 Reset bit 3.
A4B5 OR C Merge the flag bit back in.
A4B6 LD (IX+$00),A Write it to the actor type.
A4B9 RET Return.
Prev: A3C1 Up: Map Next: A4BA