Prev: 51231 Up: Map Next: 51328
51304: 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 51304 LD A,(23614) The horizontal scroll limit.
51307 SRL A Shift A right.
51309 BIT 7,H Jump to LimitHorizontalSpeed_Positive if bit 7 of H is clear.
51311 JR Z,LimitHorizontalSpeed_Positive
51313 NEG Negate A.
51315 LD B,A B=A.
51316 LD A,H A=H.
51317 CP B Return if A is B or more.
51318 RET NC
51319 DEC B Step B back.
51320 LD H,B H=B.
51321 RET Return.
LimitHorizontalSpeed_Positive 51322 LD B,A B=A.
51323 LD A,H A=H.
51324 CP B Return if A is less than B.
51325 RET C
51326 LD H,B H=B.
51327 RET Return.
Prev: 51231 Up: Map Next: 51328