From 79737aecf3806662a5b50914c7a6900186c4597a Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Fri, 13 Apr 2012 20:40:22 +0200 Subject: [PATCH] (SSNES_CONSOLE) Introduce HAVE_SSNES_MAIN_WRAP define --- 360/main.c | 17 +------------ Makefile.ps3 | 2 +- console/console_ext.c | 38 ++++++++++++++++++++++++++++ console/console_ext.h | 8 ++++++ msvc-360/SSNES-360/SSNES-360.vcxproj | 12 ++++----- ps3/main.c | 26 ++----------------- ssnes.c | 3 +-- 7 files changed, 57 insertions(+), 49 deletions(-) diff --git a/360/main.c b/360/main.c index faf56669de..49ad691a98 100644 --- a/360/main.c +++ b/360/main.c @@ -406,22 +406,7 @@ begin_loop: else if(g_console.mode_switch == MODE_MENU) { menu_loop(); - - if(g_console.initialize_ssnes_enable) - { - if(g_console.emulator_initialized) - ssnes_main_deinit(); - - struct ssnes_main_wrap args = {0}; - - args.verbose = g_extern.verbose; - args.config_path = SYS_CONFIG_FILE; - args.rom_path = g_console.rom_path; - - int init_ret = ssnes_main_init_wrap(&args); - g_console.emulator_initialized = 1; - g_console.initialize_ssnes_enable = 0; - } + ssnes_startup(SYS_CONFIG_FILE); } else goto begin_shutdown; diff --git a/Makefile.ps3 b/Makefile.ps3 index 5b6c20f4d3..81d108561d 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_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) +DEFINES += -DSSNES_CONSOLE -DHAVE_OPENGL -DHAVE_CG -DHAVE_FBO -DHAVE_SSNES_MAIN_WRAP -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 20dd9c41e0..98df3be649 100644 --- a/console/console_ext.c +++ b/console/console_ext.c @@ -620,3 +620,41 @@ bool ssnes_manage_libretro_core(const char *full_path, const char *path, const c } #endif +/*============================================================ + SSNES MAIN WRAP + ============================================================ */ + +#ifdef HAVE_SSNES_MAIN_WRAP + +void ssnes_startup (const char * config_path) +{ + if(g_console.initialize_ssnes_enable) + { + if(g_console.emulator_initialized) + ssnes_main_deinit(); + +#ifdef __cplusplus + struct ssnes_main_wrap args = {0}; + + args.verbose = g_extern.verbose; + args.config_path = config_path; + args.sram_path = g_console.default_sram_dir_enable ? g_console.default_sram_dir : NULL, + args.state_path = g_console.default_savestate_dir_enable ? g_console.default_savestate_dir : NULL, + args.rom_path = g_console.rom_path; +#else + struct ssnes_main_wrap args = { + .verbose = g_extern.verbose, + .config_path = config_path, + .sram_path = g_console.default_sram_dir_enable ? g_console.default_sram_dir : NULL, + .state_path = g_console.default_savestate_dir_enable ? g_console.default_savestate_dir : NULL, + .rom_path = g_console.rom_path + }; +#endif + + int init_ret = ssnes_main_init_wrap(&args); + g_console.emulator_initialized = 1; + g_console.initialize_ssnes_enable = 0; + } +} + +#endif diff --git a/console/console_ext.h b/console/console_ext.h index ccf6c7a82b..8a4d671ee4 100644 --- a/console/console_ext.h +++ b/console/console_ext.h @@ -86,3 +86,11 @@ bool ssnes_manage_libretro_core(const char *full_path, const char *path, const c #endif #endif + +/*============================================================ + SSNES MAIN WRAP + ============================================================ */ + +#ifdef HAVE_SSNES_MAIN_WRAP +void ssnes_startup (const char * config_path); +#endif diff --git a/msvc-360/SSNES-360/SSNES-360.vcxproj b/msvc-360/SSNES-360/SSNES-360.vcxproj index 574f7e389b..309f7bccd9 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;HAVE_LIBRETRO_MANAGEMENT;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_SSNES_MAIN_WRAP;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;HAVE_LIBRETRO_MANAGEMENT;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_SSNES_MAIN_WRAP;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;HAVE_LIBRETRO_MANAGEMENT;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_SSNES_MAIN_WRAP;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;HAVE_LIBRETRO_MANAGEMENT;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_SSNES_MAIN_WRAP;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;HAVE_LIBRETRO_MANAGEMENT;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_SSNES_MAIN_WRAP;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;HAVE_LIBRETRO_MANAGEMENT;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_SSNES_MAIN_WRAP;HAVE_LIBRETRO_MANAGEMENT;D3DCOMPILE_USEVOIDS;HAVE_GRIFFIN true diff --git a/ps3/main.c b/ps3/main.c index 806f538729..dc1be0287c 100644 --- a/ps3/main.c +++ b/ps3/main.c @@ -436,28 +436,6 @@ static void get_environment_settings(int argc, char *argv[]) g_extern.verbose = false; } -static void startup_ssnes(void) -{ - if(g_console.initialize_ssnes_enable) - { - if(g_console.emulator_initialized) - ssnes_main_deinit(); - - struct ssnes_main_wrap args = { - .verbose = g_extern.verbose, - .config_path = SYS_CONFIG_FILE, - .sram_path = g_console.default_sram_dir_enable ? g_console.default_sram_dir : NULL, - .state_path = g_console.default_savestate_dir_enable ? g_console.default_savestate_dir : NULL, - .rom_path = g_console.rom_path - }; - - int init_ret = ssnes_main_init_wrap(&args); - g_console.emulator_initialized = 1; - g_console.initialize_ssnes_enable = 0; - } -} - - int main(int argc, char *argv[]) { SSNES_LOG("Registering system utility callback...\n"); @@ -527,7 +505,7 @@ int main(int argc, char *argv[]) strncpy(g_console.rom_path, argv[1], sizeof(g_console.rom_path)); g_console.initialize_ssnes_enable = 1; g_console.mode_switch = MODE_EMULATION; - startup_ssnes(); + ssnes_startup(SYS_CONFIG_FILE); break; } @@ -545,7 +523,7 @@ begin_loop: else if(g_console.mode_switch == MODE_MENU) { menu_loop(); - startup_ssnes(); + ssnes_startup(SYS_CONFIG_FILE); } else goto begin_shutdown; diff --git a/ssnes.c b/ssnes.c index ae13e04c5b..7a50f9bba9 100644 --- a/ssnes.c +++ b/ssnes.c @@ -2483,7 +2483,7 @@ void ssnes_main_deinit(void) uninit_libretro_sym(); } -#if !defined(SSNES_CONSOLE) || defined(GEKKO) +#ifndef HAVE_SSNES_MAIN_WRAP // Consoles use the higher level API. int main(int argc, char *argv[]) { @@ -2495,4 +2495,3 @@ int main(int argc, char *argv[]) return 0; } #endif -