Prev: 47287 Up: Map Next: 47330
47308: Test Overlap In Z
Tests whether two objects overlap along z, once the first has moved by its new speed along z. They overlap when the distance between the z positions is smaller than the height of whichever of the objects is lower.
Input
H New speed along z of the first object
IX The address of the first object
IY The address of the second object
Output
F Carry flag set if the objects overlap
Use the height of the lower object.
TestOverlapInZ 47308 LD A,(IX+3) Fetch the z position of the first object.
47311 ADD A,H Add H.
47312 SUB (IY+3) Subtract the z position of the second object.
47315 JP P,TestOverlapInZ_SecondLower Jump to TestOverlapInZ_SecondLower if the first object is the higher.
47318 NEG Negate A.
47320 LD D,(IX+6) Fetch the height of the first object, which is the lower.
Compare the distance with the height of the lower object.
TestOverlapInZ_Compare 47323 SUB D Subtract the height of the lower object, which sets the carry flag if they overlap.
47324 RET Return.
TestOverlapInZ_SecondLower 47325 LD D,(IY+6) Fetch the height of the second object, which is the lower.
47328 JR TestOverlapInZ_Compare Jump to TestOverlapInZ_Compare.
View the equivalent code in;
Prev: 47287 Up: Map Next: 47330