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

Go to the source code of this file.

Functions

void misc_particles_init (EffectInstance *effect)
 
void misc_particles_update (EffectInstance *effect)
 
void misc_particles_render (EffectInstance *effect)
 
void misc_particles_appendGfx (void *effect)
 
EffectInstancemisc_particles_main (s32 variation, f32 posX, f32 posY, f32 posZ, f32 scaleX, f32 scaleY, f32 arg6, s32 numParticles, s32 duration)
 
void func_E00E4954 (void)
 

Variables

Gfx D_09001580_3E03E0 []
 
Gfx D_09001670_3E04D0 []
 
Gfx D_09001768_3E05C8 []
 
Gfx D_09001818_3E0678 []
 
Gfx D_09001A20_3E0880 []
 
Gfx D_09001A40_3E08A0 []
 
Gfx D_09001A60_3E08C0 []
 
Gfx D_09001A80_3E08E0 []
 
Gfx * D_E00E4D90 []
 
Gfx * D_E00E4DA8 []
 
u8 D_E00E4DC0 []
 
u8 D_E00E4DE0 []
 
u8 D_E00E4E00 []
 

Function Documentation

◆ misc_particles_init()

void misc_particles_init ( EffectInstance * effect)

Definition at line 144 of file misc_particles.c.

144 {
145}

Referenced by misc_particles_main().

◆ misc_particles_update()

void misc_particles_update ( EffectInstance * effect)

Definition at line 147 of file misc_particles.c.

