Reverted GX FIFO breakage.
[libogc.git] / gc / ogc / gx.h
bloba56ded0b4da6412517612a8ab0f0def1d41fd888
1 #ifndef __GX_H__
2 #define __GX_H__
4 /*!
5 * \file gx.h
6 * \brief GX subsystem
8 */
10 #include <gctypes.h>
11 #include "lwp.h"
12 #include "gx_struct.h"
13 #include "gu.h"
15 #define GX_FALSE 0
16 #define GX_TRUE 1
17 #define GX_DISABLE 0
18 #define GX_ENABLE 1
19 #define GX_CLIP_DISABLE 0
20 #define GX_CLIP_ENABLE 1
22 #define GX_FIFO_MINSIZE (64*1024)
23 #define GX_FIFO_HIWATERMARK (16*1024)
24 #define GX_FIFO_OBJSIZE 128
26 #define GX_PERSPECTIVE 0
27 #define GX_ORTHOGRAPHIC 1
29 #define GX_MT_NULL 0
30 #define GX_MT_XF_FLUSH 1
31 #define GX_MT_DL_SAVE_CTX 2
33 #define GX_XF_FLUSH_NONE 0
34 #define GX_XF_FLUSH_SAFE 1
36 /* chan id */
37 #define GX_COLOR0 0
38 #define GX_COLOR1 1
39 #define GX_ALPHA0 2
40 #define GX_ALPHA1 3
41 #define GX_COLOR0A0 4
42 #define GX_COLOR1A1 5
43 #define GX_COLORZERO 6
44 #define GX_BUMP 7
45 #define GX_BUMPN 8
46 #define GX_COLORNULL 0xff
48 /* Matrix Type */
49 #define GX_MTX2x4 0
50 #define GX_MTX3x4 1
52 /*! \addtogroup vtxfmt Vertex format index
53 * @{
55 #define GX_VTXFMT0 0
56 #define GX_VTXFMT1 1
57 #define GX_VTXFMT2 2
58 #define GX_VTXFMT3 3
59 #define GX_VTXFMT4 4
60 #define GX_VTXFMT5 5
61 #define GX_VTXFMT6 6
62 #define GX_VTXFMT7 7
63 #define GX_MAXVTXFMT 8
65 /*! @} */
68 /*! \addtogroup vtxattrin Vertex data input type
69 * @{
71 #define GX_NONE 0 /*!< Input data is not used */
72 #define GX_DIRECT 1 /*!< Input data is set direct */
73 #define GX_INDEX8 2 /*!< Input data is set by a 8bit index */
74 #define GX_INDEX16 3 /*!< Input data is set by a 16bit index */
76 /*! @} */
79 /* CompType */
80 #define GX_U8 0
81 #define GX_S8 1
82 #define GX_U16 2
83 #define GX_S16 3
84 #define GX_F32 4
85 #define GX_RGB565 0
86 #define GX_RGB8 1
87 #define GX_RGBX8 2
88 #define GX_RGBA4 3
89 #define GX_RGBA6 4
90 #define GX_RGBA8 5
92 /* CompCount */
93 #define GX_POS_XY 0
94 #define GX_POS_XYZ 1
95 #define GX_NRM_XYZ 0
96 #define GX_NRM_NBT 1
97 #define GX_NRM_NBT3 2
98 #define GX_CLR_RGB 0
99 #define GX_CLR_RGBA 1
100 #define GX_TEX_S 0
101 #define GX_TEX_ST 1
103 /* Attribute */
104 #define GX_VA_PTNMTXIDX 0
105 #define GX_VA_TEX0MTXIDX 1
106 #define GX_VA_TEX1MTXIDX 2
107 #define GX_VA_TEX2MTXIDX 3
108 #define GX_VA_TEX3MTXIDX 4
109 #define GX_VA_TEX4MTXIDX 5
110 #define GX_VA_TEX5MTXIDX 6
111 #define GX_VA_TEX6MTXIDX 7
112 #define GX_VA_TEX7MTXIDX 8
113 #define GX_VA_POS 9
114 #define GX_VA_NRM 10
115 #define GX_VA_CLR0 11
116 #define GX_VA_CLR1 12
117 #define GX_VA_TEX0 13
118 #define GX_VA_TEX1 14
119 #define GX_VA_TEX2 15
120 #define GX_VA_TEX3 16
121 #define GX_VA_TEX4 17
122 #define GX_VA_TEX5 18
123 #define GX_VA_TEX6 19
124 #define GX_VA_TEX7 20
125 #define GX_POSMTXARRAY 21
126 #define GX_NRMMTXARRAY 22
127 #define GX_TEXMTXARRAY 23
128 #define GX_LITMTXARRAY 24
129 #define GX_VA_NBT 25
130 #define GX_VA_MAXATTR 26
131 #define GX_VA_NULL 0xff
133 #define GX_POINTS 0xB8
134 #define GX_LINES 0xA8
135 #define GX_LINESTRIP 0xB0
136 #define GX_TRIANGLES 0x90
137 #define GX_TRIANGLESTRIP 0x98
138 #define GX_TRIANGLEFAN 0xA0
139 #define GX_QUADS 0x80
141 #define GX_SRC_REG 0
142 #define GX_SRC_VTX 1
144 #define GX_LIGHT0 0x001
145 #define GX_LIGHT1 0x002
146 #define GX_LIGHT2 0x004
147 #define GX_LIGHT3 0x008
148 #define GX_LIGHT4 0x010
149 #define GX_LIGHT5 0x020
150 #define GX_LIGHT6 0x040
151 #define GX_LIGHT7 0x080
152 #define GX_MAXLIGHT 0x100
153 #define GX_LIGHTNULL 0x000
155 #define GX_DF_NONE 0
156 #define GX_DF_SIGNED 1
157 #define GX_DF_CLAMP 2
159 #define GX_AF_SPEC 0
160 #define GX_AF_SPOT 1
161 #define GX_AF_NONE 2
163 /* pos,nrm,tex,dtt matrix */
164 #define GX_PNMTX0 0
165 #define GX_PNMTX1 3
166 #define GX_PNMTX2 6
167 #define GX_PNMTX3 9
168 #define GX_PNMTX4 12
169 #define GX_PNMTX5 15
170 #define GX_PNMTX6 18
171 #define GX_PNMTX7 21
172 #define GX_PNMTX8 24
173 #define GX_PNMTX9 27
174 #define GX_TEXMTX0 30
175 #define GX_TEXMTX1 33
176 #define GX_TEXMTX2 36
177 #define GX_TEXMTX3 39
178 #define GX_TEXMTX4 42
179 #define GX_TEXMTX5 45
180 #define GX_TEXMTX6 48
181 #define GX_TEXMTX7 51
182 #define GX_TEXMTX8 54
183 #define GX_TEXMTX9 57
184 #define GX_IDENTITY 60
185 #define GX_DTTMTX0 64
186 #define GX_DTTMTX1 67
187 #define GX_DTTMTX2 70
188 #define GX_DTTMTX3 73
189 #define GX_DTTMTX4 76
190 #define GX_DTTMTX5 79
191 #define GX_DTTMTX6 82
192 #define GX_DTTMTX7 85
193 #define GX_DTTMTX8 88
194 #define GX_DTTMTX9 91
195 #define GX_DTTMTX10 94
196 #define GX_DTTMTX11 97
197 #define GX_DTTMTX12 100
198 #define GX_DTTMTX13 103
199 #define GX_DTTMTX14 106
200 #define GX_DTTMTX15 109
201 #define GX_DTTMTX16 112
202 #define GX_DTTMTX17 115
203 #define GX_DTTMTX18 118
204 #define GX_DTTMTX19 121
205 #define GX_DTTIDENTITY 125
207 /* tex coord id
208 used by: XF: 0x1040,0x1050
209 BP: 0x30
211 #define GX_TEXCOORD0 0x0
212 #define GX_TEXCOORD1 0x1
213 #define GX_TEXCOORD2 0x2
214 #define GX_TEXCOORD3 0x3
215 #define GX_TEXCOORD4 0x4
216 #define GX_TEXCOORD5 0x5
217 #define GX_TEXCOORD6 0x6
218 #define GX_TEXCOORD7 0x7
219 #define GX_MAXCOORD 0x8
220 #define GX_TEXCOORDNULL 0xff
222 /* tex format */
223 #define _GX_TF_ZTF 0x10
224 #define _GX_TF_CTF 0x20
226 /*! \addtogroup texfmt Texture format
227 * @{
230 #define GX_TF_I4 0x0
231 #define GX_TF_I8 0x1
232 #define GX_TF_IA4 0x2
233 #define GX_TF_IA8 0x3
234 #define GX_TF_RGB565 0x4
235 #define GX_TF_RGB5A3 0x5
236 #define GX_TF_RGBA8 0x6
237 #define GX_TF_CI4 0x8
238 #define GX_TF_CI8 0x9
239 #define GX_TF_CI14 0xa
240 #define GX_TF_CMPR 0xE
242 #define GX_TL_IA8 0x00
243 #define GX_TL_RGB565 0x01
244 #define GX_TL_RGB5A3 0x02
246 #define GX_CTF_R4 (0x0|_GX_TF_CTF)
247 #define GX_CTF_RA4 (0x2|_GX_TF_CTF)
248 #define GX_CTF_RA8 (0x3|_GX_TF_CTF)
249 #define GX_CTF_YUVA8 (0x6|_GX_TF_CTF)
250 #define GX_CTF_A8 (0x7|_GX_TF_CTF)
251 #define GX_CTF_R8 (0x8|_GX_TF_CTF)
252 #define GX_CTF_G8 (0x9|_GX_TF_CTF)
253 #define GX_CTF_B8 (0xA|_GX_TF_CTF)
254 #define GX_CTF_RG8 (0xB|_GX_TF_CTF)
255 #define GX_CTF_GB8 (0xC|_GX_TF_CTF)
257 /*! \addtogroup ztexfmt Z Texture format
258 * @{
261 #define GX_TF_Z8 (0x1|_GX_TF_ZTF)
262 #define GX_TF_Z16 (0x3|_GX_TF_ZTF)
263 #define GX_TF_Z24X8 (0x6|_GX_TF_ZTF)
265 /*! @} */
267 /*! @} */
269 #define GX_CTF_Z4 (0x0|_GX_TF_ZTF|_GX_TF_CTF)
270 #define GX_CTF_Z8M (0x9|_GX_TF_ZTF|_GX_TF_CTF)
271 #define GX_CTF_Z8L (0xA|_GX_TF_ZTF|_GX_TF_CTF)
272 #define GX_CTF_Z16L (0xC|_GX_TF_ZTF|_GX_TF_CTF)
274 #define GX_TF_A8 GX_CTF_A8
276 /* gx tlut size */
277 #define GX_TLUT_16 1 // number of 16 entry blocks.
278 #define GX_TLUT_32 2
279 #define GX_TLUT_64 4
280 #define GX_TLUT_128 8
281 #define GX_TLUT_256 16
282 #define GX_TLUT_512 32
283 #define GX_TLUT_1K 64
284 #define GX_TLUT_2K 128
285 #define GX_TLUT_4K 256
286 #define GX_TLUT_8K 512
287 #define GX_TLUT_16K 1024
289 /*! \addtogroup ztexop Z Texture operator
290 * @{
293 #define GX_ZT_DISABLE 0
294 #define GX_ZT_ADD 1
295 #define GX_ZT_REPLACE 2
296 #define GX_MAX_ZTEXOP 3
298 /*! @} */
301 /* TexGenType */
302 #define GX_TG_MTX3x4 0
303 #define GX_TG_MTX2x4 1
304 #define GX_TG_BUMP0 2
305 #define GX_TG_BUMP1 3
306 #define GX_TG_BUMP2 4
307 #define GX_TG_BUMP3 5
308 #define GX_TG_BUMP4 6
309 #define GX_TG_BUMP5 7
310 #define GX_TG_BUMP6 8
311 #define GX_TG_BUMP7 9
312 #define GX_TG_SRTG 10
314 /* TexGenSrc */
315 #define GX_TG_POS 0
316 #define GX_TG_NRM 1
317 #define GX_TG_BINRM 2
318 #define GX_TG_TANGENT 3
319 #define GX_TG_TEX0 4
320 #define GX_TG_TEX1 5
321 #define GX_TG_TEX2 6
322 #define GX_TG_TEX3 7
323 #define GX_TG_TEX4 8
324 #define GX_TG_TEX5 9
325 #define GX_TG_TEX6 10
326 #define GX_TG_TEX7 11
327 #define GX_TG_TEXCOORD0 12
328 #define GX_TG_TEXCOORD1 13
329 #define GX_TG_TEXCOORD2 14
330 #define GX_TG_TEXCOORD3 15
331 #define GX_TG_TEXCOORD4 16
332 #define GX_TG_TEXCOORD5 17
333 #define GX_TG_TEXCOORD6 18
334 #define GX_TG_COLOR0 19
335 #define GX_TG_COLOR1 20
337 /* Compare */
338 #define GX_NEVER 0
339 #define GX_LESS 1
340 #define GX_EQUAL 2
341 #define GX_LEQUAL 3
342 #define GX_GREATER 4
343 #define GX_NEQUAL 5
344 #define GX_GEQUAL 6
345 #define GX_ALWAYS 7
347 /* Text Wrap Mode */
348 #define GX_CLAMP 0
349 #define GX_REPEAT 1
350 #define GX_MIRROR 2
351 #define GX_MAXTEXWRAPMODE 3
353 /* Blend mode */
354 #define GX_BM_NONE 0
355 #define GX_BM_BLEND 1
356 #define GX_BM_LOGIC 2
357 #define GX_BM_SUBSTRACT 3
358 #define GX_MAX_BLENDMODE 4
360 /* blend factor */
361 #define GX_BL_ZERO 0
362 #define GX_BL_ONE 1
363 #define GX_BL_SRCCLR 2
364 #define GX_BL_INVSRCCLR 3
365 #define GX_BL_SRCALPHA 4
366 #define GX_BL_INVSRCALPHA 5
367 #define GX_BL_DSTALPHA 6
368 #define GX_BL_INVDSTALPHA 7
369 #define GX_BL_DSTCLR GX_BL_SRCCLR
370 #define GX_BL_INVDSTCLR GX_BL_INVSRCCLR
372 /* logic op */
373 #define GX_LO_CLEAR 0
374 #define GX_LO_AND 1
375 #define GX_LO_REVAND 2
376 #define GX_LO_COPY 3
377 #define GX_LO_INVAND 4
378 #define GX_LO_NOOP 5
379 #define GX_LO_XOR 6
380 #define GX_LO_OR 7
381 #define GX_LO_NOR 8
382 #define GX_LO_EQUIV 9
383 #define GX_LO_INV 10
384 #define GX_LO_REVOR 11
385 #define GX_LO_INVCOPY 12
386 #define GX_LO_INVOR 13
387 #define GX_LO_NAND 14
388 #define GX_LO_SET 15
390 /* point/line fmt */
391 #define GX_TO_ZERO 0
392 #define GX_TO_SIXTEENTH 1
393 #define GX_TO_EIGHTH 2
394 #define GX_TO_FOURTH 3
395 #define GX_TO_HALF 4
396 #define GX_TO_ONE 5
397 #define GX_MAX_TEXOFFSET 6
399 /*! \addtogroup tevdefmode TEV combiner operation
400 * Color/Alpha combiner modes for GX_SetTevOp().
402 * @{
405 #define GX_MODULATE 0
406 #define GX_DECAL 1
407 #define GX_BLEND 2
408 #define GX_REPLACE 3
409 #define GX_PASSCLR 4
411 /*! @} */
414 /*! \addtogroup tevcolorarg TEV color combiner input
415 * @{
418 #define GX_CC_CPREV 0 /*!< Use the color value from previous TEV stage */
419 #define GX_CC_APREV 1 /*!< Use the alpha value from previous TEV stage */
420 #define GX_CC_C0 2 /*!< Use the color value from the color/output register 0 */
421 #define GX_CC_A0 3 /*!< Use the alpha value from the color/output register 0 */
422 #define GX_CC_C1 4 /*!< Use the color value from the color/output register 1 */
423 #define GX_CC_A1 5 /*!< Use the alpha value from the color/output register 1 */
424 #define GX_CC_C2 6 /*!< Use the color value from the color/output register 2 */
425 #define GX_CC_A2 7 /*!< Use the alpha value from the color/output register 2 */
426 #define GX_CC_TEXC 8 /*!< Use the color value from texture */
427 #define GX_CC_TEXA 9 /*!< Use the alpha value from texture */
428 #define GX_CC_RASC 10 /*!< Use the color value from rasterizer */
429 #define GX_CC_RASA 11 /*!< Use the alpha value from rasterizer */
430 #define GX_CC_ONE 12
431 #define GX_CC_HALF 13
432 #define GX_CC_KONST 14
433 #define GX_CC_ZERO 15 /*!< Use to pass zero value */
435 /*! @} */
438 /*! \addtogroup tevalphaarg TEV alpha combiner input
439 * @{
442 #define GX_CA_APREV 0 /*!< Use the alpha value from previous TEV stage */
443 #define GX_CA_A0 1 /*!< Use the alpha value from the color/output register 0 */
444 #define GX_CA_A1 2 /*!< Use the alpha value from the color/output register 1 */
445 #define GX_CA_A2 3 /*!< Use the alpha value from the color/output register 2 */
446 #define GX_CA_TEXA 4 /*!< Use the alpha value from texture */
447 #define GX_CA_RASA 5 /*!< Use the alpha value from rasterizer */
448 #define GX_CA_KONST 6
449 #define GX_CA_ZERO 7 /*!< Use to pass zero value */
451 /*! @} */
454 /*! \addtogroup tevstage TEV stage
455 * @{
458 #define GX_TEVSTAGE0 0
459 #define GX_TEVSTAGE1 1
460 #define GX_TEVSTAGE2 2
461 #define GX_TEVSTAGE3 3
462 #define GX_TEVSTAGE4 4
463 #define GX_TEVSTAGE5 5
464 #define GX_TEVSTAGE6 6
465 #define GX_TEVSTAGE7 7
466 #define GX_TEVSTAGE8 8
467 #define GX_TEVSTAGE9 9
468 #define GX_TEVSTAGE10 10
469 #define GX_TEVSTAGE11 11
470 #define GX_TEVSTAGE12 12
471 #define GX_TEVSTAGE13 13
472 #define GX_TEVSTAGE14 14
473 #define GX_TEVSTAGE15 15
474 #define GX_MAX_TEVSTAGE 16
476 /*! @} */
479 /*! \addtogroup tevop TEV combiner operator
480 * @{
483 #define GX_TEV_ADD 0
484 #define GX_TEV_SUB 1
485 #define GX_TEV_COMP_R8_GT 8
486 #define GX_TEV_COMP_R8_EQ 9
487 #define GX_TEV_COMP_GR16_GT 10
488 #define GX_TEV_COMP_GR16_EQ 11
489 #define GX_TEV_COMP_BGR24_GT 12
490 #define GX_TEV_COMP_BGR24_EQ 13
491 #define GX_TEV_COMP_RGB8_GT 14
492 #define GX_TEV_COMP_RGB8_EQ 15
493 #define GX_TEV_COMP_A8_GT GX_TEV_COMP_RGB8_GT // for alpha channel
494 #define GX_TEV_COMP_A8_EQ GX_TEV_COMP_RGB8_EQ // for alpha channel
496 /*! @} */
499 /*! \addtogroup tevbias TEV bias value
500 * @{
503 #define GX_TB_ZERO 0
504 #define GX_TB_ADDHALF 1
505 #define GX_TB_SUBHALF 2
506 #define GX_MAX_TEVBIAS 3
508 /*! @} */
511 /*! \addtogroup tevbias TEV clamp mode value
512 * @{
515 #define GX_TC_LINEAR 0
516 #define GX_TC_GE 1
517 #define GX_TC_EQ 2
518 #define GX_TC_LE 3
519 #define GX_MAX_TEVCLAMPMODE 4
521 /*! @} */
524 /*! \addtogroup tevscale TEV scale value
525 * @{
528 #define GX_CS_SCALE_1 0
529 #define GX_CS_SCALE_2 1
530 #define GX_CS_SCALE_4 2
531 #define GX_CS_DIVIDE_2 3
532 #define GX_MAX_TEVSCALE 4
534 /*! @} */
537 /*! \addtogroup tevcoloutreg TEV color/output register
538 * @{
541 #define GX_TEVPREV 0
542 #define GX_TEVREG0 1
543 #define GX_TEVREG1 2
544 #define GX_TEVREG2 3
545 #define GX_MAX_TEVREG 4
547 /*! @} */
550 /* cull mode */
551 #define GX_CULL_NONE 0
552 #define GX_CULL_FRONT 1
553 #define GX_CULL_BACK 2
554 #define GX_CULL_ALL 3
556 /* tex map */
557 #define GX_TEXMAP0 0
558 #define GX_TEXMAP1 1
559 #define GX_TEXMAP2 2
560 #define GX_TEXMAP3 3
561 #define GX_TEXMAP4 4
562 #define GX_TEXMAP5 5
563 #define GX_TEXMAP6 6
564 #define GX_TEXMAP7 7
565 #define GX_MAX_TEXMAP 8
566 #define GX_TEXMAP_NULL 0xff
567 #define GX_TEXMAP_DISABLE 0x100
569 /* alpha op */
570 #define GX_AOP_AND 0
571 #define GX_AOP_OR 1
572 #define GX_AOP_XOR 2
573 #define GX_AOP_XNOR 3
574 #define GX_MAX_ALPHAOP 4
576 /* tev const color reg id */
577 #define GX_KCOLOR0 0
578 #define GX_KCOLOR1 1
579 #define GX_KCOLOR2 2
580 #define GX_KCOLOR3 3
581 #define GX_KCOLOR_MAX 4
583 /* tev const color sel */
584 #define GX_TEV_KCSEL_1 0x00
585 #define GX_TEV_KCSEL_7_8 0x01
586 #define GX_TEV_KCSEL_3_4 0x02
587 #define GX_TEV_KCSEL_5_8 0x03
588 #define GX_TEV_KCSEL_1_2 0x04
589 #define GX_TEV_KCSEL_3_8 0x05
590 #define GX_TEV_KCSEL_1_4 0x06
591 #define GX_TEV_KCSEL_1_8 0x07
592 #define GX_TEV_KCSEL_K0 0x0C
593 #define GX_TEV_KCSEL_K1 0x0D
594 #define GX_TEV_KCSEL_K2 0x0E
595 #define GX_TEV_KCSEL_K3 0x0F
596 #define GX_TEV_KCSEL_K0_R 0x10
597 #define GX_TEV_KCSEL_K1_R 0x11
598 #define GX_TEV_KCSEL_K2_R 0x12
599 #define GX_TEV_KCSEL_K3_R 0x13
600 #define GX_TEV_KCSEL_K0_G 0x14
601 #define GX_TEV_KCSEL_K1_G 0x15
602 #define GX_TEV_KCSEL_K2_G 0x16
603 #define GX_TEV_KCSEL_K3_G 0x17
604 #define GX_TEV_KCSEL_K0_B 0x18
605 #define GX_TEV_KCSEL_K1_B 0x19
606 #define GX_TEV_KCSEL_K2_B 0x1A
607 #define GX_TEV_KCSEL_K3_B 0x1B
608 #define GX_TEV_KCSEL_K0_A 0x1C
609 #define GX_TEV_KCSEL_K1_A 0x1D
610 #define GX_TEV_KCSEL_K2_A 0x1E
611 #define GX_TEV_KCSEL_K3_A 0x1F
613 /* tev const alpha sel */
614 #define GX_TEV_KASEL_1 0x00
615 #define GX_TEV_KASEL_7_8 0x01
616 #define GX_TEV_KASEL_3_4 0x02
617 #define GX_TEV_KASEL_5_8 0x03
618 #define GX_TEV_KASEL_1_2 0x04
619 #define GX_TEV_KASEL_3_8 0x05
620 #define GX_TEV_KASEL_1_4 0x06
621 #define GX_TEV_KASEL_1_8 0x07
622 #define GX_TEV_KASEL_K0_R 0x10
623 #define GX_TEV_KASEL_K1_R 0x11
624 #define GX_TEV_KASEL_K2_R 0x12
625 #define GX_TEV_KASEL_K3_R 0x13
626 #define GX_TEV_KASEL_K0_G 0x14
627 #define GX_TEV_KASEL_K1_G 0x15
628 #define GX_TEV_KASEL_K2_G 0x16
629 #define GX_TEV_KASEL_K3_G 0x17
630 #define GX_TEV_KASEL_K0_B 0x18
631 #define GX_TEV_KASEL_K1_B 0x19
632 #define GX_TEV_KASEL_K2_B 0x1A
633 #define GX_TEV_KASEL_K3_B 0x1B
634 #define GX_TEV_KASEL_K0_A 0x1C
635 #define GX_TEV_KASEL_K1_A 0x1D
636 #define GX_TEV_KASEL_K2_A 0x1E
637 #define GX_TEV_KASEL_K3_A 0x1F
640 /*! \addtogroup tevswapsel TEV color swap table entry
641 * @{
644 #define GX_TEV_SWAP0 0
645 #define GX_TEV_SWAP1 1
646 #define GX_TEV_SWAP2 2
647 #define GX_TEV_SWAP3 3
648 #define GX_MAX_TEVSWAP 4
650 /*! @} */
653 /* tev color chan */
654 #define GX_CH_RED 0
655 #define GX_CH_GREEN 1
656 #define GX_CH_BLUE 2
657 #define GX_CH_ALPHA 3
659 /* ind tex stage id */
660 #define GX_INDTEXSTAGE0 0
661 #define GX_INDTEXSTAGE1 1
662 #define GX_INDTEXSTAGE2 2
663 #define GX_INDTEXSTAGE3 3
664 #define GX_MAX_INDTEXSTAGE 4
666 /* ind tex format */
667 #define GX_ITF_8 0
668 #define GX_ITF_5 1
669 #define GX_ITF_4 2
670 #define GX_ITF_3 3
671 #define GX_MAX_ITFORMAT 4
673 /* ind tex bias sel */
674 #define GX_ITB_NONE 0
675 #define GX_ITB_S 1
676 #define GX_ITB_T 2
677 #define GX_ITB_ST 3
678 #define GX_ITB_U 4
679 #define GX_ITB_SU 5
680 #define GX_ITB_TU 6
681 #define GX_ITB_STU 7
682 #define GX_MAX_ITBIAS 8
684 /* ind tex mtx idx */
685 #define GX_ITM_OFF 0
686 #define GX_ITM_0 1
687 #define GX_ITM_1 2
688 #define GX_ITM_2 3
689 #define GX_ITM_S0 5
690 #define GX_ITM_S1 6
691 #define GX_ITM_S2 7
692 #define GX_ITM_T0 9
693 #define GX_ITM_T1 10
694 #define GX_ITM_T2 11
696 /* ind tex warp */
697 #define GX_ITW_OFF 0
698 #define GX_ITW_256 1
699 #define GX_ITW_128 2
700 #define GX_ITW_64 3
701 #define GX_ITW_32 4
702 #define GX_ITW_16 5
703 #define GX_ITW_0 6
704 #define GX_MAX_ITWRAP 7
706 /* ind tex alpha sel */
707 #define GX_ITBA_OFF 0
708 #define GX_ITBA_S 1
709 #define GX_ITBA_T 2
710 #define GX_ITBA_U 3
711 #define GX_MAX_ITBALPHA 4
713 /* ind tex coord scale */
714 #define GX_ITS_1 0
715 #define GX_ITS_2 1
716 #define GX_ITS_4 2
717 #define GX_ITS_8 3
718 #define GX_ITS_16 4
719 #define GX_ITS_32 5
720 #define GX_ITS_64 6
721 #define GX_ITS_128 7
722 #define GX_ITS_256 8
723 #define GX_MAX_ITSCALE 9
725 /* fog type */
726 #define GX_FOG_NONE 0
728 #define GX_FOG_PERSP_LIN 2
729 #define GX_FOG_PERSP_EXP 4
730 #define GX_FOG_PERSP_EXP2 5
731 #define GX_FOG_PERSP_REVEXP 6
732 #define GX_FOG_PERSP_REVEXP2 7
734 #define GX_FOG_ORTHO_LIN 10
735 #define GX_FOG_ORTHO_EXP 12
736 #define GX_FOG_ORTHO_EXP2 13
737 #define GX_FOG_ORTHO_REVEXP 14
738 #define GX_FOG_ORTHO_REVEXP2 15
740 #define GX_FOG_LIN GX_FOG_PERSP_LIN
741 #define GX_FOG_EXP GX_FOG_PERSP_EXP
742 #define GX_FOG_EXP2 GX_FOG_PERSP_EXP2
743 #define GX_FOG_REVEXP GX_FOG_PERSP_REVEXP
744 #define GX_FOG_REVEXP2 GX_FOG_PERSP_REVEXP2
747 /* pixel format */
748 #define GX_PF_RGB8_Z24 0
749 #define GX_PF_RGBA6_Z24 1
750 #define GX_PF_RGB565_Z16 2
751 #define GX_PF_Z24 3
752 #define GX_PF_Y8 4
753 #define GX_PF_U8 5
754 #define GX_PF_V8 6
755 #define GX_PF_YUV420 7
757 /* z pixel format */
758 #define GX_ZC_LINEAR 0
759 #define GX_ZC_NEAR 1
760 #define GX_ZC_MID 2
761 #define GX_ZC_FAR 3
763 /*! \addtogroup xfbclamp XFB clamp modes
764 * @{
767 #define GX_CLAMP_NONE 0
768 #define GX_CLAMP_TOP 1
769 #define GX_CLAMP_BOTTOM 2
771 /*! @} */
774 /*! \addtogroup gammamode Gamma values
775 * @{
778 #define GX_GM_1_0 0
779 #define GX_GM_1_7 1
780 #define GX_GM_2_2 2
782 /*! @} */
785 /* copy mode */
786 #define GX_COPY_PROGRESSIVE 0
787 #define GX_COPY_INTLC_EVEN 2
788 #define GX_COPY_INTLC_ODD 3
790 /* alpha read mode */
791 #define GX_READ_00 0
792 #define GX_READ_FF 1
793 #define GX_READ_NONE 2
795 /* tex cache size */
796 #define GX_TEXCACHE_32K 0
797 #define GX_TEXCACHE_128K 1
798 #define GX_TEXCACHE_512K 2
799 #define GX_TEXCACHE_NONE 3
801 /* dist attn fn */
802 #define GX_DA_OFF 0
803 #define GX_DA_GENTLE 1
804 #define GX_DA_MEDIUM 2
805 #define GX_DA_STEEP 3
807 /* spot fn */
808 #define GX_SP_OFF 0
809 #define GX_SP_FLAT 1
810 #define GX_SP_COS 2
811 #define GX_SP_COS2 3
812 #define GX_SP_SHARP 4
813 #define GX_SP_RING1 5
814 #define GX_SP_RING2 6
816 /* tex filter */
817 #define GX_NEAR 0
818 #define GX_LINEAR 1
819 #define GX_NEAR_MIP_NEAR 2
820 #define GX_LIN_MIP_NEAR 3
821 #define GX_NEAR_MIP_LIN 4
822 #define GX_LIN_MIP_LIN 5
824 /* anisotropy */
825 #define GX_ANISO_1 0
826 #define GX_ANISO_2 1
827 #define GX_ANISO_4 2
828 #define GX_MAX_ANISOTROPY 3
830 /* vcache metric settings */
831 #define GX_VC_POS 0
832 #define GX_VC_NRM 1
833 #define GX_VC_CLR0 2
834 #define GX_VC_CLR1 3
835 #define GX_VC_TEX0 4
836 #define GX_VC_TEX1 5
837 #define GX_VC_TEX2 6
838 #define GX_VC_TEX3 7
839 #define GX_VC_TEX4 8
840 #define GX_VC_TEX5 9
841 #define GX_VC_TEX6 10
842 #define GX_VC_TEX7 11
843 #define GX_VC_ALL 15
845 /* perf0 counter sets */
846 #define GX_PERF0_VERTICES 0
847 #define GX_PERF0_CLIP_VTX 1
848 #define GX_PERF0_CLIP_CLKS 2
849 #define GX_PERF0_XF_WAIT_IN 3
850 #define GX_PERF0_XF_WAIT_OUT 4
851 #define GX_PERF0_XF_XFRM_CLKS 5
852 #define GX_PERF0_XF_LIT_CLKS 6
853 #define GX_PERF0_XF_BOT_CLKS 7
854 #define GX_PERF0_XF_REGLD_CLKS 8
855 #define GX_PERF0_XF_REGRD_CLKS 9
856 #define GX_PERF0_CLIP_RATIO 10
857 #define GX_PERF0_TRIANGLES 11
858 #define GX_PERF0_TRIANGLES_CULLED 12
859 #define GX_PERF0_TRIANGLES_PASSED 13
860 #define GX_PERF0_TRIANGLES_SCISSORED 14
861 #define GX_PERF0_TRIANGLES_0TEX 15
862 #define GX_PERF0_TRIANGLES_1TEX 16
863 #define GX_PERF0_TRIANGLES_2TEX 17
864 #define GX_PERF0_TRIANGLES_3TEX 18
865 #define GX_PERF0_TRIANGLES_4TEX 19
866 #define GX_PERF0_TRIANGLES_5TEX 20
867 #define GX_PERF0_TRIANGLES_6TEX 21
868 #define GX_PERF0_TRIANGLES_7TEX 22
869 #define GX_PERF0_TRIANGLES_8TEX 23
870 #define GX_PERF0_TRIANGLES_0CLR 24
871 #define GX_PERF0_TRIANGLES_1CLR 25
872 #define GX_PERF0_TRIANGLES_2CLR 26
873 #define GX_PERF0_QUAD_0CVG 27
874 #define GX_PERF0_QUAD_NON0CVG 28
875 #define GX_PERF0_QUAD_1CVG 29
876 #define GX_PERF0_QUAD_2CVG 30
877 #define GX_PERF0_QUAD_3CVG 31
878 #define GX_PERF0_QUAD_4CVG 32
879 #define GX_PERF0_AVG_QUAD_CNT 33
880 #define GX_PERF0_CLOCKS 34
881 #define GX_PERF0_NONE 35
883 /* perf1 counter sets */
884 #define GX_PERF1_TEXELS 0
885 #define GX_PERF1_TX_IDLE 1
886 #define GX_PERF1_TX_REGS 2
887 #define GX_PERF1_TX_MEMSTALL 3
888 #define GX_PERF1_TC_CHECK1_2 4
889 #define GX_PERF1_TC_CHECK3_4 5
890 #define GX_PERF1_TC_CHECK5_6 6
891 #define GX_PERF1_TC_CHECK7_8 7
892 #define GX_PERF1_TC_MISS 8
893 #define GX_PERF1_VC_ELEMQ_FULL 9
894 #define GX_PERF1_VC_MISSQ_FULL 10
895 #define GX_PERF1_VC_MEMREQ_FULL 11
896 #define GX_PERF1_VC_STATUS7 12
897 #define GX_PERF1_VC_MISSREP_FULL 13
898 #define GX_PERF1_VC_STREAMBUF_LOW 14
899 #define GX_PERF1_VC_ALL_STALLS 15
900 #define GX_PERF1_VERTICES 16
901 #define GX_PERF1_FIFO_REQ 17
902 #define GX_PERF1_CALL_REQ 18
903 #define GX_PERF1_VC_MISS_REQ 19
904 #define GX_PERF1_CP_ALL_REQ 20
905 #define GX_PERF1_CLOCKS 21
906 #define GX_PERF1_NONE 22
908 /* tlut */
909 #define GX_TLUT0 0
910 #define GX_TLUT1 1
911 #define GX_TLUT2 2
912 #define GX_TLUT3 3
913 #define GX_TLUT4 4
914 #define GX_TLUT5 5
915 #define GX_TLUT6 6
916 #define GX_TLUT7 7
917 #define GX_TLUT8 8
918 #define GX_TLUT9 9
919 #define GX_TLUT10 10
920 #define GX_TLUT11 11
921 #define GX_TLUT12 12
922 #define GX_TLUT13 13
923 #define GX_TLUT14 14
924 #define GX_TLUT15 15
925 #define GX_BIGTLUT0 16
926 #define GX_BIGTLUT1 17
927 #define GX_BIGTLUT2 18
928 #define GX_BIGTLUT3 19
930 #define GX_MAX_VTXDESC GX_VA_MAXATTR
931 #define GX_MAX_VTXDESC_LISTSIZE (GX_VA_MAXATTR+1)
933 #define GX_MAX_VTXATTRFMT GX_VA_MAXATTR
934 #define GX_MAX_VTXATTRFMT_LISTSIZE (GX_VA_MAXATTR+1)
936 #define GX_MAX_Z24 0x00ffffff
938 #define WGPIPE (0xCC008000)
940 #define FIFO_PUTU8(x) *(vu8*)WGPIPE = (u8)(x)
941 #define FIFO_PUTS8(x) *(vs8*)WGPIPE = (s8)(x)
942 #define FIFO_PUTU16(x) *(vu16*)WGPIPE = (u16)(x)
943 #define FIFO_PUTS16(x) *(vs16*)WGPIPE = (s16)(x)
944 #define FIFO_PUTU32(x) *(vu32*)WGPIPE = (u32)(x)
945 #define FIFO_PUTS32(x) *(vs32*)WGPIPE = (s32)(x)
946 #define FIFO_PUTF32(x) *(vf32*)WGPIPE = (f32)(x)
948 #ifdef __cplusplus
949 extern "C" {
950 #endif /* __cplusplus */
952 typedef struct _gx_color {
953 u8 r;
954 u8 g;
955 u8 b;
956 u8 a;
957 } GXColor;
959 typedef struct _gx_colors10 {
960 s16 r;
961 s16 g;
962 s16 b;
963 s16 a;
964 } GXColorS10;
966 typedef struct _gx_texobj {
967 u32 val[8];
968 } GXTexObj;
970 typedef struct _gx_tlutobj {
971 u32 val[3];
972 } GXTlutObj;
974 typedef struct _gx_texreg {
975 u32 val[4];
976 } GXTexRegion;
978 typedef struct _gx_tlutreg {
979 u32 val[4];
980 } GXTlutRegion;
982 typedef struct _gx_litobj {
983 u32 val[16];
984 } GXLightObj;
986 typedef struct _vtx {
987 f32 x,y,z;
988 u16 s,t;
989 u32 rgba;
990 } Vtx;
992 typedef struct {
993 u8 attr;
994 u8 type;
995 } GXVtxDesc;
997 typedef struct {
998 u32 vtxattr;
999 u32 comptype;
1000 u32 compsize;
1001 u32 frac;
1002 } GXVtxAttrFmt;
1004 typedef struct {
1005 u8 pad[GX_FIFO_OBJSIZE];
1006 } GXFifoObj;
1008 typedef struct {
1009 u8 dummy[4];
1010 } GXTexReg;
1012 typedef struct {
1013 u16 r[10];
1014 } GXFogAdjTbl;
1016 typedef void (*GXBreakPtCallback)(void);
1017 typedef void (*GXDrawDoneCallback)(void);
1019 /*! \typedef void (*GXDrawSyncCallback)(u16 token)
1020 \brief function pointer typedef for the drawsync-token callback
1021 \param[out] token tokenvalue most recently encountered.
1023 typedef void (*GXDrawSyncCallback)(u16 token);
1025 /*! \typedef GXTexRegion* (*GXTexRegionCallback)(GXTexObj *obj,u8 mapid)
1026 \brief function pointer typedef for the texture region callback
1027 \param[out] token tokenvalue most recently encountered.
1029 typedef GXTexRegion* (*GXTexRegionCallback)(GXTexObj *obj,u8 mapid);
1031 /*! \typedef GXTlutRegion* (*GXTlutRegionCallback)(u32 tlut_name)
1032 \brief function pointer typedef for the TLUT region callback
1033 \param[out] token tokenvalue most recently encountered.
1035 typedef GXTlutRegion* (*GXTlutRegionCallback)(u32 tlut_name);
1037 /*!
1038 * \fn GXFifoObj* GX_Init(void *base,u32 size)
1039 * \brief Initializes the graphics processor to its initial state and should be called before any other GX functions.
1041 * \param[in] base pointer to the GX fifo buffer base address. Must be aligned on a 32 Byte boundery.
1042 * \param[in] size size of buffer. Must be a multiple of 32.
1044 * \return pointer to the intialized GXFifoObj object.
1046 GXFifoObj* GX_Init(void *base,u32 size);
1048 void GX_InitFifoBase(GXFifoObj *fifo,void *base,u32 size);
1049 void GX_InitFifoLimits(GXFifoObj *fifo,u32 hiwatermark,u32 lowatermark);
1050 void GX_InitFifoPtrs(GXFifoObj *fifo,void *rd_ptr,void *wt_ptr);
1051 void GX_SetCPUFifo(GXFifoObj *fifo);
1052 void GX_SetGPFifo(GXFifoObj *fifo);
1053 void GX_GetCPUFifo(GXFifoObj *fifo);
1054 void GX_GetGPFifo(GXFifoObj *fifo);
1055 GXDrawDoneCallback GX_SetDrawDoneCallback(GXDrawDoneCallback cb);
1056 GXBreakPtCallback GX_SetBreakPtCallback(GXBreakPtCallback cb);
1058 void GX_AbortFrame();
1059 void GX_Flush();
1060 void GX_SetMisc(u32 token,u32 value);
1061 void GX_SetDrawDone();
1062 void GX_WaitDrawDone();
1064 /*!
1065 * \fn u16 GX_GetDrawSync()
1066 * \brief Returns the value of the token register, which is written using the GX_SetDrawSync() function.
1068 * \return the value of the token register, u16.
1070 u16 GX_GetDrawSync();
1072 /*!
1073 * \fn void GX_SetDrawSync(u16 token)
1074 * \brief This function sends a token into the command stream.
1075 * When the token register is set, an interrupt will also be received by the CPU. You can install a callback on this interrupt
1076 * with GX_SetDrawSyncCallback(). Draw syncs can be used to notify the CPU that the graphics processor is finished using a shared
1077 * resource (a vertex array for instance).
1079 * \param[in] token 16-bit value to write to the token register.
1081 * \return none
1083 void GX_SetDrawSync(u16 token);
1085 /*!
1086 * \fn GXDrawSyncCallback GX_SetDrawSyncCallback(GXDrawSyncCallback cb)
1087 * \brief Installs a callback that is invoked whenever a DrawSync token is encountered by the graphics pipeline. The callbacks argument is
1088 * is the value of the token most recently encountered. Since it is possible to miss tokens(graphics processing does not stop while
1089 * the callback is running), your code should be capable of deducing if any tokens have been missed.
1091 * \param[in] cb callback to be invoked when the DrawSnyc tokens are encountered in the graphics pipeline.
1093 * \return pointer to the previously set callback function.
1095 GXDrawSyncCallback GX_SetDrawSyncCallback(GXDrawSyncCallback cb);
1097 void GX_DisableBreakPt();
1098 void GX_EnableBreakPt(void *break_pt);
1099 void GX_DrawDone();
1100 void GX_TexModeSync();
1101 void GX_InvVtxCache();
1102 void GX_ClearVtxDesc();
1103 void GX_LoadProjectionMtx(Mtx44 mt,u8 type);
1104 void GX_SetViewport(f32 xOrig,f32 yOrig,f32 wd,f32 ht,f32 nearZ,f32 farZ);
1105 void GX_SetViewportJitter(f32 xOrig,f32 yOrig,f32 wd,f32 ht,f32 nearZ,f32 farZ,u32 field);
1106 void GX_SetChanCtrl(s32 channel,u8 enable,u8 ambsrc,u8 matsrc,u8 litmask,u8 diff_fn,u8 attn_fn);
1107 void GX_SetChanAmbColor(s32 channel,GXColor color);
1108 void GX_SetChanMatColor(s32 channel,GXColor color);
1109 void GX_SetArray(u32 attr,void *ptr,u8 stride);
1111 /*!
1112 * \fn void GX_SetVtxAttrFmt(u8 vtxfmt,u32 vtxattr,u32 comptype,u32 compsize,u32 frac)
1113 * \brief Installs a callback that is invoked whenever a DrawSync token is encountered by the graphics pipeline. The callbacks argument is
1114 * is the value of the token most recently encountered. Since it is possible to miss tokens(graphics processing does not stop while
1115 * the callback is running), your code should be capable of deducing if any tokens have been missed.
1117 * \param[in] vtxfmt \ref vtxfmt
1118 * \param[in] vtxattr to be invoked when the DrawSnyc tokens are encountered in the graphics pipeline.
1119 * \param[in] comptype to be invoked when the DrawSnyc tokens are encountered in the graphics pipeline.
1120 * \param[in] compsize to be invoked when the DrawSnyc tokens are encountered in the graphics pipeline.
1121 * \param[in] frac to be invoked when the DrawSnyc tokens are encountered in the graphics pipeline.
1123 * \return none
1125 void GX_SetVtxAttrFmt(u8 vtxfmt,u32 vtxattr,u32 comptype,u32 compsize,u32 frac);
1126 void GX_SetVtxAttrFmtv(u8 vtxfmt,GXVtxAttrFmt *attr_list);
1127 void GX_SetVtxDesc(u8 attr,u8 type);
1128 void GX_SetVtxDescv(GXVtxDesc *attr_list);
1130 u32 GX_EndDispList();
1131 void GX_Begin(u8 primitve,u8 vtxfmt,u16 vtxcnt);
1132 void GX_BeginDispList(void *list,u32 size);
1133 void GX_CallDispList(void *list,u32 nbytes);
1135 static inline void GX_End()
1139 static inline void GX_Position3f32(f32 x,f32 y,f32 z)
1141 FIFO_PUTF32(x);
1142 FIFO_PUTF32(y);
1143 FIFO_PUTF32(z);
1146 static inline void GX_Position3u16(u16 x,u16 y,u16 z)
1148 FIFO_PUTU16(x);
1149 FIFO_PUTU16(y);
1150 FIFO_PUTU16(z);
1153 static inline void GX_Position3s16(s16 x,s16 y,s16 z)
1155 FIFO_PUTS16(x);
1156 FIFO_PUTS16(y);
1157 FIFO_PUTS16(z);
1160 static inline void GX_Position3u8(u8 x,u8 y,u8 z)
1162 FIFO_PUTU8(x);
1163 FIFO_PUTU8(y);
1164 FIFO_PUTU8(z);
1167 static inline void GX_Position3s8(s8 x,s8 y,s8 z)
1169 FIFO_PUTS8(x);
1170 FIFO_PUTS8(y);
1171 FIFO_PUTS8(z);
1174 static inline void GX_Position2f32(f32 x,f32 y)
1176 FIFO_PUTF32(x);
1177 FIFO_PUTF32(y);
1180 static inline void GX_Position2u16(u16 x,u16 y)
1182 FIFO_PUTU16(x);
1183 FIFO_PUTU16(y);
1186 static inline void GX_Position2s16(s16 x,s16 y)
1188 FIFO_PUTS16(x);
1189 FIFO_PUTS16(y);
1192 static inline void GX_Position2u8(u8 x,u8 y)
1194 FIFO_PUTU8(x);
1195 FIFO_PUTU8(y);
1198 static inline void GX_Position2s8(s8 x,s8 y)
1200 FIFO_PUTS8(x);
1201 FIFO_PUTS8(y);
1204 static inline void GX_Position1x8(u8 index)
1206 FIFO_PUTU8(index);
1209 static inline void GX_Position1x16(u16 index)
1211 FIFO_PUTU16(index);
1214 static inline void GX_Normal3f32(f32 nx,f32 ny,f32 nz)
1216 FIFO_PUTF32(nx);
1217 FIFO_PUTF32(ny);
1218 FIFO_PUTF32(nz);
1221 static inline void GX_Normal3s16(s16 nx,s16 ny,s16 nz)
1223 FIFO_PUTS16(nx);
1224 FIFO_PUTS16(ny);
1225 FIFO_PUTS16(nz);
1228 static inline void GX_Normal3s8(s8 nx,s8 ny,s8 nz)
1230 FIFO_PUTS8(nx);
1231 FIFO_PUTS8(ny);
1232 FIFO_PUTS8(nz);
1235 static inline void GX_Normal1x8(u8 index)
1237 FIFO_PUTU8(index);
1240 static inline void GX_Normal1x16(u16 index)
1242 FIFO_PUTU16(index);
1245 static inline void GX_Color4u8(u8 r,u8 g,u8 b,u8 a)
1247 FIFO_PUTU8(r);
1248 FIFO_PUTU8(g);
1249 FIFO_PUTU8(b);
1250 FIFO_PUTU8(a);
1253 static inline void GX_Color3u8(u8 r,u8 g,u8 b)
1255 FIFO_PUTU8(r);
1256 FIFO_PUTU8(g);
1257 FIFO_PUTU8(b);
1260 static inline void GX_Color3f32(f32 r, f32 g, f32 b)
1263 FIFO_PUTU8((u8)(r * 255.0));
1264 FIFO_PUTU8((u8)(g * 255.0));
1265 FIFO_PUTU8((u8)(b * 255.0));
1270 static inline void GX_Color1u32(u32 clr)
1272 FIFO_PUTU32(clr);
1275 static inline void GX_Color1u16(u16 clr)
1277 FIFO_PUTU16(clr);
1280 static inline void GX_Color1x8(u8 index)
1282 FIFO_PUTU8(index);
1285 static inline void GX_Color1x16(u16 index)
1287 FIFO_PUTU16(index);
1290 static inline void GX_TexCoord2f32(f32 s,f32 t)
1292 FIFO_PUTF32(s);
1293 FIFO_PUTF32(t);
1296 static inline void GX_TexCoord2u16(u16 s,u16 t)
1298 FIFO_PUTU16(s);
1299 FIFO_PUTU16(t);
1302 static inline void GX_TexCoord2s16(s16 s,s16 t)
1304 FIFO_PUTS16(s);
1305 FIFO_PUTS16(t);
1308 static inline void GX_TexCoord2u8(u8 s,u8 t)
1310 FIFO_PUTU8(s);
1311 FIFO_PUTU8(t);
1314 static inline void GX_TexCoord2s8(s8 s,s8 t)
1316 FIFO_PUTS8(s);
1317 FIFO_PUTS8(t);
1320 static inline void GX_TexCoord1f32(f32 s)
1322 FIFO_PUTF32(s);
1325 static inline void GX_TexCoord1u16(u16 s)
1327 FIFO_PUTU16(s);
1330 static inline void GX_TexCoord1s16(s16 s)
1332 FIFO_PUTS16(s);
1335 static inline void GX_TexCoord1u8(u8 s)
1337 FIFO_PUTU8(s);
1340 static inline void GX_TexCoord1s8(s8 s)
1342 FIFO_PUTS8(s);
1345 static inline void GX_TexCoord1x8(u8 index)
1347 FIFO_PUTU8(index);
1350 static inline void GX_TexCoord1x16(u16 index)
1352 FIFO_PUTU16(index);
1355 static inline void GX_MatrixIndex1x8(u8 index)
1357 FIFO_PUTU8(index);
1361 void GX_AdjustForOverscan(GXRModeObj *rmin,GXRModeObj *rmout,u16 hor,u16 ver);
1362 void GX_LoadPosMtxImm(Mtx mt,u32 pnidx);
1363 void GX_LoadPosMtxIdx(u16 mtxidx,u32 pnidx);
1364 void GX_LoadNrmMtxImm(Mtx mt,u32 pnidx);
1365 void GX_LoadNrmMtxIdx3x3(u16 mtxidx,u32 pnidx);
1366 void GX_LoadTexMtxImm(Mtx mt,u32 texidx,u8 type);
1367 void GX_LoadTexMtxIdx(u16 mtxidx,u32 texidx,u8 type);
1368 void GX_SetCurrentMtx(u32 mtx);
1370 /*!
1371 * \fn void GX_SetTevOp(u8 tevstage,u8 mode)
1372 * \brief Simplified function to set GX_SetTevColorIn(), GX_SetTevAlphaIn(), GX_SetTevColorOp() and GX_SetTevAlphaOp() for
1373 * this <b><i>tevstage</i></b> based on a predefined combiner <b><i>mode</i></b>.
1375 * \param[in] tevstage \ref tevstage.
1376 * \param[in] mode \ref tevdefmode
1378 * \return none
1380 void GX_SetTevOp(u8 tevstage,u8 mode);
1382 /*!
1383 * \fn void GX_SetTevColor(u8 tev_regid,GXColor color)
1384 * \brief Sets the vertical clamping mode to use during the EFB to XFB or texture copy.
1386 * \param[in] tev_regid \ref tevcoloutreg.
1387 * \param[in] color Constant color value.
1389 * \return none
1391 void GX_SetTevColor(u8 tev_regid,GXColor color);
1393 /*!
1394 * \fn void GX_SetTevColorS10(u8 tev_regid,GXColor color)
1395 * \brief Sets the vertical clamping mode to use during the EFB to XFB or texture copy.
1397 * \param[in] tev_regid \ref tevcoloutreg.
1398 * \param[in] color Constant color value in S10 format.
1400 * \return none
1402 void GX_SetTevColorS10(u8 tev_regid,GXColorS10 color);
1404 /*!
1405 * \fn void GX_SetTevColorIn(u8 tevstage,u8 a,u8 b,u8 c,u8 d)
1406 * \brief Sets the color input sources for one <b><i>tevstage</i></b> of the Texture Environment (TEV) color combiner.
1407 * This includes constant (register) colors and alphas, texture color/alpha, rasterized color/alpha (the result
1408 * of per-vertex lighting), and a few useful constants.<br><br>
1409 * <b><i>Note:</i></b> The input controls are independent for each TEV stage.
1411 * \param[in] tevstage \ref tevstage
1412 * \param[in] a \ref tevcolorarg
1413 * \param[in] b \ref tevcolorarg
1414 * \param[in] c \ref tevcolorarg
1415 * \param[in] d \ref tevcolorarg
1417 * \return none
1419 void GX_SetTevColorIn(u8 tevstage,u8 a,u8 b,u8 c,u8 d);
1421 /*!
1422 * \fn void GX_SetTevAlphaIn(u8 tevstage,u8 a,u8 b,u8 c,u8 d)
1423 * \brief Sets the alpha input sources for one <b><i>tevstage</i></b> of the Texture Environment (TEV) alpha combiner.
1424 * There are fewer alpha inputs than color inputs, and there are no color channels available in the alpha combiner.<br><br>
1425 * <b><i>Note:</i></b> The input controls are independent for each TEV stage.
1427 * \param[in] tevstage \ref tevstage
1428 * \param[in] a \ref tevalphaarg
1429 * \param[in] b \ref tevalphaarg
1430 * \param[in] c \ref tevalphaarg
1431 * \param[in] d \ref tevalphaarg
1433 * \return none
1435 void GX_SetTevAlphaIn(u8 tevstage,u8 a,u8 b,u8 c,u8 d);
1437 /*!
1438 * \fn void GX_SetTevColorOp(u8 tevstage,u8 tevop,u8 tevbias,u8 tevscale,u8 clamp,u8 tevregid)
1439 * \brief Sets the <b><i>tevop</i></b>, <b><i>tevbias</i></b>, <b><i>tevscale</i></b> and <b><i>clamp</i></b>-mode operation for the color combiner
1440 * for this <b><i>tevstage</i></b> of the Texture Environment (TEV) unit. This function also specifies the register, <b><i>tevregid</i></b>, that
1441 * will contain the result of the color combiner function. The color combiner function is:<br><br>
1442 * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b><i>tevregid</i></b> = (d (<b><i>tevop</i></b>) ((1.0 - c)*a + c*b) + <b><i>tevbias</i></b>) * <b><i>tevscale</i></b>;<br><br>
1443 * The input sources a,b,c and d are set using GX_SetTevColorIn().
1445 * \param[in] tevstage \ref tevstage.
1446 * \param[in] tevop \ref tevop
1447 * \param[in] tevbias \ref tevbias.
1448 * \param[in] tevscale \ref tevscale.
1449 * \param[in] clamp Clamp results when GX_TRUE.
1450 * \param[in] tevregid \ref tevcoloutreg
1452 * \return none
1454 void GX_SetTevColorOp(u8 tevstage,u8 tevop,u8 tevbias,u8 tevscale,u8 clamp,u8 tevregid);
1457 /*!
1458 * \fn void GX_SetTevAlphaOp(u8 tevstage,u8 tevop,u8 tevbias,u8 tevscale,u8 clamp,u8 tevregid)
1459 * \brief Sets the <b><i>tevop</i></b>, <b><i>tevbias</i></b>, <b><i>tevscale</i></b> and <b><i>clamp</i></b>-mode operation for the alpha combiner
1460 * for this <b><i>tevstage</i></b> of the Texture Environment (TEV) unit. This function also specifies the register, <b><i>tevregid</i></b>, that
1461 * will contain the result of the alpha combiner function. The alpha combiner function is:<br><br>
1462 * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b><i>tevregid</i></b> = (d (<b><i>tevop</i></b>) ((1.0 - c)*a + c*b) + <b><i>tevbias</i></b>) * <b><i>tevscale</i></b>;<br><br>
1463 * The input sources a,b,c and d are set using GX_SetTevAlphaIn().
1465 * \param[in] tevstage \ref tevstage.
1466 * \param[in] tevop \ref tevop
1467 * \param[in] tevbias \ref tevbias.
1468 * \param[in] tevscale \ref tevscale.
1469 * \param[in] clamp Clamp results when GX_TRUE.
1470 * \param[in] tevregid \ref tevcoloutreg
1472 * \return none
1474 void GX_SetTevAlphaOp(u8 tevstage,u8 tevop,u8 tevbias,u8 tevscale,u8 clamp,u8 tevregid);
1475 void GX_SetNumTexGens(u32 nr);
1476 void GX_SetTexCoordGen(u16 texcoord,u32 tgen_typ,u32 tgen_src,u32 mtxsrc);
1477 void GX_SetTexCoordGen2(u16 texcoord,u32 tgen_typ,u32 tgen_src,u32 mtxsrc,u32 normalize,u32 postmtx);
1479 /*!
1480 * \fn void GX_SetZTexture(u8 op,u8 fmt,u32 bias)
1481 * \brief Sets the vertical clamping mode to use during the EFB to XFB or texture copy.
1483 * \param[in] op \ref ztexop
1484 * \param[in] fmt \ref ztexfmt
1485 * \param[in] bias Bias value. Format is 24bit unsigned.
1487 * \return none
1489 void GX_SetZTexture(u8 op,u8 fmt,u32 bias);
1490 void GX_SetZMode(u8 enable,u8 func,u8 update_enable);
1491 void GX_SetZCompLoc(u8 before_tex);
1492 void GX_SetLineWidth(u8 width,u8 fmt);
1493 void GX_SetPointSize(u8 width,u8 fmt);
1495 void GX_SetBlendMode(u8 type,u8 src_fact,u8 dst_fact,u8 op);
1496 void GX_SetCullMode(u8 mode);
1497 void GX_SetCoPlanar(u8 enable);
1498 void GX_EnableTexOffsets(u8 coord,u8 line_enable,u8 point_enable);
1499 void GX_SetClipMode(u8 mode);
1500 void GX_SetScissor(u32 xOrigin,u32 yOrigin,u32 wd,u32 ht);
1501 void GX_SetScissorBoxOffset(s32 xoffset,s32 yoffset);
1502 void GX_SetNumChans(u8 num);
1504 void GX_SetTevOrder(u8 tevstage,u8 texcoord,u32 texmap,u8 color);
1505 void GX_SetNumTevStages(u8 num);
1507 void GX_SetAlphaCompare(u8 comp0,u8 ref0,u8 aop,u8 comp1,u8 ref1);
1508 void GX_SetTevKColor(u8 sel, GXColor col);
1509 void GX_SetTevKColorSel(u8 tevstage,u8 sel);
1510 void GX_SetTevKAlphaSel(u8 tevstage,u8 sel);
1511 void GX_SetTevKColorS10(u8 sel, GXColorS10 col);
1513 /*!
1514 * \fn void GX_SetTevSwapMode(u8 tevstage,u8 ras_sel,u8 tex_sel)
1515 * \brief Selects a set of swap modes for the rasterized color and texture color for a given TEV stage. This allows the
1516 * color components of these inputs to be rearranged or duplicated.
1517 * There are four different swap mode table entries and each entry in the table specifies how the RGBA inputs map
1518 * to the RGBA outputs. See GX_SetTevSwapModeTable() for more information.
1520 * \param[in] tevstage \ref tevstage
1521 * \param[in] ras_sel selects a swap mode for the rasterized color input.
1522 * \param[in] tex_sel selects a swap mode for the texture color input.
1524 * \return none
1526 void GX_SetTevSwapMode(u8 tevstage,u8 ras_sel,u8 tex_sel);
1528 /*!
1529 * \fn void GX_SetTevSwapModeTable(u8 swapid,u8 r,u8 g,u8 b,u8 a)
1530 * \brief Sets up the TEV color swap table. The swap table allows the rasterized color and texture color to be swapped component-wise.
1531 * An entry in the table specifies how the input color components map to the output color components.
1533 * \param[in] swapid \ref tevswapsel
1534 * \param[in] r input color component that should be mapped to the red output component.
1535 * \param[in] g input color component that should be mapped to the green output component.
1536 * \param[in] b input color component that should be mapped to the blue output component.
1537 * \param[in] a input color component that should be mapped to the alpha output component.
1539 * \return none
1541 void GX_SetTevSwapModeTable(u8 swapid,u8 r,u8 g,u8 b,u8 a);
1542 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);
1543 void GX_SetTevDirect(u8 tevstage);
1544 void GX_SetNumIndStages(u8 nstages);
1545 void GX_SetIndTexOrder(u8 indtexstage,u8 texcoord,u8 texmap);
1546 void GX_SetIndTexCoordScale(u8 indtexid,u8 scale_s,u8 scale_t);
1547 void GX_SetFog(u8 type,f32 startz,f32 endz,f32 nearz,f32 farz,GXColor col);
1548 void GX_SetFogRangeAdj(u8 enable,u16 center,GXFogAdjTbl *table);
1549 void GX_SetIndTexMatrix(u8 indtexmtx,f32 offset_mtx[2][3],s8 scale_exp);
1550 void GX_SetTevIndBumpST(u8 tevstage,u8 indstage,u8 mtx_sel);
1551 void GX_SetTevIndBumpXYZ(u8 tevstage,u8 indstage,u8 mtx_sel);
1552 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);
1554 void GX_SetColorUpdate(u8 enable);
1555 void GX_SetAlphaUpdate(u8 enable);
1556 void GX_SetPixelFmt(u8 pix_fmt,u8 z_fmt);
1557 void GX_SetDither(u8 dither);
1558 void GX_SetDstAlpha(u8 enable,u8 a);
1559 void GX_SetFieldMask(u8 even_mask,u8 odd_mask);
1560 void GX_SetFieldMode(u8 field_mode,u8 half_aspect_ratio);
1562 /*!
1563 * \fn f32 GX_GetYScaleFactor(u16 efbHeight,u16 xfbHeight)
1564 * \brief Calculates an appropriate Y scale factor value for GX_SetDispCopyYScale based on the height of the EFB and
1565 * the height of the XFB.
1567 * \param[in] efbHeight Height of embedded framebuffer. Range from 2 to 528. Should be a multiple of 2.
1568 * \param[in] xfbHeight Height of external framebuffer. Range from 2 to 1024. Should be equal or greater than efbHeight.
1570 * \return Y scale factor which can be used as argument of GX_SetDispCopyYScale().
1572 f32 GX_GetYScaleFactor(u16 efbHeight,u16 xfbHeight);
1574 /*!
1575 * \fn u32 GX_SetDispCopyYScale(f32 yscale)
1576 * \brief Sets the vertical scale factor for the EFB to XFB copy operation. The number of actual lines copied is returned, based on the current EFB height.
1577 * You can use this number to allocate the proper XFB size. You have to call GX_SetDispCopySrc() prior to this function call if you want to get the
1578 * number of lines by using this function. There is also another way (GX_GetNumXfbLines) to calculate this number.
1580 * \param[in] yscale Vertical scale value. Range from 1.0 to 256.0.
1582 * \return Number of lines that will be copied.
1584 u32 GX_SetDispCopyYScale(f32 yscale);
1586 /*!
1587 * \fn void GX_SetDispCopySrc(u16 left,u16 top,u16 wd,u16 ht)
1588 * \brief Sets the source parameters for the EFB to XFB copy operation.
1590 * \param[in] left left most source pixel to copy. Must be a multiple of 2 pixels.
1591 * \param[in] top top most source line to copy. Must be a multiple of 2 lines.
1592 * \param[in] wd width in pixels to copy. Must be a multiple of 2 pixels.
1593 * \param[in] ht height in lines to copy. Must be a multiple of 2 lines.
1595 * \return none
1597 void GX_SetDispCopySrc(u16 left,u16 top,u16 wd,u16 ht);
1599 /*!
1600 * \fn void GX_SetDispCopyDst(u16 wd,u16 ht)
1601 * \brief Sets the witdth and height of the display buffer in pixels. The application typical renders an image into the EFB(source) and
1602 * then copies it into the XFB(destination) in main memory. The <b><i>wd</i></b> specifies the number of pixels between adjacent lines in the
1603 * destination buffer and can be different than the width of the EFB.
1605 * \param[in] wd Distance between successive lines in the XFB, in pixels. Must be a multiple of 16.
1606 * \param[in] ht Height of the XFB in lines.
1608 * \return none
1610 void GX_SetDispCopyDst(u16 wd,u16 ht);
1612 /*!
1613 * \fn void GX_SetCopyClamp(u8 clamp)
1614 * \brief Sets the vertical clamping mode to use during the EFB to XFB or texture copy.
1616 * \param[in] clamp clamp mode. bit-wise OR of \ref xfbclamp. Use GX_CLAMP_NONE for no clamping.
1618 * \return none
1620 void GX_SetCopyClamp(u8 clamp);
1622 /*!
1623 * \fn void GX_SetDispCopyGamma(u8 gamma)
1624 * \brief Sets the gamma correction applied to pixels during EFB to XFB copy operation.
1626 * \param[in] gamma \ref gammamode
1628 * \return none
1630 void GX_SetDispCopyGamma(u8 gamma);
1632 void GX_SetCopyFilter(u8 aa,u8 sample_pattern[12][2],u8 vf,u8 vfilter[7]);
1633 void GX_SetDispCopyFrame2Field(u8 mode);
1635 /*!
1636 * \fn void GX_SetCopyClear(GXColor color,u32 zvalue)
1637 * \brief Sets color and Z value to clear the EFB to, during copy operations. These values are used during both display copies and texture copies.
1639 * \param[in] color RGBA color (8-bit/component) to use during clear operation.
1640 * \param[in] zvalue 24-bit Z value to use during clear operation. Use the constant GX_MAX_Z24 to specify the maximum depth value.
1642 * \return none
1644 void GX_SetCopyClear(GXColor color,u32 zvalue);
1646 /*!
1647 * \fn void GX_CopyDisp(void *dest,u8 clear)
1648 * \brief Copies the embedded framebuffer(XFB) to the external framebuffer(XFB) in main memory. The stride of
1649 * the XFB is set using GX_SetDispCopyDst(). The source image in the EFB is described using GX_SetDispCopySrc().
1651 * The graphics processor will stall all graphics commands util the copy is complete.
1653 * If the <b><i>clear</i></b> flag is true, the color and Z buffers will be cleared during the copy. They will be
1654 * cleared to the constant values set using GX_SetCopyClear().
1656 * \param[in] dest pointer to the external framebuffer. <b><i>dest</i></b> should be 32B aligned.
1657 * \param[in] clear flag that indicates framebuffer should be cleared if GX_TRUE.
1659 * \return none
1661 void GX_CopyDisp(void *dest,u8 clear);
1663 void GX_SetTexCopySrc(u16 left,u16 top,u16 wd,u16 ht);
1665 /*!
1666 * \fn void GX_SetTexCopyDst(u16 wd,u16 ht,u32 fmt,u8 mipmap)
1667 * \brief Copies the embedded framebuffer(XFB) to the texture image buffer <b><i>dest</i></b> in main memory. This is useful
1668 * when creating textures using the Graphics Processor(CP).
1669 * If the <b><i>clear</i></b> flag is set to GX_TRUE, the EFB will be cleared to the current color(see GX_SetCopyClear())
1670 * during the copy operation.
1672 * \param[in] wd pointer to the image buffer in main memory. <b><i>dest</i></b> should be 32B aligned.
1673 * \param[in] ht flag that indicates framebuffer should be cleared if GX_TRUE.
1674 * \param[in] fmt \ref texfmt
1675 * \param[in] mipmap
1677 * \return none
1679 void GX_SetTexCopyDst(u16 wd,u16 ht,u32 fmt,u8 mipmap);
1681 /*!
1682 * \fn void GX_CopyTex(void *dest,u8 clear)
1683 * \brief Copies the embedded framebuffer(XFB) to the texture image buffer <b><i>dest</i></b> in main memory. This is useful
1684 * when creating textures using the Graphics Processor(CP).
1685 * If the <b><i>clear</i></b> flag is set to GX_TRUE, the EFB will be cleared to the current color(see GX_SetCopyClear())
1686 * during the copy operation.
1688 * \param[in] dest pointer to the image buffer in main memory. <b><i>dest</i></b> should be 32B aligned.
1689 * \param[in] clear flag that indicates framebuffer should be cleared if GX_TRUE.
1691 * \return none
1693 void GX_CopyTex(void *dest,u8 clear);
1695 /*!
1696 * \fn void GX_PixModeSync()
1697 * \brief Inserts a synchronization command into the graphics FIFO. When the GPU sees this command it will allow the
1698 * rest of the pipe to flush before continuing. This command is useful in certain situation such as after a GX_CopyTex()
1699 * command and before a primitive that uses the copied texture.
1701 * \return none
1703 void GX_PixModeSync();
1705 /*!
1706 * \fn void GX_ClearBoundingBox()
1707 * \brief Clears the bounding box values before a new image is drawn.
1708 * The graphics hardware keeps track of a bounding box of pixel coordinates that are drawn in the EFB.
1710 * \return none
1712 void GX_ClearBoundingBox();
1713 void GX_PokeAlphaMode(u8 func,u8 threshold);
1714 void GX_PokeAlphaUpdate(u8 update_enable);
1715 void GX_PokeColorUpdate(u8 update_enable);
1716 void GX_PokeDither(u8 dither);
1717 void GX_PokeBlendMode(u8 type,u8 src_fact,u8 dst_fact,u8 op);
1718 void GX_PokeAlphaRead(u8 mode);
1719 void GX_PokeDstAlpha(u8 enable,u8 a);
1720 void GX_PokeARGB(u16 x,u16 y,GXColor color);
1721 void GX_PeekARGB(u16 x,u16 y,GXColor *color);
1722 void GX_PokeZ(u16 x,u16 y,u32 z);
1723 void GX_PeekZ(u16 x,u16 y,u32 *z);
1724 void GX_PokeZMode(u8 comp_enable,u8 func,u8 update_enable);
1726 u32 GX_GetTexObjFmt(GXTexObj *obj);
1727 u32 GX_GetTexObjMipMap(GXTexObj *obj);
1729 u8 GX_GetTexFmt(GXTexObj *obj);
1730 u32 GX_GetTexBufferSize(u16 wd,u16 ht,u32 fmt,u8 mipmap,u8 maxlod);
1731 void GX_InvalidateTexAll();
1732 void GX_InvalidateTexRegion(GXTexRegion *region);
1733 void GX_InitTexCacheRegion(GXTexRegion *region,u8 is32bmipmap,u32 tmem_even,u8 size_even,u32 tmem_odd,u8 size_odd);
1734 void GX_InitTexPreloadRegion(GXTexRegion *region,u32 tmem_even,u32 size_even,u32 tmem_odd,u32 size_odd);
1735 void GX_InitTexObj(GXTexObj *obj,void *img_ptr,u16 wd,u16 ht,u8 fmt,u8 wrap_s,u8 wrap_t,u8 mipmap);
1736 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);
1737 void GX_InitTexObjTlut(GXTexObj *obj,u32 tlut_name);
1738 void GX_InitTexObjData(GXTexObj *obj,void *img_ptr);
1739 void GX_InitTexObjWrapMode(GXTexObj *obj,u8 wrap_s,u8 wrap_t);
1740 void GX_InitTexObjFilterMode(GXTexObj *obj,u8 minfilt,u8 magfilt);
1741 void GX_InitTexObjMinLOD(GXTexObj *obj,f32 minlod);
1742 void GX_InitTexObjMaxLOD(GXTexObj *obj,f32 maxlod);
1743 void GX_InitTexObjLODBias(GXTexObj *obj,f32 lodbias);
1744 void GX_InitTexObjBiasClamp(GXTexObj *obj,u8 biasclamp);
1745 void GX_InitTexObjEdgeLOD(GXTexObj *obj,u8 edgelod);
1746 void GX_InitTexObjMaxAniso(GXTexObj *obj,u8 maxaniso);
1747 void GX_LoadTexObj(GXTexObj *obj,u8 mapid);
1748 void GX_LoadTlut(GXTlutObj *obj,u32 tlut_name);
1749 void GX_LoadTexObjPreloaded(GXTexObj *obj,GXTexRegion *region,u8 mapid);
1750 void GX_PreloadEntireTex(GXTexObj *obj,GXTexRegion *region);
1751 void GX_InitTlutObj(GXTlutObj *obj,void *lut,u8 fmt,u16 entries);
1752 void GX_InitTlutRegion(GXTlutRegion *region,u32 tmem_addr,u8 tlut_sz);
1753 void GX_InitTexObjLOD(GXTexObj *obj,u8 minfilt,u8 magfilt,f32 minlod,f32 maxlod,f32 lodbias,u8 biasclamp,u8 edgelod,u8 maxaniso);
1754 void GX_SetTexCoorScaleManually(u8 texcoord,u8 enable,u16 ss,u16 ts);
1755 void GX_SetTexCoordBias(u8 texcoord,u8 s_enable,u8 t_enable);
1756 GXTexRegionCallback GX_SetTexRegionCallback(GXTexRegionCallback cb);
1757 GXTlutRegionCallback GX_SetTlutRegionCallback(GXTlutRegionCallback cb);
1759 void GX_InitLightPos(GXLightObj *lit_obj,f32 x,f32 y,f32 z);
1760 void GX_InitLightColor(GXLightObj *lit_obj,GXColor col);
1761 void GX_InitLightDir(GXLightObj *lit_obj,f32 nx,f32 ny,f32 nz);
1762 void GX_LoadLightObj(GXLightObj *lit_obj,u8 lit_id);
1763 void GX_LoadLightObjIdx(u32 litobjidx,u8 litid);
1764 void GX_InitLightDistAttn(GXLightObj *lit_obj,f32 ref_dist,f32 ref_brite,u8 dist_fn);
1765 void GX_InitLightAttn(GXLightObj *lit_obj,f32 a0,f32 a1,f32 a2,f32 k0,f32 k1,f32 k2);
1766 void GX_InitLightAttnA(GXLightObj *lit_obj,f32 a0,f32 a1,f32 a2);
1767 void GX_InitLightAttnK(GXLightObj *lit_obj,f32 k0,f32 k1,f32 k2);
1768 void GX_InitSpecularDirHA(GXLightObj *lit_obj,f32 nx,f32 ny,f32 nz,f32 hx,f32 hy,f32 hz);
1769 void GX_InitSpecularDir(GXLightObj *lit_obj,f32 nx,f32 ny,f32 nz);
1770 void GX_InitLightSpot(GXLightObj *lit_obj,f32 cut_off,u8 spotfn);
1772 u32 GX_ReadClksPerVtx();
1773 u32 GX_GetOverflowCount();
1774 u32 GX_ResetOverflowCount();
1775 lwp_t GX_GetCurrentGXThread();
1776 lwp_t GX_SetCurrentGXThread();
1777 void GX_RestoreWriteGatherPipe();
1778 void GX_SetGPMetric(u32 perf0,u32 perf1);
1779 void GX_ClearGPMetric();
1780 void GX_InitXfRasMetric();
1781 void GX_ReadXfRasMetric(u32 *xfwaitin,u32 *xfwaitout,u32 *rasbusy,u32 *clks);
1782 void GX_ClearVCacheMetric();
1783 void GX_ReadVCacheMetric(u32 *check,u32 *miss,u32 *stall);
1784 void GX_SetVCacheMetric(u32 attr);
1785 void GX_GetGPStatus(u8 *overhi,u8 *underlow,u8 *readIdle,u8 *cmdIdle,u8 *brkpt);
1786 void GX_ReadGPMetric(u32 *cnt0,u32 *cnt1);
1787 void GX_GetFifoPtrs(GXFifoObj *fifo,void **rd_ptr,void **wt_ptr);
1788 volatile void* GX_RedirectWriteGatherPipe(void *ptr);
1790 #define GX_InitLightPosv(lo,vec) \
1791 (GX_InitLightPos((lo), *(f32*)(vec), *((f32*)(vec)+1), *((f32*)(vec)+2)))
1793 #define GX_InitLightDirv(lo,vec) \
1794 (GX_InitLightDir((lo), *(f32*)(vec), *((f32*)(vec)+1), *((f32*)(vec)+2)))
1796 #define GX_InitSpecularDirv(lo,vec) \
1797 (GX_InitSpecularDir((lo), *(f32*)(vec), *((f32*)(vec)+1), *((f32*)(vec)+2)))
1799 #define GX_InitSpecularDirHAv(lo,vec0,vec1) \
1800 (GX_InitSpecularDirHA((lo), \
1801 *(f32*)(vec0), *((f32*)(vec0)+1), *((f32*)(vec0)+2), \
1802 *(f32*)(vec1), *((f32*)(vec1)+1), *((f32*)(vec1)+2)))
1804 #define GX_InitLightShininess(lobj, shininess) \
1805 (GX_InitLightAttn(lobj, 0.0F, 0.0F, 1.0F, \
1806 (shininess)/2.0F, 0.0F, \
1807 1.0F-(shininess)/2.0F ))
1809 #ifdef __cplusplus
1811 #endif /* __cplusplus */
1813 #endif