Prev: DCDC Up: Map Next: DD01
DCE0: Set Velocity From Speed
Sets the velocity of an object along the X and Y axes from its speed and the direction that it faces. Only one axis is used, and the velocity is negative for the directions that face down the screen and to the left.
Input
A Speed
IX Object
Put the speed on the X axis.
SetVelocityFromSpeed DCE0 LD H,$00 Make the speed the X velocity, with no Y velocity.
DCE2 LD L,A
DCE3 BIT 6,(IX+$06) Jump to SetVelocityFromSpeed_Sign if the direction is along x.
DCE7 JR NZ,SetVelocityFromSpeed_Sign
Put the speed on the Y axis.
DCE9 LD H,A Make the speed the Y velocity, with no X velocity.
DCEA LD L,$00
Make the speed negative for down and left.
SetVelocityFromSpeed_Sign DCEC BIT 7,(IX+$06) Jump to SetVelocityFromSpeed_Set unless the direction faces down the screen or to the left.
DCF0 JR Z,SetVelocityFromSpeed_Set
Negate the velocity along both axes.
DCF2 LD A,L Make the X velocity negative.
DCF3 NEG
DCF5 LD L,A
DCF6 LD A,H Make the Y velocity negative.
DCF7 NEG
DCF9 LD H,A
Store the velocities.
SetVelocityFromSpeed_Set DCFA LD (IX+$0A),L Set the X velocity of the object.
DCFD LD (IX+$0B),H Set the Y velocity and return.
DD00 RET
View the equivalent code in;
Prev: DCDC Up: Map Next: DD01