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

Go to the source code of this file.

Enumerations

enum  {
  BUFF_STATE_IDLE = 0 , BUFF_STATE_DECREMENT_TURNS_INIT = 1 , BUFF_STATE_DECREMENT_TURNS = 10 , BUFF_STATE_SET_TURNS_INIT = 2 ,
  BUFF_STATE_SET_TURNS = 20 , BUFF_STATE_FADE_OUT = 3 , BUFF_STATE_FADE_IN_INIT = 4 , BUFF_STATE_FADE_IN = 40
}
 

Functions

void partner_buff_init (EffectInstance *effect)
 
void partner_buff_update (EffectInstance *effect)
 
void partner_buff_render (EffectInstance *effect)
 
void func_E011A3A0 (EffectInstance *effect)
 
void func_E011A700 (EffectInstance *effect)
 
EffectInstancepartner_buff_main (s32 useRandomValues, f32 arg1, f32 arg2, f32 arg3, f32 arg4, s32 duration)
 
void func_E011A3BC (s16 alpha)
 
void func_E011A48C (s32 posX, s32 posY, s32 tile, f32 scale)
 

Variables

Gfx D_09001800_406740 []
 
Gfx D_090019A0_4068E0 []
 
Gfx D_09001A18_406958 []
 
Gfx D_09001A90_4069D0 []
 
Gfx D_09001B08_406A48 []
 
Gfx D_09001B80_406AC0 []
 
Gfx * D_E011AC20 [] = { D_09001800_406740 }
 
Gfx * D_E011AC24 []
 
s8 D_E011AC4C [] = { 15, 15, 15, 15, 15, 35, 75, 100, 100, 100, 100, 0 }
 
s8 D_E011AC58 [] = { 100, 100, 100, 100, 100, 90, 10, 10, 10, 10, 10, 0 }
 
s8 D_E011AC64 [] = { 0, -1, -3, -4, -4, 4, 32, 32, 32, 32, 32, 0 }
 

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
BUFF_STATE_IDLE 
BUFF_STATE_DECREMENT_TURNS_INIT 
BUFF_STATE_DECREMENT_TURNS 
BUFF_STATE_SET_TURNS_INIT 
BUFF_STATE_SET_TURNS 
BUFF_STATE_FADE_OUT 
BUFF_STATE_FADE_IN_INIT 
BUFF_STATE_FADE_IN 

Definition at line 10 of file partner_buff.c.

10 {
19};
@ BUFF_STATE_FADE_IN_INIT
@ BUFF_STATE_FADE_IN
@ BUFF_STATE_SET_TURNS
@ BUFF_STATE_SET_TURNS_INIT
@ BUFF_STATE_DECREMENT_TURNS_INIT
@ BUFF_STATE_DECREMENT_TURNS
@ BUFF_STATE_FADE_OUT
@ BUFF_STATE_IDLE

Function Documentation

◆ partner_buff_init()

void partner_buff_init ( EffectInstance * effect)

Definition at line 81 of file partner_buff.c.

81 {
82}

Referenced by partner_buff_main().

◆ partner_buff_update()

void partner_buff_update ( EffectInstance * effect)

Definition at line 84 of file partner_buff.c.

