![]() |
Routines |
| Prev: B97A | Up: Map | Next: B9BB |
|
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 60 columns.
|
||||||||||||||||
| FindHorizontalMove | B980 | LD H,(IX+$02) | The horizontal position. | |||||||||||||
| B983 | LD L,(IX+$03) | Read offset 03 of IX into L. | ||||||||||||||
| B986 | LD D,(IX+$07) | The high byte of the horizontal speed. | ||||||||||||||
| B989 | LD E,(IX+$08) | The low byte of the horizontal speed. | ||||||||||||||
| B98C | ADD HL,DE | HL gains DE. | ||||||||||||||
| B98D | LD E,L | E=L. | ||||||||||||||
| B98E | LD L,H | L=H. | ||||||||||||||
| B98F | LD H,(IX+$01) | The map column. | ||||||||||||||
| B992 | LD C,(IX+$02) | The horizontal position. | ||||||||||||||
| B995 | LD A,L | A=L. | ||||||||||||||
| B996 | BIT 7,D | Jump to FindHorizontalMove_Left if bit 7 of D is set. | ||||||||||||||
| B998 | JR NZ,FindHorizontalMove_Left | |||||||||||||||
| FindHorizontalMove_Right | B99A | CP $E8 | Jump to FindHorizontalMove_Next if A is E8 or more. | |||||||||||||
| B99C | JR NC,FindHorizontalMove_Next | |||||||||||||||
| B99E | CP C | Return if A is C or more. | ||||||||||||||
| B99F | RET NC | |||||||||||||||
| FindHorizontalMove_Next | B9A0 | SUB $E0 | Subtract E0 from A. | |||||||||||||
| B9A2 | LD L,A | L=A. | ||||||||||||||
| B9A3 | INC H | Advance H. | ||||||||||||||
| B9A4 | LD A,H | A=H. | ||||||||||||||
| B9A5 | SUB $60 | Subtract 60 from A. | ||||||||||||||
| B9A7 | RET NZ | Return if the zero flag is clear. | ||||||||||||||
| B9A8 | LD H,A | H=A. | ||||||||||||||
| B9A9 | RET | Return. | ||||||||||||||
| FindHorizontalMove_Left | B9AA | CP $08 | Jump to FindHorizontalMove_Previous if A is less than 08. | |||||||||||||
| B9AC | JR C,FindHorizontalMove_Previous | |||||||||||||||
| B9AE | CP C | Return if A is less than C. | ||||||||||||||
| B9AF | RET C | |||||||||||||||
| B9B0 | RET Z | Return if the zero flag is set. | ||||||||||||||
| FindHorizontalMove_Previous | B9B1 | ADD A,$E0 | Add E0 to A. | |||||||||||||
| B9B3 | LD L,A | L=A. | ||||||||||||||
| B9B4 | DEC H | Step H back. | ||||||||||||||
| B9B5 | LD A,H | A=H. | ||||||||||||||
| B9B6 | INC A | Advance A. | ||||||||||||||
| B9B7 | RET NZ | Return if the zero flag is clear. | ||||||||||||||
| B9B8 | LD H,$5F | H=5F. | ||||||||||||||
| B9BA | RET | Return. | ||||||||||||||
| Prev: B97A | Up: Map | Next: B9BB |