![]() |
Routines |
| Prev: C19C | Up: Map | Next: C1DB |
|
Used by the routine at FindNearestMonster.
Works out the distance from the object at IX to a monster, which is the sum of the differences in their columns and rows.
|
||||||||||||||
|
Return FF if the monster is dead.
|
||||||||||||||
| GetDistanceToMonster | C1B9 | LD A,(IY+$00) | Check whether the monster is alive, and jump to GetDistanceToMonster_Alive if it is. | |||||||||||
| C1BC | AND A | |||||||||||||
| C1BD | JR NZ,GetDistanceToMonster_Alive | |||||||||||||
| C1BF | LD A,$FF | The monster has been killed, so return a distance of FF, which is too far away to matter. | ||||||||||||
| C1C1 | RET | Return. | ||||||||||||
|
Add the absolute differences in columns and rows.
|
||||||||||||||
| GetDistanceToMonster_Alive | C1C2 | LD A,(IX+$02) | Work out how many columns the object is from the monster. | |||||||||||
| C1C5 | SUB (IY+$02) | |||||||||||||
| C1C8 | JP P,GetDistanceToMonster_Rows | Jump to GetDistanceToMonster_Rows if the difference is not negative. | ||||||||||||
| C1CB | NEG | Otherwise turn the distance round, so that it is positive. | ||||||||||||
| GetDistanceToMonster_Rows | C1CD | LD C,A | Keep the distance in columns. | |||||||||||
| C1CE | LD A,(IX+$04) | Work out how many rows the object is from the monster. | ||||||||||||
| C1D1 | SUB (IY+$04) | |||||||||||||
| C1D4 | JP P,GetDistanceToMonster_Add | Jump to GetDistanceToMonster_Add if the difference is not negative. | ||||||||||||
| C1D7 | NEG | Otherwise turn the distance round, so that it is positive. | ||||||||||||
| GetDistanceToMonster_Add | C1D9 | ADD A,C | Add the two distances together to get the distance from the monster. | |||||||||||
| C1DA | RET | Return. | ||||||||||||
| Prev: C19C | Up: Map | Next: C1DB |