Prev: 52280 Up: Map Next: 52402
52381: 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 52381 LD A,(IX+4) Fetch the width of the first object.
52384 ADD A,(IY+4) Add the width of the second object.
52387 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.
52388 LD A,(IX+1) Fetch the x position of the first object.
52391 ADD A,C Add C.
52392 SUB (IY+1) Subtract the x position of the second object.
52395 JP P,TestOverlapInX_TakeWidths Jump to TestOverlapInX_TakeWidths if it is not negative.
52398 NEG Negate A.
TestOverlapInX_TakeWidths 52400 SUB D Take the total widths off it, which sets the carry flag if the objects overlap.
52401 RET Return.
View the equivalent code in;
Prev: 52280 Up: Map Next: 52402