Prev: 56938 Up: Map Next: 57043
56946: Test Move Up
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.
Input
IX Object
Output
F The carry flag is set if there was a collision
TestMoveUp 56946 LD L,(IX+1) Fetch the X position of the object.
56949 LD H,(IX+2)
56952 LD C,(IX+8) Fetch the half width of the object.
56955 LD B,0
56957 AND A Subtract it to get the left edge, and keep it in DE.
56958 SBC HL,BC
56960 EX DE,HL
56961 LD L,(IX+3) Fetch the Y position of the object.
56964 LD H,(IX+4)
56967 LD C,(IX+9) Add the half depth to get the front edge.
56970 ADD HL,BC
56971 PUSH DE Save the left edge and the front edge.
56972 PUSH HL
56973 CALL TestCellMovingUp Check whether the front left corner of the object hits a wall.
56976 POP DE Get the edges back, with the registers swapped over.
56977 POP HL
56978 RET C Return if the object hit a wall.
56979 PUSH HL Save the edges again.
56980 PUSH DE
56981 LD C,(IX+8) Work out the width of the object.
56984 SLA C
56986 LD B,0
56988 LD A,H Keep the cell of the left edge.
56989 ADD HL,BC Work out the right edge.
56990 CP H Jump to TestMoveUp_SameCell if the right edge is in the same cell as the left edge.
56991 JR Z,TestMoveUp_SameCell
56993 EX DE,HL Use the right edge.
56994 CALL TestCellMovingUp Check whether the front right corner of the object hits a wall.
56997 POP HL Get the edges back.
56998 POP DE
56999 RET C Return if the object hit a wall.
57000 LD C,(IX+11) Fetch the velocity along the Y axis.
57003 LD B,0
57005 LD A,H Keep the cell of the front edge.
57006 ADD HL,BC Work out where the velocity takes the front edge to.
57007 CP H Return if the front edge stays in the same cell.
57008 RET Z
57009 PUSH DE Save the edges.
57010 PUSH HL
57011 CALL TestCellMovingUp Check whether the front left corner hits a wall in the next cell.
57014 POP DE Get the edges back, with the registers swapped over.
57015 POP HL
57016 RET C Return if the object hit a wall.
57017 LD C,(IX+8) Work out the width of the object.
57020 SLA C
57022 LD B,0
57024 ADD HL,BC Work out the right edge.
57025 EX DE,HL Use the right edge.
Check whether the front right corner hits a wall in the next cell.
57026 JP TestCellMovingUp Jump to TestCellMovingUp.
The left and right edges are in the same cell.
TestMoveUp_SameCell 57029 POP HL Get the edges back.
57030 POP DE
57031 LD C,(IX+11) Fetch the velocity along the Y axis.
57034 LD B,0
57036 LD A,H Keep the cell of the front edge.
57037 ADD HL,BC Work out where the velocity takes the front edge to.
57038 CP H Return if the front edge stays in the same cell.
57039 RET Z
Check whether the front edge hits a wall in the next cell.
57040 JP TestCellMovingUp Jump to TestCellMovingUp.
View the equivalent code in;
Prev: 56938 Up: Map Next: 57043