| Routines

7C6E: Make a teacher perform dinner duty (1)

Used by command list 0xB8. Makes the teacher on dinner duty pace up and down the dinner hall, checking whether ERIC is present. If ERIC is absent, the teacher is sent to find him, after which the command list is restarted.
Input
H | 0xA3 (MR WACKER) or 0xA5 (MR WITHIT)
7C6E | LD DE,$7FC8 | Set bit 7 at 7FC8, indicating that dinner has started (and so ERIC should be in the dinner hall)
7C71 | EX DE,HL
7C72 | SET 7,(HL)
7C74 | EX DE,HL
This entry point is used on subsequent calls when the teacher on dinner duty has reached the right end of the dinner hall.
7C75 | CALL $79D4 | Set the zero flag if ERIC is where he should be
7C78 | LD DE,$9721 | D=0x97 (LSB of 7C97), E=33 (x-coordinate of the left end of the teacher's dinner duty orbit)
This entry point is used by the routine at 7C97 with D=0x75 (LSB of the entry point at 7C75, above) and E=62 (x-coordinate of the right end of the teacher's dinner duty orbit), and also by the routine at F300 with the zero flag reset.
7C7B | LD L,$69 |
7C7D | JR Z,$7C87 | Jump if ERIC is where he should be
7C7F | LD (HL),$A0 | Place the address of the interruptible subcommand routine at 7BA0 into bytes 0x69 and 0x6A of the character's buffer
7C81 | INC L
7C82 | LD (HL),$7B
7C84 | JP $7BA0 | And jump to that routine now
ERIC is where he should be, so there's no need to chase him.
7C87 | LD (HL),$3C | Place the address of the interruptible subcommand routine at 633C into bytes 0x69 and 0x6A of the teacher's buffer
7C89 | INC L
7C8A | LD (HL),$63
7C8C | INC L | Place 33 or 62 into byte 0x6B of the teacher's buffer (to make him go to that x-coordinate next)
7C8D | LD (HL),E
7C8E | INC L | Place 0 into byte 0x6C of the teacher's buffer, giving him more than enough time to reach the other end of the dinner hall without interruption
7C8F | LD (HL),$00
7C91 | LD L,$63 | Replace the address of this primary command routine in bytes 0x63 and 0x64 of the teacher's buffer with that of 7C97 or 7C75
7C93 | LD (HL),D
7C94 | JP $633C | Proceed to the other end of the dinner hall