From 7c4189cdd57a81a5d1597cd4a2049b62c4cb3b16 Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Sat, 18 Aug 2012 22:45:46 +0200 Subject: [PATCH] (RMenu) Split up platform-specific code into Rmenu context files --- console/griffin/griffin.c | 5 ++++ console/rmenu/context/rmenu_ctx_ps3.c | 33 +++++++++++++++++++++++++++ console/rmenu/context/rmenu_ctx_xdk.c | 33 +++++++++++++++++++++++++++ console/rmenu/rmenu.c | 20 +++++++++++----- console/rmenu/rmenu.h | 6 +++++ gx/frontend/main.c | 4 ++-- ps3/frontend/main.c | 4 ++-- xdk/frontend/main.c | 12 ++++++++-- 8 files changed, 105 insertions(+), 12 deletions(-) create mode 100644 console/rmenu/context/rmenu_ctx_ps3.c create mode 100644 console/rmenu/context/rmenu_ctx_xdk.c diff --git a/console/griffin/griffin.c b/console/griffin/griffin.c index a4f814d4fe..3218af0e9d 100644 --- a/console/griffin/griffin.c +++ b/console/griffin/griffin.c @@ -295,6 +295,11 @@ NETPLAY MENU ============================================================ */ #ifdef HAVE_RMENU +#if defined(__CELLOS_LV2__) +#include "../rmenu/context/rmenu_ctx_ps3.c" +#elif defined(_XBOX1) +#include "../rmenu/context/rmenu_ctx_xdk.c" +#endif #include "../rmenu/rmenu.c" #endif diff --git a/console/rmenu/context/rmenu_ctx_ps3.c b/console/rmenu/context/rmenu_ctx_ps3.c new file mode 100644 index 0000000000..28a1de0145 --- /dev/null +++ b/console/rmenu/context/rmenu_ctx_ps3.c @@ -0,0 +1,33 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2010-2012 - Hans-Kristian Arntzen + * Copyright (C) 2011-2012 - 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 "../rmenu.h" +#include "../../../gfx/context/ps3_ctx.h" + +static void rmenu_ctx_ps3_clear(void) +{ + gfx_ctx_clear(); +} + +static void rmenu_ctx_ps3_blend(bool enable) +{ + gfx_ctx_set_blend(enable); +} + +const rmenu_context_t rmenu_ctx_ps3 = { + .clear = rmenu_ctx_ps3_clear, + .blend = rmenu_ctx_ps3_blend, +}; diff --git a/console/rmenu/context/rmenu_ctx_xdk.c b/console/rmenu/context/rmenu_ctx_xdk.c new file mode 100644 index 0000000000..65246eeaba --- /dev/null +++ b/console/rmenu/context/rmenu_ctx_xdk.c @@ -0,0 +1,33 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2010-2012 - Hans-Kristian Arntzen + * Copyright (C) 2011-2012 - 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 "../rmenu.h" +#include "../../gfx/context/xdk_ctx.h" + +static void rmenu_ctx_xdk_clear(void) +{ + gfx_ctx_clear(); +} + +static void rmenu_ctx_xdk_blend(bool enable) +{ + gfx_ctx_set_blend(enable); +} + +const rmenu_context_t rmenu_ctx_xdk = { + .clear = rmenu_ctx_xdk_clear, + .blend = rmenu_ctx_xdk_blend, +}; diff --git a/console/rmenu/rmenu.c b/console/rmenu/rmenu.c index 29dd42e5e7..bc2b133374 100644 --- a/console/rmenu/rmenu.c +++ b/console/rmenu/rmenu.c @@ -95,6 +95,8 @@ unsigned set_shader = 0; unsigned currently_selected_controller_menu = 0; char m_title[256]; +static const rmenu_context_t *context; + static uint64_t old_state = 0; typedef enum { @@ -1017,7 +1019,7 @@ static void rarch_filename_input_and_save (unsigned filename_type) while(OSK_IS_RUNNING(g_console.oskutil_handle)) { - gfx_ctx_clear(); + context->clear(); gfx_ctx_swap_buffers(); #ifdef HAVE_SYSUTILS cellSysutilCheckCallback(); @@ -1053,7 +1055,7 @@ static void rarch_filename_input_and_save (unsigned filename_type) while(OSK_IS_RUNNING(g_console.oskutil_handle)) { /* OSK Util gets updated */ - gfx_ctx_clear(); + context->clear(); gfx_ctx_swap_buffers(); #ifdef HAVE_SYSUTILS cellSysutilCheckCallback(); @@ -1427,7 +1429,7 @@ static void producesettingentry(menu *current_menu, item *items, unsigned switch oskutil_start(&g_console.oskutil_handle); while(OSK_IS_RUNNING(g_console.oskutil_handle)) { - gfx_ctx_clear(); + context->clear(); gfx_ctx_swap_buffers(); #ifdef HAVE_SYSUTILS cellSysutilCheckCallback(); @@ -2319,6 +2321,12 @@ void menu_init (void) snprintf(m_title, sizeof(m_title), "Libretro core: %s %s", id, info.library_version); rmenu_filebrowser_init(); + +#if defined(__CELLOS_LV2__) + context = &rmenu_ctx_ps3; +#elif defined(_XBOX1) + context = (rmenu_context_t*)&rmenu_ctx_xdk; +#endif } void menu_free (void) @@ -2474,7 +2482,7 @@ void menu_loop(void) } } - gfx_ctx_clear(); + context->clear(); if(current_menu->enum_id == INGAME_MENU_RESIZE && (trig_state & RETRO_DEVICE_ID_JOYPAD_Y) || current_menu->enum_id == INGAME_MENU_SCREENSHOT) { @@ -2484,7 +2492,7 @@ void menu_loop(void) } else { - gfx_ctx_set_blend(true); + context->blend(true); #ifdef __CELLOS_LV2__ device_ptr->menu_render = true; #endif @@ -2603,7 +2611,7 @@ void menu_loop(void) if(current_menu->enum_id == INGAME_MENU_RESIZE && (old_state & (1 << RETRO_DEVICE_ID_JOYPAD_Y)) || current_menu->enum_id == INGAME_MENU_SCREENSHOT) { } else - gfx_ctx_set_blend(false); + context->blend(false); }while(g_console.menu_enable); #ifdef __CELLOS_LV2__ diff --git a/console/rmenu/rmenu.h b/console/rmenu/rmenu.h index 8821d088fa..079151a912 100644 --- a/console/rmenu/rmenu.h +++ b/console/rmenu/rmenu.h @@ -224,6 +224,12 @@ enum #define MAX_NO_OF_PATH_SETTINGS SETTING_PATH_DEFAULT_ALL+1 #define MAX_NO_OF_CONTROLS_SETTINGS SETTING_CONTROLS_DEFAULT_ALL+1 +typedef struct rmenu_context +{ + void (*clear)(void); + void (*blend)(bool enable); +} rmenu_context_t; + void menu_init (void); void menu_loop (void); void menu_free (void); diff --git a/gx/frontend/main.c b/gx/frontend/main.c index d2db184997..d67d0de123 100644 --- a/gx/frontend/main.c +++ b/gx/frontend/main.c @@ -362,7 +362,7 @@ int main(void) config_set_defaults(); input_gx.init(); - video_start_func(); + video_gx.start(); gx_video_t *gx = (gx_video_t*)driver.video_data; gx->menu_data = menu_framebuf; @@ -420,7 +420,7 @@ begin_shutdown: input_gx.free(NULL); - video_stop_func(); + video_gx.stop(); menu_free(); #ifdef HAVE_FILE_LOGGER diff --git a/ps3/frontend/main.c b/ps3/frontend/main.c index a41636f6bf..2b7e1fdc00 100644 --- a/ps3/frontend/main.c +++ b/ps3/frontend/main.c @@ -284,7 +284,7 @@ int main(int argc, char *argv[]) #endif #endif - video_start_func(); + video_gl.start(); #ifdef HAVE_OSKUTIL oskutil_init(&g_console.oskutil_handle, 0); @@ -342,7 +342,7 @@ begin_shutdown: rarch_main_deinit(); input_ps3.free(NULL); - video_stop_func(); + video_gl.stop(); menu_free(); #ifdef HAVE_OSKUTIL diff --git a/xdk/frontend/main.c b/xdk/frontend/main.c index eff4be9e37..e53b90f21d 100644 --- a/xdk/frontend/main.c +++ b/xdk/frontend/main.c @@ -170,7 +170,11 @@ int main(int argc, char *argv[]) input_xinput.post_init(); - video_start_func(); +#if defined(HAVE_D3D9) || defined(HAVE_D3D8) + video_xdk_d3d.start(); +#else + video_null.start(); +#endif system_init(); @@ -206,7 +210,11 @@ begin_shutdown: rarch_config_save(default_paths.config_file); menu_free(); - video_stop_func(); +#if defined(HAVE_D3D8) || defined(HAVE_D3D9) + video_xdk_d3d.stop(); +#else + video_null.stop(); +#endif input_xinput.free(NULL); if(g_console.return_to_launcher)