| Routines

7EB1: Print the lesson and ring the bell

Used by the routine at F74D. Prints the lesson or 'DEMO.MODE' in the lesson box, and makes the bell sound effect.
7EB1 | LD HL,$7FDE | 7FDE holds the current game mode
7EB4 | LD A,(HL) | A=0xFF if we're in demo mode, 0x00 otherwise
7EB5 | INC A | Set the zero flag if we're in demo mode
7EB6 | LD A,$3F | Message 0x3F: DEMO.MODE
7EB8 | JR Z,$7EDE | Jump if we're in demo mode
A real game is in progress. First, figure out what to print in the bottom row of the lesson box (the room name, 'LIBRARY', 'PLAYTIME', 'ASSEMBLY' or 'DINNER').
7EBA | LD L,$E0 | HL=7FE0 (lesson descriptor)
7EBC | LD A,(HL) | Pick this up in A
7EBD | AND $0F | Keep only the room identifier bits
7EBF | LD E,$20 | 0x20 is the ASCII code for SPACE
7EC1 | ADD A,$7E | D=message number for the text to go on the bottom row of the lesson box
7EC3 | LD D,A
7EC4 | CP $83 | Is it PLAYTIME (0x80), ASSEMBLY (0x81) or DINNER (0x82)?
7EC6 | JR C,$7ED6 | Jump if so
7EC8 | LD E,$87 | Message 0x87: REVISION
7ECA | JR Z,$7ED6 | Jump if it's REVISION LIBRARY (D=0x83: LIBRARY)
Next, figure out what to print (if anything) in the top row of the lesson box (the teacher's name, or 'REVISION').
7ECC | LD A,(HL) | A=lesson descriptor
7ECD | AND $F0 | Keep only the teacher-identifying bits and push them into bits 0-3
7ECF | RLCA
7ED0 | RLCA
7ED1 | RLCA
7ED2 | RLCA
7ED3 | ADD A,$14 | E=0x16, 0x17 or 0x18 (teacher's name)
7ED5 | LD E,A
Now we can construct message 0x10 (teacher/room) ready for printing.
7ED6 | LD L,$88 | Place the teacher message number (or ASCII code for SPACE) in 7F88
7ED8 | LD (HL),E
7ED9 | LD L,$8A | Place the room message number in 7F8A
7EDB | LD (HL),D
7EDC | LD A,$10 | Message 0x10: teacher/room
This entry point is used by the routine at 5D63.
7EDE | LD DE,$5AB0 | DE=base display file address for the lesson box
7EE1 | LD C,$57 | INK 7: PAPER 2: BRIGHT 1
7EE3 | CALL $6B46 | Print the lesson
And finally, ring the bell. Your browser doesn't support HTML5 audio. Here is a link to the audio instead.
7EE6 | LD BC,$8010 | Set the parameters for the bell sound effect
7EE9 | LD D,C
7EEA | LD A,$01
7EEC | JP $748C | Ring the bell