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
4
extern
Gfx
D_09000200_3D6130
[];
5
extern
Gfx
D_090003A8_3D62D8
[];
6
extern
Gfx
D_090003C8_3D62F8
[];
7
extern
Gfx
D_090003E8_3D6318
[];
8
extern
Gfx
D_09000528_3D6458
[];
9
extern
Gfx
D_09000540_3D6470
[];
10
extern
Gfx
D_09000558_3D6488
[];
11
extern
Gfx
D_09000688_3D65B8
[];
12
extern
Gfx
D_09000808_3D6738
[];
13
14
Gfx*
D_E00D6E40
[] = {
15
D_090003A8_3D62D8
,
D_090003C8_3D62F8
,
D_090003E8_3D6318
,
D_09000528_3D6458
,
16
D_09000540_3D6470
,
D_09000558_3D6488
,
D_09000688_3D65B8
,
D_09000688_3D65B8
,
17
D_09000688_3D65B8
,
D_09000558_3D6488
,
D_09000808_3D6738
,
D_09000688_3D65B8
,
18
D_09000558_3D6488
19
};
20
21
u8
D_E00D6E74
[] = {
22
0x0B, 0x0B, 0x0B, 0x0B, 0x11, 0x0B, 0x0B, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x00, 0x00, 0x00
23
};
24
25
u8
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
30
void
energy_in_out_init
(
EffectInstance
* effect);
31
void
energy_in_out_update
(
EffectInstance
* effect);
32
void
energy_in_out_render
(
EffectInstance
* effect);
33
void
energy_in_out_appendGfx
(
void
* effect);
34
35
EffectInstance
*
energy_in_out_main
(s32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4, s32 arg5) {
36
EffectBlueprint
bp;
37
EffectInstance
* effect;
38
EnergyInOutFXData
* part;
39
EnergyInOutFXData
* firstPart;
40
s32 numParts =
D_E00D6E74
[arg0];
41
f32 randAngle;
42
s32 i;
43
44
bp.
init
=
energy_in_out_init
;
45
bp.
update
=
energy_in_out_update
;
46
bp.
renderWorld
=
energy_in_out_render
;
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
166
void
energy_in_out_init
(
EffectInstance
* effect) {
167
}
168
169
void
energy_in_out_update
(
EffectInstance
* effect) {
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
227
void
energy_in_out_render
(
EffectInstance
* effect) {
228
RenderTask
renderTask;
229
RenderTask
* retTask;
230
231
renderTask.
appendGfx
=
energy_in_out_appendGfx
;
232
renderTask.
appendGfxArg
= effect;
233
renderTask.
dist
= 10;
234
renderTask.
renderMode
=
RENDER_MODE_CLOUD_NO_ZCMP
;
235
236
retTask =
queue_render_task
(&renderTask);
237
}
238
239
void
func_E00D6978
(
void
) {
240
}
241
242
void
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
);
259
guMtxF2L
(sp20, &
gDisplayContext
->
matrixStack
[
gMatrixListPos
]);
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);
281
guMtxF2L
(sp20, &
gDisplayContext
->
matrixStack
[
gMatrixListPos
]);
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
}
DisplayContext::matrixStack
Mtx matrixStack[0x200]
Definition
common_structs.h:2191
Matrix4f
f32 Matrix4f[4][4]
Definition
common_structs.h:132
Vec3f::z
f32 z
Definition
common_structs.h:102
Vec3f::x
f32 x
Definition
common_structs.h:100
Vec3f::y
f32 y
Definition
common_structs.h:101
unk_14
s8 unk_14
Definition
demo_api.c:19
general_heap_malloc
#define general_heap_malloc
Definition
effect_shims.h:51
guRotateF
#define guRotateF
Definition
effect_shims.h:42
queue_render_task
#define queue_render_task
Definition
effect_shims.h:48
guMtxF2L
#define guMtxF2L
Definition
effect_shims.h:47
sin_deg
#define sin_deg
Definition
effect_shims.h:55
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
rand_int
#define rand_int
Definition
effect_shims.h:53
guPositionF
#define guPositionF
Definition
effect_shims.h:65
create_effect_instance
#define create_effect_instance
Definition
effect_shims.h:49
guScaleF
#define guScaleF
Definition
effect_shims.h:45
EnergyInOutFXData::unk_2C
s32 unk_2C
Definition
effects.h:1921
EnergyInOutFXData::unk_30
s32 unk_30
Definition
effects.h:1922
EffectInstance::flags
s32 flags
Definition
effects.h:2602
EnergyInOutFXData::unk_00
s32 unk_00
Definition
effects.h:1912
EnergyInOutFXData::unk_40
f32 unk_40
Definition
effects.h:1926
EffectData::energyInOut
struct EnergyInOutFXData * energyInOut
Definition
effects.h:2571
EnergyInOutFXData::unk_38
f32 unk_38
Definition
effects.h:1924
EnergyInOutFXData::pos
Vec3f pos
Definition
effects.h:1913
EnergyInOutFXData::unk_24
s32 unk_24
Definition
effects.h:1919
EnergyInOutFXData::unk_20
s32 unk_20
Definition
effects.h:1918
EffectInstance::numParts
s32 numParts
Definition
effects.h:2604
EnergyInOutFXData::unk_3C
f32 unk_3C
Definition
effects.h:1925
EnergyInOutFXData::unk_28
s32 unk_28
Definition
effects.h:1920
EnergyInOutFXData::scale
f32 scale
Definition
effects.h:1923
EnergyInOutFXData::unk_44
f32 unk_44
Definition
effects.h:1927
EnergyInOutFXData::unk_10
s32 unk_10
Definition
effects.h:1914
EnergyInOutFXData::unk_1C
s32 unk_1C
Definition
effects.h:1917
EffectInstance::data
EffectData data
Definition
effects.h:2605
EnergyInOutFXData::unk_14
s32 unk_14
Definition
effects.h:1915
EnergyInOutFXData::unk_18
s32 unk_18
Definition
effects.h:1916
EffectInstance
Definition
effects.h:2601
EnergyInOutFXData
Definition
effects.h:1911
effects_internal.h
ASSERT
#define ASSERT(condition)
Definition
effects_internal.h:7
energy_in_out_appendGfx
void energy_in_out_appendGfx(void *effect)
Definition
energy_in_out.c:242
D_E00D6E74
u8 D_E00D6E74[]
Definition
energy_in_out.c:21
D_E00D6E84
u8 D_E00D6E84[]
Definition
energy_in_out.c:25
D_090003E8_3D6318
Gfx D_090003E8_3D6318[]
energy_in_out_render
void energy_in_out_render(EffectInstance *effect)
Definition
energy_in_out.c:227
D_E00D6E40
Gfx * D_E00D6E40[]
Definition
energy_in_out.c:14
D_09000808_3D6738
Gfx D_09000808_3D6738[]
D_090003C8_3D62F8
Gfx D_090003C8_3D62F8[]
D_09000200_3D6130
Gfx D_09000200_3D6130[]
energy_in_out_main
EffectInstance * energy_in_out_main(s32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4, s32 arg5)
Definition
energy_in_out.c:35
D_09000558_3D6488
Gfx D_09000558_3D6488[]
D_090003A8_3D62D8
Gfx D_090003A8_3D62D8[]
D_09000528_3D6458
Gfx D_09000528_3D6458[]
D_09000540_3D6470
Gfx D_09000540_3D6470[]
D_09000688_3D65B8
Gfx D_09000688_3D65B8[]
func_E00D6978
void func_E00D6978(void)
Definition
energy_in_out.c:239
energy_in_out_init
void energy_in_out_init(EffectInstance *effect)
Definition
energy_in_out.c:166
energy_in_out_update
void energy_in_out_update(EffectInstance *effect)
Definition
energy_in_out.c:169
FX_INSTANCE_FLAG_DISMISS
@ FX_INSTANCE_FLAG_DISMISS
Definition
enums.h:3517
RENDER_MODE_CLOUD_NO_ZCMP
@ RENDER_MODE_CLOUD_NO_ZCMP
Definition
enums.h:3311
VIRTUAL_TO_PHYSICAL
#define VIRTUAL_TO_PHYSICAL(addr)
Definition
macros.h:47
EffectBlueprint
Definition
effects.h:2649
EffectBlueprint::renderUI
void(* renderUI)(EffectInstance *effectInst)
Definition
effects.h:2655
EffectBlueprint::effectID
s32 effectID
Definition
effects.h:2651
EffectBlueprint::init
void(* init)(EffectInstance *effectInst)
Definition
effects.h:2652
EffectBlueprint::update
void(* update)(EffectInstance *effectInst)
Definition
effects.h:2653
EffectBlueprint::unk_00
s32 unk_00
Definition
effects.h:2650
EffectBlueprint::renderWorld
void(* renderWorld)(EffectInstance *effectInst)
Definition
effects.h:2654
RenderTask
Definition
common_structs.h:1507
RenderTask::renderMode
s32 renderMode
Definition
common_structs.h:1508
RenderTask::appendGfxArg
void * appendGfxArg
Definition
common_structs.h:1510
RenderTask::appendGfx
void(* appendGfx)(void *)
Definition
common_structs.h:1511
RenderTask::dist
s32 dist
Definition
common_structs.h:1509
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
energy_in_out.c
Generated by
1.10.0