Prev: 8F80 Up: Map Next: 8FCA
8F96: Slow Velocity
Used by the routine at ControlPlayer.
Takes some speed off both of the velocities of an entity, which are at offsets 06 and 07. Neither of them goes beyond zero. Nothing is done while an automatic walk is under way (see AutoWalkStep).
Input
HL The amount to take off each velocity (X in L and Y in H)
IX The entity
SlowVelocity 8F96 LD A,(IX+$02) Fetch offset 02 of the entity.
8F99 AND %00001111 Keep only bits 0-3.
8F9B RET NZ Return if an automatic walk is under way.
8F9C LD A,(IX+$06) Fetch the X velocity.
8F9F AND A Test whether it is zero.
8FA0 JR Z,SlowVelocity_Y Jump to SlowVelocity_Y if it is.
8FA2 JP M,SlowVelocity_NegativeX Jump to SlowVelocity_NegativeX if it is negative.
8FA5 SUB L Subtract the amount from the velocity.
8FA6 JP P,SlowVelocity_SetX Jump to SlowVelocity_SetX if it is still positive.
SlowVelocity_ZeroX 8FA9 XOR A A=00 (the velocity when it is stopped).
SlowVelocity_SetX 8FAA LD (IX+$06),A Update the X velocity.
SlowVelocity_Y 8FAD LD A,(IX+$07) Fetch the Y velocity.
8FB0 AND A Test whether it is zero.
8FB1 RET Z Return if it is.
8FB2 JP M,SlowVelocity_NegativeY Jump to SlowVelocity_NegativeY if it is negative.
8FB5 SUB H Subtract the amount from the velocity.
8FB6 JP P,SlowVelocity_SetY Jump to SlowVelocity_SetY if it is still positive.
SlowVelocity_ZeroY 8FB9 XOR A A=00 (the velocity when it is stopped).
SlowVelocity_SetY 8FBA LD (IX+$07),A Update the Y velocity.
8FBD RET Return.
SlowVelocity_NegativeX 8FBE ADD A,L Add the amount to the velocity.
8FBF JP M,SlowVelocity_SetX Jump to SlowVelocity_SetX if it is still negative.
8FC2 JR SlowVelocity_ZeroX Jump to SlowVelocity_ZeroX to zero the X velocity.
SlowVelocity_NegativeY 8FC4 ADD A,H Add the amount to the velocity.
8FC5 JP M,SlowVelocity_SetY Jump to SlowVelocity_SetY if it is still negative.
8FC8 JR SlowVelocity_ZeroY Jump to SlowVelocity_ZeroY to zero the Y velocity.
Prev: 8F80 Up: Map Next: 8FCA