| Routines

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

The address of this interruptible subcommand routine is placed into bytes 0x0E and 0x0F of a character's buffer by the routine at F375. 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 (0xD7-0xE5)
F383 | LD L,$00 | Point HL at byte 0x00 of the character's buffer
F385 | BIT 2,(HL) | Does the character have his arm raised?
F387 | JR NZ,$F37B | Make the character lower his arm if so
F389 | LD D,H | D=character number
F38A | CALL $F293 | Check whether the door is open
F38D | EX DE,HL | H=character number
F38E | JP NZ,$F284 | 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.
F391 | LD L,$10 | Decrement the counter in byte 0x10 of the policeman's buffer
F393 | DEC (HL)
F394 | JP NZ,$F33C | Raise the policeman's arm for another knock if the counter has not reached zero
F397 | EX DE,HL | Point HL at the door status flags
F398 | JP $F2B3 | Bust open the door