Paper Mario DX
Paper Mario (N64) modding
Loading...
Searching...
No Matches
gather_energy_pink.c
Go to the documentation of this file.
1
#include "common.h"
2
#include "
effects_internal.h
"
3
4
extern
Gfx
D_09000DA0_33C970
[];
5
extern
Gfx
D_09000E28_33C9F8
[];
6
extern
Gfx
D_090010B0_33CC80
[];
7
extern
Gfx
D_09001138_33CD08
[];
8
9
Gfx*
D_E00269F0
[] = {
D_090010B0_33CC80
,
D_09000DA0_33C970
};
10
Gfx*
D_E00269F8
[] = {
D_09001138_33CD08
,
D_09000E28_33C9F8
};
11
12
u8
D_E0026A00
[] = {
13
0xFF, 0xC5, 0x9C, 0xFF, 0x9C, 0xFF, 0xFF, 0x73, 0xD6, 0xFF, 0x9C, 0xFF, 0xFF, 0xC5, 0x7B, 0xFF,
14
0xB4, 0xFF, 0xDE, 0x73, 0xFF, 0xFF, 0x94, 0x9C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
15
};
16
17
void
gather_energy_pink_init
(
EffectInstance
* effect);
18
void
gather_energy_pink_update
(
EffectInstance
* effect);
19
void
gather_energy_pink_render
(
EffectInstance
* effect);
20
void
gather_energy_pink_appendGfx
(
void
* effect);
21
22
void
gather_energy_pink_main
(s32 type, f32 posX, f32 posY, f32 posZ, f32 scale, s32 duration) {
23
EffectBlueprint
bp;
24
EffectInstance
* effect;
25
GatherEnergyPinkFXData
* data;
26
s32 numParts = 1;
27
28
bp.
unk_00
= 0;
29
bp.
init
=
gather_energy_pink_init
;
30
bp.
update
=
gather_energy_pink_update
;
31
bp.
renderWorld
=
gather_energy_pink_render
;
32
bp.
renderUI
= NULL;
33
bp.
effectID
= EFFECT_GATHER_ENERGY_PINK;
34
35
effect =
create_effect_instance
(&bp);
36
effect->
numParts
= numParts;
37
data = effect->
data
.
gatherEnergyPink
=
general_heap_malloc
(
sizeof
(*data));
38
ASSERT
(data != NULL);
39
40
data->
unk_00
= type;
41
data->
unk_28
= duration;
42
data->
unk_2C
= 0;
43
data->
unk_24
= 0;
44
data->
posB
.
x
= posX;
45
data->
posB
.
y
= posY;
46
data->
posB
.
z
= posZ;
47
data->
unk_44
= 0;
48
data->
unk_40
= 0;
49
data->
unk_4C
= 0;
50
data->
unk_48
= 0;
51
data->
unk_34
= 0;
52
data->
unk_30
= 0;
53
data->
unk_3C
= 0;
54
data->
unk_38
= 0;
55
data->
posA
.
x
= posX;
56
data->
posA
.
y
= posY;
57
data->
posA
.
z
= posZ;
58
59
data->
unk_1C
= 10.0f;
60
61
data->
unk_58
=
effect_rand_int
(360);
62
data->
unk_5C
= 4.0f;
63
64
data->
unk_50
= 0;
65
data->
unk_54
= 0;
66
67
if
(type == 1) {
68
data->
unk_3C
= 96;
69
data->
unk_20
= scale;
70
}
else
{
71
data->
unk_44
= -2;
72
data->
unk_4C
= -4;
73
data->
unk_20
= scale * 0.2;
74
}
75
return
;
76
}
77
78
void
gather_energy_pink_init
(
EffectInstance
* effect) {
79
}
80
81
void
gather_energy_pink_update
(
EffectInstance
* effect) {
82
GatherEnergyPinkFXData
* part = effect->
data
.
gatherEnergyPink
;
83
s32 unk_28;
84
s32 unk_2C;
85
f32 sp28;
86
f32 sp2C;
87
f32 sp30;
88
f32 sp34;
89
s32 i;
90
91
part->
unk_28
--;
92
part->
unk_2C
++;
93
94
if
(part->
unk_28
< 0) {
95
remove_effect
(effect);
96
return
;
97
}
98
99
unk_28 = part->
unk_28
;
100
unk_2C = part->
unk_2C
;
101
102
if
(unk_2C < 11) {
103
part->
unk_24
= (unk_2C * 255) / 10;
104
}
105
106
if
(unk_28 < 6) {
107
part->
unk_24
= (unk_28 * 255) / 6;
108
}
109
110
if
(unk_28 < 10 && part->unk_00 == 0) {
111
part->
unk_1C
*= 0.7;
112
}
113
114
if
(part->
unk_00
== 1) {
115
part->
unk_1C
+= (part->
unk_20
+
sin_deg
(unk_28 * 10) * 0.1 * part->
unk_20
- part->
unk_1C
) * 0.4;
116
}
else
{
117
part->
unk_1C
+= (part->
unk_20
+
sin_deg
(unk_28 * 10) * 0.1 * part->
unk_20
- part->
unk_1C
) * 0.3;
118
}
119
120
transform_point
(&
gCameras
[
gCurrentCameraID
].mtxPerspective[0], part->
posA
.
x
, part->
posA
.
y
, part->
posA
.
z
, 1.0f, &sp28, &sp2C, &sp30, &sp34);
121
122
sp34 = 1.0f / sp34;
123
sp28 *= sp34;
124
sp2C *= sp34;
125
sp30 *= sp34;
126
127
part->
posB
.
x
= sp28;
128
part->
posB
.
y
= sp2C;
129
part->
posB
.
z
= 0;
130
131
for
(i = 0; i < effect->
numParts
; i++, part++) {
132
part->
unk_30
+= part->
unk_34
;
133
part->
unk_38
+= part->
unk_3C
;
134
part->
unk_40
+= part->
unk_44
;
135
part->
unk_48
+= part->
unk_4C
;
136
part->
unk_58
+= part->
unk_5C
;
137
part->
unk_50
+= part->
unk_54
;
138
if
(part->
unk_40
< 0) {
139
part->
unk_40
+= 256;
140
}
141
if
(part->
unk_48
< 0) {
142
part->
unk_48
+= 256;
143
}
144
}
145
}
146
147
void
gather_energy_pink_render
(
EffectInstance
* effect) {
148
RenderTask
renderTask;
149
RenderTask
* retTask;
150
151
renderTask.
appendGfx
=
gather_energy_pink_appendGfx
;
152
renderTask.
appendGfxArg
= effect;
153
renderTask.
dist
= 0;
154
renderTask.
renderMode
=
RENDER_MODE_CLOUD_NO_ZCMP
;
155
156
retTask =
queue_render_task
(&renderTask);
157
retTask->
renderMode
|=
RENDER_TASK_FLAG_REFLECT_FLOOR
;
158
}
159
160
void
gather_energy_pink_appendGfx
(
void
* effect) {
161
GatherEnergyPinkFXData
* part = ((
EffectInstance
*)effect)->data.gatherEnergyPink;
162
s32 unk_00 = part->
unk_00
;
163
Gfx* dlist =
D_E00269F8
[unk_00];
164
Gfx* dlist2 =
D_E00269F0
[unk_00];
165
Camera
* camera = &
gCameras
[
gCurrentCameraID
];
166
Matrix4f
sp20;
167
Matrix4f
sp60;
168
Matrix4f
unused;
169
u16 perspNorm;
170
s32 alpha;
171
s32 idx;
172
s32 i;
173
174
gDPPipeSync(
gMainGfxPos
++);
175
gSPSegment(
gMainGfxPos
++, 0x09,
VIRTUAL_TO_PHYSICAL
(((
EffectInstance
*)effect)->graphics->data));
176
gSPDisplayList(
gMainGfxPos
++, dlist);
177
178
guTranslateF
(sp20, part->
posB
.
x
, part->
posB
.
y
, part->
posB
.
z
);
179
guScaleF
(sp60, part->
unk_1C
, part->
unk_1C
, 1.0f);
180
guMtxCatF
(sp60, sp20, sp20);
181
guPerspectiveF
(sp60, &perspNorm, unk_00 == 1 ? 130.0f : 30.0f, (f32) camera->
viewportW
/ camera->
viewportH
, 4.0f, 16384.0f, 1.0f);
182
guMtxCatF
(sp60, sp20, sp20);
183
guMtxF2L
(sp20, &
gDisplayContext
->
matrixStack
[
gMatrixListPos
]);
184
185
gSPMatrix(
gMainGfxPos
++, &
gDisplayContext
->
matrixStack
[
gMatrixListPos
++], G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION);
186
187
switch
(unk_00) {
188
case
1:
189
guTranslateF
(sp20, 0.0f, 0.0f, -70.0f);
190
break
;
191
case
0:
192
guTranslateF
(sp20, 0.0f, 0.0f, -80.0f);
193
break
;
194
}
195
196
guMtxF2L
(sp20, &
gDisplayContext
->
matrixStack
[
gMatrixListPos
]);
197
198
gSPMatrix(
gMainGfxPos
++, &
gDisplayContext
->
matrixStack
[
gMatrixListPos
++], G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
199
200
idx = part->
unk_2C
* 3;
201
alpha = part->
unk_24
;
202
203
for
(i = 0; i < ((
EffectInstance
*)effect)->numParts; i++, part++) {
204
s32 tempX;
205
s32 tempY;
206
s32 tempX2;
207
s32 tempY2;
208
209
idx += 30;
210
idx %= 24;
211
212
gDPSetEnvColor(
gMainGfxPos
++, 0, 0, 0, alpha / 2);
213
gDPSetPrimColor(
gMainGfxPos
++, 0, 0,
D_E0026A00
[idx], 0,
D_E0026A00
[idx + 2], alpha);
214
215
tempX = part->
unk_30
;
216
tempY = part->
unk_40
;
217
tempX2 = part->
unk_38
;
218
tempY2 = part->
unk_48
;
219
220
gDPSetTileSize(
gMainGfxPos
++, G_TX_RENDERTILE, tempX, tempY, tempX + 256, tempY + 256);
221
gDPSetTileSize(
gMainGfxPos
++, 1, tempX2, tempY2, tempX2 + 256, tempY2 + 256);
222
gSPDisplayList(
gMainGfxPos
++, dlist2);
223
}
224
225
gSPPopMatrix(
gMainGfxPos
++, G_MTX_MODELVIEW);
226
gSPMatrix(
gMainGfxPos
++, &
gDisplayContext
->
camPerspMatrix
[
gCurrentCameraID
], G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION);
227
gDPPipeSync(
gMainGfxPos
++);
228
}
DisplayContext::camPerspMatrix
Mtx camPerspMatrix[8]
Definition
common_structs.h:2184
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
general_heap_malloc
#define general_heap_malloc
Definition
effect_shims.h:51
transform_point
#define transform_point
Definition
effect_shims.h:64
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
guPerspectiveF
#define guPerspectiveF
Definition
effect_shims.h:63
create_effect_instance
#define create_effect_instance
Definition
effect_shims.h:49
guScaleF
#define guScaleF
Definition
effect_shims.h:45
GatherEnergyPinkFXData::posA
Vec3f posA
Definition
effects.h:258
GatherEnergyPinkFXData::unk_30
s32 unk_30
Definition
effects.h:265
GatherEnergyPinkFXData::unk_38
s32 unk_38
Definition
effects.h:267
GatherEnergyPinkFXData::unk_00
s32 unk_00
Definition
effects.h:257
GatherEnergyPinkFXData::unk_48
s32 unk_48
Definition
effects.h:271
GatherEnergyPinkFXData::unk_44
s32 unk_44
Definition
effects.h:270
GatherEnergyPinkFXData::unk_50
f32 unk_50
Definition
effects.h:273
EffectData::gatherEnergyPink
struct GatherEnergyPinkFXData * gatherEnergyPink
Definition
effects.h:2483
GatherEnergyPinkFXData::unk_40
s32 unk_40
Definition
effects.h:269
GatherEnergyPinkFXData::unk_4C
s32 unk_4C
Definition
effects.h:272
GatherEnergyPinkFXData::posB
Vec3f posB
Definition
effects.h:259
GatherEnergyPinkFXData::unk_1C
f32 unk_1C
Definition
effects.h:260
GatherEnergyPinkFXData::unk_3C
s32 unk_3C
Definition
effects.h:268
GatherEnergyPinkFXData::unk_20
f32 unk_20
Definition
effects.h:261
GatherEnergyPinkFXData::unk_58
f32 unk_58
Definition
effects.h:275
GatherEnergyPinkFXData::unk_34
s32 unk_34
Definition
effects.h:266
GatherEnergyPinkFXData::unk_5C
f32 unk_5C
Definition
effects.h:276
GatherEnergyPinkFXData::unk_54
f32 unk_54
Definition
effects.h:274
EffectInstance::numParts
s32 numParts
Definition
effects.h:2604
GatherEnergyPinkFXData::unk_28
s32 unk_28
Definition
effects.h:263
GatherEnergyPinkFXData::unk_2C
s32 unk_2C
Definition
effects.h:264
GatherEnergyPinkFXData::unk_24
s32 unk_24
Definition
effects.h:262
EffectInstance::data
EffectData data
Definition
effects.h:2605
EffectInstance
Definition
effects.h:2601
GatherEnergyPinkFXData
Definition
effects.h:256
effects_internal.h
ASSERT
#define ASSERT(condition)
Definition
effects_internal.h:7
effect_rand_int
s32 effect_rand_int(s32)
Definition
effect_utils.c:38
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
D_E00269F8
Gfx * D_E00269F8[]
Definition
gather_energy_pink.c:10
D_090010B0_33CC80
Gfx D_090010B0_33CC80[]
D_09000E28_33C9F8
Gfx D_09000E28_33C9F8[]
gather_energy_pink_update
void gather_energy_pink_update(EffectInstance *effect)
Definition
gather_energy_pink.c:81
D_E00269F0
Gfx * D_E00269F0[]
Definition
gather_energy_pink.c:9
D_E0026A00
u8 D_E0026A00[]
Definition
gather_energy_pink.c:12
D_09001138_33CD08
Gfx D_09001138_33CD08[]
gather_energy_pink_appendGfx
void gather_energy_pink_appendGfx(void *effect)
Definition
gather_energy_pink.c:160
gather_energy_pink_render
void gather_energy_pink_render(EffectInstance *effect)
Definition
gather_energy_pink.c:147
gather_energy_pink_main
void gather_energy_pink_main(s32 type, f32 posX, f32 posY, f32 posZ, f32 scale, s32 duration)
Definition
gather_energy_pink.c:22
gather_energy_pink_init
void gather_energy_pink_init(EffectInstance *effect)
Definition
gather_energy_pink.c:78
D_09000DA0_33C970
Gfx D_09000DA0_33C970[]
VIRTUAL_TO_PHYSICAL
#define VIRTUAL_TO_PHYSICAL(addr)
Definition
macros.h:47
Camera
Definition
common_structs.h:748
Camera::viewportW
s16 viewportW
Definition
common_structs.h:754
Camera::viewportH
s16 viewportH
Definition
common_structs.h:755
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
gather_energy_pink.c
Generated by
1.10.0