Prev: 50485 Up: Map Next: 50622
50601: 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 50601 LD A,(IX+4) Fetch the width of the first object.
50604 ADD A,(IY+4) Add the width of the second object.
50607 LD D,A Copy the total to D.
50608 LD A,(IX+1) Fetch the x position of the first object.
50611 ADD A,C Add C.
50612 SUB (IY+1) Subtract the x position of the second object.
50615 JP P,TestOverlapInX_Compare Jump to TestOverlapInX_Compare if the sign flag is clear.
50618 NEG Negate A.
TestOverlapInX_Compare 50620 SUB D Subtract D.
50621 RET Return.
View the equivalent code in;
Prev: 50485 Up: Map Next: 50622