Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
energy_orb_wave.c
Go to the documentation of this file.
1#include "common.h"
2#include "effects_internal.h"
3
4extern Gfx D_09001000_3A5320[];
5extern Gfx D_090010A8_3A53C8[];
6extern Gfx D_090011D0_3A54F0[];
7extern Gfx D_090011F0_3A5510[];
8extern Gfx D_09001210_3A5530[];
9
13void energy_orb_wave_appendGfx(void* effect);
14
15EffectInstance* energy_orb_wave_main(s32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4, s32 arg5) {
17 EffectInstance* effect;
19 s32 numParts = 1;
20
24 bp.unk_00 = 0;
25 bp.renderUI = NULL;
26 bp.effectID = EFFECT_ENERGY_ORB_WAVE;
27
28 effect = create_effect_instance(&bp);
29 effect->numParts = numParts;
30 data = effect->data.energyOrbWave = general_heap_malloc(numParts * sizeof(*data));
31 ASSERT(effect->data.energyOrbWave != NULL);
32
33 data->unk_00 = arg0;
34 data->unk_14 = 0;
35 if (arg5 <= 0) {
36 data->unk_10 = 100;
37 } else {
38 data->unk_10 = arg5;
39 }
40 data->unk_2C = 0;
41 data->pos.x = arg1;
42 data->pos.y = arg2;
43 data->pos.z = arg3;
44 data->scale = arg4;
45 data->unk_18 = 0;
46
47 switch (arg0) {
48 case 0:
49 data->unk_1C = 0;
50 break;
51 case 1:
52 data->unk_1C = 2;
53 break;
54 case 2:
55 data->unk_1C = 4;
56 break;
57 case 3:
58 data->unk_1C = 6;
59 break;
60 case 4:
61 data->unk_1C = 7;
62 break;
63 case 5:
64 data->unk_1C = 8;
65 break;
66 case 6:
67 data->unk_1C = 9;
68 break;
69 default:
70 data->unk_1C = 10;
71 data->unk_34 = -(arg4 - 0.1) / arg5;
72 break;
73 }
74
75 return effect;
76}
77
80
83 f32 var_float;
84 s32 unk_14;
85 s32 var_2;
86 s32 var_1;
87 s32 unk_1C;
88 u16 var_4;
89 s32 var_3;
90
91 if (effect->flags & FX_INSTANCE_FLAG_DISMISS) {
92 effect->flags &= ~FX_INSTANCE_FLAG_DISMISS;
93 data->unk_10 = 30;
94 }
95
96 if (data->unk_10 < 100) {
97 data->unk_10--;
98 }
99 data->unk_14++;
100
101 if (data->unk_10 < 0) {
102 remove_effect(effect);
103 return;
104 }
105
106 unk_14 = data->unk_14;
107 unk_1C = data->unk_1C;
108 var_1 = 0xFF;
109 var_2 = 0xFF;
110
111 if (unk_14 < 16) {
112 var_1 = (unk_14 * 16) - 1;
113 }
114 if (data->unk_10 < 16) {
115 var_1 = var_1 * data->unk_10 / 16;
116 var_2 = data->unk_10 * 16;
117 }
118
119 switch (unk_1C) {
120 case 0:
121 data->unk_20 = 70;
122 data->unk_24 = 180;
123 data->unk_28 = 120;
124 var_float = sin_deg(unk_14 * 2) * 10.0f + 190.0f;
125 data->unk_2C = ((s32) var_float * var_1) / 255;
126 break;
127 case 1:
128 var_3 = 255;
129 data->unk_20 = 70;
130 data->unk_24 = 255;
131 data->unk_28 = 230;
132 data->unk_2C = (var_1 * var_3) / 255;
133 break;
134 case 2:
135 data->unk_20 = 170;
136 data->unk_24 = 40;
137 data->unk_28 = 110;
138 var_float = sin_deg(unk_14 * 2) * 10.0f + 190.0f;
139 data->unk_2C = ((s32) var_float * var_1) / 255;
140 break;
141 case 3:
142 var_4 = 255;
143 data->unk_20 = 220;
144 data->unk_24 = 40;
145 data->unk_28 = 170;
146 data->unk_2C = (var_1 * var_4) / 255;
147 break;
148 case 4:
149 data->unk_20 = 235;
150 data->unk_24 = 235;
151 data->unk_28 = 200;
152 var_float = sin_deg(unk_14 * 2) * 15.0f + 215.0f;
153 data->unk_2C = ((s32) var_float * var_1) / 255;
154 break;
155 case 5:
156 var_4 = 255;
157 data->unk_20 = 235;
158 data->unk_24 = 235;
159 data->unk_28 = 200;
160 data->unk_2C = (var_1 * var_4) / 255;
161 break;
162 case 6:
163 var_4 = 127;
164 data->unk_20 = 70;
165 data->unk_24 = 180;
166 data->unk_28 = 120;
167 data->unk_2C = (var_2 * var_4) / 255;
168 data->scale *= 1.1;
169 break;
170 case 7:
171 var_4 = 160;
172 data->unk_20 = 162;
173 data->unk_24 = 189;
174 data->unk_28 = 174;
175 data->unk_2C = (var_2 * var_4) / 255;
176 data->scale *= 1.1;
177 break;
178 case 8:
179 var_4 = 127;
180 data->unk_20 = 170;
181 data->unk_24 = 40;
182 data->unk_28 = 110;
183 data->unk_2C = (var_2 * var_4) / 255;
184 data->scale *= 1.1;
185 break;
186 case 9:
187 var_4 = 160;
188 data->unk_20 = 180;
189 data->unk_24 = 178;
190 data->unk_28 = 174;
191 data->unk_2C = (var_2 * var_4) / 255;
192 data->scale *= 1.1;
193 break;
194 default:
195 var_4 = 160;
196 data->unk_20 = 50;
197 data->unk_24 = 50;
198 data->unk_28 = 255;
199 data->unk_2C = (var_2 * var_4) / 255;
200 data->scale += data->unk_34;
201 break;
202 }
203}
204
206 EnergyOrbWaveFXData* effect82 = effect->data.energyOrbWave;
207 RenderTask renderTask;
208 RenderTask* retTask;
209 RenderTask* renderTaskPointer = &renderTask;
210
212 renderTask.dist = 10;
213 renderTask.appendGfxArg = effect;
215 if (effect82->unk_00 >= 3) {
216 queue_render_task(renderTaskPointer);
217 return;
218 }
219
220 retTask = queue_render_task(renderTaskPointer);
222}
223
224void func_E00A4648(void) {
225}
226
227void energy_orb_wave_appendGfx(void* effect) {
228 EnergyOrbWaveFXData* data = ((EffectInstance*)effect)->data.energyOrbWave;
229 Camera* camera = &gCameras[gCurrentCameraID];
230 s32 unk_14 = data->unk_14;
231 s32 unk_2C = data->unk_2C;
232 s32 unk_00 = data->unk_00;
233 Matrix4f sp18;
234 Matrix4f sp58;
235
236 gDPPipeSync(gMainGfxPos++);
237 gSPSegment(gMainGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(((EffectInstance*)effect)->graphics->data));
238
239 guTranslateF(sp18, data->pos.x, data->pos.y, data->pos.z);
240 guScaleF(sp58, data->scale, data->scale, data->scale);
241 guMtxCatF(sp58, sp18, sp18);
243
244 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
245 gSPMatrix(gMainGfxPos++, camera->mtxBillboard, G_MTX_NOPUSH | G_MTX_MUL | G_MTX_MODELVIEW);
246 gDPSetPrimColor(gMainGfxPos++, 0, 0, data->unk_20, data->unk_24, data->unk_28, unk_2C);
247 gDPSetColorDither(gMainGfxPos++, G_CD_BAYER);
248 gDPSetAlphaDither(gMainGfxPos++, G_AD_PATTERN);
249
250 if (unk_00 < 3) {
251 gSPDisplayList(gMainGfxPos++, D_09001000_3A5320);
252
253 guRotateF(sp18, unk_14, 0.0f, 0.0f, 1.0f);
255
256 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
257 gSPDisplayList(gMainGfxPos++, D_090011D0_3A54F0);
258 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
259 gDPSetColorDither(gMainGfxPos++, G_CD_MAGICSQ);
260
261 guRotateF(sp18, -unk_14 * 8, 0.0f, 0.0f, 1.0f);
263
264 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
265 gSPDisplayList(gMainGfxPos++, D_090011F0_3A5510);
266 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
267 } else {
268 gSPDisplayList(gMainGfxPos++, D_090010A8_3A53C8);
269 gSPDisplayList(gMainGfxPos++, D_09001210_3A5530);
270 }
271
272 gDPSetColorDither(gMainGfxPos++, G_CD_DISABLE);
273 gDPSetAlphaDither(gMainGfxPos++, G_AD_DISABLE);
274 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
275}
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 create_effect_instance
#define guScaleF
struct EnergyOrbWaveFXData * energyOrbWave
Definition effects.h:2546
EffectData data
Definition effects.h:2605
#define ASSERT(condition)
Gfx D_090010A8_3A53C8[]
Gfx D_09001000_3A5320[]
Gfx D_090011F0_3A5510[]
void energy_orb_wave_appendGfx(void *effect)
void energy_orb_wave_init(EffectInstance *effect)
void energy_orb_wave_update(EffectInstance *effect)
EffectInstance * energy_orb_wave_main(s32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4, s32 arg5)
Gfx D_09001210_3A5530[]
void energy_orb_wave_render(EffectInstance *effect)
Gfx D_090011D0_3A54F0[]
void func_E00A4648(void)
@ 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