Skip to content

Commit

Permalink
SaveState: Add configurable type and level
Browse files Browse the repository at this point in the history
  • Loading branch information
kamfretoz committed Sep 26, 2024
1 parent d9b7f41 commit 774a0e6
Show file tree
Hide file tree
Showing 5 changed files with 188 additions and 39 deletions.
6 changes: 6 additions & 0 deletions pcsx2-qt/Settings/AdvancedSettingsWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ AdvancedSettingsWidget::AdvancedSettingsWidget(SettingsWindow* dialog, QWidget*
SettingWidgetBinder::BindWidgetToFloatSetting(sif, m_ui.ntscFrameRate, "EmuCore/GS", "FramerateNTSC", 59.94f);
SettingWidgetBinder::BindWidgetToFloatSetting(sif, m_ui.palFrameRate, "EmuCore/GS", "FrameratePAL", 50.00f);

SettingWidgetBinder::BindWidgetToIntSetting(
sif, m_ui.savestateCompressionMethod, "EmuCore", "SavestateCompressionType", static_cast<int>(SavestateCompressionMethod::Zstandard));

SettingWidgetBinder::BindWidgetToIntSetting(
sif, m_ui.savestateCompressionLevel, "EmuCore", "SavestateCompressionRatio", static_cast<int>(SavestateCompressionLevel::Medium));

SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.pineEnable, "EmuCore", "EnablePINE", false);
SettingWidgetBinder::BindWidgetToIntSetting(sif, m_ui.pineSlot, "EmuCore", "PINESlot", 28011);

Expand Down
132 changes: 99 additions & 33 deletions pcsx2-qt/Settings/AdvancedSettingsWidget.ui
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<y>-180</y>
<width>790</width>
<height>765</height>
<height>997</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
Expand All @@ -48,7 +48,7 @@
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label_2">
<widget class="QLabel" name="disclaimerLabel">
<property name="text">
<string>Changing these options may cause games to become non-functional. Modify at your own risk, the PCSX2 team will not provide support for configurations with these settings changed.</string>
</property>
Expand All @@ -58,13 +58,13 @@
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<widget class="QGroupBox" name="eeSettings">
<property name="title">
<string extracomment="Emotion Engine = Commercial name of one of PS2's processors. Leave as-is unless there's an official name (like for Japanese).">EmotionEngine (MIPS-IV)</string>
</property>
<layout class="QGridLayout" name="gridLayout_7">
<item row="0" column="0">
<widget class="QLabel" name="label_11">
<widget class="QLabel" name="eeRoundingLabel">
<property name="text">
<string extracomment="Rounding refers here to the mathematical term.">Rounding Mode:</string>
</property>
Expand Down Expand Up @@ -95,7 +95,7 @@
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_13">
<widget class="QLabel" name="eeDivRoundingLabel">
<property name="text">
<string extracomment="Rounding refers here to the mathematical term.">Division Rounding Mode:</string>
</property>
Expand Down Expand Up @@ -126,7 +126,7 @@
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_12">
<widget class="QLabel" name="eeClampLabel">
<property name="text">
<string extracomment="Clamping: Forcing out of bounds things in bounds by changing them to the closest possible value. In this case, this refers to clamping large PS2 floating point values (which map to infinity or NaN in PCs' IEEE754 floats) to non-infinite ones.">Clamping Mode:</string>
</property>
Expand Down Expand Up @@ -157,7 +157,7 @@
</widget>
</item>
<item row="3" column="0" colspan="2">
<layout class="QGridLayout" name="gridLayout_4">
<layout class="QGridLayout" name="eeSettingsMisc">
<item row="1" column="0">
<widget class="QCheckBox" name="eeWaitLoopDetection">
<property name="text">
Expand Down Expand Up @@ -213,13 +213,13 @@
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<widget class="QGroupBox" name="vuSettings">
<property name="title">
<string extracomment="Vector Unit/VU: refers to two of PS2's processors. Do not translate the full text or do so as a comment. Leave the acronym as-is.">Vector Units (VU)</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<widget class="QLabel" name="vu1RoundingLabel">
<property name="text">
<string>VU1 Rounding Mode:</string>
</property>
Expand Down Expand Up @@ -250,7 +250,7 @@
</widget>
</item>
<item row="4" column="0" colspan="2">
<layout class="QGridLayout" name="gridLayout_6">
<layout class="QGridLayout" name="vuSettingsLayout">
<item row="1" column="0">
<widget class="QCheckBox" name="vuFlagHack">
<property name="text">
Expand Down Expand Up @@ -306,21 +306,21 @@
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_5">
<widget class="QLabel" name="vu0ClampLabel">
<property name="text">
<string>VU0 Clamping Mode:</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_6">
<widget class="QLabel" name="vu0RoundingLabel">
<property name="text">
<string>VU0 Rounding Mode:</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_4">
<widget class="QLabel" name="vu1ClampLabel">
<property name="text">
<string>VU1 Clamping Mode:</string>
</property>
Expand Down Expand Up @@ -378,7 +378,7 @@
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_3">
<widget class="QGroupBox" name="iopSettings">
<property name="title">
<string>I/O Processor (IOP, MIPS-I)</string>
</property>
Expand All @@ -394,7 +394,7 @@
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_4">
<widget class="QGroupBox" name="gameSettings">
<property name="title">
<string>Game Settings</string>
</property>
Expand All @@ -417,24 +417,24 @@
</widget>
</item>
<item>
<widget class="QGroupBox" name="basicGroupBox">
<widget class="QGroupBox" name="framerateControlSettings">
<property name="title">
<string>Frame Rate Control</string>
</property>
<layout class="QGridLayout" name="gridLayout_5">
<layout class="QGridLayout" name="framerateControlLayout">
<item row="1" column="1">
<widget class="QDoubleSpinBox" name="palFrameRate">
<property name="suffix">
<string extracomment="hz=Hertz, as in the measuring unit. Shown after the corresponding number. Those languages who'd need to remove the space or do something in between should do so."> hz</string>
</property>
<property name="singleStep">
<double>0.010000000000000</double>
</property>
<property name="minimum">
<double>10.0</double>
<double>10.000000000000000</double>
</property>
<property name="maximum">
<double>300.0</double>
<double>300.000000000000000</double>
</property>
<property name="singleStep">
<double>0.010000000000000</double>
</property>
</widget>
</item>
Expand All @@ -443,26 +443,26 @@
<property name="suffix">
<string> hz</string>
</property>
<property name="singleStep">
<double>0.010000000000000</double>
</property>
<property name="minimum">
<double>10.0</double>
<double>10.000000000000000</double>
</property>
<property name="maximum">
<double>300.0</double>
<double>300.000000000000000</double>
</property>
<property name="singleStep">
<double>0.010000000000000</double>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_7">
<widget class="QLabel" name="palLabel">
<property name="text">
<string>PAL Frame Rate:</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<widget class="QLabel" name="ntscLabel">
<property name="text">
<string>NTSC Frame Rate:</string>
</property>
Expand All @@ -472,11 +472,77 @@
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_5">
<widget class="QGroupBox" name="savestateSettings">
<property name="title">
<string>Savestate Settings</string>
</property>
<layout class="QGridLayout" name="savestateSettingsLayout">
<item row="1" column="0">
<widget class="QLabel" name="savestateCompressionMethodLabel">
<property name="text">
<string>Compression Level:</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="savestateCompressionLabel">
<property name="text">
<string>Compression Method:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="savestateCompressionMethod">
<item>
<property name="text">
<string>Uncompressed</string>
</property>
</item>
<item>
<property name="text">
<string>Deflate</string>
</property>
</item>
<item>
<property name="text">
<string>Zstandard</string>
</property>
</item>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="savestateCompressionLevel">
<item>
<property name="text">
<string>Low (Fast)</string>
</property>
</item>
<item>
<property name="text">
<string>Medium (Recommended)</string>
</property>
</item>
<item>
<property name="text">
<string>High</string>
</property>
</item>
<item>
<property name="text">
<string>Very High (Slow, Not Recommended)</string>
</property>
</item>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="pineSettings">
<property name="title">
<string>PINE Settings</string>
</property>
<layout class="QGridLayout" name="gridLayout_8">
<layout class="QGridLayout" name="pineSettingsLayout">
<item row="1" column="1">
<widget class="QLineEdit" name="pineSlot">
<property name="sizePolicy">
Expand All @@ -488,7 +554,7 @@
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_8">
<widget class="QLabel" name="pineSlotLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
Expand Down
29 changes: 28 additions & 1 deletion pcsx2/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,21 @@ enum class GSDumpCompressionMethod : u8
Zstandard,
};

