Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
shockwave.c File Reference

Go to the source code of this file.

Functions

void shockwave_init (EffectInstance *effect)
 
void shockwave_update (EffectInstance *effect)
 
void shockwave_render (EffectInstance *effect)
 
void shockwave_appendGfx (void *effect)
 
void shockwave_main (s32 arg0, f32 arg1, f32 arg2, f32 arg3)
 

Variables

Gfx D_09000940_359CF0 []
 
Gfx D_090009A0_359D50 []
 
Gfx D_09000A80_359E30 []
 
Gfx * D_E004AE60 []
 

Function Documentation

◆ shockwave_init()

void shockwave_init ( EffectInstance * effect)

Definition at line 145 of file shockwave.c.

145 {
146}

Referenced by shockwave_main().

◆ shockwave_update()

void shockwave_update ( EffectInstance * effect)

Definition at line 148 of file shockwave.c.

148 {
149 ShockwaveFXData* part = effect->data.shockwave;
150 s32 unk_00;
151 s32 unk_2C;
152 s32 i;
153
154 part->unk_2C++;
155 part->unk_28--;
156
157 if (part->unk_28 < 0) {
158 remove_effect(effect);
159 return;
160 }
161
162 unk_00 = part->unk_00;
163 unk_2C = part->unk_2C;
164
165 switch (unk_00) {
166 case 0:
167 case 1:
168 if (unk_2C >= 8) {
169 part->alpha *= 0.8;
170 }
171 break;
172 default:
173 if (unk_2C >= 8) {
174 part->alpha *= 0.94;
175 }
176 break;
177 }
178
179 part++;
180 for (i = 1; i < effect->numParts; i++, part++) {
181 part->unk_4C++;
182 if (part->unk_4C >= 0) {
183 if (part->unk_4C == 0) {
184 part->pos.x = 0.0f;
185 part->pos.y = 0.0f;
186 part->pos.z = 0.0f;
187 part->unk_10 = -sin_deg(part->unk_34) * 0.5;
188 part->unk_14 = cos_deg(part->unk_34) * 0.5;
189 part->unk_18 = 0;
190 part->unk_3C = 32.0f;
191 part->unk_40 = 32.0f;
192 part->unk_48 = 32.0f;
193 part->unk_20 = 8.0 - (f32) i;
194
195 switch (unk_00) {
196 case 0:
197 case 1:
198 part->unk_1C = i + 0.5;
199 part->unk_24 = (i + 0.5) * 0.5;
200 break;
201 case 2:
202 case 5:
203 part->unk_1C = i + 2;
204 part->unk_24 = (i + 2) * 0.5;
205 break;
206 case 3:
207 part->unk_1C = i + 3;
208 part->unk_24 = (i + 3) * 0.5;
209 part->unk_3C = 16.0f;
210 part->unk_40 = 16.0f;
211 part->unk_48 = 16.0f;
212 break;
213 case 4:
214 default:
215 part->unk_1C = (i + 3) * 0.5;
216 part->unk_24 = (i + 3) * 0.5 * 0.5;
217 part->unk_3C = 16.0f;
218 part->unk_40 = 16.0f;
219 part->unk_48 = 16.0f;
220 part->unk_20 *= 0.8;
221 break;
222 }
223
224 part->unk_44 = 32.0f;
225 }
226
227 part->unk_3C += part->unk_40;
228 part->unk_44 += part->unk_48;
229
230 switch (unk_00) {
231 case 0:
232 case 1:
233 part->unk_40 *= 0.9;
234 break;
235 case 2:
236 case 5:
237 part->unk_40 *= 0.75;
238 part->unk_48 *= 0.99;
239 break;
240 default:
241 part->unk_40 *= 0.75;
242 part->unk_48 *= 0.95;
243 break;
244 }
245
246 part->unk_1C *= 1.002;
247 part->unk_24 *= 1.002;
248 if (part->unk_3C > 128.0f) {
249 part->unk_3C = 128.0f;
250 }
251 }
252 }
253}
#define sin_deg
#define remove_effect
#define cos_deg
struct ShockwaveFXData * shockwave
Definition effects.h:2501
EffectData data
Definition effects.h:2605

Referenced by shockwave_main().

◆ shockwave_render()

void shockwave_render ( EffectInstance * effect)

Definition at line 255 of file shockwave.c.

255 {
256 RenderTask renderTask;
257 RenderTask* retTask;
258
259 renderTask.appendGfx = shockwave_appendGfx;
260 renderTask.appendGfxArg = effect;
261 renderTask.dist = 0;
263
264 retTask = queue_render_task(&renderTask);
266}
#define queue_render_task
@ RENDER_TASK_FLAG_REFLECT_FLOOR
Definition enums.h:3318
@ RENDER_MODE_PASS_THROUGH
Definition enums.h:3306
void shockwave_appendGfx(void *effect)
Definition shockwave.c:268
void * appendGfxArg
void(* appendGfx)(void *)

