From 69645d421b4e570ac017b9380c49682f23ec03e6 Mon Sep 17 00:00:00 2001 From: LPFaint99 Date: Sat, 7 May 2011 03:48:27 +0000 Subject: [PATCH] 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 --- Source/Core/Common/Src/CommonPaths.h | 1 + Source/Core/Common/Src/FileUtil.cpp | 2 +- Source/Core/Common/Src/SysConf.cpp | 2 +- Source/Core/Core/Src/Boot/Boot_BS2Emu.cpp | 25 ++++++++----- Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE.cpp | 37 +++----------------- Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE.h | 2 -- 6 files changed, 25 insertions(+), 44 deletions(-) diff --git a/Source/Core/Common/Src/CommonPaths.h b/Source/Core/Common/Src/CommonPaths.h index 96ced5b7c6..6949250560 100644 --- a/Source/Core/Common/Src/CommonPaths.h +++ b/Source/Core/Common/Src/CommonPaths.h @@ -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" diff --git a/Source/Core/Common/Src/FileUtil.cpp b/Source/Core/Common/Src/FileUtil.cpp index bbfc03f2fa..2f061e789d 100644 --- a/Source/Core/Common/Src/FileUtil.cpp +++ b/Source/Core/Common/Src/FileUtil.cpp @@ -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; } diff --git a/Source/Core/Common/Src/SysConf.cpp b/Source/Core/Common/Src/SysConf.cpp index 9fd54174e4..3066013146 100644 --- a/Source/Core/Common/Src/SysConf.cpp +++ b/Source/Core/Common/Src/SysConf.cpp @@ -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); diff --git a/Source/Core/Core/Src/Boot/Boot_BS2Emu.cpp b/Source/Core/Core/Src/Boot/Boot_BS2Emu.cpp index 2ca8974e9c..19d4783ba9 100644 --- a/Source/Core/Core/Src/Boot/Boot_BS2Emu.cpp +++ b/Source/Core/Core/Src/Boot/Boot_BS2Emu.cpp @@ -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); } /* diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE.cpp b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE.cpp index fb5889f473..6937d102a6 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE.cpp +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE.cpp @@ -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; diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE.h b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE.h index cbef421f45..11420d1cdd 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE.h +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE.h @@ -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