Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
shimmer_wave.c
Go to the documentation of this file.
1#include "common.h"
2#include "effects_internal.h"
3
4extern Gfx D_09000F20_338EE0[];
5extern Gfx D_090011C8_339188[];
6extern Gfx D_090011E0_3391A0[];
7extern Gfx D_090011F8_3391B8[];
8extern Gfx D_09001210_3391D0[];
9extern Gfx D_09001228_3391E8[];
10extern Gfx D_09001240_339200[];
11extern Gfx D_09001258_339218[];
12extern Gfx D_09001270_339230[];
13
18
19f32 D_E0074B80[] = {
20 0.2f, 0.4f, 0.8f, 1.3f, 1.5f, 1.3f, 0.9f, 0.6f, 0.4f, 0.3f,
21 0.2f, 0.4f, 0.8f, 1.3f, 1.5f, 1.3f, 0.9f, 0.6f, 0.4f, 0.3f
22};
23
24s32 D_E0074BD0[] = {
25 0xC8FAFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFAC8, 0x00000000, 0x00000000, 0x00000000
26};
27
31void shimmer_wave_appendGfx(void* effect);
32
34 s32 arg0,
35 f32 arg1,
36 f32 arg2,
37 f32 arg3,
38 f32 arg4,
39 f32 arg5,
40 s32 arg6,
41 s32 arg7
42) {
44 EffectInstance* effect;
46 f32 one = 1.0f;
47 f32 temp;
48 s32 i;
49
50 arg6++;
51
55 bp.unk_00 = 0;
56 bp.renderUI = NULL;
57 bp.effectID = EFFECT_SHIMMER_WAVE;
58
59 effect = create_effect_instance(&bp);
60 effect->numParts = arg6;
61 part = effect->data.shimmerWave = general_heap_malloc(arg6 * sizeof(*part));
62 ASSERT(effect->data.shimmerWave != NULL);
63
64 part->unk_00 = arg0;
65 part->unk_3C = 0;
66 if (arg7 <= 0) {
67 part->unk_38 = 1000;
68 } else {
69 part->unk_38 = arg7;
70 }
71 part->unk_4C = 255;
72 part->unk_04 = arg1;
73 part->unk_08 = arg2;
74 part->unk_0C = arg3;
75 part->unk_60 = one;
76 part->unk_10 = arg4;
77 part->unk_14 = arg5;
78 part->unk_40 = 255;
79 part->unk_44 = 255;
80 part->unk_48 = 255;
81 part->unk_50 = 255;
82 part->unk_54 = 255;
83 part->unk_58 = 127;
84 part->unk_5C = 255;
85
86 part++;
87
88 if (arg7 < 20) {
89 temp = 20.0f / (arg6 - 1);
90 } else {
91 temp = (f32) arg7 / (arg6 - 1);
92 }
93
94 for (i = 1; i < arg6; i++, part++) {
95 part->unk_30 = (s32) (-(f32) i * temp) - 1;
96 }
97
98 return effect;
99}
100
103
105 ShimmerWaveFXData* part = effect->data.shimmerWave;
106 f32 unk_10;
107 f32 unk_14;
108 s32 i;
109
110 if (effect->flags & FX_INSTANCE_FLAG_DISMISS) {
111 effect->flags &= ~FX_INSTANCE_FLAG_DISMISS;
112 part->unk_38 = 16;
113 }
114
115 if (part->unk_38 < 1000) {
116 part->unk_38--;
117 }
118
119 part->unk_3C++;
120
121 if (part->unk_38 < 0) {
122 remove_effect(effect);
123 return;
124 }
125
126 if (part->unk_38 < 8) {
127 part->unk_4C = part->unk_38 * 32;
128 }
129
130 unk_10 = part->unk_10;
131 unk_14 = part->unk_14;
132
133 part++;
134 for (i = 1; i < effect->numParts; i++, part++) {
135 part->unk_30++;
136 if (part->unk_30 >= ARRAY_COUNT(D_E0074B80)) {
137 part->unk_30 = 0;
138 }
139
140 if (part->unk_30 >= 0) {
141 if (part->unk_30 == 0) {
142 f32 rand = rand_int(359);
143 rand_int(359);
144
145 part->unk_04 = unk_10 * sin_deg(rand);
146 part->unk_08 = rand_int(unk_14) - unk_14 * 0.5;
147 part->unk_0C = unk_10 * cos_deg(rand);
148 part->unk_18 = sin_deg(rand) * 15.0f;
149 part->unk_1C = part->unk_08 * 0.4;
150 part->unk_20 = cos_deg(rand) * 15.0f;
151 part->unk_24 = part->unk_18 * 0.5;
152 part->unk_28 = part->unk_1C * 0.5;
153 part->unk_2C = part->unk_20 * 0.5;
154 part->unk_64 = rand_int(15);
155 part->unk_68 = rand_int(15);
156 part->unk_34 = 0.0f;
157 part->unk_4C = 255;
158 }
159
160 part->unk_60 = 2.0f * D_E0074B80[part->unk_30];
161 part->unk_34 += 4.0f;
162 part->unk_04 += part->unk_18;
163 part->unk_08 += part->unk_1C;
164 part->unk_0C += part->unk_20;
165 part->unk_64 += 0.2;
166 part->unk_68 += 0.6;
167 part->unk_18 += (part->unk_24 - part->unk_18) * 0.04;
168 part->unk_1C += (part->unk_28 - part->unk_1C) * 0.04;
169 part->unk_20 += (part->unk_2C - part->unk_20) * 0.04;
170 }
171 }
172}
173
175 RenderTask renderTask;
176 RenderTask* retTask;
177
179 renderTask.appendGfxArg = effect;
180 renderTask.dist = 10;
182
183 retTask = queue_render_task(&renderTask);
185}
186
187void shimmer_wave_appendGfx(void* effect) {
188 ShimmerWaveFXData* part = ((EffectInstance*)effect)->data.shimmerWave;
189 s32 unk_50 = part->unk_50;
190 s32 unk_54 = part->unk_54;
191 s32 unk_58 = part->unk_58;
192 f32 temp_4C = part->unk_4C / 255.0f;
193 Gfx* savedGfxPos;
194 Matrix4f sp20;
195 Matrix4f sp60;
196 s32 i;
197
198 gDPPipeSync(gMainGfxPos++);
199 gSPSegment(gMainGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(((EffectInstance*)effect)->graphics->data));
200
201 guTranslateF(sp20, part->unk_04, part->unk_08, part->unk_0C);
202 guScaleF(sp60, part->unk_60, part->unk_60, part->unk_60);
203 guMtxCatF(sp60, sp20, sp20);
205
206 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
207 gDPSetEnvColor(gMainGfxPos++, part->unk_40, part->unk_44, part->unk_48, part->unk_5C);
208 gSPDisplayList(gMainGfxPos++, D_09000F20_338EE0);
209
210 savedGfxPos = gMainGfxPos;
211 gMainGfxPos++;
212
213 part++;
214 for (i = 1; i < ((EffectInstance*)effect)->numParts; i++, part++) {
215 if (part->unk_30 >= 0) {
216 guPositionF(sp20, 0.0f, 0.0f, part->unk_34, part->unk_60 * temp_4C, part->unk_04, part->unk_08, part->unk_0C);
218
219 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
220 gDPSetPrimColor(gMainGfxPos++, 0, 0, unk_50, unk_54, unk_58, part->unk_4C * temp_4C);
221 gSPDisplayList(gMainGfxPos++, D_E0074B60[i & 7]);
222 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
223 }
224 }
225
226 gSPEndDisplayList(gMainGfxPos++);
227 gSPBranchList(savedGfxPos, gMainGfxPos);
228 gSPDisplayList(gMainGfxPos++, savedGfxPos + 1);
229
230 guRotateF(sp20, 120.0f, 0.0f, 1.0f, 0.0f);
232
233 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
234 gSPDisplayList(gMainGfxPos++, savedGfxPos + 1);
235 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
236
237 guRotateF(sp20, -120.0f, 0.0f, 1.0f, 0.0f);
239
240 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
241 gSPDisplayList(gMainGfxPos++, savedGfxPos + 1);
242 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
243 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
244}
Mtx matrixStack[0x200]
f32 Matrix4f[4][4]
s8 unk_14
Definition demo_api.c:19
#define general_heap_malloc
#define guRotateF
#define queue_render_task
#define guMtxF2L
#define sin_deg
#define guTranslateF
#define guMtxCatF
#define remove_effect
#define rand_int
#define guPositionF
#define cos_deg
#define create_effect_instance
#define guScaleF
struct ShimmerWaveFXData * shimmerWave
Definition effects.h:2522
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 ARRAY_COUNT(arr)
Definition macros.h:40
#define VIRTUAL_TO_PHYSICAL(addr)
Definition macros.h:47
Gfx D_090011E0_3391A0[]
Gfx D_09001228_3391E8[]
Gfx D_09000F20_338EE0[]
Gfx D_090011C8_339188[]
void shimmer_wave_update(EffectInstance *effect)
f32 D_E0074B80[]
void shimmer_wave_appendGfx(void *effect)
void shimmer_wave_init(EffectInstance *effect)
Gfx D_09001210_3391D0[]
EffectInstance * shimmer_wave_main(s32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4, f32 arg5, s32 arg6, s32 arg7)
void shimmer_wave_render(EffectInstance *effect)
Gfx D_090011F8_3391B8[]
Gfx D_09001258_339218[]
s32 D_E0074BD0[]
Gfx D_09001270_339230[]
Gfx * D_E0074B60[]
Gfx D_09001240_339200[]
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 *)
Gfx * gMainGfxPos
Definition cam_main.c:15
u16 gMatrixListPos
Definition main_loop.c:45
DisplayContext * gDisplayContext
Definition cam_main.c:16