Prev: 49342 Up: Map Next: 49468
49431: 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 (128) 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 49431 LD HL,(23307) Fetch RoomSize_X and RoomSize_Y.
49434 LD A,L Copy the distance along x to A.
49435 SUB (IX+4) Subtract the width of the player.
49438 LD L,A Store the limit along x in L.
49439 LD A,H Copy the distance along y to A.
49440 SUB (IX+5) Subtract the depth of the player.
49443 LD H,A Store the limit along y in H.
Compare the x distance from the middle.
49444 LD A,(IX+1) Fetch the x position of the player.
49447 SUB 128 Subtract 128.
49449 JP P,TestPlayerInRoom_LimitX Jump to TestPlayerInRoom_LimitX if the sign flag is clear.
49452 NEG Negate A.
TestPlayerInRoom_LimitX 49454 CP L Return if the player is outside along x.
49455 RET NC
Compare the y distance from the middle.
49456 LD A,(IX+2) Fetch the y position of the player.
49459 SUB 128 Subtract 128.
49461 JP P,TestPlayerInRoom_LimitY Jump to TestPlayerInRoom_LimitY if the sign flag is clear.
49464 NEG Negate A.
TestPlayerInRoom_LimitY 49466 CP H Compare it with the limit along y.
49467 RET Return.
View the equivalent code in;
Prev: 49342 Up: Map Next: 49468