Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
purple_ring.c
Go to the documentation of this file.
1#include "common.h"
2#include "effects_internal.h"
3
4extern Gfx D_09000200_352EE0[];
5extern Gfx D_090004E8_3531C8[];
6
10void purple_ring_appendGfx(void* effect);
11
13 s32 arg0,
14 f32 arg1,
15 f32 arg2,
16 f32 arg3,
17 f32 arg4,
18 f32 arg5,
19 f32 arg6,
20 f32 arg7
21) {
23 EffectBlueprint* bpPtr = &bp;
24 EffectInstance* effect;
25 PurpleRingFXData* data;
26 s32 numParts = 1;
27 f32 temp_f12;
28 f32 sp68;
29 f32 sp6C;
30 f32 sp70;
31 f32 var_f24;
32 f32 var_f20;
33 f32 var_f22;
34 Matrix4f unused;
35
36 if (arg4 == 0.0f && arg5 == 0.0f && arg6 == 0.0f) {
37 return NULL;
38 }
39
40 temp_f12 = SQ(arg4) + SQ(arg5) + SQ(arg6);
41 if (temp_f12 == 0.0f) {
42 return NULL;
43 }
44
45 temp_f12 = 1.0f / sqrtf(temp_f12);
46 arg4 *= temp_f12;
47 arg5 *= temp_f12;
48 arg6 *= temp_f12;
49
50 if (arg4 != 0.0f) {
51 var_f20 = -arg4;
52 var_f22 = arg6;
53 var_f24 = 0.0f;
54 } else if (arg6 != 0.0f) {
55 var_f20 = -arg4;
56 var_f22 = arg6;
57 var_f24 = 0.0f;
58 } else {
59 var_f20 = 0.0f;
60 var_f22 = 1.0f;
61 var_f24 = 0.0f;
62 }
63
64 temp_f12 = SQ(var_f22) + SQ(var_f24) + SQ(var_f20);
65 if (temp_f12 == 0.0f) {
66 return NULL;
67 }
68
69 temp_f12 = 1.0f / sqrtf(temp_f12);
70 var_f22 *= temp_f12;
71 var_f24 *= temp_f12;
72 var_f20 *= temp_f12;
73
74 sp68 = var_f24 * arg6 - var_f20 * arg5;
75 sp6C = var_f20 * arg4 - var_f22 * arg6;
76 sp70 = var_f22 * arg5 - var_f24 * arg4;
77
78 temp_f12 = SQ(sp68) + SQ(sp6C) + SQ(sp70);
79 if (temp_f12 == 0.0f) {
80 return NULL;
81 }
82
83 temp_f12 = 1.0f / sqrtf(temp_f12);
84 sp68 *= temp_f12;
85 sp6C *= temp_f12;
86 sp70 *= temp_f12;
87
88 bpPtr->init = purple_ring_init;
91 bpPtr->unk_00 = 0;
92 bpPtr->renderUI = NULL;
93 bpPtr->effectID = EFFECT_PURPLE_RING;
94
95 effect = create_effect_instance(bpPtr);
96 effect->numParts = numParts;
97 data = effect->data.purpleRing = general_heap_malloc(numParts * sizeof(*data));
98 ASSERT(effect->data.purpleRing != NULL);
99
100 data->unk_00 = arg0;
101 data->unk_04 = arg1;
102 data->unk_08 = arg2;
103 data->unk_0C = arg3;
104 data->unk_68 = 0;
105 data->unk_6C = 16;
106 data->unk_70 = 0;
107 data->unk_74 = 248;
108 data->unk_75 = 92;
109 data->unk_76 = 229;
110 data->unk_77 = 248;
111 data->unk_78 = 92;
112 data->unk_79 = 229;
113 data->unk_10 = -arg4 * 4.0f;
114 data->unk_14 = -arg5 * 4.0f;
115 data->unk_18 = -arg6 * 4.0f;
116 data->unk_1C[0][0] = var_f22;
117 data->unk_1C[0][1] = var_f24;
118 data->unk_1C[0][2] = var_f20;
119 data->unk_1C[0][3] = 0;
120 data->unk_1C[1][0] = sp68;
121 data->unk_1C[1][1] = sp6C;
122 data->unk_1C[1][2] = sp70;
123 data->unk_1C[1][3] = 0;
124 data->unk_1C[2][0] = arg4;
125 data->unk_1C[2][1] = arg5;
126 data->unk_1C[2][2] = arg6;
127 data->unk_1C[2][3] = 0;
128 data->unk_1C[3][0] = 0;
129 data->unk_1C[3][1] = 0;
130 data->unk_1C[3][2] = 0;
131 data->unk_5C = 278.0f;
132 data->unk_60 = 32.0f;
133 data->unk_1C[3][3] = 1.0f;
134 data->unk_64 = arg7 * 0.1;
135
136 return effect;
137}
138
140}
141
143 PurpleRingFXData* part = effect->data.purpleRing;
144 s32 unk_6C;
145 s32 i;
146
147 part->unk_6C--;
148 part->unk_70++;
149
150 if (part->unk_6C < 0) {
151 remove_effect(effect);
152 return;
153 }
154
155 unk_6C = part->unk_6C;
156
157 for (i = 0; i < effect->numParts; i++, part++) {
158 if (unk_6C >= 6) {
159 part->unk_68 += (255 - part->unk_68) * 0.3;
160 part->unk_10 *= 0.8;
161 part->unk_14 *= 0.8;
162 part->unk_18 *= 0.8;
163 }
164 if (unk_6C < 5) {
165 part->unk_68 *= 0.6;
166 part->unk_10 *= 0.7;
167 part->unk_14 *= 0.7;
168 part->unk_18 *= 0.7;
169 }
170 part->unk_04 += part->unk_10;
171 part->unk_08 += part->unk_14;
172 part->unk_0C += part->unk_18;
173 part->unk_5C += part->unk_60;
174 part->unk_64 *= 1.05;
175 }
176}
177
179 RenderTask renderTask;
180 RenderTask* retTask;
181
182 renderTask.appendGfx = purple_ring_appendGfx;
183 renderTask.appendGfxArg = effect;
184 renderTask.dist = 0;
186
187 retTask = queue_render_task(&renderTask);
189}
190
191void purple_ring_appendGfx(void* effect) {
192 PurpleRingFXData* data = ((EffectInstance*)effect)->data.purpleRing;
193 s32 unk_5C = data->unk_5C;
194 s32 temp = 64;
195 Matrix4f sp10;
196 Matrix4f sp50;
197
198 gDPPipeSync(gMainGfxPos++);
199 gSPSegment(gMainGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(((EffectInstance*)effect)->graphics->data));
200 gSPDisplayList(gMainGfxPos++, D_09000200_352EE0);
201 gDPSetPrimColor(gMainGfxPos++, 0, 0, data->unk_74, data->unk_75, data->unk_76, data->unk_68);
202
203 guTranslateF(sp10, data->unk_04, data->unk_08, data->unk_0C);
204 guMtxCatF(data->unk_1C, sp10, sp10);
205 guScaleF(sp50, data->unk_64, data->unk_64, data->unk_64);
206 guMtxCatF(sp50, sp10, sp10);
208
209 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
210 gDPSetTileSize(gMainGfxPos++, G_TX_RENDERTILE, 0, unk_5C, temp * 4, unk_5C + temp);
211 gSPDisplayList(gMainGfxPos++, D_090004E8_3531C8);
212 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
213 gDPPipeSync(gMainGfxPos++);
214}
Mtx matrixStack[0x200]
f32 Matrix4f[4][4]
#define general_heap_malloc
#define queue_render_task
#define sqrtf
#define guMtxF2L
#define guTranslateF
#define guMtxCatF
#define remove_effect
#define create_effect_instance
#define guScaleF
struct PurpleRingFXData * purpleRing
Definition effects.h:2495
Matrix4f unk_1C
Definition effects.h:463
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
Gfx D_090004E8_3531C8[]
void purple_ring_update(EffectInstance *effect)
EffectInstance * purple_ring_main(s32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4, f32 arg5, f32 arg6, f32 arg7)
Definition purple_ring.c:12
void purple_ring_appendGfx(void *effect)
void purple_ring_init(EffectInstance *effect)
Gfx D_09000200_352EE0[]
void purple_ring_render(EffectInstance *effect)
#define SQ(x)
Definition macros.h:166
#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
u16 gMatrixListPos
Definition main_loop.c:45
DisplayContext * gDisplayContext
Definition cam_main.c:16