Paper Mario DX
Paper Mario (N64) modding
Loading...
Searching...
No Matches
stars_shimmer.c
Go to the documentation of this file.
1
#include "common.h"
2
#include "
effects_internal.h
"
3
4
void
stars_shimmer_init
(
EffectInstance
* effect);
5
void
stars_shimmer_update
(
EffectInstance
* effect);
6
void
stars_shimmer_render
(
EffectInstance
* effect);
7
void
stars_shimmer_appendGfx
(
void
* effect);
8
9
extern
Gfx
D_09000F20_338EE0
[];
10
extern
Gfx
D_090011C8_339188
[];
11
extern
Gfx
D_090011E0_3391A0
[];
12
extern
Gfx
D_090011F8_3391B8
[];
13
extern
Gfx
D_09001210_3391D0
[];
14
extern
Gfx
D_09001228_3391E8
[];
15
extern
Gfx
D_09001240_339200
[];
16
extern
Gfx
D_09001258_339218
[];
17
extern
Gfx
D_09001270_339230
[];
18
19
Gfx*
D_E0044DB0
[] = {
20
D_09001210_3391D0
,
D_09001228_3391E8
,
D_09001240_339200
,
D_09001258_339218
,
21
D_09001270_339230
,
D_090011C8_339188
,
D_090011E0_3391A0
,
D_090011F8_3391B8
22
};
23
24
u8
D_E0044DD0
[] = {
25
254, 172, 172,
26
254, 172, 213,
27
254, 180, 154,
28
213, 180, 254,
29
180, 180, 254,
30
180, 221, 254,
31
180, 254, 254,
32
180, 254, 213,
33
180, 254, 180,
34
213, 254, 180,
35
254, 254, 180,
36
254, 213, 172,
37
};
38
39
u8
D_E0044DF4
[] = {
40
30, 60, 90, 100, 104, 106, 108, 110, 112, 113, 113, 110, 107, 103, 0x00, 0x00
41
};
42
43
u8
D_E0044E04
[] = {
44
30, 60, 90, 100, 104, 106, 108, 110, 112, 113, 113, 110, 107, 103, 0x00, 0x00
45
};
46
47
void
stars_shimmer_main
(s32 type, f32 x, f32 y, f32 z, f32 arg4, f32 arg5, s32 numParts, s32 arg7) {
48
EffectBlueprint
bp;
49
EffectBlueprint
* bpPtr = &bp;
50
EffectInstance
* effect;
51
StarsShimmerFXData
* part;
52
f32 cosTheta;
53
f32 sinTheta;
54
f32 temp_f22;
55
f32 temp_f8;
56
f32 temp_ft;
57
f32 theta;
58
f32 temp5;
59
f32 t3;
60
f32 new_var;
61
s32 i;
62
63
numParts++;
64
65
bpPtr->
init
=
stars_shimmer_init
;
66
bpPtr->
update
=
stars_shimmer_update
;
67
bpPtr->
renderWorld
=
stars_shimmer_render
;
68
bpPtr->
unk_00
= 0;
69
bpPtr->
renderUI
= NULL;
70
bpPtr->
effectID
= EFFECT_STARS_SHIMMER;
71
72
effect =
create_effect_instance
(bpPtr);
73
effect->
numParts
= numParts;
74
part = effect->
data
.
starsShimmer
=
general_heap_malloc
(numParts *
sizeof
(*part));
75
ASSERT
(effect->
data
.
starsShimmer
!= NULL);
76
77
if
(type == 6) {
78
part->
unk_00
= 1;
79
type = 3;
80
}
else
{
81
part->
unk_00
= 0;
82
}
83
part->
pos
.
x
= x;
84
part->
pos
.
y
= y;
85
part->
pos
.
z
= z;
86
part->
lifeTime
= 0;
87
part->
state
= type;
88
part->
timeLeft
= arg7;
89
90
part++;
91
for
(i = 1; i < numParts; i++, part++) {
92
temp_f22 = (360.0f / (numParts - 1)) * i;
93
if
(type > 1) {
94
theta = temp_f22 +
rand_int
(359);
95
}
else
{
96
theta = temp_f22 + 0.0f;
97
}
98
t3 = (temp_f22 * 10.0f) - 90.0f;
99
sinTheta =
sin_deg
(theta);
100
cosTheta =
cos_deg
(theta);
101
temp_f22 =
sin_deg
(t3);
102
temp_f8 = (arg4 * 0.4) - (arg4 * 0.1 * temp_f22);
103
temp_ft = (arg5 * 0.4) - (arg5 * 0.1 * temp_f22);
104
new_var = 1.0f;
// TODO dumb temp and cast later required to match
105
temp5 = (arg5 / (numParts - 1)) * (i - 1);
106
107
part->
unk_1C
= (u8) new_var;
108
part->
lifeTime
= 0;
109
part->
timeLeft
= i + 30;
110
111
switch
(type) {
112
case
0:
113
case
1:
114
part->
unk_18
= 0;
115
part->
pos
.
z
= 0.0f;
116
part->
unk_10
= sinTheta * temp_f8;
117
part->
unk_14
= cosTheta * temp_ft;
118
break
;
119
case
3:
120
part->
pos
.
x
= (sinTheta * arg4 *
rand_int
(100)) * 0.005;
121
part->
pos
.
y
= (cosTheta * arg5 *
rand_int
(100)) * 0.005;
122
part->
pos
.
z
= 0.0f;
123
124
part->
unk_18
= part->
unk_10
= part->
unk_14
= 0.0f;
125
126
part->
timeLeft
+= i * 2;
127
break
;
128
case
2:
129
case
4:
130
case
5:
131
default
:
132
part->
unk_10
= sinTheta * temp_f8;
133
part->
pos
.
y
= temp5;
134
part->
pos
.
z
= cosTheta * temp_f8;
135
part->
unk_14
= -
rand_int
(10) * 0.03f;
136
part->
unk_18
= (
rand_int
(10) * 0.04f) + 0.01;
137
break
;
138
}
139
}
140
}
141
142
void
stars_shimmer_init
(
EffectInstance
* effect) {
143
}
144
145
void
stars_shimmer_update
(
EffectInstance
* effect) {
146
StarsShimmerFXData
* data = effect->
data
.
starsShimmer
;
147
StarsShimmerFXData
* it = data;
148
s32 deadParts = 0;
149
s32 state = it->
state
;
150
s32 lifeTime;
151
s32 i;
152
153
it->
timeLeft
--;
154
it->
lifeTime
++;
155
lifeTime = it->
lifeTime
;
156
if
(state == 0 || state == 1 || state == 3 || state >= 10) {
157
if
(it->
timeLeft
< 0) {
158
remove_effect
(effect);
159
return
;
160
}
161
}
162
163
it++;
164
for
(i = 0; i < effect->
numParts
- 1; i++, it++) {
165
switch
(state) {
166
case
0:
167
case
1:
168
it->
unk_28
= (lifeTime + i) & 7;
169
it->
unk_18
+= -0.02;
170
if
(lifeTime - 1 < 14) {
171
f32 temp_f0 = (f32)
D_E0044DF4
[lifeTime - 1] * 0.01;
172
173
it->
pos
.
x
= it->
unk_10
* temp_f0;
174
it->
pos
.
y
= (it->
unk_14
* temp_f0) + it->
unk_18
;
175
it->
unk_1C
= (f32)
D_E0044E04
[lifeTime - 1] * 0.01;
176
}
else
{
177
f32 var_f20 = ((360.0f / (effect->
numParts
- 1)) * i) + 60.0f;
178
179
if
(i % 2 != 0) {
180
var_f20 -= 120.0f;
181
}
182
data->
state
= 10;
183
it->
unk_10
=
sin_deg
(var_f20);
184
it->
unk_14
=
cos_deg
(var_f20);
185
it->
unk_18
= -0.05f;
186
}
187
break
;
188
case
10:
189
case
30:
190
it->
unk_28
= (lifeTime + i) & 7;
191
it->
unk_10
*= 0.96;
192
it->
unk_14
*= 0.96;
193
it->
unk_14
+= it->
unk_18
;
194
it->
unk_1C
+= (0.1 - it->
unk_1C
) * 0.1;
195
it->
pos
.
x
+= it->
unk_10
;
196
it->
pos
.
y
+= it->
unk_14
;
197
break
;
198
case
3:
199
it->
unk_28
= (lifeTime + i + i) & 7;
200
if
(lifeTime - 1 < 14) {
201
it->
unk_1C
= (f32)
D_E0044E04
[lifeTime - 1] * 0.01;
202
break
;
203
}
204
data->
state
= 30;
205
break
;
206
case
2:
207
case
4:
208
case
5:
209
case
6:
210
case
7:
211
case
8:
212
case
9:
213
case
11:
214
case
12:
215
case
13:
216
case
14:
217
case
15:
218
case
16:
219
case
17:
220
case
18:
221
case
19:
222
case
20:
223
case
21:
224
case
22:
225
case
23:
226
case
24:
227
case
25:
228
case
26:
229
case
27:
230
case
28:
231
case
29:
232
default
:
233
it->
unk_28
= (lifeTime + i + i) & 7;
234
if
(it->
timeLeft
< 0) {
235
deadParts++;
236
}
237
it->
timeLeft
--;
238
if
((u32) it->
timeLeft
> 30) {
239
it->
unk_28
= -1;
240
}
else
{
241
it->
lifeTime
++;
242
lifeTime = it->
lifeTime
;
243
if
(lifeTime - 1 < 14) {
244
it->
unk_1C
= (f32)
D_E0044E04
[lifeTime - 1] * 0.01;
245
if
(state == 5) {
246
it->
unk_14
+= it->
unk_18
;
247
it->
pos
.
y
+= it->
unk_14
;
248
}
249
}
else
{
250
it->
unk_14
+= it->
unk_18
;
251
it->
pos
.
y
+= it->
unk_14
;
252
it->
unk_1C
+= (0.1 - it->
unk_1C
) * 0.1;
253
}
254
if
(state == 4) {
255
it->
pos
.
x
= (it->
unk_10
*
sin_deg
(lifeTime * 12));
256
it->
pos
.
z
= (it->
unk_10
*
cos_deg
(lifeTime * 12));
257
}
else
{
258
it->
pos
.
x
= it->
unk_10
;
259
}
260
it->
unk_14
*= 0.96;
261
}
262
}
263
}
264
265
if
(state != 0 && state != 1 && state != 3 && state < 10 && deadParts >= effect->
numParts
- 1) {
266
remove_effect
(effect);
267
}
268
}
269
270
void
stars_shimmer_render
(
EffectInstance
* effect) {
271
RenderTask
renderTask;
272
RenderTask
* retTask;
273
274
renderTask.
appendGfx
=
stars_shimmer_appendGfx
;
275
renderTask.
appendGfxArg
= effect;
276
renderTask.
dist
= 0;
277
renderTask.
renderMode
=
RENDER_MODE_CLOUD_NO_ZCMP
;
278
279
retTask =
queue_render_task
(&renderTask);
280
}
281
282
void
stars_shimmer_appendGfx
(
void
* effect) {
283
Matrix4f
sp18, sp58, sp98;
284
StarsShimmerFXData
* data = ((
EffectInstance
*)effect)->data.starsShimmer;
285
s32 state;
286
s32 temp_s4;
287
s32 unk_28;
288
f32 rf, gf, bf;
289
s32 r, g, b;
290
s32 i;
291
292
state = data->
state
;
293
294
gDPPipeSync(
gMainGfxPos
++);
295
gSPSegment(
gMainGfxPos
++, 0x09,
VIRTUAL_TO_PHYSICAL
(((
EffectInstance
*)effect)->graphics->data));
296
gSPDisplayList(
gMainGfxPos
++,
D_09000F20_338EE0
);
297
298
temp_s4 = (data->
lifeTime
- 1) * 3;
299
guTranslateF
(sp18, data->
pos
.
x
, data->
pos
.
y
, data->
pos
.
z
);
300
guRotateF
(sp58, -
gCameras
[
gCurrentCameraID
].curYaw, 0.0f, 1.0f, 0.0f);
301
guMtxCatF
(sp58, sp18, sp98);
302
303
switch
(state) {
304
case
0:
305
case
1:
306
case
2:
307
case
10:
308
rf = 1.0f;
309
gf = 0.5f;
310
bf = 0.1f;
311
break
;
312
case
3:
313
case
30:
314
rf = 1.0f;
315
gf = 0.8f;
316
bf = 0.7f;
317
if
(data->
unk_00
!= 0) {
318
gDPSetRenderMode(
gMainGfxPos
++, G_RM_ZB_CLD_SURF, G_RM_ZB_CLD_SURF2);
319
}
320
break
;
321
case
5:
322
rf = 1.4f;
323
gf = 1.4f;
324
bf = 0.7f;
325
break
;
326
default
:
327
rf = 1.4f;
328
gf = 0.7f;
329
bf = 0.7f;
330
break
;
331
}
332
333
data++;
334
for
(i = 0; i < ((
EffectInstance
*)effect)->numParts - 1; i++, data++) {
335
unk_28 = data->
unk_28
;
336
if
(unk_28 >= 0) {
337
guTranslateF
(sp58, data->
pos
.
x
, data->
pos
.
y
, data->
pos
.
z
);
338
sp58[0][0] = sp58[1][1] = sp58[2][2] = data->
unk_1C
;
339
guMtxCatF
(sp58, sp98, sp18);
340
guMtxF2L
(sp18, &
gDisplayContext
->
matrixStack
[
gMatrixListPos
]);
341
if
(temp_s4 >= 36) {
342
temp_s4 = 0;
343
}
344
r =
D_E0044DD0
[temp_s4++] * rf;
345
g =
D_E0044DD0
[temp_s4++] * gf;
346
b =
D_E0044DD0
[temp_s4++] * bf;
347
if
(r > 255) {
348
r = 255;
349
}
350
if
(g > 255) {
351
g = 255;
352
}
353
if
(b > 255) {
354
b = 255;
355
}
356
gDPSetPrimColor(
gMainGfxPos
++, 0, 0, r, g, b, 255);
357
gSPMatrix(
gMainGfxPos
++, &
gDisplayContext
->
matrixStack
[
gMatrixListPos
++],
358
G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
359
gSPDisplayList(
gMainGfxPos
++,
D_E0044DB0
[unk_28 & 7]);
360
gSPPopMatrix(
gMainGfxPos
++, G_MTX_MODELVIEW);
361
}
362
}
363
gDPPipeSync(
gMainGfxPos
++);
364
}
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
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
cos_deg
#define cos_deg
Definition
effect_shims.h:56
create_effect_instance
#define create_effect_instance
Definition
effect_shims.h:49
EffectData::starsShimmer
struct StarsShimmerFXData * starsShimmer
Definition
effects.h:2498
StarsShimmerFXData::timeLeft
s32 timeLeft
Definition
effects.h:525
StarsShimmerFXData::state
s16 state
Definition
effects.h:518
StarsShimmerFXData::unk_28
s32 unk_28
Definition
effects.h:526
StarsShimmerFXData::unk_14
f32 unk_14
Definition
effects.h:521
StarsShimmerFXData::unk_10
f32 unk_10
Definition
effects.h:520
StarsShimmerFXData::lifeTime
s32 lifeTime
Definition
effects.h:524
StarsShimmerFXData::pos
Vec3f pos
Definition
effects.h:519
EffectInstance::numParts
s32 numParts
Definition
effects.h:2604
StarsShimmerFXData::unk_1C
f32 unk_1C
Definition
effects.h:523
StarsShimmerFXData::unk_18
f32 unk_18
Definition
effects.h:522
EffectInstance::data
EffectData data
Definition
effects.h:2605
StarsShimmerFXData::unk_00
s16 unk_00
Definition
effects.h:517
EffectInstance
Definition
effects.h:2601
StarsShimmerFXData
Definition
effects.h:516
effects_internal.h
ASSERT
#define ASSERT(condition)
Definition
effects_internal.h:7
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_090011E0_3391A0
Gfx D_090011E0_3391A0[]
D_09001228_3391E8
Gfx D_09001228_3391E8[]
stars_shimmer_main
void stars_shimmer_main(s32 type, f32 x, f32 y, f32 z, f32 arg4, f32 arg5, s32 numParts, s32 arg7)
Definition
stars_shimmer.c:47
D_09000F20_338EE0
Gfx D_09000F20_338EE0[]
stars_shimmer_render
void stars_shimmer_render(EffectInstance *effect)
Definition
stars_shimmer.c:270
D_090011C8_339188
Gfx D_090011C8_339188[]
D_E0044DB0
Gfx * D_E0044DB0[]
Definition
stars_shimmer.c:19
D_E0044DF4
u8 D_E0044DF4[]
Definition
stars_shimmer.c:39
D_E0044E04
u8 D_E0044E04[]
Definition
stars_shimmer.c:43
stars_shimmer_update
void stars_shimmer_update(EffectInstance *effect)
Definition
stars_shimmer.c:145
stars_shimmer_init
void stars_shimmer_init(EffectInstance *effect)
Definition
stars_shimmer.c:142
D_09001210_3391D0
Gfx D_09001210_3391D0[]
D_E0044DD0
u8 D_E0044DD0[]
Definition
stars_shimmer.c:24
D_090011F8_3391B8
Gfx D_090011F8_3391B8[]
stars_shimmer_appendGfx
void stars_shimmer_appendGfx(void *effect)
Definition
stars_shimmer.c:282
D_09001258_339218
Gfx D_09001258_339218[]
D_09001270_339230
Gfx D_09001270_339230[]
D_09001240_339200
Gfx D_09001240_339200[]
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
stars_shimmer.c
Generated by
1.10.0