Removed SupportFPMathsFunctions and SupportFPSquareRoot macros.
This commit is contained in:
parent
d655ca3f04
commit
2e7aec7855
4 changed files with 0 additions and 361 deletions
|
@ -36,9 +36,6 @@ extern "C" {
|
|||
|
||||
/******************** General *****************************/
|
||||
|
||||
#define SupportFPMathsFunctions Yes
|
||||
#define SupportFPSquareRoot Yes
|
||||
|
||||
#define GlobalScale 1
|
||||
|
||||
|
||||
|
|
|
@ -50,8 +50,6 @@ typedef struct quat {
|
|||
|
||||
} QUAT;
|
||||
|
||||
#if SupportFPMathsFunctions
|
||||
|
||||
typedef struct vectorchf {
|
||||
|
||||
float vx;
|
||||
|
@ -62,9 +60,6 @@ typedef struct vectorchf {
|
|||
|
||||
void FNormalise(VECTORCHF *n);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
typedef struct vector2d {
|
||||
|
||||
int vx;
|
||||
|
@ -72,9 +67,6 @@ typedef struct vector2d {
|
|||
|
||||
} VECTOR2D;
|
||||
|
||||
|
||||
#if SupportFPMathsFunctions
|
||||
|
||||
typedef struct vector2df {
|
||||
|
||||
float vx;
|
||||
|
@ -84,9 +76,6 @@ typedef struct vector2df {
|
|||
|
||||
void FNormalise2d(VECTOR2DF *n);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
typedef struct line {
|
||||
|
||||
VECTORCH v0;
|
||||
|
@ -132,9 +121,6 @@ typedef struct matrixch {
|
|||
|
||||
} MATRIXCH;
|
||||
|
||||
|
||||
#if SupportFPMathsFunctions
|
||||
|
||||
typedef struct matrixchf {
|
||||
|
||||
float mat11;
|
||||
|
@ -151,9 +137,6 @@ typedef struct matrixchf {
|
|||
|
||||
} MATRIXCHF;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/* Sorry about this... */
|
||||
|
||||
//#include "hmodel.h"
|
||||
|
|
|
@ -524,8 +524,6 @@ static void RotateAndCopyVector_ASM(VECTORCH *v1, VECTORCH *v2, MATRIXCH *m)
|
|||
}
|
||||
}
|
||||
|
||||
#if (SupportFPMathsFunctions || SupportFPSquareRoot)
|
||||
|
||||
/*
|
||||
|
||||
Square Root
|
||||
|
@ -550,8 +548,6 @@ static int SqRoot32(int A)
|
|||
return (int)temp2;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
|
||||
|
|
|
@ -524,10 +524,6 @@ void MakeNormal(VECTORCH *v1, VECTORCH *v2, VECTORCH *v3, VECTORCH *v4)
|
|||
|
||||
{
|
||||
|
||||
|
||||
#if SupportFPMathsFunctions
|
||||
|
||||
|
||||
VECTORCHF vect0;
|
||||
VECTORCHF vect1;
|
||||
VECTORCHF n;
|
||||
|
@ -571,137 +567,6 @@ void MakeNormal(VECTORCH *v1, VECTORCH *v2, VECTORCH *v3, VECTORCH *v4)
|
|||
WaitForReturn();
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#else /* SupportFPMathsFunctions */
|
||||
|
||||
|
||||
LONGLONGCH x;
|
||||
LONGLONGCH y;
|
||||
LONGLONGCH z;
|
||||
LONGLONGCH tmp;
|
||||
VECTORCH vect0;
|
||||
VECTORCH vect1;
|
||||
LONGLONGCH max_abs_xyz64;
|
||||
LONGLONGCH abs_xyz[3];
|
||||
int s, shift;
|
||||
|
||||
|
||||
/* vect0 = v2 - v1 */
|
||||
|
||||
vect0.vx = v2->vx - v1->vx;
|
||||
vect0.vy = v2->vy - v1->vy;
|
||||
vect0.vz = v2->vz - v1->vz;
|
||||
|
||||
/* vect1 = v3 - v1 */
|
||||
|
||||
vect1.vx = v3->vx - v1->vx;
|
||||
vect1.vy = v3->vy - v1->vy;
|
||||
vect1.vz = v3->vz - v1->vz;
|
||||
|
||||
|
||||
/* nx = v0y.v1z - v0z.v1y */
|
||||
|
||||
#if 0
|
||||
x =
|
||||
(long long)vect0.vy * (long long)vect1.vz
|
||||
-(long long)vect0.vz * (long long)vect1.vy;
|
||||
#endif
|
||||
|
||||
MUL_I_WIDE(vect0.vy, vect1.vz, &x);
|
||||
MUL_I_WIDE(vect0.vz, vect1.vy, &tmp);
|
||||
SUB_LL_MM(&x, &tmp);
|
||||
|
||||
|
||||
/* ny = v0z.v1x - v0x.v1z */
|
||||
|
||||
#if 0
|
||||
y =
|
||||
(long long)vect0.vz * (long long)vect1.vx
|
||||
-(long long)vect0.vx * (long long)vect1.vz;
|
||||
#endif
|
||||
|
||||
MUL_I_WIDE(vect0.vz, vect1.vx, &y);
|
||||
MUL_I_WIDE(vect0.vx, vect1.vz, &tmp);
|
||||
SUB_LL_MM(&y, &tmp);
|
||||
|
||||
|
||||
/* nz = v0x.v1y - v0y.v1x */
|
||||
|
||||
#if 0
|
||||
z =
|
||||
(long long)vect0.vx * (long long)vect1.vy
|
||||
-(long long)vect0.vy * (long long)vect1.vx;
|
||||
#endif
|
||||
|
||||
MUL_I_WIDE(vect0.vx, vect1.vy, &z);
|
||||
MUL_I_WIDE(vect0.vy, vect1.vx, &tmp);
|
||||
SUB_LL_MM(&z, &tmp);
|
||||
|
||||
|
||||
/* Before we can normalise we must bring these vectors down to 14-bits */
|
||||
|
||||
#if 0
|
||||
abs_xyz[0] = x;
|
||||
if(abs_xyz[0] < 0) abs_xyz[0] = -abs_xyz[0];
|
||||
|
||||
abs_xyz[1] = y;
|
||||
if(abs_xyz[1] < 1) abs_xyz[1] = -abs_xyz[1];
|
||||
|
||||
abs_xyz[2] = z;
|
||||
if(abs_xyz[2] < 0) abs_xyz[2] = -abs_xyz[2];
|
||||
|
||||
#endif
|
||||
|
||||
EQUALS_LL(&abs_xyz[0], &x);
|
||||
s = CMP_LL(&abs_xyz[0], &ll_zero);
|
||||
if(s < 0) NEG_LL(&abs_xyz[0]);
|
||||
|
||||
EQUALS_LL(&abs_xyz[1], &y);
|
||||
s = CMP_LL(&abs_xyz[1], &ll_zero);
|
||||
if(s < 0) NEG_LL(&abs_xyz[1]);
|
||||
|
||||
EQUALS_LL(&abs_xyz[2], &z);
|
||||
s = CMP_LL(&abs_xyz[2], &ll_zero);
|
||||
if(s < 0) NEG_LL(&abs_xyz[2]);
|
||||
|
||||
MaxLONGLONGCH(&abs_xyz[0], 3, &max_abs_xyz64);
|
||||
|
||||
shift = FindShift64(&max_abs_xyz64, &ll_one14);
|
||||
|
||||
#if 0
|
||||
x >>= shift;
|
||||
y >>= shift;
|
||||
z >>= shift;
|
||||
#endif
|
||||
|
||||
ASR_LL(&x, shift);
|
||||
ASR_LL(&y, shift);
|
||||
ASR_LL(&z, shift);
|
||||
|
||||
/* Watcom specific copying of lower 32-bits of LONGLONGCH values */
|
||||
|
||||
v4->vx = x.lo32;
|
||||
v4->vy = y.lo32;
|
||||
v4->vz = z.lo32;
|
||||
|
||||
|
||||
|
||||
/* Normalise the vector */
|
||||
|
||||
#if 0
|
||||
textprint("v4 = %d,%d,%d\n", x.lo32, y.lo32, z.lo32);
|
||||
textprint("v4 = %d,%d,%d\n", v4->vx, v4->vy, v4->vz);
|
||||
#endif
|
||||
|
||||
Normalise(v4);
|
||||
|
||||
#if 0
|
||||
textprint(" - v4 = %d,%d,%d\n", v4->vx, v4->vy, v4->vz);
|
||||
#endif
|
||||
|
||||
#endif /* SupportFPMathsFunctions */
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -733,11 +598,6 @@ void MakeNormal(VECTORCH *v1, VECTORCH *v2, VECTORCH *v3, VECTORCH *v4)
|
|||
void Normalise(VECTORCH *nvector)
|
||||
|
||||
{
|
||||
|
||||
|
||||
#if SupportFPMathsFunctions
|
||||
|
||||
|
||||
VECTORCHF n;
|
||||
float m;
|
||||
|
||||
|
@ -751,71 +611,6 @@ void Normalise(VECTORCH *nvector)
|
|||
f2i(nvector->vx, (n.vx * m) );
|
||||
f2i(nvector->vy, (n.vy * m) );
|
||||
f2i(nvector->vz, (n.vz * m) );
|
||||
|
||||
|
||||
#else /* SupportFPMathsFunctions */
|
||||
|
||||
|
||||
int m, s;
|
||||
int xsq, ysq, zsq;
|
||||
|
||||
LONGLONGCH max_abs_xyz64;
|
||||
|
||||
LONGLONGCH abs_xyz[3];
|
||||
|
||||
int shift;
|
||||
|
||||
|
||||
/* Before we can normalise we must bring these vectors down to 14-bits */
|
||||
|
||||
IntToLL(&abs_xyz[0], &nvector->vx);
|
||||
s = CMP_LL(&abs_xyz[0], &ll_zero);
|
||||
if(s < 0) NEG_LL(&abs_xyz[0]);
|
||||
|
||||
IntToLL(&abs_xyz[1], &nvector->vy);
|
||||
s = CMP_LL(&abs_xyz[1], &ll_zero);
|
||||
if(s < 0) NEG_LL(&abs_xyz[1]);
|
||||
|
||||
IntToLL(&abs_xyz[2], &nvector->vz);
|
||||
s = CMP_LL(&abs_xyz[2], &ll_zero);
|
||||
if(s < 0) NEG_LL(&abs_xyz[2]);
|
||||
|
||||
MaxLONGLONGCH(&abs_xyz[0], 3, &max_abs_xyz64);
|
||||
|
||||
|
||||
#if 0
|
||||
textprint("value to shift = %d, %d\n", max_abs_xyz64.lo32, max_abs_xyz64.hi32);
|
||||
#endif
|
||||
|
||||
shift = FindShift64(&max_abs_xyz64, &ll_one14);
|
||||
|
||||
#if 0
|
||||
textprint("shift = %d\n", shift);
|
||||
#endif
|
||||
|
||||
nvector->vx >>= shift;
|
||||
nvector->vy >>= shift;
|
||||
nvector->vz >>= shift;
|
||||
|
||||
|
||||
/* Normalise */
|
||||
|
||||
xsq = nvector->vx * nvector->vx;
|
||||
ysq = nvector->vy * nvector->vy;
|
||||
zsq = nvector->vz * nvector->vz;
|
||||
|
||||
m = SqRoot32(xsq + ysq + zsq);
|
||||
|
||||
if(m == 0) m = 1; /* Just in case */
|
||||
|
||||
nvector->vx = WideMulNarrowDiv(nvector->vx, ONE_FIXED, m);
|
||||
nvector->vy = WideMulNarrowDiv(nvector->vy, ONE_FIXED, m);
|
||||
nvector->vz = WideMulNarrowDiv(nvector->vz, ONE_FIXED, m);
|
||||
|
||||
|
||||
#endif /* SupportFPMathsFunctions */
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -827,11 +622,6 @@ void Normalise(VECTORCH *nvector)
|
|||
void Normalise2d(VECTOR2D *nvector)
|
||||
|
||||
{
|
||||
|
||||
|
||||
#if SupportFPMathsFunctions
|
||||
|
||||
|
||||
VECTOR2DF n;
|
||||
float m;
|
||||
|
||||
|
@ -843,71 +633,9 @@ void Normalise2d(VECTOR2D *nvector)
|
|||
|
||||
nvector->vx = (n.vx * ONE_FIXED) / m;
|
||||
nvector->vy = (n.vy * ONE_FIXED) / m;
|
||||
|
||||
|
||||
#else /* SupportFPMathsFunctions */
|
||||
|
||||
|
||||
int m, s;
|
||||
int xsq, ysq;
|
||||
LONGLONGCH max_abs_xy64;
|
||||
LONGLONGCH abs_xy[2];
|
||||
int shift;
|
||||
|
||||
|
||||
/* Before we can normalise we must bring these vectors down to 14-bits */
|
||||
|
||||
IntToLL(&abs_xyz[0], &nvector->vx);
|
||||
s = CMP_LL(&abs_xyz[0], &ll_zero);
|
||||
if(s < 0) NEG_LL(&abs_xyz[0]);
|
||||
|
||||
IntToLL(&abs_xyz[1], &nvector->vy);
|
||||
s = CMP_LL(&abs_xyz[1], &ll_zero);
|
||||
if(s < 0) NEG_LL(&abs_xyz[1]);
|
||||
|
||||
MaxLONGLONGCH(&abs_xy[0], 2, &max_abs_xy64);
|
||||
|
||||
|
||||
#if 0
|
||||
textprint("value to shift = %d, %d\n", max_abs_xyz64.lo32, max_abs_xyz64.hi32);
|
||||
#endif
|
||||
|
||||
shift = FindShift64(&max_abs_xy64, &ll_one14);
|
||||
|
||||
#if 0
|
||||
textprint("shift = %d\n", shift);
|
||||
#endif
|
||||
|
||||
nvector->vx >>= shift;
|
||||
nvector->vy >>= shift;
|
||||
|
||||
|
||||
/* Normalise */
|
||||
|
||||
xsq = nvector->vx * nvector->vx;
|
||||
ysq = nvector->vy * nvector->vy;
|
||||
|
||||
m = SqRoot32(xsq + ysq);
|
||||
|
||||
if(m == 0) m = 1; /* Just in case */
|
||||
|
||||
nvector->vx = WideMulNarrowDiv(nvector->vx, ONE_FIXED, m);
|
||||
nvector->vy = WideMulNarrowDiv(nvector->vy, ONE_FIXED, m);
|
||||
|
||||
|
||||
#endif /* SupportFPMathsFunctions */
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#if SupportFPMathsFunctions
|
||||
|
||||
void FNormalise(VECTORCHF *n)
|
||||
|
||||
{
|
||||
|
@ -937,8 +665,6 @@ void FNormalise2d(VECTOR2DF *n)
|
|||
|
||||
}
|
||||
|
||||
#endif /* SupportFPMathsFunctions */
|
||||
|
||||
|
||||
/*
|
||||
|
||||
|
@ -949,12 +675,6 @@ void FNormalise2d(VECTOR2DF *n)
|
|||
int Magnitude(VECTORCH *v)
|
||||
|
||||
{
|
||||
|
||||
|
||||
#if SupportFPMathsFunctions
|
||||
|
||||
|
||||
|
||||
VECTORCHF n;
|
||||
int m;
|
||||
|
||||
|
@ -966,63 +686,6 @@ int Magnitude(VECTORCH *v)
|
|||
f2i(m, sqrt((n.vx * n.vx) + (n.vy * n.vy) + (n.vz * n.vz)));
|
||||
|
||||
return m;
|
||||
|
||||
|
||||
#else /* SupportFPMathsFunctions */
|
||||
|
||||
|
||||
VECTORCH vtemp;
|
||||
LONGLONGCH max_abs_xyz64;
|
||||
LONGLONGCH abs_xyz[3];
|
||||
int shift;
|
||||
int m;
|
||||
int xsq, ysq, zsq;
|
||||
int s;
|
||||
|
||||
|
||||
/*
|
||||
|
||||
Before we can square and add the components we must bring these vectors
|
||||
down to 14-bits
|
||||
|
||||
*/
|
||||
|
||||
IntToLL(&abs_xyz[0], &v->vx);
|
||||
s = CMP_LL(&abs_xyz[0], &ll_zero);
|
||||
if(s < 0) NEG_LL(&abs_xyz[0]);
|
||||
|
||||
IntToLL(&abs_xyz[1], &v->vy);
|
||||
s = CMP_LL(&abs_xyz[1], &ll_zero);
|
||||
if(s < 0) NEG_LL(&abs_xyz[1]);
|
||||
|
||||
IntToLL(&abs_xyz[2], &v->vz);
|
||||
s = CMP_LL(&abs_xyz[2], &ll_zero);
|
||||
if(s < 0) NEG_LL(&abs_xyz[2]);
|
||||
|
||||
MaxLONGLONGCH(&abs_xyz[0], 3, &max_abs_xyz64);
|
||||
|
||||
shift = FindShift64(&max_abs_xyz64, &ll_one14);
|
||||
|
||||
CopyVector(v, &vtemp);
|
||||
|
||||
vtemp.vx >>= shift;
|
||||
vtemp.vy >>= shift;
|
||||
vtemp.vz >>= shift;
|
||||
|
||||
xsq = vtemp.vx * vtemp.vx;
|
||||
ysq = vtemp.vy * vtemp.vy;
|
||||
zsq = vtemp.vz * vtemp.vz;
|
||||
|
||||
m = SqRoot32(xsq + ysq + zsq);
|
||||
|
||||
m <<= shift;
|
||||
|
||||
return m;
|
||||
|
||||
|
||||
#endif /* SupportFPMathsFunctions */
|
||||
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue