| Routines

27886: Get the x-coordinate range within which a character can see or be seen

Used by the routines at 28002 and 28029. Returns with C and B holding the lower and upper x-coordinates of the range within which the target character can see or be seen. This routine is called with H holding either (a) the character number of a teacher (to determine where kids must be in order to get lines), or (b) the character number of a kid (to determine where a teacher must be in order to give lines).
Input
H | Target character's number
27886 | LD L,2 | Point HL at byte 2 of the character's buffer
27888 | LD D,(HL) | D=character's y-coordinate
27889 | DEC L | L=1
27890 | LD E,(HL) | E=character's x-coordinate
27891 | LD C,0 | Prepare a lower limit of 0 in case E<10
27893 | LD A,E | A=X (character's x-coordinate)
27894 | SUB 10 |
27896 | JR C,27899 |
27898 | LD C,A | C=max(0, X-10) (lower limit of the range)
27899 | ADD A,20 |
27901 | LD B,A | B=X+10 (upper limit of the range)
27902 | RET |