From 1e5762b163182d3b7fe7c8623c44d08be93c337f Mon Sep 17 00:00:00 2001 From: Scott Mansell Date: Sat, 1 Nov 2014 22:20:56 +1300 Subject: [PATCH] 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. --- Source/Core/Core/Boot/Boot.cpp | 53 +++++++-------------------- Source/Core/Core/Boot/Boot.h | 2 +- Source/Core/Core/Boot/Boot_BS2Emu.cpp | 4 +- 3 files changed, 17 insertions(+), 42 deletions(-) diff --git a/Source/Core/Core/Boot/Boot.cpp b/Source/Core/Core/Boot/Boot.cpp index 9da2be25d3..7b019099c7 100644 --- a/Source/Core/Core/Boot/Boot.cpp +++ b/Source/Core/Core/Boot/Boot.cpp @@ -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; diff --git a/Source/Core/Core/Boot/Boot.h b/Source/Core/Core/Boot/Boot.h index c97099d24f..a562ba889a 100644 --- a/Source/Core/Core/Boot/Boot.h +++ b/Source/Core/Core/Boot/Boot.h @@ -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); diff --git a/Source/Core/Core/Boot/Boot_BS2Emu.cpp b/Source/Core/Core/Boot/Boot_BS2Emu.cpp index 21e057fc94..260ae4c67a 100644 --- a/Source/Core/Core/Boot/Boot_BS2Emu.cpp +++ b/Source/Core/Core/Boot/Boot_BS2Emu.cpp @@ -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;