147 {
148 MiscParticlesFXData* particle = effect->data.miscParticles;
149 s32 variation = particle->variation;
150 f32 scaleX;
151 f32 scaleY;
152 f32 posX;
153 f32 posY;
154 f32 posZ;
155 s32 timeLeft;
156 s32 innerColorR;
157 s32 innerColorG;
158 s32 innerColorB;
159 f32 temp_sin;
160 f32 temp_cos;
161 s32 i;
162
163 if (effect->flags & FX_INSTANCE_FLAG_DISMISS) {
164 effect->flags &= ~FX_INSTANCE_FLAG_DISMISS;
165 particle->timeLeft = 16;
166 }
167
168 if (particle->timeLeft < 1000) {
169 particle->timeLeft--;
170 }
171
172 particle->lifetime++;
173
174 if (particle->timeLeft < 0) {
175 remove_effect(effect);
176 return;
177 }
178
179 timeLeft = particle->timeLeft;
180
181 if (particle->timeLeft < 8) {
182 particle->innerColor.a = particle->timeLeft * 32;
183 }
184
185 scaleX = particle->scaleX;
186 scaleY = particle->scaleY;
187 posX = particle->pos.x;
188 posY = particle->pos.y;
189 posZ = particle->pos.z;
190 temp_cos = cos_deg(gCameras[gCurrentCameraID].curYaw);
191 temp_sin = sin_deg(gCameras[gCurrentCameraID].curYaw);
192 innerColorR = particle->innerColor.r;
193 innerColorG = particle->innerColor.g;
194 innerColorB = particle->innerColor.b;
195
196 particle++;
197 for (i = 1; i < effect->numParts; i++, particle++) {
198 particle->animTime++;
199 if (particle->animTime >= 30) {
200 if (timeLeft < 30) {
201 // perform final fadeout
202 particle->animTime = 20;
203 } else {
204 // recycle the particle
205 particle->animTime = 0;
206 }
207 }
208
209 if (particle->animTime >= 0) {
210 if (particle->animTime == 0) {
211 f32 randMag = rand_int(scaleX) - scaleX * 0.5;
212 particle->pos.x = posX + randMag * temp_cos - temp_sin;
213 particle->pos.y = posY + rand_int(scaleY);
214 particle->pos.z = posZ + randMag * temp_sin + temp_cos;
215 particle->innerColor.r = innerColorR;
216 particle->innerColor.g = innerColorG;
217 particle->innerColor.b = innerColorB;
218 }
219
220 switch (variation) {
221 case 0:
222 case 1:
223 if (particle->animTime == 0) {
224 particle->unk_18 = 0.0f;
225 particle->unk_1C = 0.0f;
226 particle->unk_24 = 0.0f;
227 particle->unk_28 = (f32) (-rand_int(10) - 2) * 0.05;
228 particle->unk_5C = 0.0f;
229 particle->unk_60 = 0.0f;
230 particle->scale = (f32) rand_int(10) * 0.05 + 0.5;
231 }
232 particle->innerColor.a = D_E00E4E00[particle->animTime];
233 particle->pos.x += particle->unk_18;
234 particle->pos.y += particle->unk_1C;
235 particle->unk_5C += 0.2;
236 particle->unk_60 += 0.6;
237 particle->unk_18 += (particle->unk_24 - particle->unk_18) * 0.04;
238 particle->unk_1C += (particle->unk_28 - particle->unk_1C) * 0.04;
239 break;
240 case 2:
241 case 3:
242 if (particle->animTime == 0) {
243 if (variation == 2) {
244 particle->unk_18 = (f32) (rand_int(20) - 10) * 0.05;
245 particle->unk_1C = (f32) (rand_int(20) - 10) * 0.05;
246 } else {
247 particle->unk_18 = 0.0f;
248 particle->unk_1C = 0.0f;
249 }
250 particle->unk_24 = 0.0f;
251 particle->unk_28 = 0.0f;
252 particle->unk_5C = rand_int(15);
253 particle->unk_60 = rand_int(15);
254 particle->innerColor.a = 255;
255 }
256 particle->scale = (f32) D_E00E4DC0[particle->animTime] * 0.1;
257 particle->pos.x += particle->unk_18;
258 particle->pos.y += particle->unk_1C;
259 particle->unk_5C += 0.2;
260 particle->unk_60 += 0.6;
261 particle->unk_18 += (particle->unk_24 - particle->unk_18) * 0.04;
262 particle->unk_1C += (particle->unk_28 - particle->unk_1C) * 0.04;
263 break;
264 default:
265 if (particle->animTime == 0) {
266 particle->unk_5C = 0.0f;
267 particle->unk_60 = 0.0f;
268 particle->innerColor.a = 255;
269 particle->scale = 1.0f;
270 particle->innerColor.r = rand_int(127) + 128;
271 particle->innerColor.g = rand_int(255 - particle->innerColor.r) + 128;
272 particle->innerColor.b = rand_int(383 - particle->innerColor.r - particle->innerColor.g) + 128;
273 }
274 if (variation == 4) {
275 particle->scale = (f32) D_E00E4DE0[particle->animTime] * 0.01;
276 } else {
277 particle->scale = (f32) D_E00E4DC0[particle->animTime] * 0.01;
278 }
279 break;
280 }
281 }
282 }
283}
#define sin_deg
#define remove_effect
#define rand_int
#define cos_deg
struct MiscParticlesFXData * miscParticles
Definition effects.h:2578
EffectData data
Definition effects.h:2605
@ FX_INSTANCE_FLAG_DISMISS
Definition enums.h:3517
u8 D_E00E4DE0[]
u8 D_E00E4DC0[]
u8 D_E00E4E00[]
Camera gCameras[4]
Definition cam_main.c:17
s32 gCurrentCameraID
Definition cam_math.c:4

Referenced by misc_particles_main().

◆ misc_particles_render()

void misc_particles_render ( EffectInstance * effect)

Definition at line 285 of file misc_particles.c.

285 {
286 RenderTask renderTask;
287 RenderTask* retTask;
288
290 renderTask.appendGfxArg = effect;
291 renderTask.dist = 7;
293
294 retTask = queue_render_task(&renderTask);
296}
#define queue_render_task
@ RENDER_TASK_FLAG_REFLECT_FLOOR
Definition enums.h:3318
@ RENDER_MODE_CLOUD_NO_ZCMP
Definition enums.h:3311
void misc_particles_appendGfx(void *effect)
void * appendGfxArg
void(* appendGfx)(void *)

Referenced by misc_particles_main().

◆ misc_particles_appendGfx()

void misc_particles_appendGfx ( void * effect)

Definition at line 301 of file misc_particles.c.

