Back to Skool Routines
27886: Get limits of range within which character can be seen by teacher
Used by the routines at 28002 and 28029. Returns with B and C holding the upper and lower x-coordinates of the range.
H Number of character we're interested in the visibility of
27886 LD L,2 Copy the character's y-coordinate from byte 2 of the character buffer into D
27888 LD D,(HL)
27889 DEC L Copy the character's x-coordinate from byte 1 of the character buffer into E
27890 LD E,(HL)
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 range)
27899 ADD A,20
27901 LD B,A B=X+10 (upper limit of range)
27902 RET