Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
spiky_white_aura.c
Go to the documentation of this file.
1#include "common.h"
2#include "effects_internal.h"
3
4extern Gfx* D_09000440_34EBB0[];
5extern Gfx* D_090004E8_34EC58[];
6
7// RGB values? unused
8u8 D_E00389F0[] = {
9 254, 172, 172,
10 254, 172, 213,
11 254, 180, 154,
12 213, 180, 254,
13 180, 180, 254,
14 180, 221, 254,
15 180, 254, 254,
16 180, 254, 213,
17 180, 254, 180,
18 213, 254, 180,
19 254, 254, 180,
20 254, 213, 172,
21};
22
26void spiky_white_aura_appendGfx(void* effect);
27
28void spiky_white_aura_main(s32 arg0, f32 arg1, f32 arg2, f32 arg3, s32 arg4) {
30 EffectBlueprint* bpPtr = &bp;
31 EffectInstance* effect;
33 s32 numParts = 5;
34 f32 fs1 = 0.0f;
35 f32 fs2 = -1.0f;
36 f32 fs3 = 0.0f;
37 f32 var_f0;
38 f32 var_f2;
39 f32 var_f4;
40 f32 temp_f12;
41 f32 sinYaw;
42 f32 cosYaw;
43 f32 rotateA;
44 Matrix4f sp30;
45 s32 i;
46
47 temp_f12 = SQ(fs3) + SQ(fs2) + SQ(fs1);
48 if (temp_f12 != 0.0f) {
49 temp_f12 = -1.0f / sqrtf(temp_f12);
50
51 fs3 *= temp_f12;
52 fs2 *= temp_f12;
53 fs1 *= temp_f12;
54
55 if (fs1 != 0.0f) {
56 var_f0 = temp_f12 / fs1;
57 var_f2 = 1.0f;
58 var_f4 = 0.0f;
59 } else if (fs2 != 0.0f) {
60 var_f2 = -fs1 / fs2;
61 var_f0 = 1.0f;
62 var_f4 = 0.0f;
63 } else {
64 var_f4 = -fs1 / fs3;
65 var_f2 = 0.0f;
66 var_f0 = 1.0f;
67 }
68
69 temp_f12 = SQ(var_f0) + SQ(var_f2) + SQ(var_f4);
70 if (temp_f12 != 0.0f) {
71 temp_f12 = 1.0 / sqrtf(temp_f12);
72
73 fs3 *= 18.0f;
74 fs2 *= 18.0f;
75 fs1 *= 18.0f;
76
80 bpPtr->unk_00 = 0;
81 bpPtr->renderUI = NULL;
82 bpPtr->effectID = EFFECT_SPIKY_WHITE_AURA;
83
84 effect = create_effect_instance(bpPtr);
85 effect->numParts = numParts;
86 part = effect->data.spikyWhiteAura = general_heap_malloc(numParts * sizeof(*part));
87 ASSERT(effect->data.spikyWhiteAura != NULL);
88
89 for (i = 0; i < numParts; i++, part++) {
90 Camera* camera = &gCameras[gCurrentCameraID]; // required to match
91 f32 (*matrix)[4] = &sp30[0]; // required to match
92
93 part->unk_00 = arg0;
94 part->unk_04 = arg1;
95 part->unk_08 = arg2;
96 part->unk_0C = arg3;
97
98 sinYaw = sin_deg(gCameras[gCurrentCameraID].curYaw);
99 cosYaw = -cos_deg(gCameras[gCurrentCameraID].curYaw);
100
101 if (numParts != 1) {
102 rotateA = (i * 100) / (numParts - 1) - 50;
103 } else {
104 rotateA = 0.0f;
105 }
106
107 guRotateF(matrix, rotateA, sinYaw, 0.0f, cosYaw);
108
109 part->unk_10 = (sp30[0][0] * fs3 + sp30[1][0] * fs2 + sp30[2][0] * fs1) * 0.6;
110 part->unk_14 = sp30[0][1] * fs3 + sp30[1][1] * fs2 + sp30[2][1] * fs1;
111 part->unk_18 = (sp30[0][2] * fs3 + sp30[1][2] * fs2 + sp30[2][2] * fs1) * 0.6;
112 part->unk_1C = 50 - (i * 100) / (numParts - 1);
113 part->unk_20 = 0.5f;
114 part->unk_28 = arg4;
115 part->unk_2C = 0;
116 part->unk_24 = 0;
117 }
118 }
119 }
120}
121
124
127 s32 unk_28;
128 s32 unk_2C;
129 s32 i;
130
131 part->unk_28--;
132 part->unk_2C++;
133
134 if (part->unk_28 < 0) {
135 remove_effect(effect);
136 return;
137 }
138
139 unk_28 = part->unk_28;
140 unk_2C = part->unk_2C;
141
142 for (i = 0; i < effect->numParts; i++, part++) {
143 if (unk_28 >= 6) {
144 part->unk_10 *= 0.8;
145 part->unk_14 *= 0.8;
146 part->unk_18 *= 0.8;
147 part->unk_24 += (255 - part->unk_24) * 0.4;
148 part->unk_20 = sin_deg(part->unk_24 / 2) * 3.0f + sin_deg(unk_2C * 30.0f);
149 }
150
151 if (unk_28 < 5) {
152 part->unk_24 *= 0.6;
153 part->unk_10 *= 0.7;
154 part->unk_14 *= 0.7;
155 part->unk_18 *= 0.7;
156 part->unk_20 = sin_deg(part->unk_24 / 2) * 3.0f + sin_deg(unk_2C * 30.0f) + (255 - part->unk_24) / 30.0f;
157 }
158
159 part->unk_04 += part->unk_10;
160 part->unk_08 += part->unk_14;
161 part->unk_0C += part->unk_18;
162 }
163}
164
166 RenderTask renderTask;
167 RenderTask* retTask;
168
170 renderTask.appendGfxArg = effect;
171 renderTask.dist = 0;
173
174 retTask = queue_render_task(&renderTask);
176}
177
178void spiky_white_aura_appendGfx(void* effect) {
179 SpikyWhiteAuraFXData* part = ((EffectInstance*)effect)->data.spikyWhiteAura;
180 Matrix4f sp18;
181 Matrix4f sp58;
182 s32 i;
183
184 gSPSegment(gMainGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(((EffectInstance*)effect)->graphics->data));
185 gSPDisplayList(gMainGfxPos++, D_09000440_34EBB0);
186 gDPSetPrimColor(gMainGfxPos++, 0, 0, 255, 255, 255, part->unk_24);
187
188 for (i = 0; i < ((EffectInstance*)effect)->numParts; i++, part++) {
189 guTranslateF(sp18, part->unk_04, part->unk_08, part->unk_0C);
190 guRotateF(sp58, -gCameras[gCurrentCameraID].curYaw, 0.0f, 1.0f, 0.0f);
191 guMtxCatF(sp58, sp18, sp18);
192 guRotateF(sp58, part->unk_1C, 0.0f, 0.0f, 1.0f);
193 guMtxCatF(sp58, sp18, sp18);
194 guScaleF(sp58, part->unk_20, part->unk_20, 1.0f);
195 guMtxCatF(sp58, sp18, sp18);
197
198 gDPPipeSync(gMainGfxPos++);
199 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
200 gSPDisplayList(gMainGfxPos++, D_090004E8_34EC58);
201 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
202 }
203}
Mtx matrixStack[0x200]
f32 Matrix4f[4][4]
#define general_heap_malloc
#define guRotateF
#define queue_render_task
#define sqrtf
#define guMtxF2L
#define sin_deg
#define guTranslateF
#define guMtxCatF
#define remove_effect
#define cos_deg
#define create_effect_instance
#define guScaleF
struct SpikyWhiteAuraFXData * spikyWhiteAura
Definition effects.h:2492
EffectData data
Definition effects.h:2605
#define ASSERT(condition)
@ RENDER_TASK_FLAG_REFLECT_FLOOR
Definition enums.h:3318
@ RENDER_MODE_CLOUD_NO_ZCMP
Definition enums.h:3311
#define SQ(x)
Definition macros.h:166
#define VIRTUAL_TO_PHYSICAL(addr)
Definition macros.h:47
u8 D_E00389F0[]
Gfx * D_09000440_34EBB0[]
void spiky_white_aura_init(EffectInstance *effect)
void spiky_white_aura_main(s32 arg0, f32 arg1, f32 arg2, f32 arg3, s32 arg4)
void spiky_white_aura_update(EffectInstance *effect)
void spiky_white_aura_render(EffectInstance *effect)
Gfx * D_090004E8_34EC58[]
void spiky_white_aura_appendGfx(void *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