| Routines

63829: Make a stricken teacher give lines or reveal his safe combination letter

Used by the routine at 27206. If the character who has been knocked over is a teacher, this routine makes him reveal his safe combination letter (if all the shields are flashing but the safe has not been opened yet) and give lines to the nearest main kid (if any are close enough).
Input
A | Knockout delay counter (1-18)
H | Character number (152-169)
63829 | CP 18 | Is it time to reveal a safe combination letter?
63831 | JR Z,63840 | Jump if so
63833 | CP 9 | Is it time to give lines to the nearest main kid?
63835 | RET NZ | Return if not
63836 | POP BC |
63837 | JP 27196 | Give lines to the nearest main kid if we're dealing with a teacher
It's time to reveal a safe combination letter (if all shields are flashing).
63840 | LD A,(32746) | Collect the game mode indicator from 32746
63843 | CP 2 | Set the zero flag if all the shields are flashing but the safe has not been opened
63845 | LD A,18 | Restore the knockout delay counter to A
63847 | RET NZ | Return unless all the shields are flashing
63848 | LD A,H | Return unless we are dealing with a teacher
63849 | CP 163
63851 | RET C
63852 | CP 166
63854 | RET NC
63855 | POP BC |
This entry point is used by the routine at 63191 to make MR CREAK reveal his safe combination letter after seeing his year of birth written on a blackboard.
63856 | LD L,97 | Pick up the character's coordinates in DE
63858 | LD D,(HL)
63859 | INC L
63860 | LD E,(HL)
63861 | LD L,H | Pick up the teacher's safe combination letter in A
63862 | LD H,127
63864 | LD A,(HL)
63865 | LD L,150 | Place this in 32662
63867 | LD (HL),A
63868 | CALL 29871 | Save the area of the screen that will be overwritten by the bubble
63871 | RET C | Return if the character is off-screen
63872 | PUSH DE |
63873 | LD DE,60464 | Point DE at the graphic data portion of the safe combination letter bubble graphic buffer at 60416
63876 | LD HL,55945 | 55945: ' ' (single space)
63879 | CALL 30245 | Write this into the first line of the graphic buffer
63882 | LD DE,60528 | Write the teacher's safe combination letter into the second line of the graphic buffer
63885 | LD HL,32662
63888 | CALL 30245
63891 | LD HL,60440 | Set the attribute bytes in the graphic buffer - INK 7: PAPER 0
63894 | DEC L
63895 | LD (HL),7
63897 | JR NZ,63894
63899 | POP DE | Restore the attribute file address of the top left corner of the bubble to DE and save it again
63900 | PUSH DE
63901 | CALL 29977 | Display the combination letter in a bubble
63904 | XOR A | A=0 (black border for the sound effect)
63905 | JP 30575 | Make a sound effect and remove the bubble