1 #ifndef __GX_H__
2 #define __GX_H__
3 
4 /*!
5  * \file gx.h
6  * \brief GX subsystem
7  *
8  */
9 
10 #include <gctypes.h>
11 #include "lwp.h"
12 #include "gx_struct.h"
13 #include "gu.h"
14 
15 #define GX_FALSE			0
16 #define GX_TRUE				1
17 #define GX_DISABLE			0
18 #define GX_ENABLE			1
19 
20 /*! \addtogroup clipmode Clipping mode
21  * @{
22  */
23 #define GX_CLIP_DISABLE		1
24 #define GX_CLIP_ENABLE		0
25 /*! @} */
26 
27 #define GX_FIFO_MINSIZE		(64*1024)			/*!< Smallest usable graphics FIFO size. */
28 #define GX_FIFO_HIWATERMARK	(16*1024)			/*!< Default hi watermark for FIFO buffer control. */
29 #define GX_FIFO_OBJSIZE		128
30 
31 #define GX_PERSPECTIVE		0
32 #define GX_ORTHOGRAPHIC		1
33 
34 #define GX_MT_NULL			0
35 #define GX_MT_XF_FLUSH		1
36 #define GX_MT_DL_SAVE_CTX	2
37 
38 #define GX_XF_FLUSH_NONE	0
39 #define GX_XF_FLUSH_SAFE	1
40 
41 /*! \addtogroup channelid Color channel ID
42  * @{
43  */
44 #define GX_COLOR0			0
45 #define GX_COLOR1			1
46 #define GX_ALPHA0			2
47 #define GX_ALPHA1			3
48 #define GX_COLOR0A0			4
49 #define GX_COLOR1A1			5
50 #define GX_COLORZERO		6
51 #define GX_ALPHA_BUMP		7
52 #define GX_ALPHA_BUMPN		8
53 #define GX_COLORNULL		0xff
54 /*! @} */
55 
56 /*! \addtogroup mtxtype Matrix type
57  * @{
58  */
59 #define GX_MTX2x4			0
60 #define GX_MTX3x4			1
61 /*! @} */
62 
63 /*! \addtogroup vtxfmt Vertex format index
64  * @{
65  */
66 #define GX_VTXFMT0			0
67 #define GX_VTXFMT1			1
68 #define GX_VTXFMT2			2
69 #define GX_VTXFMT3			3
70 #define GX_VTXFMT4			4
71 #define GX_VTXFMT5			5
72 #define GX_VTXFMT6			6
73 #define GX_VTXFMT7			7
74 #define GX_MAXVTXFMT		8
75 
76 /*! @} */
77 
78 /*! \addtogroup vtxattrin Vertex data input type
79  * @{
80  */
81 #define GX_NONE				0			/*!< Input data is not used */
82 #define GX_DIRECT			1			/*!< Input data is set direct */
83 #define GX_INDEX8			2			/*!< Input data is set by a 8bit index */
84 #define GX_INDEX16			3			/*!< Input data is set by a 16bit index */
85 
86 /*! @} */
87 
88 /*! \addtogroup compsize Number of components in an attribute
89  * @{
90  */
91 #define GX_U8				0			/*!< Unsigned 8-bit integer */
92 #define GX_S8				1			/*!< Signed 8-bit integer */
93 #define GX_U16				2			/*!< Unsigned 16-bit integer */
94 #define GX_S16				3			/*!< Signed 16-bit integer */
95 #define GX_F32				4			/*!< 32-bit floating-point */
96 #define GX_RGB565			0			/*!< 16-bit RGB */
97 #define GX_RGB8				1			/*!< 24-bit RGB */
98 #define GX_RGBX8			2			/*!< 32-bit RGBX */
99 #define GX_RGBA4			3			/*!< 16-bit RGBA */
100 #define GX_RGBA6			4			/*!< 24-bit RGBA */
101 #define GX_RGBA8			5			/*!< 32-bit RGBA */
102 /*! @} */
103 
104 /*! \addtogroup comptype Attribute component type
105  * @{
106  */
107 #define GX_POS_XY			0			/*!< X,Y position */
108 #define GX_POS_XYZ			1			/*!< X,Y,Z position */
109 #define GX_NRM_XYZ			0			/*!< X,Y,Z normal */
110 #define GX_NRM_NBT			1
111 #define GX_NRM_NBT3			2
112 #define GX_CLR_RGB			0			/*!< RGB color */
113 #define GX_CLR_RGBA			1			/*!< RGBA color */
114 #define GX_TEX_S			0			/*!< One texture dimension */
115 #define GX_TEX_ST			1			/*!< Two texture dimensions */
116 /*! @} */
117 
118 /*! \addtogroup vtxattr Vertex attribute array type
119  * @{
120  */
121 #define GX_VA_PTNMTXIDX			0
122 #define GX_VA_TEX0MTXIDX		1
123 #define GX_VA_TEX1MTXIDX		2
124 #define GX_VA_TEX2MTXIDX		3
125 #define GX_VA_TEX3MTXIDX		4
126 #define GX_VA_TEX4MTXIDX		5
127 #define GX_VA_TEX5MTXIDX		6
128 #define GX_VA_TEX6MTXIDX		7
129 #define GX_VA_TEX7MTXIDX		8
130 #define GX_VA_POS				9
131 #define GX_VA_NRM				10
132 #define GX_VA_CLR0				11
133 #define GX_VA_CLR1				12
134 #define GX_VA_TEX0				13
135 #define GX_VA_TEX1				14
136 #define GX_VA_TEX2				15
137 #define GX_VA_TEX3				16
138 #define GX_VA_TEX4				17
139 #define GX_VA_TEX5				18
140 #define GX_VA_TEX6				19
141 #define GX_VA_TEX7				20
142 #define GX_POSMTXARRAY			21
143 #define GX_NRMMTXARRAY			22
144 #define GX_TEXMTXARRAY			23
145 #define GX_LIGHTARRAY			24
146 #define GX_VA_NBT				25
147 #define GX_VA_MAXATTR			26
148 #define GX_VA_NULL				0xff
149 /*! @} */
150 
151 /*! \addtogroup primtype Primitive type
152  * \brief Collection of primitive types that can be drawn by the GP.
153  *
154  * \note Which type you use depends on your needs; however, performance can increase by using triangle strips or fans instead of discrete triangles.
155  * @{
156  */
157 #define GX_POINTS				0xB8			/*!< Draws a series of points. Each vertex is a single point. */
158 #define GX_LINES				0xA8			/*!< Draws a series of unconnected line segments. Each pair of vertices makes a line. */
159 #define GX_LINESTRIP			0xB0			/*!< Draws a series of lines. Each vertex (besides the first) makes a line between it and the previous. */
160 #define GX_TRIANGLES			0x90			/*!< Draws a series of unconnected triangles. Three vertices make a single triangle. */
161 #define GX_TRIANGLESTRIP		0x98			/*!< Draws a series of triangles. Each triangle (besides the first) shares a side with the previous triangle.
162 												* Each vertex (besides the first two) completes a triangle. */
163 #define GX_TRIANGLEFAN			0xA0			/*!< Draws a single triangle fan. The first vertex is the "centerpoint". The second and third vertex complete
164 												* the first triangle. Each subsequent vertex completes another triangle which shares a side with the previous
165 												* triangle (except the first triangle) and has the centerpoint vertex as one of the vertices. */
166 #define GX_QUADS				0x80			/*!< Draws a series of unconnected quads. Every four vertices completes a quad. Internally, each quad is
167 												* translated into a pair of triangles. */
168 /*! @} */
169 
170 #define GX_SRC_REG			0
171 #define GX_SRC_VTX			1
172 
173 /*! \addtogroup lightid Light ID
174  * @{
175  */
176 #define GX_LIGHT0			0x001			/*!< Light 0 */
177 #define GX_LIGHT1			0x002			/*!< Light 2 */
178 #define GX_LIGHT2			0x004			/*!< Light 3 */
179 #define GX_LIGHT3			0x008			/*!< Light 4 */
180 #define GX_LIGHT4			0x010			/*!< Light 5 */
181 #define GX_LIGHT5			0x020			/*!< Light 6 */
182 #define GX_LIGHT6			0x040			/*!< Light 7 */
183 #define GX_LIGHT7			0x080			/*!< Light 8 */
184 #define GX_MAXLIGHT			0x100			/*!< All lights */
185 #define GX_LIGHTNULL		0x000			/*!< No lights */
186 /*! @} */
187 
188 /*! \addtogroup difffn Diffuse function
189  * @{
190  */
191 #define GX_DF_NONE			0
192 #define GX_DF_SIGNED		1
193 #define GX_DF_CLAMP			2
194 /*! @} */
195 
196 /*! \addtogroup attenfunc Attenuation function
197  * @{
198  */
199 #define GX_AF_SPEC			0			/*!< Specular computation */
200 #define GX_AF_SPOT			1			/*!< Spot light attenuation */
201 #define GX_AF_NONE			2			/*!< No attenuation */
202 /*! @} */
203 
204 /* pos,nrm,tex,dtt matrix */
205 /*! \addtogroup pnmtx Position-normal matrix index
206  * @{
207  */
208 #define GX_PNMTX0			0
209 #define GX_PNMTX1			3
210 #define GX_PNMTX2			6
211 #define GX_PNMTX3			9
212 #define GX_PNMTX4			12
213 #define GX_PNMTX5			15
214 #define GX_PNMTX6			18
215 #define GX_PNMTX7			21
216 #define GX_PNMTX8			24
217 #define GX_PNMTX9			27
218 /*! @} */
219 
220 /*! \addtogroup texmtx Texture matrix index
221  * @{
222  */
223 #define GX_TEXMTX0			30
224 #define GX_TEXMTX1			33
225 #define GX_TEXMTX2			36
226 #define GX_TEXMTX3			39
227 #define GX_TEXMTX4			42
228 #define GX_TEXMTX5			45
229 #define GX_TEXMTX6			48
230 #define GX_TEXMTX7			51
231 #define GX_TEXMTX8			54
232 #define GX_TEXMTX9			57
233 #define GX_IDENTITY			60
234 /*! @} */
235 
236 /*! \addtogroup dttmtx Post-transform texture matrix index
237  * @{
238  */
239 #define GX_DTTMTX0			64
240 #define GX_DTTMTX1			67
241 #define GX_DTTMTX2			70
242 #define GX_DTTMTX3			73
243 #define GX_DTTMTX4			76
244 #define GX_DTTMTX5			79
245 #define GX_DTTMTX6			82
246 #define GX_DTTMTX7			85
247 #define GX_DTTMTX8			88
248 #define GX_DTTMTX9			91
249 #define GX_DTTMTX10			94
250 #define GX_DTTMTX11			97
251 #define GX_DTTMTX12			100
252 #define GX_DTTMTX13			103
253 #define GX_DTTMTX14			106
254 #define GX_DTTMTX15			109
255 #define GX_DTTMTX16			112
256 #define GX_DTTMTX17			115
257 #define GX_DTTMTX18			118
258 #define GX_DTTMTX19			121
259 #define GX_DTTIDENTITY		125
260 /*! @} */
261 
262 /* tex coord id
263    used by: XF: 0x1040,0x1050
264             BP: 0x30
265 */
266 /*! \addtogroup texcoordid texture coordinate slot
267  * @{
268  */
269 #define GX_TEXCOORD0		0x0
270 #define GX_TEXCOORD1		0x1
271 #define GX_TEXCOORD2		0x2
272 #define GX_TEXCOORD3		0x3
273 #define GX_TEXCOORD4		0x4
274 #define GX_TEXCOORD5		0x5
275 #define GX_TEXCOORD6		0x6
276 #define GX_TEXCOORD7		0x7
277 #define GX_MAXCOORD			0x8
278 #define GX_TEXCOORDNULL		0xff
279 /*! @} */
280 
281 /* tex format */
282 #define _GX_TF_ZTF			0x10
283 #define _GX_TF_CTF			0x20
284 
285 /*! \addtogroup texfmt Texture format
286  * @{
287  */
288 
289 #define GX_TF_I4			0x0
290 #define GX_TF_I8			0x1
291 #define GX_TF_IA4			0x2
292 #define GX_TF_IA8			0x3
293 #define GX_TF_RGB565		0x4
294 #define GX_TF_RGB5A3		0x5
295 #define GX_TF_RGBA8			0x6
296 #define GX_TF_CI4			0x8
297 #define GX_TF_CI8			0x9
298 #define GX_TF_CI14			0xa
299 #define GX_TF_CMPR			0xE			/*!< Compressed */
300 
301 #define GX_TL_IA8			0x00
302 #define GX_TL_RGB565		0x01
303 #define GX_TL_RGB5A3		0x02
304 
305 #define GX_CTF_R4			(0x0|_GX_TF_CTF)			/*!< For copying 4 bits from red */
306 #define GX_CTF_RA4			(0x2|_GX_TF_CTF)			/*!< For copying 4 bits from red, 4 bits from alpha */
307 #define GX_CTF_RA8			(0x3|_GX_TF_CTF)			/*!< For copying 8 bits from red, 8 bits from alpha */
308 #define GX_CTF_YUVA8		(0x6|_GX_TF_CTF)
309 #define GX_CTF_A8			(0x7|_GX_TF_CTF)			/*!< For copying 8 bits from alpha */
310 #define GX_CTF_R8			(0x8|_GX_TF_CTF)			/*!< For copying 8 bits from red */
311 #define GX_CTF_G8			(0x9|_GX_TF_CTF)			/*!< For copying 8 bits from green */
312 #define GX_CTF_B8			(0xA|_GX_TF_CTF)			/*!< For copying 8 bits from blue */
313 #define GX_CTF_RG8			(0xB|_GX_TF_CTF)			/*!< For copying 8 bits from red, 8 bits from green */
314 #define GX_CTF_GB8			(0xC|_GX_TF_CTF)			/*!< For copying 8 bits from green, 8 bits from blue */
315 
316 /*! \addtogroup ztexfmt Z Texture format
317  * @{
318  */
319 
320 #define GX_TF_Z8			(0x1|_GX_TF_ZTF)			/*!< For texture copy, specifies upper 8 bits of Z */
321 #define GX_TF_Z16			(0x3|_GX_TF_ZTF)			/*!< For texture copy, specifies upper 16 bits of Z */
322 #define GX_TF_Z24X8			(0x6|_GX_TF_ZTF)			/*!< For texture copy, copies 24 Z bits and 0xFF */
323 
324 /*! @} */
325 
326 #define GX_CTF_Z4			(0x0|_GX_TF_ZTF|_GX_TF_CTF)			/*!< For copying 4 upper bits from Z */
327 #define GX_CTF_Z8M			(0x9|_GX_TF_ZTF|_GX_TF_CTF)			/*!< For copying the middle 8 bits of Z */
328 #define GX_CTF_Z8L			(0xA|_GX_TF_ZTF|_GX_TF_CTF)			/*!< For copying the lower 8 bits of Z */
329 #define GX_CTF_Z16L			(0xC|_GX_TF_ZTF|_GX_TF_CTF)			/*!< For copying the lower 16 bits of Z */
330 
331 #define GX_TF_A8			GX_CTF_A8
332 
333 /*! @} */
334 
335 /* gx tlut size */
336 #define GX_TLUT_16			1	// number of 16 entry blocks.
337 #define GX_TLUT_32			2
338 #define GX_TLUT_64			4
339 #define GX_TLUT_128			8
340 #define GX_TLUT_256			16
341 #define GX_TLUT_512			32
342 #define GX_TLUT_1K			64
343 #define GX_TLUT_2K			128
344 #define GX_TLUT_4K			256
345 #define GX_TLUT_8K			512
346 #define GX_TLUT_16K			1024
347 
348 /*! \addtogroup ztexop Z Texture operator
349  * @{
350  */
351 
352 #define GX_ZT_DISABLE		0
353 #define GX_ZT_ADD			1			/*!< Add a Z texel to reference Z */
354 #define GX_ZT_REPLACE		2			/*!< Replace reference Z with Z texel */
355 #define GX_MAX_ZTEXOP		3
356 
357 /*! @} */
358 
359 /*! \addtogroup texgentyp Texture coordinate generation type
360  * @{
361  */
362 #define GX_TG_MTX3x4		0			/*!< 2x4 matrix multiply on the input attribute and generate S,T texture coordinates. */
363 #define GX_TG_MTX2x4		1			/*!< 3x4 matrix multiply on the input attribute and generate S,T,Q coordinates; S,T are then divided
364 										* by Q to produce the actual 2D texture coordinates. */
365 #define GX_TG_BUMP0			2			/*!< Use light 0 in the bump map calculation. */
366 #define GX_TG_BUMP1			3			/*!< Use light 1 in the bump map calculation. */
367 #define GX_TG_BUMP2			4			/*!< Use light 2 in the bump map calculation. */
368 #define GX_TG_BUMP3			5			/*!< Use light 3 in the bump map calculation. */
369 #define GX_TG_BUMP4			6			/*!< Use light 4 in the bump map calculation. */
370 #define GX_TG_BUMP5			7			/*!< Use light 5 in the bump map calculation. */
371 #define GX_TG_BUMP6			8			/*!< Use light 6 in the bump map calculation. */
372 #define GX_TG_BUMP7			9			/*!< Use light 7 in the bump map calculation. */
373 #define GX_TG_SRTG			10			/*!< Coordinates generated from vertex lighting results; one of the color channel results is converted
374 										* into texture coordinates. */
375 /*! @} */
376 
377 /*! \addtogroup texgensrc Texture coordinate source
378  * @{
379  */
380 #define GX_TG_POS			0
381 #define GX_TG_NRM			1
382 #define GX_TG_BINRM			2
383 #define GX_TG_TANGENT		3
384 #define GX_TG_TEX0			4
385 #define GX_TG_TEX1			5
386 #define GX_TG_TEX2			6
387 #define GX_TG_TEX3			7
388 #define GX_TG_TEX4			8
389 #define GX_TG_TEX5			9
390 #define GX_TG_TEX6			10
391 #define GX_TG_TEX7			11
392 #define GX_TG_TEXCOORD0		12
393 #define GX_TG_TEXCOORD1		13
394 #define GX_TG_TEXCOORD2		14
395 #define GX_TG_TEXCOORD3		15
396 #define GX_TG_TEXCOORD4		16
397 #define GX_TG_TEXCOORD5		17
398 #define GX_TG_TEXCOORD6		18
399 #define GX_TG_COLOR0		19
400 #define GX_TG_COLOR1		20
401 /*! @} */
402 
403 /*! \addtogroup compare Compare type
404  * @{
405  */
406 #define GX_NEVER			0
407 #define GX_LESS				1
408 #define GX_EQUAL			2
409 #define GX_LEQUAL			3
410 #define GX_GREATER			4
411 #define GX_NEQUAL			5
412 #define GX_GEQUAL			6
413 #define GX_ALWAYS			7
414 /*! @} */
415 
416 /* Text Wrap Mode */
417 #define GX_CLAMP			0
418 #define GX_REPEAT			1
419 #define GX_MIRROR			2
420 #define GX_MAXTEXWRAPMODE	3
421 
422 /*! \addtogroup blendmode Blending type
423  * @{
424  */
425 #define GX_BM_NONE			0			/*!< Write input directly to EFB */
426 #define GX_BM_BLEND			1			/*!< Blend using blending equation */
427 #define GX_BM_LOGIC			2			/*!< Blend using bitwise operation */
428 #define GX_BM_SUBTRACT		3			/*!< Input subtracts from existing pixel */
429 #define GX_MAX_BLENDMODE	4
430 /*! @} */
431 
432 /*! \addtogroup blendfactor Blending control
433  * \details Each pixel (source or destination) is multiplied by any of these controls.
434  * @{
435  */
436 #define GX_BL_ZERO			0			/*!< 0.0 */
437 #define GX_BL_ONE			1			/*!< 1.0 */
438 #define GX_BL_SRCCLR		2			/*!< source color */
439 #define GX_BL_INVSRCCLR		3			/*!< 1.0 - (source color) */
440 #define GX_BL_SRCALPHA		4			/*!< source alpha */
441 #define GX_BL_INVSRCALPHA	5			/*!< 1.0 - (source alpha) */
442 #define GX_BL_DSTALPHA		6			/*!< framebuffer alpha */
443 #define GX_BL_INVDSTALPHA	7			/*!< 1.0 - (FB alpha) */
444 #define GX_BL_DSTCLR		GX_BL_SRCCLR
445 #define GX_BL_INVDSTCLR		GX_BL_INVSRCCLR
446 /*! @} */
447 
448 /*! \addtogroup logicop Logical operation type
449  * \details Destination (dst) acquires the value of one of these operations, given in C syntax.
450  * @{
451  */
452 #define GX_LO_CLEAR			0			/*!< 0 */
453 #define GX_LO_AND			1			/*!< src & dst */
454 #define GX_LO_REVAND		2			/*!< src & ~dst */
455 #define GX_LO_COPY			3			/*!< src */
456 #define GX_LO_INVAND		4			/*!< ~src & dst */
457 #define GX_LO_NOOP			5			/*!< dst */
458 #define GX_LO_XOR			6			/*!< src ^ dst */
459 #define GX_LO_OR			7			/*!< src | dst */
460 #define GX_LO_NOR			8			/*!< ~(src | dst) */
461 #define GX_LO_EQUIV			9			/*!< ~(src ^ dst) */
462 #define GX_LO_INV			10			/*!< ~dst */
463 #define GX_LO_REVOR			11			/*!< src | ~dst */
464 #define GX_LO_INVCOPY		12			/*!< ~src */
465 #define GX_LO_INVOR			13			/*!< ~src | dst */
466 #define GX_LO_NAND			14			/*!< ~(src & dst) */
467 #define GX_LO_SET			15			/*!< 1 */
468 /*! @} */
469 
470 /*! \addtogroup texoff Texture offset value
471  * \brief Used for texturing points or lines.
472  * @{
473  */
474 #define GX_TO_ZERO			0
475 #define GX_TO_SIXTEENTH		1
476 #define GX_TO_EIGHTH		2
477 #define GX_TO_FOURTH		3
478 #define GX_TO_HALF			4
479 #define GX_TO_ONE			5
480 #define GX_MAX_TEXOFFSET	6
481 /*! @} */
482 
483 /*! \addtogroup tevdefmode TEV combiner operation
484  * \brief Color/Alpha combiner modes for GX_SetTevOp().
485  *
486  * \details For these equations, <i>Cv</i> is the output color for the stage, <i>Cr</i> is the output color of previous stage, and <i>Ct</i> is the texture color. <i>Av</i> is the output
487  * alpha for a stage, <i>Ar</i> is the output alpha of previous stage, and <i>At</i> is the texture alpha. As a special case, rasterized color
488  * (<tt>GX_CC_RASC</tt>) is used as <i>Cr</i> and rasterized alpha (<tt>GX_CA_RASA</tt>) is used as <i>Ar</i> at the first TEV stage because there is no previous stage.
489  *
490  * @{
491  */
492 
493 #define GX_MODULATE			0			/*!< <i>Cv</i>=<i>CrCt</i>; <i>Av</i>=<i>ArAt</i> */
494 #define GX_DECAL			1			/*!< <i>Cv</i>=(1-<i>At</i>)<i>Cr</i> + <i>AtCt</i>; <i>Av</i>=<i>Ar</i> */
495 #define GX_BLEND			2			/*!< <i>Cv=(1-<i>Ct</i>)<i>Cr</i> + <i>Ct</i>; <i>Av</i>=<i>AtAr</i> */
496 #define GX_REPLACE			3			/*!< <i>Cv=<i>Ct</i>; <i>Ar=<i>At</i> */
497 #define GX_PASSCLR			4			/*!< <i>Cv=<i>Cr</i>; <i>Av=<i>Ar</i> */
498 
499 /*! @} */
500 
501 /*! \addtogroup tevcolorarg TEV color combiner input
502  * @{
503  */
504 
505 #define GX_CC_CPREV			0				/*!< Use the color value from previous TEV stage */
506 #define GX_CC_APREV			1				/*!< Use the alpha value from previous TEV stage */
507 #define GX_CC_C0			2				/*!< Use the color value from the color/output register 0 */
508 #define GX_CC_A0			3				/*!< Use the alpha value from the color/output register 0 */
509 #define GX_CC_C1			4				/*!< Use the color value from the color/output register 1 */
510 #define GX_CC_A1			5				/*!< Use the alpha value from the color/output register 1 */
511 #define GX_CC_C2			6				/*!< Use the color value from the color/output register 2 */
512 #define GX_CC_A2			7				/*!< Use the alpha value from the color/output register 2 */
513 #define GX_CC_TEXC			8				/*!< Use the color value from texture */
514 #define GX_CC_TEXA			9				/*!< Use the alpha value from texture */
515 #define GX_CC_RASC			10				/*!< Use the color value from rasterizer */
516 #define GX_CC_RASA			11				/*!< Use the alpha value from rasterizer */
517 #define GX_CC_ONE			12
518 #define GX_CC_HALF			13
519 #define GX_CC_KONST			14
520 #define GX_CC_ZERO			15				/*!< Use to pass zero value */
521 
522 /*! @} */
523 
524 /*! \addtogroup tevalphaarg TEV alpha combiner input
525  * @{
526  */
527 
528 #define GX_CA_APREV			0				/*!< Use the alpha value from previous TEV stage */
529 #define GX_CA_A0			1				/*!< Use the alpha value from the color/output register 0 */
530 #define GX_CA_A1			2				/*!< Use the alpha value from the color/output register 1 */
531 #define GX_CA_A2			3				/*!< Use the alpha value from the color/output register 2 */
532 #define GX_CA_TEXA			4				/*!< Use the alpha value from texture */
533 #define GX_CA_RASA			5				/*!< Use the alpha value from rasterizer */
534 #define GX_CA_KONST			6
535 #define GX_CA_ZERO			7				/*!< Use to pass zero value */
536 
537 /*! @} */
538 
539 /*! \addtogroup tevstage TEV stage
540  * \details The GameCube's Graphics Processor (GP) can use up to 16 stages to compute a texel for a particular surface.
541  * By default, each texture will use two stages, but it can be configured through various functions calls.
542  *
543  * \note This is different from \ref texmapid s, where textures are loaded into.
544  * @{
545  */
546 
547 #define GX_TEVSTAGE0		0
548 #define GX_TEVSTAGE1		1
549 #define GX_TEVSTAGE2		2
550 #define GX_TEVSTAGE3		3
551 #define GX_TEVSTAGE4		4
552 #define GX_TEVSTAGE5		5
553 #define GX_TEVSTAGE6		6
554 #define GX_TEVSTAGE7		7
555 #define GX_TEVSTAGE8		8
556 #define GX_TEVSTAGE9		9
557 #define GX_TEVSTAGE10		10
558 #define GX_TEVSTAGE11		11
559 #define GX_TEVSTAGE12		12
560 #define GX_TEVSTAGE13		13
561 #define GX_TEVSTAGE14		14
562 #define GX_TEVSTAGE15		15
563 #define GX_MAX_TEVSTAGE		16
564 
565 /*! @} */
566 
567 /*! \addtogroup tevop TEV combiner operator
568  * @{
569  */
570 
571 #define GX_TEV_ADD				0
572 #define GX_TEV_SUB				1
573 #define GX_TEV_COMP_R8_GT		8
574 #define GX_TEV_COMP_R8_EQ		9
575 #define GX_TEV_COMP_GR16_GT		10
576 #define GX_TEV_COMP_GR16_EQ		11
577 #define GX_TEV_COMP_BGR24_GT	12
578 #define GX_TEV_COMP_BGR24_EQ	13
579 #define GX_TEV_COMP_RGB8_GT		14
580 #define GX_TEV_COMP_RGB8_EQ		15
581 #define GX_TEV_COMP_A8_GT		GX_TEV_COMP_RGB8_GT	 // for alpha channel
582 #define GX_TEV_COMP_A8_EQ		GX_TEV_COMP_RGB8_EQ  // for alpha channel
583 
584 /*! @} */
585 
586 /*! \addtogroup tevbias TEV bias value
587  * @{
588  */
589 
590 #define GX_TB_ZERO				0
591 #define GX_TB_ADDHALF			1
592 #define GX_TB_SUBHALF			2
593 #define GX_MAX_TEVBIAS			3
594 
595 /*! @} */
596 
597 /*! \addtogroup tevclampmode TEV clamping mode
598  * \note These modes are used for a function which is not implementable on production (i.e. retail) GameCube hardware.
599  * @{
600  */
601 
602 #define GX_TC_LINEAR			0
603 #define GX_TC_GE				1
604 #define GX_TC_EQ				2
605 #define GX_TC_LE				3
606 #define GX_MAX_TEVCLAMPMODE		4
607 
608 /*! @} */
609 
610 /*! \addtogroup tevscale TEV scale value
611  * @{
612  */
613 
614 #define GX_CS_SCALE_1			0
615 #define GX_CS_SCALE_2			1
616 #define GX_CS_SCALE_4			2
617 #define GX_CS_DIVIDE_2			3
618 #define GX_MAX_TEVSCALE			4
619 
620 /*! @} */
621 
622 /*! \addtogroup tevcoloutreg TEV color/output register
623  * @{
624  */
625 
626 #define GX_TEVPREV				0			/*!< Default register for passing results from one stage to another. */
627 #define GX_TEVREG0				1
628 #define GX_TEVREG1				2
629 #define GX_TEVREG2				3
630 #define GX_MAX_TEVREG			4
631 
632 /*! @} */
633 
634 /*! \addtogroup cullmode Backface culling mode
635  * @{
636  */
637 #define GX_CULL_NONE			0			/*!< Do not cull any primitives. */
638 #define GX_CULL_FRONT			1			/*!< Cull front-facing primitives. */
639 #define GX_CULL_BACK			2			/*!< Cull back-facing primitives. */
640 #define GX_CULL_ALL				3			/*!< Cull all primitives. */
641 /*! @} */
642 
643 /*! \addtogroup texmapid texture map slot
644  * \brief Texture map slots to hold textures in.
645  *
646  * \details The GameCube's Graphics Processor (GP) can apply up to eight textures to a single surface. Those textures
647  * are assigned one of these slots. Various operations used on or with a particular texture will also take one of these
648  * items, including operations regarding texture coordinate generation (although not necessarily on the same slot).
649  *
650  * \note This is different from \ref tevstage s, which are the actual quanta for work with textures.
651  * @{
652  */
653 #define GX_TEXMAP0				0			/*!< Texture map slot 0 */
654 #define GX_TEXMAP1				1			/*!< Texture map slot 1 */
655 #define GX_TEXMAP2				2			/*!< Texture map slot 2 */
656 #define GX_TEXMAP3				3			/*!< Texture map slot 3 */
657 #define GX_TEXMAP4				4			/*!< Texture map slot 4 */
658 #define GX_TEXMAP5				5			/*!< Texture map slot 5 */
659 #define GX_TEXMAP6				6			/*!< Texture map slot 6 */
660 #define GX_TEXMAP7				7			/*!< Texture map slot 7 */
661 #define GX_MAX_TEXMAP			8
662 #define GX_TEXMAP_NULL			0xff			/*!< No texmap */
663 #define GX_TEXMAP_DISABLE		0x100			/*!< Disable texmap lookup for this texmap slot (use bitwise OR with a texture map slot). */
664 /*! @} */
665 
666 /*! \addtogroup alphaop Alpha combine control
667  * @{
668  */
669 #define GX_AOP_AND				0
670 #define GX_AOP_OR				1
671 #define GX_AOP_XOR				2
672 #define GX_AOP_XNOR				3
673 #define GX_MAX_ALPHAOP			4
674 /*! @} */
675 
676 /*! \addtogroup tevkcolorid TEV constant color register
677  * @{
678  */
679 #define GX_KCOLOR0				0			/*!< Constant register 0 */
680 #define GX_KCOLOR1				1			/*!< Constant register 1 */
681 #define GX_KCOLOR2				2			/*!< Constant register 2 */
682 #define GX_KCOLOR3				3			/*!< Constant register 3 */
683 #define GX_KCOLOR_MAX			4
684 /*! @} */
685 
686 /*! \addtogroup tevkcolorsel TEV constant color selection
687  * @{
688  */
689 #define GX_TEV_KCSEL_1					0x00			/*!< constant 1.0 */
690 #define GX_TEV_KCSEL_7_8				0x01			/*!< constant 7/8 */
691 #define GX_TEV_KCSEL_3_4				0x02			/*!< constant 3/4 */
692 #define GX_TEV_KCSEL_5_8				0x03			/*!< constant 5/8 */
693 #define GX_TEV_KCSEL_1_2				0x04			/*!< constant 1/2 */
694 #define GX_TEV_KCSEL_3_8				0x05			/*!< constant 3/8 */
695 #define GX_TEV_KCSEL_1_4				0x06			/*!< constant 1/4 */
696 #define GX_TEV_KCSEL_1_8				0x07			/*!< constant 1/8 */
697 #define GX_TEV_KCSEL_K0					0x0C			/*!< K0[RGB] register */
698 #define GX_TEV_KCSEL_K1					0x0D			/*!< K1[RGB] register */
699 #define GX_TEV_KCSEL_K2					0x0E			/*!< K2[RGB] register */
700 #define GX_TEV_KCSEL_K3					0x0F			/*!< K3[RGB] register */
701 #define GX_TEV_KCSEL_K0_R				0x10			/*!< K0[RRR] register */
702 #define GX_TEV_KCSEL_K1_R				0x11			/*!< K1[RRR] register */
703 #define GX_TEV_KCSEL_K2_R				0x12			/*!< K2[RRR] register */
704 #define GX_TEV_KCSEL_K3_R				0x13			/*!< K3[RRR] register */
705 #define GX_TEV_KCSEL_K0_G				0x14			/*!< K0[GGG] register */
706 #define GX_TEV_KCSEL_K1_G				0x15			/*!< K1[GGG] register */
707 #define GX_TEV_KCSEL_K2_G				0x16			/*!< K2[GGG] register */
708 #define GX_TEV_KCSEL_K3_G				0x17			/*!< K3[GGG] register */
709 #define GX_TEV_KCSEL_K0_B				0x18			/*!< K0[BBB] register */
710 #define GX_TEV_KCSEL_K1_B				0x19			/*!< K1[BBB] register */
711 #define GX_TEV_KCSEL_K2_B				0x1A			/*!< K2[BBB] register */
712 #define GX_TEV_KCSEL_K3_B				0x1B			/*!< K3[RBB] register */
713 #define GX_TEV_KCSEL_K0_A				0x1C			/*!< K0[AAA] register */
714 #define GX_TEV_KCSEL_K1_A				0x1D			/*!< K1[AAA] register */
715 #define GX_TEV_KCSEL_K2_A				0x1E			/*!< K2[AAA] register */
716 #define GX_TEV_KCSEL_K3_A				0x1F			/*!< K3[AAA] register */
717 /*! @} */
718 
719 /*! \addtogroup tevkalphasel TEV constant alpha selection
720  * @{
721  */
722 #define GX_TEV_KASEL_1					0x00			/*!< constant 1.0 */
723 #define GX_TEV_KASEL_7_8				0x01			/*!< constant 7/8 */
724 #define GX_TEV_KASEL_3_4				0x02			/*!< constant 3/4 */
725 #define GX_TEV_KASEL_5_8				0x03			/*!< constant 5/8 */
726 #define GX_TEV_KASEL_1_2				0x04			/*!< constant 1/2 */
727 #define GX_TEV_KASEL_3_8				0x05			/*!< constant 3/8 */
728 #define GX_TEV_KASEL_1_4				0x06			/*!< constant 1/4 */
729 #define GX_TEV_KASEL_1_8				0x07			/*!< constant 1/8 */
730 #define GX_TEV_KASEL_K0_R				0x10			/*!< K0[R] register */
731 #define GX_TEV_KASEL_K1_R				0x11			/*!< K1[R] register */
732 #define GX_TEV_KASEL_K2_R				0x12			/*!< K2[R] register */
733 #define GX_TEV_KASEL_K3_R				0x13			/*!< K3[R] register */
734 #define GX_TEV_KASEL_K0_G				0x14			/*!< K0[G] register */
735 #define GX_TEV_KASEL_K1_G				0x15			/*!< K1[G] register */
736 #define GX_TEV_KASEL_K2_G				0x16			/*!< K2[G] register */
737 #define GX_TEV_KASEL_K3_G				0x17			/*!< K3[G] register */
738 #define GX_TEV_KASEL_K0_B				0x18			/*!< K0[B] register */
739 #define GX_TEV_KASEL_K1_B				0x19			/*!< K1[B] register */
740 #define GX_TEV_KASEL_K2_B				0x1A			/*!< K2[B] register */
741 #define GX_TEV_KASEL_K3_B				0x1B			/*!< K3[B] register */
742 #define GX_TEV_KASEL_K0_A				0x1C			/*!< K0[A] register */
743 #define GX_TEV_KASEL_K1_A				0x1D			/*!< K1[A] register */
744 #define GX_TEV_KASEL_K2_A				0x1E			/*!< K2[A] register */
745 #define GX_TEV_KASEL_K3_A				0x1F			/*!< K3[A] register */
746 /*! @} */
747 
748 /*! \addtogroup tevswapsel TEV color swap table entry
749  * @{
750  */
751 
752 #define GX_TEV_SWAP0					0
753 #define GX_TEV_SWAP1					1
754 #define GX_TEV_SWAP2					2
755 #define GX_TEV_SWAP3					3
756 #define GX_MAX_TEVSWAP					4
757 
758 /*! @} */
759 
760 /* tev color chan */
761 #define GX_CH_RED						0
762 #define GX_CH_GREEN						1
763 #define GX_CH_BLUE						2
764 #define GX_CH_ALPHA						3
765 
766 /*! \addtogroup indtexstage Indirect texture stage
767  * @{
768  */
769 #define GX_INDTEXSTAGE0					0
770 #define GX_INDTEXSTAGE1					1
771 #define GX_INDTEXSTAGE2					2
772 #define GX_INDTEXSTAGE3					3
773 #define GX_MAX_INDTEXSTAGE				4
774 /*! @} */
775 
776 /*! \addtogroup indtexformat Indirect texture format
777  * \details Bits for the indirect offsets are extracted from the high end of each component byte. Bits for the bump alpha
778  * are extraced off the low end of the byte. For <tt>GX_ITF_8</tt>, the byte is duplicated for the offset and the bump alpha.
779  * @{
780  */
781 #define GX_ITF_8						0
782 #define GX_ITF_5						1
783 #define GX_ITF_4						2
784 #define GX_ITF_3						3
785 #define GX_MAX_ITFORMAT					4
786 /*! @} */
787 
788 /*! \addtogroup indtexbias Indirect texture bias select
789  * \brief Indicates which components of the indirect offset should receive a bias value.
790  *
791  * \details The bias is fixed at -128 for <tt>GX_ITF_8</tt> and +1 for the other formats. The bias happens prior to the indirect matrix multiply.
792  * @{
793  */
794 #define GX_ITB_NONE						0
795 #define GX_ITB_S						1
796 #define GX_ITB_T						2
797 #define GX_ITB_ST						3
798 #define GX_ITB_U						4
799 #define GX_ITB_SU						5
800 #define GX_ITB_TU						6
801 #define GX_ITB_STU						7
802 #define GX_MAX_ITBIAS					8
803 /*! @} */
804 
805 /*! \addtogroup indtexmtx Indirect texture matrix
806  * @{
807  */
808 #define GX_ITM_OFF						0			/*!< Specifies a matrix of all zeroes. */
809 #define GX_ITM_0						1			/*!< Specifies indirect matrix 0, indirect scale 0. */
810 #define GX_ITM_1						2			/*!< Specifies indirect matrix 1, indirect scale 1. */
811 #define GX_ITM_2						3			/*!< Specifies indirect matrix 2, indirect scale 2. */
812 #define GX_ITM_S0						5			/*!< Specifies dynamic S-type matrix, indirect scale 0. */
813 #define GX_ITM_S1						6			/*!< Specifies dynamic S-type matrix, indirect scale 1. */
814 #define GX_ITM_S2						7			/*!< Specifies dynamic S-type matrix, indirect scale 2. */
815 #define GX_ITM_T0						9			/*!< Specifies dynamic T-type matrix, indirect scale 0. */
816 #define GX_ITM_T1						10			/*!< Specifies dynamic T-type matrix, indirect scale 1. */
817 #define GX_ITM_T2						11			/*!< Specifies dynamic T-type matrix, indirect scale 2. */
818 /*! @} */
819 
820 /*! \addtogroup indtexwrap Indirect texture wrap value
821  * \brief Indicates whether the regular texture coordinate should be wrapped before being added to the offset.
822  *
823  * \details <tt>GX_ITW_OFF</tt> specifies no wrapping. <tt>GX_ITW_0</tt> will zero out the regular texture coordinate.
824  * @{
825  */
826 #define GX_ITW_OFF						0
827 #define GX_ITW_256						1
828 #define GX_ITW_128						2
829 #define GX_ITW_64						3
830 #define GX_ITW_32						4
831 #define GX_ITW_16						5
832 #define GX_ITW_0						6
833 #define GX_MAX_ITWRAP					7
834 /*! @} */
835 
836 /*! \addtogroup indtexalphasel Indirect texture bump alpha select
837  * \brief Indicates which offset component should provide the "bump" alpha output for the given TEV stage.
838  *
839  * \note Bump alpha is not available for TEV stage 0.
840  * @{
841  */
842 #define GX_ITBA_OFF						0
843 #define GX_ITBA_S						1
844 #define GX_ITBA_T						2
845 #define GX_ITBA_U						3
846 #define GX_MAX_ITBALPHA					4
847 /*! @} */
848 
849 /*! \addtogroup indtexscale Indirect texture scale
850  * \brief Specifies an additional scale value that may be applied to the texcoord used for an indirect initial lookup (not a TEV stage regular lookup).
851  *
852  * \details The scale value is a fraction; thus <tt>GX_ITS_32</tt> means to divide the texture coordinate values by 32.
853  * @{
854  */
855 #define GX_ITS_1						0
856 #define GX_ITS_2						1
857 #define GX_ITS_4						2
858 #define GX_ITS_8						3
859 #define GX_ITS_16						4
860 #define GX_ITS_32						5
861 #define GX_ITS_64						6
862 #define GX_ITS_128						7
863 #define GX_ITS_256						8
864 #define GX_MAX_ITSCALE					9
865 /*! @} */
866 
867 /*! \addtogroup fogtype Fog equation control
868  * @{
869  */
870 #define GX_FOG_NONE						0
871 
872 #define GX_FOG_PERSP_LIN				2
873 #define GX_FOG_PERSP_EXP				4
874 #define GX_FOG_PERSP_EXP2				5
875 #define GX_FOG_PERSP_REVEXP				6
876 #define GX_FOG_PERSP_REVEXP2			7
877 
878 #define GX_FOG_ORTHO_LIN				10
879 #define GX_FOG_ORTHO_EXP				12
880 #define GX_FOG_ORTHO_EXP2				13
881 #define GX_FOG_ORTHO_REVEXP				14
882 #define GX_FOG_ORTHO_REVEXP2			15
883 
884 #define GX_FOG_LIN						GX_FOG_PERSP_LIN
885 #define GX_FOG_EXP						GX_FOG_PERSP_EXP
886 #define GX_FOG_EXP2						GX_FOG_PERSP_EXP2
887 #define GX_FOG_REVEXP  					GX_FOG_PERSP_REVEXP
888 #define GX_FOG_REVEXP2 					GX_FOG_PERSP_REVEXP2
889 /*! @} */
890 
891 /* pixel format */
892 #define GX_PF_RGB8_Z24					0
893 #define GX_PF_RGBA6_Z24					1
894 #define GX_PF_RGB565_Z16				2
895 #define GX_PF_Z24						3
896 #define GX_PF_Y8						4
897 #define GX_PF_U8						5
898 #define GX_PF_V8						6
899 #define GX_PF_YUV420					7
900 
901 /*! \addtogroup zfmt Compressed Z format
902  * @{
903  */
904 #define GX_ZC_LINEAR					0
905 #define GX_ZC_NEAR						1
906 #define GX_ZC_MID						2
907 #define GX_ZC_FAR						3
908 /*! @} */
909 
910 /*! \addtogroup xfbclamp XFB clamp modes
911  * @{
912  */
913 
914 #define GX_CLAMP_NONE					0
915 #define GX_CLAMP_TOP					1
916 #define GX_CLAMP_BOTTOM					2
917 
918 /*! @} */
919 
920 /*! \addtogroup gammamode Gamma values
921  * @{
922  */
923 
924 #define GX_GM_1_0						0
925 #define GX_GM_1_7						1
926 #define GX_GM_2_2						2
927 
928 /*! @} */
929 
930 /*! \addtogroup copymode EFB copy mode
931  * \brief Controls whether all lines, only even lines, or only odd lines are copied from the EFB.
932  * @{
933  */
934 #define GX_COPY_PROGRESSIVE				0
935 #define GX_COPY_INTLC_EVEN				2
936 #define GX_COPY_INTLC_ODD				3
937 /*! @} */
938 
939 /*! \addtogroup alphareadmode Alpha read mode
940  * @{
941  */
942 #define GX_READ_00						0			/*!< Always read 0x00. */
943 #define GX_READ_FF						1			/*!< Always read 0xFF. */
944 #define GX_READ_NONE					2			/*!< Always read the real alpha value. */
945 /*! @} */
946 
947 /*! \addtogroup texcachesize Texture cache size
948  * \brief Size of texture cache regions.
949  * @{
950  */
951 #define GX_TEXCACHE_32K					0
952 #define GX_TEXCACHE_128K				1
953 #define GX_TEXCACHE_512K				2
954 #define GX_TEXCACHE_NONE				3
955 /*! @} */
956 
957 /*! \addtogroup distattnfn Brightness decreasing function
958  * \brief Type of the brightness decreasing function by distance.
959  * @{
960  */
961 #define GX_DA_OFF						0
962 #define GX_DA_GENTLE					1
963 #define GX_DA_MEDIUM					2
964 #define GX_DA_STEEP						3
965 /*! @} */
966 
967 /*! \addtogroup spotfn Spot illumination distribution function
968  * @{
969  */
970 #define GX_SP_OFF						0
971 #define GX_SP_FLAT						1
972 #define GX_SP_COS						2
973 #define GX_SP_COS2						3
974 #define GX_SP_SHARP						4
975 #define GX_SP_RING1						5
976 #define GX_SP_RING2						6
977 /*! @} */
978 
979 /*! \addtogroup texfilter Texture filter types
980  * @{
981  */
982 #define GX_NEAR							0			/*!< Point sampling, no mipmap */
983 #define GX_LINEAR						1			/*!< Bilinear filtering, no mipmap */
984 #define GX_NEAR_MIP_NEAR				2			/*!< Point sampling, discrete mipmap */
985 #define GX_LIN_MIP_NEAR					3			/*!< Bilinear filtering, discrete mipmap */
986 #define GX_NEAR_MIP_LIN					4			/*!< Point sampling, linear mipmap */
987 #define GX_LIN_MIP_LIN					5			/*!< Trilinear filtering */
988 /*! @} */
989 
990 /*! \addtogroup anisotropy Maximum anisotropy filter control
991  * @{
992  */
993 #define GX_ANISO_1						0
994 #define GX_ANISO_2						1
995 #define GX_ANISO_4						2
996 #define GX_MAX_ANISOTROPY				3
997 /*! @} */
998 
999 /*! \addtogroup vcachemetrics Vertex cache performance counter
1000  * @{
1001  */
1002 #define GX_VC_POS						0
1003 #define GX_VC_NRM						1
1004 #define GX_VC_CLR0						2
1005 #define GX_VC_CLR1						3
1006 #define GX_VC_TEX0						4
1007 #define GX_VC_TEX1						5
1008 #define GX_VC_TEX2						6
1009 #define GX_VC_TEX3						7
1010 #define GX_VC_TEX4						8
1011 #define GX_VC_TEX5						9
1012 #define GX_VC_TEX6						10
1013 #define GX_VC_TEX7						11
1014 #define GX_VC_ALL						15
1015 /*! @} */
1016 
1017 /*! \addtogroup perf0metrics Performance counter 0 metric
1018  * \details Performance counter 0 is used to measure attributes dealing with geometry and primitives, such as triangle counts and clipping ratios.
1019  *
1020  * \note <tt>GX_PERF0_XF_*</tt> measure how many GP cycles are spent in each stage of the XF.<br><br>
1021  *
1022  * \note The triangle metrics (<tt>GX_PERF0_TRIANGLES_*</tt>) allow counting triangles under specific conditions or with specific attributes.<br><br>
1023  *
1024  * \note <tt>GX_PERF0_TRIANGLES_*TEX</tt> count triangles based on the number of texture coordinates supplied; <tt>GX_PERF0_TRIANGLES_*CLR</tt> count
1025  * triangles based on the number of colors supplied.<br><br>
1026  *
1027  * \note The quad metrics allow you to count the number of quads (2x2 pixels) the GP processes. The term <i>coverage</i> is used to indicate how many
1028  * pixels in the quad are actually part of the triangle being rasterized. For example, a coverage of 4 means all pixels in the quad intersect the
1029  * triangle. A coverage of 1 indicates that only 1 pixel in the quad intersected the triangle.
1030  * @{
1031  */
1032 #define GX_PERF0_VERTICES				0			/*!< Number of vertices processed by the GP. */
1033 #define GX_PERF0_CLIP_VTX				1			/*!< Number of vertices that were clipped by the GP. */
1034 #define GX_PERF0_CLIP_CLKS				2			/*!< Number of GP clocks spent clipping. */
1035 #define GX_PERF0_XF_WAIT_IN				3			/*!< Number of cycles the XF is waiting on input. If the XF is waiting a large percentage
1036 													* of the total time, it may indicate that the CPU is not supplying data fast enough to
1037 													* keep the GP busy. */
1038 #define GX_PERF0_XF_WAIT_OUT			4			/*!< Number of cycles the XF waits to send its output to the rest of the GP pipeline. If
1039 													* the XF cannot output, it may indicate that the GP is currently fill-rate limited. */
1040 #define GX_PERF0_XF_XFRM_CLKS			5			/*!< Number of cycles the transform engine is busy. */
1041 #define GX_PERF0_XF_LIT_CLKS			6			/*!< Number of cycles the lighting engine is busy. */
1042 #define GX_PERF0_XF_BOT_CLKS			7			/*!< Number of cycles the bottom of the pipe (result combiner) is busy. */
1043 #define GX_PERF0_XF_REGLD_CLKS			8			/*!< Number of cycles are spent loading XF state registers. */
1044 #define GX_PERF0_XF_REGRD_CLKS			9			/*!< Number of cycles the XF reads the state registers. */
1045 #define GX_PERF0_CLIP_RATIO				10
1046 #define GX_PERF0_TRIANGLES				11			/*!< Number of triangles. */
1047 #define GX_PERF0_TRIANGLES_CULLED		12			/*!< Number of triangles that <i>failed</i> the front-face/back-face culling test. */
1048 #define GX_PERF0_TRIANGLES_PASSED		13			/*!< Number of triangles that <i>passed</i> the front-face/back-face culling test. */
1049 #define GX_PERF0_TRIANGLES_SCISSORED	14			/*!< Number of triangles that are scissored. */
1050 #define GX_PERF0_TRIANGLES_0TEX			15
1051 #define GX_PERF0_TRIANGLES_1TEX			16
1052 #define GX_PERF0_TRIANGLES_2TEX			17
1053 #define GX_PERF0_TRIANGLES_3TEX			18
1054 #define GX_PERF0_TRIANGLES_4TEX			19
1055 #define GX_PERF0_TRIANGLES_5TEX			20
1056 #define GX_PERF0_TRIANGLES_6TEX			21
1057 #define GX_PERF0_TRIANGLES_7TEX			22
1058 #define GX_PERF0_TRIANGLES_8TEX			23
1059 #define GX_PERF0_TRIANGLES_0CLR			24
1060 #define GX_PERF0_TRIANGLES_1CLR			25
1061 #define GX_PERF0_TRIANGLES_2CLR			26
1062 #define GX_PERF0_QUAD_0CVG				27			/*!< Number of quads having zero coverage. */
1063 #define GX_PERF0_QUAD_NON0CVG			28			/*!< Number of quads having coverage greater than zero. */
1064 #define GX_PERF0_QUAD_1CVG				29			/*!< Number of quads with 1 pixel coverage. */
1065 #define GX_PERF0_QUAD_2CVG				30			/*!< Number of quads with 2 pixel coverage. */
1066 #define GX_PERF0_QUAD_3CVG				31			/*!< Number of quads with 3 pixel coverage. */
1067 #define GX_PERF0_QUAD_4CVG				32			/*!< Number of quads with 4 pixel coverage. */
1068 #define GX_PERF0_AVG_QUAD_CNT			33			/*!< Average quad count; average based on what is unknown */
1069 #define GX_PERF0_CLOCKS					34			/*!< Number of GP clocks that have elapsed since the previous call to GX_ReadGP0Metric(). */
1070 #define GX_PERF0_NONE					35			/*!< Disables performance measurement for perf0 and resets the counter. */
1071 /*! @} */
1072 
1073 /*! \addtogroup perf1metrics Performance counter 1 metric
1074  * \details Performance counter 1 is used for measuring texturing and caching performance as well as FIFO performance.
1075  *
1076  * \note <tt>GX_PERF1_TC_*</tt> can be used to compute the texture cache (TC) miss rate. The <tt>TC_CHECK*</tt> parameters count how many texture cache lines are
1077  * accessed for each pixel. In the worst case, for a mipmap, up to 8 cache lines may be accessed to produce one textured pixel.
1078  * <tt>GX_PERF1_TC_MISS</tt> counts how many of those accesses missed the texture cache. To compute the miss rate, divide <tt>GX_PERF1_TC_MISS</tt> by the sum of all four
1079  * <tt>GX_PERF1_TC_CHECK*</tt> values.<br><br>
1080  *
1081  * \note <tt>GX_PERF1_VC_*</tt> count different vertex cache stall conditions.
1082  * @{
1083  */
1084 #define GX_PERF1_TEXELS					0			/*!< Number of texels processed by the GP. */
1085 #define GX_PERF1_TX_IDLE				1			/*!< Number of clocks that the texture unit (TX) is idle. */
1086 #define GX_PERF1_TX_REGS				2			/*!< Number of GP clocks spent writing to state registers in the TX unit. */
1087 #define GX_PERF1_TX_MEMSTALL			3			/*!< Number of GP clocks the TX unit is stalled waiting for main memory. */
1088 #define GX_PERF1_TC_CHECK1_2			4
1089 #define GX_PERF1_TC_CHECK3_4			5
1090 #define GX_PERF1_TC_CHECK5_6			6
1091 #define GX_PERF1_TC_CHECK7_8			7
1092 #define GX_PERF1_TC_MISS				8			/*!< Number of texture cache misses in total? */
1093 #define GX_PERF1_VC_ELEMQ_FULL			9
1094 #define GX_PERF1_VC_MISSQ_FULL			10
1095 #define GX_PERF1_VC_MEMREQ_FULL			11
1096 #define GX_PERF1_VC_STATUS7				12
1097 #define GX_PERF1_VC_MISSREP_FULL		13
1098 #define GX_PERF1_VC_STREAMBUF_LOW		14
1099 #define GX_PERF1_VC_ALL_STALLS			15
1100 #define GX_PERF1_VERTICES				16			/*!< Number of vertices processed by the GP. */
1101 #define GX_PERF1_FIFO_REQ				17			/*!< Number of lines (32B) read from the GP FIFO. */
1102 #define GX_PERF1_CALL_REQ				18			/*!< Number of lines (32B) read from called display lists. */
1103 #define GX_PERF1_VC_MISS_REQ			19			/*!< Number vertex cache miss request. Each miss requests a 32B transfer from main memory. */
1104 #define GX_PERF1_CP_ALL_REQ				20			/*!< Counts all requests (32B/request) from the GP Command Processor (CP). It should be equal to
1105 													* the sum of counts returned by <tt>GX_PERF1_FIFO_REQ</tt>, <tt>GX_PERF1_CALL_REQ</tt>, and <tt>GX_PERF1_VC_MISS_REQ</tt>. */
1106 #define GX_PERF1_CLOCKS					21			/*!< Number of GP clocks that have elapsed since the last call to GX_ReadGP1Metric(). */
1107 #define GX_PERF1_NONE					22			/*!< Disables performance measurement for perf1 and resets the counter. */
1108 /*! @} */
1109 
1110 /*! \addtogroup tlutname TLUT name
1111  * \brief Name of Texture Look-Up Table (TLUT) in texture memory.
1112  *
1113  * \details Each table <tt>GX_TLUT0</tt>-<tt>GX_TLUT15</tt> contains 256 entries,16b per entry. <tt>GX_BIGTLUT0</tt>-<tt>3</tt>
1114  * contains 1024 entries, 16b per entry. Used for configuring texture memory in GX_Init().
1115  * @{
1116  */
1117 #define GX_TLUT0						 0
1118 #define GX_TLUT1						 1
1119 #define GX_TLUT2						 2
1120 #define GX_TLUT3						 3
1121 #define GX_TLUT4						 4
1122 #define GX_TLUT5						 5
1123 #define GX_TLUT6						 6
1124 #define GX_TLUT7						 7
1125 #define GX_TLUT8						 8
1126 #define GX_TLUT9						 9
1127 #define GX_TLUT10						10
1128 #define GX_TLUT11						11
1129 #define GX_TLUT12						12
1130 #define GX_TLUT13						13
1131 #define GX_TLUT14						14
1132 #define GX_TLUT15						15
1133 #define GX_BIGTLUT0						16
1134 #define GX_BIGTLUT1						17
1135 #define GX_BIGTLUT2						18
1136 #define GX_BIGTLUT3						19
1137 /*! @} */
1138 
1139 #define GX_MAX_VTXDESC					GX_VA_MAXATTR
1140 #define GX_MAX_VTXDESC_LISTSIZE			(GX_VA_MAXATTR+1)
1141 
1142 #define GX_MAX_VTXATTRFMT				GX_VA_MAXATTR
1143 #define GX_MAX_VTXATTRFMT_LISTSIZE		(GX_VA_MAXATTR+1)
1144 
1145 #define GX_MAX_Z24						0x00ffffff
1146 
1147 #ifdef __cplusplus
1148    extern "C" {
1149 #endif /* __cplusplus */
1150 
1151 typedef union _wgpipe
1152 {
1153 	vu8 U8;
1154 	vs8 S8;
1155 	vu16 U16;
1156 	vs16 S16;
1157 	vu32 U32;
1158 	vs32 S32;
1159 	vf32 F32;
1160 } WGPipe;
1161 
1162 /*! \typedef struct _gx_color GXColor
1163  * \brief Structure used to pass colors to some GX functions.
1164  */
1165 typedef struct _gx_color {
1166  	u8 r;			/*!< Red color component. */
1167  	u8 g;			/*!< Green color component. */
1168  	u8 b;			/*!< Blue alpha component. */
1169 	u8 a;			/*!< Alpha component. If a function does not use the alpha value, it is safely ignored. */
1170 } GXColor;
1171 
1172 /*! \typedef struct _gx_colors10 GXColorS10
1173  * \brief Structure used to pass signed 10-bit colors to some GX functions.
1174  */
1175 typedef struct _gx_colors10 {
1176  	s16 r;			/*!< Red color component. */
1177  	s16 g;			/*!< Green color component. */
1178  	s16 b;			/*!< Blue color component. */
1179 	s16 a;			/*!< Alpha component. If a function does not use the alpha value, it is safely ignored. */
1180 } GXColorS10;
1181 
1182 /*! \typedef struct _gx_texobj GXTexObj
1183  * \brief Object containing information about a texture.
1184  *
1185  * \details This structure contains precompiled register state setting commands and data. The application must use the GX_InitTexObj*()
1186  * function to initialize or change this object. The proper size of the object is returned by
1187  *
1188  * \code sizeof(GXTexObj) \endcode
1189  *
1190  * \details but the internal data representation is not visible to the application.
1191  */
1192 typedef struct _gx_texobj {
1193 	u32 val[8];
1194 } GXTexObj;
1195 
1196 /*! \typedef struct _gx_tlutobj GXTlutObj
1197  * \brief Object containing information on a TLUT.
1198  *
1199  * \details This structure contains precompiled register state setting commands and data. The application must use the GX_InitTlutObj()
1200  * function to initialize or change this object. The proper size of the object is returned by
1201  *
1202  * \code sizeof(GXTlutObj) \endcode
1203  *
1204  * \details but the internal data representation is not visible to the application.
1205  */
1206 typedef struct _gx_tlutobj {
1207 	u32 val[3];
1208 } GXTlutObj;
1209 
1210 /*! \typedef struct _gx_texreg GXTexRegion
1211  * \brief Object containing information on a texture cache region.
1212  *
1213  * \details This structure contains precompiled register state setting commands and data. The application must use the
1214  * GX_InitTexCacheRegion() function to initialize or change this object. The proper size of the object is returned by
1215  *
1216  * \code sizeof(GXTexRegion) \endcode
1217  *
1218  * \details but the internal data representation is not visible to the application.
1219  */
1220 typedef struct _gx_texreg {
1221 	u32 val[4];
1222 } GXTexRegion;
1223 
1224 /*! \typedef struct _gx_tlutreg GXTlutRegion
1225  * \brief Object containing information on a TLUT cache region.
1226  *
1227  * \details This structure contains precompiled register state setting commands and data. The application must use the GX_InitTlutRegion()
1228  * function to initialize or change this object. The proper size of the object is returned by
1229  *
1230  * \code sizeof(GXTlutRegion) \endcode
1231  *
1232  * \details but the internal data representation is not visible to the application.
1233  */
1234 typedef struct _gx_tlutreg {
1235 	u32 val[4];
1236 } GXTlutRegion;
1237 
1238 /*! \typedef _gx_litobj GXLightObj
1239  * \brief Object containing information on a light.
1240  *
1241  * \details This structure contains precompiled register state setting commands and data. The application must use the GX_InitLight*() functions
1242  * to initialize or change this object. The proper size of the object is returned by
1243  *
1244  * \code sizeof(GXLightObj) \endcode
1245  *
1246  * \details but the internal data representation is not visible to the application.
1247  */
1248 typedef struct _gx_litobj {
1249 	u32 val[16];
1250 } GXLightObj;
1251 
1252 typedef struct _vtx {
1253 	f32 x,y,z;
1254 	u16 s,t;
1255 	u32 rgba;
1256 } Vtx;
1257 
1258 /*! \struct GXVtxDesc
1259  * \brief Structure describing how a single vertex attribute will be referenced.
1260  *
1261  * \details An array of these structures can be used to describe all the attributes in a vertex. The attribute <tt>GX_VA_NULL</tt> should be
1262  * used to mark the end of the array.
1263  */
1264 typedef struct {
1265 	u8 attr;			/*!< \ref vtxattr for this element. */
1266 	u8 type;			/*!< \ref vtxattrin for this element. */
1267 } GXVtxDesc;
1268 
1269 /*! \struct GXVtxAttrFmt
1270  * \brief Structure describing the attribute format for one attribute.
1271  *
1272  * \details An array of these structures can be used to describe the format of all attributes in a vertex. The attribute <tt>GX_VA_NULL</tt>
1273  * should be used to mark the end of the array.
1274  */
1275 typedef struct {
1276 	u32 vtxattr;			/*!< \ref vtxattr for this element. */
1277 	u32 comptype;			/*!< \ref comptype for this element. */
1278 	u32 compsize;			/*!< \ref compsize for this element. */
1279 	u32 frac;				/*!< Number of fractional bits for a fixed-point number. */
1280 } GXVtxAttrFmt;
1281 
1282 /*! \struct GXFifoObj
1283  * \brief Object describing a graphics FIFO.
1284  *
1285  * \details This structure contains precompiled register state setting commands and data. The application must use the GX_InitFifo*() functions
1286  * to initialize or change this object. The proper size of the object is returned by
1287  *
1288  * \code sizeof(GXFifoObj) \endcode
1289  *
1290  * but the internal data representation is not visible to the application.
1291  */
1292 typedef struct {
1293 	u8 pad[GX_FIFO_OBJSIZE];
1294 } GXFifoObj;
1295 
1296 typedef struct {
1297 	u8 dummy[4];
1298 } GXTexReg;
1299 
1300 /*! \struct GXFogAdjTbl
1301  * \brief Fog range adjustment parameter table.
1302  */
1303 typedef struct {
1304 	u16 r[10];			/*!< u4.8 format range parameter. */
1305 } GXFogAdjTbl;
1306 
1307 /*! \typedef void (*GXBreakPtCallback)(void)
1308  * \brief function pointer typedef for the GP breakpoint-token callback
1309  */
1310 typedef void (*GXBreakPtCallback)(void);
1311 
1312 /*! \typedef void (*GXDrawDoneCallback)(void)
1313  * \brief function pointer typedef for the GP drawdone-token callback
1314  */
1315 typedef void (*GXDrawDoneCallback)(void);
1316 
1317 /*! \typedef void (*GXDrawSyncCallback)(u16 token)
1318  * \brief function pointer typedef for the drawsync-token callback
1319  * \param[out] token tokenvalue most recently encountered.
1320  */
1321 typedef void (*GXDrawSyncCallback)(u16 token);
1322 
1323 /*! \typedef GXTexRegion* (*GXTexRegionCallback)(GXTexObj *obj,u8 mapid)
1324  * \brief function pointer typedef for the texture region callback
1325  * \param[out] token tokenvalue most recently encountered.
1326  */
1327 typedef GXTexRegion* (*GXTexRegionCallback)(GXTexObj *obj,u8 mapid);
1328 
1329 /*! \typedef GXTlutRegion* (*GXTlutRegionCallback)(u32 tlut_name)
1330  * \brief function pointer typedef for the TLUT region callback
1331  * \param[out] token tokenvalue most recently encountered.
1332  */
1333 typedef GXTlutRegion* (*GXTlutRegionCallback)(u32 tlut_name);
1334 
1335 extern WGPipe* const wgPipe;
1336 /*!
1337  * \fn GXFifoObj* GX_Init(void *base,u32 size)
1338  * \brief Initializes the graphics processor to its initial state.
1339  *
1340  * \details This function sets the default state of the graphics processor and should be called before any other GX functions.
1341  * This function sets up an immediate-mode method of communicating graphics commands from the CPU to the Graphics Processor
1342  * (GP). This function will initialize a FIFO and attach it to both the CPU and GP. The CPU will write commands to the FIFO
1343  * and the GP will read the commands. This function returns a pointer to the initialized FIFO. The application must allocate
1344  * the memory for the FIFO. The parameter \a base is a pointer to the allocated main memory and must be aligned to 32B. \a size
1345  * is the size of the FIFO in bytes and must be a multiple of 32B. Refer to additional notes in GX_InitFifoBase() concerning
1346  * the FIFO memory.
1347  *
1348  * \note It is also possible to override the default immediate-mode style and instead buffer the graphics for frame <i>n+1</i>
1349  * while the GP is reading the graphics for frame <i>n</i>. See GX_SetCPUFifo() and GX_SetGPFifo() for further information.<br><br>
1350  *
1351  * \note This function also designates the calling thread as the default GX thread; i.e., it assumes the calling thread is the
1352  * one responsible for generating graphics data. This thread will be the thread to be suspended when the FIFO gets too full.
1353  * The current GX thread can be changed by calling GX_SetCurrentGXThread().
1354  *
1355  * \param[in] base pointer to the GX FIFO buffer base address. Must be aligned on a 32 Byte boundery.
1356  * \param[in] size size of buffer. Must be a multiple of 32.
1357  *
1358  * \return pointer to the intialized GXFifoObj object.
1359  */
1360 GXFifoObj* GX_Init(void *base,u32 size);
1361 
1362 /*!
1363  * \fn void GX_InitFifoBase(GXFifoObj *fifo,void *base,u32 size)
1364  * \brief Describes the area of main memory that will be used for this \a fifo.
1365  *
1366  * The Graphics FIFO is the mechanism used to communicate graphics commands from the CPU to the Graphics Processor (GP). The FIFO
1367  * base pointer should be 32-byte aligned. memalign() can return 32-byte aligned pointers. The size should also be a multiple of
1368  * 32B.
1369  *
1370  * The CPU's write-gather pipe is used to write data to the FIFO. Therefore, the FIFO memory area must be forced out of the CPU
1371  * cache prior to being used. DCInvalidateRange() may be used for this purpose. Due to the mechanics of flushing the write-gather
1372  * pipe, the FIFO memory area should be at least 32 bytes larger than the maximum expected amount of data stored. Up to 32 NOPs
1373  * may be written at the end during flushing.
1374  *
1375  * \note GX_Init() also takes the arguments \a base and \a size and initializes a FIFO using these values and attaches the FIFO
1376  * to both the CPU and GP. The application must allocate the memory for the graphics FIFO before calling GX_Init(). Therefore, it
1377  * is not necessary to call this function unless you want to resize the default FIFO sometime after GX_Init() has been called or
1378  * you are creating a new FIFO. The minimum size is 64kB defined by <tt>GX_FIFO_MINSIZE</tt>.<br><br>
1379  *
1380  * \note This function will also set the read and write pointers for the FIFO to the base address, so ordinarily it is not
1381  * necessary to call GX_InitFifoPtrs() when initializing the FIFO. In addition, This function sets the FIFO's high water mark to
1382  * (size-16kB) and the low water mark to (size/2), so it is also not necessary to call GX_InitFifoLimits().
1383  *
1384  * \param[in] fifo the fifo struct to use
1385  * \param[in] base ptr to the base of allocation; must be 32-byte aligned
1386  * \param[in] size size of the FIFO in bytes; must be multiple of 32; size must be <tt>GX_FIFO_MINSIZE</tt> or larger
1387  *
1388  * \return none
1389  */
1390 void GX_InitFifoBase(GXFifoObj *fifo,void *base,u32 size);
1391 
1392 /*!
1393  * \fn void GX_InitFifoLimits(GXFifoObj *fifo,u32 hiwatermark,u32 lowatermark)
1394  * \brief Sets the high and low water mark for the \a fifo.
1395  *
1396  * \details The high and low water marks are used in <i>immediate-mode</i>, i.e. when the \a fifo is attached to both the CPU and
1397  * Graphics Processor (GP) (see GX_SetCPUFifo() and GX_SetGPFifo()).
1398  *
1399  * The hardware keeps track of the number of bytes between the read and write pointers. This number represents how full the FIFO is,
1400  * and when it is greater than or equal to the \a hiwatermark, the hardware issues an interrupt. The GX API will suspend sending
1401  * graphics to the Graphics FIFO until it has emptied to a certain point. The \a lowatermark is used to set the point at which the
1402  * FIFO is empty enough to resume sending graphics commands to the  FIFO. Both \a hiwatermark and \a lowatermark should be in
1403  * multiples of 32B. The count for \a lowatermark should be less than \a hiwatermark. Of course, \a hiwatermark and \a lowatermark
1404  * must be less than the size of the FIFO.
1405  *
1406  * \note When the FIFO is only attached to the CPU or only attached to the GP, the high and low water mark interrupts are disabled.
1407  *
1408  * \param[in] fifo the fifo struct to use
1409  * \param[in] hiwatermark number of bytes to be queued before libogc stops writing commands to the FIFO
1410  * \param[in] lowatermark number of bytes to be queued before libogc resumes writing commands to the FIFO
1411  *
1412  * \return none
1413  */
1414 void GX_InitFifoLimits(GXFifoObj *fifo,u32 hiwatermark,u32 lowatermark);
1415 
1416 /*!
1417  * \fn void GX_InitFifoPtrs(GXFifoObj *fifo,void *rd_ptr,void *wt_ptr)
1418  * \brief Sets the \a fifo read and write pointers.
1419  *
1420  * \note This is normally done only during initialization of the FIFO. After that, the graphics hardware manages the FIFO pointers.
1421  *
1422  * \param[in] fifo the fifo struct to use
1423  * \param[in] rd_ptr the pointer to use for the FIFO read pointer; must be 32-byte aligned
1424  * \param[in] wt_ptr the pointer to use for the FIFO write pointer; must be 32-byte aligned
1425  *
1426  * \return none
1427  */
1428 void GX_InitFifoPtrs(GXFifoObj *fifo,void *rd_ptr,void *wt_ptr);
1429 
1430 /*!
1431  * \fn void GX_GetFifoPtrs(GXFifoObj *fifo,void **rd_ptr,void **wt_ptr)
1432  * \brief Returns the current value of the Graphics FIFO read and write pointers.
1433  *
1434  * \note See GX_EnableBreakPt() for an example of why you would do this.
1435  *
1436  * \param[in] fifo pointer to a FIFO struct
1437  * \param[out] rd_ptr address of the FIFO read pointer
1438  * \param[out] wt_ptr address of the FIFO write pointer
1439  *
1440  * \return none
1441  */
1442 void GX_GetFifoPtrs(GXFifoObj *fifo,void **rd_ptr,void **wt_ptr);
1443 
1444 /*!
1445  * \fn void GX_SetCPUFifo(GXFifoObj *fifo)
1446  * \brief Attaches a FIFO to the CPU.
1447  *
1448  * \note If the FIFO being attached is one already attached to the GP, the FIFO can be considered to be in immediate mode. If not,
1449  * the CPU can write commands, and the GP will execute them when the GP attaches to this FIFO (multi-buffered mode).
1450  *
1451  * \param[in] fifo fifo struct containing info on the FIFO to attach
1452  *
1453  * \return none
1454  */
1455 void GX_SetCPUFifo(GXFifoObj *fifo);
1456 
1457 /*!
1458  * \fn void GX_SetGPFifo(GXFifoObj *fifo)
1459  * \brief Attaches \a fifo to the GP.
1460  *
1461  * \note If the FIFO is also attached to the CPU, the system is in immediate-mode, and the fifo acts like a true FIFO. In immediate-mode,
1462  * graphics commands are fed directly from the CPU to the GP. In immediate-mode the FIFO's high and low water marks are active. The high
1463  * and low water marks implement the flow-control mechanism between the CPU and GP. When the FIFO becomes more full than the high water
1464  * mark, the CPU will stop writing graphics commands into the FIFO.  When the FIFO empties to a point lower than the low water mark, the
1465  * CPU will resume writing graphics commands into the FIFO. The high and low water marks are set when intializing the FIFO using
1466  * GX_InitFifoLimits().<br><br>
1467  *
1468  * \note If the FIFO is only attached to the GP, the FIFO acts like a buffer. In this case, high and low water marks are disabled, and
1469  * the GP reads the FIFO until it is empty. Before attaching a new FIFO to the GP, you should make sure the previous FIFO is empty, using
1470  * the \a cmdIdle status returned by GX_GetGPStatus().<br><br>
1471  *
1472  * \note The break point mechanism can be used to force the FIFO to stop reading commands at a certain point; see GX_EnableBreakPt().
1473  *
1474  * \param[in] fifo struct containing info on the FIFO to attach
1475  *
1476  * \return none
1477  */
1478 void GX_SetGPFifo(GXFifoObj *fifo);
1479 
1480 /*!
1481  * \fn void GX_GetCPUFifo(GXFifoObj *fifo)
1482  * \brief Copies the information from the currently attached CPU FIFO into \a fifo.
1483  *
1484  * \param[out] fifo the object to copy the current CPU FIFO object data into
1485  *
1486  * \return none
1487  */
1488 void GX_GetCPUFifo(GXFifoObj *fifo);
1489 
1490 /*!
1491  * \fn void GX_GetGPFifo(GXFifoObj *fifo)
1492  * \brief Copies the information from the currently attached GP FIFO info \a fifo.
1493  *
1494  * \param[out] fifo the object to copy the current GP FIFO object data into
1495  *
1496  * \return none
1497  */
1498 void GX_GetGPFifo(GXFifoObj *fifo);
1499 
1500 /*!
1501  * \fn void* GX_GetFifoBase(GXFifoObj *fifo)
1502  * \brief Get the base address for a given \a fifo.
1503  *
1504  * \param[in] fifo the object to get the address from
1505  *
1506  * \return pointer to the base address of the FIFO in main memory.
1507  */
1508 void* GX_GetFifoBase(GXFifoObj *fifo);
1509 
1510 /*!
1511  * \fn u32 GX_GetFifoCount(GXFifoObj *fifo)
1512  * \brief Returns number of cache lines in the FIFO.
1513  *
1514  * \note The count is incorrect if an overflow has occurred (i.e. you have written more data than the size of the fifo), as the
1515  * hardware cannot detect an overflow in general.
1516  *
1517  * \param[in] fifo the FIFO to get the count from
1518  *
1519  * \return number of cache lines in the FIFO
1520  */
1521 u32 GX_GetFifoCount(GXFifoObj *fifo);
1522 
1523 /*!
1524  * \fn u32 GX_GetFifoSize(GXFifoObj *fifo)
1525  * \brief Get the size of a given \a fifo.
1526  *
1527  * \param[in] fifo the object to get the size from
1528  *
1529  * \return size of the FIFO, in bytes
1530  */
1531 u32 GX_GetFifoSize(GXFifoObj *fifo);
1532 
1533 /*!
1534  * \fn u8 GX_GetFifoWrap(GXFifoObj *fifo)
1535  * \brief Returns a non-zero value if the write pointer has passed the TOP of the FIFO.
1536  *
1537  * \details Returns true only if the FIFO is attached to the CPU and the FIFO write pointer has passed the top of the FIFO. Use the
1538  * return value to detect whether or not an overflow has occured by initializing the FIFO's write pointer to the base of the FIFO
1539  * before sending any commands to the FIFO.
1540  *
1541  * \note If the FIFO write pointer is not explicitly set to the base of the FIFO, you cannot rely on this function to detect overflows.
1542  *
1543  * \param[in] fifo the object to get the wrap status from
1544  *
1545  * \return wrap value
1546  */
1547 u8 GX_GetFifoWrap(GXFifoObj *fifo);
1548 
1549 /*!
1550  * \fn GXDrawDoneCallback GX_SetDrawDoneCallback(GXDrawDoneCallback cb)
1551  * \brief Installs a callback that is invoked whenever a DrawDone command is encountered by the GP.
1552  *
1553  * \details The DrawDone command is sent by GX_SetDrawDone().
1554  *
1555  * \note By the time the callback is invoked, the GP will already have resumed reading from the FIFO, if there are any commands in it.
1556  *
1557  * \param[in] cb callback to be invoked when DrawDone is encountered
1558  *
1559  * \return pointer to the previous callback
1560  */
1561 GXDrawDoneCallback GX_SetDrawDoneCallback(GXDrawDoneCallback cb);
1562 
1563 /*!
1564  * \fn GXBreakPtCallback GX_SetBreakPtCallback(GXBreakPtCallback cb)
1565  * \brief Registers \a cb as a function to be invoked when a break point is encountered.
1566  *
1567  * \warning The callback will run with interrupts disabled, so it should terminate as quickly as possible.
1568  *
1569  * \param[in] cb function to be invoked when the breakpoint is encountered; NULL means no function will run
1570  *
1571  * \return pointer to the previous callback function
1572  */
1573 GXBreakPtCallback GX_SetBreakPtCallback(GXBreakPtCallback cb);
1574 
1575 /*!
1576  * \fn void GX_AbortFrame()
1577  * \brief Aborts the current frame.
1578  *
1579  * \details This command will reset the entire graphics pipeline, including any commands in the graphics FIFO.
1580  *
1581  * \note Texture memory will not be reset, so currently loaded textures will still be valid; however, when loading texture using
1582  * GX_PreloadEntireTexture() or TLUTs using GX_LoadTlut(), you must make sure the command completed. You can use the draw sync mechanism to
1583  * do this; see GX_SetDrawSync() and GX_GetDrawSync().
1584  *
1585  * \return none
1586  */
1587 void GX_AbortFrame();
1588 
1589 /*!
1590  * \fn void GX_Flush()
1591  * \brief Flushes all commands to the GP.
1592  *
1593  * \details Specifically, it flushes the write-gather FIFO in the CPU to make sure that all commands are sent to the GP.
1594  *
1595  * \return none
1596  */
1597 void GX_Flush();
1598 
1599 /*!
1600  * \fn void GX_SetMisc(u32 token,u32 value)
1601  * \brief Sets miscellanous settings in the GP.
1602  *
1603  * \param[in] token setting to change
1604  * \param[in] value value to change the setting to
1605  *
1606  * \return none
1607  */
1608 void GX_SetMisc(u32 token,u32 value);
1609 
1610 /*!
1611  * \fn void GX_SetDrawDone()
1612  * \brief Sends a DrawDone command to the GP.
1613  *
1614  * \details When all previous commands have been processed and the pipeline is empty, a <i>DrawDone</i> status bit will be set,
1615  * and an interrupt will occur. You can receive notification of this event by installing a callback on the interrupt with
1616  * GX_SetDrawDoneCallback(), or you can poll the status bit with GX_WaitDrawDone(). This function also flushes the write-gather
1617  * FIFO in the CPU to make sure that all commands are sent to the graphics processor.
1618  *
1619  * \note This function is normally used in multibuffer mode (see GX_SetCPUFifo()). In immediate mode, the GX_DrawDone() command
1620  * can be used, which both sends the command and stalls until the DrawDone status is true.
1621  *
1622  * \return none
1623  */
1624 void GX_SetDrawDone();
1625 
1626 /*!
1627  * \fn void GX_WaitDrawDone()
1628  * \brief Stalls until <i>DrawDone</i> is encountered by the GP.
1629  *
1630  * \details It means all graphics commands sent before this DrawDone command have executed and the last pixel has been written to
1631  * the frame buffer. You may want to execute some non-graphics operations between executing GX_SetDrawDone() and this function, but
1632  * if you simply want to wait and have nothing to execute, you can use GX_DrawDone().
1633  *
1634  * \note This function is normally used in immediate mode (see GX_SetCPUFifo()). In multibuffer mode, sending the '<i>done</i>' command is
1635  * separated from polling the '<i>done</i>' status (see GX_SetDrawDone() and GX_WaitDrawDone()).
1636  *
1637  * \return none
1638  */
1639 void GX_WaitDrawDone();
1640 
1641 /*!
1642  * \fn u16 GX_GetDrawSync()
1643  * \brief Returns the value of the token register, which is written using the GX_SetDrawSync() function.
1644  *
1645  * \return the value of the token register.
1646  */
1647 u16 GX_GetDrawSync();
1648 
1649 /*!
1650  * \fn void GX_SetDrawSync(u16 token)
1651  * \brief This function sends a token into the command stream.
1652  *
1653  * \details When the token register is set, an interrupt will also be received by the CPU. You can install a callback on this interrupt
1654  *          with GX_SetDrawSyncCallback(). Draw syncs can be used to notify the CPU that the graphics processor is finished using a shared
1655  *          resource (a vertex array for instance).
1656  *
1657  * \param[in] token 16-bit value to write to the token register.
1658  *
1659  * \return none
1660  */
1661 void GX_SetDrawSync(u16 token);
1662 
1663 /*!
1664  * \fn GXDrawSyncCallback GX_SetDrawSyncCallback(GXDrawSyncCallback cb)
1665  * \brief Installs a callback that is invoked whenever a DrawSync token is encountered by the graphics pipeline.
1666  *
1667  * \details The callback's argument is the value of the token most recently encountered. Since it is possible to
1668  *          miss tokens (graphics processing does not stop while the callback is running), your code should be
1669  *          capable of deducing if any tokens have been missed.
1670  *
1671  * \param[in] cb callback to be invoked when the DrawSync tokens are encountered in the graphics pipeline.
1672  *
1673  * \return pointer to the previously set callback function.
1674  */
1675 GXDrawSyncCallback GX_SetDrawSyncCallback(GXDrawSyncCallback cb);
1676 
1677 /*!
1678  * \fn void GX_DisableBreakPt()
1679  * \brief Allows reads from the FIFO currently attached to the Graphics Processor (GP) to resume.
1680  *
1681  * \details See GX_EnableBreakPt() for an explanation of the FIFO break point feature.
1682  *
1683  * \note The breakpoint applies to the FIFO currently attached to the Graphics Processor (GP) (see GX_SetGPFifo()).
1684  *
1685  * \return none
1686  */
1687 void GX_DisableBreakPt();
1688 
1689 /*!
1690  * \fn void GX_EnableBreakPt(void *break_pt)
1691  * \brief Sets a breakpoint that causes the GP to halt when encountered.
1692  *
1693  * \note The break point feature allows the application to have two frames of graphics in the FIFO at the same time, overlapping
1694  * one frame's processing by the graphics processor with another frame's processing by the CPU. For example, suppose you finish
1695  * writing the graphics commands for one frame and are ready to start on the next. First, execute a GX_Flush() command to make
1696  * sure all the data in the CPU write gatherer is flushed into the FIFO. This will also align the FIFO write pointer to a 32B
1697  * boundary. Next, read the value of the current write pointer using GX_GetFifoPtrs(). Write the value of the write pointer as
1698  * the break point address using GX_EnableBreakPt(). When the FIFO read pointer reaches the break point address the hardware
1699  * will disable reads from the FIFO.  The status \a brkpt, returned by GX_GetGPStatus(), can be polled to detect when the break point
1700  * is reached. The application can then decide when to disable the break point, using GX_DisableBreakPt(), which will allow the FIFO
1701  * to resume reading graphics commands.<br><br>
1702  *
1703  * \note FIFO reads will stall when the GP FIFO read pointer is equal to the break point address \a break_pt. To re-enable reads of
1704  * the GP FIFO, use GX_DisableBreakPt().<br><br>
1705  *
1706  * \note Use GX_SetBreakPtCallback() to set what function runs when the breakpoint is encountered.
1707  *
1708  * \param[in] break_pt address for GP to break on when read.
1709  *
1710  * \return none
1711  */
1712 void GX_EnableBreakPt(void *break_pt);
1713 
1714 /*!
1715  * \fn void GX_DrawDone()
1716  * \brief Sends a DrawDone command to the GP and stalls until its subsequent execution.
1717  *
1718  * \note This function is equivalent to calling GX_SetDrawDone() then GX_WaitDrawDone().
1719  *
1720  * \return none
1721  */
1722 void GX_DrawDone();
1723 
1724 /*!
1725  * \fn void GX_TexModeSync()
1726  * \brief Inserts a synchronization command into the graphics FIFO. When the Graphics Processor sees this command, it will
1727  * allow the texture pipeline to flush before continuing.
1728  *
1729  * \details This command is necessary when changing the usage of regions of texture memory from preloaded or TLUT to cached areas.
1730  * It makes sure that the texture pipeline is finished with that area of the texture memory prior to changing its usage.
1731  * This function should be called prior to drawing any primitives that uses the texture memory region in its new mode. It is not
1732  * necessary to call this command when changing texture memory regions from cached to preloaded (or TLUT), since the commands to
1733  * load the regions with data will cause the necessary synchronization to happen automatically.
1734  *
1735  * \return none
1736  */
1737 void GX_TexModeSync();
1738 
1739 /*!
1740  * \fn void GX_InvVtxCache();
1741  * \brief Invalidates the vertex cache.
1742  *
1743  * \details Specifically, this functions invalidates the vertex cache tags. This function should be used whenever you relocate or modify
1744  * data that is read by, or may be cached by, the vertex cache. The invalidate is very fast, taking only two Graphics Processor (GP) clock
1745  * cycles to complete.
1746  *
1747  * \note The vertex cache is used to cache indexed attribute data. Any attribute that is set to <tt>GX_INDEX8</tt> or <tt>GX_INDEX16</tt> in the current
1748  * vertex descriptor (see GX_SetVtxDesc()) is indexed. Direct data bypasses the vertex cache. Direct data is any attribute that is set to
1749  * <tt>GX_DIRECT</tt> in the current vertex descriptor.
1750  *
1751  * \return none
1752  */
1753 void GX_InvVtxCache();
1754 
1755 /*!
1756  * \fn void GX_ClearVtxDesc()
1757  * \brief Clears all vertex attributes of the current vertex descriptor to GX_NONE.
1758  *
1759  * \note The same functionality can be obtained using GX_SetVtxDescv(), however using GX_ClearVtxDesc() is much more efficient.
1760  *
1761  * \return none
1762  */
1763 void GX_ClearVtxDesc();
1764 
1765 /*!
1766  * \fn void GX_LoadProjectionMtx(Mtx44 mt,u8 type)
1767  * \brief Sets the projection matrix.
1768  *
1769  * \note Only two types of projection matrices are supported: <tt>GX_PERSPECTIVE</tt> or <tt>GX_ORTHOGRAPHIC</tt>.
1770  *
1771  * \param[in] mt matrix to use for the perspective
1772  * \param[in] type which perspective type to use
1773  *
1774  * \return none
1775  */
1776 void GX_LoadProjectionMtx(Mtx44 mt,u8 type);
1777 
1778 /*!
1779  * \fn void GX_SetViewport(f32 xOrig,f32 yOrig,f32 wd,f32 ht,f32 nearZ,f32 farZ)
1780  * \brief Sets the viewport rectangle in screen coordinates.
1781  *
1782  * \details The screen origin (\a xOrig = 0.0f, \a yOrig = 0.0f) is at the top left corner of the display. Floating point arguments allow the
1783  * viewport to be adjusted by 1/2 line for interlaced field rendering modes; see GX_SetViewportJitter(). The viewport depth parameters are normalized coordinates
1784  * from 0.0f - 1.0f. The GX API will convert the depth range values to proper scale values depending on the type and format of the Z-buffer.
1785  *
1786  * \note You should avoid using negative values for \a xOrig or \a yOrig. While this may work, it may cause problems with points and lines being clipped incorrectly. If
1787  * you need to shift the viewport up or left, consider using GX_SetScissorBoxOffset() instead.
1788  *
1789  * \param[in] xOrig left-most X coordinate on the screen
1790  * \param[in] yOrig top-most Y coordinate on the screen
1791  * \param[in] wd width of the viewport
1792  * \param[in] ht height of the viewport
1793  * \param[in] nearZ value to use for near depth scale
1794  * \param[in] farZ value to use for far depth scale
1795  *
1796  * \return none
1797  */
1798 void GX_SetViewport(f32 xOrig,f32 yOrig,f32 wd,f32 ht,f32 nearZ,f32 farZ);
1799 
1800 /*!
1801  * \fn void GX_SetViewportJitter(f32 xOrig,f32 yOrig,f32 wd,f32 ht,f32 nearZ,f32 farZ,u32 field)
1802  * \brief Sets the viewport and adjusts the viewport's line offset for interlaced field rendering.
1803  *
1804  * \details Depending on whether the viewport starts on an even or odd line, and whether the next \a field to be rendered is
1805  * even or odd, the viewport may be adjusted by half a line. This has the same effect as slightly tilting the camera down and is necessary
1806  * for interlaced rendering. No other camera adjustment (i.e. don't change the projection matrix) is needed for interlaced field rendering.
1807  *
1808  * \note To set a viewport <i>without</i> jitter, use GX_SetViewport().
1809  *
1810  * \param[in] xOrig left-most X coordinate on the screen
1811  * \param[in] yOrig top-most Y coordinate on the screen
1812  * \param[in] wd width of the viewport
1813  * \param[in] ht height of the viewport
1814  * \param[in] nearZ value to use for near depth scale
1815  * \param[in] farZ value to use for far depth scale
1816  * \param[in] field whether the next field is even (0) or odd (1)
1817  *
1818  * \return none
1819  */
1820 void GX_SetViewportJitter(f32 xOrig,f32 yOrig,f32 wd,f32 ht,f32 nearZ,f32 farZ,u32 field);
1821 
1822 /*!
1823  * \fn void GX_SetChanCtrl(s32 channel,u8 enable,u8 ambsrc,u8 matsrc,u8 litmask,u8 diff_fn,u8 attn_fn)
1824  * \brief Sets the lighting controls for a particular color channel.
1825  *
1826  * \details The color channel can have one or more (up to 8) lights associated with it, set using \a litmask. The \a diff_fn and \a attn_fn parameters
1827  * control the lighting equation for all lights associated with this channel; the \a ambsrc and \a matsrc can be used to select whether the input
1828  * source colors come from register colors or vertex colors. When the channel \a enable is set to <tt>GX_FALSE</tt>, the material color source (set by \a matsrc)
1829  * is passed through as the channel's output color. When the channel \a enable is <tt>GX_TRUE</tt>, the output color depends on the settings of the other
1830  * controls (i.e., the lighting equation). GX_Init() sets the \a enable for all channels to <tt>GX_FALSE</tt>. This function only configures the lighting
1831  * channel; to output the result of the channel computation, use GX_SetNumChans().
1832  *
1833  * \note Even though channels <tt>GX_COLOR0</tt> and <tt>GX_ALPHA0</tt> are controlled separately for lighting, they are rasterized together as one RGBA color, effectively
1834  * <tt>GX_COLOR0A0</tt>. The same is true for <tt>GX_COLOR1</tt> and <tt>GX_ALPHA1</tt>-- effectively, they are rasterized as <tt>GX_COLOR1A1</tt>. Since there is only one rasterizer for
1835  * color in the graphics hardware, you must choose which color to rasterize for each stage in the Texture Environment (TEV) unit. This is accomplished
1836  * using GX_SetTevOrder().<br><br>
1837  *
1838  * \note In order to use a vertex color in channel <tt>GX_COLOR1A1</tt>, two colors per vertex must be supplied, i.e. both <tt>GX_VA_CLR0</tt> and <tt>GX_VA_CLR1</tt> must be
1839  * enabled in the current vertex descriptor. If only <tt>GX_VA_CLR0</tt> <b>or</b> <tt>GX_VA_CLR1</tt> is enabled in the current vertex descriptor, the vertex color is
1840  * directed to the channel <tt>GX_VA_COLOR0A0</tt>.<br><br>
1841  *
1842  * \note When \a ambsrc is set to <tt>GX_SRC_REG</tt>, the color set by GX_SetChanAmbColor() is used as the ambient color. When \a matsrc is <tt>GX_SRC_REG</tt>, the color set
1843  * by GX_SetChanMatColor() is used as the material color.
1844  *
1845  * \param[in] channel color channel to use
1846  * \param[in] enable whether or not to enable lighting for this channel
1847  * \param[in] ambsrc source for the ambient color
1848  * \param[in] matsrc source for the material color
1849  * \param[in] litmask \ref lightid or IDs to associate with this channel
1850  * \param[in] diff_fn \ref difffn to use
1851  * \param[in] attn_fn \ref attenfunc to use
1852  *
1853  * \return none
1854  */
1855 void GX_SetChanCtrl(s32 channel,u8 enable,u8 ambsrc,u8 matsrc,u8 litmask,u8 diff_fn,u8 attn_fn);
1856 
1857 /*!
1858  * \fn void GX_SetChanAmbColor(s32 channel,GXColor color)
1859  * \brief Sets the ambient color register for color channel \a chan.
1860  *
1861  * \details This color will be used by the channel as the ambient color if the ambient source, set by GX_SetChanCtrl(), is <tt>GX_SRC_REG</tt>.
1862  *
1863  * \param[in] channel channel to set
1864  * \param[in] color color to set it to
1865  *
1866  * \return none
1867  */
1868 void GX_SetChanAmbColor(s32 channel,GXColor color);
1869 
1870 /*!
1871  * \fn void GX_SetChanMatColor(s32 channel,GXColor color)
1872  * \brief Sets the material color register for color channel \a chan.
1873  *
1874  * \details This color will be used by the channel as the material color if the material source, set by GX_SetChanCtrl(), is <tt>GX_SRC_REG</tt>.
1875  *
1876  * \param[in] channel channel to set
1877  * \param[in] color color to set it to
1878  *
1879  * \return none
1880  */
1881 void GX_SetChanMatColor(s32 channel,GXColor color);
1882 
1883 /*!
1884  * \fn void GX_SetArray(u32 attr,void *ptr,u8 stride)
1885  * \brief Sets the array base pointer and stride for a single attribute.
1886  *
1887  * \details The array base and stride are used to compute the address of indexed attribute data using the equation:<br><br>
1888  *
1889  * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<i>attr_addr</i> = \a ptr + <i>attr_idx</i> * \a stride
1890  *
1891  * When drawing a graphics primitive that has been enabled to use indexed attributes (see GX_SetVtxDesc()), <i>attr_idx</i> is supplied in the vertex
1892  * data. The format and size of the data in the array must also be described using GX_SetVtxAttrFmt(). You can also index other data, such as
1893  * matrices (see GX_LoadPosMtxIdx(), GX_LoadNrmMtxIdx3x3(), and GX_LoadTexMtxIdx()), and light objects (see GX_LoadLightObjIdx()). In the case
1894  * of matrices and light objects, the size and format of the data to be loaded is implied by the function call.
1895  *
1896  * There is a base pointer, \a ptr, for each type of attribute as well as for light data and matrices. Each attribute can be stored in its own
1897  * array for maximum data compression (i.e., removal of redundant attribute data). The \a stride is in byte units and is the distance between
1898  * attributes in the array.
1899  *
1900  * \note Indexed data is loaded into a vertex cache in the graphics processor. The vertex cache fetches 32B of data for each cache miss;
1901  * therefore, there is a small performance benefit to aligning attribute arrays to 32B, and possibly for arranging vertex data so that it
1902  * doesn't span 32B boundaries. Conveniently enough, memalign() returns 32-byte aligned pointers. For static data arrays, you can use the
1903  * ATTRIBUTE_ALIGN(32) attribute macro to align the \a ptr to 32B.
1904  *
1905  * \param[in] attr \ref vtxattr that the array is storing
1906  * \param[in] ptr pointer to the array itself
1907  * \param[in] stride stride (in bytes) between each element in the array
1908  *
1909  * \return none
1910  */
1911 void GX_SetArray(u32 attr,void *ptr,u8 stride);
1912 
1913 /*!
1914  * \fn void GX_SetVtxAttrFmt(u8 vtxfmt,u32 vtxattr,u32 comptype,u32 compsize,u32 frac)
1915  * \brief Sets the attribute format (\a vtxattr) for a single attribute in the Vertex Attribute Table (VAT).
1916  *
1917  * \details Each attribute format describes the data type (comptype), number of elements (compsize), and fixed point format (frac), if required. The
1918  * are eight vertex formats available in the VAT. The vertex format describes the format of all attributes in a vertex. The application can pre-program
1919  * all eight vertex formats and then select one of them during the actual drawing of geometry (See GX_Begin()). Note that all vertices used to draw a
1920  * particular graphics primitive will have the same format. The vertex format set using this function, along with the current vertex descriptor set
1921  * using GX_SetVtxDesc(), completely define the vertex data format.
1922  *
1923  * \note The vertex format allows data to be sent to the graphics processor in its most <i>quantized</i> format. The graphics hardware will <i>inverse-quantize</i>
1924  * the data (into floating point format) before it is used. The vertex attribute format is used to communicate the data quantization format to the hardware.<br><br>
1925  *
1926  * \note <tt>GX_VA_NRM</tt> and <tt>GX_VA_NBT</tt> attributes share the same type. Also, the frac for these attributes is fixed according to the type. The component count
1927  * (compsize) for <tt>GX_VA_NRM</tt> must be set to <tt>GX_NRM_XYZ</tt>. The component count for <tt>GX_VA_NBT</tt> must be set to <tt>GX_NRM_NBT</tt> or <tt>GX_NRM_NBT3</tt>.
1928  *
1929  * \param[in] vtxfmt \ref vtxfmt
1930  * \param[in] vtxattr \ref vtxattr
1931  * \param[in] comptype \ref comptype
1932  * \param[in] compsize \ref compsize
1933  * \param[in] frac number of fractional bits in a fixed-point number
1934  *
1935  * \return none
1936  */
1937 void GX_SetVtxAttrFmt(u8 vtxfmt,u32 vtxattr,u32 comptype,u32 compsize,u32 frac);
1938 
1939 /*!
1940  * \fn void GX_SetVtxAttrFmtv(u8 vtxfmt,GXVtxAttrFmt *attr_list)
1941  * \brief Sets multiple attribute formats within a single vertex format.
1942  *
1943  * \details This is useful when you need to set all the attributes in a vertex format at once (e.g., during graphics initialization).
1944  *
1945  * \note The constant <tt>GX_MAX_VTXATTRFMT_LISTSIZE</tt> should be used to allocate the list. You can get a current vertex format using GX_GetVtxAttrFmtv().
1946  *
1947  * \param[in] vtxfmt \ref vtxfmt
1948  * \param[in] attr_list pointer to array of GXVtxAttrFmt structs to draw from
1949  *
1950  * \return none
1951  */
1952 void GX_SetVtxAttrFmtv(u8 vtxfmt,GXVtxAttrFmt *attr_list);
1953 
1954 /*!
1955  * \fn void GX_SetVtxDesc(u8 attr,u8 type)
1956  * \brief Sets the \a type of a single attribute (\a attr) in the current vertex descriptor.
1957  *
1958  * \details The current vertex descriptor defines which attributes are present in a vertex and how each attribute is referenced. The current
1959  * vertex descriptor is used by the Graphics Processor (GP) to interpret the graphics command stream produced by the GX API. In particular,
1960  * the current vertex descriptor is used to parse the vertex data that is present in the command stream.
1961  *
1962  * \param[in] attr \ref vtxattr
1963  * \param[in] type \ref vtxattrin
1964  *
1965  * \return none
1966  */
1967 void GX_SetVtxDesc(u8 attr,u8 type);
1968 
1969 /*!
1970  * \fn void GX_SetVtxDescv(GXVtxDesc *attr_list)
1971  * \brief Sets the type of multiple attributes.
1972  *
1973  * \details This function is used when more than one attribute needs to be set (e.g., during initialization of geometry).
1974  *
1975  * \note The constant <tt>GX_MAX_VTXATTRFMT_LISTSIZE</tt> can be used to allocate memory for \a attr_list
1976  *
1977  * \param[in] attr_list array of pointers to GXVtxDesc structs; last element of the array should be <tt>GX_VA_NULL</tt>
1978  *
1979  * \return none
1980  */
1981 void GX_SetVtxDescv(GXVtxDesc *attr_list);
1982 
1983 /*!
1984  * \fn void GX_GetVtxDescv(GXVtxDesc *attr_list)
1985  * \brief Gets the type of multiple attributes.
1986  *
1987  * \details This function saves the attributes that are current set. This is usually used in conjunction with GX_SetVtxDescv
1988  *
1989  * \note The constant <tt>GX_MAX_VTXATTRFMT_LISTSIZE</tt> must be used to allocate memory for \a attr_list
1990  *
1991  * \param[in] attr_list array of pointers to GXVtxDesc structs
1992  *
1993  * \return none
1994  */
1995 void GX_GetVtxDescv(GXVtxDesc *attr_list);
1996 
1997 /*!
1998  * \fn u32 GX_EndDispList()
1999  * \brief Ends a display list and resumes writing graphics commands to the CPU FIFO.
2000  *
2001  * \details This function returns the size of the display list written to the display list buffer since GX_BeginDispList() was called. If
2002  * the display list size exceeds the size of the buffer allocated, a zero length size will be returned. The display list size is a
2003  * multiple of 32B and any unsed commands in the last 32B will be padded with <tt>GX_NOP</tt>. The size returned should be passed to
2004  * GX_CallDispList() when the display list needs to be executed.
2005  *
2006  * \note Due to the mechanics of flushing the write-gather pipe (which is used to create the display list), the display buffer should be
2007  * at least 32 bytes larger than the maximum expected amount of data stored. This function calls GX_Flush(), and thus it is not necessary
2008  * to call GX_Flush() explicitly after creating the display list.<br><br>
2009  *
2010  * \note A display list cannot be nested; i.e., no display list functions (GX_BeginDispList(), GX_EndDispList() and GX_CallDispList()) can
2011  * be called between a GX_BeginDispList() and GX_EndDispList() pair.<br><br>
2012  *
2013  * \note To execute a display list, use GX_CallDispList().
2014  *
2015  * \return 0 if display list size exceeds buffer, otherwise gives list size in bytes
2016  *
2017  * \bug Specifying a display list buffer size for GX_BeginDispList() the exact size that the display list will be (after padding) will cause
2018  * this function to return a very large (and very incorrect) value.
2019  */
2020 u32 GX_EndDispList();
2021 
2022 /*!
2023  * \fn void GX_Begin(u8 primitve,u8 vtxfmt,u16 vtxcnt)
2024  * \brief Begins drawing of a graphics primitive.
2025  *
2026  * \details To draw a graphics primitive, a stream of vertex data matching the description of both GX_SetVtxDesc() and GX_SetVtxAttrFmt() is
2027  * enclosed between GX_Begin()/GX_End() pairs. The number of vertices between GX_Begin() and GX_End() must match that specified by the \a vtxcnt
2028  * parameter. The type of the primitive will determine the minimum number of vertices required. For example, a <tt>GX_TRIANGLES</tt> primitive must
2029  * have at least 3 vertices.
2030  *
2031  * \note Primitives in which the vertex order is clockwise to the viewer are considered front-facing (for culling purposes).
2032  *
2033  * \param[in] primitve \ref primtype to draw
2034  * \param[in] vtxfmt \ref vtxfmt to use
2035  * \param[in] vtxcnt number of vertices being drawn; maximum is 65536
2036  */
2037 void GX_Begin(u8 primitve,u8 vtxfmt,u16 vtxcnt);
2038 
2039 /*!
2040  * \fn void GX_BeginDispList(void *list,u32 size)
2041  * \brief Begins a display list and disables writes to the FIFO currently attached to the CPU.
2042  *
2043  * \details After this function is called, GX API functions that normally send command or data into the CPU FIFO will send them to the
2044  * display list buffer instead of the FIFO until GX_EndDispList() is called. Writes to the CPU FIFO will be re-enabled when the function
2045  * GX_EndDispList() executes.
2046  *
2047  * Basically you can put most of GX API commands into a display list. However, since the use of display list can bypass all state
2048  * coherences controlled by GX API in run-time, sometimes it brings some state collisions or incoherences that may lead to unexpected
2049  * behavior or even graphics pipeline hang. The most recommended safe way is putting only primitives (regions enclosed by GX_Begin() and
2050  * GX_End()) that don't cause any state collisions.
2051  *
2052  * \note The application is expected to allocate the memory for the display list buffer. If the display list exceeds the maximum size
2053  * of the buffer, GX_EndDispList() will return 0. The address of the buffer must be 32-byte aligned; memalign() can return 32-byte-aligned
2054  * pointers. You can use the macro ATTRIBUTE_ALIGN(32) to align statically allocated buffers.<br><br>
2055  *
2056  * \note The CPU's write-gather pipe is used to write graphics commands to the display list. Therefore, the display list buffer must be
2057  * forced out of the CPU cache prior to being filled. DCInvalidateRange() may be used for this purpose. In addition, due to the mechanics
2058  * of flushing the write-gather pipe, the display list buffer should be at least 63 bytes larger than the maximum expected amount of data
2059  * stored.<br><br>
2060  *
2061  * \note A display list cannot be nested; i.e., no display list functions (GX_BeginDispList(), GX_EndDispList() and GX_CallDispList()) can
2062  * be called between a GX_BeginDispList() and GX_EndDispList() pair.<br><br>
2063  *
2064  * \note To execute a display list, use GX_CallDispList().
2065  *
2066  * \param[in] list 32-byte aligned buffer to hold the list
2067  * \param[in] size size of the buffer, multiple of 32
2068  *
2069  * \return none
2070  */
2071 void GX_BeginDispList(void *list,u32 size);
2072 
2073 /*!
2074  * \fn void GX_CallDispList(void *list,u32 nbytes)
2075  * \brief Causes the GP to execute graphics commands from the display \a list instead of from the GP FIFO.
2076  *
2077  * \details When the number of bytes specified by \a nbytes have been read, the graphics processor will resume executing
2078  * commands from the graphics FIFO. Graphics commands from a display list are prefetched into a separate 4KB FIFO. This prevents
2079  * any data prefetched for the main graphics command stream from being lost during the display list call.
2080  *
2081  * \note A display list cannot call another display list.<br><br>
2082  *
2083  * \note The display list must be padded to a length of 32B. All the data in the display list is interpreted by the graphics
2084  * processor, so any unused memory at the end of a display list should be set to GX_NOP. If you create the display list using
2085  * GX_BeginDispList()/GX_EndDispList(), this padding will be inserted automatically.
2086  *
2087  * \param[in] list 32-byte aligned pointer to the display list buffer
2088  * \param[in] nbytes number of bytes in the display list. Use the return value of GX_EndDispList() here.
2089  *
2090  * \return none
2091  */
2092 void GX_CallDispList(void *list,u32 nbytes);
2093 
2094 /*!
2095  * \fn static inline void GX_End()
2096  * \brief Used to end the drawing of a graphics primitive. This does nothing in libogc.
2097  *
2098  * \return none
2099  */
GX_End()2100 static inline void GX_End()
2101 {
2102 }
2103 
GX_Position3f32(f32 x,f32 y,f32 z)2104 static inline void GX_Position3f32(f32 x,f32 y,f32 z)
2105 {
2106 	wgPipe->F32 = x;
2107 	wgPipe->F32 = y;
2108 	wgPipe->F32 = z;
2109 }
2110 
GX_Position3u16(u16 x,u16 y,u16 z)2111 static inline void GX_Position3u16(u16 x,u16 y,u16 z)
2112 {
2113 	wgPipe->U16 = x;
2114 	wgPipe->U16 = y;
2115 	wgPipe->U16 = z;
2116 }
2117 
GX_Position3s16(s16 x,s16 y,s16 z)2118 static inline void GX_Position3s16(s16 x,s16 y,s16 z)
2119 {
2120 	wgPipe->S16 = x;
2121 	wgPipe->S16 = y;
2122 	wgPipe->S16 = z;
2123 }
2124 
GX_Position3u8(u8 x,u8 y,u8 z)2125 static inline void GX_Position3u8(u8 x,u8 y,u8 z)
2126 {
2127 	wgPipe->U8 = x;
2128 	wgPipe->U8 = y;
2129 	wgPipe->U8 = z;
2130 }
2131 
GX_Position3s8(s8 x,s8 y,s8 z)2132 static inline void GX_Position3s8(s8 x,s8 y,s8 z)
2133 {
2134 	wgPipe->S8 = x;
2135 	wgPipe->S8 = y;
2136 	wgPipe->S8 = z;
2137 }
2138 
GX_Position2f32(f32 x,f32 y)2139 static inline void GX_Position2f32(f32 x,f32 y)
2140 {
2141 	wgPipe->F32 = x;
2142 	wgPipe->F32 = y;
2143 }
2144 
GX_Position2u16(u16 x,u16 y)2145 static inline void GX_Position2u16(u16 x,u16 y)
2146 {
2147 	wgPipe->U16 = x;
2148 	wgPipe->U16 = y;
2149 }
2150 
GX_Position2s16(s16 x,s16 y)2151 static inline void GX_Position2s16(s16 x,s16 y)
2152 {
2153 	wgPipe->S16 = x;
2154 	wgPipe->S16 = y;
2155 }
2156 
GX_Position2u8(u8 x,u8 y)2157 static inline void GX_Position2u8(u8 x,u8 y)
2158 {
2159 	wgPipe->U8 = x;
2160 	wgPipe->U8 = y;
2161 }
2162 
GX_Position2s8(s8 x,s8 y)2163 static inline void GX_Position2s8(s8 x,s8 y)
2164 {
2165 	wgPipe->S8 = x;
2166 	wgPipe->S8 = y;
2167 }
2168 
GX_Position1x8(u8 index)2169 static inline void GX_Position1x8(u8 index)
2170 {
2171 	wgPipe->U8 = index;
2172 }
2173 
GX_Position1x16(u16 index)2174 static inline void GX_Position1x16(u16 index)
2175 {
2176 	wgPipe->U16 = index;
2177 }
2178 
GX_Normal3f32(f32 nx,f32 ny,f32 nz)2179 static inline void GX_Normal3f32(f32 nx,f32 ny,f32 nz)
2180 {
2181 	wgPipe->F32 = nx;
2182 	wgPipe->F32 = ny;
2183 	wgPipe->F32 = nz;
2184 }
2185 
GX_Normal3s16(s16 nx,s16 ny,s16 nz)2186 static inline void GX_Normal3s16(s16 nx,s16 ny,s16 nz)
2187 {
2188 	wgPipe->S16 = nx;
2189 	wgPipe->S16 = ny;
2190 	wgPipe->S16 = nz;
2191 }
2192 
GX_Normal3s8(s8 nx,s8 ny,s8 nz)2193 static inline void GX_Normal3s8(s8 nx,s8 ny,s8 nz)
2194 {
2195 	wgPipe->S8 = nx;
2196 	wgPipe->S8 = ny;
2197 	wgPipe->S8 = nz;
2198 }
2199 
GX_Normal1x8(u8 index)2200 static inline void GX_Normal1x8(u8 index)
2201 {
2202 	wgPipe->U8 = index;
2203 }
2204 
GX_Normal1x16(u16 index)2205 static inline void GX_Normal1x16(u16 index)
2206 {
2207 	wgPipe->U16 = index;
2208 }
2209 
GX_Color4u8(u8 r,u8 g,u8 b,u8 a)2210 static inline void GX_Color4u8(u8 r,u8 g,u8 b,u8 a)
2211 {
2212 	wgPipe->U8 = r;
2213 	wgPipe->U8 = g;
2214 	wgPipe->U8 = b;
2215 	wgPipe->U8 = a;
2216 }
2217 
GX_Color3u8(u8 r,u8 g,u8 b)2218 static inline void GX_Color3u8(u8 r,u8 g,u8 b)
2219 {
2220 	wgPipe->U8 = r;
2221 	wgPipe->U8 = g;
2222 	wgPipe->U8 = b;
2223 }
2224 
GX_Color3f32(f32 r,f32 g,f32 b)2225 static inline void GX_Color3f32(f32 r, f32 g, f32 b)
2226 {
2227 	wgPipe->U8 = (u8)(r * 255.0);
2228 	wgPipe->U8 = (u8)(g * 255.0);
2229 	wgPipe->U8 = (u8)(b * 255.0);
2230 }
2231 
GX_Color1u32(u32 clr)2232 static inline void GX_Color1u32(u32 clr)
2233 {
2234 	wgPipe->U32 = clr;
2235 }
2236 
GX_Color1u16(u16 clr)2237 static inline void GX_Color1u16(u16 clr)
2238 {
2239 	wgPipe->U16 = clr;
2240 }
2241 
GX_Color1x8(u8 index)2242 static inline void GX_Color1x8(u8 index)
2243 {
2244 	wgPipe->U8 = index;
2245 }
2246 
GX_Color1x16(u16 index)2247 static inline void GX_Color1x16(u16 index)
2248 {
2249 	wgPipe->U16 = index;
2250 }
2251 
GX_TexCoord2f32(f32 s,f32 t)2252 static inline void GX_TexCoord2f32(f32 s,f32 t)
2253 {
2254 	wgPipe->F32 = s;
2255 	wgPipe->F32 = t;
2256 }
2257 
GX_TexCoord2u16(u16 s,u16 t)2258 static inline void GX_TexCoord2u16(u16 s,u16 t)
2259 {
2260 	wgPipe->U16 = s;
2261 	wgPipe->U16 = t;
2262 }
2263 
GX_TexCoord2s16(s16 s,s16 t)2264 static inline void GX_TexCoord2s16(s16 s,s16 t)
2265 {
2266 	wgPipe->S16 = s;
2267 	wgPipe->S16 = t;
2268 }
2269 
GX_TexCoord2u8(u8 s,u8 t)2270 static inline void GX_TexCoord2u8(u8 s,u8 t)
2271 {
2272 	wgPipe->U8 = s;
2273 	wgPipe->U8 = t;
2274 }
2275 
GX_TexCoord2s8(s8 s,s8 t)2276 static inline void GX_TexCoord2s8(s8 s,s8 t)
2277 {
2278 	wgPipe->S8 = s;
2279 	wgPipe->S8 = t;
2280 }
2281 
GX_TexCoord1f32(f32 s)2282 static inline void GX_TexCoord1f32(f32 s)
2283 {
2284 	wgPipe->F32 = s;
2285 }
2286 
GX_TexCoord1u16(u16 s)2287 static inline void GX_TexCoord1u16(u16 s)
2288 {
2289 	wgPipe->U16 = s;
2290 }
2291 
GX_TexCoord1s16(s16 s)2292 static inline void GX_TexCoord1s16(s16 s)
2293 {
2294 	wgPipe->S16 = s;
2295 }
2296 
GX_TexCoord1u8(u8 s)2297 static inline void GX_TexCoord1u8(u8 s)
2298 {
2299 	wgPipe->U8 = s;
2300 }
2301 
GX_TexCoord1s8(s8 s)2302 static inline void GX_TexCoord1s8(s8 s)
2303 {
2304 	wgPipe->S8 = s;
2305 }
2306 
GX_TexCoord1x8(u8 index)2307 static inline void GX_TexCoord1x8(u8 index)
2308 {
2309 	wgPipe->U8 = index;
2310 }
2311 
GX_TexCoord1x16(u16 index)2312 static inline void GX_TexCoord1x16(u16 index)
2313 {
2314 	wgPipe->U16 = index;
2315 }
2316 
GX_MatrixIndex1x8(u8 index)2317 static inline void GX_MatrixIndex1x8(u8 index)
2318 {
2319 	wgPipe->U8 = index;
2320 }
2321 
2322 /*!
2323  * \fn void GX_AdjustForOverscan(GXRModeObj *rmin,GXRModeObj *rmout,u16 hor,u16 ver)
2324  * \brief Takes a given render mode and returns a version that is reduced in size to account for overscan.
2325  *
2326  * \details The number of pixels specified by \a hor is subtracted from each side of the screen, and the number of pixels specified
2327  * by \a ver is subtracted from both the top and the bottom of the screen. The active screen area is centered within what the render
2328  * mode specified before the adjustment.
2329  *
2330  * \note Due to the wide possibilities of how a render mode may be configured, this function may not work in all cases. For instance,
2331  * if you use Y-scaling to create a size difference between the EFB and XFB, this function may not do the right thing. In such cases,
2332  * you should configure the desired render mode manually (or else call this function and then fix up the results).
2333  *
2334  * \param[in] rmin rmode that is being copied
2335  * \param[in] rmout rmode to hold the adjusted version. Needs to be allocated but can be uninitialized.
2336  * \param[in] hor pixels to trim from each side of the screen
2337  * \param[in] ver pixels to tim from top and bottom of the screen
2338  *
2339  * \returns none
2340  */
2341 void GX_AdjustForOverscan(GXRModeObj *rmin,GXRModeObj *rmout,u16 hor,u16 ver);
2342 
2343 /*!
2344  * \fn void GX_LoadPosMtxImm(Mtx mt,u32 pnidx)
2345  * \brief Used to load a 3x4 modelview matrix \a mt into matrix memory at location \a pnidx.
2346  *
2347  * \details This matrix can be used to transform positions in model space to view space, either by making the matrix the current one (see
2348  * GX_SetCurrentMtx()), or by setting a matrix \a pnidx for each vertex. The parameter \a mt is a pointer to a 3x4 (row x column) matrix. The
2349  * parameter \a pnidx is used to refer to the matrix location (see \ref pnmtx) in matrix memory.
2350  *
2351  * You can also load a normal matrix (GX_LoadNrmMtxImm() or GX_LoadNrmMtxIdx3x3()) to the same \a pnidx. Generally, the normal matrix
2352  * will be the inverse transpose of the position matrix. The normal matrix is used during vertex lighting. In cases where the modelview
2353  * and inverse transpose of the modelview (excluding translation) are the same, you can load the <i>same</i> matrix for both position and normal
2354  * transforms.
2355  *
2356  * \note The matrix data is copied from DRAM through the CPU cache into the Graphics FIFO, so matrices loaded using this function are always
2357  * coherent with the CPU cache.
2358  *
2359  * \param[in] mt the matrix to load
2360  * \param[in] pnidx \ref pnmtx to load into
2361  *
2362  * \return none
2363  */
2364 void GX_LoadPosMtxImm(Mtx mt,u32 pnidx);
2365 
2366 /*!
2367  * \fn void GX_LoadPosMtxIdx(u16 mtxidx,u32 pnidx)
2368  * \brief Loads a 3x4 modelview matrix at index \a mtxidx from the array in main memory.
2369  *
2370  * \details The array is set by GX_SetArray(), and the matrix is loaded into matrix memory at index \a pnidx (see \ref pnmtx). This
2371  * modelview matrix is used to transform positions in model space to view space, either by making the matrix the current one (see
2372  * GX_SetCurrentMtx()) or by setting a matrix \a pnidx for each vertex (see GX_SetVtxDesc()). The matrix will be loaded through the vertex cache.
2373  *
2374  * You can also load a normal matrix (GX_LoadNrmMtxImm() or GX_LoadNrmMtxIdx3x3()) to the same \a pnidx. Generally, the normal matrix
2375  * will be the inverse transpose of the position matrix. The normal matrix is used during vertex lighting. In cases where the modelview
2376  * and inverse transpose of the modelview (excluding translation) are the same, you can load the <i>same</i> matrix for both position and normal
2377  * transforms. Since indexed matrix loads are through the vertex cache, you will only incur the main memory bandwidth load of one matrix load.
2378  *
2379  * \note The matrix is loaded directly from main memory into the matrix memory thrugh the vertex cache, so it is incoherent with the CPU's cache.
2380  * It is the application's responsibility to flush any matrix data from the CPU cache (see DCStoreRange()) before calling this function.
2381  *
2382  * \param[in] mtxidx index to the matrix array to load
2383  * \param[in] pnidx \ref pnmtx to load into
2384  *
2385  * \return none
2386  */
2387 void GX_LoadPosMtxIdx(u16 mtxidx,u32 pnidx);
2388 
2389 /*!
2390  * \fn void GX_LoadNrmMtxImm(Mtx mt,u32 pnidx)
2391  * \brief Used to load a normal transform matrix into matrix memory at location \a pnidx from the 4x3 matrix \a mt.
2392  *
2393  * \details This matrix is used to transform normals in model space to view space, either by making it the current matrix (see GX_SetCurrentMtx()),
2394  * or by setting a matrix pnidx for each vertex. The parameter \a mt is a pointer to a 3x4 (row x column) matrix. The translation terms
2395  * in the 3x4 matrix are not needed for normal rotation and are ignored during the load. The parameter \a pnidx is used to refer to the
2396  * matrix location (see \ref pnmtx) in matrix memory.
2397  *
2398  * \note You can also load a position matrix (GX_LoadPosMtxImm()) to the same \a pnidx. Normally, the normal matrix will be the inverse transpose of
2399  * the position (modelview) matrix and is used during vertex lighting. In cases where the modelview and the inverse transpose of the modelview
2400  * matrix (excluding translation) are the same, the same matrix can be loaded for both normal and position matrices.<br><br>
2401  *
2402  * \note The matrix data is copied from main memory or the CPU cache into the Graphics FIFO, so matrices loaded by this function are always coherent
2403  * with the CPU cache.<br><br>
2404  *
2405  * \param[in] mt the matrix to load
2406  * \param[in] pnidx \ref pnmtx to load into
2407  *
2408  * \return none
2409  */
2410 void GX_LoadNrmMtxImm(Mtx mt,u32 pnidx);
2411 
2412 /*!
2413  * \fn void GX_LoadNrmMtxIdx3x3(u16 mtxidx,u32 pnidx)
2414  * \brief Loads a 3x3 normal matrix into matrix memory at location \a pnidx from a 3x3 matrix located at index \a mtxidx
2415  * from the array in main memory.
2416  *
2417  * \details The array is set by set by GX_SetArray(), and the matrix is loaded into matrix memory at index \a pnidx. This matrix can be used to
2418  * transform normals in model space to view space, either by making the matrix the current one (see GX_SetCurrentMtx()), or by setting a
2419  * matrix \a pnidx for each vertex (see GX_SetVtxDesc()). The matrix will be loaded through the vertex cache. You can also load a position
2420  * matrix (GX_LoadPosMtxImm() or GX_LoadPosMtxIdx()) to the same \a pnidx.
2421  *
2422  * \note You cannot use an indexed load to load a 3x3 matrix from an indexed 3x4 matrix in main memory; you must use GX_LoadNrmMtxImm() for
2423  * this case.<br><br>
2424  *
2425  * \note The matrix is loaded directly from main memory into the matrix memory through the vertex cache, therefore it is incoherent with the
2426  * CPU's cache. It is the application's responsibility to flush any matrix data from the CPU cache (see DCStoreRange()) before calling this
2427  * function.
2428  *
2429  * \param[in] mtxidx index to the matrix array to load
2430  * \param[in] pnidx \ref pnmtx to load into
2431  *
2432  * \return none
2433  */
2434 void GX_LoadNrmMtxIdx3x3(u16 mtxidx,u32 pnidx);
2435 
2436 /*!
2437  * \fn void GX_LoadTexMtxImm(Mtx mt,u32 texidx,u8 type)
2438  * \brief Loads a texture matrix \a mt into the matrix memory at location \a texidx.
2439  *
2440  * \details The matrix loaded can be either a 2x4 or 3x4 matrix as indicated by \a type. You can use the loaded matrix to
2441  * transform texture coordinates, or to generate texture coordinates from position or normal vectors. Such generated texture
2442  * coordinates are used for projected textures, reflection mapping, etc. See GX_SetTexCoordGen() for more details.
2443  *
2444  * Texture matrices can be either 2x4 or 3x4. <tt>GX_MTX_2x4</tt> matrices can be used for simple translations and/or rotations of texture
2445  * coordinates. <tt>GX_MTX_3x4</tt> matrices are used when projection is required.
2446  *
2447  * \note The default matrix memory configuration allows for ten (3x4 or 2x4) texture matrices, and a 3x4 identity matrix. The <tt>GX_IDENTITY</tt>
2448  * matrix is preloaded by GX_Init().<br><br>
2449  *
2450  * \note This function allows one to load post-transform texture matrices as well. Specifying a texidx in the range of \ref dttmtx will load a
2451  * post-transform texture matrix instead of a regular, first-pass texture matrix. Note that post-transform matrices are always 3x4. Refer to
2452  * GX_SetTexCoordGen2() for information about how to use post-transform texture matrices.
2453  *
2454  * \param[in] mt the matrix to load
2455  * \param[in] texidx \ref texmtx
2456  * \param[in] type \ref mtxtype
2457  *
2458  * \return none
2459  */
2460 void GX_LoadTexMtxImm(Mtx mt,u32 texidx,u8 type);
2461 
2462 /*!
2463  * \fn void GX_LoadTexMtxIdx(u16 mtxidx,u32 texidx,u8 type)
2464  * \brief Loads a texture matrix at index \a mtxidx from the array in main memory
2465  *
2466  * \details The array is set by GX_SetArray(), and the matrix is loaded into matrix memory at location \a texid. The loaded matrix can be
2467  * either 2x4 or 3x4 as indicated by \a type. This matrix can be used to generate texture coordinates from positions, normals, and input
2468  * texture coordinates (see GX_SetTexCoordGen()). The matrix is loaded through the vertex cache. The size of the matrix to load is indicated by its
2469  * \a type. Texture matrices can be either 2x4 or 3x4. <tt>GX_MTX_2x4</tt> matrices can be used for simple translations and/or rotations of texture
2470  * coordinates; <tt>GX_MTX_3x4</tt> matrices are used when projection is required.
2471  *
2472  * \note The matrix is loaded directly from main memory into the matrix memory through the vertex cache, so it is incoherent with the CPU's
2473  * cache. It is the application's responsibility to flush any matrix data from the CPU cache (see DCStoreRange()) before calling this function.<br><br>
2474  *
2475  * \note This function allows one to load post-transform texture matrices as well. Specifying a \a texidx in the range of \ref dttmtx will load a
2476  * post-transform texture matrix instead of a regular, first-pass texture matrix. Note that post-transform matrices are always 3x4. Refer to
2477  * GX_SetTexCoordGen2() for information about how to use post-transform texture matrices.
2478  *
2479  * \param[in] mtxidx index to the matrix array to load
2480  * \param[in] texidx \ref texmtx
2481  * \param[in] type \ref mtxtype
2482  *
2483  * \return none
2484  */
2485 void GX_LoadTexMtxIdx(u16 mtxidx,u32 texidx,u8 type);
2486 
2487 /*!
2488  * \fn void GX_SetCurrentMtx(u32 mtx)
2489  * \brief Selects a specific matrix to use for transformations.
2490  *
2491  * \details The matrix \a mtx specified will be used to select the current modelview transform matrix and normal transform matrix,
2492  * as long as a matrix index is not present in the vertex data (see GX_SetVtxDesc()). If the current vertex descriptor enables <tt>GX_VA_PTNMTXIDX</tt>,
2493  * the matrix \a mtx specified by this function will be overwritten when the vertices are drawn.
2494  *
2495  * \param[in] mtx \ref pnmtx
2496  *
2497  * \return none
2498  */
2499 void GX_SetCurrentMtx(u32 mtx);
2500 
2501 /*!
2502  * \fn void GX_SetTevOp(u8 tevstage,u8 mode)
2503  * \brief Simplified function to set various TEV parameters for this \a tevstage based on a predefined combiner \a mode.
2504  *
2505  * \details This is a convenience function designed to make initial programming of the Texture Environment unit (TEV) easier. This function calls
2506  * GX_SetTevColorIn(), GX_SetTevColorOp(), GX_SetTevAlphaIn() and GX_SetTevAlphaOp() with predefined arguments to implement familiar texture
2507  * combining functions.
2508  *
2509  * \note To enable a consecutive set of TEV stages, you must call GX_SetNumTevStages().
2510  *
2511  * \param[in] tevstage \ref tevstage.
2512  * \param[in] mode \ref tevdefmode
2513  *
2514  * \return none
2515  */
2516 void GX_SetTevOp(u8 tevstage,u8 mode);
2517 
2518 /*!
2519  * \fn void GX_SetTevColor(u8 tev_regid,GXColor color)
2520  * \brief Used to set one of the primary color registers in the TEV unit.
2521  *
2522  * \details These registers are available to all TEV stages. At least one of these registers is used to pass the output of one TEV stage to
2523  * the next in a multi-texture configuration. The application is responsible for allocating these registers so that no collisions in usage occur.
2524  *
2525  * \note This function can only set unsigned 8-bit colors. To set signed, 10-bit colors use GX_SetTevColorS10().
2526  *
2527  * \param[in] tev_regid \ref tevcoloutreg.
2528  * \param[in] color Constant color value.
2529  *
2530  * \return none
2531  */
2532 void GX_SetTevColor(u8 tev_regid,GXColor color);
2533 
2534 /*!
2535  * \fn void GX_SetTevColorS10(u8 tev_regid,GXColorS10 color)
2536  * \brief Used to set one of the constant color registers in the TEV unit.
2537  *
2538  * \details These registers are available to all TEV stages. At least one of these registers is used to pass the output of one TEV stage to the
2539  * next in a multi-texture configuration. The application is responsible for allocating these registers so that no collisions in usage occur.
2540  *
2541  * \note This function enables the color components to be signed 10-bit numbers. To set 8-bit unsigned colors (the common case), use GX_SetTevColor().
2542  *
2543  * \param[in] tev_regid \ref tevcoloutreg.
2544  * \param[in] color Constant color value in S10 format.
2545  *
2546  * \return none
2547  */
2548 void GX_SetTevColorS10(u8 tev_regid,GXColorS10 color);
2549 
2550 /*!
2551  * \fn void GX_SetTevColorIn(u8 tevstage,u8 a,u8 b,u8 c,u8 d)
2552  * \brief Sets the color input sources for one \a tevstage of the Texture Environment (TEV) color combiner.
2553  *
2554  * \details This includes constant (register) colors and alphas, texture color/alpha, rasterized color/alpha (the result of per-vertex lighting),
2555  * and a few useful constants.
2556  *
2557  * \note The input controls are independent for each TEV stage.
2558  *
2559  * \param[in] tevstage \ref tevstage
2560  * \param[in] a \ref tevcolorarg
2561  * \param[in] b \ref tevcolorarg
2562  * \param[in] c \ref tevcolorarg
2563  * \param[in] d \ref tevcolorarg
2564  *
2565  * \return none
2566  */
2567 void GX_SetTevColorIn(u8 tevstage,u8 a,u8 b,u8 c,u8 d);
2568 
2569 /*!
2570  * \fn void GX_SetTevAlphaIn(u8 tevstage,u8 a,u8 b,u8 c,u8 d)
2571  * \brief Sets the alpha input sources for one \a tevstage of the Texture Environment (TEV) alpha combiner.
2572  *
2573  * \details There are fewer alpha inputs than color inputs, and there are no color channels available in the alpha combiner.
2574  *
2575  * \note The input controls are independent for each TEV stage.
2576  *
2577  * \param[in] tevstage \ref tevstage
2578  * \param[in] a \ref tevalphaarg
2579  * \param[in] b \ref tevalphaarg
2580  * \param[in] c \ref tevalphaarg
2581  * \param[in] d \ref tevalphaarg
2582  *
2583  * \return none
2584  */
2585 void GX_SetTevAlphaIn(u8 tevstage,u8 a,u8 b,u8 c,u8 d);
2586 
2587 /*!
2588  * \fn void GX_SetTevColorOp(u8 tevstage,u8 tevop,u8 tevbias,u8 tevscale,u8 clamp,u8 tevregid)
2589  * \brief Sets the \a tevop, \a tevbias, \a tevscale and \a clamp-mode operation for the color combiner
2590  *        for this \a tevstage of the TEV unit.
2591  *
2592  * \details This function also specifies the register, \a tevregid, that will contain the result of the color combiner function. The color
2593  * combiner function is:<br><br>
2594  *
2595  *		  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\a tevregid = (d (\a tevop) ((1.0 - c)*a + c*b) + \a tevbias) * \a tevscale;<br><br>
2596  *
2597  *
2598  * The input sources a,b,c and d are set using GX_SetTevColorIn().
2599  *
2600  * \param[in] tevstage \ref tevstage.
2601  * \param[in] tevop \ref tevop
2602  * \param[in] tevbias \ref tevbias.
2603  * \param[in] tevscale \ref tevscale.
2604  * \param[in] clamp Clamp results when <tt>GX_TRUE</tt>.
2605  * \param[in] tevregid \ref tevcoloutreg
2606  *
2607  * \return none
2608  */
2609 void GX_SetTevColorOp(u8 tevstage,u8 tevop,u8 tevbias,u8 tevscale,u8 clamp,u8 tevregid);
2610 
2611 /*!
2612  * \fn void GX_SetTevAlphaOp(u8 tevstage,u8 tevop,u8 tevbias,u8 tevscale,u8 clamp,u8 tevregid)
2613  * \brief Sets the \a tevop, \a tevbias, \a tevscale and \a clamp-mode operation for the alpha combiner
2614  *        for this \a tevstage of the TEV unit.
2615  *
2616  * \details This function also specifies the register, \a tevregid, that will contain the result of the alpha combiner function. The alpha
2617  * combiner function is:<br><br>
2618  *
2619  *        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\a tevregid = (d (\a tevop) ((1.0 - c)*a + c*b) + \a tevbias) * \a tevscale;<br><br>
2620  *
2621  * The input sources a,b,c and d are set using GX_SetTevAlphaIn().
2622  *
2623  * \param[in] tevstage \ref tevstage.
2624  * \param[in] tevop \ref tevop
2625  * \param[in] tevbias \ref tevbias.
2626  * \param[in] tevscale \ref tevscale.
2627  * \param[in] clamp Clamp results when <tt>GX_TRUE</tt>.
2628  * \param[in] tevregid \ref tevcoloutreg
2629  *
2630  * \return none
2631  */
2632 void GX_SetTevAlphaOp(u8 tevstage,u8 tevop,u8 tevbias,u8 tevscale,u8 clamp,u8 tevregid);
2633 
2634 /*!
2635  * \fn void GX_SetNumTexGens(u32 nr)
2636  * \brief Sets the number of texture coordinates that are generated and available for use in the Texture Environment TEV stages.
2637  *
2638  * \details Texture coordinates are generated from input data as described by GX_SetTexCoordGen(). The generated texture coordinates are linked to
2639  * specific textures and specific TEV stages using GX_SetTevOrder().
2640  *
2641  * \note A consecutive number of texture coordinates may be generated, starting at <tt>GX_TEXCOORD0</tt>. A maximum of 8 texture coordinates may be generated.
2642  * If \a nr is set to 0, no texture coordinates will be generated. In this case, at least one color channel must be output (see GX_SetNumChans()).
2643  *
2644  * \param[in] nr number of tex coords to generate, between 0 and 8 inclusive
2645  *
2646  * \return none
2647  */
2648 void GX_SetNumTexGens(u32 nr);
2649 
2650 /*!
2651  * \fn void GX_SetTexCoordGen(u16 texcoord,u32 tgen_typ,u32 tgen_src,u32 mtxsrc)
2652  * \brief Specifies how texture coordinates are generated.
2653  *
2654  * \details Output texture coordinates are usually the result of some transform of an input attribute; either position, normal, or texture coordinate.
2655  * You can also generate texture coordinates from the output color channel of the per-vertex lighting calculations. In C-language syntax the texture
2656  * coordinate generation function would look like this:<br><br>
2657  *
2658  * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\a texcoord = \a tgen_typ(\a tgen_src, \a mtxsrc);<br><br>
2659  *
2660  * The current vertex descriptor as set by GX_SetVtxDesc() only describes the data input to the graphics processor. Using this function, you can create
2661  * new output texture coordinates from the input data. The texcoord parameter is used to give the output texture coordinate a name. This texture
2662  * coordinate can be bound to a texture using GX_SetTevOrder(). GX_SetNumTexGens() specifies a consecutive number of texture coordinates, starting at
2663  * <tt>GX_TEXCOORD0</tt>, that are available to GX_SetTevOrder().
2664  *
2665  * \ref texmtx defines a default set of texture matrix names that can be supplied as mtxsrc. The matrix names are actually row addresses (4 floats per
2666  * row) in the matrix memory that indicate the first row of a loaded matrix. The user may define another memory map of matrix memory to suit their
2667  * needs. Keep in mind, however, that modelview matrices (see GX_LoadPosMtxImm() and \ref pnmtx) and texture matrices share matrix memory.
2668  *
2669  * \note Input texture coordinates must always go through the texture coordinate generation hardware. GX_Init() initializes the hardware (by calling
2670  * this function) so that all texture coordinates are transformed by the <tt>GX_IDENTITY</tt> matrix in order to appear as if input coordinates are passed
2671  * unchanged through to the texture hardware.
2672  *
2673  * There are 8 output texture coordinates that can be referenced in any of the 16 TEV stages. There are a maximum of 8 input texture coordinates.
2674  *
2675  * \param[in] texcoord \ref texcoordid
2676  * \param[in] tgen_typ \ref texgentyp
2677  * \param[in] tgen_src \ref texgensrc
2678  * \param[in] mtxsrc \ref texmtx
2679  *
2680  * \return none
2681  */
2682 void GX_SetTexCoordGen(u16 texcoord,u32 tgen_typ,u32 tgen_src,u32 mtxsrc);
2683 
2684 /*!
2685  * \fn void GX_SetTexCoordGen2(u16 texcoord,u32 tgen_typ,u32 tgen_src,u32 mtxsrc,u32 normalize,u32 postmtx)
2686  * \brief An extension of GX_SetTexCoordGen(). It allows one to specify additional texgen options.
2687  *
2688  * \details The first four arguments are identical to those for GX_SetTexCoordGen() and function in the same way. All requirements for the first
2689  * four arguments are the same as they are for that function as well. The new options only apply for "ordinary" texgens, where the texgen type is
2690  * <tt>GX_TG_MTX2x4</tt> or <tt>GX_TG_MTX3x4</tt>. They do not work for light-based texgens or emboss texgens.
2691  *
2692  * The \a normalize argument allows the computed texcoord to be normalized after the multiplication by \a mtxsrc (the first-pass transformation).
2693  * After the optional normalization step, the texcoord is then multiplied by the 3x4 matrix \a postmtx. This matrix is refered to as the
2694  * post-transform matrix.
2695  *
2696  * The result of this step is the texture coordinate that is used to look up the texture.
2697  *
2698  * \note The post-transform matrices are separate from the first pass matrices. They are stored in a separate memory area in the same format as the
2699  * first pass matrices, except that all matrices have three rows.<br><br>
2700  *
2701  * \note When a vertex contains only position and one texture coordinate and the texgen type is <tt>GX_TG_MTX2x4</tt>, there are certain limitations. In
2702  * this special performance case, normalization is not performed (even if specified).
2703  *
2704  * \param[in] texcoord \ref texcoordid
2705  * \param[in] tgen_typ \ref texgentyp
2706  * \param[in] tgen_src \ref texgensrc
2707  * \param[in] mtxsrc \ref texmtx
2708  * \param[in] normalize if <tt>GX_TRUE</tt>, normalize tex coord after first-pass transform. Only used with <tt>GX_TG_MTX*</tt>.
2709  * \param[in] postmtx \ref dttmtx
2710  *
2711  * \return none
2712  */
2713 void GX_SetTexCoordGen2(u16 texcoord,u32 tgen_typ,u32 tgen_src,u32 mtxsrc,u32 normalize,u32 postmtx);
2714 
2715 /*!
2716  * \fn void GX_SetZTexture(u8 op,u8 fmt,u32 bias)
2717  * \brief Controls Z texture operations.
2718  *
2719  * \details Z textures can be used to implement image-based rendering algorithms. A composite image consisting of color and depth image planes can
2720  * be merged into the Embedded Frame Buffer (EFB).
2721  *
2722  * Normally, the Z for a quad (2x2) of pixels is computed as a reference Z and two slopes. Once Z texturing is enabled, the Z is computed by adding
2723  * a Z texel to the reference Z (\a op = <tt>GX_ZT_ADD</tt>) or by replacing the reference Z with the Z texel value (\a op = <tt>GX_ZT_REPLACE</tt>).
2724  *
2725  * Z textures are always the output from the last active Texture Environment (TEV) stage (see GX_SetNumTevStages()) when enabled. When Z texturing is
2726  * enabled, the texture color of the last TEV stage is not available, but all other color inputs and operations are available. The pixel color is
2727  * always output from the last active TEV stage. You cannot use the TEV to operate on the Z texture, it is fed directly into the Z texture logic.
2728  *
2729  * Z texel formats can be unsigned 8-bit (<tt>GX_TF_Z8</tt>), 16-bit (<tt>GX_TF_Z16</tt>), or 24-bit (<tt>GX_TF_Z24X8</tt> (32-bit texture)) are used. The Graphics Processor
2730  * converts the Z-textures to 24-bit values by placing the texel value in the least-significant bits and inserting zero's in the remaining
2731  * most-significant bits. The 24-bit constant \a bias is added to the Z texture. If the pixel format is GX_PF_RGB565_Z16 the 24-bit result is converted
2732  * to the current 16-bit Z format before comparing with the EFB's Z.
2733  *
2734  * \note The Z-texture calculation is done before the fog range calculation.<br><br>
2735  *
2736  * \note GX_Init() disables Z texturing.
2737  *
2738  * \param[in] op \ref ztexop to perform
2739  * \param[in] fmt \ref ztexfmt to use
2740  * \param[in] bias Bias value. Format is 24bit unsigned.
2741  *
2742  * \return none
2743  */
2744 void GX_SetZTexture(u8 op,u8 fmt,u32 bias);
2745 
2746 /*!
2747  * \fn void GX_SetZMode(u8 enable,u8 func,u8 update_enable)
2748  * \brief Sets the Z-buffer compare mode.
2749  *
2750  * \details The result of the Z compare is used to conditionally write color values to the Embedded Frame Buffer (EFB).
2751  *
2752  * When \a enable is set to <tt>GX_DISABLE</tt>, Z buffering is disabled and the Z buffer is not updated.
2753  *
2754  * The \a func parameter determines the comparison that is performed. In the comparison function, the newly rasterized Z value is on the left
2755  * while the Z value from the Z buffer is on the right. If the result of the comparison is false, the newly rasterized pixel is discarded.
2756  *
2757  * The parameter \a update_enable determines whether or not the Z buffer is updated with the new Z value after a comparison is performed. This
2758  * parameter also affects whether the Z buffer is cleared during copy operations (see GX_CopyDisp() and GX_CopyTex()).
2759  *
2760  * \param[in] enable Enables comparisons with source and destination Z values if <tt>GX_TRUE</tt>; disables compares otherwise.
2761  * \param[in] func \ref compare
2762  * \param[in] update_enable Enables Z-buffer updates when <tt>GX_TRUE</tt>; otherwise, Z-buffer updates are disabled, but compares may still be enabled.
2763  *
2764  * \return none
2765  */
2766 void GX_SetZMode(u8 enable,u8 func,u8 update_enable);
2767 
2768 /*!
2769  * \fn void GX_SetZCompLoc(u8 before_tex)
2770  * \brief Sets whether Z buffering happens before or after texturing.
2771  *
2772  * \details Normally, Z buffering should happen before texturing, as this enables better performance by not texturing pixels that are not
2773  * visible; however, when alpha compare is used, Z buffering must be done after texturing (see GX_SetAlphaCompare()).
2774  *
2775  * \param[in] before_tex Enables Z-buffering before texturing when set to <tt>GX_TRUE</tt>; otherwise, Z-buffering takes place after texturing.
2776  *
2777  * \return none
2778  */
2779 void GX_SetZCompLoc(u8 before_tex);
2780 
2781 /*!
2782  * \fn void GX_SetLineWidth(u8 width,u8 fmt)
2783  * \brief Sets the width of line primitives.
2784  *
2785  * The parameter \a fmt is added to the texture coordinate to obtain texture coordinates at the other corners of a wide line. The \a fmt
2786  * values are added after the texture coordinate generation operation; see GX_SetTexCoordGen().
2787  *
2788  * \param[in] width width of the line in 1/16th pixel increments; maximum width is 42.5 px
2789  * \param[in] fmt \ref texoff
2790  *
2791  * \return none
2792  */
2793 void GX_SetLineWidth(u8 width,u8 fmt);
2794 
2795 /*!
2796  * \fn void GX_SetPointSize(u8 width,u8 fmt)
2797  * \brief Sets the size of point primitives.
2798  *
2799  * \details The parameter \a fmt is added to the texture coordinate(s), if any, to obtain texture coordinates at the other corners of a point. The
2800  * \a fmts are added after the texture coordinate generation operation; see GX_SetTexCoordGen().
2801  *
2802  * \param[in] width width of the point in 1/16th pixel increments; maximum width is 42.5 px
2803  * \param[in] fmt \ref texoff
2804  *
2805  * \return none
2806  */
2807 void GX_SetPointSize(u8 width,u8 fmt);
2808 
2809 /*!
2810  * \fn void GX_SetBlendMode(u8 type,u8 src_fact,u8 dst_fact,u8 op)
2811  * \brief Determines how the source image, generated by the graphics processor, is blended with the Embedded Frame Buffer (EFB).
2812  *
2813  * \details When \a type is set to <tt>GX_BM_NONE</tt>, the source data is written directly to the EFB. When \a type is set to <tt>GX_BM_BLEND</tt>, the source color and EFB
2814  * pixels are blended using the following equation:
2815  *
2816  * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<i>dst_pix_clr</i> = <i>src_pix_clr</i> * \a src_fact + <i>dst_pix_clr</i> * \a dst_fact
2817  *
2818  * The <tt>GX_BL_DSTALPHA</tt> / <tt>GX_BL_INVDSTALPHA</tt> can be used only when the EFB has <tt>GX_PF_RGBA6_Z24</tt> as the pixel format (see GX_SetPixelFmt()). If the pixel
2819  * format is <tt>GX_PF_RGBA6_Z24</tt> then the \a src_fact and \a dst_fact are also applied to the alpha channel. To write the alpha channel to the EFB you must
2820  * call GX_SetAlphaUpdate().
2821  *
2822  * When type is set to <tt>GX_BM_LOGIC</tt>, the source and EFB pixels are blended using logical bitwise operations. When type is set to <tt>GX_BM_SUBTRACT</tt>, the destination
2823  * pixel is computed as follows:
2824  *
2825  * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<i>dst_pix_clr</i> = <i>dst_pix_clr</i> - <i>src_pix_clr [clamped to zero]</i>
2826  *
2827  * Note that \a src_fact and \a dst_fact are not part of this equation.
2828  *
2829  * \note Color updates should be enabled by calling GX_SetColorUpdate().
2830  *
2831  * \param[in] type \ref blendmode
2832  * \param[in] src_fact \ref blendfactor
2833  * \param[in] dst_fact \ref blendfactor
2834  * \param[in] op \ref logicop
2835  *
2836  * \return none
2837  */
2838 void GX_SetBlendMode(u8 type,u8 src_fact,u8 dst_fact,u8 op);
2839 
2840 /*!
2841  * \fn void GX_SetCullMode(u8 mode)
2842  * \brief Enables or disables culling of geometry based on its orientation to the viewer.
2843  *
2844  * \details Primitives in which the vertex order is clockwise to the viewer are considered front-facing.
2845  *
2846  * \note GX_Init() sets this to <tt>GX_CULL_BACK</tt>.
2847  *
2848  * \param[in] mode \ref cullmode
2849  *
2850  * \return none
2851  */
2852 void GX_SetCullMode(u8 mode);
2853 
2854 /*!
2855  * \fn void GX_SetCoPlanar(u8 enable)
2856  * \brief Enables or disables coplanar triangle processing.
2857  *
2858  * \details While coplanar mode is enabled, all subsequent triangles (called decal triangles) will have the same Z coefficients as the reference
2859  * plane. Coplanar mode should be enabled immediately after a reference triangle is drawn.
2860  *
2861  * \note The reference triangle can be culled using <tt>GX_SetCullMode(GX_CULL_ALL)</tt> to create an invisible reference plane; however, the reference
2862  * triangle must not be completely out of view, i.e. trivially rejected by clipping.<br><br>
2863  *
2864  * \note GX_Init() disables coplanar mode.
2865  *
2866  * \param[in] enable when <tt>GX_ENABLE</tt>, coplanar mode is enabled; <tt>GX_DISABLE</tt> disables this mode
2867  *
2868  * \return none
2869  */
2870 void GX_SetCoPlanar(u8 enable);
2871 
2872 /*!
2873  * \fn void GX_EnableTexOffsets(u8 coord,u8 line_enable,u8 point_enable)
2874  * \brief Enables a special texture offset feature for points and lines.
2875  *
2876  * \details When a point's size is defined using GX_SetPointSize() or a line's width is described using GX_SetLineWidth(), you can also specify a second
2877  * parameter. The parameter \a fmt is added to the texture coordinate(s), if any, to obtain texture coordinates at the other corners of a
2878  * point or line. The \a fmts are added after the texture coordinate generation operation; see GX_SetTexCoordGen(). This function enables this
2879  * operation for a particular texture coordinate. Offset operations for points and lines are enabled separately. If the enables are false, the same
2880  * texture coordinate is used for every vertex of the line or point.
2881  *
2882  * \param[in] coord \ref texcoordid
2883  * \param[in] line_enable enable or disable tex offset calculation for lines
2884  * \param[in] point_enable enable or disable tex offset calculation for points
2885  *
2886  * \return none
2887  */
2888 void GX_EnableTexOffsets(u8 coord,u8 line_enable,u8 point_enable);
2889 
2890 /*!
2891  * \fn void GX_SetClipMode(u8 mode)
2892  * \brief Enables or disables clipping of geometry.
2893  *
2894  * \details This may help performance issues that occur when objects are far-clipped; however, any near-clipped objects will be rendered incorrectly.
2895  *
2896  * \note GX_Init() sets this to <tt>GX_CLIP_ENABLE</tt>.
2897  *
2898  * \param[in] mode \ref clipmode
2899  *
2900  * \return none
2901  */
2902 void GX_SetClipMode(u8 mode);
2903 
2904 /*!
2905  * \fn void GX_SetScissor(u32 xOrigin,u32 yOrigin,u32 wd,u32 ht)
2906  * \brief Sets the scissor rectangle.
2907  *
2908  * \details The scissor rectangle specifies an area of the screen outside of which all primitives are culled. This function sets the scissor rectangle in
2909  * screen coordinates. The screen origin (\a xOrigin=0, \a yOrigin=0) is at the top left corner of the display.
2910  *
2911  * The values may be within the range of 0 - 2047 inclusive. Using values that extend beyond the EFB size is allowable since the scissor box may be
2912  * repositioned within the EFB using GX_SetScissorBoxOffset().
2913  *
2914  * \note By default, the scissor rectangle is set to match the viewport rectangle. GX_Init() initializes the scissor rectangle to match the viewport
2915  * given the current render mode.
2916  *
2917  * \param[in] xOrigin left-most coord in screen coordinates
2918  * \param[in] yOrigin top-most coord in screen coordinates
2919  * \param[in] wd width of the scissorbox in screen coordinates
2920  * \param[in] ht height of the scissorbox in screen coordinates
2921  *
2922  * \return none
2923  */
2924 void GX_SetScissor(u32 xOrigin,u32 yOrigin,u32 wd,u32 ht);
2925 
2926 /*!
2927  * \fn void GX_SetScissorBoxOffset(s32 xoffset,s32 yoffset)
2928  * \brief Repositions the scissorbox rectangle within the Embedded Frame Buffer (EFB) memory space.
2929  *
2930  * \details The offsets are subtracted from the screen coordinates to determine the actual EFB coordinates where the pixels are stored. Thus with
2931  * positive offsets, the scissor box may be shifted left and/or up; and with negative offsets, the scissor box may be shifted right and/or down.
2932  *
2933  * The intended use for this command is to make it easy to do two-pass antialiased rendering. To draw the top half of the screen, the scissor box is set to
2934  * the top and the offset set to zero. To draw the bottom half, the scissor box is set to the bottom, and the offset is set to shift the scissor box back up
2935  * to the top.
2936  *
2937  * Another use for the offset is to displace how an image is rendered with respect to the dither matrix. Since the dither matrix is 4x4, a \a yoffset of -2
2938  * shifts the image down by 2 lines with respect to the matrix. This can be useful for field-rendering mode.
2939  *
2940  * \note Achieving an offset of an odd number of lines is possible, but more difficult than just changing the scissor box: one must render and copy 2
2941  * additional lines, then skip one by adjusting the argument of VIDEO_SetNextFrameBuffer().<br><br>
2942  *
2943  * \note GX_Init() initializes the scissor box offset to zero. Since the GP works on 2x2 regions of pixels, only even offsets are allowed.
2944  *
2945  * \param[in] xoffset number of pixels to shift the scissorbox left, between -342 - 382 inclusive; must be even
2946  * \param[in] yoffset number of pixels to shift the scissorbox up, between -342 - 494 inclusive; must be even
2947  *
2948  * \return none
2949  */
2950 void GX_SetScissorBoxOffset(s32 xoffset,s32 yoffset);
2951 
2952 /*!
2953  * \fn void GX_SetNumChans(u8 num)
2954  * \brief Sets the number of color channels that are output to the TEV stages.
2955  *
2956  * \details Color channels are the mechanism used to compute per-vertex lighting effects. Color channels are controlled using GX_SetChanCtrl().
2957  * Color channels are linked to specific TEV stages using GX_SetTevOrder().
2958  *
2959  * This function basically defines the number of per-vertex colors that get rasterized. If \a num is set to 0, then at least one texture coordinate
2960  * must be generated (see GX_SetNumTexGens()). If \a num is set to 1, then channel <tt>GX_COLOR0A0</tt> will be rasterized. If \a num is set to 2 (the maximum
2961  * value), then <tt>GX_COLOR0A0</tt> and <tt>GX_COLOR1A1</tt> will be rasterized.
2962  *
2963  * \param[in] num number of color channels to rasterize; number must be 0, 1 or 2
2964  *
2965  * \return none
2966  */
2967 void GX_SetNumChans(u8 num);
2968 
2969 /*!
2970  * \fn void GX_SetTevOrder(u8 tevstage,u8 texcoord,u32 texmap,u8 color)
2971  * \brief Specifies the texture and rasterized color that will be available as inputs to this TEV \a tevstage.
2972  *
2973  * The texture coordinate \a texcoord is generated from input attributes using the GX_SetTexCoordGen() function and is used to look up the
2974  * texture map, previously loaded by GX_LoadTexObj(). The \a color to rasterize for this \a tevstage is also specified. The color
2975  * is the result of per-vertex lighting which is controlled by GX_SetChanCtrl().
2976  *
2977  * This function will scale the normalized texture coordinates produced by GX_SetTexCoordGen() according to the size of the texture map in the
2978  * function call. For this reason, texture coordinates can only be broadcast to multiple texture maps if and only if the maps are the same size. In
2979  * some cases, you may want to generate a texture coordinate having a certain scale, but disable the texture lookup (this comes up when generating
2980  * texture coordinates for indirect bump mapping). To accomplish this, use the <tt>GX_TEXMAP_DISABLE</tt> flag:
2981  *
2982  * \code GX_SetTevOrder(GX_TEVSTAGE1, GX_TEXCOORD0, GX_TEXMAP3 | GX_TEXMAP_DISABLE, GX_COLORNULL); \endcode
2983  *
2984  * \details This will scale <tt>GX_TEXCOORD0</tt> using <tt>GX_TEXMAP3</tt> but disable the lookup of <tt>GX_TEXMAP3</tt>.
2985  *
2986  * \note This function does not enable the TEV stage. To enable a consecutive number of TEV stages, starting at stage <tt>GX_TEVSTAGE0</tt>, use GX_SetNumTevStages().<br><br>
2987  *
2988  * \note The operation of each TEV stage is independent. The color operations are controlled by GX_SetTevColorIn() and GX_SetTevColorOp(). The alpha
2989  * operations are controlled by GX_SetTevAlphaIn() and GX_SetTevAlphaOp().<br><br>
2990  *
2991  * \note The number of texture coordinates available for all the active TEV stages is set using GX_SetNumTexGens(). The number of color channels
2992  * available for all the active TEV stages is set using GX_SetNumChans(). Active TEV stages should not reference more texture coordinates or colors
2993  * than are being generated.<br><br>
2994  *
2995  * \note There are some special settings for the \a color argument. If you specify <tt>GX_COLOR_ZERO</tt>, you always get zero as rasterized color. If you specify
2996  * <tt>GX_ALPHA_BUMP</tt> or <tt>GX_ALPHA_BUMPN</tt>, you can use "Bump alpha" component from indirect texture unit as rasterized color input (see GX_SetTevIndirect()
2997  * for details about how to configure bump alpha). Since bump alpha contains only 5-bit data, <tt>GX_ALPHA_BUMP</tt> shifts them to higher bits, which makes the
2998  * value range 0-248. Meanwhile <tt>GX_ALPHA_BUMPN</tt> performs normalization and you can get the value range 0-255.
2999  *
3000  * \param[in] tevstage \ref tevstage
3001  * \param[in] texcoord \ref texcoordid
3002  * \param[in] texmap \ref texmapid
3003  * \param[in] color \ref channelid
3004  *
3005  * \return none
3006  */
3007 void GX_SetTevOrder(u8 tevstage,u8 texcoord,u32 texmap,u8 color);
3008 
3009 /*!
3010  * \fn void GX_SetNumTevStages(u8 num)
3011  * \brief Enables a <i>consecutive</i> number of TEV stages.
3012  *
3013  * \details The output pixel color (before fogging and blending) is the result from the last stage. The last TEV stage must write to register <tt>GX_TEVPREV</tt>;
3014  * see GX_SetTevColorOp() and GX_SetTevAlphaOp(). At least one TEV stage must be enabled. If a Z-texture is enabled, the Z texture must be looked up on
3015  * the last stage; see GX_SetZTexture().
3016  *
3017  * \note The association of lighting colors, texture coordinates, and texture maps with a TEV stage is set using GX)SetTevOrder(). The number of texture
3018  * coordinates available is set using GX_SetNumTexGens(). The number of color channels available is set using GX_SetNumChans().<br><br>
3019  *
3020  * \note GX_Init() will set \a num to 1.
3021  *
3022  * \param[in] num number of active TEV stages, between 1 and 16 inclusive
3023  *
3024  * \return none
3025  */
3026 void GX_SetNumTevStages(u8 num);
3027 
3028 /*!
3029  * \fn void GX_SetAlphaCompare(u8 comp0,u8 ref0,u8 aop,u8 comp1,u8 ref1)
3030  * \brief Sets the parameters for the alpha compare function which uses the alpha output from the last active TEV stage.
3031  *
3032  * \details The alpha compare operation is:<br><br>
3033  *
3034  * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<i>alpha_pass</i> = (<i>alpha_src</i> (\a comp0) \a ref0) (\a op) (<i>alpha_src</i> (\a comp1) \a ref1)<br><br>
3035  *
3036  * where <i>alpha_src</i> is the alpha from the last active TEV stage. As an example, you can implement these equations:<br><br>
3037  *
3038  * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<i>alpha_pass</i> = (<i>alpha_src</i> \> \a ref0) <b>AND</b> (<i>alpha_src</i> \< \a ref1)
3039  *
3040  * or
3041  *
3042  * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<i>alpha_pass</i> = (<i>alpha_src</i> \> \a ref0) <b>OR</b> (<i>alpha_src</i> \< \a ref1)
3043  *
3044  * \note The output alpha can be used in the blending equation (see GX_SetBlendMode()) to control how source and destination (frame buffer)
3045  * pixels are combined.<br><br>
3046  *
3047  * \note The Z compare can occur either before or after texturing (see GX_SetZCompLoc()). In the case where Z compare occurs before texturing, the Z is
3048  * written based only on the Z test. The color is written if both the Z test and alpha test pass. When Z compare occurs <i>after</i> texturing, the color
3049  * and Z are written if both the Z test and alpha test pass. When using texture to make cutout shapes (like billboard trees) that need to be correctly Z
3050  * buffered, you should configure the pipeline to Z buffer after texturing.<br><br>
3051  *
3052  * \note The number of active TEV stages is specified using GX_SetNumTevStages().
3053  *
3054  * \param[in] comp0 \ref compare subfunction 0
3055  * \param[in] ref0 reference val for subfunction 0
3056  * \param[in] aop \ref alphaop for combining subfunctions 0 and 1; must not be <tt>GX_MAX_ALPHAOP</tt>
3057  * \param[in] comp1 \ref compare subfunction 1
3058  * \param[in] ref1 reference val for subfunction 1
3059  *
3060  * \return none
3061  */
3062 void GX_SetAlphaCompare(u8 comp0,u8 ref0,u8 aop,u8 comp1,u8 ref1);
3063 
3064 /*!
3065  * \fn void GX_SetTevKColor(u8 sel, GXColor col)
3066  * \brief Sets one of the "konstant" color registers in the TEV unit.
3067  *
3068  * \details These registers are available to all TEV stages. They are constant in the sense that they cannot be written to be the TEV itself.
3069  *
3070  * \param[in] sel \ref tevkcolorid
3071  * \param[in] col constant color value
3072  *
3073  * \return none
3074  */
3075 void GX_SetTevKColor(u8 sel, GXColor col);
3076 
3077 /*!
3078  * \fn void GX_SetTevKColorSel(u8 tevstage,u8 sel)
3079  * \brief Selects a "konstant" color input to be used in a given TEV stage.
3080  *
3081  * The constant color input is used only if <tt>GX_CC_KONST</tt> is selected for an input for that TEV stage. Only one constant color selection is
3082  * available for a given TEV stage, though it may be used for more than one input.
3083  *
3084  * \param[in] tevstage \ref tevstage
3085  * \param[in] sel \ref tevkcolorsel
3086  *
3087  * \return none
3088  */
3089 void GX_SetTevKColorSel(u8 tevstage,u8 sel);
3090 
3091 /*!
3092  * \fn void GX_SetTevKAlphaSel(u8 tevstage,u8 sel)
3093  * \brief Selects a "konstant" alpha input to be used in a given TEV stage.
3094  *
3095  * \details The constant alpha input is used only if <tt>GX_CA_KONST</tt> is selected for an input for that TEV stage. Only one constant alpha selection is
3096  * available for a given TEV stage, though it may be used for more than one input.
3097  *
3098  * \param[in] tevstage \ref tevstage
3099  * \param[in] sel \ref tevkalphasel
3100  *
3101  * \return none
3102  */
3103 void GX_SetTevKAlphaSel(u8 tevstage,u8 sel);
3104 
3105 /*!
3106  * \fn void GX_SetTevKColorS10(u8 sel, GXColorS10 col)
3107  * \brief Used to set one of the constant color registers in the Texture Environment (TEV) unit.
3108  *
3109  * \details These registers are available to all TEV stages. At least one of these registers is used to pass the output of one TEV stage to the next
3110  * in a multi-texture configuration.
3111  *
3112  * \note The application is responsible for allocating these registers so that no collisions in usage occur.<br><br>
3113  *
3114  * \note This function takes 10-bit signed values as color values; use GX_SetTevColor() to give 8-bit values.
3115  *
3116  * \param[in] sel \ref tevcoloutreg
3117  * \param[in] col constant color value
3118  *
3119  * \return none
3120  */
3121 void GX_SetTevKColorS10(u8 sel, GXColorS10 col);
3122 
3123 /*!
3124  * \fn void GX_SetTevSwapMode(u8 tevstage,u8 ras_sel,u8 tex_sel)
3125  * \brief Selects a set of swap modes for the rasterized color and texture color for a given TEV stage.
3126  *
3127  * \details This allows the color components of these inputs to be rearranged or duplicated.
3128  *
3129  * \note There are four different swap mode table entries, and each entry in the table specifies how the RGBA inputs map to the RGBA outputs.
3130  *
3131  * \param[in] tevstage \ref tevstage
3132  * \param[in] ras_sel selects a swap mode for the rasterized color input.
3133  * \param[in] tex_sel selects a swap mode for the texture color input.
3134  *
3135  * \return none
3136  */
3137 void GX_SetTevSwapMode(u8 tevstage,u8 ras_sel,u8 tex_sel);
3138 
3139 /*!
3140  * \fn void GX_SetTevSwapModeTable(u8 swapid,u8 r,u8 g,u8 b,u8 a)
3141  * \brief Sets up the TEV color swap table.
3142  *
3143  * \details The swap table allows the rasterized color and texture color to be swapped component-wise. An entry in the table specifies how the
3144  * input color components map to the output color components.
3145  *
3146  * \param[in] swapid \ref tevswapsel
3147  * \param[in] r input color component that should be mapped to the red output component.
3148  * \param[in] g input color component that should be mapped to the green output component.
3149  * \param[in] b input color component that should be mapped to the blue output component.
3150  * \param[in] a input color component that should be mapped to the alpha output component.
3151  *
3152  * \return none
3153  */
3154 void GX_SetTevSwapModeTable(u8 swapid,u8 r,u8 g,u8 b,u8 a);
3155 
3156 /*!
3157  * \fn void GX_SetTevIndirect(u8 tevstage,u8 indtexid,u8 format,u8 bias,u8 mtxid,u8 wrap_s,u8 wrap_t,u8 addprev,u8 utclod,u8 a)
3158  * \brief Controls how the results from an indirect lookup will be used to modify a given regular TEV stage lookup.
3159  *
3160  * \param[in] tevstage \ref tevstage being affected
3161  * \param[in] indtexid \ref indtexstage results to use with this TEV stage
3162  * \param[in] format \ref indtexformat, i.e. how many bits to extract from the indirect result color to use in indirect offsets and the indirect "bump" alpha
3163  * \param[in] bias \ref indtexbias to be applied to each component of the indirect offset
3164  * \param[in] mtxid which \ref indtexmtx and scale value to multiply the offsets with
3165  * \param[in] wrap_s \ref indtexwrap to use with the S component of the regular texture coordinate
3166  * \param[in] wrap_t \ref indtexwrap to use with the T component of the regular texture coordinate
3167  * \param[in] addprev whether the tex coords results from the previous TEV stage should be added in
3168  * \param[in] utclod whether to the unmodified (<tt>GX_TRUE</tt>) or modified (<tt>GX_FALSE</tt>) tex coords for mipmap LOD computation
3169  * \param[in] a which offset component will supply the \ref indtexalphasel, if any
3170  *
3171  * \return none
3172  */
3173 void GX_SetTevIndirect(u8 tevstage,u8 indtexid,u8 format,u8 bias,u8 mtxid,u8 wrap_s,u8 wrap_t,u8 addprev,u8 utclod,u8 a);
3174 
3175 /*!
3176  * \fn void GX_SetTevDirect(u8 tevstage)
3177  * \brief Used to turn off all indirect texture processing for the specified regular TEV stage.
3178  *
3179  * \param[in] tevstage the \ref tevstage to change
3180  *
3181  * \return none
3182  */
3183 void GX_SetTevDirect(u8 tevstage);
3184 
3185 /*!
3186  * \fn void GX_SetNumIndStages(u8 nstages)
3187  * \brief Used to set how many indirect lookups will take place.
3188  *
3189  * \details The results from these indirect lookups may then be used to alter the lookups for any number of regular TEV stages.
3190  *
3191  * \param[in] nstages number of indirect lookup stages
3192  *
3193  * \return none
3194  */
3195 void GX_SetNumIndStages(u8 nstages);
3196 
3197 /*!
3198  * \fn void GX_SetIndTexOrder(u8 indtexstage,u8 texcoord,u8 texmap)
3199  * \brief Used to specify the \a texcoord and \a texmap to used with a given indirect lookup.
3200  *
3201  * \param[in] indtexstage \ref indtexstage being affected
3202  * \param[in] texcoord \ref texcoordid to be used for this stage
3203  * \param[in] texmap \ref texmapid to be used for this stage
3204  *
3205  * \return none
3206  */
3207 void GX_SetIndTexOrder(u8 indtexstage,u8 texcoord,u8 texmap);
3208 
3209 /*!
3210  * \fn void GX_SetIndTexCoordScale(u8 indtexid,u8 scale_s,u8 scale_t)
3211  * \brief Allows the sharing of a texcoord between an indirect stage and a regular TEV stage.
3212  *
3213  * It allows the texture coordinates to be scaled down for use with an indirect map that is smaller than the corresponding regular map.
3214  *
3215  * \param[in] indtexid \ref indtexstage being affected
3216  * \param[in] scale_s \ref indtexscale factor for the S coord
3217  * \param[in] scale_t \ref indtexscale factor for the T coord
3218  *
3219  * \return none
3220  */
3221 void GX_SetIndTexCoordScale(u8 indtexid,u8 scale_s,u8 scale_t);
3222 
3223 /*!
3224  * \fn void GX_SetFog(u8 type,f32 startz,f32 endz,f32 nearz,f32 farz,GXColor col)
3225  * \brief Enables fog.
3226  *
3227  * \details Using \a type, the programmer may select one of several functions to control the fog density as a function of range to a quad (2x2 pixels).
3228  * Range is cosine corrected Z in the x-z plane (eye coordinates), but is not corrected in the y direction (see GX_SetFogRangeAdj()). The parameters \a startz and
3229  * \a endz allow further control over the fog behavior. The parameters \a nearz and \a farz should be set consistent with the projection matrix parameters. Note that these
3230  * parameters are defined in eye-space. The fog color, in RGBX format (i.e. the alpha component is ignored), is set using the \a col parameter. This will be the
3231  * color of the pixel when fully fogged.
3232  *
3233  * \note GX_Init() turns fog off by default.
3234  *
3235  * \param[in] type \ref fogtype to use
3236  * \param[in] startz minimum Z value at which the fog function is active
3237  * \param[in] endz maximum Z value at which the fog function is active
3238  * \param[in] nearz near plane (which should match the projection matrix parameters)
3239  * \param[in] farz far plane (which should match the projection matrix parameters)
3240  * \param[in] col fog color; alpha component is ignored
3241  *
3242  * \return none
3243  */
3244 void GX_SetFog(u8 type,f32 startz,f32 endz,f32 nearz,f32 farz,GXColor col);
3245 
3246 /*!
3247  * \fn void GX_SetFogRangeAdj(u8 enable,u16 center,GXFogAdjTbl *table)
3248  * \brief Enables or disables horizontal fog-range adjustment.
3249  *
3250  * \details This adjustment is a factor that is multiplied by the eye-space Z used for fog computation; it is based upon the X position of the pixels being
3251  * rendered. The Y direction is not compensated. This effectively increases the fog density at the edges of the screen, making for a more realistic fog
3252  * effect. The adjustment is computed per quad (2x2 pixels), not per-pixel. The center of the viewport is specified using \a center. The range adjustment
3253  * table is specified using \a table. The range adjust function is mirrored horizontally about the \a center.
3254  *
3255  * \note GX_Init() disables range adjustment.
3256  *
3257  * \sa GX_InitFogAdjTable()
3258  *
3259  * \param[in] enable enables adjustment when <tt>GX_ENABLE</tt> is passed; disabled with <tt>GX_DISABLE</tt>
3260  * \param[in] center centers the range adjust function; normally corresponds with the center of the viewport
3261  * \param[in] table range adjustment parameter table
3262  *
3263  * \return none
3264  */
3265 void GX_SetFogRangeAdj(u8 enable,u16 center,GXFogAdjTbl *table);
3266 
3267 /*!
3268  * \fn GX_SetFogColor(GXColor color)
3269  * \brief Sets the fog color.
3270  *
3271  * \details \a color is the color that a pixel will be if fully fogged. Alpha channel is ignored.
3272  *
3273  * \param[in] color color to set fog to
3274  */
3275 void GX_SetFogColor(GXColor color);
3276 
3277 /*!
3278  * \fn void GX_InitFogAdjTable(GXFogAdjTbl *table,u16 width,f32 projmtx[4][4])
3279  * \brief Generates the standard range adjustment table and puts the results into \a table.
3280  *
3281  * \details This table can be used by GX_SetFogRangeAdj() to adjust the eye-space Z used for fog based upon the X position of the pixels being rendered.
3282  * The Y direction is not compensated. This effectively increases the fog density at the edges of the screen, making for a more realistic fog effect. The
3283  * width of the viewport is specified using \a width. The \a projmtx parameter is the projection matrix that is used to render into the viewport. It must
3284  * be specified so that the function can compute the X extent of the viewing frustum in eye space.
3285  *
3286  * \note You must allocate \a table yourself.
3287  *
3288  * \param[in] table range adjustment parameter table
3289  * \param[in] width width of the viewport
3290  * \param[in] projmtx projection matrix used to render into the viewport
3291  */
3292 void GX_InitFogAdjTable(GXFogAdjTbl *table,u16 width,f32 projmtx[4][4]);
3293 
3294 /*!
3295  * \fn void GX_SetIndTexMatrix(u8 indtexmtx,f32 offset_mtx[2][3],s8 scale_exp)
3296  * \brief Sets one of the three static indirect matrices and the associated scale factor.
3297  *
3298  * \details The indirect matrix and scale is used to process the results of an indirect lookup in order to produce offsets to use during a regular lookup.
3299  * The matrix is multiplied by the [S T U] offsets that have been extracted (and optionally biased) from the indirect lookup color. In this matrix-vector
3300  * multiply, the matrix is on the left and the [S T U] column vector is on the right.
3301  *
3302  * \note The matrix values are stored in the hardware as a sign and 10 fractional bits (two's complement); thus the smallest number that can be stored is
3303  * -1 and the largest is (1 - 1/1024) or approximately 0.999. Since +1 cannot be stored, you may consider dividing all the matrix values by 2 (thus +1
3304  * becomes +0.5) and adding one to the scale value in order to compensate.
3305  *
3306  * \param[in] indtexmtx \ref indtexmtx that is being affected
3307  * \param[in] offset_mtx values to assign to the indirect matrix
3308  * \param[in] scale_exp exponent to use for the associated scale factor
3309  *
3310  * \return none
3311  */
3312 void GX_SetIndTexMatrix(u8 indtexmtx,f32 offset_mtx[2][3],s8 scale_exp);
3313 
3314 /*!
3315  * \fn void GX_SetTevIndBumpST(u8 tevstage,u8 indstage,u8 mtx_sel)
3316  * \brief Sets up an environment-mapped bump-mapped indirect lookup.
3317  *
3318  * \details The indirect map specifies offsets in (S,T) space. This kind of lookup requires 3 TEV stages to compute. As a result of all this work, a simple
3319  * 2D bump map is properly oriented to the surface to which it is applied. It is used to alter a normal-based texgen which then looks up an environment map.
3320  * The environment map may be a simple light map, or else it may be a reflection map of the surrounding scenery.
3321  *
3322  * \note When using this function, texture lookup should be disabled for the first two TEV stages. The third stage is where the texture lookup is actually performed.
3323  * The associated geometry must supply normal/binormal/tangent coordinates at each vertex. Appropriate texgens must supply each of these to the proper stages
3324  * (binormal to the first, tangent to the second, and normal to the third). Although a static indirect matrix is not used, one must choose a matrix slot and set up
3325  * the associated scale value to be used with this lookup.
3326  *
3327  * \param[in] tevstage \ref tevstage that is being affected
3328  * \param[in] indstage \ref indtexstage results to use with this TEV stage
3329  * \param[in] mtx_sel which \ref indtexmtx to multiply the offsets with
3330  *
3331  * \return none
3332  */
3333 void GX_SetTevIndBumpST(u8 tevstage,u8 indstage,u8 mtx_sel);
3334 
3335 /*!
3336  * \fn void GX_SetTevIndBumpXYZ(u8 tevstage,u8 indstage,u8 mtx_sel)
3337  * \brief Sets up an environment-mapped bump-mapped indirect lookup.
3338  *
3339  * \details The indirect map specifies offsets in object (X, Y, Z) space. This kind of lookup requires only one TEV stage to compute; however, the bump map (indirect
3340  * map) used is geometry-specific. Thus there is a space/computation tradeoff between using this function and using GX_SetTevIndBumpST().
3341  *
3342  * \note The indirect matrix must be loaded with a transformation for normals from object space to texture space (similar to eye space, but possibly with an inverted
3343  * Y axis). The surface geometry need only provide regular normals at each vertex. A normal-based texgen must be set up for the regular texture coordinate.
3344  *
3345  * \param[in] tevstage \ref tevstage that is being affected
3346  * \param[in] indstage \ref indtexstage results to use with this TEV stage
3347  * \param[in] mtx_sel which \ref indtexmtx to multiply the offsets with
3348  *
3349  * \return none
3350  */
3351 void GX_SetTevIndBumpXYZ(u8 tevstage,u8 indstage,u8 mtx_sel);
3352 
3353 /*!
3354  * \fn void GX_SetTevIndTile(u8 tevstage,u8 indtexid,u16 tilesize_x,u16 tilesize_y,u16 tilespacing_x,u16 tilespacing_y,u8 indtexfmt,u8 indtexmtx,u8 bias_sel,u8 alpha_sel)
3355  * \brief Used to implement tiled texturing using indirect textures.
3356  *
3357  * \details It will set up the correct values in the given indirect matrix; you only need to specify which matrix slot to use.
3358  *
3359  * \note The regular texture map contains only the tile definitions. The actual texture size to be applied to the polygon being drawn is the product of the base tile
3360  * size and the size of the indirect map. In order to set the proper texture coordinate scale, one must call GX_SetTexCoordScaleManually(). One can also use
3361  * GX_SetIndTexCoordScale() in order to use the same texcoord for the indirect stage as the regular TEV stage.
3362  *
3363  * \param[in] tevstage \ref tevstage that is being affected
3364  * \param[in] indtexid \ref indtexstage results to use with this TEV stage
3365  * \param[in] tilesize_x size of the tile in the X dimension
3366  * \param[in] tilesize_y size of the tile in the Y dimension
3367  * \param[in] tilespacing_x spacing of the tiles (in the tile-definition map) in the X dimension
3368  * \param[in] tilespacing_y spacing of the tiles (in the tile-definition map) in the Y dimension
3369  * \param[in] indtexfmt \ref indtexformat to use
3370  * \param[in] indtexmtx \ref indtexmtx to multiply the offsets with
3371  * \param[in] bias_sel \ref indtexbias to indicate tile stacking direction for pseudo-3D textures
3372  * \param[in] alpha_sel which \ref indtexalphasel will supply the indirect "bump" alpha, if any (for pseudo-3D textures).
3373  *
3374  * \return none
3375  */
3376 void GX_SetTevIndTile(u8 tevstage,u8 indtexid,u16 tilesize_x,u16 tilesize_y,u16 tilespacing_x,u16 tilespacing_y,u8 indtexfmt,u8 indtexmtx,u8 bias_sel,u8 alpha_sel);
3377 
3378 /*!
3379  * \fn void GX_SetTevIndRepeat(u8 tevstage)
3380  * \brief Set a given TEV stage to use the same texture coordinates as were computed in the previous stage.
3381  *
3382  * \note This is only useful when the previous stage texture coordinates took more than one stage to compute, as is the case for GX_SetTevIndBumpST().
3383  *
3384  * \param[in] tevstage \ref tevstage to modify
3385  *
3386  * \return none
3387  */
3388 void GX_SetTevIndRepeat(u8 tevstage);
3389 
3390 /*!
3391  * \fn void GX_SetColorUpdate(u8 enable)
3392  * \brief Enables or disables color-buffer updates when rendering into the Embedded Frame Buffer (EFB).
3393  *
3394  * \note This function also affects whether the color buffer is cleared during copies; see GX_CopyDisp() and GX_CopyTex().
3395  *
3396  * \param[in] enable enables color-buffer updates with <tt>GX_TRUE</tt>
3397  *
3398  * \return none
3399  */
3400 void GX_SetColorUpdate(u8 enable);
3401 
3402 /*!
3403  * \fn void GX_SetAlphaUpdate(u8 enable)
3404  * \brief Enables or disables alpha-buffer updates of the Embedded Frame Buffer (EFB).
3405  *
3406  * \note This function also affects whether the alpha buffer is cleared during copy operations; see GX_CopyDisp() and GX_CopyTex().<br><br>
3407  *
3408  * \note The only EFB pixel format supporting an alpha buffer is <tt>GX_PF_RGBA6_Z24</tt>; see GX_SetPixelFmt(). The alpha \a enable is ignored for non-alpha
3409  * pixel formats.
3410  *
3411  * \param[in] enable enables alpha-buffer updates with <tt>GX_TRUE</tt>
3412  *
3413  * \return none
3414  */
3415 void GX_SetAlphaUpdate(u8 enable);
3416 
3417 /*!
3418  * \fn void GX_SetPixelFmt(u8 pix_fmt,u8 z_fmt)
3419  * \brief Sets the format of pixels in the Embedded Frame Buffer (EFB).
3420  *
3421  * \details There are two non-antialiased \a pix_fmts: <tt>GX_PF_RGB8_Z24</tt> and <tt>GX_PF_RGBA6_Z24</tt>. The stride of the EFB is fixed at 640 pixels. The
3422  * non-antialiased EFB has 528 lines available.
3423  *
3424  * When \a pix_fmt is set to <tt>GX_PF_RGB565_Z16</tt>, multi-sample antialiasing is enabled. In order to get proper results, one must also call GX_SetCopyFilter().
3425  * The position of the subsamples and the antialiasing filter coefficients are set using GX_SetCopyFilter(). When antialiasing, three 16b color/Z
3426  * samples are computed for each pixel, and the total available number of pixels in the EFB is reduced by half (640 pixels x 264 lines). This function also sets the
3427  * compression type for 16-bit Z formats, which allows trading off Z precision for range. The following guidelines apply:<br><br>
3428  *
3429  * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;a) far/near ratio <= 2^16, use <tt>GX_ZC_LINEAR</tt><br>
3430  * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;b) far/near ratio <= 2^18, use <tt>GX_ZC_NEAR</tt><br>
3431  * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;c) far/near ratio <= 2^20, use <tt>GX_ZC_MID</tt><br>
3432  * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;d) far/near ratio <= 2^24, use <tt>GX_ZC_FAR</tt><br><br>
3433  *
3434  * It is always best to use as little compression as possible (choice "a" is least compressed, choice "d" is most compressed). You get less precision with higher compression.
3435  * The "far" in the above list does not necessarily refer to the far clipping plane. You should think of it as the farthest object you want correct occlusion for.
3436  *
3437  * \note This function also controls antialiasing (AA) mode.<br><br>
3438  *
3439  * \note Since changing pixel format requires the pixel pipeline to be synchronized, the use of this function causes stall of the graphics processor as a result. Therefore,
3440  * you should avoid redundant calls of this function.
3441  *
3442  * \param[in] pix_fmt <tt>GX_PF_RGB8_Z24</tt> or <tt>GX_PF_RGBA6_Z24</tt> for non-AA, <tt>GX_PF_RGB565_Z16</tt> for AA
3443  * \param[in] z_fmt \ref zfmt to use
3444  *
3445  * \return none
3446  */
3447 void GX_SetPixelFmt(u8 pix_fmt,u8 z_fmt);
3448 
3449 /*!
3450  * \fn void GX_SetDither(u8 dither)
3451  * \brief Enables or disables dithering.
3452  *
3453  * \details A 4x4 Bayer matrix is used for dithering.
3454  *
3455  * \note Only valid when the pixel format (see GX_SetPixelFmt()) is either <tt>GX_PF_RGBA6_Z24</tt> or <tt>GX_PF_RGB565_Z16</tt>.<br><br>
3456  *
3457  * \note Dithering should probably be turned off if you are planning on using the result of rendering for comparisons (e.g. outline rendering
3458  * algorithm that writes IDs to the alpha channel, copies the alpha channel to a texture, and later compares the texture in the TEV).
3459  *
3460  * \param[in] dither enables dithering if <tt>GX_TRUE</tt> is given and pixel format is one of the two above, otherwise disabled
3461  *
3462  * \return none
3463  */
3464 void GX_SetDither(u8 dither);
3465 
3466 /*!
3467  * \fn void GX_SetDstAlpha(u8 enable,u8 a)
3468  * \brief Sets a constant alpha value for writing to the Embedded Frame Buffer (EFB).
3469  *
3470  * \note To be effective, the EFB pixel type must have an alpha channel (see GX_SetPixelFmt()). The alpha compare operation (see
3471  * GX_SetAlphaCompare()) and blending operations (see GX_SetBlendMode()) still use source alpha (output from the last TEV stage) but when
3472  * writing the pixel color, the constant alpha will replace the pixel alpha in the EFB.
3473  *
3474  * \param[in] enable \a a will be written to the framebuffer if <tt>GX_ENABLE</tt> is here and frame buffer pixel format supports destination alpha
3475  * \param[in] a constant alpha value
3476  *
3477  * \return none
3478  */
3479 void GX_SetDstAlpha(u8 enable,u8 a);
3480 
3481 /*!
3482  * \fn void GX_SetFieldMask(u8 even_mask,u8 odd_mask)
3483  * \brief selectively enables and disables interlacing of the frame buffer image.
3484  *
3485  * \details This function is used when rendering fields to an interlaced Embedded Frame Buffer (EFB).
3486  *
3487  * \note When the mask is <tt>GX_FALSE</tt>, that field will not be written to the EFB, but the other field will be computed. In other words, you pay the
3488  * fill rate price of a frame to produce a field.
3489  *
3490  * \param[in] even_mask whether to write pixels with even Y coordinate
3491  * \param[in] odd_mask whether to write pixels with odd Y coordinate
3492  *
3493  * \return none
3494  */
3495 void GX_SetFieldMask(u8 even_mask,u8 odd_mask);
3496 
3497 /*!
3498  * \fn void GX_SetFieldMode(u8 field_mode,u8 half_aspect_ratio)
3499  * \brief Controls various rasterization and texturing parameters that relate to field-mode and double-strike rendering.
3500  *
3501  * \details In field-mode rendering, one must adjust the vertical part of the texture LOD computation to account for the fact that pixels cover only half of
3502  * the space from one rendered scan line to the next (with the other half of the space filled by a pixel from the other field).  In both field-mode and
3503  * double-strike rendering, one must adjust the aspect ratio for points and lines to account for the fact that pixels will be double-height when displayed
3504  * (the pixel aspect ratio is 1/2).
3505  *
3506  * \note The values set here usually come directly from the render mode. The \a field_rendering flags goes straight into \a field_mode. The \a half_aspect_ratio
3507  * parameter is true if the \a xfbHeight is half of the \a viHeight, false otherwise.<br><br>
3508  *
3509  * \note GX_Init() sets both fields according to the default render mode.<br><br>
3510  *
3511  * \note On production hardware (i.e. a retail GameCube), only line aspect-ratio adjustment is implemented. Points are not adjusted.
3512  *
3513  * \param[in] field_mode adjusts texture LOD computation as described above if true, otherwise does not
3514  * \param[in] half_aspect_ratio adjusts line aspect ratio accordingly, otherwise does not
3515  *
3516  * \return none
3517  */
3518 void GX_SetFieldMode(u8 field_mode,u8 half_aspect_ratio);
3519 
3520 /*!
3521  * \fn f32 GX_GetYScaleFactor(u16 efbHeight,u16 xfbHeight)
3522  * \brief Calculates an appropriate Y scale factor value for GX_SetDispCopyYScale() based on the height of the EFB and
3523  *        the height of the XFB.
3524  *
3525  * \param[in] efbHeight Height of embedded framebuffer. Range from 2 to 528. Should be a multiple of 2.
3526  * \param[in] xfbHeight Height of external framebuffer. Range from 2 to 1024. Should be equal or greater than \a efbHeight.
3527  *
3528  * \return Y scale factor which can be used as argument of GX_SetDispCopyYScale().
3529  */
3530 f32 GX_GetYScaleFactor(u16 efbHeight,u16 xfbHeight);
3531 
3532 /*!
3533  * \fn u32 GX_SetDispCopyYScale(f32 yscale)
3534  * \brief Sets the vertical scale factor for the EFB to XFB copy operation.
3535  *
3536  * \details The number of actual lines copied is returned, based on the current EFB height. You can use this number to allocate the proper XFB size. You
3537  * have to call GX_SetDispCopySrc() prior to this function call if you want to get the number of lines by using this function.
3538  *
3539  * \param[in] yscale Vertical scale value. Range from 1.0 to 256.0.
3540  *
3541  * \return Number of lines that will be copied.
3542  */
3543 u32 GX_SetDispCopyYScale(f32 yscale);
3544 
3545 /*!
3546  * \fn void GX_SetDispCopySrc(u16 left,u16 top,u16 wd,u16 ht)
3547  * \brief Sets the source parameters for the EFB to XFB copy operation.
3548  *
3549  * \param[in] left left most source pixel to copy. Must be a multiple of 2 pixels.
3550  * \param[in] top top most source line to copy. Must be a multiple of 2 lines.
3551  * \param[in] wd width in pixels to copy. Must be a multiple of 2 pixels.
3552  * \param[in] ht height in lines to copy. Must be a multiple of 2 lines.
3553  *
3554  * \return none
3555  */
3556 void GX_SetDispCopySrc(u16 left,u16 top,u16 wd,u16 ht);
3557 
3558 /*!
3559  * \fn void GX_SetDispCopyDst(u16 wd,u16 ht)
3560  * \brief Sets the witdth and height of the display buffer in pixels.
3561  *
3562  * \details The application typical renders an image into the EFB(source) and then copies it into the XFB(destination) in main memory. \a wd
3563  * specifies the number of pixels between adjacent lines in the destination buffer and can be different than the width of the EFB.
3564  *
3565  * \param[in] wd Distance between successive lines in the XFB, in pixels. Must be a multiple of 16.
3566  * \param[in] ht Height of the XFB in lines.
3567  *
3568  * \return none
3569  */
3570 void GX_SetDispCopyDst(u16 wd,u16 ht);
3571 
3572 /*!
3573  * \fn void GX_SetCopyClamp(u8 clamp)
3574  * \brief Sets the vertical clamping mode to use during the EFB to XFB or texture copy.
3575  *
3576  * \param[in] clamp bit-wise OR of desired \ref xfbclamp. Use <tt>GX_CLAMP_NONE</tt> for no clamping.
3577  *
3578  * \return none
3579  */
3580 void GX_SetCopyClamp(u8 clamp);
3581 
3582 /*!
3583  * \fn void GX_SetDispCopyGamma(u8 gamma)
3584  * \brief Sets the gamma correction applied to pixels during EFB to XFB copy operation.
3585  *
3586  * \param[in] gamma \ref gammamode
3587  *
3588  * \return none
3589  */
3590 void GX_SetDispCopyGamma(u8 gamma);
3591 
3592 /*!
3593  * \fn void GX_SetCopyFilter(u8 aa,u8 sample_pattern[12][2],u8 vf,u8 vfilter[7])
3594  * \brief Sets the subpixel sample patterns and vertical filter coefficients used to filter subpixels into pixels.
3595  *
3596  * \details This function normally uses the \a aa, \a sample_pattern and \a vfilter provided by the render mode struct:<br><br>
3597  *
3598  * \code GXRModeObj* rmode = VIDEO_GetPreferredMode(NULL);
3599  * GX_SetCopyFilter(rmode->aa,rmode->sample_pattern,GX_TRUE,rmode->vfilter); \endcode
3600  *
3601  * \note In order to make use of the \a sample_pattern, antialiasing must be enabled by setting the Embedded Frame Buffer (EFB) format to
3602  * <tt>GX_PF_RGB565_Z16</tt>; see GX_SetPixelFmt().
3603  *
3604  * \param[in] aa utilizes \a sample_pattern if <tt>GX_TRUE</tt>, otherwise all sample points are centered
3605  * \param[in] sample_pattern array of coordinates for sample points; valid range is 1 - 11 inclusive
3606  * \param[in] vf use \a vfilter if <tt>GX_TRUE</tt>, otherwise use default 1-line filter
3607  * \param[in] vfilter vertical filter coefficients; valid coefficient range is 0 - 63 inclusive; sum should equal 64
3608  *
3609  * \return none
3610  */
3611 void GX_SetCopyFilter(u8 aa,u8 sample_pattern[12][2],u8 vf,u8 vfilter[7]);
3612 
3613 /*!
3614  * \fn void GX_SetDispCopyFrame2Field(u8 mode)
3615  * \brief Determines which lines are read from the Embedded Frame Buffer (EFB) when using GX_CopyDisp().
3616  *
3617  * \details Specifically, it determines whether all lines, only even lines, or only odd lines are read.
3618  *
3619  * \note The opposite function, which determines whether all lines, only even lines or only odd lines are <i>written</i> to the EFB, is GX_SetFieldMask().<br><br>
3620  *
3621  * \note Only applies to display copies, GX_CopyTex() always uses the <tt>GX_COPY_PROGRESSIVE</tt> mode.
3622  *
3623  * \param[in] mode \ref copymode to determine which field to copy (or both)
3624  *
3625  * \return none
3626  */
3627 void GX_SetDispCopyFrame2Field(u8 mode);
3628 
3629 /*!
3630  * \fn void GX_SetCopyClear(GXColor color,u32 zvalue)
3631  * \brief Sets color and Z value to clear the EFB to during copy operations.
3632  *
3633  * \details These values are used during both display copies and texture copies.
3634  *
3635  * \param[in] color RGBA color (8-bit/component) to use during clear operation.
3636  * \param[in] zvalue 24-bit Z value to use during clear operation. Use the constant <tt>GX_MAX_Z24</tt> to specify the maximum depth value.
3637  *
3638  * \return none
3639  */
3640 void GX_SetCopyClear(GXColor color,u32 zvalue);
3641 
3642 /*!
3643  * \fn void GX_CopyDisp(void *dest,u8 clear)
3644  * \brief Copies the embedded framebuffer (EFB) to the external framebuffer(XFB) in main memory.
3645  *
3646  * \note The stride of the XFB is set using GX_SetDispCopyDst(). The source image in the EFB is described using GX_SetDispCopySrc().<br><br>
3647  *
3648  * \note The graphics processor will stall all graphics commands util the copy is complete.<br><br>
3649  *
3650  * \note If the \a clear flag is true, the color and Z buffers will be cleared during the copy. They will be cleared to the constant
3651  * values set using GX_SetCopyClear().
3652  *
3653  * \param[in] dest pointer to the external framebuffer. \a dest should be 32B aligned.
3654  * \param[in] clear flag that indicates framebuffer should be cleared if <tt>GX_TRUE</tt>.
3655  *
3656  * \return none
3657  */
3658 void GX_CopyDisp(void *dest,u8 clear);
3659 
3660 /*!
3661  * \fn void GX_SetTexCopySrc(u16 left,u16 top,u16 wd,u16 ht)
3662  * \brief Sets the source parameters for the Embedded Frame Buffer (EFB) to texture image copy.
3663  *
3664  * \details The GP will copy textures into the tiled texture format specified in GX_CopyTex(). The GP always copies tiles (32B) so image widths and
3665  * heights that are not a multiple of the tile width will be padded with undefined data in the copied image
3666  *
3667  * \param[in] left left-most source pixel to copy, multiple of two
3668  * \param[in] top top-most source line to copy, multiple of two
3669  * \param[in] wd width to copy in pixels, multiple of two
3670  * \param[in] ht height to copy in pixels, multiple of two
3671  *
3672  * \return none
3673  */
3674 void GX_SetTexCopySrc(u16 left,u16 top,u16 wd,u16 ht);
3675 
3676 /*!
3677  * \fn void GX_SetTexCopyDst(u16 wd,u16 ht,u32 fmt,u8 mipmap)
3678  * \brief This function sets the width and height of the destination texture buffer in texels.
3679  *
3680  * \details This function sets the width (\a wd) and height (\a ht) of the destination texture buffer in texels. The application may render an image into
3681  * the EFB and then copy it into a texture buffer in main memory. \a wd specifies the number of texels between adjacent lines in the texture buffer and can
3682  * be different than the width of the source image. This function also sets the texture format (\a fmt) to be created during the copy operation. An
3683  * optional box filter can be enabled using \a mipmap. This flag will scale the source image by 1/2.
3684  *
3685  * Normally, the width of the EFB and destination \a wd are the same. When rendering smaller images that get copied and composited into a larger texture
3686  * buffer, however, the EFB width and texture buffer \a wd are not necessarily the same.
3687  *
3688  * The Z buffer can be copied to a Z texture format by setting \a fmt to <tt>GX_TF_Z24X8</tt>. This operation is only valid when the EFB format is
3689  * <tt>GX_PF_RGB8_Z24</tt> or <tt>GX_PF_RGBA6_Z24</tt>.
3690  *
3691  * The alpha channel can be copied from an EFB with format <tt>GX_PF_RGBA6_Z24</tt> by setting \a fmt to <tt>GX_TF_A8</tt>.
3692  *
3693  * \param[in] wd distance between successive lines in the texture buffer, in texels; must be a multiple of the texture tile width, which depends on \a fmt.
3694  * \param[in] ht height of the texture buffer
3695  * \param[in] fmt \ref texfmt
3696  * \param[in] mipmap flag that indicates framebuffer should be cleared if <tt>GX_TRUE</tt>.
3697  *
3698  * \return none
3699  */
3700 void GX_SetTexCopyDst(u16 wd,u16 ht,u32 fmt,u8 mipmap);
3701 
3702 /*!
3703  * \fn void GX_CopyTex(void *dest,u8 clear)
3704  * \brief Copies the embedded framebuffer (EFB) to the texture image buffer \a dest in main memory.
3705  *
3706  * \details This is useful when creating textures using the Graphics Processor (GP). If the \a clear flag is set to <tt>GX_TRUE</tt>, the EFB will be cleared
3707  * to the current color(see GX_SetCopyClear()) during the copy operation.
3708  *
3709  * \param[in] dest pointer to the image buffer in main memory. \a dest should be 32B aligned.
3710  * \param[in] clear flag that indicates framebuffer should be cleared if <tt>GX_TRUE</tt>.
3711  *
3712  * \return none
3713  */
3714 void GX_CopyTex(void *dest,u8 clear);
3715 
3716 /*!
3717  * \fn void GX_PixModeSync()
3718  * \brief Causes the GPU to wait for the pipe to flush.
3719  *
3720  * \details This function inserts a synchronization command into the graphics FIFO. When the GPU sees this command it will allow the rest of the pipe to
3721  * flush before continuing. This command is useful in certain situation such as after using GX_CopyTex() and before a primitive that uses the copied texture.
3722  *
3723  * \note The command is actually implemented by writing the control register that determines the format of the embedded frame buffer (EFB). As a result, care
3724  * should be used if this command is placed within a display list.
3725  *
3726  * \return none
3727  */
3728 void GX_PixModeSync();
3729 
3730 /*!
3731  * \fn void GX_ClearBoundingBox()
3732  * \brief Clears the bounding box values before a new image is drawn.
3733  *
3734  * \details The graphics hardware keeps track of a bounding box of pixel coordinates that are drawn in the Embedded Frame Buffer (EFB).
3735  *
3736  * \return none
3737  */
3738 void GX_ClearBoundingBox();
3739 
3740 /*!
3741  * \fn GX_PokeAlphaMode(u8 func,u8 threshold)
3742  * \brief Sets a threshold which is compared to the alpha of pixels written to the Embedded Frame Buffer (EFB) using the GX_Poke*() functions.
3743  *
3744  * \details The compare function order is:<br><br>
3745  *
3746  * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;src_alpha \a func \a threshold
3747  *
3748  * \note The alpha compare function can be used to conditionally write pixels to the EFB using the source alpha channel as a template. If the compare function is
3749  * true, the source color will be written to the EFB based on the result of the Z compare (see GX_PokeZMode()). If the alpha compare function is false, the source
3750  * color is not written to the EFB.<br><br>
3751  *
3752  * \note The alpha compare test happens before the Z compare and before blending (see GX_PokeBlendMode()).
3753  *
3754  * \param[in] func \ref compare to use
3755  * \param[in] threshold to which the source alpha will be compared to
3756  *
3757  * \return none
3758  */
3759 void GX_PokeAlphaMode(u8 func,u8 threshold);
3760 
3761 /*!
3762  * \fn void GX_PokeAlphaUpdate(u8 update_enable)
3763  * \brief Enables or disables alpha-buffer updates for GX_Poke*() functions.
3764  *
3765  * \details The normal rendering state (set by GX_SetAlphaUpdate()) is not affected.
3766  *
3767  * \param[in] update_enable enables alpha-buffer updates with <tt>GX_TRUE</tt>, otherwise does not
3768  *
3769  * \return none
3770  */
3771 void GX_PokeAlphaUpdate(u8 update_enable);
3772 
3773 /*!
3774  * \fn void GX_PokeColorUpdate(u8 update_enable)
3775  * \brief Enables or disables color-buffer updates when writing the Embedded Frame Buffer (EFB) using the GX_Poke*() functions.
3776  *
3777  * \param[in] update_enable enables color-buffer updates with <tt>GX_TRUE</tt>, otherwise does not
3778  *
3779  * \return none
3780  */
3781 void GX_PokeColorUpdate(u8 update_enable);
3782 
3783 /*!
3784  * \fn void GX_PokeDither(u8 dither)
3785  * \brief Enables dithering when writing the Embedded Frame Buffer (EFB) using GX_Poke*() functions.
3786  *
3787  * \note The \a dither enable is only valid when the pixel format (see GX_SetPixelFmt()) is either <tt>GX_PF_RGBA6_Z24</tt> or <tt>GX_PF_RGB565_Z16</tt>.<br><br>
3788  *
3789  * \note A 4x4 Bayer matrix is used for dithering.
3790  *
3791  * \param[in] dither if set to <tt>GX_TRUE</tt> and pixel format is one of the above, dithering is enabled; otherwise disabled
3792  *
3793  * \return none
3794  */
3795 void GX_PokeDither(u8 dither);
3796 
3797 /*!
3798  * \fn void GX_PokeBlendMode(u8 type,u8 src_fact,u8 dst_fact,u8 op)
3799  * \brief Determines how the source image, is blended with the current Embedded Frame Buffer (EFB).
3800  *
3801  * \details When type is set to <tt>GX_BM_NONE</tt>, no color data is written to the EFB. When type is set to <tt>GX_BM_BLEND</tt>, the source and EFB pixels
3802  * are blended using the following equation:<br><br>
3803  *
3804  * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<i>dst_pix_clr</i> = <i>src_pix_clr</i> * \a src_fact + <i>dst_pix_clr</i> * \a dst_fact<br><br>
3805  *
3806  * When type is set to <tt>GX_BM_SUBTRACT</tt>, the destination pixel is computed as follows:<br><br>
3807  *
3808  * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<i>dst_pix_clr</i> = <i>dst_pix_clr</i> - <i>src_pix_clr [clamped to zero]</i><br><br>
3809  *
3810  * Note that \a src_fact and \a dst_fact are not part of the equation.
3811  *
3812  * \note \a dst_fact can be used only when the frame buffer has <tt>GX_PF_RGBA6_Z24</tt> as the pixel format (see GX_SetPixelFmt()).<br><br>
3813  *
3814  * \note When type is set to <tt>GX_BM_LOGIC</tt>, the source and EFB pixels are blended using logical bitwise operations.<br><br>
3815  *
3816  * \note This function does not effect the normal rendering state; see GX_SetBlendMode().
3817  *
3818  * \param[in] type \ref blendmode
3819  * \param[in] src_fact source \ref blendfactor; the pixel color produced by the graphics processor is multiplied by this factor
3820  * \param[in] dst_fact destination \ref blendfactor; the current frame buffer pixel color is multiplied by this factor
3821  * \param[in] op \ref logicop to use
3822  */
3823 void GX_PokeBlendMode(u8 type,u8 src_fact,u8 dst_fact,u8 op);
3824 
3825 /*!
3826  * \fn void GX_PokeAlphaRead(u8 mode)
3827  * \brief Determines what value of alpha will be read from the Embedded Frame Buffer (EFB).
3828  *
3829  * \details The mode only applies to GX_Peek*() functions.
3830  *
3831  * \note This feature works no matter what pixel type (see GX_SetPixelFmt()) you are using. If you are using the EFB with alpha plane, it is
3832  * recommended that you use <tt>GX_READ_NONE</tt> so that you can read correct alpha value from the EFB. If you are using the EFB with no alpha, you should
3833  * set either of <tt>GX_READ_00</tt> or <tt>GX_READ_FF</tt> in order to get a certain value.<br><br>
3834  *
3835  * \param[in] mode \ref alphareadmode that determines value of alpha read from a frame buffer with no alpha channel.
3836  *
3837  * \return none
3838  */
3839 void GX_PokeAlphaRead(u8 mode);
3840 
3841 /*!
3842  * \fn void GX_PokeDstAlpha(u8 enable,u8 a)
3843  * \brief Sets a constant alpha value for writing to the Embedded Frame Buffer (EFB).
3844  *
3845  * \details The EFB pixel type must have an alpha channel for this function to be effective (see GX_SetPixelFmt()). The blending operations (see
3846  * GX_PokeBlendMode()) still use source alpha but when writing the pixel color, the constant \a a will replace the pixel alpha in the EFB.
3847  *
3848  * \param[in] enable if set to <tt>GX_ENABLE</tt> and pixel format supports dest alpha, \a a will be written to the framebuffer
3849  * \param[in] a constant alpha value
3850  *
3851  * \return none
3852  */
3853 void GX_PokeDstAlpha(u8 enable,u8 a);
3854 
3855 /*!
3856  * \fn void GX_PokeARGB(u16 x,u16 y,GXColor color)
3857  * \brief Allows the CPU to write \a color directly to the Embedded Frame Buffer (EFB) at position \a x,\a y.
3858  *
3859  * \details The alpha value in \a color can be compared with the current alpha threshold (see GX_PokeAlphaMode()). The color will be blended
3860  * into the EFB using the blend mode set by GX_PokeBlendMode().
3861  *
3862  * \note For an antialiased frame buffer, all 3 subsamples of a pixel are affected by the poke.
3863  *
3864  * \param[in] x coordinate, in pixels; must be 0 - 639 inclusive
3865  * \param[in] y coordinate, in lines; must be 0 - 527 inclusive
3866  * \param[in] color color to write at the location
3867  *
3868  * \return none
3869  */
3870 void GX_PokeARGB(u16 x,u16 y,GXColor color);
3871 
3872 /*!
3873  * \fn void GX_PeekARGB(u16 x,u16 y,GXColor *color)
3874  * \brief Allows the CPU to read a color value directly from the Embedded Frame Buffer (EFB) at position \a x,\a y.
3875  *
3876  * \note For an antialiased frame buffer, only subsample 0 of a pixel is read.
3877  *
3878  * \param[in] x coordinate, in pixels; must be 0 - 639 inclusive
3879  * \param[in] y coordinate, in lines; must be 0 - 527 inclusive
3880  * \param[out] color struct to store color in
3881  *
3882  * \return none
3883  */
3884 void GX_PeekARGB(u16 x,u16 y,GXColor *color);
3885 
3886 /*!
3887  * \fn void GX_PokeZ(u16 x,u16 y,u32 z)
3888  * \brief Allows the CPU to write a z value directly to the Embedded Frame Buffer (EFB) at position \a x,\a y.
3889  *
3890  * \details The \a z value can be compared with the current contents of the EFB. The Z compare fuction is set using GX_PokeZMode().
3891  *
3892  * \note The \a z value should be in the range of 0x00000000 <= \a z < 0x00FFFFFF in the case of non-antialiased frame buffer. For an antialiased
3893  * frame buffer, the \a z value should be in the compressed 16-bit format (0x00000000 <= \a z <= 0x0000FFFF), and the poke will affect all 3
3894  * subsamples of a pixel.
3895  *
3896  * \param[in] x coordinate, in pixels; must be 0 - 639 inclusive
3897  * \param[in] y coordinate, in lines; must be 0 - 527 inclusive
3898  * \param[in] z value to write at position \a x,\a y in the EFB
3899  *
3900  * \return none
3901  */
3902 void GX_PokeZ(u16 x,u16 y,u32 z);
3903 
3904 /*!
3905  * \fn void GX_PeekZ(u16 x,u16 y,u32 *z)
3906  * \brief Allows the CPU to read a z value directly from the Embedded Frame Buffer (EFB) at position x,y.
3907  *
3908  * \details The z value is raw integer value from the Z buffer.
3909  *
3910  * \note The value range is 24-bit when reading from non-antialiased frame buffer. When reading from an antialiased frame buffer, subsample
3911  * 0 is read and returned. The value will be compressed 16-bit form in this case.
3912  *
3913  * \param[in] x coordinate, in pixels; must be 0 - 639 inclusive
3914  * \param[in] y coordinate, in lines; must be 0 - 527 inclusive
3915  * \param[out] z pointer to a returned Z value
3916  *
3917  * \return none
3918  */
3919 void GX_PeekZ(u16 x,u16 y,u32 *z);
3920 
3921 /*!
3922  * \fn void GX_PokeZMode(u8 comp_enable,u8 func,u8 update_enable)
3923  * \brief Sets the Z-buffer compare mode when writing the Embedded Frame Buffer (EFB).
3924  *
3925  * \details The result of the Z compare is used to conditionally write color values to the EFB. The Z value will be updated according to the
3926  * result of the compare if Z update is enabled.
3927  *
3928  * When \a comp_enable is set to <tt>GX_DISABLE</tt>, poke Z buffering is disabled and the Z buffer is not updated. The \a func parameter determines the
3929  * comparison that is performed. In the comparison function, the poked Z value is on the left while the Z value from the Z buffer is on the
3930  * right. If the result of the comparison is false, the poked Z value is discarded. The parameter \a update_enable determines whether or not the
3931  * Z buffer is updated with the new Z value after a comparison is performed.
3932  *
3933  * \note The normal rendering Z mode (set by GX_SetZMode()) is not affected by this function.<br><br>
3934  *
3935  * \note Even if update_enable is <tt>GX_FALSE</tt>, compares may still be enabled.
3936  *
3937  * \param[in] comp_enable enables comparisons with source and destination Z values if <tt>GX_TRUE</tt>
3938  * \param[in] func \ref compare function to use
3939  * \param[in] update_enable enables Z-buffer updates when <tt>GX_TRUE</tt>
3940  *
3941  * \return none
3942  */
3943 void GX_PokeZMode(u8 comp_enable,u8 func,u8 update_enable);
3944 
3945 /*!
3946  * \fn u32 GX_GetTexObjFmt(GXTexObj *obj)
3947  * \brief Returns the texture format described by texture object \a obj.
3948  *
3949  * \note Use GX_InitTexObj() or GX_InitTexObjCI() to initialize the texture format.
3950  *
3951  * \param[in] obj ptr to a texture object
3952  *
3953  * \return texture format of the given texture object
3954  */
3955 u32 GX_GetTexObjFmt(GXTexObj *obj);
3956 
3957 /*!
3958  * \fn u32 GX_GetTexObjMipMap(GXTexObj *obj)
3959  * \brief Returns the texture mipmap enable described by texture object \a obj.
3960  *
3961  * \note Use GX_InitTexObj() or GX_InitTexObjCI() to initialize the texture mipmap enable.
3962  *
3963  * \param[in] obj ptr to a texture object
3964  *
3965  * \return mipmap enable flag
3966  */
3967 u32 GX_GetTexObjMipMap(GXTexObj *obj);
3968 
3969 /*!
3970  * \fn void* GX_GetTexObjUserData(GXTexObj *obj)
3971  * \brief Used to get a pointer to user data from the \ref GXTexObj structure.
3972  *
3973  * \details You can use this function to retrieve private data structures from the texture object. This pointer is set using GX_InitTexObjUserData().
3974  *
3975  * \param[in] obj ptr to object to read data from
3976  *
3977  * \return Pointer to user data.
3978  */
3979 void* GX_GetTexObjUserData(GXTexObj *obj);
3980 
3981 /*!
3982  * \fn void* GX_GetTexObjData(GXTexObj *obj)
3983  * \brief Used to get a pointer to texture data from the \ref GXTexObj structure.
3984  *
3985  * \note The returned pointer is a physical address.
3986  *
3987  * \param[in] obj ptr to a texture object
3988  *
3989  * \return Physical pointer to texture data.
3990  */
3991 void* GX_GetTexObjData(GXTexObj *obj);
3992 
3993 /*!
3994  * \fn u8 GX_GetTexObjWrapS(GXTexObj* obj)
3995  * \brief Returns the texture wrap s mode described by texture object \a obj.
3996  *
3997  * \note Use GX_InitTexObj() or GX_InitTexObjCI() to initialize the texture wrap s mode.
3998  *
3999  * \param[in] obj ptr to a texture object
4000  *
4001  * \return wrap s mode
4002  */
4003 u8 GX_GetTexObjWrapS(GXTexObj* obj);
4004 
4005 /*!
4006  * \fn u8 GX_GetTexObjWrapT(GXTexObj* obj)
4007  * \brief Returns the texture wrap t mode described by texture object \a obj.
4008  *
4009  * \note Use GX_InitTexObj() or GX_InitTexObjCI() to initialize the texture wrap t mode.
4010  *
4011  * \param[in] obj ptr to a texture object
4012  *
4013  * \return wrap t mode
4014  */
4015 u8 GX_GetTexObjWrapT(GXTexObj* obj);
4016 
4017 /*!
4018  * \fn u16 GX_GetTexObjHeight(GXTexObj* obj)
4019  * \brief Returns the texture height described by texture object \a obj.
4020  *
4021  * \note Use GX_InitTexObj() or GX_InitTexObjCI() to initialize the texture height.
4022  *
4023  * \param[in] obj ptr to a texture object
4024  *
4025  * \return texture height
4026  */
4027 u16 GX_GetTexObjHeight(GXTexObj* obj);
4028 
4029 /*!
4030  * \fn u16 GX_GetTexObjWidth(GXTexObj* obj)
4031  * \brief Returns the texture width described by texture object \a obj.
4032  *
4033  * \note Use GX_InitTexObj() or GX_InitTexObjCI() to initialize the texture width.
4034  *
4035  * \param[in] obj ptr to a texture object
4036  *
4037  * \return texture width
4038  */
4039 u16 GX_GetTexObjWidth(GXTexObj* obj);
4040 
4041 /*!
4042  * \fn void GX_GetTexObjAll(GXTexObj* obj, void** image_ptr, u16* width, u16* height, u8* format, u8* wrap_s, u8* wrap_t, u8* mipmap);
4043  * \brief Returns the parameters described by a texture object. Texture objects are used to describe all the parameters associated with a texture, including size, format, wrap modes, filter modes, etc. Texture objects are initialized using either GX_InitTexObj() or, for color index format textures, GX_InitTexObjCI().
4044  *
4045  * \param[in] obj ptr to a texture object
4046  * \param[out] image_ptr Returns a physical pointer to the image data for a texture.
4047  * \param[out] width Returns the width of the texture or LOD 0 for mipmaps
4048  * \param[out] height Returns the height of the texture or LOD 0 for mipmaps
4049  * \param[out] format Returns the texel format
4050  * \param[out] mipmap Returns the mipmap enable flag.
4051  *
4052  * \return none
4053  */
4054 void GX_GetTexObjAll(GXTexObj* obj, void** image_ptr, u16* width, u16* height, u8* format, u8* wrap_s, u8* wrap_t, u8* mipmap);
4055 
4056 /*!
4057  * \fn u32 GX_GetTexBufferSize(u16 wd,u16 ht,u32 fmt,u8 mipmap,u8 maxlod)
4058  * \brief Returns the amount of memory in bytes needed to store a texture of the given size and \a fmt.
4059  *
4060  * \details If the \a mipmap flag is <tt>GX_TRUE</tt>, then the size of buffer needed for the mipmap pyramid up to \a maxlod will be returned.
4061  * \a maxlod will be clamped to the number of LODs possible given the map \a wd and \a ht. For mipmaps, \a wd and \a ht must be a power of two.
4062  *
4063  * \note This function takes into account the tiling and padding requirements of the GameCube's native texture format. The resulting size can be used
4064  * along with memalign() to allocate texture buffers (see GX_CopyTex()).
4065  *
4066  * \param[in] wd width of the texture in texels
4067  * \param[in] ht height of the texture in texels
4068  * \param[in] fmt format of the texture; use GX_TexFmt() or GX_CITexFmt() to get it
4069  * \param[in] mipmap flag indicating whether or not the texture is a mipmap
4070  * \param[in] maxlod if \a mipmap is \a GX_TRUE, texture size will include mipmap pyramid up to this value
4071  *
4072  * \return number of bytes needed for the texture, including tile padding
4073  */
4074 u32 GX_GetTexBufferSize(u16 wd,u16 ht,u32 fmt,u8 mipmap,u8 maxlod);
4075 
4076 /*!
4077  * \fn void GX_InvalidateTexAll()
4078  * \brief Invalidates the current caches of the Texture Memory (TMEM).
4079  *
4080  * \details It takes about 512 GP clocks to invalidate all the texture caches.
4081  *
4082  * \note Preloaded textures (see GX_PreloadEntireTexture()) are not affected.
4083  *
4084  * \return none
4085  */
4086 void GX_InvalidateTexAll();
4087 
4088 /*!
4089  * \fn void GX_InvalidateTexRegion(GXTexRegion *region)
4090  * \brief Invalidates the texture cache in Texture Memory (TMEM) described by \a region.
4091  *
4092  * \details This function should be called when the CPU is used to modify a texture in main memory, or a new texture is loaded into main memory that
4093  * is possibly cached in the texture region.
4094  *
4095  * \note In reality, this function invalidates the cache tags, forcing the texture cache to load new data. Preloaded textures (see
4096  * GX_PreloadEntireTexture()) do not use the tags.<br><br>
4097  *
4098  * \note The texture hardware can invalidate 4 tags each GP clock. Each tag represents a superline or 512B of TMEM. Therefore, it takes 16
4099  * GP clocks to invalidate a 32KB texture region.
4100  *
4101  * \param[in] region ptr to GXTexRegion object
4102  *
4103  * \return none
4104  */
4105 void GX_InvalidateTexRegion(GXTexRegion *region);
4106 
4107 /*!
4108  * \fn void GX_InitTexCacheRegion(GXTexRegion *region,u8 is32bmipmap,u32 tmem_even,u8 size_even,u32 tmem_odd,u8 size_odd)
4109  * \brief Initializes a texture memory (TMEM) region object for cache.
4110  *
4111  * \details The region is allocated by the application and can be used as a cache. An application can create many region objects and some of them can
4112  * overlap; however, no two overlapping regions can be active at the same time.
4113  *
4114  * The possible sizes of a TMEM cache region are 32K, 128K or 512K.
4115  *
4116  * \note For pre-loaded textures, the region must be defined by using GX_InitTexPreloadRegion().<br><br>
4117  *
4118  * \note GX_Init() creates default texture regions, so it is not necessary for the application to use this function unless a different Texture Memory
4119  * configuration is desired. In that case, the application should also define a region allocator using GX_SetTexRegionCallback().<br><br>
4120  *
4121  * \note The function GX_InvalidateTexRegion() can be used to force the texture in main memory associated with this region to be reloaded. This will be
4122  * necessary whenever the texture data in main memory changes. You may invalidate all cached regions at once using GX_InvalidateTexAll().
4123  *
4124  * \param[in] region ptr to a GXTexRegion struct
4125  * \param[in] is32bmipmap should be set to <tt>GX_TRUE</tt> to interpret parameters according to the 32b mipmap meaning.
4126  * \param[in] tmem_even base ptr in TMEM for even LODs; must be multiple of 2KB
4127  * \param[in] size_even even \ref texcachesize other than <tt>GX_TEXCACHE_NONE</tt>
4128  * \param[in] tmem_odd base ptr in TMEM for odd LODs; must be multiple of 2KB
4129  * \param[in] size_odd odd \ref texcachesize other than <tt>GX_TEXCACHE_NONE</tt>
4130  *
4131  * \return none
4132  */
4133 void GX_InitTexCacheRegion(GXTexRegion *region,u8 is32bmipmap,u32 tmem_even,u8 size_even,u32 tmem_odd,u8 size_odd);
4134 
4135 /*!
4136  * \fn void GX_InitTexPreloadRegion(GXTexRegion *region,u32 tmem_even,u32 size_even,u32 tmem_odd,u32 size_odd)
4137  * \brief Initializes a Texture Memory (TMEM) region object for preloading.
4138  *
4139  * \details The region is allocated in TMEM by the application and can be used only as a pre-loaded buffer. Cache regions must be allocated
4140  * by using GX_InitTexCacheRegion(). For pre-loaded textures, the size of the region must match the size of the texture. An application can
4141  * create many region objects and some of them can overlap; however, no two overlapping regions can be active at the same time.
4142  *
4143  * \note The maximum size of a region is 512K.
4144  *
4145  * \warning GX_Init() creates no region for preloading, so the application should allocate appropriate regions if preloading is necessary. It
4146  * is also required to create cache regions and its allocator by using GX_InitTexCacheRegion() and GX_SetTexRegionCallback(), otherwise new
4147  * cache regions may overwrite the preloaded areas. (Alternatively, if you do not use any color-index textures, you may preload textures into
4148  * the portion of texture memory normally allocated to color-index usage by the default allocator.)
4149  *
4150  * \param[in] region ptr to a GXTexRegion struct
4151  * \param[in] tmem_even base ptr in TMEM for even LODs; must be 32B aligned
4152  * \param[in] size_even size of the even cache, in bytes; should be multiple of 32B
4153  * \param[in] tmem_odd base ptr in TMEM for odd LODs; must be 32B aligned
4154  * \param[in] size_odd size of the odd cache, in bytes; should be multiple of 32B
4155  *
4156  * \return none
4157  */
4158 void GX_InitTexPreloadRegion(GXTexRegion *region,u32 tmem_even,u32 size_even,u32 tmem_odd,u32 size_odd);
4159 
4160 /*!
4161  * \fn void GX_InitTexObj(GXTexObj *obj,void *img_ptr,u16 wd,u16 ht,u8 fmt,u8 wrap_s,u8 wrap_t,u8 mipmap)
4162  * \brief Used to initialize or change a texture object for non-color index textures.
4163  *
4164  * \details Texture objects are used to describe all the parameters associated with a texture, including size, format, wrap modes, filter modes,
4165  * etc. It is the application's responsibility to provide memory for a texture object. Once initialized, a texture object can be associated with
4166  * one of eight active texture IDs using GX_LoadTexObj().
4167  *
4168  * \note To initialize a texture object for color index format textures, use GX_InitTexObjCI().<br><br>
4169  *
4170  * \note If the mipmap flag is <tt>GX_TRUE</tt>, then the texture is a mipmap and the texture will be trilerped. If the mipmap flag is <tt>GX_FALSE</tt>, the texture
4171  * is not a mipmap and the texture will be bilerped. To override the filter modes and other mipmap controls, see GX_InitTexObjLOD().
4172  *
4173  * \param[out] obj ptr to a texture object
4174  * \param[in] img_ptr ptr to the image data for a texture, aligned to 32B
4175  * \param[in] wd width of the texture, or LOD level 0 for mipmaps; max value is 1024; mipmaps must be a power of two
4176  * \param[in] ht height of the texture, or LOD level 0 for mipmaps; max value is 1024; mipmaps must be a power of two
4177  * \param[in] fmt \ref texfmt
4178  * \param[in] wrap_s texture coordinate wrapping strategy in the S direction; use <tt>GX_CLAMP</tt>, <tt>GX_REPEAT</tt> or <tt>GX_MIRROR</tt>
4179  * \param[in] wrap_t texture coordinate wrapping strategy in the T direction; use <tt>GX_CLAMP</tt>, <tt>GX_REPEAT</tt> or <tt>GX_MIRROR</tt>
4180  * \param[in] mipmap trilinear filtering will be used if <tt>GX_TRUE</tt>, otherwise bilinear is used
4181  *
4182  * \return none
4183  */
4184 void GX_InitTexObj(GXTexObj *obj,void *img_ptr,u16 wd,u16 ht,u8 fmt,u8 wrap_s,u8 wrap_t,u8 mipmap);
4185 
4186 /*!
4187  * \fn void GX_InitTexObjCI(GXTexObj *obj,void *img_ptr,u16 wd,u16 ht,u8 fmt,u8 wrap_s,u8 wrap_t,u8 mipmap,u32 tlut_name)
4188  * \brief Used to initialize or change a texture object when the texture is color index format.
4189  *
4190  * \details Texture objects are used to describe all the parameters associated with a texture, including size, format, wrap modes, filter modes,
4191  * etc. It is the application's responsibility to provide memory for a texture object. Once initialized, a texture object can be associated with
4192  * one of eight active texture IDs using GX_LoadTexObj().
4193  *
4194  * \note If the \a mipmap flag is <tt>GX_TRUE</tt>, then the texture is a mipmap and the texture will be filtered using the <tt>GX_LIN_MIP_NEAR</tt> filter mode
4195  * (color index mipmaps cannot use the <tt>GX_LIN_MIP_LIN</tt> or <tt>GX_NEAR_MIP_LIN</tt> mode). If the \a mipmap flag is <tt>GX_FALSE</tt>, the texture is not a mipmap
4196  * and the texture will be bilerped. To override the filter modes and other mipmap controls, use GX_InitTexObjLOD(). Mipmap textures should
4197  * set the width and height to a power of two, but mipmaps do not need to be square.<br><br>
4198  *
4199  * \note Non-mipmap (planar) textures do not have to be a power of two. However, to use the <tt>GX_REPEAT</tt> or <tt>GX_MIRROR</tt> modes for \a wrap_s and \a wrap_t
4200  * the width and height, respectively, must be a power of two.<br><br>
4201  *
4202  * \note The \a tlut_name is used to indicate which texture lookup table (TLUT) to use for the index to color conversion. To load the TLUT into
4203  * texture memory, use GX_LoadTlut().
4204  *
4205  * \param[in] obj ptr to a texture object
4206  * \param[in] img_ptr ptr to the image data for a texture, aligned to 32B
4207  * \param[in] wd width of the texture, or LOD level 0 for mipmaps; max value is 1024; mipmaps must be a power of two
4208  * \param[in] ht height of the texture, or LOD level 0 for mipmaps; max value is 1024; mipmaps must be a power of two
4209  * \param[in] fmt \ref texfmt
4210  * \param[in] wrap_s texture coordinate wrapping strategy in the S direction; use <tt>GX_CLAMP</tt>, <tt>GX_REPEAT</tt> or <tt>GX_MIRROR</tt>
4211  * \param[in] wrap_t texture coordinate wrapping strategy in the T direction; use <tt>GX_CLAMP</tt>, <tt>GX_REPEAT</tt> or <tt>GX_MIRROR</tt>
4212  * \param[in] mipmap if <tt>GX_TRUE</tt>, it is a mipmap texture, else it is a planar texture
4213  * \param[in] tlut_name TLUT name to use for this texture; default texture configuration recognizes \ref tlutname
4214  *
4215  * \return none
4216  */
4217 void GX_InitTexObjCI(GXTexObj *obj,void *img_ptr,u16 wd,u16 ht,u8 fmt,u8 wrap_s,u8 wrap_t,u8 mipmap,u32 tlut_name);
4218 
4219 /*!
4220  * \fn void GX_InitTexObjTlut(GXTexObj *obj,u32 tlut_name)
4221  * \brief Allows one to modify the TLUT that is associated with an existing texture object.
4222  *
4223  * \param[in] obj ptr to a texture object
4224  * \param[in] tlut_name TLUT name to use for this texture; default texture configuration recognizes \ref tlutname
4225  *
4226  * \return none
4227  */
4228 void GX_InitTexObjTlut(GXTexObj *obj,u32 tlut_name);
4229 
4230 /*!
4231  * \fn void GX_InitTexObjData(GXTexObj *obj,void *img_ptr)
4232  * \brief Allows one to modify the image data pointer for an existing texture object.
4233  *
4234  * \note The image format and size for the new data must agree with what they were when the texture object was first initialized using
4235  * GX_InitTexObj() or GX_InitTexObjCI().
4236  *
4237  * \param[in] obj ptr to a texture object
4238  * \param[in] img_ptr ptr to the texture data in main memory
4239  *
4240  * \return none
4241  */
4242 void GX_InitTexObjData(GXTexObj *obj,void *img_ptr);
4243 
4244 /*!
4245  * \fn void GX_InitTexObjWrapMode(GXTexObj *obj,u8 wrap_s,u8 wrap_t)
4246  * \brief Allows one to modify the texture coordinate wrap modes for an existing texture object.
4247  *
4248  * \param[in] obj ptr to a texture object
4249  * \param[in] wrap_s texture coordinate wrapping strategy in the S direction; use <tt>GX_CLAMP</tt>, <tt>GX_REPEAT</tt> or <tt>GX_MIRROR</tt>
4250  * \param[in] wrap_t texture coordinate wrapping strategy in the T direction; use <tt>GX_CLAMP</tt>, <tt>GX_REPEAT</tt> or <tt>GX_MIRROR</tt>
4251  *
4252  * \return none
4253  */
4254 void GX_InitTexObjWrapMode(GXTexObj *obj,u8 wrap_s,u8 wrap_t);
4255 
4256 /*!
4257  * \fn void GX_InitTexObjFilterMode(GXTexObj *obj,u8 minfilt,u8 magfilt)
4258  * \brief Sets the filter mode for a texture.
4259  *
4260  * \details When the ratio of texels for this texture to pixels is not 1:1, the filter type for \a minfilt or \a magfilt is used.
4261  *
4262  * \param[in] obj texture object to set the filters for
4263  * \param[in] minfilt filter mode to use when the texel/pixel ratio is >= 1.0; needs to be one of \ref texfilter.
4264  * \param[in] magfilt filter mode to use when the texel/pixel ratio is < 1.0; needs to be \a GX_NEAR or \a GX_LINEAR
4265  */
4266 void GX_InitTexObjFilterMode(GXTexObj *obj,u8 minfilt,u8 magfilt);
4267 
4268 /*!
4269  * \fn void GX_InitTexObjMinLOD(GXTexObj *obj,f32 minlod)
4270  * \brief Sets the minimum LOD for a given texture.
4271  *
4272  * \param[in] obj texture to set the minimum LOD for
4273  * \param[in] minlod minimum LOD value; the hardware will use MAX(min_lod, lod); range is 0.0 to 10.0.
4274  */
4275 void GX_InitTexObjMinLOD(GXTexObj *obj,f32 minlod);
4276 
4277 /*!
4278  * void GX_InitTexObjMaxLOD(GXTexObj *obj,f32 maxlod)
4279  * \brief Sets the maximum LOD for a given texture.
4280  *
4281  * \param[in] obj texture to set the maximum LOD for
4282  * \param[in] maxlod maximum LOD value; the hardware will use MIN(max_lod, lod); range is 0.0 to 10.0.
4283  */
4284 void GX_InitTexObjMaxLOD(GXTexObj *obj,f32 maxlod);
4285 
4286 /*!
4287  * \fn void GX_InitTexObjLODBias(GXTexObj *obj,f32 lodbias)
4288  * \brief Sets the LOD bias for a given texture.
4289  *
4290  * \details The LOD computed by the graphics hardware can be biased using this function. The \a lodbias is added to the computed lod and the
4291  * result is clamped between the values given to GX_InitTexObjMinLOD() and GX_InitTexObjMaxLOD(). If \a GX_ENABLE is given to
4292  * GX_InitTexObjBiasClamp(), the effect of \a lodbias will diminish as the polygon becomes more perpendicular to the view direction.
4293  *
4294  * \param[in] obj texture to set the LOD bias for
4295  * \param[in] lodbias bias to add to computed LOD value
4296  */
4297 void GX_InitTexObjLODBias(GXTexObj *obj,f32 lodbias);
4298 
4299 /*!
4300  * \fn void GX_InitTexObjBiasClamp(GXTexObj *obj,u8 biasclamp)
4301  * \brief Enables bias clamping for texture LOD.
4302  *
4303  * \details If \a biasclamp is \a GX_ENABLE, the sum of LOD and \a lodbias (given in GX_InitTexObjLODBias()) is clamped so that it is never
4304  * less than the minimum extent of the pixel projected in texture space. This prevents over-biasing the LOD when the polygon is perpendicular
4305  * to the view direction.
4306  *
4307  * \param[in] obj texture to set the bias clamp value for
4308  * \param[in] biasclamp whether or not to enable the bias clamp
4309  */
4310 void GX_InitTexObjBiasClamp(GXTexObj *obj,u8 biasclamp);
4311 
4312 /*!
4313  * \fn void GX_InitTexObjEdgeLOD(GXTexObj *obj,u8 edgelod)
4314  * \brief Changes LOD computing mode.
4315  *
4316  * \details When set to \a GX_ENABLE, the LOD is computed using adjacent texels; when \a GX_DISABLE, diagonal texels are used instead. This
4317  * should be set to \a GX_ENABLE if you use bias clamping (see GX_InitTexObjBiasClamp()) or anisotropic filtering (GX_ANISO_2 or GX_ANISO_4
4318  * for GX_InitTexObjMaxAniso() argument).
4319  *
4320  * \param[in] obj texture to set the edge LOD for
4321  * \param[in] edgelod mode to set LOD computation to
4322  */
4323 void GX_InitTexObjEdgeLOD(GXTexObj *obj,u8 edgelod);
4324 
4325 /*!
4326  * \fn void GX_InitTexObjMaxAniso(GXTexObj *obj,u8 maxaniso)
4327  * \brief Sets the maximum anisotropic filter to use for a texture.
4328  *
4329  * \details Anisotropic filtering is accomplished by iterating the square filter along the direction of anisotropy to better approximate the
4330  * quadralateral. This type of filtering results in sharper textures at the expense of multiple cycles per quad. The hardware will only use
4331  * multiple cycles when necessary, and the maximum number of cycles is clamped by the \a maxaniso parameter, so setting \a maxaniso to
4332  * \a GX_ANISO_2 will use at most 2 filter cycles per texture.
4333  *
4334  * \note These filter cycles are internal to the texture filter hardware and do not affect the available number of TEV stages. When setting
4335  * \a maxaniso to \a GX_ANISO_2 or \a GX_ANISO_4, the \a minfilt parameter given to GX_InitTexObjFilterMode() should be set to
4336  * \a GX_LIN_MIP_LIN.
4337  *
4338  * \param[in] obj texture to set the max anisotropy value to
4339  * \param[in] maxaniso the maximum anistropic filter to use; must be one of \ref anisotropy
4340  */
4341 void GX_InitTexObjMaxAniso(GXTexObj *obj,u8 maxaniso);
4342 
4343 /*!
4344  * \fn GX_InitTexObjUserData(GXTexObj *obj,void *userdata)
4345  * \brief Used to set a pointer to user data in the \ref GXTexObj structure.
4346  *
4347  * \details You can use this function to attach private data structures to the texture object. This pointer can be retrieved using GX_GetTexObjUserData().
4348  *
4349  * \param[in] obj ptr to a texture object
4350  * \param[in] userdata pointer to your data to attach to this texture
4351  */
4352 void GX_InitTexObjUserData(GXTexObj *obj,void *userdata);
4353 
4354 /*!
4355  * \fn void GX_LoadTexObj(GXTexObj *obj,u8 mapid)
4356  * \brief Loads the state describing a texture into one of eight hardware register sets.
4357  *
4358  * \details Before this happens, the texture object \a obj should be initialized using GX_InitTexObj() or GX_InitTexObjCI(). The \a id parameter refers to
4359  * the texture state register set. Once loaded, the texture can be used in any Texture Environment (TEV) stage using GX_SetTevOrder().
4360  *
4361  * \note This function will call the functions set by GX_SetTexRegionCallback() (and GX_SetTlutRegionCallback() if the texture is color-index
4362  * format) to obtain the texture regions associated with this texture object. These callbacks are set to default functions by GX_Init().
4363  *
4364  * \warning If the texture is a color-index texture, you <b>must</b> load the associated TLUT (using GX_LoadTlut()) before calling GX_LoadTexObj().
4365  *
4366  * \param[in] obj ptr to a texture object
4367  * \param[in] mapid \ref texmapid, <tt>GX_TEXMAP0</tt> to <tt>GX_TEXMAP7</tt> only
4368  *
4369  * \return none
4370  */
4371 void GX_LoadTexObj(GXTexObj *obj,u8 mapid);
4372 
4373 /*!
4374  * \fn void GX_LoadTlut(GXTlutObj *obj,u32 tlut_name)
4375  * \brief Copies a Texture Look-Up Table (TLUT) from main memory to Texture Memory (TMEM).
4376  *
4377  * \details The \a tlut_name parameter is the name of a pre-allocated area of TMEM. The callback function set by GX_SetTlutRegionCallback() converts
4378  * the \a tlut_name into a \ref GXTlutRegion pointer. The TLUT is loaded in the TMEM region described by this pointer. The TLUT object \a obj describes the
4379  * location of the TLUT in main memory, the TLUT format, and the TLUT size. \a obj should have been previously initialized using GX_InitTlutObj().
4380  *
4381  * \note GX_Init() sets a default callback to convert \a tlut_names from \ref tlutname to \ref GXTlutRegion pointers. The default configuration of
4382  * TMEM has 20 TLUTs, 16 each 256 entries by 16 bits, and 4 each 1k entries by 16 bits. This configuration can be overriden by calling
4383  * GX_InitTlutRegion() and GX_InitTexCacheRegion() to allocate TMEM. Then you can define your own region allocation scheme using GX_SetTlutRegionCallback()
4384  * and GX_SetTexRegionCallback().
4385  *
4386  * \param[in] obj ptr to a TLUT object; application must allocate this
4387  * \param[in] tlut_name \ref tlutname
4388  *
4389  * \return none
4390  */
4391 void GX_LoadTlut(GXTlutObj *obj,u32 tlut_name);
4392 
4393 /*!
4394  * \fn void GX_LoadTexObjPreloaded(GXTexObj *obj,GXTexRegion *region,u8 mapid)
4395  * \brief Loads the state describing a preloaded texture into one of eight hardware register sets.
4396  *
4397  * \details Before this happens, the texture object \a obj should be initialized using GX_InitTexObj() or GX_InitTexObjCI(). The \a mapid parameter refers to
4398  * the texture state register set. The texture should be loaded beforehand using GX_PreloadEntireTexture(). Once loaded, the texture can be used in any Texture Environment
4399  * (TEV) stage using GX_SetTevOrder().
4400  *
4401  * \note GX_Init() initially calls GX_SetTevOrder() to make a simple texture pipeline that associates <tt>GX_TEXMAP0</tt> with <tt>GX_TEVSTAGE0</tt>,
4402  * <tt>GX_TEXMAP1</tt> with <tt>GX_TEVSTAGE1</tt>, etc.<br><br>
4403  *
4404  * \note GX_LoadTexObjPreloaded() will not call the functions set by GX_SetTexRegionCallback() (and GX_SetTlutRegionCallback() if the texture is color
4405  * index format) because the region is set explicitly; however, these callback functions must be aware of all regions that are preloaded. The default
4406  * callbacks set by GX_Init() assume there are no preloaded regions.
4407  *
4408  * \param[in] obj ptr to a texture object
4409  * \param[in] region ptr to a region object that describes an area of texture memory
4410  * \param[in] mapid \ref texmapid for reference in a TEV stage
4411  *
4412  * \return none
4413  */
4414 void GX_LoadTexObjPreloaded(GXTexObj *obj,GXTexRegion *region,u8 mapid);
4415 
4416 /*!
4417  * \fn void GX_PreloadEntireTexture(GXTexObj *obj,GXTexRegion *region)
4418  * \brief Loads a given texture from DRAM into the texture memory.
4419  *
4420  * \details Accesses to this texture will bypass the texture cache tag look-up and instead read the texels directly from texture memory. The
4421  * texture region must be the same size as the texture (see GX_InitTexPreloadRegion()).
4422  *
4423  * \note This function loads the texture into texture memory, but to use it as a source for the Texture Environment (TEV) unit, you must first
4424  * call GX_LoadTexObjPreloaded(). The default configuration (as set by GX_Init()) of texture memory has no preloaded regions, so you must install
4425  * your own region allocator callbacks using GX_SetTexRegionCallback() and GX_SetTlutRegionCallback().
4426  *
4427  * \param[in] obj ptr to object describing the texture to laod
4428  * \param[in] region TMEM texture region to load the texture into
4429  *
4430  * \return none
4431  */
4432 void GX_PreloadEntireTexture(GXTexObj *obj,GXTexRegion *region);
4433 
4434 /*!
4435  * \fn void GX_InitTlutObj(GXTlutObj *obj,void *lut,u8 fmt,u16 entries)
4436  * \brief Initializes a Texture Look-Up Table (TLUT) object.
4437  *
4438  * \details The TLUT object describes the location of the TLUT in main memory, its format and the number of entries. The TLUT in main
4439  * memory described by this object can be loaded into a TLUT allocated in the texture memory using the GX_LoadTlut() function.
4440  *
4441  * \param[in] obj ptr to a TLUT object
4442  * \param[in] lut ptr to look-up table data; must be 32B aligned
4443  * \param[in] fmt format of the entries in the TLUt; <tt>GX_TL_IA8</tt>, <tt>GX_TL_RGB565</tt> or <tt>GX_TL_RGB5A3</tt>
4444  * \param[in] entries number of entries in this table; maximum is 16,384
4445  *
4446  * \return none
4447  */
4448 void GX_InitTlutObj(GXTlutObj *obj,void *lut,u8 fmt,u16 entries);
4449 
4450 /*!
4451  * \fn void GX_InitTlutRegion(GXTlutRegion *region,u32 tmem_addr,u8 tlut_sz)
4452  * \brief Initializes a Texture Look-Up Table (TLUT) region object.
4453  *
4454  * \note GX_Init() creates default TLUT regions, so the application does not need to call this function unless a new configuration
4455  * of Texture Memory is desired. In that case, the application should also set a new TLUT region allocator using GX_SetTlutRegionCallback().
4456  *
4457  * \param[in] region obj ptr to a TLUT region struct; application must allocate this
4458  * \param[in] tmem_addr location of the TLU in TMEM; ptr must be aligned to table size
4459  * \param[in] tlut_sz size of the table
4460  *
4461  * \return none
4462  */
4463 void GX_InitTlutRegion(GXTlutRegion *region,u32 tmem_addr,u8 tlut_sz);
4464 
4465 /*!
4466  * \fn void GX_InitTexObjLOD(GXTexObj *obj,u8 minfilt,u8 magfilt,f32 minlod,f32 maxlod,f32 lodbias,u8 biasclamp,u8 edgelod,u8 maxaniso)
4467  * \brief Sets texture Level Of Detail (LOD) controls explicitly for a texture object.
4468  *
4469  * \details It is the application's responsibility to provide memory for a texture object. When initializing a texture object using GX_InitTexObj()
4470  * or GX_InitTexObjCI(), this information is set to default values based on the mipmap flag. This function allows the programmer to override those
4471  * defaults.
4472  *
4473  * \note This function should be called after GX_InitTexObj() or GX_InitTexObjCI() for a particular texture object.<br><br>
4474  *
4475  * \note Setting \a biasclamp prevents over-biasing the LOD when the polygon is perpendicular to the view direction.<br><br>
4476  *
4477  * \note \a edgelod should be set if \a biasclamp is set or \a maxaniso is set to <tt>GX_ANISO_2</tt> or <tt>GX_ANISO_4</tt>.<br><br>
4478  *
4479  * \note Theoretically, there is no performance difference amongst various magnification/minification filter settings except <tt>GX_LIN_MIP_LIN</tt> filter with
4480  * <tt>GX_TF_RGBA8</tt> texture format which takes twice as much as other formats. However, this argument is assuming an environment where texture cache always
4481  * hits. On real environments, you will see some performance differences by changing filter modes (especially minification filter) because cache-hit ratio
4482  * changes according to which filter mode is being used.
4483  *
4484  * \param[in] obj ptr to a texture object
4485  * \param[in] minfilt \ref texfilter to use when the texel/pixel ratio is >= 1.0
4486  * \param[in] magfilt \ref texfilter to use when the texel/pixel ratio is < 1.0; use only <tt>GX_NEAR</tt> or <tt>GX_LINEAR</tt>
4487  * \param[in] minlod minimum LOD value from 0.0 - 10.0 inclusive
4488  * \param[in] maxlod maximum LOD value from 0.0 - 10.0 inclusive
4489  * \param[in] lodbias bias to add to computed LOD value
4490  * \param[in] biasclamp if <tt>GX_ENABLE</tt>, clamp (LOD+lodbias) so that it is never less than the minimum extent of the pixel projected in texture space
4491  * \param[in] edgelod if <tt>GX_ENABLE</tt>, compute LOD using adjacent texels
4492  * \param[in] maxaniso \ref anisotropy to use
4493  *
4494  * \return none
4495  */
4496 void GX_InitTexObjLOD(GXTexObj *obj,u8 minfilt,u8 magfilt,f32 minlod,f32 maxlod,f32 lodbias,u8 biasclamp,u8 edgelod,u8 maxaniso);
4497 
4498 /*!
4499  * \fn void GX_SetTexCoordScaleManually(u8 texcoord,u8 enable,u16 ss,u16 ts)
4500  * \brief Overrides the automatic texture coordinate scaling (based upon the associated map size) and lets one manually assign the scale values that
4501  * are used for a given \a texcoord.
4502  *
4503  * \details Setting the \a enable parameter to <tt>GX_TRUE</tt> gives this behavior. The given \a texcoord retains these manual scale values until this function is
4504  * called again. This function is also used to return a given texture coordinate back to normal, automatic scaling (by setting \a enable to <tt>GX_FALSE</tt>).
4505  *
4506  * \note A texture coordinate is scaled after being computed by the relevant texgen and before the actual texture lookup  Normally, the scale value is set
4507  * according to the texture map that is associated with the texcoord by GX_SetTevOrder(). However, there are certain cases where a different scale value is
4508  * desirable. One such case is when using indirect tiled textures (see GX_SetTevIndTile()).
4509  *
4510  * \param[in] texcoord the \ref texcoordid being changed
4511  * \param[in] enable if <tt>GX_TRUE</tt>, scale will be set manually, otherwise set automatically and \a ss and \a ts ignored
4512  * \param[in] ss manual scale value for the S component of the coordinate
4513  * \param[in] ts manual scale value for the T component of the coordinate
4514  *
4515  * \return none
4516  */
4517 void GX_SetTexCoordScaleManually(u8 texcoord,u8 enable,u16 ss,u16 ts);
4518 
4519 /*!
4520  * \fn void GX_SetTexCoordBias(u8 texcoord,u8 s_enable,u8 t_enable)
4521  * \brief Sets the texture coordinate bias of a particular texture.
4522  *
4523  * \details Range bias is used with texture coordinates applied in <tt>GX_REPEAT</tt> wrap mode in order to increase the precision of texture coordinates
4524  * that spread out over a large range. The texture coordinate values for a primitive are biased (by an equal integer) towards zero early in the
4525  * graphics pipeline, thus preserving bits for calculation later in the pipe.  Since the coordinates are repeated, this bias by an integer should
4526  * have no effect upon the actual appearance of the texture.
4527  *
4528  * \note Texture coordinate range bias is something that is normally set automatically by the GX API (during GX_Begin()); however, when a texture
4529  * coordinate is being scaled manually (by using GX_SetTexCoordScaleManually()), the associated bias is no longer modified by GX. Thus,
4530  * GX_SetTexCoordBias() allows the bias to be changed while a texture coordinate is being manually controlled.
4531  *
4532  * \param[in] texcoord \ref texcoordid being changed
4533  * \param[in] s_enable enable or disable range bias in the S direction with <tt>GX_ENABLE</tt>/<tt>GX_DISABLE</tt>
4534  * \param[in] t_enable enable or disable range bias in the T direction with <tt>GX_ENABLE</tt>/<tt>GX_DISABLE</tt>
4535  *
4536  * \return none
4537  */
4538 void GX_SetTexCoordBias(u8 texcoord,u8 s_enable,u8 t_enable);
4539 
4540 /*!
4541  * \fn GXTexRegionCallback GX_SetTexRegionCallback(GXTexRegionCallback cb)
4542  * \brief Sets the callback function called by GX_LoadTexObj() to obtain an available texture region.
4543  *
4544  * \details GX_Init() calls this function to set a default region-assignment policy. A programmer can override this default region assignment
4545  * by implementing his own callback function. A pointer to the texture object and the texture map ID that are passed
4546  * to GX_LoadTexObj() are provided to the callback function.
4547  *
4548  * \param[in] cb ptr to a function that takes a pointer to a GXTexObj and a \ref texmapid as a parameter and returns a pointer to a \ref GXTexRegion.
4549  *
4550  * \return pointer to the previously set callback
4551  */
4552 GXTexRegionCallback GX_SetTexRegionCallback(GXTexRegionCallback cb);
4553 
4554 /*!
4555  * \fn GXTlutRegionCallback GX_SetTlutRegionCallback(GXTlutRegionCallback cb)
4556  * \brief Sets the callback function called by GX_LoadTlut() to find the region into which to load the TLUT.
4557  *
4558  * \details GX_LoadTexObj() will also call \a cb to obtain the Texture Look-up Table (TLUT) region when the texture forma
4559  * is color-index.
4560  *
4561  * GX_Init() calls GX_SetTlutRegionCallback() to set a default TLUT index-to-region mapping. The name for the TLUT from the texture
4562  * object is provided as an argument to the callback. The callback should return a pointer to the \ref GXTlutRegion for this TLUT index.
4563  *
4564  * \note For a given \a tlut_name (in the \ref GXTlutRegionCallback struct), \a cb must always return the same \ref GXTlutRegion; this is because
4565  * GX_LoadTlut() will initialize data into the \ref GXTlutRegion which GX_LoadTexObj() will subsequently use.
4566  *
4567  * \param[in] cb ptr to a function that takes a u32 TLUT name as a parameter and returns a pointer to a \ref GXTlutRegion.
4568  *
4569  * \return pointer to the previously set callback
4570  */
4571 GXTlutRegionCallback GX_SetTlutRegionCallback(GXTlutRegionCallback cb);
4572 
4573 /*!
4574  * \fn void GX_InitLightPos(GXLightObj *lit_obj,f32 x,f32 y,f32 z)
4575  * \brief Sets the position of the light in the light object.
4576  *
4577  * \details The GameCube graphics hardware supports local diffuse lights. The position of the light should be in the same space as a transformed
4578  * vertex position (i.e., view space).
4579  *
4580  * \note Although the hardware doesn't support parallel directional diffuse lights, it is possible to get "almost parallel" lights by setting
4581  * sufficient large values to position parameters (x, y and z) which makes the light position very far away from objects to be lit and all rays
4582  * considered almost parallel.<br><br>
4583  *
4584  * \note The memory for the light object must be allocated by the application; this function does not load any hardware registers directly. To
4585  * load a light object into a hardware light, use GX_LoadLightObj() or GX_LoadLightObjIdx().
4586  *
4587  * \param[in] lit_obj ptr to the light object
4588  * \param[in] x X coordinate to place the light at
4589  * \param[in] y Y coordinate to place the light at
4590  * \param[in] z Z coordinate to place the light at
4591  *
4592  * \return none
4593  */
4594 void GX_InitLightPos(GXLightObj *lit_obj,f32 x,f32 y,f32 z);
4595 
4596 /*!
4597  * \fn void GX_InitLightColor(GXLightObj *lit_obj,GXColor col)
4598  * \brief Sets the color of the light in the light object.
4599  *
4600  * \note The memory for the light object should be allocated by the application; this function does not load any hardware register directly.  To
4601  * load a light object into a hardware light, use GX_LoadLightObj() or GX_LoadLightObjIdx().
4602  *
4603  * \param[in] lit_obj ptr to the light object
4604  * \param[in] col color to set the light to
4605  *
4606  * \return none
4607  */
4608 void GX_InitLightColor(GXLightObj *lit_obj,GXColor col);
4609 
4610 /*!
4611  * \fn void GX_InitLightDir(GXLightObj *lit_obj,f32 nx,f32 ny,f32 nz)
4612  * \brief Sets the direction of a light in the light object.
4613  *
4614  * \details This direction is used when the light object is used as spotlight or a specular light (see the <i>attn_fn</i> parameter of GX_SetChanCtrl()).
4615  *
4616  * \note The coordinate space of the light normal should be consistent with a vertex normal transformed by a normal matrix; i.e., it should be
4617  * transformed to view space.<br><br>
4618  *
4619  * \note This function does not set the direction of parallel directional diffuse lights. If you want parallel diffuse lights, you may put the light
4620  * position very far from every objects to be lit. (See GX_InitLightPos() and GX_SetChanCtrl())<br><br>
4621  *
4622  * \note The memory for the light object must be allocated by the application; this function does not load any hardware registers.  To load a light
4623  * object into a hardware light, use GX_LoadLightObj() or GX_LoadLightObjIdx().
4624  *
4625  * \param[in] lit_obj ptr to the light object
4626  * \param[in] nx X coordinate of the light normal
4627  * \param[in] ny Y coordinate of the light normal
4628  * \param[in] nz Z coordinate of the light normal
4629  *
4630  * \return none
4631  */
4632 void GX_InitLightDir(GXLightObj *lit_obj,f32 nx,f32 ny,f32 nz);
4633 
4634 /*!
4635  * \fn void GX_LoadLightObj(GXLightObj *lit_obj,u8 lit_id)
4636  * \brief Loads a light object into a set of hardware registers associated with a \ref lightid.
4637  *
4638  * \details This function copies the light object data into the graphics FIFO through the CPU write-gather buffer mechanism. This guarantees that
4639  * the light object is coherent with the CPU cache.
4640  *
4641  * \note The light object must have been initialized first using the necessary GX_InitLight*() functions.<br><br>
4642  *
4643  * \note Another way to load a light object is with GX_LoadLightObjIdx().
4644  *
4645  * \param[in] lit_obj ptr to the light object to load
4646  * \param[in] lit_id \ref lightid to load this light into
4647  *
4648  * \return none
4649  */
4650 void GX_LoadLightObj(GXLightObj *lit_obj,u8 lit_id);
4651 
4652 /*!
4653  * \fn void GX_LoadLightObjIdx(u32 litobjidx,u8 litid)
4654  * \brief Instructs the GP to fetch the light object at \a ltobjindx from an array.
4655  *
4656  * \details The light object is retrieved from the array to which <tt>GX_SetArray(GX_VA_LIGHTARRAY, ...)</tt> points. Then it loads the object into
4657  * the hardware register associated with \ref lightid.
4658  *
4659  * \note Data flows directly from the array in DRAM to the GP; therefore, the light object data may not be coherent with the CPU's cache. The
4660  * application is responsible for storing the light object data from the CPU cache (using DCStoreRange()) before calling GX_LoadLightObjIdx().
4661  *
4662  * \param[in] litobjidx index to a light object
4663  * \param[in] litid \ref lightid to load this light into
4664  *
4665  * \return none
4666  */
4667 void GX_LoadLightObjIdx(u32 litobjidx,u8 litid);
4668 
4669 /*!
4670  * \fn void GX_InitLightDistAttn(GXLightObj *lit_obj,f32 ref_dist,f32 ref_brite,u8 dist_fn)
4671  * \brief Sets coefficients for distance attenuation in a light object.
4672  *
4673  * \details This function uses three easy-to-control parameters instead of <i>k0</i>, <i>k1</i>, and <i>k2</i> in GX_InitLightAttn().
4674  *
4675  * In this function, you can specify the brightness on an assumed reference point. The parameter \a ref_distance is distance between the light
4676  * and the reference point. The parameter \a ref_brite specifies ratio of the brightness on the reference point. The value for \a ref_dist should
4677  * be greater than 0 and that for \a ref_brite should be within 0 < \a ref_brite < 1, otherwise distance attenuation feature is turned off. The
4678  * parameter \a dist_fn defines type of the brightness decreasing curve by distance; <tt>GX_DA_OFF</tt> turns distance attenuation feature off.
4679  *
4680  * \note If you want more flexible control, it is better to use GX_InitLightAttn() and calculate appropriate coefficients.<br><br>
4681  *
4682  * \note This function sets parameters only for distance attenuation. Parameters for angular attenuation should be set by using
4683  * GX_InitLightSpot() or GX_InitLightAttnA().<br><br>
4684  *
4685  * \note This function does not load any hardware registers directly. To load a light object into a hardware light, use GX_LoadLightObj() or
4686  * GX_LoadLightObjIdx().
4687  *
4688  * \param[in] lit_obj ptr to a light object
4689  * \param[in] ref_dist distance between the light and reference point
4690  * \param[in] ref_brite brightness of the reference point
4691  * \param[in] dist_fn \ref distattnfn to use
4692  *
4693  * \return none
4694  */
4695 void GX_InitLightDistAttn(GXLightObj *lit_obj,f32 ref_dist,f32 ref_brite,u8 dist_fn);
4696 
4697 /*!
4698  * \fn void GX_InitLightAttn(GXLightObj *lit_obj,f32 a0,f32 a1,f32 a2,f32 k0,f32 k1,f32 k2)
4699  * \brief Sts coefficients used in the lighting attenuation calculation in a given light object.
4700  *
4701  * \details The parameters \a a0, \a a1, and \a a2 are used for angular (spotlight) attenuation. The coefficients \a k0, \a k1, and \a k2 are used for
4702  * distance attenuation. The attenuation function is:
4703  *
4704  * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<i>atten</i> = <i>clamp0</i>(\a a2^2 * <i>aattn</i>^2 + \a a1 * <i>aattn</i> + \a a0) / (\a k2 * <i>d</i>^2 + \a k1  * <i>d</i> + \a k0)
4705  *
4706  * where <i>aattn</i> is the cosine of the angle between the light direction and the vector from the light position to the vertex, and <i>d</i> is
4707  * the distance from the light position to the vertex when the channel attenuation function is <tt>GX_AF_SPOT</tt>. The light color will be
4708  * multiplied by the <i>atten</i> factor when the attenuation function for the color channel referencing this light is set to <tt>GX_AF_SPOT</tt>
4709  * (see GX_SetChanCtrl()).
4710  *
4711  * \note The convenience function GX_InitLightSpot() can be used to set the angle attenuation coefficents based on several spot light
4712  * types. The convenience function GX_InitLightDistAttn() can be used to set the distance attenuation coefficients using one of several
4713  * common attenuation functions.<br><br>
4714  *
4715  * \note The convenience macro GX_InitLightShininess() can be used to set the attenuation parameters for specular lights.<br><br>
4716  *
4717  * \note When the channel attenuation function is set to <tt>GX_AF_SPEC</tt>, the <i>aattn</i> and <i>d</i> parameter are equal to the dot product of the
4718  * eye-space vertex normal and the half-angle vector set by GX_InitSpecularDir().<br><br>
4719  *
4720  * \note This function does not load any hardware registers directly. To load a light object into a hardware light, use GX_LoadLightObj()
4721  * or GX_LoadLightObjIdx().
4722  *
4723  * \param[in] lit_obj ptr to a light object
4724  * \param[in] a0 angle attenuation coefficient
4725  * \param[in] a1 angle attenuation coefficient
4726  * \param[in] a2 angle attenuation coefficient
4727  * \param[in] k0 distance attenuation coefficient
4728  * \param[in] k1 distance attenuation coefficient
4729  * \param[in] k2 distance attenuation coefficient
4730  *
4731  * \return none
4732  */
4733 void GX_InitLightAttn(GXLightObj *lit_obj,f32 a0,f32 a1,f32 a2,f32 k0,f32 k1,f32 k2);
4734 
4735 /*!
4736  * \fn void GX_InitLightAttnA(GXLightObj *lit_obj,f32 a0,f32 a1,f32 a2)
4737  * \brief Sets coefficients used in the lighting angle attenuation calculation in a given light object.
4738  *
4739  * \details The parameters \a a0, \a a1, and \a a2 are used for angular (spotlight) attenuation. The attenuation
4740  * function is:
4741  *
4742  * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<i>atten</i> = <i>clamp0</i>(\a a2^2 * <i>cos(theta)</i>^2 + \a a1 * <i>cos(theta)</i> + \a a0) / (\a k2 * <i>d</i>^2 + \a k1  * <i>d</i> + \a k0)
4743  *
4744  * where <i>cos(theta)</i> is the cosine of the angle between the light normal and the vector from the light position to the vertex, and <i>d</i> is the distance
4745  * from the light position to the vertex. The \a k0-\a 2 coefficients can be set using GX_InitLightAttnK(). You can set both the \a a0-\a 2 and \a k0-\a 2 coefficients
4746  * can be set using GX_InitLightAttn(). The light color will be multiplied by the <i>atten</i> factor when the attenuation function for the color channel
4747  * referencing this light is set to <tt>GX_AF_SPOT</tt> (see GX_SetChanCtrl()).
4748  *
4749  * \note The convenience function GX_InitLightSpot() can be used to set the angle attenuation coefficents based on several spot light types. The
4750  * convenience function GX_InitLightDistAttn() can be used to set the distance attenuation coefficients using one of several common attenuation functions.<br><br>
4751  *
4752  * \note This function does not load any hardware registers directly. To load a light object into a hardware light, use GX_LoadLightObj() or GX_LoadLightObjIdx().
4753  *
4754  * \param[in] lit_obj ptr to a light object
4755  * \param[in] a0 angle attenuation coefficient
4756  * \param[in] a1 angle attenuation coefficient
4757  * \param[in] a2 angle attenuation coefficient
4758  *
4759  * \return none
4760  */
4761 void GX_InitLightAttnA(GXLightObj *lit_obj,f32 a0,f32 a1,f32 a2);
4762 
4763 /*!
4764  * \fn void GX_InitLightAttnK(GXLightObj *lit_obj,f32 k0,f32 k1,f32 k2)
4765  * \brief Sets coefficients used in the lighting distance attenuation calculation in a given light object.
4766  *
4767  * \details The coefficients \a k0, \a k1, and \a k2 are used for distance attenuation. The attenuation function is:
4768  *
4769  * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<i>atten</i> = <i>clamp0</i>(\a a2^2 * <i>cos(theta)</i>^2 + \a a1 * <i>cos(theta)</i> + \a a0) / (\a k2 * <i>d</i>^2 + \a k1  * <i>d</i> + \a k0)
4770  *
4771  * where <i>cos(theta)</i> is the cosine of the angle between the light normal and the vector from the light position to the vertex, and <i>d</i> is the distance
4772  * from the light position to the vertex. The \a a0-\a 2 coefficients can be set using GX_InitLightAttnA(). You can set both the \a a0-\a 2 and \a k0-\a 2 coefficients
4773  * can be set using GX_InitLightAttn(). The light color will be multiplied by the <i>atten</i> factor when the attenuation function for the color channel
4774  * referencing this light is set to <tt>GX_AF_SPOT</tt> (see GX_SetChanCtrl()).
4775  *
4776  * \note The convenience function GX_InitLightSpot() can be used to set the angle attenuation coefficents based on several spot light types. The convenience
4777  * function GX_InitLightDistAttn() can be used to set the distance attenuation coefficients using one of several common attenuation functions.<br><br>
4778  *
4779  * \note Note that this function does not load any hardware registers directly. To load a light object into a hardware light, use GX_LoadLightObj() or
4780  * GX_LoadLightObjIdx().
4781  *
4782  * \param[in] lit_obj ptr to a light object
4783  * \param[in] k0 distance attenuation coefficient
4784  * \param[in] k1 distance attenuation coefficient
4785  * \param[in] k2 distance attenuation coefficient
4786  *
4787  * \return none
4788  */
4789 void GX_InitLightAttnK(GXLightObj *lit_obj,f32 k0,f32 k1,f32 k2);
4790 
4791 /*!
4792  * \fn void GX_InitSpecularDirHA(GXLightObj *lit_obj,f32 nx,f32 ny,f32 nz,f32 hx,f32 hy,f32 hz)
4793  * \brief Sets the direction and half-angle vector of a specular light in the light object.
4794  *
4795  * \details These vectors are used when the light object is used only as specular light. In contrast to GX_InitSpecularDir(),
4796  * which caclulates half-angle vector automatically by assuming the view vector as (0, 0, 1), this function allows users to
4797  * specify half-angle vector directly as input arguments. It is useful to do detailed control for orientation of highlights.
4798  *
4799  * \note This function does not load any hardware registers. To load a light object into a hardware light, use GX_LoadLightObj()
4800  * or GX_LoadLightObjIdx().<br><br>
4801  *
4802  * \note Other notes are similar to those described in GX_InitSpecularDir().
4803  *
4804  * \param[in] lit_obj ptr to a light object
4805  * \param[in] nx X coordinate of the light normal
4806  * \param[in] ny Y coordinate of the light normal
4807  * \param[in] nz Z coordinate of the light normal
4808  * \param[in] hx X coordinate of half-angle
4809  * \param[in] hy Y coordinate of half-angle
4810  * \param[in] hz Z coordinate of half-angle
4811  *
4812  * \return none
4813  */
4814 void GX_InitSpecularDirHA(GXLightObj *lit_obj,f32 nx,f32 ny,f32 nz,f32 hx,f32 hy,f32 hz);
4815 
4816 /*!
4817  * \fn void GX_InitSpecularDir(GXLightObj *lit_obj,f32 nx,f32 ny,f32 nz)
4818  * \brief Sets the direction of a specular light in the light object.
4819  *
4820  * \details This direction is used when the light object is used only as specular light. The coordinate space of the light normal
4821  * should be consistent with a vertex normal transformed by a normal matrix; i.e., it should be transformed to view space.
4822  *
4823  * \note This function should be used if and only if the light object is used as specular light. One specifies a specular light in
4824  * GX_SetChanCtrl() by setting the \ref attenfunc to <tt>GX_AF_SPEC</tt>. Furthermore, one must not use GX_InitLightDir() or
4825  * GX_InitLightPos() to set up a light object which will be used as a specular light since these functions will destroy the information
4826  * set by GX_InitSpecularDir(). In contrast to diffuse lights (including spotlights) that are considered local lights, a specular light
4827  * is a parallel light (i.e. the specular light is infinitely far away such that all the rays of the light are parallel), and thus one
4828  * can only specify directional information.
4829  *
4830  * \note This function does not load any hardware registers. To load a light object into a hardware light, use GX_LoadLightObj()
4831  * or GX_LoadLightObjIdx().
4832  *
4833  * \param[in] lit_obj ptr to a light object
4834  * \param[in] nx X coordinate of the light normal
4835  * \param[in] ny Y coordinate of the light normal
4836  * \param[in] nz Z coordinate of the light normal
4837  *
4838  * \return none
4839  */
4840 void GX_InitSpecularDir(GXLightObj *lit_obj,f32 nx,f32 ny,f32 nz);
4841 
4842 /*!
4843  * \fn void GX_InitLightSpot(GXLightObj *lit_obj,f32 cut_off,u8 spotfn)
4844  * \brief Sets coefficients for angular (spotlight) attenuation in light object.
4845  *
4846  * \details This function uses two easy-to-control parameters instead of \a a0, \a a1, and \a a2 on GX_InitLightAttn().
4847  *
4848  * \details The parameter \a cut_off specifies cutoff angle of the spotlight by degree. The spotlight works while the angle between the ray for a vertex and
4849  * the light direction given by GX_InitLightDir() is smaller than this cutoff angle. The value for \a cut_off should be within 0 < \a cut_off <= 90.0, otherwise
4850  * given light object doesn't become a spotlight.
4851  *
4852  * The parameter \a spotfn defines type of the illumination distribution within cutoff angle. The value <tt>GX_SP_OFF</tt> turns spotlight feature off even if
4853  * color channel setting is using <tt>GX_AF_SPOT</tt> (see GX_SetChanCtrl()).
4854  *
4855  * \note This function can generate only some kind of simple spotlights. If you want more flexible control, it is better to use GX_InitLightAttn() and calculate
4856  * appropriate coefficients.<br><br>
4857  *
4858  * \note This function sets parameters only for angular attenuation. Parameters for distance attenuation should be set by using GX_InitLightDistAttn() or
4859  * GX_InitLightAttnK().<br><br>
4860  *
4861  * \note This function does not load any hardware registers directly. To load a light object into a hardware light, use GX_LoadLightObj() or GX_LoadLightObjIdx().
4862  *
4863  * \param[in] lit_obj ptr to a light object
4864  * \param[in] cut_off cutoff angle of the spotlight, in degrees
4865  * \param[in] spotfn \ref spotfn to use for this light
4866  *
4867  * \return none
4868  */
4869 void GX_InitLightSpot(GXLightObj *lit_obj,f32 cut_off,u8 spotfn);
4870 
4871 u32 GX_ReadClksPerVtx();
4872 u32 GX_GetOverflowCount();
4873 u32 GX_ResetOverflowCount();
4874 
4875 /*!
4876  * \fn lwp_t GX_GetCurrentGXThread()
4877  * \brief Returns the current GX thread.
4878  *
4879  * \details The current GX thread should be the thread that is currently responsible for generating graphics data. By default,
4880  * the GX thread is the thread that invoked GX_Init(); however, it may be changed by calling GX_SetCurrentGXThread().
4881  *
4882  * \note When graphics data is being generated in immediate mode (that is, the CPU FIFO = GP FIFO, and the GP is actively consuming
4883  * data), the high watermark may be triggered. When this happens, the high watermark interrupt handler will suspend the GX thread, thus
4884  * preventing any further graphics data from being generated. The low watermark interrupt handler will resume the thread.
4885  *
4886  * \return the current GX thread
4887  */
4888 lwp_t GX_GetCurrentGXThread();
4889 
4890 /*!
4891  * \fn lwp_t GX_SetCurrentGXThread()
4892  * \brief Sets the current GX thread to the calling thread.
4893  *
4894  * \details The new thread should be the thread that will be responsible for generating graphics data. By default, the GX thread is
4895  * the thread that invoked GX_Init(); however, it may be changed by calling this function.
4896  *
4897  * \note It is a programming error to change GX thread while the current GX thread is suspended by a high water mark interrupt. This
4898  * indicates that you have two threads about to generate GX data.<br><br>
4899  *
4900  * \note When graphics data is being generated in immediate mode (that is, the CPU FIFO = GP FIFO, and the GP is actively consuming
4901  * data), the high watermark may be triggered. When this happens, the high watermark interrupt handler will suspend the GX thread, thus
4902  * preventing any further graphics data from being generated. The low watermark interrupt handler will resume the thread.
4903  *
4904  * \return the previous GX thread ID
4905  */
4906 lwp_t GX_SetCurrentGXThread();
4907 
4908 /*!
4909  * \fn void GX_RestoreWriteGatherPipe()
4910  * \brief Restores the write-gather pipe.
4911  *
4912  * \details The CPU fifo that was attached at the time GX_RedirectWriteGatherPipe() was called will be re-attached. If there is data pending
4913  * in the write gather pipe (e.g. if the amount of data written was not a multiple of 32 bytes), the data will be padded with zeroes and
4914  * flushed out.
4915  *
4916  * \warning This function must be called between successive calls to GX_RedirectWriteGatherPipe().
4917  *
4918  * \return none
4919  */
4920 void GX_RestoreWriteGatherPipe();
4921 
4922 /*!
4923  * \fn void GX_SetGPMetric(u32 perf0,u32 perf1)
4924  * \brief Sets two performance metrics to measure in the GP.
4925  *
4926  * \details perf0 and perf1 are set to measure. The initial metrics measured are <tt>GX_PERF0_NONE</tt> and <tt>GX_PERF1_NONE</tt>, which return counts of zero
4927  * for the first call to GX_ReadGPMetric().
4928  *
4929  * Each performance counter has a unique set of events or ratios that it can count. In some cases the same metric can be counted using both
4930  * counters, for example <tt>GX_PERF0_VERTICES</tt> and <tt>GX_PERF1_VERTICES</tt>. Ratios (the metric name ends in <tt>_RATIO</tt>) are multiplied by
4931  * 1000 (1000 = all misses/clips, etc., 0 = no misses/clips, etc.).
4932  *
4933  * \note GX_ReadGPMetric() and GX_ClearGPMetric() can be used in the callback associated with the draw sync interrupt (see GX_SetDrawSyncCallback()).
4934  * This function should not be used in the draw sync callback because it will insert tokens in the GP command stream at random times.
4935  *
4936  * \warning This function reads results from CPU-accessible registers in the GP, therefore, this command <i>must not</i> be used in a display list. In
4937  * addition, the performance counters in some cases are triggered by sending tokens through the Graphics FIFO to the GP.  This implies that
4938  * the function should only be used in immediate mode (when the Graphics FIFO is connected to the CPU and the GP at the same time).  It may
4939  * also be necessary to send a draw sync token using GX_SetDrawSync() or call GX_SetDrawDone() after GX_ReadGPMetric() to ensure that the
4940  * state has actually been processed by the GP.
4941  *
4942  * \param[in] perf0 \ref perf0metrics to measure
4943  * \param[in] perf1 \ref perf1metrics to measure
4944  *
4945  * \returns none
4946  */
4947 void GX_SetGPMetric(u32 perf0,u32 perf1);
4948 
4949 /*!
4950  * \fn void GX_ClearGPMetric()
4951  * \brief Clears the two virtual GP performance counters to zero.
4952  *
4953  * \note The counter's function is set using GX_SetGPMetric(); the counter's value is read using GX_ReadGPMetric(). Consult these for more details.
4954  *
4955  * \warning This function resets CPU accessible counters, so it should <b>not</b> be used in a display list.
4956  *
4957  * \return none
4958  */
4959 void GX_ClearGPMetric();
4960 
4961 /*!
4962  * \fn void GX_InitXfRasMetric()
4963  * \brief Initialize the transformation unit (XF) rasterizer unit (RAS) to take performance measurements.
4964  *
4965  * \warning This function should be avoided; use the GP performance metric functions instead.
4966  *
4967  * \return none
4968  */
4969 void GX_InitXfRasMetric();
4970 
4971 /*!
4972  * \fn void GX_ReadXfRasMetric(u32 *xfwaitin,u32 *xfwaitout,u32 *rasbusy,u32 *clks)
4973  * \brief Read performance metric values from the XF and RAS units.
4974  *
4975  * \warning This function should be avoided; use the GP performance metric functions instead.<br><br>
4976  *
4977  * \warning The parameters for this function are a best guess based on names and existing code.
4978  *
4979  * \param[out] xfwaitin Number of clocks the XF has waited for data to arrive?
4980  * \param[out] xfwaitout Number of clocks the XF has waited to push finished data down?
4981  * \param[out] rasbusy Number of clocks the RAS has spent being busy?
4982  * \param[out] clks Clocks that have passed since last count reset?
4983  *
4984  * \return none
4985  */
4986 void GX_ReadXfRasMetric(u32 *xfwaitin,u32 *xfwaitout,u32 *rasbusy,u32 *clks);
4987 
4988 /*!
4989  * \fn void GX_ClearVCacheMetric()
4990  * \brief Clears the Vertex Cache performance counter.
4991  *
4992  * \details This function clears the performance counter by sending a special clear token via the Graphics FIFO.
4993  *
4994  * \note To set the metric for the counter, call GX_SetVCacheMetric(); to read the counter value, call GX_ReadVCacheMetric().
4995  *
4996  * \return none
4997  */
4998 void GX_ClearVCacheMetric();
4999 
5000 /*!
5001  * \fn void GX_ReadVCacheMetric(u32 *check,u32 *miss,u32 *stall)
5002  * \brief Returns Vertex Cache performance counters.
5003  *
5004  * \details Each call to this function resets the counter to zero. GX_SetVCacheMetric() sets the metric to be measured by
5005  * the Vertex Cache performance counter.
5006  *
5007  * \warning This function reads CPU-accessible registers in the GP and so should not be called in a display list.
5008  *
5009  * \param[out] check total number of accesses to the vertex cache
5010  * \param[out] miss total number of cache misses to the vertex cache
5011  * \param[out] stall number of GP clocks that the vertex cache was stalled
5012  *
5013  * \return none
5014  */
5015 void GX_ReadVCacheMetric(u32 *check,u32 *miss,u32 *stall);
5016 
5017 /*!
5018  * \fn void GX_SetVCacheMetric(u32 attr)
5019  * \brief Sets the metric the Vertex Cache performance counter will measure.
5020  *
5021  * \details It is possible to monitor a particular attribute or all attributes using \a attr.
5022  *
5023  * \note To clear the counter, call GX_ClearVCacheMetric(); to read the counter value, call GX_ReadVCacheMetric().
5024  *
5025  * \param[in] attr \ref vcachemetrics to measure
5026  *
5027  * \return none
5028  */
5029 void GX_SetVCacheMetric(u32 attr);
5030 
5031 /*!
5032  * \fn void GX_GetGPStatus(u8 *overhi,u8 *underlow,u8 *readIdle,u8 *cmdIdle,u8 *brkpt)
5033  * \brief Reads the current status of the GP.
5034  *
5035  * \details \a overhi and \a underlow will indicate whether or not the watermarks have been reached. If the CPU and GP FIFOs
5036  * are the same, then \a overhi will indicate whether or not the current GX thread is suspended. The value of \a brkpt can be
5037  * used to determine if a breakpoint is in progress (i.e. GP reads are suspended; they are resumed by a call to
5038  * GX_DisableBreakPt()). A callback can also be used to notify your application that the break point has been reached. (see
5039  * GX_SetBreakPtCallback())
5040  *
5041  * \param[out] overhi <tt>GX_TRUE</tt> if high watermark has been passed
5042  * \param[out] underlow <tt>GX_TRUE</tt> if low watermark has been passed
5043  * \param[out] readIdle <tt>GX_TRUE</tt> if the GP read unit is idle
5044  * \param[out] cmdIdle <tt>GX_TRUE</tt> if all commands have been flushed to XF
5045  * \param[out] brkpt <tt>GX_TRUE</tt> if FIFO has reached a breakpoint and GP reads have been stopped
5046  *
5047  * \return none
5048  */
5049 void GX_GetGPStatus(u8 *overhi,u8 *underlow,u8 *readIdle,u8 *cmdIdle,u8 *brkpt);
5050 
5051 /*!
5052  * \fn void GX_ReadGPMetric(u32 *cnt0,u32 *cnt1)
5053  * \brief Returns the count of the previously set performance metrics.
5054  *
5055  * \note The performance metrics can be set using GX_SetGPMetric(); the counters can be cleared using GX_ClearGPMetric().<br><br>
5056  *
5057  * \note GX_ReadGPMetric() and GX_ClearGPMetric() can be used in the callback associated with the draw sync interrupt (see GX_SetDrawSyncCallback()).
5058  * The function GX_SetGPMetric() should <b>not</b> be used in the draw sync callback because it will insert tokens in the GP command stream at random times.<br><br>
5059  *
5060  * \warning This function reads results from CPU-accessible registers in the GP, therefore, this command <i>must not</i> be used in a display list. It
5061  * may also be necessary to send a draw sync token using GX_SetDrawSync() or GX_SetDrawDone() before GX_ReadGPMetric() is called to ensure that the
5062  * state has actually been processed by the GP.
5063  *
5064  * \param[out] cnt0 current value of GP counter 0
5065  * \param[out] cnt1 current value of GP counter 1
5066  *
5067  * \return none
5068  */
5069 void GX_ReadGPMetric(u32 *cnt0,u32 *cnt1);
5070 
5071 /*!
5072  * \fn void GX_ReadBoundingBox(u16 *top,u16 *bottom,u16 *left,u16 *right)
5073  * \brief Returns the bounding box of pixel coordinates that are drawn in the Embedded Framebuffer (EFB).
5074  *
5075  * \details This function reads the bounding box values. GX_ClearBoundingBox() can be used reset the values of the bounding box.
5076  *
5077  * \note Since the hardware can only test the bounding box in quads (2x2 pixel blocks), the result of this function may contain error
5078  * of plus or minus 1 pixel. Also because of this, <b>left</b> and <b>top</b> are always even-numbered and <b>right</b> and <b>bottom</b>
5079  * are always odd-numbered.
5080  *
5081  * \param[out] top uppermost line in the bounding box
5082  * \param[out] bottom lowest line in the bounding box
5083  * \param[out] left leftmost pixel in the bounding box
5084  * \param[out] right rightmost pixel in the bounding box
5085  *
5086  * \return none
5087  */
5088 void GX_ReadBoundingBox(u16 *top,u16 *bottom,u16 *left,u16 *right);
5089 
5090 /*!
5091  * \fn volatile void* GX_RedirectWriteGatherPipe(void *ptr)
5092  * \brief Temporarily points the CPU's write-gather pipe at a new location.
5093  *
5094  * \details After calling this function, subsequent writes to the address returned by this function (or the WGPipe union)
5095  * will be gathered and sent to a destination buffer. The write pointer is automatically incremented by the GP.  The write
5096  * gather pipe can be restored by calling GX_RestoreWriteGatherPipe(). This function cannot be called between a
5097  * GX_Begin()/GX_End() pair.
5098  *
5099  * \note The destination buffer, referred to by \a ptr, must be 32 byte aligned. The amount of data written should
5100  * also be 32-byte aligned. If it is not, zeroes will be added to pad the destination buffer to 32 bytes. No part of the
5101  * destination buffer should be modified inside the CPU caches - this may introduce cache incoherency problems.<br><br>
5102  *
5103  * \note The write gather pipe is one of the fastest ways to move data out of the CPU (the other being the locked cache DMA).
5104  * In general, you are compute-bound when sending data from the CPU.<br><br>
5105  *
5106  * \note This function is cheaper than trying to create a fake CPU fifo around a destination buffer, which requires calls to
5107  * GX_SetCPUFifo(), GX_InitFifoBase(), etc. This function performs very light weight state saves by assuming that the CPU and
5108  * GP FIFOs never change.
5109  *
5110  * \warning <b>No GX commands can be called until the write gather pipe is restored. You MUST call
5111  * GX_RestoreWriteGatherPipe() before calling this function again, or else the final call to restore the pipe will fail.</b>
5112  *
5113  * \param[in] ptr to destination buffer, 32-byte aligned
5114  *
5115  * \return real address of the write-gather "port". All writes to this address will be gathered by the CPU write gather pipe.
5116  * You may also use the WGPipe union. If you do not use the WGPipe union, ensure that your local variable is volatile.
5117  */
5118 volatile void* GX_RedirectWriteGatherPipe(void *ptr);
5119 
5120 /*!
5121  * \def GX_InitLightPosv(lo,vec)
5122  * \brief Sets the position of the light in the light object using a vector structure.
5123  *
5124  * \note The GameCube graphics hardware supports local diffuse lights. The position of the light should be in the same space as a
5125  * transformed vertex position (i.e. view space).<br><br>
5126  *
5127  * \note The memory for the light object must be allocated by the application; this function does not load any hardware registers directly. To
5128  * load a light object into a hardware light, use GX_LoadLightObj() or GX_LoadLightObjIdx().
5129  *
5130  * \param[in] lo ptr to the light object
5131  * \param[in] vec struct or array of three values for the position
5132  *
5133  * \return none
5134  */
5135 #define GX_InitLightPosv(lo,vec) \
5136     (GX_InitLightPos((lo), *(f32*)(vec), *((f32*)(vec)+1), *((f32*)(vec)+2)))
5137 
5138 /*!
5139  * \def GX_InitLightDirv(lo,vec)
5140  * \brief Sets the direction of a light in the light object using a vector structure.
5141  *
5142  * \details This direction is used when the light object is used as a spotlight or a specular light, see the \a attn_fn parameter of
5143  * GX_SetChanCtrl().
5144  *
5145  * \note The memory for the light object must be allocated by the application; this function does not load any hardware registers. To load a
5146  * light object into a hardware light, use GX_LoadLightObj() or GX_LoadLightObjIdx().<br><br>
5147  *
5148  * \note The coordinate space of the light normal should be consistent with a vertex normal transformed by a normal matrix; i.e., it should be
5149  * transformed to view space.<br><br>
5150  *
5151  * \note This function does not set the direction of parallel lights.
5152  *
5153  * \param[in] lo ptr to the light object
5154  * \param[in] vec struct or array of three values for the direction
5155  *
5156  * \return none
5157  */
5158 #define GX_InitLightDirv(lo,vec) \
5159     (GX_InitLightDir((lo), *(f32*)(vec), *((f32*)(vec)+1), *((f32*)(vec)+2)))
5160 
5161 /*!
5162  * \def GX_InitSpecularDirv(lo,vec)
5163  * \brief Sets the direction of a specular light in the light object using a vector.
5164  *
5165  * \details This direction is used when the light object is used only as specular light.
5166  *
5167  * \note The memory for the light object must be allocated by the application; this function does not load any hardware registers. To load a
5168  * light object into a hardware light, use GX_LoadLightObj() or GX_LoadLightObjIdx().<br><br>
5169  *
5170  * \note The coordinate space of the light normal should be consistent with a vertex normal transformed by a normal matrix; i.e., it should
5171  * be transformed to view space.
5172  *
5173  * \warning This function should be used if and only if the light object is used as specular light. One specifies a specular light in
5174  * GX_SetChanCtrl() by setting \a attn_fn to <tt>GX_AF_SPEC</tt>. Furthermore, one must not use GX_InitLightDir() or GX_InitLightPos() to
5175  * set up a light object which will be used as a specular light since these functions will destroy the information set by GX_InitSpecularDir().
5176  * In contrast to diffuse lights (including spotlights) that are considered <i>local</i> lights, a specular light is a <i>parallel</i> light (i.e. the
5177  * specular light is infinitely far away such that all the rays of the light are parallel), and thus one can only specify directional
5178  * information.
5179  *
5180  * \param[in] lo ptr to the light object
5181  * \param[in] vec struct or array of three values for the direction
5182  *
5183  * \return none
5184  */
5185 #define GX_InitSpecularDirv(lo,vec) \
5186     (GX_InitSpecularDir((lo), *(f32*)(vec), *((f32*)(vec)+1), *((f32*)(vec)+2)))
5187 
5188 /*!
5189  * \def GX_InitSpecularDirHAv(lo,vec0,vec1)
5190  * \brief Sets the direction and half-angle vector of a specular light in the light object using a vector.
5191  *
5192  * \details These vectors are used when the light object is used only as specular light.
5193  *
5194  * \note The memory for the light object must be allocated by the application; this function does not load any hardware registers. To load a
5195  * light object into a hardware light, use GX_LoadLightObj() or GX_LoadLightObjIdx().<br><br>
5196  *
5197  * \note In contrast to GX_InitSpecularDirv(), which caclulates half-angle vector automatically by assuming the view vector as (0,0,1), this
5198  * function allows users to specify half-angle vector directly as input arguments. It is useful to do detailed control for orientation of
5199  * highlights.<br><br>
5200  *
5201  * \note Other notes are similar to that described in GX_InitSpecularDirv().
5202  *
5203  * \param[in] lo ptr to the light object
5204  * \param[in] vec0 struct or array of three values for the direction
5205  * \param[in] vec1 struct or array of three values for the half-angle
5206  *
5207  * \return none
5208  */
5209 #define GX_InitSpecularDirHAv(lo,vec0,vec1) \
5210     (GX_InitSpecularDirHA((lo), \
5211     *(f32*)(vec0), *((f32*)(vec0)+1), *((f32*)(vec0)+2), \
5212     *(f32*)(vec1), *((f32*)(vec1)+1), *((f32*)(vec1)+2)))
5213 
5214 /*!
5215  * \def GX_InitLightShininess(lobj, shininess)
5216  * \brief Sets \a shininess of a per-vertex specular light.
5217  *
5218  * \details In reality, shininess is a property of the <i>material</i> being lit, not the light. However, in the Graphics Processor, the specular
5219  * calculation is implemented by reusing the diffuse angle/distance attenuation function, so shininess is determined by the light attenuation
5220  * parameters (see GX_InitLightAttn()). Note that the equation is attempting to approximate the function (N*H)^shininess. Since the attenuation
5221  * equation is only a ratio of quadratics, a true exponential function is not possible. To enable the specular calculation, you must set the
5222  * attenuation parameter of the lighting channel to <tt>GX_AF_SPEC</tt> using GX_SetChanCtrl().
5223  *
5224  * \param[in] lobj ptr to the light object
5225  * \param[in] shininess shininess parameter
5226  *
5227  * \return none
5228  */
5229 #define GX_InitLightShininess(lobj, shininess) \
5230     (GX_InitLightAttn(lobj, 0.0F, 0.0F, 1.0F,  \
5231                     (shininess)/2.0F, 0.0F,   \
5232                     1.0F-(shininess)/2.0F ))
5233 
5234 #ifdef __cplusplus
5235    }
5236 #endif /* __cplusplus */
5237 
5238 #endif
5239