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

Go to the source code of this file.

Functions

void snowfall_init (EffectInstance *effect)
 
void snowfall_update (EffectInstance *effect)
 
void snowfall_render (EffectInstance *effect)
 
void snowfall_appendGfx (void *effect)
 
void func_E008A000 (SnowfallFXData *data)
 
EffectInstancesnowfall_main (s32 arg0, s32 arg1)
 
void func_E008A290 (SnowfallFXData *data, s32 arg1, s32 arg2, s32 arg3)
 

Variables

Gfx D_09000C00_38DC70 []
 
Gfx D_09000D50_38DDC0 []
 
Gfx * D_E008AA50 [] = { D_09000D50_38DDC0, D_09000D50_38DDC0 }
 

Function Documentation

◆ snowfall_init()

void snowfall_init ( EffectInstance * effect)

Definition at line 62 of file snowfall.c.

62 {
63}

Referenced by snowfall_main().

◆ snowfall_update()

void snowfall_update ( EffectInstance * effect)

Definition at line 113 of file snowfall.c.

113 {
114 Camera* camera = &gCameras[gCurrentCameraID];
115 SnowfallFXData* data = effect->data.snowfall;
116 s32 timeLeft;
117 s32 boomLength;
118 s32 temp_s5;
119 s32 temp_s6;
120 s32 i;
121
122 if (data->timeLeft < 100) {
123 data->timeLeft--;
124 }
125 if (data->timeLeft < 0) {
126 remove_effect(effect);
127 return;
128 }
129
130 data->lifeTime++;
131 timeLeft = data->timeLeft;
132 temp_s5 = data->unk_2C;
133 if (timeLeft < 10) {
134 data->unk_28 = timeLeft * 25;
135 }
136 boomLength = camera->curBoomLength;
137 temp_s6 = (boomLength * 0.3) + 1.0;
138
139 data++;
140 for (i = 0; i < temp_s5; i++, data++) {
141 if (data->unk_30 <= 0 || --data->unk_30 <= 0) {
142 data->unk_08 += data->unk_14;
143 data->unk_0C += data->unk_18;
144 data->unk_10 += data->unk_1C;
145 func_E008A290(data, boomLength, temp_s6, timeLeft);
146 }
147 }
148}
#define remove_effect
struct SnowfallFXData * snowfall
Definition effects.h:2533
EffectData data
Definition effects.h:2605
void func_E008A290(SnowfallFXData *data, s32 arg1, s32 arg2, s32 arg3)
Definition snowfall.c:65
f32 curBoomLength
Camera gCameras[4]
Definition cam_main.c:17
s32 gCurrentCameraID
Definition cam_math.c:4

Referenced by snowfall_main().

◆ snowfall_render()

void snowfall_render ( EffectInstance * effect)

Definition at line 150 of file snowfall.c.

150 {
151 RenderTask renderTask;
152 RenderTask* retTask;
153
154 renderTask.appendGfx = snowfall_appendGfx;
155 renderTask.appendGfxArg = effect;
156 renderTask.dist = 0;
158
159 retTask = queue_render_task(&renderTask);
161}
#define queue_render_task
@ RENDER_TASK_FLAG_REFLECT_FLOOR
Definition enums.h:3318
@ RENDER_MODE_CLOUD_NO_ZCMP
Definition enums.h:3311
void snowfall_appendGfx(void *effect)
Definition snowfall.c:163
void * appendGfxArg
void(* appendGfx)(void *)

Referenced by snowfall_main().

◆ snowfall_appendGfx()

void snowfall_appendGfx ( void * effect)

Definition at line 163 of file snowfall.c.

