Routines
 Prev: 62119 Up: Map Next: 62173
62120: Check whether a character can open a door
Used by the routines at 62216 and 62278. Returns with the carry flag reset if the door is already open, or the character can open the door (either because the door requires no key, or because the character has the key); otherwise returns with the carry flag set, and the zero flag set if the character has no keys. If the door is closed and requires a key, this routine will either open it (if the character has the key), or signal that the door was knocked on.
Input
H Character number (215-230)
62120 LD D,H D=character number
62121 CALL 62099 Check whether the door is open
62124 EX DE,HL H=character number
62125 RET NZ Return (with the carry flag reset) if the door is open
62126 EX DE,HL Point HL at the door status flags
62127 LD A,(HL) A=door status flags
62128 AND A Does the door require a key to unlock it?
62129 JR NZ,62142 Jump if so
This entry point is used by the routines at 62216 and 62339.
62131 LD A,(HL) Initialise the door close delay timer (in bits 0-2 of the door status flags) to 7
62134 LD (HL),A
62135 PUSH DE Save the character number (in D) briefly
62136 CALL 63437 Open the door
62139 POP HL Restore the character number to H
62140 XOR A Reset the carry flag
62141 RET
The door requires a key to unlock it.
62142 LD A,D A=character number (215-230)
62143 CP 230 Is this Sam?
62145 JR NZ,62152 Jump if not
62147 LD A,(32746) Pick up the key inventory flags from 32746
62150 JR 62158
62152 ADD A,10 A=character number + 10 (225-239)
62154 LD C,A Point BC at the entry in the table of key ownership flags at 62177 that corresponds to this character
62155 LD B,242
62157 LD A,(BC) Pick up the key ownership flags
62158 LD C,A C=character's key ownership flags
62159 AND (HL) Does the character have the key to this door?
62160 JR NZ,62131 Jump if so
62162 LD A,L A=LSB of the door status flag byte (240-249)
62163 SUB 70 A=170-179
62165 LD L,A Point HL at the door knock status flags for the door (at 32682)
62166 SET 7,(HL) Signal: somebody has knocked on the door
62168 LD A,C A=character's key ownership flags
62169 AND A Set the zero flag if the character has no keys
62170 SCF Signal: the character cannot open the door
62171 EX DE,HL Restore the character number to H
62172 RET
 Prev: 62119 Up: Map Next: 62173