Paper Mario DX
Paper Mario (N64) modding
Loading...
Searching...
No Matches
something_rotating.c
Go to the documentation of this file.
1
#include "common.h"
2
#include "
effects_internal.h
"
3
4
extern
Gfx
D_09003F98_3FE448
[];
5
extern
Gfx
D_09004010_3FE4C0
[];
6
extern
Gfx
D_09004088_3FE538
[];
7
extern
Gfx
D_09004100_3FE5B0
[];
8
extern
Gfx
D_09004178_3FE628
[];
9
extern
Gfx
D_090041F0_3FE6A0
[];
10
extern
Gfx
D_09004268_3FE718
[];
11
extern
Gfx
D_090042E0_3FE790
[];
12
extern
Gfx
D_09004360_3FE810
[];
13
extern
Gfx
D_09004458_3FE908
[];
14
extern
Gfx
D_09004508_3FE9B8
[];
15
extern
Gfx
D_09004600_3FEAB0
[];
16
17
Gfx*
D_E0116C60
[] = {
D_09004458_3FE908
};
18
19
Gfx*
D_E0116C64
[] = {
D_09004600_3FEAB0
};
20
21
Gfx*
D_E0116C68
[] = {
D_09004360_3FE810
};
22
23
Gfx*
D_E0116C6C
[] = {
D_09004508_3FE9B8
};
24
25
Gfx*
D_E0116C70
[] = {
26
D_09003F98_3FE448
,
D_09004010_3FE4C0
,
D_09004088_3FE538
,
27
D_09004100_3FE5B0
,
D_09004178_3FE628
,
D_090041F0_3FE6A0
,
28
D_09004268_3FE718
29
};
30
31
Color_RGB8
D_E0116C8C
[] = {
32
{ 255, 224, 65 },
33
{ 244, 227, 72 },
34
{ 211, 220, 22 },
35
{ 152, 214, 222 },
36
{ 211, 138, 239 },
37
{ 231, 174, 219 },
38
{ 255, 200, 11 },
39
{ 0, 0, 0 }
40
};
41
42
s16
D_E0116CA4
[] = {
43
0, 60, 120, 180, 240, 300,
44
0, 60, 120, 180, 240, 300,
45
0, 60, 120, 180, 240, 300,
46
0, 60, 120, 180, 240, 300,
47
0, 30, 60, 90, 120, 150, 180, 210, 240, 270, 300, 330, 345, 353, 357, 359,
48
0
49
};
50
51
u8
D_E0116CF8
[] = {
52
2, 20, 40, 60, 80, 100, 120, 160, 180, 200, 220, 240, 255
53
};
54
55
u8
D_E0116D08
[] = {
56
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
57
0, 0, 20, 40, 60, 80, 100, 120, 160, 180, 200, 220, 240, 255
58
};
59
60
u8
D_E0116D3C
[] = {
61
255, 255, 255, 255, 255, 255, 255, 225, 185, 165, 148, 128,
62
255, 255, 255, 255, 255, 255, 255, 225, 185, 165, 148, 128,
63
255, 255, 255, 255, 255, 255, 255, 225, 185, 165, 148, 128,
64
255, 255, 255, 255, 255, 255, 255, 225, 185, 165, 148, 128
65
};
66
67
u8
D_E0116D6C
[] = {
68
50, 80, 100, 105, 107, 108, 108, 108, 108, 108, 108, 107, 105, 100, 95, 90, 85, 80, 75, 70, 65, 60, 55, 50
69
};
70
71
void
something_rotating_init
(
EffectInstance
* effect);
72
void
something_rotating_update
(
EffectInstance
* effect);
73
void
something_rotating_render
(
EffectInstance
* effect);
74
void
something_rotating_appendGfx
(
void
* effect);
75
76
EffectInstance
*
something_rotating_main
(
77
s32 arg0,
78
f32 arg1,
79
f32 arg2,
80
f32 arg3,
81
f32 arg4,
82
s32 arg5
83
) {
84
EffectBlueprint
bp;
85
EffectInstance
* effect;
86
SomethingRotatingFXData
* part;
87
s32 numParts = 8;
88
s32 i;
89
90
bp.
init
=
something_rotating_init
;
91
bp.
update
=
something_rotating_update
;
92
bp.
renderWorld
=
something_rotating_render
;
93
bp.
unk_00
= 0;
94
bp.
renderUI
= NULL;
95
bp.
effectID
= EFFECT_SOMETHING_ROTATING;
96
97
effect =
create_effect_instance
(&bp);
98
effect->
numParts
= numParts;
99
part = effect->
data
.
somethingRotating
=
general_heap_malloc
(numParts *
sizeof
(*part));
100
ASSERT
(effect->
data
.
somethingRotating
!= NULL);
101
102
part->
unk_00
= arg0;
103
part->
unk_14
= 0;
104
if
(arg5 <= 0) {
105
part->
unk_10
= 1000;
106
}
else
{
107
part->
unk_10
= arg5;
108
}
109
part->
pos
.
x
= arg1;
110
part->
pos
.
y
= arg2;
111
part->
pos
.
z
= arg3;
112
part->
unk_18
= arg4;
113
part->
unk_1C
= 30.0f;
114
part->
unk_20
= 0;
115
116
part++;
117
for
(i = 1; i < numParts; i++, part++) {
118
part->
primAlpha
= 0;
119
part->
unk_18
= arg4 * 0.5;
120
part->
env
.
r
= 255;
121
part->
env
.
g
= 255;
122
part->
env
.
b
= 0;
123
part->
unk_25
= 0;
124
part->
unk_1C
= 30.0f;
125
part->
unk_20
= 0;
126
part->
state
= 0;
127
part->
unk_2C
= 50.0f;
128
}
129
130
return
effect;
131
}
132
133
void
something_rotating_init
(
EffectInstance
* effect) {
134
}
135
136
void
something_rotating_update
(
EffectInstance
* effect) {
137
SomethingRotatingFXData
* part = effect->
data
.
somethingRotating
;
138
f32 x = part->
pos
.
x
;
139
f32 y = part->
pos
.
y
;
140
f32 z = part->
pos
.
z
;
141
s32
unk_14
;
142
s32 unk_14_2;
143
f32 factor;
144
f32 angle1;
145
s32 i;
146
147
if
(effect->
flags
&
FX_INSTANCE_FLAG_DISMISS
) {
148
effect->
flags
&= ~FX_INSTANCE_FLAG_DISMISS;
149
part->
unk_10
= 32;
150
}
151
152
if
(part->
unk_10
< 1000) {
153
part->
unk_10
--;
154
}
155
156
part->
unk_14
++;
157
158
if
(part->
unk_10
< 0) {
159
remove_effect
(effect);
160
return
;
161
}
162
163
unk_14
= part->
unk_14
;
164
part->
unk_20
= 90.0f;
165
angle1 = 90.0f;
166
167
part++;
168
for
(i = 1; i < effect->
numParts
; i++, part++) {
169
f32 angle2 =
unk_14
* 4.0f + (f32) i * 51.43;
170
f32 temp_f24 =
sin_deg
(angle2);
171
f32 temp_f22 = part->
unk_2C
;
172
173
part->
pos
.
x
= x + temp_f22 *
sin_deg
(angle1) * temp_f24;
174
part->
pos
.
y
= y + temp_f22 *
cos_deg
(angle2);
175
part->
pos
.
z
= z + temp_f22 *
cos_deg
(angle1) * temp_f24;
176
177
switch
(part->
state
) {
178
case
1:
179
part->
unk_14
= 0;
180
part->
state
++;
181
// fallthrough
182
case
2:
183
unk_14_2 = part->
unk_14
;
184
185
if
(unk_14_2 <
ARRAY_COUNT
(
D_E0116CA4
)) {
186
part->
unk_20
=
D_E0116CA4
[unk_14_2];
187
}
else
{
188
part->
unk_20
=
D_E0116CA4
[
ARRAY_COUNT
(
D_E0116CA4
) - 1];
189
}
190
if
(unk_14_2 <
ARRAY_COUNT
(
D_E0116CF8
)) {
191
part->
primAlpha
=
D_E0116CF8
[unk_14_2];
192
}
else
{
193
part->
primAlpha
=
D_E0116CF8
[
ARRAY_COUNT
(
D_E0116CF8
) - 1];
194
}
195
if
(unk_14_2 <
ARRAY_COUNT
(
D_E0116D08
)) {
196
part->
unk_25
=
D_E0116D08
[unk_14_2];
197
}
else
{
198
part->
unk_25
=
D_E0116D08
[
ARRAY_COUNT
(
D_E0116D08
) - 1];
199
}
200
201
if
(unk_14_2 <
ARRAY_COUNT
(
D_E0116D3C
)) {
202
factor =
D_E0116D3C
[unk_14_2];
203
}
else
{
204
factor =
D_E0116D3C
[
ARRAY_COUNT
(
D_E0116D3C
) - 1];
205
}
206
207
factor *= 0.0039215686;
// 1 / 255
208
part->
env
.
r
= factor *
D_E0116C8C
[i - 1].
r
;
209
part->
env
.
g
= factor *
D_E0116C8C
[i - 1].
g
;
210
part->
env
.
b
= factor *
D_E0116C8C
[i - 1].
b
;
211
212
if
(unk_14_2 <
ARRAY_COUNT
(
D_E0116D6C
)) {
213
part->
unk_18
= (f32)
D_E0116D6C
[unk_14_2] * 0.01;
214
}
else
{
215
part->
unk_18
= (f32)
D_E0116D6C
[
ARRAY_COUNT
(
D_E0116D6C
) - 1] * 0.01;
216
}
217
218
break
;
219
case
3:
220
part->
unk_14
= 0;
221
part->
state
++;
222
// fallthrough
223
case
4:
224
unk_14_2 = part->
unk_14
;
225
226
if
(unk_14_2 < 18) {
227
part->
unk_2C
= (
sin_deg
(90 - unk_14_2 * 10) + 1.0f) * 50.0f * 0.5;
228
}
else
{
229
part->
unk_2C
= 0.0f;
230
part->
state
++;
231
}
232
233
break
;
234
case
5:
235
break
;
236
}
237
238
part->
unk_14
++;
239
}
240
}
241
242
void
something_rotating_render
(
EffectInstance
* effect) {
243
RenderTask
renderTask;
244
RenderTask
* retTask;
245
246
renderTask.
appendGfx
=
something_rotating_appendGfx
;
247
renderTask.
appendGfxArg
= effect;
248
renderTask.
dist
= 10;
249
renderTask.
renderMode
=
RENDER_MODE_SURFACE_XLU_LAYER1
;
250
251
retTask =
queue_render_task
(&renderTask);
252
retTask->
renderMode
|=
RENDER_TASK_FLAG_REFLECT_FLOOR
;
253
}
254
255
void
func_E01166E8
(s32 arg0,
SomethingRotatingFXData
* part) {
256
f32 temp;
257
Matrix4f
sp20;
258
Matrix4f
sp60;
259
260
if
(arg0 == 0) {
261
temp =
gCameras
[
gCurrentCameraID
].
curYaw
;
262
}
else
{
263
temp = 0.0f;
264
}
265
266
guPositionF
(sp20, 0.0f, part->
unk_20
- temp, 0.0f, part->
unk_18
,
267
part->
pos
.
x
+ 2.0f,
268
part->
pos
.
y
,
269
part->
pos
.
z
+ 2.0f
270
);
271
guRotateF
(sp60, part->
unk_1C
, 0.0f, 0.0f, 1.0f);
272
guMtxCatF
(sp60, sp20, sp20);
273
guTranslateF
(sp60, 0.0f, 0.0f, -2.0f);
274
guMtxCatF
(sp60, sp20, sp20);
275
guMtxF2L
(sp20, &
gDisplayContext
->
matrixStack
[
gMatrixListPos
]);
276
277
gSPMatrix(
gMainGfxPos
++, &
gDisplayContext
->
matrixStack
[
gMatrixListPos
++],
278
G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
279
}
280
281
void
something_rotating_appendGfx
(
void
* effect) {
282
SomethingRotatingFXData
* data = ((
EffectInstance
*)effect)->data.somethingRotating;
283
s32
unk_14
= data->
unk_14
;
284
s32 l, t;
285
s32 i;
286
287
gDPPipeSync(
gMainGfxPos
++);
288
gSPSegment(
gMainGfxPos
++, 0x09,
VIRTUAL_TO_PHYSICAL
(((
EffectInstance
*)effect)->graphics->data));
289
290
gSPDisplayList(
gMainGfxPos
++,
D_090042E0_3FE790
);
291
gDPSetEnvColor(
gMainGfxPos
++, 0, 0, 0, 255);
292
293
data++;
294
for
(i = 1; i < ((
EffectInstance
*)effect)->numParts; i++, data++) {
295
if
(data->
state
!= 5) {
296
func_E01166E8
(1, data);
297
if
(data->
primAlpha
!= 255) {
298
gDPSetPrimColor(
gMainGfxPos
++, 0, 0, 0, 0, 0, data->
primAlpha
);
299
gDPSetEnvColor(
gMainGfxPos
++, data->
env
.
r
, data->
env
.
g
, data->
env
.
b
, 0x78);
300
gSPDisplayList(
gMainGfxPos
++,
D_E0116C6C
[0]);
301
302
l = ((
unk_14
* 4.0f) * 100.0f) * (1.0 / 1024);
303
t = ((
unk_14
* 4.0f) * 40.0f) * (1.0 / 1024);
304
gDPSetTileSize(
gMainGfxPos
++, G_TX_RENDERTILE, l, t, l + 0xFC, t + 0xFC);
305
306
l = ((
unk_14
* 4.0f) * 200.0f) * (1.0 / 1024);
307
t = ((
unk_14
* 4.0f) * 90.0f) * (1.0 / 1024);
308
gDPSetTileSize(
gMainGfxPos
++, 1, l, t, l + 0xFC, t + 0xFC);
309
gSPDisplayList(
gMainGfxPos
++,
D_E0116C64
[0]);
310
}
else
{
311
gSPDisplayList(
gMainGfxPos
++,
D_E0116C68
[0]);
312
gDPSetEnvColor(
gMainGfxPos
++, data->
env
.
r
, data->
env
.
g
, data->
env
.
b
, data->
unk_25
);
313
gSPDisplayList(
gMainGfxPos
++,
D_E0116C70
[i - 1]);
314
gSPDisplayList(
gMainGfxPos
++,
D_E0116C60
[0]);
315
}
316
gSPPopMatrix(
gMainGfxPos
++, G_MTX_MODELVIEW);
317
}
318
}
319
}
Color_RGB8::r
u8 r
Definition
common_structs.h:38
Color_RGB8::g
u8 g
Definition
common_structs.h:38
DisplayContext::matrixStack
Mtx matrixStack[0x200]
Definition
common_structs.h:2191
Matrix4f
f32 Matrix4f[4][4]
Definition
common_structs.h:132
Color_RGB8::b
u8 b
Definition
common_structs.h:38
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
Color_RGB8
Definition
common_structs.h:37
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
guPositionF
#define guPositionF
Definition
effect_shims.h:65
cos_deg
#define cos_deg
Definition
effect_shims.h:56
create_effect_instance
#define create_effect_instance
Definition
effect_shims.h:49
SomethingRotatingFXData::pos
Vec3f pos
Definition
effects.h:2285
SomethingRotatingFXData::unk_1C
f32 unk_1C
Definition
effects.h:2289
EffectInstance::flags
s32 flags
Definition
effects.h:2602
SomethingRotatingFXData::unk_10
s32 unk_10
Definition
effects.h:2286
SomethingRotatingFXData::unk_20
f32 unk_20
Definition
effects.h:2290
EffectData::somethingRotating
struct SomethingRotatingFXData * somethingRotating
Definition
effects.h:2589
SomethingRotatingFXData::state
u8 state
Definition
effects.h:2294
SomethingRotatingFXData::env
Color_RGB8 env
Definition
effects.h:2293
EffectInstance::numParts
s32 numParts
Definition
effects.h:2604
SomethingRotatingFXData::unk_25
s8 unk_25
Definition
effects.h:2292
SomethingRotatingFXData::unk_14
s32 unk_14
Definition
effects.h:2287
SomethingRotatingFXData::primAlpha
u8 primAlpha
Definition
effects.h:2291
SomethingRotatingFXData::unk_18
f32 unk_18
Definition
effects.h:2288
SomethingRotatingFXData::unk_00
s32 unk_00
Definition
effects.h:2284
EffectInstance::data
EffectData data
Definition
effects.h:2605
SomethingRotatingFXData::unk_2C
f32 unk_2C
Definition
effects.h:2296
EffectInstance
Definition
effects.h:2601
SomethingRotatingFXData
Definition
effects.h:2283
effects_internal.h
ASSERT
#define ASSERT(condition)
Definition
effects_internal.h:7
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_SURFACE_XLU_LAYER1
@ RENDER_MODE_SURFACE_XLU_LAYER1
Definition
enums.h:3282
ARRAY_COUNT
#define ARRAY_COUNT(arr)
Definition
macros.h:40
VIRTUAL_TO_PHYSICAL
#define VIRTUAL_TO_PHYSICAL(addr)
Definition
macros.h:47
D_E0116C6C
Gfx * D_E0116C6C[]
Definition
something_rotating.c:23
something_rotating_appendGfx
void something_rotating_appendGfx(void *effect)
Definition
something_rotating.c:281
D_09004458_3FE908
Gfx D_09004458_3FE908[]
D_E0116C68
Gfx * D_E0116C68[]
Definition
something_rotating.c:21
D_09003F98_3FE448
Gfx D_09003F98_3FE448[]
D_09004178_3FE628
Gfx D_09004178_3FE628[]
D_090041F0_3FE6A0
Gfx D_090041F0_3FE6A0[]
D_09004010_3FE4C0
Gfx D_09004010_3FE4C0[]
D_090042E0_3FE790
Gfx D_090042E0_3FE790[]
D_E0116CA4
s16 D_E0116CA4[]
Definition
something_rotating.c:42
D_E0116D08
u8 D_E0116D08[]
Definition
something_rotating.c:55
D_E0116C64
Gfx * D_E0116C64[]
Definition
something_rotating.c:19
D_09004088_3FE538
Gfx D_09004088_3FE538[]
D_E0116CF8
u8 D_E0116CF8[]
Definition
something_rotating.c:51
D_E0116C8C
Color_RGB8 D_E0116C8C[]
Definition
something_rotating.c:31
D_E0116D6C
u8 D_E0116D6C[]
Definition
something_rotating.c:67
func_E01166E8
void func_E01166E8(s32 arg0, SomethingRotatingFXData *part)
Definition
something_rotating.c:255
D_09004268_3FE718
Gfx D_09004268_3FE718[]
D_E0116C70
Gfx * D_E0116C70[]
Definition
something_rotating.c:25
D_E0116D3C
u8 D_E0116D3C[]
Definition
something_rotating.c:60
D_09004600_3FEAB0
Gfx D_09004600_3FEAB0[]
D_09004100_3FE5B0
Gfx D_09004100_3FE5B0[]
something_rotating_update
void something_rotating_update(EffectInstance *effect)
Definition
something_rotating.c:136
D_09004508_3FE9B8
Gfx D_09004508_3FE9B8[]
something_rotating_main
EffectInstance * something_rotating_main(s32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4, s32 arg5)
Definition
something_rotating.c:76
D_E0116C60
Gfx * D_E0116C60[]
Definition
something_rotating.c:17
something_rotating_init
void something_rotating_init(EffectInstance *effect)
Definition
something_rotating.c:133
D_09004360_3FE810
Gfx D_09004360_3FE810[]
something_rotating_render
void something_rotating_render(EffectInstance *effect)
Definition
something_rotating.c:242
Camera::curYaw
f32 curYaw
Definition
common_structs.h:800
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
something_rotating.c
Generated by
1.10.0