Prev: C0BE Up: Map Next: C13C
C117: Test Player In Room
Used by the routines at HandlePickupAndDrop and HandlePlayerLegs.
Tests whether the player is inside the room. The distance from the middle of the room (80) has to be smaller than the distance to the wall, less the width of the player along x and less the depth of the player along y.
Input
IX The address of the object
Output
F Carry flag set if the player is inside the room
Limits from the wall distances.
TestPlayerInRoom C117 LD HL,($5B0B) Fetch RoomSize_X and RoomSize_Y.
C11A LD A,L Copy the distance along x to A.
C11B SUB (IX+$04) Subtract the width of the player.
C11E LD L,A Store the limit along x in L.
C11F LD A,H Copy the distance along y to A.
C120 SUB (IX+$05) Subtract the depth of the player.
C123 LD H,A Store the limit along y in H.
Compare the x distance from the middle.
C124 LD A,(IX+$01) Fetch the x position of the player.
C127 SUB $80 Subtract 80.
C129 JP P,TestPlayerInRoom_LimitX Jump to TestPlayerInRoom_LimitX if the sign flag is clear.
C12C NEG Negate A.
TestPlayerInRoom_LimitX C12E CP L Return if the player is outside along x.
C12F RET NC
Compare the y distance from the middle.
C130 LD A,(IX+$02) Fetch the y position of the player.
C133 SUB $80 Subtract 80.
C135 JP P,TestPlayerInRoom_LimitY Jump to TestPlayerInRoom_LimitY if the sign flag is clear.
C138 NEG Negate A.
TestPlayerInRoom_LimitY C13A CP H Compare it with the limit along y.
C13B RET Return.
View the equivalent code in;
Prev: C0BE Up: Map Next: C13C