Twilight Princess
Decompilation of The Legend of Zelda: Twilight Princess
Loading...
Searching...
No Matches
gx.h
Go to the documentation of this file.
1#ifndef GX_H_
2#define GX_H_
3
4#include "dolphin/gx/GXAttr.h"
5#include "dolphin/gx/GXBump.h"
7#include "dolphin/gx/GXFifo.h"
10#include "dolphin/gx/GXInit.h"
11#include "dolphin/gx/GXLight.h"
12#include "dolphin/gx/GXMisc.h"
13#include "dolphin/gx/GXPerf.h"
14#include "dolphin/gx/GXPixel.h"
15#include "dolphin/gx/GXTev.h"
17
18#ifdef __cplusplus
19extern "C" {
20#endif
21
22// Pack value into bitfield
23// clang-format off
24#define GX_BITFIELD_SET(field, pos, size, value) (field) = __rlwimi((field), (value), 31 - (pos) - (size) + 1, (pos), (pos) + (size)-1)
25#define GX_BITFIELD_TRUNC(field, pos, size, value) (__rlwimi((field), (value), 0, (pos), (pos) + (size)-1))
26
27#define GX_BITGET(field, pos, size) ((field) >> (31 - (pos) - (size) + 1) & ((1 << (size)) - 1))
28#define GX_GET_REG(reg, st, end) GX_BITGET(reg, st, (end - st + 1))
29#define GX_SET_REG(reg, x, st, end) GX_BITFIELD_SET(reg, st, (end - st + 1), x)
30#define GX_SET_TRUNC(reg, x, st, end) GX_BITFIELD_TRUNC((reg), (st), ((end) - (st) + 1), (x))
31
32#define GXCOLOR_AS_U32(color) (*((u32*)&(color)))
33
34#define INSERT_FIELD(reg, value, nbits, shift) \
35 (reg) = ((u32) (reg) & ~(((1 << (nbits)) - 1) << (shift))) | \
36 ((u32) (value) << (shift));
37
38#define FAST_FLAG_SET(regOrg, newFlag, shift, size) \
39 do { \
40 (regOrg) = (u32)__rlwimi((int)(regOrg), (int)(newFlag), (shift), (32 - (shift) - (size)), (31 - (shift))); \
41 } while (0);
42// clang-format on
43
44#define GX_LOAD_BP_REG 0x61
45#define GX_NOP 0
46
59
60#define GXFIFO_ADDR 0xCC008000
62
63#define GX_WRITE_U8(data) GXWGFifo.u8 = data;
64#define GX_WRITE_U32(data) GXWGFifo.u32 = data;
65#define GX_WRITE_F32(val) (GXWGFifo.f32 = (f32)val)
66
67#define GX_CP_LOAD_REG(addr, data) \
68 GXWGFifo.s8 = GX_FIFO_CMD_LOAD_CP_REG; \
69 GXWGFifo.s8 = (addr); \
70 GXWGFifo.s32 = (data);
71
75#define GX_XF_LOAD_REG_HDR(addr) \
76 GXWGFifo.s8 = GX_FIFO_CMD_LOAD_XF_REG; \
77 GXWGFifo.s32 = (addr);
78
82#define GX_XF_LOAD_REG(addr, data) \
83 GX_XF_LOAD_REG_HDR(addr); \
84 GXWGFifo.s32 = (data);
85
89#define GX_BP_LOAD_REG(data) \
90 GXWGFifo.s8 = GX_FIFO_CMD_LOAD_BP_REG; \
91 GXWGFifo.s32 = (data);
92
96#define GX_XF_LOAD_REGS(size, addr) \
97 { \
98 u32 cmd = (size) << 16 | addr; \
99 GX_XF_LOAD_REG_HDR(cmd); \
100 }
101
102static inline void GXPosition3f32(const f32 x, const f32 y, const f32 z) {
103 GXWGFifo.f32 = x;
104 GXWGFifo.f32 = y;
105 GXWGFifo.f32 = z;
106}
107
108static inline void GXNormal3f32(const f32 x, const f32 y, const f32 z) {
109 GXWGFifo.f32 = x;
110 GXWGFifo.f32 = y;
111 GXWGFifo.f32 = z;
112}
113
114static inline void GXNormal1x16(const u16 x) {
115 GXWGFifo.u16 = x;
116}
117
118static inline void GXPosition2f32(const f32 x, const f32 z) {
119 GXWGFifo.f32 = x;
120 GXWGFifo.f32 = z;
121}
122
123static inline void GXColor1u32(const u32 c) {
124 GXWGFifo.u32 = c;
125}
126
127static inline void GXColor4u8(const u8 r, const u8 g, const u8 b, const u8 a) {
128 GXWGFifo.u8 = r;
129 GXWGFifo.u8 = g;
130 GXWGFifo.u8 = b;
131 GXWGFifo.u8 = a;
132}
133
134static inline void GXTexCoord2f32(const f32 s, const f32 t) {
135 GXWGFifo.f32 = s;
136 GXWGFifo.f32 = t;
137}
138
139static inline void GXTexCoord2u8(const u8 s, const u8 t) {
140 GXWGFifo.u8 = s;
141 GXWGFifo.u8 = t;
142}
143
144static inline void GXTexCoord1x8(const u8 s) {
145 GXWGFifo.u8 = s;
146}
147
148static inline void GXTexCoord1x16(const u16 s) {
149 GXWGFifo.u16 = s;
150}
151
152static inline void GXPosition2u16(const u16 x, const u16 y) {
153 GXWGFifo.u16 = x;
154 GXWGFifo.u16 = y;
155}
156
157static inline void GXPosition1x16(const u16 x) {
158 GXWGFifo.u16 = x;
159}
160
161static inline void GXPosition1x8(const u8 x) {
162 GXWGFifo.u8 = x;
163}
164
165static inline void GXPosition3s8(const s8 x, const s8 y, const s8 z) {
166 GXWGFifo.s8 = x;
167 GXWGFifo.s8 = y;
168 GXWGFifo.s8 = z;
169}
170
171static inline void GXPosition2s8(const s8 x, const s8 y) {
172 GXWGFifo.s8 = x;
173 GXWGFifo.s8 = y;
174}
175
176static inline void GXPosition2s16(const s16 x, const s16 y) {
177 GXWGFifo.s16 = x;
178 GXWGFifo.s16 = y;
179}
180
181static inline void GXPosition3s16(const s16 x, const s16 y, const s16 z) {
182 GXWGFifo.s16 = x;
183 GXWGFifo.s16 = y;
184 GXWGFifo.s16 = z;
185}
186
187static inline void GXTexCoord2s8(const s8 x, const s8 y) {
188 GXWGFifo.s8 = x;
189 GXWGFifo.s8 = y;
190}
191
192static inline void GXTexCoord2u16(const u16 x, const u16 y) {
193 GXWGFifo.u16 = x;
194 GXWGFifo.u16 = y;
195}
196
197static inline void GXTexCoord2s16(const s16 u, const s16 v) {
198 GXWGFifo.s16 = u;
199 GXWGFifo.s16 = v;
200}
201
202static inline void GFWriteBPCmd(u32 param_1) {
203 GXWGFifo.u8 = 0x61;
204 GXWGFifo.u32 = param_1;
205}
206
210 do {
211 hiNew = hiStart;
214 } while (hiStart != hiNew);
215
216 return ((hiStart << 16) | lo);
217}
218
219inline void GFFill(u16 param_1, u32 param_2) {
220 GXWGFifo.u8 = 0x10;
221 GXWGFifo.u16 = 0;
222 GXWGFifo.u16 = param_1;
223 GXWGFifo.u32 = param_2;
224}
225
226static inline void GXEnd(void) {}
227
233
234#ifdef __cplusplus
235};
236#endif
237
238#endif
T cLib_calcTimer(T *value)
Definition c_lib.h:79
s
Definition e_acos.c:94
r
Definition e_acos.c:100
c
Definition e_acos.c:97
t
Definition e_asin.c:95
double x double x
Definition e_atan2.c:58
double x double y
Definition e_atan2.c:58
double u
Definition e_pow.c:163
double v
Definition e_pow.c:163
z
Definition e_pow.c:390
volatile PPCWGPipe GXWGFifo AT_ADDRESS(GXFIFO_ADDR)
static void GFWriteBPCmd(u32 param_1)
Definition gx.h:202
GXRenderModeObj GXNtsc480Int
Definition GXFrameBuf.c:49
static void GXTexCoord2u8(const u8 s, const u8 t)
Definition gx.h:139
static void GXPosition3s8(const s8 x, const s8 y, const s8 z)
Definition gx.h:165
static void GXPosition3s16(const s16 x, const s16 y, const s16 z)
Definition gx.h:181
static void GXTexCoord1x8(const u8 s)
Definition gx.h:144
static void GXColor4u8(const u8 r, const u8 g, const u8 b, const u8 a)
Definition gx.h:127
static u32 GXReadCPReg(u32 addrLo, u32 addrHi)
Definition gx.h:207
static void GXPosition1x16(const u16 x)
Definition gx.h:157
GXRenderModeObj GXNtsc480IntDf
Definition GXFrameBuf.c:4
static void GXPosition1x8(const u8 x)
Definition gx.h:161
static void GXTexCoord2f32(const f32 s, const f32 t)
Definition gx.h:134
GXRenderModeObj GXPal528IntDf
Definition GXFrameBuf.c:139
static void GXColor1u32(const u32 c)
Definition gx.h:123
static void GXNormal1x16(const u16 x)
Definition gx.h:114
static void GXTexCoord2s8(const s8 x, const s8 y)
Definition gx.h:187
static void GXPosition2s8(const s8 x, const s8 y)
Definition gx.h:171
static void GXEnd(void)
Definition gx.h:226
GXRenderModeObj GXMpal480IntDf
Definition GXFrameBuf.c:94
static void GXTexCoord2u16(const u16 x, const u16 y)
Definition gx.h:192
static void GXTexCoord1x16(const u16 s)
Definition gx.h:148
static void GXPosition2s16(const s16 x, const s16 y)
Definition gx.h:176
void GFFill(u16 param_1, u32 param_2)
Definition gx.h:219
GXRenderModeObj GXEurgb60Hz480IntDf
Definition GXFrameBuf.c:184
static void GXPosition2f32(const f32 x, const f32 z)
Definition gx.h:118
static void GXPosition2u16(const u16 x, const u16 y)
Definition gx.h:152
static void GXTexCoord2s16(const s16 u, const s16 v)
Definition gx.h:197
static void GXPosition3f32(const f32 x, const f32 y, const f32 z)
Definition gx.h:102
static void GXNormal3f32(const f32 x, const f32 y, const f32 z)
Definition gx.h:108
a
Definition k_cos.c:89
Definition GXStruct.h:22
signed char s8
Definition types.h:4
unsigned long u32
Definition types.h:10
signed long long s64
Definition types.h:7
float f32
Definition types.h:22
signed short s16
Definition types.h:5
double f64
Definition types.h:23
unsigned short u16
Definition types.h:9
unsigned long long u64
Definition types.h:11
signed long s32
Definition types.h:6
unsigned char u8
Definition types.h:8
Definition gx.h:47
s16 s16
Definition gx.h:53
s8 s8
Definition gx.h:52
f64 f64
Definition gx.h:57
f32 f32
Definition gx.h:56
u32 u32
Definition gx.h:50
u16 u16
Definition gx.h:49
s32 s32
Definition gx.h:54
s64 s64
Definition gx.h:55
u8 u8
Definition gx.h:48
u64 u64
Definition gx.h:51