Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
star_spirits_energy.c
Go to the documentation of this file.
1#include "common.h"
2#include "effects_internal.h"
3
4extern Gfx D_09004E00_412090[];
5extern Gfx D_09005168_4123F8[];
6extern Gfx D_090051C8_412458[];
7extern Gfx D_09005370_412600[];
8extern Gfx D_090053D0_412660[];
9extern Gfx D_09005440_4126D0[];
10
14
17
18typedef struct UnkStarSpiritsEnergy {
19 /* 0x00 */ u16 unk_00;
20 /* 0x02 */ char unk_02;
21 /* 0x03 */ u8 unk_03;
22} UnkStarSpiritsEnergy; // size = 0x4
23
25 { 100, 0, 255 },
26 { 200, 0, 255 },
27 { 300, 0, 255 },
28 { 400, 0, 255 },
29 { 500, 0, 245 },
30 { 600, 0, 235 },
31 { 700, 0, 225 },
32 { 800, 0, 215 },
33 { 900, 0, 205 },
34 { 1000, 0, 195 },
35 { 1100, 0, 185 },
36 { 1200, 0, 175 },
37 { 1300, 0, 165 },
38 { 1400, 0, 155 },
39 { 1500, 0, 145 },
40 { 1600, 0, 135 },
41 { 1700, 0, 125 },
42 { 1800, 0, 115 },
43 { 1900, 0, 105 },
44 { 2000, 0, 95 },
45 { 2100, 0, 85 },
46 { 2200, 0, 75 },
47 { 2300, 0, 65 },
48 { 2400, 0, 55 },
49 { 2500, 0, 45 },
50 { 2600, 0, 30 },
51 { 2700, 0, 20 },
52 { 2800, 0, 10 },
53 { 2900, 0, 5 },
54 { 3000, 0, 0 },
55};
56
58 { 3000, 0, 0 },
59 { 2900, 0, 5 },
60 { 2800, 0, 10 },
61 { 2700, 0, 20 },
62 { 2600, 0, 30 },
63 { 2500, 0, 45 },
64 { 2400, 0, 55 },
65 { 2300, 0, 65 },
66 { 2200, 0, 75 },
67 { 2100, 0, 85 },
68 { 2000, 0, 95 },
69 { 1900, 0, 105 },
70 { 1800, 0, 115 },
71 { 1700, 0, 125 },
72 { 1600, 0, 135 },
73 { 1500, 0, 145 },
74 { 1400, 0, 155 },
75 { 1300, 0, 165 },
76 { 1200, 0, 175 },
77 { 1100, 0, 185 },
78 { 1000, 0, 195 },
79 { 900, 0, 205 },
80 { 800, 0, 215 },
81 { 700, 0, 225 },
82 { 600, 0, 235 },
83 { 500, 0, 245 },
84 { 400, 0, 255 },
85 { 300, 0, 255 },
86 { 200, 0, 255 },
87 { 100, 0, 255 },
88};
89
93void star_spirits_energy_appendGfx(void* effect);
94
95EffectInstance* star_spirits_energy_main(s32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4, s32 arg5) {
97 EffectInstance* effect;
99 s32 numParts = 1;
100
104 bp.unk_00 = 0;
105 bp.renderUI = NULL;
106 bp.effectID = EFFECT_STAR_SPIRITS_ENERGY;
107
108 effect = create_effect_instance(&bp);
109 effect->numParts = numParts;
110 data = effect->data.starSpiritsEnergy = general_heap_malloc(numParts * sizeof(*data));
111 ASSERT(effect->data.starSpiritsEnergy != NULL);
112
113 data->unk_00 = arg0 & 0xFF00;
114 arg0 &= 0xFF;
115 data->unk_04 = arg0;
116 data->unk_18 = 0;
117 if (arg5 <= 0) {
118 data->unk_14 = 1000;
119 } else {
120 data->unk_14 = arg5;
121 }
122 data->unk_28 = 255;
123 data->unk_08 = arg1;
124 data->unk_0C = arg2;
125 data->unk_10 = arg3;
126 data->unk_3C = arg4;
127 data->unk_1C = 255;
128 data->unk_20 = 255;
129 data->unk_24 = 255;
130 data->unk_2C = 255;
131 data->unk_30 = 255;
132 data->unk_34 = 255;
133 data->unk_38 = 255;
134 data->unk_60 = 0;
135 data->unk_64 = 0;
136 data->unk_68 = 0;
137 data->unk_6C = 0;
138 data->unk_40[0] = 1.0f;
139 data->unk_40[1] = 0;
140 data->unk_40[2] = 0;
141 data->unk_40[3] = 0;
142 data->unk_50[0] = 255;
143 data->unk_50[1] = 0;
144 data->unk_50[2] = 0;
145 data->unk_50[3] = 0;
146 if (arg0 == 3) {
147 data->unk_70 = 1;
148 } else {
149 data->unk_70 = 0;
150 }
151 data->unk_74 = 0;
152
153 return effect;
154}
155
158
161 s32 unk_04 = data->unk_04;
162 s32 unk_18;
163 s32 i;
164 f32 var_float_1;
165 f32 var_float_2;
166 f32 var_float_3;
167 u8 var_int_1;
168 u8 var_int_2;
169 u8 var_int_3;
170
171 if (effect->flags & FX_INSTANCE_FLAG_DISMISS) {
172 effect->flags &= ~FX_INSTANCE_FLAG_DISMISS;
173 data->unk_14 = 16;
174 }
175
176 if (data->unk_14 < 1000) {
177 data->unk_14--;
178 }
179
180 data->unk_18++;
181
182 if (data->unk_14 < 0) {
183 remove_effect(effect);
184 return;
185 }
186
187 unk_18 = data->unk_18;
188
189 if (data->unk_14 < 16) {
190 data->unk_28 = data->unk_14 * 16;
191 }
192
193 switch (data->unk_70) {
194 case 0:
195 data->unk_50[0] = (unk_18 & 3) * 30 + 200;
196 data->unk_74++;
197 data->unk_40[0] = sin_deg(unk_18 * 20) * 0.04 + 0.5;
198 if (data->unk_00 != 0) {
199 data->unk_08 += sin_deg(unk_18);
200 data->unk_0C += cos_deg(unk_18 * 1.235631);
201 if (data->unk_74 > 50) {
202 data->unk_74 = 0;
203 if (unk_04 == 3) {
204 data->unk_70 = 100;
205 } else {
206 data->unk_70 = 1;
207 }
208 }
209 }
210 break;
211 case 100:
212 switch (data->unk_74) {
213 case 0:
214 data->unk_40[3] = 4.0f;
215 data->unk_50[3] = 255;
216 break;
217 case 1:
218 data->unk_40[3] = 8.0f;
219 data->unk_50[3] = 255;
220 break;
221 default:
222 data->unk_40[3] = 0.0f;
223 data->unk_50[3] = 0;
224 break;
225 }
226 if (data->unk_74 < 30) {
227 var_float_1 = (f32) D_E0122BA8[data->unk_74].unk_00 * 0.01 + data->unk_74 * 0.3;
228 var_int_1 = D_E0122BA8[data->unk_74].unk_03;
229 } else {
230 var_float_1 = (f32) D_E0122BA8[29].unk_00 * 0.01 + data->unk_74 * 0.3;
231 var_int_1 = D_E0122BA8[29].unk_03;
232 }
233 data->unk_40[0] = data->unk_50[0] = 0;
234 data->unk_50[1] = var_int_1;
235 data->unk_50[2] = var_int_1;
236 data->unk_40[1] = var_float_1;
237 data->unk_40[2] = var_float_1 + 0.6;
238 data->unk_74++;
239 break;
240 case 1:
241 switch (data->unk_74) {
242 case 0:
243 data->unk_40[3] = 4.0f;
244 data->unk_50[3] = 255;
245 break;
246 case 1:
247 data->unk_40[3] = 8.0f;
248 data->unk_50[3] = 255;
249 break;
250 default:
251 data->unk_40[3] = 0.0f;
252 data->unk_50[3] = 0;
253 break;
254 }
255 var_float_2 = (f32) D_E0122BA8[data->unk_74].unk_00 * 0.01;
256 var_int_2 = D_E0122BA8[data->unk_74].unk_03;
257
258 data->unk_40[0] = data->unk_50[0] = 0;
259 data->unk_50[1] = var_int_2;
260 data->unk_50[2] = var_int_2;
261 data->unk_40[1] = var_float_2;
262 data->unk_40[2] = var_float_2 * 1.2 + 4.0;
263 data->unk_74++;
264 if (data->unk_74 >= 30) {
265 data->unk_74 = 0;
266 data->unk_70 = 4;
267 }
268 break;
269 case 4:
270 switch (29 - data->unk_74) {
271 case 0:
272 data->unk_40[3] = 4.0f;
273 data->unk_50[3] = 255;
274 break;
275 case 1:
276 data->unk_40[3] = 8.0f;
277 data->unk_50[3] = 255;
278 break;
279 default:
280 data->unk_40[3] = 0;
281 data->unk_50[3] = 0;
282 break;
283 }
284 var_float_3 = (f32) D_E0122C20[data->unk_74].unk_00 * 0.01;
285 var_int_3 = D_E0122C20[data->unk_74].unk_03;
286 data->unk_40[0] = data->unk_50[0] = 0;
287 data->unk_50[1] = var_int_3;
288 data->unk_50[2] = 0;
289 data->unk_40[1] = var_float_3;
290 data->unk_40[2] = 0.0f;
291 data->unk_74++;
292 if (data->unk_74 >= 30) {
293 data->unk_74 = 0;
294 data->unk_70 = 5;
295 }
296 break;
297 case 5:
298 default:
299 data->unk_40[0] = 0.0f;
300 data->unk_40[1] = 0.0f;
301 data->unk_40[2] = 0.0f;
302 data->unk_50[0] = 0;
303 data->unk_50[1] = 0;
304 data->unk_50[2] = 0;
305 data->unk_40[3] = 0;
306 data->unk_50[3] = 0;
307 data->unk_40[3] = 0;
308 data->unk_74++;
309 break;
310 }
311
312 for (i = 0; i < 4; i++) {
313 if (data->unk_50[i] > 255) {
314 data->unk_50[i] = 255;
315 }
316 if (data->unk_50[i] < 0) {
317 data->unk_50[i] = 0;
318 }
319 if (data->unk_40[i] < 0.0f) {
320 data->unk_40[i] = 0.0f;
321 }
322 }
323}
324
326 RenderTask renderTask;
327 RenderTask* retTask;
328
330 renderTask.appendGfxArg = effect;
331 renderTask.dist = 10;
333
334 retTask = queue_render_task(&renderTask);
336}
337
339 StarSpiritsEnergyFXData* data = ((EffectInstance*)effect)->data.starSpiritsEnergy;
340 s32 unk_04 = data->unk_04;
341 s32 alpha;
342 Matrix4f sp20;
343 s32 i;
344
345 gDPPipeSync(gMainGfxPos++);
346 gSPSegment(gMainGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(((EffectInstance*)effect)->graphics->data));
347
348 guPositionF(sp20, 0.0f, -gCameras[gCurrentCameraID].curYaw, 0.0f,
349 data->unk_3C, data->unk_08, data->unk_0C, data->unk_10);
351
353 G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
354 gSPDisplayList(gMainGfxPos++, D_E0122BA4[0]);
355 gDPSetEnvColor(gMainGfxPos++, data->unk_2C, data->unk_30, data->unk_34, data->unk_38);
356
357 for (i = 0; i < 4; i++) {
358 if (unk_04 != 1 || i != 2) {
359 if (data->unk_40[i] != 0.0f && data->unk_50[i] != 0) {
360 guPositionF(sp20, 0.0f, 0.0f, 0.0f, data->unk_40[i], 0.0f, 0.0f, 0.0f);
362
364 G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
365 gDPSetPrimColor(gMainGfxPos++, 0, 0, data->unk_1C, data->unk_20, data->unk_24, data->unk_50[i]);
366 gSPDisplayList(gMainGfxPos++, D_E0122B90[i]);
367 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
368 }
369 }
370 }
371
372 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
373
374 if (unk_04 == 2 || unk_04 == 3) {
375 alpha = 0;
376
377 if ((data->unk_70 == 1 || data->unk_70 == 100) && data->unk_74 > 2 && data->unk_74 < 11) {
378 alpha = 255 - (data->unk_74 - 2) * 30;
379 }
380
381 if (data->unk_70 == 5 && data->unk_74 > 0 && data->unk_74 < 9) {
382 alpha = 255 - data->unk_74 * 30;
383 }
384
385 if (alpha > 0) {
386 gDPSetPrimColor(gMainGfxPos++, 0, 0, 208, 208, 208, alpha);
387 gSPDisplayList(gMainGfxPos++, D_E0122BA0[0]);
388 }
389 }
390
391 gDPPipeSync(gMainGfxPos++);
392}
Mtx matrixStack[0x200]
f32 Matrix4f[4][4]
#define general_heap_malloc
#define queue_render_task
#define guMtxF2L
#define sin_deg
#define remove_effect
#define guPositionF
#define cos_deg
#define create_effect_instance
struct StarSpiritsEnergyFXData * starSpiritsEnergy
Definition effects.h:2595
EffectData data
Definition effects.h:2605
#define ASSERT(condition)
@ FX_INSTANCE_FLAG_DISMISS
Definition enums.h:3517
@ RENDER_TASK_FLAG_REFLECT_FLOOR
Definition enums.h:3318
@ RENDER_MODE_CLOUD_NO_ZCMP
Definition enums.h:3311
#define VIRTUAL_TO_PHYSICAL(addr)
Definition macros.h:47
Gfx D_09005440_4126D0[]
Gfx D_09005168_4123F8[]
void star_spirits_energy_init(EffectInstance *effect)
UnkStarSpiritsEnergy D_E0122C20[]
Gfx D_090053D0_412660[]
Gfx * D_E0122B90[]
Gfx D_09004E00_412090[]
UnkStarSpiritsEnergy D_E0122BA8[]
Gfx * D_E0122BA0[]
void star_spirits_energy_render(EffectInstance *effect)
Gfx D_09005370_412600[]
void star_spirits_energy_update(EffectInstance *effect)
EffectInstance * star_spirits_energy_main(s32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4, s32 arg5)
Gfx * D_E0122BA4[]
Gfx D_090051C8_412458[]
void star_spirits_energy_appendGfx(void *effect)
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