00001
00002
00003
00004
00005
00007
00008 #ifndef __TYPEDEFS_H__
00009 #define __TYPEDEFS_H__
00010
00011 #ifdef _PSX
00013 // PSX fixed point types
00014 typedef int REAL;
00015 #define FIXED_PRECISION 16
00016
00017 #define LONG_MAX ((1 << 31) - 1)
00018
00019 #define SMALL_REAL (1<<3)
00020 #define SIMILAR_REAL (SMALL_REAL<<1)
00021 #define ZERO (0)
00022 #define ONE (1 << FIXED_PRECISION)
00023 #define HALF (1 << (FIXED_PRECISION - 1))
00024 #define LONGTIME (LONG_MAX)
00025 #define QUITELONGTIME (LONG_MAX >> 1)
00026 #define LARGEDIST (LONG_MAX)
00027
00028 #define Real(x) ((signed long)(x * 65536.0f))
00029 #define Int(r) ((r) >> FIXED_PRECISION)
00030
00031
00032 #else //_PSX
00034 // PC and N64 floating point types
00035 typedef float REAL;
00036
00037 #define SMALL_REAL (0.00001f)
00038 #define SIMILAR_REAL (0.0001f)
00039 #define ZERO (0.0f)
00040 #define ONE (1.0f)
00041 #define HALF (0.5f)
00042 #define LONGTIME (100000.0f)
00043 #define QUITELONGTIME (HALF * LONGTIME)
00044 #define LARGEDIST (1000000.0f)
00045
00046 #define Real(x) ((REAL) (ONE * (x)))
00047 #define Int(r) ((int)(r))
00048
00049 #ifdef _N64
00050 #define LONG_MAX 0x7FFFFFFF
00051 #define FLT_MAX 3.402823466e+38f
00052 #endif
00053
00054 #endif //_PSX
00055
00056
00057 #define NearestInt(r) (Int((r) + HALF))
00058
00059
00060 typedef short INDEX;
00061
00063
00065
00066 #ifndef NULL
00067 #define NULL ((void *)0)
00068 #endif
00069
00070 #ifndef FALSE
00071 #define FALSE 0
00072 #endif
00073
00074 #ifndef TRUE
00075 #define TRUE (!FALSE)
00076 #endif
00077
00078
00080
00082
00083 enum VectorElements {X, Y, Z};
00084 enum MatrixElements {
00085 XX, XY, XZ,
00086 YX, YY, YZ,
00087 ZX, ZY, ZZ,
00088 RX=0, RY, RZ,
00089 UX, UY, UZ,
00090 LX, LY, LZ
00091 };
00092 enum MatrixVectors {R, U, L};
00093 enum PlaneElements {A, B, C, D};
00094
00095 enum QuaternionElements {VX, VY, VZ, S};
00096
00097 #ifdef _PSX
00098
00099 typedef char bool;
00100 typedef char csbool;
00101
00102
00103
00104
00105 typedef struct VectorStruct {
00106 REAL v[3];
00107 } VEC;
00108
00109
00110 typedef union MatrixUnion {
00111 REAL m[9];
00112 VEC mv[3];
00113 struct {
00114 REAL r[3];
00115 REAL u[3];
00116 REAL l[3];
00117 } row;
00118 } MAT;
00119
00120
00121
00122
00123 typedef struct {
00124 REAL v[4];
00125 } PLANE;
00126
00127 typedef struct {
00128 REAL Xmin, Xmax;
00129 REAL Ymin, Ymax;
00130 REAL Zmin, Zmax;
00131 } BOUNDING_BOX;
00132
00133
00134 #else
00135
00136 #ifndef _PC
00137 typedef unsigned long long VISIMASK;
00138 #else
00139 #ifdef _CARCONV
00140 typedef long bool;
00141 typedef long VISIMASK;
00142 #else
00143 typedef unsigned __int64 VISIMASK;
00144 #endif
00145 #endif
00146
00147 typedef struct VectorStruct {
00148 REAL v[3];
00149 } VEC;
00150
00151 typedef struct PlaneStruct {
00152 REAL v[4];
00153 } PLANE;
00154
00155 typedef union MatrixUnion {
00156 REAL m[9];
00157 VEC mv[3];
00158 struct {
00159 REAL r[3];
00160 REAL u[3];
00161 REAL l[3];
00162 } row;
00163 } MAT;
00164
00165 typedef struct ShortVectorStruct {
00166 short v[3];
00167 short pad;
00168 } SHORTVEC;
00169
00170 typedef union ShortMatrixUnion {
00171 short m[9];
00172 SHORTVEC mv[3];
00173 } SHORTMAT;
00174
00175 typedef struct BoundingBoxStruct {
00176 REAL Xmin, Xmax;
00177 REAL Ymin, Ymax;
00178 REAL Zmin, Zmax;
00179 } BOUNDING_BOX;
00180
00181 typedef struct ShortQuatStruct {
00182 short v[4];
00183 } SHORTQUAT;
00184
00185 typedef struct CharQuatStruct {
00186 char v[4];
00187 } CHARQUAT;
00188
00189 #endif
00190
00191 typedef struct QuaternionStruct {
00192 REAL v[4];
00193 } QUATERNION;
00194
00195
00196 typedef struct SphereStruct {
00197 VEC Pos;
00198 REAL Radius;
00199 } SPHERE;
00200
00201 typedef struct {
00202 long data[2];
00203 } MEM8;
00204
00205 typedef struct {
00206 long data[3];
00207 } MEM12;
00208
00209 typedef struct {
00210 long data[4];
00211 } MEM16;
00212
00213 typedef struct {
00214 long data[5];
00215 } MEM20;
00216
00217 typedef struct {
00218 long data[6];
00219 } MEM24;
00220
00221 typedef struct {
00222 long data[7];
00223 } MEM28;
00224
00225 typedef struct {
00226 long data[8];
00227 } MEM32;
00228
00229 #endif
00230