From a3f2f13fa9a6ebd81a3a4bf9ee742ebb747d64b3 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Mon, 5 Oct 2020 00:17:12 +1000 Subject: [PATCH] GameSettings: Add CD-ROM Read Speedup --- src/duckstation-qt/gamepropertiesdialog.cpp | 14 ++++ src/duckstation-qt/gamepropertiesdialog.ui | 77 ++++++++++++++++++++- src/frontend-common/game_list.h | 2 +- src/frontend-common/game_settings.cpp | 14 +++- src/frontend-common/game_settings.h | 1 + 5 files changed, 104 insertions(+), 4 deletions(-) diff --git a/src/duckstation-qt/gamepropertiesdialog.cpp b/src/duckstation-qt/gamepropertiesdialog.cpp index 5ef3004ce..6337f8c4e 100644 --- a/src/duckstation-qt/gamepropertiesdialog.cpp +++ b/src/duckstation-qt/gamepropertiesdialog.cpp @@ -270,6 +270,12 @@ void GamePropertiesDialog::populateGameSettings() populateBooleanUserSetting(m_ui.userEnableCPUClockSpeedControl, gs.cpu_overclock_enable); updateCPUClockSpeedLabel(); + if (gs.cdrom_read_speedup.has_value()) + { + QSignalBlocker sb(m_ui.userCDROMReadSpeedup); + m_ui.userCDROMReadSpeedup->setCurrentIndex(static_cast(gs.cdrom_read_speedup.value())); + } + if (gs.display_active_start_offset.has_value()) { QSignalBlocker sb(m_ui.displayActiveStartOffset); @@ -435,6 +441,14 @@ void GamePropertiesDialog::connectUi() updateCPUClockSpeedLabel(); }); + connect(m_ui.userCDROMReadSpeedup, QOverload::of(&QComboBox::currentIndexChanged), [this](int index) { + if (index <= 0) + m_game_settings.cdrom_read_speedup.reset(); + else + m_game_settings.cdrom_read_speedup = static_cast(index); + saveGameSettings(); + }); + connect(m_ui.userAspectRatio, QOverload::of(&QComboBox::currentIndexChanged), [this](int index) { if (index <= 0) m_game_settings.display_aspect_ratio.reset(); diff --git a/src/duckstation-qt/gamepropertiesdialog.ui b/src/duckstation-qt/gamepropertiesdialog.ui index f34b57bad..e36e46e42 100644 --- a/src/duckstation-qt/gamepropertiesdialog.ui +++ b/src/duckstation-qt/gamepropertiesdialog.ui @@ -402,7 +402,82 @@ - + + + Other Settings + + + + + + CD-ROM Read Speedup: + + + + + + + + (unchanged) + + + + + None (Double Speed) + + + + + 2x (Quad Speed) + + + + + 3x (6x Speed) + + + + + 4x (8x Speed) + + + + + 5x (10x Speed) + + + + + 6x (12x Speed) + + + + + 7x (14x Speed) + + + + + 8x (16x Speed) + + + + + 9x (18x Speed) + + + + + 10x (20x Speed) + + + + + + + + + Qt::Vertical diff --git a/src/frontend-common/game_list.h b/src/frontend-common/game_list.h index b70f3aa4f..822a55051 100644 --- a/src/frontend-common/game_list.h +++ b/src/frontend-common/game_list.h @@ -115,7 +115,7 @@ private: enum : u32 { GAME_LIST_CACHE_SIGNATURE = 0x45434C47, - GAME_LIST_CACHE_VERSION = 12 + GAME_LIST_CACHE_VERSION = 13 }; using DatabaseMap = std::unordered_map; diff --git a/src/frontend-common/game_settings.cpp b/src/frontend-common/game_settings.cpp index 545183579..ebd3926af 100644 --- a/src/frontend-common/game_settings.cpp +++ b/src/frontend-common/game_settings.cpp @@ -106,7 +106,7 @@ bool Entry::LoadFromStream(ByteStream* stream) if (!stream->Read2(bits.data(), num_bytes) || !ReadOptionalFromStream(stream, &cpu_overclock_numerator) || !ReadOptionalFromStream(stream, &cpu_overclock_denominator) || - !ReadOptionalFromStream(stream, &cpu_overclock_enable) || + !ReadOptionalFromStream(stream, &cpu_overclock_enable) || !ReadOptionalFromStream(stream, &cdrom_read_speedup) || !ReadOptionalFromStream(stream, &display_active_start_offset) || !ReadOptionalFromStream(stream, &display_active_end_offset) || !ReadOptionalFromStream(stream, &display_crop_mode) || !ReadOptionalFromStream(stream, &display_aspect_ratio) || @@ -149,7 +149,7 @@ bool Entry::SaveToStream(ByteStream* stream) const return stream->Write2(bits.data(), num_bytes) && WriteOptionalToStream(stream, cpu_overclock_numerator) && WriteOptionalToStream(stream, cpu_overclock_denominator) && - WriteOptionalToStream(stream, cpu_overclock_enable) && + WriteOptionalToStream(stream, cpu_overclock_enable) && WriteOptionalToStream(stream, cdrom_read_speedup) && WriteOptionalToStream(stream, display_active_start_offset) && WriteOptionalToStream(stream, display_active_end_offset) && WriteOptionalToStream(stream, display_crop_mode) && WriteOptionalToStream(stream, display_aspect_ratio) && @@ -183,6 +183,10 @@ static void ParseIniSection(Entry* entry, const char* section, const CSimpleIniA if (cvalue) entry->cpu_overclock_enable = StringUtil::FromChars(cvalue); + cvalue = ini.GetValue(section, "CDROMReadSpeedup", nullptr); + if (cvalue) + entry->cdrom_read_speedup = StringUtil::FromChars(cvalue); + long lvalue = ini.GetLongValue(section, "DisplayActiveStartOffset", 0); if (lvalue != 0) entry->display_active_start_offset = static_cast(lvalue); @@ -267,6 +271,9 @@ static void StoreIniSection(const Entry& entry, const char* section, CSimpleIniA if (entry.cpu_overclock_enable.has_value()) ini.SetBoolValue(section, "CPUOverclockEnable", entry.cpu_overclock_enable.value()); + if (entry.cdrom_read_speedup.has_value()) + ini.SetBoolValue(section, "CDROMReadSpeedup", entry.cdrom_read_speedup.value()); + if (entry.display_active_start_offset.has_value()) ini.SetLongValue(section, "DisplayActiveStartOffset", entry.display_active_start_offset.value()); @@ -430,6 +437,9 @@ void Entry::ApplySettings(bool display_osd_messages) const g_settings.cpu_overclock_enable = cpu_overclock_enable.value(); g_settings.UpdateOverclockActive(); + if (cdrom_read_speedup.has_value()) + g_settings.cdrom_read_speedup = cdrom_read_speedup.value(); + if (display_active_start_offset.has_value()) g_settings.display_active_start_offset = display_active_start_offset.value(); if (display_active_end_offset.has_value()) diff --git a/src/frontend-common/game_settings.h b/src/frontend-common/game_settings.h index 46628b5aa..e83412ccc 100644 --- a/src/frontend-common/game_settings.h +++ b/src/frontend-common/game_settings.h @@ -43,6 +43,7 @@ struct Entry std::optional cpu_overclock_numerator; std::optional cpu_overclock_denominator; std::optional cpu_overclock_enable; + std::optional cdrom_read_speedup; std::optional display_crop_mode; std::optional display_aspect_ratio; std::optional display_linear_upscaling;