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

Go to the source code of this file.

Functions

void sparkles_init (EffectInstance *effect)
 
void sparkles_update (EffectInstance *effect)
 
void sparkles_render (EffectInstance *effect)
 
void sparkles_appendGfx (void *effect)
 
void sparkles_main (s32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4)
 

Variables

Gfx D_09000F20_338EE0 []
 
Gfx D_090011C8_339188 []
 
Gfx D_090011E0_3391A0 []
 
Gfx D_090011F8_3391B8 []
 
Gfx D_09001210_3391D0 []
 
Gfx D_09001228_3391E8 []
 
Gfx D_09001240_339200 []
 
Gfx D_09001258_339218 []
 
Gfx D_09001270_339230 []
 
Gfx * D_E0022CD0 []
 
u8 D_E0022CF0 []
 
u8 D_E0022D14 [] = { 0x1E, 0x3C, 0x50, 0x5F, 0x64, 0x68, 0x6A }
 
u8 D_E0022D1C [] = { 0x3C, 0x5A, 0x64, 0x68, 0x6A, 0x6C, 0x6D }
 

Function Documentation

◆ sparkles_init()

void sparkles_init ( EffectInstance * effect)

Definition at line 150 of file sparkles.c.

150 {
151}

Referenced by sparkles_main().

◆ sparkles_update()

void sparkles_update ( EffectInstance * effect)

Definition at line 153 of file sparkles.c.

153 {
154 SparklesFXData* part = effect->data.sparkles;
155 SparklesFXData* firstPart = part;
156 s32 unk_00 = part->unk_00;
157 f32 unk_10;
158 f32 unk_14;
159 s32 unk_20;
160 s32 count = 0;
161 f32 temp_f20;
162 f32 angle;
163 s32 i;
164
165 part->unk_24--;
166 part->unk_20++;
167
168 unk_20 = part->unk_20;
169
170 if ((unk_00 == 0 || unk_00 == 10) && part->unk_24 < 0) {
171 remove_effect(effect);
172 return;
173 }
174
175 part++;
176 for (i = 0; i < effect->numParts - 1; i++, part++) {
177 part->unk_2C = (unk_20 + i) & 7;
178 switch (unk_00) {
179 case 0:
180 part->unk_18 += -0.02;
181 if (unk_20 - 1 < 7) {
182 part->unk_04 = part->unk_10 * D_E0022D14[unk_20 - 1] * 0.01;
183 part->unk_08 = part->unk_14 * D_E0022D14[unk_20 - 1] * 0.01 + part->unk_18;
184 part->unk_1C = (f32) D_E0022D1C[unk_20 - 1] * 0.01;
185 } else {
186 angle = effect_simple_rand(360, i + 177);
187 temp_f20 = (i & 3) * 0.5f + 1.0f;
188 firstPart->unk_00 = 10;
189 part->unk_10 = temp_f20 * sin_deg(angle);
190 part->unk_14 = temp_f20 * cos_deg(angle);
191 part->unk_18 = -0.05f;
192 }
193 break;
194 case 10:
195 part->unk_10 *= 0.96;
196 part->unk_1C += (0.1 - part->unk_1C) * 0.1;
197 part->unk_14 *= 0.96;
198 part->unk_14 += part->unk_18;
199 part->unk_04 += part->unk_10;
200 part->unk_08 += part->unk_14;
201 break;
202 default:
203 part->unk_10 *= 0.9;
204 part->unk_14 += part->unk_18;
205 unk_10 = part->unk_10;
206 unk_14 = part->unk_14;
207 if (part->unk_24 < 0) {
208 count++;
209 }
210 part->unk_04 += unk_10;
211 part->unk_08 += unk_14;
212 part->unk_24--;
213 if (part->unk_24 < 0 || part->unk_24 >= 21) {
214 part->unk_2C = -1;
215 } else {
216 part->unk_20++;
217 unk_20 = part->unk_20;
218 if (unk_20 - 1 < 7) {
219 part->unk_1C = (f32) D_E0022D1C[unk_20 - 1] * 0.01;
220 } else {
221 part->unk_1C += (0.1 - part->unk_1C) * 0.1;
222 }
223 }
224 break;
225 }
226 }
227
228 if (unk_00 != 0 && unk_00 != 10 && count >= effect->numParts - 1) {
229 remove_effect(effect);
230 }
231}
s8 unk_14
Definition demo_api.c:19
#define sin_deg
#define remove_effect
#define cos_deg
struct SparklesFXData * sparkles
Definition effects.h:2481
EffectData data
Definition effects.h:2605
s32 effect_simple_rand(s32, s32)
u8 D_E0022D14[]
Definition sparkles.c:35
u8 D_E0022D1C[]
Definition sparkles.c:36

Referenced by sparkles_main().

◆ sparkles_render()

void sparkles_render ( EffectInstance * effect)

Definition at line 233 of file sparkles.c.

