Routines

28029: Find any main kids near teacher


Used by routine at 30102

H Character number of teacher (200-204)

28029 CDEE6C CALL 27886 Get limits of teacher's range of vision in C and B
28032 2E00 LD L,0
28034 D9 EXX
28035 26CE LD H,206 206=BOY WANDER
28037 01FF05 LD BC,1535 B'=5 (main kids including ERIC), C'=255
28040 D9 EXX
28041 CD326D CALL 27954 Find first main kid in visible range
28044 A7 AND A
28045 7D LD A,L A=character number of nearest kid, or 0 if none
28046 C8 RET Z Return if finished checking all main kids
28047 7B LD A,E A=teacher's x-coordinate
28048 D9 EXX
28049 93 SUB E Subtract x-coordinate of main kid
28050 3002 JR NC,28054 Jump if kid's to left of teacher
28052 ED44 NEG
28054 B9 CP C Is this kid closer to the teacher than the last?
28055 3005 JR NC,28062 Jump if not
28057 4F LD C,A C'=distance from teacher of nearest kid found so far
28058 7C LD A,H A=character number of this kid
28059 D9 EXX
28060 6F LD L,A Store this character number in L
28061 D9 EXX
28062 CD4D6D CALL 27981 Check the remaining kids
28065 18E9 JR 28044