Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
bombette_breaking.c File Reference

Go to the source code of this file.

Functions

void bombette_breaking_init (EffectInstance *effect)
 
void bombette_breaking_update (EffectInstance *effect)
 
void bombette_breaking_render (EffectInstance *effect)
 
void bombette_breaking_appendGfx (void *effect)
 
void bombette_breaking_get_model_center_and_size (s32 modelID, f32 *centerX, f32 *centerY, f32 *centerZ, f32 *sizeX, f32 *sizeY, f32 *sizeZ)
 
Modelbombette_breaking_get_model_from_list_index (s32 listIndex)
 
s32 bombette_breaking_get_model_list_index_from_tree_index (s32 listIndex)
 
EffectInstancebombette_breaking_main (s32 type, s32 modelID, s32 treeIndex, f32 arg3, s32 arg4, s32 time)
 

Variables

Gfx D_090017D0_37F1A0 []
 
Gfx D_090018C0_37F290 []
 
Gfx D_09001C80_37F650 []
 
Gfx D_09001CC8_37F698 []
 
Gfx D_09001D00_37F6D0 []
 
Gfx * D_E0084E10 [] = { D_090018C0_37F290, D_090018C0_37F290, D_090018C0_37F290 }
 
Gfx * D_E0084E1C [] = { D_09001D00_37F6D0, D_09001CC8_37F698, D_09001C80_37F650 }
 
Gfx * D_E0084E28 [] = { D_090017D0_37F1A0, D_090017D0_37F1A0, D_090017D0_37F1A0 }
 
void(* D_E0084E34 )(u16, f32 *, f32 *, f32 *, f32 *, f32 *, f32 *) = get_model_center_and_size
 
Model *(* D_E0084E38 )(s32) = get_model_from_list_index
 
s32(* D_E0084E3C )(s32) = get_model_list_index_from_tree_index
 

Function Documentation

◆ bombette_breaking_init()

void bombette_breaking_init ( EffectInstance * effect)

Definition at line 143 of file bombette_breaking.c.

143 {
144}

Referenced by bombette_breaking_main().

◆ bombette_breaking_update()

void bombette_breaking_update ( EffectInstance * effect)

Definition at line 146 of file bombette_breaking.c.

146 {
148 f32 unk_04;
149 s32 i;
150
151 data->unk_48++;
152 data->timeLeft--;
153
154 if (data->timeLeft < 0) {
155 remove_effect(effect);
156 return;
157 }
158
159 unk_04 = data->unk_04;
160
161 if (data->timeLeft < 25.0f) {
162 data->alpha = data->timeLeft * 10.0f;
163 }
164 data->unk_38 += (data->unk_3C - data->unk_38) * 0.1;
165
166 data++;
167 for (i = 1; i < effect->numParts; i++, data++) {
168 data->unk_20.x *= 0.9;
169 data->unk_20.y *= 0.9;
170 data->unk_20.z *= 0.9;
171 data->center.x += data->unk_20.x;
172 data->center.y += data->unk_20.y;
173 data->center.z += data->unk_20.z;
174 if (data->center.y < unk_04 && data->unk_20.y < 0.0f) {
175 data->center.y = unk_04;
176 data->unk_20.y *= -0.7;
177 }
178
179 data->unk_2C.x *= 0.95;
180 data->unk_2C.y -= 0.4;
181 data->unk_2C.z *= 0.95;
182 data->unk_14.x += data->unk_2C.x;
183 data->unk_14.y += data->unk_2C.y;
184 data->unk_14.z += data->unk_2C.z;
185 if (data->unk_14.y < unk_04 && data->unk_2C.y < 0.0f) {
186 data->unk_14.y = unk_04;
187 data->unk_2C.y *= -0.4;
188 }
189 }
190}
#define remove_effect
struct BombetteBreakingFXData * bombetteBreaking
Definition effects.h:2530
EffectData data
Definition effects.h:2605

Referenced by bombette_breaking_main().

◆ bombette_breaking_render()

void bombette_breaking_render ( EffectInstance * effect)

Definition at line 192 of file bombette_breaking.c.

192 {
193 RenderTask renderTask;
194 RenderTask* retTask;
195
197 renderTask.appendGfxArg = effect;
198 renderTask.dist = 0;
200
201 retTask = queue_render_task(&renderTask);
203}
void bombette_breaking_appendGfx(void *effect)
#define queue_render_task
@ RENDER_TASK_FLAG_REFLECT_FLOOR
Definition enums.h:3318
@ RENDER_MODE_PASS_THROUGH
Definition enums.h:3306
void * appendGfxArg
void(* appendGfx)(void *)

Referenced by bombette_breaking_main().

◆ bombette_breaking_appendGfx()

void bombette_breaking_appendGfx ( void * effect)

Definition at line 205 of file bombette_breaking.c.

