| Routines

663F: Knock the current occupant (if any) out of a chair

Used by the routines at 6697 and F3FC. Knocks the current occupant (if any) out of the chair next to the character looking for a seat.
Input
H | Number of the character looking for a seat (0xB7-0xD1)
663F | LD D,$B7 | 0xB7=little girl no. 1
6641 | LD L,$01 |
6643 | LD BC,$1187 | B=0x11 (7 girls, 10 boys), C=0x87 (animatory state mask)
6646 | CALL $6621 | Are any of these characters sitting in the chair?
6649 | JR Z,$6667 | Jump if so
664B | LD BC,$0287 | B=0x02 (EINSTEIN and HAYLEY), C=0x87 (animatory state mask)
664E | LD D,$D0 | 0xD0=EINSTEIN
6650 | CALL $6618 | Is one of the main kids sitting here?
6653 | JR Z,$6667 | Jump if so
6655 | LD DE,$D212 | D=0xD2 (ERIC), E=0x12
6658 | INC B | B=1 (just ERIC)
6659 | XOR A | Zero out byte 0x12 of ERIC's buffer (to indicate that he may be pushed out of the seat if he's in it)
665A | LD (DE),A
665B | CALL $6621 | Is ERIC sitting here?
665E | RET NZ | Return if not
665F | LD DE,$7FFB | HL=7FFB (ERIC's primary status flags)
6662 | EX DE,HL
6663 | SET 7,(HL) | Set bit 7 of ERIC's primary status flags, indicating that he's been knocked to the floor; however, bit 7 is ignored by the routine at F7AD (because bit 2 is also set), so ERIC actually stays in his seat (which is a bug)
6665 | EX DE,HL | Restore the number of the character looking for a seat to H
6666 | RET |
A character (other than ERIC) must be knocked out of the chair.
6667 | LD A,$66 | Place the address of the uninterruptible subcommand routine at 6670 into bytes 0x11 and 0x12 of the buffer of the character who's been knocked out of the chair
6669 | LD (DE),A
666A | DEC E
666B | LD A,$70
666D | LD (DE),A
666E | RET |