Skip to content

Commit e02c74b

Browse files
committed
Added support for ACE loaders
1 parent afb1834 commit e02c74b

File tree

5 files changed

+32
-15
lines changed

5 files changed

+32
-15
lines changed

ttyd-tools/rel/include/patch.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace mod::patch {
66

77
void clear_DC_IC_Cache(void *ptr, uint32_t size);
8+
void overwriteAddressValue(void *address, uint32_t value);
89
void writeStandardBranches(void *address, void functionStart(), void functionBranchBack());
910
void writeBranch(void *ptr, void *destination);
1011
void writeBranchBL(void *ptr, void *destination);

ttyd-tools/rel/source/global.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
namespace mod {
55

6-
const char *VersionNumber = "v3.0.42";
6+
const char *VersionNumber = "v3.0.43";
77

88
const char *RootLines[] =
99
{

ttyd-tools/rel/source/main.cpp

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -738,20 +738,23 @@ void initAddressOverwrites()
738738

739739
patch::writeBranchBL(FallThroughMostObjectsBowserAddress, reinterpret_cast<void *>(StartFallThroughMostObjectsBowser));
740740

741-
*reinterpret_cast<uint32_t *>(DebugModeInitialzeAddress) = 0x3800FFFF; // li r0,-1
742-
*reinterpret_cast<uint32_t *>(DebugModeShowBuildDateAddress) = 0x60000000; // nop
741+
patch::overwriteAddressValue(DebugModeInitialzeAddress, 0x3800FFFF); // li r0,-1
743742

744-
*reinterpret_cast<uint32_t *>(PauseMenuPartnerMenuAddress) = 0x60000000; // nop
745-
*reinterpret_cast<uint32_t *>(PauseMenuBadgeMenuAddress) = 0x60000000; // nop
743+
patch::overwriteAddressValue(DebugModeShowBuildDateAddress, 0x60000000); // nop
746744

747-
*reinterpret_cast<uint32_t *>(PreventImportantItemCutscenesAddress) = 0x48000030; // b 0x30
745+
patch::overwriteAddressValue(PauseMenuPartnerMenuAddress, 0x60000000); // nop
748746

749-
*reinterpret_cast<uint32_t *>(msgWindowMrAddress) = 0x38830001; // addi r4,r3,1
747+
patch::overwriteAddressValue(PauseMenuBadgeMenuAddress, 0x60000000); // nop
748+
749+
patch::overwriteAddressValue(PreventImportantItemCutscenesAddress, 0x48000030); // b 0x30
750+
751+
patch::overwriteAddressValue(msgWindowMrAddress, 0x38830001); // addi r4,r3,1
750752

751753
// Set the initial value for the debug mode variable
752-
*reinterpret_cast<int32_t *>(
753-
reinterpret_cast<uint32_t>(
754-
ttyd::seq_title::seqTitleWorkPointer2) + 0x30) = -1;
754+
int32_t *DebugModeVar = reinterpret_cast<int32_t *>(
755+
reinterpret_cast<uint32_t>(ttyd::seq_title::seqTitleWorkPointer2) + 0x30);
756+
757+
patch::overwriteAddressValue(DebugModeVar, static_cast<uint32_t>(-1));
755758
}
756759

757760
void Mod::run()

ttyd-tools/rel/source/mod.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,18 @@ void Mod::init()
140140
gMod->errorHandler(error, context, dsisr, dar);
141141
});
142142

143-
// Initialize typesetting early
144-
ttyd::fontmgr::fontmgrTexSetup();
145-
patch::hookFunction(ttyd::fontmgr::fontmgrTexSetup, [](){});
143+
// Initialize typesettings early
144+
// Only run if an ACE loader was not used
145+
uint32_t LoaderValue = *reinterpret_cast<uint32_t *>(0x80004148);
146+
if (LoaderValue == 0)
147+
{
148+
// ACE loader was not used, so run the functions
149+
ttyd::fontmgr::fontmgrTexSetup();
150+
ttyd::windowdrv::windowTexSetup();
151+
}
146152

147-
// Initialize typesetting early
148-
ttyd::windowdrv::windowTexSetup();
153+
// Prevent the functions from being ran again
154+
patch::hookFunction(ttyd::fontmgr::fontmgrTexSetup, [](){});
149155
patch::hookFunction(ttyd::windowdrv::windowTexSetup, [](){});
150156

151157
// Skip the logo

ttyd-tools/rel/source/patch.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ void clear_DC_IC_Cache(void *ptr, uint32_t size)
1212
gc::OSCache::ICInvalidateRange(ptr, size);
1313
}
1414

15+
void overwriteAddressValue(void *address, uint32_t value)
16+
{
17+
uint32_t *tempAddress = reinterpret_cast<uint32_t *>(address);
18+
*tempAddress = value;
19+
clear_DC_IC_Cache(address, sizeof(uint32_t));
20+
}
21+
1522
void writeStandardBranches(void *address, void functionStart(), void functionBranchBack())
1623
{
1724
void *BranchBackAddress = reinterpret_cast<void *>(

0 commit comments

Comments
 (0)