Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
pink_sparkles.c
Go to the documentation of this file.
1#include "common.h"
2#include "effects_internal.h"
3
4extern Gfx D_09000F20_338EE0[];
5extern Gfx D_090011C8_339188[];
6extern Gfx D_090011E0_3391A0[];
7extern Gfx D_090011F8_3391B8[];
8extern Gfx D_09001210_3391D0[];
9extern Gfx D_09001228_3391E8[];
10extern Gfx D_09001240_339200[];
11extern Gfx D_09001258_339218[];
12extern Gfx D_09001270_339230[];
13
19
20s8 D_E01248C0[] = {
21 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2B, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E,
22 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x40, 0x2E, 0x23, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E,
23 0x2E, 0x2E, 0x2E, 0x2E, 0x24, 0x25, 0x26, 0x2E, 0x2A, 0x3D, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E,
24 0x2E, 0x2E, 0x2E, 0x2E, 0x2D, 0x2E, 0x2E, 0x2E, 0x3B, 0x3E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E,
25 0x2E, 0x2E, 0x2E, 0x2C, 0x27, 0x2E, 0x2E, 0x2E, 0x2E, 0x29, 0x21, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E,
26 0x2E, 0x2E, 0x7E, 0x7E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x7B, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E,
27 0x2E, 0x2E, 0x7E, 0x7E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x5D, 0x40, 0x40, 0x5E, 0x2E, 0x2E,
28 0x2E, 0x2E, 0x7E, 0x2F, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E,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0xD5, 0xAC
84};
85
86u8 D_E0124BE4[] = {
87 0x1E, 0x3C, 0x5A, 0x64, 0x68,
88 0x6A, 0x6C, 0x6E, 0x70, 0x71,
89 0x71, 0x6E, 0x6B, 0x67, 0x64,
90 0x68, 0x6A, 0x6C, 0x6E, 0x70,
91 0x71, 0x71, 0x6E, 0x6B, 0x67
92};
93
97void pink_sparkles_appendGfx(void* effect);
98
99EffectInstance* pink_sparkles_main(s32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4, f32 arg5) {
101 EffectInstance* effect;
102 PinkSparklesFXData* part;
103 s32 numParts = 101;
104 s32 count;
105 f32 angle;
106 s32 i;
107 s32 j;
108
112 bp.unk_00 = 0;
113 bp.renderUI = NULL;
114 bp.effectID = EFFECT_PINK_SPARKLES;
115
116 effect = create_effect_instance(&bp);
117 effect->numParts = numParts;
118 part = effect->data.pinkSparkles = general_heap_malloc(numParts * sizeof(*part));
119 ASSERT(effect->data.pinkSparkles != NULL);
120
121 part->unk_04 = arg1;
122 part->unk_08 = arg2;
123 part->unk_0C = arg3;
124 part->unk_20 = 0;
125 part->unk_00 = arg0;
126 part->unk_1C = 80;
127
128 part++;
129 angle = arg5;
130 count = 1;
131
132 for (i = 0; i < 16; i++) {
133 for (j = 0; j < 16; j++) {
134 if (D_E01248C0[j + (15 - i) * 16 + arg0 * 256] != 46) {
135 f32 temp_f20 = j * 2 - 16 + (rand_int(20) - 10) * 0.1;
136
137 part->unk_04 = temp_f20 * cos_deg(angle);
138 part->unk_08 = i * 2 + (rand_int(20) - 10) * 0.1;
139 part->unk_0C = temp_f20 * sin_deg(angle);
140 part->unk_10 = part->unk_04 * 0.04;
141 part->unk_14 = part->unk_08 * 0.04;
142 part->unk_18 = rand_int(10) * 0.001;
143 part->unk_1C = rand_int(7) + 30;
144 part->unk_20 = 0;
145
146 count++;
147 part++;
148
149 if (count >= numParts) {
150 break;
151 }
152 }
153 }
154
155 if (count >= numParts) {
156 break;
157 }
158 }
159
160 for (; count < numParts; count++, part++) {
161 part->unk_04 = part->unk_08 = part->unk_0C =
162 part->unk_10 = part->unk_14 = part->unk_18 =
163 part->unk_24 = 0.0f;
164 part->unk_1C = -1;
165 part->unk_20 = 0;
166 };
167
168 return effect;
169}
170
173
175 PinkSparklesFXData* part = effect->data.pinkSparkles;
176 s32 unk_20;
177 s32 count = 0;
178 s32 i;
179
180 part->unk_1C--;
181 part->unk_20++;
182 unk_20 = part->unk_20;
183
184 part++;
185 for (i = 0; i < effect->numParts - 1; i++, part++) {
186 part->unk_28 = (unk_20 + i + i) & 7;
187
188 if (part->unk_1C < 0) {
189 count += 1;
190 }
191
192 part->unk_1C--;
193 if (part->unk_1C < 0 || part->unk_1C >= 31) {
194 part->unk_28 = -1;
195 } else {
196 part->unk_20++;
197 unk_20 = part->unk_20;
198
199 if (unk_20 - 1 < 25) {
200 part->unk_24 = (f32) D_E0124BE4[unk_20 - 1] * 0.01 * 0.4;
201 } else {
202 part->unk_24 += (0.1 - part->unk_24) * 0.1;
203 }
204
205 part->unk_04 += part->unk_10;
206 part->unk_08 += part->unk_14;
207 part->unk_14 += part->unk_18;
208 part->unk_0C += part->unk_10;
209 }
210 }
211
212 if (count >= effect->numParts - 1) {
213 remove_effect(effect);
214 }
215}
216
218 RenderTask renderTask;
219 RenderTask* retTask;
220
222 renderTask.appendGfxArg = effect;
223 renderTask.dist = 0;
225
226 retTask = queue_render_task(&renderTask);
227}
228
229void pink_sparkles_appendGfx(void* effect) {
230 PinkSparklesFXData* part = ((EffectInstance*)effect)->data.pinkSparkles;
231 s32 primR;
232 s32 primG;
233 s32 primB;
234 f32 factorR = 1.4f;
235 f32 factorG = 0.7f;
236 f32 factorB = 0.7f;
237 Matrix4f sp18;
238 Matrix4f sp58;
239 Matrix4f sp98;
240 s32 colorIdx;
241 s32 i;
242
243 gDPPipeSync(gMainGfxPos++);
244 gSPSegment(gMainGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(((EffectInstance*)effect)->graphics->data));
245 gSPDisplayList(gMainGfxPos++, D_09000F20_338EE0);
246
247 colorIdx = (part->unk_20 - 1) * 3;
248
249 guTranslateF(sp98, part->unk_04, part->unk_08, part->unk_0C);
250 guRotateF(sp58, -gCameras[gCurrentCameraID].curYaw, 0.0f, 1.0f, 0.0f);
251 guMtxCatF(sp58, sp98, sp98);
252
253 part++;
254 for (i = 0; i < ((EffectInstance*)effect)->numParts - 1; i++, part++) {
255 s32 unk_28 = part->unk_28;
256
257 if (unk_28 >= 0) {
258 guTranslateF(sp58, part->unk_04, part->unk_08, part->unk_0C);
259
260 sp58[0][0] = sp58[1][1] = sp58[2][2] = part->unk_24;
261
262 guMtxCatF(sp58, sp98, sp18);
264
265 if (colorIdx >= ARRAY_COUNT(D_E0124BC0)) {
266 colorIdx = 0;
267 }
268
269 primR = D_E0124BC0[colorIdx++] * factorR;
270 primG = D_E0124BC0[colorIdx++] * factorG;
271 primB = D_E0124BC0[colorIdx++] * factorB;
272
273 if (primR > 255) {
274 primR = 255;
275 }
276 if (primG > 255) {
277 primG = 255;
278 }
279 if (primB > 255) {
280 primB = 255;
281 }
282
283 gDPSetPrimColor(gMainGfxPos++, 0, 0, primR, primG, primB, 255);
284 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
285 gSPDisplayList(gMainGfxPos++, D_E01248A0[unk_28 & 7]);
286 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
287 }
288 }
289
290 gDPPipeSync(gMainGfxPos++);
291}
Mtx matrixStack[0x200]
f32 Matrix4f[4][4]
#define general_heap_malloc
#define guRotateF
#define queue_render_task
#define guMtxF2L
#define sin_deg
#define guTranslateF
#define guMtxCatF
#define remove_effect
#define rand_int
#define cos_deg
#define create_effect_instance
struct PinkSparklesFXData * pinkSparkles
Definition effects.h:2596
EffectData data
Definition effects.h:2605
#define ASSERT(condition)
@ RENDER_MODE_CLOUD_NO_ZCMP
Definition enums.h:3311
Gfx D_090011E0_3391A0[]
Gfx D_09001228_3391E8[]
Gfx D_09000F20_338EE0[]
u8 D_E0124BC0[]
Gfx D_090011C8_339188[]
EffectInstance * pink_sparkles_main(s32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4, f32 arg5)
u8 D_E0124BE4[]
void pink_sparkles_appendGfx(void *effect)
Gfx * D_E01248A0[]
void pink_sparkles_update(EffectInstance *effect)
void pink_sparkles_render(EffectInstance *effect)
void pink_sparkles_init(EffectInstance *effect)
Gfx D_09001210_3391D0[]
Gfx D_090011F8_3391B8[]
s8 D_E01248C0[]
Gfx D_09001258_339218[]
Gfx D_09001270_339230[]
Gfx D_09001240_339200[]
#define ARRAY_COUNT(arr)
Definition macros.h:40
#define VIRTUAL_TO_PHYSICAL(addr)
Definition macros.h:47
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
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