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
4extern Gfx D_09002170_336DE0[];
5extern Gfx D_09002238_336EA8[];
6extern Gfx D_090022E0_336F50[];
7extern Gfx D_09002308_336F78[];
8extern Gfx D_090023B0_337020[];
9extern Gfx D_090023D8_337048[];
10extern Gfx D_09002480_3370F0[];
11extern Gfx D_090024A8_337118[];
12extern Gfx D_09002550_3371C0[];
13extern Gfx D_09002578_3371E8[];
14
16
18
19s8 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
24s8 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
28s8 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
33s8 D_E0020D24[12] = { 0, 0, 1, 1, 2, 2, 3, 3, -13, 0, 0, 0 };
34
35s8 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
42
43u8 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
53void emote_init(EffectInstance* effect);
54void emote_update(EffectInstance* effect);
55void emote_render(EffectInstance* effect);
56void emote_appendGfx(void* effect);
57
58void 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
88void emote_main(s32 arg0, Npc* arg1, f32 arg2, f32 arg3, f32 arg4, f32 arg5, f32 arg6, s32 arg7, EffectInstance** arg8) {
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;
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
148}
149
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
192 RenderTask renderTask;
193 RenderTask* retTask;
194
195 renderTask.appendGfx = emote_appendGfx;
196 renderTask.appendGfxArg = effect;
197 renderTask.dist = 0;
199
200 retTask = queue_render_task(&renderTask);
202}
203
204void 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
229
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);
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);
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}
Mtx matrixStack[0x200]
f32 Matrix4f[4][4]
#define general_heap_malloc
#define guRotateF
#define queue_render_task
#define guMtxF2L
#define sin_deg
#define guTranslateF
#define guMtxCatF
#define remove_effect
#define cos_deg
#define create_effect_instance
#define guScaleF
struct EmoteFXData * emote
Definition effects.h:2480
Npc * unk_3C
Definition effects.h:215
EffectData data
Definition effects.h:2605
#define ASSERT(condition)
s8 D_E0020CFC[40]
Definition emote.c:28
void emote_render(EffectInstance *effect)
Definition emote.c:191
Gfx D_090023D8_337048[]
Gfx D_09002238_336EA8[]
Gfx D_090022E0_336F50[]
s8 D_E0020D24[12]
Definition emote.c:33
Gfx D_09002308_336F78[]
u8 D_E0020D94[]
Definition emote.c:43
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
Gfx * D_E0020C90[]
Definition emote.c:15
Gfx D_090024A8_337118[]
Gfx D_09002170_336DE0[]
s8 D_E0020CB8[40]
Definition emote.c:19
void emote_update(EffectInstance *effect)
Definition emote.c:150
Gfx D_090023B0_337020[]
s8 * D_E0020D80[5]
Definition emote.c:41
Gfx D_09002578_3371E8[]
Gfx D_09002480_3370F0[]
s8 D_E0020CE0[28]
Definition emote.c:24
s8 D_E0020D30[80]
Definition emote.c:35
void func_E0020000(EmoteFXData *part, s32 arg1)
Definition emote.c:58
Gfx D_09002550_3371C0[]
void emote_init(EffectInstance *effect)
Definition emote.c:147
void emote_appendGfx(void *effect)
Definition emote.c:204
Gfx * D_E0020CA4[]
Definition emote.c:17
@ RENDER_TASK_FLAG_REFLECT_FLOOR
Definition enums.h:3318
@ RENDER_MODE_CLOUD_NO_ZCMP
Definition enums.h:3311
#define ARRAY_COUNT(arr)
Definition macros.h:40
#define PTR_LIST_END
Definition macros.h:42
#define VIRTUAL_TO_PHYSICAL(addr)
Definition macros.h:47
void(* renderUI)(EffectInstance *effectInst)
Definition effects.h:2655
void(* init)(EffectInstance *effectInst)
Definition effects.h:2652
void(* update)(EffectInstance *effectInst)
Definition effects.h:2653
void(* renderWorld)(EffectInstance *effectInst)
Definition effects.h:2654
Vec3f pos
void * appendGfxArg
void(* appendGfx)(void *)
Camera gCameras[4]
Definition cam_main.c:17
Gfx * gMainGfxPos
Definition cam_main.c:15
u16 gMatrixListPos
Definition main_loop.c:45
PlayerStatus gPlayerStatus
Definition 77480.c:39
s32 gCurrentCameraID
Definition cam_math.c:4
DisplayContext * gDisplayContext
Definition cam_main.c:16