| Routines

6D62: Check whether ERIC can be seen by an adult

Used by the routine at 7D3E. 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.
6D62 | LD H,$D2 | 0xD2=ERIC
This entry point is used by the routines at 775B (with H=0xCE: BOY WANDER) and 77F2 (with H=0xCF: ANGELFACE).
6D64 | CALL $6CEE | Collect in C and B the lower and upper x-coordinates of the 'visibility region' (20 character spaces wide) around the boy
6D67 | EXX |
6D68 | LD H,$C8 | 0xC8=MR WACKER
6D6A | LD B,$06 | There are 6 adult characters
6D6C | EXX |
6D6D | CALL $6D32 | Find the first adult character inside the visibility region (if any)
6D70 | JR C,$6D79 | Jump if we found one who can see the boy
6D72 | AND A | Are there any adult characters left to check?
6D73 | RET Z | Return with the carry flag reset if not
6D74 | CALL $6D4C | 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
6D77 | JR NC,$6D72 | 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.
6D79 | EXX |
6D7A | LD A,H | A=character number of the adult who saw the boy
6D7B | EXX |
6D7C | RET | Return with the carry flag set