diff --git a/Source/Core/Core/Src/Boot/Boot_BIOSEmu.cpp b/Source/Core/Core/Src/Boot/Boot_BIOSEmu.cpp index 48d3f46e19..dbd3673586 100644 --- a/Source/Core/Core/Src/Boot/Boot_BIOSEmu.cpp +++ b/Source/Core/Core/Src/Boot/Boot_BIOSEmu.cpp @@ -42,6 +42,30 @@ void CBoot::RunFunction(u32 _iAddr) PowerPC::SingleStep(); } +// THIS IS UGLY. this should be figured out properly instead of patching the games. +bool Remove_002_Protection(u32 addr, int Size) +{ + u32 SearchPattern[3] = { 0x2C000000, 0x40820214, 0x3C608000 }; + u32 PatchData[3] = { 0x2C000000, 0x48000214, 0x3C608000 }; + + while (Size >= 12) + { + if (Memory::ReadUnchecked_U32(addr + 0) == SearchPattern[0] && + Memory::ReadUnchecked_U32(addr + 4) == SearchPattern[1] && + Memory::ReadUnchecked_U32(addr + 8) == SearchPattern[2]) + { + Memory::WriteUnchecked_U32(PatchData[0], addr); + Memory::WriteUnchecked_U32(PatchData[1], addr + 4); + Memory::WriteUnchecked_U32(PatchData[2], addr + 8); + return true; + } + addr += 4; + Size -= 4; + } + + return false; +} + // __________________________________________________________________________________________________ // // GameCube BIOS HLE: @@ -265,7 +289,6 @@ bool CBoot::SetupWiiMemory(unsigned int _CountryCode) { Memory::Write_U32(0x00000000, 0x80000000 + i); } - return true; } @@ -373,6 +396,14 @@ bool CBoot::EmulatedBIOS_Wii(bool _bDebug) PowerPC::ppcState.DebugCount = 0; + if (Core::GetStartupParameter().bFix002) + { + // UGLY UGLY UGLY + // TODO: Understand what this does and fix it properly.. + // This "fixes" games that display "Error 002" instead of running. + Remove_002_Protection(0x80004000, 0x5000000); + } + return true; } diff --git a/Source/Core/Core/Src/CoreParameter.cpp b/Source/Core/Core/Src/CoreParameter.cpp index d17b991743..446fe9e617 100644 --- a/Source/Core/Core/Src/CoreParameter.cpp +++ b/Source/Core/Core/Src/CoreParameter.cpp @@ -44,6 +44,7 @@ void SCoreStartupParameter::LoadDefaults() bDSPThread = true; bLockThreads = true; bWii = false; + bFix002 = false; SelectedLanguage = 0; iTLBHack = 0; delete gameIni; diff --git a/Source/Core/Core/Src/CoreParameter.h b/Source/Core/Core/Src/CoreParameter.h index 1011ed359c..ed21630e8a 100644 --- a/Source/Core/Core/Src/CoreParameter.h +++ b/Source/Core/Core/Src/CoreParameter.h @@ -71,6 +71,7 @@ struct SCoreStartupParameter bool bRunCompareClient; int iTLBHack; + bool bFix002; int SelectedLanguage; diff --git a/Source/Core/Core/Src/HW/EXI_Channel.h b/Source/Core/Core/Src/HW/EXI_Channel.h index c4ff4e96f4..23f9c6f1ff 100644 --- a/Source/Core/Core/Src/HW/EXI_Channel.h +++ b/Source/Core/Core/Src/HW/EXI_Channel.h @@ -14,6 +14,7 @@ // Official SVN repository and contact information can be found at // http://code.google.com/p/dolphin-emu/ + #ifndef _EXICHANNEL_H #define _EXICHANNEL_H @@ -93,7 +94,6 @@ private: IEXIDevice* m_pDevices[NUM_DEVICES]; public: - // channelId for debugging u32 m_ChannelId; diff --git a/Source/Core/DolphinWX/Src/BootManager.cpp b/Source/Core/DolphinWX/Src/BootManager.cpp index 3ea75aae0d..f5cdbc66d2 100644 --- a/Source/Core/DolphinWX/Src/BootManager.cpp +++ b/Source/Core/DolphinWX/Src/BootManager.cpp @@ -135,6 +135,7 @@ bool BootCore(const std::string& _rFilename) ini->Get("Core", "SkipIdle", &StartUp.bSkipIdle, StartUp.bSkipIdle); ini->Get("Core", "OptimizeQuantizers", &StartUp.bOptimizeQuantizers, StartUp.bOptimizeQuantizers); ini->Get("Core", "TLBHack", &StartUp.iTLBHack, StartUp.iTLBHack); + ini->Get("Core", "Fix002", &StartUp.bFix002, false); // ------------------------------------------------ // Wii settings