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 GXPosition2f32(const f32 x, const f32 z) {
115 GXWGFifo.f32 = x;
116 GXWGFifo.f32 = z;
117}
118
119static inline void GXColor1u32(const u32 c) {
120 GXWGFifo.u32 = c;
121}
122
123static inline void GXColor4u8(const u8 r, const u8 g, const u8 b, const u8 a) {
124 GXWGFifo.u8 = r;
125 GXWGFifo.u8 = g;
126 GXWGFifo.u8 = b;
127 GXWGFifo.u8 = a;
128}
129
130static inline void GXTexCoord2f32(const f32 s, const f32 t) {
131 GXWGFifo.f32 = s;
132 GXWGFifo.f32 = t;
133}
134
135static inline void GXTexCoord2u8(const u8 s, const u8 t) {
136 GXWGFifo.u8 = s;
137 GXWGFifo.u8 = t;
138}
139
140static inline void GXTexCoord1x8(const u8 s) {
141 GXWGFifo.u8 = s;
142}
143
144static inline void GXPosition2u16(const u16 x, const u16 y) {
145 GXWGFifo.u16 = x;
146 GXWGFifo.u16 = y;
147}
148
149static inline void GXPosition1x16(const u16 x) {
150 GXWGFifo.u16 = x;
151}
152
153static inline void GXPosition1x8(const u8 x) {
154 GXWGFifo.u8 = x;
155}
156
157static inline void GXPosition3s8(const s8 x, const s8 y, const s8 z) {
158 GXWGFifo.s8 = x;
159 GXWGFifo.s8 = y;
160 GXWGFifo.s8 = z;
161}
162
163static inline void GXPosition2s8(const s8 x, const s8 y) {
164 GXWGFifo.s8 = x;
165 GXWGFifo.s8 = y;
166}
167
168static inline void GXPosition2s16(const s16 x, const s16 y) {
169 GXWGFifo.s16 = x;
170 GXWGFifo.s16 = y;
171}
172
173static inline void GXPosition3s16(const s16 x, const s16 y, const s16 z) {
174 GXWGFifo.s16 = x;
175 GXWGFifo.s16 = y;
176 GXWGFifo.s16 = z;
177}
178
179static inline void GXTexCoord2s8(const s8 x, const s8 y) {
180 GXWGFifo.s8 = x;
181 GXWGFifo.s8 = y;
182}
183
184static inline void GXTexCoord2u16(const u16 x, const u16 y) {
185 GXWGFifo.u16 = x;
186 GXWGFifo.u16 = y;
187}
188
189static inline void GXTexCoord2s16(const s16 u, const s16 v) {
190 GXWGFifo.s16 = u;
191 GXWGFifo.s16 = v;
192}
193
194static inline void GFWriteBPCmd(u32 param_1) {
195 GXWGFifo.u8 = 0x61;
196 GXWGFifo.u32 = param_1;
197}
198
202 do {
203 hiNew = hiStart;
206 } while (hiStart != hiNew);
207
208 return ((hiStart << 16) | lo);
209}
210
211inline void GFFill(u16 param_1, u32 param_2) {
212 GXWGFifo.u8 = 0x10;
213 GXWGFifo.u16 = 0;
214 GXWGFifo.u16 = param_1;
215 GXWGFifo.u32 = param_2;
216}
217
218static inline void GXEnd(void) {}
219
225
226#ifdef __cplusplus
227};
228#endif
229
230#endif
T cLib_calcTimer(T *value)
Definition c_lib.h:74
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:194
GXRenderModeObj GXNtsc480Int
Definition GXFrameBuf.c:49
static void GXTexCoord2u8(const u8 s, const u8 t)
Definition gx.h:135
static void GXPosition3s8(const s8 x, const s8 y, const s8 z)
Definition gx.h:157
static void GXPosition3s16(const s16 x, const s16 y, const s16 z)
Definition gx.h:173
static void GXTexCoord1x8(const u8 s)
Definition gx.h:140
static void GXColor4u8(const u8 r, const u8 g, const u8 b, const u8 a)
Definition gx.h:123
static u32 GXReadCPReg(u32 addrLo, u32 addrHi)
Definition gx.h:199
static void GXPosition1x16(const u16 x)
Definition gx.h:149
GXRenderModeObj GXNtsc480IntDf
Definition GXFrameBuf.c:4
static void GXPosition1x8(const u8 x)
Definition gx.h:153
static void GXTexCoord2f32(const f32 s, const f32 t)
Definition gx.h:130
GXRenderModeObj GXPal528IntDf
Definition GXFrameBuf.c:139
static void GXColor1u32(const u32 c)
Definition gx.h:119
static void GXTexCoord2s8(const s8 x, const s8 y)
Definition gx.h:179
static void GXPosition2s8(const s8 x, const s8 y)
Definition gx.h:163
static void GXEnd(void)
Definition gx.h:218
GXRenderModeObj GXMpal480IntDf
Definition GXFrameBuf.c:94
static void GXTexCoord2u16(const u16 x, const u16 y)
Definition gx.h:184
static void GXPosition2s16(const s16 x, const s16 y)
Definition gx.h:168
void GFFill(u16 param_1, u32 param_2)
Definition gx.h:211
GXRenderModeObj GXEurgb60Hz480IntDf
Definition GXFrameBuf.c:184
static void GXPosition2f32(const f32 x, const f32 z)
Definition gx.h:114
static void GXPosition2u16(const u16 x, const u16 y)
Definition gx.h:144
static void GXTexCoord2s16(const s16 u, const s16 v)
Definition gx.h:189
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