Prev: AFC1 Up: Map Next: AFE0
AFD0: Limit Velocity
Used by the routine at HandlerChasingNastie.
Limits a signed velocity to a maximum speed.
Input
A Velocity
B Maximum speed
Output
A The limited velocity
LimitVelocity AFD0 JP M,LimitVelocity_Negative Jump to LimitVelocity_Negative if the velocity is negative.
AFD3 CP B Return if the velocity is less than the maximum speed.
AFD4 RET C
AFD5 LD A,B Limit the velocity to the maximum speed.
AFD6 RET Return.
LimitVelocity_Negative AFD7 NEG Make the velocity positive.
AFD9 CP B Jump to LimitVelocity_Restore if the speed is less than the maximum speed.
AFDA JR C,LimitVelocity_Restore
AFDC LD A,B Limit the speed to the maximum speed.
LimitVelocity_Restore AFDD NEG Make the velocity negative again.
AFDF RET Return.
Prev: AFC1 Up: Map Next: AFE0