Prev: AAF7 Up: Map Next: AB36
AB01: 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 10 to 1F) 0C 0F
Attacking (sprite IDs 20 to 2F) 1C 0F
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 AB01 LD A,($96B5) Fetch the start-of-turn delay from GameDelayTimer.
AB04 AND A Return (with the carry flag reset) if the start-of-turn delay is running.
AB05 RET NZ
AB06 LD A,($9702) Fetch the sprite ID of the player from ImmortalData.
AB09 SUB $10 Subtract 10 (the first Sabreman sprite ID).
AB0B CP $20 Return if the player is not walking or attacking.
AB0D RET NC
This entry point is used by the routine at HandlerSleepingHippoWarthog.
TestPlayerTouchingActor_Reach AB0E LD HL,$0F0C Set the reach below the actor in H to 0F and the reach to the left in L to 0C.
AB11 CP $10 Jump to TestPlayerTouchingActor_X if the player is walking.
AB13 JR C,TestPlayerTouchingActor_X
AB15 LD HL,$0F1C Set the longer reach to the left of an attacking player in L to 1C.
Compare the X positions.
TestPlayerTouchingActor_X AB18 LD A,($9705) Fetch the X position of the player from 9705.
AB1B SUB (IX+$03) Subtract the X position of the actor to get the horizontal distance.
AB1E JR C,TestPlayerTouchingActor_Left Jump to TestPlayerTouchingActor_Left if the player is to the left of the actor.
AB20 CP C Compare the distance with the reach to the right.
TestPlayerTouchingActor_TooFarRight AB21 RET NC Return if the player is too far to the right.
Compare the Y positions.
TestPlayerTouchingActor_Y AB22 LD A,($9706) Fetch the Y position of the player from 9706.
AB25 SUB (IX+$04) Subtract the Y position of the actor to get the vertical distance.
AB28 JR C,TestPlayerTouchingActor_Above Jump to TestPlayerTouchingActor_Above if the player is above the actor.
AB2A CP H Compare the distance with the reach below.
TestPlayerTouchingActor_Return AB2B RET Return.
The player is to the left of the actor.
TestPlayerTouchingActor_Left AB2C NEG Make the distance positive.
AB2E CP L Compare the distance with the reach to the left.
AB2F JR TestPlayerTouchingActor_TooFarRight Jump to TestPlayerTouchingActor_TooFarRight.
The player is above the actor.
TestPlayerTouchingActor_Above AB31 NEG Make the distance positive.
AB33 CP B Compare the distance with the reach above.
AB34 JR TestPlayerTouchingActor_Return Jump to TestPlayerTouchingActor_Return.
Prev: AAF7 Up: Map Next: AB36