Referenced by shockwave_main().

◆ shockwave_appendGfx()

void shockwave_appendGfx ( void * effect)

Definition at line 268 of file shockwave.c.

268 {
269 ShockwaveFXData* data = ((EffectInstance*) effect)->data.shockwave;
270 Matrix4f sp20, sp60;
271 Gfx* dlist = D_09000940_359CF0;
272 Gfx* dlist2;
273 s32 primA;
274 s32 primR, primG, primB;
275 s32 envR, envG, envB;
276 s32 primR2, primG2, primB2;
277 s32 envR2, envG2, envB2;
278 Gfx* savedGfxPos;
279 Gfx* savedGfxPos2;
280 s32 temp_v0;
281 s32 i;
282
283 primR = data->prim.r;
284 primG = data->prim.g;
285 primB = data->prim.b;
286 envR = data->env.r;
287 envG = data->env.g;
288 envB = data->env.b;
289 primR2 = data->prim.r;
290 primG2 = data->prim.g;
291 primB2 = data->prim.b;
292 envR2 = data->env.r;
293 envG2 = data->env.g;
294 envB2 = data->env.b;
295
296 temp_v0 = data->unk_00;
297 dlist2 = D_E004AE60[temp_v0];
298
299 if (temp_v0 >= 2) {
300 primR2 = primR >> 2;
301 primG2 = primG >> 2;
302 primB2 = primB >> 2;
303 envR2 = envR >> 2;
304 envG2 = envG >> 2;
305 envB2 = envB >> 2;
306 }
307
308 gDPPipeSync(gMainGfxPos++);
309 gSPSegment(gMainGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(((EffectInstance*)effect)->graphics->data));
310 gSPDisplayList(gMainGfxPos++, dlist2);
311
312 guPositionF(sp20, 0.0f, -gCameras[gCurrentCameraID].curYaw, 0.0f, 1.0f,
313 data->pos.x, data->pos.y, data->pos.z);
315
317 G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
318 primA = data->alpha;
319
320 savedGfxPos = gMainGfxPos;
321 gMainGfxPos++;
322 savedGfxPos2 = gMainGfxPos;
323
324 data++;
325 for (i = 1; i < ((EffectInstance*) effect)->numParts; i++, data++) {
326 if (data->unk_4C >= 0) {
327 guTranslateF(sp20, data->pos.x, data->pos.y, data->pos.z);
328 guRotateF(sp60, data->unk_34, 0.0f, 0.0f, 1.0f);
329 guMtxCatF(sp60, sp20, sp20);
330 guScaleF(sp60, data->unk_1C * 0.3, data->unk_20 * 0.3, data->unk_24 * 0.3);
331 guMtxCatF(sp60, sp20, sp20);
332 guRotateF(sp60, data->unk_30, 0.0f, 1.0f, 0.0f);
333 guMtxCatF(sp60, sp20, sp20);
335
336 gDPSetTileSize(gMainGfxPos++, G_TX_RENDERTILE, 0, (s32) data->unk_3C, 0x00FC, (s32) data->unk_3C + 0x7C);
337 gDPSetTileSize(gMainGfxPos++, 1, 0, (s32) data->unk_44, 0x007C, (s32) data->unk_44 + 0x7C);
338
340 G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
341 gSPDisplayList(gMainGfxPos++, dlist);
342 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
343 }
344 }
345 gSPEndDisplayList(gMainGfxPos++);
346 gSPBranchList(savedGfxPos, gMainGfxPos);
347 gDPSetPrimColor(gMainGfxPos++, 0, 0, primR2, primG2, primB2, primA);
348 gDPSetEnvColor(gMainGfxPos++, envR2, envG2, envB2, 0);
349 gSPClearGeometryMode(gMainGfxPos++, G_CULL_BOTH);
350 gSPSetGeometryMode(gMainGfxPos++, G_CULL_FRONT);
351 gSPDisplayList(gMainGfxPos++, savedGfxPos2);
352 gDPSetPrimColor(gMainGfxPos++, 0, 0, primR, primG, primB, primA);
353 gDPSetEnvColor(gMainGfxPos++, envR, envG, envB, 0);
354 gSPClearGeometryMode(gMainGfxPos++, G_CULL_BOTH);
355 gSPSetGeometryMode(gMainGfxPos++, G_CULL_BACK);
356 gSPDisplayList(gMainGfxPos++, savedGfxPos2);
357 gDPSetColorDither(gMainGfxPos++, G_CD_DISABLE);
358 gDPSetAlphaDither(gMainGfxPos++, G_AD_DISABLE);
359 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
360}
Mtx matrixStack[0x200]
f32 Matrix4f[4][4]
#define guRotateF
#define guMtxF2L
#define guTranslateF
#define guMtxCatF
#define guPositionF
#define guScaleF
Color_RGB8 prim
Definition effects.h:573
Color_RGB8 env
Definition effects.h:574
#define VIRTUAL_TO_PHYSICAL(addr)
Definition macros.h:47
Gfx * D_E004AE60[]
Definition shockwave.c:8
Gfx D_09000940_359CF0[]
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