205 {
206 Matrix4f sp20;
207 BombetteBreakingFXData* data = ((EffectInstance*)effect)->data.bombetteBreaking;
208 s32 timeLeft = data->timeLeft;
209 u16 type = data->type;
210 Gfx* sp60 = D_E0084E10[type];
211 Gfx* sp64 = D_E0084E28[type];
212 f32 unk_38 = data->unk_38;
213 f32 unk_40 = data->unk_40;
214 s32 mainAlpha = data->alpha;
215 s32 i;
216
217 timeLeft *= 4;
218
219 gDPPipeSync(gMainGfxPos++);
220 gSPSegment(gMainGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(((EffectInstance*)effect)->graphics->data));
221 guTranslateF(sp20, data->center.x, data->center.y, data->center.z);
223 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
224
226
227 data++;
228 for (i = 1; i < ((EffectInstance*)effect)->numParts; i++, data++) {
229 guPositionF(sp20, timeLeft + (130 * i), timeLeft - (40 * i), timeLeft + (80 * i), unk_40,
230 data->unk_14.x, data->unk_14.y, data->unk_14.z);
233 G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
234 gSPDisplayList(gMainGfxPos++, D_E0084E1C[type]);
235 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
236 }
237
238 gSPDisplayList(gMainGfxPos++, sp64);
239
240 data = ((EffectInstance*)effect)->data.bombetteBreaking;
241 data++;
242 for (i = 1; i < ((EffectInstance*)effect)->numParts; i++, data++) {
243 gDPSetPrimColor(gMainGfxPos++, 0, 0, 255, 255, 255, (data->alpha * mainAlpha) / 255);
244 guPositionF(sp20, 0.0f, -gCameras[gCurrentCameraID].curYaw, 0.0f, unk_38,
245 data->center.x, data->center.y, data->center.z);
248 G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
249 gSPDisplayList(gMainGfxPos++, sp60);
250 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
251 }
252
253 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
254}
Gfx * D_E0084E10[]
Gfx * D_E0084E1C[]
Gfx * D_E0084E28[]
Mtx matrixStack[0x200]
f32 Matrix4f[4][4]
#define guMtxF2L
#define guTranslateF
#define mdl_draw_hidden_panel_surface
#define guPositionF
#define VIRTUAL_TO_PHYSICAL(addr)
Definition macros.h:47
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

Referenced by bombette_breaking_render().

◆ bombette_breaking_get_model_center_and_size()

void bombette_breaking_get_model_center_and_size ( s32 modelID,
f32 * centerX,
f32 * centerY,
f32 * centerZ,
f32 * sizeX,
f32 * sizeY,
f32 * sizeZ )

Definition at line 24 of file bombette_breaking.c.

27{
28 D_E0084E34(modelID, centerX, centerY, centerZ, sizeX, sizeY, sizeZ);
29}
void(* D_E0084E34)(u16, f32 *, f32 *, f32 *, f32 *, f32 *, f32 *)

Referenced by bombette_breaking_main().

◆ bombette_breaking_get_model_from_list_index()

Model * bombette_breaking_get_model_from_list_index ( s32 listIndex)

Definition at line 31 of file bombette_breaking.c.

31 {
32 return D_E0084E38(listIndex);
33}
Model *(* D_E0084E38)(s32)

◆ bombette_breaking_get_model_list_index_from_tree_index()

s32 bombette_breaking_get_model_list_index_from_tree_index ( s32 listIndex)

Definition at line 35 of file bombette_breaking.c.

35 {
36 return D_E0084E3C(listIndex);
37}
s32(* D_E0084E3C)(s32)

◆ bombette_breaking_main()

EffectInstance * bombette_breaking_main ( s32 type,
s32 modelID,
s32 treeIndex,
f32 arg3,
s32 arg4,
s32 time )

Definition at line 39 of file bombette_breaking.c.

