| Routines

F9E5: Compare a character's coordinates with ERIC's

Used by the routine at F78E. On entry, the zero flag is set if ERIC's y-coordinate matches that of the character looking for him. On exit, the zero flag is set if the character looking for ERIC is within 3 y-coordinates of ERIC's location and not on a staircase (in which case the routine at F78E checks whether the character is also within 3 x-coordinates of ERIC's location, i.e. has found ERIC).
Input
A | Character's y-coordinate
D | ERIC's y-coordinate
H | Character number (0xA1, 0xA3, 0xA4)
L | 0x61
F9E5 | JR Z,$F9F2 | Jump if ERIC and his chaser are on the same floor
F9E7 | SUB D | A=absolute difference between the y-coordinates of ERIC and his chaser
F9E8 | JR NC,$F9EC
F9EA | NEG
F9EC | CP $04 | Are ERIC and his chaser within 3 y-coordinates of each other?
F9EE | JR C,$F9F2 | Jump if so
F9F0 | AND A | Reset the zero flag (ERIC has not been found)
F9F1 | RET |
F9F2 | LD A,(HL) | A=y-coordinate of the character looking for ERIC
F9F3 | JP $6649 | Set the zero flag set if the character is not on a staircase