![]() |
Routines |
| Prev: 42407 | Up: Map | Next: 42533 |
|
Used by the routines at CheckEnemyOverlap and CheckShotHit.
Compares the position of an entity with the position of another one, in both directions.
|
||||||||||||||||||||
| ComparePositions | 42474 | PUSH HL | Save the Y position... | |||||||||||||||||
| 42475 | PUSH DE | ...and the X position. | ||||||||||||||||||
| 42476 | LD E,(IY+3) | Fetch the Y position of the other entity. | ||||||||||||||||||
| 42479 | LD D,(IY+4) | |||||||||||||||||||
| 42482 | AND A | Subtract it from the Y position, and jump if the result is positive. | ||||||||||||||||||
| 42483 | SBC HL,DE | |||||||||||||||||||
| 42485 | JR NC,ComparePositions_TestY | |||||||||||||||||||
| 42487 | EX DE,HL | Otherwise negate it. | ||||||||||||||||||
| 42488 | AND A | |||||||||||||||||||
| 42489 | LD HL,0 | |||||||||||||||||||
| 42492 | SBC HL,DE | |||||||||||||||||||
| ComparePositions_TestY | 42494 | LD A,H | Jump if the difference is more than the size of the world. | |||||||||||||||||
| 42495 | AND 63 | |||||||||||||||||||
| 42497 | JR NZ,ComparePositions_Done | |||||||||||||||||||
| 42499 | LD A,L | Jump if the difference is not less than the maximum. | ||||||||||||||||||
| 42500 | CP B | |||||||||||||||||||
| 42501 | JR NC,ComparePositions_Done | |||||||||||||||||||
| 42503 | POP HL | Restore the X position into HL and save it again. | ||||||||||||||||||
| 42504 | PUSH HL | |||||||||||||||||||
| 42505 | LD E,(IY+1) | Fetch the X position of the other entity. | ||||||||||||||||||
| 42508 | LD D,(IY+2) | |||||||||||||||||||
| 42511 | AND A | Subtract it from the X position, and jump if the result is positive. | ||||||||||||||||||
| 42512 | SBC HL,DE | |||||||||||||||||||
| 42514 | JR NC,ComparePositions_TestX | |||||||||||||||||||
| 42516 | EX DE,HL | Otherwise negate it. | ||||||||||||||||||
| 42517 | AND A | |||||||||||||||||||
| 42518 | LD HL,0 | |||||||||||||||||||
| 42521 | SBC HL,DE | |||||||||||||||||||
| ComparePositions_TestX | 42523 | LD A,H | Jump if the difference is more than the size of the world. | |||||||||||||||||
| 42524 | AND 63 | |||||||||||||||||||
| 42526 | JR NZ,ComparePositions_Done | |||||||||||||||||||
| 42528 | LD A,L | Compare the difference with the maximum, which sets the carry flag if it is less. | ||||||||||||||||||
| 42529 | CP C | |||||||||||||||||||
| ComparePositions_Done | 42530 | POP DE | Restore the X position... | |||||||||||||||||
| 42531 | POP HL | ...and the Y position. | ||||||||||||||||||
| 42532 | RET | Return. | ||||||||||||||||||
| Prev: 42407 | Up: Map | Next: 42533 |