Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
big_smoke_puff.c
Go to the documentation of this file.
1#include "common.h"
2#include "effects_internal.h"
3
4static f32 D_E0002760[10] = { 10.0f, 40.0f, 80.0f, 170.0f, 140.0f, 100.0f, 25.0f, 155.0f, 60.0f, 120.0f };
5static f32 D_E0002788[10] = { 2.2f, 2.7f, 3.0f, 2.2f, 2.7f, 3.0f, 1.9f, 1.9f, 1.5f, 1.5f };
6static f32 sPartScales[10] = { 1.4f, 1.3f, 1.2f, 1.3f, 1.4f, 1.3f, 1.6f, 1.6f, 1.6f, 1.6f };
7static f32 sPartYaws[10] = { 0.0f, 234.0f, 468.0f, 702.0f, 936.0f, 1260.0f, 1404.0f, 1638.0f, 1902.0f, 1976.0f };
8
9extern Gfx D_09000FA0_3273B0[];
10extern Gfx D_09001060_327470[];
11extern Gfx D_09001120_327530[];
12extern Gfx D_090011E0_3275F0[];
13extern Gfx D_090012A0_3276B0[];
14extern Gfx D_09001360_327770[];
15extern Gfx D_09001420_327830[];
16
17static Gfx* sDlists[7] = {
20};
21
25void big_smoke_puff_appendGfx(void* effect);
26
27void big_smoke_puff_main(f32 x, f32 y, f32 z) {
29 EffectInstance* effect;
31 f32 theta;
32 f32 temp_f20;
33 f32 cosTheta;
34 f32 sinTheta;
35 s32 numParts = 10;
36 s32 i;
37
38 bp.unk_00 = 0;
42 bp.renderUI = NULL;
43 bp.effectID = EFFECT_BIG_SMOKE_PUFF;
44
45 effect = create_effect_instance(&bp);
46 effect->numParts = numParts;
47
48 data = general_heap_malloc(effect->numParts * sizeof(*data));
49 effect->data.bigSmokePuff = data;
50
51 ASSERT(data != NULL);
52
53 for (i = 0; i < effect->numParts; i++, data++) {
54 data->unk_00 = 0;
55 data->unk_02 = data->unk_04 = effect_rand_int(6) + 0x10;
56 data->unk_06 = 4;
57 data->unk_08 = 0;
58 data->x = x;
59 data->y = y;
60 data->z = z;
61 data->partX = 0;
62 data->partY = 0;
63
64 theta = D_E0002760[i] + 90.0f;
65 temp_f20 = 2.0 * D_E0002788[i];
66 sinTheta = sin_deg(theta);
67 cosTheta = cos_deg(theta);
68
69 data->unk_20 = temp_f20 * sinTheta;
70 data->unk_24 = -temp_f20 * cosTheta;
71 }
72}
73
76
78 BigSmokePuffFXData* data = effect->data.bigSmokePuff;
79 s32 cond = FALSE;
80 s32 i;
81
82 for (i = 0; i < effect->numParts; i++, data++) {
83 if (data->unk_02 >= 0) {
84 data->unk_08--;
85
86 if (data->unk_08 < 0) {
87 data->partX += data->unk_20;
88 data->partY += data->unk_24;
89 data->unk_00++;
90 data->unk_02--;
91 cond = TRUE;
92
93 if (data->unk_02 >= 0) {
94 data->unk_06--;
95 if (data->unk_06 < 0) {
96 data->unk_20 /= 1.25;
97 data->unk_24 /= 1.25;
98 }
99 }
100 }
101 }
102 }
103
104 if (!cond) {
105 remove_effect(effect);
106 }
107}
108
110 RenderTask renderTask;
111 RenderTask* retTask;
112
114 renderTask.appendGfxArg = effect;
115 renderTask.dist = 0;
117
118 retTask = queue_render_task(&renderTask);
120}
121
122void big_smoke_puff_appendGfx(void* effect) {
123 EffectInstance* eff = (EffectInstance*)effect;
124 BigSmokePuffFXData* data = ((EffectInstance*)effect)->data.bigSmokePuff;
125 Matrix4f mtx;
126 s32 i;
127
128 gDPPipeSync(gMainGfxPos++);
129 gSPSegment(gMainGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(((EffectInstance*)effect)->graphics->data));
130
131 guPositionF(mtx, 0.0f, -gCameras[gCurrentCameraID].curYaw, 0.0f, 1.0f, data->x, data->y, data->z);
133
134 gSPMatrix(gMainGfxPos++,
135 &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
136
137 for (i = 0; i < ((EffectInstance*)effect)->numParts; i++, data++) {
138 if (data->unk_02 >= 0 && data->unk_08 < 0) {
139 s32 primAlpha = data->unk_02;
140 f32 temp_f12;
141 s32 envAlpha;
142 Gfx* dlist;
143
144 if (primAlpha > 16) {
145 primAlpha = 16;
146 }
147
148 guPositionF(mtx, 0.0f, 0.0f, sPartYaws[i], sPartScales[i], data->partX,
149 data->partY, 0.0f);
151
152 gSPMatrix(gMainGfxPos++,
153 &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
154
155 temp_f12 = data->unk_00 - 1;
156
157 if (data->unk_04 <= temp_f12) {
158 envAlpha = 255;
159 dlist = sDlists[ARRAY_COUNT(sDlists) - 1];
160 } else {
161 f32 temp = sin_deg((((temp_f12 * 7.0f) / data->unk_04) * 90.0f) / 7.0f) * 7.0f;
162
163 envAlpha = (s32)(temp * 255.0f) % 256;
164 dlist = sDlists[(s32)temp];
165 }
166
167 gDPSetPrimColor(gMainGfxPos++, 0, 0, 0, 0, 0, (u32)(primAlpha * 105) / 8);
168 gDPSetEnvColor(gMainGfxPos++, 0, 0, 0, envAlpha);
169 gSPDisplayList(gMainGfxPos++, dlist);
170 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
171 }
172 }
173
174 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
175 gDPPipeSync(gMainGfxPos++);
176}
177
179 remove_effect(effect);
180}
void big_smoke_puff_update(EffectInstance *effect)
Gfx D_090012A0_3276B0[]
void big_smoke_puff_render(EffectInstance *effect)
Gfx D_09001360_327770[]
Gfx D_09001120_327530[]
void func_E0002738(EffectInstance *effect)
Gfx D_090011E0_3275F0[]
Gfx D_09001420_327830[]
Gfx D_09001060_327470[]
Gfx D_09000FA0_3273B0[]
void big_smoke_puff_appendGfx(void *effect)
void big_smoke_puff_main(f32 x, f32 y, f32 z)
void big_smoke_puff_init(EffectInstance *effect)
Mtx matrixStack[0x200]
f32 Matrix4f[4][4]
#define general_heap_malloc
#define queue_render_task
#define guMtxF2L
#define sin_deg
#define remove_effect
#define guPositionF
#define cos_deg
#define create_effect_instance
struct BigSmokePuffFXData * bigSmokePuff
Definition effects.h:2465
EffectData data
Definition effects.h:2605
#define ASSERT(condition)
s32 effect_rand_int(s32)
@ RENDER_TASK_FLAG_REFLECT_FLOOR
Definition enums.h:3318
@ RENDER_MODE_CLOUD_NO_ZCMP
Definition enums.h:3311
#define ARRAY_COUNT(arr)
Definition macros.h:40
#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