![]() |
Routines |
| Prev: DE6A | Up: Map | Next: DED3 |
|
Tests the move of an object that is facing up the screen (along the positive Y axis). The front edge is at the Y position plus the depth of the object, and it is tested from the left corner to the right corner, in the cell that the edge is in and then in the next one along the Y axis that the velocity takes the object into. Each cell is tested by TestCellMovingUp.
|
||||||||||||
| TestMoveUp | DE72 | LD L,(IX+$01) | Fetch the X position of the object. | |||||||||
| DE75 | LD H,(IX+$02) | |||||||||||
| DE78 | LD C,(IX+$08) | Fetch the half width of the object. | ||||||||||
| DE7B | LD B,$00 | |||||||||||
| DE7D | AND A | Subtract it to get the left edge, and keep it in DE. | ||||||||||
| DE7E | SBC HL,BC | |||||||||||
| DE80 | EX DE,HL | |||||||||||
| DE81 | LD L,(IX+$03) | Fetch the Y position of the object. | ||||||||||
| DE84 | LD H,(IX+$04) | |||||||||||
| DE87 | LD C,(IX+$09) | Add the half depth to get the front edge. | ||||||||||
| DE8A | ADD HL,BC | |||||||||||
| DE8B | PUSH DE | Save the left edge and the front edge. | ||||||||||
| DE8C | PUSH HL | |||||||||||
| DE8D | CALL TestCellMovingUp | Check whether the front left corner of the object hits a wall. | ||||||||||
| DE90 | POP DE | Get the edges back, with the registers swapped over. | ||||||||||
| DE91 | POP HL | |||||||||||
| DE92 | RET C | Return if the object hit a wall. | ||||||||||
| DE93 | PUSH HL | Save the edges again. | ||||||||||
| DE94 | PUSH DE | |||||||||||
| DE95 | LD C,(IX+$08) | Work out the width of the object. | ||||||||||
| DE98 | SLA C | |||||||||||
| DE9A | LD B,$00 | |||||||||||
| DE9C | LD A,H | Keep the cell of the left edge. | ||||||||||
| DE9D | ADD HL,BC | Work out the right edge. | ||||||||||
| DE9E | CP H | Jump to TestMoveUp_SameCell if the right edge is in the same cell as the left edge. | ||||||||||
| DE9F | JR Z,TestMoveUp_SameCell | |||||||||||
| DEA1 | EX DE,HL | Use the right edge. | ||||||||||
| DEA2 | CALL TestCellMovingUp | Check whether the front right corner of the object hits a wall. | ||||||||||
| DEA5 | POP HL | Get the edges back. | ||||||||||
| DEA6 | POP DE | |||||||||||
| DEA7 | RET C | Return if the object hit a wall. | ||||||||||
| DEA8 | LD C,(IX+$0B) | Fetch the velocity along the Y axis. | ||||||||||
| DEAB | LD B,$00 | |||||||||||
| DEAD | LD A,H | Keep the cell of the front edge. | ||||||||||
| DEAE | ADD HL,BC | Work out where the velocity takes the front edge to. | ||||||||||
| DEAF | CP H | Return if the front edge stays in the same cell. | ||||||||||
| DEB0 | RET Z | |||||||||||
| DEB1 | PUSH DE | Save the edges. | ||||||||||
| DEB2 | PUSH HL | |||||||||||
| DEB3 | CALL TestCellMovingUp | Check whether the front left corner hits a wall in the next cell. | ||||||||||
| DEB6 | POP DE | Get the edges back, with the registers swapped over. | ||||||||||
| DEB7 | POP HL | |||||||||||
| DEB8 | RET C | Return if the object hit a wall. | ||||||||||
| DEB9 | LD C,(IX+$08) | Work out the width of the object. | ||||||||||
| DEBC | SLA C | |||||||||||
| DEBE | LD B,$00 | |||||||||||
| DEC0 | ADD HL,BC | Work out the right edge. | ||||||||||
| DEC1 | EX DE,HL | Use the right edge. | ||||||||||
|
Check whether the front right corner hits a wall in the next cell.
|
||||||||||||
| DEC2 | JP TestCellMovingUp | Jump to TestCellMovingUp. | ||||||||||
|
The left and right edges are in the same cell.
|
||||||||||||
| TestMoveUp_SameCell | DEC5 | POP HL | Get the edges back. | |||||||||
| DEC6 | POP DE | |||||||||||
| DEC7 | LD C,(IX+$0B) | Fetch the velocity along the Y axis. | ||||||||||
| DECA | LD B,$00 | |||||||||||
| DECC | LD A,H | Keep the cell of the front edge. | ||||||||||
| DECD | ADD HL,BC | Work out where the velocity takes the front edge to. | ||||||||||
| DECE | CP H | Return if the front edge stays in the same cell. | ||||||||||
| DECF | RET Z | |||||||||||
|
Check whether the front edge hits a wall in the next cell.
|
||||||||||||
| DED0 | JP TestCellMovingUp | Jump to TestCellMovingUp. | ||||||||||
|
View the equivalent code in;
|
||||||||||||
| Prev: DE6A | Up: Map | Next: DED3 |