mirror of https://github.com/PCSX2/pcsx2.git
DEV9: Apply settings if configuration was performed during emulation
This commit is contained in:
parent
0800cdbbc2
commit
81fd8e011f
|
@ -97,6 +97,8 @@ int mapping;
|
|||
std::string s_strIniPath = "inis";
|
||||
std::string s_strLogPath = "logs";
|
||||
|
||||
bool isRunning = false;
|
||||
|
||||
s32 DEV9init()
|
||||
{
|
||||
DevCon.WriteLn("DEV9init");
|
||||
|
@ -222,6 +224,7 @@ s32 DEV9open(void* pDsp)
|
|||
if (config.ethEnable)
|
||||
InitNet();
|
||||
|
||||
isRunning = true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -231,6 +234,7 @@ void DEV9close()
|
|||
|
||||
dev9.ata->Close();
|
||||
TermNet();
|
||||
isRunning = false;
|
||||
}
|
||||
|
||||
int DEV9irqHandler(void)
|
||||
|
@ -1079,3 +1083,74 @@ void DEV9setLogDir(const char* dir)
|
|||
// Get the path to the log directory.
|
||||
s_strLogPath = (dir == NULL) ? "logs" : dir;
|
||||
}
|
||||
|
||||
void ApplyConfigIfRunning(Config oldConfig)
|
||||
{
|
||||
if (!isRunning)
|
||||
return;
|
||||
|
||||
//Eth
|
||||
if (config.ethEnable)
|
||||
{
|
||||
if (oldConfig.ethEnable)
|
||||
{
|
||||
//Reload Net if adapter changed
|
||||
if (strcmp(oldConfig.Eth, config.Eth) != 0)
|
||||
{
|
||||
TermNet();
|
||||
InitNet();
|
||||
}
|
||||
}
|
||||
else
|
||||
InitNet();
|
||||
}
|
||||
else if (oldConfig.ethEnable)
|
||||
TermNet();
|
||||
|
||||
//Hdd
|
||||
//Hdd Validate Path
|
||||
#ifdef _WIN32
|
||||
ghc::filesystem::path hddPath(std::wstring(config.Hdd));
|
||||
#else
|
||||
ghc::filesystem::path hddPath(config.Hdd);
|
||||
#endif
|
||||
|
||||
if (hddPath.empty())
|
||||
config.hddEnable = false;
|
||||
|
||||
if (hddPath.is_relative())
|
||||
{
|
||||
//GHC uses UTF8 on all platforms
|
||||
ghc::filesystem::path path(GetSettingsFolder().ToUTF8().data());
|
||||
hddPath = path / hddPath;
|
||||
}
|
||||
|
||||
//Hdd Compare with old config
|
||||
if (config.hddEnable)
|
||||
{
|
||||
if (oldConfig.hddEnable)
|
||||
{
|
||||
//ATA::Open/Close dosn't set any regs
|
||||
//So we can close/open to apply settings
|
||||
#ifdef _WIN32
|
||||
if (wcscmp(config.Hdd, oldConfig.Hdd))
|
||||
#else
|
||||
if (strcmp(config.Hdd, oldConfig.Hdd))
|
||||
#endif
|
||||
{
|
||||
dev9.ata->Close();
|
||||
if (dev9.ata->Open(hddPath) != 0)
|
||||
config.hddEnable = false;
|
||||
}
|
||||
|
||||
if (config.HddSize != oldConfig.HddSize)
|
||||
{
|
||||
dev9.ata->Close();
|
||||
if (dev9.ata->Open(hddPath) != 0)
|
||||
config.hddEnable = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (oldConfig.hddEnable)
|
||||
dev9.ata->Close();
|
||||
}
|
||||
|
|
|
@ -723,6 +723,7 @@ u32 DEV9read32(u32 addr);
|
|||
void DEV9write8(u32 addr, u8 value);
|
||||
void DEV9write16(u32 addr, u16 value);
|
||||
void DEV9write32(u32 addr, u32 value);
|
||||
void ApplyConfigIfRunning(Config oldConfig);
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma warning(error : 4013)
|
||||
|
|
|
@ -186,6 +186,8 @@ void OnOk()
|
|||
void DEV9configure()
|
||||
{
|
||||
ScopedCoreThreadPause paused_core;
|
||||
Config oldConfig = config;
|
||||
|
||||
gtk_init(NULL, NULL);
|
||||
GError* error = NULL;
|
||||
if (builder == nullptr)
|
||||
|
@ -217,5 +219,8 @@ void DEV9configure()
|
|||
break;
|
||||
}
|
||||
gtk_widget_hide(GTK_WIDGET(dlg));
|
||||
|
||||
ApplyConfigIfRunning(oldConfig);
|
||||
|
||||
paused_core.AllowResume();
|
||||
}
|
||||
|
|
|
@ -358,11 +358,16 @@ BOOL CALLBACK ConfigureDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
|||
void DEV9configure()
|
||||
{
|
||||
ScopedCoreThreadPause paused_core;
|
||||
Config oldConfig = config;
|
||||
|
||||
DialogBox(hInst,
|
||||
MAKEINTRESOURCE(IDD_CONFIG),
|
||||
GetActiveWindow(),
|
||||
(DLGPROC)ConfigureDlgProc);
|
||||
//SysMessage("Nothing to Configure");
|
||||
|
||||
ApplyConfigIfRunning(oldConfig);
|
||||
|
||||
paused_core.AllowResume();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue