Prev: CFC5 Up: Map Next: D002
CFDE: Check Walls Horizontal First
Used by the routines at CheckWallVertical and CheckWallVerticalReverse.
Checks whether an object touches any wall rectangle in the cell containing a point. The list for the cell is found from WallRectanglePointers. The horizontal range is checked first.
Input
DE The horizontal position of the point
HL The vertical position of the point
IX The address of the object
Output
A The depth into the wall along Y, negative if they overlap
F The carry flag is set if the object touches a wall
Find the cell and its rectangle list.
CheckWallsHorizontalFirst CFDE CALL FindPositionInCell Call FindPositionInCell.
CFE1 LD BC,$6151 Point BC at WallRectanglePointers.
CFE4 CALL GetTableEntry Call GetTableEntry.
CFE7 PUSH HL Copy the rectangle list to IY (using the stack).
CFE8 POP IY
Test the next rectangle.
CheckWallsHorizontalFirst_Next CFEA LD A,(IY+$00) Return if this is the end of the list.
CFED AND A
CFEE RET Z
CFEF CALL CheckOverlapAlongX Call CheckOverlapAlongX.
CFF2 JR NC,CheckWallsHorizontalFirst_Skip Jump to CheckWallsHorizontalFirst_Skip if the object is not touching the rectangle.
CFF4 CALL CheckOverlapAlongY Call CheckOverlapAlongY.
CFF7 RET C Return if the object is touching the rectangle.
Move on to the next rectangle.
CheckWallsHorizontalFirst_Skip CFF8 INC IY Move on to the next rectangle.
CFFA INC IY
CFFC INC IY
CFFE INC IY
D000 JR CheckWallsHorizontalFirst_Next Jump to CheckWallsHorizontalFirst_Next.
View the equivalent code in;
Prev: CFC5 Up: Map Next: D002