| Routines

F017: Make EINSTEIN speak

The address of this interruptible subcommand routine is placed into bytes 0x09 and 0x0A of the buffer of the teacher who is taking ERIC's class by the routine at F100. It is used to make EINSTEIN tell a tale.
Input
E | Message number
H | Teacher's character number (0xC9-0xCB)
F017 | LD A,E | A=message number for EINSTEIN
F018 | LD ($D00B),A | Place this in byte 0x0B of EINSTEIN's buffer
The address of this entry point is placed into bytes 0x09 and 0x0A of the buffer of the teacher who is taking ERIC's class by the routine at F100. It is used to make EINSTEIN answer the teacher's question.
F01B | EX DE,HL |
F01C | LD HL,$7F80 | Set bit 3 at 7F80 to indicate that it's EINSTEIN's turn to speak
F01F | SET 3,(HL)
F021 | EX DE,HL |
F022 | LD L,$09 | Replace the address of this routine in bytes 0x09 and 0x0A of the teacher's buffer with F026 (below)
F024 | LD (HL),$26
This entry point is used while the teacher is waiting for EINSTEIN to finish speaking.
F026 | LD A,($7F80) | Has EINSTEIN finished speaking yet?
F029 | BIT 3,A
F02B | RET NZ | Return if not
F02C | JP $6390 | Otherwise terminate this interruptible subcommand, thus restoring control to the main routine at F100