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

Go to the source code of this file.

Functions

void windy_leaves_init (EffectInstance *effect)
 
void windy_leaves_update (EffectInstance *effect)
 
void windy_leaves_render (EffectInstance *effect)
 
void windy_leaves_appendGfx (void *effect)
 
void windy_leaves_main (s32 type, f32 arg1, f32 arg2, f32 arg3)
 

Variables

Gfx D_09001180_33E790 []
 
Gfx D_09001258_33E868 []
 
Gfx D_09001280_33E890 []
 

Function Documentation

◆ windy_leaves_init()

void windy_leaves_init ( EffectInstance * effect)

Definition at line 82 of file windy_leaves.c.

82 {
83}

Referenced by windy_leaves_main().

◆ windy_leaves_update()

void windy_leaves_update ( EffectInstance * effect)

Definition at line 85 of file windy_leaves.c.

85 {
86 WindyLeavesFXData* part = effect->data.windyLeaves;
87 f32 temp_f0_2;
88 f32 temp_f4;
89 s32 temp_v0;
90 s32 temp_v0_2;
91 s32 temp_a1;
92 s32 i;
93 s32 temp;
94 s32 temp2;
95
96 part->unk_28--;
97 part->unk_2C++;
98 if (part->unk_28 < 0) {
99 remove_effect(effect);
100 return;
101 }
102 temp_a1 = part->unk_2C;
103 temp_v0 = part->unk_28;
104 temp = part->type;
105 if (temp_a1 < 10) {
106 part->alpha += (255 - part->alpha) * 0.3;
107 }
108 if (temp_v0 < 10) {
109 part->alpha *= 0.8;
110 }
111
112 part++;
113 switch (temp) {
114 case 0:
115 for (i = 1; i < effect->numParts; i++, part++) {
116 f32 temp3 = (sin_deg(2.0f * part->unk_18) * 0.2);
117 part->unk_14 += -0.05f;
118 part->unk_10 += temp3;
119 if (temp == 0) {
120 part->unk_10 *= 0.94;
121 part->unk_14 *= sin_deg(part->unk_18) * 0.05 + 0.95;
122 } else {
123 part->unk_14 += -0.05f;
124 part->unk_10 *= 0.92;
125 }
126 part->unk_1C += effect_simple_rand(50, temp_a1 + i * 20) - 25;
127 part->unk_18 += sin_deg(part->unk_1C) * 10.0f;
128 part->unk_20 += cos_deg(part->unk_1C * 0.5) * 10.0f;
129 part->unk_04.x += part->unk_10;
130 part->unk_04.y += part->unk_14;
131 if (part->unk_04.y < 30.0f) {
132 if (part->unk_04.x > -200.0f) {
133 part->unk_30 -= 0.4;
134 } else {
135 part->unk_30 += 0.4;
136 }
137 if (part->unk_04.z > 0.0f) {
138 part->unk_38 -= 0.4;
139 } else {
140 part->unk_38 += 0.4;
141 }
142 part->unk_30 *= 0.98;
143 part->unk_38 *= 0.98;
144 part->unk_14 *= 0.98;
145 } else {
146 if(part->unk_04.x > 0.0f) {
147 part->unk_30 -= 0.4;
148 } else {
149 part->unk_30 += 0.4;
150 }
151 if (part->unk_04.z > 0.0f){
152 part->unk_38 -= 0.4;
153 } else {
154 part->unk_38 += 0.4;
155 }
156 part->unk_30 *= 0.98;
157 part->unk_38 *= 0.98;
158 }
159 part->unk_04.x += part->unk_30;
160 part->unk_04.y += part->unk_34;
161 part->unk_04.z += part->unk_38;
162 }
163 break;
164 case 1:
165 for (i = 1; i < effect->numParts; i++, part++) {
166 part->unk_10 += (f32)(sin_deg(2.0f * part->unk_18) * 0.2 * 2.0);
167 part->unk_14 += -0.05f;
168 part->unk_10 *= 0.8464;
169 part->unk_14 += -0.05f;
170 part->unk_1C += effect_simple_rand(50, temp_a1 + i * 20) - 25;
171 part->unk_18 += sin_deg(part->unk_1C) * 10.0f;
172 part->unk_20 += cos_deg(part->unk_1C * 0.5) * 10.0f;
173 part->unk_04.x += part->unk_10;
174 part->unk_04.y += part->unk_14;
175 if (part->unk_04.y < 30.0f) {
176 if (part->unk_04.x > -200.0f) {
177 part->unk_30 -= 0.8;
178 } else {
179 part->unk_30 += 0.8;
180 }
181 if (part->unk_04.z > 0.0f) {
182 part->unk_38 -= 0.8;
183 } else {
184 part->unk_38 += 0.8;
185 }
186 part->unk_30 *= 0.9603999999999999;
187 part->unk_38 *= 0.9603999999999999;
188 part->unk_14 *= 0.9603999999999999;
189 } else {
190 if (part->unk_04.x > 0.0f){
191 part->unk_30 -= 0.8;
192 } else {
193 part->unk_30 += 0.8;
194 }
195 if (part->unk_04.z > 0.0f){
196 part->unk_38 -= 0.8;
197 } else {
198 part->unk_38 += 0.8;
199 }
200 part->unk_30 *= 0.9603999999999999;
201 part->unk_38 *= 0.9603999999999999;
202 }
203 part->unk_04.x += part->unk_30;
204 part->unk_04.y += part->unk_34;
205 part->unk_04.z += part->unk_38;
206 }
207 break;
208 case 2:
209 for (i = 1; i < effect->numParts; i++, part++) {
210 part->unk_1C += effect_simple_rand(50, temp_a1 + i * 20) - 25;
211 part->unk_18 += sin_deg(part->unk_1C) * 10.0f;
212 part->unk_20 += cos_deg(part->unk_1C * 0.5) * 10.0f;
213 part->unk_04.x += part->unk_10;
214 part->unk_04.y += part->unk_14;
215 }
216 break;
217 }
218}
#define sin_deg
#define remove_effect
#define cos_deg
EffectData data
Definition effects.h:2605
struct WindyLeavesFXData * windyLeaves
Definition effects.h:2507
s32 effect_simple_rand(s32, s32)

