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
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
50 f32 sp28;
51 ConfettiFXData* data;
52 EffectInstance* effect;
53 s32 numParts;
54 f32 theta;
57 f32 theta2;
63 s32 np;
64 s32 i;
65
66 switch (arg0) {
67 case 0:
68 case 4:
69 np = 12;
70 break;
71 case 1:
72 case 5:
73 np = 18;
74 break;
75 case 2:
76 case 6:
77 np = 24;
78 break;
79 default:
80 np = 48;
81 break;
82 }
83
84 switch (arg0) {
85 case 0:
86 case 4:
87 sp28 = 3.0f;
88 break;
89 case 1:
90 case 5:
91 sp28 = 4.0f;
92 break;
93 case 2:
94 case 3:
95 case 6:
96 default:
97 sp28 = 5.0f;
98 break;
99 }
100
101 numParts = np + 1;
102
103 bpPtr->init = confetti_init;
104 bpPtr->update = confetti_update;
105 bpPtr->renderScene = confetti_render;
106 bpPtr->unk_00 = 0;
107 bpPtr->renderUI = nullptr;
109
111 effect->numParts = numParts;
112 data = effect->data.confetti = (ConfettiFXData*)general_heap_malloc(numParts * sizeof(*data));
113 ASSERT(effect->data.confetti != nullptr);
114
115 data->unk_04 = arg1;
116 data->unk_08 = arg2;
117 data->unk_0C = arg3;
118 data->unk_24 = 0;
119 data->unk_20 = arg5;
120 data->unk_00 = arg0;
121 data->unk_2C = np;
122 data->unk_28 = 255;
123
124 data++;
125 temp_fp = rand_int(360);
126
127 for (i = 0; i < np; i++, data++) {
128 temp_f30 = sp28 * (effect_rand_int(100) * 0.01f);
129 switch (arg0) {
130 case 0:
131 case 4:
132 temp_f28 = sp28 * 0.5 * 2.0;
133 break;
134 case 1:
135 case 5:
136 temp_f28 = sp28 * 0.5 * 2.0;
137 break;
138 case 2:
139 case 6:
140 temp_f28 = sp28 * 0.5 * 2.0;
141 break;
142 }
143 temp_f28 = sp28 * 0.5 * 2.0;
144 theta2 = D_E0088D08[i % 4];
145 theta = ((i * 360.0f) / np) + temp_fp;
146
147 data->unk_00 = arg0;
148
153 if (arg0 == 3) {
154 func_E0088000(data);
155 data->unk_30 = i * 3;
156 } else {
157 data->unk_04 = temp_f30 * sinTheta * cosTheta2;
158 data->unk_08 = temp_f30 * cosTheta * cosTheta2;
159 data->unk_0C = temp_f30 * sinTheta2;
160 data->unk_10 = temp_f28 * sinTheta * cosTheta2;
161 data->unk_14 = (temp_f28 * cosTheta * cosTheta2) + 1.0f;
162 data->unk_18 = temp_f28 * sinTheta2;
163 if (arg0 >= 4) {
164 data->unk_1C = -0.02 - ((i + 1) % 3) * 0.02;
165 } else {
166 data->unk_1C = 0.0f;
167 }
168 data->unk_30 = i & 3;
169 }
170 }
171 return effect;
172}
173
175}
176
178 ConfettiFXData* part = effect->data.confetti;
179 s32 unk_00;
180 s32 unk_24;
181 s32 unk_2C;
182 s32 i;
183
184 part->unk_20--;
185 if (part->unk_20 < 0) {
186 remove_effect(effect);
187 return;
188 }
189
190 part->unk_24++;
191 if (part->unk_24 > 324000) {
192 part->unk_24 = 10;
193 }
194
195 unk_24 = part->unk_24;
196 unk_00 = part->unk_00;
197 unk_2C = part->unk_2C;
198
199 if (part->unk_20 < 10) {
200 part->unk_28 = part->unk_20 * 25;
201 }
202
203 part++;
204 for (i = 0; i < unk_2C; i++, part++) {
205 if (unk_00 == 3) {
206 if (part->unk_30 <= 0 || --part->unk_30 <= 0) {
207 part->unk_20--;
208 if (part->unk_20 < 0) {
210 part->unk_20--;
211 }
212 part->unk_04 += part->unk_10;
213 part->unk_08 += part->unk_14;
214 part->unk_0C += part->unk_18;
215 }
216 } else {
217 if (part->unk_30 <= 0 || --part->unk_30 <= 0) {
218 if (unk_00 >= 4) {
219 part->unk_10 *= 0.98;
220 part->unk_14 *= 0.98;
221 part->unk_18 *= 0.98;
222 if (unk_24 >= 6 && part->unk_14 > -0.5) {
223 part->unk_14 += part->unk_1C;
224 }
225 }
226 part->unk_04 += part->unk_10;
227 part->unk_08 += part->unk_14;
228 part->unk_0C += part->unk_18;
229 }
230 }
231 }
232}
233
237
239 renderTask.appendGfxArg = effect;
240 renderTask.dist = 0;
242
244}
245
246void confetti_appendGfx(void* effect) {
247 ConfettiFXData* part = ((EffectInstance*)effect)->data.confetti; //s3
250 s32 i;
251 s32 uly;
252 s32 width = 0x3C;
253 s32 height = 0x3C;
254 s32 ulx = 0;
255 s32 unk_28;
256 s32 unk_2C;
257 Gfx* spA0;
259 s32 unk_24;
260 Color_RGB8* color;
261
262 unk_24 = part->unk_24;
263 unk_2C = part->unk_2C;
264 unk_28 = part->unk_28;
265 spA0 = D_E0088CC0[part->unk_00];
266
268 gSPSegment(gMainGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(((EffectInstance*)effect)->shared->graphics));
270
271 guTranslateF(sp18, part->unk_04, part->unk_08, part->unk_0C);
272 guRotateF(sp58, -gCameras[gCurrentCameraID].curYaw, 0.0f, 1.0f, 0.0f);
275
278
279 part++;
280 for (i = 0; i < unk_2C; i++, part++) {
281 color = &D_E0088CDC[i % 12];
282
283 if (part->unk_30 <= 0) {
284 guTranslateF(sp18, part->unk_04, part->unk_08, part->unk_0C);
286
287 gDPSetPrimColor(gMainGfxPos++, 0, 0, color->r, color->g, color->b, unk_28);
288
289 switch ((unk_24 + i) % 3) {
290 case 0:
292 break;
293 case 1:
295 break;
296 case 2:
298 break;
299 }
300 uly = ((i + D_E0088D00[unk_24 % 6]) & 0xF) * 16;
301
302 gDPSetTileSize(gMainGfxPos++, G_TX_RENDERTILE, ulx << 2, uly << 2,
303 (ulx << 2) + ((width >> 1) << 1), (uly << 2) + height);
307 }
308 }
309
312 savedGfxPos++;
316}
317
BSS s32 PopupMenu_SelectedIndex
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:177
u8 D_E0088D08[]
Definition confetti.c:35
void confetti_render(EffectInstance *effect)
Definition confetti.c:234
Gfx D_09000940_38C4E0[]
void confetti_init(EffectInstance *effect)
Definition confetti.c:174
void confetti_appendGfx(void *effect)
Definition confetti.c:246
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
EffectInstanceDataPtr data
Definition effects.h:2605
struct ConfettiFXData * confetti
Definition effects.h:2532
#define ASSERT(condition)
s32 effect_rand_int(s32)
@ RENDER_MODE_CLOUD_NO_ZCMP
Definition enums.h:3345
#define PM_CC_45
Definition macros.h:484
#define PM_CC_47
Definition macros.h:486
#define PM_CC_46
Definition macros.h:485
#define VIRTUAL_TO_PHYSICAL(addr)
Definition macros.h:46
void(* appendGfx)(void *)
Camera gCameras[4]
Definition cam_main.c:16
Gfx * gMainGfxPos
Definition cam_main.c:14
u16 gMatrixListPos
Definition main_loop.c:44
s32 gCurrentCameraID
Definition cam_math.c:5
DisplayContext * gDisplayContext
Definition cam_main.c:15