Prev: CC38 Up: Map Next: CCB2
CC9D: Test Overlap In X
Tests whether two objects overlap along x, once the first has moved by its new speed along x. They overlap when the distance between the x positions is smaller than the two widths added together.
Input
C New speed along x 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 x distance with the widths.
TestOverlapInX CC9D LD A,(IX+$04) Fetch the width of the first object.
CCA0 ADD A,(IY+$04) Add the width of the second object.
CCA3 LD D,A Copy the total to D.
Take the X coordinate of the second object off the X coordinate of the first object plus the new speed.
CCA4 LD A,(IX+$01) Fetch the x position of the first object.
CCA7 ADD A,C Add C.
CCA8 SUB (IY+$01) Subtract the x position of the second object.
CCAB JP P,TestOverlapInX_TakeWidths Jump to TestOverlapInX_TakeWidths if it is not negative.
CCAE NEG Negate A.
TestOverlapInX_TakeWidths CCB0 SUB D Take the total widths off it, which sets the carry flag if the objects overlap.
CCB1 RET Return.
View the equivalent code in;
Prev: CC38 Up: Map Next: CCB2