Prev: 57443 Up: Map Next: 57504
57479: 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 57479 LD A,(IX+8) Work out the combined half widths of the object and the rectangle.
57482 SRL A
57484 ADD A,(IY+2)
57487 LD C,A
Find the distance between the middles.
57488 LD A,(IX+10) Fetch the velocity along x.
57491 SRA A Add half of it to the position, then find the distance from the middle of the rectangle.
57493 ADD A,E
57494 SUB (IY+0)
Make the distance positive, then subtract the sum.
57497 JP P,CheckOverlapAlongX_Depth Make the distance positive.
57500 NEG
Subtract the combined half widths and return.
CheckOverlapAlongX_Depth 57502 SUB C Subtract the sum.
57503 RET Return.
View the equivalent code in;
Prev: 57443 Up: Map Next: 57504