Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
squirt.c File Reference

Go to the source code of this file.

Functions

void squirt_init (EffectInstance *effect)
 
void squirt_update (EffectInstance *effect)
 
void squirt_render (EffectInstance *effect)
 
void squirt_appendGfx (void *effect)
 
EffectInstancesquirt_main (s32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4, f32 arg5, f32 arg6, f32 arg7, s32 arg8)
 
void func_E00B24A8 (void)
 

Variables

u8 D_E00B2BA0 [] = { 255, 255, 255, 255, 255, 255, 255, 255, 255, 200, 128, 32, 0, 0, 0, 0 }
 
Gfx D_09000800_3B5B40 []
 
Gfx D_090008A8_3B5BE8 []
 

Function Documentation

◆ squirt_init()

void squirt_init ( EffectInstance * effect)

Definition at line 84 of file squirt.c.

84 {
85}

Referenced by squirt_main().

◆ squirt_update()

void squirt_update ( EffectInstance * effect)

Definition at line 87 of file squirt.c.

87 {
88 SquirtFXData* data = effect->data.squirt;
89 s32 unk_00 = data->unk_00;
90 s32 unk_28;
91 s32 var_v1;
92 f32 factor;
93 s32 i;
94
95 if (effect->flags & FX_INSTANCE_FLAG_DISMISS) {
96 effect->flags &= ~FX_INSTANCE_FLAG_DISMISS;
97 data->unk_2C = 16;
98 }
99
100 if (data->unk_2C < 1000) {
101 data->unk_2C--;
102 }
103
104 data->unk_30++;
105
106 if (data->unk_2C < 0) {
107 remove_effect(effect);
108 return;
109 }
110
111 unk_28 = data->unk_28;
112
113 data->unk_54++;
114 if (data->unk_54 > 12) {
115 data->unk_54 = 12;
116 }
117
118 for (i = 0; i < 12; i++) {
119 if (data->unk_178[i] == 0 || --data->unk_178[i] == 0) {
120 data->unk_1A8[i]++;
121 if (data->unk_1A8[i] >= unk_28) {
122 var_v1 = unk_28;
123 } else {
124 var_v1 = data->unk_1A8[i];
125 }
126
127 factor = (f32) var_v1 / unk_28;
128
129 if (unk_00 == 0) {
130 data->unk_E8[i] = data->unk_10 + (data->unk_1C - data->unk_10) * factor;
131 data->unk_118[i] = data->unk_14 + (data->unk_20 - data->unk_14) * factor;
132 data->unk_148[i] = data->unk_18 + (data->unk_24 - data->unk_18) * factor;
133 } else {
134 data->unk_E8[i] = data->unk_10 + (data->unk_1C - data->unk_10) * factor;
135 data->unk_118[i] = data->unk_14 + (data->unk_20 - data->unk_14) * factor + sin_deg(factor * 180.0f) * 120.0f;
136 data->unk_148[i] = data->unk_18 + (data->unk_24 - data->unk_18) * factor;
137 data->unk_1D8[i] = 255.0f - factor * 255.0f;
138 }
139 }
140 }
141}
#define sin_deg
#define remove_effect
f32 unk_E8[12]
Definition effects.h:1530
f32 unk_118[12]
Definition effects.h:1531
struct SquirtFXData * squirt
Definition effects.h:2553
u8 unk_1D8[12]
Definition effects.h:1535
s32 unk_178[12]
Definition effects.h:1533
f32 unk_148[12]
Definition effects.h:1532
s32 unk_1A8[12]
Definition effects.h:1534
EffectData data
Definition effects.h:2605
@ FX_INSTANCE_FLAG_DISMISS
Definition enums.h:3517

Referenced by squirt_main().

◆ squirt_render()

void squirt_render ( EffectInstance * effect)

Definition at line 143 of file squirt.c.

143 {
144 RenderTask renderTask;
145 RenderTask* retTask;
146
147 renderTask.appendGfx = squirt_appendGfx;
148 renderTask.appendGfxArg = effect;
149 renderTask.dist = 10;
151
152 retTask = queue_render_task(&renderTask);
154}
#define queue_render_task
void squirt_appendGfx(void *effect)
Definition squirt.c:159
@ RENDER_TASK_FLAG_REFLECT_FLOOR
Definition enums.h:3318
@ RENDER_MODE_CLOUD_NO_ZCMP
Definition enums.h:3311
void * appendGfxArg
void(* appendGfx)(void *)

Referenced by squirt_main().

◆ squirt_appendGfx()

void squirt_appendGfx ( void * effect)

