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
4extern Gfx D_09000280_3E1550[];
5extern Gfx D_090003A0_3E1670[];
6
9
10// number of frames in animation for type 0 and type 1
11s32 StaticEffectFrameCount[] = { 24, 12 };
12
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
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
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
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
36void static_status_appendGfx(void* effect);
37
39 s32 type,
40 f32 x,
41 f32 y,
42 f32 z,
43 f32 scale,
44 s32 numBolts,
45 s32 duration)
46{
48 EffectInstance* effect;
50 f32 invisTime;
51 s32 i;
52
53 numBolts++;
54
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
92
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
176 RenderTask renderTask;
177 RenderTask* retTask;
178
180 renderTask.appendGfxArg = effect;
181 renderTask.dist = 10;
183
184 retTask = queue_render_task(&renderTask);
186}
187
188void func_E00E651C(void) {
189}
190
191void 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)->graphics->data));
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);
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);
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}
Mtx matrixStack[0x200]
f32 Matrix4f[4][4]
#define general_heap_malloc
#define queue_render_task
#define guMtxF2L
#define sin_deg
#define guTranslateF
#define guMtxCatF
#define remove_effect
#define guPositionF
#define cos_deg
#define create_effect_instance
#define guScaleF
struct StaticStatusFXData * staticStatus
Definition effects.h:2579
EffectData data
Definition effects.h:2605
#define ASSERT(condition)
@ FX_INSTANCE_FLAG_DISMISS
Definition enums.h:3517
@ RENDER_TASK_FLAG_REFLECT_FLOOR
Definition enums.h:3318
@ RENDER_MODE_SURFACE_OPA
Definition enums.h:3264
#define VIRTUAL_TO_PHYSICAL(addr)
Definition macros.h:47
Gfx D_090003A0_3E1670[]
void func_E00E651C(void)
u8 StaticEffectAlphaVals1[]
void static_status_appendGfx(void *effect)
f32 StaticEffectScaleVals0[]
EffectInstance * static_status_main(s32 type, f32 x, f32 y, f32 z, f32 scale, s32 numBolts, s32 duration)
void static_status_init(EffectInstance *effect)
s32 StaticEffectFrameCount[]
Gfx D_09000280_3E1550[]
Gfx * D_E00E6888[]
u8 StaticEffectAlphaVals0[]
f32 StaticEffectScaleVals1[]
Gfx * D_E00E6880[]
void static_status_update(EffectInstance *effect)
void static_status_render(EffectInstance *effect)
Mtx * mtxBillboard
void(* renderUI)(EffectInstance *effectInst)
Definition effects.h:2655
void(* init)(EffectInstance *effectInst)
Definition effects.h:2652
void(* update)(EffectInstance *effectInst)
Definition effects.h:2653
void(* renderWorld)(EffectInstance *effectInst)
Definition effects.h:2654
void * appendGfxArg
void(* appendGfx)(void *)
Camera gCameras[4]
Definition cam_main.c:17
Gfx * gMainGfxPos
Definition cam_main.c:15
u16 gMatrixListPos
Definition main_loop.c:45
s32 gCurrentCameraID
Definition cam_math.c:4
DisplayContext * gDisplayContext
Definition cam_main.c:16