Prev: 9DB1 Up: Map Next: 9DD8
9DBB: Test Horizontal Overlap
Used by the routine at TestBoxesOverlap.
Tests whether two boxes overlap horizontally. The result is stored in 5C1C.
Input
D Width of the second box
L Horizontal position of the second box
IX Address of the first box
TestHorizontalOverlap 9DBB XOR A Clear the result.
9DBC LD ($5C1C),A Store it.
9DBF LD A,(IX+$00) Fetch the left edge of the first box.
9DC2 SUB L Subtract the left edge of the second box.
9DC3 JR C,TestHorizontalOverlap_Left Jump to TestHorizontalOverlap_Left if the first box starts to the left of the second.
9DC5 CP D Does the first box start within the width of the second?
9DC6 JR C,SetOverlapFlag Jump to SetOverlapFlag if so.
TestHorizontalOverlap_Left 9DC8 LD A,(IX+$00) Fetch the left edge of the first box.
9DCB CP L Is it to the right of the second box?
9DCC RET NC Return if so, as the boxes do not overlap.
9DCD ADD A,(IX+$02) Add the width of the first box to get its right edge.
9DD0 CP L Is it to the left of the second box?
9DD1 RET C Return if so, as the boxes do not overlap.
This entry point is used by the routines at TestVerticalOverlap, TestSlopeCollision and FindMirroredSlopeOverlap.
SetOverlapFlag 9DD2 LD A,$01 Set the result to 01.
9DD4 LD ($5C1C),A Store it.
9DD7 RET Return.
Prev: 9DB1 Up: Map Next: 9DD8