Prev: E063 Up: Map Next: E0A0
E087: Check Overlap Along X
Used by the routines at CheckWallsVerticalFirst and CheckWallsHorizontalFirst.
Checks whether an object overlaps a rectangle along the X axis, using the position that the velocity takes the object to.
Input
E Position of the object along the X axis in the cell
IX Object
IY Rectangle
Output
A The depth that the object has gone into the rectangle (negative)
F The carry flag is set if the object overlaps the rectangle
Find the sum of the half widths.
CheckOverlapAlongX E087 LD A,(IX+$08) Work out the combined half widths of the object and the rectangle.
E08A SRL A
E08C ADD A,(IY+$02)
E08F LD C,A
Find the distance between the middles.
E090 LD A,(IX+$0A) Fetch the velocity along x.
E093 SRA A Add half of it to the position, then find the distance from the middle of the rectangle.
E095 ADD A,E
E096 SUB (IY+$00)
Make the distance positive, then subtract the sum.
E099 JP P,CheckOverlapAlongX_Depth Make the distance positive.
E09C NEG
Subtract the combined half widths and return.
CheckOverlapAlongX_Depth E09E SUB C Subtract the sum.
E09F RET Return.
View the equivalent code in;
Prev: E063 Up: Map Next: E0A0