Prev: 51304 Up: Map Next: 51345
51328: Limit Speed
Used by the routine at CheckTerrainCollision.
Keeps the high byte of a speed within 253 (the fastest upwards or to the left) and 2 (the fastest downwards or to the right).
Input
H Speed (high byte)
Output
H Limited speed (high byte)
LimitSpeed 51328 LD A,H A=H.
51329 BIT 7,A Jump to LimitSpeed_Positive if bit 7 of A is clear.
51331 JR Z,LimitSpeed_Positive
51333 CP 254 Return if A is 254 or more.
51335 RET NC
51336 LD H,253 H=253.
51338 RET Return.
LimitSpeed_Positive 51339 CP 2 Return if A is less than 2.
51341 RET C
51342 LD H,2 H=2.
51344 RET Return.
Prev: 51304 Up: Map Next: 51345