From e384c91313bc6a50644212ef09bad055ff5df1b8 Mon Sep 17 00:00:00 2001 From: "sl1nk3.s" Date: Mon, 8 Jun 2009 18:07:45 +0000 Subject: [PATCH] Fix error #002 for Wad games, also fix the Wii menu black screen, this is still a bit hacky as we don't know where to read the IOS rev, but hey it works :p git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3378 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/Core/Src/Boot/Boot_WiiWAD.cpp | 17 +++++++++++++++++ Source/Core/DiscIO/Src/NANDContentLoader.cpp | 9 +++++++-- Source/Core/DiscIO/Src/NANDContentLoader.h | 1 + 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/Source/Core/Core/Src/Boot/Boot_WiiWAD.cpp b/Source/Core/Core/Src/Boot/Boot_WiiWAD.cpp index 83a27b93e2..1e31fdfc57 100644 --- a/Source/Core/Core/Src/Boot/Boot_WiiWAD.cpp +++ b/Source/Core/Core/Src/Boot/Boot_WiiWAD.cpp @@ -20,12 +20,14 @@ #include "../HLE/HLE.h" #include "../HW/Memmap.h" #include "../ConfigManager.h" +#include "../PatchEngine.h" #include "../IPC_HLE/WII_IPC_HLE.h" #include "NANDContentLoader.h" #include "FileUtil.h" #include "Boot_DOL.h" #include "Volume.h" +#include "VolumeCreator.h" bool CBoot::IsWiiWAD(const char *filename) @@ -62,6 +64,21 @@ bool CBoot::Boot_WiiWAD(const char* _pFilename) CDolLoader DolLoader(pContent->m_pData, pContent->m_Size); PC = DolLoader.GetEntryPoint() | 0x80000000; + // Pass the "#002 check" + // Apploader should write the IOS version and revision to 0x3140, and compare it + // to 0x3188 to pass the check, but we don't do it, and i don't know where to read the IOS rev... + // Currently we just write 0xFFFF for the revision, copy manually and it works fine :p + + // TODO : figure it correctly : where should we read the IOS rev that the wad "needs" ? + Memory::Write_U16(ContentLoader.GetIosVersion(), 0x00003140); + Memory::Write_U16(0xFFFF, 0x00003142); + Memory::Write_U32(Memory::Read_U32(0x00003140), 0x00003188); + + // Load patches and run startup patches + const DiscIO::IVolume* pVolume = DiscIO::CreateVolumeFromFilename(_pFilename); + if (pVolume != NULL) + PatchEngine::LoadPatches(pVolume->GetUniqueID().c_str()); + return true; } diff --git a/Source/Core/DiscIO/Src/NANDContentLoader.cpp b/Source/Core/DiscIO/Src/NANDContentLoader.cpp index b80156973f..eef2586b7b 100644 --- a/Source/Core/DiscIO/Src/NANDContentLoader.cpp +++ b/Source/Core/DiscIO/Src/NANDContentLoader.cpp @@ -123,6 +123,7 @@ public: bool IsValid() const { return m_Valid; } u64 GetTitleID() const { return m_TitleID; } + u16 GetIosVersion() const { return m_IosVersion; } u32 GetBootIndex() const { return m_BootIndex; } size_t GetContentSize() const { return m_Content.size(); } const SNANDContent* GetContentByIndex(int _Index) const; @@ -138,6 +139,7 @@ private: bool m_Valid; u64 m_TitleID; + u16 m_IosVersion; u32 m_BootIndex; u16 m_numEntries; u16 m_TileVersion; @@ -166,6 +168,7 @@ CNANDContentLoader::CNANDContentLoader(const std::string& _rName) : m_TitleID(-1) , m_BootIndex(-1) , m_Valid(false) + , m_IosVersion(0x09) { if (File::IsDirectory(_rName.c_str())) { @@ -233,7 +236,8 @@ bool CNANDContentLoader::CreateFromDirectory(const std::string& _rPath) m_TileVersion = Common::swap16(pTMD + 0x01dc); m_numEntries = Common::swap16(pTMD + 0x01de); m_BootIndex = Common::swap16(pTMD + 0x01e0); - m_TitleID = Common::swap64(pTMD + 0x018C); + m_TitleID = Common::swap64(pTMD + 0x018c); + m_IosVersion = Common::swap16(pTMD + 0x018a); m_Content.resize(m_numEntries); @@ -325,7 +329,8 @@ bool CNANDContentLoader::ParseTMD(u8* pDataApp, u32 pDataAppSize, u8* pTicket, u u32 numEntries = Common::swap16(pTMD + 0x01de); m_BootIndex = Common::swap16(pTMD + 0x01e0); - m_TitleID = Common::swap64(pTMD + 0x018C); + m_TitleID = Common::swap64(pTMD + 0x018c); + m_IosVersion = Common::swap16(pTMD + 0x018a); u8* p = pDataApp; diff --git a/Source/Core/DiscIO/Src/NANDContentLoader.h b/Source/Core/DiscIO/Src/NANDContentLoader.h index 9b5068fa9d..ee433e71b9 100644 --- a/Source/Core/DiscIO/Src/NANDContentLoader.h +++ b/Source/Core/DiscIO/Src/NANDContentLoader.h @@ -50,6 +50,7 @@ public: virtual bool IsValid() const = 0; virtual u64 GetTitleID() const = 0; + virtual u16 GetIosVersion() const = 0; virtual u32 GetBootIndex() const = 0; virtual size_t GetContentSize() const = 0; virtual const SNANDContent* GetContentByIndex(int _Index) const = 0;