mirror of
https://github.com/libretro/RetroArch
synced 2025-01-30 03:32:46 +00:00
(Salamander) Refactorings - Salamander should be easier to get to
work now on new console platforms
This commit is contained in:
parent
7676de50ce
commit
faea453a0b
@ -268,7 +268,7 @@ void main_exit(args_type() args)
|
||||
|
||||
if (g_extern.lifecycle_state & (1ULL << MODE_EXITSPAWN) && driver.frontend_ctx
|
||||
&& driver.frontend_ctx->exitspawn)
|
||||
driver.frontend_ctx->exitspawn();
|
||||
driver.frontend_ctx->exitspawn(g_settings.libretro, sizeof(g_settings.libretro));
|
||||
|
||||
rarch_main_clear_state();
|
||||
|
||||
|
@ -17,6 +17,7 @@
|
||||
#ifndef __FRONTEND_CONTEXT_H
|
||||
#define __FRONTEND_CONTEXT_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include "../boolean.h"
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
@ -34,7 +35,7 @@ typedef struct frontend_ctx_driver
|
||||
|
||||
void (*init)(void *data);
|
||||
void (*deinit)(void *data);
|
||||
void (*exitspawn)(void);
|
||||
void (*exitspawn)(char *core_path, size_t sizeof_core_path);
|
||||
|
||||
void (*process_args)(int *argc, char *argv[], void *args);
|
||||
int (*process_events)(void *data);
|
||||
@ -44,9 +45,6 @@ typedef struct frontend_ctx_driver
|
||||
|
||||
// Human readable string.
|
||||
const char *ident;
|
||||
#ifdef IS_SALAMANDER
|
||||
void (*salamander_init)(void);
|
||||
#endif
|
||||
} frontend_ctx_driver_t;
|
||||
|
||||
extern const frontend_ctx_driver_t frontend_ctx_gx;
|
||||
|
@ -104,8 +104,52 @@ static void find_and_set_first_file(char *path, size_t sizeof_path, const char *
|
||||
RARCH_ERR("Failed last fallback - RetroArch Salamander will exit.\n");
|
||||
}
|
||||
|
||||
static void salamander_init(char *libretro_path, size_t sizeof_libretro_path)
|
||||
{
|
||||
//normal executable loading path
|
||||
bool config_file_exists = false;
|
||||
|
||||
if (path_file_exists(default_paths.config_path))
|
||||
config_file_exists = true;
|
||||
|
||||
if (config_file_exists)
|
||||
{
|
||||
char tmp_str[PATH_MAX];
|
||||
config_file_t * conf = config_file_new(default_paths.config_path);
|
||||
|
||||
if (conf)
|
||||
{
|
||||
config_get_array(conf, "libretro_path", tmp_str, sizeof(tmp_str));
|
||||
config_file_free(conf);
|
||||
strlcpy(libretro_path, tmp_str, sizeof_libretro_path);
|
||||
}
|
||||
#ifdef GEKKO
|
||||
else // stupid libfat bug or something; somtimes it says the file is there when it doesn't
|
||||
config_file_exists = false;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!config_file_exists || !strcmp(libretro_path, ""))
|
||||
find_and_set_first_file(libretro_path, sizeof_libretro_path, EXT_EXECUTABLES);
|
||||
else
|
||||
RARCH_LOG("Start [%s] found in retroarch.cfg.\n", libretro_path);
|
||||
|
||||
if (!config_file_exists)
|
||||
{
|
||||
config_file_t *conf = config_file_new(NULL);
|
||||
|
||||
if (conf)
|
||||
{
|
||||
config_set_string(conf, "libretro_path", libretro_path);
|
||||
config_file_write(conf, default_paths.config_path);
|
||||
config_file_free(conf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
char libretro_path[PATH_MAX];
|
||||
void *args = NULL;
|
||||
struct rarch_main_wrap *wrap_args;
|
||||
|
||||
@ -121,14 +165,13 @@ int main(int argc, char *argv[])
|
||||
if (frontend_ctx && frontend_ctx->environment_get)
|
||||
frontend_ctx->environment_get(&argc, argv, args, wrap_args);
|
||||
|
||||
if (frontend_ctx && frontend_ctx->salamander_init)
|
||||
frontend_ctx->salamander_init();
|
||||
salamander_init(libretro_path, sizeof(libretro_path));
|
||||
|
||||
if (frontend_ctx && frontend_ctx->deinit)
|
||||
frontend_ctx->deinit(args);
|
||||
|
||||
if (frontend_ctx && frontend_ctx->exitspawn)
|
||||
frontend_ctx->exitspawn();
|
||||
frontend_ctx->exitspawn(libretro_path, sizeof(libretro_path));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -50,47 +50,7 @@ extern void system_exec_wii(const char *path, bool should_load_game);
|
||||
#include <sdcard/gcsd.h>
|
||||
#include <fat.h>
|
||||
|
||||
#ifdef IS_SALAMANDER
|
||||
char libretro_path[PATH_MAX];
|
||||
|
||||
static void frontend_gx_salamander_init(void)
|
||||
{
|
||||
char tmp_str[PATH_MAX] = {0};
|
||||
bool config_file_exists;
|
||||
|
||||
if (path_file_exists(default_paths.config_path))
|
||||
config_file_exists = true;
|
||||
|
||||
if(config_file_exists)
|
||||
{
|
||||
config_file_t * conf = config_file_new(default_paths.config_path);
|
||||
if (!conf) // stupid libfat bug or something; somtimes it says the file is there when it doesn't
|
||||
config_file_exists = false;
|
||||
else
|
||||
{
|
||||
config_get_array(conf, "libretro_path", tmp_str, sizeof(tmp_str));
|
||||
config_file_free(conf);
|
||||
strlcpy(libretro_path, tmp_str, sizeof(libretro_path));
|
||||
}
|
||||
}
|
||||
|
||||
if(!config_file_exists || !strcmp(libretro_path, ""))
|
||||
find_and_set_first_file(libretro_path, sizeof(libretro_path), EXT_EXECUTABLES);
|
||||
else
|
||||
{
|
||||
RARCH_LOG("Start [%s] found in retroarch.cfg.\n", libretro_path);
|
||||
}
|
||||
|
||||
if (!config_file_exists)
|
||||
{
|
||||
config_file_t *new_conf = config_file_new(NULL);
|
||||
config_set_string(new_conf, "libretro_path", libretro_path);
|
||||
config_file_write(new_conf, default_paths.config_path);
|
||||
config_file_free(new_conf);
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
#ifndef IS_SALAMANDER
|
||||
|
||||
enum
|
||||
{
|
||||
@ -321,24 +281,21 @@ static void frontend_gx_init(void *data)
|
||||
|
||||
static void frontend_gx_exec(const char *path, bool should_load_game);
|
||||
|
||||
static void frontend_gx_exitspawn(void)
|
||||
static void frontend_gx_exitspawn(char *core_path, size_t sizeof_core_path)
|
||||
{
|
||||
char boot_dol[PATH_MAX];
|
||||
|
||||
(void)boot_dol;
|
||||
|
||||
#if defined(IS_SALAMANDER)
|
||||
frontend_gx_exec(libretro_path, gx_rom_path[0] != '\0' ? true : false);
|
||||
#elif defined(HW_RVL)
|
||||
bool should_load_game = false;
|
||||
#if defined(IS_SALAMANDER)
|
||||
if (gx_rom_path[0] != '\0')
|
||||
should_load_game = true;
|
||||
#elif defined(HW_RVL)
|
||||
if (g_extern.lifecycle_state & (1ULL << MODE_EXITSPAWN_START_GAME))
|
||||
should_load_game = true;
|
||||
|
||||
frontend_gx_exec(g_settings.libretro, should_load_game);
|
||||
// direct loading failed (out of memory), try to jump to salamander then load the correct core
|
||||
fill_pathname_join(boot_dol, default_paths.core_dir, "boot.dol", sizeof(boot_dol));
|
||||
frontend_gx_exec(boot_dol, should_load_game);
|
||||
fill_pathname_join(core_path, default_paths.core_dir, "boot.dol", sizeof_core_path);
|
||||
#endif
|
||||
frontend_gx_exec(core_path, should_load_game);
|
||||
}
|
||||
|
||||
static void frontend_gx_process_args(int *argc, char *argv[], void *args)
|
||||
@ -382,7 +339,4 @@ const frontend_ctx_driver_t frontend_ctx_gx = {
|
||||
NULL, /* shutdown */
|
||||
frontend_gx_get_rating, /* get_rating */
|
||||
"gx",
|
||||
#ifdef IS_SALAMANDER
|
||||
frontend_gx_salamander_init,
|
||||
#endif
|
||||
};
|
||||
|
@ -46,40 +46,6 @@ SYS_PROCESS_PARAM(1001, 0x200000)
|
||||
#include <np.h>
|
||||
#include <np/drm.h>
|
||||
#include <cell/sysmodule.h>
|
||||
|
||||
char libretro_path[PATH_MAX];
|
||||
|
||||
static void frontend_ps3_salamander_init(void)
|
||||
{
|
||||
//normal executable loading path
|
||||
char tmp_str[PATH_MAX];
|
||||
bool config_file_exists = false;
|
||||
|
||||
if (path_file_exists(default_paths.config_path))
|
||||
config_file_exists = true;
|
||||
|
||||
if (config_file_exists)
|
||||
{
|
||||
config_file_t * conf = config_file_new(default_paths.config_path);
|
||||
config_get_array(conf, "libretro_path", tmp_str, sizeof(tmp_str));
|
||||
config_file_free(conf);
|
||||
strlcpy(libretro_path, tmp_str, sizeof(libretro_path));
|
||||
}
|
||||
|
||||
if (!config_file_exists || !strcmp(libretro_path, ""))
|
||||
find_and_set_first_file(libretro_path, sizeof(libretro_path), EXT_EXECUTABLES);
|
||||
else
|
||||
RARCH_LOG("Start [%s] found in retroarch.cfg.\n", libretro_path);
|
||||
|
||||
if (!config_file_exists)
|
||||
{
|
||||
config_file_t *new_conf = config_file_new(NULL);
|
||||
config_set_string(new_conf, "libretro_path", libretro_path);
|
||||
config_file_write(new_conf, default_paths.config_path);
|
||||
config_file_free(new_conf);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYSUTILS
|
||||
@ -342,42 +308,41 @@ static void frontend_ps3_deinit(void *data)
|
||||
|
||||
static void frontend_ps3_exec(const char *path, bool should_load_game);
|
||||
|
||||
static void frontend_ps3_exitspawn(void)
|
||||
static void frontend_ps3_exitspawn(char *core_path, size_t core_path_size)
|
||||
{
|
||||
#ifdef HAVE_RARCH_EXEC
|
||||
bool should_load_game = false;
|
||||
|
||||
#ifndef IS_SALAMANDER
|
||||
bool original_verbose = g_extern.verbose;
|
||||
g_extern.verbose = true;
|
||||
#endif
|
||||
#ifdef IS_SALAMANDER
|
||||
frontend_ps3_exec(libretro_path, false);
|
||||
|
||||
cellSysmoduleUnloadModule(CELL_SYSMODULE_SYSUTIL_GAME);
|
||||
cellSysmoduleLoadModule(CELL_SYSMODULE_FS);
|
||||
cellSysmoduleLoadModule(CELL_SYSMODULE_IO);
|
||||
#else
|
||||
char core_launch[256];
|
||||
#ifdef HAVE_MULTIMAN
|
||||
if (g_extern.lifecycle_state & (1ULL << MODE_EXITSPAWN_MULTIMAN))
|
||||
{
|
||||
RARCH_LOG("Boot Multiman: %s.\n", MULTIMAN_SELF_FILE);
|
||||
strlcpy(core_launch, MULTIMAN_SELF_FILE, sizeof(core_launch));
|
||||
strlcpy(core_path, MULTIMAN_SELF_FILE, core_path_size);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
strlcpy(core_launch, g_settings.libretro, sizeof(core_launch));
|
||||
bool should_load_game = false;
|
||||
if (g_extern.lifecycle_state & (1ULL << MODE_EXITSPAWN_START_GAME))
|
||||
should_load_game = true;
|
||||
#endif
|
||||
|
||||
frontend_ps3_exec(core_path, should_load_game);
|
||||
|
||||
#ifdef IS_SALAMANDER
|
||||
cellSysmoduleUnloadModule(CELL_SYSMODULE_SYSUTIL_GAME);
|
||||
cellSysmoduleLoadModule(CELL_SYSMODULE_FS);
|
||||
cellSysmoduleLoadModule(CELL_SYSMODULE_IO);
|
||||
#else
|
||||
|
||||
frontend_ps3_exec(core_launch, should_load_game);
|
||||
#endif
|
||||
|
||||
#ifndef IS_SALAMANDER
|
||||
g_extern.verbose = original_verbose;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#include <stdio.h>
|
||||
@ -477,7 +442,4 @@ const frontend_ctx_driver_t frontend_ctx_ps3 = {
|
||||
NULL, /* shutdown */
|
||||
frontend_ps3_get_rating, /* get_rating */
|
||||
"ps3",
|
||||
#ifdef IS_SALAMANDER
|
||||
frontend_ps3_salamander_init,
|
||||
#endif
|
||||
};
|
||||
|
@ -40,41 +40,6 @@ char eboot_path[512];
|
||||
|
||||
#ifdef IS_SALAMANDER
|
||||
#include "../../file_ext.h"
|
||||
|
||||
char libretro_path[512];
|
||||
|
||||
static void find_and_set_first_file(char *path, size_t sizeof_path, const char *ext);
|
||||
|
||||
static void frontend_psp_salamander_init(void)
|
||||
{
|
||||
//normal executable loading path
|
||||
char tmp_str[PATH_MAX];
|
||||
bool config_file_exists = false;
|
||||
|
||||
if (path_file_exists(default_paths.config_path))
|
||||
config_file_exists = true;
|
||||
|
||||
if (config_file_exists)
|
||||
{
|
||||
config_file_t * conf = config_file_new(default_paths.config_path);
|
||||
config_get_array(conf, "libretro_path", tmp_str, sizeof(tmp_str));
|
||||
config_file_free(conf);
|
||||
strlcpy(libretro_path, tmp_str, sizeof(libretro_path));
|
||||
}
|
||||
|
||||
if (!config_file_exists || !strcmp(libretro_path, ""))
|
||||
find_and_set_first_file(libretro_path, sizeof(libretro_path), EXT_EXECUTABLES);
|
||||
else
|
||||
RARCH_LOG("Start [%s] found in retroarch.cfg.\n", libretro_path);
|
||||
|
||||
if (!config_file_exists)
|
||||
{
|
||||
config_file_t *new_conf = config_file_new(NULL);
|
||||
config_set_string(new_conf, "libretro_path", libretro_path);
|
||||
config_file_write(new_conf, default_paths.config_path);
|
||||
config_file_free(new_conf);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static void frontend_psp_get_environment_settings(int *argc, char *argv[],
|
||||
@ -226,10 +191,10 @@ static void frontend_psp_exec(const char *path, bool should_load_game)
|
||||
}
|
||||
|
||||
|
||||
static void frontend_psp_exitspawn(void)
|
||||
static void frontend_psp_exitspawn(char *core_path, size_t sizeof_core_path)
|
||||
{
|
||||
#ifdef IS_SALAMANDER
|
||||
frontend_psp_exec(libretro_path, false);
|
||||
frontend_psp_exec(core_path, false);
|
||||
#else
|
||||
char core_launch[256];
|
||||
|
||||
@ -258,7 +223,4 @@ const frontend_ctx_driver_t frontend_ctx_psp = {
|
||||
frontend_psp_shutdown, /* shutdown */
|
||||
frontend_psp_get_rating, /* get_rating */
|
||||
"psp",
|
||||
#ifdef IS_SALAMANDER
|
||||
frontend_psp_salamander_init,
|
||||
#endif
|
||||
};
|
||||
|
@ -27,39 +27,7 @@
|
||||
#include "../../conf/config_file_macros.h"
|
||||
#include "../../file.h"
|
||||
|
||||
#ifdef IS_SALAMANDER
|
||||
char libretro_path[512];
|
||||
|
||||
static void frontend_xdk_salamander_init(void)
|
||||
{
|
||||
//normal executable loading path
|
||||
char tmp_str[PATH_MAX];
|
||||
bool config_file_exists = false;
|
||||
|
||||
if(path_file_exists(default_paths.config_path))
|
||||
config_file_exists = true;
|
||||
|
||||
if(config_file_exists)
|
||||
{
|
||||
config_file_t * conf = config_file_new(default_paths.config_path);
|
||||
config_get_array(conf, "libretro_path", tmp_str, sizeof(tmp_str));
|
||||
strlcpy(libretro_path, tmp_str, sizeof(libretro_path));
|
||||
}
|
||||
|
||||
if(!config_file_exists || !strcmp(libretro_path, ""))
|
||||
find_and_set_first_file(libretro_path, sizeof(libretro_path), EXT_EXECUTABLES);
|
||||
else
|
||||
RARCH_LOG("Start [%s] found in retroarch.cfg.\n", libretro_path);
|
||||
|
||||
if (!config_file_exists)
|
||||
{
|
||||
config_file_t *new_conf = config_file_new(NULL);
|
||||
config_set_string(new_conf, "libretro_path", libretro_path);
|
||||
config_file_write(new_conf, default_paths.config_path);
|
||||
config_file_free(new_conf);
|
||||
}
|
||||
}
|
||||
#else
|
||||
#ifndef IS_SALAMANDER
|
||||
#include "../../general.h"
|
||||
#endif
|
||||
|
||||
@ -274,10 +242,10 @@ static void frontend_xdk_init(void *data)
|
||||
|
||||
static void frontend_xdk_exec(const char *path, bool should_load_game);
|
||||
|
||||
static void frontend_xdk_exitspawn(void)
|
||||
static void frontend_xdk_exitspawn(char *core_path, size_t sizeof_core_path)
|
||||
{
|
||||
#ifdef IS_SALAMANDER
|
||||
frontend_xdk_exec(libretro_path, false);
|
||||
frontend_xdk_exec(core_path, false);
|
||||
#else
|
||||
bool should_load_game = false;
|
||||
if (g_extern.lifecycle_state & (1ULL << MODE_EXITSPAWN_START_GAME))
|
||||
@ -353,7 +321,4 @@ const frontend_ctx_driver_t frontend_ctx_xdk = {
|
||||
NULL, /* shutdown */
|
||||
frontend_xdk_get_rating, /* get_rating */
|
||||
"xdk",
|
||||
#ifdef IS_SALAMANDER
|
||||
frontend_xdk_salamander_init,
|
||||
#endif
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user