301 {
302 MiscParticlesFXData* particle = ((EffectInstance*)effect)->data.miscParticles;
303 s32 variation = particle->variation;
304 f32 alphaScale = (particle->innerColor.a / 255.0f) * particle->scale;
305 Matrix4f mtxTransform;
306 Matrix4f unused;
307 s32 i;
308
309 gDPPipeSync(gMainGfxPos++);
310 gSPSegment(gMainGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(((EffectInstance*)effect)->graphics->data));
311 gDPSetEnvColor(gMainGfxPos++, particle->glowColor.r, particle->glowColor.g, particle->glowColor.b, particle->glowColor.a);
312 gSPDisplayList(gMainGfxPos++, D_E00E4DA8[variation]);
313
314 particle++;
315 for (i = 1; i < ((EffectInstance*)effect)->numParts; i++, particle++) {
316 if (particle->animTime >= 0) {
317 guPositionF(mtxTransform, 0.0f, -gCameras[gCurrentCameraID].curYaw, 0.0f, particle->scale * alphaScale, particle->pos.x, particle->pos.y, particle->pos.z);
319
320 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
321 gDPSetPrimColor(gMainGfxPos++, 0, 80 - particle->animTime, particle->innerColor.r, particle->innerColor.g, particle->innerColor.b, alphaScale * particle->innerColor.a);
322 gDPSetTileSize(gMainGfxPos++, 1,
323 (s32) particle->unk_5C * 4,
324 (s32) particle->unk_60 * 4,
325 ((s32) particle->unk_5C + 15) * 4,
326 ((s32) particle->unk_60 + 15) * 4);
327
328 if (variation == 2) {
329 gDPSetTileSize(gMainGfxPos++, G_TX_RENDERTILE,
330 ((i & 0x1F) * 32 ) * 4, 31 * 4,
331 ((i & 0x1F) * 32 + 31) * 4, 31 * 4);
332 }
333
334 gSPDisplayList(gMainGfxPos++, D_E00E4D90[variation]);
335 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
336 }
337 }
338}
Mtx matrixStack[0x200]
f32 Matrix4f[4][4]
#define guMtxF2L
#define guPositionF
Gfx * D_E00E4D90[]
Gfx * D_E00E4DA8[]
#define VIRTUAL_TO_PHYSICAL(addr)
Definition macros.h:47
Gfx * gMainGfxPos
Definition cam_main.c:15
u16 gMatrixListPos
Definition main_loop.c:45
DisplayContext * gDisplayContext
Definition cam_main.c:16

Referenced by misc_particles_render().

◆ misc_particles_main()

EffectInstance * misc_particles_main ( s32 variation,
f32 posX,
f32 posY,
f32 posZ,
f32 scaleX,
f32 scaleY,
f32 arg6,
s32 numParticles,
s32 duration )

Definition at line 46 of file misc_particles.c.

