-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathgfxd.h
393 lines (358 loc) · 10.4 KB
/
gfxd.h
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
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
#ifndef GFXD_H
#define GFXD_H
#include <stdarg.h>
#include <stdint.h>
#ifdef __cplusplus
extern "C"
{
#endif
enum
{
gfxd_Word, /* generic word */
gfxd_Opcode, /* command opcode (G_*) */
gfxd_Coordi, /* integer coordinate */
gfxd_Coordq, /* fractional (q10.2) coordinate */
gfxd_Pal, /* palette index */
gfxd_Tlut, /* tlut pointer */
gfxd_Timg, /* texture image pointer */
gfxd_Tmem, /* tmem address */
gfxd_Tile, /* tile index */
gfxd_Fmt, /* texture format */
gfxd_Siz, /* texture pixel size */
gfxd_Dim, /* integer dimension (width / height) */
gfxd_Cm, /* clamp and mirror flags */
gfxd_Tm, /* tile mask */
gfxd_Ts, /* tile shift */
gfxd_Dxt, /* texture dxt */
gfxd_Tag, /* generic tag */
gfxd_Pm, /* pipeline mode */
gfxd_Colorpart, /* color component */
gfxd_Color, /* color */
gfxd_Lodfrac, /* lod fraction (q0.8) */
gfxd_Cimg, /* color image pointer */
gfxd_Zimg, /* depth image pointer */
gfxd_Ac, /* alpha compare mode */
gfxd_Ad, /* alpha dither mode */
gfxd_Cd, /* color dither mode */
gfxd_Ccpre, /* color combiner preset index */
gfxd_Ccmuxa, /* color mux operand (a) */
gfxd_Ccmuxb, /* color mux operand (b) */
gfxd_Ccmuxc, /* color mux operand (c) */
gfxd_Ccmuxd, /* color mux operand (d) */
gfxd_Acmuxabd, /* alpha mux operand (a, b, or d) */
gfxd_Acmuxc, /* alpha mux operand (c) */
gfxd_Cv, /* color convert operand */
gfxd_Tc, /* texture convert mode */
gfxd_Cyc, /* cycle type */
gfxd_Zs, /* depth source mode */
gfxd_Ck, /* combine key mode */
gfxd_Keyscale, /* combine key scale */
gfxd_Keywidth, /* combine key width */
gfxd_Zi, /* integer depth */
gfxd_Rm1, /* cycle 1 render mode */
gfxd_Rm2, /* cycle 2 render mode */
gfxd_Sc, /* scissor mode */
gfxd_Td, /* texture detail mode */
gfxd_Tf, /* texture filter mode */
gfxd_Tl, /* texture LOD mode */
gfxd_Tt, /* textuure LUT mode */
gfxd_Tp, /* texture perspective mode */
gfxd_Line, /* texture line size */
gfxd_Vtx, /* vertex index */
gfxd_Vtxflag, /* vertex flag */
gfxd_Dl, /* display list pointer */
gfxd_Zraw, /* raw depth value (q16.16) */
gfxd_Dlflag, /* display list flag */
gfxd_Cr, /* clip ratio */
gfxd_Num, /* element count */
gfxd_Fogz, /* fog factor */
gfxd_Fogp, /* fog position (0 - 1000) */
gfxd_Mtxptr, /* matrix pointer */
gfxd_Gm, /* geometry mode */
gfxd_Mwo_matrix, /* matrix moveword offset */
gfxd_Linewd, /* line width (1.5 + q7.1) */
gfxd_Uctext, /* microcode text pointer */
gfxd_Ucdata, /* microcode data pointer */
gfxd_Size, /* data size */
gfxd_Lookatptr, /* lookat pointer */
gfxd_Mtxparam, /* matrix param */
gfxd_Mtxstack, /* matrix param (stack select only) */
gfxd_Mwo_point, /* vertex moveword offset */
gfxd_Wscale, /* w-component scale (perspnorm) */
gfxd_Seg, /* segment number */
gfxd_Segptr, /* segment pointer */
gfxd_Lightsn, /* dereferenced LightsM (0-7 or n) pointer */
gfxd_Numlights, /* light count (NUMLIGHTS_*) */
gfxd_Lightnum, /* light number (LIGHT_*) */
gfxd_Lightptr, /* diffuse or ambient light pointer */
gfxd_Tcscale, /* texture coordinate scale */
gfxd_Switch, /* on-off value */
gfxd_St, /* vertex coordinate (q10.5) */
gfxd_Stdelta, /* vertex coordinate delta (q5.10) */
gfxd_Vtxptr, /* vertex pointer */
gfxd_Vpptr, /* viewport pointer */
gfxd_Dram, /* generic dram address */
gfxd_Sftlo, /* othermode lo shift */
gfxd_Othermodelo, /* othermode lo value */
gfxd_Sfthi, /* othermode hi shift */
gfxd_Othermodehi, /* othermode hi value */
gfxd_Mw, /* moveword index */
gfxd_Mwo, /* moveword offset */
gfxd_Mwo_clip, /* clip ratio moveword offset */
gfxd_Mwo_lightcol, /* light color moveword offset */
gfxd_Mv, /* movemem index */
gfxd_Mvo, /* movemem offset */
gfxd_Dmem, /* dmem address */
gfxd_Dmaflag, /* dma io flag */
};
enum
{
gfxd_Invalid,
gfxd_DPFillRectangle,
gfxd_DPFullSync,
gfxd_DPLoadSync,
gfxd_DPTileSync,
gfxd_DPPipeSync,
gfxd_DPLoadTLUT_pal16,
gfxd_DPLoadTLUT_pal256,
gfxd_DPLoadMultiBlockYuvS,
gfxd_DPLoadMultiBlockYuv,
gfxd_DPLoadMultiBlock_4bS,
gfxd_DPLoadMultiBlock_4b,
gfxd_DPLoadMultiBlockS,
gfxd_DPLoadMultiBlock,
gfxd__DPLoadTextureBlockYuvS,
gfxd__DPLoadTextureBlockYuv,
gfxd__DPLoadTextureBlock_4bS,
gfxd__DPLoadTextureBlock_4b,
gfxd__DPLoadTextureBlockS,
gfxd__DPLoadTextureBlock,
gfxd_DPLoadTextureBlockYuvS,
gfxd_DPLoadTextureBlockYuv,
gfxd_DPLoadTextureBlock_4bS,
gfxd_DPLoadTextureBlock_4b,
gfxd_DPLoadTextureBlockS,
gfxd_DPLoadTextureBlock,
gfxd_DPLoadMultiTileYuv,
gfxd_DPLoadMultiTile_4b,
gfxd_DPLoadMultiTile,
gfxd__DPLoadTextureTileYuv,
gfxd__DPLoadTextureTile_4b,
gfxd__DPLoadTextureTile,
gfxd_DPLoadTextureTileYuv,
gfxd_DPLoadTextureTile_4b,
gfxd_DPLoadTextureTile,
gfxd_DPLoadBlock,
gfxd_DPNoOp,
gfxd_DPNoOpTag,
gfxd_DPPipelineMode,
gfxd_DPSetBlendColor,
gfxd_DPSetEnvColor,
gfxd_DPSetFillColor,
gfxd_DPSetFogColor,
gfxd_DPSetPrimColor,
gfxd_DPSetColorImage,
gfxd_DPSetDepthImage,
gfxd_DPSetTextureImage,
gfxd_DPSetAlphaCompare,
gfxd_DPSetAlphaDither,
gfxd_DPSetColorDither,
gfxd_DPSetCombineMode,
gfxd_DPSetCombineLERP,
gfxd_DPSetConvert,
gfxd_DPSetTextureConvert,
gfxd_DPSetCycleType,
gfxd_DPSetDepthSource,
gfxd_DPSetCombineKey,
gfxd_DPSetKeyGB,
gfxd_DPSetKeyR,
gfxd_DPSetPrimDepth,
gfxd_DPSetRenderMode,
gfxd_DPSetScissor,
gfxd_DPSetScissorFrac,
gfxd_DPSetTextureDetail,
gfxd_DPSetTextureFilter,
gfxd_DPSetTextureLOD,
gfxd_DPSetTextureLUT,
gfxd_DPSetTexturePersp,
gfxd_DPSetTile,
gfxd_DPSetTileSize,
gfxd_SP1Triangle,
gfxd_SP2Triangles,
gfxd_SP1Quadrangle,
gfxd_SPBranchLessZraw,
gfxd_SPBranchList,
gfxd_SPClipRatio,
gfxd_SPCullDisplayList,
gfxd_SPDisplayList,
gfxd_SPEndDisplayList,
gfxd_SPFogFactor,
gfxd_SPFogPosition,
gfxd_SPForceMatrix,
gfxd_SPSetGeometryMode,
gfxd_SPClearGeometryMode,
gfxd_SPLoadGeometryMode,
gfxd_SPInsertMatrix,
gfxd_SPLine3D,
gfxd_SPLineW3D,
gfxd_SPLoadUcode,
gfxd_SPLookAtX,
gfxd_SPLookAtY,
gfxd_SPLookAt,
gfxd_SPMatrix,
gfxd_SPModifyVertex,
gfxd_SPPerspNormalize,
gfxd_SPPopMatrix,
gfxd_SPPopMatrixN,
gfxd_SPSegment,
gfxd_SPSetLights1,
gfxd_SPSetLights2,
gfxd_SPSetLights3,
gfxd_SPSetLights4,
gfxd_SPSetLights5,
gfxd_SPSetLights6,
gfxd_SPSetLights7,
gfxd_SPNumLights,
gfxd_SPLight,
gfxd_SPLightColor,
gfxd_SPTexture,
gfxd_SPTextureRectangle,
gfxd_SPTextureRectangleFlip,
gfxd_SPVertex,
gfxd_SPViewport,
gfxd_DPLoadTLUTCmd,
gfxd_DPLoadTLUT,
gfxd_BranchZ,
gfxd_DisplayList,
gfxd_DPHalf1,
gfxd_DPHalf2,
gfxd_DPWord,
gfxd_DPLoadTile,
gfxd_SPGeometryMode,
gfxd_SPSetOtherMode,
gfxd_SPSetOtherModeLo,
gfxd_SPSetOtherModeHi,
gfxd_DPSetOtherMode,
gfxd_MoveWd,
gfxd_MoveMem,
gfxd_SPDma_io,
gfxd_SPDmaRead,
gfxd_SPDmaWrite,
gfxd_LoadUcode,
gfxd_SPLoadUcodeEx,
gfxd_TexRect,
gfxd_TexRectFlip,
gfxd_SPNoOp,
gfxd_Special3,
gfxd_Special2,
gfxd_Special1,
};
enum
{
gfxd_stop_on_invalid,
gfxd_stop_on_end,
gfxd_emit_dec_color,
gfxd_emit_q_macro,
gfxd_emit_ext_macro,
};
enum
{
gfxd_endian_big,
gfxd_endian_little,
gfxd_endian_host,
};
enum
{
gfxd_argfmt_i,
gfxd_argfmt_u,
gfxd_argfmt_f,
};
typedef union
{
int32_t i;
uint32_t u;
float f;
} gfxd_value_t;
typedef const struct gfxd_ucode *gfxd_ucode_t;
typedef int gfxd_input_fn_t(void *buf, int count);
void gfxd_input_buffer(const void *buf, int size);
void gfxd_input_fd(int fd);
void gfxd_input_callback(gfxd_input_fn_t *fn);
typedef int gfxd_output_fn_t(const char *buf, int count);
void gfxd_output_buffer(char *buf, int size);
void gfxd_output_fd(int fd);
void gfxd_output_callback(gfxd_output_fn_t *fn);
typedef int gfxd_macro_fn_t(void);
void gfxd_macro_fn(gfxd_macro_fn_t *fn);
gfxd_macro_fn_t gfxd_macro_dflt;
typedef void gfxd_arg_fn_t(int arg_num);
void gfxd_arg_fn(gfxd_arg_fn_t *fn);
gfxd_arg_fn_t gfxd_arg_dflt;
typedef int gfxd_tlut_fn_t(uint32_t tlut, int32_t idx, int32_t count);
void gfxd_tlut_callback(gfxd_tlut_fn_t *fn);
typedef int gfxd_timg_fn_t(uint32_t timg, int32_t fmt, int32_t siz,
int32_t width, int32_t height, int32_t pal);
void gfxd_timg_callback(gfxd_timg_fn_t *fn);
typedef int gfxd_cimg_fn_t(uint32_t cimg, int32_t fmt, int32_t siz,
int32_t width);
void gfxd_cimg_callback(gfxd_cimg_fn_t *fn);
typedef int gfxd_zimg_fn_t(uint32_t zimg);
void gfxd_zimg_callback(gfxd_zimg_fn_t *fn);
typedef int gfxd_dl_fn_t(uint32_t dl);
void gfxd_dl_callback(gfxd_dl_fn_t *fn);
typedef int gfxd_mtx_fn_t(uint32_t mtx);
void gfxd_mtx_callback(gfxd_mtx_fn_t *fn);
typedef int gfxd_lookat_fn_t(uint32_t lookat, int32_t count);
void gfxd_lookat_callback(gfxd_lookat_fn_t *fn);
typedef int gfxd_light_fn_t(uint32_t light);
void gfxd_light_callback(gfxd_light_fn_t *fn);
typedef int gfxd_lightsn_fn_t(uint32_t lightsn, int32_t count);
void gfxd_lightsn_callback(gfxd_lightsn_fn_t *fn);
typedef int gfxd_seg_fn_t(uint32_t seg, int32_t num);
void gfxd_seg_callback(gfxd_seg_fn_t *fn);
typedef int gfxd_vtx_fn_t(uint32_t vtx, int32_t num);
void gfxd_vtx_callback(gfxd_vtx_fn_t *fn);
typedef int gfxd_vp_fn_t(uint32_t vp);
void gfxd_vp_callback(gfxd_vp_fn_t *fn);
typedef int gfxd_uctext_fn_t(uint32_t text, uint32_t size);
void gfxd_uctext_callback(gfxd_uctext_fn_t *fn);
typedef int gfxd_ucdata_fn_t(uint32_t data, uint32_t size);
void gfxd_ucdata_callback(gfxd_ucdata_fn_t *fn);
typedef int gfxd_dram_fn_t(uint32_t dram, uint32_t size);
void gfxd_dram_callback(gfxd_dram_fn_t *fn);
int gfxd_write(const void *buf, int count);
int gfxd_puts(const char *str);
int gfxd_vprintf(const char *fmt, va_list arg);
int gfxd_printf(const char *fmt, ...);
int gfxd_print_value(int type, const gfxd_value_t *value);
void gfxd_target(gfxd_ucode_t ucode);
void gfxd_endian(int endian, int wordsize);
void gfxd_dynamic(const char *arg);
void gfxd_enable(int cap);
void gfxd_disable(int cap);
void gfxd_udata_set(void *ptr);
void *gfxd_udata_get(void);
int gfxd_execute(void);
int gfxd_macro_offset(void);
int gfxd_macro_packets(void);
int gfxd_foreach_pkt(int (*fn)(void));
const void *gfxd_macro_data(void);
int gfxd_macro_id(void);
const char *gfxd_macro_name(void);
int gfxd_arg_count(void);
int gfxd_arg_type(int arg_num);
const char *gfxd_arg_name(int arg_num);
int gfxd_arg_fmt(int arg_num);
const gfxd_value_t *gfxd_arg_value(int arg_num);
const gfxd_value_t *gfxd_value_by_type(int type, int idx);
int gfxd_arg_valid(int arg_num);
int gfxd_arg_callbacks(int arg_num);
extern const gfxd_ucode_t gfxd_f3d;
extern const gfxd_ucode_t gfxd_f3db;
extern const gfxd_ucode_t gfxd_f3dex;
extern const gfxd_ucode_t gfxd_f3dexb;
extern const gfxd_ucode_t gfxd_f3dex2;
#ifdef __cplusplus
}
#endif
#endif