![]() |
Routines |
| Prev: 47482 | Up: Map | Next: 47547 |
|
Works out the horizontal position of an object after it has moved by its horizontal speed, which is wrapped around to the next map column, or the previous one, when it goes off the edge of the column. There are 96 columns.
|
||||||||||||||||
| FindHorizontalMove | 47488 | LD H,(IX+2) | The horizontal position. | |||||||||||||
| 47491 | LD L,(IX+3) | Read offset 3 of IX into L. | ||||||||||||||
| 47494 | LD D,(IX+7) | The high byte of the horizontal speed. | ||||||||||||||
| 47497 | LD E,(IX+8) | The low byte of the horizontal speed. | ||||||||||||||
| 47500 | ADD HL,DE | HL gains DE. | ||||||||||||||
| 47501 | LD E,L | E=L. | ||||||||||||||
| 47502 | LD L,H | L=H. | ||||||||||||||
| 47503 | LD H,(IX+1) | The map column. | ||||||||||||||
| 47506 | LD C,(IX+2) | The horizontal position. | ||||||||||||||
| 47509 | LD A,L | A=L. | ||||||||||||||
| 47510 | BIT 7,D | Jump to FindHorizontalMove_Left if bit 7 of D is set. | ||||||||||||||
| 47512 | JR NZ,FindHorizontalMove_Left | |||||||||||||||
| FindHorizontalMove_Right | 47514 | CP 232 | Jump to FindHorizontalMove_Next if A is 232 or more. | |||||||||||||
| 47516 | JR NC,FindHorizontalMove_Next | |||||||||||||||
| 47518 | CP C | Return if A is C or more. | ||||||||||||||
| 47519 | RET NC | |||||||||||||||
| FindHorizontalMove_Next | 47520 | SUB 224 | Subtract 224 from A. | |||||||||||||
| 47522 | LD L,A | L=A. | ||||||||||||||
| 47523 | INC H | Advance H. | ||||||||||||||
| 47524 | LD A,H | A=H. | ||||||||||||||
| 47525 | SUB 96 | Subtract 96 from A. | ||||||||||||||
| 47527 | RET NZ | Return if the zero flag is clear. | ||||||||||||||
| 47528 | LD H,A | H=A. | ||||||||||||||
| 47529 | RET | Return. | ||||||||||||||
| FindHorizontalMove_Left | 47530 | CP 8 | Jump to FindHorizontalMove_Previous if A is less than 8. | |||||||||||||
| 47532 | JR C,FindHorizontalMove_Previous | |||||||||||||||
| 47534 | CP C | Return if A is less than C. | ||||||||||||||
| 47535 | RET C | |||||||||||||||
| 47536 | RET Z | Return if the zero flag is set. | ||||||||||||||
| FindHorizontalMove_Previous | 47537 | ADD A,224 | Add 224 to A. | |||||||||||||
| 47539 | LD L,A | L=A. | ||||||||||||||
| 47540 | DEC H | Step H back. | ||||||||||||||
| 47541 | LD A,H | A=H. | ||||||||||||||
| 47542 | INC A | Advance A. | ||||||||||||||
| 47543 | RET NZ | Return if the zero flag is clear. | ||||||||||||||
| 47544 | LD H,95 | H=95. | ||||||||||||||
| 47546 | RET | Return. | ||||||||||||||
| Prev: 47482 | Up: Map | Next: 47547 |