Prev: 9611 Up: Map Next: 96DA
9686: Is the object within the player's reach?
Stops the player using something that another character is holding. Characters are not subject to this check, and neither are objects that nobody is holding or that Bilbo himself is holding (directly or inside something he carries).
If object A is held by a living character, and Bilbo is visible, the game says, for example, 'gandalf is carrying the curious map.' and returns with Z reset: the action is not allowed. But if Bilbo is invisible - wearing the ring clears bit 7 of his flags - the check is skipped, and he can take things straight out of other characters' hands.
Input
A Object
Output
F Z reset if the object is out of reach
9686 CP $FF Nothing at all?
9688 RET Z Then there is nothing to check
9689 PUSH IX
968B PUSH IY
968D PUSH BC
968E LD B,A B = the object
968F LD A,($B5DB) Is the actor Bilbo?
9692 CP $00
9694 JR Z,$9699 Yes: check
9696 XOR A A character: always allowed (Z set)
9697 JR $96D4
9699 LD A,B
969A CALL $9B25 IX = the object's record
969D LD A,(IX+$01) Is anyone holding it?
96A0 CP $FF
96A2 JR Z,$96D4 No: allowed
96A4 LD A,B
96A5 PUSH IX IY = the object's record
96A7 POP IY
96A9 CALL $9BD0 Is Bilbo holding it (perhaps inside something)?
96AC JR C,$96D4 Yes: allowed
96AE CALL $9B25 IX = the holder's record
96B1 BIT 6,(IX+$07) Is the holder a living character?
96B5 JR Z,$96D4 No (a box, a table): allowed
96B7 LD A,($C012) Is Bilbo visible?
96BA BIT 7,A
96BC JR Z,$96D4 No - he is wearing the ring: allowed
96BE LD L,(IY+$08) Push the object's name...
96C1 LD H,(IY+$09)
96C4 PUSH HL
96C5 LD L,(IX+$08) ...and the holder's
96C8 LD H,(IX+$09)
96CB PUSH HL
96CC LD HL,$AED6 "gandalf is carrying the curious map."
96CF CALL $72D4
96D2 OR $01 Not allowed: return with Z reset
96D4 POP BC
96D5 POP IY
96D7 POP IX
96D9 RET
Prev: 9611 Up: Map Next: 96DA