![]() |
Routines |
| Prev: DE72 | Up: Map | Next: DF34 |
|
Tests the move of an object that is facing to the right (along the positive X axis), in the same way as TestMoveUp. The front edge is at the X position plus the half width of the object, and it is tested from the top corner to the bottom corner. Each cell is tested by TestCellMovingRight.
|
||||||||||||
| TestMoveRight | DED3 | LD L,(IX+$01) | Fetch the X position of the object. | |||||||||
| DED6 | LD H,(IX+$02) | |||||||||||
| DED9 | LD C,(IX+$08) | Fetch the half width of the object. | ||||||||||
| DEDC | LD B,$00 | |||||||||||
| DEDE | ADD HL,BC | Add it to get the front edge. | ||||||||||
| DEDF | EX DE,HL | Keep the front edge. | ||||||||||
| DEE0 | LD L,(IX+$03) | Fetch the Y position of the object. | ||||||||||
| DEE3 | LD H,(IX+$04) | |||||||||||
| DEE6 | LD C,(IX+$09) | Fetch the half depth of the object. | ||||||||||
| DEE9 | AND A | Subtract it to get the first side edge. | ||||||||||
| DEEA | SBC HL,BC | |||||||||||
| DEEC | PUSH DE | Save the edges. | ||||||||||
| DEED | PUSH HL | |||||||||||
| DEEE | CALL TestCellMovingRight | Check whether the first corner of the front edge hits a wall. | ||||||||||
| DEF1 | POP HL | Get the edges back. | ||||||||||
| DEF2 | POP DE | |||||||||||
| DEF3 | RET C | Return if the object hit a wall. | ||||||||||
| DEF4 | PUSH DE | Save the edges again. | ||||||||||
| DEF5 | PUSH HL | |||||||||||
| DEF6 | LD C,(IX+$09) | Work out the depth of the object. | ||||||||||
| DEF9 | SLA C | |||||||||||
| DEFB | LD B,$00 | |||||||||||
| DEFD | LD A,H | Keep the cell of the first side edge. | ||||||||||
| DEFE | ADD HL,BC | Work out the second side edge. | ||||||||||
| DEFF | CP H | Jump to TestMoveRight_SameCell if the second side edge is in the same cell as the first. | ||||||||||
| DF00 | JR Z,TestMoveRight_SameCell | |||||||||||
| DF02 | CALL TestCellMovingRight | Check whether the second corner of the front edge hits a wall. | ||||||||||
| DF05 | POP DE | Get the edges back, with the registers swapped over. | ||||||||||
| DF06 | POP HL | |||||||||||
| DF07 | RET C | Return if the object hit a wall. | ||||||||||
| DF08 | LD C,(IX+$0A) | Fetch the velocity along the X axis. | ||||||||||
| DF0B | LD B,$00 | |||||||||||
| DF0D | LD A,H | Keep the cell of the front edge. | ||||||||||
| DF0E | ADD HL,BC | Work out where the velocity takes the front edge to. | ||||||||||
| DF0F | CP H | Return if the front edge stays in the same cell. | ||||||||||
| DF10 | RET Z | |||||||||||
| TestMoveRight_Next | DF11 | EX DE,HL | Use the new position of the front edge. | |||||||||
| DF12 | PUSH DE | Save the edges. | ||||||||||
| DF13 | PUSH HL | |||||||||||
| DF14 | CALL TestCellMovingRight | Check whether the first corner hits a wall in the next cell. | ||||||||||
| DF17 | POP HL | Get the edges back. | ||||||||||
| DF18 | POP DE | |||||||||||
| DF19 | RET C | Return if the object hit a wall. | ||||||||||
| DF1A | LD C,(IX+$09) | Work out the depth of the object. | ||||||||||
| DF1D | SLA C | |||||||||||
| DF1F | LD B,$00 | |||||||||||
| DF21 | ADD HL,BC | Work out the second side edge. | ||||||||||
|
Check whether the second corner hits a wall in the next cell.
|
||||||||||||
| DF22 | JP TestCellMovingRight | Jump to TestCellMovingRight. | ||||||||||
|
The side edges are in the same cell.
|
||||||||||||
| TestMoveRight_SameCell | DF25 | POP DE | Get the edges back, with the registers swapped over. | |||||||||
| DF26 | POP HL | |||||||||||
| DF27 | LD C,(IX+$0A) | Fetch the velocity along the X axis. | ||||||||||
| DF2A | LD B,$00 | |||||||||||
| DF2C | LD A,H | Keep the cell of the front edge. | ||||||||||
| DF2D | ADD HL,BC | Work out where the velocity takes the front edge to. | ||||||||||
| DF2E | CP H | Return if the front edge stays in the same cell. | ||||||||||
| DF2F | RET Z | |||||||||||
| DF30 | EX DE,HL | Use the new position of the front edge. | ||||||||||
|
Check whether the first corner hits a wall in the next cell.
|
||||||||||||
| DF31 | JP TestCellMovingRight | Jump to TestCellMovingRight. | ||||||||||
|
View the equivalent code in;
|
||||||||||||
| Prev: DE72 | Up: Map | Next: DF34 |