Routines
 Prev: 28211 Up: Map Next: 28303
28220: Check whether a boy can be seen by a teacher
Used by the routines at 28446, 28672 and 62495. Returns with the carry flag set if the boy can be seen by a teacher, and the teacher's character number in H'.
Input
H 167 (BOY WANDER), 168 (ANGELFACE) or 172 (ERIC)
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 the 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 Collect the teacher's x-coordinate from byte 98 of his buffer
28233 LD A,(HL)
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 that the boy wasn't seen by a teacher
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 check his y-coordinate.
28250 EXX
28251 LD L,112 Is there an uninterruptible subcommand 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 (this one is occupied)
28257 LD L,97 Collect the teacher's y-coordinate from byte 97 of his buffer
28259 LD A,(HL)
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 This is the y-coordinate of the top floor
28268 JR 28278
28270 CP 165
28272 LD A,162 This is the y-coordinate of the middle floor
28274 JR C,28278 Jump if the teacher is near or on the middle floor
28276 LD A,169 This is the y-coordinate of the 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
The teacher is close enough to the boy to see him. But is the teacher facing the right way?
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 Return with the carry flag set if so
28286 RET Z
28287 CP E A=128 if the boy is to the right of the teacher, 0 if the boy is to the left
28288 LD A,0
28290 RRA
28291 EXX
28292 LD L,96 Byte 96 of the teacher's buffer holds his 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 Return with the carry flag set if the teacher is facing the boy
28300 RET C
28301 JR 28240 Otherwise consider the next teacher
 Prev: 28211 Up: Map Next: 28303