| Routines

63191: Make MR CREAK reveal his safe combination letter if appropriate

Used by the routine at 32132. A teacher is standing at the doorway of a classroom, ready to tell the kids to sit down; this routine checks whether the teacher is MR CREAK, and if it is, makes him reveal his safe combination letter if his birth year has been written on the blackboard by ERIC, and ERIC has not yet opened the safe.
Input
H | Teacher's character number (163-166)
L | 122
63191 | CALL 63734 | Return unless we're dealing with CREAK and ERIC has not yet opened the safe
63194 | RET C
63195 | CALL 64016 | Return unless CREAK is near a blackboard last written on by ERIC
63198 | RET NZ
63199 | LD A,E | A=56 (Reading Room blackboard) or 58 (White Room blackboard)
63200 | SUB 181
63202 | PUSH HL | Save CREAK's character number
63203 | LD L,A | HL=32680 (Reading Room blackboard contents buffer) or 32686 (White Room blackboard contents buffer)
63204 | ADD A,A
63205 | ADD A,L
63206 | NOP
63207 | LD L,A
63208 | LD H,D
Check whether CREAK's birth year has been written on the board.
63209 | LD E,155 | DE=32667 (which holds CREAK's year of birth)
63211 | LD B,4 | There are 4 digits in CREAK's year of birth
63213 | LD A,(DE) | A=digit from CREAK's year of birth
63214 | INC E | Move DE along to the next digit
63215 | CP (HL) | Compare the digit with the character written on the board
63216 | JR NZ,63226 | Jump if they don't match
63218 | INC L | Move to the next character written on the board
63219 | DJNZ 63213 | Jump back until all 4 digits have been checked
The first four characters written on the board by ERIC match the digits in MR CREAK's year of birth.
63221 | POP HL | Restore CREAK's character number (166) to H
63222 | PUSH HL | Save it again
63223 | CALL 63856 | Reveal CREAK's safe combination letter
63226 | POP HL | Restore CREAK's character number (166) to H
63227 | LD BC,61889 | Set BC to 61889 (SILENCE! OR I'LL CANE THE LOT OF YOU) before returning
63230 | RET |