Skip to content

Commit 035049d

Browse files
committed
Jump Storage + Other minor changes
Added a code to display and activate Jump Storage, changed some naming of variables, and changed some variable sizes.
1 parent a28d90c commit 035049d

File tree

12 files changed

+162
-84
lines changed

12 files changed

+162
-84
lines changed

ttyd-tools/rel/include/mod.h

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ class Mod
2020
// Palace Skip
2121
void palaceSkip();
2222
Timer<uint32_t> mPalaceSkipTimer;
23-
bool mPalaceSkipTimerPaused = false;
24-
bool mPalaceSkipInfoEnabled = false;
23+
bool palaceSkipTimerPaused = false;
24+
bool palaceSkipInfoEnabled = false;
2525

2626
// Yoshi Skip
2727
void yoshiSkip();
2828
Timer<uint32_t> mYoshiSkipTimer;
29-
bool mYoshiSkipTimerPaused = false;
30-
bool mYoshiSkipInfoEnabled = false;
29+
bool yoshiSkipTimerPaused = false;
30+
bool yoshiSkipInfoEnabled = false;
3131

3232
// --Codes--
3333
// Force Phantom Ember Drop
@@ -48,16 +48,16 @@ class Mod
4848

4949
// Save/Load Mario/Partner Positions
5050
void saveLoadPositions();
51-
float MarioSavePositions[4];
52-
float PartnerSavePositions[4];
51+
float marioSavePositions[4];
52+
float partnerSavePositions[4];
5353

5454
// Reload Screen
5555
void reloadScreen();
5656

5757
// On-Screen Timer
5858
void onScreenTimer();
5959
Timer<uint32_t> mOnScreenTimer;
60-
bool mOnScreenTimerEnabled = false;
60+
bool onScreenTimerEnabled = false;
6161

6262
// Auto Action Commands
6363
void autoActionCommands();
@@ -67,12 +67,12 @@ class Mod
6767

6868
// Save Anywhere
6969
void saveAnywhere();
70-
bool mSaveAnywhereScriptRunning = false;
71-
uint32_t mSaveAnywhereThreadID;
70+
bool saveAnywhereScriptRunning = false;
71+
uint32_t saveAnywhereThreadID;
7272

7373
// Adjust Coin Count + Set Sequence
7474
void adjustCoinCountSetSequence();
75-
uint32_t CoinCountButtonHoldCounter;
75+
uint16_t CoinCountButtonHoldCounter;
7676

7777
// Warp
7878
void warp();
@@ -89,13 +89,13 @@ class Mod
8989

9090
// Lock Mario's HP, Toggle
9191
void lockMarioHPToggle();
92-
bool MarioHPCurrentlyLocked = false;
92+
bool marioHPCurrentlyLocked = false;
9393
bool lockMarioHPToggleDisable = false;
9494

9595
// Change Inventory
9696
void changeInventory();
97-
uint16_t FirstButtonPressed;
98-
uint32_t ChangeInventoryButtonHoldCounter;
97+
uint16_t firstButtonPressed;
98+
uint16_t changeInventoryButtonHoldCounter;
9999

100100
// Allow running from any fight
101101
void allowRunAway();
@@ -123,12 +123,18 @@ class Mod
123123

124124
// Button Input Display
125125
void buttonInputDisplay();
126-
uint32_t mButtonInputDisplayCounter;
127-
bool mButtonInputDisplayEnabled = false;
126+
uint16_t buttonInputDisplayCounter;
127+
bool buttonInputDisplayEnabled = false;
128+
129+
// Jump Storage Display
130+
void jumpStorageDisplay();
131+
uint16_t jumpStorageDisplayCounter;
132+
uint8_t jumpStorageButtonCounter;
133+
bool jumpStorageDisplayEnabled = false;
128134

129135
private:
130-
uint32_t mResetCounter;
131-
uint32_t mEnabledOrDisabledCounter;
136+
uint16_t mResetCounter;
137+
uint16_t mEnabledOrDisabledCounter;
132138

133139
void (*mPFN_makeKey_trampoline)() = nullptr;
134140
char mDisplayBuffer[256];

ttyd-tools/rel/source/codes/ButtonInputDisplayC.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,22 @@ void Mod::buttonInputDisplay()
1515

