SSBM Decomp
Loading...
Searching...
No Matches
tobj.h
Go to the documentation of this file.
1#ifndef _hsd_tobj_h_
2#define _hsd_tobj_h_
3
4#include <platform.h>
5
6#include "baselib/class.h"
7
8#include "baselib/forward.h" // IWYU pragma: export
9
10#include "baselib/object.h"
11
12#include <dolphin/gx.h>
13#include <dolphin/gx/GXEnum.h>
14#include <dolphin/mtx.h>
15
16struct HSD_TObj;
17
18#define TOBJ_ANIM 0x10
19
20#define HSD_A_T_TIMG 1
21#define HSD_A_T_TRAU 2
22#define HSD_A_T_TRAV 3
23#define HSD_A_T_SCAU 4
24#define HSD_A_T_SCAV 5
25#define HSD_A_T_ROTX 6
26#define HSD_A_T_ROTY 7
27#define HSD_A_T_ROTZ 8
28#define HSD_A_T_BLEND 9
29#define HSD_A_T_TCLT 10
30#define HSD_A_T_LOD_BIAS 11
31#define HSD_A_T_KONST_R 12
32#define HSD_A_T_KONST_G 13
33#define HSD_A_T_KONST_B 14
34#define HSD_A_T_KONST_A 15
35#define HSD_A_T_TEV0_R 16
36#define HSD_A_T_TEV0_G 17
37#define HSD_A_T_TEV0_B 18
38#define HSD_A_T_TEV0_A 19
39#define HSD_A_T_TEV1_R 20
40#define HSD_A_T_TEV1_G 21
41#define HSD_A_T_TEV1_B 22
42#define HSD_A_T_TEV1_A 23
43#define HSD_A_T_TS_BLEND 24
44
45#define TOBJ_TEV_CC_KONST_RGB (0x01 << 7 | 0)
46#define TOBJ_TEV_CC_KONST_RRR (0x01 << 7 | 1)
47#define TOBJ_TEV_CC_KONST_GGG (0x01 << 7 | 2)
48#define TOBJ_TEV_CC_KONST_BBB (0x01 << 7 | 3)
49#define TOBJ_TEV_CC_KONST_AAA (0x01 << 7 | 4)
50#define TOBJ_TEV_CC_TEX0_RGB (0x01 << 7 | 5)
51#define TOBJ_TEV_CC_TEX0_AAA (0x01 << 7 | 6)
52#define TOBJ_TEV_CC_TEX1_RGB (0x01 << 7 | 7)
53#define TOBJ_TEV_CC_TEX1_AAA (0x01 << 7 | 8)
54
55#define TOBJ_TEV_CA_KONST_R (0x01 << 6 | 0)
56#define TOBJ_TEV_CA_KONST_G (0x01 << 6 | 1)
57#define TOBJ_TEV_CA_KONST_B (0x01 << 6 | 2)
58#define TOBJ_TEV_CA_KONST_A (0x01 << 6 | 3)
59#define TOBJ_TEV_CA_TEX0_A (0x01 << 6 | 4)
60#define TOBJ_TEV_CA_TEX1_A (0x01 << 6 | 5)
61
62#define TOBJ_TEVREG_ACTIVE_KONST_R (0x01 << 0)
63#define TOBJ_TEVREG_ACTIVE_KONST_G (0x01 << 1)
64#define TOBJ_TEVREG_ACTIVE_KONST_B (0x01 << 2)
65#define TOBJ_TEVREG_ACTIVE_KONST_A (0x01 << 3)
66#define TOBJ_TEVREG_ACTIVE_KONST \
67 (TOBJ_TEVREG_ACTIVE_KONST_R | TOBJ_TEVREG_ACTIVE_KONST_G | \
68 TOBJ_TEVREG_ACTIVE_KONST_B | TOBJ_TEVREG_ACTIVE_KONST_A)
69#define TOBJ_TEVREG_ACTIVE_TEV0_R (0x01 << 4)
70#define TOBJ_TEVREG_ACTIVE_TEV0_G (0x01 << 5)
71#define TOBJ_TEVREG_ACTIVE_TEV0_B (0x01 << 6)
72#define TOBJ_TEVREG_ACTIVE_TEV0_A (0x01 << 7)
73#define TOBJ_TEVREG_ACTIVE_TEV0 \
74 (TOBJ_TEVREG_ACTIVE_TEV0_R | TOBJ_TEVREG_ACTIVE_TEV0_G | \
75 TOBJ_TEVREG_ACTIVE_TEV0_B | TOBJ_TEVREG_ACTIVE_TEV0_A)
76#define TOBJ_TEVREG_ACTIVE_TEV1_R (0x01 << 8)
77#define TOBJ_TEVREG_ACTIVE_TEV1_G (0x01 << 9)
78#define TOBJ_TEVREG_ACTIVE_TEV1_B (0x01 << 10)
79#define TOBJ_TEVREG_ACTIVE_TEV1_A (0x01 << 11)
80#define TOBJ_TEVREG_ACTIVE_TEV1 \
81 (TOBJ_TEVREG_ACTIVE_TEV1_R | TOBJ_TEVREG_ACTIVE_TEV1_G | \
82 TOBJ_TEVREG_ACTIVE_TEV1_B | TOBJ_TEVREG_ACTIVE_TEV1_A)
83#define TOBJ_TEVREG_ACTIVE_COLOR_TEV (0x01 << 30)
84#define TOBJ_TEVREG_ACTIVE_ALPHA_TEV (0x01U << 31)
85
86#define TEX_COORD_UV 0
87#define TEX_COORD_REFLECTION 1
88#define TEX_COORD_HILIGHT 2
89#define TEX_COORD_SHADOW 3
90#define TEX_COORD_TOON 4
91#define TEX_COORD_GRADATION 5
92#define TEX_COORD_BACKLIGHT 6
93#define TEX_COORD_MASK (0x0f)
94#define tobj_coord(T) ((T)->flags & TEX_COORD_MASK)
95
96#define TEX_COLORMAP_NONE (0 << 16)
97#define TEX_COLORMAP_ALPHA_MASK (1 << 16)
98#define TEX_COLORMAP_RGB_MASK (2 << 16)
99#define TEX_COLORMAP_BLEND (3 << 16)
100#define TEX_COLORMAP_MODULATE (4 << 16)
101#define TEX_COLORMAP_REPLACE (5 << 16)
102#define TEX_COLORMAP_PASS (6 << 16)
103#define TEX_COLORMAP_ADD (7 << 16)
104#define TEX_COLORMAP_SUB (8 << 16)
105#define TEX_COLORMAP_MASK (0x0f << 16)
106#define tobj_colormap(T) ((T)->flags & TEX_COLORMAP_MASK)
107
108#define TEX_ALPHAMAP_NONE (0 << 20)
109#define TEX_ALPHAMAP_ALPHA_MASK (1 << 20)
110#define TEX_ALPHAMAP_BLEND (2 << 20)
111#define TEX_ALPHAMAP_MODULATE (3 << 20)
112#define TEX_ALPHAMAP_REPLACE (4 << 20)
113#define TEX_ALPHAMAP_PASS (5 << 20)
114#define TEX_ALPHAMAP_ADD (6 << 20)
115#define TEX_ALPHAMAP_SUB (7 << 20)
116#define TEX_ALPHAMAP_MASK (0x0f << 20)
117#define tobj_alphamap(T) ((T)->flags & TEX_ALPHAMAP_MASK)
118
119#define TEX_LIGHTMAP_DIFFUSE (0x1 << 4)
120#define TEX_LIGHTMAP_SPECULAR (0x1 << 5)
121#define TEX_LIGHTMAP_AMBIENT (0x1 << 6)
122#define TEX_LIGHTMAP_EXT (0x1 << 7)
123#define TEX_LIGHTMAP_SHADOW (0x1 << 8)
124#define TEX_LIGHTMAP_MASK \
125 (TEX_LIGHTMAP_DIFFUSE | TEX_LIGHTMAP_SPECULAR | TEX_LIGHTMAP_AMBIENT | \
126 TEX_LIGHTMAP_EXT | TEX_LIGHTMAP_SHADOW)
127#define tobj_lightmap(T) ((T)->flags & TEX_LIGHTMAP_MASK)
128
129#define TEX_BUMP (0x1 << 24)
130#define tobj_bump(T) ((T)->flags & TEX_BUMP)
131#define TEX_MTX_DIRTY (1U << 31)
132
133// Texture Object
134struct HSD_TObj {
137 GXTexMapID id;
138 GXTexGenSrc src;
139 u32 mtxid;
140 Quaternion rotate;
141 Vec3 scale;
143 GXTexWrapMode wrap_s;
144 GXTexWrapMode wrap_t;
147 u32 flags;
149 GXTexFilter magFilt;
151 struct _HSD_Tlut* tlut;
152 struct _HSD_TexLODDesc* lod;
155 struct _HSD_Tlut** tluttbl;
157 Mtx mtx;
158 GXTexCoordID coord;
159 struct _HSD_TObjTev* tev;
160};
161
162typedef struct _HSD_TObjDesc {
164 struct _HSD_TObjDesc* next;
165 GXTexMapID id;
166 GXTexGenSrc src;
167 Vec3 rotate;
168 Vec3 scale;
170 GXTexWrapMode wrap_s;
171 GXTexWrapMode wrap_t;
176 GXTexFilter magFilt;
178 struct _HSD_TlutDesc* tlutdesc;
179 struct _HSD_TexLODDesc* lod;
180 struct _HSD_TObjTevDesc* tev;
182
183typedef struct _HSD_Tlut {
184 void* lut;
185 GXTlutFmt fmt;
188} HSD_Tlut;
189
190typedef struct _HSD_TlutDesc {
191 void* lut;
192 GXTlutFmt fmt;
196
197typedef struct _HSD_TexLODDesc {
198 GXTexFilter minFilt;
202 GXAnisotropy max_anisotropy;
204
207 u16 width;
209 GXTexFmt format;
213};
214
215typedef struct _HSD_TObjTev {
224 u8 color_a, color_b, color_c, color_d;
225 u8 alpha_a, alpha_b, alpha_c, alpha_d;
226 GXColor konst, tev0, tev1;
229
230typedef struct _HSD_TObjTevDesc {
239 u8 color_a, color_b, color_c, color_d;
240 u8 alpha_a, alpha_b, alpha_c, alpha_d;
241 GXColor konst, tev0, tev1;
244
245typedef struct _HSD_TObjInfo {
247 void (*make_mtx)(HSD_TObj* tobj);
248 int (*load)(HSD_TObj* tobj, HSD_TObjDesc* desc);
249 void (*make_texp)(HSD_TObj* tobj, u32 lightmap, u32 lightmap_done,
250 HSD_TExp** c, HSD_TExp** a, HSD_TExp** list);
252
253typedef struct _HSD_TexAnim {
254 struct _HSD_TexAnim* next;
255 GXTexMapID id;
258 struct _HSD_TlutDesc** tluttbl;
262
263extern HSD_TObjInfo hsdTObj;
264
265#define HSD_TOBJ(o) ((HSD_TObj*) (o))
266#define HSD_TOBJ_INFO(i) ((HSD_TObjInfo*) (i))
267#define HSD_TOBJ_METHOD(o) HSD_TOBJ_INFO(HSD_OBJECT_METHOD(o))
268
270void HSD_TObjAddAnim(HSD_TObj* tobj, HSD_TexAnim* texanim);
271void HSD_TObjAddAnimAll(HSD_TObj* tobj, HSD_TexAnim* texanim);
272void HSD_TObjReqAnimAllByFlags(HSD_TObj* tobj, f32 startframe, u32 flags);
273void HSD_TObjReqAnim(HSD_TObj* tobj, f32 startframe);
274void HSD_TObjReqAnimAll(HSD_TObj* tobj, f32 startframe);
275void HSD_TObjAnim(HSD_TObj* tobj);
276void HSD_TObjAnimAll(HSD_TObj* tobj);
277
281HSD_TObj* _HSD_TObjGetCurrentByType(HSD_TObj* from, u32 mapping);
282
283void HSD_TObjRemove(HSD_TObj* tobj);
284void HSD_TObjRemoveAll(HSD_TObj* tobj);
287void HSD_TObjFree(HSD_TObj* tobj);
291void HSD_TlutFree(HSD_Tlut* tlut);
292void HSD_TlutRemove(HSD_Tlut* tlut);
298void HSD_ImageDescCopyFromEFB(HSD_ImageDesc* idesc, u16 origx, u16 origy,
299 GXBool clear, bool sync);
301void HSD_TObjSetupVolatileTev(HSD_TObj* tobj, u32 rendermode);
302s32 HSD_TObjAssignResources(HSD_TObj* tobj_top);
303void HSD_TObjSetup(HSD_TObj* tobj);
304u32 HSD_TGTex2Index(GXTexGenSrc tgtex);
305GXTexGenSrc HSD_TexCoordID2TexGenSrc(GXTexCoordID coord);
306u32 HSD_TexCoord2Index(GXTexCoordID coord_id);
307GXTexCoordID HSD_Index2TexCoord(u32 index);
308u32 HSD_TexMtx2Index(GXTexMtx texmtx);
309GXTexMtx HSD_Index2TexMtx(u32 index);
310GXTexMapID HSD_Index2TexMap(u32 index);
311u32 HSD_TexMap2Index(GXTexMapID mapid);
313
314void HSD_TObjRemoveAnim(HSD_TObj* tobj);
315void HSD_TObjReqAnimByFlags(HSD_TObj* tobj, f32 startframe, u32 flags);
316
317#endif
int index
Definition gmstaffroll.c:52
int td
Definition aobj.h:51
Definition aobj.h:41
Definition class.h:32
Definition tobj.h:205
u32 mipmap
Definition tobj.h:210
void * image_ptr
Definition tobj.h:206
f32 maxLOD
Definition tobj.h:212
GXTexFmt format
Definition tobj.h:209
f32 minLOD
Definition tobj.h:211
u16 height
Definition tobj.h:208
u16 width
Definition tobj.h:207
Definition object.h:60
Definition tobj.h:162
u8 repeat_t
Definition tobj.h:173
char * class_name
Definition tobj.h:163
struct _HSD_TObjTevDesc * tev
Definition tobj.h:180
GXTexWrapMode wrap_s
Definition tobj.h:170
struct _HSD_TlutDesc * tlutdesc
Definition tobj.h:178
f32 blending
Definition tobj.h:175
u8 repeat_s
Definition tobj.h:172
struct HSD_ImageDesc * imagedesc
Definition tobj.h:177
u32 blend_flags
Definition tobj.h:174
GXTexWrapMode wrap_t
Definition tobj.h:171
Vec3 rotate
Definition tobj.h:167
Vec3 translate
Definition tobj.h:169
Vec3 scale
Definition tobj.h:168
GXTexGenSrc src
Definition tobj.h:166
GXTexFilter magFilt
Definition tobj.h:176
GXTexMapID id
Definition tobj.h:165
struct _HSD_TObjDesc * next
Definition tobj.h:164
struct _HSD_TexLODDesc * lod
Definition tobj.h:179
Definition tobj.h:245
HSD_ClassInfo parent
Definition tobj.h:246
Definition tobj.h:230
u8 alpha_bias
Definition tobj.h:234
u8 color_bias
Definition tobj.h:233
u8 color_a
Definition tobj.h:239
u8 alpha_clamp
Definition tobj.h:238
u8 alpha_scale
Definition tobj.h:236
u8 color_scale
Definition tobj.h:235
u8 alpha_a
Definition tobj.h:240
GXColor konst
Definition tobj.h:241
u8 alpha_op
Definition tobj.h:232
u8 color_op
Definition tobj.h:231
u8 color_clamp
Definition tobj.h:237
u32 active
Definition tobj.h:242
Definition tobj.h:215
u8 alpha_a
Definition tobj.h:225
u8 color_scale
Definition tobj.h:220
u8 color_bias
Definition tobj.h:218
u8 color_clamp
Definition tobj.h:222
u8 alpha_bias
Definition tobj.h:219
u32 active
Definition tobj.h:227
u8 alpha_op
Definition tobj.h:217
u8 alpha_clamp
Definition tobj.h:223
u8 color_op
Definition tobj.h:216
GXColor konst
Definition tobj.h:226
u8 alpha_scale
Definition tobj.h:221
u8 color_a
Definition tobj.h:224
Definition tobj.h:134
struct _HSD_Tlut * tlut
Definition tobj.h:151
u8 repeat_s
Definition tobj.h:145
struct _HSD_Tlut ** tluttbl
Definition tobj.h:155
Vec3 translate
Definition tobj.h:142
Vec3 scale
Definition tobj.h:141
struct HSD_ImageDesc * imagedesc
Definition tobj.h:150
u32 flags
Definition tobj.h:147
GXTexMapID id
Definition tobj.h:137
HSD_TObj * next
Definition tobj.h:136
u32 mtxid
Definition tobj.h:139
HSD_Obj parent
Definition tobj.h:135
GXTexWrapMode wrap_s
Definition tobj.h:143
GXTexGenSrc src
Definition tobj.h:138
struct _HSD_TObjTev * tev
Definition tobj.h:159
GXTexFilter magFilt
Definition tobj.h:149
GXTexCoordID coord
Definition tobj.h:158
struct HSD_ImageDesc ** imagetbl
Definition tobj.h:154
HSD_AObj * aobj
Definition tobj.h:153
struct _HSD_TexLODDesc * lod
Definition tobj.h:152
u8 tlut_no
Definition tobj.h:156
Mtx mtx
Definition tobj.h:157
f32 blending
Definition tobj.h:148
u8 repeat_t
Definition tobj.h:146
GXTexWrapMode wrap_t
Definition tobj.h:144
Quaternion rotate
Definition tobj.h:140
Definition tobj.h:253
struct _HSD_TlutDesc ** tluttbl
Definition tobj.h:258
u16 n_imagetbl
Definition tobj.h:259
HSD_AObjDesc * aobjdesc
Definition tobj.h:256
GXTexMapID id
Definition tobj.h:255
struct HSD_ImageDesc ** imagetbl
Definition tobj.h:257
u16 n_tluttbl
Definition tobj.h:260
struct _HSD_TexAnim * next
Definition tobj.h:254
Definition tobj.h:197
f32 LODBias
Definition tobj.h:199
GXBool bias_clamp
Definition tobj.h:200
GXTexFilter minFilt
Definition tobj.h:198
GXAnisotropy max_anisotropy
Definition tobj.h:202
GXBool edgeLODEnable
Definition tobj.h:201
Definition tobj.h:190
void * lut
Definition tobj.h:191
u32 tlut_name
Definition tobj.h:193
GXTlutFmt fmt
Definition tobj.h:192
u16 n_entries
Definition tobj.h:194
Definition tobj.h:183
GXTlutFmt fmt
Definition tobj.h:185
u16 n_entries
Definition tobj.h:187
void * lut
Definition tobj.h:184
u32 tlut_name
Definition tobj.h:186
Definition ground.c:2356
int c
Definition tev.c:12
void HSD_TObjAnimAll(HSD_TObj *tobj)
Definition tobj.c:238
u32 HSD_TexMap2Index(GXTexMapID mapid)
Definition tobj.c:1442
HSD_Tlut * HSD_TlutLoadDesc(HSD_TlutDesc *tlutdesc)
Definition tobj.c:299
void HSD_TObjReqAnim(HSD_TObj *tobj, f32 startframe)
Definition tobj.c:125
HSD_TObj * _HSD_TObjGetCurrentByType(HSD_TObj *from, u32 mapping)
Definition tobj.c:319
u32 HSD_TGTex2Index(GXTexGenSrc tgtex)
Definition tobj.c:1255
HSD_TObjInfo * HSD_TObjGetDefaultClass(void)
Definition tobj.c:1498
void HSD_TlutFree(HSD_Tlut *tlut)
Definition tobj.c:1525
void HSD_ImageDescFree(HSD_ImageDesc *idesc)
Definition tobj.c:1565
void HSD_TObjReqAnimAllByFlags(HSD_TObj *tobj, f32 startframe, u32 flags)
Definition tobj.c:114
HSD_Tlut * HSD_TlutAlloc(void)
Definition tobj.c:1517
void HSD_TObjAddAnimAll(HSD_TObj *tobj, HSD_TexAnim *texanim)
Definition tobj.c:94
HSD_TObj * HSD_TObjLoadDesc(HSD_TObjDesc *td)
Definition tobj.c:280
void HSD_TObjRemoveAll(HSD_TObj *tobj)
Definition tobj.c:1472
void HSD_TObjTevFree(HSD_TObjTev *tev)
Definition tobj.c:1545
GXTexMtx HSD_Index2TexMtx(u32 index)
Definition tobj.c:1385
void HSD_TObjAddAnim(HSD_TObj *tobj, HSD_TexAnim *texanim)
Definition tobj.c:59
HSD_TObj * HSD_TObjAlloc(void)
Definition tobj.c:1503
void HSD_TObjSetDefaultClass(HSD_TObjInfo *info)
Definition tobj.c:1490
HSD_TObj * HSD_TObjGetNext(HSD_TObj *tobj)
Definition tobj.c:1481
HSD_TObjTev * HSD_TObjTevAlloc(void)
Definition tobj.c:1537
void HSD_TObjAnim(HSD_TObj *tobj)
Definition tobj.c:229
void HSD_TlutRemove(HSD_Tlut *tlut)
Definition tobj.c:1530
u32 HSD_TexCoord2Index(GXTexCoordID coord_id)
Definition tobj.c:1304
HSD_ImageDesc * HSD_ImageDescAlloc(void)
Definition tobj.c:1557
GXTexMapID HSD_Index2TexMap(u32 index)
Definition tobj.c:1417
u32 HSD_TexMtx2Index(GXTexMtx texmtx)
Definition tobj.c:1354
void HSD_TObjRemove(HSD_TObj *tobj)
Definition tobj.c:1467
GXTexGenSrc HSD_TexCoordID2TexGenSrc(GXTexCoordID coord)
Definition tobj.c:1280
void HSD_ImageDescCopyFromEFB(HSD_ImageDesc *idesc, u16 origx, u16 origy, GXBool clear, bool sync)
Definition tobj.c:1570
void HSD_TObjSetupVolatileTev(HSD_TObj *tobj, u32 rendermode)
Definition tobj.c:616
void HSD_TObjSetup(HSD_TObj *tobj)
Definition tobj.c:1142
void HSD_TObjTevRemove(HSD_TObjTev *tev)
Definition tobj.c:1550
GXTexCoordID HSD_Index2TexCoord(u32 index)
Definition tobj.c:1329
void HSD_TObjRemoveAnimAll(HSD_TObj *tobj)
Definition tobj.c:37
void HSD_TObjRemoveAnim(HSD_TObj *tobj)
Definition tobj.c:27
void HSD_TObjReqAnimByFlags(HSD_TObj *tobj, f32 startframe, u32 flags)
Definition tobj.c:105
void HSD_TObjFree(HSD_TObj *tobj)
Definition tobj.c:1510
HSD_TObjTev * HSD_TObjTevLoadDesc(HSD_TObjTevDesc *tevdesc)
Definition tobj.c:309
HSD_TObjInfo hsdTObj
Definition tobj.c:21
s32 HSD_TObjAssignResources(HSD_TObj *tobj_top)
Definition tobj.c:1057
void HSD_TObjSetupTextureCoordGen(HSD_TObj *tobj)
Definition tobj.c:550
void HSD_TObjReqAnimAll(HSD_TObj *tobj, f32 startframe)
Definition tobj.c:130
Definition texp.h:168