Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
water_splash.c
Go to the documentation of this file.
1#include "common.h"
2#include "nu/nusys.h"
3#include "effects_internal.h"
4
5extern Gfx D_09000100_3BCB90[];
6extern Gfx D_09000268_3BCCF8[];
7extern Gfx D_09000288_3BCD18[];
8extern Gfx D_090002A8_3BCD38[];
9
13
17void water_splash_appendGfx(void* effect);
18
19EffectInstance* water_splash_main(s32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4, s32 arg5) {
21 EffectBlueprint* bpPtr = &bp;
22 EffectInstance *effect;
24 s32 i;
25 s32 numParts;
26
27 switch (arg0) {
28 case 0:
29 case 1:
30 numParts = 21;
31 break;
32 case 2:
33 numParts = 41;
34 break;
35 default:
36 numParts = 11;
37 break;
38 }
39
40 bpPtr->init = water_splash_init;
43 bpPtr->unk_00 = 0;
44 bpPtr->renderUI = NULL;
45 bpPtr->effectID = EFFECT_WATER_SPLASH;
46 effect = create_effect_instance(bpPtr);
47 effect->numParts = numParts;
48 effect->data.waterSplash = part = general_heap_malloc(numParts * sizeof(*part));
49 ASSERT(part != NULL);
50
51 part->unk_00 = arg0;
52 part->unk_20 = 0;
53 if (arg5 <= 0) {
54 part->unk_1C = 1000;
55 } else {
56 part->unk_1C = arg5;
57 }
58 part->unk_30 = 255;
59 part->unk_04.x = arg1;
60 part->unk_04.y = arg2;
61 part->unk_04.z = arg3;
62 part->unk_34 = arg4;
63 part->unk_24 = 70;
64 part->unk_28 = 180;
65 part->unk_2C = 255;
66 part++;
67
68 for (i = 1; i < effect->numParts; i++, part++) {
69 part->unk_04.x = 0.0f;
70 part->unk_04.y = 0.0f;
71 part->unk_04.z = 0.0f;
72 part->unk_34 = 2.0f;
73 switch (arg0) {
74 case 0:
75 part->unk_10.x = rand_int(10) - 2;
76 part->unk_10.y = rand_int(10) - 5;
77 part->unk_10.z = rand_int(10) - 5;
78 break;
79 case 1:
80 part->unk_10.x = 2 - rand_int(10);
81 part->unk_10.y = rand_int(10) - 5;
82 part->unk_10.z = rand_int(10) - 5;
83 break;
84 case 2:
85 part->unk_10.x = (rand_int(100) - 50) * 0.07f;
86 part->unk_10.y = (rand_int(100) + 10) * 0.2f;
87 part->unk_10.z = (rand_int(100) - 50) * 0.07f;
88 break;
89 default:
90 part->unk_10.x = (rand_int(10) - 5) * 0.5;
91 part->unk_10.y = (rand_int(10) - 5) * 0.5;
92 part->unk_10.z = (rand_int(10) - 5) * 0.5;
93 part->unk_1C = i;
94 part->unk_34 = 0.4f;
95 break;
96 }
97 part->unk_30 = 0xFF;
98 }
99 return effect;
100}
101
104
106 WaterSplashFXData *part;
107 s32 temp_a1_3;
108 s32 temp_a2;
109 s32 i;
110
111 part = effect->data.waterSplash;
112 temp_a2 = part->unk_00;
113 if (effect->flags & FX_INSTANCE_FLAG_DISMISS) {
114 effect->flags &= ~FX_INSTANCE_FLAG_DISMISS;
115 part->unk_1C = 0x10;
116 }
117
118 if (part->unk_1C < 1000) {
119 part->unk_1C--;
120 }
121
122 temp_a1_3 = part->unk_1C;
123 part->unk_20++;
124 if (temp_a1_3 < 0) {
125 remove_effect(effect);
126 return;
127 }
128
129 if (temp_a1_3 < 4) {
130 part->unk_30 = temp_a1_3 * 64;
131 }
132
133 part++;
134 for (i = 1; i < effect->numParts; i++, part++) {
135 part->unk_04.x += part->unk_10.x;
136 part->unk_04.y += part->unk_10.y;
137 part->unk_04.z += part->unk_10.z;
138 part->unk_30 *= 0.98;
139 if (temp_a2 == 2) {
140 part->unk_10.y += -0.8;
141 }
142 part->unk_10.y += -0.1;
143 part->unk_10.x *= 0.98;
144 part->unk_10.y *= 0.98;
145 part->unk_10.z *= 0.98;
146 if (temp_a2 == 3) {
147 part->unk_34 *= 1.2;
148 } else {
149 part->unk_34 *= 0.9;
150 }
151 }
152}
153
155 RenderTask renderTask;
156 RenderTask* retTask;
157
159 renderTask.appendGfxArg = effect;
160 renderTask.dist = 10;
162
163 retTask = queue_render_task(&renderTask);
164}
165
166void func_E00BE5B4(void) {
167}
168
169void water_splash_appendGfx(void* effect) {
170 Matrix4f sp10;
171 Matrix4f sp50;
172 WaterSplashFXData* data = ((EffectInstance*)effect)->data.waterSplash;
173 s32 sp90 = data->unk_30;
174 s32 sp94 = data->unk_04.x;
175 s32 temp_fp = data->unk_04.y;
176 Camera* currentCamera = &gCameras[gCurrentCameraID];
177 s32 i;
178
179 gDPPipeSync(gMainGfxPos++);
180 gSPSegment(gMainGfxPos++, 0x09, OS_K0_TO_PHYSICAL(((EffectInstance*)effect)->graphics->data));
181 guTranslateF(sp10, sp94, temp_fp, data->unk_04.z);
182 guScaleF(sp50, data->unk_34, data->unk_34, data->unk_34);
183 guMtxCatF(sp50, sp10, sp10);
185 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
186 gSPMatrix(gMainGfxPos++, currentCamera->mtxBillboard, G_MTX_NOPUSH | G_MTX_MUL | G_MTX_MODELVIEW);
187 gSPDisplayList(gMainGfxPos++, D_09000100_3BCB90);
188
189 data++;
190 for (i = 1; i < ((EffectInstance*)effect)->numParts; i++, data++) {
191 s32 temp_t2 = (s32)data->unk_04.x + sp94;
192 s32 temp_t3 = (s32)data->unk_04.y + temp_fp;
193
194 if (temp_t2 < 0) {
195 temp_t2 = -(temp_t2 & 0x7F);
196 } else {
197 temp_t2 = temp_t2 & 0x7F;
198 }
199
200 if (temp_t3 > 0) {
201 temp_t3 = -(temp_t3 & 0x3F);
202 } else {
203 temp_t3 = temp_t3 & 0x3F;
204 }
205
206 gDPLoadMultiTile(gMainGfxPos++, OS_K0_TO_PHYSICAL(nuGfxCfb_ptr), 0x100, 1, G_IM_FMT_RGBA, G_IM_SIZ_16b, 320, 0,
207 temp_t2 + 0xA0, temp_t3 + 0x78, temp_t2 + 0xBF, temp_t3 + 0x97, 0,
208 G_TX_WRAP, G_TX_WRAP, 5, 5, G_TX_NOLOD, G_TX_NOLOD);
209
210 guTranslateF(sp10, data->unk_04.x, data->unk_04.y, data->unk_04.z);
211 guScaleF(sp50, data->unk_34, data->unk_34, data->unk_34);
212 guMtxCatF(sp50, sp10, sp10);
214 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
215 gDPSetPrimColor(gMainGfxPos++, 0, 0, 200, 255, 255, (sp90 * data->unk_30) / 255);
216 gDPSetEnvColor(gMainGfxPos++, 0, 32, 32, 0);
217 gSPDisplayList(gMainGfxPos++, D_E00BEAF0[(i + (gGameStatusPtr->frameCounter / 2)) & 3]);
218 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
219 }
220 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
221}
u16 * nuGfxCfb_ptr
Definition cam_main.c:14
Mtx matrixStack[0x200]
f32 Matrix4f[4][4]
#define general_heap_malloc
#define queue_render_task
#define guMtxF2L
#define guTranslateF
#define guMtxCatF
#define remove_effect
#define rand_int
#define create_effect_instance
#define guScaleF
struct WaterSplashFXData * waterSplash
Definition effects.h:2559
EffectData data
Definition effects.h:2605
#define ASSERT(condition)
@ FX_INSTANCE_FLAG_DISMISS
Definition enums.h:3517
@ RENDER_MODE_CLOUD_NO_ZCMP
Definition enums.h:3311
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 *)
GameStatus * gGameStatusPtr
Definition main_loop.c:32
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
void water_splash_update(EffectInstance *effect)
void func_E00BE5B4(void)
Gfx D_09000100_3BCB90[]
Gfx D_09000268_3BCCF8[]
EffectInstance * water_splash_main(s32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4, s32 arg5)
void water_splash_render(EffectInstance *effect)
void water_splash_init(EffectInstance *effect)
void water_splash_appendGfx(void *effect)
Gfx * D_E00BEAF0[]
Gfx D_090002A8_3BCD38[]
Gfx D_09000288_3BCD18[]