Prev: 57140 Up: Map Next: 57338
57239: Test Move Left
Tests the move of an object that is facing to the left (along the negative X axis), in the same way as TestMoveUp. The front edge is at the X position minus the half width of the object, and it is tested from the top corner to the bottom corner. Each cell is tested by TestCellMovingLeft.
Input
IX Object
Output
F The carry flag is set if there was a collision
TestMoveLeft 57239 LD L,(IX+1) Fetch the X position of the object.
57242 LD H,(IX+2)
57245 LD C,(IX+8) Fetch the half width of the object.
57248 LD B,0
57250 AND A Subtract it to get the front edge, and keep it in DE.
57251 SBC HL,BC
57253 EX DE,HL
57254 LD L,(IX+3) Fetch the Y position of the object.
57257 LD H,(IX+4)
57260 LD C,(IX+9) Fetch the half depth of the object.
57263 AND A Subtract it to get the first side edge.
57264 SBC HL,BC
57266 PUSH DE Save the edges.
57267 PUSH HL
57268 CALL TestCellMovingLeft Check whether the first corner of the front edge hits a wall.
57271 POP HL Get the edges back, with the registers swapped over.
57272 POP DE
57273 RET C Return if the object hit a wall.
57274 PUSH DE Save the edges again.
57275 PUSH HL
57276 LD C,(IX+9) Work out the depth of the object.
57279 SLA C
57281 LD B,0
57283 LD A,H Work out the second side edge.
57284 ADD HL,BC
57285 CP H Jump to TestMoveLeft_SameCell if the second side edge is in the same cell as the first.
57286 JR Z,TestMoveLeft_SameCell
57288 CALL TestCellMovingLeft Check whether the second corner of the front edge hits a wall.
57291 POP DE Get the edges back.
57292 POP HL
57293 RET C Return if the object hit a wall.
Check the cells after the move.
57294 LD C,(IX+10) Fetch the velocity along the X axis.
57297 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.
57299 LD A,H Find the front edge after the move.
57300 ADD HL,BC
57301 CP H Return if it is in the same cell.
57302 RET Z
57303 EX DE,HL Use the new position of the front edge.
57304 PUSH DE Save the edges.
57305 PUSH HL
57306 CALL TestCellMovingLeft Check whether the first corner hits a wall in the next cell.
57309 POP HL Get the edges back, with the registers swapped over.
57310 POP DE
57311 RET C Return if the object hit a wall.
57312 LD C,(IX+9) Work out the depth of the object.
57315 SLA C
57317 LD B,0
57319 ADD HL,BC Work out the second side edge.
Check whether the second corner hits a wall in the next cell.
57320 JP TestCellMovingLeft Jump to TestCellMovingLeft.
The side edges are in the same cell.
TestMoveLeft_SameCell 57323 POP DE Get the edges back.
57324 POP HL
Fetch the velocity along the X axis, which is negative.
57325 LD C,(IX+10) Fetch the velocity along the X axis.
57328 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.
57330 LD A,H Find the front edge after the move.
57331 ADD HL,BC
57332 CP H Return if it is in the same cell.
57333 RET Z
57334 EX DE,HL Use the new position of the front edge.
Check whether the first corner hits a wall in the next cell.
57335 JP TestCellMovingLeft Jump to TestCellMovingLeft.
View the equivalent code in;
Prev: 57140 Up: Map Next: 57338