Add a mode to use a dummy Wii NAND.

Eventually, netplay will be able to use the host's NAND, but this could
still be useful in some cases; for TAS it definitely makes sense to have
a way to avoid using any preexisting NAND.

In terms of implementation: remove D_WIIUSER_IDX, which was just WIIROOT
+ "/", as well as some other indices which are pointless to have as
separate variables rather than just using the actual path (fixed, since
they're actual Wii NAND paths) at the call site.  Then split off
D_SESSION_WIIROOT_IDX, which can point to the dummy NAND directory, from
D_WIIROOT_IDX, which always points to the "real" one the user
configured.
This commit is contained in:
comex
2014-11-17 20:59:14 -05:00
parent f6c6822f71
commit dc91e8b607
23 changed files with 127 additions and 59 deletions

View File

@ -475,8 +475,6 @@ void SConfig::LoadGeneralSettings(IniFile& ini)
general->Get("NANDRootPath", &m_NANDPath);
File::SetUserPath(D_WIIROOT_IDX, m_NANDPath);
DiscIO::cUIDsys::AccessInstance().UpdateLocation();
DiscIO::CSharedContent::AccessInstance().UpdateLocation();
general->Get("WirelessMac", &m_WirelessMac);
}

View File

@ -832,6 +832,7 @@ void UpdateWantDeterminism(bool initial)
g_video_backend->UpdateWantDeterminism(new_want_determinism);
// We need to clear the cache because some parts of the JIT depend on want_determinism, e.g. use of FMA.
JitInterface::ClearCache();
Common::InitializeWiiRoot(g_want_determinism);
Core::PauseAndLock(false, was_unpaused);
}

View File

@ -4,6 +4,7 @@
#include "Common/ChunkFile.h"
#include "Common/CommonTypes.h"
#include "Common/NandPaths.h"
#include "Core/ConfigManager.h"
#include "Core/Core.h"
@ -25,6 +26,7 @@
#include "Core/IPC_HLE/WII_IPC_HLE.h"
#include "Core/PowerPC/PowerPC.h"
#include "Core/PowerPC/PPCAnalyst.h"
#include "DiscIO/NANDContentLoader.h"
namespace HW
{
@ -50,6 +52,9 @@ namespace HW
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bWii)
{
Common::InitializeWiiRoot(Core::g_want_determinism);
DiscIO::cUIDsys::AccessInstance().UpdateLocation();
DiscIO::CSharedContent::AccessInstance().UpdateLocation();
WII_IPCInterface::Init();
WII_IPC_HLE_Interface::Init();
}
@ -70,6 +75,7 @@ namespace HW
{
WII_IPCInterface::Shutdown();
WII_IPC_HLE_Interface::Shutdown();
Common::ShutdownWiiRoot();
}
State::Shutdown();

View File

