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