Paper Mario DX
Paper Mario (N64) modding
Loading...
Searching...
No Matches
static_status.c
Go to the documentation of this file.
1
#include "common.h"
2
#include "
effects_internal.h
"
3
4
extern
Gfx
D_09000280_3E1550
[];
5
extern
Gfx
D_090003A0_3E1670
[];
6
7
Gfx
*
D_E00E6880
[] = {
D_090003A0_3E1670
,
D_090003A0_3E1670
};
8
Gfx
*
D_E00E6888
[] = {
D_09000280_3E1550
,
D_09000280_3E1550
};
9
10
// number of frames in animation for type 0 and type 1
11
s32
StaticEffectFrameCount
[] = { 24, 12 };
12
13
f32
StaticEffectScaleVals0
[] = {
14
0.9f, 1.0f, 1.0f, 0.9f, 0.85f, 0.8f, 0.75f, 0.7f, 0.65f, 0.6f, 0.55f, 0.5f,
15
0.45f, 0.4f, 0.35f, 0.3f, 0.25f, 0.2f, 0.15f, 0.1f, 0.05f, 0.03f, 0.02f, 0.01f
16
};
17
18
u8
StaticEffectAlphaVals0
[] = {
19
0xFA, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
20
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
21
};
22
23
f32
StaticEffectScaleVals1
[] = {
24
0.9f, 1.0f, 1.0f, 0.9f, 0.8f, 0.7f, 0.6f, 0.5f, 0.4f, 0.3f, 0.2f, 0.1f,
25
0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f
26
};
27
28
u8
StaticEffectAlphaVals1
[] = {
29
0xFA, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
30
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
31
};
32
33
void
static_status_init
(
EffectInstance
* effect);
34
void
static_status_update
(
EffectInstance
* effect);
35
void
static_status_render
(
EffectInstance
* effect);
36
void
static_status_appendGfx
(
void
* effect);
37
38
EffectInstance
*
static_status_main
(
39
s32
type,
40
f32
x,
41
f32
y,
42
f32
z,
43
f32
scale,
44
s32
numBolts
,
45
s32
duration)
46
{
47
EffectBlueprint
bp
;
48
EffectInstance
* effect;
49
StaticStatusFXData
*
part
;
50
f32
invisTime
;
51
s32
i;
52
53
numBolts
++;
54
55
bp
.init =
static_status_init
;
56
bp
.update =
static_status_update
;
57
bp
.renderScene =
static_status_render
;
58
bp
.unk_00 = 0;
59
bp
.renderUI =
NULL
;
60
bp
.effectID =
EFFECT_STATIC_STATUS
;
61
62
effect =
create_effect_instance
(&
bp
);
63
effect->
numParts
=
numBolts
;
64
part
= effect->
data
.
staticStatus
=
general_heap_malloc
(
numBolts
*
sizeof
(*
part
));
65
ASSERT
(effect->
data
.
staticStatus
!=
NULL
);
66
67
part
->type = type;
68
part
->lifetime = 0;
69
if
(duration <= 0) {
70
part
->timeLeft = 1000;
71
}
else
{
72
part
->timeLeft = duration;
73
}
74
part
->alpha = 255;
75
part
->pos.x = x;
76
part
->pos.y = y;
77
part
->pos.z = z;
78
part
->scale = scale;
79
80
invisTime
=
StaticEffectFrameCount
[type] * 0.5f;
81
82
part
++;
83
for
(i = 1; i <
numBolts
; i++,
part
++) {
84
part
->frame = -1.0f -
invisTime
* (i & 1);
85
}
86
87
return
effect;
88
}
89
90
void
static_status_init
(
EffectInstance
* effect) {
91
}
92
93
void
static_status_update
(
EffectInstance
* effect) {
94
StaticStatusFXData
*
part
= effect->
data
.
staticStatus
;
95
s32
type =
part
->
type
;
96
s32
unk_28;
97
s32
time;
98
f32
interpAmt
;
99
f32
initialAmt
;
100
f32
angle;
101
s32
i;
102
103
if
(effect->
flags
&
FX_INSTANCE_FLAG_DISMISS
) {
104
effect->
flags
&=
~FX_INSTANCE_FLAG_DISMISS
;
105
part
->timeLeft = 16;
106
}
107
108
if
(
part
->timeLeft < 1000) {
109
part
->timeLeft--;
110
}
111
112
part
->lifetime++;
113
114
if
(
part
->timeLeft < 0) {
115
remove_effect
(effect);
116
return
;
117
}
118
119
time =
part
->lifetime;
120
121
if
(
part
->timeLeft < 16) {
122
part
->alpha =
part
->timeLeft * 16;
123
}
124
125
if
(type == 0) {
126
initialAmt
= 0.1f;
127
interpAmt
= 0.2f;
128
}
else
{
129
initialAmt
= 0.2f;
130
interpAmt
= 0.2f;
131
}
132
133
part
++;
134
for
(i = 1; i < effect->
numParts
; i++,
part
++) {
135
part
->frame++;
136
if
(
part
->frame >=
StaticEffectFrameCount
[type]) {
137
part
->frame = 0;
138
}
139
140
if
(
part
->frame >= 0) {
141
if
(
part
->frame == 0) {
142
angle = (i * 360.0f) / (effect->
numParts
- 1);
143
part
->pos.x =
sin_deg
(angle) * 16.0f;
144
part
->pos.y =
cos_deg
(angle) * 16.0f;
145
part
->unk_10 =
part
->pos.x *
initialAmt
;
146
part
->unk_14 =
part
->pos.y *
initialAmt
;
147
part
->unk_18 = 0.0f;
148
part
->unk_1C = 0.0f;
149
part
->scale = 1.0f;
150
part
->rot = -angle - 45.0f;
151
}
152
153
if
(type == 0) {
154
part
->alpha =
StaticEffectAlphaVals0
[
part
->frame];
155
part
->scale =
StaticEffectScaleVals0
[
part
->frame];
156
}
else
{
157
part
->alpha =
StaticEffectAlphaVals1
[
part
->frame];
158
part
->scale =
StaticEffectScaleVals1
[
part
->frame];
159
}
160
161
if
((time & 1) == (i & 1)) {
162
part
->pos.x +=
part
->unk_10;
163
part
->pos.y +=
part
->unk_14;
164
}
else
{
165
part
->pos.x +=
part
->unk_10 * 0.2;
166
part
->pos.y +=
part
->unk_14 * 0.2;
167
}
168
169
part
->unk_10 += (
part
->unk_18 -
part
->unk_10) *
interpAmt
;
170
part
->unk_14 += (
part
->unk_1C -
part
->unk_14) *
interpAmt
;
171
}
172
}
173
}
174
175
void
static_status_render
(
EffectInstance
* effect) {
176
RenderTask
renderTask
;
177
RenderTask
*
retTask
;
178
179
renderTask
.
appendGfx
=
static_status_appendGfx
;
180
renderTask
.appendGfxArg = effect;
181
renderTask
.dist = 10;
182
renderTask
.renderMode =
RENDER_MODE_SURFACE_OPA
;
183
184
retTask
=
queue_render_task
(&
renderTask
);
185
retTask
->renderMode |=
RENDER_TASK_FLAG_REFLECT_FLOOR
;
186
}
187
188
void
func_E00E651C
(
void
) {
189
}
190
191
void
static_status_appendGfx
(
void
* effect) {
192
StaticStatusFXData
*
part
= ((
EffectInstance
*)effect)->data.staticStatus;
193
Camera
*
camera
= &
gCameras
[
gCurrentCameraID
];
194
s32
unk_30 =
part
->alpha;
195
s32
unk_00 =
part
->type;
196
Matrix4f
mtxTransform
;
197
Matrix4f
mtxTemp
;
198
s32
i;
199
200
gDPPipeSync
(
gMainGfxPos
++);
201
gSPSegment
(
gMainGfxPos
++, 0x09,
VIRTUAL_TO_PHYSICAL
(((
EffectInstance
*)effect)->shared->graphics));
202
203
guTranslateF
(
mtxTransform
,
part
->pos.x,
part
->pos.y,
part
->pos.z);
204
guScaleF
(
mtxTemp
,
part
->scale,
part
->scale,
part
->scale);
205
guMtxCatF
(
mtxTemp
,
mtxTransform
,
mtxTransform
);
206
guMtxF2L
(
mtxTransform
, &
gDisplayContext
->
matrixStack
[
gMatrixListPos
]);
207
208
gSPMatrix
(
gMainGfxPos
++, &
gDisplayContext
->
matrixStack
[
gMatrixListPos
++],
G_MTX_PUSH
|
G_MTX_LOAD
|
G_MTX_MODELVIEW
);
209
gSPMatrix
(
gMainGfxPos
++,
camera
->mtxBillboard,
G_MTX_NOPUSH
|
G_MTX_MUL
|
G_MTX_MODELVIEW
);
210
gSPDisplayList
(
gMainGfxPos
++,
D_E00E6888
[unk_00]);
211
212
part
++;
213
for
(i = 1; i < ((
EffectInstance
*)effect)->numParts; i++,
part
++) {
214
if
(
part
->frame >= 0) {
215
guPositionF
(
mtxTransform
, 0.0f, 0.0f,
part
->rot,
part
->scale,
part
->pos.x,
part
->pos.y, 0.0f);
216
guMtxF2L
(
mtxTransform
, &
gDisplayContext
->
matrixStack
[
gMatrixListPos
]);
217
218
gSPMatrix
(
gMainGfxPos
++, &
gDisplayContext
->
matrixStack
[
gMatrixListPos
++],
G_MTX_PUSH
|
G_MTX_MUL
|
G_MTX_MODELVIEW
);
219
gDPSetPrimColor
(
gMainGfxPos
++, 0, 0, 0, 0, 0, (unk_30 *
part
->alpha) >> 8);
220
gSPDisplayList
(
gMainGfxPos
++,
D_E00E6880
[unk_00]);
221
gSPPopMatrix
(
gMainGfxPos
++,
G_MTX_MODELVIEW
);
222
}
223
}
224
225
gSPPopMatrix
(
gMainGfxPos
++,
G_MTX_MODELVIEW
);
226
}
PopupMenu_SelectedIndex
BSS s32 PopupMenu_SelectedIndex
Definition
8a860_len_3f30.c:84
DisplayContext::matrixStack
Mtx matrixStack[0x200]
Definition
common_structs.h:2196
Matrix4f
f32 Matrix4f[4][4]
Definition
common_structs.h:135
general_heap_malloc
#define general_heap_malloc
Definition
effect_shims.h:51
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
guScaleF
#define guScaleF
Definition
effect_shims.h:45
EffectInstance::flags
s32 flags
Definition
effects.h:2602
EffectInstance::data
EffectInstanceDataPtr data
Definition
effects.h:2605
StaticStatusFXData::type
s32 type
Definition
effects.h:2065
EffectInstanceDataPtr::staticStatus
struct StaticStatusFXData * staticStatus
Definition
effects.h:2579
EffectInstance::numParts
s32 numParts
Definition
effects.h:2604
EffectInstance
Definition
effects.h:2601
StaticStatusFXData
Definition
effects.h:2064
effects_internal.h
ASSERT
#define ASSERT(condition)
Definition
effects_internal.h:8
FX_INSTANCE_FLAG_DISMISS
@ FX_INSTANCE_FLAG_DISMISS
Definition
enums.h:3551
RENDER_TASK_FLAG_REFLECT_FLOOR
@ RENDER_TASK_FLAG_REFLECT_FLOOR
Definition
enums.h:3352
RENDER_MODE_SURFACE_OPA
@ RENDER_MODE_SURFACE_OPA
Definition
enums.h:3298
VIRTUAL_TO_PHYSICAL
#define VIRTUAL_TO_PHYSICAL(addr)
Definition
macros.h:47
D_090003A0_3E1670
Gfx D_090003A0_3E1670[]
func_E00E651C
void func_E00E651C(void)
Definition
static_status.c:188
StaticEffectAlphaVals1
u8 StaticEffectAlphaVals1[]
Definition
static_status.c:28
static_status_appendGfx
void static_status_appendGfx(void *effect)
Definition
static_status.c:191
StaticEffectScaleVals0
f32 StaticEffectScaleVals0[]
Definition
static_status.c:13
static_status_main
EffectInstance * static_status_main(s32 type, f32 x, f32 y, f32 z, f32 scale, s32 numBolts, s32 duration)
Definition
static_status.c:38
static_status_init
void static_status_init(EffectInstance *effect)
Definition
static_status.c:90
StaticEffectFrameCount
s32 StaticEffectFrameCount[]
Definition
static_status.c:11
D_09000280_3E1550
Gfx D_09000280_3E1550[]
D_E00E6888
Gfx * D_E00E6888[]
Definition
static_status.c:8
StaticEffectAlphaVals0
u8 StaticEffectAlphaVals0[]
Definition
static_status.c:18
StaticEffectScaleVals1
f32 StaticEffectScaleVals1[]
Definition
static_status.c:23
D_E00E6880
Gfx * D_E00E6880[]
Definition
static_status.c:7
static_status_update
void static_status_update(EffectInstance *effect)
Definition
static_status.c:93
static_status_render
void static_status_render(EffectInstance *effect)
Definition
static_status.c:175
Camera
Definition
common_structs.h:753
EffectBlueprint
Definition
effects.h:2649
RenderTask
Definition
common_structs.h:1512
RenderTask::appendGfx
void(* appendGfx)(void *)
Definition
common_structs.h:1516
gCameras
Camera gCameras[4]
Definition
cam_main.c:16
gMainGfxPos
Gfx * gMainGfxPos
Definition
cam_main.c:14
gMatrixListPos
u16 gMatrixListPos
Definition
main_loop.c:44
gCurrentCameraID
s32 gCurrentCameraID
Definition
cam_math.c:5
gDisplayContext
DisplayContext * gDisplayContext
Definition
cam_main.c:15
src
effects
static_status.c
Generated by
1.10.0