Prev: 43767 Up: Map Next: 43830
43777: Test Player Touching Actor
Tests whether the player is touching an actor. The reach in B and C is how far the player can be above and to the right of the position of the actor, and the reach below and to the left is fixed:
Player Left Below
Walking (sprite IDs 16 to 31) 12 15
Attacking (sprite IDs 32 to 47) 28 15
No touching takes place while the game delay in GameDelayTimer is running, or if the player is not walking or attacking.
Input
B How far above the actor the player can be
C How far to the right of the actor the player can be
IX Actor record
Output
F Carry flag set if the player is touching the actor
TestPlayerTouchingActor 43777 LD A,(38581) Fetch the start-of-turn delay from GameDelayTimer.
43780 AND A Return (with the carry flag reset) if the start-of-turn delay is running.
43781 RET NZ
43782 LD A,(38658) Fetch the sprite ID of the player from ImmortalData.
43785 SUB 16 Subtract 16 (the first Sabreman sprite ID).
43787 CP 32 Return if the player is not walking or attacking.
43789 RET NC
This entry point is used by the routine at HandlerSleepingHippoWarthog.
TestPlayerTouchingActor_Reach 43790 LD HL,3852 Set the reach below the actor in H to 15 and the reach to the left in L to 12.
43793 CP 16 Jump to TestPlayerTouchingActor_X if the player is walking.
43795 JR C,TestPlayerTouchingActor_X
43797 LD HL,3868 Set the longer reach to the left of an attacking player in L to 28.
Compare the X positions.
TestPlayerTouchingActor_X 43800 LD A,(38661) Fetch the X position of the player from 38661.
43803 SUB (IX+3) Subtract the X position of the actor to get the horizontal distance.
43806 JR C,TestPlayerTouchingActor_Left Jump to TestPlayerTouchingActor_Left if the player is to the left of the actor.
43808 CP C Compare the distance with the reach to the right.
TestPlayerTouchingActor_TooFarRight 43809 RET NC Return if the player is too far to the right.
Compare the Y positions.
TestPlayerTouchingActor_Y 43810 LD A,(38662) Fetch the Y position of the player from 38662.
43813 SUB (IX+4) Subtract the Y position of the actor to get the vertical distance.
43816 JR C,TestPlayerTouchingActor_Above Jump to TestPlayerTouchingActor_Above if the player is above the actor.
43818 CP H Compare the distance with the reach below.
TestPlayerTouchingActor_Return 43819 RET Return.
The player is to the left of the actor.
TestPlayerTouchingActor_Left 43820 NEG Make the distance positive.
43822 CP L Compare the distance with the reach to the left.
43823 JR TestPlayerTouchingActor_TooFarRight Jump to TestPlayerTouchingActor_TooFarRight.
The player is above the actor.
TestPlayerTouchingActor_Above 43825 NEG Make the distance positive.
43827 CP B Compare the distance with the reach above.
43828 JR TestPlayerTouchingActor_Return Jump to TestPlayerTouchingActor_Return.
Prev: 43767 Up: Map Next: 43830