I took a quick look at the latest version of my code, and I don't use shifts for movements (since I just integrated your code).
The Jo_cos_mult/sin functions use JO_DIV_BY_32768 (or >>15) and they accept signed integers returned by the cosinus/sinus lookup table.
static __jo_force_inline int jo_sin_mult(const int value, const int angle) { return JO_DIV_BY_32768(value * jo_sin(angle)); }
Maybe adding a check would help?
Like, instead of simply returning the value >> 15 :
int val = value * jo_sin(angle)
if (val<0)
return -JO_DIV_BY_32768(JO_ABS(val));
else
return JO_DIV_BY_32768(val);
Or is it supposed to be dealed with by the compiler?
EDIT : Did a small test by modifying the math.h file directly, it didn't really help.
Here is a video of the issue, but without the modification to the math.h file : https://youtu.be/i2N4E0j8FZI
The first time I used the JO Engine to make the First Person movement I had a similar issue, I pointed in a certain direction and I wouldn't go exactly in that direction. That was because of loss of precision, my workaround for that was just increasing the amount of space I was traveling forward so that the precision loss wasn't so problematic.
The problem is that if you have smaller 3D objects on your world when you are moving you will be going too fast.
Later when I re-used some of the SGL example code to make the VDP2 demo I just used the SGL functions, in that case I did not have the same issue. Maybe that was because I was using the SGL functions directly instead of the JO Engine functions for handling sinus and cosinus.
My guess is that you are having trouble in a part like this one:
position_increment[X] -= movement_speed * slSin(angle[Z]) / 10;
position_increment[Y] -= movement_speed * slCos(angle[Z]) / 10;
position[X] = position_increment[X];
position[Y] = position_increment[Y];
position[Z] = toFIXED(-35.0);
I can try to take at look at this later, in the meanwhile could you try with the slSin() and slCos() to check if it makes any difference?
I also used the SGL "ANGLE" data type and used the corresponding function to convert from degrees to it like in this example:
ANGLE testAngle = DEGtoANG(90.0);
PS:
I noticed that there is something in the SGL that might cause some confusion:
There is a macro that simplifies coordinate handling in a way of just declaring an array of 3 positions differently.
Let me just elaborate a simple example:
int test[XYZ]; // this is basically the same thing as "int test[3];"
test[X] = 1; // same as test[0] = 1;
test[Y] = 2; // same as test[1] = 2;
test[Z] = 3; // same as test[2] = 3;