Prev: C7AD Up: Map Next: C83B
C802: 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 C802 LD IY,$A76F Start with the first object record, ObjectsTable, which is the legs of the player.
C806 LD A,(IY+$00) Fetch the type of the legs.
C809 SUB $10 Take away 10 from it.
C80B CP $20 Return if the legs are not of a type that is from 10 to 2F, which are the types of the player when alive.
C80D RET NC
C80E BIT 3,(IY+$07) Return if the player cannot open doors.
C812 RET Z
C813 CALL TestNearTo Return if the player is not in front of the door.
C816 RET NC
C817 SET 0,(IY+$07) Make the player ignore the walls, so that it can go through the door.
C81B LD BC,$C83B Take the table of the routines for the four directions that the player may face, DoorPassageRoutines.
C81E LD HL,($A71D) Fetch the limits of the room.
C821 PUSH HL Stash them on the stack.
Work out the direction that the player is facing, in the same way as GetFacingDirection.
C822 LD A,(IY+$07) Fetch the flags of the legs.
C825 RRCA Move bit 6, which mirrors the object, down to bit 3.
C826 RRCA
C827 RRCA
C828 AND %00001000 Keep only that bit.
C82A XOR %00001000 Flip it, to say that the object is not mirrored.
C82C LD L,A Stash the flag in L.
C82D LD A,(IY+$00) Fetch the type of the legs.
C830 AND %00000100 Keep only bit 2 of the type.
C832 OR L Combine it with the other bit.
C833 RRCA Move the two bits down to bits 0 and 1.
C834 RRCA
C835 AND %00000011 Keep only those two bits.
C837 LD L,A Set the direction in L.
C838 JP RunGame_JumpViaTable Jump to RunGame_JumpViaTable to run the routine for the direction.
Prev: C7AD Up: Map Next: C83B