![]() |
Routines |
| Prev: 56946 | Up: Map | Next: 57140 |
|
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 | 57043 | LD L,(IX+1) | Fetch the X position of the object. | |||||||||
| 57046 | LD H,(IX+2) | |||||||||||
| 57049 | LD C,(IX+8) | Fetch the half width of the object. | ||||||||||
| 57052 | LD B,0 | |||||||||||
| 57054 | ADD HL,BC | Add it to get the front edge. | ||||||||||
| 57055 | EX DE,HL | Keep the front edge. | ||||||||||
| 57056 | LD L,(IX+3) | Fetch the Y position of the object. | ||||||||||
| 57059 | LD H,(IX+4) | |||||||||||
| 57062 | LD C,(IX+9) | Fetch the half depth of the object. | ||||||||||
| 57065 | AND A | Subtract it to get the first side edge. | ||||||||||
| 57066 | SBC HL,BC | |||||||||||
| 57068 | PUSH DE | Save the edges. | ||||||||||
| 57069 | PUSH HL | |||||||||||
| 57070 | CALL TestCellMovingRight | Check whether the first corner of the front edge hits a wall. | ||||||||||
| 57073 | POP HL | Get the edges back. | ||||||||||
| 57074 | POP DE | |||||||||||
| 57075 | RET C | Return if the object hit a wall. | ||||||||||
| 57076 | PUSH DE | Save the edges again. | ||||||||||
| 57077 | PUSH HL | |||||||||||
| 57078 | LD C,(IX+9) | Work out the depth of the object. | ||||||||||
| 57081 | SLA C | |||||||||||
| 57083 | LD B,0 | |||||||||||
| 57085 | LD A,H | Keep the cell of the first side edge. | ||||||||||
| 57086 | ADD HL,BC | Work out the second side edge. | ||||||||||
| 57087 | CP H | Jump to TestMoveRight_SameCell if the second side edge is in the same cell as the first. | ||||||||||
| 57088 | JR Z,TestMoveRight_SameCell | |||||||||||
| 57090 | CALL TestCellMovingRight | Check whether the second corner of the front edge hits a wall. | ||||||||||
| 57093 | POP DE | Get the edges back, with the registers swapped over. | ||||||||||
| 57094 | POP HL | |||||||||||
| 57095 | RET C | Return if the object hit a wall. | ||||||||||
| 57096 | LD C,(IX+10) | Fetch the velocity along the X axis. | ||||||||||
| 57099 | LD B,0 | |||||||||||
| 57101 | LD A,H | Keep the cell of the front edge. | ||||||||||
| 57102 | ADD HL,BC | Work out where the velocity takes the front edge to. | ||||||||||
| 57103 | CP H | Return if the front edge stays in the same cell. | ||||||||||
| 57104 | RET Z | |||||||||||
| TestMoveRight_Next | 57105 | EX DE,HL | Use the new position of the front edge. | |||||||||
| 57106 | PUSH DE | Save the edges. | ||||||||||
| 57107 | PUSH HL | |||||||||||
| 57108 | CALL TestCellMovingRight | Check whether the first corner hits a wall in the next cell. | ||||||||||
| 57111 | POP HL | Get the edges back. | ||||||||||
| 57112 | POP DE | |||||||||||
| 57113 | RET C | Return if the object hit a wall. | ||||||||||
| 57114 | LD C,(IX+9) | Work out the depth of the object. | ||||||||||
| 57117 | SLA C | |||||||||||
| 57119 | LD B,0 | |||||||||||
| 57121 | ADD HL,BC | Work out the second side edge. | ||||||||||
|
Check whether the second corner hits a wall in the next cell.
|
||||||||||||
| 57122 | JP TestCellMovingRight | Jump to TestCellMovingRight. | ||||||||||
|
The side edges are in the same cell.
|
||||||||||||
| TestMoveRight_SameCell | 57125 | POP DE | Get the edges back, with the registers swapped over. | |||||||||
| 57126 | POP HL | |||||||||||
| 57127 | LD C,(IX+10) | Fetch the velocity along the X axis. | ||||||||||
| 57130 | LD B,0 | |||||||||||
| 57132 | LD A,H | Keep the cell of the front edge. | ||||||||||
| 57133 | ADD HL,BC | Work out where the velocity takes the front edge to. | ||||||||||
| 57134 | CP H | Return if the front edge stays in the same cell. | ||||||||||
| 57135 | RET Z | |||||||||||
| 57136 | EX DE,HL | Use the new position of the front edge. | ||||||||||
|
Check whether the first corner hits a wall in the next cell.
|
||||||||||||
| 57137 | JP TestCellMovingRight | Jump to TestCellMovingRight. | ||||||||||
|
View the equivalent code in;
|
||||||||||||
| Prev: 56946 | Up: Map | Next: 57140 |