enum class SavestateCompressionMethod : u8
{
Uncompressed = 0,
Deflate = 1,
Zstandard = 2,
};

enum class SavestateCompressionLevel : u8
{
Low = 0,
Medium = 1,
High = 2,
VeryHigh = 3,
};

enum class GSHardwareDownloadMode : u8
{
Enabled,
Expand Down Expand Up @@ -1129,6 +1144,18 @@ struct Pcsx2Config
bool operator!=(const AchievementsOptions& right) const;
};

struct SavestateOptions
{
SavestateOptions();
void LoadSave(SettingsWrapper& wrap);

SavestateCompressionMethod CompressionType = SavestateCompressionMethod::Zstandard;
SavestateCompressionLevel CompressionRatio = SavestateCompressionLevel::Medium;

bool operator==(const SavestateOptions& right) const;
bool operator!=(const SavestateOptions& right) const;
};

// ------------------------------------------------------------------------

BITFIELD32()
Expand All @@ -1151,7 +1178,6 @@ struct Pcsx2Config
EnableDiscordPresence : 1, // enables discord rich presence integration
InhibitScreensaver : 1,
BackupSavestate : 1,
SavestateZstdCompression : 1,
McdFolderAutoManage : 1,

HostFs : 1,
Expand All @@ -1166,6 +1192,7 @@ struct Pcsx2Config
ProfilerOptions Profiler;
DebugOptions Debugger;
EmulationSpeedOptions EmulationSpeed;
SavestateOptions Savestate;
SPU2Options SPU2;
DEV9Options DEV9;
USBOptions USB;
Expand Down
Loading

0 comments on commit 774a0e6

Please sign in to comment.