| Routines

6697: Deal with a character who is looking for a seat

The address of this uninterruptible subcommand routine is placed into bytes 0x11 and 0x12 of a character's buffer by the routine at 667F (after he's been knocked out of his chair and just got up to look for another one - or the same one, in EINSTEIN's case), or by the routine at 66C0.
Input
H | Character number (0xB7-0xD1)
6697 | LD L,$00 | Byte 0x00 holds the character's animatory state
6699 | BIT 0,(HL) | Is the character midstride?
669B | JP NZ,$63FD | Finish the stride if so
669E | CALL $65D4 | Is the character standing beside a chair?
66A1 | AND A
66A2 | JR NZ,$66B5 | Jump if not
66A4 | CALL $663F | Knock anybody who's sitting here out of the way
66A7 | CALL $61B4 | Update the SRB for the character's current animatory state and location
66AA | AND $F8 |
66AC | ADD A,$04 | A=animatory state of the character (as if sitting in a chair)
66AE | LD L,$12 | Remove the address of this routine from bytes 0x11 and 0x12 of the character's buffer
66B0 | LD (HL),$00
66B2 | JP $6130 | Update the character's animatory state and update the SRB
66B5 | CP $04 | A=0x00 if the character must walk back to the rightmost chair in the room, or 0xFF if there is one in front of him
66B7 | SBC A,A
66B8 | LD L,$00 | Byte 0x00 holds the character's animatory state
66BA | XOR (HL) | Reset the carry flag if the character must turn round
66BB | RLCA
66BC | JP $642E | Update the character's animatory state and update the SRB