84 {
85 PartnerBuffFXData* data = effect->data.partnerBuff;
86 s32 useRandomValues = data->useRandomValues;
87 s32 time;
88 s32 i;
89
90 if (effect->flags & FX_INSTANCE_FLAG_DISMISS) {
91 effect->flags &= ~FX_INSTANCE_FLAG_DISMISS;
92 data->timeLeft = 16;
93 }
94 if (data->timeLeft < 1000) {
95 data->timeLeft--;
96 }
97
98 data->lifeTime++;
99 if (data->timeLeft < 0) {
100 remove_effect(effect);
101 return;
102 }
103
104 time = data->lifeTime;
105
106 for (i = 0; i < ARRAY_COUNT(data->unk_0C); i++) {
107 BuffData* buff = &data->unk_0C[i];
108
109 if (buff->turnsLeft < 0) {
110 buff->turnsLeft = 0;
111 }
112 // possibly a leftover debug option
113 if (useRandomValues == 1 && time % 30 == 0) {
114 buff->turnsLeft = rand_int(4);
115 }
116
117 switch (buff->state) {
118 case BUFF_STATE_IDLE:
119 if (buff->alpha == 255) {
120 if (buff->turnsLeft < buff->turnsDisplay) {
122 } else if (buff->turnsDisplay < buff->turnsLeft) {
124 } else if (buff->turnsDisplay == 0) {
126 }
127 } else if ((buff->alpha == 0) && (buff->turnsLeft > 0)) {
129 }
130 break;
132 buff->stateTimer = 0;
134 // fallthrough
136 buff->stateTimer++;
137 if (buff->stateTimer > 10) {
138 buff->stateTimer = 0;
139 buff->state = BUFF_STATE_IDLE;
140 buff->turnsDisplay--;
141 }
142 break;
144 buff->stateTimer = 0;
146 // fallthrough
148 buff->stateTimer++;
149 if (buff->stateTimer > 10) {
150 buff->stateTimer = 0;
151 buff->state = BUFF_STATE_IDLE;
152 buff->turnsDisplay = buff->turnsLeft;
153 }
154 break;
156 buff->alpha -= 32;
157 if (buff->alpha < 0) {
158 buff->alpha = 0;
159 buff->state = BUFF_STATE_IDLE;
160 }
161 break;
164 buff->turnsDisplay = buff->turnsLeft;
165 // fallthrough
167 buff->alpha += 64;
168 if (buff->alpha > 255) {
169 buff->alpha = 255;
170 buff->state = BUFF_STATE_IDLE;
171 }
172 break;
173 }
174 }
175}
#define remove_effect
#define rand_int
s16 turnsDisplay
Definition effects.h:2325
s16 turnsLeft
Definition effects.h:2326
s16 stateTimer
Definition effects.h:2328
struct PartnerBuffFXData * partnerBuff
Definition effects.h:2591
s16 alpha
Definition effects.h:2324
BuffData unk_0C[3]
Definition effects.h:2336
s16 state
Definition effects.h:2327
EffectData data
Definition effects.h:2605
@ FX_INSTANCE_FLAG_DISMISS
Definition enums.h:3517
#define ARRAY_COUNT(arr)
Definition macros.h:40

Referenced by partner_buff_main().

◆ partner_buff_render()

void partner_buff_render ( EffectInstance * effect)

Definition at line 177 of file partner_buff.c.

177 {
178}

Referenced by partner_buff_main().

◆ func_E011A3A0()

void func_E011A3A0 ( EffectInstance * effect)

Definition at line 180 of file partner_buff.c.

180 {
181 func_E011A700(effect);
182}
void func_E011A700(EffectInstance *effect)

Referenced by partner_buff_main().

◆ func_E011A700()

void func_E011A700 ( EffectInstance * effect)

Definition at line 211 of file partner_buff.c.

