Boot: Install WADs temporarily
Because the Wii NAND size is finite, mark titles that were installed only for booting as temporary, and remove them whenever we need to install another title (to make room). This is exactly what the System Menu does for temporary SD card title data.
This commit is contained in:
parent
4b4a9a6486
commit
dedb61e5bf
|
@ -38,7 +38,7 @@ bool CBoot::BootNANDTitle(const u64 title_id)
|
||||||
|
|
||||||
bool CBoot::Boot_WiiWAD(const DiscIO::WiiWAD& wad)
|
bool CBoot::Boot_WiiWAD(const DiscIO::WiiWAD& wad)
|
||||||
{
|
{
|
||||||
if (!WiiUtils::InstallWAD(*IOS::HLE::GetIOS(), wad))
|
if (!WiiUtils::InstallWAD(*IOS::HLE::GetIOS(), wad, WiiUtils::InstallType::Temporary))
|
||||||
{
|
{
|
||||||
PanicAlertT("Cannot boot this WAD because it could not be installed to the NAND.");
|
PanicAlertT("Cannot boot this WAD because it could not be installed to the NAND.");
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include "Common/NandPaths.h"
|
#include "Common/NandPaths.h"
|
||||||
#include "Common/StringUtil.h"
|
#include "Common/StringUtil.h"
|
||||||
#include "Common/Swap.h"
|
#include "Common/Swap.h"
|
||||||
|
#include "Common/SysConf.h"
|
||||||
#include "Core/CommonTitles.h"
|
#include "Core/CommonTitles.h"
|
||||||
#include "Core/ConfigManager.h"
|
#include "Core/ConfigManager.h"
|
||||||
#include "Core/IOS/Device.h"
|
#include "Core/IOS/Device.h"
|
||||||
|
@ -109,7 +110,7 @@ static bool ImportWAD(IOS::HLE::Kernel& ios, const DiscIO::WiiWAD& wad)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InstallWAD(IOS::HLE::Kernel& ios, const DiscIO::WiiWAD& wad)
|
bool InstallWAD(IOS::HLE::Kernel& ios, const DiscIO::WiiWAD& wad, InstallType install_type)
|
||||||
{
|
{
|
||||||
if (!wad.GetTMD().IsValid())
|
if (!wad.GetTMD().IsValid())
|
||||||
return false;
|
return false;
|
||||||
|
@ -121,20 +122,42 @@ bool InstallWAD(IOS::HLE::Kernel& ios, const DiscIO::WiiWAD& wad)
|
||||||
|
|
||||||
// If a different version is currently installed, warn the user to make sure
|
// If a different version is currently installed, warn the user to make sure
|
||||||
// they don't overwrite the current version by mistake.
|
// they don't overwrite the current version by mistake.
|
||||||
if (ios.GetES()->FindInstalledTMD(wad.GetTMD().GetTitleId()).IsValid() &&
|
const u64 title_id = wad.GetTMD().GetTitleId();
|
||||||
!AskYesNoT("A different version of this title is already installed on the NAND. "
|
const IOS::ES::TMDReader installed_tmd = ios.GetES()->FindInstalledTMD(title_id);
|
||||||
"Installing this WAD will replace it irreversibly. Continue?"))
|
const bool has_another_version =
|
||||||
|
installed_tmd.IsValid() && installed_tmd.GetTitleVersion() != wad.GetTMD().GetTitleVersion();
|
||||||
|
if (has_another_version &&
|
||||||
|
!AskYesNoT("A different version of this title is already installed on the NAND.\n\n"
|
||||||
|
"Installed version: %u\nWAD version: %u\n\n"
|
||||||
|
"Installing this WAD will replace it irreversibly. Continue?",
|
||||||
|
installed_tmd.GetTitleVersion(), wad.GetTMD().GetTitleVersion()))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ImportWAD(ios, wad);
|
// Delete a previous temporary title, if it exists.
|
||||||
|
SysConf sysconf{Common::FROM_SESSION_ROOT};
|
||||||
|
SysConf::Entry* tid_entry = sysconf.GetOrAddEntry("IPL.TID", SysConf::Entry::Type::LongLong);
|
||||||
|
if (const u64 previous_temporary_title_id = Common::swap64(tid_entry->GetData<u64>(0)))
|
||||||
|
ios.GetES()->DeleteTitleContent(previous_temporary_title_id);
|
||||||
|
|
||||||
|
if (!ImportWAD(ios, wad))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// Keep track of the title ID so this title can be removed to make room for any future install.
|
||||||
|
// We use the same mechanism as the System Menu for temporary SD card title data.
|
||||||
|
if (!has_another_version && install_type == InstallType::Temporary)
|
||||||
|
tid_entry->SetData<u64>(Common::swap64(title_id));
|
||||||
|
else
|
||||||
|
tid_entry->SetData<u64>(0);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InstallWAD(const std::string& wad_path)
|
bool InstallWAD(const std::string& wad_path)
|
||||||
{
|
{
|
||||||
IOS::HLE::Kernel ios;
|
IOS::HLE::Kernel ios;
|
||||||
return InstallWAD(ios, DiscIO::WiiWAD{wad_path});
|
return InstallWAD(ios, DiscIO::WiiWAD{wad_path}, InstallType::Permanent);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Common functionality for system updaters.
|
// Common functionality for system updaters.
|
||||||
|
|
|
@ -27,8 +27,15 @@ class Kernel;
|
||||||
|
|
||||||
namespace WiiUtils
|
namespace WiiUtils
|
||||||
{
|
{
|
||||||
bool InstallWAD(IOS::HLE::Kernel& ios, const DiscIO::WiiWAD& wad);
|
enum class InstallType
|
||||||
// Same as the above, but constructs a temporary IOS and WiiWAD instance for importing.
|
{
|
||||||
|
Permanent,
|
||||||
|
Temporary,
|
||||||
|
};
|
||||||
|
|
||||||
|
bool InstallWAD(IOS::HLE::Kernel& ios, const DiscIO::WiiWAD& wad, InstallType type);
|
||||||
|
// Same as the above, but constructs a temporary IOS and WiiWAD instance for importing
|
||||||
|
// and does a permanent install.
|
||||||
bool InstallWAD(const std::string& wad_path);
|
bool InstallWAD(const std::string& wad_path);
|
||||||
|
|
||||||
enum class UpdateResult
|
enum class UpdateResult
|
||||||
|
|
Loading…
Reference in New Issue