BootUp: Clean up elf BootUp code.

* The file already exsists, otherwise we wouldn't have gotten
   this far in the boot.
 * We have already checked if it's a Wii or GameCube elf,
   besides, it's too late to change our minds now anyway.
 * On Wii - Don't call EmulatedBS2, it can never succeed as
   it knows nothing about booting elfs. Just call the
   SetupWiiMemory directly if needed.
 * On GameCube - We still call EmulatedBS2_GC, but we stop
   it from running Apploader, which might boot something
   unexpected from the default iso or DVD root folder.
This commit is contained in:
Scott Mansell 2014-11-01 22:20:56 +13:00
parent 2642c3f73b
commit 1e5762b163
3 changed files with 17 additions and 42 deletions

View File

@ -324,58 +324,33 @@ bool CBoot::BootUp()
// ELF
case SCoreStartupParameter::BOOT_ELF:
{
if (!File::Exists(_StartupPara.m_strFilename))
{
PanicAlertT("The file you specified (%s) does not exist",
_StartupPara.m_strFilename.c_str());
return false;
}
// Check if we have gotten a Wii file or not
bool elfWii = IsElfWii(_StartupPara.m_strFilename);
if (elfWii != _StartupPara.bWii)
{
PanicAlertT("Warning - starting ELF in wrong console mode!");
}
bool BS2Success = false;
if (elfWii)
{
BS2Success = EmulatedBS2(elfWii);
}
else if (!VolumeHandler::IsWiiDisc() && !_StartupPara.m_strDefaultISO.empty())
{
VolumeHandler::SetVolumeName(_StartupPara.m_strDefaultISO);
BS2Success = EmulatedBS2(elfWii);
}
// load image or create virtual drive from directory
if (!_StartupPara.m_strDVDRoot.empty())
{
NOTICE_LOG(BOOT, "Setting DVDRoot %s", _StartupPara.m_strDVDRoot.c_str());
// TODO: auto-convert elf to dol, so we can load them :)
VolumeHandler::SetVolumeDirectory(_StartupPara.m_strDVDRoot, elfWii);
BS2Success = EmulatedBS2(elfWii);
VolumeHandler::SetVolumeDirectory(_StartupPara.m_strDVDRoot, _StartupPara.bWii);
}
else if (!_StartupPara.m_strDefaultISO.empty())
{
NOTICE_LOG(BOOT, "Loading default ISO %s", _StartupPara.m_strDefaultISO.c_str());
VolumeHandler::SetVolumeName(_StartupPara.m_strDefaultISO);
}
else VolumeHandler::SetVolumeDirectory(_StartupPara.m_strFilename, elfWii);
else
{
VolumeHandler::SetVolumeDirectory(_StartupPara.m_strFilename, _StartupPara.bWii);
}
DVDInterface::SetDiscInside(VolumeHandler::IsValid());
if (BS2Success)
{
HLE::PatchFunctions();
}
else // Poor man's bootup
{
Load_FST(elfWii);
Boot_ELF(_StartupPara.m_strFilename);
}
// Poor man's bootup
if(_StartupPara.bWii)
SetupWiiMemory(DiscIO::IVolume::COUNTRY_UNKNOWN);
else
EmulatedBS2_GC(true);
Load_FST(_StartupPara.bWii);
Boot_ELF(_StartupPara.m_strFilename);
UpdateDebugger_MapLoaded();
Dolphin_Debugger::AddAutoBreakpoints();
break;

View File

@ -52,7 +52,7 @@ private:
static bool Boot_ELF(const std::string& filename);
static bool Boot_WiiWAD(const std::string& filename);
static bool EmulatedBS2_GC();
static bool EmulatedBS2_GC(bool skipAppLoader = false);
static bool EmulatedBS2_Wii();
static bool EmulatedBS2(bool _bIsWii);
static bool Load_BS2(const std::string& _rBootROMFilename);

View File

@ -34,7 +34,7 @@ void CBoot::RunFunction(u32 _iAddr)
// GameCube Bootstrap 2 HLE:
// copy the apploader to 0x81200000
// execute the apploader, function by function, using the above utility.
bool CBoot::EmulatedBS2_GC()
bool CBoot::EmulatedBS2_GC(bool skipAppLoader)
{
INFO_LOG(BOOT, "Faking GC BS2...");
@ -84,7 +84,7 @@ bool CBoot::EmulatedBS2_GC()
u32 iAppLoaderOffset = 0x2440;
u32 iAppLoaderEntry = VolumeHandler::Read32(iAppLoaderOffset + 0x10, false);
u32 iAppLoaderSize = VolumeHandler::Read32(iAppLoaderOffset + 0x14, false) + VolumeHandler::Read32(iAppLoaderOffset + 0x18, false);
if ((iAppLoaderEntry == (u32)-1) || (iAppLoaderSize == (u32)-1))
if ((iAppLoaderEntry == (u32)-1) || (iAppLoaderSize == (u32)-1) || skipAppLoader)
{
INFO_LOG(BOOT, "GC BS2: Not running apploader!");
return false;