Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
radiating_energy_orb.c
Go to the documentation of this file.
1#include "common.h"
2#include "effects_internal.h"
3
4extern Gfx D_09001200_3A1F60[];
5extern Gfx D_090012A8_3A2008[];
6extern Gfx D_09001490_3A21F0[];
7extern Gfx D_090014B0_3A2210[];
8extern Gfx D_090014D0_3A2230[];
9extern Gfx D_090014F0_3A2250[];
10extern Gfx D_09001510_3A2270[];
11
16
20void radiating_energy_orb_appendGfx(void* effect);
21
23 s32 arg0,
24 f32 arg1,
25 f32 arg2,
26 f32 arg3,
27 f32 arg4,
28 s32 arg5
29) {
31 EffectInstance* effect;
33 s32 numParts = 6;
34 s32 i;
35
36 bp.unk_00 = 0;
40 bp.renderUI = NULL;
41 bp.effectID = EFFECT_RADIATING_ENERGY_ORB;
42
43 effect = create_effect_instance(&bp);
44 effect->numParts = numParts;
45 part = effect->data.radiatingEnergyOrb = general_heap_malloc(numParts * sizeof(*part));
46 ASSERT(effect->data.radiatingEnergyOrb != NULL);
47
48 part->unk_04 = arg0;
49 part->unk_1C = 0;
50 if (arg5 <= 0) {
51 part->unk_18 = 100;
52 } else {
53 part->unk_18 = arg5;
54 }
55 part->unk_14 = 0;
56 part->unk_08 = arg1;
57 part->unk_0C = arg2;
58 part->unk_10 = arg3;
59
60 part++;
61 for (i = 1; i < numParts; i++, part++) {
62 part->unk_20 = rand_int(360);
63 part->unk_2C = (i * 2) % 20 + 60;
64 part->unk_28 = rand_int(15) * 0.1 + 0.4;
65 part->unk_30 = rand_int(10) * 0.1 + 0.1;
66 }
67
68 return effect;
69}
70
73
76 s32 unk_18;
77 s32 unk_1C;
78 s32 i;
79
80 if (effect->flags & FX_INSTANCE_FLAG_DISMISS) {
81 effect->flags &= ~FX_INSTANCE_FLAG_DISMISS;
82 part->unk_18 = 30;
83 }
84
85 if (part->unk_18 < 100) {
86 part->unk_18--;
87 }
88
89 part->unk_1C++;
90
91 if (part->unk_18 < 0) {
92 remove_effect(effect);
93 return;
94 }
95
96 unk_18 = part->unk_18;
97 unk_1C = part->unk_1C;
98
99 if (unk_1C < 21) {
100 part->unk_14 = unk_1C * 12;
101 } else if (unk_18 < 20) {
102 part->unk_14 = unk_18 * 12;
103 }
104
105 part++;
106 for (i = 1; i < effect->numParts; i++, part++) {
107 part->unk_14 = cos_deg((part->unk_2C - 70.0f) * 90.0f / 10.0f) * 255.0f;
108 part->unk_2C += part->unk_30;
109 if (part->unk_2C > 80.0f) {
110 part->unk_2C = 60.0f;
111 part->unk_28 = rand_int(15) * 0.1 + 0.4;
112 part->unk_30 = rand_int(10) * 0.1 + 0.1;
113 part->unk_20 = rand_int(360);
114 }
115 }
116}
117
119 RenderTask renderTask;
120 RenderTask* retTask;
121
123 renderTask.appendGfxArg = effect;
124 renderTask.dist = 10;
126
127 retTask = queue_render_task(&renderTask);
129}
130
132 RadiatingEnergyOrbFXData* part = ((EffectInstance*)effect)->data.radiatingEnergyOrb;
133 Camera* camera = &gCameras[gCurrentCameraID];
134 s32 unk_1C = part->unk_1C;
135 s32 unk_14 = part->unk_14;
136 s32 temp_s2 = unk_1C & 1;
137 Matrix4f sp18;
138 Matrix4f sp58;
139 Matrix4f unused;
140 s32 i;
141
142 if (temp_s2) {
143 unk_14 *= 0.95;
144 }
145
146 gDPPipeSync(gMainGfxPos++);
147 gSPSegment(gMainGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(((EffectInstance*)effect)->graphics->data));
148
149 guTranslateF(sp18, part->unk_08, part->unk_0C, part->unk_10);
151
152 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
153 gSPMatrix(gMainGfxPos++, camera->mtxBillboard, G_MTX_NOPUSH | G_MTX_MUL | G_MTX_MODELVIEW);
154 gDPSetPrimColor(gMainGfxPos++, 0, 0, 255, 64, 64, unk_14);
155
156 guRotateF(sp18, temp_s2 * 2 + unk_1C, 0.0f, 0.0f, 1.0f);
158
159 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
160 gSPDisplayList(gMainGfxPos++, D_090012A8_3A2008);
161 gSPDisplayList(gMainGfxPos++, D_09001510_3A2270);
162 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
163 gSPDisplayList(gMainGfxPos++, D_09001200_3A1F60);
164
165 part++;
166 for (i = 1; i < ((EffectInstance*)effect)->numParts; i++, part++) {
167 f32 scale = part->unk_28;
168
169 if (scale != 0.0f) {
170 gDPSetPrimColor(gMainGfxPos++, 0, 0, 255, 255, 255, (part->unk_14 * unk_14) >> 8);
171 gDPSetCombineMode(gMainGfxPos++, PM_CC_07, PM_CC_07);
172
173 guRotateF(sp18, part->unk_20, 0.0f, 0.0f, 1.0f);
174 guTranslateF(sp58, part->unk_2C, 0.0f, 0.0f);
175 guMtxCatF(sp58, sp18, sp18);
176 guScaleF(sp58, scale, scale, scale);
177 guMtxCatF(sp58, sp18, sp18);
179
180 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
181 gSPDisplayList(gMainGfxPos++, D_E009EDFC[0]);
182 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
183
184 guRotateF(sp18, part->unk_20, 0.0f, 0.0f, 1.0f);
185 guTranslateF(sp58, part->unk_2C + 5.0f, 0.0f, 0.0f);
186 guMtxCatF(sp58, sp18, sp18);
187 guScaleF(sp58, 2.3 - scale, 2.3 - scale, 2.3 - scale);
188 guMtxCatF(sp58, sp18, sp18);
190
191 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
192 gSPDisplayList(gMainGfxPos++, D_E009EDF8[0]);
193 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
194 gDPSetPrimColor(gMainGfxPos++, 0, 0, 255, 0, 255, (part->unk_14 * unk_14) >> 9);
195 gDPSetEnvColor(gMainGfxPos++, 255, 128, 255, 0);
196 gDPSetCombineMode(gMainGfxPos++, PM_CC_4D, PM_CC_4D);
197
198 guRotateF(sp18, part->unk_20 + 14.0f, 0.0f, 0.0f, 1.0f);
199 guRotateF(sp58, (i * 10) % 45 + unk_1C, 0.0f, 1.0f, 0.0f);
200 guMtxCatF(sp58, sp18, sp18);
201 guTranslateF(sp58, 20.0f, 0.0f, 0.0f);
202 guMtxCatF(sp58, sp18, sp18);
203 guScaleF(sp58, (part->unk_2C - 60.0f) * 0.05 + 1.0, 2.0 - (part->unk_2C - 60.0f) * 0.05, 1.0f);
204 guMtxCatF(sp58, sp18, sp18);
206
207 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
208 gSPDisplayList(gMainGfxPos++, D_E009EDF4[0]);
209 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
210 gDPSetPrimColor(gMainGfxPos++, 0, 0, 255, 64, 64, (part->unk_14 * unk_14) >> 8);
211
212 guRotateF(sp18, part->unk_20 + 34.0f + unk_1C, 0.0f, 0.0f, 1.0f);
213 guRotateF(sp58, i * 35, 0.0f, 1.0f, 0.0f);
214 guMtxCatF(sp58, sp18, sp18);
215 guTranslateF(sp58, 15.0f, 0.0f, 0.0f);
216 guMtxCatF(sp58, sp18, sp18);
217 guScaleF(sp58, (part->unk_2C - 60.0f) * 0.1 + 2.0, 1.0f, 1.0f);
218 guMtxCatF(sp58, sp18, sp18);
220
221 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
222 gSPDisplayList(gMainGfxPos++, D_E009EDF0[0]);
223 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
224 }
225 }
226
227 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
228}
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 guTranslateF
#define guMtxCatF
#define remove_effect
#define rand_int
#define cos_deg
#define create_effect_instance
#define guScaleF
struct RadiatingEnergyOrbFXData * radiatingEnergyOrb
Definition effects.h:2543
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_LAYER3
Definition enums.h:3299
void radiating_energy_orb_appendGfx(void *effect)
Gfx * D_E009EDF0[]
Gfx D_090014F0_3A2250[]
Gfx * D_E009EDF4[]
Gfx D_09001200_3A1F60[]
EffectInstance * radiating_energy_orb_main(s32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4, s32 arg5)
void radiating_energy_orb_update(EffectInstance *effect)
Gfx D_09001490_3A21F0[]
Gfx * D_E009EDFC[]
Gfx * D_E009EDF8[]
Gfx D_09001510_3A2270[]
Gfx D_090012A8_3A2008[]
Gfx D_090014D0_3A2230[]
void radiating_energy_orb_init(EffectInstance *effect)
Gfx D_090014B0_3A2210[]
void radiating_energy_orb_render(EffectInstance *effect)
#define PM_CC_07
Definition macros.h:282
#define VIRTUAL_TO_PHYSICAL(addr)
Definition macros.h:47
#define PM_CC_4D
Definition macros.h:483
Mtx * mtxBillboard
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