So I've created a simple system for showing animated sprites I have an array-like structure with each entry containing fixed point position,velocity and acceleration values. (lowest 6 bits are the fractional part)
I have this sprite that acts like a bouncing ball. It has a constant positive vertical acceleration value so it accelerates downwards (unless A,B,C are being pressed, in which case it accelerates upwards).
So, to make this sprite bounce I set the velocity this way every time the sprite touches a lower limit and then I change its sign:
VerticalAcc=VerticalAcc *4/3
In 68K asm and assuming d3 is the vertical acceleration (again, a 16 bit value whose lower 6 bits correspond to the fractional part)
Code: Select all
divs.w #4,d3
muls.w #3,d3
neg d3
Let's say d3 is -7 ($FFF9 in two's complement)
doing
Code: Select all
move.w #-7,d3
divs.w #2,d3
According to the 68k reference the result should be $FFFFFFFD (remainder -1,quotient -3)
So yeah that's pretty much it? What could it be? Both Gens and Fusion produce the same result.. I couldn't test it on real hardware.For DIVS, the sign of the remainder is always the same
as the sign of the dividend (unless the remainder is zero).