Prev: 52637 Up: Map Next: 52744
52645: Test Move Up
Checks the walls for an object that is moving in the direction of heading zero. The front edge is the vertical position plus the vertical size. The two ends of that edge, now and after the move, are checked with CheckWallVertical.
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.
TestMoveUp 52645 LD L,(IX+1) Fetch the horizontal position of the object.
52648 LD H,(IX+2)
52651 LD C,(IX+8) Fetch the horizontal size.
52654 LD B,0
52656 AND A Subtract it to get the left end in DE.
52657 SBC HL,BC
52659 EX DE,HL
52660 LD L,(IX+3) Fetch the vertical position of the object.
52663 LD H,(IX+4)
52666 LD C,(IX+9) Fetch the vertical size.
52669 ADD HL,BC Add it to get the front edge.
Check the cell at the left end.
52670 PUSH DE Stash the left end and the front edge on the stack.
52671 PUSH HL
52672 CALL CheckWallVertical Call CheckWallVertical.
52675 POP DE Restore the front edge and the left end from the stack, with the registers swapped.
52676 POP HL
52677 RET C Return if the object has hit a wall.
Check the cell at the right end, if it is in another cell.
52678 PUSH HL Stash the left end and the front edge on the stack.
52679 PUSH DE
52680 LD C,(IX+8) Double the horizontal size into BC.
52683 SLA C
52685 LD B,0
52687 LD A,H Find the right end of the front edge.
52688 ADD HL,BC
52689 CP H Jump to TestMoveUp_Same if it is in the same cell.
52690 JR Z,TestMoveUp_Same
52692 EX DE,HL Make the right end the one to check.
52693 CALL CheckWallVertical Call CheckWallVertical.
52696 POP HL Restore the left end and the front edge from the stack.
52697 POP DE
52698 RET C Return if the object has hit a wall.
Check the cells after the move.
52699 LD A,(41493) Fetch VerticalSpeed.
52702 LD C,A Make it a word in BC.
52703 LD B,0
52705 LD A,H Find the front edge after the move.
52706 ADD HL,BC
52707 CP H Return if it is in the same cell.
52708 RET Z
52709 PUSH DE Stash the left end and the front edge on the stack.
52710 PUSH HL
52711 CALL CheckWallVertical Call CheckWallVertical.
52714 POP DE Restore the front edge and the left end from the stack, with the registers swapped.
52715 POP HL
52716 RET C Return if the object has hit a wall.
52717 LD C,(IX+8) Double the horizontal size into BC.
52720 SLA C
52722 LD B,0
52724 ADD HL,BC Find the right end of the front edge.
52725 EX DE,HL Make the right end the one to check.
Check the cell at the right end.
52726 JP CheckWallVertical Jump to CheckWallVertical.
The ends are in the same cell, so only the cell beyond the front edge is checked.
TestMoveUp_Same 52729 POP HL Restore the front edge and the left end from the stack.
52730 POP DE
52731 LD A,(41493) Fetch VerticalSpeed.
52734 LD C,A Make it a word in BC.
52735 LD B,0
52737 LD A,H Find the front edge after the move.
52738 ADD HL,BC
52739 CP H Return if it is in the same cell.
52740 RET Z
Check the cell.
52741 JP CheckWallVertical Jump to CheckWallVertical.
View the equivalent code in;
Prev: 52637 Up: Map Next: 52744