233 {
234 RenderTask renderTask;
235 RenderTask* retTask;
236
237 renderTask.appendGfx = sparkles_appendGfx;
238 renderTask.appendGfxArg = effect;
239 renderTask.dist = 0;
241
242 retTask = queue_render_task(&renderTask);
243}
#define queue_render_task
@ RENDER_MODE_CLOUD_NO_ZCMP
Definition enums.h:3311
void sparkles_appendGfx(void *effect)
Definition sparkles.c:245
void * appendGfxArg
void(* appendGfx)(void *)

Referenced by sparkles_main().

◆ sparkles_appendGfx()

void sparkles_appendGfx ( void * effect)

Definition at line 245 of file sparkles.c.

245 {
246 SparklesFXData* part = ((EffectInstance*)effect)->data.sparkles;
247 Matrix4f sp18;
248 Matrix4f sp58;
249 Matrix4f sp98;
250 s32 colorIdx;
251 s32 i;
252
253 gDPPipeSync(gMainGfxPos++);
254 gSPSegment(gMainGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(((EffectInstance*)effect)->graphics->data));
255 gSPDisplayList(gMainGfxPos++, D_09000F20_338EE0);
256
257 colorIdx = (part->unk_20 - 1) * 3;
258
259 guTranslateF(sp18, part->unk_04, part->unk_08, part->unk_0C);
260 guRotateF(sp58, -gCameras[gCurrentCameraID].curYaw, 0.0f, 1.0f, 0.0f);
261 guMtxCatF(sp58, sp18, sp98);
262
263 part++;
264 for (i = 0; i < ((EffectInstance*)effect)->numParts - 1; i++, part++) {
265 s32 unk_2C = part->unk_2C;
266
267 if (unk_2C >= 0) {
268 guTranslateF(sp58, part->unk_04, part->unk_08, part->unk_0C);
269
270 sp58[0][0] = part->unk_1C;
271 sp58[1][1] = part->unk_1C;
272 sp58[2][2] = part->unk_1C;
273 colorIdx += 3;
274
275 guMtxCatF(sp58, sp98, sp18);
277
278 colorIdx %= ARRAY_COUNT(D_E0022CF0);
279
280 gDPSetPrimColor(gMainGfxPos++, 0, 0, D_E0022CF0[colorIdx], D_E0022CF0[colorIdx + 1], D_E0022CF0[colorIdx + 2], 255);
281 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
282 gSPDisplayList(gMainGfxPos++, D_E0022CD0[unk_2C & 7]);
283 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
284 }
285 }
286
287 gDPPipeSync(gMainGfxPos++);
288}
Mtx matrixStack[0x200]
f32 Matrix4f[4][4]
#define guRotateF
#define guMtxF2L
#define guTranslateF
#define guMtxCatF
#define ARRAY_COUNT(arr)
Definition macros.h:40
#define VIRTUAL_TO_PHYSICAL(addr)
Definition macros.h:47
Gfx D_09000F20_338EE0[]
u8 D_E0022CF0[]
Definition sparkles.c:20
Gfx * D_E0022CD0[]
Definition sparkles.c:14
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 sparkles_render().

◆ sparkles_main()

void sparkles_main ( s32 arg0,
f32 arg1,
f32 arg2,
f32 arg3,
f32 arg4 )

Definition at line 43 of file sparkles.c.

