From 0357f1510c71e06790a92110d251b50a41a03339 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 17 Feb 2013 20:23:27 +0100 Subject: [PATCH] (RMenu) Add low RAM mode --- frontend/menu/rmenu.c | 26 ++++++++++++++++++++++++++ frontend/menu/rmenu.h | 1 + general.h | 1 + gfx/context/ps3_ctx.c | 3 +++ gfx/context/xdk_ctx.c | 4 +++- settings.c | 11 +++++++++++ 6 files changed, 45 insertions(+), 1 deletion(-) diff --git a/frontend/menu/rmenu.c b/frontend/menu/rmenu.c index 5917caaf14..fbc9e58172 100644 --- a/frontend/menu/rmenu.c +++ b/frontend/menu/rmenu.c @@ -167,6 +167,12 @@ static void populate_setting_item(void *data, unsigned input) snprintf(current_item->setting_text, sizeof(current_item->setting_text), "%s", fname); snprintf(current_item->comment, sizeof(current_item->comment), "INFO - Select a skin for the menu."); break; + case SETTING_EMU_LOW_RAM_MODE_ENABLE: + fill_pathname_base(fname, g_extern.console.menu_texture_path, sizeof(fname)); + snprintf(current_item->text, sizeof(current_item->text), "Low RAM Mode"); + snprintf(current_item->setting_text, sizeof(current_item->setting_text), (g_extern.lifecycle_mode_state & (1ULL << MODE_MENU_LOW_RAM_MODE_ENABLE)) ? "ON" : "OFF"); + snprintf(current_item->comment, sizeof(current_item->comment), "INFO - Will not load skin at startup to save up on RAM."); + break; case SETTING_FONT_SIZE: snprintf(current_item->text, sizeof(current_item->text), "Font Size"); snprintf(current_item->setting_text, sizeof(current_item->setting_text), "%f", g_settings.video.font_size); @@ -1092,6 +1098,26 @@ static int set_setting_action(void *data, unsigned switchvalue, uint64_t input) RARCH_ERR("Shaders are unsupported on this platform.\n"); } break; + case SETTING_EMU_LOW_RAM_MODE_ENABLE: + if((input & (1ULL << RMENU_DEVICE_NAV_LEFT)) || (input & (1ULL << RMENU_DEVICE_NAV_RIGHT)) || (input & (1ULL << RMENU_DEVICE_NAV_B))) + { + if (g_extern.lifecycle_mode_state & (1ULL << MODE_MENU_LOW_RAM_MODE_ENABLE)) + g_extern.lifecycle_mode_state &= ~(1ULL << MODE_MENU_LOW_RAM_MODE_ENABLE); + else + g_extern.lifecycle_mode_state |= (1ULL << MODE_MENU_LOW_RAM_MODE_ENABLE); + + if (g_extern.lifecycle_mode_state & (1ULL << MODE_INFO_DRAW)) + rmenu_settings_msg(S_MSG_RESTART_RARCH, S_DELAY_180); + + } + if(input & (1ULL << RMENU_DEVICE_NAV_START)) + { + g_extern.lifecycle_mode_state &= ~(1ULL << MODE_MENU_LOW_RAM_MODE_ENABLE); + + if (g_extern.lifecycle_mode_state & (1ULL << MODE_INFO_DRAW)) + rmenu_settings_msg(S_MSG_RESTART_RARCH, S_DELAY_180); + } + break; case SETTING_EMU_SKIN: if((input & (1ULL << RMENU_DEVICE_NAV_LEFT)) || (input & (1ULL << RMENU_DEVICE_NAV_RIGHT)) || (input & (1ULL << RMENU_DEVICE_NAV_B))) { diff --git a/frontend/menu/rmenu.h b/frontend/menu/rmenu.h index 7fa62d64fa..031970ad3f 100644 --- a/frontend/menu/rmenu.h +++ b/frontend/menu/rmenu.h @@ -141,6 +141,7 @@ enum SETTING_EMU_SHOW_DEBUG_INFO_MSG, SETTING_EMU_SHOW_INFO_MSG, SETTING_EMU_SKIN, + SETTING_EMU_LOW_RAM_MODE_ENABLE, SETTING_RARCH_DEFAULT_EMU, SETTING_QUIT_RARCH, SETTING_EMU_DEFAULT_ALL, diff --git a/general.h b/general.h index e6bfa575fe..2da44b0cfd 100644 --- a/general.h +++ b/general.h @@ -125,6 +125,7 @@ enum menu_enums MODE_MENU_INGAME, MODE_MENU_INGAME_EXIT, MODE_MENU_DRAW, + MODE_MENU_LOW_RAM_MODE_ENABLE, MODE_INFO_DRAW, MODE_FPS_DRAW, MODE_EXTLAUNCH_SALAMANDER, diff --git a/gfx/context/ps3_ctx.c b/gfx/context/ps3_ctx.c index d5ac62cdb2..061a8f4825 100644 --- a/gfx/context/ps3_ctx.c +++ b/gfx/context/ps3_ctx.c @@ -329,6 +329,9 @@ void texture_image_border_load(const char *path) static bool gfx_ctx_rmenu_init(void) { + if (g_extern.lifecycle_mode_state & (1ULL << MODE_MENU_LOW_RAM_MODE_ENABLE)) + return true; + texture_image_border_load(g_extern.console.menu_texture_path); return true; diff --git a/gfx/context/xdk_ctx.c b/gfx/context/xdk_ctx.c index dde1e519e0..0db5096ebd 100644 --- a/gfx/context/xdk_ctx.c +++ b/gfx/context/xdk_ctx.c @@ -154,7 +154,9 @@ static bool gfx_ctx_xdk_menu_init(void) m_menuMainRomListPos_y = 130; } - texture_image_load(g_extern.console.menu_texture_path, &g_extern.console.menu_texture); + if (g_extern.lifecycle_mode_state & (1ULL << MODE_MENU_LOW_RAM_MODE_ENABLE)) { } + else + texture_image_load(g_extern.console.menu_texture_path, &g_extern.console.menu_texture); // Load rom selector panel texture_image_load("D:\\Media\\menuMainRomSelectPanel.png", &g_extern.console.menu_panel); diff --git a/settings.c b/settings.c index d6a798f20f..01d1ea3ace 100644 --- a/settings.c +++ b/settings.c @@ -703,6 +703,10 @@ bool config_load_file(const char *path) CONFIG_GET_BOOL(input.autodetect_enable, "input_autodetect_enable"); #endif + int low_ram_mode = 0; + if (config_get_int(conf, "rmenu_low_ram_mode_enable", &low_ram_mode)) + g_extern.lifecycle_mode_state |= (1ULL << MODE_MENU_LOW_RAM_MODE_ENABLE); + if (config_get_string(conf, "environment_variables", &g_extern.system.environment)) { @@ -1194,6 +1198,13 @@ bool config_save_file(const char *path) config_set_int(conf, "input_autodetect_icade_profile_pad4", input.icade_profile[3]); #endif +#ifdef HAVE_RMENU + if (g_extern.lifecycle_mode_state & (1ULL << MODE_MENU_LOW_RAM_MODE_ENABLE)) + config_set_int(conf, "rmenu_low_ram_mode_enable", 1); + else + config_set_int(conf, "rmenu_low_ram_mode_enable", 0); +#endif + if (g_extern.lifecycle_mode_state & (1ULL << MODE_VIDEO_OVERSCAN_ENABLE)) config_set_bool(conf, "overscan_enable", true); else