1616
if ((ButtonInput & ButtonInputDisplayEnableCombo) == ButtonInputDisplayEnableCombo)
1717
{
18-
// Hold button to increment counter
19-
++mButtonInputDisplayCounter;
18+
// Hold button combo to increment counter
19+
++buttonInputDisplayCounter;
2020
}
2121
else
2222
{
23-
mButtonInputDisplayCounter = 0;
23+
buttonInputDisplayCounter = 0;
2424
}
2525

26-
if (mButtonInputDisplayCounter > 360)
26+
if (buttonInputDisplayCounter > 360)
2727
{
28-
// Enable/Disable the Button Input Display when button is held for 6 seconds
29-
mButtonInputDisplayEnabled = !mButtonInputDisplayEnabled;
30-
mButtonInputDisplayCounter = 0;
28+
// Enable/Disable the Button Input Display when button combo is held for 6 seconds
29+
buttonInputDisplayEnabled = !buttonInputDisplayEnabled;
30+
buttonInputDisplayCounter = 0;
3131
}
3232

33-
if (mButtonInputDisplayEnabled)
33+
if (buttonInputDisplayEnabled)
3434
{
3535
char ButtonArray[] = {'(', ')', 'v', '^', 'Z', 'R', 'L', ' ', 'A', 'B', 'X', 'Y', 'S'};
3636
int32_t DrawX = -252;

ttyd-tools/rel/source/codes/ChangeInventoryC.cpp

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ void Mod::changeInventory()
111111
{
112112
// Currently in the pause menu
113113
uint32_t ButtonInput = ttyd::system::keyGetButton(0);
114-
int16_t PressedOrHeldButtonCount = 0;
114+
uint8_t PressedOrHeldButtonCount = 0;
115115
uint16_t ButtonHoldFrames = 45; // 0.75 Seconds
116116

117117
uint32_t PauseMenuAddress = *reinterpret_cast<uint32_t *>(PauseMenuAddressesStart);
@@ -149,14 +149,14 @@ void Mod::changeInventory()
149149

150150
if (PressedOrHeldButtonCount < 2)
151151
{
152-
// Zero or one button(s) are pressed/held, so set FirstButtonPressed to 0 or currently-pressed/held button
153-
FirstButtonPressed = ButtonInput;
152+
// Zero or one button(s) are pressed/held, so set firstButtonPressed to 0 or currently-pressed/held button
153+
firstButtonPressed = ButtonInput;
154154
}
155155

156156
// Add item/badge
157-
if (((ButtonInput & InventoryAddItemOrBadgeCombo) == InventoryAddItemOrBadgeCombo) && (FirstButtonPressed == InventoryAddItemOrBadgeFirstButtonCombo))
157+
if (((ButtonInput & InventoryAddItemOrBadgeCombo) == InventoryAddItemOrBadgeCombo) && (firstButtonPressed == InventoryAddItemOrBadgeFirstButtonCombo))
158158
{
159-
if (ChangeInventoryButtonHoldCounter == 0)
159+
if (changeInventoryButtonHoldCounter == 0)
160160
{
161161
// Add item/badge
162162
if (CurrentTab == 2)
@@ -170,11 +170,11 @@ void Mod::changeInventory()
170170
addItemOrBadge(PouchBadgeInventoryAddress, CursorItem, PowerJump, BadgesLoopCounter, SubMenuEquippedBadges);
171171
}
172172
}
173-
ChangeInventoryButtonHoldCounter++;
173+
changeInventoryButtonHoldCounter++;
174174
}
175-
else if (((ButtonInput & InventoryRemoveItemOrBadgeCombo) == InventoryRemoveItemOrBadgeCombo) && (FirstButtonPressed == InventoryRemoveItemOrBadgeFirstButtonCombo))
175+
else if (((ButtonInput & InventoryRemoveItemOrBadgeCombo) == InventoryRemoveItemOrBadgeCombo) && (firstButtonPressed == InventoryRemoveItemOrBadgeFirstButtonCombo))
176176
{
177-
if (ChangeInventoryButtonHoldCounter == 0)
177+
if (changeInventoryButtonHoldCounter == 0)
178178
{
179179
// Remove item/badge
180180
if ((CurrentTab == 2) && (CursorItem != 0))
@@ -189,11 +189,11 @@ void Mod::changeInventory()
189189
ttyd::mario_pouch::pouchReviseMarioParam(); // Check equipped badges and adjust BP used
190190
}
191191
}
192-
ChangeInventoryButtonHoldCounter++;
192+
changeInventoryButtonHoldCounter++;
193193
}
194-
else if (((ButtonInput & InventoryPreviousValueCombo) == InventoryPreviousValueCombo) && (FirstButtonPressed == InventoryPreviousValueFirstButtonCombo))
194+
else if (((ButtonInput & InventoryPreviousValueCombo) == InventoryPreviousValueCombo) && (firstButtonPressed == InventoryPreviousValueFirstButtonCombo))
195195
{
196-
if (ChangeInventoryButtonHoldCounter == 0)
196+
if (changeInventoryButtonHoldCounter == 0)
197197
{
198198
if ((CursorItem > 0) && (CursorItem < 236))
199199
{
@@ -207,11 +207,11 @@ void Mod::changeInventory()
207207
ttyd::mario_pouch::pouchReviseMarioParam(); // Check equipped badges and adjust BP used
208208
}
209209
}
210-
ChangeInventoryButtonHoldCounter++;
210+
changeInventoryButtonHoldCounter++;
211211
}
212-
else if (((ButtonInput & InventoryNextValueCombo) == InventoryNextValueCombo) && (FirstButtonPressed == InventoryNextValueFirstButtonCombo))
212+
else if (((ButtonInput & InventoryNextValueCombo) == InventoryNextValueCombo) && (firstButtonPressed == InventoryNextValueFirstButtonCombo))
213213
{
214-
if (ChangeInventoryButtonHoldCounter == 0)
214+
if (changeInventoryButtonHoldCounter == 0)
215215
{
216216
if ((CursorItem > 0) && (CursorItem < 236))
217217
{
@@ -225,18 +225,18 @@ void Mod::changeInventory()
225225
ttyd::mario_pouch::pouchReviseMarioParam(); // Check equipped badges and adjust BP used
226226
}
227227
}
228-
ChangeInventoryButtonHoldCounter++;
228+
changeInventoryButtonHoldCounter++;
229229
}
230230
else
231231
{
232232
// Reset counter if no button combo is pressed/held
233-
ChangeInventoryButtonHoldCounter = 0;
233+
changeInventoryButtonHoldCounter = 0;
234234
}
235235

