| Routines

79D4: Check whether ERIC is where he should be

Used by the routines at 7BA0, 7C6E, 7C97, 7CD0 and F300. Returns with the zero flag set if and only if ERIC is where he should be during dinner or class.
79D4 | CALL $79FD | Get ERIC's coordinates in DE
79D7 | LD A,D | A=ERIC's y-coordinate
79D8 | PUSH HL |
79D9 | LD HL,$7790 | Point HL at the skool region table for the top floor (see 77AC)
79DC | CP $9B | Is ERIC on the top floor?
79DE | JR Z,$79EE | Jump if so
79E0 | CP $A2 | Set the zero flag if ERIC's on the middle floor
79E2 | LD L,$9C | HL=779C (skool region data table for the middle floor; see 77AC)
79E4 | JR Z,$79EE | Jump if ERIC's on the middle floor
79E6 | LD L,$A6 | HL=77A6 (skool region data table for the bottom floor; see 77AC)
79E8 | CP $A9 | Is ERIC on the bottom floor?
79EA | JR Z,$79EE | Jump if so
79EC | POP HL |
79ED | RET | Return with the zero flag reset
ERIC is on the top, middle or bottom floor (i.e. not on a staircase).
79EE | LD A,E | A=ERIC's x-coordinate
79EF | CP (HL) | Find the region identifier (0-7) for ERIC's current location
79F0 | INC HL
79F1 | INC HL
79F2 | JR NC,$79EF
79F4 | DEC HL | HL now points at the region identifier
79F5 | LD A,($7FF4) | Pick up the current lesson descriptor from 7FF4
79F8 | AND $07 | Keep only the room bits (bits 0-2)
79FA | CP (HL) | Is ERIC where he should be?
79FB | POP HL |
79FC | RET | Return with the zero flag set if so