![]() |
Routines |
| Prev: 52843 | Up: Map | Next: 53045 |
|
Checks the walls for an object that is moving in the direction of heading three. The front edge is the horizontal position minus the horizontal size. The two ends of that edge, now and after the move, are checked with CheckWallHorizontalReverse.
|
||||||||||||
|
Find the front edge and the lower end.
|
||||||||||||
| TestMoveLeft | 52944 | LD L,(IX+1) | Fetch the horizontal position of the object. | |||||||||
| 52947 | LD H,(IX+2) | |||||||||||
| 52950 | LD C,(IX+8) | Fetch the horizontal size. | ||||||||||
| 52953 | LD B,0 | |||||||||||
| 52955 | AND A | Subtract it to get the front edge in DE. | ||||||||||
| 52956 | SBC HL,BC | |||||||||||
| 52958 | EX DE,HL | |||||||||||
| 52959 | LD L,(IX+3) | Fetch the vertical position of the object. | ||||||||||
| 52962 | LD H,(IX+4) | |||||||||||
| 52965 | LD C,(IX+9) | Fetch the vertical size. | ||||||||||
| 52968 | AND A | Subtract it to get the lower end. | ||||||||||
| 52969 | SBC HL,BC | |||||||||||
|
Check the cell at the lower end.
|
||||||||||||
| 52971 | PUSH DE | Stash the front edge and the end on the stack. | ||||||||||
| 52972 | PUSH HL | |||||||||||
| 52973 | CALL CheckWallHorizontalReverse | Call CheckWallHorizontalReverse. | ||||||||||
| 52976 | POP HL | Restore the end and the front edge from the stack. | ||||||||||
| 52977 | POP DE | |||||||||||
| 52978 | RET C | Return if the object has hit a wall. | ||||||||||
|
Check the cell at the other end, if it is in another cell.
|
||||||||||||
| 52979 | PUSH DE | Stash the front edge and the end on the stack. | ||||||||||
| 52980 | PUSH HL | |||||||||||
| 52981 | LD C,(IX+9) | Double the vertical size into BC. | ||||||||||
| 52984 | SLA C | |||||||||||
| 52986 | LD B,0 | |||||||||||
| 52988 | LD A,H | Find the other end of the front edge. | ||||||||||
| 52989 | ADD HL,BC | |||||||||||
| 52990 | CP H | Jump to TestMoveLeft_Same if it is in the same cell. | ||||||||||
| 52991 | JR Z,TestMoveLeft_Same | |||||||||||
| 52993 | CALL CheckWallHorizontalReverse | Call CheckWallHorizontalReverse. | ||||||||||
| 52996 | POP DE | Restore the front edge and the end from the stack, with the registers swapped. | ||||||||||
| 52997 | POP HL | |||||||||||
| 52998 | RET C | Return if the object has hit a wall. | ||||||||||
|
Check the cells after the move.
|
||||||||||||
| 52999 | LD A,(41492) | Fetch HorizontalSpeed. | ||||||||||
| 53002 | LD C,A | Make it a negative word in BC. | ||||||||||
| 53003 | LD B,255 | |||||||||||
| 53005 | LD A,H | Find the front edge after the move. | ||||||||||
| 53006 | ADD HL,BC | |||||||||||
| 53007 | CP H | Return if it is in the same cell. | ||||||||||
| 53008 | RET Z | |||||||||||
| 53009 | EX DE,HL | Make the first end the one to check. | ||||||||||
| 53010 | PUSH DE | Stash the front edge and the end on the stack. | ||||||||||
| 53011 | PUSH HL | |||||||||||
| 53012 | CALL CheckWallHorizontalReverse | Call CheckWallHorizontalReverse. | ||||||||||
| 53015 | POP HL | Restore the end and the front edge from the stack. | ||||||||||
| 53016 | POP DE | |||||||||||
| 53017 | RET C | Return if the object has hit a wall. | ||||||||||
| 53018 | LD C,(IX+9) | Double the vertical size into BC. | ||||||||||
| 53021 | SLA C | |||||||||||
| 53023 | LD B,0 | |||||||||||
| 53025 | ADD HL,BC | Find the other end of the front edge. | ||||||||||
|
Check the cell at the other end.
|
||||||||||||
| 53026 | JP CheckWallHorizontalReverse | Jump to CheckWallHorizontalReverse. | ||||||||||
|
The ends are in the same cell, so only the cell beyond the front edge is checked.
|
||||||||||||
| TestMoveLeft_Same | 53029 | POP DE | Restore the end and the front edge from the stack, with the registers swapped. | |||||||||
| 53030 | POP HL | |||||||||||
| 53031 | LD A,(41492) | Fetch HorizontalSpeed. | ||||||||||
| 53034 | LD C,A | Make it a negative word in BC. | ||||||||||
| 53035 | LD B,255 | |||||||||||
| 53037 | LD A,H | Find the front edge after the move. | ||||||||||
| 53038 | ADD HL,BC | |||||||||||
| 53039 | CP H | Return if it is in the same cell. | ||||||||||
| 53040 | RET Z | |||||||||||
| 53041 | EX DE,HL | Make the front edge the one to check. | ||||||||||
|
Check the cell.
|
||||||||||||
| 53042 | JP CheckWallHorizontalReverse | Jump to CheckWallHorizontalReverse. | ||||||||||
|
View the equivalent code in;
|
||||||||||||
| Prev: 52843 | Up: Map | Next: 53045 |