Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
shape_spell.c
Go to the documentation of this file.
1#include "common.h"
2#include "effects_internal.h"
3
4typedef struct UnkStruct {
5 /* 0x00 */ u8 unk_00;
6 /* 0x01 */ u8 unk_01;
7 /* 0x02 */ u8 unk_02;
8 /* 0x03 */ u8 unk_03;
9 /* 0x04 */ Gfx* unk_04;
10 /* 0x08 */ Gfx* unk_08;
11} UnkStruct; // size = 0xC
12
13extern Gfx D_09001080_33AFE0[];
14extern Gfx D_09001128_33B088[];
15extern Gfx D_09001150_33B0B0[];
16extern Gfx D_09001178_33B0D8[];
17extern Gfx D_090011A0_33B100[];
18extern Gfx D_090011C8_33B128[];
19extern Gfx D_090011F0_33B150[];
20
22 { 0, 255, 208, 26, D_09001128_33B088, D_090011A0_33B100 },
23 { 120, 77, 208, 254, D_09001150_33B0B0, D_090011C8_33B128 },
24 { 240, 254, 76, 110, D_09001178_33B0D8, D_090011F0_33B150 }
25};
26
27void shape_spell_appendGfx(void* effect);
31
32EffectInstance* shape_spell_main(s32 isChild, f32 x, f32 y, f32 z, f32 arg4, f32 arg5, f32 arg6, s32 arg7) {
34 EffectBlueprint* bpPtr = &bp;
35 EffectInstance* effect;
36 ShapeSpellFXData* part;
37 s32 numParts = 1;
38
42 bp.unk_00 = 0;
43 bp.renderUI = NULL;
44 bp.effectID = EFFECT_SHAPE_SPELL;
45
46 effect = create_effect_instance(bpPtr);
47 effect->numParts = numParts;
48 part = effect->data.shapeSpell = general_heap_malloc(numParts * sizeof(*part));
49
50 ASSERT(effect->data.shapeSpell != NULL);
51
52 part->unk_2C = 0;
53 part->isChild = isChild;
54 part->unk_34 = 255;
55 part->pos.x = x;
56 part->pos.y = y;
57 part->pos.z = z;
58 part->unk_28 = 1.0f;
59 if (!isChild) {
60 part->unk_10 = 0;
61 part->unk_14 = 0.0f;
62 part->unk_18 = 0.0f;
63 part->timeLeft = arg7;
64 part->unk_1C = (arg4 - x) * (1.0f / arg7);
65 part->unk_20 = (arg5 - y) * (1.0f / arg7);
66 part->unk_24 = (arg6 - z) * (1.0f / arg7);
67 } else {
68 part->unk_10 = 29.f;
69 part->unk_14 = 0.0f;
70 part->unk_18 = 0.0f;
71 part->unk_1C = 6.2f;
72 part->unk_20 = 0.0f;
73 part->unk_24 = 0.0f;
74 part->timeLeft = 24;
75 }
76
77 return effect;
78}
79
81}
82
84 s32 flags = effect->flags;
85 ShapeSpellFXData* part = effect->data.shapeSpell;
86 s32 isChild;
87
89 effect->flags = flags & ~FX_INSTANCE_FLAG_DISMISS;
90 part->timeLeft = 0;
91 }
92
93 part->timeLeft--;
94 part->unk_2C++;
95
96 if (part->timeLeft < 0) {
97 remove_effect(effect);
98 return;
99 }
100
101 isChild = part->isChild;
102
103 if (!isChild && part->timeLeft == 0) {
105 1,
106 part->pos.x + part->unk_10,
107 part->pos.y + part->unk_14,
108 part->pos.z + part->unk_18,
109 0.0f, 0.0f, 0.0f, 0x18
110 )->data.shapeSpell;
111 newPart->unk_28 = part->unk_28;
112 }
113
114 if (isChild == TRUE) {
115 part->unk_34 = part->unk_34 * 0.9;
116 part->unk_1C = part->unk_1C * 0.83;
117 }
118 part->unk_10 += part->unk_1C;
119 part->unk_14 += part->unk_20;
120 part->unk_18 += part->unk_24;
121}
122
124 RenderTask renderTask;
125 RenderTask* retTask;
126
127 renderTask.appendGfx = shape_spell_appendGfx;
128 renderTask.appendGfxArg = effect;
129 renderTask.dist = 0;
131
132 retTask = queue_render_task(&renderTask);
134}
135
136s32 func_E0024324(s32 arg0, s32 arg1) {
137 s32 frameCounter = gGameStatusPtr->frameCounter * 32;
138
139 return (f32)((sin_deg(frameCounter + arg1) * (255 - arg0) + (255 - arg0)) * 0.5 + arg0);
140}
141
142s32 func_E00243BC(s32 arg0, s32 arg1) {
143 s32 frameCounter = gGameStatusPtr->frameCounter * 32;
144
145 arg1 += 180;
146
147 return (f32)((sin_deg(frameCounter + arg1) * -arg0 + -arg0) * 0.5 + arg0);
148}
149
150void shape_spell_appendGfx(void* effect) {
151 ShapeSpellFXData* data = ((EffectInstance*)effect)->data.shapeSpell;
152 s32 isChild;
153 Gfx* savedGfxPos2;
154 Gfx* savedGfxPos;
155 f32 unk_28 = data->unk_28;
156 s32 primA;
157 f32 unk_10;
158 f32 unk_14;
159 f32 unk_18;
160 f32 angle;
161 f32 factor;
162 f32 var_f30;
163 s32 timeLeft;
164 Matrix4f sp20;
165 Mtx* sp60[3];
166 Mtx* mtx;
167 s32 i;
168 s32 j;
169
170 gDPPipeSync(gMainGfxPos++);
171 gSPSegment(gMainGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(((EffectInstance*)effect)->graphics->data));
172 gSPDisplayList(gMainGfxPos++, D_09001080_33AFE0);
173
174 savedGfxPos = gMainGfxPos++;
175 savedGfxPos2 = gMainGfxPos;
176 isChild = data->isChild;
177 primA = data->unk_34;
178 unk_10 = data->unk_10;
179 unk_14 = data->unk_14;
180 unk_18 = data->unk_18;
181 timeLeft = data->timeLeft;
182
183 if (isChild == 0) {
184 angle = timeLeft * 35;
185 factor = 9.0f;
186 var_f30 = -gCameras[gCurrentCameraID].curYaw;
187 } else {
188 angle = timeLeft * 25;
189 factor = 6.0f;
190 var_f30 = 0.0f;
191 unk_10 *= unk_28;
192 }
193
194 for (i = 0; i < 3; i++) {
195 if (i > 0) {
196 if (!isChild) {
197 angle -= 70.0f;
198 unk_10 -= 2.0f * data->unk_1C;
199 unk_14 -= 2.0f * data->unk_20;
200 unk_18 -= 2.0f * data->unk_24;
201 } else {
202 angle -= 50.0f;
203 unk_10 -= data->unk_1C * (100.0 / 83) * 2.0;
204 }
205 primA = data->unk_34 * 100 / 255;
206 }
207
208 guPositionF(sp20, 0.0f, var_f30, 0.0f, unk_28, unk_10, unk_14, unk_18);
210
211 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
212
213 guTranslateF(sp20,
214 sin_deg(angle) * factor,
215 cos_deg(angle) * factor, 0.0f);
216
217 angle += 120.0f;
219
220 guMtxF2L(sp20, sp60[0]);
221 guTranslateF(sp20,
222 sin_deg(angle) * factor,
223 cos_deg(angle) * factor, 0.0f);
224
225 angle += 120.0f;
227
228 guMtxF2L(sp20, sp60[1]);
229 guTranslateF(sp20,
230 sin_deg(angle) * factor,
231 cos_deg(angle) * factor, 0.0f);
232
234
235 guMtxF2L(sp20, sp60[2]);
236
237 for (j = 0; j < 3; j++) {
238 gSPMatrix(gMainGfxPos++, sp60[j], G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
239 gDPSetPrimColor(gMainGfxPos++, 0, 0,
240 func_E00243BC(D_E0024CC0[j].unk_01, D_E0024CC0[j].unk_00),
241 func_E00243BC(D_E0024CC0[j].unk_02, D_E0024CC0[j].unk_00),
242 func_E00243BC(D_E0024CC0[j].unk_03, D_E0024CC0[j].unk_00),
243 primA);
244 gDPSetEnvColor(gMainGfxPos++,
245 func_E0024324(D_E0024CC0[j].unk_01, D_E0024CC0[j].unk_00),
246 func_E0024324(D_E0024CC0[j].unk_02, D_E0024CC0[j].unk_00),
247 func_E0024324(D_E0024CC0[j].unk_03, D_E0024CC0[j].unk_00),
248 255);
249 gSPDisplayList(gMainGfxPos++, !isChild ?
250 D_E0024CC0[j].unk_04 : D_E0024CC0[j].unk_08);
251 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
252 }
253
254 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
255 }
256
257 gSPEndDisplayList(gMainGfxPos++);
258 gSPBranchList(savedGfxPos, gMainGfxPos);
259
260 if (!isChild) {
261 var_f30 = 0.0f;
262 } else {
263 var_f30 = -gCameras[gCurrentCameraID].curYaw;
264 }
265
266 guPositionF(sp20, 0.0f, var_f30, 0.0f, 1.0f, data->pos.x, data->pos.y, data->pos.z);
268
269 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
270
271 if (!isChild) {
272 gSPDisplayList(gMainGfxPos++, savedGfxPos2);
273 } else {
274 guRotateF(sp20, 30.0f, 0.0f, 0.0f, 1.0f);
275
277 guMtxF2L(sp20, mtx);
278
279 for (i = 0; i < 12; i++) {
280 gSPMatrix(gMainGfxPos++, mtx, G_MTX_NOPUSH | G_MTX_MUL | G_MTX_MODELVIEW);
281 gSPDisplayList(gMainGfxPos++, savedGfxPos2);
282 }
283 }
284
285 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
286 gDPPipeSync(gMainGfxPos++);
287}
Mtx matrixStack[0x200]
f32 Matrix4f[4][4]
s8 unk_14
Definition demo_api.c:19
s8 flags
Definition demo_api.c:15
#define general_heap_malloc
#define guRotateF
#define queue_render_task
#define guMtxF2L
#define sin_deg
#define guTranslateF
#define remove_effect
#define guPositionF
#define cos_deg
#define create_effect_instance
struct ShapeSpellFXData * shapeSpell
Definition effects.h:2482
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
void shape_spell_update(EffectInstance *effect)
Definition shape_spell.c:83
void shape_spell_render(EffectInstance *effect)
Gfx D_090011F0_33B150[]
void shape_spell_init(EffectInstance *effect)
Definition shape_spell.c:80
s32 func_E0024324(s32 arg0, s32 arg1)
void shape_spell_appendGfx(void *effect)
Gfx D_09001178_33B0D8[]
Gfx D_09001080_33AFE0[]
Gfx D_090011C8_33B128[]
Gfx D_09001150_33B0B0[]
s32 func_E00243BC(s32 arg0, s32 arg1)
EffectInstance * shape_spell_main(s32 isChild, f32 x, f32 y, f32 z, f32 arg4, f32 arg5, f32 arg6, s32 arg7)
Definition shape_spell.c:32
Gfx D_09001128_33B088[]
Gfx D_090011A0_33B100[]
UnkStruct D_E0024CC0[]
Definition shape_spell.c:21
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 *)
GameStatus * gGameStatusPtr
Definition main_loop.c:32
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
Gfx * unk_04
Definition shape_spell.c:9
Gfx * unk_08
Definition shape_spell.c:10