diff --git a/Source/Core/Common/Src/SysConf.h b/Source/Core/Common/Src/SysConf.h index 84c21a3e51..a790dd137a 100644 --- a/Source/Core/Common/Src/SysConf.h +++ b/Source/Core/Common/Src/SysConf.h @@ -67,9 +67,9 @@ struct SSysConfEntry bool SetArrayData(u8* buffer, u16 bufferSize) { - if (buffer && bufferSize == dataLength) + if (buffer && bufferSize <= dataLength) { - memcpy(data, buffer, dataLength); + memcpy(data, buffer, bufferSize); return true; } return false; diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_es.cpp b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_es.cpp index 4ee8eb9291..fe4c1b97be 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_es.cpp +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_es.cpp @@ -515,9 +515,12 @@ bool CWII_IPC_HLE_Device_es::IOCtlV(u32 _CommandAddress) _dbg_assert_msg_(WII_IPC_ES, Buffer.NumberPayloadBuffer == 1, "IOCTL_ES_GETTMDVIEWCNT no out buffer"); u64 TitleID = Memory::Read_U64(Buffer.InBuffer[0].m_Address); + u32 TitleID_HI = (u32)(TitleID >> 32); const DiscIO::INANDContentLoader& Loader = DiscIO::CNANDContentManager::Access().GetNANDLoader(TitleID); - _dbg_assert_msg_(WII_IPC_ES, Loader.IsValid(), "Loader not valid for TitleID %08x/%08x", (u32)(TitleID >> 32), (u32)TitleID); + // Assert if title is not a disc title and the loader is not valid + _dbg_assert_msg_(WII_IPC_ES, (TitleID_HI == 0x00010000) || (TitleID_HI == 0x00010004) || Loader.IsValid(), "Loader not valid for TitleID %08x/%08x", TitleID_HI, (u32)TitleID); + u32 TMDViewCnt = 0; if (Loader.IsValid()) { @@ -528,10 +531,10 @@ bool CWII_IPC_HLE_Device_es::IOCtlV(u32 _CommandAddress) } Memory::Write_U32(TMDViewCnt, Buffer.PayloadBuffer[0].m_Address); - Memory::Write_U32(0, _CommandAddress + 0x4); + Memory::Write_U32(0, _CommandAddress + 0x4); INFO_LOG(WII_IPC_ES, "IOCTL_ES_GETTMDVIEWCNT: title: %08x/%08x (view size %i)", (u32)(TitleID >> 32), (u32)TitleID, TMDViewCnt); - return true; + return true; } break; diff --git a/Source/Core/DiscIO/Src/NANDContentLoader.cpp b/Source/Core/DiscIO/Src/NANDContentLoader.cpp index a4c0a7f4e8..1b77a2bfa3 100644 --- a/Source/Core/DiscIO/Src/NANDContentLoader.cpp +++ b/Source/Core/DiscIO/Src/NANDContentLoader.cpp @@ -219,7 +219,7 @@ bool CNANDContentLoader::CreateFromDirectory(const std::string& _rPath) m_IosVersion = Common::swap16(pTMD + 0x018a); m_Country = *(u8*)&m_TitleID; if (m_Country == 2) // SYSMENU - m_Country = DiscIO::GetSysMenuRegion(m_TileVersion); + m_Country = GetSysMenuRegion(m_TileVersion); m_Content.resize(m_numEntries); @@ -305,7 +305,7 @@ bool CNANDContentLoader::ParseTMD(u8* pDataApp, u32 pDataAppSize, u8* pTicket, u m_IosVersion = Common::swap16(pTMD + 0x018a); m_Country = *(u8*)&m_TitleID; if (m_Country == 2) // SYSMENU - m_Country = DiscIO::GetSysMenuRegion(m_TileVersion); + m_Country = GetSysMenuRegion(m_TileVersion); u8* p = pDataApp; diff --git a/Source/Core/DiscIO/Src/VolumeWad.cpp b/Source/Core/DiscIO/Src/VolumeWad.cpp index a0f424905e..5fd81cca8b 100644 --- a/Source/Core/DiscIO/Src/VolumeWad.cpp +++ b/Source/Core/DiscIO/Src/VolumeWad.cpp @@ -42,7 +42,7 @@ CVolumeWAD::CVolumeWAD(IBlobReader* _pReader) { u16 titlever = 0; Read(TmdOffset + 0x01dc, 2, (u8*)&titlever); - m_Country = DiscIO::GetSysMenuRegion(Common::swap16(titlever)); + m_Country = GetSysMenuRegion(Common::swap16(titlever)); } } diff --git a/Source/Core/DolphinWX/Src/ConfigMain.cpp b/Source/Core/DolphinWX/Src/ConfigMain.cpp index 31af886908..e2bad5bf47 100644 --- a/Source/Core/DolphinWX/Src/ConfigMain.cpp +++ b/Source/Core/DolphinWX/Src/ConfigMain.cpp @@ -1288,8 +1288,16 @@ void CConfigMain::WiiSettingsChanged(wxCommandEvent& event) SConfig::GetInstance().m_SYSCONF->SetData("IPL.AR", WiiAspectRatio->GetSelection()); break; case ID_WII_IPL_LNG: - SConfig::GetInstance().m_SYSCONF->SetData("IPL.LNG", WiiSystemLang->GetSelection()); + { + int wii_system_lang = WiiSystemLang->GetSelection(); + SConfig::GetInstance().m_SYSCONF->SetData("IPL.LNG", wii_system_lang); + u8 country_code = GetSADRCountryCode(wii_system_lang); + if(!SConfig::GetInstance().m_SYSCONF->SetArrayData("IPL.SADR", &country_code, 1)) + { + PanicAlert("Failed to update country code in SYSCONF"); + } break; + } // Wii - Devices case ID_WII_SD_CARD: SConfig::GetInstance().m_WiiSDCard = WiiSDCard->IsChecked(); @@ -1436,3 +1444,43 @@ void CConfigMain::AddResolutions() } #endif } + +// Change from IPL.LNG value to IPL.SADR country code +inline u8 CConfigMain::GetSADRCountryCode(int language) +{ + //http://wiibrew.org/wiki/Country_Codes + u8 countrycode = language; + switch (countrycode) + { + case 0: //Japanese + countrycode = 1; //Japan + break; + case 1: //English + countrycode = 49; // United States + break; + case 2: //German + countrycode = 78; //Germany + break; + case 3: //French + countrycode = 77; //France + break; + case 4: //Spanish + countrycode = 105; //Spain + break; + case 5: //Italian + countrycode = 83; //Italy + break; + case 6: //Dutch + countrycode = 94; //Netherlands + break; + case 7: //Simplified Chinese + case 8: //Traditional Chinese + countrycode = 157; //China + break; + case 9: //Korean + countrycode = 136; //Korea + break; + } + return countrycode; +} + diff --git a/Source/Core/DolphinWX/Src/ConfigMain.h b/Source/Core/DolphinWX/Src/ConfigMain.h index adbf89b819..0b67e9d591 100644 --- a/Source/Core/DolphinWX/Src/ConfigMain.h +++ b/Source/Core/DolphinWX/Src/ConfigMain.h @@ -292,6 +292,8 @@ private: void ChooseEXIDevice(std::string deviceName, int deviceNum); void WiiSettingsChanged(wxCommandEvent& event); + // Change from IPL.LNG value to country code + inline u8 GetSADRCountryCode(int language); void ISOPathsSelectionChanged(wxCommandEvent& event); void RecursiveDirectoryChanged(wxCommandEvent& event);