![]() |
Routines |
| Prev: 57043 | Up: Map | Next: 57239 |
|
Tests the move of an object that is facing down the screen (along the negative Y axis), in the same way as TestMoveUp. The front edge is at the Y position minus the half depth of the object, and it is tested from the left corner to the right corner. Each cell is tested by TestCellMovingDown.
|
||||||||||||
| TestMoveDown | 57140 | LD L,(IX+1) | Fetch the X position of the object. | |||||||||
| 57143 | LD H,(IX+2) | |||||||||||
| 57146 | LD C,(IX+8) | Fetch the half width of the object. | ||||||||||
| 57149 | LD B,0 | |||||||||||
| 57151 | AND A | Subtract it to get the left edge, and keep it in DE. | ||||||||||
| 57152 | SBC HL,BC | |||||||||||
| 57154 | EX DE,HL | |||||||||||
| 57155 | LD L,(IX+3) | Fetch the Y position of the object. | ||||||||||
| 57158 | LD H,(IX+4) | |||||||||||
| 57161 | LD C,(IX+9) | Fetch the half depth of the object. | ||||||||||
| 57164 | AND A | Subtract it to get the front edge. | ||||||||||
| 57165 | SBC HL,BC | |||||||||||
| 57167 | PUSH DE | Save the edges. | ||||||||||
| 57168 | PUSH HL | |||||||||||
| 57169 | CALL TestCellMovingDown | Check whether the front left corner of the object hits a wall. | ||||||||||
| 57172 | POP DE | Get the edges back, with the registers swapped over. | ||||||||||
| 57173 | POP HL | |||||||||||
| 57174 | RET C | Return if the object hit a wall. | ||||||||||
| 57175 | PUSH HL | Save the edges again. | ||||||||||
| 57176 | PUSH DE | |||||||||||
| 57177 | LD C,(IX+8) | Work out the width of the object. | ||||||||||
| 57180 | SLA C | |||||||||||
| 57182 | LD B,0 | |||||||||||
| 57184 | LD A,H | Keep the cell of the left edge. | ||||||||||
| 57185 | ADD HL,BC | Work out the right edge. | ||||||||||
| 57186 | CP H | Jump to TestMoveDown_SameCell if the right edge is in the same cell as the left edge. | ||||||||||
| 57187 | JR Z,TestMoveDown_SameCell | |||||||||||
| 57189 | EX DE,HL | Use the right edge. | ||||||||||
| 57190 | CALL TestCellMovingDown | Check whether the front right corner of the object hits a wall. | ||||||||||
| 57193 | POP HL | Get the edges back. | ||||||||||
| 57194 | POP DE | |||||||||||
| 57195 | RET C | Return if the object hit a wall. | ||||||||||
|
Check the cells after the move.
|
||||||||||||
| 57196 | LD C,(IX+11) | Fetch the velocity along the Y axis. | ||||||||||
| 57199 | LD B,255 | Make it a negative word in BC. | ||||||||||
|
Work out the position that the velocity takes the front edge to, and return if it is in the same cell.
|
||||||||||||
| 57201 | LD A,H | Find the front edge after the move. | ||||||||||
| 57202 | ADD HL,BC | |||||||||||
| 57203 | CP H | Return if it is in the same cell. | ||||||||||
| 57204 | RET Z | |||||||||||
| 57205 | PUSH DE | Save the edges. | ||||||||||
| 57206 | PUSH HL | |||||||||||
| 57207 | CALL TestCellMovingDown | Check whether the front left corner hits a wall in the next cell. | ||||||||||
| 57210 | POP DE | Get the edges back, with the registers swapped over. | ||||||||||
| 57211 | POP HL | |||||||||||
| 57212 | RET C | Return if the object hit a wall. | ||||||||||
| 57213 | LD C,(IX+8) | Work out the width of the object. | ||||||||||
| 57216 | SLA C | |||||||||||
| 57218 | LD B,0 | |||||||||||
| 57220 | ADD HL,BC | Work out the right edge. | ||||||||||
| 57221 | EX DE,HL | Use the right edge. | ||||||||||
|
Check whether the front right corner hits a wall in the next cell.
|
||||||||||||
| 57222 | JP TestCellMovingDown | Jump to TestCellMovingDown. | ||||||||||
|
The left and right edges are in the same cell.
|
||||||||||||
| TestMoveDown_SameCell | 57225 | POP HL | Get the edges back. | |||||||||
| 57226 | POP DE | |||||||||||
|
Fetch the velocity along the Y axis, which is negative.
|
||||||||||||
| 57227 | LD C,(IX+11) | Fetch the velocity along the Y axis. | ||||||||||
| 57230 | LD B,255 | Make it a negative word in BC. | ||||||||||
|
Work out the position that the velocity takes the front edge to, and return if it is in the same cell.
|
||||||||||||
| 57232 | LD A,H | Find the front edge after the move. | ||||||||||
| 57233 | ADD HL,BC | |||||||||||
| 57234 | CP H | Return if it is in the same cell. | ||||||||||
| 57235 | RET Z | |||||||||||
|
Check whether the front edge hits a wall in the next cell.
|
||||||||||||
| 57236 | JP TestCellMovingDown | Jump to TestCellMovingDown. | ||||||||||
|
View the equivalent code in;
|
||||||||||||
| Prev: 57043 | Up: Map | Next: 57239 |