gu.h
9.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
#ifndef _GU_H_
#define _GU_H_
/**************************************************************************
* *
* 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. *
* *
**************************************************************************/
/**************************************************************************
*
* $Revision: 1.1.1.2 $
* $Date: 2002/10/29 08:06:34 $
* $Source: /root/leakn64/depot/rf/sw/n64os20l/include/gu.h,v $
*
**************************************************************************/
#include <PR/mbi.h>
#include <PR/ultratypes.h>
#include <PR/sptask.h>
#ifndef MAX
#define MAX(a,b) (((a)>(b))?(a):(b))
#endif
#ifndef MIN
#define MIN(a,b) (((a)<(b))?(a):(b))
#endif
#define M_PI 3.14159265358979323846
#define M_DTOR (3.14159265358979323846/180.0)
#define FTOFIX32(x) (long)((x) * (float)0x00010000)
#define FIX32TOF(x) ((float)(x) * (1.0f / (float)0x00010000))
#define FTOFRAC8(x) ((int) MIN(((x) * (128.0f)), 127.0f) & 0xff)
#define FILTER_WRAP 0
#define FILTER_CLAMP 1
#define RAND(x) (guRandom()%x) /* random number between 0 to x */
/*
* Data Structures
*/
typedef struct {
unsigned char *base;
int fmt, siz;
int xsize, ysize;
int lsize;
/* current tile info */
int addr;
int w, h;
int s, t;
} Image;
typedef struct {
float col[3];
float pos[3];
float a1, a2; /* actual color = col/(a1*dist + a2) */
} PositionalLight;
/*
* Function Prototypes
*/
extern int guLoadTextureBlockMipMap(Gfx **glist, unsigned char *tbuf, Image *im,
unsigned char startTile, unsigned char pal, unsigned char cms,
unsigned char cmt, unsigned char masks, unsigned char maskt,
unsigned char shifts, unsigned char shiftt, unsigned char cfs,
unsigned char cft);
extern int guGetDPLoadTextureTileSz (int ult, int lrt);
extern void guDPLoadTextureTile (Gfx *glistp, void *timg,
int texl_fmt, int texl_size,
int img_width, int img_height,
int uls, int ult, int lrs, int lrt,
int palette,
int cms, int cmt,
int masks, int maskt,
int shifts, int shiftt);
/*
* matrix operations:
*
* The 'F' version is floating point, in case the application wants
* to do matrix manipulations and convert to fixed-point at the last
* minute.
*/
extern void guMtxIdent(Mtx *m);
extern void guMtxIdentF(float mf[4][4]);
extern void guOrtho(Mtx *m, float l, float r, float b, float t,
float n, float f, float scale);
extern void guOrthoF(float mf[4][4], float l, float r, float b, float t,
float n, float f, float scale);
extern void guFrustum(Mtx *m, float l, float r, float b, float t,
float n, float f, float scale);
extern void guFrustumF(float mf[4][4], float l, float r, float b, float t,
float n, float f, float scale);
extern void guPerspective(Mtx *m, u16 *perspNorm, float fovy,
float aspect, float near, float far, float scale);
extern void guPerspectiveF(float mf[4][4], u16 *perspNorm, float fovy,
float aspect, float near, float far, float scale);
extern void guLookAt(Mtx *m,
float xEye, float yEye, float zEye,
float xAt, float yAt, float zAt,
float xUp, float yUp, float zUp);
extern void guLookAtF(float mf[4][4], float xEye, float yEye, float zEye,
float xAt, float yAt, float zAt,
float xUp, float yUp, float zUp);
extern void guLookAtReflect(Mtx *m, LookAt *l,
float xEye, float yEye, float zEye,
float xAt, float yAt, float zAt,
float xUp, float yUp, float zUp);
extern void guLookAtReflectF(float mf[4][4], LookAt *l,
float xEye, float yEye, float zEye,
float xAt, float yAt, float zAt,
float xUp, float yUp, float zUp);
extern void guLookAtHilite(Mtx *m, LookAt *l, Hilite *h,
float xEye, float yEye, float zEye,
float xAt, float yAt, float zAt,
float xUp, float yUp, float zUp,
float xl1, float yl1, float zl1,
float xl2, float yl2, float zl2,
int twidth, int theight);
extern void guLookAtHiliteF(float mf[4][4], LookAt *l, Hilite *h,
float xEye, float yEye, float zEye,
float xAt, float yAt, float zAt,
float xUp, float yUp, float zUp,
float xl1, float yl1, float zl1,
float xl2, float yl2, float zl2,
int twidth, int theight);
extern void guLookAtStereo(Mtx *m,
float xEye, float yEye, float zEye,
float xAt, float yAt, float zAt,
float xUp, float yUp, float zUp,
float eyedist);
extern void guLookAtStereoF(float mf[4][4],
float xEye, float yEye, float zEye,
float xAt, float yAt, float zAt,
float xUp, float yUp, float zUp,
float eyedist);
extern void guRotate(Mtx *m, float a, float x, float y, float z);
extern void guRotateF(float mf[4][4], float a, float x, float y, float z);
extern void guRotateRPY(Mtx *m, float r, float p, float y);
extern void guRotateRPYF(float mf[4][4], float r, float p, float h);
extern void guAlign(Mtx *m, float a, float x, float y, float z);
extern void guAlignF(float mf[4][4], float a, float x, float y, float z);
extern void guScale(Mtx *m, float x, float y, float z);
extern void guScaleF(float mf[4][4], float x, float y, float z);
extern void guTranslate(Mtx *m, float x, float y, float z);
extern void guTranslateF(float mf[4][4], float x, float y, float z);
extern void guPosition(Mtx *m, float r, float p, float h, float s,
float x, float y, float z);
extern void guPositionF(float mf[4][4], float r, float p, float h, float s,
float x, float y, float z);
extern void guMtxF2L(float mf[4][4], Mtx *m);
extern void guMtxL2F(float mf[4][4], Mtx *m);
extern void guMtxCatF(float m[4][4], float n[4][4], float r[4][4]);
extern void guMtxCatL(Mtx *m, Mtx *n, Mtx *res);
extern void guMtxXFMF(float mf[4][4], float x, float y, float z,
float *ox, float *oy, float *oz);
extern void guMtxXFML(Mtx *m, float x, float y, float z,
float *ox, float *oy, float *oz);
/* vector utility: */
extern void guNormalize(float *x, float *y, float *z);
/* light utilities: */
void guPosLight(PositionalLight *pl, Light *l,
float xOb, float yOb, float zOb);
void guPosLightHilite(PositionalLight *pl1, PositionalLight *pl2,
Light *l1, Light *l2,
LookAt *l, Hilite *h,
float xEye, float yEye, float zEye,
float xOb, float yOb, float zOb,
float xUp, float yUp, float zUp,
int twidth, int theight);
extern int guRandom(void);
/*
* Math functions
*/
extern float sinf(float angle);
extern float cosf(float angle);
extern signed short sins (unsigned short angle);
extern signed short coss (unsigned short angle);
extern float sqrtf(float value);
#ifdef __sgi
#pragma intrinsic(sqrtf);
#endif
/*
* Dump routines for low-level display lists
*/
/* flag values for guParseRdpDL() */
#define GU_PARSERDP_VERBOSE 1
#define GU_PARSERDP_PRAREA 2
#define GU_PARSERDP_PRHISTO 4
#define GU_PARSERDP_DUMPONLY 32 /* doesn't need to be same as */
/* GU_PARSEGBI_DUMPOLNY, but this */
/* allows app to use interchangeably */
extern void guParseRdpDL(u64 *rdp_dl, u64 nbytes, u8 flags);
extern void guParseString(char *StringPointer, u64 nbytes);
/*
* NO LONGER SUPPORTED,
* use guParseRdpDL with GU_PARSERDP_DUMPONLY flags
*/
/* extern void guDumpRawRdpDL(u64 *rdp_dl, u64 nbytes); */
/* flag values for guBlinkRdpDL() */
#define GU_BLINKRDP_HILITE 1
#define GU_BLINKRDP_EXTRACT 2
extern void
guBlinkRdpDL(u64 *rdp_dl_in, u64 nbytes_in,
u64 *rdp_dl_out, u64 *nbytes_out,
u32 x, u32 y, u32 radius,
u8 red, u8 green, u8 blue,
u8 flags);
/* flag values for guParseGbiDL() */
#define GU_PARSEGBI_ROWMAJOR 1
#define GU_PARSEGBI_NONEST 2
#define GU_PARSEGBI_FLTMTX 4
#define GU_PARSEGBI_SHOWDMA 8
#define GU_PARSEGBI_ALLMTX 16
#define GU_PARSEGBI_DUMPONLY 32
/*
#define GU_PARSEGBI_HANGAFTER 64
#define GU_PARSEGBI_NOTEXTURES 128
*/
extern void guParseGbiDL(u64 *gbi_dl, u32 nbytes, u8 flags);
extern void guDumpGbiDL(OSTask *tp,u8 flags);
#define GU_PARSE_GBI_TYPE 1
#define GU_PARSE_RDP_TYPE 2
#define GU_PARSE_READY 3
#define GU_PARSE_MEM_BLOCK 4
#define GU_PARSE_ABI_TYPE 5
#define GU_PARSE_STRING_TYPE 6
typedef struct {
int dataSize;
int dlType;
int flags;
u32 paddr;
} guDLPrintCB;
void guSprite2DInit(uSprite *SpritePointer,
void *SourceImagePointer,
void *TlutPointer,
int Stride,
int SubImageWidth,
int SubImageHeight,
int SourceImageType,
int SourceImageBitSize,
int SourceImageOffsetS,
int SourceImageOffsetT);
#endif /* !_GU_H_ */