Skip to content

Commit c54c054

Browse files
committed
Adjust pouchGetPtr() and use nullptr where appropriate
pouchGetPtr() returns a pointer, rather than a uint32_t. Use nullptr where appropriate for clarity.
1 parent 59d4b4d commit c54c054

File tree

8 files changed

+13
-10
lines changed

8 files changed

+13
-10
lines changed

ttyd-tools/rel/include/ttyd/mario_pouch.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ void pouchReviseMarioParam();
7878
// pouchHaveItem
7979
// pouchKeyItem
8080
// pouchInit
81-
uint32_t pouchGetPtr();
81+
void *pouchGetPtr();
8282

8383
}
8484

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ void Mod::addOrRemovePartners()
2222
{
2323
// Currently in the partners menu
2424
uint32_t ButtonInput = ttyd::system::keyGetButton(0);
25-
uint32_t PouchAddress = ttyd::mario_pouch::pouchGetPtr();
25+
uint32_t PouchAddress = reinterpret_cast<uint32_t>(ttyd::mario_pouch::pouchGetPtr());
2626

2727
if ((ButtonInput & AddPartnersCombo) == AddPartnersCombo)
2828
{

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ void Mod::adjustCoinCountSetSequence()
3333
if ((ttyd::mariost::marioStGetSystemLevel() == 15) && (CurrentTab == 0))
3434
{
3535
// Currently in the pause menu and Current Tab is Mario's stats
36-
uint32_t CoinCountAddress = ttyd::mario_pouch::pouchGetPtr() + 0x78;
36+
uint32_t PouchAddress = reinterpret_cast<uint32_t>(ttyd::mario_pouch::pouchGetPtr());
37+
uint32_t CoinCountAddress = PouchAddress + 0x78;
3738
int16_t CoinCount = *reinterpret_cast<int16_t *>(CoinCountAddress);
3839

3940
uint32_t ButtonInput = ttyd::system::keyGetButton(0);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ void Mod::changeInventory()
122122
uint32_t SubMenuEquippedBadges = *reinterpret_cast<uint32_t *>(PauseMenuAddress + 0x3E0);
123123
int32_t BadgesCurrentIndex = *reinterpret_cast<int32_t *>(PauseMenuAddress + 0x3E4);
124124

125-
uint32_t PouchAddress = ttyd::mario_pouch::pouchGetPtr();
125+
uint32_t PouchAddress = reinterpret_cast<uint32_t>(ttyd::mario_pouch::pouchGetPtr());
126126
uint32_t PouchStandardInventoryAddress = PouchAddress + 0x192;
127127
uint32_t PouchBadgeInventoryAddress = PouchAddress + 0x1FA;
128128

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ void Mod::gameOver()
1717
if (ttyd::seqdrv::seqGetNextSeq() != Logo)
1818
{
1919
// The game will crash if the following code runs during the Logo
20-
ttyd::seqdrv::seqSetSeq(ttyd::seqdrv::SeqIndex::kGameOver, 0, 0);
20+
ttyd::seqdrv::seqSetSeq(ttyd::seqdrv::SeqIndex::kGameOver, nullptr, nullptr);
2121
}
2222
}
2323
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ void Mod::lockMarioHPToggle()
3737
else
3838
{
3939
// Lock HP
40-
uint32_t PouchPointer = ttyd::mario_pouch::pouchGetPtr();
41-
*reinterpret_cast<int16_t *>(PouchPointer + 0x70) = *reinterpret_cast<int16_t *>(PouchPointer + 0x72); // Copy Max HP to Current HP
40+
uint32_t PouchAddress = reinterpret_cast<uint32_t>(ttyd::mario_pouch::pouchGetPtr());
41+
*reinterpret_cast<int16_t *>(PouchAddress + 0x70) = *reinterpret_cast<int16_t *>(PouchAddress + 0x72); // Copy Max HP to Current HP
4242
uint32_t BattleAddress = *reinterpret_cast<uint32_t *>(BattleAddressesStart);
4343
if (BattleAddress != 0)
4444
{

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ void Mod::spawnItem()
2424
if ((ttyd::seqdrv::seqGetNextSeq() == Game) && (ttyd::mariost::marioStGetSystemLevel() != 15))
2525
{
2626
// Not in pause menu
27-
int16_t CoinCount = *reinterpret_cast<int16_t *>(ttyd::mario_pouch::pouchGetPtr() + 0x78);
27+
uint32_t PouchAddress = reinterpret_cast<uint32_t>(ttyd::mario_pouch::pouchGetPtr());
28+
int16_t CoinCount = *reinterpret_cast<int16_t *>(PouchAddress + 0x78);
2829

2930
if ((CoinCount >= 1) && (CoinCount <= 338))
3031
{
@@ -51,7 +52,7 @@ void Mod::spawnItem()
5152
ItemCoordinateX += 30;
5253
}
5354

54-
ttyd::itemdrv::itemEntry(ItemName, CoinCount, 16, -1, 0, ItemCoordinateX, ItemCoordinateY, ItemCoordinateZ);
55+
ttyd::itemdrv::itemEntry(ItemName, CoinCount, 16, -1, nullptr, ItemCoordinateX, ItemCoordinateY, ItemCoordinateZ);
5556
delete[] (ItemName);
5657
}
5758
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ void Mod::warp()
2727
if ((ttyd::mariost::marioStGetSystemLevel() == 15) && (CurrentTab == 0))
2828
{
2929
// Currently in the pause menu, and Current Tab is Mario's stats
30-
int16_t CoinCount = *reinterpret_cast<int16_t *>(ttyd::mario_pouch::pouchGetPtr() + 0x78);
30+
uint32_t PouchAddress = reinterpret_cast<uint32_t>(ttyd::mario_pouch::pouchGetPtr());
31+
int16_t CoinCount = *reinterpret_cast<int16_t *>(PouchAddress + 0x78);
3132
uint32_t WarpToMap = 0;
3233

3334
switch (CoinCount)

0 commit comments

Comments
 (0)