GameSettings: Add CD-ROM seek speedup

This commit is contained in:
Connor McLaughlin 2021-05-23 13:44:40 +10:00
parent 98e4c181ca
commit 3dc7ef92c2
5 changed files with 283 additions and 152 deletions

View File

@ -319,6 +319,12 @@ void GamePropertiesDialog::populateGameSettings()
m_ui.userCDROMReadSpeedup->setCurrentIndex(static_cast<int>(gs.cdrom_read_speedup.value()));
}
if (gs.cdrom_seek_speedup.has_value())
{
QSignalBlocker sb(m_ui.userCDROMSeekSpeedup);
m_ui.userCDROMSeekSpeedup->setCurrentIndex(static_cast<int>(gs.cdrom_seek_speedup.value()) + 1);
}
if (gs.display_active_start_offset.has_value())
{
QSignalBlocker sb(m_ui.displayActiveStartOffset);
@ -589,6 +595,14 @@ void GamePropertiesDialog::connectUi()
saveGameSettings();
});
connect(m_ui.userCDROMSeekSpeedup, QOverload<int>::of(&QComboBox::currentIndexChanged), [this](int index) {
if (index <= 0)
m_game_settings.cdrom_seek_speedup.reset();
else
m_game_settings.cdrom_seek_speedup = static_cast<u32>(index - 1);
saveGameSettings();
});
connect(m_ui.userAspectRatio, QOverload<int>::of(&QComboBox::currentIndexChanged), [this](int index) {
if (index <= 0)
m_game_settings.display_aspect_ratio.reset();

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>769</width>
<height>706</height>
<width>692</width>
<height>562</height>
</rect>
</property>
<property name="windowTitle">
@ -262,6 +262,246 @@
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Other Settings</string>
</property>
<layout class="QFormLayout" name="formLayout_7">
<item row="0" column="0">
<widget class="QLabel" name="label_13">
<property name="text">
<string>CD-ROM Read Speedup:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="userCDROMReadSpeedup">
<item>
<property name="text">
<string>(unchanged)</string>
</property>
</item>
<item>
<property name="text">
<string>None (Double Speed)</string>
</property>
</item>
<item>
<property name="text">
<string>2x (Quad Speed)</string>
</property>
</item>
<item>
<property name="text">
<string>3x (6x Speed)</string>
</property>
</item>
<item>
<property name="text">
<string>4x (8x Speed)</string>
</property>
</item>
<item>
<property name="text">
<string>5x (10x Speed)</string>
</property>
</item>
<item>
<property name="text">
<string>6x (12x Speed)</string>
</property>
</item>
<item>
<property name="text">
<string>7x (14x Speed)</string>
</property>
</item>
<item>
<property name="text">
<string>8x (16x Speed)</string>
</property>
</item>
<item>
<property name="text">
<string>9x (18x Speed)</string>
</property>
</item>
<item>
<property name="text">
<string>10x (20x Speed)</string>
</property>
</item>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_35">
<property name="text">
<string>CD-ROM Seek Speedup:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="userCDROMSeekSpeedup">
<property name="currentIndex">
<number>0</number>
</property>
<item>
<property name="text">
<string>(unchanged)</string>
</property>
</item>
<item>
<property name="text">
<string>Infinite/Instantaneous</string>
</property>
</item>
<item>
<property name="text">
<string>None (Normal Speed)</string>
</property>
</item>
<item>
<property name="text">
<string>2x</string>
</property>
</item>
<item>
<property name="text">
<string>3x</string>
</property>
</item>
<item>
<property name="text">
<string>4x</string>
</property>
</item>
<item>
<property name="text">
<string>5x</string>
</property>
</item>
<item>
<property name="text">
<string>6x</string>
</property>
</item>
<item>
<property name="text">
<string>7x</string>
</property>
</item>
<item>
<property name="text">
<string>8x</string>
</property>
</item>
<item>
<property name="text">
<string>9x</string>
</property>
</item>
<item>
<property name="text">
<string>10x</string>
</property>
</item>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_32">
<property name="text">
<string>Runahead Frames:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="userRunaheadFrames">
<item>
<property name="text">
<string>(unchanged)</string>
</property>
</item>
<item>
<property name="text">
<string>Disabled</string>
</property>
</item>
<item>
<property name="text">
<string>1 Frame</string>
</property>
</item>
<item>
<property name="text">
<string>2 Frames</string>
</property>
</item>
<item>
<property name="text">
<string>3 Frames</string>
</property>
</item>
<item>
<property name="text">
<string>4 Frames</string>
</property>
</item>
<item>
<property name="text">
<string>5 Frames</string>
</property>
</item>
<item>
<property name="text">
<string>6 Frames</string>
</property>
</item>
<item>
<property name="text">
<string>7 Frames</string>
</property>
</item>
<item>
<property name="text">
<string>8 Frames</string>
</property>
</item>
<item>
<property name="text">
<string>9 Frames</string>
</property>
</item>
<item>
<property name="text">
<string>10 Frames</string>
</property>
</item>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_5">
<attribute name="title">
<string>User Settings (Graphics)</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<widget class="QGroupBox" name="groupBox_4">
<property name="title">
@ -490,153 +730,7 @@
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Other Settings</string>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
<widget class="QLabel" name="label_13">
<property name="text">
<string>CD-ROM Read Speedup:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="userCDROMReadSpeedup">
<item>
<property name="text">
<string>(unchanged)</string>
</property>
</item>
<item>
<property name="text">
<string>None (Double Speed)</string>
</property>
</item>
<item>
<property name="text">
<string>2x (Quad Speed)</string>
</property>
</item>
<item>
<property name="text">
<string>3x (6x Speed)</string>
</property>
</item>
<item>
<property name="text">
<string>4x (8x Speed)</string>
</property>
</item>
<item>
<property name="text">
<string>5x (10x Speed)</string>
</property>
</item>
<item>
<property name="text">
<string>6x (12x Speed)</string>
</property>
</item>
<item>
<property name="text">
<string>7x (14x Speed)</string>
</property>
</item>
<item>
<property name="text">
<string>8x (16x Speed)</string>
</property>
</item>
<item>
<property name="text">
<string>9x (18x Speed)</string>
</property>
</item>
<item>
<property name="text">
<string>10x (20x Speed)</string>
</property>
</item>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_32">
<property name="text">
<string>Runahead Frames:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="userRunaheadFrames">
<item>
<property name="text">
<string>(unchanged)</string>
</property>
</item>
<item>
<property name="text">
<string>Disabled</string>
</property>
</item>
<item>
<property name="text">
<string>1 Frame</string>
</property>
</item>
<item>
<property name="text">
<string>2 Frames</string>
</property>
</item>
<item>
<property name="text">
<string>3 Frames</string>
</property>
</item>
<item>
<property name="text">
<string>4 Frames</string>
</property>
</item>
<item>
<property name="text">
<string>5 Frames</string>
</property>
</item>
<item>
<property name="text">
<string>6 Frames</string>
</property>
</item>
<item>
<property name="text">
<string>7 Frames</string>
</property>
</item>
<item>
<property name="text">
<string>8 Frames</string>
</property>
</item>
<item>
<property name="text">
<string>9 Frames</string>
</property>
</item>
<item>
<property name="text">
<string>10 Frames</string>
</property>
</item>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer_3">
<spacer name="verticalSpacer_4">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>

View File

@ -133,7 +133,7 @@ private:
enum : u32
{
GAME_LIST_CACHE_SIGNATURE = 0x45434C47,
GAME_LIST_CACHE_VERSION = 30
GAME_LIST_CACHE_VERSION = 31
};
using CacheMap = std::unordered_map<std::string, GameListEntry>;

View File

@ -110,7 +110,7 @@ bool Entry::LoadFromStream(ByteStream* stream)
!ReadOptionalFromStream(stream, &cpu_overclock_numerator) ||
!ReadOptionalFromStream(stream, &cpu_overclock_denominator) ||
!ReadOptionalFromStream(stream, &cpu_overclock_enable) || !ReadOptionalFromStream(stream, &enable_8mb_ram) ||
!ReadOptionalFromStream(stream, &cdrom_read_speedup) ||
!ReadOptionalFromStream(stream, &cdrom_read_speedup) || !ReadOptionalFromStream(stream, &cdrom_seek_speedup) ||
!ReadOptionalFromStream(stream, &display_active_start_offset) ||
!ReadOptionalFromStream(stream, &display_active_end_offset) ||
!ReadOptionalFromStream(stream, &display_line_start_offset) ||
@ -166,7 +166,7 @@ bool Entry::SaveToStream(ByteStream* stream) const
WriteOptionalToStream(stream, cpu_overclock_numerator) &&
WriteOptionalToStream(stream, cpu_overclock_denominator) &&
WriteOptionalToStream(stream, cpu_overclock_enable) && WriteOptionalToStream(stream, enable_8mb_ram) &&
WriteOptionalToStream(stream, cdrom_read_speedup) &&
WriteOptionalToStream(stream, cdrom_read_speedup) && WriteOptionalToStream(stream, cdrom_seek_speedup) &&
WriteOptionalToStream(stream, display_active_start_offset) &&
WriteOptionalToStream(stream, display_active_end_offset) &&
WriteOptionalToStream(stream, display_line_start_offset) &&
@ -221,6 +221,9 @@ static void ParseIniSection(Entry* entry, const char* section, const CSimpleIniA
cvalue = ini.GetValue(section, "CDROMReadSpeedup", nullptr);
if (cvalue)
entry->cdrom_read_speedup = StringUtil::FromChars<u32>(cvalue);
cvalue = ini.GetValue(section, "CDROMSeekSpeedup", nullptr);
if (cvalue)
entry->cdrom_seek_speedup = StringUtil::FromChars<u32>(cvalue);
long lvalue = ini.GetLongValue(section, "DisplayActiveStartOffset", 0);
if (lvalue != 0)
@ -370,6 +373,8 @@ static void StoreIniSection(const Entry& entry, const char* section, CSimpleIniA
if (entry.cdrom_read_speedup.has_value())
ini.SetLongValue(section, "CDROMReadSpeedup", static_cast<long>(entry.cdrom_read_speedup.value()));
if (entry.cdrom_seek_speedup.has_value())
ini.SetLongValue(section, "CDROMSeekSpeedup", static_cast<long>(entry.cdrom_seek_speedup.value()));
if (entry.display_active_start_offset.has_value())
ini.SetLongValue(section, "DisplayActiveStartOffset", entry.display_active_start_offset.value());
@ -473,6 +478,7 @@ u32 Entry::GetUserSettingsCount() const
count += BoolToUInt32(cpu_overclock_enable.has_value());
count += BoolToUInt32(enable_8mb_ram.has_value());
count += BoolToUInt32(cdrom_read_speedup.has_value());
count += BoolToUInt32(cdrom_seek_speedup.has_value());
count += BoolToUInt32(display_crop_mode.has_value());
count += BoolToUInt32(display_aspect_ratio.has_value());
count += BoolToUInt32(gpu_downsample_mode.has_value());
@ -534,6 +540,13 @@ static std::optional<std::string> GetEntryValueForKey(const Entry& entry, const
else
return std::to_string(entry.cdrom_read_speedup.value());
}
else if (key == "CDROMSeekSpeedup")
{
if (!entry.cdrom_seek_speedup.has_value())
return std::nullopt;
else
return std::to_string(entry.cdrom_seek_speedup.value());
}
else if (key == "DisplayCropMode")
{
if (!entry.display_crop_mode.has_value())
@ -796,6 +809,13 @@ static void SetEntryValueForKey(Entry& entry, const std::string_view& key, const
else
entry.cdrom_read_speedup = StringUtil::FromChars<u32>(value.value());
}
else if (key == "CDROMSeekSpeedup")
{
if (!value.has_value())
entry.cdrom_seek_speedup.reset();
else
entry.cdrom_seek_speedup = StringUtil::FromChars<u32>(value.value());
}
else if (key == "DisplayCropMode")
{
if (!value.has_value())
@ -1160,6 +1180,8 @@ void Entry::ApplySettings(bool display_osd_messages) const
if (cdrom_read_speedup.has_value())
g_settings.cdrom_read_speedup = cdrom_read_speedup.value();
if (cdrom_seek_speedup.has_value())
g_settings.cdrom_seek_speedup = cdrom_seek_speedup.value();
if (display_active_start_offset.has_value())
g_settings.display_active_start_offset = display_active_start_offset.value();

View File

@ -57,6 +57,7 @@ struct Entry
std::optional<bool> cpu_overclock_enable;
std::optional<bool> enable_8mb_ram;
std::optional<u32> cdrom_read_speedup;
std::optional<u32> cdrom_seek_speedup;
std::optional<DisplayCropMode> display_crop_mode;
std::optional<DisplayAspectRatio> display_aspect_ratio;
std::optional<GPURenderer> gpu_renderer;