236-
if (ChangeInventoryButtonHoldCounter > ButtonHoldFrames)
236+
if (changeInventoryButtonHoldCounter > ButtonHoldFrames)
237237
{
238238
// Reset if counter exceeds ButtonHoldFrames
239-
ChangeInventoryButtonHoldCounter = 0;
239+
changeInventoryButtonHoldCounter = 0;
240240
}
241241
}
242242
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#include "mod.h"
2+
#include "buttons.h"
3+
4+
#include <ttyd/system.h>
5+
#include <ttyd/mario.h>
6+
#include <ttyd/fontmgr.h>
7+
8+
#include <cstdio>
9+
10+
extern uint16_t JumpStorageDisplayEnableCombo;
11+
12+
namespace mod {
13+
14+
void Mod::jumpStorageDisplay()
15+
{
16+
if ((ttyd::system::keyGetButton(0) & JumpStorageDisplayEnableCombo) == JumpStorageDisplayEnableCombo)
17+
{
18+
// Hold button combo to increment counter
19+
++jumpStorageDisplayCounter;
20+
}
21+
else
22+
{
23+
jumpStorageDisplayCounter = 0;
24+
}
25+
26+
if (jumpStorageDisplayCounter > 360)
27+
{
28+
// Enable/Disable the Jump Storage Display when button combo is held for 6 seconds
29+
jumpStorageDisplayEnabled = !jumpStorageDisplayEnabled;
30+
jumpStorageDisplayCounter = 0;
31+
}
32+
33+
if (jumpStorageDisplayEnabled)
34+
{
35+
ttyd::mario::Player *player = ttyd::mario::marioGetPtr();
36+
uint32_t ButtonInputTrg = ttyd::system::keyGetButtonTrg(0);
37+
38+
if (ButtonInputTrg & PAD_Y)
39+
{
40+
// Press Y to increment counter
41+
++jumpStorageButtonCounter;
42+
}
43+
else if (ButtonInputTrg != 0)
44+
{
45+
// Reset counter if a different button is pressed
46+
jumpStorageButtonCounter = 0;
47+
}
48+
49+
if (jumpStorageButtonCounter == 3)
50+
{
51+
player->flags3 |= 1 << 16; // Turn on the 16 bit
52+
jumpStorageButtonCounter = 0;
53+
}
54+
55+
sprintf(mDisplayBuffer,
56+
"JS: %ld\r\nSpdY: %.2f",
57+
(player->flags3 & (1 << 16)) >> 16, // Get only the 16 bit
58+
player->wJumpVelocityY);
59+
60+
ttyd::fontmgr::FontDrawStart();
61+
uint32_t color = 0xFFFFFFFF;
62+
ttyd::fontmgr::FontDrawColor(reinterpret_cast<uint8_t *>(&color));
63+
ttyd::fontmgr::FontDrawEdge();
64+
ttyd::fontmgr::FontDrawMessage(87, 120, mDisplayBuffer);
65+
}
66+
}
67+
68+
}

