remove "done" folders, label "bs/droneenter, bs/dronelook, and bs/dronevanish files and functions"
This commit is contained in:
137
src/core1/gu/cosf.c
Normal file
137
src/core1/gu/cosf.c
Normal file
@@ -0,0 +1,137 @@
|
||||
/**************************************************************************
|
||||
* *
|
||||
* Copyright (C) 1994, Silicon Graphics, Inc. *
|
||||
* *
|
||||
* These coded instructions, statements, and computer programs contain *
|
||||
* unpublished proprietary information of Silicon Graphics, Inc., and *
|
||||
* are protected by Federal copyright law. They may not be disclosed *
|
||||
* to third parties or copied or duplicated in any form, in whole or *
|
||||
* in part, without the prior written consent of Silicon Graphics, Inc. *
|
||||
* *
|
||||
**************************************************************************/
|
||||
|
||||
#include "guint.h"
|
||||
|
||||
/* ====================================================================
|
||||
* ====================================================================
|
||||
*
|
||||
* Module: fcos.c
|
||||
* $Revision: 1.2 $
|
||||
* $Date: 1995/07/12 17:47:57 $
|
||||
* $Author: jeffd $
|
||||
* $Source: /disk6/Master/cvsmdev2/PR/libultra/gu/cosf.c,v $
|
||||
*
|
||||
* Revision history:
|
||||
* 09-Jun-93 - Original Version
|
||||
*
|
||||
* Description: source code for fcos function
|
||||
*
|
||||
* ====================================================================
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
#pragma weak fcos = __cosf
|
||||
#pragma weak cosf = __cosf
|
||||
#define fcos __cosf
|
||||
|
||||
/* coefficients for polynomial approximation of cos on +/- pi/2 */
|
||||
|
||||
static const du P[] =
|
||||
{
|
||||
{0x3ff00000, 0x00000000},
|
||||
{0xbfc55554, 0xbc83656d},
|
||||
{0x3f8110ed, 0x3804c2a0},
|
||||
{0xbf29f6ff, 0xeea56814},
|
||||
{0x3ec5dbdf, 0x0e314bfe},
|
||||
};
|
||||
|
||||
static const du rpi =
|
||||
{0x3fd45f30, 0x6dc9c883};
|
||||
|
||||
static const du pihi =
|
||||
{0x400921fb, 0x50000000};
|
||||
|
||||
static const du pilo =
|
||||
{0x3e6110b4, 0x611a6263};
|
||||
|
||||
static const fu zero = {0x00000000};
|
||||
|
||||
|
||||
/* ====================================================================
|
||||
*
|
||||
* FunctionName fcos
|
||||
*
|
||||
* Description computes cosine of arg
|
||||
*
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
float
|
||||
fcos( float x )
|
||||
{
|
||||
float absx;
|
||||
double dx, xsq, poly;
|
||||
double dn;
|
||||
int n;
|
||||
double result;
|
||||
int ix, xpt;
|
||||
|
||||
|
||||
ix = *(int *)&x;
|
||||
xpt = (ix >> 22);
|
||||
xpt &= 0x1ff;
|
||||
|
||||
/* xpt is exponent(x) + 1 bit of mantissa */
|
||||
|
||||
|
||||
if ( xpt < 0x136 )
|
||||
{
|
||||
/* |x| < 2^28 */
|
||||
|
||||
/* use the standard algorithm from Cody and Waite, doing
|
||||
the computations in double precision
|
||||
*/
|
||||
|
||||
absx = ABS(x);
|
||||
|
||||
dx = absx;
|
||||
|
||||
dn = dx*rpi.d + 0.5;
|
||||
n = ROUND(dn);
|
||||
dn = n;
|
||||
|
||||
dn -= 0.5;
|
||||
|
||||
dx = dx - dn*pihi.d;
|
||||
dx = dx - dn*pilo.d; /* dx = x - (n - 0.5)*pi */
|
||||
|
||||
xsq = dx*dx;
|
||||
|
||||
poly = ((P[4].d*xsq + P[3].d)*xsq + P[2].d)*xsq + P[1].d;
|
||||
|
||||
result = dx + (dx*xsq)*poly;
|
||||
|
||||
/* negate result if n is odd */
|
||||
|
||||
if ( (n & 1) == 0 )
|
||||
return ( (float)result );
|
||||
|
||||
return ( -(float)result );
|
||||
}
|
||||
|
||||
if ( x != x )
|
||||
{
|
||||
/* x is a NaN; return a quiet NaN */
|
||||
|
||||
#ifdef _IP_NAN_SETS_ERRNO
|
||||
|
||||
*__errnoaddr = EDOM;
|
||||
#endif
|
||||
|
||||
return ( __libm_qnan_f );
|
||||
}
|
||||
|
||||
/* just give up and return 0.0 */
|
||||
|
||||
return ( zero.f );
|
||||
}
|
42
src/core1/gu/guint.h
Normal file
42
src/core1/gu/guint.h
Normal file
@@ -0,0 +1,42 @@
|
||||
/**************************************************************************
|
||||
* *
|
||||
* Copyright (C) 1994, Silicon Graphics, Inc. *
|
||||
* *
|
||||
* These coded instructions, statements, and computer programs contain *
|
||||
* unpublished proprietary information of Silicon Graphics, Inc., and *
|
||||
* are protected by Federal copyright law. They may not be disclosed *
|
||||
* to third parties or copied or duplicated in any form, in whole or *
|
||||
* in part, without the prior written consent of Silicon Graphics, Inc. *
|
||||
* *
|
||||
**************************************************************************/
|
||||
|
||||
#include "mbi.h"
|
||||
#include "gu.h"
|
||||
|
||||
typedef union
|
||||
{
|
||||
struct
|
||||
{
|
||||
unsigned int hi;
|
||||
unsigned int lo;
|
||||
} word;
|
||||
|
||||
double d;
|
||||
} du;
|
||||
|
||||
typedef union
|
||||
{
|
||||
unsigned int i;
|
||||
float f;
|
||||
} fu;
|
||||
|
||||
#ifndef __GL_GL_H__
|
||||
|
||||
typedef float Matrix[4][4];
|
||||
|
||||
#endif
|
||||
|
||||
#define ROUND(d) (int)(((d) >= 0.0) ? ((d) + 0.5) : ((d) - 0.5))
|
||||
#define ABS(d) ((d) > 0) ? (d) : -(d)
|
||||
|
||||
extern float __libm_qnan_f;
|
62
src/core1/gu/mtxutil.c
Normal file
62
src/core1/gu/mtxutil.c
Normal file
@@ -0,0 +1,62 @@
|
||||
#include <ultra64.h>
|
||||
#include "functions.h"
|
||||
#include "variables.h"
|
||||
|
||||
void guMtxL2F(float mf[4][4], Mtx *m)
|
||||
{
|
||||
int i, j;
|
||||
unsigned int e1,e2;
|
||||
unsigned int *ai,*af;
|
||||
int q1,q2;
|
||||
|
||||
ai=(unsigned int *) &m->m[0][0];
|
||||
af=(unsigned int *) &m->m[2][0];
|
||||
|
||||
for (i=0; i<4; i++)
|
||||
for (j=0; j<2; j++) {
|
||||
e1 = (*ai & 0xffff0000) | ((*af >> 16) & 0xffff);
|
||||
e2 = ((*(ai++) << 16) & 0xffff0000) | ((u16)(*(af++) >> 0));
|
||||
q1 = *((int *)&e1);
|
||||
q2 = *((int *)&e2);
|
||||
|
||||
mf[i][j*2] = (f32)q1/65536.0f;
|
||||
mf[i][j*2+1] = (f32)q2/65536.0f;
|
||||
}
|
||||
}
|
||||
|
||||
void guMtxIdent(Mtx *m){
|
||||
float mf[4][4];
|
||||
|
||||
guMtxIdentF(mf);
|
||||
guMtxF2L(mf, m);
|
||||
}
|
||||
|
||||
void guMtxIdentF(float mf[4][4])
|
||||
{
|
||||
int i, j;
|
||||
|
||||
for (i=0; i<4; i++)
|
||||
for (j=0; j<4; j++)
|
||||
if (i == j) mf[i][j] = 1.0;
|
||||
else mf[i][j] = 0.0;
|
||||
}
|
||||
|
||||
|
||||
void guMtxF2L(float mf[4][4], Mtx *m)
|
||||
{
|
||||
int i, j;
|
||||
int e1,e2;
|
||||
int *ai,*af;
|
||||
|
||||
|
||||
ai=(int *) &m->m[0][0];
|
||||
af=(int *) &m->m[2][0];
|
||||
|
||||
for (i=0; i<4; i++)
|
||||
for (j=0; j<2; j++) {
|
||||
e1=FTOFIX32(mf[i][j*2]);
|
||||
e2=FTOFIX32(mf[i][j*2+1]);
|
||||
*(ai++) = ( e1 & 0xffff0000 ) | ((e2 >> 16)&0xffff);
|
||||
*(af++) = ((e1 << 16) & 0xffff0000) | (e2 & 0xffff);
|
||||
}
|
||||
}
|
15
src/core1/gu/normalize.c
Normal file
15
src/core1/gu/normalize.c
Normal file
@@ -0,0 +1,15 @@
|
||||
#include <ultra64.h>
|
||||
#include "functions.h"
|
||||
#include "variables.h"
|
||||
|
||||
|
||||
void guNormalize(float *x, float *y, float *z)
|
||||
{
|
||||
float m;
|
||||
|
||||
m = gu_sqrtf((*x)*(*x) + (*y)*(*y) + (*z)*(*z));
|
||||
m = (f32)1.0/ m;
|
||||
*x *= m;
|
||||
*y *= m;
|
||||
*z *= m;
|
||||
}
|
31
src/core1/gu/ortho.c
Normal file
31
src/core1/gu/ortho.c
Normal file
@@ -0,0 +1,31 @@
|
||||
#include <ultra64.h>
|
||||
#include "functions.h"
|
||||
#include "variables.h"
|
||||
|
||||
|
||||
void guOrthoF(float mf[4][4], float l, float r, float b, float t, float n, float f, float scale)
|
||||
{
|
||||
int i, j;
|
||||
|
||||
guMtxIdentF(mf);
|
||||
|
||||
mf[0][0] = 2/(r-l);
|
||||
mf[1][1] = 2/(t-b);
|
||||
mf[2][2] = -2/(f-n);
|
||||
mf[3][0] = -(r+l)/(r-l);
|
||||
mf[3][1] = -(t+b)/(t-b);
|
||||
mf[3][2] = -(f+n)/(f-n);
|
||||
mf[3][3] = 1;
|
||||
|
||||
for (i=0; i<4; i++)
|
||||
for (j=0; j<4; j++)
|
||||
mf[i][j] *= scale;
|
||||
}
|
||||
|
||||
void guOrtho(Mtx *m, float l, float r, float b, float t, float n, float f, float scale)
|
||||
{
|
||||
float mf[4][4];
|
||||
|
||||
guOrthoF(mf, l, r, b, t, n, f, scale);
|
||||
guMtxF2L(mf, m);
|
||||
}
|
49
src/core1/gu/rotate.c
Normal file
49
src/core1/gu/rotate.c
Normal file
@@ -0,0 +1,49 @@
|
||||
#include <ultra64.h>
|
||||
#include "functions.h"
|
||||
#include "variables.h"
|
||||
|
||||
f32 sinf(f32);
|
||||
f32 cosf(f32);
|
||||
|
||||
void guRotateF(float mf[4][4], float a, float x, float y, float z)
|
||||
{
|
||||
static f32 D_80285900 = 3.1415926 / 180.0;
|
||||
float sine;
|
||||
float cosine;
|
||||
float ab, bc, ca, t;
|
||||
|
||||
|
||||
guNormalize(&x, &y, &z);
|
||||
a *= D_80285900;
|
||||
sine = sinf(a);
|
||||
cosine = cosf(a);
|
||||
t = (1-cosine);
|
||||
ab = x*y*t;
|
||||
bc = y*z*t;
|
||||
ca = z*x*t;
|
||||
|
||||
guMtxIdentF(mf);
|
||||
|
||||
t = x*x;
|
||||
mf[0][0] = t+cosine*(1-t);
|
||||
mf[2][1] = bc-x*sine;
|
||||
mf[1][2] = bc+x*sine;
|
||||
|
||||
t = y*y;
|
||||
mf[1][1] = t+cosine*(1-t);
|
||||
mf[2][0] = ca+y*sine;
|
||||
mf[0][2] = ca-y*sine;
|
||||
|
||||
t = z*z;
|
||||
mf[2][2] = t+cosine*(1-t);
|
||||
mf[1][0] = ab-z*sine;
|
||||
mf[0][1] = ab+z*sine;
|
||||
}
|
||||
|
||||
void guRotate(Mtx *m, float a, float x, float y, float z)
|
||||
{
|
||||
float mf[4][4];
|
||||
|
||||
guRotateF(mf, a, x, y, z);
|
||||
guMtxF2L(mf, m);
|
||||
}
|
157
src/core1/gu/sinf.c
Normal file
157
src/core1/gu/sinf.c
Normal file
@@ -0,0 +1,157 @@
|
||||
/**************************************************************************
|
||||
* *
|
||||
* Copyright (C) 1994, Silicon Graphics, Inc. *
|
||||
* *
|
||||
* These coded instructions, statements, and computer programs contain *
|
||||
* unpublished proprietary information of Silicon Graphics, Inc., and *
|
||||
* are protected by Federal copyright law. They may not be disclosed *
|
||||
* to third parties or copied or duplicated in any form, in whole or *
|
||||
* in part, without the prior written consent of Silicon Graphics, Inc. *
|
||||
* *
|
||||
**************************************************************************/
|
||||
|
||||
#include "guint.h"
|
||||
|
||||
/* ====================================================================
|
||||
* ====================================================================
|
||||
*
|
||||
* Module: fsin.c
|
||||
* $Revision: 1.2 $
|
||||
* $Date: 1995/07/12 17:48:01 $
|
||||
* $Author: jeffd $
|
||||
* $Source: /disk6/Master/cvsmdev2/PR/libultra/gu/sinf.c,v $
|
||||
*
|
||||
* Revision history:
|
||||
* 09-Jun-93 - Original Version
|
||||
*
|
||||
* Description: source code for fsin function
|
||||
*
|
||||
* ====================================================================
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
#pragma weak fsin = __sinf
|
||||
#pragma weak sinf = __sinf
|
||||
#define fsin __sinf
|
||||
|
||||
/* coefficients for polynomial approximation of sin on +/- pi/2 */
|
||||
|
||||
static const du P[] =
|
||||
{
|
||||
{0x3ff00000, 0x00000000},
|
||||
{0xbfc55554, 0xbc83656d},
|
||||
{0x3f8110ed, 0x3804c2a0},
|
||||
{0xbf29f6ff, 0xeea56814},
|
||||
{0x3ec5dbdf, 0x0e314bfe},
|
||||
};
|
||||
|
||||
static const du rpi =
|
||||
{0x3fd45f30, 0x6dc9c883};
|
||||
|
||||
static const du pihi =
|
||||
{0x400921fb, 0x50000000};
|
||||
|
||||
static const du pilo =
|
||||
{0x3e6110b4, 0x611a6263};
|
||||
|
||||
static const fu zero = {0x00000000};
|
||||
|
||||
|
||||
/* ====================================================================
|
||||
*
|
||||
* FunctionName fsin
|
||||
*
|
||||
* Description computes sine of arg
|
||||
*
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
float
|
||||
sinf( float x )
|
||||
{
|
||||
double dx, xsq, poly;
|
||||
double dn;
|
||||
int n;
|
||||
double result;
|
||||
int ix, xpt;
|
||||
|
||||
|
||||
ix = *(int *)&x;
|
||||
xpt = (ix >> 22);
|
||||
xpt &= 0x1ff;
|
||||
|
||||
/* xpt is exponent(x) + 1 bit of mantissa */
|
||||
|
||||
if ( xpt < 0xff )
|
||||
{
|
||||
/* |x| < 1.5 */
|
||||
|
||||
dx = x;
|
||||
|
||||
if ( xpt >= 0xe6 )
|
||||
{
|
||||
/* |x| >= 2^(-12) */
|
||||
|
||||
/* compute sin(x) with a standard polynomial approximation */
|
||||
|
||||
xsq = dx*dx;
|
||||
|
||||
poly = ((P[4].d*xsq + P[3].d)*xsq + P[2].d)*xsq + P[1].d;
|
||||
|
||||
result = dx + (dx*xsq)*poly;
|
||||
|
||||
return ( (float)result );
|
||||
}
|
||||
|
||||
return ( x );
|
||||
}
|
||||
|
||||
if ( xpt < 0x136 )
|
||||
{
|
||||
/* |x| < 2^28 */
|
||||
|
||||
dx = x;
|
||||
|
||||
/* reduce argument to +/- pi/2 */
|
||||
|
||||
dn = dx*rpi.d;
|
||||
|
||||
n = ROUND(dn);
|
||||
dn = n;
|
||||
|
||||
dx = dx - dn*pihi.d;
|
||||
dx = dx - dn*pilo.d; /* dx = x - n*pi */
|
||||
|
||||
/* compute sin(dx) as before, negating result if n is odd
|
||||
*/
|
||||
|
||||
xsq = dx*dx;
|
||||
|
||||
poly = ((P[4].d*xsq + P[3].d)*xsq + P[2].d)*xsq + P[1].d;
|
||||
|
||||
result = dx + (dx*xsq)*poly;
|
||||
|
||||
|
||||
if ( (n & 1) == 0 )
|
||||
return ( (float)result );
|
||||
|
||||
return ( -(float)result );
|
||||
}
|
||||
|
||||
if ( x != x )
|
||||
{
|
||||
/* x is a NaN; return a quiet NaN */
|
||||
|
||||
#ifdef _IP_NAN_SETS_ERRNO
|
||||
|
||||
*__errnoaddr = EDOM;
|
||||
#endif
|
||||
|
||||
return ( __libm_qnan_f );
|
||||
}
|
||||
|
||||
/* just give up and return 0.0 */
|
||||
|
||||
return ( zero.f );
|
||||
}
|
||||
|
8
src/core1/gu/sqrtf.c
Normal file
8
src/core1/gu/sqrtf.c
Normal file
@@ -0,0 +1,8 @@
|
||||
#include <ultra64.h>
|
||||
#include "functions.h"
|
||||
#include "variables.h"
|
||||
|
||||
|
||||
float gu_sqrtf(float val){
|
||||
return sqrtf(val);
|
||||
}
|
22
src/core1/gu/translate.c
Normal file
22
src/core1/gu/translate.c
Normal file
@@ -0,0 +1,22 @@
|
||||
#include <ultra64.h>
|
||||
#include "functions.h"
|
||||
#include "variables.h"
|
||||
|
||||
|
||||
void guTranslateF(float mf[4][4], float x, float y, float z)
|
||||
{
|
||||
guMtxIdentF(mf);
|
||||
|
||||
mf[3][0] = x;
|
||||
mf[3][1] = y;
|
||||
mf[3][2] = z;
|
||||
}
|
||||
|
||||
|
||||
void guTranslate(Mtx *m, float x, float y, float z)
|
||||
{
|
||||
float mf[4][4];
|
||||
|
||||
guTranslateF(mf, x, y, z);
|
||||
guMtxF2L(mf, m);
|
||||
}
|
Reference in New Issue
Block a user