| Routines

F9BB: Check whether ERIC has 10000 lines

Used by the routine at 76F9. The number of lines has just been printed. Has ERIC gone over the limit?
F9BB | LD A,($7FC7) | Collect the MSB of the lines total
F9BE | CP $03 | Is the lines total < 7680 (30*256)?
F9C0 | RET C | Return if so
F9C1 | JR NZ,$F9C9 | Jump if the MSB > 3 (lines total > 10240)
F9C3 | LD A,($7FC6) | So the MSB is 3; collect the LSB from 7FC6
F9C6 | CP $E8 | Is the lines total < 10000 (=232+256*30)?
F9C8 | RET C | Return if so
ERIC has 10000 lines or more. The end (of the game) is nigh.
F9C9 | PUSH HL |
F9CA | LD HL,$FAE2 | Point HL at the first of the last two commands in command list 0xDE ('Find ERIC', and 'Send ERIC home')
F9CD | LD ($A377),HL | Place this address into bytes 0x77 and 0x78 of MR WACKER's buffer, so that these commands become his command list
F9D0 | LD HL,$A37A | Set bit 0 of byte 0x7A of MR WACKER's buffer, triggering a command list restart
F9D3 | SET 0,(HL)
F9D5 | LD HL,$7FF8 | Set the MSB of the lesson clock to 0xFF (so that the lesson cannot end before MR WACKER has begun looking for ERIC)
F9D8 | LD (HL),$FF
F9DA | POP HL |
F9DB | RET |