211 {
212 PartnerBuffFXData* data = effect->data.partnerBuff;
213 Camera* camera = &gCameras[gCurrentCameraID];
214 s32 numShown;
215 s32 alpha;
216 s32 temp1;
217 s32 temp2;
218 f32 scale;
219 Gfx* dlist;
220 f32 x, y;
221 s32 i;
222
223 if (data->visible) {
224 gDPPipeSync(gMainGfxPos++);
225 gSPSegment(gMainGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(((EffectInstance*)effect)->graphics->data));
226
227 gSPDisplayList(gMainGfxPos++, D_E011AC20[0]);
228
229 numShown = 0;
230 for (i = 0; i < ARRAY_COUNT(data->unk_0C); i++) {
231 BuffData* buffData = &data->unk_0C[i];
232
233 alpha = buffData->alpha;
234 if (alpha != 0) {
235 gSPTexture(gMainGfxPos++, 0xFFFF, 0xFFFF, 2, i, G_ON);
236 func_E011A3BC(alpha);
237 func_E011A48C(20 + numShown * 32, 50, i, 1024.0f);
238 numShown++;
239 }
240 }
241
242 gSPTexture(gMainGfxPos++, 0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON);
243 gDPSetTextureLUT(gMainGfxPos++, G_TT_NONE);
244
245 numShown = 0;
246 for (i = 0; i < ARRAY_COUNT(data->unk_0C); i++) {
247 BuffData* buffData = &data->unk_0C[i];
248 s16 turnsDisplay = buffData->turnsDisplay;
249 s16 stateTimer = buffData->stateTimer;
250
251 alpha = buffData->alpha;
252
253 if (alpha != 0) {
254 if (turnsDisplay < 0) {
255 turnsDisplay = 0;
256 }
257 if (turnsDisplay > 9) {
258 turnsDisplay = 9;
259 }
260 func_E011A3BC(alpha);
261
262 if (buffData->state == BUFF_STATE_DECREMENT_TURNS || buffData->state == BUFF_STATE_SET_TURNS) {
263 s32 idx;
264
265 if (buffData->state == BUFF_STATE_DECREMENT_TURNS) {
266 idx = turnsDisplay - 1;
267 } else if (buffData->state == BUFF_STATE_SET_TURNS) {
268 idx = turnsDisplay + 1;
269 }
270 dlist = D_E011AC24[idx];
271 if (dlist != NULL) {
272 gSPDisplayList(gMainGfxPos++, dlist);
273 scale = D_E011AC4C[(s16)stateTimer] * 0.01f;
274 temp2 = (-(scale - 1.0f) * 16.0f) + 0.5;
275 x = temp2 + 20 + numShown * 32;
276 y = temp2 + 50;
277 func_E011A48C(x, y, 0, 1024.0f / scale);
278 }
279 }
280
281 dlist = D_E011AC24[turnsDisplay];
282 if (dlist != NULL) {
283 gSPDisplayList(gMainGfxPos++, dlist);
284 temp1 = D_E011AC64[(s16)stateTimer];
285 temp2 = -temp1;
286 scale = D_E011AC58[(s16)stateTimer] * 0.01f;
287 x = temp1 + 20 + numShown * 32;
288 y = temp2 + 50;
289 func_E011A48C(x, y, 0, 1024.0f / scale);
290 }
291 numShown++;
292 }
293 }
294
295 gDPSetScissor(gMainGfxPos++, G_SC_NON_INTERLACE,
296 camera->viewportStartX,
297 camera->viewportStartY,
298 camera->viewportStartX + camera->viewportW,
299 camera->viewportStartY + camera->viewportH
300 );
301 gDPPipeSync(gMainGfxPos++);
302 }
303}
s8 D_E011AC58[]
s8 D_E011AC64[]
s8 D_E011AC4C[]
Gfx * D_E011AC24[]
Gfx * D_E011AC20[]
void func_E011A3BC(s16 alpha)
void func_E011A48C(s32 posX, s32 posY, s32 tile, f32 scale)
#define VIRTUAL_TO_PHYSICAL(addr)
Definition macros.h:47
s16 viewportStartX
s16 viewportStartY
Camera gCameras[4]
Definition cam_main.c:17
Gfx * gMainGfxPos
Definition cam_main.c:15
s32 gCurrentCameraID
Definition cam_math.c:4

Referenced by func_E011A3A0().

◆ partner_buff_main()

EffectInstance * partner_buff_main ( s32 useRandomValues,
f32 arg1,
f32 arg2,
f32 arg3,
f32 arg4,
s32 duration )

Definition at line 38 of file partner_buff.c.

38 {
40 EffectInstance* effect;
42 s32 numParts = 1;
43 s32 i;
44
45 bp.unk_00 = 0;
50 bp.effectID = EFFECT_PARTNER_BUFF;
51
52 effect = create_effect_instance(&bp);
53 effect->numParts = numParts;
54 part = effect->data.partnerBuff = general_heap_malloc(numParts * sizeof(*part));
55 ASSERT(effect->data.partnerBuff != NULL);
56
57 part->useRandomValues = useRandomValues;
58 part->lifeTime = 0;
59 if (duration <= 0) {
60 part->timeLeft = 1000;
61 } else {
62 part->timeLeft = duration;
63 }
64
65 for (i = 0; i < ARRAY_COUNT(part->unk_0C); i++) {
66 part->unk_0C[i].alpha = 0;
67 part->unk_0C[i].turnsDisplay = 0;
68 part->unk_0C[i].turnsLeft = 0;
69 part->unk_0C[i].state = BUFF_STATE_IDLE;
70 part->unk_0C[i].stateTimer = 0;
71 }
72
73 part->visible = FALSE;
74 if (useRandomValues == 1) {
75 part->visible = TRUE;
76 }
77
78 return effect;
79}
#define general_heap_malloc
#define create_effect_instance
#define ASSERT(condition)
void partner_buff_init(EffectInstance *effect)
void partner_buff_render(EffectInstance *effect)
void func_E011A3A0(EffectInstance *effect)
void partner_buff_update(EffectInstance *effect)
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

