Prev: 53214 Up: Map Next: 53275
53250: Check Overlap Along Y
Used by the routines at CheckWallsVerticalFirst and CheckWallsHorizontalFirst.
Checks whether the vertical range of an object, after it moves by VerticalSpeed, overlaps the vertical range of a rectangle of a wall. The distance between the middles is compared with half of the height of the object plus the half height of the rectangle.
Input
D The vertical position of the object in the cell
IX The address of the object
IY The address of the rectangle
Output
A The depth into the rectangle, negative if they overlap
F The carry flag is set if the ranges overlap
Find the sum of the half heights.
CheckOverlapAlongY 53250 LD A,(IX+9) Find the sum of half of the height of the object and the half height of the rectangle, in C.
53253 SRL A
53255 ADD A,(IY+3)
53258 LD C,A
Find the distance between the middles.
53259 LD A,(41493) Fetch VerticalSpeed.
53262 SRA A Add half of it to the position, then find the distance from the middle of the rectangle.
53264 ADD A,D
53265 SUB (IY+1)
Make the distance positive, then subtract the sum.
53268 JP P,CheckOverlapAlongY_Depth Make the distance positive.
53271 NEG
CheckOverlapAlongY_Depth 53273 SUB C Subtract the sum.
53274 RET Return.
View the equivalent code in;
Prev: 53214 Up: Map Next: 53275