Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
drop_leaves.c
Go to the documentation of this file.
1#include "common.h"
2#include "effects_internal.h"
3
4extern Gfx D_09001180_33E790[];
5extern Gfx D_09001230_33E840[];
6
10void drop_leaves_appendGfx(void* effect);
11
12void drop_leaves_main(s32 arg0, f32 arg1, f32 arg2, f32 arg3, s32 arg4) {
14 EffectInstance* effect;
15 DropLeavesFXData* part;
16 s32 numParts = 5;
17 s32 i;
18
22 bp.unk_00 = 0;
23 bp.renderUI = NULL;
24 bp.effectID = EFFECT_DROP_LEAVES;
25
26 effect = create_effect_instance(&bp);
27 effect->numParts = numParts;
28 part = effect->data.dropLeaves = general_heap_malloc(numParts * sizeof(*part));
29 ASSERT(effect->data.dropLeaves != NULL);
30
31 part->unk_00 = arg0;
32 part->unk_04 = arg1;
33 part->unk_08 = arg2;
34 part->unk_0C = arg3;
35 part->unk_28 = arg4;
36 part->unk_2C = 0;
37 part->unk_24 = 0;
38
39 part++;
40 for (i = 1; i < numParts; i++, part++) {
41 if (arg0 == 0) {
42 part->unk_04 = effect_rand_int(50) - 25;
43 part->unk_08 = effect_rand_int(50) - 25;
44 part->unk_0C = 0.0f;
45 part->unk_18 = effect_rand_int(360);
46 part->unk_20 = effect_rand_int(360);
47 part->unk_1C = effect_rand_int(100) / 10.0f;
48 part->unk_10 = 0;
49 part->unk_14 = 0;
50 } else {
51 part->unk_04 = effect_rand_int(10) - 5;
52 part->unk_08 = effect_rand_int(10) + 5;
53 part->unk_0C = 10.0f;
54 part->unk_18 = effect_rand_int(360);
55 part->unk_20 = effect_rand_int(360);
56 part->unk_1C = effect_rand_int(100) / 10.0f;
57 part->unk_10 = 0;
58 part->unk_14 = 2.0f;
59 }
60 }
61}
62
64}
65
67 DropLeavesFXData* part = effect->data.dropLeaves;
68 s32 unk_00;
69 s32 unk_28;
70 s32 unk_2C;
71 f32 temp;
72 s32 i;
73
74 part->unk_28--;
75 part->unk_2C++;
76
77 if (part->unk_28 < 0) {
78 remove_effect(effect);
79 return;
80 }
81
82 unk_00 = part->unk_00;
83 unk_28 = part->unk_28;
84 unk_2C = part->unk_2C;
85
86 if (unk_2C < 10) {
87 part->unk_24 += (255 - part->unk_24) * 0.3;
88 }
89 if (unk_28 < 10) {
90 part->unk_24 *= 0.8;
91 }
92
93 part++;
94 for (i = 1; i < effect->numParts; i++, part++) {
95 temp = sin_deg(2.0f * part->unk_18) * 0.2;
96
97 part->unk_14 += -0.05f;
98 part->unk_10 += temp;
99
100 if (unk_00 == 0) {
101 part->unk_10 *= 0.94;
102 part->unk_14 *= sin_deg(part->unk_18) * 0.05 + 0.95;
103 } else {
104 part->unk_14 += -0.05f;
105 part->unk_10 *= 0.92;
106 }
107
108 part->unk_1C += effect_simple_rand(50, unk_2C + i * 20) - 25;
109 part->unk_18 += sin_deg(part->unk_1C) * 10.0f;
110 part->unk_20 += cos_deg(part->unk_1C * 0.5f) * 10.0f;
111 part->unk_04 += part->unk_10;
112 part->unk_08 += part->unk_14;
113 }
114}
115
117 RenderTask renderTask;
118 RenderTask* retTask;
119
120 renderTask.appendGfx = drop_leaves_appendGfx;
121 renderTask.appendGfxArg = effect;
122 renderTask.dist = 0;
124
125 retTask = queue_render_task(&renderTask);
127}
128
129void drop_leaves_appendGfx(void* effect) {
130 DropLeavesFXData* part = ((EffectInstance*)effect)->data.dropLeaves;
131 Matrix4f sp18;
132 Matrix4f sp58;
133 Matrix4f sp98;
134 s32 i;
135
136 gSPSegment(gMainGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(((EffectInstance*)effect)->graphics->data));
137 gSPDisplayList(gMainGfxPos++, D_09001180_33E790);
138 gDPSetPrimColor(gMainGfxPos++, 0, 0, 20, 100, 20, part->unk_24);
139
140 guTranslateF(sp18, part->unk_04, part->unk_08, part->unk_0C);
141 guRotateF(sp58, -gCameras[gCurrentCameraID].curYaw, 0.0f, 1.0f, 0.0f);
142 guMtxCatF(sp58, sp18, sp98);
143
144 part++;
145 for (i = 1; i < ((EffectInstance*)effect)->numParts; i++, part++) {
146 guTranslateF(sp58, part->unk_04, part->unk_08, part->unk_0C);
147 guMtxCatF(sp58, sp98, sp18);
148 guRotateF(sp58, part->unk_18, 0.0f, 0.0f, 1.0f);
149 guMtxCatF(sp58, sp18, sp18);
150 guRotateF(sp58, part->unk_20, 0.0f, 1.0f, 0.0f);
151 guMtxCatF(sp58, sp18, sp18);
153
154 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
155 gSPDisplayList(gMainGfxPos++, D_09001230_33E840);
156 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
157 }
158}
Mtx matrixStack[0x200]
f32 Matrix4f[4][4]
Gfx D_09001230_33E840[]
void drop_leaves_update(EffectInstance *effect)
Definition drop_leaves.c:66
Gfx D_09001180_33E790[]
void drop_leaves_render(EffectInstance *effect)
void drop_leaves_main(s32 arg0, f32 arg1, f32 arg2, f32 arg3, s32 arg4)
Definition drop_leaves.c:12
void drop_leaves_init(EffectInstance *effect)
Definition drop_leaves.c:63
void drop_leaves_appendGfx(void *effect)
#define general_heap_malloc
#define guRotateF
#define queue_render_task
#define guMtxF2L
#define sin_deg
#define guTranslateF
#define guMtxCatF
#define remove_effect
#define cos_deg
#define create_effect_instance
struct DropLeavesFXData * dropLeaves
Definition effects.h:2484
EffectData data
Definition effects.h:2605
s32 effect_simple_rand(s32, s32)
#define ASSERT(condition)
s32 effect_rand_int(s32)
@ RENDER_TASK_FLAG_REFLECT_FLOOR
Definition enums.h:3318
@ RENDER_MODE_CLOUD_NO_ZCMP
Definition enums.h:3311
#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 *)
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