Skip to content

Commit

Permalink
blacklist underclocking settings in hardcore (#374)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamiras authored Oct 7, 2024
1 parent b8dd574 commit 8d49c28
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 1 deletion.
36 changes: 36 additions & 0 deletions src/rc_libretro.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,17 @@ typedef struct rc_disallowed_core_settings_t
const rc_disallowed_setting_t* disallowed_settings;
} rc_disallowed_core_settings_t;


static const rc_disallowed_setting_t _rc_disallowed_beetle_psx_settings[] = {
{ "beetle_psx_cpu_freq_scale", "<100" },
{ NULL, NULL }
};

static const rc_disallowed_setting_t _rc_disallowed_beetle_psx_hw_settings[] = {
{ "beetle_psx_hw_cpu_freq_scale", "<100" },
{ NULL, NULL }
};

static const rc_disallowed_setting_t _rc_disallowed_bsnes_settings[] = {
{ "bsnes_region", "pal" },
{ NULL, NULL }
Expand Down Expand Up @@ -80,6 +91,11 @@ static const rc_disallowed_setting_t _rc_disallowed_fceumm_settings[] = {
{ NULL, NULL }
};

static const rc_disallowed_setting_t _rc_disallowed_flycast_settings[] = {
{ "reicast_sh4clock", "<200" },
{ NULL, NULL }
};

static const rc_disallowed_setting_t _rc_disallowed_gpgx_settings[] = {
{ "genesis_plus_gx_lock_on", ",action replay (pro),game genie" },
{ "genesis_plus_gx_region_detect", "pal" },
Expand Down Expand Up @@ -108,6 +124,7 @@ static const rc_disallowed_setting_t _rc_disallowed_neocd_settings[] = {
};

static const rc_disallowed_setting_t _rc_disallowed_pcsx_rearmed_settings[] = {
{ "pcsx_rearmed_psxclock", "<55" },
{ "pcsx_rearmed_region", "pal" },
{ NULL, NULL }
};
Expand Down Expand Up @@ -140,6 +157,11 @@ static const rc_disallowed_setting_t _rc_disallowed_snes9x_settings[] = {
{ NULL, NULL }
};

static const rc_disallowed_setting_t _rc_disallowed_swanstation_settings[] = {
{ "swanstation_CPU_Overclock", "<100" },
{ NULL, NULL }
};

static const rc_disallowed_setting_t _rc_disallowed_vice_settings[] = {
{ "vice_autostart", "disabled" }, /* autostart dictates initial load and reset from menu */
{ "vice_reset", "!autostart" }, /* reset dictates behavior when pressing reset button (END) */
Expand All @@ -152,6 +174,8 @@ static const rc_disallowed_setting_t _rc_disallowed_virtual_jaguar_settings[] =
};

static const rc_disallowed_core_settings_t rc_disallowed_core_settings[] = {
{ "Beetle PSX", _rc_disallowed_beetle_psx_settings },
{ "Beetle PSX HW", _rc_disallowed_beetle_psx_hw_settings },
{ "bsnes-mercury", _rc_disallowed_bsnes_settings },
{ "cap32", _rc_disallowed_cap32_settings },
{ "dolphin-emu", _rc_disallowed_dolphin_settings },
Expand All @@ -160,6 +184,7 @@ static const rc_disallowed_core_settings_t rc_disallowed_core_settings[] = {
{ "ecwolf", _rc_disallowed_ecwolf_settings },
{ "FCEUmm", _rc_disallowed_fceumm_settings },
{ "FinalBurn Neo", _rc_disallowed_fbneo_settings },
{ "Flycast", _rc_disallowed_flycast_settings },
{ "Genesis Plus GX", _rc_disallowed_gpgx_settings },
{ "Genesis Plus GX Wide", _rc_disallowed_gpgx_wide_settings },
{ "Mesen", _rc_disallowed_mesen_settings },
Expand All @@ -171,6 +196,7 @@ static const rc_disallowed_core_settings_t rc_disallowed_core_settings[] = {
{ "QUASI88", _rc_disallowed_quasi88_settings },
{ "SMS Plus GX", _rc_disallowed_smsplus_settings },
{ "Snes9x", _rc_disallowed_snes9x_settings },
{ "SwanStation", _rc_disallowed_swanstation_settings },
{ "VICE x64", _rc_disallowed_vice_settings },
{ "Virtual Jaguar", _rc_disallowed_virtual_jaguar_settings },
{ NULL, NULL }
Expand All @@ -186,6 +212,12 @@ static int rc_libretro_string_equal_nocase_wildcard(const char* test, const char
return (*value == '\0');
}

static int rc_libretro_numeric_less_than(const char* test, const char* value) {
int test_num = atoi(test);
int value_num = atoi(value);
return (test_num < value_num);
}

static int rc_libretro_match_value(const char* val, const char* match) {
/* if value starts with a comma, it's a CSV list of potential matches */
if (*match == ',') {
Expand Down Expand Up @@ -218,6 +250,10 @@ static int rc_libretro_match_value(const char* val, const char* match) {
if (*match == '!')
return !rc_libretro_match_value(val, &match[1]);

/* a leading less tahn means the provided value is the minimum allowed */
if (*match == '<')
return rc_libretro_numeric_less_than(val, &match[1]);

/* just a single value, attempt to match it */
return rc_libretro_string_equal_nocase_wildcard(val, match);
}
Expand Down
27 changes: 26 additions & 1 deletion test/test_rc_libretro.c
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,16 @@ void test_rc_libretro(void) {
TEST_SUITE_BEGIN();

/* rc_libretro_disallowed_settings */
TEST_PARAMS3(test_allowed_setting, "Beetle PSX", "beetle_psx_cpu_freq_scale", "750%");
TEST_PARAMS3(test_allowed_setting, "Beetle PSX", "beetle_psx_cpu_freq_scale", "100%(native)");
TEST_PARAMS3(test_disallowed_setting, "Beetle PSX", "beetle_psx_cpu_freq_scale", "99%");
TEST_PARAMS3(test_disallowed_setting, "Beetle PSX", "beetle_psx_cpu_freq_scale", "50%");

TEST_PARAMS3(test_allowed_setting, "Beetle PSX HW", "beetle_psx_hw_cpu_freq_scale", "750%");
TEST_PARAMS3(test_allowed_setting, "Beetle PSX HW", "beetle_psx_hw_cpu_freq_scale", "100%(native)");
TEST_PARAMS3(test_disallowed_setting, "Beetle PSX HW", "beetle_psx_hw_cpu_freq_scale", "99%");
TEST_PARAMS3(test_disallowed_setting, "Beetle PSX HW", "beetle_psx_hw_cpu_freq_scale", "50%");

TEST_PARAMS3(test_allowed_setting, "bsnes-mercury", "bsnes_region", "Auto");
TEST_PARAMS3(test_allowed_setting, "bsnes-mercury", "bsnes_region", "NTSC");
TEST_PARAMS3(test_disallowed_setting, "bsnes-mercury", "bsnes_region", "PAL");
Expand All @@ -724,6 +734,11 @@ void test_rc_libretro(void) {
TEST_PARAMS3(test_disallowed_setting, "FCEUmm", "fceumm_region", "Dendy");
TEST_PARAMS3(test_allowed_setting, "FCEUmm", "fceumm_palette", "default"); /* setting we don't care about */

TEST_PARAMS3(test_allowed_setting, "Flycast", "reicast_sh4clock", "500");
TEST_PARAMS3(test_allowed_setting, "Flycast", "reicast_sh4clock", "200");
TEST_PARAMS3(test_disallowed_setting, "Flycast", "reicast_sh4clock", "190");
TEST_PARAMS3(test_disallowed_setting, "Flycast", "reicast_sh4clock", "50");

TEST_PARAMS3(test_allowed_setting, "FinalBurn Neo", "fbneo-allow-patched-romsets", "disabled");
TEST_PARAMS3(test_disallowed_setting, "FinalBurn Neo", "fbneo-allow-patched-romsets", "enabled");
TEST_PARAMS3(test_allowed_setting, "FinalBurn Neo", "fbneo-cheat-mvsc-P1_Char_1_Easy_Hyper_Combo", "disabled"); /* wildcard key match */
Expand Down Expand Up @@ -781,7 +796,12 @@ void test_rc_libretro(void) {
TEST_PARAMS3(test_allowed_setting, "PCSX-ReARMed", "pcsx_rearmed_region", "Auto");
TEST_PARAMS3(test_allowed_setting, "PCSX-ReARMed", "pcsx_rearmed_region", "NTSC");
TEST_PARAMS3(test_disallowed_setting, "PCSX-ReARMed", "pcsx_rearmed_region", "PAL");

TEST_PARAMS3(test_allowed_setting, "PCSX-ReARMed", "pcsx_rearmed_psxclock", "100");
TEST_PARAMS3(test_allowed_setting, "PCSX-ReARMed", "pcsx_rearmed_psxclock", "57");
TEST_PARAMS3(test_allowed_setting, "PCSX-ReARMed", "pcsx_rearmed_psxclock", "55");
TEST_PARAMS3(test_disallowed_setting, "PCSX-ReARMed", "pcsx_rearmed_psxclock", "54");
TEST_PARAMS3(test_disallowed_setting, "PCSX-ReARMed", "pcsx_rearmed_psxclock", "30");

TEST_PARAMS3(test_allowed_setting, "PicoDrive", "picodrive_region", "Auto");
TEST_PARAMS3(test_allowed_setting, "PicoDrive", "picodrive_region", "US");
TEST_PARAMS3(test_allowed_setting, "PicoDrive", "picodrive_region", "Japan NTSC");
Expand Down Expand Up @@ -811,6 +831,11 @@ void test_rc_libretro(void) {
TEST_PARAMS3(test_allowed_setting, "Snes9x", "snes9x_layer_5", "enabled");
TEST_PARAMS3(test_disallowed_setting, "Snes9x", "snes9x_layer_5", "disabled");

TEST_PARAMS3(test_allowed_setting, "SwanStation", "swanstation_CPU_Overclock", "1000");
TEST_PARAMS3(test_allowed_setting, "SwanStation", "swanstation_CPU_Overclock", "100");
TEST_PARAMS3(test_disallowed_setting, "SwanStation", "swanstation_CPU_Overclock", "99");
TEST_PARAMS3(test_disallowed_setting, "SwanStation", "swanstation_CPU_Overclock", "50");

TEST_PARAMS3(test_allowed_setting, "VICE x64", "vice_autostart", "enabled");
TEST_PARAMS3(test_disallowed_setting, "VICE x64", "vice_autostart", "disabled");
TEST_PARAMS3(test_allowed_setting, "VICE x64", "vice_autostart", "warp");
Expand Down

0 comments on commit 8d49c28

Please sign in to comment.