163 {
164 EffectInstance* effectTemp = effect;
165 SnowfallFXData* data = effectTemp->data.snowfall;
166 Matrix4f sp18;
167 Gfx* dlist;
168 Mtx* mtx;
169 u8 bgRGB;
170 u8 bgAlpha;
171 s32 unk_28;
172 s32 unk_2C;
173 s32 i;
174
175 if (data->unk_00 != 0) {
176 unk_28 = data->unk_28;
177 bgAlpha = 255;
178 unk_2C = data->unk_2C;
179 dlist = D_E008AA50[data->unk_04];
181 mdl_get_shroud_tint_params(&bgRGB, &bgRGB, &bgRGB, &bgAlpha);
182 unk_28 = 255 - bgAlpha;
183 }
184
185 if (unk_28 != 0) {
186 gDPPipeSync(gMainGfxPos++);
187 gSPSegment(gMainGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(((EffectInstance*)effect)->graphics->data));
188
189 gSPDisplayList(gMainGfxPos++, D_09000C00_38DC70);
190 gDPSetPrimColor(gMainGfxPos++, 0, 0, 255, 255, 255, unk_28);
191
192 guRotateF(sp18, -gCameras[gCurrentCameraID].curYaw, 0.0f, 1.0f, 0.0f);
194
196
197 data++;
198 for (i = 0; i < unk_2C; i++, data++) {
199 if (data->unk_30 <= 0 && data->unk_28 != 0) {
200 guTranslateF(sp18, data->unk_08, data->unk_0C, data->unk_10);
202
204 G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
205 gSPMatrix(gMainGfxPos++, mtx,
206 G_MTX_NOPUSH | G_MTX_MUL | G_MTX_MODELVIEW);
207 gSPDisplayList(gMainGfxPos++, dlist);
208 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
209 }
210 }
211 gDPPipeSync(gMainGfxPos++);
212 }
213 }
214}
Mtx matrixStack[0x200]
f32 Matrix4f[4][4]
#define guRotateF
#define guMtxF2L
#define guTranslateF
#define mdl_get_shroud_tint_params
@ ENV_TINT_SHROUD
Definition enums.h:4387
#define VIRTUAL_TO_PHYSICAL(addr)
Definition macros.h:47
Gfx D_09000C00_38DC70[]
Definition snowfall.c:11
Gfx * D_E008AA50[]
Definition snowfall.c:12
Gfx * gMainGfxPos
Definition cam_main.c:15
u16 gMatrixListPos
Definition main_loop.c:45
u8 * gBackgroundTintModePtr
Definition model.c:105
DisplayContext * gDisplayContext
Definition cam_main.c:16

Referenced by snowfall_render().

◆ func_E008A000()

void func_E008A000 ( SnowfallFXData * data)

Definition at line 14 of file snowfall.c.

14 {
16
17 data->unk_08 = (camera->lookAt_eye.x + effect_rand_int(2000)) - 1000.0f;
18 data->unk_0C = (camera->lookAt_eye.y + effect_rand_int(2000)) - 1000.0f;
19 data->unk_10 = (camera->lookAt_eye.z + effect_rand_int(2000)) - 1000.0f;
20 data->unk_14 = (effect_rand_int(20) - 10.0f) * 0.05;
21 data->unk_18 = -1.2 - (effect_rand_int(80) * 0.01);
22 data->unk_1C = (effect_rand_int(20) - 10.0f) * 0.05;
23 data->unk_28 = 255;
24}
s32 effect_rand_int(s32)
Vec3f lookAt_eye

Referenced by snowfall_main().

◆ snowfall_main()

EffectInstance * snowfall_main ( s32 arg0,
s32 arg1 )

Definition at line 26 of file snowfall.c.

