Prev: AB74 Up: Map Next: ABEF
ABDE: Choose Tribesman Velocity
Used by the routine at HandlerTribesman.
Chooses a new velocity for a tribesman if it did not manage to move. The velocities are held in TribesmanVelocities, so each one has a one in four chance of being chosen for each direction.
Input
DE The new position of the tribesman (E is X and D is Y)
IX Actor record of the tribesman
ChooseTribesmanVelocity ABDE CALL TestPositionUnchanged Test whether the tribesman has stayed where it was.
ABE1 RET NZ Return if the tribesman has moved.
ABE2 LD BC,$AC24 Point BC at the table of tribesman velocities at TribesmanVelocities.
ABE5 LD A,($9695) Fetch the random seed from RandomNumber.
ABE8 AND %00000011 Keep only bits 0-1.
ABEA LD L,A Stash the velocity index in L.
ABEB LD H,$00 Clear H.
ABED ADD HL,BC Add the table address to get the address of the velocity.
ABEE LD A,(HL) Fetch the X velocity from the table.
Prev: AB74 Up: Map Next: ABEF