Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
explosion.c
Go to the documentation of this file.
1#include "common.h"
2#include "effects_internal.h"
3
7void explosion_appendGfx(void* effect);
8
9extern Gfx D_09000840_3447B0[];
10extern Gfx D_090008F0_344860[];
11extern Gfx D_09000910_344880[];
12extern Gfx D_09000978_3448E8[];
13extern Gfx D_090009D8_344948[];
14extern Gfx D_09000A38_3449A8[];
15
17
18void explosion_main(s32 type, f32 x, f32 y, f32 z) {
20 EffectBlueprint* bpPtr = &bp;
21 EffectInstance* effect;
22 ExplosionFXData* data;
23 s32 numParts = 3;
24
25 // TODO this terrible if-else required to match
26 s32 dumb;
27 s32 temp;
28 if (type != 0) {
29 dumb = 0;
30 } else {
31 temp = 0;
32 dumb = temp;
33 }
34
35 bpPtr->unk_00 = 0;
36 bpPtr->init = explosion_init;
37 bpPtr->update = explosion_update;
39 bpPtr->renderUI = NULL;
40 bpPtr->effectID = EFFECT_EXPLOSION;
41
42 effect = create_effect_instance(bpPtr);
43 effect->numParts = numParts;
44 effect->data.explosion = data = general_heap_malloc(effect->numParts * sizeof(*data));
45 ASSERT(effect->data.explosion != NULL);
46
47 data->pos.x = x;
48 data->pos.y = y;
49 data->pos.z = z;
50 data->unk_34 = 0;
51 data->unk_30 = 60;
52 data->unk_00 = type;
53
54 data++;
55 data->unk_00 = type;
56 if (type == 0) {
57 data->unk_00 = -1;
58 }
59 data->unk_38 = 0;
60 if (type == 1) {
61 data->unk_20 = 1.0f;
62 } else {
63 data->unk_20 = 3.0f;
64 }
65 if (type == 1) {
66 data->unk_24 = 1.0f;
67 } else {
68 data->unk_24 = 3.0f;
69 }
70
71 data++;
72 data->unk_00 = type;
73 data->unk_38 = 255;
74 switch (type) {
75 case 0:
76 data->unk_20 = 9.9f;
77 data->unk_24 = 1.6f;
78 break;
79 case 1:
80 data->unk_20 = 13.9f;
81 data->unk_24 = 2.4f;
82 break;
83 default:
84 data->unk_20 = 17.8f;
85 data->unk_24 = 3.2f;
86 break;
87 }
88 data->unk_28 = 0.0f;
89 data->unk_2C = 30.0f;
90}
91
93}
94
97
99 ExplosionFXData* part = effect->data.explosion;
100 s32 unk_00;
101 s32 unk_34;
102
103 part->unk_30--;
104 if (part->unk_30 < 0) {
105 remove_effect(effect);
106 return;
107 }
108
109 part->unk_34++;
110
111 unk_00 = part->unk_00;
112 unk_34 = part->unk_34;
113
114 if (unk_34 == 7) {
115 load_effect(EFFECT_SMOKE_RING);
116 smoke_ring_main(unk_00, part->pos.x, part->pos.y, part->pos.z);
117 } else if (unk_34 == 1) {
118 load_effect(EFFECT_CONFETTI);
119 confetti_main(unk_00 + 4, part->pos.x, part->pos.y, part->pos.z, 1.0f, 50);
120 }
121
122 part++;
123
124 part->unk_20 += part->unk_24;
125
126 if (unk_34 < 8) {
127 part->unk_24 += (unk_00 == 2) ? 1.0f : 0.4;
128 part->unk_38 = (255 - part->unk_38) * 0.6;
129 } else {
130 part->unk_24 *= 0.6;
131 part->unk_38 *= 0.9;
132 }
133
134 part++;
135
136 if (unk_34 >= 3) {
137 if (unk_34 == 3) {
138 part->unk_20 = 1.0f;
139 }
140 part->unk_20 += part->unk_24;
141 if (unk_34 < 6) {
142 part->unk_24 += 0.1;
143 } else {
144 part->unk_24 *= 0.5;
145 part->unk_38 *= 0.9;
146 }
147 }
148
149 part->unk_28 += part->unk_2C;
150}
151
153 RenderTask renderTask;
154 RenderTask* retTask;
155
156 renderTask.appendGfx = explosion_appendGfx;
157 renderTask.appendGfxArg = effect;
158 renderTask.dist = 10;
160
161 retTask = queue_render_task(&renderTask);
162}
163
164void explosion_appendGfx(void* effect) {
165 ExplosionFXData* part = ((EffectInstance*)effect)->data.explosion;
166 s32 unk_34 = part->unk_34;
167 Matrix4f sp18;
168 Matrix4f sp58;
169 s32 primAlpha;
170 s32 primB;
171 s32 cond;
172
173 gDPPipeSync(gMainGfxPos++);
174 gSPSegment(gMainGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(((EffectInstance*)effect)->shared->graphics));
175
176 guTranslateF(sp18, part->pos.x, part->pos.y, part->pos.z);
177 guRotateF(sp58, -gCameras[gCurrentCameraID].curYaw, 0.0f, 1.0f, 0.0f);
178 guMtxCatF(sp58, sp18, sp18);
180
181 part++;
182
183 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
184
185 if (part->unk_00 != -1) {
186 gSPDisplayList(gMainGfxPos++, D_09000840_3447B0);
187
188 guScaleF(sp18, part->unk_20, part->unk_20, 1.0f);
190
191 gDPSetPrimColor(gMainGfxPos++, 0, 0, 255, 255, 240, part->unk_38);
192 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
193 gSPDisplayList(gMainGfxPos++, D_090008F0_344860);
194 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
195 }
196
197 part++;
198
199 gSPDisplayList(gMainGfxPos++, D_09000910_344880);
200
201 guScaleF(sp18, part->unk_20, part->unk_20, part->unk_20);
202 guRotateF(sp58, part->unk_28, 0.0f, 0.0f, 1.0f);
203 guMtxCatF(sp58, sp18, sp18);
205
206 switch (unk_34) {
207 default:
208 primAlpha = part->unk_38;
209 break;
210 case 2:
211 primAlpha = 255;
212 break;
213 case 1:
214 primAlpha = 192;
215 break;
216 }
217
218 cond = (unk_34 < 3); // required to match
219 if (!cond && unk_34 < 8) {
220 primB = unk_34 * 16 + 128;
221 } else {
222 primB = 255;
223 }
224
225 gDPSetPrimColor(gMainGfxPos++, 0, 0, 255, 255, primB, primAlpha);
226 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
227 gSPDisplayList(gMainGfxPos++, D_E00328B0[unk_34 % 3]);
228 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
229 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
230}
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
#define general_heap_malloc
#define guRotateF
#define queue_render_task
#define guMtxF2L
#define guTranslateF
#define guMtxCatF
#define remove_effect
#define load_effect
#define create_effect_instance
#define guScaleF
EffectInstanceDataPtr data
Definition effects.h:2605
struct ExplosionFXData * explosion
Definition effects.h:2489
#define ASSERT(condition)
@ RENDER_MODE_CLOUD_NO_ZCMP
Definition enums.h:3311
Gfx D_090009D8_344948[]
EFFECT_DEF_SMOKE_RING(smoke_ring_main)
void explosion_init(EffectInstance *effect)
Definition explosion.c:92
void explosion_update(EffectInstance *effect)
Definition explosion.c:98
void explosion_render(EffectInstance *effect)
Definition explosion.c:152
void explosion_main(s32 type, f32 x, f32 y, f32 z)
Definition explosion.c:18
EFFECT_DEF_CONFETTI(confetti_main)
Gfx D_09000840_3447B0[]
Gfx D_09000978_3448E8[]
Gfx * D_E00328B0[]
Definition explosion.c:16
Gfx D_09000910_344880[]
Gfx D_09000A38_3449A8[]
Gfx D_090008F0_344860[]
void explosion_appendGfx(void *effect)
Definition explosion.c:164
#define VIRTUAL_TO_PHYSICAL(addr)
Definition macros.h:47
void smoke_ring_main(s32 arg0, f32 arg1, f32 arg2, f32 arg3)
Definition smoke_ring.c:20
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(* renderScene)(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