Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
gather_energy_pink.c
Go to the documentation of this file.
1#include "common.h"
2#include "effects_internal.h"
3
4extern Gfx D_09000DA0_33C970[];
5extern Gfx D_09000E28_33C9F8[];
6extern Gfx D_090010B0_33CC80[];
7extern Gfx D_09001138_33CD08[];
8
11
12u8 D_E0026A00[] = {
13 0xFF, 0xC5, 0x9C, 0xFF, 0x9C, 0xFF, 0xFF, 0x73, 0xD6, 0xFF, 0x9C, 0xFF, 0xFF, 0xC5, 0x7B, 0xFF,
14 0xB4, 0xFF, 0xDE, 0x73, 0xFF, 0xFF, 0x94, 0x9C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
15};
16
20void gather_energy_pink_appendGfx(void* effect);
21
22void gather_energy_pink_main(s32 type, f32 posX, f32 posY, f32 posZ, f32 scale, s32 duration) {
24 EffectInstance* effect;
26 s32 numParts = 1;
27
28 bp.unk_00 = 0;
32 bp.renderUI = NULL;
33 bp.effectID = EFFECT_GATHER_ENERGY_PINK;
34
35 effect = create_effect_instance(&bp);
36 effect->numParts = numParts;
37 data = effect->data.gatherEnergyPink = general_heap_malloc(sizeof(*data));
38 ASSERT (data != NULL);
39
40 data->unk_00 = type;
41 data->unk_28 = duration;
42 data->unk_2C = 0;
43 data->unk_24 = 0;
44 data->posB.x = posX;
45 data->posB.y = posY;
46 data->posB.z = posZ;
47 data->unk_44 = 0;
48 data->unk_40 = 0;
49 data->unk_4C = 0;
50 data->unk_48 = 0;
51 data->unk_34 = 0;
52 data->unk_30 = 0;
53 data->unk_3C = 0;
54 data->unk_38 = 0;
55 data->posA.x = posX;
56 data->posA.y = posY;
57 data->posA.z = posZ;
58
59 data->unk_1C = 10.0f;
60
61 data->unk_58 = effect_rand_int(360);
62 data->unk_5C = 4.0f;
63
64 data->unk_50 = 0;
65 data->unk_54 = 0;
66
67 if (type == 1) {
68 data->unk_3C = 96;
69 data->unk_20 = scale;
70 } else {
71 data->unk_44 = -2;
72 data->unk_4C = -4;
73 data->unk_20 = scale * 0.2;
74 }
75 return;
76}
77
80
83 s32 unk_28;
84 s32 unk_2C;
85 f32 sp28;
86 f32 sp2C;
87 f32 sp30;
88 f32 sp34;
89 s32 i;
90
91 part->unk_28--;
92 part->unk_2C++;
93
94 if (part->unk_28 < 0) {
95 remove_effect(effect);
96 return;
97 }
98
99 unk_28 = part->unk_28;
100 unk_2C = part->unk_2C;
101
102 if (unk_2C < 11) {
103 part->unk_24 = (unk_2C * 255) / 10;
104 }
105
106 if (unk_28 < 6) {
107 part->unk_24 = (unk_28 * 255) / 6;
108 }
109
110 if (unk_28 < 10 && part->unk_00 == 0) {
111 part->unk_1C *= 0.7;
112 }
113
114 if (part->unk_00 == 1) {
115 part->unk_1C += (part->unk_20 + sin_deg(unk_28 * 10) * 0.1 * part->unk_20 - part->unk_1C) * 0.4;
116 } else {
117 part->unk_1C += (part->unk_20 + sin_deg(unk_28 * 10) * 0.1 * part->unk_20 - part->unk_1C) * 0.3;
118 }
119
120 transform_point(&gCameras[gCurrentCameraID].mtxPerspective[0], part->posA.x, part->posA.y, part->posA.z, 1.0f, &sp28, &sp2C, &sp30, &sp34);
121
122 sp34 = 1.0f / sp34;
123 sp28 *= sp34;
124 sp2C *= sp34;
125 sp30 *= sp34;
126
127 part->posB.x = sp28;
128 part->posB.y = sp2C;
129 part->posB.z = 0;
130
131 for (i = 0; i < effect->numParts; i++, part++) {
132 part->unk_30 += part->unk_34;
133 part->unk_38 += part->unk_3C;
134 part->unk_40 += part->unk_44;
135 part->unk_48 += part->unk_4C;
136 part->unk_58 += part->unk_5C;
137 part->unk_50 += part->unk_54;
138 if (part->unk_40 < 0) {
139 part->unk_40 += 256;
140 }
141 if (part->unk_48 < 0) {
142 part->unk_48 += 256;
143 }
144 }
145}
146
148 RenderTask renderTask;
149 RenderTask* retTask;
150
152 renderTask.appendGfxArg = effect;
153 renderTask.dist = 0;
155
156 retTask = queue_render_task(&renderTask);
158}
159
161 GatherEnergyPinkFXData* part = ((EffectInstance*)effect)->data.gatherEnergyPink;
162 s32 unk_00 = part->unk_00;
163 Gfx* dlist = D_E00269F8[unk_00];
164 Gfx* dlist2 = D_E00269F0[unk_00];
165 Camera* camera = &gCameras[gCurrentCameraID];
166 Matrix4f sp20;
167 Matrix4f sp60;
168 Matrix4f unused;
169 u16 perspNorm;
170 s32 alpha;
171 s32 idx;
172 s32 i;
173
174 gDPPipeSync(gMainGfxPos++);
175 gSPSegment(gMainGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(((EffectInstance*)effect)->graphics->data));
176 gSPDisplayList(gMainGfxPos++, dlist);
177
178 guTranslateF(sp20, part->posB.x, part->posB.y, part->posB.z);
179 guScaleF(sp60, part->unk_1C, part->unk_1C, 1.0f);
180 guMtxCatF(sp60, sp20, sp20);
181 guPerspectiveF(sp60, &perspNorm, unk_00 == 1 ? 130.0f : 30.0f, (f32) camera->viewportW / camera->viewportH, 4.0f, 16384.0f, 1.0f);
182 guMtxCatF(sp60, sp20, sp20);
184
185 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION);
186
187 switch (unk_00) {
188 case 1:
189 guTranslateF(sp20, 0.0f, 0.0f, -70.0f);
190 break;
191 case 0:
192 guTranslateF(sp20, 0.0f, 0.0f, -80.0f);
193 break;
194 }
195
197
198 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
199
200 idx = part->unk_2C * 3;
201 alpha = part->unk_24;
202
203 for (i = 0; i < ((EffectInstance*)effect)->numParts; i++, part++) {
204 s32 tempX;
205 s32 tempY;
206 s32 tempX2;
207 s32 tempY2;
208
209 idx += 30;
210 idx %= 24;
211
212 gDPSetEnvColor(gMainGfxPos++, 0, 0, 0, alpha / 2);
213 gDPSetPrimColor(gMainGfxPos++, 0, 0, D_E0026A00[idx], 0, D_E0026A00[idx + 2], alpha);
214
215 tempX = part->unk_30;
216 tempY = part->unk_40;
217 tempX2 = part->unk_38;
218 tempY2 = part->unk_48;
219
220 gDPSetTileSize(gMainGfxPos++, G_TX_RENDERTILE, tempX, tempY, tempX + 256, tempY + 256);
221 gDPSetTileSize(gMainGfxPos++, 1, tempX2, tempY2, tempX2 + 256, tempY2 + 256);
222 gSPDisplayList(gMainGfxPos++, dlist2);
223 }
224
225 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
226 gSPMatrix(gMainGfxPos++, &gDisplayContext->camPerspMatrix[gCurrentCameraID], G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION);
227 gDPPipeSync(gMainGfxPos++);
228}
Mtx matrixStack[0x200]
f32 Matrix4f[4][4]
#define general_heap_malloc
#define transform_point
#define queue_render_task
#define guMtxF2L
#define sin_deg
#define guTranslateF
#define guMtxCatF
#define remove_effect
#define guPerspectiveF
#define create_effect_instance
#define guScaleF
struct GatherEnergyPinkFXData * gatherEnergyPink
Definition effects.h:2483
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
Gfx * D_E00269F8[]
Gfx D_090010B0_33CC80[]
Gfx D_09000E28_33C9F8[]
void gather_energy_pink_update(EffectInstance *effect)
Gfx * D_E00269F0[]
u8 D_E0026A00[]
Gfx D_09001138_33CD08[]
void gather_energy_pink_appendGfx(void *effect)
void gather_energy_pink_render(EffectInstance *effect)
void gather_energy_pink_main(s32 type, f32 posX, f32 posY, f32 posZ, f32 scale, s32 duration)
void gather_energy_pink_init(EffectInstance *effect)
Gfx D_09000DA0_33C970[]
#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