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