Prev: B320 Up: Map Next: B336
B322: Limit Vertical Speed
Used by the routine at UpdateShipSpeeds.
Keeps the vertical speed of the ship within its limits: no faster than FD downwards, and no faster than half the value at VerticalLimit upwards.
Input
HL Vertical speed
Output
HL Limited vertical speed
LimitVerticalSpeed B322 LD A,H A=H.
B323 BIT 7,A Jump to LimitVerticalSpeed_Up if bit 7 of A is clear.
B325 JR Z,LimitVerticalSpeed_Up
B327 CP $FE Return if A is FE or more.
B329 RET NC
B32A LD H,$FD H=FD.
B32C RET Return.
LimitVerticalSpeed_Up B32D LD A,($5C3F) The vertical scroll limit.
B330 SRL A Shift A right.
B332 CP H Return if A is H or more.
B333 RET NC
B334 LD H,A H=A.
B335 RET Return.
Prev: B320 Up: Map Next: B336