Prev: CCB2 Up: Map Next: CCDD
CCC7: 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 CCC7 LD A,(IX+$03) Fetch the z position of the first object.
CCCA ADD A,H Add H.
CCCB SUB (IY+$03) Subtract the z position of the second object.
CCCE JP P,TestOverlapInZ_Second Jump to TestOverlapInZ_Second if it is not negative.
CCD1 NEG Negate A.
CCD3 LD D,(IX+$06) Fetch the height of the first object, which is the lower.
TestOverlapInZ_Compare CCD6 SUB D Take the height off it, which sets the carry flag if the objects overlap.
CCD7 RET Return.
TestOverlapInZ_Second CCD8 LD D,(IY+$06) Fetch the height of the second object, which is the lower.
CCDB JR TestOverlapInZ_Compare Jump to TestOverlapInZ_Compare.
View the equivalent code in;
Prev: CCB2 Up: Map Next: CCDD