![]() |
Routines |
| Prev: 49605 | Up: Map | Next: 49764 |
|
Used by the routine at RunProjectile.
Tests if an object touches either of the two creatures that wander about the room, which are in the object records ObjectsTable_Creatures and ObjectsTable_SecondCreature. The touching is tested with a margin of 2.
|
||||||||||||
| TestCreatureHit | 49670 | LD D,1 | Set the result to 1, as nothing has been hit. | |||||||||
| 49672 | LD IY,42991 | Start with the first of the creatures, ObjectsTable_Creatures. | ||||||||||
| 49676 | CALL TestCreatureHit_Test | Call TestCreatureHit_Test to test it. | ||||||||||
| 49679 | LD A,D | Fetch the result. | ||||||||||
| 49680 | AND A | Return if the creature was hit. | ||||||||||
| 49681 | RET Z | |||||||||||
| 49682 | LD IY,43023 | Move on to the second of the creatures, ObjectsTable_SecondCreature. | ||||||||||
|
This entry point is used by the routine at TestProjectileHit.
Ignore objects that are free, are of a type below 8, or are explosions.
|
||||||||||||
| TestCreatureHit_Test | 49686 | LD A,(IY+0) | Fetch the type of the creature. | |||||||||
| 49689 | AND %11111000 | Keep only the bits of the type that tell the kinds of object apart. | ||||||||||
| 49691 | RET Z | Return if the object is free or of a type that is below 8. | ||||||||||
| 49692 | CP 64 | Compare the kind of the object with 64, which is an explosion. | ||||||||||
|
This entry point is used by the routine at TestProjectileHit.
|
||||||||||||
| TestCreatureHit_Projectile | 49694 | RET Z | Return if it is an explosion. | |||||||||
|
Test along x.
|
||||||||||||
| 49695 | LD A,(IY+1) | Fetch the x position of the creature. | ||||||||||
| 49698 | SUB (IX+1) | Take away the x position of the object. | ||||||||||
| 49701 | JP P,TestCreatureHit_PositiveX | |||||||||||
| 49704 | NEG | Make the distance positive. | ||||||||||
| TestCreatureHit_PositiveX | 49706 | LD E,A | Stash the distance along x in E. | |||||||||
| 49707 | LD A,(IY+4) | Add the half sizes along x of the two objects, and the margin. | ||||||||||
| 49710 | ADD A,(IX+4) | |||||||||||
| 49713 | ADD A,2 | |||||||||||
| 49715 | CP E | Return with the carry flag set if the distance is more than that. | ||||||||||
| 49716 | RET C | |||||||||||
|
Test along y.
|
||||||||||||
| 49717 | LD A,(IX+2) | Fetch the y position of the object. | ||||||||||
| 49720 | SUB (IY+2) | Take away the y position of the creature. | ||||||||||
| 49723 | JP P,TestCreatureHit_PositiveY | |||||||||||
| 49726 | NEG | Make the distance positive. | ||||||||||
| TestCreatureHit_PositiveY | 49728 | LD E,A | Stash the distance along y in E. | |||||||||
| 49729 | LD A,(IX+5) | Add the half sizes along y of the two objects, and the margin. | ||||||||||
| 49732 | ADD A,(IY+5) | |||||||||||
| 49735 | ADD A,2 | |||||||||||
| 49737 | CP E | Return with the carry flag set if the distance is more than that. | ||||||||||
| 49738 | RET C | |||||||||||
|
Test along z.
|
||||||||||||
| 49739 | LD A,(IX+3) | Fetch the z position of the object. | ||||||||||
| 49742 | SUB (IY+3) | Take away the z position of the creature. | ||||||||||
| 49745 | JP P,TestCreatureHit_PositiveZ | |||||||||||
| 49748 | NEG | Make the distance positive. | ||||||||||
| TestCreatureHit_PositiveZ | 49750 | LD E,A | Stash the distance along z in E. | |||||||||
| 49751 | LD A,(IX+6) | Add the sizes along z of the two objects, and the margin. | ||||||||||
| 49754 | ADD A,(IY+6) | |||||||||||
| 49757 | ADD A,2 | |||||||||||
| 49759 | CP E | Return with the carry flag set if the distance is more than that. | ||||||||||
| 49760 | RET C | |||||||||||
| 49761 | LD D,0 | Set the result to 0, as the creature has been hit. | ||||||||||
| 49763 | RET | Return. | ||||||||||
| Prev: 49605 | Up: Map | Next: 49764 |