Paper Mario DX
Paper Mario (N64) modding
Loading...
Searching...
No Matches
emote.c
Go to the documentation of this file.
1
#include "common.h"
2
#include "
effects_internal.h
"
3
4
extern
Gfx
D_09002170_336DE0
[];
5
extern
Gfx
D_09002238_336EA8
[];
6
extern
Gfx
D_090022E0_336F50
[];
7
extern
Gfx
D_09002308_336F78
[];
8
extern
Gfx
D_090023B0_337020
[];
9
extern
Gfx
D_090023D8_337048
[];
10
extern
Gfx
D_09002480_3370F0
[];
11
extern
Gfx
D_090024A8_337118
[];
12
extern
Gfx
D_09002550_3371C0
[];
13
extern
Gfx
D_09002578_3371E8
[];
14
15
Gfx*
D_E0020C90
[] = {
D_090022E0_336F50
, NULL,
D_090023B0_337020
,
D_09002480_3370F0
,
D_09002550_3371C0
};
16
17
Gfx*
D_E0020CA4
[] = {
D_09002238_336EA8
, NULL,
D_09002308_336F78
,
D_090023D8_337048
,
D_090024A8_337118
};
18
19
s8
D_E0020CB8
[40] = {
20
0, 0, 1, 2, 3, 5, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
21
-1, 0
22
};
23
24
s8
D_E0020CE0
[28] = {
25
0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, -1, 0, 0, 0
26
};
27
28
s8
D_E0020CFC
[40] = {
29
0, 0, 2, 1, 3, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, -1,
30
0, 0
31
};
32
33
s8
D_E0020D24
[12] = { 0, 0, 1, 1, 2, 2, 3, 3, -13, 0, 0, 0 };
34
35
s8
D_E0020D30
[80] = {
36
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2,
37
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
38
3, 3, -1, 0
39
};
40
41
s8*
D_E0020D80
[5] = {
D_E0020CB8
,
D_E0020CE0
,
D_E0020CFC
,
D_E0020D24
,
D_E0020D30
};
42
43
u8
D_E0020D94
[] = {
44
64, 0, 0,
45
32, 0, 32,
46
0, 0, 64,
47
0, 32, 32,
48
0, 64, 0,
49
32, 32, 0,
50
0, 0, 0
51
};
52
53
void
emote_init
(
EffectInstance
* effect);
54
void
emote_update
(
EffectInstance
* effect);
55
void
emote_render
(
EffectInstance
* effect);
56
void
emote_appendGfx
(
void
* effect);
57
58
void
func_E0020000
(
EmoteFXData
* part, s32 arg1) {
59
f32 unk_1C = part->
unk_1C
;
60
f32 unk_20 = part->
unk_20
;
61
Npc
* npc = part->
unk_3C
;
62
Matrix4f
sp18;
63
f32 sin;
64
f32 cos;
65
66
sin =
sin_deg
(
gCameras
[
gCurrentCameraID
].curYaw);
67
cos =
cos_deg
(
gCameras
[
gCurrentCameraID
].curYaw);
68
guRotateF
(sp18, -(unk_1C - 20.0f + arg1 * 20), sin, 0.0f, -cos);
69
70
if
(npc ==
PTR_LIST_END
) {
71
part->
unk_04
=
gPlayerStatus
.
pos
.
x
+ part->
unk_10
+ sp18[1][0] * (unk_20 + 16.0f);
72
part->
unk_08
=
gPlayerStatus
.
pos
.
y
+ part->
unk_14
+ sp18[1][1] * (unk_20 + 16.0f);
73
part->
unk_0C
=
gPlayerStatus
.
pos
.
z
+ part->
unk_18
+ sp18[1][2] * (unk_20 + 16.0f);
74
}
else
if
(npc != NULL) {
75
part->
unk_04
= npc->
pos
.
x
+ part->
unk_10
+ sp18[1][0] * (unk_20 + 16.0f);
76
part->
unk_08
= npc->
pos
.
y
+ part->
unk_14
+ sp18[1][1] * (unk_20 + 16.0f);
77
part->
unk_0C
= npc->
pos
.
z
+ part->
unk_18
+ sp18[1][2] * (unk_20 + 16.0f);
78
}
else
{
79
part->
unk_04
= part->
unk_10
+ sp18[1][0] * (unk_20 + 16.0f);
80
part->
unk_08
= part->
unk_14
+ sp18[1][1] * (unk_20 + 16.0f);
81
part->
unk_0C
= part->
unk_18
+ sp18[1][2] * (unk_20 + 16.0f);
82
}
83
84
part->
unk_24
= unk_1C - 20.0f + arg1 * 20;
85
part->
unk_28
= (unk_20 / 12.0f) * 0.5f + 0.5;
86
}
87
88
void
emote_main
(s32 arg0,
Npc
* arg1, f32 arg2, f32 arg3, f32 arg4, f32 arg5, f32 arg6, s32 arg7,
EffectInstance
** arg8) {
89
EffectBlueprint
bp;
90
EffectBlueprint
* bpPtr = &bp;
91
EmoteFXData
* data;
92
EffectInstance
* effect;
93
s32 numParts;
94
95
if
(arg0 == 1) {
96
numParts = 3;
97
}
else
{
98
numParts = 1;
99
}
100
101
bp.
unk_00
= 0;
102
bp.
init
=
emote_init
;
103
bp.
update
=
emote_update
;
104
bp.
renderWorld
=
emote_render
;
105
bp.
renderUI
= NULL;
106
bp.
effectID
= EFFECT_EMOTE;
107
108
effect =
create_effect_instance
(bpPtr);
109
effect->
numParts
= numParts;
110
data = effect->
data
.
emote
=
general_heap_malloc
(numParts *
sizeof
(*data));
111
112
ASSERT
(effect->
data
.
emote
!= NULL);
113
data->
unk_3C
= arg1;
114
data->
unk_00
= arg0;
115
data->
unk_30
= arg0;
116
117
if
(arg7 <= 0) {
118
arg7 = 10000;
119
}
120
data->
unk_2C
= arg7;
121
data->
unk_34
= 0;
122
123
if
(arg0 == 1) {
124
s32 i;
125
126
for
(i = 0; i < numParts; i++, data++) {
127
data->
unk_10
= arg2;
128
data->
unk_14
= arg3;
129
data->
unk_18
= arg4;
130
data->
unk_1C
= arg6;
131
data->
unk_20
= arg5;
132
data->
unk_3C
= arg1;
133
func_E0020000
(data, i);
134
}
135
}
else
{
136
data->
unk_10
= arg2;
137
data->
unk_14
= arg3;
138
data->
unk_18
= arg4;
139
data->
unk_1C
= arg6;
140
data->
unk_20
= arg5;
141
data->
unk_3C
= arg1;
142
func_E0020000
(data, 1);
143
}
144
*arg8 = effect;
145
}
146
147
void
emote_init
(
EffectInstance
* effect) {
148
}
149
150
void
emote_update
(
EffectInstance
* effect) {
151
EmoteFXData
* part = effect->
data
.
emote
;
152
s32 temp_a0 =
D_E0020D80
[part->
unk_30
][part->
unk_34
];
153
s32 type = part->
unk_00
;
154
155
part->
unk_34
++;
156
part->
unk_38
= temp_a0;
157
if
(part->
unk_38
< 0) {
158
if
(part->
unk_38
!= -1) {
159
part->
unk_30
= -part->
unk_38
- 10;
160
part->
unk_34
= 0;
161
part->
unk_38
=
D_E0020D80
[part->
unk_30
][0];
162
part->
unk_34
= 1;
163
}
else
{
164
remove_effect
(effect);
165
return
;
166
}
167
}
168
169
if
(part->
unk_2C
< 10000) {
170
part->
unk_2C
--;
171
}
172
173
if
(part->
unk_2C
< 0) {
174
remove_effect
(effect);
175
return
;
176
}
177
178
if
(part->
unk_3C
!= NULL) {
179
if
(type == 1) {
180
s32 i;
181
182
for
(i = 0; i < effect->
numParts
; i++, part++) {
183
func_E0020000
(part, i);
184
}
185
}
else
{
186
func_E0020000
(part, 1);
187
}
188
}
189
}
190
191
void
emote_render
(
EffectInstance
* effect) {
192
RenderTask
renderTask;
193
RenderTask
* retTask;
194
195
renderTask.
appendGfx
=
emote_appendGfx
;
196
renderTask.
appendGfxArg
= effect;
197
renderTask.
dist
= 0;
198
renderTask.
renderMode
=
RENDER_MODE_CLOUD_NO_ZCMP
;
199
200
retTask =
queue_render_task
(&renderTask);
201
retTask->
renderMode
|=
RENDER_TASK_FLAG_REFLECT_FLOOR
;
202
}
203
204
void
emote_appendGfx
(
void
* effect) {
205
EmoteFXData
* part = ((
EffectInstance
*)effect)->data.emote;
206
s32 type = part->
unk_00
;
207
s32 unk_38;
208
Gfx* dlist;
209
Gfx* dlist2;
210
Mtx* matrix;
211
s32 w;
212
s32 h;
213
s32 uls;
214
s32 ult;
215
s32 idx;
216
Matrix4f
sp18;
217
Matrix4f
sp58;
218
s32 i;
219
220
gDPPipeSync(
gMainGfxPos
++);
221
gSPSegment(
gMainGfxPos
++, 0x09,
VIRTUAL_TO_PHYSICAL
(((
EffectInstance
*)effect)->graphics->data));
222
223
if
(type != 1) {
224
guTranslateF
(sp18, part->
unk_04
, part->
unk_08
, part->
unk_0C
);
225
guRotateF
(sp58, -
gCameras
[
gCurrentCameraID
].curYaw, 0.0f, 1.0f, 0.0f);
226
guMtxCatF
(sp58, sp18, sp18);
227
228
matrix = &
gDisplayContext
->
matrixStack
[
gMatrixListPos
];
229
230
guMtxF2L
(sp18, &
gDisplayContext
->
matrixStack
[
gMatrixListPos
++]);
231
guScaleF
(sp58, 1.0f, 0.8f, 1.0f);
232
guMtxCatF
(sp58, sp18, sp18);
233
guRotateF
(sp58, part->
unk_24
, 0.0f, 0.0f, 1.0f);
234
guMtxCatF
(sp58, sp18, sp18);
235
guMtxF2L
(sp18, &
gDisplayContext
->
matrixStack
[
gMatrixListPos
]);
236
237
gSPMatrix(
gMainGfxPos
++, &
gDisplayContext
->
matrixStack
[
gMatrixListPos
++], G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
238
gSPDisplayList(
gMainGfxPos
++,
D_09002170_336DE0
);
239
gSPPopMatrix(
gMainGfxPos
++, G_MTX_MODELVIEW);
240
}
else
{
241
if
(part->
unk_38
== 0) {
242
for
(i = 0; i < 3; i++, part++) {
243
guTranslateF
(sp18, part->
unk_04
, part->
unk_08
, part->
unk_0C
);
244
guRotateF
(sp58, -
gCameras
[
gCurrentCameraID
].curYaw, 0.0f, 1.0f, 0.0f);
245
guMtxCatF
(sp58, sp18, sp18);
246
guRotateF
(sp58, part->
unk_24
, 0.0f, 0.0f, 1.0f);
247
guMtxCatF
(sp58, sp18, sp18);
248
guScaleF
(sp58, part->
unk_28
, part->
unk_28
, 1.0f);
249
guMtxCatF
(sp58, sp18, sp18);
250
guMtxF2L
(sp18, &
gDisplayContext
->
matrixStack
[
gMatrixListPos
]);
251
252
gDPSetPrimColor(
gMainGfxPos
++, 0, 0, 235, 28, 0, 255);
253
gSPMatrix(
gMainGfxPos
++, &
gDisplayContext
->
matrixStack
[
gMatrixListPos
++], G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
254
gSPDisplayList(
gMainGfxPos
++,
D_09002578_3371E8
);
255
gSPPopMatrix(
gMainGfxPos
++, G_MTX_MODELVIEW);
256
}
257
}
258
259
return
;
260
}
261
262
gSPMatrix(
gMainGfxPos
++, matrix, G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
263
264
unk_38 = part->
unk_38
;
265
dlist =
D_E0020CA4
[type];
266
dlist2 =
D_E0020C90
[type];
267
268
switch
(type) {
269
case
0:
270
w = 16;
271
h = 16;
272
uls = 128 - unk_38 * 16;
273
ult = 0;
274
gDPSetPrimColor(
gMainGfxPos
++, 0, 0, 220, 0, 0, 255);
275
break
;
276
case
2:
277
w = 32;
278
h = 48;
279
uls = 128 - unk_38 * 32;
280
ult = 0;
281
gDPSetPrimColor(
gMainGfxPos
++, 0, 0, 220, 0, 0, 255);
282
break
;
283
case
3:
284
w = 32;
285
h = 32;
286
uls = 128 - unk_38 * 32;
287
ult = 0;
288
idx = (part->
unk_2C
* 3) % (
ARRAY_COUNT
(
D_E0020D94
) / 3);
289
gDPSetPrimColor(
gMainGfxPos
++, 0, 0,
D_E0020D94
[idx],
D_E0020D94
[idx + 1],
D_E0020D94
[idx + 2], 255);
290
break
;
291
case
4:
292
w = 32;
293
h = 8;
294
uls = 128 - unk_38 * 32;
295
ult = 0;
296
break
;
297
}
298
299
if
(dlist != NULL) {
300
gSPDisplayList(
gMainGfxPos
++, dlist);
301
}
302
303
gDPSetTileSize(
gMainGfxPos
++, G_TX_RENDERTILE, uls * 4, ult * 4, (uls + w) * 4, (ult + h) * 4);
304
305
if
(dlist2 != NULL) {
306
gSPDisplayList(
gMainGfxPos
++, dlist2);
307
}
308
309
gSPPopMatrix(
gMainGfxPos
++, G_MTX_MODELVIEW);
310
}
DisplayContext::matrixStack
Mtx matrixStack[0x200]
Definition
common_structs.h:2191
Matrix4f
f32 Matrix4f[4][4]
Definition
common_structs.h:132
Vec3f::z
f32 z
Definition
common_structs.h:102
PlayerStatus::pos
Vec3f pos
Definition
common_structs.h:1995
Vec3f::x
f32 x
Definition
common_structs.h:100
Vec3f::y
f32 y
Definition
common_structs.h:101
general_heap_malloc
#define general_heap_malloc
Definition
effect_shims.h:51
guRotateF
#define guRotateF
Definition
effect_shims.h:42
queue_render_task
#define queue_render_task
Definition
effect_shims.h:48
guMtxF2L
#define guMtxF2L
Definition
effect_shims.h:47
sin_deg
#define sin_deg
Definition
effect_shims.h:55
guTranslateF
#define guTranslateF
Definition
effect_shims.h:43
guMtxCatF
#define guMtxCatF
Definition
effect_shims.h:46
remove_effect
#define remove_effect
Definition
effect_shims.h:50
cos_deg
#define cos_deg
Definition
effect_shims.h:56
create_effect_instance
#define create_effect_instance
Definition
effect_shims.h:49
guScaleF
#define guScaleF
Definition
effect_shims.h:45
EmoteFXData::unk_34
s32 unk_34
Definition
effects.h:213
EffectData::emote
struct EmoteFXData * emote
Definition
effects.h:2480
EmoteFXData::unk_14
f32 unk_14
Definition
effects.h:205
EmoteFXData::unk_18
f32 unk_18
Definition
effects.h:206
EmoteFXData::unk_10
f32 unk_10
Definition
effects.h:204
EmoteFXData::unk_00
s32 unk_00
Definition
effects.h:200
EmoteFXData::unk_38
s32 unk_38
Definition
effects.h:214
EmoteFXData::unk_0C
f32 unk_0C
Definition
effects.h:203
EmoteFXData::unk_20
f32 unk_20
Definition
effects.h:208
EmoteFXData::unk_3C
Npc * unk_3C
Definition
effects.h:215
EmoteFXData::unk_30
s32 unk_30
Definition
effects.h:212
EmoteFXData::unk_08
f32 unk_08
Definition
effects.h:202
EffectInstance::numParts
s32 numParts
Definition
effects.h:2604
EmoteFXData::unk_1C
f32 unk_1C
Definition
effects.h:207
EmoteFXData::unk_24
f32 unk_24
Definition
effects.h:209
EmoteFXData::unk_04
f32 unk_04
Definition
effects.h:201
EmoteFXData::unk_28
f32 unk_28
Definition
effects.h:210
EffectInstance::data
EffectData data
Definition
effects.h:2605
EmoteFXData::unk_2C
s32 unk_2C
Definition
effects.h:211
EffectInstance
Definition
effects.h:2601
EmoteFXData
Definition
effects.h:199
effects_internal.h
ASSERT
#define ASSERT(condition)
Definition
effects_internal.h:7
D_E0020CFC
s8 D_E0020CFC[40]
Definition
emote.c:28
emote_render
void emote_render(EffectInstance *effect)
Definition
emote.c:191
D_090023D8_337048
Gfx D_090023D8_337048[]
D_09002238_336EA8
Gfx D_09002238_336EA8[]
D_090022E0_336F50
Gfx D_090022E0_336F50[]
D_E0020D24
s8 D_E0020D24[12]
Definition
emote.c:33
D_09002308_336F78
Gfx D_09002308_336F78[]
D_E0020D94
u8 D_E0020D94[]
Definition
emote.c:43
emote_main
void emote_main(s32 arg0, Npc *arg1, f32 arg2, f32 arg3, f32 arg4, f32 arg5, f32 arg6, s32 arg7, EffectInstance **arg8)
Definition
emote.c:88
D_E0020C90
Gfx * D_E0020C90[]
Definition
emote.c:15
D_090024A8_337118
Gfx D_090024A8_337118[]
D_09002170_336DE0
Gfx D_09002170_336DE0[]
D_E0020CB8
s8 D_E0020CB8[40]
Definition
emote.c:19
emote_update
void emote_update(EffectInstance *effect)
Definition
emote.c:150
D_090023B0_337020
Gfx D_090023B0_337020[]
D_E0020D80
s8 * D_E0020D80[5]
Definition
emote.c:41
D_09002578_3371E8
Gfx D_09002578_3371E8[]
D_09002480_3370F0
Gfx D_09002480_3370F0[]
D_E0020CE0
s8 D_E0020CE0[28]
Definition
emote.c:24
D_E0020D30
s8 D_E0020D30[80]
Definition
emote.c:35
func_E0020000
void func_E0020000(EmoteFXData *part, s32 arg1)
Definition
emote.c:58
D_09002550_3371C0
Gfx D_09002550_3371C0[]
emote_init
void emote_init(EffectInstance *effect)
Definition
emote.c:147
emote_appendGfx
void emote_appendGfx(void *effect)
Definition
emote.c:204
D_E0020CA4
Gfx * D_E0020CA4[]
Definition
emote.c:17
RENDER_TASK_FLAG_REFLECT_FLOOR
@ RENDER_TASK_FLAG_REFLECT_FLOOR
Definition
enums.h:3318
RENDER_MODE_CLOUD_NO_ZCMP
@ RENDER_MODE_CLOUD_NO_ZCMP
Definition
enums.h:3311
ARRAY_COUNT
#define ARRAY_COUNT(arr)
Definition
macros.h:40
PTR_LIST_END
#define PTR_LIST_END
Definition
macros.h:42
VIRTUAL_TO_PHYSICAL
#define VIRTUAL_TO_PHYSICAL(addr)
Definition
macros.h:47
EffectBlueprint
Definition
effects.h:2649
EffectBlueprint::renderUI
void(* renderUI)(EffectInstance *effectInst)
Definition
effects.h:2655
EffectBlueprint::effectID
s32 effectID
Definition
effects.h:2651
EffectBlueprint::init
void(* init)(EffectInstance *effectInst)
Definition
effects.h:2652
EffectBlueprint::update
void(* update)(EffectInstance *effectInst)
Definition
effects.h:2653
EffectBlueprint::unk_00
s32 unk_00
Definition
effects.h:2650
EffectBlueprint::renderWorld
void(* renderWorld)(EffectInstance *effectInst)
Definition
effects.h:2654
Npc
Definition
common_structs.h:213
Npc::pos
Vec3f pos
Definition
common_structs.h:236
RenderTask
Definition
common_structs.h:1507
RenderTask::renderMode
s32 renderMode
Definition
common_structs.h:1508
RenderTask::appendGfxArg
void * appendGfxArg
Definition
common_structs.h:1510
RenderTask::appendGfx
void(* appendGfx)(void *)
Definition
common_structs.h:1511
RenderTask::dist
s32 dist
Definition
common_structs.h:1509
gCameras
Camera gCameras[4]
Definition
cam_main.c:17
gMainGfxPos
Gfx * gMainGfxPos
Definition
cam_main.c:15
gMatrixListPos
u16 gMatrixListPos
Definition
main_loop.c:45
gPlayerStatus
PlayerStatus gPlayerStatus
Definition
77480.c:39
gCurrentCameraID
s32 gCurrentCameraID
Definition
cam_math.c:4
gDisplayContext
DisplayContext * gDisplayContext
Definition
cam_main.c:16
src
effects
emote.c
Generated by
1.10.0