43 {
45 EffectBlueprint* bpPtr = &bp;
46 EffectInstance* effect;
47 SparklesFXData* part;
48 s32 numParts;
49 f32 var_f30;
50 f32 angle;
51 f32 angle2;
52 s32 i;
53
54 switch (arg0) {
55 case 0:
56 numParts = 36;
57 var_f30 = arg4;
58 break;
59 case 1:
60 numParts = 4;
61 var_f30 = arg4;
62 break;
63 case 2:
64 numParts = 8;
65 var_f30 = arg4;
66 break;
67 case 3:
68 numParts = 4;
69 var_f30 = 8.0f;
70 break;
71 default:
72 numParts = 8;
73 var_f30 = 8.0f;
74 break;
75 }
76
77 numParts++;
78
79 bpPtr->init = sparkles_init;
80 bpPtr->update = sparkles_update;
82 bpPtr->unk_00 = 0;
83 bpPtr->renderUI = NULL;
84 bpPtr->effectID = EFFECT_SPARKLES;
85
86 effect = create_effect_instance(bpPtr);
87 effect->numParts = numParts;
88 part = effect->data.sparkles = general_heap_malloc(numParts * sizeof(*part));
89 ASSERT(effect->data.sparkles != NULL);
90
91 part->unk_04 = arg1;
92 part->unk_08 = arg2;
93 part->unk_0C = arg3;
94 part->unk_20 = 0;
95 part->unk_00 = arg0;
96 part->unk_24 = 30;
97
98 part++;
99 for (i = 1; i < numParts; i++, part++) {
100 f32 rand1 = rand_int(arg4 * 1000.0f) / 1000.0f;
101 f32 rand2 = rand_int(var_f30 * 1000.0f) / 1000.0f;
102
103 switch (arg0) {
104 case 0:
105 angle = (360.0f / (numParts - 1)) * i;
106 angle2 = (1800.0f / (numParts - 1)) * i - 90.0f;
107 part->unk_18 = 0.0f;
108 part->unk_10 = (sin_deg(angle) * (85.0f - sin_deg(angle2) * 15.0f - (i & 1) * 5) / 100.0f) * arg4;
109 part->unk_14 = (cos_deg(angle) * (85.0f - sin_deg(angle2) * 15.0f - (i & 1) * 5) / 100.0f) * arg4;
110 part->unk_0C = 0;
111 part->unk_28 = 0;
112 break;
113 case 1:
114 case 2:
115 angle = (360.0f / (numParts - 1)) * i + rand_int(359);
116 if (i & 1) {
117 part->unk_18 = -(rand_int(50) / 1000 + 0.05);
118 } else {
119 part->unk_18 = 0;
120 }
121 part->unk_10 = 0;
122 part->unk_14 = 0;
123 part->unk_04 = rand1 * sin_deg(angle);
124 part->unk_08 = rand2 * cos_deg(angle);
125 part->unk_0C = 0;
126 part->unk_1C = 1.0f;
127 part->unk_24 = i * 2 + 30;
128 part->unk_28 = i % 3;
129 part->unk_20 = 0;
130 break;
131 case 3:
132 case 4:
133 default:
134 angle = (360.0f / (numParts - 1)) * i + rand_int(359);
135 part->unk_18 = -(rand_int(50) / 1000 + 0.05);
136 part->unk_10 = 0.0f;
137 part->unk_14 = 0.0f;
138 part->unk_04 = rand1 * sin_deg(angle);
139 part->unk_08 = rand2 * cos_deg(angle);
140 part->unk_0C = 0;
141 part->unk_1C = 1.0f;
142 part->unk_24 = i * 2 + 18;
143 part->unk_28 = i % 3;
144 part->unk_20 = 0;
145 break;
146 }
147 }
148}
#define general_heap_malloc
#define rand_int
#define create_effect_instance
#define ASSERT(condition)
void sparkles_init(EffectInstance *effect)
Definition sparkles.c:150
void sparkles_update(EffectInstance *effect)
Definition sparkles.c:153
void sparkles_render(EffectInstance *effect)
Definition sparkles.c:233
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_09000F20_338EE0

Gfx D_09000F20_338EE0[]
extern

Referenced by sparkles_appendGfx().

◆ D_090011C8_339188

Gfx D_090011C8_339188[]
extern

◆ D_090011E0_3391A0

Gfx D_090011E0_3391A0[]
extern

◆ D_090011F8_3391B8

Gfx D_090011F8_3391B8[]
extern

◆ D_09001210_3391D0

Gfx D_09001210_3391D0[]
extern

◆ D_09001228_3391E8

Gfx D_09001228_3391E8[]
extern

◆ D_09001240_339200

Gfx D_09001240_339200[]
extern

◆ D_09001258_339218

Gfx D_09001258_339218[]
extern

◆ D_09001270_339230

Gfx D_09001270_339230[]
extern

◆ D_E0022CD0

Gfx* D_E0022CD0[]
Initial value:
= {
}
Gfx D_090011E0_3391A0[]
Gfx D_09001228_3391E8[]
Gfx D_090011C8_339188[]
Gfx D_09001210_3391D0[]
Gfx D_090011F8_3391B8[]
Gfx D_09001258_339218[]
Gfx D_09001270_339230[]
Gfx D_09001240_339200[]

Definition at line 14 of file sparkles.c.

Referenced by sparkles_appendGfx().

◆ D_E0022CF0

u8 D_E0022CF0[]
Initial value:
= {
254, 172, 172,
254, 172, 213,
254, 180, 154,
213, 180, 254,
180, 180, 254,
180, 221, 254,
180, 254, 254,
180, 254, 213,
180, 254, 180,
213, 254, 180,
254, 254, 180,
254, 213, 172
}

Definition at line 20 of file sparkles.c.

20 {
21 254, 172, 172,
22 254, 172, 213,
23 254, 180, 154,
24 213, 180, 254,
25 180, 180, 254,
26 180, 221, 254,
27 180, 254, 254,
28 180, 254, 213,
29 180, 254, 180,
30 213, 254, 180,
31 254, 254, 180,
32 254, 213, 172
33};

Referenced by sparkles_appendGfx().

◆ D_E0022D14

u8 D_E0022D14[] = { 0x1E, 0x3C, 0x50, 0x5F, 0x64, 0x68, 0x6A }

Definition at line 35 of file sparkles.c.

35{ 0x1E, 0x3C, 0x50, 0x5F, 0x64, 0x68, 0x6A };

Referenced by sparkles_update().

◆ D_E0022D1C

u8 D_E0022D1C[] = { 0x3C, 0x5A, 0x64, 0x68, 0x6A, 0x6C, 0x6D }

Definition at line 36 of file sparkles.c.

36{ 0x3C, 0x5A, 0x64, 0x68, 0x6A, 0x6C, 0x6D };

Referenced by sparkles_update().