Prev: 57504 Up: Map Next: 57565
57540: Check Overlap Along Y
Used by the routines at CheckWallsVerticalFirst and CheckWallsHorizontalFirst.
Checks whether an object overlaps a rectangle along the Y axis, using the position that the velocity takes the object to.
Input
D Position of the object along the Y 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 depths.
CheckOverlapAlongY 57540 LD A,(IX+9) Work out the combined half depths of the object and the rectangle.
57543 SRL A
57545 ADD A,(IY+3)
57548 LD C,A
Find the distance between the middles.
57549 LD A,(IX+11) Fetch the velocity along y.
57552 SRA A Add half of it to the position, then find the distance from the middle of the rectangle.
57554 ADD A,D
57555 SUB (IY+1)
Make the distance positive, then subtract the sum.
57558 JP P,CheckOverlapAlongY_Depth Make the distance positive.
57561 NEG
CheckOverlapAlongY_Depth 57563 SUB C Subtract the sum.
57564 RET Return.
View the equivalent code in;
Prev: 57504 Up: Map Next: 57565