Prev: 9E34 Up: Map Next: 9E7A
9E40: Is an object within reach of the character in IX?
Used by the routines at ACTOR_IN_REACH and IN_REACH.
Nothing is within reach that has bit 7 of its flags clear. Otherwise it is if the character is inside it; or if the two are shut in the same container; or if neither is shut in anything and the object is in the character's location -- any of its locations, which is how a door is within reach from either side.
Input
IX The character's record
IY The object's record
IN_REACH_OF 9E40 BIT 7,(IY+$07) Not there to be seen: never in reach
9E44 RET Z
9E45 PUSH IY
9E47 PUSH IX
9E49 PUSH BC
9E4A LD B,A B = the object; C = where the character is
9E4B LD C,(IX+$10)
9E4E PUSH IY Is the character shut inside the object itself? Then it is in reach
9E50 CALL SHUT_IN
9E53 CP B
9E54 LD B,A
9E55 POP IX
9E57 JR Z,IN_REACH_OF_2
9E59 CALL SHUT_IN Shut inside something the object is not? Out of reach
9E5C CP B
9E5D JR NZ,IN_REACH_OF_1
9E5F INC A Both shut in the same thing: in reach
9E60 JR NZ,IN_REACH_OF_2
9E62 LD B,(IY+$00) Both free: in reach if the character's location is any of the object's
9E65 LD A,C
IN_REACH_OF_0 9E66 CP (IY+$10)
9E69 JR Z,IN_REACH_OF_2
9E6B INC IY
9E6D DJNZ IN_REACH_OF_0
IN_REACH_OF_1 9E6F XOR A Z: out of reach
9E70 JR IN_REACH_OF_3
IN_REACH_OF_2 9E72 OR $01 NZ: in reach
IN_REACH_OF_3 9E74 POP BC
9E75 POP IX
9E77 POP IY
9E79 RET
Prev: 9E34 Up: Map Next: 9E7A