Prev: CE6B Up: Map Next: CF35
CED0: Test Move Left
Checks the walls for an object that is moving in the direction of heading three. The front edge is the horizontal position minus the horizontal size. The two ends of that edge, now and after the move, are checked with CheckWallHorizontalReverse.
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.
TestMoveLeft CED0 LD L,(IX+$01) Fetch the horizontal position of the object.
CED3 LD H,(IX+$02)
CED6 LD C,(IX+$08) Fetch the horizontal size.
CED9 LD B,$00
CEDB AND A Subtract it to get the front edge in DE.
CEDC SBC HL,BC
CEDE EX DE,HL
CEDF LD L,(IX+$03) Fetch the vertical position of the object.
CEE2 LD H,(IX+$04)
CEE5 LD C,(IX+$09) Fetch the vertical size.
CEE8 AND A Subtract it to get the lower end.
CEE9 SBC HL,BC
Check the cell at the lower end.
CEEB PUSH DE Stash the front edge and the end on the stack.
CEEC PUSH HL
CEED CALL CheckWallHorizontalReverse Call CheckWallHorizontalReverse.
CEF0 POP HL Restore the end and the front edge from the stack.
CEF1 POP DE
CEF2 RET C Return if the object has hit a wall.
Check the cell at the other end, if it is in another cell.
CEF3 PUSH DE Stash the front edge and the end on the stack.
CEF4 PUSH HL
CEF5 LD C,(IX+$09) Double the vertical size into BC.
CEF8 SLA C
CEFA LD B,$00
CEFC LD A,H Find the other end of the front edge.
CEFD ADD HL,BC
CEFE CP H Jump to TestMoveLeft_Same if it is in the same cell.
CEFF JR Z,TestMoveLeft_Same
CF01 CALL CheckWallHorizontalReverse Call CheckWallHorizontalReverse.
CF04 POP DE Restore the front edge and the end from the stack, with the registers swapped.
CF05 POP HL
CF06 RET C Return if the object has hit a wall.
Check the cells after the move.
CF07 LD A,($A214) Fetch HorizontalSpeed.
CF0A LD C,A Make it a negative word in BC.
CF0B LD B,$FF
CF0D LD A,H Find the front edge after the move.
CF0E ADD HL,BC
CF0F CP H Return if it is in the same cell.
CF10 RET Z
CF11 EX DE,HL Make the first end the one to check.
CF12 PUSH DE Stash the front edge and the end on the stack.
CF13 PUSH HL
CF14 CALL CheckWallHorizontalReverse Call CheckWallHorizontalReverse.
CF17 POP HL Restore the end and the front edge from the stack.
CF18 POP DE
CF19 RET C Return if the object has hit a wall.
CF1A LD C,(IX+$09) Double the vertical size into BC.
CF1D SLA C
CF1F LD B,$00
CF21 ADD HL,BC Find the other end of the front edge.
Check the cell at the other end.
CF22 JP CheckWallHorizontalReverse Jump to CheckWallHorizontalReverse.
The ends are in the same cell, so only the cell beyond the front edge is checked.
TestMoveLeft_Same CF25 POP DE Restore the end and the front edge from the stack, with the registers swapped.
CF26 POP HL
CF27 LD A,($A214) Fetch HorizontalSpeed.
CF2A LD C,A Make it a negative word in BC.
CF2B LD B,$FF
CF2D LD A,H Find the front edge after the move.
CF2E ADD HL,BC
CF2F CP H Return if it is in the same cell.
CF30 RET Z
CF31 EX DE,HL Make the front edge the one to check.
Check the cell.
CF32 JP CheckWallHorizontalReverse Jump to CheckWallHorizontalReverse.
View the equivalent code in;
Prev: CE6B Up: Map Next: CF35