Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
motion_blur_flame.c
Go to the documentation of this file.
1#include "common.h"
2#include "effects_internal.h"
3#include "nu/nusys.h"
4
5extern Gfx D_09000200_3A35D0[];
6extern Gfx D_090002A8_3A3678[];
7extern Gfx D_09000358_3A3728[];
8
10
11typedef struct UnkStruct {
12 /* 0x00 */ s32 unk_00;
13 /* 0x04 */ s32 unk_04;
14 /* 0x08 */ f32 unk_08;
15 /* 0x0C */ f32 unk_0C;
16 /* 0x10 */ s32 unk_10;
17 /* 0x14 */ s32 unk_14;
18} UnkStruct; // size = 0x18
19
21 { 16, 16, 1.0f, 1.0f, 8, 8 },
22 { 16, 16, 1.0f, 1.0f, 8, 8 },
23 { 16, 16, 1.0f, 1.0f, 8, 8 },
24};
25
26s32 D_E00A2A24[] = { 100, 60, 30, 10, 0, 0, 0 };
27
31void motion_blur_flame_appendGfx(void* effect);
32
33EffectInstance* motion_blur_flame_main(s32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4, s32 arg5) {
35 EffectInstance* effect;
37 s32 numParts = 1;
38 s32 i;
39
43 bp.unk_00 = 0;
44 bp.renderUI = NULL;
45 bp.effectID = EFFECT_MOTION_BLUR_FLAME;
46
47 effect = create_effect_instance(&bp);
48 effect->numParts = numParts;
49 data = effect->data.motionBlurFlame = general_heap_malloc(numParts * sizeof(*data));
50 ASSERT(effect->data.motionBlurFlame != NULL);
51
52 data->unk_00 = arg0;
53 if (arg5 < 0) {
54 data->unk_50 = 1000;
55 } else {
56 data->unk_50 = arg5;
57 }
58 data->unk_4C = 127;
59 data->unk_54 = 0;
60 data->unk_04 = arg1;
61 data->unk_08 = arg2;
62 data->unk_0C = arg3;
63 data->pos.x = 0;
64 data->pos.y = 0;
65 data->pos.z = 0;
66 data->unk_5C = 255;
67 data->unk_60 = 255;
68 data->unk_64 = 255;
69 data->unk_3C[1] = 0;
70 data->unk_3C[2] = 0;
71 data->unk_3C[3] = 0;
72
73 return effect;
74}
75
78
81 s32 temp;
82
83 if (effect->flags & FX_INSTANCE_FLAG_DISMISS) {
84 effect->flags &= ~FX_INSTANCE_FLAG_DISMISS;
85 data->unk_50 = 30;
86 }
87 data->unk_54++;
88 if (data->unk_50 < 1000) {
89 data->unk_50--;
90 }
91
92 if (data->unk_50 < 0) {
93 remove_effect(effect);
94 return;
95 }
96 temp = data->unk_50;
97 if (data->unk_54 <= 16) {
98 data->unk_4C = (data->unk_54 * 8) - 1;
99 }
100 if (temp < 16) {
101 data->unk_4C = temp * 8;
102 }
103
104 temp = 0;
105 data->unk_1C[temp] = data->unk_04 + data->pos.x;
106 data->unk_2C[temp] = data->unk_08 + data->pos.y;
107 data->unk_3C[temp] = data->unk_0C + data->pos.z;
108}
109
111 RenderTask renderTask;
112 RenderTask* retTask;
113
115 renderTask.appendGfxArg = effect;
116 renderTask.dist = 100;
118
119 retTask = queue_render_task(&renderTask);
121}
122
123void func_E00A2234(void) {
124}
125
126void motion_blur_flame_appendGfx(void* effect) {
127 MotionBlurFlameFXData* data = ((EffectInstance*)effect)->data.motionBlurFlame;
128 s32 temp_a2 = data->unk_00;
129 f32 sp48;
130 f32 sp4C;
131 s32 sp50 = data->unk_4C;
132 UnkStruct* temp_s1 = &D_E00A29DC[temp_a2];
133 s32 sp54; // declaration must come after sp50
134 s32 envR, envG, envB;
135 s32 sp18[4];
136 f32 sp28[4];
137 f32 sp38[4];
138 s32 i;
139
140 s32 t3;
141 s32 v0;
142 s32 temp_a0;
143 s32 s3;
144 s32 temp_v0_2;
145 s32 temp_v0_3;
146 s32 temp_v1;
147 s32 var_a0;
148 s32 var_a1;
149 s32 var_a2;
150 s32 uly;
151 s32 var_t2_2;
152 s32 var_t4;
153 s32 t6;
154 s32 var_v1;
155
156 gDPPipeSync(gMainGfxPos++);
157 gSPSegment(gMainGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(((EffectInstance*)effect)->graphics->data));
158 gSPDisplayList(gMainGfxPos++, D_E00A29D0[temp_a2]);
159
160 for (i = 0; i < UNK_ARRAY_SIZE_1; i++) {
161 f32 temp_f12 = data->unk_1C[i];
162 f32 temp_f14 = data->unk_2C[i];
163 f32 temp_f0 = data->unk_3C[i];
164 s32 temp_s5 = temp_s1->unk_10;
165 s32 height = temp_s1->unk_14;
166
167 if (i == 0) {
168 var_a2 = is_point_visible(temp_f12, temp_f14, temp_f0, -1, &sp48, &sp4C);
169 } else {
170 var_a2 = temp_f0;
171 sp48 = temp_f12;
172 sp4C = temp_f14;
173 }
174
175 sp18[i] = var_a2;
176 sp28[i] = sp48;
177 sp38[i] = sp4C;
178
179 if ((var_a2 != 0) && !(sp48 < 0.0f) && !(sp4C < 0.0f) && !(sp48 >= 320.0f) && !(sp4C >= 240.0f)) {
180 temp_a0 = (sp50 * D_E00A2A24[i]) / 100;
181 temp_v1 = (data->unk_5C * temp_a0) >> 9;
182 temp_v0_2 = (data->unk_60 * temp_a0) >> 9;
183 temp_v0_3 = (data->unk_64 * temp_a0) >> 9;
184
185 gDPSetPrimColor(gMainGfxPos++, 0, 0,
186 (temp_v1 * temp_a0) >> 8,
187 (temp_v0_2 * temp_a0) >> 8,
188 (temp_v0_3 * temp_a0) >> 8,
189 255
190 );
191
192 envR = temp_v1 + 32;
193 envG = temp_v0_2 + 32;
194 envB = temp_v0_3 + 32;
195 if (envR > 127) {
196 envR = 127;
197 }
198 if (envG > 127) {
199 envG = 127;
200 }
201 if (envB > 127) {
202 envB = 127;
203 }
204
205 gDPSetEnvColor(gMainGfxPos++, envR, envG, envB, 0);
206
207 s3 = sp48 - temp_s5;
208 t6 = s3 + temp_s5 * 2;
209 v0 = sp4C - temp_s5;
210 var_a0 = v0 + 2 * temp_s5;
211 t3 = uly = sp4C - temp_s5;
212
213 if (s3 < 0) {
214 var_a1 = -s3;
215 } else {
216 var_a1 = 0;
217 }
218
219 if (t3 < 0) {
220 var_v1 = -uly;
221 } else {
222 var_v1 = 0;
223 }
224
225 if (t6 > SCREEN_WIDTH) {
226 t6 = SCREEN_WIDTH - 1;
227 }
228 if (var_a0 > SCREEN_HEIGHT) {
229 var_a0 = SCREEN_HEIGHT - 1;
230 }
231
232 var_t2_2 = var_v1 / height;
233 sp54 = (var_a0 - t3) / height;
234
235 while (var_t2_2 < sp54) {
236 uly = t3 + var_t2_2 * height;
237 if (uly + height >= SCREEN_HEIGHT) {
238 break;
239 }
240
241 gDPSetTileSize(gMainGfxPos++, G_TX_RENDERTILE,
242 (s32) (s3 * temp_s1->unk_08) * 4,
243 (s32) (temp_s1->unk_04 * 20 - var_t2_2 * temp_s1->unk_14 * temp_s1->unk_0C) * 4,
244 (s32) (s3 * temp_s1->unk_08 + temp_s1->unk_00) * 4,
245 (s32) (temp_s1->unk_04 * 21 - var_t2_2 * temp_s1->unk_14 * temp_s1->unk_0C) * 4);
246
247 for (var_t4 = 0; var_t4 < 2; var_t4++) {
248 gDPLoadMultiTile(gMainGfxPos++, VIRTUAL_TO_PHYSICAL(nuGfxCfb_ptr + uly * SCREEN_WIDTH),
249 0x0100, 1, G_IM_FMT_RGBA, G_IM_SIZ_16b, SCREEN_WIDTH, SCREEN_HEIGHT,
250 s3 + var_a1,
251 0,
252 t6 - 1,
253 height - 1,
254 0,
255 G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 9, 8, G_TX_NOLOD, G_TX_NOLOD
256 );
257 gSPTextureRectangle(gMainGfxPos++,
258 (s3 + var_a1) * 4,
259 uly * 4,
260 t6 * 4,
261 (uly + height) * 4,
262 G_TX_RENDERTILE,
263 ((u32) (s3 + var_a1) % 0x200) * 32,
264 0,
265 0x0400,
266 0x0400
267 );
268 gDPPipeSync(gMainGfxPos++);
269 }
270 var_t2_2++;
271 }
272 }
273 }
274
275 for (i = 0; i < ARRAY_COUNT(data->unk_3C) - 1; i++) {
276 data->unk_3C[i + 1] = sp18[i];
277 data->unk_1C[i + 1] = sp28[i];
278 data->unk_2C[i + 1] = sp38[i];
279 }
280}
u16 * nuGfxCfb_ptr
Definition cam_main.c:14
#define general_heap_malloc
#define is_point_visible
#define queue_render_task
#define remove_effect
#define create_effect_instance
#define UNK_ARRAY_SIZE_1
Definition effects.h:1366
struct MotionBlurFlameFXData * motionBlurFlame
Definition effects.h:2545
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_CLOUD_NO_ZCMP
Definition enums.h:3311
EffectInstance * motion_blur_flame_main(s32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4, s32 arg5)
void motion_blur_flame_render(EffectInstance *effect)
Gfx D_09000200_3A35D0[]
UnkStruct D_E00A29DC[]
void motion_blur_flame_init(EffectInstance *effect)
s32 D_E00A2A24[]
void motion_blur_flame_appendGfx(void *effect)
void func_E00A2234(void)
Gfx D_09000358_3A3728[]
void motion_blur_flame_update(EffectInstance *effect)
Gfx D_090002A8_3A3678[]
Gfx * D_E00A29D0[]
#define SCREEN_WIDTH
Definition macros.h:105
#define ARRAY_COUNT(arr)
Definition macros.h:40
#define SCREEN_HEIGHT
Definition macros.h:106
#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