Update the country code in SysConf when wii system language is changed.

remove annoying assert for invalid loaders on disc titles.
Fixes issue 4287.


git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7514 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
LPFaint99 2011-05-05 22:38:07 +00:00
parent ff63ef20c2
commit c88126233b
6 changed files with 62 additions and 9 deletions

View File

@ -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;

View File

@ -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())
{

View File

@ -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;

View File

@ -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));
}
}

View File

@ -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;
}

View File

@ -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);