Don't patch 480p if a game uses MetaFortress

This commit is contained in:
wiidev 2021-04-04 19:00:01 +01:00
parent 2547bd75d9
commit 64bfd820bb

View File

@ -238,7 +238,7 @@ void GameBooter::ShutDownDevices(int gameUSBPort)
int GameBooter::BootGame(struct discHdr *gameHdr) int GameBooter::BootGame(struct discHdr *gameHdr)
{ {
if(!gameHdr) if (!gameHdr)
return -1; return -1;
struct discHdr gameHeader; struct discHdr gameHeader;
@ -246,10 +246,10 @@ int GameBooter::BootGame(struct discHdr *gameHdr)
gprintf("\tBootGame: %.6s\n", gameHeader.id); gprintf("\tBootGame: %.6s\n", gameHeader.id);
if(Settings.Wiinnertag) if (Settings.Wiinnertag)
Wiinnertag::TagGame((const char *) gameHeader.id); Wiinnertag::TagGame((const char *) gameHeader.id);
if(gameHeader.type == TYPE_GAME_GC_IMG || gameHeader.type == TYPE_GAME_GC_DISC || gameHdr->type == TYPE_GAME_GC_EXTRACTED) if (gameHeader.type == TYPE_GAME_GC_IMG || gameHeader.type == TYPE_GAME_GC_DISC || gameHdr->type == TYPE_GAME_GC_EXTRACTED)
return BootGCMode(&gameHeader); return BootGCMode(&gameHeader);
//! Setup game configuration from game settings. If no game settings exist use global/default. //! Setup game configuration from game settings. If no game settings exist use global/default.
@ -274,16 +274,16 @@ int GameBooter::BootGame(struct discHdr *gameHdr)
u64 returnToChoice = strlen(Settings.returnTo) > 0 ? (game_cfg->returnTo ? NandTitles.FindU32(Settings.returnTo) : 0) : 0; u64 returnToChoice = strlen(Settings.returnTo) > 0 ? (game_cfg->returnTo ? NandTitles.FindU32(Settings.returnTo) : 0) : 0;
u8 NandEmuMode = OFF; u8 NandEmuMode = OFF;
const char *NandEmuPath = game_cfg->NandEmuPath.size() == 0 ? Settings.NandEmuPath : game_cfg->NandEmuPath.c_str(); const char *NandEmuPath = game_cfg->NandEmuPath.size() == 0 ? Settings.NandEmuPath : game_cfg->NandEmuPath.c_str();
if(gameHeader.type == TYPE_GAME_WII_IMG) if (gameHeader.type == TYPE_GAME_WII_IMG)
NandEmuMode = game_cfg->NandEmuMode == INHERIT ? Settings.NandEmuMode : game_cfg->NandEmuMode; NandEmuMode = game_cfg->NandEmuMode == INHERIT ? Settings.NandEmuMode : game_cfg->NandEmuMode;
if(gameHeader.type == TYPE_GAME_EMUNANDCHAN) if (gameHeader.type == TYPE_GAME_EMUNANDCHAN)
{ {
NandEmuMode = game_cfg->NandEmuMode == INHERIT ? Settings.NandEmuChanMode : game_cfg->NandEmuMode; NandEmuMode = game_cfg->NandEmuMode == INHERIT ? Settings.NandEmuChanMode : game_cfg->NandEmuMode;
NandEmuPath = game_cfg->NandEmuPath.size() == 0 ? Settings.NandEmuChanPath : game_cfg->NandEmuPath.c_str(); NandEmuPath = game_cfg->NandEmuPath.size() == 0 ? Settings.NandEmuChanPath : game_cfg->NandEmuPath.c_str();
} }
// boot neek for Wii games and EmuNAND channels only // boot neek for Wii games and EmuNAND channels only
if(NandEmuMode == EMUNAND_NEEK && (gameHeader.type == TYPE_GAME_WII_IMG || gameHeader.type == TYPE_GAME_EMUNANDCHAN)) if (NandEmuMode == EMUNAND_NEEK && (gameHeader.type == TYPE_GAME_WII_IMG || gameHeader.type == TYPE_GAME_EMUNANDCHAN))
return BootNeek(&gameHeader); return BootNeek(&gameHeader);
AppCleanUp(); AppCleanUp();
@ -300,19 +300,19 @@ int GameBooter::BootGame(struct discHdr *gameHdr)
SetupAltDOL(gameHeader.id, alternatedol, alternatedoloffset); SetupAltDOL(gameHeader.id, alternatedol, alternatedoloffset);
//! Reload game settings cIOS for this game //! Reload game settings cIOS for this game
if(iosChoice != IOS_GetVersion()) if (iosChoice != IOS_GetVersion())
{ {
gprintf("Reloading into game cIOS: %i...\n", iosChoice); gprintf("Reloading into game cIOS: %i...\n", iosChoice);
IosLoader::LoadGameCios(iosChoice); IosLoader::LoadGameCios(iosChoice);
if(MountGamePartition(false) < 0) if (MountGamePartition(false) < 0)
return -1; return -1;
} }
//! Modify Wii Message Board to display the game starting here (before Nand Emu) //! Modify Wii Message Board to display the game starting here (before Nand Emu)
if(Settings.PlaylogUpdate) if (Settings.PlaylogUpdate)
{ {
// enable isfs permission if using IOS+AHB or Hermes v4 // enable isfs permission if using IOS+AHB or Hermes v4
if(IOS_GetVersion() < 200 || (IosLoader::IsHermesIOS() && IOS_GetRevision() == 4)) if (IOS_GetVersion() < 200 || (IosLoader::IsHermesIOS() && IOS_GetRevision() == 4))
{ {
gprintf("Patching IOS%d...\n", IOS_GetVersion()); gprintf("Patching IOS%d...\n", IOS_GetVersion());
if (IosPatch_RUNTIME(true, false, false, false, false) == ERROR_PATCH) if (IosPatch_RUNTIME(true, false, false, false, false) == ERROR_PATCH)
@ -342,18 +342,18 @@ int GameBooter::BootGame(struct discHdr *gameHdr)
} }
//! Force hooktype if not selected but Ocarina is enabled //! Force hooktype if not selected but Ocarina is enabled
if(ocarinaChoice && Hooktype == OFF) if (ocarinaChoice && Hooktype == OFF)
Hooktype = 1; Hooktype = 1;
//! Load gameconfig.txt even if ocarina disabled //! Load gameconfig.txt even if ocarina disabled
if(Hooktype) if (Hooktype)
LoadGameConfig(Settings.Cheatcodespath); LoadGameConfig(Settings.Cheatcodespath);
//! Setup NAND emulation //! Setup NAND emulation
SetupNandEmu(NandEmuMode, NandEmuPath, gameHeader); SetupNandEmu(NandEmuMode, NandEmuPath, gameHeader);
//! Setup disc stuff if we load a game //! Setup disc stuff if we load a game
if(gameHeader.tid == 0) if (gameHeader.tid == 0)
{ {
//! Setup disc in cIOS and open it //! Setup disc in cIOS and open it
ret = SetupDisc(gameHeader); ret = SetupDisc(gameHeader);
@ -366,9 +366,9 @@ int GameBooter::BootGame(struct discHdr *gameHdr)
gprintf("%d\n", ret); gprintf("%d\n", ret);
} }
if(IosLoader::IsHermesIOS(iosChoice)) if (IosLoader::IsHermesIOS(iosChoice))
{ {
if(reloadblock == ON) if (reloadblock == ON)
{ {
//! Setup IOS reload block //! Setup IOS reload block
enable_ES_ioctlv_vector(); enable_ES_ioctlv_vector();
@ -376,19 +376,19 @@ int GameBooter::BootGame(struct discHdr *gameHdr)
mload_close(); mload_close();
} }
} }
else if(IosLoader::IsD2X(iosChoice)) else if (IosLoader::IsD2X(iosChoice))
{ {
// Open ES file descriptor for the d2x patches // Open ES file descriptor for the d2x patches
static char es_fs[] ATTRIBUTE_ALIGN(32) = "/dev/es"; static char es_fs[] ATTRIBUTE_ALIGN(32) = "/dev/es";
int es_fd = IOS_Open(es_fs, 0); int es_fd = IOS_Open(es_fs, 0);
if(es_fd >= 0) if (es_fd >= 0)
{ {
// IOS Reload Block // IOS Reload Block
if(reloadblock != OFF) { if (reloadblock != OFF) {
BlockIOSReload(es_fd, iosChoice); BlockIOSReload(es_fd, iosChoice);
} }
// Check if new patch method for return to works otherwise old method will be used // Check if new patch method for return to works otherwise old method will be used
if(PatchNewReturnTo(es_fd, returnToChoice) >= 0) if (PatchNewReturnTo(es_fd, returnToChoice) >= 0)
returnToChoice = 0; // Patch successful, no need for old method returnToChoice = 0; // Patch successful, no need for old method
// Close ES file descriptor // Close ES file descriptor
@ -401,7 +401,7 @@ int GameBooter::BootGame(struct discHdr *gameHdr)
Channels::DestroyInstance(); Channels::DestroyInstance();
//! Load main.dol or alternative dol into memory, start the game apploader and get game entrypoint //! Load main.dol or alternative dol into memory, start the game apploader and get game entrypoint
if(gameHeader.tid == 0) if (gameHeader.tid == 0)
{ {
gprintf("\tGame Boot\n"); gprintf("\tGame Boot\n");
AppEntrypoint = BootPartition(Settings.dolpath, videoChoice, alternatedol, alternatedoloffset); AppEntrypoint = BootPartition(Settings.dolpath, videoChoice, alternatedol, alternatedoloffset);
@ -420,7 +420,7 @@ int GameBooter::BootGame(struct discHdr *gameHdr)
} }
//! No entrypoint found...back to HBC/SystemMenu //! No entrypoint found...back to HBC/SystemMenu
if(AppEntrypoint == 0) if (AppEntrypoint == 0)
{ {
gprintf("AppEntryPoint is 0, something went wrong\n"); gprintf("AppEntryPoint is 0, something went wrong\n");
WDVD_ClosePartition(); WDVD_ClosePartition();
@ -457,12 +457,24 @@ int GameBooter::BootGame(struct discHdr *gameHdr)
//! Load Code handler if needed //! Load Code handler if needed
load_handler(Hooktype, WiirdDebugger, Settings.WiirdDebuggerPause); load_handler(Hooktype, WiirdDebugger, Settings.WiirdDebuggerPause);
//! Apply the 480p fix (enabled by default).
//! Perform 480p fix if needed. //! This needs to be done after the call to gamepatches(), after loading any code handler.
//! Needs to be done after the call to gamepatches(), after loading any code handler.
//! Can (and should) be done before Wiimmfi patching, can't be done in gamepatches() itself. //! Can (and should) be done before Wiimmfi patching, can't be done in gamepatches() itself.
if(patchFix480pChoice) //! Exclude Prince of Persia: The Forgotten Sands and a few games that use MetaFortress
bool excludeGame = false;
if (memcmp(gameHeader.id, "RPW", 3) == 0 || memcmp(gameHeader.id, "SPX", 3) == 0 ||
memcmp(gameHeader.id, "R3D", 3) == 0 || memcmp(gameHeader.id, "SDV", 3) == 0 ||
memcmp(gameHeader.id, "SUK", 3) == 0 || memcmp(gameHeader.id, "STN", 3) == 0 ||
memcmp(gameHeader.id, "S7S", 3) == 0 || memcmp(gameHeader.id, "SDUP41", 6) == 0 ||
memcmp(gameHeader.id, "SDUE41", 6) == 0 || memcmp(gameHeader.id, "SDUX41", 6) == 0)
{
excludeGame = true;
}
if (patchFix480pChoice && !excludeGame)
{
PatchFix480p(); PatchFix480p();
}
//! If we're NOT on Wiimmfi, patch the known RCE vulnerability in MKWii. //! If we're NOT on Wiimmfi, patch the known RCE vulnerability in MKWii.
//! Wiimmfi will handle that on its own through the update payload. //! Wiimmfi will handle that on its own through the update payload.