Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
star_outline.c
Go to the documentation of this file.
1#include "common.h"
2#include "effects_internal.h"
3
4extern Gfx D_09000800_4147A0[];
5extern Gfx D_09000B20_414AC0[];
6extern Gfx D_09000B90_414B30[];
7
11
15void star_outline_appendGfx(void* effect);
16
17EffectInstance* star_outline_main(s32 arg0, f32 posX, f32 posY, f32 posZ, f32 arg4, s32 arg5) {
18 EffectBlueprint effectBp;
19 EffectInstance* effect;
21 s32 numParts = 1;
22
23 effectBp.init = star_outline_init;
24 effectBp.update = star_outline_update;
26 effectBp.unk_00 = 0;
27 effectBp.renderUI = NULL;
28 effectBp.effectID = EFFECT_STAR_OUTLINE;
29
30 effect = create_effect_instance(&effectBp);
31 effect->numParts = numParts;
32
33 data = effect->data.starOutline = general_heap_malloc(numParts * sizeof(*data));
34 ASSERT(data != NULL);
35
36 data->unk_00 = 1;
37 data->unk_02 = arg0;
38 data->lifeTime = 0;
39 if (arg5 <= 0) {
40 data->timeLeft = 1000;
41 } else {
42 data->timeLeft = arg5;
43 }
44 data->pos.x = posX;
45 data->pos.y = posY;
46 data->pos.z = posZ;
47 data->unk_38 = arg4;
48 data->unk_18 = 255;
49 data->unk_1C = 255;
50 data->unk_20 = 120;
51 data->unk_28 = 255;
52 data->unk_2C = 120;
53 data->unk_30 = 0;
54 data->unk_34 = 255;
55 data->unk_24 = 255;
56 data->unk_3C.x = 0;
57 data->unk_3C.y = 0;
58 data->unk_3C.z = 0;
59
60 return effect;
61}
62
65
67 StarOutlineFXData* data = effect->data.starOutline;
68 s32 temp_a2 = data->unk_02;
69 s32 lifeTime;
70 s32 temp;
71 s32 temp2;
72
73 if (effect->flags & FX_INSTANCE_FLAG_DISMISS) {
74 effect->flags &= ~FX_INSTANCE_FLAG_DISMISS;
75 data->timeLeft = 16;
76 }
77 if (data->timeLeft < 1000) {
78 data->timeLeft--;
79 }
80
81 data->lifeTime++;
82
83 if (data->timeLeft < 0) {
84 remove_effect(effect);
85 return;
86 }
87 lifeTime = data->lifeTime;
88 if (data->timeLeft < 16) {
89 temp = data->timeLeft * 16;
90 if (data->unk_24 > temp) {
91 data->unk_24 = temp;
92 }
93 if (data->unk_34 > temp) {
94 data->unk_34 = temp;
95 }
96 }
97 if (lifeTime < 16) {
98 temp2 = (lifeTime * 16) + 15;
99 if (data->unk_24 < temp2) {
100 data->unk_24 = temp2;
101 }
102 if (data->unk_34 < temp2) {
103 data->unk_34 = temp2;
104 }
105 }
106 data->unk_48 = data->unk_3C.x;
107 data->unk_4C = data->unk_3C.y;
108 data->unk_50 = data->unk_3C.z;
109 data->unk_54 = data->unk_38;
110 if (temp_a2 == 1) {
111 f32 lifetimeF = lifeTime;
112
113 data->unk_3C.x = lifeTime * 4;
114 data->unk_24 = 255;
115 data->unk_3C.y = (lifeTime * 4.0f * 0.4953);
116 data->unk_3C.z = (lifeTime * 4.0f * 0.2234);
117 data->unk_34 = ((sin_deg (lifetimeF * 7.12343)) * 127.0f) + 128.0f;
118 data->unk_18 = ((sin_deg (lifetimeF * 1.231)) * 127.0f) + 215.0f;
119 data->unk_1C = ((sin_deg (lifetimeF * 0.531)) * 127.0f) + 215.0f;
120 data->unk_20 = ((sin_deg (lifetimeF * 3.231)) * 127.0f) + 215.0f;
121 data->unk_28 = ((sin_deg (lifetimeF * 0.298)) * 127.0f) + 188.0f;
122 data->unk_2C = ((sin_deg (lifetimeF * 0.831)) * 127.0f) + 188.0f;
123 data->unk_30 = ((sin_deg (lifetimeF * 2.231)) * 127.0f) + 188.0f;
124 data->unk_38 = ((sin_deg (lifetimeF * 2.044)) * 0.3) + 0.7;
125 }
126 if (lifeTime == 1) {
127 data->unk_48 = data->unk_3C.x;
128 data->unk_4C = data->unk_3C.y;
129 data->unk_50 = data->unk_3C.z;
130 data->unk_54 = data->unk_38;
131 }
132}
133
135 RenderTask renderTask;
136 RenderTask* retTask;
137
139 renderTask.appendGfxArg = effect;
140 renderTask.dist = 10;
142
143 retTask = queue_render_task(&renderTask);
145}
146
147void star_outline_appendGfx(void* effect) {
148 StarOutlineFXData* data = ((EffectInstance*)effect)->data.starOutline;
149 s32 unk_18 = data->unk_18;
150 s32 unk_1C = data->unk_1C;
151 s32 unk_20 = data->unk_20;
152 s32 unk_24 = data->unk_24;
153 s32 unk_28 = data->unk_28;
154 s32 unk_2C = data->unk_2C;
155 s32 unk_30 = data->unk_30;
156 s32 unk_34 = data->unk_34;
157 Matrix4f sp20;
158 Matrix4f sp60;
159
160 if (unk_18 > 255) {
161 unk_18 = 255;
162 }
163 if (unk_1C > 255) {
164 unk_1C = 255;
165 }
166 if (unk_20 > 255) {
167 unk_20 = 255;
168 }
169 if (unk_24 > 255) {
170 unk_24 = 255;
171 }
172 if (unk_28 > 255) {
173 unk_28 = 255;
174 }
175 if (unk_2C > 255) {
176 unk_2C = 255;
177 }
178 if (unk_30 > 255) {
179 unk_30 = 255;
180 }
181 if (unk_34 > 255) {
182 unk_34 = 255;
183 }
184 if (unk_18 < 0) {
185 unk_18 = 0;
186 }
187 if (unk_1C < 0) {
188 unk_1C = 0;
189 }
190 if (unk_20 < 0) {
191 unk_20 = 0;
192 }
193 if (unk_24 < 0) {
194 unk_24 = 0;
195 }
196 if (unk_28 < 0) {
197 unk_28 = 0;
198 }
199 if (unk_2C < 0) {
200 unk_2C = 0;
201 }
202 if (unk_30 < 0) {
203 unk_30 = 0;
204 }
205 if (unk_34 < 0) {
206 unk_34 = 0;
207 }
208
209 gDPPipeSync(gMainGfxPos++);
210 gSPSegment(gMainGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(((EffectInstance*)effect)->graphics->data));
211 gSPDisplayList(gMainGfxPos++, D_E0126BC8[0]);
212
213 if (unk_34 != 0) {
214 guPositionF(sp20, 0.0f, -gCameras[gCurrentCameraID].curYaw, 0.0f, (f32) ((f64) data->unk_54 * 0.4), data->pos.x, data->pos.y, data->pos.z);
215 guPositionF(sp60, data->unk_48, data->unk_4C, data->unk_50, 1.0f, 0.0f, 0.0f, 0.0f);
216 guMtxCatF(sp60, sp20, sp20);
218
219 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
220
221 if (data->unk_00 == 0) {
222 gDPSetRenderMode(gMainGfxPos++, G_RM_CLD_SURF, G_RM_CLD_SURF2);
223 } else {
224 gDPSetRenderMode(gMainGfxPos++, G_RM_ZB_CLD_SURF, G_RM_ZB_CLD_SURF2);
225 }
226
227 gDPSetPrimColor(gMainGfxPos++, 0, 0, unk_18, unk_1C, unk_20, unk_34 >> 1);
228 gDPSetEnvColor(gMainGfxPos++, unk_28, unk_2C, unk_30, unk_34 >> 1);
229 gSPDisplayList(gMainGfxPos++, D_E0126BC4[0]);
230 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
231 }
232
233 guPositionF(sp20, 0.0f, -gCameras[gCurrentCameraID].curYaw, 0.0f, data->unk_38 * 0.4, data->pos.x, data->pos.y, data->pos.z);
234 guPositionF(sp60, data->unk_3C.x, data->unk_3C.y, data->unk_3C.z, 1.0f, 0.0f, 0.0f, 0.0f);
235 guMtxCatF(sp60, sp20, sp20);
237
238 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
239
240 if (unk_34 != 0) {
241 if (data->unk_00 == 0) {
242 gDPSetRenderMode(gMainGfxPos++, G_RM_CLD_SURF, G_RM_CLD_SURF2);
243 } else {
244 gDPSetRenderMode(gMainGfxPos++, G_RM_ZB_CLD_SURF, G_RM_ZB_CLD_SURF2);
245 }
246 gSPDisplayList(gMainGfxPos++, D_E0126BC4[0]);
247 }
248
249 if (data->unk_00 == 0) {
250 gDPSetRenderMode(gMainGfxPos++, G_RM_AA_XLU_SURF, G_RM_AA_XLU_SURF2);
251 } else {
252 gDPSetRenderMode(gMainGfxPos++, G_RM_AA_ZB_XLU_SURF, G_RM_AA_ZB_XLU_SURF2);
253 }
254
255 gDPSetPrimColor(gMainGfxPos++, 0, 0, unk_18, unk_1C, unk_20, unk_24);
256 gDPSetEnvColor(gMainGfxPos++, unk_28, unk_2C, unk_30, unk_24);
257 gSPDisplayList(gMainGfxPos++, D_E0126BC0[0]);
258 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
259}
Mtx matrixStack[0x200]
f32 Matrix4f[4][4]
#define general_heap_malloc
#define queue_render_task
#define guMtxF2L
#define sin_deg
#define guMtxCatF
#define remove_effect
#define guPositionF
#define create_effect_instance
struct StarOutlineFXData * starOutline
Definition effects.h:2597
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_CLOUD_NO_ZCMP
Definition enums.h:3311
#define VIRTUAL_TO_PHYSICAL(addr)
Definition macros.h:47
EffectInstance * star_outline_main(s32 arg0, f32 posX, f32 posY, f32 posZ, f32 arg4, s32 arg5)
void star_outline_render(EffectInstance *effect)
void star_outline_init(EffectInstance *effect)
void star_outline_appendGfx(void *effect)
Gfx * D_E0126BC4[]
Definition star_outline.c:9
Gfx D_09000B20_414AC0[]
Gfx * D_E0126BC8[]
Gfx D_09000800_4147A0[]
Gfx * D_E0126BC0[]
Definition star_outline.c:8
Gfx D_09000B90_414B30[]
void star_outline_update(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
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