Referenced by windy_leaves_main().

◆ windy_leaves_render()

void windy_leaves_render ( EffectInstance * effect)

Definition at line 220 of file windy_leaves.c.

220 {
221 RenderTask renderTask;
222 RenderTask* retTask;
223
225 renderTask.appendGfxArg = effect;
226 renderTask.dist = 0;
228
229 retTask = queue_render_task(&renderTask);
231}
#define queue_render_task
@ RENDER_TASK_FLAG_REFLECT_FLOOR
Definition enums.h:3318
@ RENDER_MODE_CLOUD_NO_ZCMP
Definition enums.h:3311
void * appendGfxArg
void(* appendGfx)(void *)
void windy_leaves_appendGfx(void *effect)

Referenced by windy_leaves_main().

◆ windy_leaves_appendGfx()

void windy_leaves_appendGfx ( void * effect)

Definition at line 233 of file windy_leaves.c.

233 {
234 WindyLeavesFXData* part = ((EffectInstance*)effect)->data.windyLeaves;
235 Matrix4f sp18, sp58, sp98;
236 Gfx* dlist;
237 s32 i;
238
239 dlist = D_09001280_33E890;
240 if (part->type == 0) {
241 dlist = D_09001258_33E868;
242 }
243
244 gSPSegment(gMainGfxPos++, 0x09, OS_K0_TO_PHYSICAL(((EffectInstance*)effect)->graphics->data));
245 gSPDisplayList(gMainGfxPos++, D_09001180_33E790);
246 gDPSetPrimColor(gMainGfxPos++, 0, 0, 20, 100, 20, part->alpha);
247 guTranslateF(sp18, part->unk_04.x, part->unk_04.y, part->unk_04.z);
248 guRotateF(sp58, -gCameras[gCurrentCameraID].curYaw, 0.0f, 1.0f, 0.0f);
249 guMtxCatF(sp58, sp18, sp98);
250
251 part++;
252 for (i = 1; i < ((EffectInstance*)effect)->numParts; i++, part++) {
253 guTranslateF(sp58, part->unk_04.x, part->unk_04.y, part->unk_04.z);
254 guMtxCatF(sp58, sp98, sp18);
255 guRotateF(sp58, part->unk_18, 0.0f, 0.0f, 1.0f);
256 guMtxCatF(sp58, sp18, sp18);
257 guRotateF(sp58, part->unk_20, 0.0f, 1.0f, 0.0f);
258 guMtxCatF(sp58, sp18, sp18);
260 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
261 gSPDisplayList(gMainGfxPos++, dlist);
262 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
263 }
264}
Mtx matrixStack[0x200]
f32 Matrix4f[4][4]
#define guRotateF
#define guMtxF2L
#define guTranslateF
#define guMtxCatF
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_09001180_33E790[]
Gfx D_09001258_33E868[]
Gfx D_09001280_33E890[]

