Prev: 52744 Up: Map Next: 52944
52843: Test Move Down
Checks the walls for an object that is moving in the direction of heading two. The front edge is the vertical position minus the vertical size. The two ends of that edge, now and after the move, are checked with CheckWallVerticalReverse.
Input
IX The address of the object
Output
F The carry flag is set if the object hit a wall
Find the left end and the front edge.
TestMoveDown 52843 LD L,(IX+1) Fetch the horizontal position of the object.
52846 LD H,(IX+2)
52849 LD C,(IX+8) Fetch the horizontal size.
52852 LD B,0
52854 AND A Subtract it to get the left end in DE.
52855 SBC HL,BC
52857 EX DE,HL
52858 LD L,(IX+3) Fetch the vertical position of the object.
52861 LD H,(IX+4)
52864 LD C,(IX+9) Fetch the vertical size.
52867 AND A Subtract it to get the front edge.
52868 SBC HL,BC
Check the cell at the left end.
52870 PUSH DE Stash the left end and the front edge on the stack.
52871 PUSH HL
52872 CALL CheckWallVerticalReverse Call CheckWallVerticalReverse.
52875 POP DE Restore the front edge and the left end from the stack, with the registers swapped.
52876 POP HL
52877 RET C Return if the object has hit a wall.
Check the cell at the right end, if it is in another cell.
52878 PUSH HL Stash the left end and the front edge on the stack.
52879 PUSH DE
52880 LD C,(IX+8) Double the horizontal size into BC.
52883 SLA C
52885 LD B,0
52887 LD A,H Find the right end of the front edge.
52888 ADD HL,BC
52889 CP H Jump to TestMoveDown_Same if it is in the same cell.
52890 JR Z,TestMoveDown_Same
52892 EX DE,HL Make the right end the one to check.
52893 CALL CheckWallVerticalReverse Call CheckWallVerticalReverse.
52896 POP HL Restore the left end and the front edge from the stack.
52897 POP DE
52898 RET C Return if the object has hit a wall.
Check the cells after the move.
52899 LD A,(41493) Fetch VerticalSpeed.
52902 LD C,A Make it a negative word in BC.
52903 LD B,255
52905 LD A,H Find the front edge after the move.
52906 ADD HL,BC
52907 CP H Return if it is in the same cell.
52908 RET Z
52909 PUSH DE Stash the left end and the front edge on the stack.
52910 PUSH HL
52911 CALL CheckWallVerticalReverse Call CheckWallVerticalReverse.
52914 POP DE Restore the front edge and the left end from the stack, with the registers swapped.
52915 POP HL
52916 RET C Return if the object has hit a wall.
52917 LD C,(IX+8) Double the horizontal size into BC.
52920 SLA C
52922 LD B,0
52924 ADD HL,BC Find the right end of the front edge.
52925 EX DE,HL Make the right end the one to check.
Check the cell at the right end.
52926 JP CheckWallVerticalReverse Jump to CheckWallVerticalReverse.
The ends are in the same cell, so only the cell beyond the front edge is checked.
TestMoveDown_Same 52929 POP HL Restore the front edge and the left end from the stack.
52930 POP DE
52931 LD A,(41493) Fetch VerticalSpeed.
52934 LD C,A Make it a negative word in BC.
52935 LD B,255
52937 LD A,H Find the front edge after the move.
52938 ADD HL,BC
52939 CP H Return if it is in the same cell.
52940 RET Z
Check the cell.
52941 JP CheckWallVerticalReverse Jump to CheckWallVerticalReverse.
View the equivalent code in;
Prev: 52744 Up: Map Next: 52944