Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
something_rotating.c
Go to the documentation of this file.
1#include "common.h"
2#include "effects_internal.h"
3
4extern Gfx D_09003F98_3FE448[];
5extern Gfx D_09004010_3FE4C0[];
6extern Gfx D_09004088_3FE538[];
7extern Gfx D_09004100_3FE5B0[];
8extern Gfx D_09004178_3FE628[];
9extern Gfx D_090041F0_3FE6A0[];
10extern Gfx D_09004268_3FE718[];
11extern Gfx D_090042E0_3FE790[];
12extern Gfx D_09004360_3FE810[];
13extern Gfx D_09004458_3FE908[];
14extern Gfx D_09004508_3FE9B8[];
15extern Gfx D_09004600_3FEAB0[];
16
18
20
22
24
30
32 { 255, 224, 65 },
33 { 244, 227, 72 },
34 { 211, 220, 22 },
35 { 152, 214, 222 },
36 { 211, 138, 239 },
37 { 231, 174, 219 },
38 { 255, 200, 11 },
39 { 0, 0, 0 }
40};
41
42s16 D_E0116CA4[] = {
43 0, 60, 120, 180, 240, 300,
44 0, 60, 120, 180, 240, 300,
45 0, 60, 120, 180, 240, 300,
46 0, 60, 120, 180, 240, 300,
47 0, 30, 60, 90, 120, 150, 180, 210, 240, 270, 300, 330, 345, 353, 357, 359,
48 0
49};
50
51u8 D_E0116CF8[] = {
52 2, 20, 40, 60, 80, 100, 120, 160, 180, 200, 220, 240, 255
53};
54
55u8 D_E0116D08[] = {
56 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
57 0, 0, 20, 40, 60, 80, 100, 120, 160, 180, 200, 220, 240, 255
58};
59
60u8 D_E0116D3C[] = {
61 255, 255, 255, 255, 255, 255, 255, 225, 185, 165, 148, 128,
62 255, 255, 255, 255, 255, 255, 255, 225, 185, 165, 148, 128,
63 255, 255, 255, 255, 255, 255, 255, 225, 185, 165, 148, 128,
64 255, 255, 255, 255, 255, 255, 255, 225, 185, 165, 148, 128
65};
66
67u8 D_E0116D6C[] = {
68 50, 80, 100, 105, 107, 108, 108, 108, 108, 108, 108, 107, 105, 100, 95, 90, 85, 80, 75, 70, 65, 60, 55, 50
69};
70
74void something_rotating_appendGfx(void* effect);
75
77 s32 arg0,
78 f32 arg1,
79 f32 arg2,
80 f32 arg3,
81 f32 arg4,
82 s32 arg5
83) {
85 EffectInstance* effect;
87 s32 numParts = 8;
88 s32 i;
89
93 bp.unk_00 = 0;
94 bp.renderUI = NULL;
95 bp.effectID = EFFECT_SOMETHING_ROTATING;
96
97 effect = create_effect_instance(&bp);
98 effect->numParts = numParts;
99 part = effect->data.somethingRotating = general_heap_malloc(numParts * sizeof(*part));
100 ASSERT(effect->data.somethingRotating != NULL);
101
102 part->unk_00 = arg0;
103 part->unk_14 = 0;
104 if (arg5 <= 0) {
105 part->unk_10 = 1000;
106 } else {
107 part->unk_10 = arg5;
108 }
109 part->pos.x = arg1;
110 part->pos.y = arg2;
111 part->pos.z = arg3;
112 part->unk_18 = arg4;
113 part->unk_1C = 30.0f;
114 part->unk_20 = 0;
115
116 part++;
117 for (i = 1; i < numParts; i++, part++) {
118 part->primAlpha = 0;
119 part->unk_18 = arg4 * 0.5;
120 part->env.r = 255;
121 part->env.g = 255;
122 part->env.b = 0;
123 part->unk_25 = 0;
124 part->unk_1C = 30.0f;
125 part->unk_20 = 0;
126 part->state = 0;
127 part->unk_2C = 50.0f;
128 }
129
130 return effect;
131}
132
135
138 f32 x = part->pos.x;
139 f32 y = part->pos.y;
140 f32 z = part->pos.z;
141 s32 unk_14;
142 s32 unk_14_2;
143 f32 factor;
144 f32 angle1;
145 s32 i;
146
147 if (effect->flags & FX_INSTANCE_FLAG_DISMISS) {
148 effect->flags &= ~FX_INSTANCE_FLAG_DISMISS;
149 part->unk_10 = 32;
150 }
151
152 if (part->unk_10 < 1000) {
153 part->unk_10--;
154 }
155
156 part->unk_14++;
157
158 if (part->unk_10 < 0) {
159 remove_effect(effect);
160 return;
161 }
162
163 unk_14 = part->unk_14;
164 part->unk_20 = 90.0f;
165 angle1 = 90.0f;
166
167 part++;
168 for (i = 1; i < effect->numParts; i++, part++) {
169 f32 angle2 = unk_14 * 4.0f + (f32) i * 51.43;
170 f32 temp_f24 = sin_deg(angle2);
171 f32 temp_f22 = part->unk_2C;
172
173 part->pos.x = x + temp_f22 * sin_deg(angle1) * temp_f24;
174 part->pos.y = y + temp_f22 * cos_deg(angle2);
175 part->pos.z = z + temp_f22 * cos_deg(angle1) * temp_f24;
176
177 switch (part->state) {
178 case 1:
179 part->unk_14 = 0;
180 part->state++;
181 // fallthrough
182 case 2:
183 unk_14_2 = part->unk_14;
184
185 if (unk_14_2 < ARRAY_COUNT(D_E0116CA4)) {
186 part->unk_20 = D_E0116CA4[unk_14_2];
187 } else {
189 }
190 if (unk_14_2 < ARRAY_COUNT(D_E0116CF8)) {
191 part->primAlpha = D_E0116CF8[unk_14_2];
192 } else {
194 }
195 if (unk_14_2 < ARRAY_COUNT(D_E0116D08)) {
196 part->unk_25 = D_E0116D08[unk_14_2];
197 } else {
199 }
200
201 if (unk_14_2 < ARRAY_COUNT(D_E0116D3C)) {
202 factor = D_E0116D3C[unk_14_2];
203 } else {
204 factor = D_E0116D3C[ARRAY_COUNT(D_E0116D3C) - 1];
205 }
206
207 factor *= 0.0039215686; // 1 / 255
208 part->env.r = factor * D_E0116C8C[i - 1].r;
209 part->env.g = factor * D_E0116C8C[i - 1].g;
210 part->env.b = factor * D_E0116C8C[i - 1].b;
211
212 if (unk_14_2 < ARRAY_COUNT(D_E0116D6C)) {
213 part->unk_18 = (f32) D_E0116D6C[unk_14_2] * 0.01;
214 } else {
215 part->unk_18 = (f32) D_E0116D6C[ARRAY_COUNT(D_E0116D6C) - 1] * 0.01;
216 }
217
218 break;
219 case 3:
220 part->unk_14 = 0;
221 part->state++;
222 // fallthrough
223 case 4:
224 unk_14_2 = part->unk_14;
225
226 if (unk_14_2 < 18) {
227 part->unk_2C = (sin_deg(90 - unk_14_2 * 10) + 1.0f) * 50.0f * 0.5;
228 } else {
229 part->unk_2C = 0.0f;
230 part->state++;
231 }
232
233 break;
234 case 5:
235 break;
236 }
237
238 part->unk_14++;
239 }
240}
241
243 RenderTask renderTask;
244 RenderTask* retTask;
245
247 renderTask.appendGfxArg = effect;
248 renderTask.dist = 10;
250
251 retTask = queue_render_task(&renderTask);
253}
254
256 f32 temp;
257 Matrix4f sp20;
258 Matrix4f sp60;
259
260 if (arg0 == 0) {
262 } else {
263 temp = 0.0f;
264 }
265
266 guPositionF(sp20, 0.0f, part->unk_20 - temp, 0.0f, part->unk_18,
267 part->pos.x + 2.0f,
268 part->pos.y,
269 part->pos.z + 2.0f
270 );
271 guRotateF(sp60, part->unk_1C, 0.0f, 0.0f, 1.0f);
272 guMtxCatF(sp60, sp20, sp20);
273 guTranslateF(sp60, 0.0f, 0.0f, -2.0f);
274 guMtxCatF(sp60, sp20, sp20);
276
278 G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
279}
280
282 SomethingRotatingFXData* data = ((EffectInstance*)effect)->data.somethingRotating;
283 s32 unk_14 = data->unk_14;
284 s32 l, t;
285 s32 i;
286
287 gDPPipeSync(gMainGfxPos++);
288 gSPSegment(gMainGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(((EffectInstance*)effect)->graphics->data));
289
290 gSPDisplayList(gMainGfxPos++, D_090042E0_3FE790);
291 gDPSetEnvColor(gMainGfxPos++, 0, 0, 0, 255);
292
293 data++;
294 for (i = 1; i < ((EffectInstance*)effect)->numParts; i++, data++) {
295 if (data->state != 5) {
296 func_E01166E8(1, data);
297 if (data->primAlpha != 255) {
298 gDPSetPrimColor(gMainGfxPos++, 0, 0, 0, 0, 0, data->primAlpha);
299 gDPSetEnvColor(gMainGfxPos++, data->env.r, data->env.g, data->env.b, 0x78);
300 gSPDisplayList(gMainGfxPos++, D_E0116C6C[0]);
301
302 l = ((unk_14 * 4.0f) * 100.0f) * (1.0 / 1024);
303 t = ((unk_14 * 4.0f) * 40.0f) * (1.0 / 1024);
304 gDPSetTileSize(gMainGfxPos++, G_TX_RENDERTILE, l, t, l + 0xFC, t + 0xFC);
305
306 l = ((unk_14 * 4.0f) * 200.0f) * (1.0 / 1024);
307 t = ((unk_14 * 4.0f) * 90.0f) * (1.0 / 1024);
308 gDPSetTileSize(gMainGfxPos++, 1, l, t, l + 0xFC, t + 0xFC);
309 gSPDisplayList(gMainGfxPos++, D_E0116C64[0]);
310 } else {
311 gSPDisplayList(gMainGfxPos++, D_E0116C68[0]);
312 gDPSetEnvColor(gMainGfxPos++, data->env.r, data->env.g, data->env.b, data->unk_25);
313 gSPDisplayList(gMainGfxPos++, D_E0116C70[i - 1]);
314 gSPDisplayList(gMainGfxPos++, D_E0116C60[0]);
315 }
316 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
317 }
318 }
319}
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 sin_deg
#define guTranslateF
#define guMtxCatF
#define remove_effect
#define guPositionF
#define cos_deg
#define create_effect_instance
struct SomethingRotatingFXData * somethingRotating
Definition effects.h:2589
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_SURFACE_XLU_LAYER1
Definition enums.h:3282
#define ARRAY_COUNT(arr)
Definition macros.h:40
#define VIRTUAL_TO_PHYSICAL(addr)
Definition macros.h:47
Gfx * D_E0116C6C[]
void something_rotating_appendGfx(void *effect)
Gfx D_09004458_3FE908[]
Gfx * D_E0116C68[]
Gfx D_09003F98_3FE448[]
Gfx D_09004178_3FE628[]
Gfx D_090041F0_3FE6A0[]
Gfx D_09004010_3FE4C0[]
Gfx D_090042E0_3FE790[]
s16 D_E0116CA4[]
u8 D_E0116D08[]
Gfx * D_E0116C64[]
Gfx D_09004088_3FE538[]
u8 D_E0116CF8[]
Color_RGB8 D_E0116C8C[]
u8 D_E0116D6C[]
void func_E01166E8(s32 arg0, SomethingRotatingFXData *part)
Gfx D_09004268_3FE718[]
Gfx * D_E0116C70[]
u8 D_E0116D3C[]
Gfx D_09004600_3FEAB0[]
Gfx D_09004100_3FE5B0[]
void something_rotating_update(EffectInstance *effect)
Gfx D_09004508_3FE9B8[]
EffectInstance * something_rotating_main(s32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4, s32 arg5)
Gfx * D_E0116C60[]
void something_rotating_init(EffectInstance *effect)
Gfx D_09004360_3FE810[]
void something_rotating_render(EffectInstance *effect)
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