39 {
41 EffectBlueprint* bpPtr = &bp;
42 EffectInstance* effect;
43 s32 numParts;
45 f32 centerX, centerY, centerZ;
46 f32 sizeX, sizeY, sizeZ;
47 s32 xParts, yParts, zParts;
48 s32 iX, iY, iZ;
49 f32 f20, f30, f40;
50
51 bombette_breaking_get_model_center_and_size(modelID & 0xFFFF, &centerX, &centerY, &centerZ, &sizeX, &sizeY, &sizeZ);
52
53 xParts = (sizeX * 0.0625f) + 1.0f;
54 yParts = (sizeY * 0.0625f) + 1.0f;
55 zParts = (sizeZ * 0.0625f) + 1.0f;
56
57 f20 = (s32)sizeX % 16;
58 f30 = (s32)sizeY % 16;
59 f40 = (s32)sizeZ % 16;
60
61 bp.unk_00 = 0;
65 bp.renderUI = NULL;
66 bp.effectID = EFFECT_BOMBETTE_BREAKING;
67
68 f20 *= 0.5;
69 f30 *= 0.5;
70 f40 *= 0.5;
71
72 numParts = (xParts * yParts * zParts) + 1;
73 effect = create_effect_instance(bpPtr);
74 effect->numParts = numParts;
75 effect->data.bombetteBreaking = data = general_heap_malloc(numParts * sizeof(*data));
76 ASSERT(data != NULL);
77
78 data->unk_04 = -sizeY * 0.5;
79 data->timeLeft = time;
80 data->unk_48 = 0;
81 data->type = type;
82 data->unk_38 = arg3;
83 data->alpha = 255;
84 data->treeIndex = treeIndex;
85 data->unk_3C = 2.0f * arg3;
86 data->center.x = centerX;
87 data->center.y = centerY;
88 data->center.z = centerZ;
89 data->unk_40 = sizeY * 0.05;
90 if (data->unk_40 < 1.0f) {
91 data->unk_40 = 1.0f;
92 }
93
94 data++;
95 for (iX = 0; iX < xParts; iX++) {
96 centerX = f20 - (sizeX * 0.5) + (iX * 16.0f);
97 for (iY = 0; iY < yParts; iY++) {
98 centerY = f30 - (sizeY * 0.5) + (iY * 16.0f);
99 for (iZ = 0; iZ < zParts; iZ++) {
100 centerZ = f30 - (sizeZ * 0.5) + (iZ * 16.0f);
101
102 data->center.x = data->unk_14.x = centerX;
103 data->center.y = data->unk_14.y = centerY;
104 data->center.z = data->unk_14.z = centerZ;
105
106 if (sizeX < sizeZ) {
107 if (xParts >= 2) {
108 data->unk_20.x = 2.0 * (centerX / (sizeX * 0.5));
109 } else {
110 if (iZ & 1) {
111 data->unk_20.x = 2.0f;
112 } else {
113 data->unk_20.x = -2.0f;
114 }
115 }
116 data->unk_20.z = 0.0f;
117 } else {
118 data->unk_20.x = 0.0f;
119 if (zParts >= 2) {
120 data->unk_20.z = 2.0 * (centerZ / (sizeZ * 0.5));
121 } else {
122 if (iX & 1) {
123 data->unk_20.z = 2.0f;
124 } else {
125 data->unk_20.z = -2.0f;
126 }
127 }
128 }
129
130 data->unk_20.y = centerY * 0.2;
131 data->unk_2C.x = centerZ * 0.2 + (centerX < centerZ ? (centerZ < 0 ? -1.0 : (centerZ > 0 ? 1.0 : 0.0)) : 0.0);
132 data->unk_2C.y = centerY * 0.2;
133 data->unk_2C.z = centerX * 0.2 + (centerZ < centerX ? (centerX < 0 ? -1.0 : (centerX > 0 ? 1.0 : 0.0)) : 0.0);
134
135 data->alpha = 255;
136 data++;
137 }
138 }
139 }
140 return effect;
141}
void bombette_breaking_update(EffectInstance *effect)
void bombette_breaking_render(EffectInstance *effect)
void bombette_breaking_get_model_center_and_size(s32 modelID, f32 *centerX, f32 *centerY, f32 *centerZ, f32 *sizeX, f32 *sizeY, f32 *sizeZ)
void bombette_breaking_init(EffectInstance *effect)
#define general_heap_malloc
#define create_effect_instance
#define ASSERT(condition)
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

Variable Documentation

◆ D_090017D0_37F1A0

Gfx D_090017D0_37F1A0[]
extern

◆ D_090018C0_37F290

Gfx D_090018C0_37F290[]
extern

◆ D_09001C80_37F650

Gfx D_09001C80_37F650[]
extern

◆ D_09001CC8_37F698

Gfx D_09001CC8_37F698[]
extern

◆ D_09001D00_37F6D0

Gfx D_09001D00_37F6D0[]
extern

◆ D_E0084E10

◆ D_E0084E1C

Definition at line 17 of file bombette_breaking.c.

Gfx D_09001D00_37F6D0[]
Gfx D_09001CC8_37F698[]
Gfx D_09001C80_37F650[]

Referenced by bombette_breaking_appendGfx().

◆ D_E0084E28

◆ D_E0084E34

void(* D_E0084E34) (u16, f32 *, f32 *, f32 *, f32 *, f32 *, f32 *) ( u16 ,
f32 * ,
f32 * ,
f32 * ,
f32 * ,
f32 * ,
f32 *  ) = get_model_center_and_size

Definition at line 20 of file bombette_breaking.c.

Referenced by bombette_breaking_get_model_center_and_size().

◆ D_E0084E38

Model *(* D_E0084E38) (s32) ( s32 ) = get_model_from_list_index

Definition at line 21 of file bombette_breaking.c.

Referenced by bombette_breaking_get_model_from_list_index().

◆ D_E0084E3C

s32(* D_E0084E3C) (s32) ( s32 ) = get_model_list_index_from_tree_index