From cc43b84ff28a1df4820774f7bf0a429c38b1d619 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 11 Jan 2013 19:44:13 +0100 Subject: [PATCH] (RARCH_CONSOLE) Refactor more state variables --- console/rarch_console_settings.c | 28 ++++--- frontend/menu/rgui.c | 7 +- frontend/menu/rmenu.c | 64 ++++++++------- frontend/platform/platform_ps3.c | 6 +- general.h | 20 +++-- gfx/context/ps3_ctx.c | 2 +- gfx/gl.c | 2 +- gx/gx_video.c | 6 +- settings.c | 130 ++++++++++++++++++++++++++----- xdk/xdk_d3d.cpp | 8 +- 10 files changed, 188 insertions(+), 85 deletions(-) diff --git a/console/rarch_console_settings.c b/console/rarch_console_settings.c index c08b9e0c97..882a15d101 100644 --- a/console/rarch_console_settings.c +++ b/console/rarch_console_settings.c @@ -62,15 +62,15 @@ void rarch_settings_change(unsigned setting) break; case S_OVERSCAN_DECREMENT: g_extern.console.screen.overscan_amount -= 0.01f; - g_extern.console.screen.state.overscan.enable = true; + g_extern.lifecycle_menu_state |= (1 << MODE_VIDEO_OVERSCAN_ENABLE); if(g_extern.console.screen.overscan_amount == 0.0f) - g_extern.console.screen.state.overscan.enable = false; + g_extern.lifecycle_menu_state &= ~(1 << MODE_VIDEO_OVERSCAN_ENABLE); break; case S_OVERSCAN_INCREMENT: g_extern.console.screen.overscan_amount += 0.01f; - g_extern.console.screen.state.overscan.enable = true; + g_extern.lifecycle_menu_state |= (1 << MODE_VIDEO_OVERSCAN_ENABLE); if(g_extern.console.screen.overscan_amount == 0.0f) - g_extern.console.screen.state.overscan.enable = 0; + g_extern.lifecycle_menu_state &= ~(1 << MODE_VIDEO_OVERSCAN_ENABLE); break; case S_RESOLUTION_PREVIOUS: if (g_extern.console.screen.resolutions.current.idx) @@ -117,12 +117,18 @@ void rarch_settings_change(unsigned setting) break; case S_THROTTLE: if(!g_extern.system.force_nonblock) - g_extern.console.screen.state.throttle.enable = - !g_extern.console.screen.state.throttle.enable; + { + if (g_extern.lifecycle_menu_state & (1 << MODE_VIDEO_THROTTLE_ENABLE)) + g_extern.lifecycle_menu_state &= ~(1 << MODE_VIDEO_THROTTLE_ENABLE); + else + g_extern.lifecycle_menu_state |= (1 << MODE_VIDEO_THROTTLE_ENABLE); + } break; case S_TRIPLE_BUFFERING: - g_extern.console.screen.state.triple_buffering.enable = - !g_extern.console.screen.state.triple_buffering.enable; + if (g_extern.lifecycle_menu_state & (1 << MODE_VIDEO_TRIPLE_BUFFERING_ENABLE)) + g_extern.lifecycle_menu_state &= ~(1 << MODE_VIDEO_TRIPLE_BUFFERING_ENABLE); + else + g_extern.lifecycle_menu_state |= (1 << MODE_VIDEO_TRIPLE_BUFFERING_ENABLE); break; } } @@ -154,17 +160,17 @@ void rarch_settings_default(unsigned setting) break; case S_DEF_OVERSCAN: g_extern.console.screen.overscan_amount = 0.0f; - g_extern.console.screen.state.overscan.enable = false; + g_extern.lifecycle_menu_state &= ~(1 << MODE_VIDEO_OVERSCAN_ENABLE); break; case S_DEF_ROTATION: g_extern.console.screen.orientation = ORIENTATION_NORMAL; break; case S_DEF_THROTTLE: if(!g_extern.system.force_nonblock) - g_extern.console.screen.state.throttle.enable = true; + g_extern.lifecycle_menu_state |= (1 << MODE_VIDEO_THROTTLE_ENABLE); break; case S_DEF_TRIPLE_BUFFERING: - g_extern.console.screen.state.triple_buffering.enable = true; + g_extern.lifecycle_menu_state |= (1 << MODE_VIDEO_TRIPLE_BUFFERING_ENABLE); break; case S_DEF_SAVE_STATE: g_extern.state_slot = 0; diff --git a/frontend/menu/rgui.c b/frontend/menu/rgui.c index 5e767a9b8c..6d585d515d 100644 --- a/frontend/menu/rgui.c +++ b/frontend/menu/rgui.c @@ -428,7 +428,7 @@ static void render_text(rgui_handle_t *rgui) break; #ifdef HW_RVL case RGUI_SETTINGS_VIDEO_SOFT_FILTER: - snprintf(type_str, sizeof(type_str), g_extern.console.screen.state.soft_filter.enable ? "ON" : "OFF"); + snprintf(type_str, sizeof(type_str), (g_extern.lifecycle_menu_state & (1 << MODE_VIDEO_SOFT_FILTER_ENABLE)) ? "ON" : "OFF"); break; #endif #ifdef GEKKO @@ -625,7 +625,10 @@ static int rgui_settings_toggle_setting(rgui_file_type_t setting, rgui_action_t #ifdef HW_RVL case RGUI_SETTINGS_VIDEO_SOFT_FILTER: { - g_extern.console.screen.state.soft_filter.enable = !g_extern.console.screen.state.soft_filter.enable; + if (g_extern.lifecycle_menu_state & (1 << MODE_VIDEO_SOFT_FILTER_ENABLE)) + g_extern.lifecycle_menu_state &= ~(1 << MODE_VIDEO_SOFT_FILTER_ENABLE); + else + g_extern.lifecycle_menu_state |= (1 << MODE_VIDEO_SOFT_FILTER_ENABLE); driver.video->apply_state_changes(); } break; diff --git a/frontend/menu/rmenu.c b/frontend/menu/rmenu.c index cf5e3c1274..f219718ebb 100644 --- a/frontend/menu/rmenu.c +++ b/frontend/menu/rmenu.c @@ -201,7 +201,7 @@ static void populate_setting_item(void *data, unsigned input) #ifdef _XBOX1 case SETTING_FLICKER_FILTER: snprintf(current_item->text, sizeof(current_item->text), "Flicker Filter"); - snprintf(current_item->setting_text, sizeof(current_item->setting_text), "%d", g_extern.console.screen.state.flicker_filter.enable); + snprintf(current_item->setting_text, sizeof(current_item->setting_text), "%d", (g_extern.lifecycle_menu_state & (1 << MODE_VIDEO_FLICKER_FILTER_ENABLE) ? true : false)); snprintf(current_item->comment, sizeof(current_item->comment), "INFO - Toggle the [Flicker Filter]."); break; case SETTING_SOFT_DISPLAY_FILTER: @@ -217,18 +217,18 @@ static void populate_setting_item(void *data, unsigned input) break; case SETTING_THROTTLE_MODE: snprintf(current_item->text, sizeof(current_item->text), "Throttle Mode"); - snprintf(current_item->setting_text, sizeof(current_item->setting_text), g_extern.console.screen.state.throttle.enable ? "ON" : "OFF"); - snprintf(current_item->comment, sizeof(current_item->comment), g_extern.console.screen.state.throttle.enable ? "INFO - [Throttle Mode] is 'ON' - Vsync is enabled." : "INFO - [Throttle Mode] is 'OFF' - Vsync is disabled."); + snprintf(current_item->setting_text, sizeof(current_item->setting_text), (g_extern.lifecycle_menu_state & (1 << MODE_VIDEO_THROTTLE_ENABLE)) ? "ON" : "OFF"); + snprintf(current_item->comment, sizeof(current_item->comment), (g_extern.lifecycle_menu_state & (1 << MODE_VIDEO_THROTTLE_ENABLE)) ? "INFO - [Throttle Mode] is 'ON' - Vsync is enabled." : "INFO - [Throttle Mode] is 'OFF' - Vsync is disabled."); break; case SETTING_TRIPLE_BUFFERING: snprintf(current_item->text, sizeof(current_item->text), "Triple Buffering"); - snprintf(current_item->setting_text, sizeof(current_item->setting_text), g_extern.console.screen.state.triple_buffering.enable ? "ON" : "OFF"); - snprintf(current_item->comment, sizeof(current_item->comment), g_extern.console.screen.state.triple_buffering.enable ? "INFO - [Triple Buffering] is set to 'ON'." : "INFO - [Triple Buffering] is set to 'OFF'."); + snprintf(current_item->setting_text, sizeof(current_item->setting_text), (g_extern.lifecycle_menu_state & (1 << MODE_VIDEO_TRIPLE_BUFFERING_ENABLE)) ? "ON" : "OFF"); + snprintf(current_item->comment, sizeof(current_item->comment), (g_extern.lifecycle_menu_state & (1 << MODE_VIDEO_TRIPLE_BUFFERING_ENABLE)) ? "INFO - [Triple Buffering] is set to 'ON'." : "INFO - [Triple Buffering] is set to 'OFF'."); break; case SETTING_ENABLE_SCREENSHOTS: snprintf(current_item->text, sizeof(current_item->text), "Screenshot Option"); - snprintf(current_item->setting_text, sizeof(current_item->setting_text), g_extern.console.screen.state.screenshots.enable ? "ON" : "OFF"); - snprintf(current_item->comment, sizeof(current_item->comment), "INFO - Screenshots feature is set to '%s'.", g_extern.console.screen.state.screenshots.enable ? "ON" : "OFF"); + snprintf(current_item->setting_text, sizeof(current_item->setting_text), (g_extern.lifecycle_menu_state & (1 << MODE_VIDEO_SCREENSHOTS_ENABLE)) ? "ON" : "OFF"); + snprintf(current_item->comment, sizeof(current_item->comment), "INFO - Screenshots feature is set to '%s'.", (g_extern.lifecycle_menu_state & (1 << MODE_VIDEO_SCREENSHOTS_ENABLE)) ? "ON" : "OFF"); break; #if defined(HAVE_CG) || defined(HAVE_HLSL) || defined(HAVE_GLSL) case SETTING_APPLY_SHADER_PRESET_ON_STARTUP: @@ -353,8 +353,8 @@ static void populate_setting_item(void *data, unsigned input) #endif case SETTING_ENABLE_CUSTOM_BGM: snprintf(current_item->text, sizeof(current_item->text), "Custom BGM Option"); - snprintf(current_item->setting_text, sizeof(current_item->setting_text), g_extern.console.sound.custom_bgm.enable ? "ON" : "OFF"); - snprintf(current_item->comment, sizeof(current_item->comment), "INFO - [Custom BGM] is set to '%s'.", g_extern.console.sound.custom_bgm.enable ? "ON" : "OFF"); + snprintf(current_item->setting_text, sizeof(current_item->setting_text), (g_extern.lifecycle_menu_state & (1 << MODE_AUDIO_CUSTOM_BGM_ENABLE)) ? "ON" : "OFF"); + snprintf(current_item->comment, sizeof(current_item->comment), "INFO - [Custom BGM] is set to '%s'.", (g_extern.lifecycle_menu_state & (1 << MODE_AUDIO_CUSTOM_BGM_ENABLE)) ? "ON" : "OFF"); break; case SETTING_PATH_DEFAULT_ROM_DIRECTORY: snprintf(current_item->text, sizeof(current_item->text), "Startup ROM Directory"); @@ -1225,22 +1225,27 @@ static int set_setting_action(void *data, unsigned switchvalue, uint64_t input) case SETTING_FLICKER_FILTER: if(input & (1ULL << RMENU_DEVICE_NAV_LEFT)) { - if(g_extern.console.screen.state.flicker_filter.value > 0) - g_extern.console.screen.state.flicker_filter.value--; + if(g_extern.console.screen.flicker_filter_index > 0) + g_extern.console.screen.flicker_filter_index--; } if(input & (1ULL << RMENU_DEVICE_NAV_RIGHT)) { - if(g_extern.console.screen.state.flicker_filter.value < 5) - g_extern.console.screen.state.flicker_filter.value++; + if(g_extern.console.screen.flicker_filter_index < 5) + g_extern.console.screen.flicker_filter_index++; } if(input & (1ULL << RMENU_DEVICE_NAV_START)) - g_extern.console.screen.state.flicker_filter.value = 0; + g_extern.console.screen.flicker_filter_index = 0; break; case SETTING_SOFT_DISPLAY_FILTER: if(input & (1ULL << RMENU_DEVICE_NAV_LEFT) || (input & (1ULL << RMENU_DEVICE_NAV_RIGHT)) || (input & (1ULL << RMENU_DEVICE_NAV_B))) - g_extern.console.screen.state.soft_filter.enable = !g_extern.console.screen.state.soft_filter.enable; + { + if (g_extern.lifecycle_menu_state & (1 << MODE_VIDEO_SOFT_FILTER_ENABLE)) + g_extern.lifecycle_menu_state &= ~(1 << MODE_VIDEO_SOFT_FILTER_ENABLE); + else + g_extern.lifecycle_menu_state |= (1 << MODE_VIDEO_SOFT_FILTER_ENABLE); + } if(input & (1ULL << RMENU_DEVICE_NAV_START)) - g_extern.console.screen.state.soft_filter.enable = true; + g_extern.lifecycle_menu_state |= (1 << MODE_VIDEO_SOFT_FILTER_ENABLE); break; #endif case SETTING_HW_OVERSCAN_AMOUNT: @@ -1264,12 +1269,12 @@ static int set_setting_action(void *data, unsigned switchvalue, uint64_t input) if((input & (1ULL << RMENU_DEVICE_NAV_LEFT)) || (input & (1ULL << RMENU_DEVICE_NAV_RIGHT)) || (input & (1ULL << RMENU_DEVICE_NAV_B))) { rarch_settings_change(S_THROTTLE); - device_ptr->ctx_driver->swap_interval(g_extern.console.screen.state.throttle.enable); + device_ptr->ctx_driver->swap_interval((g_extern.lifecycle_menu_state & (1 << MODE_VIDEO_THROTTLE_ENABLE))); } if(input & (1ULL << RMENU_DEVICE_NAV_START)) { rarch_settings_default(S_DEF_THROTTLE); - device_ptr->ctx_driver->swap_interval(g_extern.console.screen.state.throttle.enable); + device_ptr->ctx_driver->swap_interval((g_extern.lifecycle_menu_state & (1 << MODE_VIDEO_THROTTLE_ENABLE))); } break; case SETTING_TRIPLE_BUFFERING: @@ -1280,23 +1285,25 @@ static int set_setting_action(void *data, unsigned switchvalue, uint64_t input) } if(input & (1ULL << RMENU_DEVICE_NAV_START)) { - bool old_buffer_input = g_extern.console.screen.state.triple_buffering.enable; rarch_settings_default(S_DEF_TRIPLE_BUFFERING); - if(!old_buffer_input) + if(!(g_extern.lifecycle_menu_state & (1 << MODE_VIDEO_TRIPLE_BUFFERING_ENABLE))) driver.video->restart(); } break; case SETTING_ENABLE_SCREENSHOTS: if((input & (1ULL << RMENU_DEVICE_NAV_LEFT)) || (input & (1ULL << RMENU_DEVICE_NAV_RIGHT)) || (input & (1ULL << RMENU_DEVICE_NAV_B))) { - g_extern.console.screen.state.screenshots.enable = !g_extern.console.screen.state.screenshots.enable; - device_ptr->ctx_driver->rmenu_screenshot_enable(g_extern.console.screen.state.screenshots.enable); + if (g_extern.lifecycle_menu_state & (1 << MODE_VIDEO_SCREENSHOTS_ENABLE)) + g_extern.lifecycle_menu_state &= ~(1 << MODE_VIDEO_SCREENSHOTS_ENABLE); + else + g_extern.lifecycle_menu_state |= (1 << MODE_VIDEO_SCREENSHOTS_ENABLE); + device_ptr->ctx_driver->rmenu_screenshot_enable((g_extern.lifecycle_menu_state & (1 << MODE_VIDEO_SCREENSHOTS_ENABLE))); } if(input & (1ULL << RMENU_DEVICE_NAV_START)) { - g_extern.console.screen.state.screenshots.enable = true; - device_ptr->ctx_driver->rmenu_screenshot_enable(g_extern.console.screen.state.screenshots.enable); + g_extern.lifecycle_menu_state |= (1 << MODE_VIDEO_SCREENSHOTS_ENABLE); + device_ptr->ctx_driver->rmenu_screenshot_enable((g_extern.lifecycle_menu_state & (1 << MODE_VIDEO_SCREENSHOTS_ENABLE))); } break; #if defined(HAVE_CG) || defined(HAVE_HLSL) || defined(HAVE_GLSL) @@ -1460,8 +1467,11 @@ static int set_setting_action(void *data, unsigned switchvalue, uint64_t input) if((input & (1ULL << RMENU_DEVICE_NAV_LEFT)) || (input & (1ULL << RMENU_DEVICE_NAV_RIGHT)) || (input & (1ULL << RMENU_DEVICE_NAV_B))) { #if(CELL_SDK_VERSION > 0x340000) - g_extern.console.sound.custom_bgm.enable = !g_extern.console.sound.custom_bgm.enable; - if(g_extern.console.sound.custom_bgm.enable) + if (g_extern.lifecycle_menu_state & (1 << MODE_AUDIO_CUSTOM_BGM_ENABLE)) + g_extern.lifecycle_menu_state &= ~(1 << MODE_AUDIO_CUSTOM_BGM_ENABLE); + else + g_extern.lifecycle_menu_state |= (1 << MODE_AUDIO_CUSTOM_BGM_ENABLE); + if (g_extern.lifecycle_menu_state & (1 << MODE_AUDIO_CUSTOM_BGM_ENABLE)) cellSysutilEnableBgmPlayback(); else cellSysutilDisableBgmPlayback(); @@ -1471,7 +1481,7 @@ static int set_setting_action(void *data, unsigned switchvalue, uint64_t input) if(input & (1ULL << RMENU_DEVICE_NAV_START)) { #if(CELL_SDK_VERSION > 0x340000) - g_extern.console.sound.custom_bgm.enable = true; + g_extern.lifecycle_menu_state |= (1 << MODE_AUDIO_CUSTOM_BGM_ENABLE); #endif } break; diff --git a/frontend/platform/platform_ps3.c b/frontend/platform/platform_ps3.c index befc7f9958..0ac9e0088c 100644 --- a/frontend/platform/platform_ps3.c +++ b/frontend/platform/platform_ps3.c @@ -357,7 +357,7 @@ static void system_init(void) static void system_post_init(void) { #if (CELL_SDK_VERSION > 0x340000) && !defined(__PSL1GHT__) - if (g_extern.console.screen.state.screenshots.enable) + if (g_extern.lifecycle_menu_state & (1 << MODE_VIDEO_SCREENSHOTS_ENABLE)) { #ifdef HAVE_SYSMODULES cellSysmoduleLoadModule(CELL_SYSMODULE_SYSUTIL_SCREENSHOT); @@ -372,7 +372,7 @@ static void system_post_init(void) #endif } #ifdef HAVE_SYSUTILS - if (g_extern.console.sound.custom_bgm.enable) + if (g_extern.lifecycle_menu_state & (1 << MODE_AUDIO_CUSTOM_BGM_ENABLE)) cellSysutilEnableBgmPlayback(); #endif #endif @@ -422,7 +422,7 @@ static void system_deinit(void) #ifndef __PSL1GHT__ /* screenshot PRX */ - if(g_extern.console.screen.state.screenshots.enable) + if (g_extern.lifecycle_menu_state & (1 << MODE_VIDEO_SCREENSHOTS_ENABLE)) cellSysmoduleUnloadModule(CELL_SYSMODULE_SYSUTIL_SCREENSHOT); #endif diff --git a/general.h b/general.h index 1e7f944839..3f8db3a612 100644 --- a/general.h +++ b/general.h @@ -120,6 +120,13 @@ enum menu_enums MODE_EXITSPAWN, MODE_LOAD_FIRST_SHADER, MODE_LOAD_SECOND_SHADER, + MODE_VIDEO_TRIPLE_BUFFERING_ENABLE, + MODE_VIDEO_FLICKER_FILTER_ENABLE, + MODE_VIDEO_SOFT_FILTER_ENABLE, + MODE_VIDEO_SCREENSHOTS_ENABLE, + MODE_VIDEO_THROTTLE_ENABLE, + MODE_VIDEO_OVERSCAN_ENABLE, + MODE_AUDIO_CUSTOM_BGM_ENABLE, }; // All config related settings go here. @@ -525,21 +532,12 @@ struct global unsigned orientation; float overscan_amount; unsigned gamma_correction; - - struct - { - rarch_boolean_state_t triple_buffering; - rarch_boolean_state_t overscan; - rarch_boolean_state_t flicker_filter; - rarch_boolean_state_t soft_filter; - rarch_boolean_state_t screenshots; - rarch_boolean_state_t throttle; - } state; + unsigned char flicker_filter_index; + unsigned char soft_filter_index; } screen; struct { - rarch_boolean_state_t custom_bgm; unsigned mode; #ifdef _XBOX1 unsigned volume_level; diff --git a/gfx/context/ps3_ctx.c b/gfx/context/ps3_ctx.c index db7717294d..3690160c26 100644 --- a/gfx/context/ps3_ctx.c +++ b/gfx/context/ps3_ctx.c @@ -417,7 +417,7 @@ static bool gfx_ctx_init(void) params.depthFormat = GL_NONE; params.multisamplingMode = GL_MULTISAMPLING_NONE_SCE; - if (g_extern.console.screen.state.triple_buffering.enable) + if (g_extern.lifecycle_menu_state & (1 << MODE_VIDEO_TRIPLE_BUFFERING_ENABLE)) { params.enable |= PSGL_DEVICE_PARAMETERS_BUFFERING_MODE; params.bufferingMode = PSGL_BUFFERING_MODE_TRIPLE; diff --git a/gfx/gl.c b/gfx/gl.c index d36a141f9e..c38240e263 100644 --- a/gfx/gl.c +++ b/gfx/gl.c @@ -633,7 +633,7 @@ void gl_set_projection(void *data, struct gl_ortho *ortho, bool allow_rotate) { gl_t *gl = (gl_t*)data; #ifdef RARCH_CONSOLE - if (g_extern.console.screen.state.overscan.enable) + if (g_extern.lifecycle_menu_state & (1 << MODE_VIDEO_OVERSCAN_ENABLE)) { ortho->left = -g_extern.console.screen.overscan_amount / 2; ortho->right = 1 + g_extern.console.screen.overscan_amount / 2; diff --git a/gx/gx_video.c b/gx/gx_video.c index bd08bde8af..14283a0a3e 100644 --- a/gx/gx_video.c +++ b/gx/gx_video.c @@ -683,9 +683,10 @@ static void gx_resize(void *data) int x = 0, y = 0; unsigned width = gx->win_width, height = gx->win_height; + u32 lifecycle_menu_state = g_extern.lifecycle_menu_state; #ifdef HW_RVL - VIDEO_SetTrapFilter(g_extern.console.screen.state.soft_filter.enable); + VIDEO_SetTrapFilter(lifecycle_menu_state & (1 << MODE_VIDEO_SOFT_FILTER_ENABLE)); #endif GX_SetDispCopyGamma(g_extern.console.screen.gamma_correction); @@ -746,7 +747,8 @@ static void gx_resize(void *data) Mtx44 m1, m2; float top = 1, bottom = -1, left = -1, right = 1; - if (g_extern.console.screen.state.overscan.enable) + + if (g_extern.lifecycle_menu_state & (1 << MODE_VIDEO_OVERSCAN_ENABLE)) { top -= g_extern.console.screen.overscan_amount / 2; left += g_extern.console.screen.overscan_amount / 2; diff --git a/settings.c b/settings.c index 903aa2ed5f..21b331d73e 100644 --- a/settings.c +++ b/settings.c @@ -256,14 +256,16 @@ void config_set_defaults(void) // g_extern strlcpy(g_extern.console.main_wrap.paths.default_sram_dir, default_paths.sram_dir, sizeof(g_extern.console.main_wrap.paths.default_sram_dir)); - g_extern.console.screen.state.overscan.enable = false; g_extern.console.screen.overscan_amount = 0.0f; - g_extern.console.sound.custom_bgm.enable = true; g_extern.console.screen.gamma_correction = DEFAULT_GAMMA; - g_extern.console.screen.state.screenshots.enable = true; - g_extern.console.screen.state.throttle.enable = true; + g_extern.lifecycle_menu_state |= (1 << MODE_VIDEO_OVERSCAN_ENABLE); + g_extern.lifecycle_menu_state |= (1 << MODE_AUDIO_CUSTOM_BGM_ENABLE); + g_extern.lifecycle_menu_state |= (1 << MODE_VIDEO_SCREENSHOTS_ENABLE); + g_extern.lifecycle_menu_state |= (1 << MODE_VIDEO_THROTTLE_ENABLE); + g_extern.lifecycle_menu_state |= (1 << MODE_VIDEO_TRIPLE_BUFFERING_ENABLE); + g_extern.lifecycle_menu_state |= (1 << MODE_VIDEO_SOFT_FILTER_ENABLE); + g_extern.lifecycle_menu_state |= (1 << MODE_VIDEO_FLICKER_FILTER_ENABLE); - g_extern.console.screen.state.triple_buffering.enable = true; g_extern.console.main_wrap.state.default_savestate_dir.enable = false; g_extern.console.main_wrap.state.default_sram_dir.enable = false; g_extern.console.screen.orientation = ORIENTATION_NORMAL; @@ -282,10 +284,8 @@ void config_set_defaults(void) g_extern.console.screen.viewports.custom_vp.x = 0; g_extern.console.screen.viewports.custom_vp.y = 0; #ifdef _XBOX1 - g_extern.console.screen.state.flicker_filter.enable = 1; g_extern.console.sound.volume_level = 0; #endif - g_extern.console.screen.state.soft_filter.enable = true; #ifdef HAVE_ZLIB g_extern.file_state.zip_extract_mode = 0; #endif @@ -474,6 +474,14 @@ bool config_load_file(const char *path) CONFIG_GET_BOOL_EXTERN(console.screen.gamma_correction, "gamma_correction"); bool msg_enable = false; + bool throttle_enable = false; + bool triple_buffering_enable = false; + bool custom_bgm_enable = false; + bool overscan_enable = false; + bool screenshots_enable = false; + bool flicker_filter_enable = false; + bool soft_filter_enable = false; + if (config_get_bool(conf, "info_msg_enable", &msg_enable)) { if (msg_enable) @@ -482,16 +490,68 @@ bool config_load_file(const char *path) g_extern.lifecycle_menu_state &= ~(1 << MODE_INFO_DRAW); } - CONFIG_GET_BOOL_EXTERN(console.screen.state.screenshots.enable, "screenshots_enable"); - CONFIG_GET_BOOL_EXTERN(console.screen.state.throttle.enable, "throttle_enable"); - CONFIG_GET_BOOL_EXTERN(console.screen.state.triple_buffering.enable, "triple_buffering_enable"); - CONFIG_GET_BOOL_EXTERN(console.screen.state.overscan.enable, "overscan_enable"); - CONFIG_GET_BOOL_EXTERN(console.sound.custom_bgm.enable, "custom_bgm_enable"); + if (config_get_bool(conf, "throttle_enable", &throttle_enable)) + { + if (throttle_enable) + g_extern.lifecycle_menu_state |= (1 << MODE_VIDEO_THROTTLE_ENABLE); + else + g_extern.lifecycle_menu_state &= ~(1 << MODE_VIDEO_THROTTLE_ENABLE); + } + + if (config_get_bool(conf, "triple_buffering_enable", &triple_buffering_enable)) + { + if (triple_buffering_enable) + g_extern.lifecycle_menu_state |= (1 << MODE_VIDEO_TRIPLE_BUFFERING_ENABLE); + else + g_extern.lifecycle_menu_state &= ~(1 << MODE_VIDEO_TRIPLE_BUFFERING_ENABLE); + } + + if (config_get_bool(conf, "overscan_enable", &overscan_enable)) + { + if (overscan_enable) + g_extern.lifecycle_menu_state |= (1 << MODE_VIDEO_OVERSCAN_ENABLE); + else + g_extern.lifecycle_menu_state &= ~(1 << MODE_VIDEO_OVERSCAN_ENABLE); + } + + if (config_get_bool(conf, "custom_bgm_enable", &custom_bgm_enable)) + { + if (custom_bgm_enable) + g_extern.lifecycle_menu_state |= (1 << MODE_AUDIO_CUSTOM_BGM_ENABLE); + else + g_extern.lifecycle_menu_state &= ~(1 << MODE_AUDIO_CUSTOM_BGM_ENABLE); + } + + if (config_get_bool(conf, "screenshots_enable", &screenshots_enable)) + { + if (screenshots_enable) + g_extern.lifecycle_menu_state |= (1 << MODE_VIDEO_SCREENSHOTS_ENABLE); + else + g_extern.lifecycle_menu_state &= ~(1 << MODE_VIDEO_SCREENSHOTS_ENABLE); + } + + if (config_get_bool(conf, "flicker_filter_enable", &flicker_filter_enable)) + { + if (flicker_filter_enable) + g_extern.lifecycle_menu_state |= (1 << MODE_VIDEO_FLICKER_FILTER_ENABLE); + else + g_extern.lifecycle_menu_state &= ~(1 << MODE_VIDEO_FLICKER_FILTER_ENABLE); + } + + if (config_get_bool(conf, "soft_filter_enable", &soft_filter_enable)) + { + if (soft_filter_enable) + g_extern.lifecycle_menu_state |= (1 << MODE_VIDEO_SOFT_FILTER_ENABLE); + else + g_extern.lifecycle_menu_state &= ~(1 << MODE_VIDEO_SOFT_FILTER_ENABLE); + } + CONFIG_GET_BOOL_EXTERN(console.main_wrap.state.default_sram_dir.enable, "sram_dir_enable"); CONFIG_GET_BOOL_EXTERN(console.main_wrap.state.default_savestate_dir.enable, "savestate_dir_enable"); CONFIG_GET_FLOAT_EXTERN(console.screen.overscan_amount, "overscan_amount"); + CONFIG_GET_INT_EXTERN(console.screen.flicker_filter_index, "flicker_filter_index"); + CONFIG_GET_INT_EXTERN(console.screen.soft_filter_index, "soft_filter_index"); #ifdef _XBOX1 - CONFIG_GET_INT_EXTERN(console.screen.state.flicker_filter.enable, "flicker_filter"); CONFIG_GET_INT_EXTERN(console.sound.volume_level, "sound_volume_level"); #endif #ifdef HAVE_ZLIB @@ -500,7 +560,6 @@ bool config_load_file(const char *path) CONFIG_GET_INT_EXTERN(console.screen.resolutions.current.id, "current_resolution_id"); CONFIG_GET_INT_EXTERN(state_slot, "state_slot"); CONFIG_GET_INT_EXTERN(audio_data.mute, "audio_mute"); - CONFIG_GET_BOOL_EXTERN(console.screen.state.soft_filter.enable, "soft_display_filter_enable"); CONFIG_GET_INT_EXTERN(console.screen.orientation, "screen_orientation"); CONFIG_GET_INT_EXTERN(console.sound.mode, "sound_mode"); CONFIG_GET_INT_EXTERN(console.screen.viewports.custom_vp.x, "custom_viewport_x"); @@ -1092,21 +1151,47 @@ bool config_save_file(const char *path) config_set_float(conf, "audio_rate_control_delta", g_settings.audio.rate_control_delta); config_set_string(conf, "system_directory", g_settings.system_directory); - config_set_bool(conf, "overscan_enable", g_extern.console.screen.state.overscan.enable); - config_set_bool(conf, "screenshots_enable", g_extern.console.screen.state.screenshots.enable); + if (g_extern.lifecycle_menu_state & (1 << MODE_VIDEO_OVERSCAN_ENABLE)) + config_set_bool(conf, "overscan_enable", true); + else + config_set_bool(conf, "overscan_enable", false); + + if (g_extern.lifecycle_menu_state & (1 << MODE_VIDEO_SCREENSHOTS_ENABLE)) + config_set_bool(conf, "screenshots_enable", true); + else + config_set_bool(conf, "screenshots_enable", false); + config_set_bool(conf, "gamma_correction", g_extern.console.screen.gamma_correction); #ifdef _XBOX1 - config_set_int(conf, "flicker_filter", g_extern.console.screen.state.flicker_filter.value); config_set_int(conf, "sound_volume_level", g_extern.console.sound.volume_level); #endif - config_set_bool(conf, "throttle_enable", g_extern.console.screen.state.throttle.enable); - config_set_bool(conf, "triple_buffering_enable", g_extern.console.screen.state.triple_buffering.enable); + if (g_extern.lifecycle_menu_state & (1 << MODE_VIDEO_THROTTLE_ENABLE)) + config_set_bool(conf, "throttle_enable", true); + else + config_set_bool(conf, "throttle_enable", false); + + if (g_extern.lifecycle_menu_state & (1 << MODE_VIDEO_TRIPLE_BUFFERING_ENABLE)) + config_set_bool(conf, "triple_buffering_enable", true); + else + config_set_bool(conf, "triple_buffering_enable", false); if (g_extern.lifecycle_menu_state & (1 << MODE_INFO_DRAW)) config_set_bool(conf, "info_msg_enable", true); else config_set_bool(conf, "info_msg_enable", false); + if (g_extern.lifecycle_menu_state & (1 << MODE_VIDEO_SOFT_FILTER_ENABLE)) + config_set_bool(conf, "soft_filter_enable", true); + else + config_set_bool(conf, "soft_filter_enable", false); + + if (g_extern.lifecycle_menu_state & (1 << MODE_VIDEO_FLICKER_FILTER_ENABLE)) + config_set_bool(conf, "flicker_filter_enable", true); + else + config_set_bool(conf, "flicker_filter_enable", false); + + config_set_int(conf, "flicker_filter_index", g_extern.console.screen.flicker_filter_index); + config_set_int(conf, "soft_filter_index", g_extern.console.screen.soft_filter_index); config_set_int(conf, "current_resolution_id", g_extern.console.screen.resolutions.current.id); config_set_int(conf, "custom_viewport_width", g_extern.console.screen.viewports.custom_vp.width); config_set_int(conf, "custom_viewport_height", g_extern.console.screen.viewports.custom_vp.height); @@ -1123,9 +1208,12 @@ bool config_save_file(const char *path) config_set_int(conf, "sound_mode", g_extern.console.sound.mode); config_set_int(conf, "state_slot", g_extern.state_slot); config_set_int(conf, "audio_mute", g_extern.audio_data.mute); - config_set_bool(conf, "soft_display_filter_enable", g_extern.console.screen.state.soft_filter.enable); config_set_int(conf, "screen_orientation", g_extern.console.screen.orientation); - config_set_bool(conf, "custom_bgm_enable", g_extern.console.sound.custom_bgm.enable); + + if (g_extern.lifecycle_menu_state & (1 << MODE_AUDIO_CUSTOM_BGM_ENABLE)) + config_set_bool(conf, "custom_bgm_enable", true); + else + config_set_bool(conf, "custom_bgm_enable", false); config_set_bool(conf, "sram_dir_enable", g_extern.console.main_wrap.state.default_sram_dir.enable); config_set_bool(conf, "savestate_dir_enable", g_extern.console.main_wrap.state.default_savestate_dir.enable); diff --git a/xdk/xdk_d3d.cpp b/xdk/xdk_d3d.cpp index 792b79ecb4..421af44a5c 100644 --- a/xdk/xdk_d3d.cpp +++ b/xdk/xdk_d3d.cpp @@ -698,10 +698,6 @@ static bool xdk_d3d_frame(void *data, const void *frame, #ifdef HAVE_FBO D3DSurface* pRenderTarget0; #endif -#ifdef _XBOX1 - unsigned flicker_filter = g_extern.console.screen.state.flicker_filter.value; - bool soft_filter_enable = g_extern.console.screen.state.soft_filter.enable; -#endif d3dr->Clear(0, NULL, D3DCLEAR_TARGET, 0x00000000, 1.0f, 0); @@ -824,8 +820,8 @@ static bool xdk_d3d_frame(void *data, const void *frame, d3dr->Clear(0, NULL, D3DCLEAR_TARGET, 0xff000000, 1.0f, 0); d3dr->BeginScene(); - d3dr->SetFlickerFilter(flicker_filter); - d3dr->SetSoftDisplayFilter(soft_filter_enable); + d3dr->SetFlickerFilter(g_extern.console.screen.flicker_filter_index); + d3dr->SetSoftDisplayFilter(g_extern.lifecycle_menu_state & (1 << MODE_VIDEO_SOFT_FILTER_ENABLE)); d3dr->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2); d3dr->EndScene(); #elif defined(_XBOX360)