| Routines

62339: Control a character who is knocking on or opening a door (3)

The address of this interruptible subcommand routine is placed into bytes 14 and 15 of a character's buffer by the routine at 62325. At this point, either the character has opened the door already (in which case this routine does nothing more than verify that the door is still open and then terminate the subcommand), or he is knocking on the door repeatedly (in which case he must be a policeman).
Input
H | Character number (215-229)
62339 | LD L,0 | Point HL at byte 0 of the character's buffer
62341 | BIT 2,(HL) | Does the character have his arm raised?
62343 | JR NZ,62331 | Make the character lower his arm if so
62345 | LD D,H | D=character number
62346 | CALL 62099 | Check whether the door is open
62349 | EX DE,HL | H=character number
62350 | JP NZ,62084 | Terminate this subcommand if the door is open
This character must be a policeman. In this case, he will knock repeatedly for a while, and then open the door by force if there's no answer.
62353 | LD L,16 | Decrement the counter in byte 16 of the policeman's buffer
62355 | DEC (HL)
62356 | JP NZ,62268 | Raise the policeman's arm for another knock if the counter has not reached zero
62359 | EX DE,HL | Point HL at the door status flags
62360 | JP 62131 | Bust open the door