Prev: 47488 Up: Map Next: 47596
47547: Find Vertical Move
Used by the routines at BuildShip, StartTerrainCheck and MoveObject.
Works out the vertical position of an object after it has moved by its vertical speed, in the same way as FindHorizontalMove does for the horizontal position. The zone changes when the position goes beyond the limits of 24 and 184.
Input
IX Address of the object
Output
H Map zone
L Vertical position
E Fraction of the vertical position
FindVerticalMove 47547 LD H,(IX+5) The vertical position.
47550 LD L,(IX+6) Read offset 6 of IX into L.
47553 LD D,(IX+9) The high byte of the vertical speed.
47556 LD E,(IX+10) The low byte of the vertical speed.
47559 ADD HL,DE HL gains DE.
47560 LD E,L E=L.
47561 LD L,H L=H.
47562 LD H,(IX+4) The map zone.
47565 LD C,(IX+5) The vertical position.
47568 LD A,L A=L.
47569 BIT 7,D Jump to FindVerticalMove_Up if bit 7 of D is set.
47571 JR NZ,FindVerticalMove_Up
47573 CP 184 Jump to FindVerticalMove_Down if A is 184 or more.
47575 JR NC,FindVerticalMove_Down
47577 CP C Return if A is C or more.
47578 RET NC
FindVerticalMove_Down 47579 SUB 160 Subtract 160 from A.
47581 LD L,A L=A.
47582 INC H Advance H.
47583 RET Return.
FindVerticalMove_Up 47584 CP 24 Jump to FindVerticalMove_Previous if A is less than 24.
47586 JR C,FindVerticalMove_Previous
47588 CP C Return if A is less than C.
47589 RET C
47590 RET Z Return if the zero flag is set.
FindVerticalMove_Previous 47591 ADD A,160 Add 160 to A.
47593 LD L,A L=A.
47594 DEC H Step H back.
47595 RET Return.
Prev: 47488 Up: Map Next: 47596