Twilight Princess
Decompilation of The Legend of Zelda: Twilight Princess
Loading...
Searching...
No Matches
GXInit.h
Go to the documentation of this file.
1#ifndef GXINIT_H
2#define GXINIT_H
3
5
6typedef struct _GXData {
7 // Bypass and vertex info
8 u16 vNumNot; // _000, !(# flush verts to send)
9 u16 bpSentNot; // _002, !(bypass reg sent last?)
10 u16 vNum; // _004, # flush verts to send
11 u16 vLim; // _006, max vert size
12
13 // Command process (CP) regs
14 u32 cpEnable; // _008
15 u32 cpStatus; // _00C
16 u32 cpClr; // _010
17 u32 vcdLo; // _014
18 u32 vcdHi; // _018
19 u32 vatA[8]; // _01C
20 u32 vatB[8]; // _03C
21 u32 vatC[8]; // _05C
22 u32 lpSize; // _07C
23 u32 matIdxA; // _080
24 u32 matIdxB; // _084
25
26 // Index loading base/stride regs (pos, nrm, tex, light)
27 u32 indexBase[4]; // _088
28 u32 indexStride[4]; // _098
29
30 // Transform and lighting regs
31 u32 ambColor[2]; // _0A8
32 u32 matColor[2]; // _0B0
33
34 // Setup regs
35 u32 suTs0[8]; // _0B8
36 u32 suTs1[8]; // _0D8
37 u32 suScis0; // _0F8
38 u32 suScis1; // _0FC
39
40 // Raster regs
41 u32 tref[8]; // _100
42 u32 iref; // _120
43
44 // Bump/Indirect texture regs
45 u32 bpMask; // _124
48
49 // Tev regs
50 u32 tevc[16]; // _130
51 u32 teva[16]; // _170
52 u32 tevKsel[8]; // _1B0
53
54 // Performance regs
55 u32 cmode0; // _1D0
56 u32 cmode1; // _1D4
57 u32 zmode; // _1D8
58 u32 peCtrl; // _1DC
59
60 // Display copy regs
61 u32 cpDispSrc; // _1E0
62 u32 cpDispSize; // _1E4
64 u32 cpDisp; // _1EC
65
66 // Texture copy regs
67 u32 cpTexSrc; // _1F0
68 u32 cpTexSize; // _1F4
70 u32 cpTex; // _1FC
71 GXBool cpTexZ; // _200
72
73 // General raster mode
74 u32 genMode; // _204
75
76 // Texture regions
80
81 // Texture lookup table regions
85
86 // Command processor vars
88 GXBool hasNrms; // _4D4
90 u32 projType; // _4D8
91 f32 projMtx[6]; // _4DC
92
93 // Viewport parms
94 f32 vpLeft; // _4F4
95 f32 vpTop; // _4F8
96 f32 vpWd; // _4FC
97 f32 vpHt; // _500
98 f32 vpNearz; // _504
99 f32 vpFarz; // _508
100 f32 zOffset; // _50C
101 f32 zScale; // _510
102
103 // Texture regs
104 u32 tImage0[8]; // _514
105 u32 tMode0[8]; // _534
106 u32 texmapId[16]; // _554
108 u32 tevTcEnab; // _598
109
110 // Performance metrics
111 GXPerf0 perf0; // _59C
112 GXPerf1 perf1; // _5A0
113 u32 perfSel; // _5A4
114
115 // Flags
119 u8 dirtyVAT; // _5AB
121} GXData; // Size: 0x5B0
122
123STATIC_ASSERT(sizeof(GXData) == 0x5B0);
124
125extern GXData* const __GXData;
126
127// Define register addresses.
128#define GX_CP_ADDR (0x0C000000)
129#define GX_PE_ADDR (0x0C001000)
130#define GX_PI_ADDR (0x0C003000)
131#define GX_MEM_ADDR (0x0C004000)
132
133extern u32* __piReg;
134extern u16* __cpReg;
135extern u16* __peReg;
136extern vu16* __memReg;
137
138#define GX_GET_MEM_REG(offset) (*(vu16*)((vu16*)(__memReg) + (offset)))
139#define GX_GET_CP_REG(offset) (*(vu16*)((vu16*)(__cpReg) + (offset)))
140#define GX_GET_PE_REG(offset) (*(vu16*)((vu16*)(__peReg) + (offset)))
141#define GX_GET_PI_REG(offset) (*(vu32*)((vu32*)(__piReg) + (offset)))
142
143#define GX_SET_MEM_REG(offset, val) (*(vu16*)((vu16*)(__memReg) + (offset)) = val)
144#define GX_SET_CP_REG(offset, val) (*(vu16*)((vu16*)(__cpReg) + (offset)) = val)
145#define GX_SET_PE_REG(offset, val) (*(vu16*)((vu16*)(__peReg) + (offset)) = val)
146#define GX_SET_PI_REG(offset, val) (*(vu32*)((vu32*)(__piReg) + (offset)) = val)
147
148inline void GXSetWasteFlags() {
151 data->bpSentNot = 0;
152}
153
154static inline void set_x2(u16 value)
155{
156 __GXData->bpSentNot = value;
157}
158
159#ifdef __cplusplus
160extern "C" {
161#endif
162
164{
167 do {
168 hiNew = hiStart;
171 } while (hiStart != hiNew);
172
173 return ((hiStart << 16) | lo);
174}
175
179void __GXInitRevisionBits(void);
180GXFifoObj* GXInit(void* base, u32 size);
181void __GXInitGX(void);
182
183#ifdef __cplusplus
184};
185#endif
186
187#endif /* GXINIT_H */
enum _GXTexMapID GXTexMapID
@ GX_MAX_TLUT_ALL
Definition GXEnum.h:427
enum _GXPerf0 GXPerf0
enum _GXPerf1 GXPerf1
@ GX_DIRTY_BP_MASK
Definition GXEnum.h:835
@ GX_DIRTY_SU_TEX
Definition GXEnum.h:834
@ GX_MAX_TEXMAP
Definition GXEnum.h:39
u8 GXBool
Definition GXEnum.h:23
enum _GXAttrType GXAttrType
vu16 * __memReg
Definition GXInit.c:67
GXFifoObj * GXInit(void *base, u32 size)
Definition GXInit.c:224
GXTlutRegion * __GXDefaultTlutRegionCallback(u32 tlut)
Definition GXInit.c:46
GXTexRegion * __GXDefaultTexRegionCallback(const GXTexObj *obj, GXTexMapID mapID)
Definition GXInit.c:17
u16 * __peReg
Definition GXInit.c:70
void GXSetWasteFlags()
Definition GXInit.h:148
void __GXInitRevisionBits(void)
Definition GXInit.c:134
u16 * __cpReg
Definition GXInit.c:73
struct _GXData GXData
void __GXInitGX(void)
Definition GXInit.c:374
BOOL __GXShutdown(BOOL)
Definition GXInit.c:80
static u32 GXReadMEMReg(u32 addrLo, u32 addrHi)
Definition GXInit.h:163
static void set_x2(u16 value)
Definition GXInit.h:154
STATIC_ASSERT(sizeof(GXData)==0x5B0)
GXData *const __GXData
Definition GXInit.c:14
u32 * __piReg
Definition GXInit.c:77
GXTlutRegion *(* GXTlutRegionCallback)(u32 idx)
Definition GXTexture.h:11
GXTexRegion *(* GXTexRegionCallback)(const GXTexObj *t_obj, GXTexMapID id)
Definition GXTexture.h:10
T cLib_calcTimer(T *value)
Definition c_lib.h:74
static u16 data[4]
Definition d_vibration.cpp:114
Definition GXInit.h:6
u32 cpDispSrc
Definition GXInit.h:61
f32 vpHt
Definition GXInit.h:97
u32 matColor[2]
Definition GXInit.h:32
u32 dirtyState
Definition GXInit.h:120
u32 iref
Definition GXInit.h:42
u32 cpDispSize
Definition GXInit.h:62
GXPerf1 perf1
Definition GXInit.h:112
f32 vpNearz
Definition GXInit.h:98
u32 cpEnable
Definition GXInit.h:14
u32 cpTexStride
Definition GXInit.h:69
u32 cpTexSrc
Definition GXInit.h:67
f32 vpTop
Definition GXInit.h:95
f32 vpFarz
Definition GXInit.h:99
u32 tMode0[8]
Definition GXInit.h:105
u32 projType
Definition GXInit.h:90
u32 tcsManEnab
Definition GXInit.h:107
u32 indexStride[4]
Definition GXInit.h:28
u32 cmode0
Definition GXInit.h:55
u32 cpDispStride
Definition GXInit.h:63
u32 suScis1
Definition GXInit.h:38
f32 vpLeft
Definition GXInit.h:94
GXAttrType nrmType
Definition GXInit.h:87
u32 tImage0[8]
Definition GXInit.h:104
GXTexRegion TexRegions2[GX_MAX_TEXMAP]
Definition GXInit.h:79
u32 tevKsel[8]
Definition GXInit.h:52
u32 cpTexSize
Definition GXInit.h:68
f32 zScale
Definition GXInit.h:101
GXTlutRegionCallback tlutRegionCallback
Definition GXInit.h:84
u32 ambColor[2]
Definition GXInit.h:31
u32 perfSel
Definition GXInit.h:113
GXTexRegion TexRegions1[GX_MAX_TEXMAP]
Definition GXInit.h:78
u32 cmode1
Definition GXInit.h:56
u32 vatA[8]
Definition GXInit.h:19
f32 vpWd
Definition GXInit.h:96
u32 vcdLo
Definition GXInit.h:17
u32 tref[8]
Definition GXInit.h:41
u16 vNum
Definition GXInit.h:10
u32 vatB[8]
Definition GXInit.h:20
GXTexRegionCallback texRegionCallback
Definition GXInit.h:83
u32 IndTexScale1
Definition GXInit.h:47
GXBool hasBiNrms
Definition GXInit.h:89
u32 cpTex
Definition GXInit.h:70
u32 zmode
Definition GXInit.h:57
u32 suScis0
Definition GXInit.h:37
u32 suTs1[8]
Definition GXInit.h:36
u32 cpStatus
Definition GXInit.h:15
u16 vLim
Definition GXInit.h:11
u32 tevc[16]
Definition GXInit.h:50
GXBool dlSaveContext
Definition GXInit.h:117
u32 matIdxB
Definition GXInit.h:24
u32 peCtrl
Definition GXInit.h:58
u32 cpDisp
Definition GXInit.h:64
u32 tevTcEnab
Definition GXInit.h:108
GXBool abtWaitPECopy
Definition GXInit.h:118
u32 vcdHi
Definition GXInit.h:18
u32 cpClr
Definition GXInit.h:16
GXBool cpTexZ
Definition GXInit.h:71
u32 teva[16]
Definition GXInit.h:51
u32 bpMask
Definition GXInit.h:45
u32 genMode
Definition GXInit.h:74
u32 vatC[8]
Definition GXInit.h:21
GXBool inDispList
Definition GXInit.h:116
GXBool hasNrms
Definition GXInit.h:88
u32 lpSize
Definition GXInit.h:22
u32 IndTexScale0
Definition GXInit.h:46
f32 zOffset
Definition GXInit.h:100
u16 bpSentNot
Definition GXInit.h:9
GXTlutRegion TlutRegions[GX_MAX_TLUT_ALL]
Definition GXInit.h:82
f32 projMtx[6]
Definition GXInit.h:91
GXTexRegion TexRegions0[GX_MAX_TEXMAP]
Definition GXInit.h:77
u16 vNumNot
Definition GXInit.h:8
u8 dirtyVAT
Definition GXInit.h:119
u32 indexBase[4]
Definition GXInit.h:27
u32 suTs0[8]
Definition GXInit.h:35
u32 texmapId[16]
Definition GXInit.h:106
GXPerf0 perf0
Definition GXInit.h:111
u32 matIdxA
Definition GXInit.h:23
Definition GXStruct.h:80
Definition d_a_ep.cpp:147
Definition GXStruct.h:95
Definition GXStruct.h:103
int BOOL
Definition types.h:27
unsigned long u32
Definition types.h:10
float f32
Definition types.h:22
volatile u16 vu16
Definition types.h:14
unsigned short u16
Definition types.h:9
unsigned char u8
Definition types.h:8