From f72a505dbe89b240557a7b4d2e44f35d1609dc62 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 25 Feb 2013 07:01:16 +0100 Subject: [PATCH] Split up main() function to frontend/frontend.c --- Makefile | 3 +- Makefile.win | 3 +- console/griffin/griffin.c | 1 + frontend/frontend.c | 39 +++++++++++++++++++++++ general.h | 1 + msvc/msvc-2010/RetroArch-msvc2010.vcxproj | 4 ++- retroarch.c | 37 ++------------------- 7 files changed, 51 insertions(+), 37 deletions(-) create mode 100644 frontend/frontend.c diff --git a/Makefile b/Makefile index 58212f2bec..7121691591 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,8 @@ include config.mk TARGET = retroarch tools/retroarch-joyconfig tools/retrolaunch/retrolaunch -OBJ = retroarch.o \ +OBJ = frontend/frontend.o \ + retroarch.o \ file.o \ file_path.o \ hash.o \ diff --git a/Makefile.win b/Makefile.win index a038dece6a..846edc39c4 100644 --- a/Makefile.win +++ b/Makefile.win @@ -1,7 +1,8 @@ TARGET = retroarch.exe JTARGET = tools/retroarch-joyconfig.exe -OBJ = retroarch.o \ +OBJ = frontend/frontend.o \ + retroarch.o \ file.o \ file_path.o \ driver.o \ diff --git a/console/griffin/griffin.c b/console/griffin/griffin.c index 66c61f9646..0ea22a5819 100644 --- a/console/griffin/griffin.c +++ b/console/griffin/griffin.c @@ -383,6 +383,7 @@ MAIN #include "../../frontend/frontend_xenon.c" #elif defined(RARCH_CONSOLE) || defined(PSP) #include "../../frontend/frontend_console.c" +#include "../../frontend/frontend.c" #elif defined(ANDROID) #include "../../frontend/frontend_android.c" #endif diff --git a/frontend/frontend.c b/frontend/frontend.c new file mode 100644 index 0000000000..b5756919fa --- /dev/null +++ b/frontend/frontend.c @@ -0,0 +1,39 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2010-2013 - Hans-Kristian Arntzen + * Copyright (C) 2011-2013 - Daniel De Matteis + * + * RetroArch is free software: you can redistribute it and/or modify it under the terms + * of the GNU General Public License as published by the Free Software Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with RetroArch. + * If not, see . + */ + +#include "../general.h" + +int main(int argc, char *argv[]) +{ +#ifdef HAVE_RARCH_MAIN_IMPLEMENTATION + // Consoles use the higher level API. + return rarch_main(argc, argv); +#else + int init_ret; + if ((init_ret = rarch_main_init(argc, argv))) return init_ret; + rarch_init_msg_queue(); + while ((g_extern.is_paused && !g_extern.is_oneshot) ? rarch_main_idle_iterate() : rarch_main_iterate()); + rarch_main_deinit(); + rarch_deinit_msg_queue(); + +#ifdef PERF_TEST + rarch_perf_log(); +#endif + + rarch_main_clear_state(); + return 0; +#endif +} diff --git a/general.h b/general.h index e415eec7d3..fb72f45184 100644 --- a/general.h +++ b/general.h @@ -645,6 +645,7 @@ void rarch_init_system_info(void); int rarch_main(int argc, char *argv[]); int rarch_main_init_wrap(const struct rarch_main_wrap *args); int rarch_main_init(int argc, char *argv[]); +bool rarch_main_idle_iterate(void); bool rarch_main_iterate(void); void rarch_main_deinit(void); void rarch_render_cached_frame(void); diff --git a/msvc/msvc-2010/RetroArch-msvc2010.vcxproj b/msvc/msvc-2010/RetroArch-msvc2010.vcxproj index 40e35b3f1a..ba02e5f378 100644 --- a/msvc/msvc-2010/RetroArch-msvc2010.vcxproj +++ b/msvc/msvc-2010/RetroArch-msvc2010.vcxproj @@ -254,6 +254,8 @@ + + @@ -274,4 +276,4 @@ - \ No newline at end of file + diff --git a/retroarch.c b/retroarch.c index 0f9b4ab3ec..589d8dfa5c 100644 --- a/retroarch.c +++ b/retroarch.c @@ -2784,12 +2784,6 @@ error: return 1; } -static inline bool rarch_main_paused(void) -{ - return g_extern.is_paused && !g_extern.is_oneshot; -} - - bool rarch_main_iterate(void) { #ifdef HAVE_DYLIB @@ -2931,6 +2925,7 @@ void rarch_main_deinit(void) } #define MAX_ARGS 32 + int rarch_main_init_wrap(const struct rarch_main_wrap *args) { if (g_extern.main_is_init) @@ -2990,44 +2985,18 @@ int rarch_main_init_wrap(const struct rarch_main_wrap *args) return ret; } -#ifndef HAVE_RARCH_MAIN_WRAP -static bool rarch_main_idle_iterate(void) +bool rarch_main_idle_iterate(void) { #ifdef HAVE_COMMAND if (driver.command) rarch_cmd_pre_frame(driver.command); #endif - if (input_key_pressed_func(RARCH_QUIT_KEY) || - !video_alive_func()) + if (input_key_pressed_func(RARCH_QUIT_KEY) || !video_alive_func()) return false; do_state_checks(); - input_poll(); rarch_sleep(10); return true; } - -int main(int argc, char *argv[]) -{ -#ifdef HAVE_RARCH_MAIN_IMPLEMENTATION - // Consoles use the higher level API. - return rarch_main(argc, argv); -#else - int init_ret; - if ((init_ret = rarch_main_init(argc, argv))) return init_ret; - rarch_init_msg_queue(); - while (rarch_main_paused() ? rarch_main_idle_iterate() : rarch_main_iterate()); - rarch_main_deinit(); - rarch_deinit_msg_queue(); - -#ifdef PERF_TEST - rarch_perf_log(); -#endif - - rarch_main_clear_state(); - return 0; -#endif -} -#endif