[core, frontend] Add Custom CPU Ticks option (#217)
All checks were successful
eden-build / source (push) Successful in 3m26s
eden-build / linux (push) Successful in 21m54s
eden-build / android (push) Successful in 25m34s
eden-build / windows (msvc) (push) Successful in 30m51s

Co-authored-by: Gamer64 <76565986+Gamer64ytb@users.noreply.github.com>
Co-authored-by: crueter <swurl@swurl.xyz>
Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/217
This commit is contained in:
Gamer64 2025-06-27 13:45:54 +00:00
parent e7ddc647f3
commit 059d89441e
9 changed files with 55 additions and 3 deletions

View file

@ -16,6 +16,7 @@ enum class BooleanSetting(override val key: String) : AbstractBooleanSetting {
CORE_SYNC_CORE_SPEED("sync_core_speed"), CORE_SYNC_CORE_SPEED("sync_core_speed"),
RENDERER_USE_SPEED_LIMIT("use_speed_limit"), RENDERER_USE_SPEED_LIMIT("use_speed_limit"),
USE_FAST_CPU_TIME("use_fast_cpu_time"), USE_FAST_CPU_TIME("use_fast_cpu_time"),
USE_CUSTOM_CPU_TICKS("use_custom_cpu_ticks"),
USE_DOCKED_MODE("use_docked_mode"), USE_DOCKED_MODE("use_docked_mode"),
USE_AUTO_STUB("use_auto_stub"), USE_AUTO_STUB("use_auto_stub"),
RENDERER_USE_DISK_SHADER_CACHE("use_disk_shader_cache"), RENDERER_USE_DISK_SHADER_CACHE("use_disk_shader_cache"),

View file

@ -37,6 +37,7 @@ enum class IntSetting(override val key: String) : AbstractIntSetting {
MEMORY_LAYOUT("memory_layout_mode"), MEMORY_LAYOUT("memory_layout_mode"),
FSR_SHARPENING_SLIDER("fsr_sharpening_slider"), FSR_SHARPENING_SLIDER("fsr_sharpening_slider"),
FAST_CPU_TIME("fast_cpu_time"), FAST_CPU_TIME("fast_cpu_time"),
CPU_TICKS("cpu_ticks"),
FAST_GPU_TIME("fast_gpu_time"), FAST_GPU_TIME("fast_gpu_time"),
CABINET_APPLET("cabinet_applet_mode"), CABINET_APPLET("cabinet_applet_mode"),

View file

@ -580,6 +580,22 @@ abstract class SettingsItem(
valuesId = R.array.clockValues valuesId = R.array.clockValues
) )
) )
put(
SwitchSetting(
BooleanSetting.USE_CUSTOM_CPU_TICKS,
titleId = R.string.custom_cpu_ticks,
descriptionId = R.string.custom_cpu_ticks_description
)
)
put(
SliderSetting(
IntSetting.CPU_TICKS,
titleId = R.string.cpu_ticks,
descriptionId = 0,
min = 77,
max = 65535
)
)
put( put(
SwitchSetting( SwitchSetting(
BooleanSetting.RENDERER_REACTIVE_FLUSHING, BooleanSetting.RENDERER_REACTIVE_FLUSHING,

View file

@ -448,6 +448,8 @@ class SettingsFragmentPresenter(
add(HeaderSetting(R.string.veil_misc)) add(HeaderSetting(R.string.veil_misc))
add(BooleanSetting.USE_FAST_CPU_TIME.key) add(BooleanSetting.USE_FAST_CPU_TIME.key)
add(IntSetting.FAST_CPU_TIME.key) add(IntSetting.FAST_CPU_TIME.key)
add(BooleanSetting.USE_CUSTOM_CPU_TICKS.key)
add(IntSetting.CPU_TICKS.key)
add(BooleanSetting.USE_LRU_CACHE.key) add(BooleanSetting.USE_LRU_CACHE.key)
add(BooleanSetting.CORE_SYNC_CORE_SPEED.key) add(BooleanSetting.CORE_SYNC_CORE_SPEED.key)
add(IntSetting.MEMORY_LAYOUT.key) add(IntSetting.MEMORY_LAYOUT.key)

View file

@ -90,6 +90,9 @@
<string name="use_lru_cache_description">Enable or disable the Least Recently Used (LRU) cache, increasing performance by saving CPU process usage. Some games have issue with it, notably TotK 1.2.1, so disable if the game doesn\'t boot or crashes randomly.</string> <string name="use_lru_cache_description">Enable or disable the Least Recently Used (LRU) cache, increasing performance by saving CPU process usage. Some games have issue with it, notably TotK 1.2.1, so disable if the game doesn\'t boot or crashes randomly.</string>
<string name="use_fast_cpu_time">Fast CPU Time</string> <string name="use_fast_cpu_time">Fast CPU Time</string>
<string name="use_fast_cpu_time_description">Forces the emulated CPU to run at a higher clock, reducing certain FPS limiters. This option is hacky and may cause issues, and weaker CPUs may see reduced performance.</string> <string name="use_fast_cpu_time_description">Forces the emulated CPU to run at a higher clock, reducing certain FPS limiters. This option is hacky and may cause issues, and weaker CPUs may see reduced performance.</string>
<string name="custom_cpu_ticks">Custom CPU Ticks</string>
<string name="custom_cpu_ticks_description">Set a custom value of CPU ticks. Higher values can increase performance, but may also cause the game to freeze. A range of 7721000 is recommended.</string>
<string name="cpu_ticks">Ticks</string>
<string name="fast_cpu_time">CPU Clock</string> <string name="fast_cpu_time">CPU Clock</string>
<string name="fast_cpu_time_description">Use Boost (1700MHz) to run at the Switch\'s highest native clock, or Fast (2000MHz) to run at 2x clock.</string> <string name="fast_cpu_time_description">Use Boost (1700MHz) to run at the Switch\'s highest native clock, or Fast (2000MHz) to run at 2x clock.</string>
<string name="memory_layout">Memory Layout</string> <string name="memory_layout">Memory Layout</string>

View file

@ -259,6 +259,25 @@ struct Values {
true, true,
&use_fast_cpu_time}; &use_fast_cpu_time};
SwitchableSetting<bool> use_custom_cpu_ticks{linkage,
false,
"use_custom_cpu_ticks",
Category::Cpu,
Specialization::Paired,
true,
true};
SwitchableSetting<u32, true> cpu_ticks{linkage,
16000,
77,
65535,
"cpu_ticks",
Category::Cpu,
Specialization::Countable,
true,
true,
&use_custom_cpu_ticks};
SwitchableSetting<bool> cpu_debug_mode{linkage, false, "cpu_debug_mode", Category::CpuDebug}; SwitchableSetting<bool> cpu_debug_mode{linkage, false, "cpu_debug_mode", Category::CpuDebug};
Setting<bool> cpuopt_page_tables{linkage, true, "cpuopt_page_tables", Category::CpuDebug}; Setting<bool> cpuopt_page_tables{linkage, true, "cpuopt_page_tables", Category::CpuDebug};

View file

@ -172,7 +172,9 @@ void CoreTiming::UnscheduleEvent(const std::shared_ptr<EventType>& event_type,
} }
void CoreTiming::AddTicks(u64 ticks_to_add) { void CoreTiming::AddTicks(u64 ticks_to_add) {
cpu_ticks += ticks_to_add; cpu_ticks = Settings::values.use_custom_cpu_ticks.GetValue()
? Settings::values.cpu_ticks.GetValue()
: cpu_ticks + ticks_to_add;
downcount -= static_cast<s64>(cpu_ticks); downcount -= static_cast<s64>(cpu_ticks);
} }

View file

@ -73,8 +73,9 @@ void ConfigureCpu::Setup(const ConfigurationShared::Builder& builder) {
} else if (setting->Id() == Settings::values.cpu_backend.Id()) { } else if (setting->Id() == Settings::values.cpu_backend.Id()) {
backend_layout->addWidget(widget); backend_layout->addWidget(widget);
backend_combobox = widget->combobox; backend_combobox = widget->combobox;
} else if (setting->Id() == Settings::values.fast_cpu_time.Id() } else if (setting->Id() == Settings::values.fast_cpu_time.Id()) {
|| setting->Id() == Settings::values.use_fast_cpu_time.Id()) { ui->general_layout->addWidget(widget);
} else if (setting->Id() == Settings::values.cpu_ticks.Id()) {
ui->general_layout->addWidget(widget); ui->general_layout->addWidget(widget);
} else { } else {
// Presently, all other settings here are unsafe checkboxes // Presently, all other settings here are unsafe checkboxes

View file

@ -106,6 +106,13 @@ std::unique_ptr<TranslationMap> InitializeTranslations(QWidget* parent)
tr("Overclocks the emulated CPU to remove some FPS limiters. Weaker CPUs may see reduced performance, " tr("Overclocks the emulated CPU to remove some FPS limiters. Weaker CPUs may see reduced performance, "
"and certain games may behave improperly.\nUse Boost (1700MHz) to run at the Switch's highest native " "and certain games may behave improperly.\nUse Boost (1700MHz) to run at the Switch's highest native "
"clock, or Fast (2000MHz) to run at 2x clock.")); "clock, or Fast (2000MHz) to run at 2x clock."));
INSERT(Settings, use_custom_cpu_ticks, QString(), QString());
INSERT(Settings,
cpu_ticks,
tr("Custom CPU Ticks"),
tr("Set a custom value of CPU ticks. Higher values can increase performance, but may "
"also cause the game to freeze. A range of 7721000 is recommended."));
INSERT(Settings, cpu_backend, tr("Backend:"), QString()); INSERT(Settings, cpu_backend, tr("Backend:"), QString());
// Cpu Debug // Cpu Debug