![]() |
Routines |
| Prev: 49564 | Up: Map | Next: 49627 |
|
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 255 if the monster is dead.
|
||||||||||||||
| GetDistanceToMonster | 49593 | LD A,(IY+0) | Check whether the monster is alive, and jump to GetDistanceToMonster_Alive if it is. | |||||||||||
| 49596 | AND A | |||||||||||||
| 49597 | JR NZ,GetDistanceToMonster_Alive | |||||||||||||
| 49599 | LD A,255 | The monster has been killed, so return a distance of 255, which is too far away to matter. | ||||||||||||
| 49601 | RET | Return. | ||||||||||||
|
Add the absolute differences in columns and rows.
|
||||||||||||||
| GetDistanceToMonster_Alive | 49602 | LD A,(IX+2) | Work out how many columns the object is from the monster. | |||||||||||
| 49605 | SUB (IY+2) | |||||||||||||
| 49608 | JP P,GetDistanceToMonster_Rows | Jump to GetDistanceToMonster_Rows if the difference is not negative. | ||||||||||||
| 49611 | NEG | Otherwise turn the distance round, so that it is positive. | ||||||||||||
| GetDistanceToMonster_Rows | 49613 | LD C,A | Keep the distance in columns. | |||||||||||
| 49614 | LD A,(IX+4) | Work out how many rows the object is from the monster. | ||||||||||||
| 49617 | SUB (IY+4) | |||||||||||||
| 49620 | JP P,GetDistanceToMonster_Add | Jump to GetDistanceToMonster_Add if the difference is not negative. | ||||||||||||
| 49623 | NEG | Otherwise turn the distance round, so that it is positive. | ||||||||||||
| GetDistanceToMonster_Add | 49625 | ADD A,C | Add the two distances together to get the distance from the monster. | |||||||||||
| 49626 | RET | Return. | ||||||||||||
| Prev: 49564 | Up: Map | Next: 49627 |