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
4
extern
Gfx
D_09002100_3884B0
[];
5
extern
Gfx
D_09002198_388548
[];
6
extern
Gfx
D_09002230_3885E0
[];
7
extern
Gfx
D_09002250_388600
[];
8
extern
Gfx
D_09002270_388620
[];
9
extern
Gfx
D_09002290_388640
[];
10
extern
Gfx
D_090022B0_388660
[];
11
extern
Gfx
D_09002320_3886D0
[];
12
extern
Gfx
D_09002360_388710
[];
13
extern
Gfx
D_090023A0_388750
[];
14
extern
Gfx
D_090023E0_388790
[];
15
extern
Gfx
D_09002420_3887D0
[];
16
extern
Gfx
D_09002460_388810
[];
17
extern
Gfx
D_090024A0_388850
[];
18
extern
Gfx
D_090024E0_388890
[];
19
extern
Gfx
D_09002520_3888D0
[];
20
extern
Gfx
D_09002560_388910
[];
21
extern
Gfx
D_090025A0_388950
[];
22
extern
Gfx
D_090025E0_388990
[];
23
24
Gfx
*
D_E0082D00
[] = {
25
D_09002320_3886D0
,
D_09002360_388710
,
D_090023A0_388750
,
D_090023E0_388790
,
D_09002420_3887D0
,
D_09002460_388810
,
26
D_090024A0_388850
,
D_090024E0_388890
,
D_09002520_3888D0
,
D_09002560_388910
,
D_090025A0_388950
,
D_090025E0_388990
27
};
28
29
void
disable_x_init
(
EffectInstance
* effect);
30
void
disable_x_update
(
EffectInstance
* effect);
31
void
disable_x_render
(
EffectInstance
* effect);
32
void
func_E0082528
(
EffectInstance
* effect);
33
void
func_E00828B4
(
EffectInstance
* effect);
34
void
func_E0082A84
(
EffectInstance
* effect);
35
36
EffectInstance
*
disable_x_main
(s32 type,
f32
x,
f32
y,
f32
z, s32
arg4
) {
37
EffectBlueprint
bp
;
38
EffectInstance
* effect;
39
DisableXFXData
* data;
40
s32 numParts = 2;
41
s32 i;
42
43
bp
.unk_00 = 0;
44
bp
.init =
disable_x_init
;
45
bp
.update =
disable_x_update
;
46
bp
.renderScene =
disable_x_render
;
47
bp
.renderUI =
func_E0082528
;
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
99
void
disable_x_init
(
EffectInstance
* effect) {
100
}
101
102
void
disable_x_update
(
EffectInstance
* effect) {
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) {
154
sfx_play_sound_at_position
(
SOUND_INFLICT_KO
,
SOUND_SPACE_DEFAULT
, data->
pos
.
x
, data->
pos
.
y
, data->
pos
.
z
);
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
++;
198
}
199
}
200
201
void
disable_x_render
(
EffectInstance
* effect) {
202
}
203
204
void
func_E0082528
(
EffectInstance
* effect) {
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
215
void
func_E0082580
(
DisableXFXData
* data) {
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
);
222
guMtxF2L
(
sp18
, &
gDisplayContext
->
matrixStack
[
gMatrixListPos
]);
223
gSPMatrix
(
gMainGfxPos
++, &
gDisplayContext
->
matrixStack
[
gMatrixListPos
++],
224
G_MTX_PUSH
|
G_MTX_MUL
|
G_MTX_MODELVIEW
);
225
}
226
227
void
func_E00826C4
(
DisableXFXData
* data) {
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
);
237
guMtxF2L
(
sp18
, &
gDisplayContext
->
matrixStack
[
gMatrixListPos
]);
238
239
gSPMatrix
(
gMainGfxPos
++, &
gDisplayContext
->
matrixStack
[
gMatrixListPos
++],
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
255
void
func_E00828B4
(
EffectInstance
* effect) {
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->
shared
->
graphics
));
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
284
void
func_E0082A84
(
EffectInstance
* effect) {
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->
shared
->
graphics
));
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
}
PopupMenu_SelectedIndex
BSS s32 PopupMenu_SelectedIndex
Definition
8a860_len_3f30.c:84
DisplayContext::matrixStack
Mtx matrixStack[0x200]
Definition
common_structs.h:2192
Matrix4f
f32 Matrix4f[4][4]
Definition
common_structs.h:133
Vec3f::z
f32 z
Definition
common_structs.h:103
Vec3f::x
f32 x
Definition
common_structs.h:101
Vec3f::y
f32 y
Definition
common_structs.h:102
func_E00828B4
void func_E00828B4(EffectInstance *effect)
Definition
disable_x.c:255
D_090025E0_388990
Gfx D_090025E0_388990[]
D_09002198_388548
Gfx D_09002198_388548[]
D_09002270_388620
Gfx D_09002270_388620[]
func_E0082580
void func_E0082580(DisableXFXData *data)
Definition
disable_x.c:215
D_09002360_388710
Gfx D_09002360_388710[]
func_E0082A84
void func_E0082A84(EffectInstance *effect)
Definition
disable_x.c:284
D_09002290_388640
Gfx D_09002290_388640[]
D_09002560_388910
Gfx D_09002560_388910[]
D_E0082D00
Gfx * D_E0082D00[]
Definition
disable_x.c:24
disable_x_main
EffectInstance * disable_x_main(s32 type, f32 x, f32 y, f32 z, s32 arg4)
Definition
disable_x.c:36
func_E0082528
void func_E0082528(EffectInstance *effect)
Definition
disable_x.c:204
D_090025A0_388950
Gfx D_090025A0_388950[]
D_09002520_3888D0
Gfx D_09002520_3888D0[]
disable_x_init
void disable_x_init(EffectInstance *effect)
Definition
disable_x.c:99
D_09002420_3887D0
Gfx D_09002420_3887D0[]
D_09002460_388810
Gfx D_09002460_388810[]
D_09002230_3885E0
Gfx D_09002230_3885E0[]
D_090023E0_388790
Gfx D_090023E0_388790[]
D_090024A0_388850
Gfx D_090024A0_388850[]
D_09002100_3884B0
Gfx D_09002100_3884B0[]
func_E00826C4
void func_E00826C4(DisableXFXData *data)
Definition
disable_x.c:227
D_09002320_3886D0
Gfx D_09002320_3886D0[]
disable_x_update
void disable_x_update(EffectInstance *effect)
Definition
disable_x.c:102
disable_x_render
void disable_x_render(EffectInstance *effect)
Definition
disable_x.c:201
D_090023A0_388750
Gfx D_090023A0_388750[]
D_09002250_388600
Gfx D_09002250_388600[]
D_090022B0_388660
Gfx D_090022B0_388660[]
D_090024E0_388890
Gfx D_090024E0_388890[]
general_heap_malloc
#define general_heap_malloc
Definition
effect_shims.h:51
guRotateF
#define guRotateF
Definition
effect_shims.h:42
sfx_play_sound_at_position
#define sfx_play_sound_at_position
Definition
effect_shims.h:73
guMtxF2L
#define guMtxF2L
Definition
effect_shims.h:47
guTranslateF
#define guTranslateF
Definition
effect_shims.h:43
guMtxCatF
#define guMtxCatF
Definition
effect_shims.h:46
remove_effect
#define remove_effect
Definition
effect_shims.h:50
load_effect
#define load_effect
Definition
effect_shims.h:59
cos_deg
#define cos_deg
Definition
effect_shims.h:56
create_effect_instance
#define create_effect_instance
Definition
effect_shims.h:49
guScaleF
#define guScaleF
Definition
effect_shims.h:45
EffectInstanceDataPtr::disableX
struct DisableXFXData * disableX
Definition
effects.h:2529
EffectInstance::flags
s32 flags
Definition
effects.h:2602
DisableXFXData::pos
Vec3f pos
Definition
effects.h:1110
DisableXFXData::unk_14
f32 unk_14
Definition
effects.h:1111
DisableXFXData::unk_18
f32 unk_18
Definition
effects.h:1112
EffectInstance::data
EffectInstanceDataPtr data
Definition
effects.h:2605
DisableXFXData::unk_38
s32 unk_38
Definition
effects.h:1120
DisableXFXData::koDuration
s32 koDuration
Definition
effects.h:1121
DisableXFXData::unk_44
s32 unk_44
Definition
effects.h:1123
EffectInstance::shared
struct EffectSharedData * shared
Definition
effects.h:2606
DisableXFXData::unk_40
f32 unk_40
Definition
effects.h:1122
EffectInstance::numParts
s32 numParts
Definition
effects.h:2604
DisableXFXData::unk_28
s32 unk_28
Definition
effects.h:1116
DisableXFXData::type
s32 type
Definition
effects.h:1108
DisableXFXData::alpha
s32 alpha
Definition
effects.h:1115
DisableXFXData::unk_1C
f32 unk_1C
Definition
effects.h:1113
DisableXFXData::unk_04
s32 unk_04
Definition
effects.h:1109
DisableXFXData::scale
f32 scale
Definition
effects.h:1119
DisableXFXData::unk_20
f32 unk_20
Definition
effects.h:1114
DisableXFXData::unk_2C
s32 unk_2C
Definition
effects.h:1117
DisableXFXData::unk_30
f32 unk_30
Definition
effects.h:1118
DisableXFXData
Definition
effects.h:1107
EffectInstance
Definition
effects.h:2601
effects_internal.h
ASSERT
#define ASSERT(condition)
Definition
effects_internal.h:8
FX_INSTANCE_FLAG_DISMISS
@ FX_INSTANCE_FLAG_DISMISS
Definition
enums.h:3517
SOUND_INFLICT_KO
@ SOUND_INFLICT_KO
Definition
enums.h:1545
SOUND_SPACE_DEFAULT
@ SOUND_SPACE_DEFAULT
Definition
enums.h:1737
PM_CC_49
#define PM_CC_49
Definition
macros.h:482
VIRTUAL_TO_PHYSICAL
#define VIRTUAL_TO_PHYSICAL(addr)
Definition
macros.h:47
EffectBlueprint
Definition
effects.h:2649
EffectSharedData::graphics
s32 * graphics
Definition
effects.h:2666
gCameras
Camera gCameras[4]
Definition
cam_main.c:17
gMainGfxPos
Gfx * gMainGfxPos
Definition
cam_main.c:15
gMatrixListPos
u16 gMatrixListPos
Definition
main_loop.c:45
gCurrentCameraID
s32 gCurrentCameraID
Definition
cam_math.c:4
gDisplayContext
DisplayContext * gDisplayContext
Definition
cam_main.c:16
src
effects
disable_x.c
Generated by
1.10.0