mirror of
https://github.com/rvtr/unlaunch-installer_dev.git
synced 2026-01-26 13:43:08 -05:00
Allow applying splas and sound binary patch
This commit is contained in:
parent
1c0d2adf65
commit
80866c08ea
@ -16,6 +16,7 @@ static bool retailConsole = true;
|
||||
static UNLAUNCH_VERSION foundUnlaunchInstallerVersion = INVALID;
|
||||
static bool disableAllPatches = false;
|
||||
static bool enableSoundAndSplash = false;
|
||||
static const char* splashSoundBinaryPatchPath = NULL;
|
||||
bool charging = false;
|
||||
u8 batteryLevel = 0;
|
||||
|
||||
@ -74,7 +75,7 @@ static int mainMenu(int cursor)
|
||||
(foundUnlaunchInstallerVersion == v1_9 || foundUnlaunchInstallerVersion == v2_0) ? 047 : 037,
|
||||
disableAllPatches ? "On" : "Off");
|
||||
sprintf(soundPatchesStr, "\x1B[%02omEnable sound and splash: %s",
|
||||
(foundUnlaunchInstallerVersion == v2_0 && !disableAllPatches) ? 047 : 037,
|
||||
(foundUnlaunchInstallerVersion == v2_0 && !disableAllPatches && splashSoundBinaryPatchPath != NULL) ? 047 : 037,
|
||||
enableSoundAndSplash ? "On" : "Off");
|
||||
sprintf(installStr, "\x1B[%02omInstall unlaunch", (foundUnlaunchInstallerVersion != INVALID && !unlaunchFound) ? 047 : 037);
|
||||
addMenuItem(m, uninstallStr, NULL, 0);
|
||||
@ -177,6 +178,13 @@ int main(int argc, char **argv)
|
||||
"Installing unlaunch won't be possible.");
|
||||
}
|
||||
}
|
||||
|
||||
if(fileExists("nitro:/unlaunch-patch.bin"))
|
||||
{
|
||||
splashSoundBinaryPatchPath = "nitro:/unlaunch-patch.bin";
|
||||
} else if (fileExists("sd:/unlaunch-patch.bin")) {
|
||||
splashSoundBinaryPatchPath = "sd:/unlaunch-patch.bin";
|
||||
}
|
||||
|
||||
//check for unlaunch and region
|
||||
u8 region = 0xff;
|
||||
@ -257,17 +265,21 @@ int main(int argc, char **argv)
|
||||
break;
|
||||
|
||||
case MAIN_MENU_SOUND_SPLASH_PATCHES:
|
||||
if(foundUnlaunchInstallerVersion == v2_0 && !disableAllPatches) {
|
||||
if(foundUnlaunchInstallerVersion == v2_0 && !disableAllPatches && splashSoundBinaryPatchPath != NULL) {
|
||||
enableSoundAndSplash = !enableSoundAndSplash;
|
||||
}
|
||||
break;
|
||||
|
||||
case MAIN_MENU_SAFE_UNLAUNCH_INSTALL:
|
||||
if (foundUnlaunchInstallerVersion != INVALID && (choiceBox("Install unlaunch?") == YES)
|
||||
if (!unlaunchFound && foundUnlaunchInstallerVersion != INVALID && (choiceBox("Install unlaunch?") == YES)
|
||||
&& (retailLauncherTmdPresentAndToBePatched || (choiceBox("There doesn't seem to be a launcher.tmd\nfile matcing the hwinfo file\nKeep installing?") == YES))
|
||||
&& nandio_unlock_writing())
|
||||
{
|
||||
if(installUnlaunch(retailConsole, retailLauncherTmdPresentAndToBePatched ? retailLauncherTmdPath : NULL, disableAllPatches, enableSoundAndSplash))
|
||||
printf("Installing\n");
|
||||
if(installUnlaunch(retailConsole,
|
||||
retailLauncherTmdPresentAndToBePatched ? retailLauncherTmdPath : NULL,
|
||||
disableAllPatches,
|
||||
enableSoundAndSplash ? splashSoundBinaryPatchPath : NULL))
|
||||
{
|
||||
messageBox("Install successful!\n");
|
||||
unlaunchFound = true;
|
||||
|
||||
@ -402,7 +402,7 @@ static bool verifyUnlaunchInstaller(void)
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool patchUnlaunchInstaller(bool disableAllPatches, bool enableSoundAndSplash)
|
||||
static bool patchUnlaunchInstaller(bool disableAllPatches, const char* splashSoundBinaryPatchPath)
|
||||
{
|
||||
if(disableAllPatches)
|
||||
{
|
||||
@ -416,9 +416,39 @@ static bool patchUnlaunchInstaller(bool disableAllPatches, bool enableSoundAndSp
|
||||
const char newID[]{'S','A','N'};
|
||||
memcpy((unlaunchInstallerBuffer + 520) + patchOffset, newID, 3);
|
||||
}
|
||||
else if (enableSoundAndSplash)
|
||||
else if (splashSoundBinaryPatchPath)
|
||||
{
|
||||
|
||||
if(installerVersion != v2_0)
|
||||
{
|
||||
messageBox("\x1B[31mError:\x1B[33m The splash and sound patch is\n"
|
||||
"only for unlaunch 2.0\n");
|
||||
return false;
|
||||
}
|
||||
static constexpr auto patchOffset = 0x8580;
|
||||
static constexpr auto patchSectionSize = 0x67FD;
|
||||
auto* patch = fopen(splashSoundBinaryPatchPath, "rb");
|
||||
if(!patch)
|
||||
{
|
||||
messageBox("\x1B[31mError:\x1B[33m Failed to open the splash and\n"
|
||||
"sound patch is.\n");
|
||||
return false;
|
||||
}
|
||||
auto patchSize = getFileSize(patch);
|
||||
if(patchSize > patchSectionSize)
|
||||
{
|
||||
messageBox("\x1B[31mError:\x1B[33m Splash and sound patch is too\n"
|
||||
"big.\n");
|
||||
fclose(patch);
|
||||
return false;
|
||||
}
|
||||
if (fread((unlaunchInstallerBuffer + 520) + patchOffset, 1, patchSize, patch) != patchSize)
|
||||
{
|
||||
messageBox("\x1B[31mError:\x1B[33m Failed to read splash and sound\n"
|
||||
"patch.\n");
|
||||
fclose(patch);
|
||||
return false;
|
||||
}
|
||||
fclose(patch);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -432,9 +462,9 @@ UNLAUNCH_VERSION loadUnlaunchInstaller(const char* path)
|
||||
return INVALID;
|
||||
}
|
||||
|
||||
bool installUnlaunch(bool retailConsole, const char* retailLauncherTmdPath, bool disableAllPatches, bool enableSoundAndSplash)
|
||||
bool installUnlaunch(bool retailConsole, const char* retailLauncherTmdPath, bool disableAllPatches, const char* splashSoundBinaryPatchPath)
|
||||
{
|
||||
if (installerVersion == INVALID || !patchUnlaunchInstaller(disableAllPatches, enableSoundAndSplash))
|
||||
if (installerVersion == INVALID || !patchUnlaunchInstaller(disableAllPatches, splashSoundBinaryPatchPath))
|
||||
return false;
|
||||
|
||||
// Treat protos differently
|
||||
|
||||
@ -14,7 +14,7 @@ typedef enum UNLAUNCH_VERSION {
|
||||
} UNLAUNCH_VERSION;
|
||||
|
||||
bool uninstallUnlaunch(bool notProto, bool hasHNAABackup, const char* retailLauncherTmdPath);
|
||||
bool installUnlaunch(bool retailConsole, const char* retailLauncherTmdPath, bool disableAllPatches, bool enableSoundAndSplash);
|
||||
bool installUnlaunch(bool retailConsole, const char* retailLauncherTmdPath, bool disableAllPatches, const char* splashSoundBinaryPatchPath);
|
||||
|
||||
bool isLauncherTmdPatched(const char* path);
|
||||
|
||||
|
||||
BIN
nitrofiles/unlaunch-patch.bin
Normal file
BIN
nitrofiles/unlaunch-patch.bin
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user