Prev: 47248 Up: Map Next: 47287
47266: 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 47266 LD A,(IX+4) Fetch the width of the first object.
47269 ADD A,(IY+4) Add the width of the second object.
47272 LD D,A Copy the total to D.
Work out the distance between the centres, once the first has moved.
47273 LD A,(IX+1) Fetch the x position of the first object.
47276 ADD A,C Add C.
47277 SUB (IY+1) Subtract the x position of the second object.
47280 JP P,TestOverlapInX_Compare Jump to TestOverlapInX_Compare if the distance is positive.
47283 NEG Negate A.
TestOverlapInX_Compare 47285 SUB D Subtract D.
47286 RET Return.
View the equivalent code in;
Prev: 47248 Up: Map Next: 47287