Prev: C81F Up: Map Next: C880
C868: Limit Horizontal Speed
Used by the routine at UpdateHorizontalSpeed.
Keeps the horizontal speed of the ship within a limit that is half the value at HorizontalLimit.
Input
H Horizontal speed
Output
H Limited horizontal speed
LimitHorizontalSpeed C868 LD A,($5C3E) The horizontal scroll limit.
C86B SRL A Shift A right.
C86D BIT 7,H Jump to LimitHorizontalSpeed_Positive if bit 7 of H is clear.
C86F JR Z,LimitHorizontalSpeed_Positive
C871 NEG Negate A.
C873 LD B,A B=A.
C874 LD A,H A=H.
C875 CP B Return if A is B or more.
C876 RET NC
C877 DEC B Step B back.
C878 LD H,B H=B.
C879 RET Return.
LimitHorizontalSpeed_Positive C87A LD B,A B=A.
C87B LD A,H A=H.
C87C CP B Return if A is less than B.
C87D RET C
C87E LD H,B H=B.
C87F RET Return.
Prev: C81F Up: Map Next: C880