Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
confetti.c
Go to the documentation of this file.
1#include "common.h"
2#include "effects_internal.h"
3
4void confetti_init(EffectInstance* effect);
7void confetti_appendGfx(void* effect);
8
9extern Gfx D_090009E8_38C588[];
10extern Gfx D_09000A00_38C5A0[];
11extern Gfx D_09000940_38C4E0[];
12
17
19 { 232, 160, 168 },
20 { 168, 80, 88 },
21 { 160, 168, 232 },
22 { 72, 72, 232 },
23 { 160, 232, 160 },
24 { 96, 176, 120 },
25 { 224, 224, 88 },
26 { 176, 160, 56 },
27 { 232, 160, 232 },
28 { 176, 64, 160 },
29 { 160, 216, 216 },
30 { 88, 168, 168 },
31};
32
33u8 D_E0088D00[] = { 0, 1, 2, 3, 2, 1, 0, 0 };
34
35u8 D_E0088D08[] = { 0, 45, 0, 60 };
36
38 part->unk_04 = rand_int(700) * 0.1f - 35.0f;
39 part->unk_08 = 0;
40 part->unk_0C = rand_int(300) * 0.1f - 15.0f;
41 part->unk_10 = (part->unk_04 + rand_int(100) * 0.1f - 5.0f) * 0.03;
42 part->unk_14 = -1.7 - rand_int(800) * 0.1f * 0.01;
43 part->unk_18 = (rand_int(200) * 0.1f - 10.0f) * 0.05;
44 part->unk_20 = 120;
45}
46
47EffectInstance* confetti_main(s32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4, s32 arg5) {
49 EffectBlueprint* bpPtr = &bp;
50 f32 sp28;
51 ConfettiFXData* data;
52 EffectInstance* effect;
53 s32 numParts;
54 f32 theta;
55 f32 sinTheta;
56 f32 cosTheta;
57 f32 theta2;
58 f32 sinTheta2;
59 f32 cosTheta2;
60 f32 temp_f28;
61 f32 temp_f30;
62 s32 temp_fp;
63 s32 np;
64 s32 var_v0;
65 s32 i;
66
67 switch (arg0) {
68 case 0:
69 case 4:
70 np = 12;
71 break;
72 case 1:
73 case 5:
74 np = 18;
75 break;
76 case 2:
77 case 6:
78 np = 24;
79 break;
80 default:
81 np = 48;
82 break;
83 }
84
85 switch (arg0) {
86 case 0:
87 case 4:
88 sp28 = 3.0f;
89 break;
90 case 1:
91 case 5:
92 sp28 = 4.0f;
93 break;
94 case 2:
95 case 3:
96 case 6:
97 default:
98 sp28 = 5.0f;
99 break;
100 }
101
102 numParts = np + 1;
103
104 bpPtr->init = confetti_init;
105 bpPtr->update = confetti_update;
107 bpPtr->unk_00 = 0;
108 bpPtr->renderUI = NULL;
109 bpPtr->effectID = EFFECT_CONFETTI;
110
111 effect = create_effect_instance(bpPtr);
112 effect->numParts = numParts;
113 data = effect->data.confetti = (ConfettiFXData*)general_heap_malloc(numParts * sizeof(*data));
114 ASSERT(effect->data.confetti != NULL);
115
116 data->unk_04 = arg1;
117 data->unk_08 = arg2;
118 data->unk_0C = arg3;
119 data->unk_24 = 0;
120 data->unk_20 = arg5;
121 data->unk_00 = arg0;
122 data->unk_2C = np;
123 data->unk_28 = 255;
124
125 data++;
126 temp_fp = rand_int(360);
127
128 for (i = 0; i < np; i++, data++) {
129 temp_f30 = sp28 * (effect_rand_int(100) * 0.01f);
130 switch (arg0) {
131 case 0:
132 case 4:
133 temp_f28 = sp28 * 0.5 * 2.0;
134 break;
135 case 1:
136 case 5:
137 temp_f28 = sp28 * 0.5 * 2.0;
138 break;
139 case 2:
140 case 6:
141 temp_f28 = sp28 * 0.5 * 2.0;
142 break;
143 }
144 temp_f28 = sp28 * 0.5 * 2.0;
145 theta2 = D_E0088D08[i % 4];
146 theta = ((i * 360.0f) / np) + temp_fp;
147
148 data->unk_00 = arg0;
149
150 sinTheta = sin_deg(theta);
151 cosTheta = cos_deg(theta);
152 sinTheta2 = sin_deg(theta2);
153 cosTheta2 = cos_deg(theta2);
154 if (arg0 == 3) {
155 func_E0088000(data);
156 data->unk_30 = i * 3;
157 } else {
158 data->unk_04 = temp_f30 * sinTheta * cosTheta2;
159 data->unk_08 = temp_f30 * cosTheta * cosTheta2;
160 data->unk_0C = temp_f30 * sinTheta2;
161 data->unk_10 = temp_f28 * sinTheta * cosTheta2;
162 data->unk_14 = (temp_f28 * cosTheta * cosTheta2) + 1.0f;
163 data->unk_18 = temp_f28 * sinTheta2;
164 if (arg0 >= 4) {
165 data->unk_1C = -0.02 - ((i + 1) % 3) * 0.02;
166 } else {
167 data->unk_1C = 0.0f;
168 }
169 data->unk_30 = i & 3;
170 }
171 }
172 return effect;
173}
174
176}
177
179 ConfettiFXData* part = effect->data.confetti;
180 s32 unk_00;
181 s32 unk_24;
182 s32 unk_2C;
183 s32 i;
184
185 part->unk_20--;
186 if (part->unk_20 < 0) {
187 remove_effect(effect);
188 return;
189 }
190
191 part->unk_24++;
192 if (part->unk_24 > 324000) {
193 part->unk_24 = 10;
194 }
195
196 unk_24 = part->unk_24;
197 unk_00 = part->unk_00;
198 unk_2C = part->unk_2C;
199
200 if (part->unk_20 < 10) {
201 part->unk_28 = part->unk_20 * 25;
202 }
203
204 part++;
205 for (i = 0; i < unk_2C; i++, part++) {
206 if (unk_00 == 3) {
207 if (part->unk_30 <= 0 || --part->unk_30 <= 0) {
208 part->unk_20--;
209 if (part->unk_20 < 0) {
210 func_E0088000(part);
211 part->unk_20--;
212 }
213 part->unk_04 += part->unk_10;
214 part->unk_08 += part->unk_14;
215 part->unk_0C += part->unk_18;
216 }
217 } else {
218 if (part->unk_30 <= 0 || --part->unk_30 <= 0) {
219 if (unk_00 >= 4) {
220 part->unk_10 *= 0.98;
221 part->unk_14 *= 0.98;
222 part->unk_18 *= 0.98;
223 if (unk_24 >= 6 && part->unk_14 > -0.5) {
224 part->unk_14 += part->unk_1C;
225 }
226 }
227 part->unk_04 += part->unk_10;
228 part->unk_08 += part->unk_14;
229 part->unk_0C += part->unk_18;
230 }
231 }
232 }
233}
234
236 RenderTask renderTask;
237 RenderTask* retTask;
238
239 renderTask.appendGfx = confetti_appendGfx;
240 renderTask.appendGfxArg = effect;
241 renderTask.dist = 0;
243
244 retTask = queue_render_task(&renderTask);
245}
246
247void confetti_appendGfx(void* effect) {
248 ConfettiFXData* part = ((EffectInstance*)effect)->data.confetti; //s3
249 Matrix4f sp18;
250 Matrix4f sp58;
251 s32 i;
252 s32 uly;
253 s32 width = 0x3C;
254 s32 height = 0x3C;
255 s32 ulx = 0;
256 s32 unk_28;
257 s32 unk_2C;
258 Gfx* spA0;
259 s32 spA4;
260 Gfx* savedGfxPos;
261 s32 unk_24;
262 Color_RGB8* color;
263
264 unk_24 = part->unk_24;
265 unk_2C = part->unk_2C;
266 unk_28 = part->unk_28;
267 spA0 = D_E0088CC0[part->unk_00];
268
269 gDPPipeSync(gMainGfxPos++);
270 gSPSegment(gMainGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(((EffectInstance*)effect)->graphics->data));
271 gSPDisplayList(gMainGfxPos++, D_09000940_38C4E0);
272
273 guTranslateF(sp18, part->unk_04, part->unk_08, part->unk_0C);
274 guRotateF(sp58, -gCameras[gCurrentCameraID].curYaw, 0.0f, 1.0f, 0.0f);
275 guMtxCatF(sp58, sp18, sp18);
277
278 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
279 savedGfxPos = gMainGfxPos++;
280
281 part++;
282 for (i = 0; i < unk_2C; i++, part++) {
283 color = &D_E0088CDC[i % 12];
284
285 if (part->unk_30 <= 0) {
286 guTranslateF(sp18, part->unk_04, part->unk_08, part->unk_0C);
288
289 gDPSetPrimColor(gMainGfxPos++, 0, 0, color->r, color->g, color->b, unk_28);
290
291 switch ((unk_24 + i) % 3) {
292 case 0:
293 gDPSetCombineMode(gMainGfxPos++, PM_CC_45, PM_CC_46);
294 break;
295 case 1:
296 gDPSetCombineMode(gMainGfxPos++, PM_CC_45, PM_CC_45);
297 break;
298 case 2:
299 gDPSetCombineMode(gMainGfxPos++, PM_CC_45, PM_CC_47);
300 break;
301 }
302 uly = ((i + D_E0088D00[unk_24 % 6]) & 0xF) * 16;
303
304 gDPSetTileSize(gMainGfxPos++, G_TX_RENDERTILE, ulx << 2, uly << 2,
305 (ulx << 2) + ((width >> 1) << 1), (uly << 2) + height);
306 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
307 gSPDisplayList(gMainGfxPos++, spA0);
308 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
309 }
310 }
311
312 gSPEndDisplayList(gMainGfxPos++);
313 gSPBranchList(savedGfxPos, gMainGfxPos);
314 savedGfxPos++;
315 gSPDisplayList(gMainGfxPos++, savedGfxPos);
316 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
317 gDPPipeSync(gMainGfxPos++);
318}
319
Mtx matrixStack[0x200]
f32 Matrix4f[4][4]
EffectInstance * confetti_main(s32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4, s32 arg5)
Definition confetti.c:47
Color_RGB8 D_E0088CDC[]
Definition confetti.c:18
Gfx * D_E0088CC0[]
Definition confetti.c:13
Gfx D_09000A00_38C5A0[]
Gfx D_090009E8_38C588[]
void func_E0088000(ConfettiFXData *part)
Definition confetti.c:37
void confetti_update(EffectInstance *effect)
Definition confetti.c:178
u8 D_E0088D08[]
Definition confetti.c:35
void confetti_render(EffectInstance *effect)
Definition confetti.c:235
Gfx D_09000940_38C4E0[]
void confetti_init(EffectInstance *effect)
Definition confetti.c:175
void confetti_appendGfx(void *effect)
Definition confetti.c:247
u8 D_E0088D00[]
Definition confetti.c:33
#define general_heap_malloc
#define guRotateF
#define queue_render_task
#define guMtxF2L
#define sin_deg
#define guTranslateF
#define guMtxCatF
#define remove_effect
#define rand_int
#define cos_deg
#define create_effect_instance
struct ConfettiFXData * confetti
Definition effects.h:2532
EffectData data
Definition effects.h:2605
#define ASSERT(condition)
s32 effect_rand_int(s32)
@ RENDER_MODE_CLOUD_NO_ZCMP
Definition enums.h:3311
#define PM_CC_45
Definition macros.h:472
#define PM_CC_47
Definition macros.h:474
#define PM_CC_46
Definition macros.h:473
#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
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
s32 gCurrentCameraID
Definition cam_math.c:4
DisplayContext * gDisplayContext
Definition cam_main.c:16