1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
|
#ifndef __GXVERT_H__
#define __GXVERT_H__
#ifdef WIN32
#include <win32/win32.h>
#endif
// NOTE: This file closely mirrors GXVert.c.
// Don't change this file without considering that one too,
// and vice-versa.
/********************************/
#ifdef __cplusplus
extern "C" {
#endif
/*>*******************************(*)*******************************<*/
#ifndef EMU // real hardware
/*---------------------------------------------*
* Write gather pipe for GFXFifo *
*---------------------------------------------*/
#ifndef MINNOW
#define GXFIFO_ADDR 0xCC008000
#else // MINNOW
#define GXFIFO_ADDR 0x1C008000
#endif// MINNOW
typedef union uPPCWGPipe
{
u8 u8;
u16 u16;
u32 u32;
u64 u64;
s8 s8;
s16 s16;
s32 s32;
s64 s64;
f32 f32;
f64 f64;
} PPCWGPipe;
// SN-Phil: removed 'extern', added AT_ADDRESS
volatile PPCWGPipe GXWGFifo : (GXFIFO_ADDR) ;
//extern volatile PPCWGPipe GXWGFifo;
#endif // !EMU
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/*---------------------------------------------*
* GXVertex functions *
*---------------------------------------------*/
//-------------------------------
// Define gfx function templates
//-------------------------------
//
// Templates syntax:
// __GXCDEF (function_prefix, num_of_components, component_type)
// __GXCDEFX(function_name, num_of_comps, src_comp_type, dest_comp_type)
//
#define __GXCDEF(prfx,n,t) __GXCDEF##n(prfx##n##t,t,t)
#define __GXCDEFX(func,n,t) __GXCDEF##n(func,t,t)
#ifdef _DEBUG
// 1 component
#define __GXCDEF1(func,ts,td) \
void func(const ts x);
// 2 components
#define __GXCDEF2(func,ts,td) \
void func(const ts x, const ts y);
// 3 components
#define __GXCDEF3(func,ts,td) \
void func(const ts x, const ts y, const ts z);
// 4 components
#define __GXCDEF4(func,ts,td) \
void func(const ts x, const ts y, const ts z, const ts w);
#else // ifdef _DEBUG
/*---------------------------------------------*
* For real hardware *
*---------------------------------------------*/
#ifndef EMU
// 1 component
#define __GXCDEF1(func,ts,td) \
static inline void func(const ts x) \
{ \
GXWGFifo.td = (td) x; \
return; \
}
// 2 components
#define __GXCDEF2(func,ts,td) \
static inline void func(const ts x, const ts y) \
{ \
GXWGFifo.td = (td) x; \
GXWGFifo.td = (td) y; \
return; \
}
// 3 components
#define __GXCDEF3(func,ts,td) \
static inline void func(const ts x, const ts y, const ts z) \
{ \
GXWGFifo.td = (td) x; \
GXWGFifo.td = (td) y; \
GXWGFifo.td = (td) z; \
return; \
}
// 4 components
#define __GXCDEF4(func,ts,td) \
static inline void func(const ts x, const ts y, const ts z, const ts w) \
{ \
GXWGFifo.td = (td) x; \
GXWGFifo.td = (td) y; \
GXWGFifo.td = (td) z; \
GXWGFifo.td = (td) w; \
return; \
}
#endif // ifndef EMU
#endif // ifdef _DEBUG else
//---------------------------
// Generate inline functions
//---------------------------
//---- GXCmd[n][t] ----
__GXCDEF( GXCmd, 1, u8 )
__GXCDEF( GXCmd, 1, u16 )
__GXCDEF( GXCmd, 1, u32 )
//---- GXParam[n][t] ----
__GXCDEF( GXParam, 1, u8 )
__GXCDEF( GXParam, 1, u16 )
__GXCDEF( GXParam, 1, u32 )
__GXCDEF( GXParam, 1, s8 )
__GXCDEF( GXParam, 1, s16 )
__GXCDEF( GXParam, 1, s32 )
__GXCDEF( GXParam, 1, f32 )
__GXCDEF( GXParam, 3, f32 ) // for light
__GXCDEF( GXParam, 4, f32 ) // for matrix
//---- GXPosition[n][t] ----
// for GX_POS_XYZ
__GXCDEF( GXPosition, 3, f32 )
__GXCDEF( GXPosition, 3, u8 )
__GXCDEF( GXPosition, 3, s8 )
__GXCDEF( GXPosition, 3, u16 )
__GXCDEF( GXPosition, 3, s16 )
// for GX_POS_XY
__GXCDEF( GXPosition, 2, f32 )
__GXCDEF( GXPosition, 2, u8 )
__GXCDEF( GXPosition, 2, s8 )
__GXCDEF( GXPosition, 2, u16 )
__GXCDEF( GXPosition, 2, s16 )
// for Index
__GXCDEFX( GXPosition1x16, 1, u16 )
__GXCDEFX( GXPosition1x8, 1, u8 )
//---- GXNormal[n][t] ----
// for GX_NRM or GX_NBT
__GXCDEF( GXNormal, 3, f32 )
__GXCDEF( GXNormal, 3, s16 )
__GXCDEF( GXNormal, 3, s8 )
// for Index
__GXCDEFX( GXNormal1x16, 1, u16 )
__GXCDEFX( GXNormal1x8, 1, u8 )
//---- GXColor[n][t] ----
// for GX_CLR_RGBA8 or RGBX8
__GXCDEF( GXColor, 4, u8 )
__GXCDEF( GXColor, 1, u32 )
// for GX_CLR_RGBA6 or RGB8
__GXCDEF( GXColor, 3, u8 )
// for GX_CLR_RGBA4 or RGB565
__GXCDEF( GXColor, 1, u16 )
// for Index
__GXCDEFX( GXColor1x16, 1, u16 )
__GXCDEFX( GXColor1x8, 1, u8 )
//---- GXTexCoord[n][t] ----
// for GX_TEX_ST
__GXCDEF( GXTexCoord, 2, f32 )
__GXCDEF( GXTexCoord, 2, s16 )
__GXCDEF( GXTexCoord, 2, u16 )
__GXCDEF( GXTexCoord, 2, s8 )
__GXCDEF( GXTexCoord, 2, u8 )
// for GX_TEX_S
__GXCDEF( GXTexCoord, 1, f32 )
__GXCDEF( GXTexCoord, 1, s16 )
__GXCDEF( GXTexCoord, 1, u16 )
__GXCDEF( GXTexCoord, 1, s8 )
__GXCDEF( GXTexCoord, 1, u8 )
// for Index
__GXCDEFX( GXTexCoord1x16, 1, u16 )
__GXCDEFX( GXTexCoord1x8, 1, u8 )
//---- GXMatrixIndex* ----
// GXMatrixIndex1u8
__GXCDEF( GXMatrixIndex, 1, u8 )
#define GXMatrixIndex1x8 GXMatrixIndex1u8
//------------------------
// Undefine all templates
//------------------------
#undef __GXCDEF
#undef __GXCDEFX
#undef __GXCDEF1
#undef __GXCDEF2
#undef __GXCDEF3
#undef __GXCDEF4
/*---------------------------------------------------------------------------*/
// Packing macro for a several color format
#define GXPackedRGB565(r,g,b) \
((u16)((((r)&0xf8)<<8)|(((g)&0xfc)<<3)|(((b)&0xf8)>>3)))
#define GXPackedRGBA4(r,g,b,a) \
((u16)((((r)&0xf0)<<8)|(((g)&0xf0)<<4)|(((b)&0xf0) )|(((a)&0xf0)>>4)))
#define GXPackedRGB5A3(r,g,b,a) \
((u16)((a)>=224 ? \
((((r)&0xf8)<<7)|(((g)&0xf8)<<2)|(((b)&0xf8)>>3)|(1<<15)): \
((((r)&0xf0)<<4)|(((g)&0xf0) )|(((b)&0xf0)>>4)|(((a)&0xe0)<<7))))
#ifdef __cplusplus
}
#endif
#endif // __GXVERT_H__
|