add core option to enable/disable turbo buttons

This commit is contained in:
hunterk
2017-02-16 20:30:24 -06:00
parent 5a27aa3374
commit c2a21a1783

View File

@@ -42,6 +42,7 @@ static retro_environment_t environ_cb = NULL;
static bool use_overscan; static bool use_overscan;
static bool use_raw_palette; static bool use_raw_palette;
static bool use_par; static bool use_par;
int turbo_enabler;
/* emulator-specific variables */ /* emulator-specific variables */
@@ -682,6 +683,7 @@ void retro_set_environment(retro_environment_t cb)
{ "fceumm_nospritelimit", "No Sprite Limit; disabled|enabled" }, { "fceumm_nospritelimit", "No Sprite Limit; disabled|enabled" },
{ "fceumm_overclocking", "Overclocking; disabled|2x" }, { "fceumm_overclocking", "Overclocking; disabled|2x" },
{ "fceumm_overscan", "Crop Overscan; enabled|disabled" }, { "fceumm_overscan", "Crop Overscan; enabled|disabled" },
{ "fceumm_turbo_enable", "Turbo Enable; None|Player 1|Player 2|Both" },
{ "fceumm_aspect", "Preferred aspect ratio; 8:7 PAR|4:3" }, { "fceumm_aspect", "Preferred aspect ratio; 8:7 PAR|4:3" },
{ NULL, NULL }, { NULL, NULL },
}; };
@@ -941,6 +943,28 @@ static void check_variables(bool startup)
} }
} }
var.key = "fceumm_turbo_enable";
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
{
if (!strcmp(var.value, "None"))
{
turbo_enabler = 0;
}
else if (!strcmp(var.value, "Player 1"))
{
turbo_enabler = 1;
}
else if (!strcmp(var.value, "Player 2"))
{
turbo_enabler = 2;
}
else if (!strcmp(var.value, "Both"))
{
turbo_enabler = 3;
}
}
var.key = "fceumm_aspect"; var.key = "fceumm_aspect";
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
@@ -978,7 +1002,6 @@ unsigned char turbo_p1_toggle[] = {0,0};
* the slower the frequency i.e. wait time * the slower the frequency i.e. wait time
* between turbo repeats increases * between turbo repeats increases
*/ */
#define TURBO_DELAY 3 #define TURBO_DELAY 3
static void FCEUD_UpdateInput(void) static void FCEUD_UpdateInput(void)
@@ -1008,7 +1031,8 @@ static void FCEUD_UpdateInput(void)
* depending on whether the delay value has * depending on whether the delay value has
* been reached. * been reached.
*/ */
if (turbo_enabler == 1 || turbo_enabler == 3)
{
// Handle turbo buttons - player 1 // Handle turbo buttons - player 1
for ( i = 8; i < 10; i++) { for ( i = 8; i < 10; i++) {
if(input_cb(0, RETRO_DEVICE_JOYPAD, 0, bindmap[i].retro)) { if(input_cb(0, RETRO_DEVICE_JOYPAD, 0, bindmap[i].retro)) {
@@ -1026,7 +1050,9 @@ static void FCEUD_UpdateInput(void)
turbo_p0_toggle[i-8] = 0; turbo_p0_toggle[i-8] = 0;
} }
} }
}
if (turbo_enabler == 2 || turbo_enabler == 3)
{
// Handle turbo buttons - player 2 // Handle turbo buttons - player 2
for ( i = 8; i < 10; i++) { for ( i = 8; i < 10; i++) {
if(input_cb(1, RETRO_DEVICE_JOYPAD, 0, bindmap[i].retro)) { if(input_cb(1, RETRO_DEVICE_JOYPAD, 0, bindmap[i].retro)) {
@@ -1044,6 +1070,7 @@ static void FCEUD_UpdateInput(void)
turbo_p1_toggle[i-8] = 0; turbo_p1_toggle[i-8] = 0;
} }
} }
}
JSReturn[0] = pad[0] | (pad[1] << 8); JSReturn[0] = pad[0] | (pad[1] << 8);