Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Back up Wii setting.txt and SYSCONF while emulating #8672

Merged
merged 2 commits into from Mar 16, 2020

Conversation

JosJuice
Copy link
Member

When booting a Wii game, Dolphin can overwrite certain settings in the SYSCONF file, such as turning off PAL60 for NTSC games. Normally, these settings get reverted at the end of emulation, but this does not happen if Dolphin crashes or force quits in some other way. (Personally, I have a tendency to use Visual Studio's Stop Debugging button, which kills the process...)

Dolphin also overwrites certain values in setting.txt when booting a Wii game. Unlike with SYSCONF, we currently make no effort to preserve the original values in this file.

This change fixes both of these problems by copying SYSCONF and setting.txt to the Backup folder when booting a Wii game, and then copying them back either when launching Dolphin (in case the previous run of Dolphin crashed) or when ending emulation.

@leoetlino
Copy link
Member

Won't this cause setting changes that are done during emulation (e.g. updating the Wii remote speaker volume with the HOME menu, or changing console settings in the System Menu) to be always reverted?

@JosJuice
Copy link
Member Author

Yes, you're right. I didn't think of that being a valid way to change settings. I will make it so that the SYSCONF backup gets deleted instead of restored at emulation end.

@leoetlino
Copy link
Member

I wonder whether it'd be possible to improve the existing SYSCONF restore logic, so that it also works if Dolphin was closed ungracefully:

// SYSCONF can be modified during emulation by the user and internally, which makes it
// a bad idea to just always overwrite it with the settings from the base layer.
//
// Conversely, we also shouldn't just accept any changes to SYSCONF, as it may cause
// temporary settings (from Movie, Netplay, game INIs, etc.) to stick around.
//
// To avoid inconveniences in most cases, we accept changes that aren't being overriden by a
// non-base layer, and restore only the overriden settings.
static void RestoreSYSCONF()
{
// This layer contains the new SYSCONF settings (including any temporary settings).
Config::Layer temp_layer(Config::LayerType::Base);
// Use a separate loader so the temp layer doesn't automatically save
ConfigLoaders::GenerateBaseConfigLoader()->Load(&temp_layer);
for (const auto& setting : Config::SYSCONF_SETTINGS)
{
std::visit(
[&](auto& info) {
// If this setting was overridden, then we copy the base layer value back to the SYSCONF.
// Otherwise we leave the new value in the SYSCONF.
if (Config::GetActiveLayerForConfig(info) == Config::LayerType::Base)
Config::SetBase(info, temp_layer.Get(info));
},
setting.config_info);
}
// Save the SYSCONF.
Config::GetLayer(Config::LayerType::Base)->Save();
}

@JosJuice
Copy link
Member Author

That would require us to save the list of overridden settings to disk in some way, right? But in exchange, we wouldn't have to save an extra copy of the SYSCONF file itself like I do in this PR.

@leoetlino
Copy link
Member

Yeah, and one benefit is that changes won't be lost even if Dolphin crashes. (Right now, I believe that changes will still be lost if Dolphin crashes, since the entire SYSCONF is restored.) But it's more complex and I don't know if it's worth handling that (somewhat) rare situation.

@JosJuice
Copy link
Member Author

Yes, I agree with all of those points.

Source/Core/Core/WiiRoot.cpp Show resolved Hide resolved
Source/Core/Core/WiiRoot.cpp Outdated Show resolved Hide resolved
When booting a Wii game, Dolphin can overwrite certain settings
in the SYSCONF file, such as turning off PAL60 for NTSC games.
Normally, these settings get reverted at the end of emulation, but
this does not happen if Dolphin crashes or force quits in some other
way. (Personally, I have a tendency to use Visual Studio's Stop
Debugging button, which kills the process...)

Dolphin also overwrites certain values in setting.txt when booting
a Wii game. Unlike with SYSCONF, we currently make no effort to
preserve the original values in this file.

This change fixes both of these problems by copying SYSCONF and
setting.txt to the Backup folder when booting a Wii game, and then
copying them back either when launching Dolphin (in case the
previous run of Dolphin crashed) or when ending emulation.
@leoetlino leoetlino merged commit 0461170 into dolphin-emu:master Mar 16, 2020
@JosJuice JosJuice deleted the wii-setting-backup branch March 16, 2020 21:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants