Added toggling turbo on/off via X and Y for A and B respectively in 2 button mode. ignored in 6 button mode. Also added a config option to disable the feature.

This commit is contained in:
jbarfell 2017-01-14 21:38:35 -05:00
parent 0c2f00b775
commit afffa41b65
3 changed files with 32 additions and 2 deletions

View File

@ -1283,6 +1283,8 @@ static int turbo_enable[MAX_PLAYERS][MAX_BUTTONS] = {};
static int turbo_counter[MAX_PLAYERS][MAX_BUTTONS] = {};
// The number of frames between each firing of a turbo button
static int Turbo_Delay;
static int Turbo_Toggling = 1;
static int turbo_toggle_down[MAX_PLAYERS][MAX_BUTTONS] = {};
static void check_variables(void)
{
@ -1385,6 +1387,17 @@ static void check_variables(void)
log_cb(RETRO_LOG_INFO, "PCE CD Audio settings changed.\n");
}
// Set Turbo_Toggling
var.key = "Turbo_Toggling";
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
{
if (strcmp(var.value, "enabled") == 0)
Turbo_Toggling = 1;
else
Turbo_Toggling = 0;
}
// Set TURBO_DELAY
var.key = "Turbo_Delay";
@ -1584,6 +1597,7 @@ void retro_unload_game(void)
static void update_input(void)
{
static int turbo_map[] = { -1,-1,-1,-1,-1,-1,-1,-1,1,0,-1,-1,-1 };
static unsigned map[] = {
RETRO_DEVICE_ID_JOYPAD_A,
RETRO_DEVICE_ID_JOYPAD_B,
@ -1620,8 +1634,23 @@ static void update_input(void)
turbo_counter[j][i] = 0;
}
}
else if (turbo_map[i] != -1 && Turbo_Toggling && !AVPad6Enabled[j])
{
if (input_state_cb(j, RETRO_DEVICE_JOYPAD, 0, map[i]))
{
if (turbo_toggle_down[j][i] == 0)
{
turbo_toggle_down[j][i] = 1;
turbo_enable[j][turbo_map[i]] = turbo_enable[j][turbo_map[i]] ^ 1;
MDFN_DispMessage("Pad %i Button %s Turbo %s", j + 1, i == 9 ? "I" : "II", turbo_enable[j][turbo_map[i]] ? "ON" : "OFF" );
}
}
else turbo_toggle_down[j][i] = 0;
}
else input_state |= input_state_cb(j, RETRO_DEVICE_JOYPAD, 0, map[i]) ? (1 << i) : 0;
// Input data must be little endian.
input_buf[j][0] = (input_state >> 0) & 0xff;
input_buf[j][1] = (input_state >> 8) & 0xff;

View File

@ -24,7 +24,7 @@ static int InputTypes[5];
static uint8 *data_ptr[5];
static bool AVPad6Which[5]; // Lower(8 buttons) or higher(4 buttons).
static bool AVPad6Enabled[5];
bool AVPad6Enabled[5];
uint16 pce_jp_data[5];

View File

@ -10,5 +10,6 @@ void INPUT_Frame(void);
int INPUT_StateAction(StateMem *sm, int load, int data_only);
extern InputInfoStruct PCEInputInfo;
void INPUT_FixTS(void);
extern bool AVPad6Enabled[5];
#endif