Prev: 51117 Up: Map Next: 51259
51202: Test Door Passage
Used by the routine at HandleNearArch.
Finds out if the player is going through a door. This is so when the player is standing in the place in front of the door and is allowed to open doors, which means that the player has to be alive. If it is, the player is let pass through the walls, and once it has gone far enough through, it is put into the next room, which is the room of the door.
When the player enters the next room it is put at the other side of the room along the same axis, the player's two object records are saved in PlayerRecords so that the player starts here again after losing a life, and the main loop is restarted at RunGame_NewRoom to build the room.
Input
IX Door record
HL Box sizes in front of the door, along x and y
TestDoorPassage 51202 LD IY,42863 Start with the first object record, ObjectsTable, which is the legs of the player.
51206 LD A,(IY+0) Fetch the type of the legs.
51209 SUB 16 Take away 16 from it.
51211 CP 32 Return if the legs are not of a type that is from 16 to 47, which are the types of the player when alive.
51213 RET NC
51214 BIT 3,(IY+7) Return if the player cannot open doors.
51218 RET Z
51219 CALL TestNearTo Return if the player is not in front of the door.
51222 RET NC
51223 SET 0,(IY+7) Make the player ignore the walls, so that it can go through the door.
51227 LD BC,51259 Take the table of the routines for the four directions that the player may face, DoorPassageRoutines.
51230 LD HL,(42781) Fetch the limits of the room.
51233 PUSH HL Stash them on the stack.
Work out the direction that the player is facing, in the same way as GetFacingDirection.
51234 LD A,(IY+7) Fetch the flags of the legs.
51237 RRCA Move bit 6, which mirrors the object, down to bit 3.
51238 RRCA
51239 RRCA
51240 AND %00001000 Keep only that bit.
51242 XOR %00001000 Flip it, to say that the object is not mirrored.
51244 LD L,A Stash the flag in L.
51245 LD A,(IY+0) Fetch the type of the legs.
51248 AND %00000100 Keep only bit 2 of the type.
51250 OR L Combine it with the other bit.
51251 RRCA Move the two bits down to bits 0 and 1.
51252 RRCA
51253 AND %00000011 Keep only those two bits.
51255 LD L,A Set the direction in L.
51256 JP RunGame_JumpViaTable Jump to RunGame_JumpViaTable to run the routine for the direction.
Prev: 51117 Up: Map Next: 51259