ttyd-tools/rel/source/codes/MarioLockHPToggleC.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ void Mod::lockMarioHPToggle()
1717
uint32_t ButtonInput = ttyd::system::keyGetButton(0);
1818
uint32_t SystemLevel = ttyd::mariost::marioStGetSystemLevel();
1919

20-
if (!MarioHPCurrentlyLocked)
20+
if (!marioHPCurrentlyLocked)
2121
{
2222
// HP not currently locked
2323
if (((ButtonInput & LockMarioHPToggleCombo) == LockMarioHPToggleCombo) && (SystemLevel != 15))
2424
{
2525
// Not in pause menu
2626
if (!lockMarioHPToggleDisable)
2727
{
28-
MarioHPCurrentlyLocked = true;
28+
marioHPCurrentlyLocked = true;
2929
}
3030
lockMarioHPToggleDisable = true;
3131
}
@@ -64,7 +64,7 @@ void Mod::lockMarioHPToggle()
6464
// Not in pause menu
6565
if (!lockMarioHPToggleDisable)
6666
{
67-
MarioHPCurrentlyLocked = false;
67+
marioHPCurrentlyLocked = false;
6868
}
6969
lockMarioHPToggleDisable = true;
7070
}

ttyd-tools/rel/source/codes/OnScreenTimerC.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,17 @@ void Mod::onScreenTimer()
2020
if ((ButtonInput & EnableOrResetTimerCombo) == (EnableOrResetTimerCombo))
2121
{
2222
// Enable/Reset Timer
23-
mOnScreenTimerEnabled = true;
23+
onScreenTimerEnabled = true;
2424
mOnScreenTimer.stop();
2525
mOnScreenTimer.setValue(0);
2626
}
2727

28-
if (mOnScreenTimerEnabled)
28+
if (onScreenTimerEnabled)
2929
{
3030
if ((ButtonInput & DisableTimerCombo) == (DisableTimerCombo))
3131
{
3232
// Disable Timer
33-
mOnScreenTimerEnabled = false;
33+
onScreenTimerEnabled = false;
3434
mOnScreenTimer.stop();
3535
}
3636
else if ((ButtonInput & StartOrResumeTimerCombo) == (StartOrResumeTimerCombo))

ttyd-tools/rel/source/codes/SaveAnywhereC.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace mod {
1414

1515
void Mod::saveAnywhere()
1616
{
17-
if (!mSaveAnywhereScriptRunning)
17+
if (!saveAnywhereScriptRunning)
1818
{
1919
// Save Script is not running
2020
if ((ttyd::system::keyGetButton(0) & SaveAnywhereCombo) == (SaveAnywhereCombo))
@@ -34,15 +34,15 @@ void Mod::saveAnywhere()
3434
// Take away control from the player and start the Save script
3535
ttyd::mario::marioKeyOff();
3636
ttyd::mariost::marioStSystemLevel(1);
37-
mSaveAnywhereThreadID = *reinterpret_cast<uint32_t *>(ttyd::evtmgr::evtEntryType(SaveScript, 0, 0, 0) + 0x15C);
38-
mSaveAnywhereScriptRunning = true;
37+
saveAnywhereThreadID = *reinterpret_cast<uint32_t *>(ttyd::evtmgr::evtEntryType(SaveScript, 0, 0, 0) + 0x15C);
38+
saveAnywhereScriptRunning = true;
3939
}
4040
}
4141
}
42-
else if (!ttyd::evtmgr::evtCheckID(mSaveAnywhereThreadID))
42+
else if (!ttyd::evtmgr::evtCheckID(saveAnywhereThreadID))
4343
{
4444
// Save Script is no longer running, so give back control to the player
45-
mSaveAnywhereScriptRunning = false;
45+
saveAnywhereScriptRunning = false;
4646
ttyd::mariost::marioStSystemLevel(0);
4747
ttyd::mario::marioKeyOn();
4848
}

0 commit comments

Comments
 (0)