26 {
27 EffectBlueprint effectBp;
28 EffectInstance* effect;
29 SnowfallFXData* data;
30 s32 numParts = arg1 + 1;
31 s32 i;
32
33 effectBp.init = snowfall_init;
34 effectBp.update = snowfall_update;
36 effectBp.unk_00 = 0;
37 effectBp.renderUI = NULL;
38 effectBp.effectID = EFFECT_SNOWFALL;
39
40 effect = create_effect_instance(&effectBp);
41 effect->numParts = numParts;
42
43 data = effect->data.snowfall = general_heap_malloc(numParts * sizeof(*data));
44 ASSERT(data != NULL);
45
46 data->timeLeft = 100;
47 data->lifeTime = 0;
48 data->unk_28 = 255;
49 data->unk_04 = arg0;
50 data->unk_2C = arg1;
51 data->unk_00 = 1;
52
53 data++;
54 for (i = 0; i < arg1; i++, data++) {
55 func_E008A000(data);
56 data->unk_30 = 0;
57 }
58
59 return effect;
60}
#define general_heap_malloc
#define create_effect_instance
#define ASSERT(condition)
void func_E008A000(SnowfallFXData *data)
Definition snowfall.c:14
void snowfall_init(EffectInstance *effect)
Definition snowfall.c:62
void snowfall_update(EffectInstance *effect)
Definition snowfall.c:113
void snowfall_render(EffectInstance *effect)
Definition snowfall.c:150
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_E008A290()

void func_E008A290 ( SnowfallFXData * data,
s32 arg1,
s32 arg2,
s32 arg3 )

Definition at line 65 of file snowfall.c.

65 {
67 f32 unk_08 = data->unk_08;
68 f32 unk_0C = data->unk_0C;
69 f32 unk_10 = data->unk_10;
70 f32 lookX = camera->lookAt_obj.x;
71 f32 lookY = camera->lookAt_obj.y;
72 f32 lookZ = camera->lookAt_obj.z;
73 s32 temp_f12;
74 s32 temp_f12_2;
75 s32 temp_f12_3;
76
77 temp_f12 = unk_08 - lookX;
78 if (arg1 < temp_f12) {
79 temp_f12 = temp_f12 % arg1;
80 data->unk_08 = (lookX - arg1) + temp_f12;
81 } else if (-arg1 > temp_f12) {
82 temp_f12 = -temp_f12;
83 temp_f12 = temp_f12 % arg1;
84 data->unk_08 = (lookX + arg1) - temp_f12;
85 }
86
87 temp_f12_2 = unk_0C - lookY;
88 if (arg2 < temp_f12_2) {
89 temp_f12_2 = temp_f12_2 % arg2;
90 data->unk_0C = (lookY - arg2) + temp_f12_2;
91 } else if (temp_f12_2 < -arg2) {
92 if (arg3 < 100) {
93 data->unk_18 = 0;
94 data->unk_28 = 0;
95 } else {
96 temp_f12_2 = -temp_f12_2;
97 temp_f12_2 = temp_f12_2 % arg2;
98 data->unk_0C = (lookY + arg2) - temp_f12_2;
99 }
100 }
101
102 temp_f12_3 = unk_10 - lookZ;
103 if (arg1 < temp_f12_3) {
104 temp_f12_3 = temp_f12_3 % arg1;
105 data->unk_10 = (lookZ - arg1) + temp_f12_3;
106 } else if (temp_f12_3 < -arg1) {
107 temp_f12_3 = -temp_f12_3;
108 temp_f12_3 = temp_f12_3 % arg1;
109 data->unk_10 = (lookZ + arg1) - temp_f12_3;
110 }
111}
Vec3f lookAt_obj

Referenced by snowfall_update().

Variable Documentation

◆ D_09000C00_38DC70

Gfx D_09000C00_38DC70[]
extern

Definition at line 11 of file snowfall.c.

11{ 0xE7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xD7, 0x00, 0x10, 0x02, 0xFF, 0xFF, 0xFF, 0xFF };

Referenced by snowfall_appendGfx().

◆ D_09000D50_38DDC0

Gfx D_09000D50_38DDC0[]
extern

◆ D_E008AA50

Gfx* D_E008AA50[] = { D_09000D50_38DDC0, D_09000D50_38DDC0 }

Definition at line 12 of file snowfall.c.

Gfx D_09000D50_38DDC0[]

Referenced by snowfall_appendGfx().