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