Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
disable_x.c
Go to the documentation of this file.
1#include "common.h"
2#include "effects_internal.h"
3
4extern Gfx D_09002100_3884B0[];
5extern Gfx D_09002198_388548[];
6extern Gfx D_09002230_3885E0[];
7extern Gfx D_09002250_388600[];
8extern Gfx D_09002270_388620[];
9extern Gfx D_09002290_388640[];
10extern Gfx D_090022B0_388660[];
11extern Gfx D_09002320_3886D0[];
12extern Gfx D_09002360_388710[];
13extern Gfx D_090023A0_388750[];
14extern Gfx D_090023E0_388790[];
15extern Gfx D_09002420_3887D0[];
16extern Gfx D_09002460_388810[];
17extern Gfx D_090024A0_388850[];
18extern Gfx D_090024E0_388890[];
19extern Gfx D_09002520_3888D0[];
20extern Gfx D_09002560_388910[];
21extern Gfx D_090025A0_388950[];
22extern Gfx D_090025E0_388990[];
23
28
29void disable_x_init(EffectInstance* effect);
32void func_E0082528(EffectInstance* effect);
33void func_E00828B4(EffectInstance* effect);
34void func_E0082A84(EffectInstance* effect);
35
36EffectInstance* disable_x_main(s32 type, f32 x, f32 y, f32 z, s32 arg4) {
38 EffectInstance* effect;
39 DisableXFXData* data;
40 s32 numParts = 2;
41 s32 i;
42
43 bp.unk_00 = 0;
48 bp.effectID = EFFECT_DISABLE_X;
49
50 effect = create_effect_instance(&bp);
51 effect->numParts = numParts;
52 data = general_heap_malloc(numParts * sizeof(*data));
53 effect->data.disableX = data;
54 ASSERT(effect->data.disableX != NULL);
55
56 data->type = type;
57 data->scale = 1.0f;
58 if (type == 1) {
59 data->unk_38 = type;
60 data->koDuration = 0;
61 } else {
62 data->unk_38 = 0;
63 data->koDuration = arg4;
64 }
65
66 data->pos.x = x;
67 data->pos.y = y;
68 data->pos.z = z;
69
70 switch (type) {
71 case 0:
72 data->unk_28 = 100;
73 break;
74 case 1:
75 data->unk_28 = 100;
76 break;
77 case 10:
78 data->unk_28 = 21;
79 break;
80 }
81
82 data->unk_2C = 0;
83 data->unk_44 = 0;
84 data->unk_04 = 1;
85
86 data++;
87 for (i = 1; i < numParts; i++, data++) {
88 data->pos.x = data->pos.y = data->pos.z = 0.0f;
89 data->unk_18 = data->unk_1C = data->unk_20 = 0.0f;
90 data->unk_14 = 0.0f;
91 data->unk_40 = 0.0f;
92 data->unk_28 = 0;
93 data->alpha = 255;
94 }
95
96 return effect;
97}
98
100}
101
103 static const f32 D_E0082D30[12] = { 5.0f, 4.0f, 4.0f, 3.0f, 2.0f, 1.0f, 0.7f, 1.2f, 1.0f, 0.0f, 0.0f, 0.0f };
104
105 DisableXFXData* data = effect->data.disableX;
106 s32 unk_28;
107 s32 unk_2C;
108 f32 unk_34;
109 s32 unk_3C;
110 s32 unk_38;
111 u32 type;
112 s32 i;
113
114 if (effect->flags & FX_INSTANCE_FLAG_DISMISS) {
115 effect->flags &= ~FX_INSTANCE_FLAG_DISMISS;
116 data->unk_28 = 21;
117 }
118
119 if (data->unk_28 < 100) {
120 data->unk_28--;
121 }
122
123 if (data->unk_28 < 0) {
124 remove_effect(effect);
125 return;
126 }
127
128 data->unk_2C++;
129 if (data->unk_2C > 324000) {
130 data->unk_2C = 256;
131 }
132
133 type = data->type;
134 unk_28 = data->unk_28;
135 unk_2C = data->unk_2C;
136 unk_38 = data->unk_38;
137 unk_34 = data->scale;
138 unk_3C = data->koDuration;
139
140 if (type == 0) {
141 if (data->unk_44 > 0) {
142 data->unk_44--;
143 } else {
144 if (data->koDuration != unk_38) {
145 if (data->koDuration < 0) {
146 unk_3C = 0;
147 }
148 if (unk_38 < unk_3C) {
149 data->unk_28 = 100;
150 data->unk_2C = 1;
151 data[1].unk_28 = 0;
152 data->unk_38++;
153 if (data->pos.y > -500.0f) {
155 }
156 } else if (unk_3C < unk_38) {
157 load_effect(EFFECT_DISABLE_X);
158 disable_x_main(10, data->pos.x, data->pos.y + data[1].unk_20, data->pos.z, 0);
159 data->unk_38--;
160 }
161 data->unk_44 = 8;
162 }
163 }
164 }
165
166 data++;
167 for (i = 1; i < effect->numParts; i++, data++) {
168 if (data->unk_28 < 9 && type != 10) {
169 data->unk_30 = D_E0082D30[data->unk_28];
170 } else {
171 data->unk_30 = 1.0f;
172 }
173
174 data->unk_30 *= unk_34;
175 if (type < 2) {
176 data->unk_20 = cos_deg(unk_2C * 12) * 4.0f;
177 } else {
178 data->unk_20 = 0.0f;
179 }
180
181 data->pos.x += data->unk_14;
182 data->pos.y += data->unk_18;
183 data->pos.z += data->unk_1C;
184
185 if (unk_28 == 20) {
186 data->unk_18 = 4.0f;
187 data->unk_14 = -2.0f;
188 }
189 if (unk_28 < 20) {
190 data->unk_18 += -0.5;
191 data->unk_40 += 10.0f;
192 data->unk_20 *= (f32) unk_28 * 0.05;
193 }
194 if (unk_28 < 10) {
195 data->alpha = unk_28 * 25;
196 }
197 data->unk_28 += 1;
198 }
199}
200
202}
203
205 DisableXFXData* data = effect->data.disableX;
206
207 if (data->unk_04 != 0) {
208 func_E00828B4(effect);
209 if (data->type != 1) {
210 func_E0082A84(effect);
211 }
212 }
213}
214
216 Matrix4f sp18, sp58;
217
218 guTranslateF(sp18, data->pos.x, data->pos.y, data->pos.z);
219 guScaleF(sp58, data->scale, data->scale, 1.0f);
220 guRotateF(sp58, -gCameras[gCurrentCameraID].curYaw, 0.0f, 1.0f, 0.0f);
221 guMtxCatF(sp58, sp18, sp18);
224 G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
225}
226
228 Matrix4f sp18, sp58;
229
230 guTranslateF(sp18, data->pos.x, data->pos.y, data->pos.z);
231 guScaleF(sp58, data->unk_30, data->unk_30, 1.0f);
232 guMtxCatF(sp58, sp18, sp18);
233 guRotateF(sp58, data->unk_40, 0.0f, 0.0f, 1.0f);
234 guMtxCatF(sp58, sp18, sp18);
235 guTranslateF(sp58, 0.0f, data->unk_20, 0.0f);
236 guMtxCatF(sp58, sp18, sp18);
238
240 G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
241 gDPSetPrimColor(gMainGfxPos++, 0, 0, 0, 0, 0, data->alpha);
242
243 if (data->alpha == 255) {
244 gDPSetRenderMode(gMainGfxPos++, AA_EN | CVG_DST_FULL | ZMODE_OPA | CVG_X_ALPHA |
245 GBL_c1(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM),
246 AA_EN | CVG_DST_FULL | ZMODE_OPA | CVG_X_ALPHA |
247 GBL_c2(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM));
248 gDPSetCombineMode(gMainGfxPos++, G_CC_MODULATEIDECALA, G_CC_MODULATEIDECALA);
249 } else {
250 gDPSetRenderMode(gMainGfxPos++, G_RM_CLD_SURF, G_RM_CLD_SURF2);
251 gDPSetCombineMode(gMainGfxPos++, PM_CC_49, PM_CC_49);
252 }
253}
254
256 DisableXFXData* data = effect->data.disableX;
257 s32 type;
258 s32 unk_38;
259 s32 i;
260
261 gDPPipeSync(gMainGfxPos++);
262 gSPSegment(gMainGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(effect->graphics->data));
263 func_E0082580(data);
264 unk_38 = data->unk_38;
265 type = data->type;
266
267 data++;
268 for (i = 1; i < effect->numParts; i++, data++) {
269 if (unk_38 > 0 || type == 10) {
270 if (type == 1) {
271 gSPDisplayList(gMainGfxPos++, D_09002198_388548);
272 } else {
273 gSPDisplayList(gMainGfxPos++, D_09002100_3884B0);
274 }
275 func_E00826C4(data);
276 gSPDisplayList(gMainGfxPos++, D_09002230_3885E0);
277 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
278 }
279 }
280 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
281 gDPPipeSync(gMainGfxPos++);
282}
283
285 DisableXFXData* data = effect->data.disableX;
286 s32 unk_38;
287 s32 i;
288
289 gDPPipeSync(gMainGfxPos++);
290 gSPSegment(gMainGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(effect->graphics->data));
291 func_E0082580(data);
292 unk_38 = data->unk_38;
293
294 data++;
295 for (i = 1; i < effect->numParts; i++, data++) {
296 func_E00826C4(data);
297 if (unk_38 > 0) {
298 gSPDisplayList(gMainGfxPos++, D_090022B0_388660);
299 if (unk_38 < 10) {
300 gSPDisplayList(gMainGfxPos++, D_E0082D00[unk_38]);
301 gSPDisplayList(gMainGfxPos++, D_09002250_388600);
302 } else {
303 s32 ones = unk_38 % 10;
304 s32 tens = unk_38 / 10;
305
306 gSPDisplayList(gMainGfxPos++, D_E0082D00[ones]);
307 gSPDisplayList(gMainGfxPos++, D_E0082D00[tens]);
308 gSPDisplayList(gMainGfxPos++, D_09002290_388640);
309 gSPDisplayList(gMainGfxPos++, D_E0082D00[tens]);
310 gSPDisplayList(gMainGfxPos++, D_09002270_388620);
311 }
312 }
313 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
314 }
315 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
316 gDPPipeSync(gMainGfxPos++);
317}
Mtx matrixStack[0x200]
f32 Matrix4f[4][4]
void func_E00828B4(EffectInstance *effect)
Definition disable_x.c:255
Gfx D_090025E0_388990[]
Gfx D_09002198_388548[]
Gfx D_09002270_388620[]
void func_E0082580(DisableXFXData *data)
Definition disable_x.c:215
Gfx D_09002360_388710[]
void func_E0082A84(EffectInstance *effect)
Definition disable_x.c:284
Gfx D_09002290_388640[]
Gfx D_09002560_388910[]
Gfx * D_E0082D00[]
Definition disable_x.c:24
EffectInstance * disable_x_main(s32 type, f32 x, f32 y, f32 z, s32 arg4)
Definition disable_x.c:36
void func_E0082528(EffectInstance *effect)
Definition disable_x.c:204
Gfx D_090025A0_388950[]
Gfx D_09002520_3888D0[]
void disable_x_init(EffectInstance *effect)
Definition disable_x.c:99
Gfx D_09002420_3887D0[]
Gfx D_09002460_388810[]
Gfx D_09002230_3885E0[]
Gfx D_090023E0_388790[]
Gfx D_090024A0_388850[]
Gfx D_09002100_3884B0[]
void func_E00826C4(DisableXFXData *data)
Definition disable_x.c:227
Gfx D_09002320_3886D0[]
void disable_x_update(EffectInstance *effect)
Definition disable_x.c:102
void disable_x_render(EffectInstance *effect)
Definition disable_x.c:201
Gfx D_090023A0_388750[]
Gfx D_09002250_388600[]
Gfx D_090022B0_388660[]
Gfx D_090024E0_388890[]
#define general_heap_malloc
#define guRotateF
#define sfx_play_sound_at_position
#define guMtxF2L
#define guTranslateF
#define guMtxCatF
#define remove_effect
#define load_effect
#define cos_deg
#define create_effect_instance
#define guScaleF
struct DisableXFXData * disableX
Definition effects.h:2529
struct EffectGraphics * graphics
Definition effects.h:2606
EffectData data
Definition effects.h:2605
#define ASSERT(condition)
@ FX_INSTANCE_FLAG_DISMISS
Definition enums.h:3517
@ SOUND_INFLICT_KO
Definition enums.h:1545
@ SOUND_SPACE_DEFAULT
Definition enums.h:1737
#define PM_CC_49
Definition macros.h:478
#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
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