Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
water_fountain.c
Go to the documentation of this file.
1#include "common.h"
2#include "effects_internal.h"
3
4typedef struct UnkStruct {
5 /* 0x00 */ s8 unk_00;
6 /* 0x01 */ s8 unk_01;
7 /* 0x02 */ s16 unk_02;
8 /* 0x04 */ s16 unk_04;
9 /* 0x06 */ s16 unk_06;
10 /* 0x08 */ u8 sizeScale;
11 /* 0x09 */ char unk_09[1];
12} UnkStruct; // size = 0xA
13
14extern Gfx D_09000280_3B8AE0[];
15extern Gfx D_09000328_3B8B88[];
16extern Gfx D_09000348_3B8BA8[];
17
19 { 0, 0, 30, 140, 0, 255, { 0 } },
20 { 0, 6, 30, 120, 0, 250, { 0 } },
21 { 1, 12, 30, 110, -5, 240, { 0 } },
22 { 1, 17, 50, 100, -20, 240, { 0 } },
23 { 2, 22, 60, 90, -30, 240, { 0 } },
24 { 2, 26, 70, 90, -40, 240, { 0 } },
25 { 3, 28, 80, 85, -50, 240, { 0 } },
26 { 4, 32, 90, 90, -60, 240, { 0 } },
27 { 5, 35, 100, 100, -70, 240, { 0 } },
28 { 7, 38, 110, 110, -80, 240, { 0 } },
29 { 8, 40, 120, 120, -90, 240, { 0 } },
30 { 11, 42, 130, 130, -100, 240, { 0 } },
31 { 14, 43, 150, 150, -110, 240, { 0 } },
32 { 18, 44, 190, 190, -120, 240, { 0 } },
33 { 21, 45, 230, 230, -130, 240, { 0 } },
34 { 24, 46, 270, 270, -140, 240, { 0 } },
35 { 27, 47, 310, 310, -150, 240, { 0 } },
36 { 30, 48, 350, 350, -160, 200, { 0 } },
37 { 33, 49, 380, 380, -170, 140, { 0 } },
38 { 36, 50, 400, 400, -180, 40, { 0 } },
39 { 0, 0, 30, 140, 0, 255, { 0 } },
40 { 0, 6, 30, 120, 0, 240, { 0 } },
41 { -1, 12, 30, 110, 5, 230, { 0 } },
42 { -1, 17, 50, 100, 20, 220, { 0 } },
43 { -2, 22, 60, 90, 30, 210, { 0 } },
44 { -2, 26, 70, 90, 40, 200, { 0 } },
45 { -3, 28, 80, 85, 50, 190, { 0 } },
46 { -4, 32, 90, 80, 60, 180, { 0 } },
47 { -5, 35, 100, 77, 70, 170, { 0 } },
48 { -7, 38, 110, 65, 80, 160, { 0 } },
49 { -8, 40, 120, 54, 90, 150, { 0 } },
50 { -11, 42, 130, 60, 100, 140, { 0 } },
51 { -14, 43, 140, 70, 110, 130, { 0 } },
52 { -18, 44, 150, 80, 120, 120, { 0 } },
53 { -21, 45, 160, 90, 130, 110, { 0 } },
54 { -24, 46, 170, 100, 140, 90, { 0 } },
55 { -27, 47, 180, 110, 150, 80, { 0 } },
56 { -30, 48, 190, 120, 160, 70, { 0 } },
57 { -33, 49, 200, 130, 170, 30, { 0 } },
58 { -36, 50, 210, 140, 180, 10, { 0 } },
59 { 0, 0, 30, 140, 0, 255, { 0 } },
60 { 0, 6, 30, 120, 0, 240, { 0 } },
61 { 0, 12, 30, 110, 5, 230, { 0 } },
62 { 0, 17, 50, 100, 20, 220, { 0 } },
63 { 0, 22, 60, 90, 30, 210, { 0 } },
64 { 0, 26, 70, 90, 40, 200, { 0 } },
65 { 0, 28, 80, 85, 50, 190, { 0 } },
66 { 0, 32, 90, 80, 60, 180, { 0 } },
67 { 0, 35, 100, 77, 70, 170, { 0 } },
68 { 0, 38, 110, 65, 80, 160, { 0 } },
69 { 0, 40, 120, 54, 90, 150, { 0 } },
70 { 0, 42, 130, 60, 100, 140, { 0 } },
71 { 0, 43, 140, 70, 110, 130, { 0 } },
72 { 0, 44, 150, 80, 120, 120, { 0 } },
73 { 0, 45, 160, 90, 130, 110, { 0 } },
74 { 0, 46, 170, 100, 140, 90, { 0 } },
75 { 0, 47, 180, 110, 150, 80, { 0 } },
76 { 0, 48, 190, 120, 160, 70, { 0 } },
77 { 0, 49, 200, 130, 170, 30, { 0 } },
78 { 0, 50, 210, 140, 180, 10, { 0 } }
79};
80
82 { 0, 0, 30, 140, 0, 255, { 0 } },
83 { 0, 6, 30, 120, 0, 240, { 0 } },
84 { 1, 12, 30, 110, -5, 230, { 0 } },
85 { 1, 17, 50, 100, -20, 220, { 0 } },
86 { 2, 22, 60, 90, -30, 210, { 0 } },
87 { 2, 26, 70, 90, -40, 200, { 0 } },
88 { 3, 28, 80, 85, -50, 190, { 0 } },
89 { 4, 32, 90, 80, -60, 180, { 0 } },
90 { 5, 35, 100, 77, -70, 120, { 0 } },
91 { 7, 38, 110, 65, -80, 80, { 0 } },
92 { 8, 40, 120, 54, -90, 40, { 0 } },
93 { 0, 0, 30, 140, 0, 255, { 0 } },
94 { 0, 6, 30, 120, 0, 240, { 0 } },
95 { -1, 12, 30, 110, 5, 230, { 0 } },
96 { -1, 17, 50, 100, 20, 220, { 0 } },
97 { -2, 22, 60, 90, 30, 210, { 0 } },
98 { -2, 26, 70, 90, 40, 200, { 0 } },
99 { -3, 28, 80, 85, 50, 190, { 0 } },
100 { -4, 32, 90, 80, 60, 180, { 0 } },
101 { -5, 35, 100, 77, 70, 120, { 0 } },
102 { -7, 38, 110, 65, 80, 80, { 0 } },
103 { -8, 40, 120, 54, 90, 40, { 0 } },
104 { 0, 0, 30, 140, 0, 255, { 0 } },
105 { 0, 6, 30, 120, 0, 240, { 0 } },
106 { 0, 12, 30, 110, 5, 230, { 0 } },
107 { 0, 17, 50, 100, 20, 220, { 0 } },
108 { 0, 22, 60, 90, 30, 210, { 0 } },
109 { 0, 26, 70, 90, 40, 200, { 0 } },
110 { 0, 28, 80, 85, 50, 190, { 0 } },
111 { 0, 32, 90, 80, 60, 180, { 0 } },
112 { 0, 36, 100, 77, 70, 120, { 0 } },
113 { 0, 39, 110, 65, 80, 80, { 0 } },
114 { 0, 42, 120, 54, 90, 40, { 0 } }
115};
116
117s32 D_E00B8CA4[] = { 0, 40, 55, 190, 20, 130, 270, 300 };
118
122void water_fountain_appendGfx(void* effect);
123
124EffectInstance* water_fountain_main(s32 arg0, f32 posX, f32 posY, f32 posZ, f32 arg4, s32 arg5) {
125 EffectBlueprint effectBp;
126 EffectInstance* effect;
128 s32 numParts = 1;
129
130 effectBp.init = water_fountain_init;
131 effectBp.update = water_fountain_update;
133 effectBp.unk_00 = 0;
134 effectBp.renderUI = NULL;
135 effectBp.effectID = EFFECT_WATER_FOUNTAIN;
136
137 effect = create_effect_instance(&effectBp);
138 effect->numParts = numParts;
139
140 data = effect->data.waterFountain = general_heap_malloc(numParts * sizeof(*data));
141 ASSERT(data != NULL);
142
143 data->unk_00 = arg0;
144 data->lifeTime = 0;
145 if (arg5 <= 0) {
146 data->timeLeft = 1000;
147 } else {
148 data->timeLeft = arg5;
149 }
150 data->unk_24 = 255;
151 data->pos.x = posX;
152 data->pos.y = posY;
153 data->pos.z = posZ;
154 data->unk_34 = arg4;
155 data->unk_18 = 70;
156 data->unk_1C = 180;
157 data->unk_20 = 255;
158 data->unk_28 = 255;
159 data->unk_2C = 255;
160 data->unk_30 = 255;
161 data->unk_38 = 0;
162 data->unk_3C = 1.0f;
163 data->unk_40 = 1.0f;
164
165 return effect;
166}
167
170
172 WaterFountainFXData* data = effect->data.waterFountain;
173
174 if (effect->flags & FX_INSTANCE_FLAG_DISMISS) {
175 effect->flags &= ~FX_INSTANCE_FLAG_DISMISS;
176 data->timeLeft = 16;
177 }
178 if (data->timeLeft < 1000) {
179 data->timeLeft--;
180 }
181 data->lifeTime++;
182 if (data->timeLeft < 0) {
183 remove_effect(effect);
184 return;
185 }
186 if (data->lifeTime < 8) {
187 data->unk_24 = (data->lifeTime * 32) + 31;
188 }
189}
190
191
193 RenderTask renderTask;
194 RenderTask* retTask;
195
197 renderTask.appendGfxArg = effect;
198 renderTask.dist = 10;
200
201 retTask = queue_render_task(&renderTask);
203}
204
205void func_E00B8200(void) {
206}
207
208void water_fountain_appendGfx(void *effect) {
209 WaterFountainFXData* data = ((EffectInstance*)effect)->data.waterFountain;
210 Camera* camera = &gCameras[gCurrentCameraID];
211 s32 lifeTime = data->lifeTime;
212 s32 timeLeft = data->timeLeft;
213 s32 sp9C;
214 s32 unk_24 = data->unk_24;
215 s32 unk_00 = data->unk_00;
216 s32 unk_18 = data->unk_18;
217 s32 unk_1C = data->unk_1C;
218 s32 unk_20 = data->unk_20;
219 s32 spB0;
220 s32 var_s6;
221 s32 temp;
222 UnkStruct* basePtr;
223 Matrix4f sp18;
224 Matrix4f sp58;
225 s32 i;
226 s32 j;
227
228 if (unk_00 == 0) {
229 spB0 = 3;
230 basePtr = D_E00B8900;
231 var_s6 = 20;
232 } else {
233 var_s6 = 11;
234 spB0 = 3;
235 basePtr = D_E00B8B58;
236 }
237
238 gDPPipeSync(gMainGfxPos++);
239 gSPSegment(gMainGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(((EffectInstance*)effect)->graphics->data));
240
241 guTranslateF(sp18, data->pos.x, data->pos.y, data->pos.z);
242 guScaleF(sp58, data->unk_34, data->unk_34, data->unk_34);
243 guMtxCatF(sp58, sp18, sp18);
245
246 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
247 gSPMatrix(gMainGfxPos++, camera->mtxBillboard, G_MTX_NOPUSH | G_MTX_MUL | G_MTX_MODELVIEW);
248 gSPDisplayList(gMainGfxPos++, D_09000280_3B8AE0);
249
250 guRotateF(sp18, data->unk_38, 0.0f, 0.0f, 1.0f);
251 guScaleF(sp58, data->unk_3C, data->unk_40, 1.0f);
252 guMtxCatF(sp58, sp18, sp18);
254
255 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
256 gDPSetEnvColor(gMainGfxPos++, data->unk_28, data->unk_2C, data->unk_30, unk_24);
257
258 temp = sp9C + 1;
259 if (timeLeft >= var_s6 - temp) {
260 gDPSetPrimColor(gMainGfxPos++, 0, 0, unk_18, unk_1C, unk_20, unk_24);
261 gSPDisplayList(gMainGfxPos++, D_09000348_3B8BA8);
262 }
263
264 for (i = 0; i < var_s6 / 2; i++) {
265 for (j = 0; j < spB0; j++) {
266 s32 idx = (lifeTime + i * 2) % var_s6;
267 UnkStruct* ptr = &basePtr[j * var_s6];
268
269 if (lifeTime * 5 >= idx) {
270 s32 temp2 = idx + 1;
271 if (timeLeft >= var_s6 - temp2) {
272 guTranslateF(sp18, (f32) ptr[idx].unk_00, (f32) ptr[idx].unk_01 + 10.0f, 0.0f);
273 guScaleF(sp58, (f32) basePtr[idx].unk_02 * 0.01, (f32) basePtr[idx].unk_04 * 0.01, 1.0f);
274 guMtxCatF(sp58, sp18, sp18);
275 guRotateF(sp58, (f32) ptr[idx].unk_06 + D_E00B8CA4[(j + i) & 7], 0.0f, 0.0f, 1.0f);
276 guMtxCatF(sp58, sp18, sp18);
278
279 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
280 gDPSetPrimColor(gMainGfxPos++, 0, 0, unk_18, unk_1C, unk_20, (unk_24 * basePtr[idx].sizeScale) >> 8);
281 gSPDisplayList(gMainGfxPos++, D_09000328_3B8B88);
282 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
283 }
284 }
285 }
286 }
287
288 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
289 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
290 gDPPipeSync(gMainGfxPos++);
291}
Mtx matrixStack[0x200]
f32 Matrix4f[4][4]
#define general_heap_malloc
#define guRotateF
#define queue_render_task
#define guMtxF2L
#define guTranslateF
#define guMtxCatF
#define remove_effect
#define create_effect_instance
#define guScaleF
struct WaterFountainFXData * waterFountain
Definition effects.h:2556
EffectData data
Definition effects.h:2605
#define ASSERT(condition)
@ FX_INSTANCE_FLAG_DISMISS
Definition enums.h:3517
@ RENDER_TASK_FLAG_REFLECT_FLOOR
Definition enums.h:3318
@ RENDER_MODE_CLOUD_NO_ZCMP
Definition enums.h:3311
#define VIRTUAL_TO_PHYSICAL(addr)
Definition macros.h:47
Mtx * mtxBillboard
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
Gfx D_09000328_3B8B88[]
void water_fountain_init(EffectInstance *effect)
Gfx D_09000348_3B8BA8[]
Gfx D_09000280_3B8AE0[]
char unk_09[1]
UnkStruct D_E00B8B58[]
void water_fountain_appendGfx(void *effect)
EffectInstance * water_fountain_main(s32 arg0, f32 posX, f32 posY, f32 posZ, f32 arg4, s32 arg5)
void func_E00B8200(void)
s32 D_E00B8CA4[]
void water_fountain_update(EffectInstance *effect)
void water_fountain_render(EffectInstance *effect)
UnkStruct D_E00B8900[]