@ -62,7 +62,7 @@ bool CWiiSaveCrypted::ExportWiiSave(u64 title_id)
void CWiiSaveCrypted::ExportAllSaves()
{
std::string title_folder = File::GetUserPath(D_WIIUSER_IDX) + "title";
std::string title_folder = File::GetUserPath(D_WIIROOT_IDX) + "/title";
std::vector<u64> titles;
const u32 path_mask = 0x00010000;
for (int i = 0; i < 8; ++i)

View File

@ -22,6 +22,7 @@
#include "Common/CommonTypes.h"
#include "Common/FileUtil.h"
#include "Common/NandPaths.h"
#include "Core/HW/WiimoteEmu/WiimoteEmu.h"
#include "Core/HW/WiimoteEmu/WiimoteHid.h"
@ -275,7 +276,7 @@ void Wiimote::WriteData(const wm_write_data* const wd)
{
// writing the whole mii block each write :/
std::ofstream file;
OpenFStream(file, File::GetUserPath(D_WIIUSER_IDX) + "mii.bin", std::ios::binary | std::ios::out);
OpenFStream(file, File::GetUserPath(D_SESSION_WIIROOT_IDX) + "/mii.bin", std::ios::binary | std::ios::out);
file.write((char*)m_eeprom + 0x0FCA, 0x02f0);
file.close();
}
@ -417,7 +418,7 @@ void Wiimote::ReadData(const wm_read_data* const rd)
{
// reading the whole mii block :/
std::ifstream file;
file.open((File::GetUserPath(D_WIIUSER_IDX) + "mii.bin").c_str(), std::ios::binary | std::ios::in);
file.open((File::GetUserPath(D_SESSION_WIIROOT_IDX) + "/mii.bin").c_str(), std::ios::binary | std::ios::in);
file.read((char*)m_eeprom + 0x0FCA, 0x02f0);
file.close();
}

View File

@ -5,11 +5,14 @@
#include <algorithm>
#include "Common/ChunkFile.h"
#include "Common/CommonPaths.h"
#include "Common/CommonTypes.h"
#include "Common/FileUtil.h"
#include "Common/NandPaths.h"
#include "Common/StringUtil.h"
#include "Core/Core.h"
#include "Core/IPC_HLE/WII_IPC_HLE.h"
#include "Core/IPC_HLE/WII_IPC_HLE_Device_FileIO.h"
#include "Core/IPC_HLE/WII_IPC_HLE_Device_fs.h"
@ -19,7 +22,7 @@ static Common::replace_v replacements;
// This is used by several of the FileIO and /dev/fs functions
std::string HLE_IPC_BuildFilename(std::string path_wii)
{
std::string path_full = File::GetUserPath(D_WIIROOT_IDX);
std::string path_full = File::GetUserPath(D_SESSION_WIIROOT_IDX);
// Replaces chars that FAT32 can't support with strings defined in /sys/replace
for (auto& replacement : replacements)

View File

@ -32,7 +32,7 @@ IPCCommandResult CWII_IPC_HLE_Device_fs::Open(u32 _CommandAddress, u32 _Mode)
{
// clear tmp folder
{
std::string Path = File::GetUserPath(D_WIIUSER_IDX) + "tmp";
std::string Path = HLE_IPC_BuildFilename("/tmp");
File::DeleteDirRecursively(Path);
File::CreateDir(Path);
}
@ -221,7 +221,6 @@ IPCCommandResult CWII_IPC_HLE_Device_fs::IOCtlV(u32 _CommandAddress)
IPCCommandResult CWII_IPC_HLE_Device_fs::IOCtl(u32 _CommandAddress)
{
//u32 DeviceID = Memory::Read_U32(_CommandAddress + 8);
//LOG(WII_IPC_FILEIO, "FS: IOCtl (Device=%s, DeviceID=%08x)", GetDeviceName().c_str(), DeviceID);
u32 Parameter = Memory::Read_U32(_CommandAddress + 0xC);
u32 BufferIn = Memory::Read_U32(_CommandAddress + 0x10);
@ -483,7 +482,7 @@ void CWII_IPC_HLE_Device_fs::DoState(PointerWrap& p)
// handle /tmp
std::string Path = File::GetUserPath(D_WIIUSER_IDX) + "tmp";
std::string Path = File::GetUserPath(D_SESSION_WIIROOT_IDX) + "/tmp";
if (p.GetMode() == PointerWrap::MODE_READ)
{
File::DeleteDirRecursively(Path);

View File

@ -4,7 +4,9 @@
#pragma once
#include "Common/CommonPaths.h"
#include "Common/FileUtil.h"
#include "Common/NandPaths.h"
#include "Common/Timer.h"
#include "Core/HW/EXI_DeviceIPL.h"
@ -172,7 +174,7 @@ private:
public:
NWC24Config()
{
path = File::GetUserPath(D_WIIWC24_IDX) + "nwc24msg.cfg";
path = File::GetUserPath(D_SESSION_WIIROOT_IDX) + "/" WII_WC24CONF_DIR "/nwc24msg.cfg";
ReadConfig();
}
@ -211,7 +213,7 @@ public:
{
if (!File::Exists(path))
{
if (!File::CreateFullPath(File::GetUserPath(D_WIIWC24_IDX)))
if (!File::CreateFullPath(File::GetUserPath(D_SESSION_WIIROOT_IDX) + "/" WII_WC24CONF_DIR))
{
ERROR_LOG(WII_IPC_WC24, "Failed to create directory for WC24");
}
@ -322,7 +324,7 @@ class WiiNetConfig
public:
WiiNetConfig()
{
path = File::GetUserPath(D_WIISYSCONF_IDX) + "net/02/config.dat";
path = File::GetUserPath(D_SESSION_WIIROOT_IDX) + "/" WII_SYSCONF_DIR "/net/02/config.dat";
ReadConfig();
}
@ -347,7 +349,7 @@ public:
{
if (!File::Exists(path))
{
if (!File::CreateFullPath(std::string(File::GetUserPath(D_WIISYSCONF_IDX) + "net/02/")))
if (!File::CreateFullPath(std::string(File::GetUserPath(D_SESSION_WIIROOT_IDX) + "/" WII_SYSCONF_DIR "/net/02/")))
{
ERROR_LOG(WII_IPC_NET, "Failed to create directory for network config file");
}

View File

@ -5,6 +5,7 @@
#include <algorithm>
#include "Common/FileUtil.h"
#include "Common/NandPaths.h"
#include "Core/Core.h"
#include "Core/IPC_HLE/WII_IPC_HLE_Device_net_ssl.h"
#include "Core/IPC_HLE/WII_Socket.h"
@ -286,7 +287,7 @@ _SSL_NEW_ERROR:
if (SSLID_VALID(sslID))
{
WII_SSL* ssl = &_SSL[sslID];
std::string cert_base_path(File::GetUserPath(D_WIIUSER_IDX));
std::string cert_base_path = File::GetUserPath(D_SESSION_WIIROOT_IDX);
int ret = x509_crt_parse_file(&ssl->clicert, (cert_base_path + "clientca.pem").c_str());
int pk_ret = pk_parse_keyfile(&ssl->pk, (cert_base_path + "clientcakey.pem").c_str(), nullptr);
if (ret || pk_ret)
@ -343,9 +344,8 @@ _SSL_NEW_ERROR:
if (SSLID_VALID(sslID))
{
WII_SSL* ssl = &_SSL[sslID];
std::string cert_base_path(File::GetUserPath(D_WIIUSER_IDX));
int ret = x509_crt_parse_file(&ssl->cacert, (cert_base_path + "rootca.pem").c_str());
int ret = x509_crt_parse_file(&ssl->cacert, (File::GetUserPath(D_SESSION_WIIROOT_IDX) + "/rootca.pem").c_str());
if (ret)
{
x509_crt_free(&ssl->clicert);

View File

@ -61,7 +61,7 @@ void CWII_IPC_HLE_Device_sdio_slot0::EventNotify()
void CWII_IPC_HLE_Device_sdio_slot0::OpenInternal()
{
const std::string filename = File::GetUserPath(D_WIIUSER_IDX) + "sd.raw";
const std::string filename = File::GetUserPath(D_WIIROOT_IDX) + "/sd.raw";
m_Card.Open(filename, "r+b");
if (!m_Card)
{

View File

@ -119,7 +119,7 @@ void make_blanksig_ec_cert(u8 *cert_out, const char *signer, const char *name, c
EcWii::EcWii()
{
bool init = true;
std::string keys_path = File::GetUserPath(D_WIIUSER_IDX) + "keys.bin";
std::string keys_path = File::GetUserPath(D_WIIROOT_IDX) + "/keys.bin";
if (File::Exists(keys_path))
{
File::IOFile keys_f(keys_path, "rb");