Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
static_status.c File Reference

Go to the source code of this file.

Functions

void static_status_init (EffectInstance *effect)
 
void static_status_update (EffectInstance *effect)
 
void static_status_render (EffectInstance *effect)
 
void static_status_appendGfx (void *effect)
 
EffectInstancestatic_status_main (s32 type, f32 x, f32 y, f32 z, f32 scale, s32 numBolts, s32 duration)
 
void func_E00E651C (void)
 

Variables

Gfx D_09000280_3E1550 []
 
Gfx D_090003A0_3E1670 []
 
Gfx * D_E00E6880 [] = { D_090003A0_3E1670, D_090003A0_3E1670 }
 
Gfx * D_E00E6888 [] = { D_09000280_3E1550, D_09000280_3E1550 }
 
s32 StaticEffectFrameCount [] = { 24, 12 }
 
f32 StaticEffectScaleVals0 []
 
u8 StaticEffectAlphaVals0 []
 
f32 StaticEffectScaleVals1 []
 
u8 StaticEffectAlphaVals1 []
 

Function Documentation

◆ static_status_init()

void static_status_init ( EffectInstance * effect)

Definition at line 90 of file static_status.c.

90 {
91}

Referenced by static_status_main().

◆ static_status_update()

void static_status_update ( EffectInstance * effect)

Definition at line 93 of file static_status.c.

93 {
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}
#define sin_deg
#define remove_effect
#define cos_deg
struct StaticStatusFXData * staticStatus
Definition effects.h:2579
EffectData data
Definition effects.h:2605
@ FX_INSTANCE_FLAG_DISMISS
Definition enums.h:3517
u8 StaticEffectAlphaVals1[]
f32 StaticEffectScaleVals0[]
s32 StaticEffectFrameCount[]
u8 StaticEffectAlphaVals0[]
f32 StaticEffectScaleVals1[]

Referenced by static_status_main().

◆ static_status_render()

void static_status_render ( EffectInstance * effect)

Definition at line 175 of file static_status.c.

175 {
176 RenderTask renderTask;
177 RenderTask* retTask;
178
180 renderTask.appendGfxArg = effect;
181 renderTask.dist = 10;
183
184 retTask = queue_render_task(&renderTask);
186}
#define queue_render_task
@ RENDER_TASK_FLAG_REFLECT_FLOOR
Definition enums.h:3318
@ RENDER_MODE_SURFACE_OPA
Definition enums.h:3264
void static_status_appendGfx(void *effect)
void * appendGfxArg
void(* appendGfx)(void *)

Referenced by static_status_main().

◆ static_status_appendGfx()

void static_status_appendGfx ( void * effect)

Definition at line 191 of file static_status.c.

191 {
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 guMtxF2L
#define guTranslateF
#define guMtxCatF
#define guPositionF
#define guScaleF
#define VIRTUAL_TO_PHYSICAL(addr)
Definition macros.h:47
Gfx * D_E00E6888[]
Gfx * D_E00E6880[]
Mtx * mtxBillboard
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

Referenced by static_status_render().

◆ static_status_main()

EffectInstance * static_status_main ( s32 type,
f32 x,
f32 y,
f32 z,
f32 scale,
s32 numBolts,
s32 duration )

Definition at line 38 of file static_status.c.

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}
#define general_heap_malloc
#define create_effect_instance
#define ASSERT(condition)
void static_status_init(EffectInstance *effect)
void static_status_update(EffectInstance *effect)
void static_status_render(EffectInstance *effect)
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

◆ func_E00E651C()

void func_E00E651C ( void )

Definition at line 188 of file static_status.c.

188 {
189}

Variable Documentation

◆ D_09000280_3E1550

Gfx D_09000280_3E1550[]
extern

◆ D_090003A0_3E1670

Gfx D_090003A0_3E1670[]
extern

◆ D_E00E6880

Gfx* D_E00E6880[] = { D_090003A0_3E1670, D_090003A0_3E1670 }

Definition at line 7 of file static_status.c.

Gfx D_090003A0_3E1670[]

Referenced by static_status_appendGfx().

◆ D_E00E6888

Gfx* D_E00E6888[] = { D_09000280_3E1550, D_09000280_3E1550 }

Definition at line 8 of file static_status.c.

Gfx D_09000280_3E1550[]

Referenced by static_status_appendGfx().

◆ StaticEffectFrameCount

s32 StaticEffectFrameCount[] = { 24, 12 }

Definition at line 11 of file static_status.c.

11{ 24, 12 };

Referenced by static_status_main(), and static_status_update().

◆ StaticEffectScaleVals0

f32 StaticEffectScaleVals0[]
Initial value:
= {
0.9f, 1.0f, 1.0f, 0.9f, 0.85f, 0.8f, 0.75f, 0.7f, 0.65f, 0.6f, 0.55f, 0.5f,
0.45f, 0.4f, 0.35f, 0.3f, 0.25f, 0.2f, 0.15f, 0.1f, 0.05f, 0.03f, 0.02f, 0.01f
}

Definition at line 13 of file static_status.c.

13 {
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};

Referenced by static_status_update().

◆ StaticEffectAlphaVals0

u8 StaticEffectAlphaVals0[]
Initial value:
= {
0xFA, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
}

Definition at line 18 of file static_status.c.

18 {
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};

Referenced by static_status_update().

◆ StaticEffectScaleVals1

f32 StaticEffectScaleVals1[]
Initial value:
= {
0.9f, 1.0f, 1.0f, 0.9f, 0.8f, 0.7f, 0.6f, 0.5f, 0.4f, 0.3f, 0.2f, 0.1f,
0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f
}

Definition at line 23 of file static_status.c.

23 {
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};

Referenced by static_status_update().

◆ StaticEffectAlphaVals1

u8 StaticEffectAlphaVals1[]
Initial value:
= {
0xFA, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
}

Definition at line 28 of file static_status.c.

28 {
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};

Referenced by static_status_update().