Routines
 Prev: 70A9 Up: Map Next: 70D5
70AA: Check whether a policeman can spot Sam
Used by the routine at 7222. Compares the policeman's coordinates with Sam's, and returns with the carry flag set if they are close enough that the policeman has a chance of spotting Sam (if other conditions are favourable).
Input
H 0xDE or 0xDF (policeman)
70AA LD L,\$01 Point HL at byte 0x01 of the policeman's buffer
70AC LD A,(\$E601) A=Sam's x-coordinate
70AF SUB (HL) Subtract the policeman's x-coordinate
70B0 DEC HL Point HL at byte 0x00 of the policeman's buffer
70B1 JR NC,\$70BB Jump if the policeman's x-coordinate is less than or equal to Sam's
70B3 NEG A=horizontal distance between Sam and the policeman
70B5 BIT 7,(HL) Is the policeman facing left (and thus facing Sam)?
70B7 JR Z,\$70C2 Jump if so
70B9 JR \$70BF
70BB BIT 7,(HL) Is the policeman facing right (and thus facing Sam)?
70BD JR NZ,\$70C2 Jump if so
70BF CP \$03 Is the policeman (who is not facing Sam) at least 3 x-coordinates away from Sam?
70C1 RET NC Return with the carry flag reset if so
70C2 CP \$10 Is the policeman at least 16 x-coordinates away from Sam?
70C4 RET NC Return with the carry flag reset if so
At this point, the policeman is either facing Sam and located less than 16 x-coordinates away from him, or facing away from Sam and located less than 3 x-coordinates away from him. Now we check the vertical distance between the two characters.
70C5 LD E,A E=horizontal distance between Sam and the policeman
70C6 LD L,\$02 Point HL at byte 0x02 of the policeman's buffer
70C8 LD A,(\$E602) A=Sam's y-coordinate
70CB SUB (HL) Subtract the policeman's y-coordinate
70CC JR NC,\$70D0 Jump if the policeman's y-coordinate is less than or equal to Sam's
70CE NEG
70D0 LD D,A D=vertical distance between Sam and the policeman
70D1 ADD A,E Add the horizontal distance between Sam and the policeman
70D2 CP \$21 Set the carry flag if the result is less than 33
70D4 RET
 Prev: 70A9 Up: Map Next: 70D5