Skool Daze Routines
28220: Check whether character can be seen by a teacher
Used by the routines at 28446, 28672 and 62495. If the character was seen by a teacher, return with the carry flag set and the teacher's character number in H'.
H 172 (ERIC), 168 (ANGELFACE) or 167 (BOY WANDER)
28220 CALL 28304 Get the floor (155, 162, 169) nearest to the character in D
This entry point is used by the routine at 30636.
28223 CALL 28327 Get teacher's visibility range in [C,B]
28226 EXX
28227 LD B,4 There are 4 teachers
28229 LD H,163 And the first is 163=MR WACKER
28231 LD L,98 Byte 98 holds the teacher's x-coordinate
28233 LD A,(HL) Pick it up in A
28234 EXX
28235 CP B Is the teacher at or to the left of the upper bound of the visibility range?
28236 JR Z,28247 Jump if so
28238 JR C,28247
28240 EXX
28241 INC H Next teacher
28242 DJNZ 28231 Jump back until all four teachers are done
28244 AND A Clear the carry flag to indicate character wasn't seen
28245 EXX
28246 RET
28247 CP C Is the teacher to the left of the lower bound of the visibility range?
28248 JR C,28240 Jump back to consider the next teacher if so
The teacher's x-coordinate is within the visibility range [C,B]. Now to check his y-coordinate.
28250 EXX
28251 LD L,112 Is there a controlling routine address in bytes 111 and 112 of the teacher's buffer?
28253 LD A,(HL)
28254 AND A
28255 JR NZ,28241 Jump back to consider the next teacher if so
28257 LD L,97
28259 LD A,(HL) A=teacher's y-coordinate
28260 INC L L=98
28261 EXX
28262 CP 158 Is the teacher near or on the top floor?
28264 JR NC,28270 Jump if not
28266 LD A,155 155=top floor
28268 JR 28278
28270 CP 165 Is the teacher near or on the middle floor?
28272 LD A,162 162=middle floor
28274 JR C,28278 Jump if so
28276 LD A,169 169=bottom floor
28278 CP D Is the teacher within the y-coordinate visibility range?
28279 JR NZ,28240 Jump back to consider the next teacher if not
28281 EXX
28282 LD A,(HL) A=teacher's x-coordinate
28283 EXX
28284 CP E Is the teacher standing right where the boy is?
28285 SCF Set carry flag
28286 RET Z Return with carry flag set if so
28287 CP E Set carry flag if boy is to the right of the teacher
28288 LD A,0 A=128 if the boy is to the right of the teacher, 0 if the boy is to the left
28290 RRA
28291 EXX
28292 LD L,96 Byte 96 holds the teacher's animatory state
28294 XOR (HL) Reset bit 7 of A if the teacher is facing the boy
28295 LD L,98
28297 EXX
28298 RLCA Push bit 7 of A into the carry flag
28299 CCF Set the carry flag if the teacher is facing the boy
28300 RET C Return if the teacher is facing the boy
28301 JR 28240 Jump back to consider the next teacher