mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-23 06:15:38 +00:00
GameSettings: Add CPU overclocking as game option
This commit is contained in:
parent
44c85a2c24
commit
9a23c5547a
|
@ -98,6 +98,11 @@ u32 Settings::GetCPUOverclockPercent() const
|
||||||
return CPUOverclockFractionToPercent(cpu_overclock_numerator, cpu_overclock_denominator);
|
return CPUOverclockFractionToPercent(cpu_overclock_numerator, cpu_overclock_denominator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Settings::UpdateOverclockActive()
|
||||||
|
{
|
||||||
|
cpu_overclock_active = (cpu_overclock_enable && (cpu_overclock_numerator != 1 || cpu_overclock_denominator != 1));
|
||||||
|
}
|
||||||
|
|
||||||
void Settings::Load(SettingsInterface& si)
|
void Settings::Load(SettingsInterface& si)
|
||||||
{
|
{
|
||||||
region =
|
region =
|
||||||
|
@ -121,7 +126,7 @@ void Settings::Load(SettingsInterface& si)
|
||||||
cpu_overclock_numerator = std::max(si.GetIntValue("CPU", "OverclockNumerator", 1), 1);
|
cpu_overclock_numerator = std::max(si.GetIntValue("CPU", "OverclockNumerator", 1), 1);
|
||||||
cpu_overclock_denominator = std::max(si.GetIntValue("CPU", "OverclockDenominator", 1), 1);
|
cpu_overclock_denominator = std::max(si.GetIntValue("CPU", "OverclockDenominator", 1), 1);
|
||||||
cpu_overclock_enable = si.GetBoolValue("CPU", "OverclockEnable", false);
|
cpu_overclock_enable = si.GetBoolValue("CPU", "OverclockEnable", false);
|
||||||
cpu_overclock_active = (cpu_overclock_enable && (cpu_overclock_numerator != 1 || cpu_overclock_denominator != 1));
|
UpdateOverclockActive();
|
||||||
cpu_recompiler_memory_exceptions = si.GetBoolValue("CPU", "RecompilerMemoryExceptions", false);
|
cpu_recompiler_memory_exceptions = si.GetBoolValue("CPU", "RecompilerMemoryExceptions", false);
|
||||||
cpu_recompiler_icache = si.GetBoolValue("CPU", "RecompilerICache", false);
|
cpu_recompiler_icache = si.GetBoolValue("CPU", "RecompilerICache", false);
|
||||||
|
|
||||||
|
|
|
@ -183,6 +183,7 @@ struct Settings
|
||||||
|
|
||||||
void SetCPUOverclockPercent(u32 percent);
|
void SetCPUOverclockPercent(u32 percent);
|
||||||
u32 GetCPUOverclockPercent() const;
|
u32 GetCPUOverclockPercent() const;
|
||||||
|
void UpdateOverclockActive();
|
||||||
|
|
||||||
enum : u32
|
enum : u32
|
||||||
{
|
{
|
||||||
|
|
|
@ -114,7 +114,7 @@ private:
|
||||||
enum : u32
|
enum : u32
|
||||||
{
|
{
|
||||||
GAME_LIST_CACHE_SIGNATURE = 0x45434C47,
|
GAME_LIST_CACHE_SIGNATURE = 0x45434C47,
|
||||||
GAME_LIST_CACHE_VERSION = 10
|
GAME_LIST_CACHE_VERSION = 11
|
||||||
};
|
};
|
||||||
|
|
||||||
using DatabaseMap = std::unordered_map<std::string, GameListDatabaseEntry>;
|
using DatabaseMap = std::unordered_map<std::string, GameListDatabaseEntry>;
|
||||||
|
|
|
@ -104,7 +104,10 @@ bool Entry::LoadFromStream(ByteStream* stream)
|
||||||
constexpr u32 num_bytes = (static_cast<u32>(Trait::Count) + 7) / 8;
|
constexpr u32 num_bytes = (static_cast<u32>(Trait::Count) + 7) / 8;
|
||||||
std::array<u8, num_bytes> bits;
|
std::array<u8, num_bytes> bits;
|
||||||
|
|
||||||
if (!stream->Read2(bits.data(), num_bytes) || !ReadOptionalFromStream(stream, &display_active_start_offset) ||
|
if (!stream->Read2(bits.data(), num_bytes) || !ReadOptionalFromStream(stream, &cpu_overclock_numerator) ||
|
||||||
|
!ReadOptionalFromStream(stream, &cpu_overclock_denominator) ||
|
||||||
|
!ReadOptionalFromStream(stream, &cpu_overclock_enable) ||
|
||||||
|
!ReadOptionalFromStream(stream, &display_active_start_offset) ||
|
||||||
!ReadOptionalFromStream(stream, &display_active_end_offset) ||
|
!ReadOptionalFromStream(stream, &display_active_end_offset) ||
|
||||||
!ReadOptionalFromStream(stream, &display_crop_mode) || !ReadOptionalFromStream(stream, &display_aspect_ratio) ||
|
!ReadOptionalFromStream(stream, &display_crop_mode) || !ReadOptionalFromStream(stream, &display_aspect_ratio) ||
|
||||||
!ReadOptionalFromStream(stream, &display_linear_upscaling) ||
|
!ReadOptionalFromStream(stream, &display_linear_upscaling) ||
|
||||||
|
@ -144,7 +147,10 @@ bool Entry::SaveToStream(ByteStream* stream) const
|
||||||
bits[i / 8] |= (1u << (i % 8));
|
bits[i / 8] |= (1u << (i % 8));
|
||||||
}
|
}
|
||||||
|
|
||||||
return stream->Write2(bits.data(), num_bytes) && WriteOptionalToStream(stream, display_active_start_offset) &&
|
return stream->Write2(bits.data(), num_bytes) && WriteOptionalToStream(stream, cpu_overclock_numerator) &&
|
||||||
|
WriteOptionalToStream(stream, cpu_overclock_denominator) &&
|
||||||
|
WriteOptionalToStream(stream, cpu_overclock_enable) &&
|
||||||
|
WriteOptionalToStream(stream, display_active_start_offset) &&
|
||||||
WriteOptionalToStream(stream, display_active_end_offset) && WriteOptionalToStream(stream, display_crop_mode) &&
|
WriteOptionalToStream(stream, display_active_end_offset) && WriteOptionalToStream(stream, display_crop_mode) &&
|
||||||
WriteOptionalToStream(stream, display_aspect_ratio) &&
|
WriteOptionalToStream(stream, display_aspect_ratio) &&
|
||||||
WriteOptionalToStream(stream, display_linear_upscaling) &&
|
WriteOptionalToStream(stream, display_linear_upscaling) &&
|
||||||
|
@ -167,6 +173,16 @@ static void ParseIniSection(Entry* entry, const char* section, const CSimpleIniA
|
||||||
entry->AddTrait(static_cast<Trait>(trait));
|
entry->AddTrait(static_cast<Trait>(trait));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char* cvalue = ini.GetValue(section, "CPUOverclockNumerator", nullptr);
|
||||||
|
if (cvalue)
|
||||||
|
entry->cpu_overclock_numerator = StringUtil::FromChars<u32>(cvalue);
|
||||||
|
cvalue = ini.GetValue(section, "CPUOverclockDenominator", nullptr);
|
||||||
|
if (cvalue)
|
||||||
|
entry->cpu_overclock_denominator = StringUtil::FromChars<u32>(cvalue);
|
||||||
|
cvalue = ini.GetValue(section, "CPUOverclockEnable", nullptr);
|
||||||
|
if (cvalue)
|
||||||
|
entry->cpu_overclock_enable = StringUtil::FromChars<bool>(cvalue);
|
||||||
|
|
||||||
long lvalue = ini.GetLongValue(section, "DisplayActiveStartOffset", 0);
|
long lvalue = ini.GetLongValue(section, "DisplayActiveStartOffset", 0);
|
||||||
if (lvalue != 0)
|
if (lvalue != 0)
|
||||||
entry->display_active_start_offset = static_cast<s16>(lvalue);
|
entry->display_active_start_offset = static_cast<s16>(lvalue);
|
||||||
|
@ -174,7 +190,7 @@ static void ParseIniSection(Entry* entry, const char* section, const CSimpleIniA
|
||||||
if (lvalue != 0)
|
if (lvalue != 0)
|
||||||
entry->display_active_end_offset = static_cast<s16>(lvalue);
|
entry->display_active_end_offset = static_cast<s16>(lvalue);
|
||||||
|
|
||||||
const char* cvalue = ini.GetValue(section, "DisplayCropMode", nullptr);
|
cvalue = ini.GetValue(section, "DisplayCropMode", nullptr);
|
||||||
if (cvalue)
|
if (cvalue)
|
||||||
entry->display_crop_mode = Settings::ParseDisplayCropMode(cvalue);
|
entry->display_crop_mode = Settings::ParseDisplayCropMode(cvalue);
|
||||||
cvalue = ini.GetValue(section, "DisplayAspectRatio", nullptr);
|
cvalue = ini.GetValue(section, "DisplayAspectRatio", nullptr);
|
||||||
|
@ -241,6 +257,13 @@ static void StoreIniSection(const Entry& entry, const char* section, CSimpleIniA
|
||||||
ini.SetBoolValue(section, s_trait_names[trait].first, true);
|
ini.SetBoolValue(section, s_trait_names[trait].first, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (entry.cpu_overclock_numerator.has_value())
|
||||||
|
ini.SetLongValue(section, "CPUOverclockNumerator", static_cast<long>(entry.cpu_overclock_numerator.value()));
|
||||||
|
if (entry.cpu_overclock_denominator.has_value())
|
||||||
|
ini.SetLongValue(section, "CPUOverclockDenominator", static_cast<long>(entry.cpu_overclock_denominator.value()));
|
||||||
|
if (entry.cpu_overclock_enable.has_value())
|
||||||
|
ini.SetBoolValue(section, "CPUOverclockEnable", entry.cpu_overclock_enable.value());
|
||||||
|
|
||||||
if (entry.display_active_start_offset.has_value())
|
if (entry.display_active_start_offset.has_value())
|
||||||
ini.SetLongValue(section, "DisplayActiveStartOffset", entry.display_active_start_offset.value());
|
ini.SetLongValue(section, "DisplayActiveStartOffset", entry.display_active_start_offset.value());
|
||||||
|
|
||||||
|
@ -394,6 +417,14 @@ void Entry::ApplySettings(bool display_osd_messages) const
|
||||||
{
|
{
|
||||||
constexpr float osd_duration = 10.0f;
|
constexpr float osd_duration = 10.0f;
|
||||||
|
|
||||||
|
if (cpu_overclock_numerator.has_value())
|
||||||
|
g_settings.cpu_overclock_numerator = cpu_overclock_numerator.value();
|
||||||
|
if (cpu_overclock_denominator.has_value())
|
||||||
|
g_settings.cpu_overclock_denominator = cpu_overclock_denominator.value();
|
||||||
|
if (cpu_overclock_enable.has_value())
|
||||||
|
g_settings.cpu_overclock_enable = cpu_overclock_enable.value();
|
||||||
|
g_settings.UpdateOverclockActive();
|
||||||
|
|
||||||
if (display_active_start_offset.has_value())
|
if (display_active_start_offset.has_value())
|
||||||
g_settings.display_active_start_offset = display_active_start_offset.value();
|
g_settings.display_active_start_offset = display_active_start_offset.value();
|
||||||
if (display_active_end_offset.has_value())
|
if (display_active_end_offset.has_value())
|
||||||
|
|
|
@ -40,6 +40,9 @@ struct Entry
|
||||||
std::optional<s16> display_active_end_offset;
|
std::optional<s16> display_active_end_offset;
|
||||||
|
|
||||||
// user settings
|
// user settings
|
||||||
|
std::optional<u32> cpu_overclock_numerator;
|
||||||
|
std::optional<u32> cpu_overclock_denominator;
|
||||||
|
std::optional<bool> cpu_overclock_enable;
|
||||||
std::optional<DisplayCropMode> display_crop_mode;
|
std::optional<DisplayCropMode> display_crop_mode;
|
||||||
std::optional<DisplayAspectRatio> display_aspect_ratio;
|
std::optional<DisplayAspectRatio> display_aspect_ratio;
|
||||||
std::optional<bool> display_linear_upscaling;
|
std::optional<bool> display_linear_upscaling;
|
||||||
|
|
Loading…
Reference in a new issue