Definition at line 159 of file squirt.c.

159 {
160 SquirtFXData* data = ((EffectInstance*)effect)->data.squirt;
161 s32 zero = 0;
162 s32 unk_00 = data->unk_00;
163 Gfx* savedGfxPos;
164 f32 unk_50 = data->unk_50;
165 Matrix4f sp10, sp50;
166 Vtx_t* vtx;
167 s32 savedIdx;
168 s32 i;
169
170 f32 cosComp;
171 f32 sinComp;
172 f32 var_f22;
173 f32 theta;
174
175 gDPPipeSync(gMainGfxPos++);
176 gSPSegment(gMainGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(((EffectInstance*)effect)->graphics->data));
177
178 guTranslateF(sp10, 0.0f, 0.0f, 0.0f);
179 guScaleF(sp50, 0.05f, 0.05f, 0.05f);
180 guMtxCatF(sp50, sp10, sp10);
182
183 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
184 gDPSetPrimColor(gMainGfxPos++, 0, 0, data->unk_34, data->unk_38, data->unk_3C, data->unk_40);
185 gDPSetEnvColor(gMainGfxPos++, data->unk_44, data->unk_48, data->unk_4C, 200);
186
187 gSPBranchList(gMainGfxPos, &gMainGfxPos[49]);
188 savedGfxPos = gMainGfxPos + 1;
189
191
192 vtx = (Vtx_t*) savedGfxPos;
193 for (i = 0; i < 12; i++) {
194 s32 inc = i + 1;
195 s32 tc0;
196 s32 cnA;
197
198 if (i == 0 || zero == i || (i != 11 && data->unk_178[i] == 0)) {
199 theta = data->unk_118[inc];
200 theta = -atan2(theta, -data->unk_E8[i + 1], data->unk_118[i], -data->unk_E8[i]);
201 }
202
203 if (data->unk_00 == 0) {
204 var_f22 = ((f32) data->unk_1A8[i] * 0.5) + 2.0;
205 if (var_f22 > 6.0f) {
206 var_f22 = 6.0f;
207 }
208 cnA = D_E00B2BA0[i];
209 } else {
210 var_f22 = ((f32) data->unk_1A8[i] * 0.5) + 1.0;
211 if (var_f22 > 30.0f) {
212 var_f22 = 30.0f;
213 }
214 cnA = (D_E00B2BA0[i] * data->unk_1D8[i]) / 255;
215 }
216 tc0 = i * 5;
217 tc0 *= 64;
218
219 var_f22 *= unk_50;
220 sinComp = var_f22 * sin_deg(theta);
221 cosComp = var_f22 * cos_deg(theta);
222
223 vtx->ob[0] = (data->unk_E8[i] + sinComp) * 20.0f;
224 vtx->ob[1] = (data->unk_118[i] + cosComp) * 20.0f;
225 vtx->ob[2] = (data->unk_148[i] + 0.0f) * 20.0f;
226 vtx->tc[0] = tc0;
227 vtx->tc[1] = 0;
228 vtx->cn[0] = (i & 1) * 255;
229 vtx->cn[1] = ((i >> 1) & 1) * 255;
230 vtx->cn[2] = ((i >> 2) & 1) * 255;
231 vtx->cn[3] = cnA;
232 vtx++;
233
234 vtx->ob[0] = (data->unk_E8[i] - sinComp) * 20.0f;
235 vtx->ob[1] = (data->unk_118[i] - cosComp) * 20.0f;
236 vtx->ob[2] = (data->unk_148[i] + 0.0f) * 20.0f;
237 vtx->tc[0] = tc0;
238 vtx->tc[1] = 1024;
239 vtx->cn[0] = (i & 1) * 255;
240 vtx->cn[1] = ((i >> 1) & 1) * 255;
241 vtx->cn[2] = ((i >> 2) & 1) * 255;
242 vtx->cn[3] = cnA;
243 vtx++;
244 }
245
246 gSPVertex(gMainGfxPos++, savedGfxPos, i * 2, 0);
247
248 savedIdx = i;
249 gSPDisplayList(gMainGfxPos++, unk_00 == 0 ? D_09000800_3B5B40 : D_090008A8_3B5BE8);
250
251 for (i = 0; i < savedIdx - 1; i++) {
252 s32 i2 = i * 2;
253
254 if (i < zero) {
255 continue;
256 }
257 gSP2Triangles(gMainGfxPos++,
258 i2, i2 + 2, i2 + 1, i2,
259 i2 + 1, i2 + 2, i2 + 3, i2);
260 }
261
262 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
263 gDPPipeSync(gMainGfxPos++);
264}
Mtx matrixStack[0x200]
f32 Matrix4f[4][4]
#define guMtxF2L
#define guTranslateF
#define guMtxCatF
#define cos_deg
#define atan2
#define guScaleF
u8 D_E00B2BA0[]
Definition squirt.c:4
Gfx D_090008A8_3B5BE8[]
Gfx D_09000800_3B5B40[]
#define VIRTUAL_TO_PHYSICAL(addr)
Definition macros.h:47
Gfx * gMainGfxPos
Definition cam_main.c:15
u16 gMatrixListPos
Definition main_loop.c:45
DisplayContext * gDisplayContext
Definition cam_main.c:16

