Skip to content

Commit 2b969f7

Browse files
committed
Added a separate function for getting the current REL pointer
1 parent f8d3583 commit 2b969f7

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

ttyd-tools/rel/include/commonfunctions.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ bool checkButtonCombo(uint16_t combo);
1212
bool checkButtonComboEveryFrame(uint16_t combo);
1313
bool checkForSpecificSeq(ttyd::seqdrv::SeqIndex wantedSeq);
1414
bool checkIfInGame();
15+
void *getCurrentRELPointer();
1516
void *getBattlePointer();
1617
void *getMarioBattlePointer();
1718
void *getPartnerBattlePointer();

ttyd-tools/rel/source/commonfunctions.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,7 @@ bool checkIfInGame()
6666
ttyd::seqdrv::SeqIndex CurrentSeq = ttyd::seqdrv::seqGetSeq();
6767
if (CurrentSeq == Game)
6868
{
69-
uint32_t Current_REL_Loaded_Pointer = *reinterpret_cast<uint32_t *>(
70-
*reinterpret_cast<uint32_t *>(GlobalWorkPointer) + 0x15C);
71-
69+
uint32_t Current_REL_Loaded_Pointer = reinterpret_cast<uint32_t>(getCurrentRELPointer());
7270
if (Current_REL_Loaded_Pointer != 0)
7371
{
7472
#ifdef TTYD_US
@@ -91,10 +89,15 @@ bool checkIfInGame()
9189
return false;
9290
}
9391

92+
void *getCurrentRELPointer()
93+
{
94+
return *reinterpret_cast<uint32_t **>(
95+
*reinterpret_cast<uint32_t *>(GlobalWorkPointer) + 0x15C);
96+
}
97+
9498
void *getBattlePointer()
9599
{
96-
uint32_t *BattlePointer = *reinterpret_cast<uint32_t **>(BattleAddressesStart);
97-
return BattlePointer;
100+
return *reinterpret_cast<uint32_t **>(BattleAddressesStart);
98101
}
99102

100103
void *getMarioBattlePointer()
@@ -270,7 +273,7 @@ void recheckJumpAndHammerLevels()
270273

271274
uint32_t getCurrentPitFloor()
272275
{
273-
return ttyd::swdrv::swByteGet(1321) + 1; // GSW(1321);
276+
return ttyd::swdrv::swByteGet(1321) + 1; // GSW(1321)
274277
}
275278

276279
void clearGSWFsRange(uint32_t lowerBound, uint32_t upperBound)

ttyd-tools/rel/source/main.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -373,9 +373,7 @@ void performRELPatches()
373373
}
374374

375375
// Make sure a REL file is currently loaded
376-
uint32_t Current_REL_Loaded_Pointer = *reinterpret_cast<uint32_t *>(
377-
*reinterpret_cast<uint32_t *>(GlobalWorkPointer) + 0x15C);
378-
376+
uint32_t Current_REL_Loaded_Pointer = reinterpret_cast<uint32_t>(getCurrentRELPointer());
379377
if (Current_REL_Loaded_Pointer == 0)
380378
{
381379
return;

0 commit comments

Comments
 (0)