Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
effect_63.c
Go to the documentation of this file.
1#include "common.h"
2#include "effects_internal.h"
3
4extern Gfx D_09001B70_3CF250[];
5extern Gfx D_09001C98_3CF378[];
6
10
14
15void effect_63_init(EffectInstance* effect);
18void effect_63_appendGfx(void* effect);
19
21 s32 arg0,
22 f32 arg1,
23 f32 arg2,
24 f32 arg3,
25 f32 arg4,
26 f32 arg5,
27 f32 arg6,
28 f32 arg7,
29 s32 arg8,
30 s32 arg9
31) {
33 EffectBlueprint* bpPtr = &bp;
34 EffectInstance* effect;
35 Effect63FXData* part;
36 f32 randInt;
37 s32 numParts;
38 s32 i;
39
40 if (arg0 == 2) {
41 numParts = 8;
42 } else {
43 numParts = 1;
44 }
45
46 bpPtr->init = effect_63_init;
47 bpPtr->update = effect_63_update;
49 bpPtr->unk_00 = 0;
50 bpPtr->renderUI = NULL;
51 bpPtr->effectID = EFFECT_63;
52
53 effect = create_effect_instance(bpPtr);
54 effect->numParts = numParts;
55 part = effect->data.unk_63 = general_heap_malloc(numParts * sizeof(*part));
56 ASSERT(effect->data.unk_63 != NULL);
57
58 if (arg9 <= 0) {
59 part->unk_20 = 1000;
60 } else {
61 part->unk_20 = arg9;
62 }
63 part->unk_00 = arg0;
64 part->unk_24 = 0;
65 part->unk_1C = arg8;
66 part->unk_34 = 0;
67 part->unk_04 = arg1;
68 part->unk_08 = arg2;
69 part->unk_0C = arg3;
70 part->unk_10 = arg4;
71 part->unk_14 = arg5;
72 part->unk_18 = arg6;
73 part->unk_48 = arg7;
74 part->unk_60 = (part->unk_10 - part->unk_04) / arg8;
75 part->unk_64 = (part->unk_14 - part->unk_08) / arg8;
76 part->unk_68 = (part->unk_18 - part->unk_0C) / arg8;
77
78 if (arg0 != 0) {
79 if (arg0 == 1) {
80 part->unk_28 = 255;
81 part->unk_2C = 88;
82 part->unk_30 = 70;
83 part->unk_34 = 55;
84 part->unk_38 = 11;
85 part->unk_3C = 51;
86 part->unk_40 = 123;
87 part->unk_44 = 255;
88 part->unk_4C = rand_int(64);
89 part->unk_50 = rand_int(64);
90 part->unk_54 = 0;
91 part->unk_58 = 0;
92 part->unk_74 = 0;
93 part->unk_70 = 0.2f;
94 part->unk_6C = 0.3f;
95 part->unk_78 = -10.0f;
96 } else {
97 part->unk_28 = 255;
98 part->unk_2C = 88;
99 part->unk_30 = 70;
100 part->unk_34 = 55;
101 part->unk_38 = 11;
102 part->unk_3C = 51;
103 part->unk_40 = 123;
104 part->unk_44 = 255;
105 randInt = rand_int(360);
106
107 for (i = 0; i < numParts; i++, part++) {
108 part->unk_04 = arg1;
109 part->unk_08 = arg2;
110 part->unk_0C = arg3;
111 part->unk_60 = sin_deg(i * 45 + randInt) * 5.0f;
112 part->unk_64 = cos_deg(i * 45 + randInt) * 2.0f + 3.0f;
113 part->unk_4C = rand_int(64);
114 part->unk_50 = rand_int(64);
115 part->unk_70 = 1.0f;
116 part->unk_6C = 1.0f;
117 part->unk_54 = 0;
118 part->unk_58 = 0;
119 part->unk_74 = -45.0f;
120 part->unk_78 = -10.0f;
121 }
122 }
123 }
124
125 return effect;
126}
127
129}
130
132 Effect63FXData* part = effect->data.unk_63;
133 s32 unk_00 = part->unk_00;
134 s32 unk_24;
135 s32 i;
136
137 if (effect->flags & FX_INSTANCE_FLAG_DISMISS) {
138 effect->flags &= ~FX_INSTANCE_FLAG_DISMISS;
139 part->unk_20 = 0x10;
140 }
141
142 if (part->unk_20 < 1000) {
143 part->unk_20--;
144 }
145
146 part->unk_24++;
147 if (part->unk_20 == 1 && unk_00 == 1) {
148 load_effect(EFFECT_63);
149 effect_63_main(2, part->unk_04, part->unk_08, part->unk_0C, part->unk_10, part->unk_14, part->unk_18, 1.0f, 32, 32);
150 }
151
152 if (part->unk_20 < 0) {
153 remove_effect(effect);
154 return;
155 }
156
157 unk_24 = part->unk_24;
158
159 switch (unk_00) {
160 case 0:
161 if (!(unk_24 & (1 | 2))) {
162 load_effect(EFFECT_63);
163 effect_63_main(1, part->unk_04, part->unk_08, part->unk_0C, part->unk_10, part->unk_14, part->unk_18, 1.0f, part->unk_1C, part->unk_1C);
164 }
165 break;
166 case 1:
167 part->unk_60 *= 0.97;
168 part->unk_68 *= 0.97;
169 part->unk_04 += part->unk_60;
170 part->unk_74 += part->unk_78;
171 part->unk_0C += part->unk_68;
172 part->unk_64 += (1.0f - part->unk_64) * 0.02;
173 part->unk_70 += (1.0 - part->unk_70) * 0.05;
174 part->unk_6C += (1.0 - part->unk_6C) * 0.1;
175 part->unk_08 += part->unk_64;
176 break;
177 case 2:
178 for (i = 0; i < effect->numParts; i++, part++) {
179 part->unk_60 *= 0.9;
180 part->unk_64 -= 0.2;
181 part->unk_04 += part->unk_60;
182 part->unk_08 += part->unk_64;
183 if (part->unk_08 < 0.0f) {
184 part->unk_08 = 0.0f;
185 if (part->unk_64 < 0.0f) {
186 part->unk_64 *= -0.6;
187 }
188 }
189 part->unk_70 += (0.0f - part->unk_70) * 0.07;
190 part->unk_6C += (0.0f - part->unk_6C) * 0.05;
191 part->unk_74 += part->unk_78;
192 }
193 break;
194 }
195}
196
198 RenderTask renderTask;
199 RenderTask* retTask;
200
201 renderTask.appendGfx = effect_63_appendGfx;
202 renderTask.appendGfxArg = effect;
203 renderTask.dist = 10;
205
206 retTask = queue_render_task(&renderTask);
208}
209
210void effect_63_appendGfx(void* effect) {
211 Effect63FXData* part = ((EffectInstance*)effect)->data.unk_63;
212 Camera* camera = &gCameras[gCurrentCameraID];
213 s32 unk_34 = part->unk_34;
214 s32 unk_00 = part->unk_00;
215 f32 unk_48 = part->unk_48;
216 Matrix4f sp18;
217 Matrix4f sp58;
218 f32 angle;
219 s32 tempX;
220 s32 tempY;
221 s32 i;
222
223 if (part->unk_00 != 0) {
224 gDPPipeSync(gMainGfxPos++);
225 gSPSegment(gMainGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(((EffectInstance*)effect)->graphics->data));
226 gDPSetPrimColor(gMainGfxPos++, 0, 0, part->unk_28, part->unk_2C, part->unk_30, unk_34);
227 gDPSetEnvColor(gMainGfxPos++, part->unk_38, part->unk_3C, part->unk_40, part->unk_44);
228 gSPDisplayList(gMainGfxPos++, D_E00C6C9C[unk_00]);
229
230 for (i = 0; i < ((EffectInstance*)effect)->numParts; i++, part++) {
231 part->unk_4C += part->unk_54;
232 part->unk_50 += part->unk_58;
233
234 angle = -atan2(0.0f, 0.0f, part->unk_60, part->unk_64) + part->unk_74;
235 part->unk_54 = sin_deg(angle);
236 part->unk_58 = cos_deg(angle);
237
238 if (part->unk_4C < 0.0f) {
239 part->unk_4C += 128.0f;
240 }
241
242 if (part->unk_50 > 128.0f) {
243 part->unk_50 -= 128.0f;
244 }
245
246 tempX = part->unk_4C * 4.0f;
247 tempY = part->unk_50 * 4.0f;
248
249 guTranslateF(sp18, part->unk_04, part->unk_08, part->unk_0C);
250 guScaleF(sp58, unk_48, unk_48, unk_48);
251 guMtxCatF(sp58, sp18, sp18);
253
254 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
255 gSPMatrix(gMainGfxPos++, camera->mtxBillboard, G_MTX_NOPUSH | G_MTX_MUL | G_MTX_MODELVIEW);
256
257 guScaleF(sp18, part->unk_70, part->unk_6C, 1.0f);
258 guRotateF(sp58, part->unk_74, 0.0f, 0.0f, 1.0f);
259 guMtxCatF(sp58, sp18, sp18);
261
262 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_NOPUSH | G_MTX_MUL | G_MTX_MODELVIEW);
263 gDPSetTileSize(gMainGfxPos++, 1, tempX, tempY, (tempX + 0x3F) * 4, (tempY + 0xF) * 4);
264 gSPDisplayList(gMainGfxPos++, D_E00C6C90[unk_00]);
265 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
266 }
267 }
268}
Mtx matrixStack[0x200]
f32 Matrix4f[4][4]
Gfx * D_E00C6C9C[]
Definition effect_63.c:11
void effect_63_init(EffectInstance *effect)
Definition effect_63.c:128
void effect_63_render(EffectInstance *effect)
Definition effect_63.c:197
void effect_63_appendGfx(void *effect)
Definition effect_63.c:210
Gfx D_09001B70_3CF250[]
Gfx * D_E00C6C90[]
Definition effect_63.c:7
EffectInstance * effect_63_main(s32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4, f32 arg5, f32 arg6, f32 arg7, s32 arg8, s32 arg9)
Definition effect_63.c:20
Gfx D_09001C98_3CF378[]
void effect_63_update(EffectInstance *effect)
Definition effect_63.c:131
#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 load_effect
#define cos_deg
#define atan2
#define create_effect_instance
#define guScaleF
struct Effect63FXData * unk_63
Definition effects.h:2563
EffectData data
Definition effects.h:2605
#define ASSERT(condition)
@ FX_INSTANCE_FLAG_DISMISS
Definition enums.h:3517
@ RENDER_TASK_FLAG_REFLECT_FLOOR
Definition enums.h:3318
@ RENDER_MODE_CLOUD_NO_ZCMP
Definition enums.h:3311
#define VIRTUAL_TO_PHYSICAL(addr)
Definition macros.h:47
Mtx * mtxBillboard
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