![]() |
Routines |
| Prev: CE08 | Up: Map | Next: CED0 |
|
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.
|
||||||||||||
|
Find the left end and the front edge.
|
||||||||||||
| TestMoveDown | CE6B | LD L,(IX+$01) | Fetch the horizontal position of the object. | |||||||||
| CE6E | LD H,(IX+$02) | |||||||||||
| CE71 | LD C,(IX+$08) | Fetch the horizontal size. | ||||||||||
| CE74 | LD B,$00 | |||||||||||
| CE76 | AND A | Subtract it to get the left end in DE. | ||||||||||
| CE77 | SBC HL,BC | |||||||||||
| CE79 | EX DE,HL | |||||||||||
| CE7A | LD L,(IX+$03) | Fetch the vertical position of the object. | ||||||||||
| CE7D | LD H,(IX+$04) | |||||||||||
| CE80 | LD C,(IX+$09) | Fetch the vertical size. | ||||||||||
| CE83 | AND A | Subtract it to get the front edge. | ||||||||||
| CE84 | SBC HL,BC | |||||||||||
|
Check the cell at the left end.
|
||||||||||||
| CE86 | PUSH DE | Stash the left end and the front edge on the stack. | ||||||||||
| CE87 | PUSH HL | |||||||||||
| CE88 | CALL CheckWallVerticalReverse | Call CheckWallVerticalReverse. | ||||||||||
| CE8B | POP DE | Restore the front edge and the left end from the stack, with the registers swapped. | ||||||||||
| CE8C | POP HL | |||||||||||
| CE8D | RET C | Return if the object has hit a wall. | ||||||||||
|
Check the cell at the right end, if it is in another cell.
|
||||||||||||
| CE8E | PUSH HL | Stash the left end and the front edge on the stack. | ||||||||||
| CE8F | PUSH DE | |||||||||||
| CE90 | LD C,(IX+$08) | Double the horizontal size into BC. | ||||||||||
| CE93 | SLA C | |||||||||||
| CE95 | LD B,$00 | |||||||||||
| CE97 | LD A,H | Find the right end of the front edge. | ||||||||||
| CE98 | ADD HL,BC | |||||||||||
| CE99 | CP H | Jump to TestMoveDown_Same if it is in the same cell. | ||||||||||
| CE9A | JR Z,TestMoveDown_Same | |||||||||||
| CE9C | EX DE,HL | Make the right end the one to check. | ||||||||||
| CE9D | CALL CheckWallVerticalReverse | Call CheckWallVerticalReverse. | ||||||||||
| CEA0 | POP HL | Restore the left end and the front edge from the stack. | ||||||||||
| CEA1 | POP DE | |||||||||||
| CEA2 | RET C | Return if the object has hit a wall. | ||||||||||
|
Check the cells after the move.
|
||||||||||||
| CEA3 | LD A,($A215) | Fetch VerticalSpeed. | ||||||||||
| CEA6 | LD C,A | Make it a negative word in BC. | ||||||||||
| CEA7 | LD B,$FF | |||||||||||
| CEA9 | LD A,H | Find the front edge after the move. | ||||||||||
| CEAA | ADD HL,BC | |||||||||||
| CEAB | CP H | Return if it is in the same cell. | ||||||||||
| CEAC | RET Z | |||||||||||
| CEAD | PUSH DE | Stash the left end and the front edge on the stack. | ||||||||||
| CEAE | PUSH HL | |||||||||||
| CEAF | CALL CheckWallVerticalReverse | Call CheckWallVerticalReverse. | ||||||||||
| CEB2 | POP DE | Restore the front edge and the left end from the stack, with the registers swapped. | ||||||||||
| CEB3 | POP HL | |||||||||||
| CEB4 | RET C | Return if the object has hit a wall. | ||||||||||
| CEB5 | LD C,(IX+$08) | Double the horizontal size into BC. | ||||||||||
| CEB8 | SLA C | |||||||||||
| CEBA | LD B,$00 | |||||||||||
| CEBC | ADD HL,BC | Find the right end of the front edge. | ||||||||||
| CEBD | EX DE,HL | Make the right end the one to check. | ||||||||||
|
Check the cell at the right end.
|
||||||||||||
| CEBE | JP CheckWallVerticalReverse | Jump to CheckWallVerticalReverse. | ||||||||||
|
The ends are in the same cell, so only the cell beyond the front edge is checked.
|
||||||||||||
| TestMoveDown_Same | CEC1 | POP HL | Restore the front edge and the left end from the stack. | |||||||||
| CEC2 | POP DE | |||||||||||
| CEC3 | LD A,($A215) | Fetch VerticalSpeed. | ||||||||||
| CEC6 | LD C,A | Make it a negative word in BC. | ||||||||||
| CEC7 | LD B,$FF | |||||||||||
| CEC9 | LD A,H | Find the front edge after the move. | ||||||||||
| CECA | ADD HL,BC | |||||||||||
| CECB | CP H | Return if it is in the same cell. | ||||||||||
| CECC | RET Z | |||||||||||
|
Check the cell.
|
||||||||||||
| CECD | JP CheckWallVerticalReverse | Jump to CheckWallVerticalReverse. | ||||||||||
|
View the equivalent code in;
|
||||||||||||
| Prev: CE08 | Up: Map | Next: CED0 |