Split up main() function to frontend/frontend.c

This commit is contained in:
twinaphex 2013-02-25 07:01:16 +01:00
parent 49b0f5c204
commit f72a505dbe
7 changed files with 51 additions and 37 deletions

View File

@ -2,7 +2,8 @@ include config.mk
TARGET = retroarch tools/retroarch-joyconfig tools/retrolaunch/retrolaunch TARGET = retroarch tools/retroarch-joyconfig tools/retrolaunch/retrolaunch
OBJ = retroarch.o \ OBJ = frontend/frontend.o \
retroarch.o \
file.o \ file.o \
file_path.o \ file_path.o \
hash.o \ hash.o \

View File

@ -1,7 +1,8 @@
TARGET = retroarch.exe TARGET = retroarch.exe
JTARGET = tools/retroarch-joyconfig.exe JTARGET = tools/retroarch-joyconfig.exe
OBJ = retroarch.o \ OBJ = frontend/frontend.o \
retroarch.o \
file.o \ file.o \
file_path.o \ file_path.o \
driver.o \ driver.o \

View File

@ -383,6 +383,7 @@ MAIN
#include "../../frontend/frontend_xenon.c" #include "../../frontend/frontend_xenon.c"
#elif defined(RARCH_CONSOLE) || defined(PSP) #elif defined(RARCH_CONSOLE) || defined(PSP)
#include "../../frontend/frontend_console.c" #include "../../frontend/frontend_console.c"
#include "../../frontend/frontend.c"
#elif defined(ANDROID) #elif defined(ANDROID)
#include "../../frontend/frontend_android.c" #include "../../frontend/frontend_android.c"
#endif #endif

39
frontend/frontend.c Normal file
View File

@ -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 <http://www.gnu.org/licenses/>.
*/
#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
}

View File

@ -645,6 +645,7 @@ void rarch_init_system_info(void);
int rarch_main(int argc, char *argv[]); int rarch_main(int argc, char *argv[]);
int rarch_main_init_wrap(const struct rarch_main_wrap *args); int rarch_main_init_wrap(const struct rarch_main_wrap *args);
int rarch_main_init(int argc, char *argv[]); int rarch_main_init(int argc, char *argv[]);
bool rarch_main_idle_iterate(void);
bool rarch_main_iterate(void); bool rarch_main_iterate(void);
void rarch_main_deinit(void); void rarch_main_deinit(void);
void rarch_render_cached_frame(void); void rarch_render_cached_frame(void);

View File

@ -254,6 +254,8 @@
</ClCompile> </ClCompile>
<ClCompile Include="..\..\patch.c"> <ClCompile Include="..\..\patch.c">
</ClCompile> </ClCompile>
<ClCompile Include="..\..\frontend\frontend.c">
</ClCompile>
<ClCompile Include="..\..\retroarch.c"> <ClCompile Include="..\..\retroarch.c">
</ClCompile> </ClCompile>
<ClCompile Include="..\..\rewind.c"> <ClCompile Include="..\..\rewind.c">
@ -274,4 +276,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets"> <ImportGroup Label="ExtensionTargets">
</ImportGroup> </ImportGroup>
</Project> </Project>

View File

@ -2784,12 +2784,6 @@ error:
return 1; return 1;
} }
static inline bool rarch_main_paused(void)
{
return g_extern.is_paused && !g_extern.is_oneshot;
}
bool rarch_main_iterate(void) bool rarch_main_iterate(void)
{ {
#ifdef HAVE_DYLIB #ifdef HAVE_DYLIB
@ -2931,6 +2925,7 @@ void rarch_main_deinit(void)
} }
#define MAX_ARGS 32 #define MAX_ARGS 32
int rarch_main_init_wrap(const struct rarch_main_wrap *args) int rarch_main_init_wrap(const struct rarch_main_wrap *args)
{ {
if (g_extern.main_is_init) if (g_extern.main_is_init)
@ -2990,44 +2985,18 @@ int rarch_main_init_wrap(const struct rarch_main_wrap *args)
return ret; return ret;
} }
#ifndef HAVE_RARCH_MAIN_WRAP bool rarch_main_idle_iterate(void)
static bool rarch_main_idle_iterate(void)
{ {
#ifdef HAVE_COMMAND #ifdef HAVE_COMMAND
if (driver.command) if (driver.command)
rarch_cmd_pre_frame(driver.command); rarch_cmd_pre_frame(driver.command);
#endif #endif
if (input_key_pressed_func(RARCH_QUIT_KEY) || if (input_key_pressed_func(RARCH_QUIT_KEY) || !video_alive_func())
!video_alive_func())
return false; return false;
do_state_checks(); do_state_checks();
input_poll(); input_poll();
rarch_sleep(10); rarch_sleep(10);
return true; 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