Prev: B980 Up: Map Next: B9EC
B9BB: 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 18 and B8.
Input
IX Address of the object
Output
H Map zone
L Vertical position
E Fraction of the vertical position
FindVerticalMove B9BB LD H,(IX+$05) The vertical position.
B9BE LD L,(IX+$06) Read offset 06 of IX into L.
B9C1 LD D,(IX+$09) The high byte of the vertical speed.
B9C4 LD E,(IX+$0A) The low byte of the vertical speed.
B9C7 ADD HL,DE HL gains DE.
B9C8 LD E,L E=L.
B9C9 LD L,H L=H.
B9CA LD H,(IX+$04) The map zone.
B9CD LD C,(IX+$05) The vertical position.
B9D0 LD A,L A=L.
B9D1 BIT 7,D Jump to FindVerticalMove_Up if bit 7 of D is set.
B9D3 JR NZ,FindVerticalMove_Up
B9D5 CP $B8 Jump to FindVerticalMove_Down if A is B8 or more.
B9D7 JR NC,FindVerticalMove_Down
B9D9 CP C Return if A is C or more.
B9DA RET NC
FindVerticalMove_Down B9DB SUB $A0 Subtract A0 from A.
B9DD LD L,A L=A.
B9DE INC H Advance H.
B9DF RET Return.
FindVerticalMove_Up B9E0 CP $18 Jump to FindVerticalMove_Previous if A is less than 18.
B9E2 JR C,FindVerticalMove_Previous
B9E4 CP C Return if A is less than C.
B9E5 RET C
B9E6 RET Z Return if the zero flag is set.
FindVerticalMove_Previous B9E7 ADD A,$A0 Add A0 to A.
B9E9 LD L,A L=A.
B9EA DEC H Step H back.
B9EB RET Return.
Prev: B980 Up: Map Next: B9EC