diff --git a/Source/Core/Core/HW/EXI/EXI_DeviceIPL.cpp b/Source/Core/Core/HW/EXI/EXI_DeviceIPL.cpp index 528ed351f5..0cf6bbfc38 100644 --- a/Source/Core/Core/HW/EXI/EXI_DeviceIPL.cpp +++ b/Source/Core/Core/HW/EXI/EXI_DeviceIPL.cpp @@ -98,9 +98,18 @@ CEXIIPL::CEXIIPL() : m_uPosition(0), m_uAddress(0), m_uRWOffset(0), m_FontsLoade // Create the IPL m_pIPL = static_cast(Common::AllocateMemoryPages(ROM_SIZE)); - // The Wii doesn't have a copy of the IPL, only fonts. - if (SConfig::GetInstance().bWii || SConfig::GetInstance().bHLE_BS2) + // Load whole ROM dump + // Note: The Wii doesn't have a copy of the IPL, only fonts. + if (!SConfig::GetInstance().bWii && LoadFileToIPL(SConfig::GetInstance().m_strBootROM, 0)) { + // Descramble the encrypted section (contains BS1 and BS2) + Descrambler(m_pIPL + 0x100, 0x1afe00); + INFO_LOG(BOOT, "Loaded bootrom: %s", m_pIPL); // yay for null-terminated strings ;p + } + else + { + // If we are in Wii mode or if loading the GC IPL fails, we should still try to load fonts. + // Copy header if (DiscIO::IsNTSC(SConfig::GetInstance().m_region)) memcpy(m_pIPL, iplverNTSC, sizeof(iplverNTSC)); @@ -111,14 +120,6 @@ CEXIIPL::CEXIIPL() : m_uPosition(0), m_uAddress(0), m_uRWOffset(0), m_FontsLoade LoadFontFile((File::GetSysDirectory() + GC_SYS_DIR + DIR_SEP + FONT_SHIFT_JIS), 0x1aff00); LoadFontFile((File::GetSysDirectory() + GC_SYS_DIR + DIR_SEP + FONT_WINDOWS_1252), 0x1fcf00); } - else - { - // Load whole ROM dump - LoadFileToIPL(SConfig::GetInstance().m_strBootROM, 0); - // Descramble the encrypted section (contains BS1 and BS2) - Descrambler(m_pIPL + 0x100, 0x1afe00); - INFO_LOG(BOOT, "Loaded bootrom: %s", m_pIPL); // yay for null-terminated strings ;p - } // Clear RTC memset(m_RTC, 0, sizeof(m_RTC)); @@ -158,17 +159,19 @@ void CEXIIPL::DoState(PointerWrap& p) p.Do(m_FontsLoaded); } -void CEXIIPL::LoadFileToIPL(const std::string& filename, u32 offset) +bool CEXIIPL::LoadFileToIPL(const std::string& filename, u32 offset) { File::IOFile stream(filename, "rb"); if (!stream) - return; + return false; u64 filesize = stream.GetSize(); - stream.ReadBytes(m_pIPL + offset, filesize); + if (!stream.ReadBytes(m_pIPL + offset, filesize)) + return false; m_FontsLoaded = true; + return true; } std::string CEXIIPL::FindIPLDump(const std::string& path_prefix) diff --git a/Source/Core/Core/HW/EXI/EXI_DeviceIPL.h b/Source/Core/Core/HW/EXI/EXI_DeviceIPL.h index 031001e6f6..ea2d7093e2 100644 --- a/Source/Core/Core/HW/EXI/EXI_DeviceIPL.h +++ b/Source/Core/Core/HW/EXI/EXI_DeviceIPL.h @@ -74,7 +74,7 @@ private: void TransferByte(u8& _uByte) override; bool IsWriteCommand() const { return !!(m_uAddress & (1 << 31)); } u32 CommandRegion() const { return (m_uAddress & ~(1 << 31)) >> 8; } - void LoadFileToIPL(const std::string& filename, u32 offset); + bool LoadFileToIPL(const std::string& filename, u32 offset); void LoadFontFile(const std::string& filename, u32 offset); std::string FindIPLDump(const std::string& path_prefix); };