From 5290a25ccd9b6ba603d40cf9b69a58479a601ab9 Mon Sep 17 00:00:00 2001 From: ToadKing Date: Wed, 8 May 2013 19:11:52 -0400 Subject: [PATCH] (GX) support ROM passing through salamander Needed on Wii since we might need to load salamander when switching cores due to memory issues --- frontend/platform/platform_gx.c | 19 +++++++++++++++++-- frontend/platform/platform_gx_exec.c | 11 +++++++++-- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/frontend/platform/platform_gx.c b/frontend/platform/platform_gx.c index 55c26fbf26..074c35e907 100644 --- a/frontend/platform/platform_gx.c +++ b/frontend/platform/platform_gx.c @@ -225,6 +225,10 @@ int gx_logger_file(struct _reent *r, int fd, const char *ptr, size_t len) #endif +#ifdef IS_SALAMANDER +extern char gx_rom_path[PATH_MAX]; +#endif + static void get_environment_settings(int argc, char *argv[]) { (void)argc; @@ -253,6 +257,14 @@ static void get_environment_settings(int argc, char *argv[]) strlcpy(default_paths.filesystem_root_dir, "/", sizeof(default_paths.filesystem_root_dir)); snprintf(default_paths.filebrowser_startup_dir, sizeof(default_paths.filebrowser_startup_dir), default_paths.filesystem_root_dir); snprintf(default_paths.input_presets_dir, sizeof(default_paths.input_presets_dir), "%s/input", default_paths.port_dir); + +#ifdef IS_SALAMANDER + if (argc > 2 && argv[1] != NULL && argv[2] != NULL) + snprintf(gx_rom_path, sizeof(gx_rom_path), + "%s%s", argv[1], argv[2]); + else + gx_rom_path[0] = '\0'; +#endif } extern void __exception_setreload(int t); @@ -299,14 +311,17 @@ static void system_init(void) static void system_exitspawn(void) { #if defined(IS_SALAMANDER) - rarch_console_exec(default_paths.libretro_path, false); + rarch_console_exec(default_paths.libretro_path, gx_rom_path[0] != '\0' ? true : false); #elif defined(HW_RVL) bool should_load_game = false; if (g_extern.lifecycle_mode_state & (1ULL << MODE_EXITSPAWN_START_GAME)) should_load_game = true; rarch_console_exec(g_settings.libretro, should_load_game); - rarch_console_exec(g_extern.fullpath, false); + // direct loading failed (out of memory), try to jump to salamander then load the correct core + char boot_dol[PATH_MAX]; + snprintf(boot_dol, sizeof(boot_dol), "%s/boot.dol", default_paths.core_dir); + rarch_console_exec(boot_dol, should_load_game); #endif } diff --git a/frontend/platform/platform_gx_exec.c b/frontend/platform/platform_gx_exec.c index dee44d0dd1..bf2d66607d 100644 --- a/frontend/platform/platform_gx_exec.c +++ b/frontend/platform/platform_gx_exec.c @@ -38,6 +38,10 @@ extern uint8_t _binary_wii_app_booter_app_booter_bin_end[]; #include "../../retroarch_logger.h" #include "../../file.h" +#ifdef IS_SALAMANDER +char gx_rom_path[PATH_MAX]; +#endif + static void dol_copy_argv_path(const char *dolpath, const char *argpath) { char tmp[PATH_MAX]; @@ -72,7 +76,6 @@ static void dol_copy_argv_path(const char *dolpath, const char *argpath) len += t_len; cmdline[len++] = 0; -#ifndef IS_SALAMANDER // file must be split into two parts, the path and the actual filename // done to be compatible with loaders if (argpath && strchr(argpath, '/') != NULL) @@ -91,7 +94,7 @@ static void dol_copy_argv_path(const char *dolpath, const char *argpath) len += t_len; cmdline[len++] = 0; } -#endif + cmdline[len++] = 0; argv->length = len; DCFlushRange(ARGS_ADDR, sizeof(struct __argv) + argv->length); @@ -137,7 +140,11 @@ static void rarch_console_exec(const char *path, bool should_load_game) memmove(EXECUTE_ADDR, dol, size); DCFlushRange(EXECUTE_ADDR, size); +#ifdef IS_SALAMANDER + dol_copy_argv_path(path, should_load_game ? gx_rom_path : NULL); +#else dol_copy_argv_path(path, should_load_game ? g_extern.fullpath : NULL); +#endif size_t booter_size = booter_end - booter_start; memcpy(BOOTER_ADDR, booter_start, booter_size);