Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
shattering_stones.c
Go to the documentation of this file.
1#include "common.h"
2#include "effects_internal.h"
3
4extern Gfx D_09000C00_341480[];
5extern Gfx D_09001068_3418E8[];
6extern Gfx D_09001080_341900[];
7extern Gfx D_09001098_341918[];
8extern Gfx D_090010B8_341938[];
9extern Gfx D_090010D0_341950[];
10extern Gfx D_090010E8_341968[];
11extern Gfx D_09001108_341988[];
12extern Gfx D_09001120_3419A0[];
13extern Gfx D_09001138_3419B8[];
14
20
21f32 D_E002C964[] = {
22 -1.0f, -0.5f, 0.5f, 1.0f, -1.0f, -0.5f, 0.5f, 1.0f
23};
24
25f32 D_E002C984[][2] = {
26 { -5.0f, -4.0f },
27 { -3.0f, -2.0f },
28 { 2.0f, -3.0f },
29 { 5.0f, -4.0f },
30 { -4.0f, 2.0f },
31 { -1.0f, 4.0f },
32 { 3.0f, 2.0f },
33 { 5.0f, 4.0f }
34};
35
39void shattering_stones_appendGfx(void* effect);
40
41void shattering_stones_main(s32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4) {
43 EffectInstance* effect;
45 s32 numParts = 9;
46 s32 i;
47
51 bp.unk_00 = 0;
52 bp.renderUI = NULL;
53 bp.effectID = EFFECT_SHATTERING_STONES;
54
55 effect = create_effect_instance(&bp);
56 effect->numParts = numParts;
57 part = effect->data.shatteringStones = general_heap_malloc(numParts * sizeof(*part));
58 ASSERT(effect->data.shatteringStones != NULL);
59
60 part->unk_24 = 0;
61 part->unk_00 = arg1;
62 part->unk_04 = arg2;
63 part->unk_0C = arg4;
64 part->unk_08 = arg3;
65 part->unk_2C = 0;
66 part->unk_30 = 0;
67 part->unk_14 = -2.0f;
68 part->unk_34 = rand_int(60) - 30;
69 part->unk_28 = 255;
70 part->unk_38 = rand_int(60) - 30;
71 part->unk_3C = part->unk_38 * 0.25;
72 part->unk_20 = 20;
73
74 part++;
75 for (i = 1; i < numParts; i++, part++) {
76 part->unk_18 = D_E002C984[i - 1][0];
77 part->unk_1C = D_E002C984[i - 1][1];
78 part->unk_00 = 0;
79 part->unk_04 = 0;
80 part->unk_08 = 0;
81 part->unk_10 = D_E002C964[i - 1] * 2.0f;
82 part->unk_14 = (f32) rand_int(10) * 0.1 * 2.0 + 1.0;
83 part->unk_2C = 0;
84 part->unk_34 = 0;
85 }
86}
87
90
93 s32 i;
94
95 if (part->unk_24 == 0) {
96 part->unk_14 += -0.1;
97 part->unk_04 += part->unk_14;
98 part->unk_2C += part->unk_38;
99 part->unk_30 += part->unk_3C;
100 if (part->unk_04 <= part->unk_0C) {
101 part->unk_24 = 1;
102 }
103 }
104
105 if (part->unk_24 == 1) {
106 part->unk_20--;
107 if (part->unk_20 < 0) {
108 remove_effect(effect);
109 return;
110 }
111
112 if (part->unk_20 < 10) {
113 part->unk_28 *= 0.8;
114 }
115
116 part++;
117 for (i = 1; i < effect->numParts; i++, part++) {
118 part->unk_14 += -0.2;
119 part->unk_10 *= 0.9;
120 part->unk_00 += part->unk_10;
121 part->unk_04 += part->unk_14;
122 part->unk_2C += 10.0f;
123 part->unk_34 += 20.0f;
124 }
125 }
126}
127
129 RenderTask renderTask;
130 RenderTask* retTask;
131
133 renderTask.appendGfxArg = effect;
134 renderTask.dist = 0;
136
137 retTask = queue_render_task(&renderTask);
139}
140
141void shattering_stones_appendGfx(void* effect) {
142 ShatteringStonesFXData* part = ((EffectInstance*)effect)->data.shatteringStones;
143 Matrix4f sp20;
144 Matrix4f sp60;
145 Matrix4f spA0;
146 Matrix4f spE0;
147 s32 i;
148
149 gSPSegment(gMainGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(((EffectInstance*)effect)->graphics->data));
150 gSPDisplayList(gMainGfxPos++, D_09000C00_341480);
151
152 if (part->unk_24 == 0) {
153 guTranslateF(sp20, part->unk_00, part->unk_04, part->unk_08);
154 guScaleF(sp60, 1.5f, 1.5f, 1.5f);
155 guMtxCatF(sp60, sp20, spA0);
156 guRotateF(sp60, -gCameras[gCurrentCameraID].curYaw, 0.0f, 1.0f, 0.0f);
157 guMtxCatF(sp60, spA0, spA0);
158 guRotateF(sp60, part->unk_34, 0.0f, 0.0f, 1.0f);
159 guMtxCatF(sp60, spA0, spA0);
160 guRotateF(sp60, part->unk_2C, 1.0f, 0.0f, 0.0f);
161 guMtxCatF(sp60, spA0, spA0);
162 guRotateF(sp60, part->unk_30, 0.0f, 1.0f, 0.0f);
163 guMtxCatF(sp60, spA0, spA0);
165
166 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
167 gDPSetPrimColor(gMainGfxPos++, 0, 0, 102, 109, 123, part->unk_28);
168 gSPDisplayList(gMainGfxPos++, D_E002C940[0]);
169 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
170 } else {
171 s32 unk_28 = part->unk_28;
172
173 guTranslateF(sp20, part->unk_00, part->unk_04, part->unk_08);
174 guScaleF(sp60, 1.5f, 1.5f, 1.5f);
175 guMtxCatF(sp60, sp20, spA0);
176 guRotateF(sp60, -gCameras[gCurrentCameraID].curYaw, 0.0f, 1.0f, 0.0f);
177 guMtxCatF(sp60, spA0, spA0);
178 guRotateF(spE0, part->unk_2C, 1.0f, 0.0f, 0.0f);
179
180 part++;
181 for (i = 1; i < ((EffectInstance*)effect)->numParts; i++, part++) {
182 Gfx* dlist = D_E002C940[i];
183
184 guTranslateF(sp60, part->unk_00, part->unk_04, part->unk_08);
185 guMtxCatF(sp60, spA0, sp20);
186 guMtxCatF(spE0, sp20, sp20);
187 guPositionF(sp60, part->unk_2C, 0.0f, part->unk_34, 1.0f, part->unk_18, part->unk_1C, 0.0f);
188 guMtxCatF(sp60, sp20, sp20);
190
191 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
192 gDPSetPrimColor(gMainGfxPos++, 0, 0, 150, 150, 200, unk_28);
193 gSPDisplayList(gMainGfxPos++, dlist);
194 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
195 }
196 }
197}
Mtx matrixStack[0x200]
f32 Matrix4f[4][4]
#define general_heap_malloc
#define guRotateF
#define queue_render_task
#define guMtxF2L
#define guTranslateF
#define guMtxCatF
#define remove_effect
#define rand_int
#define guPositionF
#define create_effect_instance
#define guScaleF
struct ShatteringStonesFXData * shatteringStones
Definition effects.h:2486
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 VIRTUAL_TO_PHYSICAL(addr)
Definition macros.h:47
Gfx D_090010D0_341950[]
Gfx D_090010E8_341968[]
Gfx D_090010B8_341938[]
Gfx D_09001120_3419A0[]
void shattering_stones_init(EffectInstance *effect)
void shattering_stones_main(s32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4)
Gfx * D_E002C940[]
Gfx D_09001098_341918[]
void shattering_stones_render(EffectInstance *effect)
Gfx D_09001108_341988[]
f32 D_E002C964[]
f32 D_E002C984[][2]
void shattering_stones_appendGfx(void *effect)
void shattering_stones_update(EffectInstance *effect)
Gfx D_09001138_3419B8[]
Gfx D_09001080_341900[]
Gfx D_09001068_3418E8[]
Gfx D_09000C00_341480[]
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