2021-12-13 12:12:54 +00:00
|
|
|
/* PCSX2 - PS2 Emulator for PCs
|
|
|
|
* Copyright (C) 2002-2022 PCSX2 Dev Team
|
|
|
|
*
|
|
|
|
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
|
|
|
|
* of the GNU Lesser General Public License as published by the Free Software Found-
|
|
|
|
* ation, either version 3 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
|
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE. See the GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with PCSX2.
|
|
|
|
* If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "PrecompiledHeader.h"
|
|
|
|
|
|
|
|
#include <QtWidgets/QMessageBox>
|
|
|
|
#include <algorithm>
|
|
|
|
|
2022-05-24 12:37:44 +00:00
|
|
|
#include "pcsx2/HostSettings.h"
|
|
|
|
|
2022-09-07 09:20:50 +00:00
|
|
|
#include "QtHost.h"
|
2021-12-13 12:12:54 +00:00
|
|
|
#include "QtUtils.h"
|
|
|
|
#include "SettingWidgetBinder.h"
|
|
|
|
#include "SettingsDialog.h"
|
|
|
|
#include "SystemSettingsWidget.h"
|
|
|
|
|
|
|
|
static constexpr int MINIMUM_EE_CYCLE_RATE = -3;
|
|
|
|
static constexpr int MAXIMUM_EE_CYCLE_RATE = 3;
|
|
|
|
static constexpr int DEFAULT_EE_CYCLE_RATE = 0;
|
|
|
|
static constexpr int DEFAULT_EE_CYCLE_SKIP = 0;
|
|
|
|
|
2022-02-15 14:29:18 +00:00
|
|
|
SystemSettingsWidget::SystemSettingsWidget(SettingsDialog* dialog, QWidget* parent)
|
2021-12-13 12:12:54 +00:00
|
|
|
: QWidget(parent)
|
2022-02-15 14:29:18 +00:00
|
|
|
, m_dialog(dialog)
|
2021-12-13 12:12:54 +00:00
|
|
|
{
|
2022-02-15 14:29:18 +00:00
|
|
|
SettingsInterface* sif = dialog->getSettingsInterface();
|
|
|
|
|
2021-12-13 12:12:54 +00:00
|
|
|
m_ui.setupUi(this);
|
|
|
|
|
2022-03-04 08:04:05 +00:00
|
|
|
SettingWidgetBinder::BindWidgetToIntSetting(sif, m_ui.eeCycleSkipping, "EmuCore/Speedhacks", "EECycleSkip", DEFAULT_EE_CYCLE_SKIP);
|
2021-10-31 09:59:31 +00:00
|
|
|
SettingWidgetBinder::BindWidgetToIntSetting(sif, m_ui.affinityControl, "EmuCore/CPU", "AffinityControlMode", 0);
|
2022-02-15 14:29:18 +00:00
|
|
|
|
|
|
|
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.MTVU, "EmuCore/Speedhacks", "vuThread", false);
|
|
|
|
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.instantVU1, "EmuCore/Speedhacks", "vu1Instant", true);
|
|
|
|
SettingWidgetBinder::BindWidgetToIntSetting(sif, m_ui.eeRoundingMode, "EmuCore/CPU", "FPU.Roundmode", 3);
|
|
|
|
SettingWidgetBinder::BindWidgetToIntSetting(sif, m_ui.vuRoundingMode, "EmuCore/CPU", "VU.Roundmode", 3);
|
|
|
|
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.fastCDVD, "EmuCore/Speedhacks", "fastCDVD", false);
|
|
|
|
|
2022-09-13 13:40:43 +00:00
|
|
|
// Allow for FastCDVD for per-game settings only
|
|
|
|
m_ui.fastCDVD->setEnabled(m_dialog->isPerGameSettings());
|
|
|
|
|
2022-02-15 14:29:18 +00:00
|
|
|
if (m_dialog->isPerGameSettings())
|
|
|
|
{
|
|
|
|
m_ui.eeCycleRate->insertItem(
|
|
|
|
0, tr("Use Global Setting [%1]")
|
|
|
|
.arg(m_ui.eeCycleRate->itemText(
|
2022-05-24 12:37:44 +00:00
|
|
|
std::clamp(Host::GetBaseIntSettingValue("EmuCore/Speedhacks", "EECycleRate", DEFAULT_EE_CYCLE_RATE) - MINIMUM_EE_CYCLE_RATE,
|
2022-02-15 14:29:18 +00:00
|
|
|
0, MAXIMUM_EE_CYCLE_RATE - MINIMUM_EE_CYCLE_RATE))));
|
|
|
|
m_ui.eeClampMode->insertItem(0, tr("Use Global Setting [%1]").arg(m_ui.eeClampMode->itemText(getGlobalClampingModeIndex(false))));
|
|
|
|
m_ui.vuClampMode->insertItem(0, tr("Use Global Setting [%1]").arg(m_ui.vuClampMode->itemText(getGlobalClampingModeIndex(true))));
|
|
|
|
}
|
|
|
|
|
|
|
|
const std::optional<int> cycle_rate =
|
|
|
|
m_dialog->getIntValue("EmuCore/Speedhacks", "EECycleRate", sif ? std::nullopt : std::optional<int>(DEFAULT_EE_CYCLE_RATE));
|
|
|
|
m_ui.eeCycleRate->setCurrentIndex(cycle_rate.has_value() ? (std::clamp(cycle_rate.value(), MINIMUM_EE_CYCLE_RATE, MAXIMUM_EE_CYCLE_RATE) +
|
|
|
|
(0 - MINIMUM_EE_CYCLE_RATE) + static_cast<int>(m_dialog->isPerGameSettings())) :
|
|
|
|
0);
|
|
|
|
connect(m_ui.eeCycleRate, QOverload<int>::of(&QComboBox::currentIndexChanged), this, [this](int index) {
|
|
|
|
std::optional<int> value;
|
|
|
|
if (!m_dialog->isPerGameSettings() || index > 0)
|
|
|
|
value = MINIMUM_EE_CYCLE_RATE + index - static_cast<int>(m_dialog->isPerGameSettings());
|
|
|
|
m_dialog->setIntSettingValue("EmuCore/Speedhacks", "EECycleRate", value);
|
2021-12-13 12:12:54 +00:00
|
|
|
});
|
|
|
|
|
2022-02-15 14:29:18 +00:00
|
|
|
m_ui.eeClampMode->setCurrentIndex(getClampingModeIndex(false));
|
2021-12-13 12:12:54 +00:00
|
|
|
m_ui.vuClampMode->setCurrentIndex(getClampingModeIndex(true));
|
2022-02-15 14:29:18 +00:00
|
|
|
connect(m_ui.eeClampMode, QOverload<int>::of(&QComboBox::currentIndexChanged), [this](int index) { setClampingMode(false, index); });
|
|
|
|
connect(m_ui.vuClampMode, QOverload<int>::of(&QComboBox::currentIndexChanged), [this](int index) { setClampingMode(true, index); });
|
2021-12-13 12:12:54 +00:00
|
|
|
|
2022-06-27 13:08:03 +00:00
|
|
|
dialog->registerWidgetHelp(m_ui.eeCycleRate, tr("Cycle Rate"), tr("100% (Normal Speed)"),
|
|
|
|
tr("Higher values may increase internal framerate in games, but will increase CPU requirements substantially. "
|
|
|
|
"Lower values will reduce the CPU load allowing lightweight games to run full speed on weaker CPUs."));
|
|
|
|
|
2022-07-28 21:20:31 +00:00
|
|
|
dialog->registerWidgetHelp(m_ui.eeCycleSkipping, tr("Cycle Skip"), tr("None"),
|
2022-06-27 13:08:03 +00:00
|
|
|
tr("Makes the emulated Emotion Engine skip cycles. "
|
|
|
|
"Helps a small subset of games like SOTC. Most of the time it's harmful to performance."));
|
|
|
|
|
2022-07-19 00:01:37 +00:00
|
|
|
dialog->registerWidgetHelp(m_ui.MTVU, tr("MTVU (Multi-threaded VU1)"), tr("Checked"),
|
2022-06-27 13:08:03 +00:00
|
|
|
tr("Generally a speedup on CPUs with 3 or more threads. "
|
|
|
|
"Safe for most games, but a few are incompatible and may hang."));
|
|
|
|
|
|
|
|
dialog->registerWidgetHelp(m_ui.instantVU1, tr("Instant VU1"), tr("Checked"),
|
2022-07-25 19:54:23 +00:00
|
|
|
tr("Runs VU1 instantly. Provides a modest speed improvement in most games. "
|
2022-06-27 13:08:03 +00:00
|
|
|
"Safe for most games, but a few games may exhibit graphical errors."));
|
|
|
|
|
|
|
|
dialog->registerWidgetHelp(m_ui.fastCDVD, tr("Enable Fast CDVD"), tr("Unchecked"),
|
|
|
|
tr("Fast disc access, less loading times. Check HDLoader compatibility lists for known games that have issues with this."));
|
2021-12-13 12:12:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SystemSettingsWidget::~SystemSettingsWidget() = default;
|
|
|
|
|
2022-02-15 14:29:18 +00:00
|
|
|
int SystemSettingsWidget::getGlobalClampingModeIndex(bool vu) const
|
2021-12-13 12:12:54 +00:00
|
|
|
{
|
2022-05-24 12:37:44 +00:00
|
|
|
if (Host::GetBaseBoolSettingValue("EmuCore/CPU/Recompiler", vu ? "vuSignOverflow" : "fpuFullMode", false))
|
2021-12-13 12:12:54 +00:00
|
|
|
return 3;
|
2022-02-15 14:29:18 +00:00
|
|
|
|
2022-05-24 12:37:44 +00:00
|
|
|
if (Host::GetBaseBoolSettingValue("EmuCore/CPU/Recompiler", vu ? "vuExtraOverflow" : "fpuExtraOverflow", false))
|
2021-12-13 12:12:54 +00:00
|
|
|
return 2;
|
2022-02-15 14:29:18 +00:00
|
|
|
|
2022-05-24 12:37:44 +00:00
|
|
|
if (Host::GetBaseBoolSettingValue("EmuCore/CPU/Recompiler", vu ? "vuOverflow" : "fpuOverflow", true))
|
2021-12-13 12:12:54 +00:00
|
|
|
return 1;
|
2022-02-15 14:29:18 +00:00
|
|
|
|
2021-12-13 12:12:54 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-02-15 14:29:18 +00:00
|
|
|
int SystemSettingsWidget::getClampingModeIndex(bool vu) const
|
|
|
|
{
|
|
|
|
// This is so messy... maybe we should just make the mode an int in the settings too...
|
|
|
|
const bool base = m_dialog->isPerGameSettings() ? 1 : 0;
|
|
|
|
std::optional<bool> default_false = m_dialog->isPerGameSettings() ? std::nullopt : std::optional<bool>(false);
|
|
|
|
std::optional<bool> default_true = m_dialog->isPerGameSettings() ? std::nullopt : std::optional<bool>(true);
|
|
|
|
|
|
|
|
std::optional<bool> third = m_dialog->getBoolValue("EmuCore/CPU/Recompiler", vu ? "vuSignOverflow" : "fpuFullMode", default_false);
|
|
|
|
std::optional<bool> second = m_dialog->getBoolValue("EmuCore/CPU/Recompiler", vu ? "vuExtraOverflow" : "fpuExtraOverflow", default_false);
|
|
|
|
std::optional<bool> first = m_dialog->getBoolValue("EmuCore/CPU/Recompiler", vu ? "vuOverflow" : "fpuOverflow", default_true);
|
|
|
|
|
|
|
|
if (third.has_value() && third.value())
|
|
|
|
return base + 3;
|
|
|
|
if (second.has_value() && second.value())
|
|
|
|
return base + 2;
|
|
|
|
if (first.has_value() && first.value())
|
|
|
|
return base + 1;
|
|
|
|
else if (first.has_value())
|
|
|
|
return base + 0; // none
|
|
|
|
else
|
|
|
|
return 0; // no per game override
|
|
|
|
}
|
|
|
|
|
2021-12-13 12:12:54 +00:00
|
|
|
void SystemSettingsWidget::setClampingMode(bool vu, int index)
|
|
|
|
{
|
2022-02-15 14:29:18 +00:00
|
|
|
std::optional<bool> first, second, third;
|
|
|
|
|
|
|
|
if (!m_dialog->isPerGameSettings() || index > 0)
|
|
|
|
{
|
|
|
|
const bool base = m_dialog->isPerGameSettings() ? 1 : 0;
|
|
|
|
third = (index >= (base + 3));
|
|
|
|
second = (index >= (base + 2));
|
|
|
|
first = (index >= (base + 1));
|
|
|
|
}
|
|
|
|
|
|
|
|
m_dialog->setBoolSettingValue("EmuCore/CPU/Recompiler", vu ? "vuSignOverflow" : "fpuFullMode", third);
|
|
|
|
m_dialog->setBoolSettingValue("EmuCore/CPU/Recompiler", vu ? "vuExtraOverflow" : "fpuExtraOverflow", second);
|
|
|
|
m_dialog->setBoolSettingValue("EmuCore/CPU/Recompiler", vu ? "vuOverflow" : "fpuOverflow", first);
|
2021-12-13 12:12:54 +00:00
|
|
|
}
|