Settings: Add advanced option to set delay for max CD speedup

Affects both seeks and reads.
This commit is contained in:
Stenzek 2025-01-09 19:25:07 +10:00
parent 4449ae7904
commit 40589dcd93
No known key found for this signature in database
4 changed files with 23 additions and 13 deletions

View File

@ -75,7 +75,7 @@ enum : u32
static constexpr u8 INTERRUPT_REGISTER_MASK = 0x1F; static constexpr u8 INTERRUPT_REGISTER_MASK = 0x1F;
static constexpr TickCount INSTANT_SEEK_OR_READ_TICKS = 30000; static constexpr TickCount MIN_SEEK_TICKS = 30000;
enum class Interrupt : u8 enum class Interrupt : u8
{ {
@ -1568,7 +1568,7 @@ u32 CDROM::GetSectorsPerTrack(CDImage::LBA lba)
TickCount CDROM::GetTicksForSeek(CDImage::LBA new_lba, bool ignore_speed_change) TickCount CDROM::GetTicksForSeek(CDImage::LBA new_lba, bool ignore_speed_change)
{ {
if (g_settings.cdrom_seek_speedup == 0) if (g_settings.cdrom_seek_speedup == 0)
return System::ScaleTicksToOverclock(INSTANT_SEEK_OR_READ_TICKS); return System::ScaleTicksToOverclock(g_settings.cdrom_max_speedup_cycles);
u32 ticks = 0; u32 ticks = 0;
@ -1638,7 +1638,7 @@ TickCount CDROM::GetTicksForSeek(CDImage::LBA new_lba, bool ignore_speed_change)
} }
if (g_settings.cdrom_seek_speedup > 1) if (g_settings.cdrom_seek_speedup > 1)
ticks = std::max<u32>(ticks / g_settings.cdrom_seek_speedup, INSTANT_SEEK_OR_READ_TICKS); ticks = std::max<u32>(ticks / g_settings.cdrom_seek_speedup, MIN_SEEK_TICKS);
if (s_state.drive_state == DriveState::ChangingSpeedOrTOCRead && !ignore_speed_change) if (s_state.drive_state == DriveState::ChangingSpeedOrTOCRead && !ignore_speed_change)
{ {
@ -1667,7 +1667,7 @@ TickCount CDROM::GetTicksForPause()
return 7000; return 7000;
if (g_settings.cdrom_read_speedup == 0 && CanUseReadSpeedup()) if (g_settings.cdrom_read_speedup == 0 && CanUseReadSpeedup())
return System::ScaleTicksToOverclock(INSTANT_SEEK_OR_READ_TICKS); return System::ScaleTicksToOverclock(g_settings.cdrom_max_speedup_cycles);
const u32 sectors_per_track = GetSectorsPerTrack(s_state.current_lba); const u32 sectors_per_track = GetSectorsPerTrack(s_state.current_lba);
const TickCount ticks_per_read = GetTicksForRead(); const TickCount ticks_per_read = GetTicksForRead();
@ -2813,7 +2813,7 @@ void CDROM::BeginSeeking(bool logical, bool read_after_seek, bool play_after_see
{ {
DEV_COLOR_LOG(StrongCyan, "Completing seek instantly due to not passing target {}.", DEV_COLOR_LOG(StrongCyan, "Completing seek instantly due to not passing target {}.",
LBAToMSFString(seek_lba - SUBQ_SECTOR_SKEW)); LBAToMSFString(seek_lba - SUBQ_SECTOR_SKEW));
seek_time = INSTANT_SEEK_OR_READ_TICKS; seek_time = MIN_SEEK_TICKS;
} }
else else
{ {
@ -3901,7 +3901,7 @@ void CDROM::CheckForSectorBufferReadComplete()
CanUseReadSpeedup() && g_settings.cdrom_read_speedup == 0) CanUseReadSpeedup() && g_settings.cdrom_read_speedup == 0)
{ {
const TickCount remaining_time = s_state.drive_event.GetTicksUntilNextExecution(); const TickCount remaining_time = s_state.drive_event.GetTicksUntilNextExecution();
const TickCount instant_ticks = System::ScaleTicksToOverclock(INSTANT_SEEK_OR_READ_TICKS); const TickCount instant_ticks = System::ScaleTicksToOverclock(g_settings.cdrom_max_speedup_cycles);
if (remaining_time > instant_ticks) if (remaining_time > instant_ticks)
s_state.drive_event.Schedule(instant_ticks); s_state.drive_event.Schedule(instant_ticks);
} }

View File

@ -357,6 +357,7 @@ void Settings::Load(const SettingsInterface& si, const SettingsInterface& contro
Truncate8(std::min<u32>(si.GetUIntValue("CDROM", "ReadSpeedup", 1u), std::numeric_limits<u8>::max())); Truncate8(std::min<u32>(si.GetUIntValue("CDROM", "ReadSpeedup", 1u), std::numeric_limits<u8>::max()));
cdrom_seek_speedup = cdrom_seek_speedup =
Truncate8(std::min<u32>(si.GetUIntValue("CDROM", "SeekSpeedup", 1u), std::numeric_limits<u8>::max())); Truncate8(std::min<u32>(si.GetUIntValue("CDROM", "SeekSpeedup", 1u), std::numeric_limits<u8>::max()));
cdrom_max_speedup_cycles = si.GetUIntValue("CDROM", "MaxSpeedupCycles", DEFAULT_CDROM_MAX_SPEEDUP_CYCLES);
audio_backend = audio_backend =
AudioStream::ParseBackendName( AudioStream::ParseBackendName(
@ -377,7 +378,7 @@ void Settings::Load(const SettingsInterface& si, const SettingsInterface& contro
dma_max_slice_ticks = si.GetIntValue("Hacks", "DMAMaxSliceTicks", DEFAULT_DMA_MAX_SLICE_TICKS); dma_max_slice_ticks = si.GetIntValue("Hacks", "DMAMaxSliceTicks", DEFAULT_DMA_MAX_SLICE_TICKS);
dma_halt_ticks = si.GetIntValue("Hacks", "DMAHaltTicks", DEFAULT_DMA_HALT_TICKS); dma_halt_ticks = si.GetIntValue("Hacks", "DMAHaltTicks", DEFAULT_DMA_HALT_TICKS);
gpu_fifo_size = static_cast<u32>(si.GetIntValue("Hacks", "GPUFIFOSize", DEFAULT_GPU_FIFO_SIZE)); gpu_fifo_size = si.GetUIntValue("Hacks", "GPUFIFOSize", DEFAULT_GPU_FIFO_SIZE);
gpu_max_run_ahead = si.GetIntValue("Hacks", "GPUMaxRunAhead", DEFAULT_GPU_MAX_RUN_AHEAD); gpu_max_run_ahead = si.GetIntValue("Hacks", "GPUMaxRunAhead", DEFAULT_GPU_MAX_RUN_AHEAD);
bios_tty_logging = si.GetBoolValue("BIOS", "TTYLogging", false); bios_tty_logging = si.GetBoolValue("BIOS", "TTYLogging", false);
@ -650,8 +651,9 @@ void Settings::Save(SettingsInterface& si, bool ignore_base) const
si.SetBoolValue("CDROM", "LoadImageToRAM", cdrom_load_image_to_ram); si.SetBoolValue("CDROM", "LoadImageToRAM", cdrom_load_image_to_ram);
si.SetBoolValue("CDROM", "LoadImagePatches", cdrom_load_image_patches); si.SetBoolValue("CDROM", "LoadImagePatches", cdrom_load_image_patches);
si.SetBoolValue("CDROM", "MuteCDAudio", cdrom_mute_cd_audio); si.SetBoolValue("CDROM", "MuteCDAudio", cdrom_mute_cd_audio);
si.SetIntValue("CDROM", "ReadSpeedup", cdrom_read_speedup); si.SetUIntValue("CDROM", "ReadSpeedup", cdrom_read_speedup);
si.SetIntValue("CDROM", "SeekSpeedup", cdrom_seek_speedup); si.SetUIntValue("CDROM", "SeekSpeedup", cdrom_seek_speedup);
si.SetUIntValue("CDROM", "MaxSpeedupCycles", cdrom_max_speedup_cycles);
si.SetStringValue("Audio", "Backend", AudioStream::GetBackendName(audio_backend)); si.SetStringValue("Audio", "Backend", AudioStream::GetBackendName(audio_backend));
si.SetStringValue("Audio", "Driver", audio_driver.c_str()); si.SetStringValue("Audio", "Driver", audio_driver.c_str());

View File

@ -301,6 +301,8 @@ struct Settings : public GPUSettings
u8 cdrom_read_speedup = 1; u8 cdrom_read_speedup = 1;
u8 cdrom_seek_speedup = 1; u8 cdrom_seek_speedup = 1;
u32 cdrom_max_speedup_cycles = DEFAULT_CDROM_MAX_SPEEDUP_CYCLES;
u8 cdrom_readahead_sectors = DEFAULT_CDROM_READAHEAD_SECTORS; u8 cdrom_readahead_sectors = DEFAULT_CDROM_READAHEAD_SECTORS;
CDROMMechaconVersion cdrom_mechacon_version = DEFAULT_CDROM_MECHACON_VERSION; CDROMMechaconVersion cdrom_mechacon_version = DEFAULT_CDROM_MECHACON_VERSION;
@ -557,6 +559,7 @@ struct Settings : public GPUSettings
#endif #endif
static constexpr u8 DEFAULT_CDROM_READAHEAD_SECTORS = 8; static constexpr u8 DEFAULT_CDROM_READAHEAD_SECTORS = 8;
static constexpr u32 DEFAULT_CDROM_MAX_SPEEDUP_CYCLES = 30000;
static constexpr CDROMMechaconVersion DEFAULT_CDROM_MECHACON_VERSION = CDROMMechaconVersion::VC1A; static constexpr CDROMMechaconVersion DEFAULT_CDROM_MECHACON_VERSION = CDROMMechaconVersion::VC1A;
static constexpr ControllerType DEFAULT_CONTROLLER_1_TYPE = ControllerType::AnalogController; static constexpr ControllerType DEFAULT_CONTROLLER_1_TYPE = ControllerType::AnalogController;

View File

@ -275,6 +275,8 @@ void AdvancedSettingsWidget::addTweakOptions()
Settings::ParseCDROMMechVersionName, Settings::GetCDROMMechVersionName, Settings::ParseCDROMMechVersionName, Settings::GetCDROMMechVersionName,
Settings::GetCDROMMechVersionDisplayName, static_cast<u8>(CDROMMechaconVersion::Count), Settings::GetCDROMMechVersionDisplayName, static_cast<u8>(CDROMMechaconVersion::Count),
Settings::DEFAULT_CDROM_MECHACON_VERSION); Settings::DEFAULT_CDROM_MECHACON_VERSION);
addIntRangeTweakOption(m_dialog, m_ui.tweakOptionTable, tr("CD-ROM Max Speedup Read/Seek Cycles"), "CDROM",
"MaxSpeedupCycles", 0, 1000000, Settings::DEFAULT_CDROM_MAX_SPEEDUP_CYCLES);
addBooleanTweakOption(m_dialog, m_ui.tweakOptionTable, tr("CD-ROM Region Check"), "CDROM", "RegionCheck", false); addBooleanTweakOption(m_dialog, m_ui.tweakOptionTable, tr("CD-ROM Region Check"), "CDROM", "RegionCheck", false);
addBooleanTweakOption(m_dialog, m_ui.tweakOptionTable, tr("CD-ROM SubQ Skew"), "CDROM", "SubQSkew", false); addBooleanTweakOption(m_dialog, m_ui.tweakOptionTable, tr("CD-ROM SubQ Skew"), "CDROM", "SubQSkew", false);
addBooleanTweakOption(m_dialog, m_ui.tweakOptionTable, tr("Allow Booting Without SBI File"), "CDROM", addBooleanTweakOption(m_dialog, m_ui.tweakOptionTable, tr("Allow Booting Without SBI File"), "CDROM",
@ -317,10 +319,12 @@ void AdvancedSettingsWidget::onResetToDefaultClicked()
Settings::DEFAULT_CPU_FASTMEM_MODE); // Recompiler fastmem mode Settings::DEFAULT_CPU_FASTMEM_MODE); // Recompiler fastmem mode
setChoiceTweakOption(m_ui.tweakOptionTable, i++, setChoiceTweakOption(m_ui.tweakOptionTable, i++,
Settings::DEFAULT_CDROM_MECHACON_VERSION); // CDROM Mechacon Version Settings::DEFAULT_CDROM_MECHACON_VERSION); // CDROM Mechacon Version
setBooleanTweakOption(m_ui.tweakOptionTable, i++, false); // CDROM Region Check setIntRangeTweakOption(m_ui.tweakOptionTable, i++,
setBooleanTweakOption(m_ui.tweakOptionTable, i++, false); // CDROM SubQ Skew Settings::DEFAULT_CDROM_MAX_SPEEDUP_CYCLES); // CD-ROM Max Speedup Read/Seek Cycles
setBooleanTweakOption(m_ui.tweakOptionTable, i++, false); // Allow booting without SBI file setBooleanTweakOption(m_ui.tweakOptionTable, i++, false); // CDROM Region Check
setBooleanTweakOption(m_ui.tweakOptionTable, i++, false); // Enable GDB Server setBooleanTweakOption(m_ui.tweakOptionTable, i++, false); // CDROM SubQ Skew
setBooleanTweakOption(m_ui.tweakOptionTable, i++, false); // Allow booting without SBI file
setBooleanTweakOption(m_ui.tweakOptionTable, i++, false); // Enable GDB Server
setIntRangeTweakOption(m_ui.tweakOptionTable, i++, Settings::DEFAULT_GDB_SERVER_PORT); // GDB Server Port setIntRangeTweakOption(m_ui.tweakOptionTable, i++, Settings::DEFAULT_GDB_SERVER_PORT); // GDB Server Port
setBooleanTweakOption(m_ui.tweakOptionTable, i++, false); // Export Shared Memory setBooleanTweakOption(m_ui.tweakOptionTable, i++, false); // Export Shared Memory
setBooleanTweakOption(m_ui.tweakOptionTable, i++, false); // Enable PCDRV setBooleanTweakOption(m_ui.tweakOptionTable, i++, false); // Enable PCDRV
@ -349,6 +353,7 @@ void AdvancedSettingsWidget::onResetToDefaultClicked()
sif->DeleteValue("CPU", "RecompilerBlockLinking"); sif->DeleteValue("CPU", "RecompilerBlockLinking");
sif->DeleteValue("CPU", "FastmemMode"); sif->DeleteValue("CPU", "FastmemMode");
sif->DeleteValue("CDROM", "MechaconVersion"); sif->DeleteValue("CDROM", "MechaconVersion");
sif->DeleteValue("CDROM", "MaxSpeedupCycles");
sif->DeleteValue("CDROM", "RegionCheck"); sif->DeleteValue("CDROM", "RegionCheck");
sif->DeleteValue("CDROM", "SubQSkew"); sif->DeleteValue("CDROM", "SubQSkew");
sif->DeleteValue("CDROM", "AllowBootingWithoutSBIFile"); sif->DeleteValue("CDROM", "AllowBootingWithoutSBIFile");