Add RETRO_ENVIRONMENT_EXEC - refactor some stuff internally in

libretro frontend to implement this new functionality
This commit is contained in:
twinaphex 2013-08-25 01:37:15 +02:00
parent 8aef9f4c64
commit edfab9630a
3 changed files with 38 additions and 12 deletions

View File

@ -757,10 +757,35 @@ bool rarch_environment_cb(unsigned cmd, void *data)
}
case RETRO_ENVIRONMENT_SET_LIBRETRO_PATH:
{
RARCH_LOG("Environ SET_LIBRETRO_PATH.\n");
struct retro_variable *var = (struct retro_variable*)data;
strlcpy(g_settings.libretro, var->value, sizeof(g_settings.libretro));
break;
}
case RETRO_ENVIRONMENT_EXEC:
{
RARCH_LOG("Environ EXEC.\n");
struct retro_variable *var = (struct retro_variable*)data;
if (var->value)
strlcpy(g_extern.fullpath, var->value, sizeof(g_extern.fullpath));
else
*g_extern.fullpath = '\0';
if (strcasecmp(var->key, "EXEC_RELOAD") == 0)
{
#if !defined( HAVE_DYNAMIC) && defined(RARCH_CONSOLE)
g_extern.lifecycle_mode_state &= ~(1ULL << MODE_GAME);
g_extern.lifecycle_mode_state |= (1ULL << MODE_EXITSPAWN);
g_extern.lifecycle_mode_state |= (1ULL << MODE_EXITSPAWN_START_GAME);
#elif defined(HAVE_DYNAMIC)
g_extern.lifecycle_mode_state |= (1ULL << MODE_LOAD_GAME);
#endif
}
break;
}
default:
RARCH_LOG("Environ UNSUPPORTED (#%u).\n", cmd);
return false;

View File

@ -449,24 +449,18 @@ void load_menu_game_history(unsigned game_index)
rarch_environment_cb(RETRO_ENVIRONMENT_SET_LIBRETRO_PATH, &var);
if (path)
{
rgui->load_no_rom = false;
strlcpy(g_extern.fullpath, path, sizeof(g_extern.fullpath));
}
else
{
rgui->load_no_rom = true;
*g_extern.fullpath = '\0';
}
#if !defined( HAVE_DYNAMIC) && defined(RARCH_CONSOLE)
g_extern.lifecycle_mode_state &= ~(1ULL << MODE_GAME);
g_extern.lifecycle_mode_state |= (1ULL << MODE_EXITSPAWN);
g_extern.lifecycle_mode_state |= (1ULL << MODE_EXITSPAWN_START_GAME);
#elif defined(HAVE_DYNAMIC)
var.key = "EXEC_RELOAD";
var.value = path;
rarch_environment_cb(RETRO_ENVIRONMENT_EXEC, &var);
#if defined(HAVE_DYNAMIC)
libretro_free_system_info(&rgui->info);
libretro_get_system_info(g_settings.libretro, &rgui->info, NULL);
g_extern.lifecycle_mode_state |= (1ULL << MODE_LOAD_GAME);
#endif
}

View File

@ -512,6 +512,13 @@ enum retro_mod
#define RETRO_ENVIRONMENT_SET_LIBRETRO_PATH 22
// struct retro_variable * --
// Sets the absolute path for the libretro core pointed to.
#define RETRO_ENVIRONMENT_EXEC 23
// struct retro_variable * --
// Sets an input file for the libretro core to execute with, and (based on key name) will determine what
// exec method to follow.
// "EXEC_LOAD" : will start the input file whose path was passed from the parameter to RETRO_ENVIRONMENT_EXEC.
// "EXEC_RELOAD" : will set the current libretro core, deinitialize the currently running media and then
// start the input file whose path was passed from the parameter to RETRO_ENVIRONMENT_EXEC.
// Notifies libretro that audio data should be written.
typedef void (*retro_audio_callback_t)(void);