Move the HLE hack of setting.txt file redirection to the BS2Emu

we already copy the file to memory here, now we also copy the file to 
1/2/data/
 This should really fix issue 4287.
Thanks to hosigumayuugi for finding the exact cause of the issue

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7521 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
LPFaint99 2011-05-07 03:48:27 +00:00
parent 9222a818ae
commit 69645d421b
6 changed files with 25 additions and 44 deletions

View File

@ -121,6 +121,7 @@
#define GC_MEMCARDA "MemoryCardA"
#define GC_MEMCARDB "MemoryCardB"
#define WII_SETTING. "setting.txt"
#define WII_EUR_SETTING "setting-eur.txt"
#define WII_USA_SETTING "setting-usa.txt"
#define WII_JAP_SETTING "setting-jpn.txt"

View File

@ -121,7 +121,7 @@ bool Delete(const std::string &filename)
// We can't delete a directory
if (IsDirectory(filename))
{
WARN_LOG(COMMON, "Delete: %s is a directory", filename.c_str());
WARN_LOG(COMMON, "Delete failed: %s is a directory", filename.c_str());
return false;
}

View File

@ -235,7 +235,7 @@ void SysConf::GenerateSysConf()
// IPL.SADR
current_offset += create_item(items[7], Type_BigArray, "IPL.SADR", 0x1007, current_offset);
items[7].data[0] = 0x6c;
items[7].data[0] = 0x6c; //(Switzerland) TODO should this default be changed?
// IPL.CB
current_offset += create_item(items[8], Type_Long, "IPL.CB", 4, current_offset);

View File

@ -18,6 +18,7 @@
#include "Common.h"
#include "CommonPaths.h"
#include "FileUtil.h"
#include "NandPaths.h"
#include "../PowerPC/PowerPC.h"
#include "../Core.h"
@ -181,39 +182,47 @@ bool CBoot::SetupWiiMemory(unsigned int _CountryCode)
// \title\00000001\00000002\data\setting.txt directly after the read the
// SYSCONF file. The games also read it to 0x3800, what is a little strange
// however is that it only reads the first 100 bytes of it.
std::string filename(File::GetSysDirectory() + WII_SYS_DIR + DIR_SEP + WII_EUR_SETTING);
std::string region_filename,
settings_Filename(Common::CreateTitleDataPath(TITLEID_SYSMENU)+ DIR_SEP + WII_SETTING);
switch((DiscIO::IVolume::ECountry)_CountryCode)
{
case DiscIO::IVolume::COUNTRY_KOREA:
case DiscIO::IVolume::COUNTRY_TAIWAN:
// TODO: Determine if Korea / Taiwan have their own specific settings.
case DiscIO::IVolume::COUNTRY_JAPAN:
filename = File::GetSysDirectory() + WII_SYS_DIR + DIR_SEP + WII_JAP_SETTING;
region_filename = File::GetSysDirectory() + WII_SYS_DIR + DIR_SEP + WII_JAP_SETTING;
break;
case DiscIO::IVolume::COUNTRY_USA:
filename = File::GetSysDirectory() + WII_SYS_DIR + DIR_SEP + WII_USA_SETTING;
region_filename = File::GetSysDirectory() + WII_SYS_DIR + DIR_SEP + WII_USA_SETTING;
break;
case DiscIO::IVolume::COUNTRY_EUROPE:
filename = File::GetSysDirectory() + WII_SYS_DIR + DIR_SEP + WII_EUR_SETTING;
region_filename = File::GetSysDirectory() + WII_SYS_DIR + DIR_SEP + WII_EUR_SETTING;
break;
default:
// PanicAlertT("SetupWiiMem: Unknown country. Wii boot process will be switched to European settings.");
filename = File::GetSysDirectory() + WII_SYS_DIR + DIR_SEP + WII_EUR_SETTING;
region_filename = File::GetSysDirectory() + WII_SYS_DIR + DIR_SEP + WII_EUR_SETTING;
break;
}
{
File::IOFile pTmp(filename, "rb");
if (!pTmp)
if (File::Exists(settings_Filename))
{
File::Delete(settings_Filename);
}
File::CreateFullPath(settings_Filename);
File::Copy(region_filename, settings_Filename);
File::IOFile settingsFile(settings_Filename, "rb");
if (!settingsFile)
{
PanicAlertT("SetupWiiMem: Cant find setting file");
return false;
}
pTmp.ReadBytes(Memory::GetPointer(0x3800), 256);
settingsFile.ReadBytes(Memory::GetPointer(0x3800), 256);
}
/*

View File

@ -200,32 +200,6 @@ IWII_IPC_HLE_Device* CreateFileIO(u32 _DeviceID, const std::string& _rDeviceName
return pDevice;
}
// Try to make sure the game is always reading the setting.txt file we provide
void CopySettingsFile(std::string& DeviceName)
{
std::string Source = File::GetSysDirectory() + WII_SYS_DIR + DIR_SEP;
if(SConfig::GetInstance().m_LocalCoreStartupParameter.bNTSC)
Source += "setting-usa.txt";
else
Source += "setting-eur.txt";
std::string Target = File::GetUserPath(D_WIIUSER_IDX) + DeviceName;
// Check if the target dir exists, otherwise create it
std::string TargetDir = Target.substr(0, Target.find_last_of(DIR_SEP));
if (!File::IsDirectory(TargetDir))
File::CreateFullPath(Target);
if (File::Copy(Source, Target))
{
INFO_LOG(WII_IPC_FILEIO, "FS: Copied %s to %s", Source.c_str(), Target.c_str());
}
else
{
ERROR_LOG(WII_IPC_FILEIO, "Could not copy %s to %s", Source.c_str(), Target.c_str());
PanicAlertT("Could not copy %s to %s", Source.c_str(), Target.c_str());
}
}
void DoState(PointerWrap &p)
{
@ -292,10 +266,6 @@ void ExecuteCommand(u32 _Address)
std::string DeviceName;
Memory::GetString(DeviceName, Memory::Read_U32(_Address + 0xC));
// The game may try to read setting.txt here, in that case copy it so it can read it
if (DeviceName.find("setting.txt") != std::string::npos)
CopySettingsFile(DeviceName);
u32 Mode = Memory::Read_U32(_Address + 0x10);
DeviceID = GetDeviceIDByName(DeviceName);
@ -330,8 +300,11 @@ void ExecuteCommand(u32 _Address)
pDevice = AccessDeviceByID(DeviceID);
CmdSuccess = pDevice->Open(_Address, Mode);
INFO_LOG(WII_IPC_FILEIO, "IOP: ReOpen (Device=%s, DeviceID=%08x, Mode=%i)",
pDevice->GetDeviceName().c_str(), DeviceID, Mode);
if(strcmp(pDevice->GetDeviceName().c_str(), "/dev/net/kd/request"))
{
INFO_LOG(WII_IPC_FILEIO, "IOP: ReOpen (Device=%s, DeviceID=%08x, Mode=%i)",
pDevice->GetDeviceName().c_str(), DeviceID, Mode);
}
}
}
break;

View File

@ -52,8 +52,6 @@ IWII_IPC_HLE_Device* AccessDeviceByID(u32 _ID);
void DeleteDeviceByID(u32 _ID);
void CopySettingsFile(std::string& DeviceName);
IWII_IPC_HLE_Device* CreateFileIO(u32 _DeviceID, const std::string& _rDeviceName);
// Update