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

Go to the source code of this file.

Functions

void explosion_init (EffectInstance *effect)
 
void explosion_update (EffectInstance *effect)
 
void explosion_render (EffectInstance *effect)
 
void explosion_appendGfx (void *effect)
 
void explosion_main (s32 type, f32 x, f32 y, f32 z)
 
 EFFECT_DEF_SMOKE_RING (smoke_ring_main)
 
 EFFECT_DEF_CONFETTI (confetti_main)
 

Variables

Gfx D_09000840_3447B0 []
 
Gfx D_090008F0_344860 []
 
Gfx D_09000910_344880 []
 
Gfx D_09000978_3448E8 []
 
Gfx D_090009D8_344948 []
 
Gfx D_09000A38_3449A8 []
 
Gfx * D_E00328B0 [] = { D_09000978_3448E8, D_090009D8_344948, D_09000A38_3449A8 }
 

Function Documentation

◆ explosion_init()

void explosion_init ( EffectInstance * effect)

Definition at line 93 of file explosion.c.

93 {
94}

Referenced by explosion_main().

◆ explosion_update()

void explosion_update ( EffectInstance * effect)

Definition at line 100 of file explosion.c.

100 {
101 ExplosionFXData* part = effect->data.explosion;
102 s32 unk_00;
103 s32 unk_34;
104
105 part->unk_30--;
106 if (part->unk_30 < 0) {
107 remove_effect(effect);
108 return;
109 }
110
111 part->unk_34++;
112
113 unk_00 = part->unk_00;
114 unk_34 = part->unk_34;
115
116 if (unk_34 == 7) {
117 load_effect(EFFECT_SMOKE_RING);
118 smoke_ring_main(unk_00, part->pos.x, part->pos.y, part->pos.z);
119 } else if (unk_34 == 1) {
120 load_effect(EFFECT_CONFETTI);
121 confetti_main(unk_00 + 4, part->pos.x, part->pos.y, part->pos.z, 1.0f, 50);
122 }
123
124 part++;
125
126 part->unk_20 += part->unk_24;
127
128 if (unk_34 < 8) {
129 part->unk_24 += (unk_00 == 2) ? 1.0f : 0.4;
130 part->unk_38 = (255 - part->unk_38) * 0.6;
131 } else {
132 part->unk_24 *= 0.6;
133 part->unk_38 *= 0.9;
134 }
135
136 part++;
137
138 if (unk_34 >= 3) {
139 if (unk_34 == 3) {
140 part->unk_20 = 1.0f;
141 }
142 part->unk_20 += part->unk_24;
143 if (unk_34 < 6) {
144 part->unk_24 += 0.1;
145 } else {
146 part->unk_24 *= 0.5;
147 part->unk_38 *= 0.9;
148 }
149 }
150
151 part->unk_28 += part->unk_2C;
152}
EffectInstance * confetti_main(s32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4, s32 arg5)
Definition confetti.c:47
#define remove_effect
#define load_effect
struct ExplosionFXData * explosion
Definition effects.h:2489
EffectData data
Definition effects.h:2605
void smoke_ring_main(s32 arg0, f32 arg1, f32 arg2, f32 arg3)
Definition smoke_ring.c:20

Referenced by explosion_main().

◆ explosion_render()

void explosion_render ( EffectInstance * effect)

Definition at line 154 of file explosion.c.

154 {
155 RenderTask renderTask;
156 RenderTask* retTask;
157
158 renderTask.appendGfx = explosion_appendGfx;
159 renderTask.appendGfxArg = effect;
160 renderTask.dist = 10;
162
163 retTask = queue_render_task(&renderTask);
164}
#define queue_render_task
@ RENDER_MODE_CLOUD_NO_ZCMP
Definition enums.h:3311
void explosion_appendGfx(void *effect)
Definition explosion.c:166
void * appendGfxArg
void(* appendGfx)(void *)

Referenced by explosion_main().

◆ explosion_appendGfx()

void explosion_appendGfx ( void * effect)

Definition at line 166 of file explosion.c.

