Prev: 56729 Up: Map Next: 56828
56783: Choose Random Velocity
Used by the routines at UpdateSpore and UpdateVillageItem.
Chooses a new random velocity along both axes for an object when the timer has run out (the lowest six bits of the direction and timer) or when the object is not moving. The velocity along each axis is an even number, chosen from the random seeds. A new timer is set from the memory refresh register.
Input
B Number of random bits to use for each velocity
IX Object
ChooseRandomVelocity 56783 DEC (IX+6) Count down the timer, and jump to ChooseRandomVelocity_Choose if it has run out.
56786 LD A,(IX+6)
56789 AND 63
56791 JR Z,ChooseRandomVelocity_Choose
56793 LD A,(IX+10) Return if the object is moving.
56796 OR (IX+11)
56799 RET NZ
ChooseRandomVelocity_Choose 56800 LD A,(48042) Choose the velocity along the X axis from the first random seed.
56803 LD C,A
56804 CALL ChooseVelocity
56807 LD (IX+10),A
56810 LD A,(48043) Choose the velocity along the Y axis from the second random seed.
56813 LD C,A
56814 CALL ChooseVelocity
56817 LD (IX+11),A
56820 LD A,R Set a random timer.
56822 AND 63
56824 LD (IX+6),A
56827 RET Return.
Prev: 56729 Up: Map Next: 56828