Prev: B890 Up: Map Next: B8B7
B8A2: 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 B8A2 LD A,(IX+$04) Fetch the width of the first object.
B8A5 ADD A,(IY+$04) Add the width of the second object.
B8A8 LD D,A Copy the total to D.
Work out the distance between the centres, once the first has moved.
B8A9 LD A,(IX+$01) Fetch the x position of the first object.
B8AC ADD A,C Add C.
B8AD SUB (IY+$01) Subtract the x position of the second object.
B8B0 JP P,TestOverlapInX_Compare Jump to TestOverlapInX_Compare if the distance is positive.
B8B3 NEG Negate A.
TestOverlapInX_Compare B8B5 SUB D Subtract D.
B8B6 RET Return.
View the equivalent code in;
Prev: B890 Up: Map Next: B8B7