◆ func_E011A3BC()

void func_E011A3BC ( s16 alpha)

Definition at line 184 of file partner_buff.c.

184 {
185 if (alpha == 255) {
186 gDPSetRenderMode(gMainGfxPos++, AA_EN | CVG_DST_FULL | ZMODE_OPA | CVG_X_ALPHA |
187 GBL_c1(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM),
188 GBL_c2(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM));
189 gDPSetCombineMode(gMainGfxPos++, G_CC_DECALRGBA, G_CC_DECALRGBA);
190 } else {
191 gDPSetRenderMode(gMainGfxPos++, G_RM_CLD_SURF, G_RM_CLD_SURF2);
192 gDPSetCombineMode(gMainGfxPos++, PM_CC_01, PM_CC_01);
193 gDPSetPrimColor(gMainGfxPos++, 0, 0, 0, 0, 0, alpha);
194 }
195}
#define PM_CC_01
Definition macros.h:276

Referenced by func_E011A700().

◆ func_E011A48C()

void func_E011A48C ( s32 posX,
s32 posY,
s32 tile,
f32 scale )

Definition at line 197 of file partner_buff.c.

197 {
198 gSPScisTextureRectangle(gMainGfxPos++,
199 posX * 4,
200 posY * 4,
201 (posX + 32) * 4,
202 (posY + 32) * 4,
203 tile,
204 0,
205 1024,
206 scale,
207 -scale);
208 gDPPipeSync(gMainGfxPos++);
209}

Referenced by func_E011A700().

Variable Documentation

◆ D_09001800_406740

Gfx D_09001800_406740[]
extern

◆ D_090019A0_4068E0

Gfx D_090019A0_4068E0[]
extern

◆ D_09001A18_406958

Gfx D_09001A18_406958[]
extern

◆ D_09001A90_4069D0

Gfx D_09001A90_4069D0[]
extern

◆ D_09001B08_406A48

Gfx D_09001B08_406A48[]
extern

◆ D_09001B80_406AC0

Gfx D_09001B80_406AC0[]
extern

◆ D_E011AC20

Gfx* D_E011AC20[] = { D_09001800_406740 }

Definition at line 28 of file partner_buff.c.

Gfx D_09001800_406740[]

Referenced by func_E011A700().

◆ D_E011AC24

Gfx* D_E011AC24[]
Initial value:
= {
NULL, NULL, NULL, NULL, NULL
}
Gfx D_090019A0_4068E0[]
Gfx D_09001A18_406958[]
Gfx D_09001B08_406A48[]
Gfx D_09001A90_4069D0[]
Gfx D_09001B80_406AC0[]

Definition at line 29 of file partner_buff.c.

Referenced by func_E011A700().

◆ D_E011AC4C

s8 D_E011AC4C[] = { 15, 15, 15, 15, 15, 35, 75, 100, 100, 100, 100, 0 }

Definition at line 34 of file partner_buff.c.

34{ 15, 15, 15, 15, 15, 35, 75, 100, 100, 100, 100, 0 };

Referenced by func_E011A700().

◆ D_E011AC58

s8 D_E011AC58[] = { 100, 100, 100, 100, 100, 90, 10, 10, 10, 10, 10, 0 }

Definition at line 35 of file partner_buff.c.

35{ 100, 100, 100, 100, 100, 90, 10, 10, 10, 10, 10, 0 };

Referenced by func_E011A700().

◆ D_E011AC64

s8 D_E011AC64[] = { 0, -1, -3, -4, -4, 4, 32, 32, 32, 32, 32, 0 }

Definition at line 36 of file partner_buff.c.

36{ 0, -1, -3, -4, -4, 4, 32, 32, 32, 32, 32, 0 };

Referenced by func_E011A700().