Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
attack_result_text.c
Go to the documentation of this file.
1#include "common.h"
2#include "effects_internal.h"
3
4extern Gfx D_09001500_3918D0[];
5extern Gfx D_090015A8_391978[];
6extern Gfx D_09001610_3919E0[];
7extern Gfx D_09001658_391A28[];
8extern Gfx D_090016A0_391A70[];
9extern Gfx D_090016E8_391AB8[];
10extern Gfx D_09001730_391B00[];
11extern Gfx D_090018B8_391C88[];
12extern Gfx D_090018D8_391CA8[];
13extern Gfx D_090018F8_391CC8[];
14extern Gfx D_09001918_391CE8[];
15extern Gfx D_09001938_391D08[];
16
19
20u8 D_E0090A68[8] = { 10, 40, 80, 120, 125, 100, 90, 100 };
21u8 D_E0090A70[8] = { 60, 80, 100, 110, 112, 95, 100, 0 };
22
23s8 D_E0090A78[5][6] = {
24 { 255, 255, 255, 254, 159, 15 },
25 { 215, 86, 0, 254, 207, 15 },
26 { 254, 159, 15, 229, 21, 0 },
27 { 0, 107, 42, 255, 217, 69 },
28 { 0, 0, 215, 151, 255, 255 },
29};
30
34void func_E0090428(EffectInstance* effect);
35void func_E0090444(EffectInstance* effect);
36
37EffectInstance* attack_result_text_main(s32 type, f32 posX, f32 posY, f32 posZ, f32 appearVel, s32 duration) {
39 EffectInstance* effect;
41 s32 numParts = 1;
42
43 bp.unk_00 = 0;
48 bp.effectID = EFFECT_ATTACK_RESULT_TEXT;
49
50 effect = create_effect_instance(&bp);
51 effect->numParts = numParts;
52
53 data = effect->data.attackResultText = general_heap_malloc(effect->numParts * sizeof(*data));
54
55 ASSERT(data != NULL);
56
57 data->isVisible = TRUE;
58 data->unk_20 = 0;
59 data->type = type;
60 data->lifetime = 0;
61 data->unk_04 = type % 5;
62
63 if (duration <= 0) {
64 data->timeLeft = 100;
65 } else {
66 data->timeLeft = duration;
67 }
68
69 data->alpha = 0xFF;
70
71 if (type < 5) {
72 data->pos.x = posX;
73 data->pos.y = posY;
74 data->pos.z = posZ;
75 data->vel.x = 2.0f * (-sin_deg(30.0f) * appearVel);
76 data->vel.y = 2.0f * (cos_deg(30.0f) * appearVel);
77 } else {
78 data->pos.x = -100.0f;
79 data->pos.y = 40.0f;
80 data->pos.z = 0.0f;
81 data->vel.x = 115.0f;
82 data->vel.y = 0.0f;
83 }
84
85 return effect;
86}
87
90
93 s32 type = data->type;
94 s32 prevTime;
95 s32 curTime;
96 s32 timeLeft;
97 u32 temp1C;
98
99 if (data->timeLeft < 100) {
100 data->timeLeft--;
101 }
102
103 prevTime = data->lifetime;
104 data->lifetime++;
105 curTime = data->lifetime;
106
107 if (data->timeLeft < 0) {
108 data->isVisible = FALSE;
109 data->timeLeft = -1;
110 remove_effect(effect);
111 return;
112 }
113
114 timeLeft = data->timeLeft;
115
116 if (type < 5) {
117 if (data->lifetime < 9) {
118 data->scale = (f32) D_E0090A68[prevTime] * 0.01;
119 }
120
121 temp1C = prevTime - 100;
122 if (curTime == 10) {
123 data->lifetime = 9;
124 }
125
126 if (temp1C < 7) {
127 data->scale = (f32) D_E0090A70[temp1C] * 0.01;
128 }
129
130 if (curTime == 109) {
131 data->lifetime = 108;
132 }
133 if (curTime > 1000) {
134 data->lifetime = 1000;
135 }
136 if (timeLeft >= 6) {
137 data->vel.x *= 0.75;
138 data->vel.y *= 0.75;
139 }
140 if (timeLeft < 5) {
141 data->vel.x *= 0.7;
142 data->vel.y *= 0.7;
143 }
144 } else {
145 if (timeLeft >= 6) {
146 data->vel.x *= 0.7;
147 data->vel.y *= 0.7;
148 }
149 if (timeLeft < 5) {
150 data->vel.x *= 0.6;
151 data->vel.y *= 0.6;
152 }
153 }
154
155 data->pos.x += data->vel.x;
156 data->pos.y += data->vel.y;
157 if (data->unk_20 != 0) {
158 data->unk_20 = 0;
159 data->lifetime = 100;
160 data->unk_04++;
161 if (data->unk_04 > 2) {
162 data->unk_04 = 2;
163 }
164 }
165}
166
169
171 func_E0090444(effect);
172}
173
176 s32 type = data->type;
177 s32 unk_1C = data->lifetime;
178 Matrix4f mtxA;
179 Matrix4f mtxB;
180 s32 z;
181 f32 scale;
182
183 if (data->isVisible) {
184 scale = data->scale;
185 gDPPipeSync(gMainGfxPos++);
186 gSPSegment(gMainGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(effect->graphics->data));
187 gDPSetDepthSource(gMainGfxPos++, G_ZS_PRIM);
188 z = 200 - unk_1C;
189 if (z < 0) {
190 z = 0;
191 }
192 gDPSetPrimDepth(gMainGfxPos++, z, 0);
193
194 if (type < 5) {
195 guTranslateF(mtxA, data->pos.x, data->pos.y, data->pos.z);
196 guRotateF(mtxB, -gCameras[gCurrentCameraID].curYaw, 0.0f, 1.0f, 0.0f);
197 guMtxCatF(mtxB, mtxA, mtxA);
198 guScaleF(mtxB, scale, scale, 1.0f);
199 guMtxCatF(mtxB, mtxA, mtxA);
202 G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
203 gDPSetPrimColor(gMainGfxPos++, 0, 0, 255, 255, 255, data->alpha);
204 gSPDisplayList(gMainGfxPos++, D_090015A8_391978);
205 gSPDisplayList(gMainGfxPos++, D_E0090A40[data->unk_04]);
206 gSPDisplayList(gMainGfxPos++, D_E0090A54[data->unk_04]);
207 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
208 } else {
209 type -= 5;
210 gDPSetPrimColor(gMainGfxPos++, 0, 0, D_E0090A78[type][0], D_E0090A78[type][1], D_E0090A78[type][2], data->alpha);
211 gDPSetEnvColor(gMainGfxPos++, D_E0090A78[type][3], D_E0090A78[type][4], D_E0090A78[type][5], 0);
212 gSPDisplayList(gMainGfxPos++, D_09001500_3918D0);
213 gSPDisplayList(gMainGfxPos++, D_E0090A40[data->unk_04]);
214
215 gSPScisTextureRectangle(gMainGfxPos++,
216 data->pos.x * 4.0f,
217 data->pos.y * 4.0f,
218 (data->pos.x + 128.0f) * 4.0f,
219 (data->pos.y + 64.0f) * 4.0f,
220 G_TX_RENDERTILE, 0, 1024, 512, 65024);
221 }
222 gDPPipeSync(gMainGfxPos++);
223 gDPSetDepthSource(gMainGfxPos++, G_ZS_PIXEL);
224 gDPPipeSync(gMainGfxPos++);
225 }
226}
void attack_result_text_render(EffectInstance *effect)
s8 D_E0090A78[5][6]
u8 D_E0090A70[8]
Gfx * D_E0090A54[5]
Gfx D_090016E8_391AB8[]
Gfx D_09001730_391B00[]
Gfx D_090018D8_391CA8[]
void attack_result_text_init(EffectInstance *effect)
Gfx D_09001938_391D08[]
Gfx D_09001610_3919E0[]
Gfx * D_E0090A40[5]
Gfx D_09001658_391A28[]
void func_E0090444(EffectInstance *effect)
Gfx D_09001918_391CE8[]
Gfx D_090018B8_391C88[]
void attack_result_text_update(EffectInstance *effect)
Gfx D_090016A0_391A70[]
void func_E0090428(EffectInstance *effect)
u8 D_E0090A68[8]
Gfx D_09001500_3918D0[]
Gfx D_090015A8_391978[]
Gfx D_090018F8_391CC8[]
EffectInstance * attack_result_text_main(s32 type, f32 posX, f32 posY, f32 posZ, f32 appearVel, s32 duration)
Mtx matrixStack[0x200]
f32 Matrix4f[4][4]
#define general_heap_malloc
#define guRotateF
#define guMtxF2L
#define sin_deg
#define guTranslateF
#define guMtxCatF
#define remove_effect
#define cos_deg
#define create_effect_instance
#define guScaleF
struct AttackResultTextFXData * attackResultText
Definition effects.h:2536
struct EffectGraphics * graphics
Definition effects.h:2606
EffectData data
Definition effects.h:2605
#define ASSERT(condition)
#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
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