-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathsteppower.c
102 lines (90 loc) · 2.72 KB
/
steppower.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#include "steppower.h"
#include <game.h>
#include <jt.h>
#include <screen.h>
#include <clock.h>
#include <steprail.h>
void SetFsp(FSP fsp) {
// Cleanup current powerup
switch (g_fsp) {
case FSP_Ball:
// If cur powerup is roll, reset JT's body state
if (g_pjt != nullptr && g_pjt->unk2220 == 13) {
SetJtJts(g_pjt, JTS_Stand, JTBS_Nil);
}
break;
case FSP_Mine:
// If cur powerup is mine, fade out the mine
if (g_pjt != nullptr) {
LO *ploMine = g_pjt->ploMine_1518;
if ((ploMine != nullptr) && (FIsLoInWorld(ploMine))) {
FadeAloOut((ALO *)g_pjt->ploMine_1518, 0.5f);
}
}
break;
default:
break;
}
if (g_pjt != nullptr) {
g_rtClockPowerUp = 1.0f;
if ((g_pjt->unk2750 != 0) && FIsLoInWorld((JT*)g_pjt->unk2750)) {
func_001D32D8(g_pjt->unk2750, g_pjt, 1);
}
func_001D31D0(g_pjt, 0);
if (g_pjt != nullptr && g_pjt == PpoCur()) {
g_fsp = fsp;
}
}
// If fsp is unchanged or invalid, return
int fspLast = g_pgsCur->fspLast;
if (fsp == fspLast || fsp >= (uint)FSP_Max) {
return;
}
// Show note
SetBlotDtVisible((NOTE*)&g_note.unk278, (g_pjt != nullptr) && (g_pjt == PpoCur()) ? 3.0 : 8.0);
SetBlotFontScale(0.6, (NOTE*)&g_note.unk278);
((NOTE*)&g_note.unk278)->pvtnote->pfnSetNoteAchzDraw((NOTE*)&g_note.unk278, s_mpfspachz[fsp]);
((NOTE*)&g_note.unk278)->pvtnote->pfnShowBlot((NOTE*)&g_note.unk278);
// Update last fsp in game state
g_pgsCur->fspLast = fsp;
}
INCLUDE_ASM(const s32, "P2/steppower", UpdateJtActivePowerUp__FP2JTP3JOY);
int IRotatePowerUp(JOY *pjoy, int iCur, int iMax, int *mpigrfvault)
{
// If L2 or R2 not pressed, powerup is unchanged.
if ((pjoy->grfbtnPressed & (PAD_L2 | PAD_R2)) == _NOT_PRESSED)
{
return iCur;
}
// Default to next powerup (assume R2 pressed).
int direction = 1;
if ((pjoy->grfbtnPressed & PAD_L2) != _NOT_PRESSED)
{
// L2 pressed, previous powerup.
direction = -1;
}
SetJoyBtnHandled(pjoy, (ushort)(PAD_L2 | PAD_R2));
uint grfValue;
int iNew = iCur;
int attemptsLeft = iMax;
do
{
attemptsLeft--;
iNew += direction;
if (attemptsLeft < 0)
{
return iCur;
}
if (iNew < 0)
{
iNew = iMax - 1;
}
else if (iMax <= iNew)
{
iNew = 0;
}
grfValue = grfvault_something();
} while ((grfValue & mpigrfvault[iNew]) == 0);
// Return the new powerup index.
return iNew;
}