From 7210b0826a623ee31b56cf92688a9be308dedcb1 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Thu, 29 Oct 2020 23:59:48 +1000 Subject: [PATCH] GameSettings: Make DMA/GPU tweak settings overridable --- data/database/gamesettings.ini | 6 +- src/duckstation-qt/gamepropertiesdialog.cpp | 49 ++++++++++++++++ src/duckstation-qt/gamepropertiesdialog.ui | 65 +++++++++++++++++++++ src/frontend-common/game_list.h | 2 +- src/frontend-common/game_settings.cpp | 37 +++++++++++- src/frontend-common/game_settings.h | 4 ++ 6 files changed, 157 insertions(+), 6 deletions(-) diff --git a/data/database/gamesettings.ini b/data/database/gamesettings.ini index 59039f9a4..b782670f3 100644 --- a/data/database/gamesettings.ini +++ b/data/database/gamesettings.ini @@ -116,9 +116,11 @@ DisablePGXP = true ForceDigitalController = true -# SCUS-94302 (Destruction Derby (USA)) -[SCUS-94302] +# SCUS-94350 (Destruction Derby 2 (USA)) +[SCUS-94350] ForceDigitalController = true +DMAMaxSliceTicks = 225 +DMAHaltTicks = 100 # SCUS-94900 (Crash Bandicoot (USA)) diff --git a/src/duckstation-qt/gamepropertiesdialog.cpp b/src/duckstation-qt/gamepropertiesdialog.cpp index 6337f8c4e..a68e87ed5 100644 --- a/src/duckstation-qt/gamepropertiesdialog.cpp +++ b/src/duckstation-qt/gamepropertiesdialog.cpp @@ -287,6 +287,27 @@ void GamePropertiesDialog::populateGameSettings() m_ui.displayActiveEndOffset->setValue(static_cast(gs.display_active_end_offset.value())); } + if (gs.dma_max_slice_ticks.has_value()) + { + QSignalBlocker sb(m_ui.dmaMaxSliceTicks); + m_ui.dmaMaxSliceTicks->setValue(static_cast(gs.dma_max_slice_ticks.value())); + } + if (gs.dma_halt_ticks.has_value()) + { + QSignalBlocker sb(m_ui.dmaHaltTicks); + m_ui.dmaHaltTicks->setValue(static_cast(gs.dma_halt_ticks.value())); + } + if (gs.gpu_fifo_size.has_value()) + { + QSignalBlocker sb(m_ui.gpuFIFOSize); + m_ui.gpuFIFOSize->setValue(static_cast(gs.gpu_fifo_size.value())); + } + if (gs.gpu_max_run_ahead.has_value()) + { + QSignalBlocker sb(m_ui.gpuMaxRunAhead); + m_ui.gpuMaxRunAhead->setValue(static_cast(gs.gpu_max_run_ahead.value())); + } + if (gs.display_crop_mode.has_value()) { QSignalBlocker sb(m_ui.userCropMode); @@ -584,6 +605,34 @@ void GamePropertiesDialog::connectUi() m_game_settings.display_active_end_offset = static_cast(value); saveGameSettings(); }); + connect(m_ui.dmaMaxSliceTicks, QOverload::of(&QSpinBox::valueChanged), [this](int value) { + if (value == 0) + m_game_settings.dma_max_slice_ticks.reset(); + else + m_game_settings.dma_max_slice_ticks = static_cast(value); + saveGameSettings(); + }); + connect(m_ui.dmaHaltTicks, QOverload::of(&QSpinBox::valueChanged), [this](int value) { + if (value == 0) + m_game_settings.dma_halt_ticks.reset(); + else + m_game_settings.dma_halt_ticks = static_cast(value); + saveGameSettings(); + }); + connect(m_ui.gpuFIFOSize, QOverload::of(&QSpinBox::valueChanged), [this](int value) { + if (value == 0) + m_game_settings.gpu_fifo_size.reset(); + else + m_game_settings.gpu_fifo_size = static_cast(value); + saveGameSettings(); + }); + connect(m_ui.gpuMaxRunAhead, QOverload::of(&QSpinBox::valueChanged), [this](int value) { + if (value == 0) + m_game_settings.gpu_max_run_ahead.reset(); + else + m_game_settings.gpu_max_run_ahead = static_cast(value); + saveGameSettings(); + }); } void GamePropertiesDialog::updateCPUClockSpeedLabel() diff --git a/src/duckstation-qt/gamepropertiesdialog.ui b/src/duckstation-qt/gamepropertiesdialog.ui index e36e46e42..9709c859e 100644 --- a/src/duckstation-qt/gamepropertiesdialog.ui +++ b/src/duckstation-qt/gamepropertiesdialog.ui @@ -676,6 +676,71 @@ + + + + DMA Max Slice Ticks: + + + + + + + 10000 + + + 100 + + + + + + + DMA Halt Ticks: + + + + + + + 1000 + + + 10 + + + + + + + GPU FIFO Size: + + + + + + + 128 + + + + + + + GPU Max Run Ahead: + + + + + + + 1000 + + + 16 + + + diff --git a/src/frontend-common/game_list.h b/src/frontend-common/game_list.h index 822a55051..39c268737 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 = 13 + GAME_LIST_CACHE_VERSION = 14 }; using DatabaseMap = std::unordered_map; diff --git a/src/frontend-common/game_settings.cpp b/src/frontend-common/game_settings.cpp index b9768b284..98bced1b1 100644 --- a/src/frontend-common/game_settings.cpp +++ b/src/frontend-common/game_settings.cpp @@ -109,6 +109,8 @@ bool Entry::LoadFromStream(ByteStream* stream) !ReadOptionalFromStream(stream, &cpu_overclock_enable) || !ReadOptionalFromStream(stream, &cdrom_read_speedup) || !ReadOptionalFromStream(stream, &display_active_start_offset) || !ReadOptionalFromStream(stream, &display_active_end_offset) || + !ReadOptionalFromStream(stream, &dma_max_slice_ticks) || !ReadOptionalFromStream(stream, &dma_halt_ticks) || + !ReadOptionalFromStream(stream, &gpu_fifo_size) || !ReadOptionalFromStream(stream, &gpu_max_run_ahead) || !ReadOptionalFromStream(stream, &display_crop_mode) || !ReadOptionalFromStream(stream, &display_aspect_ratio) || !ReadOptionalFromStream(stream, &display_linear_upscaling) || !ReadOptionalFromStream(stream, &display_integer_upscaling) || @@ -151,8 +153,10 @@ bool Entry::SaveToStream(ByteStream* stream) const WriteOptionalToStream(stream, cpu_overclock_denominator) && 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) && + WriteOptionalToStream(stream, display_active_end_offset) && + WriteOptionalToStream(stream, dma_max_slice_ticks) && WriteOptionalToStream(stream, dma_halt_ticks) && + WriteOptionalToStream(stream, gpu_fifo_size) && WriteOptionalToStream(stream, gpu_max_run_ahead) && + WriteOptionalToStream(stream, display_crop_mode) && WriteOptionalToStream(stream, display_aspect_ratio) && WriteOptionalToStream(stream, display_linear_upscaling) && WriteOptionalToStream(stream, display_integer_upscaling) && WriteOptionalToStream(stream, display_force_4_3_for_24bit) && @@ -193,6 +197,18 @@ static void ParseIniSection(Entry* entry, const char* section, const CSimpleIniA lvalue = ini.GetLongValue(section, "DisplayActiveEndOffset", 0); if (lvalue != 0) entry->display_active_end_offset = static_cast(lvalue); + lvalue = ini.GetLongValue(section, "DMAMaxSliceTicks", 0); + if (lvalue > 0) + entry->dma_max_slice_ticks = static_cast(lvalue); + lvalue = ini.GetLongValue(section, "DMAHaltTicks", 0); + if (lvalue > 0) + entry->dma_halt_ticks = static_cast(lvalue); + lvalue = ini.GetLongValue(section, "GPUFIFOSize", 0); + if (lvalue > 0) + entry->gpu_fifo_size = static_cast(lvalue); + lvalue = ini.GetLongValue(section, "GPUMaxRunAhead", 0); + if (lvalue > 0) + entry->gpu_max_run_ahead = static_cast(lvalue); cvalue = ini.GetValue(section, "DisplayCropMode", nullptr); if (cvalue) @@ -276,9 +292,16 @@ static void StoreIniSection(const Entry& entry, const char* section, CSimpleIniA if (entry.display_active_start_offset.has_value()) ini.SetLongValue(section, "DisplayActiveStartOffset", entry.display_active_start_offset.value()); - if (entry.display_active_end_offset.has_value()) ini.SetLongValue(section, "DisplayActiveEndOffset", entry.display_active_end_offset.value()); + if (entry.dma_max_slice_ticks.has_value()) + ini.SetLongValue(section, "DMAMaxSliceTicks", static_cast(entry.dma_max_slice_ticks.value())); + if (entry.dma_halt_ticks.has_value()) + ini.SetLongValue(section, "DMAHaltTicks", static_cast(entry.dma_halt_ticks.value())); + if (entry.gpu_fifo_size.has_value()) + ini.SetLongValue(section, "GPUFIFOSize", static_cast(entry.gpu_fifo_size.value())); + if (entry.gpu_max_run_ahead.has_value()) + ini.SetLongValue(section, "GPUMaxRunAhead", static_cast(entry.gpu_max_run_ahead.value())); if (entry.display_crop_mode.has_value()) ini.SetValue(section, "DisplayCropMode", Settings::GetDisplayCropModeName(entry.display_crop_mode.value())); @@ -444,6 +467,14 @@ void Entry::ApplySettings(bool display_osd_messages) const g_settings.display_active_start_offset = display_active_start_offset.value(); if (display_active_end_offset.has_value()) g_settings.display_active_end_offset = display_active_end_offset.value(); + if (dma_max_slice_ticks.has_value()) + g_settings.dma_max_slice_ticks = dma_max_slice_ticks.value(); + if (dma_halt_ticks.has_value()) + g_settings.dma_halt_ticks = dma_halt_ticks.value(); + if (gpu_fifo_size.has_value()) + g_settings.gpu_fifo_size = gpu_fifo_size.value(); + if (gpu_max_run_ahead.has_value()) + g_settings.gpu_max_run_ahead = gpu_max_run_ahead.value(); if (display_crop_mode.has_value()) g_settings.display_crop_mode = display_crop_mode.value(); diff --git a/src/frontend-common/game_settings.h b/src/frontend-common/game_settings.h index e83412ccc..70e518313 100644 --- a/src/frontend-common/game_settings.h +++ b/src/frontend-common/game_settings.h @@ -38,6 +38,10 @@ struct Entry std::bitset(Trait::Count)> traits{}; std::optional display_active_start_offset; std::optional display_active_end_offset; + std::optional dma_max_slice_ticks; + std::optional dma_halt_ticks; + std::optional gpu_fifo_size; + std::optional gpu_max_run_ahead; // user settings std::optional cpu_overclock_numerator;