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