Skip to content

Commit c9d2c8b

Browse files
committed
Implement more uses of checkIfPointerIsValid
1 parent 46b6ea1 commit c9d2c8b

File tree

4 files changed

+8
-20
lines changed

4 files changed

+8
-20
lines changed

ttyd-tools/rel/include/commonfunctions.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
namespace mod {
99

10+
extern "C" {
11+
1012
bool checkButtonCombo(uint16_t combo);
1113
bool checkButtonComboEveryFrame(uint16_t combo);
1214
bool checkForSpecificSeq(ttyd::seqdrv::SeqIndex wantedSeq);
@@ -42,4 +44,6 @@ ttyd::evtmgr::EvtWork *getCurrentEventWork();
4244
bool checkIfPointerIsValid(void *ptr);
4345
void *getLastPointerFromPath(void *address, int32_t *offset, uint32_t offsetAmount);;
4446

47+
}
48+
4549
}

ttyd-tools/rel/source/assembly/FixBlooperCrash2.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ mr %r30,%r4
1717

1818
# Check if battleUnitPointer is valid
1919
mr %r3,%r4 # battleUnitPointer
20-
bl checkBattleUnitPointer
20+
bl checkIfPointerIsValid
2121

2222
# Check the returned bool
2323
cmpwi %r3,0 # False

ttyd-tools/rel/source/main.cpp

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -59,22 +59,6 @@ extern "C"
5959
void BranchBackFixRoomProblems();
6060
}
6161

62-
// Additional function used by assembly overwrites
63-
extern "C" {
64-
bool checkBattleUnitPointer(void *battleUnitPointer)
65-
{
66-
uint32_t BattleUnitPtr = reinterpret_cast<uint32_t>(battleUnitPointer);
67-
if ((BattleUnitPtr < 0x80000000) || (BattleUnitPtr >= 0x81800000))
68-
{
69-
return false;
70-
}
71-
else
72-
{
73-
return true;
74-
}
75-
}
76-
}
77-
7862
// Functions accessed by assembly overwrites
7963
extern "C" {
8064
void *preventPreBattleSoftlock(void *fbatPointer)
@@ -121,7 +105,7 @@ bool displayMegaHammerBadgesInMenu(uint32_t checkBit)
121105

122106
uint32_t fixBlooperCrash1(uint32_t unkValue, void *battleUnitPointer)
123107
{
124-
if (checkBattleUnitPointer(battleUnitPointer))
108+
if (checkIfPointerIsValid(battleUnitPointer))
125109
{
126110
#ifdef TTYD_US
127111
uint32_t offset = 0x218;

ttyd-tools/rel/source/memorywatch.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ const char *getAddressStringFromOffsets(int32_t slot, uint32_t maxOffset)
7373
MemoryWatch[slot].Address), OffsetArray, maxOffset));
7474

7575
// Make sure the address is valid
76-
if ((Address < 0x80000000) || (Address >= 0x81800000))
76+
if (!checkIfPointerIsValid(reinterpret_cast<void *>(Address)))
7777
{
7878
// Address is invalid
7979
return "???";
@@ -98,7 +98,7 @@ const char *getValueString(int32_t slot)
9898
MemoryWatch[slot].AddressOffset, MemoryWatch[slot].AddressOffsetAmount));
9999

100100
// Make sure the address is valid
101-
if ((Address < 0x80000000) || (Address >= 0x81800000))
101+
if (!checkIfPointerIsValid(reinterpret_cast<void *>(Address)))
102102
{
103103
// Address is invalid
104104
return "???";

0 commit comments

Comments
 (0)