166 {
167 ExplosionFXData* part = ((EffectInstance*)effect)->data.explosion;
168 s32 unk_34 = part->unk_34;
169 Matrix4f sp18;
170 Matrix4f sp58;
171 s32 primAlpha;
172 s32 primB;
173 s32 cond;
174
175 gDPPipeSync(gMainGfxPos++);
176 gSPSegment(gMainGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(((EffectInstance*)effect)->graphics->data));
177
178 guTranslateF(sp18, part->pos.x, part->pos.y, part->pos.z);
179 guRotateF(sp58, -gCameras[gCurrentCameraID].curYaw, 0.0f, 1.0f, 0.0f);
180 guMtxCatF(sp58, sp18, sp18);
182
183 part++;
184
185 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
186
187 if (part->unk_00 != -1) {
188 gSPDisplayList(gMainGfxPos++, D_09000840_3447B0);
189
190 guScaleF(sp18, part->unk_20, part->unk_20, 1.0f);
192
193 gDPSetPrimColor(gMainGfxPos++, 0, 0, 255, 255, 240, part->unk_38);
194 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
195 gSPDisplayList(gMainGfxPos++, D_090008F0_344860);
196 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
197 }
198
199 part++;
200
201 gSPDisplayList(gMainGfxPos++, D_09000910_344880);
202
203 guScaleF(sp18, part->unk_20, part->unk_20, part->unk_20);
204 guRotateF(sp58, part->unk_28, 0.0f, 0.0f, 1.0f);
205 guMtxCatF(sp58, sp18, sp18);
207
208 switch (unk_34) {
209 default:
210 primAlpha = part->unk_38;
211 break;
212 case 2:
213 primAlpha = 255;
214 break;
215 case 1:
216 primAlpha = 192;
217 break;
218 }
219
220 cond = (unk_34 < 3); // required to match
221 if (!cond && unk_34 < 8) {
222 primB = unk_34 * 16 + 128;
223 } else {
224 primB = 255;
225 }
226
227 gDPSetPrimColor(gMainGfxPos++, 0, 0, 255, 255, primB, primAlpha);
228 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
229 gSPDisplayList(gMainGfxPos++, D_E00328B0[unk_34 % 3]);
230 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
231 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
232}
Mtx matrixStack[0x200]
f32 Matrix4f[4][4]
#define guRotateF
#define guMtxF2L
#define guTranslateF
#define guMtxCatF
#define guScaleF
Gfx D_09000840_3447B0[]
Gfx * D_E00328B0[]
Definition explosion.c:16
Gfx D_09000910_344880[]
Gfx D_090008F0_344860[]
#define VIRTUAL_TO_PHYSICAL(addr)
Definition macros.h:47
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 explosion_render().

◆ explosion_main()

void explosion_main ( s32 type,
f32 x,
f32 y,
f32 z )

Definition at line 18 of file explosion.c.

18 {
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
43 effect = create_effect_instance(bpPtr);
44 effect->numParts = numParts;
45 effect->data.explosion = data = general_heap_malloc(effect->numParts * sizeof(*data));
46 ASSERT(effect->data.explosion != NULL);
47
48 data->pos.x = x;
49 data->pos.y = y;
50 data->pos.z = z;
51 data->unk_34 = 0;
52 data->unk_30 = 60;
53 data->unk_00 = type;
54
55 data++;
56 data->unk_00 = type;
57 if (type == 0) {
58 data->unk_00 = -1;
59 }
60 data->unk_38 = 0;
61 if (type == 1) {
62 data->unk_20 = 1.0f;
63 } else {
64 data->unk_20 = 3.0f;
65 }
66 if (type == 1) {
67 data->unk_24 = 1.0f;
68 } else {
69 data->unk_24 = 3.0f;
70 }
71
72 data++;
73 data->unk_00 = type;
74 data->unk_38 = 255;
75 switch (type) {
76 case 0:
77 data->unk_20 = 9.9f;
78 data->unk_24 = 1.6f;
79 break;
80 case 1:
81 data->unk_20 = 13.9f;
82 data->unk_24 = 2.4f;
83 break;
84 default:
85 data->unk_20 = 17.8f;
86 data->unk_24 = 3.2f;
87 break;
88 }
89 data->unk_28 = 0.0f;
90 data->unk_2C = 30.0f;
91}
#define general_heap_malloc
#define create_effect_instance
#define ASSERT(condition)
void explosion_init(EffectInstance *effect)
Definition explosion.c:93
void explosion_update(EffectInstance *effect)
Definition explosion.c:100
void explosion_render(EffectInstance *effect)
Definition explosion.c:154
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

◆ EFFECT_DEF_SMOKE_RING()

EFFECT_DEF_SMOKE_RING ( smoke_ring_main )

◆ EFFECT_DEF_CONFETTI()

EFFECT_DEF_CONFETTI ( confetti_main )

Variable Documentation

◆ D_09000840_3447B0

Gfx D_09000840_3447B0[]
extern

Referenced by explosion_appendGfx().

◆ D_090008F0_344860

Gfx D_090008F0_344860[]
extern

Referenced by explosion_appendGfx().

◆ D_09000910_344880

Gfx D_09000910_344880[]
extern

Referenced by explosion_appendGfx().

◆ D_09000978_3448E8

Gfx D_09000978_3448E8[]
extern

◆ D_090009D8_344948

Gfx D_090009D8_344948[]
extern

◆ D_09000A38_3449A8

Gfx D_09000A38_3449A8[]
extern

◆ D_E00328B0

Definition at line 16 of file explosion.c.

Gfx D_090009D8_344948[]
Gfx D_09000978_3448E8[]
Gfx D_09000A38_3449A8[]

Referenced by explosion_appendGfx().