Add a core option to increase the CD loading speed

This commit is contained in:
Lionel Flandrin 2017-10-08 23:04:32 +02:00
parent b0ae7dd646
commit 82f449bcd6
3 changed files with 32 additions and 5 deletions

View File

@ -44,6 +44,7 @@ static bool crop_overscan = false;
static bool enable_memcard1 = false;
static bool enable_analog_calibration = false;
static bool enable_variable_serialization_size = false;
unsigned cd_2x_speedup = 1;
// Sets how often (in number of output frames/retro_run invocations)
// the internal framerace counter should be updated if
@ -3008,6 +3009,23 @@ static void check_variables(bool startup)
image_crop = 8;
}
var.key = option_cd_fastload;
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
{
uint8_t val = var.value[0] - '0';
if (var.value[1] != 'x')
{
val = (var.value[0] - '0') * 10;
val += var.value[1] - '0';
}
// Value is a multiplier from the native 1x, so we divide by two
cd_2x_speedup = val / 2;
}
else
cd_2x_speedup = 1;
}
#ifdef NEED_CD
@ -4146,6 +4164,7 @@ void retro_set_environment(retro_environment_t cb)
{ option_memcard0_method, "Memcard 0 method; libretro|mednafen" },
{ option_memcard1_enable, "Enable memory card 1; enabled|disabled" },
{ option_memcard_shared, "Shared memcards (restart); disabled|enabled" },
{ option_cd_fastload, "Increase CD loading speed; 2x (native)|4x|6x|8x|10x|12x|14x" },
{ NULL, NULL },
};
static const struct retro_controller_description pads[] = {

View File

@ -46,6 +46,7 @@
#define option_memcard0_method "beetle_psx_hw_use_mednafen_memcard0_method"
#define option_memcard1_enable "beetle_psx_hw_enable_memcard1"
#define option_memcard_shared "beetle_psx_hw_shared_memory_cards"
#define option_cd_fastload "beetle_psx_hw_cd_fastload"
#else
#define option_renderer "beetle_psx_renderer"
#define option_renderer_software_fb "beetle_psx_renderer_software_fb"
@ -80,4 +81,5 @@
#define option_memcard0_method "beetle_psx_use_mednafen_memcard0_method"
#define option_memcard1_enable "beetle_psx_enable_memcard1"
#define option_memcard_shared "beetle_psx_shared_memory_cards"
#define option_cd_fastload "beetle_psx_cd_fastload"
#endif

View File

@ -67,6 +67,8 @@ PS_CDC::PS_CDC() : DMABuffer(4096)
#endif
}
extern unsigned cd_2x_speedup;
PS_CDC::~PS_CDC()
{
@ -859,7 +861,7 @@ void PS_CDC::EnbufferizeCDDASector(const uint8 *buf)
{
CD_Audio_Buffer *ab = &AudioBuffer;
ab->Freq = 7 * ((Mode & MODE_SPEED) ? 2 : 1);
ab->Freq = 7 * ((Mode & MODE_SPEED) ? (2 * cd_2x_speedup) : 1);
ab->Size = 588;
if(SubQBuf_Safe[0] & 0x40)
@ -1050,7 +1052,7 @@ void PS_CDC::HandlePlayRead(void)
SectorPipe_Pos = (SectorPipe_Pos + 1) % SectorPipe_Count;
SectorPipe_In++;
PSRCounter += 33868800 / (75 * ((Mode & MODE_SPEED) ? 2 : 1));
PSRCounter += 33868800 / (75 * ((Mode & MODE_SPEED) ? (2 * cd_2x_speedup) : 1));
if(DriveStatus == DS_PLAYING)
{
@ -1160,7 +1162,7 @@ int32_t PS_CDC::Update(const int32_t timestamp)
DriveStatus = StatusAfterSeek;
if(DriveStatus != DS_PAUSED && DriveStatus != DS_STANDBY)
PSRCounter = 33868800 / (75 * ((Mode & MODE_SPEED) ? 2 : 1));
PSRCounter = 33868800 / (75 * ((Mode & MODE_SPEED) ? (2 * cd_2x_speedup) : 1));
}
break;
case DS_SEEKING_LOGICAL:
@ -1188,7 +1190,7 @@ int32_t PS_CDC::Update(const int32_t timestamp)
DriveStatus = StatusAfterSeek;
if(DriveStatus != DS_PAUSED && DriveStatus != DS_STANDBY)
PSRCounter = 33868800 / (75 * ((Mode & MODE_SPEED) ? 2 : 1));
PSRCounter = 33868800 / (75 * ((Mode & MODE_SPEED) ? (2 * cd_2x_speedup) : 1));
}
}
break;
@ -1617,7 +1619,11 @@ int32 PS_CDC::CalcSeekTime(int32 initial, int32 target, bool motor_on, bool paus
//else
{
// Take twice as long for 1x mode.
ret += 1237952 * ((Mode & MODE_SPEED) ? 1 : 2);
if (Mode & MODE_SPEED) {
ret += 1237952 / cd_2x_speedup;
} else {
ret += 1237952 * 2;
}
}
}
//else if(target < initial)