| Routines

28002: Check whether ERIC can be seen by an adult

Used by the routine at 32062. Returns with the carry flag set if there is an adult nearby who can see ERIC, and A holding the adult's character number. Otherwise returns with the carry flag reset and A holding 0.
28002 | LD H,210 | 210=ERIC
This entry point is used by the routines at 30555 (with H=206: BOY WANDER) and 30706 (with H=207: ANGELFACE).
28004 | CALL 27886 | Collect in C and B the lower and upper x-coordinates of the 'visibility region' (20 character spaces wide) around the boy
28007 | EXX |
28008 | LD H,200 | 200=MR WACKER
28010 | LD B,6 | There are 6 adult characters
28012 | EXX |
28013 | CALL 27954 | Find the first adult character inside the visibility region (if any)
28016 | JR C,28025 | Jump if we found one who can see the boy
28018 | AND A | Are there any adult characters left to check?
28019 | RET Z | Return with the carry flag reset if not
28020 | CALL 27980 | We must have found an adult character who is facing the wrong way to see the boy; skip this character and find the next one inside the visibility region
28023 | JR NC,28018 | Jump if there are no others inside the visibility region, or we found another one facing the wrong way
We found an adult character inside the visibility region and facing the right way to see the boy.
28025 | EXX |
28026 | LD A,H | A=character number of the adult who saw the boy
28027 | EXX |
28028 | RET | Return with the carry flag set