[libretro] bugfix & code cleanup

This commit is contained in:
EkeEke 2017-08-08 16:46:11 +02:00
parent 147ad71a3c
commit 51f77aa38c
2 changed files with 16 additions and 15 deletions

Binary file not shown.

View File

@ -3,7 +3,7 @@
* *
* Genesis Plus GX libretro port * Genesis Plus GX libretro port
* *
* Copyright Eke-Eke (2007-2016) * Copyright Eke-Eke (2007-2017)
* *
* Copyright Daniel De Matteis (2012-2016) * Copyright Daniel De Matteis (2012-2016)
* *
@ -1792,7 +1792,7 @@ void retro_set_controller_port_device(unsigned port, unsigned device)
break; break;
case RETRO_DEVICE_MDPAD_3B: case RETRO_DEVICE_MDPAD_3B:
{ {
if (port && (input.system[0] >= RETRO_DEVICE_MDPAD_3B_WAYPLAY) && (input.system[0] <= RETRO_DEVICE_MSPAD_2B_MASTERTAP)) if (port && (input.system[0] >= SYSTEM_MASTERTAP) && (input.system[0] <= SYSTEM_WAYPLAY))
config.input[4].padtype = DEVICE_PAD3B; config.input[4].padtype = DEVICE_PAD3B;
else else
config.input[port].padtype = DEVICE_PAD3B; config.input[port].padtype = DEVICE_PAD3B;
@ -1801,7 +1801,7 @@ void retro_set_controller_port_device(unsigned port, unsigned device)
} }
case RETRO_DEVICE_MDPAD_6B: case RETRO_DEVICE_MDPAD_6B:
{ {
if (port && (input.system[0] >= RETRO_DEVICE_MDPAD_3B_WAYPLAY) && (input.system[0] <= RETRO_DEVICE_MSPAD_2B_MASTERTAP)) if (port && (input.system[0] >= SYSTEM_MASTERTAP) && (input.system[0] <= SYSTEM_WAYPLAY))
config.input[4].padtype = DEVICE_PAD6B; config.input[4].padtype = DEVICE_PAD6B;
else else
config.input[port].padtype = DEVICE_PAD6B; config.input[port].padtype = DEVICE_PAD6B;
@ -1810,7 +1810,7 @@ void retro_set_controller_port_device(unsigned port, unsigned device)
} }
case RETRO_DEVICE_MSPAD_2B: case RETRO_DEVICE_MSPAD_2B:
{ {
if (port && (input.system[0] >= RETRO_DEVICE_MDPAD_3B_WAYPLAY) && (input.system[0] <= RETRO_DEVICE_MSPAD_2B_MASTERTAP)) if (port && (input.system[0] >= SYSTEM_MASTERTAP) && (input.system[0] <= SYSTEM_WAYPLAY))
config.input[4].padtype = DEVICE_PAD2B; config.input[4].padtype = DEVICE_PAD2B;
else else
config.input[port].padtype = DEVICE_PAD2B; config.input[port].padtype = DEVICE_PAD2B;
@ -1894,7 +1894,7 @@ void retro_set_controller_port_device(unsigned port, unsigned device)
case RETRO_DEVICE_JOYPAD: case RETRO_DEVICE_JOYPAD:
default: default:
{ {
if (port && (input.system[0] >= RETRO_DEVICE_MDPAD_3B_WAYPLAY) && (input.system[0] <= RETRO_DEVICE_MSPAD_2B_MASTERTAP)) if (port && (input.system[0] >= SYSTEM_MASTERTAP) && (input.system[0] <= SYSTEM_WAYPLAY))
config.input[4].padtype = DEVICE_PAD2B | DEVICE_PAD6B | DEVICE_PAD3B; config.input[4].padtype = DEVICE_PAD2B | DEVICE_PAD6B | DEVICE_PAD3B;
else else
config.input[port].padtype = DEVICE_PAD2B | DEVICE_PAD6B | DEVICE_PAD3B; config.input[port].padtype = DEVICE_PAD2B | DEVICE_PAD6B | DEVICE_PAD3B;
@ -1946,15 +1946,16 @@ void retro_cheat_set(unsigned index, bool enabled, const char *code)
char codeCopy[256]; char codeCopy[256];
char *buff; char *buff;
/* Avoid crashing when giving empty input */ /* Avoid crashing when giving no input */
if (code=='\0') return; if (code==NULL) return;
/* clear existing ROM patches */ /* clear existing ROM patches */
clear_cheats(); clear_cheats();
/* Detect and split multiline cheats */ /* Detect and split multiline cheats */
strcpy(codeCopy,code); strncpy(codeCopy,code,255);
buff = strtok(codeCopy,"+"); codeCopy[255] = '\0';
buff = strtok(codeCopy,"+");
while (buff != NULL) while (buff != NULL)
{ {
@ -1984,8 +1985,8 @@ void retro_cheat_set(unsigned index, bool enabled, const char *code)
buff = strtok(NULL,"+"); buff = strtok(NULL,"+");
} }
/* apply ROM patches */ /* apply ROM patches */
apply_cheats(); apply_cheats();
} }
bool retro_load_game(const struct retro_game_info *info) bool retro_load_game(const struct retro_game_info *info)