Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
snowman_doll.c
Go to the documentation of this file.
1#include "common.h"
2#include "effects_internal.h"
3
4extern Gfx D_090037A8_3C1148[];
5extern Gfx D_09003818_3C11B8[];
6
7s8 D_E00C0A10[] = {
8 100, 90, 82, 76, 72, 70, 74, 89, 103, 116,
9 118, 120, 120, 120, 120, 118, 114
10};
11
12s8 D_E00C0A21 = 110;
13
14u8 D_E00C0A24[] = {
15 100, 90, 82, 76, 72, 70, 74, 89, 100, 108,
16 110, 108, 102, 96, 95, 96, 99, 101, 100, 100,
17 100, 100, 100, 100, 100, 100, 100
18};
19
20u8 D_E00C0A40[] = {
21 100, 90, 82, 76, 72, 70, 70, 70, 70, 70,
22 70, 70, 70, 70, 70, 70, 70, 70, 70, 70,
23 70, 70, 70, 70, 70, 70, 70, 70, 70, 70,
24 70, 70, 70, 70, 70, 70, 70, 70, 70, 70,
25 70, 70, 70, 70, 70, 70, 70, 70, 70, 70,
26 70, 70, 70, 70, 70, 70, 70, 70, 70, 70,
27 70, 70, 74, 89, 103, 116, 118, 120, 120, 120,
28 120, 118, 114, 110
29};
30
31s8 D_E00C0A8C[] = {
32 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x05, 0x0A, 0x10, 0x16, 0x1C, 0x21, 0x26, 0x28, 0x29,
34 0x29, 0x28, 0x26, 0x21, 0x1C, 0x16, 0x10, 0x0A, 0x05, 0x01, 0x01, 0x05, 0x0A, 0x10, 0x16,
35 0x1C, 0x21, 0x26, 0x28, 0x29, 0x29, 0x28, 0x26, 0x21, 0x1C, 0x16, 0x10, 0x0A, 0x05, 0x01,
36 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37 0x00, 0xFF, 0x38, 0x00, 0xC8, 0x1E, 0x64, 0x64, 0x00, 0xFF, 0x4C, 0x00, 0xB4, 0x1E, 0x64,
38 0x64, 0x00, 0xFF, 0x60, 0x00, 0xA0, 0x1E, 0x64, 0x64, 0x00, 0xFF, 0x74, 0x00, 0x8C, 0x1E,
39 0x64, 0x64, 0x00, 0xFF, 0x88, 0x00, 0x78, 0x1E, 0x64, 0x64, 0x00, 0xFF, 0x9C, 0x00, 0x64,
40 0x1E, 0x64, 0x64, 0x00, 0xFF, 0xB0, 0x00, 0x50, 0x1E, 0x64, 0x64, 0x00, 0xFF, 0xC4, 0x00,
41 0x3C, 0x1E, 0x64, 0x64, 0x00, 0xFF, 0xD8, 0x00, 0x28, 0x1E, 0x64, 0x64, 0x00, 0xFF, 0xEC,
42 0x00, 0x14, 0x1E, 0x64, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x64, 0x64, 0x00, 0x00,
43 0x00, 0x00, 0x00, 0x1E, 0x78, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0x82, 0x46, 0x00,
44 0x00, 0x00, 0x00, 0x00, 0x05, 0x87, 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x8A, 0x3E,
45 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8C, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8C,
46 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x8C, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF,
47 0x8C, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x8A, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x00,
48 0xFE, 0x87, 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFD, 0x82, 0x46, 0x00, 0x00, 0x00, 0x00,
49 0x00, 0xFC, 0x78, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFA, 0x64, 0x64, 0x00, 0x00, 0x00,
50 0x00, 0x00, 0xFA, 0x64, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x64, 0x64, 0x00, 0x00,
51 0x00, 0x00, 0x01, 0xF4, 0x64, 0x64, 0x00, 0x00, 0x00, 0x00, 0x03, 0xEE, 0x64, 0x64, 0x00,
52 0x00, 0x00, 0x00, 0x05, 0xE6, 0x64, 0x64, 0x00, 0x00, 0x00, 0x00, 0x0A, 0xDC, 0x64, 0x64,
53 0x00, 0x00, 0x00, 0x00, 0x0F, 0xD0, 0x64, 0x64, 0x00, 0x00, 0x00, 0x00, 0x14, 0xC2, 0x64,
54 0x64, 0x00, 0x00, 0x00, 0x00, 0x1C, 0xB2, 0x64, 0x64, 0x00, 0x00, 0x05, 0x00, 0x1E, 0xA0,
55 0x64, 0x64, 0x00, 0x00, 0x08, 0x00, 0x1E, 0xA0, 0x64, 0x64, 0x00, 0x00, 0x0A, 0x00, 0x1E,
56 0xA0, 0x64, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
57};
58
62void snowman_doll_appendGfx(void* effect);
63
65 s32 arg0,
66 f32 arg1,
67 f32 arg2,
68 f32 arg3,
69 f32 arg4,
70 s32 arg5
71) {
73 EffectInstance* effect;
75 s32 numParts = 1;
76
80 bp.unk_00 = 0;
81 bp.renderUI = NULL;
82 bp.effectID = EFFECT_SNOWMAN_DOLL;
83
84 effect = create_effect_instance(&bp);
85 effect->numParts = numParts;
86 data = effect->data.snowmanDoll = general_heap_malloc(numParts * sizeof(*data));
87 ASSERT(effect->data.snowmanDoll != NULL);
88
89 data->unk_00 = arg0;
90 data->unk_14 = 0;
91 if (arg5 <= 0) {
92 data->unk_10 = 1000;
93 } else {
94 data->unk_10 = arg5;
95 }
96 data->unk_24 = 0;
97 data->unk_04 = arg1;
98 data->unk_08 = arg2;
99 data->unk_0C = arg3;
100 data->unk_30 = 0;
101 data->unk_34 = 200.0f;
102 data->unk_38 = 0;
103 data->unk_3C = 0;
104 data->unk_40 = 0;
105 data->unk_44 = 0;
106 data->unk_54 = 0;
107 data->unk_58 = 2;
108 data->unk_28 = arg4;
109 data->unk_5C = 0;
110 data->unk_18 = 200;
111 data->unk_1C = 220;
112 data->unk_20 = 240;
113 data->unk_2C = 0;
114 data->unk_40 = -8.0f;
115 data->unk_50 = -1.0f;
116
117 return effect;
118}
119
122
125
127 SnowmanDollFXData* data = effect->data.snowmanDoll;
128 s32 unk_14;
129 s32 unk_58;
130
131 if (effect->flags & FX_INSTANCE_FLAG_DISMISS) {
132 effect->flags &= ~FX_INSTANCE_FLAG_DISMISS;
133 data->unk_10 = 16;
134 }
135
136 if (data->unk_10 < 1000) {
137 data->unk_10--;
138 }
139
140 data->unk_14++;
141
142 if (data->unk_10 < 0) {
143 remove_effect(effect);
144 return;
145 }
146
147 unk_14 = data->unk_14;
148
149 if (data->unk_10 < 16) {
150 data->unk_24 = data->unk_10 * 16;
151 }
152
153 if (unk_14 < 16) {
154 data->unk_24 = unk_14 * 16 + 15;
155 }
156
157 if (data->unk_3C != 0.0f) {
158 f32 unk_40 = data->unk_40;
159
160 if (unk_40 < 0.0f) {
161 unk_40 = -unk_40;
162 }
163
164 if (data->unk_3C < 0.0f) {
165 data->unk_2C -= unk_40;
166 } else {
167 data->unk_2C += unk_40;
168 }
169 }
170
171 unk_58 = data->unk_58;
172
173 switch (unk_58) {
174 case 0:
175 data->unk_4C = (f32) D_E00C0A24[data->unk_54++] * 0.01;
176 data->unk_48 = 2.0f - data->unk_4C;
177 if (data->unk_54 >= ARRAY_COUNT(D_E00C0A24)) {
178 data->unk_58 = 2;
179 }
180 break;
181 case 1:
182 data->unk_4C = (f32) D_E00C0A10[data->unk_54++] * 0.01;
183 data->unk_48 = 2.0f - data->unk_4C;
184 if (data->unk_54 >= ARRAY_COUNT(D_E00C0A10) + 1) {
185 data->unk_58 = 2;
186 }
187 if (data->unk_54 >= 8) {
188 data->unk_30 += data->unk_3C;
189 data->unk_34 += data->unk_40;
190 data->unk_38 += data->unk_44;
191 data->unk_40 += -1.0f;
192 }
193 break;
194 case 3:
195 data->unk_4C = (f32) D_E00C0A40[data->unk_54++] * 0.01;
196 data->unk_48 = 2.0f - data->unk_4C;
197 data->unk_2C = D_E00C0A8C[data->unk_54++];
198 if (data->unk_54 >= ARRAY_COUNT(D_E00C0A40)) {
199 data->unk_58 = 2;
200 }
201 if (data->unk_54 >= 64) {
202 data->unk_30 += data->unk_3C;
203 data->unk_34 += data->unk_40;
204 data->unk_38 += data->unk_44;
205 data->unk_40 += -1.0f;
206 }
207 break;
208 case 2:
209 data->unk_30 += data->unk_3C;
210 data->unk_34 += data->unk_40;
211 data->unk_38 += data->unk_44;
212 data->unk_40 += data->unk_50;
213 data->unk_4C = (f32) D_E00C0A21 * 0.01;
214 data->unk_48 = 2.0f - data->unk_4C;
215 if (data->unk_34 < 0.0f) {
216 switch (data->unk_5C) {
217 case 0:
218 data->unk_58 = 0;
219 break;
220 case 1:
221 data->unk_58 = 1;
222 data->unk_3C = 2.0f;
223 data->unk_44 = 2.0f;
224 data->unk_40 = 10.0f;
225 break;
226 case 2:
227 data->unk_58 = 1;
228 data->unk_3C = 2.0f;
229 data->unk_44 = -2.0f;
230 data->unk_40 = 10.0f;
231 break;
232 case 3:
233 data->unk_58 = 1;
234 data->unk_3C = -2.0f;
235 data->unk_44 = -2.0f;
236 data->unk_40 = 10.0f;
237 break;
238 case 4:
239 data->unk_44 = 0.0f;
240 data->unk_58 = 1;
241 data->unk_3C = 10.0f;
242 data->unk_40 = 14.0f;
243 data->unk_50 = -1.0f;
244 break;
245 default:
246 data->unk_3C = 0.0f;
247 data->unk_40 = 0.0f;
248 data->unk_44 = 0.0f;
249 data->unk_34 = 0.0f;
250 data->unk_58 = unk_58;
251 break;
252 }
253 data->unk_34 = 0.0f;
254 data->unk_54 = 0;
255 data->unk_5C++;
256 }
257 break;
258 }
259
260 if ((unk_14 & 7) == 1) {
261 load_effect(EFFECT_COLD_BREATH);
263 data->unk_04 + data->unk_30 + rand_int(60) - 30.0f,
264 data->unk_08 + data->unk_34 + rand_int(100) + 50.0f,
265 data->unk_0C + data->unk_38,
266 4.0f, 40);
267 load_effect(EFFECT_MISC_PARTICLES);
269 data->unk_04 + data->unk_30,
270 data->unk_08 + data->unk_34 + 10.0f,
271 data->unk_0C + data->unk_38 + 60.0f,
272 60.0f, 100.0f, 2.0f, 10, 30);
273 }
274}
275
277 RenderTask renderTask;
278 RenderTask* retTask;
279
281 renderTask.appendGfxArg = effect;
282 renderTask.dist = -10;
284
285 retTask = queue_render_task(&renderTask);
287}
288
289void func_E00C0758(void) {
290}
291
292void snowman_doll_appendGfx(void* effect) {
293 SnowmanDollFXData* data = ((EffectInstance*)effect)->data.snowmanDoll;
294 s32 unk_24 = data->unk_24;
295 Matrix4f sp18;
296 Matrix4f sp58;
297
298 gDPPipeSync(gMainGfxPos++);
299 gSPSegment(gMainGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(((EffectInstance*)effect)->graphics->data));
300
301 guTranslateF(sp18, data->unk_04, data->unk_08, data->unk_0C);
302 guScaleF(sp58, data->unk_28, data->unk_28, data->unk_28);
303 guMtxCatF(sp58, sp18, sp18);
305
306 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
307
308 guTranslateF(sp18, data->unk_30, data->unk_34, data->unk_38);
309 guScaleF(sp58, data->unk_48, data->unk_4C, data->unk_48);
310 guMtxCatF(sp58, sp18, sp18);
311 guRotateF(sp58, data->unk_2C, 0.0f, 1.0f, 0.0f);
312 guMtxCatF(sp58, sp18, sp18);
314
315 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
316 gDPSetPrimColor(gMainGfxPos++, 0, 0, data->unk_18, data->unk_1C, data->unk_20, unk_24);
317 gSPDisplayList(gMainGfxPos++, D_090037A8_3C1148);
318 gSPDisplayList(gMainGfxPos++, D_09003818_3C11B8);
319 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
320 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
321}
EffectInstance * cold_breath_main(s32 type, f32 posX, f32 posY, f32 posZ, f32 scale, s32 duration)
Definition cold_breath.c:79
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 guTranslateF
#define guMtxCatF
#define remove_effect
#define rand_int
#define load_effect
#define create_effect_instance
#define guScaleF
void snowman_doll_render(EffectInstance *effect)
s8 D_E00C0A21
EFFECT_DEF_COLD_BREATH(cold_breath_main)
void snowman_doll_appendGfx(void *effect)
u8 D_E00C0A40[]
u8 D_E00C0A24[]
EffectInstance * snowman_doll_main(s32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4, s32 arg5)
Gfx D_09003818_3C11B8[]
s8 D_E00C0A8C[]
s8 D_E00C0A10[]
Definition snowman_doll.c:7
void func_E00C0758(void)
void snowman_doll_update(EffectInstance *effect)
void snowman_doll_init(EffectInstance *effect)
Gfx D_090037A8_3C1148[]
EFFECT_DEF_MISC_PARTICLES(misc_particles_main)
struct SnowmanDollFXData * snowmanDoll
Definition effects.h:2560
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_PASS_THROUGH
Definition enums.h:3306
EffectInstance * misc_particles_main(s32 variation, f32 posX, f32 posY, f32 posZ, f32 scaleX, f32 scaleY, f32 arg6, s32 numParticles, s32 duration)
#define ARRAY_COUNT(arr)
Definition macros.h:40
#define VIRTUAL_TO_PHYSICAL(addr)
Definition macros.h:47
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