| Routines

7CFC: Make a teacher tell the kids to go to a certain page in their books

Used by the routines at 7D30 and F300. Makes the teacher tell the kids to turn to or answer the questions on a randomly chosen page of their books.
Input
H | Teacher's character number (0xA3-0xA6)
7CFC | LD DE,$F26F | BC=F262 (TURN TO PAGE 123 OF YOUR BOOKS...); DE=F26F (the '123' in this message)
7CFF | LD C,$62
7D01 | LD B,D
7D02 | CALL $61A1 | A=random number
7D05 | RLCA | This jump (which decides between the message at F262 and the message at F29D) is performed half the time
7D06 | JR C,$7D0C
7D08 | LD E,$BA | BC=F29D (ANSWER THE QUESTIONS ON PAGE 123 OF YOUR LOVELY TEXTBOOK); DE=F2BA (the '123' in this message)
7D0A | LD C,$9D
7D0C | SCF | A=128-255 (random page number to insert into the message)
7D0D | RRA
7D0E | NOP |
7D0F | EX DE,HL | Point HL at the slot for the 100s digit of the page number in the message
7D10 | LD (HL),$2F | Compute and insert the ASCII code for the 100s digit of the page number
7D12 | INC (HL)
7D13 | SUB $64
7D15 | JR NC,$7D12
7D17 | INC L | Point HL at the slot for the 10s digit of the page number
7D18 | ADD A,$64 | Compensate for the trial subtraction of 100 above
7D1A | LD (HL),$2F | Compute and insert the ASCII code for the 10s digit of the page number
7D1C | INC (HL)
7D1D | SUB $0A
7D1F | JR NC,$7D1C
7D21 | INC L | Point HL at the slot for the units digit of the page number
7D22 | ADD A,$3A | Compensate for the trial subtraction of ten above, and add an extra 0x30 (the ASCII code for '0')
7D24 | LD (HL),A | Insert the ASCII code for the units digit of the page number
7D25 | EX DE,HL | Restore the teacher's character number to H
This entry point is used by the routines at 7D30, 7D84, F300, F7E0, F800 and F9F6.
7D26 | LD L,$6C | Place the address of the message into bytes 0x6B and 0x6C of the character's buffer
7D28 | LD (HL),B
7D29 | DEC L
7D2A | LD (HL),C
7D2B | LD BC,$7986 | Place the address of the interruptible subcommand routine at 7986 (make character speak) into bytes 0x69 and 0x6A of the character's buffer and jump to it
7D2E | JR $7CF1