Skool Daze Routines
28327: Get limits of range within which one character can be seen by another
Used by the routines at 28220 and 30890. Returns with C and B holding the lower and upper bounds of the appropriate range of x-coordinates. This routine is called with DE holding either (a) the coordinates of a teacher (to determine where kids must be in order to get lines), or (b) the coordinates of a kid (to determine where a teacher must be in order to give lines).
D 155 (top floor), 162 (middle floor) or 169 (bottom floor)
E x-coordinate of character
28327 LD A,E A=x (character's x-coordinate)
28328 LD BC,24576 B=96, C=0 (maximum and minimum bounds)
28331 SUB 10 Is the character's x-coordinate < 10?
28333 JR C,28356 Jump if so
28335 LD C,A C=x-10
28336 LD A,D A=floor nearest to the character
28337 CP 169 Is the character nearest the bottom floor?
28339 JR Z,28356 Jump if so
28341 CP 162 Is the character nearest the middle floor?
28343 LD A,38 38=x-coordinate of Exam Room wall
28345 JR Z,28349 Jump if so
28347 LD A,57 57=x-coordinate of Map Room wall
28349 CP C Is character more than 10 paces to right of a wall?
28350 JR C,28356 Jump if so
28352 CP E Is character to the left of a wall?
28353 JR NC,28356 Jump if so
28355 LD C,A C=x-coordinate of wall that character is within 10 paces to the right of
28356 LD A,E A=x (character's x-coordinate)
28357 ADD A,10 A=x+10
28359 CP B Is character within 10 paces of the far right wall?
28360 RET NC Return if so
28361 LD B,A B=x+10
28362 LD A,D A=floor nearest to the character
28363 CP 169 Is character nearest to the bottom floor?
28365 RET Z Return if so
28366 CP 162 Is character nearest to the middle floor?
28368 LD A,37 37=x-coordinate of White Room wall
28370 JR Z,28374 Jump if so
28372 LD A,56 56=x-coordinate of Reading Room wall
28374 CP B Is character more than 10 paces to the left of a wall?
28375 RET NC Return if so
28376 CP E Is character to the right of a wall?
28377 RET C Return if so
28378 LD B,A B=x-coordinate of wall
28379 RET