Referenced by shockwave_render().

◆ shockwave_main()

void shockwave_main ( s32 arg0,
f32 arg1,
f32 arg2,
f32 arg3 )

Definition at line 18 of file shockwave.c.

18 {
20 EffectBlueprint* bpPtr = &bp;
21 EffectInstance* effect;
22 ShockwaveFXData* part;
23 f32 zero = 0.0f;
24 s32 numParts;
25 s32 i;
26
27 switch (arg0) {
28 case 0:
29 arg0 = 3;
30 break;
31 case 1:
32 arg0 = 2;
33 break;
34 case 2:
35 arg0 = 4;
36 break;
37 default:
38 arg0 = 5;
39 break;
40 }
41
42 switch (arg0) {
43 case 1:
44 numParts = 1;
45 break;
46 case 0:
47 case 2:
48 case 5:
49 numParts = 3;
50 break;
51 default:
52 numParts = 2;
53 break;
54 }
55
56 numParts++;
57
58 bpPtr->init = shockwave_init;
59 bpPtr->update = shockwave_update;
61 bpPtr->unk_00 = 0;
62 bpPtr->renderUI = NULL;
63 bpPtr->effectID = EFFECT_SHOCKWAVE;
64
65 effect = create_effect_instance(bpPtr);
66 effect->numParts = numParts;
67 part = effect->data.shockwave = general_heap_malloc(numParts * sizeof(*part));
68 ASSERT(effect->data.shockwave != NULL);
69
70 mem_clear(part, numParts * sizeof(*part));
71
72 if (arg0 >= 2) {
73 part->unk_28 = 60;
74 } else {
75 part->unk_28 = 30;
76 }
77 part->alpha = 255;
78 part->unk_2C = 0;
79 part->unk_00 = arg0;
80 part->pos.x = arg1;
81 part->pos.y = arg2;
82 part->pos.z = arg3;
83
84 switch (arg0) {
85 case 0:
86 case 1:
87 part->prim.r = 0;
88 part->prim.g = 255;
89 part->prim.b = 122;
90 part->env.r = 240;
91 part->env.g = 255;
92 part->env.b = 250;
93 break;
94 case 2:
95 part->prim.r = 125;
96 part->prim.g = 120;
97 part->prim.b = 100;
98 part->env.r = 255;
99 part->env.g = 255;
100 part->env.b = 240;
101 break;
102 case 3:
103 part->prim.r = 220;
104 part->prim.g = 210;
105 part->prim.b = 200;
106 part->env.r = 255;
107 part->env.g = 255;
108 part->env.b = 250;
109 break;
110 case 5:
111 part->prim.r = 225;
112 part->prim.g = 204;
113 part->prim.b = 93;
114 part->env.r = 232;
115 part->env.g = 231;
116 part->env.b = 171;
117 break;
118 default:
119 part->unk_28 = 50;
120 part->prim.r = 208;
121 part->prim.g = 136;
122 part->prim.b = 40;
123 part->env.r = 216;
124 part->env.g = 169;
125 part->env.b = 65;
126 break;
127 }
128
129 part++;
130 for (i = 1; i < numParts; i++, part++) {
131 switch (arg0) {
132 case 0:
133 case 1:
134 part->unk_4C = 1 + i * -2;
135 break;
136 default:
137 part->unk_4C = 2 + i * -3;
138 break;
139 }
140 part->unk_34 = zero;
141 part->unk_30 = i * 30;
142 }
143}
#define general_heap_malloc
#define create_effect_instance
#define mem_clear
#define ASSERT(condition)
void shockwave_init(EffectInstance *effect)
Definition shockwave.c:145
void shockwave_update(EffectInstance *effect)
Definition shockwave.c:148
void shockwave_render(EffectInstance *effect)
Definition shockwave.c:255
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

Variable Documentation

◆ D_09000940_359CF0

Gfx D_09000940_359CF0[]
extern

Referenced by shockwave_appendGfx().

◆ D_090009A0_359D50

Gfx D_090009A0_359D50[]
extern

◆ D_09000A80_359E30

Gfx D_09000A80_359E30[]
extern

◆ D_E004AE60