Prev: CD23 Up: Map Next: CD8C
CD40: Check Walls Each Way
Used by the routine at HandleTumbleweed.
Checks the walls for each speed on its own, so that the object slides along a wall instead of stopping. For each speed it sets the heading to the direction of that speed, and checks the walls with the other speed set to zero.
Input
IX The address of the object
Check the walls for the horizontal speed.
CheckWallsEachWay CD40 LD A,($A214) Fetch HorizontalSpeed.
CD43 AND A Jump to CheckWallsEachWay_Vertical if it is zero.
CD44 JR Z,CheckWallsEachWay_Vertical
CD46 LD A,$40 Use heading one.
CD48 JP P,CheckWallsEachWay_SetHorizontal Jump to CheckWallsEachWay_SetHorizontal if the speed is not negative.
CD4B OR %10000000 Use heading three.
Set the heading, zero VerticalSpeed, and check the walls.
CheckWallsEachWay_SetHorizontal CD4D LD C,A Keep the heading in C.
CD4E LD A,(IX+$06) Fetch the heading and flags.
CD51 AND %00111111 Keep the other bits.
CD53 OR C Put in the new heading.
CD54 LD (IX+$06),A Set the heading and flags.
CD57 LD A,($A215) Fetch VerticalSpeed.
CD5A PUSH AF Stash the vertical speed on the stack.
CD5B XOR A Set VerticalSpeed to 00.
CD5C LD ($A215),A
CD5F CALL TestMove Call TestMove.
CD62 POP AF Restore the vertical speed from the stack.
CD63 LD ($A215),A Set VerticalSpeed.
Check the walls for the vertical speed.
CheckWallsEachWay_Vertical CD66 LD A,($A215) Fetch VerticalSpeed.
CD69 AND A Return if it is zero.
CD6A RET Z
CD6B LD A,$00 Use heading zero.
CD6D JP P,CheckWallsEachWay_SetVertical Jump to CheckWallsEachWay_SetVertical if the speed is not negative.
CD70 OR %10000000 Use heading two.
Set the heading, zero HorizontalSpeed, and check the walls.
CheckWallsEachWay_SetVertical CD72 LD C,A Keep the heading in C.
CD73 LD A,(IX+$06) Fetch the heading and flags.
CD76 AND %00111111 Keep the other bits.
CD78 OR C Put in the new heading.
CD79 LD (IX+$06),A Set the heading and flags.
CD7C LD A,($A214) Fetch HorizontalSpeed.
CD7F PUSH AF Stash the horizontal speed on the stack.
CD80 XOR A Set HorizontalSpeed to 00.
CD81 LD ($A214),A
CD84 CALL CheckWalls Call CheckWalls.
CD87 POP AF Restore the horizontal speed from the stack.
CD88 LD ($A214),A Set HorizontalSpeed.
CD8B RET Return.
Prev: CD23 Up: Map Next: CD8C