Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
smoke_impact.c
Go to the documentation of this file.
1#include "common.h"
2#include "effects_internal.h"
3
4extern Gfx D_09002A38_32B8D8[];
5extern Gfx D_09002B60_32BA00[];
6extern Gfx D_09002B80_32BA20[];
7
11
15
19void smoke_impact_appendGfx(void* effect);
20
22 s32 arg0,
23 f32 arg1,
24 f32 arg2,
25 f32 arg3,
26 f32 arg4,
27 s32 arg5,
28 f32 arg6,
29 s32 arg7
30) {
32 EffectInstance* effect;
34 s32 i;
35
36 arg5++;
37
41 bp.unk_00 = 0;
42 bp.renderUI = NULL;
43 bp.effectID = EFFECT_SMOKE_IMPACT;
44
45 effect = create_effect_instance(&bp);
46 effect->numParts = arg5;
47 part = effect->data.smokeImpact = general_heap_malloc(arg5 * sizeof(*part));
48 ASSERT(effect->data.smokeImpact != NULL);
49
50 mem_clear(part, arg5 * sizeof(*part));
51
52 part->unk_24 = arg7;
53 part->unk_28 = 0;
54 part->unk_2C = arg7;
55 part->unk_30 = 0;
56 part->unk_00 = arg0;
57 part->unk_04 = arg1;
58 part->unk_08 = arg2;
59 part->unk_0C = arg3;
60 part->unk_20 = arg4;
61 part->unk_1C = 10.0f;
62
63 part++;
64 for (i = 1; i < arg5; i++, part++) {
65 f32 angle = arg6 + (i - 1) * 360 / (arg5 - 1);
66
67 part->unk_04 = 0;
68 part->unk_08 = 0;
69 part->unk_0C = 0;
70 part->unk_10 = sin_deg(angle);
71 part->unk_14 = 0;
72 part->unk_18 = cos_deg(angle);
73 }
74}
75
78
80 SmokeImpactFXData* part = effect->data.smokeImpact;
81 f32 unk_1C;
82 s32 i;
83
84 part->unk_30 = part->unk_28 * 8.0f / part->unk_2C;
85 part->unk_28++;
86 part->unk_24--;
87
88 if (part->unk_24 < 0) {
89 remove_effect(effect);
90 return;
91 }
92
93 part->unk_1C += (part->unk_20 - part->unk_1C) * 0.1;
94 unk_1C = part->unk_1C;
95
96 part++;
97 for (i = 1; i < effect->numParts; i++, part++) {
98 part->unk_14 += 0.04;
99 part->unk_14 *= 0.9;
100 part->unk_04 = unk_1C * part->unk_10;
101 part->unk_08 += part->unk_14;
102 part->unk_0C = unk_1C * part->unk_18;
103 }
104}
105
107 RenderTask renderTask;
108 RenderTask* retTask;
109
111 renderTask.appendGfxArg = effect;
112 renderTask.dist = 0;
114
115 retTask = queue_render_task(&renderTask);
117}
118
119void smoke_impact_appendGfx(void* effect) {
120 SmokeImpactFXData* part = ((EffectInstance*)effect)->data.smokeImpact;
121 s32 unk_00 = part->unk_00;
122 f32 unk_30 = part->unk_30;
123 s32 unk_30_s32 = unk_30;
124 s32 envAlpha = (unk_30 - unk_30_s32) * 256.0f;
125 Gfx* dlist = D_E003A800[unk_00];
126 Gfx* dlist2 = D_E003A80C[unk_00];
127 s32 cond = (unk_30_s32 == 7);
128 Matrix4f sp18;
129 Matrix4f sp58;
130 Matrix4f sp98;
131 s32 i;
132
133 gDPPipeSync(gMainGfxPos++);
134 gSPSegment(gMainGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(((EffectInstance*)effect)->graphics->data));
135 gSPDisplayList(gMainGfxPos++, dlist2);
136
137 guTranslateF(sp18, part->unk_04, part->unk_08, part->unk_0C);
138 guRotateF(sp58, -gCameras[gCurrentCameraID].curYaw, 0.0f, 1.0f, 0.0f);
139 guMtxCatF(sp58, sp18, sp98);
141
142 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
143
144 if (unk_00 < 2) {
145 gDPSetPrimColor(gMainGfxPos++, 0, 0, 230, 222, 222, 130);
146 } else {
147 gDPSetPrimColor(gMainGfxPos++, 0, 0, 255, 40, 10, 160);
148 gDPSetAlphaCompare(gMainGfxPos++, G_AC_DITHER);
149 }
150
151 gDPSetEnvColor(gMainGfxPos++, 0, 0, 0, envAlpha);
152 gDPSetTileSize(gMainGfxPos++, G_TX_RENDERTILE,
153 (unk_30_s32 * 32 ) * 4, 0,
154 (unk_30_s32 * 32 + 32) * 4, 32 * 4);
155
156 if (cond) {
157 gDPSetTileSize(gMainGfxPos++, 1,
158 (unk_30_s32 * 32 + 32) * 4, 32 * 4,
159 (unk_30_s32 * 32 + 64) * 4, 64 * 4);
160 } else {
161 gDPSetTileSize(gMainGfxPos++, 1,
162 (unk_30_s32 * 32 + 32) * 4, 0,
163 (unk_30_s32 * 32 + 64) * 4, 32 * 4);
164 }
165
166 part++;
167 for (i = 1; i < ((EffectInstance*)effect)->numParts; i++, part++) {
168 guTranslateF(sp18, part->unk_04, part->unk_08, part->unk_0C);
170
171 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
172 gSPDisplayList(gMainGfxPos++, dlist);
173 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
174 }
175
176 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
177
178 if (unk_00 == 2) {
179 gDPSetAlphaCompare(gMainGfxPos++, G_AC_NONE);
180 }
181
182 gDPPipeSync(gMainGfxPos++);
183}
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 cos_deg
#define create_effect_instance
#define mem_clear
struct SmokeImpactFXData * smokeImpact
Definition effects.h:2493
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
#define VIRTUAL_TO_PHYSICAL(addr)
Definition macros.h:47
void smoke_impact_main(s32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4, s32 arg5, f32 arg6, s32 arg7)
void smoke_impact_appendGfx(void *effect)
void smoke_impact_render(EffectInstance *effect)
Gfx D_09002B80_32BA20[]
void smoke_impact_init(EffectInstance *effect)
Gfx * D_E003A80C[]
void smoke_impact_update(EffectInstance *effect)
Gfx D_09002A38_32B8D8[]
Gfx D_09002B60_32BA00[]
Gfx * D_E003A800[]
Definition smoke_impact.c:8
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