Paper Mario DX
Paper Mario (N64) modding
Loading...
Searching...
No Matches
butterflies.c
Go to the documentation of this file.
1
#include "common.h"
2
#include "
effects_internal.h
"
3
4
extern
Vtx
D_09002D40_3ADD70
[][6];
// TODO confirm this type is correct
5
extern
Gfx
D_09003880_3AE8B0
[];
6
extern
Gfx
D_090038F8_3AE928
[];
7
extern
Gfx
D_09003968_3AE998
[];
8
extern
Gfx
D_090039D8_3AEA08
[];
9
extern
Gfx
D_09003A48_3AEA78
[];
10
extern
Gfx
D_09003AB8_3AEAE8
[];
11
extern
Gfx
D_09003B28_3AEB58
[];
12
extern
Gfx
D_09003B98_3AEBC8
[];
13
extern
Gfx
D_09003C08_3AEC38
[];
14
extern
Gfx
D_09003C78_3AECA8
[];
15
extern
Gfx
D_09003CE8_3AED18
[];
16
extern
Gfx
D_09003D58_3AED88
[];
17
extern
Gfx
D_09003DC8_3AEDF8
[];
18
19
Gfx
*
D_E00AA6C0
[11] = {
20
D_090038F8_3AE928
,
D_09003968_3AE998
,
D_090039D8_3AEA08
,
D_09003A48_3AEA78
,
D_09003AB8_3AEAE8
,
D_09003B28_3AEB58
,
D_09003B98_3AEBC8
,
D_09003C08_3AEC38
,
D_09003C78_3AECA8
,
D_09003CE8_3AED18
,
D_09003D58_3AED88
21
};
22
23
s8
D_E00AA6EC
[] = {
24
-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -17, -15, -13, -11, -9, -7, -5, -3, -1, 0, 0, 0, 0, 0, 0, 0, 0
25
};
26
27
void
butterflies_init
(
EffectInstance
* effect);
28
void
butterflies_update
(
EffectInstance
* effect);
29
void
butterflies_render
(
EffectInstance
* effect);
30
void
butterflies_appendGfx
(
void
* effect);
31
32
EffectInstance
*
butterflies_main
(s32
arg0
,
f32
arg1
,
f32
arg2
,
f32
arg3
) {
33
EffectBlueprint
bp
;
34
EffectInstance
* effect;
35
ButterfliesFXData
*
part
;
36
s32 numParts = 1;
37
s32 i;
38
39
bp
.
unk_00
= 0;
40
bp
.init =
butterflies_init
;
41
bp
.update =
butterflies_update
;
42
bp
.renderScene =
butterflies_render
;
43
bp
.renderUI =
NULL
;
44
bp
.effectID =
EFFECT_BUTTERFLIES
;
45
46
effect =
create_effect_instance
(&
bp
);
47
effect->
numParts
= numParts;
48
part
= effect->
data
.
butterflies
=
general_heap_malloc
(numParts *
sizeof
(*
part
));
49
ASSERT
(effect->
data
.
butterflies
!=
NULL
);
50
51
part
->unk_04 = 1000;
52
part
->unk_00 =
arg0
;
53
part
->unk_24 = 255;
54
part
->unk_0C =
arg1
;
55
part
->unk_18 =
arg1
;
56
part
->unk_10 =
arg2
;
57
part
->unk_1C =
arg2
;
58
part
->unk_14 =
arg3
;
59
part
->unk_20 =
arg3
;
60
part
->unk_08 = 0;
61
part
->unk_2C = 0;
62
part
->unk_30 = 0;
63
part
->unk_34 = 50.0f;
64
part
->unk_38 = 30.0f;
65
return
effect;
66
}
67
68
void
butterflies_init
(
EffectInstance
* effect) {
69
}
70
71
void
butterflies_update
(
EffectInstance
* effect) {
72
ButterfliesFXData
*
temp_s0
;
73
f32
temp_f20
;
74
f32
temp_f20_2
;
75
f32
temp_f22
;
76
f32
temp_f24
;
77
f32
temp_f4
;
78
f32
temp_f6
;
79
f32
temp_f8
;
80
f32
var_f12
;
81
f32
var_f20
;
82
f32
var_f22
;
83
f32
var_f24
;
84
85
temp_s0
= effect->
data
.
butterflies
;
86
if
(effect->
flags
&
FX_INSTANCE_FLAG_DISMISS
) {
87
effect->
flags
&=
~FX_INSTANCE_FLAG_DISMISS
;
88
temp_s0
->unk_04 = 900;
89
}
90
91
if
(
temp_s0
->unk_04 < 1000) {
92
temp_s0
->unk_04--;
93
}
94
temp_s0
->unk_08++;
95
if
(
temp_s0
->unk_04 < 0) {
96
remove_effect
(effect);
97
return
;
98
}
99
if
(
temp_s0
->unk_04 < 0x10) {
100
temp_s0
->unk_24 =
temp_s0
->unk_04 * 0x10;
101
}
102
103
temp_s0
->unk_30--;
104
if
(
temp_s0
->unk_30 <= 0) {
105
s32
t
;
106
107
temp_f20
=
rand_int
(359);
108
temp_f24
=
temp_s0
->unk_18 + (
temp_s0
->unk_34 *
sin_deg
(
temp_f20
));
109
temp_f22
=
temp_s0
->unk_1C +
rand_int
(
temp_s0
->unk_38);
110
temp_f20_2
=
temp_s0
->unk_20 + (
temp_s0
->unk_34 *
cos_deg
(
temp_f20
));
111
t
=
rand_int
(100) + 10;
112
temp_f4
=
temp_s0
->unk_0C;
113
temp_f6
=
temp_s0
->unk_10;
114
temp_f8
=
temp_s0
->unk_14;
115
var_f24
=
temp_f24
-
temp_f4
;
116
var_f22
=
temp_f22
-
temp_f6
;
117
var_f20
=
temp_f20_2
-
temp_f8
;
118
temp_s0
->unk_30 =
t
;
119
if
(
var_f24
== 0.0f &&
var_f22
== 0.0f &&
var_f20
== 0.0f) {
120
var_f24
=
temp_s0
->unk_18 -
temp_f4
;
121
var_f22
=
temp_s0
->unk_1C -
temp_f6
;
122
var_f20
=
temp_s0
->unk_20 -
temp_f8
;
123
if
(
var_f24
== 0.0f &&
var_f22
== 0.0f &&
var_f20
== 0.0f) {
124
var_f24
= 1.0f;
125
var_f20
= 0.0f;
126
var_f22
= 0.0f;
127
}
128
}
129
var_f12
=
SQ
(
var_f24
) +
SQ
(
var_f22
) +
SQ
(
var_f20
);
130
if
(
var_f12
!= 0.0f) {
131
var_f12
= 1.0f /
sqrtf
(
var_f12
);
132
}
133
var_f24
*=
var_f12
;
134
var_f22
*=
var_f12
;
135
var_f20
*=
var_f12
;
136
temp_s0
->unk_3C =
var_f24
;
137
temp_s0
->unk_40 =
var_f22
;
138
temp_s0
->unk_44 =
var_f20
;
139
temp_s0
->unk_28 =
atan2
(0.0f, 0.0f, -
temp_s0
->unk_3C,
temp_s0
->unk_44);
140
}
141
temp_s0
->unk_2C += 3;
142
if
(
temp_s0
->unk_2C >= 30) {
143
temp_s0
->unk_2C -= 30;
144
}
145
temp_s0
->unk_0C +=
temp_s0
->unk_3C;
146
temp_s0
->unk_10 +=
temp_s0
->unk_40;
147
temp_s0
->unk_14 +=
temp_s0
->unk_44;
148
}
149
150
void
butterflies_render
(
EffectInstance
* effect) {
151
RenderTask
renderTask
;
152
RenderTask
*
retTask
;
153
154
renderTask
.
appendGfx
=
butterflies_appendGfx
;
155
renderTask
.appendGfxArg = effect;
156
renderTask
.dist = 0;
157
renderTask
.renderMode =
RENDER_MODE_CLOUD_NO_ZCMP
;
158
159
retTask
=
queue_render_task
(&
renderTask
);
160
retTask
->renderMode |=
RENDER_TASK_FLAG_REFLECT_FLOOR
;
161
}
162
163
void
butterflies_appendGfx
(
void
* effect) {
164
EffectInstance
*
effectTemp
= effect;
165
ButterfliesFXData
* data =
effectTemp
->data.butterflies;
166
Matrix4f
sp18
;
167
Matrix4f
sp58
;
168
169
s32 primColor = data->
unk_24
;
170
s32 type = data->
unk_00
;
171
172
gDPPipeSync
(
gMainGfxPos
++);
173
gSPSegment
(
gMainGfxPos
++, 0x09,
VIRTUAL_TO_PHYSICAL
(
effectTemp
->shared->graphics));
174
175
guTranslateF
(
sp18
, data->
unk_0C
, data->
unk_10
+
D_E00AA6EC
[data->
unk_2C
] * 0.3f, data->
unk_14
);
176
guRotateF
(
sp58
, data->
unk_28
, 0.0f, 1.0f, 0.0f);
177
guMtxCatF
(
sp58
,
sp18
,
sp18
);
178
guScaleF
(
sp58
, 0.02f, 0.02f, 0.02f);
179
guMtxCatF
(
sp58
,
sp18
,
sp18
);
180
guMtxF2L
(
sp18
, &
gDisplayContext
->
matrixStack
[
gMatrixListPos
]);
181
182
gSPMatrix
(
gMainGfxPos
++, &
gDisplayContext
->
matrixStack
[
gMatrixListPos
++],
G_MTX_PUSH
|
G_MTX_LOAD
|
G_MTX_MODELVIEW
);
183
gDPSetPrimColor
(
gMainGfxPos
++, 0, 0, primColor, primColor, primColor, 255);
184
gSPDisplayList
(
gMainGfxPos
++,
D_09003880_3AE8B0
);
185
gSPDisplayList
(
gMainGfxPos
++,
D_E00AA6C0
[type]);
186
gSPVertex
(
gMainGfxPos
++, &
D_09002D40_3ADD70
[data->
unk_2C
], 6, 0);
187
gSPDisplayList
(
gMainGfxPos
++,
D_09003DC8_3AEDF8
);
188
gSPPopMatrix
(
gMainGfxPos
++,
G_MTX_MODELVIEW
);
189
gDPPipeSync
(
gMainGfxPos
++);
190
}
PopupMenu_SelectedIndex
BSS s32 PopupMenu_SelectedIndex
Definition
8a860_len_3f30.c:84
D_09003D58_3AED88
Gfx D_09003D58_3AED88[]
D_090039D8_3AEA08
Gfx D_090039D8_3AEA08[]
D_09003B98_3AEBC8
Gfx D_09003B98_3AEBC8[]
D_09003C78_3AECA8
Gfx D_09003C78_3AECA8[]
D_09003880_3AE8B0
Gfx D_09003880_3AE8B0[]
D_09003AB8_3AEAE8
Gfx D_09003AB8_3AEAE8[]
D_090038F8_3AE928
Gfx D_090038F8_3AE928[]
D_09003B28_3AEB58
Gfx D_09003B28_3AEB58[]
D_09003CE8_3AED18
Gfx D_09003CE8_3AED18[]
D_09003A48_3AEA78
Gfx D_09003A48_3AEA78[]
butterflies_render
void butterflies_render(EffectInstance *effect)
Definition
butterflies.c:150
D_09003C08_3AEC38
Gfx D_09003C08_3AEC38[]
D_E00AA6EC
s8 D_E00AA6EC[]
Definition
butterflies.c:23
D_09003968_3AE998
Gfx D_09003968_3AE998[]
butterflies_appendGfx
void butterflies_appendGfx(void *effect)
Definition
butterflies.c:163
D_09003DC8_3AEDF8
Gfx D_09003DC8_3AEDF8[]
D_09002D40_3ADD70
Vtx D_09002D40_3ADD70[][6]
D_E00AA6C0
Gfx * D_E00AA6C0[11]
Definition
butterflies.c:19
butterflies_update
void butterflies_update(EffectInstance *effect)
Definition
butterflies.c:71
butterflies_init
void butterflies_init(EffectInstance *effect)
Definition
butterflies.c:68
butterflies_main
EffectInstance * butterflies_main(s32 arg0, f32 arg1, f32 arg2, f32 arg3)
Definition
butterflies.c:32
DisplayContext::matrixStack
Mtx matrixStack[0x200]
Definition
common_structs.h:2192
Matrix4f
f32 Matrix4f[4][4]
Definition
common_structs.h:133
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
sqrtf
#define sqrtf
Definition
effect_shims.h:60
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
cos_deg
#define cos_deg
Definition
effect_shims.h:56
atan2
#define atan2
Definition
effect_shims.h:57
create_effect_instance
#define create_effect_instance
Definition
effect_shims.h:49
guScaleF
#define guScaleF
Definition
effect_shims.h:45
ButterfliesFXData::unk_0C
f32 unk_0C
Definition
effects.h:1439
EffectInstance::flags
s32 flags
Definition
effects.h:2602
ButterfliesFXData::unk_28
f32 unk_28
Definition
effects.h:1446
EffectInstanceDataPtr::butterflies
struct ButterfliesFXData * butterflies
Definition
effects.h:2549
ButterfliesFXData::unk_2C
s32 unk_2C
Definition
effects.h:1447
EffectInstance::data
EffectInstanceDataPtr data
Definition
effects.h:2605
ButterfliesFXData::unk_10
f32 unk_10
Definition
effects.h:1440
ButterfliesFXData::unk_14
f32 unk_14
Definition
effects.h:1441
ButterfliesFXData::unk_24
s32 unk_24
Definition
effects.h:1445
ButterfliesFXData::unk_00
s32 unk_00
Definition
effects.h:1436
EffectInstance::numParts
s32 numParts
Definition
effects.h:2604
ButterfliesFXData
Definition
effects.h:1435
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
RENDER_TASK_FLAG_REFLECT_FLOOR
@ RENDER_TASK_FLAG_REFLECT_FLOOR
Definition
enums.h:3318
RENDER_MODE_CLOUD_NO_ZCMP
@ RENDER_MODE_CLOUD_NO_ZCMP
Definition
enums.h:3311
SQ
#define SQ(x)
Definition
macros.h:170
VIRTUAL_TO_PHYSICAL
#define VIRTUAL_TO_PHYSICAL(addr)
Definition
macros.h:47
EffectBlueprint
Definition
effects.h:2649
RenderTask
Definition
common_structs.h:1508
RenderTask::appendGfx
void(* appendGfx)(void *)
Definition
common_structs.h:1512
gMainGfxPos
Gfx * gMainGfxPos
Definition
cam_main.c:15
gMatrixListPos
u16 gMatrixListPos
Definition
main_loop.c:45
gDisplayContext
DisplayContext * gDisplayContext
Definition
cam_main.c:16
src
effects
butterflies.c
Generated by
1.10.0