From edfab9630aeea3b8ed90de1ef7240a1f251fec92 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 25 Aug 2013 01:37:15 +0200 Subject: [PATCH] Add RETRO_ENVIRONMENT_EXEC - refactor some stuff internally in libretro frontend to implement this new functionality --- dynamic.c | 25 +++++++++++++++++++++++++ frontend/menu/menu_common.c | 18 ++++++------------ libretro.h | 7 +++++++ 3 files changed, 38 insertions(+), 12 deletions(-) diff --git a/dynamic.c b/dynamic.c index ec7a0cd77a..b24ef9b2c1 100644 --- a/dynamic.c +++ b/dynamic.c @@ -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; diff --git a/frontend/menu/menu_common.c b/frontend/menu/menu_common.c index 39046d2443..ef1ff7e72e 100644 --- a/frontend/menu/menu_common.c +++ b/frontend/menu/menu_common.c @@ -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 } diff --git a/libretro.h b/libretro.h index 36baa0d14b..2d84aaf1b3 100755 --- a/libretro.h +++ b/libretro.h @@ -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);