Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
stat_change.c
Go to the documentation of this file.
1#include "common.h"
2#include "effects_internal.h"
3
9
14
19
20extern Gfx D_09002700_3B1E00[];
21extern Gfx D_09002798_3B1E98[];
22extern Gfx D_09002860_3B1F60[];
23extern Gfx D_09002880_3B1F80[];
24extern Gfx D_090028A0_3B1FA0[];
25extern Gfx D_090028C0_3B1FC0[];
26extern Gfx D_090028E0_3B1FE0[];
27extern Gfx D_09002950_3B2050[];
28extern Gfx D_09002990_3B2090[];
29extern Gfx D_090029D0_3B20D0[];
30extern Gfx D_09002A10_3B2110[];
31extern Gfx D_09002A50_3B2150[];
32extern Gfx D_09002A90_3B2190[];
33extern Gfx D_09002AD0_3B21D0[];
34extern Gfx D_09002B10_3B2210[];
35extern Gfx D_09002B50_3B2250[];
36extern Gfx D_09002B90_3B2290[];
37extern Gfx D_09002BD0_3B22D0[];
38extern Gfx D_09002C10_3B2310[];
39
41
43
49
51 { .unk_00 = 0xFF, .unk_01 = 0x96 },
52 { .unk_00 = 0xFF, .unk_01 = 0x82 },
53 { .unk_00 = 0xFF, .unk_01 = 0x64 },
54 { .unk_00 = 0xFF, .unk_01 = 0x46 },
55 { .unk_00 = 0xFF, .unk_01 = 0x3C },
56 { .unk_00 = 0xFF, .unk_01 = 0x50 },
57 { .unk_00 = 0xFF, .unk_01 = 0x6E },
58 { .unk_00 = 0xFF, .unk_01 = 0x73 },
59 { .unk_00 = 0xFF, .unk_01 = 0x6B },
60 { .unk_00 = 0xFF, .unk_01 = 0x5C },
61 { .unk_00 = 0xFF, .unk_01 = 0x5A },
62 { .unk_00 = 0xFF, .unk_01 = 0x5E },
63 { .unk_00 = 0xFF, .unk_01 = 0x67 },
64 { .unk_00 = 0xFF, .unk_01 = 0x68 },
65 { .unk_00 = 0xFF, .unk_01 = 0x67 },
66 { .unk_00 = 0xFF, .unk_01 = 0x64 },
67 { .unk_00 = 0xFF, .unk_01 = 0x62 },
68 { .unk_00 = 0xFF, .unk_01 = 0x63 },
69 { .unk_00 = 0xFF, .unk_01 = 0x65 },
70 { .unk_00 = 0xFF, .unk_01 = 0x64 },
71 { .unk_00 = 0xF0, .unk_01 = 0x64 },
72 { .unk_00 = 0xDC, .unk_01 = 0x64 },
73 { .unk_00 = 0xC8, .unk_01 = 0x64 },
74 { .unk_00 = 0xB4, .unk_01 = 0x64 },
75 { .unk_00 = 0xA0, .unk_01 = 0x64 },
76 { .unk_00 = 0x82, .unk_01 = 0x64 },
77 { .unk_00 = 0x64, .unk_01 = 0x64 },
78 { .unk_00 = 0x46, .unk_01 = 0x64 },
79 { .unk_00 = 0x32, .unk_01 = 0x64 },
80 { .unk_00 = 0x28, .unk_01 = 0x64 },
81 { .unk_00 = 0x1E, .unk_01 = 0x64 },
82 { .unk_00 = 0x14, .unk_01 = 0x64 },
83 { .unk_00 = 0x0A, .unk_01 = 0x64 },
84};
85
87 { .unk_00 = 0xFF, .unk_01 = 0x96 },
88 { .unk_00 = 0xFF, .unk_01 = 0x82 },
89 { .unk_00 = 0xFF, .unk_01 = 0x64 },
90 { .unk_00 = 0xFF, .unk_01 = 0x46 },
91 { .unk_00 = 0xFF, .unk_01 = 0x3C },
92 { .unk_00 = 0xFF, .unk_01 = 0x50 },
93 { .unk_00 = 0xFF, .unk_01 = 0x6E },
94 { .unk_00 = 0xFF, .unk_01 = 0x73 },
95 { .unk_00 = 0xFF, .unk_01 = 0x6B },
96 { .unk_00 = 0xFF, .unk_01 = 0x5C },
97 { .unk_00 = 0xFF, .unk_01 = 0x5A },
98 { .unk_00 = 0xFF, .unk_01 = 0x5E },
99 { .unk_00 = 0xFF, .unk_01 = 0x67 },
100 { .unk_00 = 0xFF, .unk_01 = 0x68 },
101 { .unk_00 = 0xFF, .unk_01 = 0x67 },
102 { .unk_00 = 0xFF, .unk_01 = 0x64 },
103 { .unk_00 = 0xFF, .unk_01 = 0x62 },
104 { .unk_00 = 0xFF, .unk_01 = 0x63 },
105 { .unk_00 = 0xFF, .unk_01 = 0x65 },
106 { .unk_00 = 0xFF, .unk_01 = 0x64 },
107 { .unk_00 = 0xF0, .unk_01 = 0x64 },
108 { .unk_00 = 0xDC, .unk_01 = 0x64 },
109 { .unk_00 = 0xC8, .unk_01 = 0x64 },
110 { .unk_00 = 0xB4, .unk_01 = 0x64 },
111 { .unk_00 = 0xA0, .unk_01 = 0x64 },
112 { .unk_00 = 0x82, .unk_01 = 0x64 },
113 { .unk_00 = 0x64, .unk_01 = 0x64 },
114 { .unk_00 = 0x46, .unk_01 = 0x64 },
115 { .unk_00 = 0x32, .unk_01 = 0x64 },
116 { .unk_00 = 0x28, .unk_01 = 0x64 },
117 { .unk_00 = 0x1E, .unk_01 = 0x64 },
118 { .unk_00 = 0x14, .unk_01 = 0x64 },
119 { .unk_00 = 0x0A, .unk_01 = 0x64 },
120};
121
123 { .type = ARROW_TYPE_ATK_UP, .value = 1 },
124 { .type = ARROW_TYPE_ATK_UP, .value = 2 },
125 { .type = ARROW_TYPE_ATK_UP, .value = 3 },
126 { .type = ARROW_TYPE_ATK_DOWN, .value = -1 },
127 { .type = ARROW_TYPE_ATK_DOWN, .value = -2 },
128 { .type = ARROW_TYPE_ATK_DOWN, .value = -3 },
129 { .type = ARROW_TYPE_DEF_UP, .value = 1 },
130 { .type = ARROW_TYPE_DEF_UP, .value = 2 },
131 { .type = ARROW_TYPE_DEF_UP, .value = 3 },
132 { .type = ARROW_TYPE_ATK_UP, .value = 0 },
133};
134
135void func_E00AC288(EffectInstance* effect);
136void func_E00AC2A4(EffectInstance* effect);
137void stat_change_init(EffectInstance* effect);
140
141EffectInstance* stat_change_main(s32 arg0, f32 x, f32 y, f32 z, f32 scale, s32 time) {
143 EffectBlueprint* bpPtr = &bp;
144 EffectInstance* effect;
145 StatChangeFXData* part;
146 s32 numParts = 1;
147
152 bp.unk_00 = 0;
153 bp.effectID = EFFECT_STAT_CHANGE;
154
155 effect = create_effect_instance(bpPtr);
156 effect->numParts = numParts;
157 part = effect->data.statChange = general_heap_malloc(numParts * sizeof(*part));
158
159 ASSERT(effect->data.statChange != NULL);
160
161 part->unk_00 = arg0;
162 part->pos.x = x;
163 part->pos.y = y;
164 part->pos.z = z;
165 part->timeLeft = time;
166
167 part->unk_18 = 0;
168 part->scale = scale;
169 part->unk_24 = 255;
170 part->scaleX = 0;
171 part->scaleY = 0;
172 part->unk_30 = 0;
173 part->unk_38 = 0;
174 part->unk_34 = 0;
175
176 part->arrowType = D_E00AC880[arg0].type;
177 part->arrowValue = D_E00AC880[arg0].value;
178
179 return effect;
180}
181
183}
184
186 StatChangeFXData* part = effect->data.statChange;
187 s32 old_unk18;
188
189 part->timeLeft--;
190 old_unk18 = part->unk_18++;
191
192 if (part->timeLeft < 0) {
193 remove_effect(effect);
194 return;
195 }
196
197 if (part->arrowType == ARROW_TYPE_ATK_DOWN) {
198 if (old_unk18 >= ARRAY_COUNT(D_E00AC83C)) {
199 part->unk_24 = 0;
200 part->scaleX = 0.0f;
201 part->scaleY = 0.0f;
202 } else {
203 part->unk_24 = D_E00AC83C[old_unk18].unk_00;
204 part->scaleY = (f32)D_E00AC83C[old_unk18].unk_01 * 0.01;
205 part->scaleX = 1.0f - part->scaleY + 1.0f;
206 }
207 } else {
208 if (old_unk18 >= ARRAY_COUNT(D_E00AC7F8)) {
209 part->unk_24 = 0;
210 part->scaleX = 0.0f;
211 part->scaleY = 0.0f;
212 } else {
213 part->unk_24 = D_E00AC7F8[old_unk18].unk_00;
214 part->scaleX = (f32)D_E00AC7F8[old_unk18].unk_01 * 0.01;
215 part->scaleY = 1.0f - part->scaleX + 1.0f;
216 }
217 }
218
219 part->unk_3C = 0;
220 part->unk_40 = 0;
221
222 part->pos.x += part->unk_30;
223 part->pos.y += part->unk_38;
224 part->pos.z += part->unk_34;
225}
226
229
231 func_E00AC2A4(effect);
232}
233
235 StatChangeFXData* data = effect->data.statChange;
236 s32 arrowType = data->arrowType;
237 s32 arrowValue = data->arrowValue;
238 s32 idx;
239 Matrix4f sp20;
240 Matrix4f sp60;
241
242 if (data->scaleX != 0.0f && data->scaleY != 0.0f) {
243 gDPPipeSync(gMainGfxPos++);
244 gSPSegment(gMainGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(((EffectInstance*)effect)->graphics->data));
245
246 guPositionF(sp20, 0.0f, -gCameras[gCurrentCameraID].curYaw, 0.0f, data->scale, data->pos.x, data->pos.y, data->pos.z);
248
249 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
250
251 if (data->unk_24 == 255) {
252 gDPSetRenderMode(gMainGfxPos++, AA_EN | CVG_DST_FULL | ZMODE_OPA | CVG_X_ALPHA | GBL_c1(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM), AA_EN | CVG_DST_FULL | ZMODE_OPA | CVG_X_ALPHA | GBL_c2(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM));
253 gDPSetCombineMode(gMainGfxPos++, G_CC_MODULATEIDECALA, G_CC_MODULATEIDECALA);
254 } else {
255 gDPSetRenderMode(gMainGfxPos++, G_RM_CLD_SURF, G_RM_CLD_SURF2);
256 gDPSetCombineMode(gMainGfxPos++, PM_CC_49, PM_CC_49);
257 }
258
259 guTranslateF(sp20, 0.0f, data->unk_40, 0.0f);
260 guScaleF(sp60, data->scaleX, data->scaleY, 1.0f);
261 guMtxCatF(sp60, sp20, sp20);
263
264 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
265 gSPDisplayList(gMainGfxPos++, D_E00AC7B0[arrowType]);
266 gDPSetPrimColor(gMainGfxPos++, 0, 0, 0, 0, 0, data->unk_24);
267 gSPDisplayList(gMainGfxPos++, D_E00AC7BC[arrowType]);
268 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
269 gSPDisplayList(gMainGfxPos++, D_090028E0_3B1FE0);
270
271 guTranslateF(sp20, 0.0f, data->unk_3C, 0.0f);
273
274 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
275
276 if (arrowValue < 0) {
277 idx = -arrowValue;
278 } else {
279 idx = arrowValue;
280 }
281
282 gSPDisplayList(gMainGfxPos++, D_E00AC7C8[idx % 10]);
283 gSPDisplayList(gMainGfxPos++, D_090028C0_3B1FC0);
284
285 if (arrowValue >= 0) {
286 gSPDisplayList(gMainGfxPos++, D_E00AC7C8[11]);
287 } else {
288 gSPDisplayList(gMainGfxPos++, D_E00AC7C8[10]);
289 }
290
291 gSPDisplayList(gMainGfxPos++, D_090028A0_3B1FA0);
292 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
293 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
294 gDPPipeSync(gMainGfxPos++);
295 }
296}
Mtx matrixStack[0x200]
f32 Matrix4f[4][4]
#define general_heap_malloc
#define guMtxF2L
#define guTranslateF
#define guMtxCatF
#define remove_effect
#define guPositionF
#define create_effect_instance
#define guScaleF
struct StatChangeFXData * statChange
Definition effects.h:2550
EffectData data
Definition effects.h:2605
#define ASSERT(condition)
#define ARRAY_COUNT(arr)
Definition macros.h:40
#define PM_CC_49
Definition macros.h:478
#define VIRTUAL_TO_PHYSICAL(addr)
Definition macros.h:47
void func_E00AC288(EffectInstance *effect)
Gfx D_09002990_3B2090[]
Gfx * D_E00AC7B0[]
Definition stat_change.c:40
Gfx D_09002AD0_3B21D0[]
EffectInstance * stat_change_main(s32 arg0, f32 x, f32 y, f32 z, f32 scale, s32 time)
void func_E00AC2A4(EffectInstance *effect)
Gfx D_09002B10_3B2210[]
ExtraArrowDataEntry D_E00AC83C[]
Definition stat_change.c:86
Gfx D_09002A10_3B2110[]
Gfx D_09002880_3B1F80[]
Gfx D_09002798_3B1E98[]
Gfx D_09002700_3B1E00[]
Gfx D_09002B90_3B2290[]
Gfx D_09002BD0_3B22D0[]
Gfx D_09002C10_3B2310[]
Gfx D_090028C0_3B1FC0[]
Gfx D_09002A50_3B2150[]
Gfx D_090028E0_3B1FE0[]
Gfx D_090028A0_3B1FA0[]
void stat_change_init(EffectInstance *effect)
void stat_change_render(EffectInstance *effect)
void stat_change_update(EffectInstance *effect)
Gfx D_09002950_3B2050[]
Gfx D_090029D0_3B20D0[]
Gfx D_09002A90_3B2190[]
Gfx * D_E00AC7C8[]
Definition stat_change.c:44
Gfx * D_E00AC7BC[]
Definition stat_change.c:42
Gfx D_09002860_3B1F60[]
ArrowType
Definition stat_change.c:4
@ ARROW_TYPE_DEF_UP
Definition stat_change.c:7
@ ARROW_TYPE_ATK_DOWN
Definition stat_change.c:6
@ ARROW_TYPE_ATK_UP
Definition stat_change.c:5
ExtraArrowDataEntry D_E00AC7F8[]
Definition stat_change.c:50
ArrowDataTableEntry D_E00AC880[]
Gfx D_09002B50_3B2250[]
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
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