Prev: C868 Up: Map Next: C891
C880: Limit Speed
Used by the routine at CheckTerrainCollision.
Keeps the high byte of a speed within FD (the fastest upwards or to the left) and 02 (the fastest downwards or to the right).
Input
H Speed (high byte)
Output
H Limited speed (high byte)
LimitSpeed C880 LD A,H A=H.
C881 BIT 7,A Jump to LimitSpeed_Positive if bit 7 of A is clear.
C883 JR Z,LimitSpeed_Positive
C885 CP $FE Return if A is FE or more.
C887 RET NC
C888 LD H,$FD H=FD.
C88A RET Return.
LimitSpeed_Positive C88B CP $02 Return if A is less than 02.
C88D RET C
C88E LD H,$02 H=02.
C890 RET Return.
Prev: C868 Up: Map Next: C891