Prev: 52645 Up: Map Next: 52843
52744: Test Move Right
Checks the walls for an object that is moving in the direction of heading one. The front edge is the horizontal position plus the horizontal size. The two ends of that edge, now and after the move, are checked with CheckWallHorizontal.
Input
IX The address of the object
Output
F The carry flag is set if the object hit a wall
Find the front edge and the lower end.
TestMoveRight 52744 LD L,(IX+1) Fetch the horizontal position of the object.
52747 LD H,(IX+2)
52750 LD C,(IX+8) Fetch the horizontal size.
52753 LD B,0
52755 ADD HL,BC Add it to get the front edge in DE.
52756 EX DE,HL
52757 LD L,(IX+3) Fetch the vertical position of the object.
52760 LD H,(IX+4)
52763 LD C,(IX+9) Fetch the vertical size.
52766 AND A Subtract it to get the lower end.
52767 SBC HL,BC
Check the cell at the lower end.
52769 PUSH DE Stash the front edge and the end on the stack.
52770 PUSH HL
52771 CALL CheckWallHorizontal Call CheckWallHorizontal.
52774 POP HL Restore the end and the front edge from the stack.
52775 POP DE
52776 RET C Return if the object has hit a wall.
Check the cell at the other end, if it is in another cell.
52777 PUSH DE Stash the front edge and the end on the stack.
52778 PUSH HL
52779 LD C,(IX+9) Double the vertical size into BC.
52782 SLA C
52784 LD B,0
52786 LD A,H Find the other end of the front edge.
52787 ADD HL,BC
52788 CP H Jump to TestMoveRight_Same if it is in the same cell.
52789 JR Z,TestMoveRight_Same
52791 CALL CheckWallHorizontal Call CheckWallHorizontal.
52794 POP DE Restore the front edge and the end from the stack, with the registers swapped.
52795 POP HL
52796 RET C Return if the object has hit a wall.
Check the cells after the move.
52797 LD A,(41492) Fetch HorizontalSpeed.
52800 LD C,A Make it a word in BC.
52801 LD B,0
52803 LD A,H Find the front edge after the move.
52804 ADD HL,BC
52805 CP H Return if it is in the same cell.
52806 RET Z
52807 EX DE,HL Make the first end the one to check.
52808 PUSH DE Stash the front edge and the end on the stack.
52809 PUSH HL
52810 CALL CheckWallHorizontal Call CheckWallHorizontal.
52813 POP HL Restore the end and the front edge from the stack.
52814 POP DE
52815 RET C Return if the object has hit a wall.
52816 LD C,(IX+9) Double the vertical size into BC.
52819 SLA C
52821 LD B,0
52823 ADD HL,BC Find the other end of the front edge.
Check the cell at the other end.
52824 JP CheckWallHorizontal Jump to CheckWallHorizontal.
The ends are in the same cell, so only the cell beyond the front edge is checked.
TestMoveRight_Same 52827 POP DE Restore the end and the front edge from the stack, with the registers swapped.
52828 POP HL
52829 LD A,(41492) Fetch HorizontalSpeed.
52832 LD C,A Make it a word in BC.
52833 LD B,0
52835 LD A,H Find the front edge after the move.
52836 ADD HL,BC
52837 CP H Return if it is in the same cell.
52838 RET Z
52839 EX DE,HL Make the front edge the one to check.
Check the cell.
52840 JP CheckWallHorizontal Jump to CheckWallHorizontal.
View the equivalent code in;
Prev: 52645 Up: Map Next: 52843