Referenced by squirt_render().

◆ squirt_main()

EffectInstance * squirt_main ( s32 arg0,
f32 arg1,
f32 arg2,
f32 arg3,
f32 arg4,
f32 arg5,
f32 arg6,
f32 arg7,
s32 arg8 )

Definition at line 14 of file squirt.c.

14 {
16 EffectInstance* effect;
17 SquirtFXData* data;
18 s32 numParts = 1;
19 s32 i;
20
21 bp.init = squirt_init;
24 bp.unk_00 = 0;
25 bp.renderUI = NULL;
26 bp.effectID = EFFECT_SQUIRT;
27
28 effect = create_effect_instance(&bp);
29 effect->numParts = numParts;
30 data = effect->data.squirt = general_heap_malloc(numParts * sizeof(*data));
31 ASSERT(effect->data.squirt != NULL);
32
33 data->unk_00 = arg0;
34 data->unk_30 = 0;
35 if (arg8 <= 0) {
36 data->unk_2C = 1000;
37 } else if (arg0 == 0) {
38 data->unk_2C = arg8 * 2;
39 } else {
40 data->unk_2C = arg8 * 4;
41 }
42 data->unk_28 = arg8;
43 if (arg0 == 0) {
44 data->unk_40 = 200;
45 } else {
46 data->unk_40 = 255;
47 }
48 data->unk_10 = arg1;
49 data->unk_14 = arg2;
50 data->unk_18 = arg3;
51 data->unk_04 = data->unk_10;
52 data->unk_08 = data->unk_14;
53 data->unk_0C = data->unk_18;
54 data->unk_1C = arg4;
55 data->unk_20 = arg5;
56 data->unk_24 = arg6;
57 data->unk_50 = arg7;
58 data->unk_34 = 210;
59 data->unk_38 = 230;
60 data->unk_3C = 255;
61 data->unk_44 = 0;
62 data->unk_48 = 30;
63 data->unk_4C = 205;
64 data->unk_54 = 0;
65
66 for (i = 0; i < 12; i++) {
67 data->unk_58[i] = 10.0f;
68 data->unk_88[i] = 2.0f;
69 data->unk_B8[i] = 0;
70 if (arg0 == 0) {
71 data->unk_178[i] = i + 1;
72 } else {
73 data->unk_178[i] = i * 5 + 1;
74 }
75 data->unk_E8[i] = data->unk_04;
76 data->unk_118[i] = data->unk_08;
77 data->unk_148[i] = data->unk_0C;
78 data->unk_1A8[i] = 0;
79 }
80
81 return effect;
82}
#define general_heap_malloc
#define create_effect_instance
void squirt_update(EffectInstance *effect)
Definition squirt.c:87
void squirt_init(EffectInstance *effect)
Definition squirt.c:84
void squirt_render(EffectInstance *effect)
Definition squirt.c:143
f32 unk_58[12]
Definition effects.h:1527
s32 unk_B8[12]
Definition effects.h:1529
f32 unk_88[12]
Definition effects.h:1528
#define ASSERT(condition)
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

◆ func_E00B24A8()

void func_E00B24A8 ( void )

Definition at line 156 of file squirt.c.

156 {
157}

Variable Documentation

◆ D_E00B2BA0

u8 D_E00B2BA0[] = { 255, 255, 255, 255, 255, 255, 255, 255, 255, 200, 128, 32, 0, 0, 0, 0 }

Definition at line 4 of file squirt.c.

4{ 255, 255, 255, 255, 255, 255, 255, 255, 255, 200, 128, 32, 0, 0, 0, 0 };

Referenced by squirt_appendGfx().

◆ D_09000800_3B5B40

Gfx D_09000800_3B5B40[]
extern

Referenced by squirt_appendGfx().

◆ D_090008A8_3B5BE8

Gfx D_090008A8_3B5BE8[]
extern

Referenced by squirt_appendGfx().