Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
energy_in_out.c
Go to the documentation of this file.
1#include "common.h"
2#include "effects_internal.h"
3
4extern Gfx D_09000200_3D6130[];
5extern Gfx D_090003A8_3D62D8[];
6extern Gfx D_090003C8_3D62F8[];
7extern Gfx D_090003E8_3D6318[];
8extern Gfx D_09000528_3D6458[];
9extern Gfx D_09000540_3D6470[];
10extern Gfx D_09000558_3D6488[];
11extern Gfx D_09000688_3D65B8[];
12extern Gfx D_09000808_3D6738[];
13
20
21u8 D_E00D6E74[] = {
22 0x0B, 0x0B, 0x0B, 0x0B, 0x11, 0x0B, 0x0B, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x00, 0x00, 0x00
23};
24
25u8 D_E00D6E84[] = {
26 0x14, 0x05, 0x14, 0x14, 0x0A, 0x14, 0x14, 0x08, 0x08, 0x08, 0x01, 0x01, 0x01, 0x00,
27 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
28};
29
33void energy_in_out_appendGfx(void* effect);
34
35EffectInstance* energy_in_out_main(s32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4, s32 arg5) {
37 EffectInstance* effect;
39 EnergyInOutFXData* firstPart;
40 s32 numParts = D_E00D6E74[arg0];
41 f32 randAngle;
42 s32 i;
43
47 bp.unk_00 = 0;
48 bp.renderUI = NULL;
49 bp.effectID = EFFECT_ENERGY_IN_OUT;
50
51 effect = create_effect_instance(&bp);
52 effect->numParts = numParts;
53 firstPart = part = effect->data.energyInOut = general_heap_malloc(numParts * sizeof(*part));
54 ASSERT(effect->data.energyInOut != NULL);
55
56 part->unk_00 = arg0;
57 part->unk_14 = 0;
58 if (arg5 <= 0) {
59 part->unk_10 = 1000;
60 } else {
61 part->unk_10 = arg5;
62 }
63 part->unk_24 = 0;
64 part->pos.x = arg1;
65 part->pos.y = arg2;
66 part->pos.z = arg3;
67 part->scale = arg4;
68 part->unk_18 = 255;
69 part->unk_1C = 255;
70 part->unk_20 = 255;
71 part->unk_28 = 255;
72 part->unk_2C = 245;
73 part->unk_30 = 0;
74 part->unk_44 = 1.0f;
75 part->unk_38 = D_E00D6E84[arg0];
76
77 randAngle = rand_int(360);
78
79 part++;
80 for (i = 1; i < effect->numParts; i++, part++) {
81 part->unk_00 = arg0 % 3;
82
83 switch (arg0) {
84 case 0:
85 case 1:
86 case 2:
87 part->unk_38 = -(rand_int(10) * 0.2 + 0.2);
88 part->unk_10 = 20;
89 part->unk_40 = 0;
90 part->scale = 1.0 - (i % 3) * 0.1;
91 break;
92 case 3:
93 case 5:
94 part->unk_38 = rand_int(10) * 0.2 + 0.2;
95 part->unk_10 = 20;
96 part->unk_40 = 0;
97 part->scale = 1.0 - (i % 3) * 0.1;
98 break;
99 case 6:
100 part->unk_38 = -(rand_int(10) + 4);
101 part->unk_10 = 10;
102 part->unk_40 = 0;
103 part->scale = 1.0 - (i % 3) * 0.3;
104 break;
105 case 7:
106 part->unk_38 = -(rand_int(10) + 4);
107 part->unk_10 = 10;
108 part->unk_40 = 0;
109 part->scale = 1.0 - (i % 3) * 0.3;
110 break;
111 case 8:
112 part->unk_38 = rand_int(10) * 0.2 + 0.6;
113 part->unk_10 = 20;
114 part->unk_40 = -1.0f;
115 part->scale = 1.0 - (i % 3) * 0.3;
116 break;
117 case 9:
118 part->unk_38 = -(rand_int(10) * 0.2 + 0.6);
119 part->unk_10 = 20;
120 part->unk_40 = -2.0f;
121 part->scale = 1.0 - (i % 3) * 0.3;
122 firstPart->unk_18 = 255;
123 firstPart->unk_1C = 245;
124 firstPart->unk_20 = 215;
125 firstPart->unk_28 = 220;
126 firstPart->unk_2C = 60;
127 firstPart->unk_30 = 10;
128 break;
129 case 10:
130 part->unk_38 = rand_int(10) * 0.1 + 2.0;
131 part->unk_10 = 10;
132 part->unk_40 = 0;
133 part->scale = (1.0 - (i % 3) * 0.3) * 0.5;
134 break;
135 case 11:
136 part->unk_38 = rand_int(10) * 0.05 + 0.2;
137 part->unk_40 = -1.0f;
138 part->unk_10 = 30;
139 part->scale = 1.0 - (i % 3) * 0.3;
140 break;
141 case 4:
142 case 12:
143 part->unk_38 = rand_int(10) * 0.2 + 0.6;
144 part->unk_10 = 20;
145 part->unk_40 = -2.0f;
146 part->scale = 1.0 - (i % 3) * 0.3;
147 break;
148 }
149
150 part->unk_14 = -rand_int(part->unk_10);
151
152 if (part->unk_38 < 0.0f) {
153 part->pos.x = (part->unk_10 - part->unk_14) * (-part->unk_38);
154 } else {
155 part->pos.x = (-part->unk_14) * part->unk_38;
156 }
157 part->pos.y = 0;
158 part->pos.z = 0;
159
160 part->unk_3C = (i - 1) * 360 / (numParts - 1) + randAngle;
161 }
162
163 return effect;
164}
165
168
170 EnergyInOutFXData* part = effect->data.energyInOut;
171 s32 unk_10;
172 s32 unk_14;
173 f32 angle;
174 s32 i;
175
176 if (effect->flags & FX_INSTANCE_FLAG_DISMISS) {
177 effect->flags &= ~FX_INSTANCE_FLAG_DISMISS;
178 part->unk_10 = 16;
179 }
180
181 if (part->unk_10 < 1000) {
182 part->unk_10--;
183 }
184
185 part->unk_14++;
186 if (part->unk_10 < 0) {
187 remove_effect(effect);
188 return;
189 }
190
191 unk_10 = part->unk_10;
192 unk_14 = part->unk_14;
193
194 if (unk_10 < 16) {
195 part->unk_24 = unk_10 * 16;
196 }
197
198 if (unk_14 < 16) {
199 part->unk_24 = unk_14 * 16 + 15;
200 }
201
202 part++;
203 for (i = 1; i < effect->numParts; i++, part++) {
204 part->unk_14++;
205 if (part->unk_14 >= part->unk_10) {
206 part->unk_14 = 0;
207 if (part->unk_38 < 0.0f) {
208 part->pos.x = -part->unk_10 * part->unk_38;
209 } else {
210 part->pos.x = 0.0f;
211 }
212 part->unk_3C = rand_int(359);
213 }
214
215 part->pos.x += part->unk_38;
216 part->unk_3C += part->unk_40;
217
218 angle = (part->unk_14 * 180) / part->unk_10;
219 if (angle < 0.0f || angle > 180.0f) {
220 part->unk_24 = 0;
221 } else {
222 part->unk_24 = sin_deg(angle) * 255.0f;
223 }
224 }
225}
226
228 RenderTask renderTask;
229 RenderTask* retTask;
230
232 renderTask.appendGfxArg = effect;
233 renderTask.dist = 10;
235
236 retTask = queue_render_task(&renderTask);
237}
238
239void func_E00D6978(void) {
240}
241
242void energy_in_out_appendGfx(void* effect) {
243 EnergyInOutFXData* part = ((EffectInstance*)effect)->data.energyInOut;
244 s32 unk_24 = part->unk_24;
245 s32 unk_00 = part->unk_00;
246 f32 scale = part->scale * part->unk_44;
247 s32 unk_18 = part->unk_18;
248 s32 unk_1C = part->unk_1C;
249 s32 unk_20 = part->unk_20;
250 f32 unk_38 = part->unk_38;
251 Matrix4f sp20;
252 Matrix4f sp60;
253 s32 i;
254
255 gDPPipeSync(gMainGfxPos++);
256 gSPSegment(gMainGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(((EffectInstance*)effect)->graphics->data));
257
258 guPositionF(sp20, 0.0f, -gCameras[gCurrentCameraID].curYaw, 0.0f, scale, part->pos.x, part->pos.y, part->pos.z);
260
261 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
262 gDPSetPrimColor(gMainGfxPos++, 0, 0, part->unk_18, part->unk_1C, part->unk_20, unk_24);
263 gDPSetEnvColor(gMainGfxPos++, part->unk_28, part->unk_2C, part->unk_30, 0);
264 gSPDisplayList(gMainGfxPos++, D_09000200_3D6130);
265
266 part++;
267 for (i = 1; i < ((EffectInstance*)effect)->numParts; i++, part++) {
268 f32 scale = part->scale;
269
270 gDPSetPrimColor(gMainGfxPos++, 0, 0, unk_18, unk_1C, unk_20, (unk_24 * part->unk_24) / 255);
271
272 guRotateF(sp20, part->unk_3C, 0.0f, 0.0f, 1.0f);
273 guTranslateF(sp60, part->pos.x + unk_38, 0.0f, 0.0f);
274 guMtxCatF(sp60, sp20, sp20);
275 if (D_E00D6E40[unk_00] == D_09000688_3D65B8 || D_E00D6E40[unk_00] == D_09000808_3D6738) {
276 guScaleF(sp60, scale, 1.0f, 1.0f);
277 } else {
278 guScaleF(sp60, scale, scale, 1.0f);
279 }
280 guMtxCatF(sp60, sp20, sp20);
282
283 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
284 gSPDisplayList(gMainGfxPos++, D_E00D6E40[unk_00]);
285 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
286 }
287
288 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
289}
Mtx matrixStack[0x200]
f32 Matrix4f[4][4]
s8 unk_14
Definition demo_api.c:19
#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 guPositionF
#define create_effect_instance
#define guScaleF
struct EnergyInOutFXData * energyInOut
Definition effects.h:2571
EffectData data
Definition effects.h:2605
#define ASSERT(condition)
void energy_in_out_appendGfx(void *effect)
u8 D_E00D6E74[]
u8 D_E00D6E84[]
Gfx D_090003E8_3D6318[]
void energy_in_out_render(EffectInstance *effect)
Gfx * D_E00D6E40[]
Gfx D_09000808_3D6738[]
Gfx D_090003C8_3D62F8[]
Gfx D_09000200_3D6130[]
EffectInstance * energy_in_out_main(s32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4, s32 arg5)
Gfx D_09000558_3D6488[]
Gfx D_090003A8_3D62D8[]
Gfx D_09000528_3D6458[]
Gfx D_09000540_3D6470[]
Gfx D_09000688_3D65B8[]
void func_E00D6978(void)
void energy_in_out_init(EffectInstance *effect)
void energy_in_out_update(EffectInstance *effect)
@ FX_INSTANCE_FLAG_DISMISS
Definition enums.h:3517
@ RENDER_MODE_CLOUD_NO_ZCMP
Definition enums.h:3311
#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