Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
landing_dust.c
Go to the documentation of this file.
1#include "common.h"
2#include "effects_internal.h"
3
4extern Gfx D_09002780_32B620[];
5extern Gfx D_09002868_32B708[];
6extern Gfx D_09002950_32B7F0[];
7extern Gfx D_09002A38_32B8D8[];
8extern Gfx D_09002B20_32B9C0[];
9extern Gfx D_09002B40_32B9E0[];
10extern Gfx D_09002B60_32BA00[];
11
14
15static s8 D_E000CC38[] = { 0x00, 0x01, 0x02, 0x1A, 0x03, 0x1B, 0x04, 0x1C, 0x05, 0x15, 0x35, 0x46, 0x46, 0x46, 0xFF,
16 0x00 };
17
18static s8 D_E000CC48[] = { 0x00, 0x01, 0x02, 0x1A, 0x03, 0x1B, 0x04, 0x1C, 0x05, 0x1D, 0x06, 0x16, 0x26, 0x47, 0x57,
19 0x67, 0xFF, 0x00, 0x00, 0x00 };
20
21static s8 D_E000CC5C[] = {
22 0x00, 0x08, 0x10, 0x18, 0x20, 0x28, 0x30, 0x38, 0x01, 0x09, 0x11, 0x19, 0x21, 0x29, 0x31, 0x39, 0x02, 0x02, 0x0A,
23 0x0A, 0x12, 0x12, 0x1A, 0x1A, 0x22, 0x22, 0x2A, 0x2A, 0x32, 0x32, 0x3A, 0x3A, 0x03, 0x03, 0x0B, 0x0B, 0x13, 0x13,
24 0x1B, 0x1B, 0x23, 0x23, 0x2B, 0x2B, 0x33, 0x33, 0x3B, 0x3B, 0x04, 0x04, 0x0C, 0x0C, 0x14, 0x14, 0x1C, 0x1C, 0x24,
25 0x24, 0x2C, 0x2C, 0x34, 0x34, 0x3C, 0x3C, 0x05, 0x05, 0x0D, 0x0D, 0x15, 0x15, 0x1D, 0x1D, 0x25, 0x25, 0x2D, 0x2D,
26 0x35, 0x35, 0x3D, 0x3D, 0x06, 0x06, 0x06, 0x0E, 0x0E, 0x0E, 0x16, 0x16, 0x16, 0x1E, 0x1E, 0x1E, 0x26, 0x26, 0x26,
27 0x2E, 0x2E, 0x2E, 0x36, 0x36, 0x36, 0x3E, 0x3E, 0x3E, 0x47, 0x47, 0x47, 0x4F, 0x4F, 0x4F, 0x57, 0x57, 0x57, 0x5F,
28 0x5F, 0x5F, 0x67, 0x67, 0x67, 0x6F, 0x6F, 0x6F, 0x77, 0x77, 0x77, 0x7F, 0x7F, 0x7F, 0xFF, 0x00, 0x00, 0x00
29};
30
31static s8 D_E000CCE0[] = { 0x00, 0x10, 0x20, 0x30, 0x01, 0x11, 0x21, 0x31, 0x02, 0x0A, 0x12, 0x1A, 0x22, 0x2A, 0x32,
32 0x3A, 0x03, 0x0B, 0x13, 0x1B, 0x23, 0x2B, 0x33, 0x3B, 0x04, 0x0C, 0x14, 0x1C, 0x24, 0x2C,
33 0x34, 0x3C, 0x05, 0x0D, 0x15, 0x1D, 0x25, 0x2D, 0x35, 0x3D, 0x06, 0x06, 0x0E, 0x16, 0x16,
34 0x1E, 0x26, 0x26, 0x2E, 0x36, 0x36, 0x3E, 0x47, 0x47, 0x4F, 0x57, 0x57, 0x5F, 0x67, 0x67,
35 0x6F, 0x77, 0x77, 0x7F, 0xFF, 0x00, 0x00, 0x00 };
36
37static s8* D_E000CD24[4] = { D_E000CC38, D_E000CC48, D_E000CC5C, D_E000CCE0 };
38
42void landing_dust_appendGfx(void* effect);
43
45 part->unk_18 += part->unk_1C;
46 part->unk_14 += part->unk_18;
47 part->unk_10 += part->unk_14;
48 part->x += part->unk_10 * part->unk_30;
49 part->z += part->unk_10 * part->unk_34;
50 part->unk_28 += part->unk_2C;
51 part->unk_24 += part->unk_28;
52 part->unk_20 += part->unk_24;
53 part->y += part->unk_20;
54}
55
57 part->y += part->unk_20;
58 part->unk_20 += part->unk_24;
59 part->unk_24 *= part->unk_28;
60}
61
63 part->x += part->unk_10 * part->unk_30;
64 part->y += part->unk_20;
65 part->z += part->unk_10 * part->unk_34;
66 part->unk_20 += part->unk_24;
67 part->unk_10 *= part->unk_14;
68 part->unk_24 *= part->unk_28;
69 part->unk_20 *= part->unk_2C;
70}
71
72void landing_dust_main(s32 type, f32 x, f32 y, f32 z, f32 angle) {
74 EffectBlueprint* bpPtr = &bp;
75 EffectInstance* effect;
77 f32 theta;
78 f32 temp_f20_2;
79 s32 numParts;
80 s32 i;
81
82 switch (type) {
83 case 2:
84 numParts = 1;
85 break;
86 case 3:
87 numParts = 4;
88 break;
89 case 4:
90 numParts = 9;
91 break;
92 default:
93 numParts = 3;
94 break;
95 }
96
97 bpPtr->init = landing_dust_init;
100 bpPtr->unk_00 = 0;
101 bpPtr->renderUI = NULL;
102 bpPtr->effectID = EFFECT_LANDING_DUST;
103
104 effect = create_effect_instance(bpPtr);
105 effect->numParts = numParts;
106
107 data = general_heap_malloc(numParts * sizeof(*data));
108 effect->data.landingDust = data;
109 ASSERT(effect->data.landingDust != NULL);
110
111 mem_clear(data, numParts * sizeof(*data));
112
113 switch (type) {
114 case 0:
115 case 1:
116 data->unk_38 = 0;
117 break;
118 case 3:
119 data->unk_38 = 2;
120 break;
121 case 2:
122 case 4:
123 data->unk_38 = 3;
124 break;
125 }
126
127 data->unk_3C = 0;
128 data->type = type;
129 data->x = x;
130 data->y = y;
131 data->z = z;
132
133 data++;
134
135 switch (type) {
136 case 0:
137 case 1:
138 for (i = 1; i < numParts; i++, data++) {
139 data->unk_10 = -3.0f;
140 data->unk_14 = 0.29999998f;
141 data->unk_18 = 0;
142 data->unk_1C = 0;
143 data->unk_20 = 1.75f;
144 data->unk_24 = -0.16f;
145 data->unk_28 = 0.0f;
146 data->unk_2C = 0.0f;
147 data->x = 0.0f;
148 data->y = 0.0f;
149 data->z = 4.0f;
150 theta = clamp_angle(90 + (180 * (i - 1)));
151 data->unk_30 = sin_deg(theta);
152 data->unk_34 = cos_deg(theta);
153 }
154 break;
155 case 2:
156 break;
157 case 3:
158 for (i = 1; i < numParts; i++, data++) {
159 switch (i - 1) {
160 case 0:
161 theta = 135.0f;
162 data->x = -sin_deg(theta) * 25.0f;
163 data->y = 0.0f;
164 data->z = -cos_deg(theta) * 25.0f;
165 data->unk_24 = -0.04f;
166 data->unk_28 = 0.94f;
167 data->unk_20 = 0.95f;
168 break;
169 case 1:
170 theta = -135.0f;
171 data->x = -sin_deg(theta) * 25.0f;
172 data->y = 4.0f;
173 data->z = -cos_deg(theta) * 25.0f;
174 data->unk_24 = -0.04f;
175 data->unk_28 = 0.94f;
176 data->unk_20 = 0.84999996f;
177 break;
178 case 2:
179 theta = 20.0f;
180 data->x = -sin_deg(theta) * 25.0f;
181 data->y = 10.0f;
182 data->z = -cos_deg(theta) * 25.0f;
183 data->unk_24 = -0.04f;
184 data->unk_28 = 0.94f;
185 data->unk_20 = 0.75f;
186 break;
187
188 }
189 data->unk_30 = 0.0f;
190 data->unk_34 = 0.0f;
191 }
192 break;
193 case 4:
194 for (i = 1; i < numParts; i++, data++) {
195 data->unk_10 = -3.0f;
196 data->unk_14 = 0.93f;
197 data->unk_20 = 0.0f;
198 data->unk_24 = 0.099999994f;
199 data->unk_28 = 0.94f;
200 data->unk_2C = 0.94f;
201 theta = angle + ((i - 1) * 360 / (numParts - 1));
202 data->x = -sin_deg(theta) * 10.0f;
203 data->y = 0.0f;
204 data->z = -cos_deg(theta) * 10.0f;
205 data->unk_30 = sin_deg(theta);
206 data->unk_34 = cos_deg(theta);
207 }
208 break;
209 }
210}
211
214
216 LandingDustFXData* data = effect->data.landingDust;
217
218 data->unk_40 = D_E000CD24[data->unk_38][data->unk_3C++];
219
220 if (data->unk_40 < 0) {
221 remove_effect(effect);
222 } else {
223 s32 type = data->type;
224 s32 i;
225
226 data++;
227
228 for (i = 1; i < effect->numParts; i++, data++) {
229 switch (type) {
230 case 0:
231 case 1:
232 func_E000C000(data);
233 break;
234 case 2:
235 break;
236 case 3:
237 func_E000C094(data);
238 break;
239 case 4:
240 func_E000C0C8(data);
241 break;
242 }
243 }
244 }
245}
246
248 RenderTask renderTask;
249 RenderTask* retTask;
250
252 renderTask.appendGfxArg = effect;
253 renderTask.dist = 0;
255
256 retTask = queue_render_task(&renderTask);
258}
259
260void landing_dust_appendGfx(void* effect) {
261 LandingDustFXData* part = ((EffectInstance*)effect)->data.landingDust;
262 s32 type = part->type;
263 s32 temp_t0 = part->unk_40;
264 Matrix4f mtx1;
265 Matrix4f mtx2;
266 Matrix4f mtx3;
267 s32 spD8;
268 s32 spDC;
269 s32 temp_lo;
270 s32 envAlpha;
271 Gfx* dlist1;
272 Gfx* dlist2;
273 s32 phi_a0;
274 s32 temp;
275 s32 i;
276
277 envAlpha = (temp_t0 & 0x38) * 4;
278
279 dlist1 = sDlists[type];
280 dlist2 = sDlists2[type];
281
282 gDPPipeSync(gMainGfxPos++);
283 gSPSegment(gMainGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(((EffectInstance*)effect)->graphics->data));
284 gSPDisplayList(gMainGfxPos++, dlist2);
285
286 spD8 = temp_t0 & 7;
287 spDC = temp_t0 & 0x40;
288
289 guTranslateF(mtx1, part->x, part->y, part->z);
290 guRotateF(mtx2, -gCameras[gCurrentCameraID].curYaw, 0.0f, 1.0f, 0.0f);
291 guMtxCatF(mtx2, mtx1, mtx3);
293
294 gSPMatrix(gMainGfxPos++,
295 &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
296
297 switch (type) {
298 case 0:
299 case 1:
300 gDPSetPrimColor(gMainGfxPos++, 0, 0, 230, 222, 222, 110);
301 gDPSetEnvColor(gMainGfxPos++, 0, 0, 0, envAlpha);
302 break;
303 case 2:
304 case 3:
305 case 4:
306 gDPSetPrimColor(gMainGfxPos++, 0, 0, 230, 222, 222, 130);
307 gDPSetEnvColor(gMainGfxPos++, 0, 0, 0, envAlpha);
308 break;
309 }
310
311 if (type == 0) {
312 phi_a0 = 24;
313 } else {
314 phi_a0 = 32;
315 }
316
317 temp_lo = spD8 * phi_a0;
318 temp = temp_lo + phi_a0;
319
320 gDPSetTileSize(gMainGfxPos++, G_TX_RENDERTILE, temp_lo * 4, 0, temp * 4, phi_a0 * 4);
321
322 if (spDC) {
323 gDPSetTileSize(gMainGfxPos++, 1, temp * 4, phi_a0 * 4, (temp_lo + (phi_a0 * 2)) * 4, phi_a0 * 8);
324 } else {
325 gDPSetTileSize(gMainGfxPos++, 1, temp * 4, 0, (temp_lo + (phi_a0 * 2)) * 4, phi_a0 * 4);
326 }
327
328 if (type == 2) {
329 gSPDisplayList(gMainGfxPos++, dlist1);
330 }
331
332 part++;
333
334 for (i = 1; i < ((EffectInstance*)effect)->numParts; i++, part++) {
335 guTranslateF(mtx1, part->x, part->y, part->z);
338 G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
339 gSPDisplayList(gMainGfxPos++, dlist1);
340 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
341 }
342
343 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
344 gDPPipeSync(gMainGfxPos++);
345}
Mtx matrixStack[0x200]
f32 Matrix4f[4][4]
#define general_heap_malloc
#define guRotateF
#define queue_render_task
#define guMtxF2L
#define sin_deg
#define guTranslateF
#define guMtxCatF
#define remove_effect
#define clamp_angle
#define cos_deg
#define create_effect_instance
#define mem_clear
struct LandingDustFXData * landingDust
Definition effects.h:2470
EffectData data
Definition effects.h:2605
#define ASSERT(condition)
@ RENDER_TASK_FLAG_REFLECT_FLOOR
Definition enums.h:3318
@ RENDER_MODE_PASS_THROUGH
Definition enums.h:3306
void landing_dust_render(EffectInstance *effect)
Gfx D_09002950_32B7F0[]
Gfx D_09002780_32B620[]
void landing_dust_appendGfx(void *effect)
void landing_dust_init(EffectInstance *effect)
Gfx D_09002B40_32B9E0[]
Gfx D_09002B20_32B9C0[]
void func_E000C000(LandingDustFXData *part)
Gfx D_09002A38_32B8D8[]
Gfx D_09002B60_32BA00[]
void func_E000C0C8(LandingDustFXData *part)
Gfx D_09002868_32B708[]
void func_E000C094(LandingDustFXData *part)
void landing_dust_main(s32 type, f32 x, f32 y, f32 z, f32 angle)
void landing_dust_update(EffectInstance *effect)
#define VIRTUAL_TO_PHYSICAL(addr)
Definition macros.h:47
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