Prev: 902B Up: Map Next: 90FB
90CC: Is the player standing in this doorway?
Used by the routines at DOOR, DOOR_NEEDS_KEY and TRAPDOOR_FALL.
Unlike CHECK_HIT the box is not centred on the door. Both comparisons are unsigned against a subtraction that is not made absolute, so the box starts at the door's own corner (+$03, +$04) and runs right and up from it -- the door's own cells. It also needs the player in play and the low nibble of the player's +$02 clear.
Bit 6 of +$05 says which way the doorway faces, and it halves the tolerance across the door rather than along it: a door in a side wall is generous vertically and tight horizontally, and the other way round for one in the top or bottom wall. The caller passes $1111 as the starting tolerance in BC.
Input
IX The door
BC Tolerance across and along the doorway
F Carry set if the player is in it
PLAYER_AT_DOOR 90CC LD A,($EA92) Suppressed while the low nibble of $EA92 is set -- the flag ENTER_ROOM leaves behind, so one doorway cannot fire twice.
90CF AND $0F
90D1 RET NZ
90D2 LD A,($EA90) And only while the player is actually in play, the same $01-$30 test CHECK_HIT makes.
90D5 DEC A
90D6 CP $30
90D8 RET NC
90D9 BIT 6,(IX+$05) Halve the tolerance across the door, unless it faces the other way.
90DD JR Z,PLAYER_AT_DOOR_0
90DF SRL C
PLAYER_AT_DOOR_0 90E1 LD A,($EA93) One-sided: unsigned, so a negative difference fails the compare outright.
90E4 SUB (IX+$03)
90E7 CP C
90E8 RET NC
90E9 BIT 6,(IX+$05)
90ED JR NZ,PLAYER_AT_DOOR_1
90EF SRL B
PLAYER_AT_DOOR_1 90F1 LD A,($EA94) The same again for the other axis, negated because this one is measured the opposite way.
90F4 SUB (IX+$04)
90F7 NEG
90F9 CP B
90FA RET
Prev: 902B Up: Map Next: 90FB