Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
shimmer_burst.c
Go to the documentation of this file.
1#include "common.h"
2#include "effects_internal.h"
3
4extern Gfx D_09000F20_338EE0[];
5extern Gfx D_090011C8_339188[];
6extern Gfx D_090011E0_3391A0[];
7extern Gfx D_090011F8_3391B8[];
8extern Gfx D_09001210_3391D0[];
9extern Gfx D_09001228_3391E8[];
10extern Gfx D_09001240_339200[];
11extern Gfx D_09001258_339218[];
12extern Gfx D_09001270_339230[];
13
18
19f32 D_E0070CF0[] = {
20 0.2f, 0.4f, 0.8f, 1.3f, 1.5f, 1.3f, 0.9f, 0.6f, 0.4f, 0.3f,
21 0.2f, 0.4f, 0.8f, 1.3f, 1.5f, 1.3f, 0.9f, 0.6f, 0.4f, 0.3f
22};
23
24s32 D_E0070D70[] = {
25 0xC8FAFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFAC8, 0x00000000, 0x00000000, 0x00000000
26};
27
31void shimmer_burst_appendGfx(void* effect);
32
33EffectInstance* shimmer_burst_main(s32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4, s32 arg5) {
35 EffectInstance* effect;
37 s32 numParts = 61;
38 s32 temp30 = 30;
39 f32 temp;
40 s32 i;
41
45 bp.unk_00 = 0;
46 bp.renderUI = NULL;
47 bp.effectID = EFFECT_SHIMMER_BURST;
48
49 effect = create_effect_instance(&bp);
50 effect->numParts = numParts;
51 part = effect->data.shimmerBurst = general_heap_malloc(numParts * sizeof(*part));
52 ASSERT(effect->data.shimmerBurst != NULL);
53
54 part->unk_00 = arg0;
55 part->unk_3C = 0;
56 if (arg5 <= 0) {
57 part->unk_38 = 1000;
58 } else {
59 part->unk_38 = arg5;
60 }
61 part->unk_4C = 255;
62 part->unk_04 = arg1;
63 part->unk_08 = arg2;
64 part->unk_0C = arg3;
65 part->unk_60 = arg4;
66 part->unk_10 = temp30;
67 part->unk_14 = temp30;
68 part->unk_40 = 255;
69 part->unk_44 = 255;
70 part->unk_48 = 255;
71
72 if (arg0 == 0) {
73 part->unk_50 = 215;
74 part->unk_54 = 255;
75 part->unk_58 = 235;
76 part->unk_5C = 255;
77 } else {
78 part->unk_50 = 255;
79 part->unk_54 = 127;
80 part->unk_58 = 255;
81 part->unk_5C = 255;
82 }
83
84 part++;
85
86 if (arg5 < 20) {
87 temp = 20.0f / (numParts - 1);
88 } else {
89 temp = (f32) arg5 / (numParts - 1);
90 }
91
92 for (i = 1; i < numParts; i++, part++) {
93 part->unk_30 = (s32) (-(f32) i * temp) - 1;
94 }
95
96 return effect;
97}
98
101
103 ShimmerBurstFXData* part = effect->data.shimmerBurst;
104 s32 unk_00 = part->unk_00;
105 f32 unk_10;
106 f32 unk_14;
107 s32 i;
108
109 if (effect->flags & FX_INSTANCE_FLAG_DISMISS) {
110 effect->flags &= ~FX_INSTANCE_FLAG_DISMISS;
111 part->unk_38 = 16;
112 }
113
114 if (part->unk_38 < 1000) {
115 part->unk_38--;
116 }
117
118 part->unk_3C++;
119
120 if (part->unk_38 < 0) {
121 remove_effect(effect);
122 return;
123 }
124
125 if (part->unk_38 < 8) {
126 part->unk_4C = part->unk_38 * 32;
127 }
128
129 unk_10 = part->unk_10;
130 unk_14 = part->unk_14;
131
132 part++;
133 for (i = 1; i < effect->numParts; i++, part++) {
134 part->unk_30++;
135 if (part->unk_30 >= ARRAY_COUNT(D_E0070CF0)) {
136 part->unk_30 = 0;
137 }
138
139 if (part->unk_30 >= 0) {
140 if (part->unk_30 == 0) {
141 f32 rand1 = rand_int(359);
142 f32 rand2 = rand_int(359);
143
144 if (unk_00 == 0) {
145 part->unk_04 = unk_10 * sin_deg(rand1) * cos_deg(rand2);
146 part->unk_08 = unk_14 * cos_deg(rand1) * cos_deg(rand2);
147 part->unk_0C = unk_10 * sin_deg(rand2);
148 part->unk_18 = part->unk_04 * 0.4;
149 part->unk_1C = part->unk_08 * 0.4;
150 part->unk_20 = part->unk_0C * 0.4;
151 part->unk_24 = part->unk_18 * 0.1;
152 part->unk_28 = part->unk_1C * 0.1;
153 part->unk_2C = part->unk_20 * 0.1;
154 } else {
155 part->unk_04 = rand_int(unk_10) - unk_10 * 0.5;
156 part->unk_08 = rand_int(unk_14) - unk_14 * 0.5;
157 part->unk_0C = rand_int(unk_10) - unk_10 * 0.5;
158 part->unk_18 = part->unk_04 * 0.3;
159 part->unk_1C = part->unk_08 * 0.3;
160 part->unk_20 = part->unk_0C * 0.3;
161 part->unk_24 = part->unk_18 * 0.02;
162 part->unk_28 = part->unk_1C * 0.02;
163 part->unk_2C = part->unk_20 * 0.02;
164 }
165
166 part->unk_64 = rand_int(15);
167 part->unk_68 = rand_int(15);
168 part->unk_34 = 0.0f;
169 part->unk_4C = 255;
170 }
171
172 part->unk_60 = D_E0070CF0[part->unk_30];
173 part->unk_34 += 4.0f;
174 part->unk_04 += part->unk_18;
175 part->unk_08 += part->unk_1C;
176 part->unk_0C += part->unk_20;
177 part->unk_64 += 0.2;
178 part->unk_68 += 0.6;
179 part->unk_18 += (part->unk_24 - part->unk_18) * 0.04;
180 part->unk_1C += (part->unk_28 - part->unk_1C) * 0.04;
181 part->unk_20 += (part->unk_2C - part->unk_20) * 0.04;
182 }
183 }
184}
185
187 RenderTask renderTask;
188 RenderTask* retTask;
189
191 renderTask.appendGfxArg = effect;
192 renderTask.dist = 10;
194
195 retTask = queue_render_task(&renderTask);
197}
198
199void func_E0070738(void) {
200}
201
202void shimmer_burst_appendGfx(void* effect) {
203 ShimmerBurstFXData* part = ((EffectInstance*)effect)->data.shimmerBurst;
204 s32 unk_50 = part->unk_50;
205 s32 unk_54 = part->unk_54;
206 s32 unk_58 = part->unk_58;
207 f32 temp_f20 = part->unk_4C / 255.0f;
208 Gfx* savedGfxPos;
209 Matrix4f sp20;
210 Matrix4f sp60;
211 s32 i;
212
213 gDPPipeSync(gMainGfxPos++);
214 gSPSegment(gMainGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(((EffectInstance*)effect)->graphics->data));
215
216 guTranslateF(sp20, part->unk_04, part->unk_08, part->unk_0C);
217 guScaleF(sp60, part->unk_60, part->unk_60, part->unk_60);
218 guMtxCatF(sp60, sp20, sp20);
220
221 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
222 gDPSetEnvColor(gMainGfxPos++, part->unk_40, part->unk_44, part->unk_48, part->unk_5C);
223 gSPDisplayList(gMainGfxPos++, D_09000F20_338EE0);
224
225 savedGfxPos = gMainGfxPos;
226 gMainGfxPos++;
227
228 part++;
229 for (i = 1; i < ((EffectInstance*)effect)->numParts; i++, part++) {
230 if (part->unk_30 >= 0) {
231 guPositionF(sp20, 0.0f, 0.0f, part->unk_34, part->unk_60 * temp_f20, part->unk_04, part->unk_08, part->unk_0C);
233
234 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
235 gDPSetPrimColor(gMainGfxPos++, 0, 0, unk_50, unk_54, unk_58, part->unk_4C * temp_f20);
236 gSPDisplayList(gMainGfxPos++, D_E0070CD0[i & 7]);
237 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
238 }
239 }
240
241 gSPEndDisplayList(gMainGfxPos++);
242 gSPBranchList(savedGfxPos, gMainGfxPos);
243 gSPDisplayList(gMainGfxPos++, savedGfxPos + 1);
244
245 guRotateF(sp20, 120.0f, 0.4f, 0.0f, 0.8f);
247
248 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
249 gSPDisplayList(gMainGfxPos++, savedGfxPos + 1);
250 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
251
252 guRotateF(sp20, -120.0f, 0.4f, 0.0f, 0.8f);
254
255 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
256 gSPDisplayList(gMainGfxPos++, savedGfxPos + 1);
257 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
258 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
259}
Mtx matrixStack[0x200]
f32 Matrix4f[4][4]
s8 unk_14
Definition demo_api.c:19
#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 guPositionF
#define cos_deg
#define create_effect_instance
#define guScaleF
struct ShimmerBurstFXData * shimmerBurst
Definition effects.h:2520
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 ARRAY_COUNT(arr)
Definition macros.h:40
#define VIRTUAL_TO_PHYSICAL(addr)
Definition macros.h:47
void shimmer_burst_init(EffectInstance *effect)
void shimmer_burst_update(EffectInstance *effect)
Gfx D_090011E0_3391A0[]
Gfx D_09001228_3391E8[]
Gfx D_09000F20_338EE0[]
Gfx D_090011C8_339188[]
Gfx * D_E0070CD0[]
EffectInstance * shimmer_burst_main(s32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4, s32 arg5)
void shimmer_burst_render(EffectInstance *effect)
void func_E0070738(void)
s32 D_E0070D70[]
Gfx D_09001210_3391D0[]
f32 D_E0070CF0[]
Gfx D_090011F8_3391B8[]
Gfx D_09001258_339218[]
void shimmer_burst_appendGfx(void *effect)
Gfx D_09001270_339230[]
Gfx D_09001240_339200[]
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 *)
Gfx * gMainGfxPos
Definition cam_main.c:15
u16 gMatrixListPos
Definition main_loop.c:45
DisplayContext * gDisplayContext
Definition cam_main.c:16