![]() |
Routines |
| Prev: CDA5 | Up: Map | Next: CE6B |
|
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.
|
||||||||||||
|
Find the front edge and the lower end.
|
||||||||||||
| TestMoveRight | CE08 | LD L,(IX+$01) | Fetch the horizontal position of the object. | |||||||||
| CE0B | LD H,(IX+$02) | |||||||||||
| CE0E | LD C,(IX+$08) | Fetch the horizontal size. | ||||||||||
| CE11 | LD B,$00 | |||||||||||
| CE13 | ADD HL,BC | Add it to get the front edge in DE. | ||||||||||
| CE14 | EX DE,HL | |||||||||||
| CE15 | LD L,(IX+$03) | Fetch the vertical position of the object. | ||||||||||
| CE18 | LD H,(IX+$04) | |||||||||||
| CE1B | LD C,(IX+$09) | Fetch the vertical size. | ||||||||||
| CE1E | AND A | Subtract it to get the lower end. | ||||||||||
| CE1F | SBC HL,BC | |||||||||||
|
Check the cell at the lower end.
|
||||||||||||
| CE21 | PUSH DE | Stash the front edge and the end on the stack. | ||||||||||
| CE22 | PUSH HL | |||||||||||
| CE23 | CALL CheckWallHorizontal | Call CheckWallHorizontal. | ||||||||||
| CE26 | POP HL | Restore the end and the front edge from the stack. | ||||||||||
| CE27 | POP DE | |||||||||||
| CE28 | RET C | Return if the object has hit a wall. | ||||||||||
|
Check the cell at the other end, if it is in another cell.
|
||||||||||||
| CE29 | PUSH DE | Stash the front edge and the end on the stack. | ||||||||||
| CE2A | PUSH HL | |||||||||||
| CE2B | LD C,(IX+$09) | Double the vertical size into BC. | ||||||||||
| CE2E | SLA C | |||||||||||
| CE30 | LD B,$00 | |||||||||||
| CE32 | LD A,H | Find the other end of the front edge. | ||||||||||
| CE33 | ADD HL,BC | |||||||||||
| CE34 | CP H | Jump to TestMoveRight_Same if it is in the same cell. | ||||||||||
| CE35 | JR Z,TestMoveRight_Same | |||||||||||
| CE37 | CALL CheckWallHorizontal | Call CheckWallHorizontal. | ||||||||||
| CE3A | POP DE | Restore the front edge and the end from the stack, with the registers swapped. | ||||||||||
| CE3B | POP HL | |||||||||||
| CE3C | RET C | Return if the object has hit a wall. | ||||||||||
|
Check the cells after the move.
|
||||||||||||
| CE3D | LD A,($A214) | Fetch HorizontalSpeed. | ||||||||||
| CE40 | LD C,A | Make it a word in BC. | ||||||||||
| CE41 | LD B,$00 | |||||||||||
| CE43 | LD A,H | Find the front edge after the move. | ||||||||||
| CE44 | ADD HL,BC | |||||||||||
| CE45 | CP H | Return if it is in the same cell. | ||||||||||
| CE46 | RET Z | |||||||||||
| CE47 | EX DE,HL | Make the first end the one to check. | ||||||||||
| CE48 | PUSH DE | Stash the front edge and the end on the stack. | ||||||||||
| CE49 | PUSH HL | |||||||||||
| CE4A | CALL CheckWallHorizontal | Call CheckWallHorizontal. | ||||||||||
| CE4D | POP HL | Restore the end and the front edge from the stack. | ||||||||||
| CE4E | POP DE | |||||||||||
| CE4F | RET C | Return if the object has hit a wall. | ||||||||||
| CE50 | LD C,(IX+$09) | Double the vertical size into BC. | ||||||||||
| CE53 | SLA C | |||||||||||
| CE55 | LD B,$00 | |||||||||||
| CE57 | ADD HL,BC | Find the other end of the front edge. | ||||||||||
|
Check the cell at the other end.
|
||||||||||||
| CE58 | JP CheckWallHorizontal | Jump to CheckWallHorizontal. | ||||||||||
|
The ends are in the same cell, so only the cell beyond the front edge is checked.
|
||||||||||||
| TestMoveRight_Same | CE5B | POP DE | Restore the end and the front edge from the stack, with the registers swapped. | |||||||||
| CE5C | POP HL | |||||||||||
| CE5D | LD A,($A214) | Fetch HorizontalSpeed. | ||||||||||
| CE60 | LD C,A | Make it a word in BC. | ||||||||||
| CE61 | LD B,$00 | |||||||||||
| CE63 | LD A,H | Find the front edge after the move. | ||||||||||
| CE64 | ADD HL,BC | |||||||||||
| CE65 | CP H | Return if it is in the same cell. | ||||||||||
| CE66 | RET Z | |||||||||||
| CE67 | EX DE,HL | Make the front edge the one to check. | ||||||||||
|
Check the cell.
|
||||||||||||
| CE68 | JP CheckWallHorizontal | Jump to CheckWallHorizontal. | ||||||||||
|
View the equivalent code in;
|
||||||||||||
| Prev: CDA5 | Up: Map | Next: CE6B |