Prev: C535 Up: Map Next: C5BE
C5A9: 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 C5A9 LD A,(IX+$04) Fetch the width of the first object.
C5AC ADD A,(IY+$04) Add the width of the second object.
C5AF LD D,A Copy the total to D.
C5B0 LD A,(IX+$01) Fetch the x position of the first object.
C5B3 ADD A,C Add C.
C5B4 SUB (IY+$01) Subtract the x position of the second object.
C5B7 JP P,TestOverlapInX_Compare Jump to TestOverlapInX_Compare if the sign flag is clear.
C5BA NEG Negate A.
TestOverlapInX_Compare C5BC SUB D Subtract D.
C5BD RET Return.
View the equivalent code in;
Prev: C535 Up: Map Next: C5BE