diff --git a/360/main.c b/360/main.c index e4233faa3e..f8dfeb462b 100644 --- a/360/main.c +++ b/360/main.c @@ -369,83 +369,6 @@ static void get_environment_settings (void) strlcpy(SYS_CONFIG_FILE, "game:\\ssnes.cfg", sizeof(SYS_CONFIG_FILE)); } -static bool manage_libretro_core(void) -{ - g_extern.verbose = true; - bool return_code; - - bool set_libretro_path = false; - char tmp_path[1024], tmp_path2[1024], tmp_pathnewfile[1024]; - snprintf(tmp_path, sizeof(tmp_path), "game:\\CORE.xex"); - SSNES_LOG("Assumed path of CORE.xex: [%s]\n", tmp_path); - - if(path_file_exists(tmp_path)) - { - //if CORE.xex exists, this indicates we have just installed - //a new libretro port and that we need to change it to a more - //sane name. - - int ret; - - ssnes_console_name_from_id(tmp_path2, sizeof(tmp_path2)); - strlcat(tmp_path2, ".xex", sizeof(tmp_path2)); - snprintf(tmp_pathnewfile, sizeof(tmp_pathnewfile), "game:\\%s", tmp_path2); - - if(path_file_exists(tmp_pathnewfile)) - { - SSNES_LOG("Upgrading emulator core...\n"); - - //if libretro core already exists, then that means we are - //upgrading the libretro core - so delete pre-existing - //file first - - ret = DeleteFile(tmp_pathnewfile); - if(ret != 0) - { - SSNES_LOG("Succeeded in removing pre-existing libretro core: [%s].\n", tmp_pathnewfile); - } - else - { - SSNES_LOG("Failed to remove pre-existing libretro core: [%s].\n", tmp_pathnewfile); - } - } - - //now attempt the renaming - ret = MoveFileExA(tmp_path, tmp_pathnewfile, NULL); - if(ret == 0) - { - SSNES_ERR("Failed to rename CORE.xex.\n"); - } - else - { - SSNES_LOG("libretro core [%s] renamed to: [%s].\n", tmp_path, tmp_pathnewfile); - set_libretro_path = true; - } - } - else - { - SSNES_LOG("CORE.xex was not found, libretro core path will be loaded from config file.\n"); - } - - if(set_libretro_path) - { - //CORE.xex has been renamed, libretro path will now be set to the recently - //renamed new libretro core - strlcpy(g_settings.libretro, tmp_pathnewfile, sizeof(g_settings.libretro)); - return_code = 0; - } - else - { - //There was no CORE.xex present, or the CORE.xex file was not renamed. - //The libretro core path will still be loaded from the config file - return_code = 1; - } - - g_extern.verbose = false; - - return return_code; -} - int main(int argc, char *argv[]) { get_environment_settings(); @@ -453,7 +376,10 @@ int main(int argc, char *argv[]) ssnes_main_clear_state(); config_set_defaults(); - bool load_libretro_path = manage_libretro_core(); + char full_path[1024]; + snprintf(full_path, sizeof(full_path), "game:\\CORE.xex"); + + bool load_libretro_path = ssnes_manage_libretro_core(full_path, "game:\\", ".xex"); set_default_settings(); init_settings(load_libretro_path); diff --git a/Makefile.ps3 b/Makefile.ps3 index 371492b26e..5b6c20f4d3 100644 --- a/Makefile.ps3 +++ b/Makefile.ps3 @@ -68,7 +68,7 @@ endif PPU_LDLIBS = -ldbgfont $(GL_LIBS) -lretro -lcgc -lgcm_cmd -lgcm_sys_stub -lresc_stub -lm -lio_stub -lfs_stub -lsysutil_stub -lsysutil_game_stub -lsysutil_screenshot_stub -lsysutil_np_stub -lpngdec_stub -ljpgdec_stub -lsysmodule_stub -laudio_stub -lnet_stub -lnetctl_stub -lpthread -DEFINES += -DSSNES_CONSOLE -DHAVE_OPENGL -DHAVE_CG -DHAVE_FBO -DHAVE_RSOUND -DHAVE_ZLIB -D__CELLOS_LV2__ -DHAVE_CONFIGFILE=1 -DHAVE_NETPLAY=1 -DHAVE_SOCKET_LEGACY=1 -DHAVE_GRIFFIN=1 -DPACKAGE_VERSION=\"$(SSNES_VERSION)\" -Dmain=ssnes_main -DPC_DEVELOPMENT_IP_ADDRESS=\"$(PC_DEVELOPMENT_IP_ADDRESS)\" -DPC_DEVELOPMENT_UDP_PORT=$(PC_DEVELOPMENT_UDP_PORT) +DEFINES += -DSSNES_CONSOLE -DHAVE_OPENGL -DHAVE_CG -DHAVE_FBO -DHAVE_LIBRETRO_MANAGEMENT -DHAVE_RSOUND -DHAVE_ZLIB -D__CELLOS_LV2__ -DHAVE_CONFIGFILE=1 -DHAVE_NETPLAY=1 -DHAVE_SOCKET_LEGACY=1 -DHAVE_GRIFFIN=1 -DPACKAGE_VERSION=\"$(SSNES_VERSION)\" -Dmain=ssnes_main -DPC_DEVELOPMENT_IP_ADDRESS=\"$(PC_DEVELOPMENT_IP_ADDRESS)\" -DPC_DEVELOPMENT_UDP_PORT=$(PC_DEVELOPMENT_UDP_PORT) ifeq ($(DEBUG), 1) PPU_OPTIMIZE_LV := -O0 -g diff --git a/console/console_ext.c b/console/console_ext.c index b85970a4bd..d18fd20d0b 100644 --- a/console/console_ext.c +++ b/console/console_ext.c @@ -26,6 +26,7 @@ #include "../compat/strl.h" #include "main_wrap.h" #include "console_ext.h" +#include "../file.h" #ifdef HAVE_ZLIB #include "szlib/zlib.h" @@ -594,3 +595,99 @@ struct aspectratios_list_t aspectratio_lut[ASPECT_RATIO_CUSTOM+1] = { {"Auto", 0.0f}, {"Custom", 0.0f} }; + +/*============================================================ + LIBRETRO +============================================================ */ + +#ifdef HAVE_LIBRETRO_MANAGEMENT +bool ssnes_manage_libretro_core(const char * full_path, const char * path, const char * exe_ext) +{ + g_extern.verbose = true; + bool return_code; + + bool set_libretro_path = false; + char tmp_path2[1024], tmp_pathnewfile[1024]; + SSNES_LOG("Assumed path of CORE executable: [%s]\n", full_path); + + if(path_file_exists(full_path)) + { + //if CORE executable exists, this means we have just installed + //a new libretro port and therefore we need to change it to a more + //sane name. + +#if defined(__CELLOS_LV2__) + CellFsErrno ret; +#else + int ret; +#endif + + ssnes_console_name_from_id(tmp_path2, sizeof(tmp_path2)); + strlcat(tmp_path2, exe_ext, sizeof(tmp_path2)); + snprintf(tmp_pathnewfile, sizeof(tmp_pathnewfile), "%s%s", path, tmp_path2); + + if(path_file_exists(tmp_pathnewfile)) + { + //if libretro core already exists, this means we are + //upgrading the libretro core - so delete pre-existing + //file first. + + SSNES_LOG("Upgrading emulator core...\n"); +#if defined(__CELLOS_LV2__) + ret = cellFsUnlink(tmp_pathnewfile); + if(ret == CELL_FS_SUCCEEDED) +#elif defined(_XBOX) + ret = DeleteFile(tmp_pathnewfile); + if(ret != 0) +#endif + { + SSNES_LOG("Succeeded in removing pre-existing libretro core: [%s].\n", tmp_pathnewfile); + } + else + { + SSNES_LOG("Failed to remove pre-existing libretro core: [%s].\n", tmp_pathnewfile); + } + } + + //now attempt the renaming. +#if defined(__CELLOS_LV2__) + ret = cellFsRename(full_path, tmp_pathnewfile); + + if(ret != CELL_FS_SUCCEEDED) +#elif defined(_XBOX) + ret = MoveFileExA(full_path, tmp_pathnewfile, NULL); + if(ret == 0) +#endif + { + SSNES_ERR("Failed to rename CORE executable.\n"); + } + else + { + SSNES_LOG("Libsnes core [%s] renamed to: [%s].\n", full_path, tmp_pathnewfile); + set_libretro_path = true; + } + } + else + { + SSNES_LOG("CORE executable was not found, libretro core path will be loaded from config file.\n"); + } + + if(set_libretro_path) + { + //CORE executable has been renamed, libretro path will now be set to the recently + //renamed new libretro core. + strlcpy(g_settings.libretro, tmp_pathnewfile, sizeof(g_settings.libretro)); + return_code = 0; + } + else + { + //There was no CORE executable present, or the CORE executable file was not renamed. + //The libretro core path will still be loaded from the config file. + return_code = 1; + } + + g_extern.verbose = false; + + return return_code; +} +#endif diff --git a/console/console_ext.h b/console/console_ext.h index 85d9d87a27..900d12c0b9 100644 --- a/console/console_ext.h +++ b/console/console_ext.h @@ -81,4 +81,8 @@ void ssnes_input_set_default_keybind_names_for_emulator(void); void ssnes_input_set_keybind(unsigned player, unsigned keybind_action, uint64_t default_retro_joypad_id); +#if defined(__CELLOS_LV2__) || defined(_XBOX) +bool ssnes_manage_libretro_core(const char * full_path, const char * path, const char * exe_ext); +#endif + #endif diff --git a/console/salamander/main.c b/console/salamander/main.c index e5770d4dd7..6ad7827d9f 100644 --- a/console/salamander/main.c +++ b/console/salamander/main.c @@ -40,6 +40,10 @@ #define NP_POOL_SIZE (128*1024) #endif +#ifndef PATH_MAX +#define PATH_MAX 512 +#endif + #define MAX_PATH_LENGTH 1024 #ifdef HAVE_LOGGER diff --git a/file.h b/file.h index d3eead20ba..4c7d4b24d2 100644 --- a/file.h +++ b/file.h @@ -24,6 +24,10 @@ #include #include "general.h" +#ifdef __CELLOS_LV2__ +#include +#endif + // Generic file, path and directory handling. ssize_t read_file(const char *path, void **buf); diff --git a/msvc-360/SSNES-360/SSNES-360.vcxproj b/msvc-360/SSNES-360/SSNES-360.vcxproj index 93dfc44ce4..574f7e389b 100644 --- a/msvc-360/SSNES-360/SSNES-360.vcxproj +++ b/msvc-360/SSNES-360/SSNES-360.vcxproj @@ -112,7 +112,7 @@ true false MultiThreadedDebug - _DEBUG;_XBOX;PACKAGE_VERSION="0.9.5";%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS;main=ssnes_main;SSNES_CONSOLE;HAVE_CONFIGFILE;HAVE_NETPLAY;HAVE_SOCKET_LEGACY;HAVE_ZLIB;D3DCOMPILE_USEVOIDS;HAVE_GRIFFIN + _DEBUG;_XBOX;PACKAGE_VERSION="0.9.5";%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS;main=ssnes_main;SSNES_CONSOLE;HAVE_CONFIGFILE;HAVE_NETPLAY;HAVE_SOCKET_LEGACY;HAVE_ZLIB;HAVE_LIBRETRO_MANAGEMENT;D3DCOMPILE_USEVOIDS;HAVE_GRIFFIN Callcap @@ -150,7 +150,7 @@ AnalyzeOnly false MultiThreadedDebug - _DEBUG;_XBOX;%(PreprocessorDefinitions);PACKAGE_VERSION="0.9.5";_CRT_SECURE_NO_WARNINGS;main=ssnes_main;HAVE_CONFIGFILE;SSNES_CONSOLE;HAVE_ZLIB;D3DCOMPILE_USEVOIDS;HAVE_GRIFFIN + _DEBUG;_XBOX;%(PreprocessorDefinitions);PACKAGE_VERSION="0.9.5";_CRT_SECURE_NO_WARNINGS;main=ssnes_main;HAVE_CONFIGFILE;SSNES_CONSOLE;HAVE_ZLIB;HAVE_LIBRETRO_MANAGEMENT;D3DCOMPILE_USEVOIDS;HAVE_GRIFFIN Callcap @@ -189,7 +189,7 @@ Size false MultiThreaded - NDEBUG;_XBOX;PROFILE;%(PreprocessorDefinitions);PACKAGE_VERSION="0.9.5";_CRT_SECURE_NO_WARNINGS;SSNES_CONSOLE;main=ssnes_main;HAVE_CONFIGFILE;HAVE_ZLIB;D3DCOMPILE_USEVOIDS;HAVE_GRIFFIN + NDEBUG;_XBOX;PROFILE;%(PreprocessorDefinitions);PACKAGE_VERSION="0.9.5";_CRT_SECURE_NO_WARNINGS;SSNES_CONSOLE;main=ssnes_main;HAVE_CONFIGFILE;HAVE_ZLIB;HAVE_LIBRETRO_MANAGEMENT;D3DCOMPILE_USEVOIDS;HAVE_GRIFFIN Callcap @@ -233,7 +233,7 @@ Size false MultiThreaded - NDEBUG;_XBOX;PROFILE;FASTCAP;%(PreprocessorDefinitions);PACKAGE_VERSION="0.9.5";_CRT_SECURE_NO_WARNINGS;main=ssnes_main;HAVE_CONFIGFILE;HAVE_ZLIB;D3DCOMPILE_USEVOIDS;HAVE_GRIFFIN + NDEBUG;_XBOX;PROFILE;FASTCAP;%(PreprocessorDefinitions);PACKAGE_VERSION="0.9.5";_CRT_SECURE_NO_WARNINGS;main=ssnes_main;HAVE_CONFIGFILE;HAVE_ZLIB;HAVE_LIBRETRO_MANAGEMENT;D3DCOMPILE_USEVOIDS;HAVE_GRIFFIN true @@ -274,7 +274,7 @@ false false MultiThreaded - NDEBUG;_XBOX;%(PreprocessorDefinitions);PACKAGE_VERSION="0.9.5";_CRT_SECURE_NO_WARNINGS;main=ssnes_main;SSNES_CONSOLE=1;HAVE_CONFIGFILE;HAVE_NETPLAY;HAVE_SOCKET_LEGACY;HAVE_ZLIB;D3DCOMPILE_USEVOIDS;HAVE_GRIFFIN + NDEBUG;_XBOX;%(PreprocessorDefinitions);PACKAGE_VERSION="0.9.5";_CRT_SECURE_NO_WARNINGS;main=ssnes_main;SSNES_CONSOLE=1;HAVE_CONFIGFILE;HAVE_NETPLAY;HAVE_SOCKET_LEGACY;HAVE_ZLIB;HAVE_LIBRETRO_MANAGEMENT;D3DCOMPILE_USEVOIDS;HAVE_GRIFFIN true @@ -315,7 +315,7 @@ false false MultiThreaded - NDEBUG;_XBOX;LTCG;%(PreprocessorDefinitions);PACKAGE_VERSION="0.9.5";_CRT_SECURE_NO_WARNINGS;SSNES_CONSOLE;main=ssnes_main;HAVE_CONFIGFILE;HAVE_NETPLAY;HAVE_SOCKET_LEGACY;HAVE_ZLIB;D3DCOMPILE_USEVOIDS;HAVE_GRIFFIN + NDEBUG;_XBOX;LTCG;%(PreprocessorDefinitions);PACKAGE_VERSION="0.9.5";_CRT_SECURE_NO_WARNINGS;SSNES_CONSOLE;main=ssnes_main;HAVE_CONFIGFILE;HAVE_NETPLAY;HAVE_SOCKET_LEGACY;HAVE_ZLIB;HAVE_LIBRETRO_MANAGEMENT;D3DCOMPILE_USEVOIDS;HAVE_GRIFFIN true @@ -644,4 +644,4 @@ - \ No newline at end of file + diff --git a/ps3/main.c b/ps3/main.c index 9455e64428..73ca2820f5 100644 --- a/ps3/main.c +++ b/ps3/main.c @@ -457,80 +457,6 @@ static void startup_ssnes(void) } } -static bool manage_libretro_core(void) -{ - g_extern.verbose = true; - bool return_code; - - bool set_libretro_path = false; - char tmp_path[1024], tmp_path2[1024], tmp_pathnewfile[1024]; - snprintf(tmp_path, sizeof(tmp_path), "%s/%s/CORE.SELF", usrDirPath, EMULATOR_CORE_DIR); - SSNES_LOG("Assumed path of CORE.SELF: [%s]\n", tmp_path); - - if(path_file_exists(tmp_path)) - { - //if CORE.SELF exists, this indicates we have just installed - //a new libretro port and that we need to change it to a more - //sane name. - - CellFsErrno ret; - - ssnes_console_name_from_id(tmp_path2, sizeof(tmp_path2)); - strlcat(tmp_path2, ".SELF", sizeof(tmp_path2)); - snprintf(tmp_pathnewfile, sizeof(tmp_pathnewfile), "%s/%s/%s", usrDirPath, EMULATOR_CORE_DIR, tmp_path2); - - if(path_file_exists(tmp_pathnewfile)) - { - SSNES_LOG("Upgrading emulator core...\n"); - //if libretro core already exists, then that means we are - //upgrading the libretro core - so delete pre-existing - //file first - ret = cellFsUnlink(tmp_pathnewfile); - if(ret == CELL_FS_SUCCEEDED) - { - SSNES_LOG("Succeeded in removing pre-existing libretro core: [%s].\n", tmp_pathnewfile); - } - else - { - SSNES_LOG("Failed to remove pre-existing libretro core: [%s].\n", tmp_pathnewfile); - } - } - - //now attempt the renaming - ret = cellFsRename(tmp_path, tmp_pathnewfile); - if(ret != CELL_FS_SUCCEEDED) - { - SSNES_ERR("Failed to rename CORE.SELF.\n"); - } - else - { - SSNES_LOG("Libsnes core [%s] renamed to: [%s].\n", tmp_path, tmp_pathnewfile); - set_libretro_path = true; - } - } - else - { - SSNES_LOG("CORE.SELF was not found, libretro core path will be loaded from config file.\n"); - } - - if(set_libretro_path) - { - //CORE.BIN has been renamed, libretro path will now be set to the recently - //renamed new libretro core - strlcpy(g_settings.libretro, tmp_pathnewfile, sizeof(g_settings.libretro)); - return_code = 0; - } - else - { - //There was no CORE.BIN present, or the CORE.BIN file was not renamed. - //The libretro core path will still be loaded from the config file - return_code = 1; - } - - g_extern.verbose = false; - - return return_code; -} int main(int argc, char *argv[]) { @@ -559,7 +485,10 @@ int main(int argc, char *argv[]) config_set_defaults(); - bool load_libretro_path = manage_libretro_core(); + char full_path[1024], tmp_path[1024]; + snprintf(full_path, sizeof(full_path), "%s/%s/CORE.SELF", usrDirPath, EMULATOR_CORE_DIR); + snprintf(tmp_path, sizeof(tmp_path), "%s/%s/", usrDirPath, EMULATOR_CORE_DIR); + bool load_libretro_path = ssnes_manage_libretro_core(full_path, tmp_path, ".SELF"); set_default_settings(); init_settings(load_libretro_path);