diff --git a/Data/Sys/codehandler.bin b/Data/Sys/codehandler.bin new file mode 100644 index 0000000000..7a95e724b1 Binary files /dev/null and b/Data/Sys/codehandler.bin differ diff --git a/Source/Core/Common/Src/CommonPaths.h b/Source/Core/Common/Src/CommonPaths.h index 150453928e..d319fb541e 100644 --- a/Source/Core/Common/Src/CommonPaths.h +++ b/Source/Core/Common/Src/CommonPaths.h @@ -126,7 +126,7 @@ #define WII_USA_SETTING "setting-usa.txt" #define WII_JAP_SETTING "setting-jpn.txt" -#define GECKO_CODE_HANDLER "kenobiwii.bin" +#define GECKO_CODE_HANDLER "codehandler.bin" // Subdirs in Sys #define GC_SYS_DIR "GC" diff --git a/Source/Core/Core/Src/GeckoCode.cpp b/Source/Core/Core/Src/GeckoCode.cpp index 2bbe101cee..c0b7af3779 100644 --- a/Source/Core/Core/Src/GeckoCode.cpp +++ b/Source/Core/Core/Src/GeckoCode.cpp @@ -118,6 +118,7 @@ void SetActiveCodes(const std::vector& gcodes) bool InstallCodeHandler() { + u32 codelist_location = 0x800028B8; // Debugger on location (0x800022A8 = Debugger off, using codehandleronly.bin) std::string data; std::string _rCodeHandlerFilename = File::GetSysDirectory() + GECKO_CODE_HANDLER; if (!File::ReadFileToString(false, _rCodeHandlerFilename.c_str(), data)) @@ -127,14 +128,14 @@ bool InstallCodeHandler() Memory::WriteBigEData((const u8*)data.data(), 0x80001800, data.length()); // Turn off Pause on start - Memory::Write_U32(0, 0x80001808); + Memory::Write_U32(0, 0x80002774); // Write the Game ID into the location expected by WiiRD Memory::WriteBigEData(Memory::GetPointer(0x80000000), 0x80001800, 6); // Create GCT in memory - Memory::Write_U32(0x00d0c0de, 0x800027d0); - Memory::Write_U32(0x00d0c0de, 0x800027d4); + Memory::Write_U32(0x00d0c0de, codelist_location); + Memory::Write_U32(0x00d0c0de, codelist_location + 4); std::lock_guard lk(active_codes_lock); @@ -151,15 +152,20 @@ bool InstallCodeHandler() for (; current_code < codes_end; ++current_code) { const GeckoCode::Code& code = *current_code; - Memory::Write_U32(code.address, 0x800027d8 + i); - Memory::Write_U32(code.data, 0x800027d8 + i + 4); - i += 8; + + // Make sure we have enough memory to hold the code list + if ((codelist_location + 24 + i) < 0x80003000) + { + Memory::Write_U32(code.address, codelist_location + 8 + i); + Memory::Write_U32(code.data, codelist_location + 12 + i); + i += 8; + } } } } - Memory::Write_U32(0xff000000, 0x800027d8 + i); - Memory::Write_U32(0x00000000, 0x800027d8 + i + 4); + Memory::Write_U32(0xff000000, codelist_location + 8 + i); + Memory::Write_U32(0x00000000, codelist_location + 12 + i); // Turn on codes Memory::Write_U8(1, 0x80001807); @@ -214,7 +220,7 @@ bool RunGeckoCode(GeckoCode& gecko_code) gecko_code.enabled = false; PanicAlertT("GeckoCode failed to run (CT%i CST%i) (%s)" - "\n(either a bad code or the code type is not yet supported. Try using the native code handler by placing the kenobiwii.bin file into the Sys directory and restarting Dolphin.)" + "\n(either a bad code or the code type is not yet supported. Try using the native code handler by placing the codehandler.bin file into the Sys directory and restarting Dolphin.)" , code.type, code.subtype, gecko_code.name.c_str()); return false; }