Prev: CC9D Up: Map Next: CCC7
CCB2: Test Overlap In Y
Tests whether two objects overlap along y, once the first has moved by its new speed along y. They overlap when the distance between the y positions is smaller than the two depths added together.
Input
L New speed along y 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
Compare the y distance with the depths.
TestOverlapInY CCB2 LD A,(IX+$05) Fetch the depth of the first object.
CCB5 ADD A,(IY+$05) Add the depth of the second object.
CCB8 LD D,A Copy the total to D.
Take the Y coordinate of the second object off the Y coordinate of the first object plus the new speed.
CCB9 LD A,(IX+$02) Fetch the y position of the first object.
CCBC ADD A,L Add L.
CCBD SUB (IY+$02) Subtract the y position of the second object.
CCC0 JP P,TestOverlapInY_TakeDepths Jump to TestOverlapInY_TakeDepths if it is not negative.
CCC3 NEG Negate A.
TestOverlapInY_TakeDepths CCC5 SUB D Take the total depths off it, which sets the carry flag if the objects overlap.
CCC6 RET Return.
View the equivalent code in;
Prev: CC9D Up: Map Next: CCC7