Prev: CD9D Up: Map Next: CE08
CDA5: 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 CDA5 LD L,(IX+$01) Fetch the horizontal position of the object.
CDA8 LD H,(IX+$02)
CDAB LD C,(IX+$08) Fetch the horizontal size.
CDAE LD B,$00
CDB0 AND A Subtract it to get the left end in DE.
CDB1 SBC HL,BC
CDB3 EX DE,HL
CDB4 LD L,(IX+$03) Fetch the vertical position of the object.
CDB7 LD H,(IX+$04)
CDBA LD C,(IX+$09) Fetch the vertical size.
CDBD ADD HL,BC Add it to get the front edge.
Check the cell at the left end.
CDBE PUSH DE Stash the left end and the front edge on the stack.
CDBF PUSH HL
CDC0 CALL CheckWallVertical Call CheckWallVertical.
CDC3 POP DE Restore the front edge and the left end from the stack, with the registers swapped.
CDC4 POP HL
CDC5 RET C Return if the object has hit a wall.
Check the cell at the right end, if it is in another cell.
CDC6 PUSH HL Stash the left end and the front edge on the stack.
CDC7 PUSH DE
CDC8 LD C,(IX+$08) Double the horizontal size into BC.
CDCB SLA C
CDCD LD B,$00
CDCF LD A,H Find the right end of the front edge.
CDD0 ADD HL,BC
CDD1 CP H Jump to TestMoveUp_Same if it is in the same cell.
CDD2 JR Z,TestMoveUp_Same
CDD4 EX DE,HL Make the right end the one to check.
CDD5 CALL CheckWallVertical Call CheckWallVertical.
CDD8 POP HL Restore the left end and the front edge from the stack.
CDD9 POP DE
CDDA RET C Return if the object has hit a wall.
Check the cells after the move.
CDDB LD A,($A215) Fetch VerticalSpeed.
CDDE LD C,A Make it a word in BC.
CDDF LD B,$00
CDE1 LD A,H Find the front edge after the move.
CDE2 ADD HL,BC
CDE3 CP H Return if it is in the same cell.
CDE4 RET Z
CDE5 PUSH DE Stash the left end and the front edge on the stack.
CDE6 PUSH HL
CDE7 CALL CheckWallVertical Call CheckWallVertical.
CDEA POP DE Restore the front edge and the left end from the stack, with the registers swapped.
CDEB POP HL
CDEC RET C Return if the object has hit a wall.
CDED LD C,(IX+$08) Double the horizontal size into BC.
CDF0 SLA C
CDF2 LD B,$00
CDF4 ADD HL,BC Find the right end of the front edge.
CDF5 EX DE,HL Make the right end the one to check.
Check the cell at the right end.
CDF6 JP CheckWallVertical Jump to CheckWallVertical.
The ends are in the same cell, so only the cell beyond the front edge is checked.
TestMoveUp_Same CDF9 POP HL Restore the front edge and the left end from the stack.
CDFA POP DE
CDFB LD A,($A215) Fetch VerticalSpeed.
CDFE LD C,A Make it a word in BC.
CDFF LD B,$00
CE01 LD A,H Find the front edge after the move.
CE02 ADD HL,BC
CE03 CP H Return if it is in the same cell.
CE04 RET Z
Check the cell.
CE05 JP CheckWallVertical Jump to CheckWallVertical.
View the equivalent code in;
Prev: CD9D Up: Map Next: CE08