Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
fire_flower.c
Go to the documentation of this file.
1#include "common.h"
2#include "effects_internal.h"
3
4extern char D_09000000_3803A0[][0x200];
10
11s8 D_E007EC30[] = { 50, 60, 70, 80, 90, 100, 105, 100 };
12
13void fire_flower_appendGfx(void* effect);
17
20 EffectInstance* effect;
23 s32 numParts = 31;
24 s32 i;
25
26 bp.unk_00 = 0;
27 bp.init = fire_flower_init;
28 bp.update = fire_flower_update;
29 bp.renderScene = fire_flower_render;
30 bp.renderUI = nullptr;
31 bp.effectID = EFFECT_FIRE_FLOWER;
32
33 effect = create_effect_instance(&bp);
34 effect->numParts = numParts;
35 part = general_heap_malloc(numParts * sizeof(*part));
36 effect->data.fireFlower = part;
37
38 ASSERT(effect->data.fireFlower != nullptr);
39
40 part->unk_04 = 0;
41 part->unk_00 = arg0;
42 part->pos.x = arg1;
43 part->pos.y = arg2;
44 part->pos.z = arg3;
45 part->unk_40.x = arg4;
46 part->unk_40.y = 0;
47 part->unk_34 = 0;
48 part->unk_38 = 0;
49 part->unk_28 = 0;
50
51 part->unk_3C = 255;
52 part->unk_30 = 0.5f;
53 part->unk_2C = -10.0f;
54
55 part++;
56
57 for (i = 1; i < numParts; i++, part++) {
58 partData = &part->unk_40;
59 part->unk_00 = 1;
60 part->pos.x = 0;
61 part->pos.y = 0;
62 part->pos.z = 0;
63 part->unk_14 = 8.0f;
64 part->unk_18 = 0;
65 part->unk_1C = effect_rand_int(20) - 8;
66 part->unk_20 = (effect_rand_int(10) - 5) * 0.05;
67 part->unk_24 = effect_rand_int(80) + 5;
68 part->unk_3C = 255;
69 partData->z = i - 1;
70 partData->x = 10;
71 }
72
73 return effect;
74}
75
77}
78
80
83 s32 unk_04;
85 s32 i;
86
87 part->unk_40.y++;
88 part->unk_40.x++;
89
90 unk_04 = part->unk_04;
91 unk_40X = part->unk_40.x;
92
93 if (unk_04 == 7) {
94 remove_effect(effect);
95 return;
96 }
97
98 switch (unk_04) {
99 case 0:
101 stars_spread_main(0, part->pos.x - 10.0f, part->pos.y, part->pos.z, 7, 20);
102 part->unk_34 = 0;
103 part->unk_38 = 0;
104 part->unk_40.x = 0;
105 part->unk_04++;
106 break;
107 case 1:
109 part->unk_40.x = 0;
110 part->unk_04++;
111 } else {
112 part->unk_30 = D_E007EC30[unk_40X - 1] * 0.01;
113 part->unk_34 = 0;
114 part->unk_38 = 0;
115 }
116 break;
117 case 2:
118 if (unk_40X >= 2) {
119 part->unk_40.x = 0;
120 part->unk_04++;
121 } else {
122 part->unk_34 = 1;
123 }
124 break;
125 case 3:
126 if (unk_40X >= 15) {
127 part->unk_40.x = 0;
128 part->unk_04++;
129 } else {
130 part->unk_34 = 2;
131 }
132 break;
133 case 4:
134 if (unk_40X >= 45) {
135 part->unk_40.x = 0;
136 part->unk_04++;
137 } else {
138 part->unk_34 = 3;
139 part->unk_2C = 0;
140 if (unk_40X % 2) {
141 part->unk_30 = 1.0f;
142 } else {
143 part->unk_30 = 1.05f;
144 }
145 }
146 break;
147 case 5:
148 if (unk_40X >= 10) {
149 part->unk_40.x = 0;
150 part->unk_04++;
151 } else {
152 part->unk_34 = 0;
153 part->unk_2C = -10.0f;
154 }
155 break;
156 case 6:
157 part->unk_28 += 36.0f;
158 part->unk_34 = 0;
159 part->unk_3C *= 0.9;
160 if (part->unk_28 >= 720.0f) {
161 part->unk_28 = 720.0f;
162 part->unk_04++;
163 }
164 break;
165 }
166
167 unk_04 = part->unk_04;
168 part++;
169
170 if (unk_04 == 4 || unk_04 == 5 || unk_04 == 6) {
171 for (i = 1; i < effect->numParts; i++, part++) {
172 if (part->unk_40.z <= 0 || --part->unk_40.z <= 0) {
173 part->unk_18 += part->unk_20;
174 part->pos.x += part->unk_14;
175 part->pos.y += part->unk_18;
176 part->pos.z += part->unk_1C;
177
178 if (unk_04 == 4 && part->pos.x > 200.0f) {
179 part->pos.x = 0;
180 part->pos.y = 0;
181 part->unk_18 = 0;
182 part->pos.z = 0;
183 }
184 }
185 }
186 }
187}
188
201
202void fire_flower_appendGfx(void* effect) {
203 FireFlowerFXData* part = ((EffectInstance*)effect)->data.fireFlower;
204 s32 unk_34 = part->unk_34;
205 f32 unk_30 = part->unk_30;
206 s32 unk_04 = part->unk_04;
207 f32 unk_28 = part->unk_28;
208 f32 unk_2C = part->unk_2C;
211 s32 i;
212
214 gSPSegment(gMainGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(((EffectInstance*)effect)->shared->graphics));
215
216 guTranslateF(sp18, part->pos.x, part->pos.y, part->pos.z);
217 guRotateF(sp58, -gCameras[gCurrentCameraID].curYaw, 0.0f, 1.0f, 0.0f);
220
222 gDPSetPrimColor(gMainGfxPos++, 0, 0, 255, 0, 0, part->unk_3C);
223 gDPSetEnvColor(gMainGfxPos++, 255, 0, 0, part->unk_38);
224
225 if ((u32) (unk_04 - 4) < 3U) {
226 guTranslateF(sp18, 0.0f, 16.0f, 0.0f);
228
231
232 part++;
233 for (i = 1; i < ((EffectInstance*)effect)->numParts; i++, part++) {
234 if (part->unk_40.z == 0) {
235 guRotateF(sp18, part->unk_24, 0.0f, 0.0f, 1.0f);
236 guTranslateF(sp58, part->pos.x, part->pos.y, part->pos.z);
239
243 }
244 }
245
247 }
248
251 gMainGfxPos++, D_09000000_3803A0[3 - unk_34],
252 G_IM_FMT_CI, 32, 0, 0, 0, 31, 31, 0,
254 5, 5, G_TX_NOLOD, G_TX_NOLOD);
256 gMainGfxPos++, D_09000000_3803A0[2 - unk_34],
257 0x0080, 1, G_IM_FMT_CI, 32, 0, 0, 0, 31, 31, 0,
259 5, 5, G_TX_NOLOD, G_TX_NOLOD);
260
261 guTranslateF(sp18, unk_2C, 0.0f, 0.0f);
262 guScaleF(sp58, unk_30, unk_30, unk_30);
264 guRotateF(sp58, unk_28, 0.0f, 1.0f, 0.0f);
267
272}
BSS s32 PopupMenu_SelectedIndex
Mtx matrixStack[0x200]
f32 Matrix4f[4][4]
#define general_heap_malloc
#define guRotateF
#define queue_render_task
#define guMtxF2L
#define guTranslateF
#define guMtxCatF
#define remove_effect
#define load_effect
#define create_effect_instance
#define guScaleF
Gfx D_09000D40_3810E0[]
void fire_flower_init(EffectInstance *effect)
Definition fire_flower.c:76
Gfx D_09000ED8_381278[]
EffectInstance * fire_flower_main(s32 arg0, f32 arg1, f32 arg2, f32 arg3, s32 arg4)
Definition fire_flower.c:18
s8 D_E007EC30[]
Definition fire_flower.c:11
void fire_flower_render(EffectInstance *effect)
Gfx D_09000DE0_381180[]
void fire_flower_update(EffectInstance *effect)
Definition fire_flower.c:81
EFFECT_DEF_STARS_SPREAD(stars_spread_main)
Gfx D_09000EB8_381258[]
Gfx D_09000EF8_381298[]
char D_09000000_3803A0[][0x200]
void fire_flower_appendGfx(void *effect)
EffectInstanceDataPtr data
Definition effects.h:2605
struct FireFlowerFXData * fireFlower
Definition effects.h:2527
#define ASSERT(condition)
s32 effect_rand_int(s32)
@ RENDER_TASK_FLAG_REFLECT_FLOOR
Definition enums.h:3352
@ RENDER_MODE_CLOUD_NO_ZCMP
Definition enums.h:3345
#define ARRAY_COUNT(arr)
Definition macros.h:39
#define VIRTUAL_TO_PHYSICAL(addr)
Definition macros.h:46
void stars_spread_main(s32 arg0, f32 arg1, f32 arg2, f32 arg3, s32 arg4, s32 arg5)
void(* appendGfx)(void *)
Camera gCameras[4]
Definition cam_main.c:16
Gfx * gMainGfxPos
Definition cam_main.c:14
u16 gMatrixListPos
Definition main_loop.c:44
s32 gCurrentCameraID
Definition cam_math.c:5
DisplayContext * gDisplayContext
Definition cam_main.c:15