Paper Mario DX
Paper Mario (N64) modding
Loading...
Searching...
No Matches
shattering_stones.c
Go to the documentation of this file.
1
#include "common.h"
2
#include "
effects_internal.h
"
3
4
extern
Gfx
D_09000C00_341480
[];
5
extern
Gfx
D_09001068_3418E8
[];
6
extern
Gfx
D_09001080_341900
[];
7
extern
Gfx
D_09001098_341918
[];
8
extern
Gfx
D_090010B8_341938
[];
9
extern
Gfx
D_090010D0_341950
[];
10
extern
Gfx
D_090010E8_341968
[];
11
extern
Gfx
D_09001108_341988
[];
12
extern
Gfx
D_09001120_3419A0
[];
13
extern
Gfx
D_09001138_3419B8
[];
14
15
Gfx*
D_E002C940
[] = {
16
D_09001138_3419B8
,
D_09001120_3419A0
,
D_09001108_341988
,
17
D_090010E8_341968
,
D_090010D0_341950
,
D_090010B8_341938
,
18
D_09001098_341918
,
D_09001080_341900
,
D_09001068_3418E8
19
};
20
21
f32
D_E002C964
[] = {
22
-1.0f, -0.5f, 0.5f, 1.0f, -1.0f, -0.5f, 0.5f, 1.0f
23
};
24
25
f32
D_E002C984
[][2] = {
26
{ -5.0f, -4.0f },
27
{ -3.0f, -2.0f },
28
{ 2.0f, -3.0f },
29
{ 5.0f, -4.0f },
30
{ -4.0f, 2.0f },
31
{ -1.0f, 4.0f },
32
{ 3.0f, 2.0f },
33
{ 5.0f, 4.0f }
34
};
35
36
void
shattering_stones_init
(
EffectInstance
* effect);
37
void
shattering_stones_update
(
EffectInstance
* effect);
38
void
shattering_stones_render
(
EffectInstance
* effect);
39
void
shattering_stones_appendGfx
(
void
* effect);
40
41
void
shattering_stones_main
(s32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4) {
42
EffectBlueprint
bp;
43
EffectInstance
* effect;
44
ShatteringStonesFXData
* part;
45
s32 numParts = 9;
46
s32 i;
47
48
bp.
init
=
shattering_stones_init
;
49
bp.
update
=
shattering_stones_update
;
50
bp.
renderWorld
=
shattering_stones_render
;
51
bp.
unk_00
= 0;
52
bp.
renderUI
= NULL;
53
bp.
effectID
= EFFECT_SHATTERING_STONES;
54
55
effect =
create_effect_instance
(&bp);
56
effect->
numParts
= numParts;
57
part = effect->
data
.
shatteringStones
=
general_heap_malloc
(numParts *
sizeof
(*part));
58
ASSERT
(effect->
data
.
shatteringStones
!= NULL);
59
60
part->
unk_24
= 0;
61
part->
unk_00
= arg1;
62
part->
unk_04
= arg2;
63
part->
unk_0C
= arg4;
64
part->
unk_08
= arg3;
65
part->
unk_2C
= 0;
66
part->
unk_30
= 0;
67
part->
unk_14
= -2.0f;
68
part->
unk_34
=
rand_int
(60) - 30;
69
part->
unk_28
= 255;
70
part->
unk_38
=
rand_int
(60) - 30;
71
part->
unk_3C
= part->
unk_38
* 0.25;
72
part->
unk_20
= 20;
73
74
part++;
75
for
(i = 1; i < numParts; i++, part++) {
76
part->
unk_18
=
D_E002C984
[i - 1][0];
77
part->
unk_1C
=
D_E002C984
[i - 1][1];
78
part->
unk_00
= 0;
79
part->
unk_04
= 0;
80
part->
unk_08
= 0;
81
part->
unk_10
=
D_E002C964
[i - 1] * 2.0f;
82
part->
unk_14
= (f32)
rand_int
(10) * 0.1 * 2.0 + 1.0;
83
part->
unk_2C
= 0;
84
part->
unk_34
= 0;
85
}
86
}
87
88
void
shattering_stones_init
(
EffectInstance
* effect) {
89
}
90
91
void
shattering_stones_update
(
EffectInstance
* effect) {
92
ShatteringStonesFXData
* part = effect->
data
.
shatteringStones
;
93
s32 i;
94
95
if
(part->
unk_24
== 0) {
96
part->
unk_14
+= -0.1;
97
part->
unk_04
+= part->
unk_14
;
98
part->
unk_2C
+= part->
unk_38
;
99
part->
unk_30
+= part->
unk_3C
;
100
if
(part->
unk_04
<= part->
unk_0C
) {
101
part->
unk_24
= 1;
102
}
103
}
104
105
if
(part->
unk_24
== 1) {
106
part->
unk_20
--;
107
if
(part->
unk_20
< 0) {
108
remove_effect
(effect);
109
return
;
110
}
111
112
if
(part->
unk_20
< 10) {
113
part->
unk_28
*= 0.8;
114
}
115
116
part++;
117
for
(i = 1; i < effect->
numParts
; i++, part++) {
118
part->
unk_14
+= -0.2;
119
part->
unk_10
*= 0.9;
120
part->
unk_00
+= part->
unk_10
;
121
part->
unk_04
+= part->
unk_14
;
122
part->
unk_2C
+= 10.0f;
123
part->
unk_34
+= 20.0f;
124
}
125
}
126
}
127
128
void
shattering_stones_render
(
EffectInstance
* effect) {
129
RenderTask
renderTask;
130
RenderTask
* retTask;
131
132
renderTask.
appendGfx
=
shattering_stones_appendGfx
;
133
renderTask.
appendGfxArg
= effect;
134
renderTask.
dist
= 0;
135
renderTask.
renderMode
=
RENDER_MODE_CLOUD_NO_ZCMP
;
136
137
retTask =
queue_render_task
(&renderTask);
138
retTask->
renderMode
|=
RENDER_TASK_FLAG_REFLECT_FLOOR
;
139
}
140
141
void
shattering_stones_appendGfx
(
void
* effect) {
142
ShatteringStonesFXData
* part = ((
EffectInstance
*)effect)->data.shatteringStones;
143
Matrix4f
sp20;
144
Matrix4f
sp60;
145
Matrix4f
spA0;
146
Matrix4f
spE0;
147
s32 i;
148
149
gSPSegment(
gMainGfxPos
++, 0x09,
VIRTUAL_TO_PHYSICAL
(((
EffectInstance
*)effect)->graphics->data));
150
gSPDisplayList(
gMainGfxPos
++,
D_09000C00_341480
);
151
152
if
(part->
unk_24
== 0) {
153
guTranslateF
(sp20, part->
unk_00
, part->
unk_04
, part->
unk_08
);
154
guScaleF
(sp60, 1.5f, 1.5f, 1.5f);
155
guMtxCatF
(sp60, sp20, spA0);
156
guRotateF
(sp60, -
gCameras
[
gCurrentCameraID
].curYaw, 0.0f, 1.0f, 0.0f);
157
guMtxCatF
(sp60, spA0, spA0);
158
guRotateF
(sp60, part->
unk_34
, 0.0f, 0.0f, 1.0f);
159
guMtxCatF
(sp60, spA0, spA0);
160
guRotateF
(sp60, part->
unk_2C
, 1.0f, 0.0f, 0.0f);
161
guMtxCatF
(sp60, spA0, spA0);
162
guRotateF
(sp60, part->
unk_30
, 0.0f, 1.0f, 0.0f);
163
guMtxCatF
(sp60, spA0, spA0);
164
guMtxF2L
(spA0, &
gDisplayContext
->
matrixStack
[
gMatrixListPos
]);
165
166
gSPMatrix(
gMainGfxPos
++, &
gDisplayContext
->
matrixStack
[
gMatrixListPos
++], G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
167
gDPSetPrimColor(
gMainGfxPos
++, 0, 0, 102, 109, 123, part->
unk_28
);
168
gSPDisplayList(
gMainGfxPos
++,
D_E002C940
[0]);
169
gSPPopMatrix(
gMainGfxPos
++, G_MTX_MODELVIEW);
170
}
else
{
171
s32 unk_28 = part->
unk_28
;
172
173
guTranslateF
(sp20, part->
unk_00
, part->
unk_04
, part->
unk_08
);
174
guScaleF
(sp60, 1.5f, 1.5f, 1.5f);
175
guMtxCatF
(sp60, sp20, spA0);
176
guRotateF
(sp60, -
gCameras
[
gCurrentCameraID
].curYaw, 0.0f, 1.0f, 0.0f);
177
guMtxCatF
(sp60, spA0, spA0);
178
guRotateF
(spE0, part->
unk_2C
, 1.0f, 0.0f, 0.0f);
179
180
part++;
181
for
(i = 1; i < ((
EffectInstance
*)effect)->numParts; i++, part++) {
182
Gfx* dlist =
D_E002C940
[i];
183
184
guTranslateF
(sp60, part->
unk_00
, part->
unk_04
, part->
unk_08
);
185
guMtxCatF
(sp60, spA0, sp20);
186
guMtxCatF
(spE0, sp20, sp20);
187
guPositionF
(sp60, part->
unk_2C
, 0.0f, part->
unk_34
, 1.0f, part->
unk_18
, part->
unk_1C
, 0.0f);
188
guMtxCatF
(sp60, sp20, sp20);
189
guMtxF2L
(sp20, &
gDisplayContext
->
matrixStack
[
gMatrixListPos
]);
190
191
gSPMatrix(
gMainGfxPos
++, &
gDisplayContext
->
matrixStack
[
gMatrixListPos
++], G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
192
gDPSetPrimColor(
gMainGfxPos
++, 0, 0, 150, 150, 200, unk_28);
193
gSPDisplayList(
gMainGfxPos
++, dlist);
194
gSPPopMatrix(
gMainGfxPos
++, G_MTX_MODELVIEW);
195
}
196
}
197
}
DisplayContext::matrixStack
Mtx matrixStack[0x200]
Definition
common_structs.h:2191
Matrix4f
f32 Matrix4f[4][4]
Definition
common_structs.h:132
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
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
ShatteringStonesFXData::unk_10
f32 unk_10
Definition
effects.h:320
ShatteringStonesFXData::unk_1C
f32 unk_1C
Definition
effects.h:323
ShatteringStonesFXData::unk_14
f32 unk_14
Definition
effects.h:321
ShatteringStonesFXData::unk_30
f32 unk_30
Definition
effects.h:328
ShatteringStonesFXData::unk_24
s32 unk_24
Definition
effects.h:325
EffectData::shatteringStones
struct ShatteringStonesFXData * shatteringStones
Definition
effects.h:2486
ShatteringStonesFXData::unk_2C
f32 unk_2C
Definition
effects.h:327
ShatteringStonesFXData::unk_3C
f32 unk_3C
Definition
effects.h:331
ShatteringStonesFXData::unk_20
s32 unk_20
Definition
effects.h:324
ShatteringStonesFXData::unk_0C
f32 unk_0C
Definition
effects.h:319
ShatteringStonesFXData::unk_34
f32 unk_34
Definition
effects.h:329
EffectInstance::numParts
s32 numParts
Definition
effects.h:2604
ShatteringStonesFXData::unk_08
f32 unk_08
Definition
effects.h:318
ShatteringStonesFXData::unk_04
f32 unk_04
Definition
effects.h:317
ShatteringStonesFXData::unk_28
s32 unk_28
Definition
effects.h:326
ShatteringStonesFXData::unk_38
f32 unk_38
Definition
effects.h:330
ShatteringStonesFXData::unk_18
f32 unk_18
Definition
effects.h:322
ShatteringStonesFXData::unk_00
f32 unk_00
Definition
effects.h:316
EffectInstance::data
EffectData data
Definition
effects.h:2605
EffectInstance
Definition
effects.h:2601
ShatteringStonesFXData
Definition
effects.h:315
effects_internal.h
ASSERT
#define ASSERT(condition)
Definition
effects_internal.h:7
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
VIRTUAL_TO_PHYSICAL
#define VIRTUAL_TO_PHYSICAL(addr)
Definition
macros.h:47
D_090010D0_341950
Gfx D_090010D0_341950[]
D_090010E8_341968
Gfx D_090010E8_341968[]
D_090010B8_341938
Gfx D_090010B8_341938[]
D_09001120_3419A0
Gfx D_09001120_3419A0[]
shattering_stones_init
void shattering_stones_init(EffectInstance *effect)
Definition
shattering_stones.c:88
shattering_stones_main
void shattering_stones_main(s32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4)
Definition
shattering_stones.c:41
D_E002C940
Gfx * D_E002C940[]
Definition
shattering_stones.c:15
D_09001098_341918
Gfx D_09001098_341918[]
shattering_stones_render
void shattering_stones_render(EffectInstance *effect)
Definition
shattering_stones.c:128
D_09001108_341988
Gfx D_09001108_341988[]
D_E002C964
f32 D_E002C964[]
Definition
shattering_stones.c:21
D_E002C984
f32 D_E002C984[][2]
Definition
shattering_stones.c:25
shattering_stones_appendGfx
void shattering_stones_appendGfx(void *effect)
Definition
shattering_stones.c:141
shattering_stones_update
void shattering_stones_update(EffectInstance *effect)
Definition
shattering_stones.c:91
D_09001138_3419B8
Gfx D_09001138_3419B8[]
D_09001080_341900
Gfx D_09001080_341900[]
D_09001068_3418E8
Gfx D_09001068_3418E8[]
D_09000C00_341480
Gfx D_09000C00_341480[]
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
shattering_stones.c
Generated by
1.10.0