Skip to content

Commit 274e715

Browse files
committed
Implement balloon time and unused evil trampoline
1 parent 319fd65 commit 274e715

2 files changed

Lines changed: 59 additions & 0 deletions

File tree

src/hooks/Jsk/items_Jsk.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,32 @@ TRAMPOLINE_DEF(0x8058321c, 0x80583220) {
3737
// clang-format on
3838
}
3939

40+
/**
41+
* @brief Sets the balloon time in Power Cruising
42+
*
43+
*/
44+
int JskSetBalloons() {
45+
return ItemMgr::GetInstance().GetJskFreeTimerNum() * 12;
46+
}
47+
48+
/**
49+
* @brief JskSetBalloons trampoline
50+
*/
51+
TRAMPOLINE_DEF(0x80581eb0, 0x80581eb4) {
52+
// clang-format off
53+
TRAMPOLINE_BEGIN
54+
55+
bl JskSetBalloons
56+
mr r0, r3
57+
58+
TRAMPOLINE_END
59+
mr r4, r0
60+
li r0, 0
61+
62+
blr
63+
// clang-format on
64+
}
65+
4066
/**
4167
* @brief Unlocks Boosting in Power Cruising
4268
*/

src/hooks/trampoline.h

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,37 @@
7575
addi r1, r1, 0x100;
7676
// clang-format on
7777

78+
/******************************************************************************
79+
*
80+
* Save/restore all registers (r3-r31) and leave room on the stack
81+
*
82+
******************************************************************************/
83+
84+
/**
85+
* @brief Saves *ALL* registers at the start of a trampoline function
86+
*/
87+
// clang-format off
88+
#define TRAMPOLINE_BEGIN_SP(length) \
89+
nofralloc ; \
90+
stwu r1, (-0x100 - length)(r1); \
91+
stmw r3, (0x0C + length)(r1) ; \
92+
mflr r12 ; \
93+
stw r12, (0x08 + length)(r1) ; \
94+
mfcr r12 ; \
95+
stw r12, (0x88 + length)(r1) ; \
96+
// clang-format on
97+
98+
/**
99+
* @brief Restores registers at the end of a trampoline function
100+
*/
101+
// clang-format off
102+
#define TRAMPOLINE_END_SP(length) \
103+
lwz r12, (0x88 + length)(r1); \
104+
mtcr r12 ; \
105+
lwz r12, (0x08 + length)(r1); \
106+
mtlr r12 ; \
107+
lmw r3, (0x0C + length)(r1); \
108+
addi r1, r1, (0x100 + length); \
109+
// clang-format on
110+
78111
#endif

0 commit comments

Comments
 (0)