Prev: C19C Up: Map Next: C1DB
C1B9: How far is the villain at IY from the thing at IX?
Used by the routine at NEAREST_VILLAIN.
Input
IX the thing
IY the villain's record
Output
A the columns apart plus the rows apart; 255 for an empty record
VILLAIN_DISTANCE C1B9 LD A,(IY+$00) an empty record is 255 away
C1BC AND A
C1BD JR NZ,VILLAIN_DISTANCE_0
C1BF LD A,$FF
C1C1 RET
VILLAIN_DISTANCE_0 C1C2 LD A,(IX+$02) the columns apart
C1C5 SUB (IY+$02)
C1C8 JP P,VILLAIN_DISTANCE_1
C1CB NEG
VILLAIN_DISTANCE_1 C1CD LD C,A
C1CE LD A,(IX+$04) plus the rows apart
C1D1 SUB (IY+$04)
C1D4 JP P,VILLAIN_DISTANCE_2
C1D7 NEG
VILLAIN_DISTANCE_2 C1D9 ADD A,C
C1DA RET
Prev: C19C Up: Map Next: C1DB