56 {
58 EffectInstance* effect;
60 f32 interval;
61 s32 i;
62
63 numParticles++;
64
68 bp.unk_00 = 0;
69 bp.renderUI = NULL;
70 bp.effectID = EFFECT_MISC_PARTICLES;
71
72 effect = create_effect_instance(&bp);
73 effect->numParts = numParticles;
74 part = effect->data.miscParticles = general_heap_malloc(numParticles * sizeof(*part));
75 ASSERT(effect->data.miscParticles != NULL);
76
77 part->variation = variation;
78 part->lifetime = 0;
79 if (duration <= 0) {
80 part->timeLeft = 1000;
81 } else {
82 part->timeLeft = duration;
83 }
84 part->innerColor.a = 255;
85 part->pos.x = posX;
86 part->pos.y = posY;
87 part->pos.z = posZ;
88 part->scale = arg6;
89 part->scaleX = scaleX;
90 part->scaleY = scaleY;
91 part->innerColor.r = 255;
92 part->innerColor.g = 255;
93 part->innerColor.b = 255;
94
95 switch (variation) {
96 case 0:
97 part->glowColor.r = 255;
98 part->glowColor.g = 255;
99 part->glowColor.b = 255;
100 part->glowColor.a = 255;
101 break;
102 case 1:
103 part->glowColor.r = 0;
104 part->glowColor.g = 127;
105 part->glowColor.b = 255;
106 part->glowColor.a = 255;
107 break;
108 case 2:
109 case 3:
110 part->glowColor.r = 255;
111 part->glowColor.g = 255;
112 part->glowColor.b = 128;
113 part->glowColor.a = 255;
114 break;
115 default:
116 part->innerColor.r = rand_int(127) + 128;
117 part->innerColor.g = rand_int(255 - part->innerColor.r) + 128;
118 part->innerColor.b = rand_int(383 - part->innerColor.r - part->innerColor.g) + 128;
119 part->glowColor.r = 127;
120 part->glowColor.g = 127;
121 part->glowColor.b = 127;
122 part->glowColor.a = 127;
123 break;
124 }
125
126 // determine delay for particles to appear
127 if (part->timeLeft < 30) {
128 interval = (f32) part->timeLeft / (numParticles - 1);
129 } else {
130 interval = 30.0f / (numParticles - 1);
131 }
132
133 // skip delay for first particle
134 part++;
135
136 // set initial delay for each particle after the first
137 for (i = 1; i < numParticles; i++, part++) {
138 part->animTime = (s32)(-1.0f * i * interval) - 1;
139 }
140
141 return effect;
142}
#define general_heap_malloc
#define create_effect_instance
#define ASSERT(condition)
void misc_particles_update(EffectInstance *effect)
void misc_particles_render(EffectInstance *effect)
void misc_particles_init(EffectInstance *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

Referenced by ice_pillar_main(), snowman_doll_update(), and spirit_card_main().

◆ func_E00E4954()

void func_E00E4954 ( void )

Definition at line 298 of file misc_particles.c.

298 {
299}

Variable Documentation

◆ D_09001580_3E03E0

Gfx D_09001580_3E03E0[]
extern

◆ D_09001670_3E04D0

Gfx D_09001670_3E04D0[]
extern

◆ D_09001768_3E05C8

Gfx D_09001768_3E05C8[]
extern

◆ D_09001818_3E0678

Gfx D_09001818_3E0678[]
extern

◆ D_09001A20_3E0880

Gfx D_09001A20_3E0880[]
extern

◆ D_09001A40_3E08A0

Gfx D_09001A40_3E08A0[]
extern

◆ D_09001A60_3E08C0

Gfx D_09001A60_3E08C0[]
extern

◆ D_09001A80_3E08E0

Gfx D_09001A80_3E08E0[]
extern

◆ D_E00E4D90

Gfx* D_E00E4D90[]

◆ D_E00E4DA8

Gfx* D_E00E4DA8[]

◆ D_E00E4DC0

u8 D_E00E4DC0[]
Initial value:
= {
0x02, 0x04, 0x08, 0x0D, 0x0F, 0x0D, 0x09, 0x06, 0x04, 0x03,
0x02, 0x04, 0x08, 0x0D, 0x0F, 0x0D, 0x09, 0x06, 0x04, 0x03,
0x02, 0x04, 0x08, 0x0D, 0x0F, 0x0D, 0x09, 0x06, 0x04, 0x03
}

Definition at line 23 of file misc_particles.c.

23 {
24 0x02, 0x04, 0x08, 0x0D, 0x0F, 0x0D, 0x09, 0x06, 0x04, 0x03,
25 0x02, 0x04, 0x08, 0x0D, 0x0F, 0x0D, 0x09, 0x06, 0x04, 0x03,
26 0x02, 0x04, 0x08, 0x0D, 0x0F, 0x0D, 0x09, 0x06, 0x04, 0x03
27};

Referenced by misc_particles_update().

◆ D_E00E4DE0

u8 D_E00E4DE0[]
Initial value:
= {
0x28, 0x5A, 0x51, 0x48, 0x41, 0x3B, 0x35, 0x2F, 0x2B, 0x26,
0x22, 0x1F, 0x1C, 0x19, 0x16, 0x14, 0x12, 0x10, 0x0F, 0x0D,
0x0C, 0x0A, 0x09, 0x08, 0x07, 0x07, 0x06, 0x05, 0x05, 0x04
}

Definition at line 29 of file misc_particles.c.

29 {
30 0x28, 0x5A, 0x51, 0x48, 0x41, 0x3B, 0x35, 0x2F, 0x2B, 0x26,
31 0x22, 0x1F, 0x1C, 0x19, 0x16, 0x14, 0x12, 0x10, 0x0F, 0x0D,
32 0x0C, 0x0A, 0x09, 0x08, 0x07, 0x07, 0x06, 0x05, 0x05, 0x04
33};

Referenced by misc_particles_update().

◆ D_E00E4E00

u8 D_E00E4E00[]
Initial value:
= {
0xC8, 0xFA, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFA, 0xC8
}

Definition at line 35 of file misc_particles.c.

35 {
36 0xC8, 0xFA, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
37 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
38 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFA, 0xC8
39};

Referenced by misc_particles_update().