Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
red_impact.c
Go to the documentation of this file.
1#include "common.h"
2#include "effects_internal.h"
3
4extern Gfx D_09000940_359CF0[];
5extern Gfx D_090009A0_359D50[];
6
8
12void red_impact_appendGfx(void* effect);
13
14EffectInstance* red_impact_main(s32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4, s32 arg5) {
16 EffectBlueprint* bpPtr = &bp;
17 EffectInstance* effect;
18 RedImpactFXData* part;
19 f32 zero = 0.0f;
20 s32 numParts;
21 s32 temp;
22 s32 i;
23
24 if (arg0 == 0) {
25 numParts = 7;
26 } else {
27 temp = 3; // Required to match
28 numParts = temp;
29 }
30 numParts++;
31
32 bpPtr->unk_00 = 0;
33 bpPtr->init = red_impact_init;
36 bpPtr->renderUI = NULL;
37 bpPtr->effectID = EFFECT_RED_IMPACT;
38
39 effect = create_effect_instance(bpPtr);
40 effect->numParts = numParts;
41 part = effect->data.redImpact = general_heap_malloc(numParts * sizeof(*part));
42 ASSERT(effect->data.redImpact != NULL);
43
44 part->unk_2C = 0;
45 part->unk_00 = arg0;
46 part->unk_04 = arg1;
47 part->unk_08 = arg2;
48 part->unk_0C = arg3;
49 part->unk_24 = arg4;
50 part->unk_20 = arg4;
51 part->unk_1C = arg4;
52 part->unk_28 = 60;
53 part->unk_38 = 255;
54 part->unk_50.r = 255;
55 part->unk_50.g = 0;
56 part->unk_50.b = 0;
57 part->unk_53.r = 255;
58 part->unk_53.g = 200;
59 part->unk_53.b = 100;
60
61 part++;
62 for (i = 1; i < numParts; i++, part++) {
63 part->unk_4C = -1 + (i - 1) * (-2);
64 part->unk_34 = zero;
65 part->unk_30 = i * 30;
66 }
67
68 return effect;
69}
70
72}
73
75 RedImpactFXData* part = effect->data.redImpact;
76 s32 unk_00;
77 s32 i;
78
79 part->unk_2C++;
80 part->unk_28--;
81
82 if (part->unk_28 < 0) {
83 remove_effect(effect);
84 return;
85 }
86
87 unk_00 = part->unk_00;
88
89 if (part->unk_2C >= 8) {
90 part->unk_38 *= 0.8;
91 }
92
93 part++;
94 for (i = 1; i < effect->numParts; i++, part++) {
95 part->unk_4C++;
96 if (part->unk_4C >= 0) {
97 if (part->unk_4C == 0) {
98 part->unk_04 = 0;
99 part->unk_08 = 0;
100 part->unk_0C = 0;
101 part->unk_10 = -sin_deg(part->unk_34) * 0.5;
102 part->unk_14 = cos_deg(part->unk_34) * 0.5;
103 part->unk_18 = 0;
104 part->unk_3C = 32.0f;
105 part->unk_40 = 32.0f;
106 part->unk_48 = 32.0f;
107 part->unk_20 = 8.0 - (f32) i;
108 if (unk_00 == 0) {
109 part->unk_1C = 2 + i * 2;
110 part->unk_24 = (2 + i * 2) * 0.5;
111 } else {
112 part->unk_1C = i + 0.5;
113 part->unk_20 *= 0.6;
114 part->unk_24 = (i + 0.5) * 0.5;
115 }
116 part->unk_44 = 32.0f;
117 }
118 part->unk_3C += part->unk_40;
119 part->unk_44 += part->unk_48;
120 part->unk_40 *= 0.9;
121 part->unk_1C *= 1.002;
122 part->unk_24 *= 1.002;
123 if (part->unk_3C > 128.0f) {
124 part->unk_3C = 128.0f;
125 }
126 }
127 }
128}
129
131 RenderTask renderTask;
132 RenderTask* retTask;
133
134 renderTask.appendGfx = red_impact_appendGfx;
135 renderTask.appendGfxArg = effect;
136 renderTask.dist = 0;
138
139 retTask = queue_render_task(&renderTask);
141}
142
143void red_impact_appendGfx(void* effect) {
144 RedImpactFXData* part = ((EffectInstance*)effect)->data.redImpact;
145 Gfx* dlist = D_E00D0B10[part->unk_00];
146 Gfx* dlist2;
147 f32 temp_1C = part->unk_1C * 0.3;
148 f32 temp_20 = part->unk_20 * 0.3;
149 f32 temp_24 = part->unk_24 * 0.3;
150 s32 alpha;
151 s32 primR = part->unk_50.r;
152 s32 primG = part->unk_50.g;
153 s32 primB = part->unk_50.b;
154 s32 envR = part->unk_53.r;
155 s32 envG = part->unk_53.g;
156 s32 envB = part->unk_53.b;
157 s32 primR2;
158 s32 primG2;
159 s32 primB2;
160 s32 envR2;
161 s32 envG2;
162 s32 envB2;
163 Gfx* savedGfxPos;
164 Gfx* savedGfxPos2;
165 Matrix4f sp20;
166 Matrix4f sp60;
167 s32 i;
168
169 gDPPipeSync(gMainGfxPos++);
170 gSPSegment(gMainGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(((EffectInstance*)effect)->graphics->data));
171 gSPDisplayList(gMainGfxPos++, dlist);
172
173 guPositionF(sp20, 0.0f, -gCameras[gCurrentCameraID].curYaw, 0.0f, 1.0f, part->unk_04, part->unk_08, part->unk_0C);
175
176 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
177
178 alpha = part->unk_38;
179 primR2 = primR;
180 primG2 = primG;
181 primB2 = primB;
182 envR2 = envR;
183 envG2 = envG;
184 envB2 = envB;
185
186 savedGfxPos = gMainGfxPos;
187 gMainGfxPos++;
188 savedGfxPos2 = savedGfxPos + 1;
189
190 part++;
191 for (i = 1; i < ((EffectInstance*)effect)->numParts; i++, part++) {
192 if (part->unk_4C >= 0) {
193 guTranslateF(sp20, part->unk_04, part->unk_08, part->unk_0C);
194 guRotateF(sp60, part->unk_34, 0.0f, 0.0f, 1.0f);
195 guMtxCatF(sp60, sp20, sp20);
196 guScaleF(sp60, part->unk_1C * temp_1C, part->unk_20 * temp_20, part->unk_24 * temp_24);
197 guMtxCatF(sp60, sp20, sp20);
198 guRotateF(sp60, part->unk_30, 0.0f, 1.0f, 0.0f);
199 guMtxCatF(sp60, sp20, sp20);
201
202 dlist2 = D_09000940_359CF0;
203
204 gDPSetTileSize(gMainGfxPos++, G_TX_RENDERTILE, 0, (s32) part->unk_3C, 0x00FC, (s32) part->unk_3C + 0x7C);
205 gDPSetTileSize(gMainGfxPos++, 1, 0, (s32) part->unk_44, 0x007C, (s32) part->unk_44 + 0x7C);
206 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
207 gSPDisplayList(gMainGfxPos++, dlist2);
208 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
209 }
210 }
211
212 gSPEndDisplayList(gMainGfxPos++);
213 gSPBranchList(savedGfxPos, gMainGfxPos);
214
215 gDPSetPrimColor(gMainGfxPos++, 0, 0, primR2, primG2, primB2, alpha);
216 gDPSetEnvColor(gMainGfxPos++, envR2, envG2, envB2, 0);
217 gSPClearGeometryMode(gMainGfxPos++, G_CULL_BOTH);
218 gSPSetGeometryMode(gMainGfxPos++, G_CULL_FRONT);
219 gSPDisplayList(gMainGfxPos++, savedGfxPos2);
220
221 gDPSetPrimColor(gMainGfxPos++, 0, 0, primR, primG, primB, alpha);
222 gDPSetEnvColor(gMainGfxPos++, envR, envG, envB, 0);
223 gSPClearGeometryMode(gMainGfxPos++, G_CULL_BOTH);
224 gSPSetGeometryMode(gMainGfxPos++, G_CULL_BACK);
225 gSPDisplayList(gMainGfxPos++, savedGfxPos2);
226
227 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
228}
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 guPositionF
#define cos_deg
#define create_effect_instance
#define guScaleF
Color_RGB8 unk_50
Definition effects.h:1888
Color_RGB8 unk_53
Definition effects.h:1889
struct RedImpactFXData * redImpact
Definition effects.h:2568
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
Gfx * D_E00D0B10[]
Definition red_impact.c:7
void red_impact_init(EffectInstance *effect)
Definition red_impact.c:71
Gfx D_09000940_359CF0[]
void red_impact_appendGfx(void *effect)
Definition red_impact.c:143
void red_impact_update(EffectInstance *effect)
Definition red_impact.c:74
Gfx D_090009A0_359D50[]
EffectInstance * red_impact_main(s32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4, s32 arg5)
Definition red_impact.c:14
void red_impact_render(EffectInstance *effect)
Definition red_impact.c:130
#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