Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
firework.c
Go to the documentation of this file.
1#include "common.h"
2#include "effects_internal.h"
3
4extern Gfx D_09000940_38AC90[];
5extern Gfx D_09000A00_38AD50[];
6extern Gfx D_09000A20_38AD70[];
7extern Gfx D_09000A40_38AD90[];
8extern Gfx D_09000A60_38ADB0[];
9extern Gfx D_09000A80_38ADD0[];
10
15
17
18u8 D_E0086AC0[] = { 0x0D, 0x0D, 0x0D, 0x00 };
19
20u8 D_E0086AC4[] = {
21 0x40, 0x68, 0x90, 0xA4, 0xB8, 0xC0, 0xD0, 0xD8,
22 0xE0, 0xE8, 0xF0, 0xF8, 0xFF, 0x00, 0x00, 0x00
23};
24
25u8 D_E0086AD4[] = {
26 0x0A, 0x14, 0x1C, 0x23, 0x2A, 0x30, 0x35, 0x39,
27 0x3C, 0x3E, 0x3F, 0x40, 0x41, 0x00, 0x00, 0x00
28};
29
30u8 D_E0086AE4[] = {
31 0xFF, 0xFF, 0xC8, 0x82, 0x3C, 0x00, 0x00, 0x00,
32 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
34 0x00, 0x00, 0x00, 0x00
35};
36
37void firework_init(EffectInstance* effect);
40void func_E0086398(EffectInstance* effect);
41void func_E00863B4(EffectInstance* effect);
42
44 s32 arg0,
45 f32 arg1,
46 f32 arg2,
47 f32 arg3,
48 f32 arg4,
49 s32 arg5
50) {
52 EffectInstance* effect;
53 FireworkFXData* part;
54 s32 numParts = (arg5 * 5 + 20) / 3 + 1;
55 s32 i;
56
57 bp.unk_00 = 0;
62 bp.effectID = EFFECT_FIREWORK;
63
64 effect = create_effect_instance(&bp);
65 effect->numParts = numParts;
66 part = effect->data.firework = general_heap_malloc(numParts * sizeof(*part));
67 ASSERT(effect->data.firework != NULL);
68
69 part->unk_00 = arg0;
70 part->unk_04 = arg1;
71 part->unk_08 = arg2;
72 part->unk_0C = arg3;
73 part->unk_30 = D_E0086AC0[arg0];
74 part->unk_34 = 0;
75 part->unk_38 = 0;
76 switch (arg0) {
77 case 0:
78 part->unk_3C = 255;
79 part->unk_3D = 255;
80 part->unk_3E = 255;
81 part->unk_3F = 255;
82 part->unk_40 = 255;
83 part->unk_41 = 255;
84 break;
85 case 1:
86 part->unk_3C = 255;
87 part->unk_3D = 255;
88 part->unk_3E = 0;
89 part->unk_3F = 255;
90 part->unk_40 = 0;
91 part->unk_41 = 0;
92 break;
93 case 2:
94 default:
95 part->unk_3C = 255;
96 part->unk_3D = 255;
97 part->unk_3E = 0;
98 part->unk_3F = 200;
99 part->unk_40 = 255;
100 part->unk_41 = 230;
101 break;
102 }
103 part->unk_28 = arg4;
104
105 part++;
106 for (i = 1; i < numParts; i++, part++) {
107 f32 unk_1C = (i * 360) / (numParts - 1);
108 s32 unk_24 = rand_int(359);
109
110 part->unk_04 = 0;
111 part->unk_08 = 0;
112 part->unk_0C = 0;
113 part->unk_10 = 0;
114 part->unk_14 = 0;
115 part->unk_20 = 0;
116 part->unk_00 = 0;
117 part->unk_1C = unk_1C;
118 part->unk_24 = unk_24;
119 part->unk_10 = 0;
120 part->unk_2C = 255;
121 }
122
123 return effect;
124}
125
127}
128
130 FireworkFXData* part = effect->data.firework;
131 s32 unk_00 = part->unk_00;
132 s32 unk_34;
133 s32 idx;
134 s32 i;
135
136 part->unk_30--;
137 part->unk_34++;
138
139 if (part->unk_30 < 0) {
140 remove_effect(effect);
141 return;
142 }
143
144 unk_34 = part->unk_34;
145
146 if (D_E0086AC0[unk_00] >= unk_34) {
147 part->unk_38 = D_E0086AC4[unk_34 - 1] / 256.0f;
148 } else {
149 part->unk_38 = 1.0f;
150 }
151
152 part++;
153 for (i = 1; i < effect->numParts; i++, part++) {
154 if (D_E0086AC0[unk_00] >= unk_34) {
155 idx = unk_34 - 1;
156 } else {
157 idx = 12;
158 }
159 part->unk_04 = D_E0086AD4[idx];
160 part->unk_08 = 0;
161 part->unk_0C = 0;
162 }
163}
164
166}
167
169 func_E00863B4(effect);
170}
171
173 FireworkFXData* part = effect->data.firework;
174 Gfx* savedGfxPos;
175 f32 temp_f32 = part->unk_38 * 5.0f;
176 s32 envA;
177 s32 temp_s32 = temp_f32;
178 s32 primR;
179 s32 primG;
180 s32 primB;
181 s32 envR;
182 s32 envG;
183 s32 engB;
184 s32 primA;
185 s32 unk_34 = part->unk_34;
186 s32 unk_00 = part->unk_00;
187 s32 var_v1;
188 Matrix4f sp20;
189 Matrix4f sp60;
190 s32 i;
191
192 if (temp_s32 < 5) {
193 s32 cond;
194 f32 unk_28;
195
196 gDPPipeSync(gMainGfxPos++);
197 gSPSegment(gMainGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(effect->graphics->data));
198
199 unk_28 = part->unk_28;
200
201 guPositionF(sp20, 0.0f, -gCameras[gCurrentCameraID].curYaw, 0.0f, unk_28, part->unk_04, part->unk_08, part->unk_0C);
203
204 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
205
206 envA = (temp_f32 - temp_s32) * 256.0f;
207 primA = part->unk_2C;
208 cond = (temp_s32 >= 4);
209
210 switch (unk_00) {
211 case 1:
212 if (unk_34 - 1 < 13) {
213 var_v1 = D_E0086AE4[unk_34 - 1];
214 } else {
215 var_v1 = 0;
216 }
217 primR = part->unk_3C;
218 primG = (part->unk_3D * var_v1) >> 8;
219 primB = (part->unk_3E * var_v1) >> 8;
220 envR = (part->unk_3F * var_v1) >> 8;
221 envG = (part->unk_40 * var_v1) >> 8;
222 engB = (part->unk_41 * var_v1) >> 8;
223 break;
224 case 2:
225 if (unk_34 % 2 == 0) {
226 primR = 0;
227 primG = 0;
228 primB = 0;
229 envR = part->unk_3C;
230 envG = part->unk_3D;
231 engB = part->unk_3E;
232 } else {
233 primR = part->unk_3C;
234 primG = part->unk_3D;
235 primB = part->unk_3E;
236 envR = part->unk_3F;
237 envG = part->unk_40;
238 engB = part->unk_41;
239 }
240 break;
241 case 0:
242 default:
243 primR = part->unk_3C;
244 primG = part->unk_3D;
245 primB = part->unk_3E;
246 envR = part->unk_3F;
247 envG = part->unk_40;
248 engB = part->unk_41;
249 break;
250 }
251
252 savedGfxPos = gMainGfxPos++;
253 gSPDisplayList(gMainGfxPos++, D_E0086AB4[unk_00]);
254
255 part++;
256
257 if (cond) {
258 gDPSetTileSize(gMainGfxPos++, 1, 0, 0, 0, 0);
259 }
260
261 for (i = 1; i < effect->numParts; i++, part++) {
262 gSPDisplayList(gMainGfxPos++, D_E0086AB4[part->unk_00]);
263
264 guRotateF(sp20, part->unk_1C, 0.0f, 0.0f, 1.0f);
265 guRotateF(sp60, part->unk_24, 0.0f, 1.0f, 0.0f);
266 guMtxCatF(sp60, sp20, sp20);
267 guTranslateF(sp60, part->unk_04, part->unk_08, part->unk_0C);
268 guMtxCatF(sp60, sp20, sp20);
270
271 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
272 gSPDisplayList(gMainGfxPos++, D_E0086AA0[temp_s32]);
273 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
274 }
275
276 gSPEndDisplayList(gMainGfxPos++);
277 gSPBranchList(savedGfxPos, gMainGfxPos);
278
279 gDPSetPrimColor(gMainGfxPos++, 0, 0, primR, primG, primB, primA);
280 gDPSetEnvColor(gMainGfxPos++, envR, envG, engB, envA);
281 gSPDisplayList(gMainGfxPos++, savedGfxPos + 1);
282
283 guRotateF(sp20, 120.0f, 1.0f, 1.0f, 1.0f);
285
286 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos], G_MTX_NOPUSH | G_MTX_MUL | G_MTX_MODELVIEW);
287 gSPDisplayList(gMainGfxPos++, savedGfxPos + 1);
288 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_NOPUSH | G_MTX_MUL | G_MTX_MODELVIEW);
289 gSPDisplayList(gMainGfxPos++, savedGfxPos + 1);
290 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
291 gDPPipeSync(gMainGfxPos++);
292 }
293}
Mtx matrixStack[0x200]
f32 Matrix4f[4][4]
#define general_heap_malloc
#define guRotateF
#define guMtxF2L
#define guTranslateF
#define guMtxCatF
#define remove_effect
#define rand_int
#define guPositionF
#define create_effect_instance
struct FireworkFXData * firework
Definition effects.h:2531
struct EffectGraphics * graphics
Definition effects.h:2606
EffectData data
Definition effects.h:2605
#define ASSERT(condition)
void func_E0086398(EffectInstance *effect)
Definition firework.c:168
void firework_update(EffectInstance *effect)
Definition firework.c:129
u8 D_E0086AC4[]
Definition firework.c:20
Gfx D_09000A40_38AD90[]
Gfx D_09000A00_38AD50[]
void firework_init(EffectInstance *effect)
Definition firework.c:126
Gfx * D_E0086AB4[]
Definition firework.c:16
u8 D_E0086AE4[]
Definition firework.c:30
u8 D_E0086AD4[]
Definition firework.c:25
Gfx D_09000A80_38ADD0[]
Gfx * D_E0086AA0[]
Definition firework.c:11
Gfx D_09000940_38AC90[]
Gfx D_09000A20_38AD70[]
u8 D_E0086AC0[]
Definition firework.c:18
void firework_render(EffectInstance *effect)
Definition firework.c:165
EffectInstance * firework_main(s32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4, s32 arg5)
Definition firework.c:43
Gfx D_09000A60_38ADB0[]
void func_E00863B4(EffectInstance *effect)
Definition firework.c:172
#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
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