Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
gather_magic.c
Go to the documentation of this file.
1#include "common.h"
2#include "effects_internal.h"
3
4extern Gfx D_09000080_38F790[];
5extern Gfx D_090001A8_38F8B8[];
6extern Gfx D_090001C8_38F8D8[];
7
9
10void gather_magic_appendGfx(void* effect);
14
15EffectInstance* gather_magic_main(s32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4, s32 arg5) {
17 EffectInstance* effect;
19 s32 numParts = 31;
20 s32 i;
21
22 bp.unk_00 = 0;
26 bp.renderUI = NULL;
27 bp.effectID = EFFECT_GATHER_MAGIC;
28
29 effect = create_effect_instance(&bp);
30 effect->numParts = numParts;
31 data = general_heap_malloc(numParts * sizeof(*data));
32 effect->data.gatherMagic = data;
33 ASSERT(effect->data.gatherMagic != NULL);
34
35 data->unk_04 = arg0;
36 data->unk_1C = 0;
37 if (arg5 <= 0) {
38 data->unk_18 = 100;
39 } else {
40 data->unk_18 = arg5;
41 }
42 data->unk_14 = 0;
43 data->unk_08 = arg1;
44 data->unk_0C = arg2;
45 data->unk_10 = arg3;
46
47 if (arg0 == 0) {
48 data->unk_30 = 255;
49 data->unk_34 = 0;
50 data->unk_38 = 255;
51 data->unk_3C = 255;
52 data->unk_40 = 255;
53 data->unk_44 = 255;
54 } else {
55 data->unk_30 = 255;
56 data->unk_34 = 20;
57 data->unk_38 = 33;
58 data->unk_3C = 50;
59 data->unk_40 = 20;
60 data->unk_44 = 10;
61 }
62
63 data++;
64 for (i = 1; i < numParts; i++, data++) {
65 s32 d = numParts - 1;
66 f32 zero = 0.0f;
67
68 data->unk_20 = ((i - 1) * 3240) / d;
69 data->unk_24 = zero;
70 data->unk_2C = ((i - 1) * 100) / d;
71 data->unk_00 = 0;
72 }
73 return effect;
74}
75
78
80 GatherMagicFXData* part = effect->data.gatherMagic;
81 s32 unk_1C;
82 s32 i;
83
84 if (part->unk_18 < 100) {
85 part->unk_18--;
86 }
87
88 part->unk_1C++;
89
90 if (part->unk_18 < 0) {
91 remove_effect(effect);
92 return;
93 }
94
95 unk_1C = part->unk_1C;
96
97 if (unk_1C < 21) {
98 part->unk_14 = unk_1C * 12;
99 } else {
100 part->unk_14 = 255;
101 }
102
103 if (unk_1C % 2) {
104 part->unk_14 *= 0.5;
105 }
106
107 unk_1C = part->unk_1C;
108
109 part++;
110 for (i = 1; i < effect->numParts; i++, part++) {
111 f32 unk_20 = part->unk_20;
112 f32 unk_2C = part->unk_2C;
113 f32 unk_24 = part->unk_24;
114 f32 sin_20 = sin_deg(unk_20);
115 f32 cos_20 = cos_deg(unk_20);
116 f32 sin_24 = sin_deg(unk_24);
117 f32 cos_24 = cos_deg(unk_24);
118
119 part->unk_08 = unk_2C * sin_20 * cos_24;
120 part->unk_0C = unk_2C * cos_20 * cos_24;
121 part->unk_10 = unk_2C * sin_24;
122
123 part->unk_14 = ((100.0f - part->unk_2C) * 255.0f * 2.0f) / 100.0f;
124 if (part->unk_14 >= 256) {
125 part->unk_14 = 255;
126 }
127
128 part->unk_28 = part->unk_2C / 80.0f + 0.2;
129 part->unk_2C -= (i & 3) * 2 + 2;
130
131 if (part->unk_2C < 0.0f) {
132 part->unk_2C = 0.0f;
133 part->unk_28 = 0.0f;
134 }
135
136 part->unk_20 += (unk_1C % 2) ? 5.0f : 2.0f;
137 part->unk_24 += (unk_1C % 2) ? 2.0f : 5.0f;
138 }
139}
140
142 RenderTask renderTask;
143 RenderTask* retTask;
144
146 renderTask.appendGfxArg = effect;
147 renderTask.dist = 10;
149
150 retTask = queue_render_task(&renderTask);
152}
153
154void gather_magic_appendGfx(void* effect) {
155 GatherMagicFXData* part = ((EffectInstance*)effect)->data.gatherMagic;
156 s32 unk_30 = part->unk_30;
157 s32 unk_34 = part->unk_34;
158 s32 unk_38 = part->unk_38;
159 Matrix4f sp18;
160 Matrix4f sp58;
161 Matrix4f sp98;
162 s32 i;
163
164 gDPPipeSync(gMainGfxPos++);
165 gSPSegment(gMainGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(((EffectInstance*)effect)->graphics->data));
166
167 guTranslateF(sp18, part->unk_08, part->unk_0C, part->unk_10);
168 guRotateF(sp98, -gCameras[gCurrentCameraID].curYaw, 0.0f, 1.0f, 0.0f);
169 guMtxCatF(sp98, sp18, sp18);
171
172 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
173 gSPDisplayList(gMainGfxPos++, D_09000080_38F790);
174 gDPSetEnvColor(gMainGfxPos++, part->unk_3C, part->unk_40, part->unk_44, 0);
175
176 part++;
177 for (i = 1; i < ((EffectInstance*)effect)->numParts; i++, part++) {
178 f32 scale = part->unk_28;
179
180 if (scale != 0.0f) {
181 gDPSetPrimColor(gMainGfxPos++, 0, 0, unk_30, unk_34, unk_38, part->unk_14);
182
183 guTranslateF(sp18, part->unk_08, part->unk_0C, part->unk_10);
184 guScaleF(sp58, scale, scale, scale);
185 guMtxCatF(sp58, sp18, sp18);
187
188 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
189 gSPDisplayList(gMainGfxPos++, D_E008E890[i & 1]);
190 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
191 }
192 }
193
194 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
195}
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 cos_deg
#define create_effect_instance
#define guScaleF
struct GatherMagicFXData * gatherMagic
Definition effects.h:2535
EffectData data
Definition effects.h:2605
#define ASSERT(condition)
@ RENDER_TASK_FLAG_REFLECT_FLOOR
Definition enums.h:3318
@ RENDER_MODE_SURFACE_XLU_LAYER3
Definition enums.h:3299
void gather_magic_appendGfx(void *effect)
Gfx D_090001A8_38F8B8[]
Gfx D_090001C8_38F8D8[]
EffectInstance * gather_magic_main(s32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4, s32 arg5)
void gather_magic_update(EffectInstance *effect)
void gather_magic_init(EffectInstance *effect)
void gather_magic_render(EffectInstance *effect)
Gfx D_09000080_38F790[]
Gfx * D_E008E890[]
Definition gather_magic.c:8
#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