Prev: C7AD Up: Map Next: C83B
C802: Is the player in the doorway, and has he walked out of the room?
Used by the routine at FIRST_PILLAR.
Only the player's legs, record 0, can use a doorway, and only while their graphic is one of 16 to 47 -- which leaves out the puff he becomes when he dies -- and bit 3 of the flags is set. In the doorway (IS_NEAR_TO, with the limits the pillar gives), bit 0 of the legs' flags is set: while it is, the collision code (ADJ_FOR_OUT_OF_BOUNDS) lets him past the line of the wall, and PLAYER_LEGS clears it again at the end of his next update. Then one of four routines (SCREEN_MOVE_TBL), by the way he faces, decides whether he is wholly past the wall he faces.
This is Knight Lore's doorway check and its exit check in one. Knight Lore marks the player in the doorway from the arch and decides the exit in the player's own move; Pentagram leaves the move alone (EXIT_STUB) and decides here, from the player's position after his move rather than from his position plus the step. The room's half-sizes (ROOM_EXTENT) are pushed for the four, because the dispatch uses HL.
Input
IX The first pillar, holding the arch's middle at +$09 to +$0B
L How near in U
H How near in V
HANDLE_EXIT_SCREEN C802 LD IY,OBJECTS The player's legs, graphics 16 to 47 only
C806 LD A,(IY+$00)
C809 SUB $10
C80B CP $20
C80D RET NC
C80E BIT 3,(IY+$07) Not one that uses doorways
C812 RET Z
C813 CALL IS_NEAR_TO Not in the doorway
C816 RET NC
C817 SET 0,(IY+$07) In it: he may cross the line of the wall
C81B LD BC,SCREEN_MOVE_TBL The four exits, and the room's half-sizes in U and V for them
C81E LD HL,(ROOM_EXTENT)
C821 PUSH HL
C822 LD A,(IY+$07) Jump to the exit for the way he faces (GET_SPRITE_DIR's sum, done here for IY)
C825 RRCA
C826 RRCA
C827 RRCA
C828 AND $08
C82A XOR $08
C82C LD L,A
C82D LD A,(IY+$00)
C830 AND $04
C832 OR L
C833 RRCA
C834 RRCA
C835 AND $03
C837 LD L,A
C838 JP JUMP_TO_TBL_ENTRY
Prev: C7AD Up: Map Next: C83B