Prev: 53153 Up: Map Next: 53214
53189: Check Overlap Along X
Used by the routines at CheckWallsVerticalFirst and CheckWallsHorizontalFirst.
Checks whether the horizontal range of an object, after it moves by HorizontalSpeed, overlaps the horizontal range of a rectangle of a wall. The distance between the middles is compared with half of the width of the object plus the half width of the rectangle.
Input
E The horizontal 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 widths.
CheckOverlapAlongX 53189 LD A,(IX+8) Find the sum of half of the width of the object and the half width of the rectangle, in C.
53192 SRL A
53194 ADD A,(IY+2)
53197 LD C,A
Find the distance between the middles.
53198 LD A,(41492) Fetch HorizontalSpeed.
53201 SRA A Add half of it to the position, then find the distance from the middle of the rectangle.
53203 ADD A,E
53204 SUB (IY+0)
Make the distance positive, then subtract the sum.
53207 JP P,CheckOverlapAlongX_Depth Make the distance positive.
53210 NEG
CheckOverlapAlongX_Depth 53212 SUB C Subtract the sum.
53213 RET Return.
View the equivalent code in;
Prev: 53153 Up: Map Next: 53214