| Routines

31188: Check whether ERIC is where he should be

Used by the routines at 31648, 31854, 31895, 31952 and 62208. Returns with the zero flag set if and only if ERIC is where he should be during dinner or class.
31188 | CALL 31229 | Get ERIC's coordinates in DE
31191 | LD A,D | A=ERIC's y-coordinate
31192 | PUSH HL |
31193 | LD HL,30608 | Point HL at the skool region table for the top floor (see 30636)
31196 | CP 155 | Is ERIC on the top floor?
31198 | JR Z,31214 | Jump if so
31200 | CP 162 | Set the zero flag if ERIC's on the middle floor
31202 | LD L,156 | HL=30620 (skool region data table for the middle floor; see 30636)
31204 | JR Z,31214 | Jump if ERIC's on the middle floor
31206 | LD L,166 | HL=30630 (skool region data table for the bottom floor; see 30636)
31208 | CP 169 | Is ERIC on the bottom floor?
31210 | JR Z,31214 | Jump if so
31212 | POP HL |
31213 | RET | Return with the zero flag reset
ERIC is on the top, middle or bottom floor (i.e. not on a staircase).
31214 | LD A,E | A=ERIC's x-coordinate
31215 | CP (HL) | Find the region identifier (0-7) for ERIC's current location
31216 | INC HL
31217 | INC HL
31218 | JR NC,31215
31220 | DEC HL | HL now points at the region identifier
31221 | LD A,(32756) | Pick up the current lesson descriptor from 32756
31224 | AND 7 | Keep only the room bits (bits 0-2)
31226 | CP (HL) | Is ERIC where he should be?
31227 | POP HL |
31228 | RET | Return with the zero flag set if so