LIBRETRO: remove need to restart to enable settings

This commit is contained in:
Giovanni Cascione 2023-03-25 16:18:24 +01:00
parent 737ff66cd3
commit ba1567f7d6
5 changed files with 25 additions and 19 deletions

View File

@ -194,7 +194,7 @@ struct retro_core_option_v2_definition option_defs_it[] = {
},
{
"scummvm_allow_timing_inaccuracies",
"Consenti inaccuratezze di timing (riavvio necessario)",
"Consenti inaccuratezze di timing",
NULL,
"Consente inaccuratezze di timing che riducono significativamente le richeste di CPU. Anche se la maggior parte delle inaccuratezze sono impercettibili, in alcuni casi potrebbe introdurre problemi di sincronizzazione audio, quindi questa opzione andrebbe abilitata solo se il raggiungimento della piena velocità non è possibile in altro modo.",
NULL,

View File

@ -259,7 +259,7 @@ struct retro_core_option_v2_definition option_defs_us[] = {
},
{
"scummvm_allow_timing_inaccuracies",
"Allow Timing Inaccuracies (Restart)",
"Allow Timing Inaccuracies",
NULL,
"Allow timing inaccuracies that reduces CPU requirements. Though most timing deviations are imperceptible, in some cases it may introduce audio sync/timing issues, hence this option should be enabled only if full speed cannot be reached otherwise.",
NULL,

View File

@ -71,7 +71,7 @@ extern char cmd_params_num;
extern int access(const char *path, int amode);
#endif
OSystem *retroBuildOS(bool aEnableSpeedHack);
OSystem *retroBuildOS();
const Graphics::Surface &getScreen();
void retroProcessMouse(retro_input_state_t aCallback, int device, float gamepad_cursor_speed, float gamepad_acceleration_time, bool analog_response_is_quadratic, int analog_deadzone, float mouse_speed);

View File

@ -319,6 +319,8 @@ static Common::String s_saveDir;
Common::List<Common::Event> _events;
extern bool timing_inaccuracies_is_enabled(void);
class OSystem_RETRO : public EventsBaseBackend, public PaletteManager {
public:
Graphics::Surface _screen;
@ -359,11 +361,9 @@ public:
uint32 _threadExitTime;
uint8 _threadSwitchCaller;
bool _speed_hack_enabled;
Audio::MixerImpl *_mixer;
OSystem_RETRO(bool aEnableSpeedHack) : _mousePaletteEnabled(false), _mouseVisible(false), _mouseX(0), _mouseY(0), _mouseXAcc(0.0), _mouseYAcc(0.0), _mouseHotspotX(0), _mouseHotspotY(0), _dpadXAcc(0.0), _dpadYAcc(0.0), _dpadXVel(0.0f), _dpadYVel(0.0f), _mouseKeyColor(0), _mouseDontScale(false), _joypadnumpadLast(8), _joypadnumpadActive(false), _mixer(0), _startTime(0), _threadExitTime(0), _threadSwitchCaller(0), _speed_hack_enabled(aEnableSpeedHack) {
OSystem_RETRO() : _mousePaletteEnabled(false), _mouseVisible(false), _mouseX(0), _mouseY(0), _mouseXAcc(0.0), _mouseYAcc(0.0), _mouseHotspotX(0), _mouseHotspotY(0), _dpadXAcc(0.0), _dpadYAcc(0.0), _dpadXVel(0.0f), _dpadYVel(0.0f), _mouseKeyColor(0), _mouseDontScale(false), _joypadnumpadLast(8), _joypadnumpadActive(false), _mixer(0), _startTime(0), _threadExitTime(0), _threadSwitchCaller(0) {
_fsFactory = new FS_SYSTEM_FACTORY();
memset(_mouseButtons, 0, sizeof(_mouseButtons));
memset(_joypadmouseButtons, 0, sizeof(_joypadmouseButtons));
@ -501,7 +501,7 @@ public:
/* In a series of consecutive updateScreen calls, additionally switch directly to main thread when
(and if) first copyRectToScreen is called between two updateScreen. This reduces audio crackling.
Consecutive copyRectToScreen other than first are covered by thread switch triggered by pollEvent or delayMillis. */
if (! _speed_hack_enabled) {
if (! timing_inaccuracies_is_enabled()) {
if (!(_threadSwitchCaller & THREAD_SWITCH_RECT) && (_threadSwitchCaller & THREAD_SWITCH_UPDATE)) {
retro_switch_to_main_thread();
_threadSwitchCaller |= THREAD_SWITCH_RECT;
@ -547,11 +547,13 @@ public:
/* Switch directly to main thread in case of consecutive updateScreen, to avoid losing frames.
Non consecutive updateScreen are covered by thread switches triggered by pollEvent or delayMillis. */
if (! _speed_hack_enabled && (_threadSwitchCaller & THREAD_SWITCH_UPDATE)) {
retro_switch_to_main_thread();
_threadSwitchCaller &= ~THREAD_SWITCH_RECT;
} else {
_threadSwitchCaller = THREAD_SWITCH_UPDATE;
if (! timing_inaccuracies_is_enabled()) {
if (_threadSwitchCaller & THREAD_SWITCH_UPDATE) {
retro_switch_to_main_thread();
_threadSwitchCaller &= ~THREAD_SWITCH_RECT;
} else {
_threadSwitchCaller = THREAD_SWITCH_UPDATE;
}
}
}
@ -686,7 +688,7 @@ public:
// Implement 'non-blocking' sleep...
uint32 start_time = getMillis();
if (_speed_hack_enabled) {
if (timing_inaccuracies_is_enabled()) {
// Use janky inaccurate method...
uint32 elapsed_time = 0;
uint32 time_remaining = msecs;
@ -1289,8 +1291,8 @@ public:
};
OSystem *retroBuildOS(bool aEnableSpeedHack) {
return new OSystem_RETRO(aEnableSpeedHack);
OSystem *retroBuildOS() {
return new OSystem_RETRO();
}
const Graphics::Surface &getScreen() {

View File

@ -72,7 +72,7 @@ static bool analog_response_is_quadratic = false;
static float mouse_speed = 1.0f;
static float gamepad_acceleration_time = 0.2f;
static bool speed_hack_is_enabled = false;
static bool timing_inaccuracies_enabled = false;
char cmd_params[20][200];
char cmd_params_num;
@ -178,10 +178,10 @@ static void update_variables(void) {
var.key = "scummvm_allow_timing_inaccuracies";
var.value = NULL;
speed_hack_is_enabled = false;
timing_inaccuracies_enabled = false;
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) {
if (strcmp(var.value, "enabled") == 0)
speed_hack_is_enabled = true;
timing_inaccuracies_enabled = true;
}
var.key = "scummvm_frameskip_threshold";
@ -215,6 +215,10 @@ static void update_variables(void) {
}
}
bool timing_inaccuracies_is_enabled(){
return timing_inaccuracies_enabled;
}
void parse_command_params(char *cmdline) {
int j = 0;
int cmdlen = strlen(cmdline);
@ -441,7 +445,7 @@ void retro_init(void) {
retroSetSaveDir(".");
}
g_system = retroBuildOS(speed_hack_is_enabled);
g_system = retroBuildOS();
}
void retro_deinit(void) {