Referenced by windy_leaves_render().

◆ windy_leaves_main()

void windy_leaves_main ( s32 type,
f32 arg1,
f32 arg2,
f32 arg3 )

Definition at line 13 of file windy_leaves.c.

13 {
15 EffectBlueprint* bpPtr = &bp;
16 EffectInstance* effect;
18 s32 numParts;
19 s32 i;
20
24 bp.unk_00 = 0;
25 bp.renderUI = NULL;
26 bp.effectID = EFFECT_WINDY_LEAVES;
27
28 numParts = 5;
29 effect = create_effect_instance(bpPtr);
30 effect->numParts = numParts;
31 effect->data.windyLeaves = part = general_heap_malloc(numParts * sizeof(*part));
32 ASSERT(part != NULL);
33
34 part->type = type;
35 part->unk_04.x = arg1;
36 part->unk_04.y = arg2;
37 part->unk_04.z = arg3;
38 part->unk_28 = 100;
39 part->unk_2C = 0;
40 part->alpha = 0;
41
42 part++;
43 for (i = 1; i < numParts; i++, part++) {
44 s32 temp_s0_2 = effect_rand_int(50);
45 s32 temp_s1 = effect_rand_int(20);
46 s32 temp_s2 = effect_rand_int(360);
47 s32 temp_v0_2 = effect_rand_int(100);
48 part->unk_04.x = temp_s0_2 + 75;
49 part->unk_04.y = temp_s1 + 70;
50 part->unk_04.z = 0;
51 part->unk_18 = temp_s2;
52 part->unk_20 = 360 - temp_s2;
53
54 switch (type) {
55 case 0:
56 part->unk_10 = 0.0f;
57 part->unk_14 = 0.0f;
58 part->unk_34 = 0;
59 part->unk_30 = -3.0f;
60 part->unk_38 = 3.0f;
61 part->unk_1C = (f32)temp_v0_2 * 0.1;
62 break;
63 case 1:
64 part->unk_10 = 0.0f;
65 part->unk_14 = 0.0f;
66 part->unk_34 = 0;
67 part->unk_30 = -6.0f;
68 part->unk_38 = 6.0f;
69 part->unk_1C = 2.0 * ((f32)temp_v0_2 * 0.1);
70 break;
71 case 2:
72 part->unk_1C = 2.0 * ((f32)temp_v0_2 * 0.1);
73 part->unk_10 = -part->unk_04.x * (rand_int(10) * 0.008 + 0.05);
74 part->unk_14 = -part->unk_04.y * (rand_int(10) * 0.008 + 0.05);
75 break;
76 default:
77 break;
78 }
79 }
80}
#define general_heap_malloc
#define rand_int
#define create_effect_instance
#define ASSERT(condition)
s32 effect_rand_int(s32)
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 windy_leaves_update(EffectInstance *effect)
void windy_leaves_render(EffectInstance *effect)
void windy_leaves_init(EffectInstance *effect)

Variable Documentation

◆ D_09001180_33E790

Gfx D_09001180_33E790[]
extern

Referenced by windy_leaves_appendGfx().

◆ D_09001258_33E868

Gfx D_09001258_33E868[]
extern

Referenced by windy_leaves_appendGfx().

◆ D_09001280_33E890

Gfx D_09001280_33E890[]
extern

Referenced by windy_leaves_appendGfx().