![]() |
Routines |
| Prev: 50516 | Up: Map | Next: 50612 |
|
Used by the routines at SpawnGhost, UpdateGhost, UpdateCreature, UpdateSpore, UpdateSpeedBonus, UpdateHealthBonus, UpdateMonsterItem, UpdateMonster and UpdateVillageItem.
Checks whether the object at IX is touching the player. Nothing touches the player until the player has finished materialising, or when the player is dead.
|
||||||||||||||
| CheckPlayerCollision | 50527 | LD A,(48130) | Return if the player is still materialising. | |||||||||||
| 50530 | SUB 112 | |||||||||||||
| 50532 | AND A | |||||||||||||
| 50533 | RET NZ | |||||||||||||
| 50534 | LD IY,48270 | Use the player as the second object. | ||||||||||||
| 50538 | LD A,(IY+0) | Return if the player is dead. | ||||||||||||
| 50541 | SUB 16 | |||||||||||||
| 50543 | CP 32 | |||||||||||||
| 50545 | RET NC | |||||||||||||
|
This entry point is used by the routines at CheckShotHit and CheckOverlapWithNextObject.
Checks whether two objects overlap along both axes. The overlap is measured from the centres of the objects, using half of the width and the depth of the object at IY and the full width and depth of the object at IX.
|
||||||||||||||
| CheckObjectsOverlap | 50546 | LD A,(IY+8) | Add half of the width of the second object to the width of the first object, to find the distance along the X axis within which they overlap. | |||||||||||
| 50549 | SRL A | |||||||||||||
| 50551 | ADD A,(IX+8) | |||||||||||||
| 50554 | LD C,A | |||||||||||||
| 50555 | LD B,0 | |||||||||||||
| 50557 | LD L,(IX+1) | Fetch the X positions of the two objects. | ||||||||||||
| 50560 | LD H,(IX+2) | |||||||||||||
| 50563 | LD E,(IY+1) | |||||||||||||
| 50566 | LD D,(IY+2) | |||||||||||||
| 50569 | AND A | Subtract one from the other to get the distance between the objects. | ||||||||||||
| 50570 | SBC HL,DE | |||||||||||||
| 50572 | CALL C,NegateHL | Turn the distance round if it is negative, so that it is positive. | ||||||||||||
| 50575 | AND A | Subtract the distance within which the objects overlap. | ||||||||||||
| 50576 | SBC HL,BC | |||||||||||||
| 50578 | RET NC | Return with the carry flag clear if the objects do not overlap along the X axis. | ||||||||||||
| 50579 | LD A,(IY+9) | Add half of the depth of the second object to the depth of the first object, to find the distance along the Y axis within which they overlap. | ||||||||||||
| 50582 | SRL A | |||||||||||||
| 50584 | ADD A,(IX+9) | |||||||||||||
| 50587 | LD C,A | |||||||||||||
| 50588 | LD B,0 | |||||||||||||
| 50590 | LD L,(IX+3) | Fetch the Y positions of the two objects. | ||||||||||||
| 50593 | LD H,(IX+4) | |||||||||||||
| 50596 | LD E,(IY+3) | |||||||||||||
| 50599 | LD D,(IY+4) | |||||||||||||
| 50602 | AND A | Subtract one from the other to get the distance between the objects. | ||||||||||||
| 50603 | SBC HL,DE | |||||||||||||
| 50605 | CALL C,NegateHL | Turn the distance round if it is negative, so that it is positive. | ||||||||||||
| 50608 | AND A | Subtract the distance within which the objects overlap. | ||||||||||||
| 50609 | SBC HL,BC | |||||||||||||
| 50611 | RET | Return with the carry flag set if the objects overlap along the Y axis as well, which means they are touching. | ||||||||||||
| Prev: 50516 | Up: Map | Next: 50612 |