diff --git a/360/frontend-xdk/menu.cpp b/360/frontend-xdk/menu.cpp index bfc022a7e0..429e78ba48 100644 --- a/360/frontend-xdk/menu.cpp +++ b/360/frontend-xdk/menu.cpp @@ -248,7 +248,7 @@ HRESULT CRetroArchSettings::OnInit(XUIMessageInit * pInitData, BOOL& bHandled) m_settingslist.SetText(SETTING_EMU_REWIND_ENABLED, g_settings.rewind_enable ? L"Rewind: ON" : L"Rewind: OFF"); m_settingslist.SetText(SETTING_EMU_SHOW_INFO_MSG, g_console.info_msg_enable ? L"Info messages: ON" : L"Info messages: OFF"); m_settingslist.SetText(SETTING_EMU_MENUS, g_console.menus_hd_enable ? L"Menus: HD" : L"Menus: SD"); - m_settingslist.SetText(SETTING_GAMMA_CORRECTION_ENABLED, g_console.gamma_correction_enable ? L"Gamma correction: ON" : L"Gamma correction: OFF"); + m_settingslist.SetText(SETTING_GAMMA_CORRECTION_ENABLED, g_console.gamma_correction ? L"Gamma correction: ON" : L"Gamma correction: OFF"); m_settingslist.SetText(SETTING_HW_TEXTURE_FILTER, g_settings.video.smooth ? L"Hardware filtering shader #1: Linear interpolation" : L"Hardware filtering shader #1: Point filtering"); m_settingslist.SetText(SETTING_HW_TEXTURE_FILTER_2, g_settings.video.second_pass_smooth ? L"Hardware filtering shader #2: Linear interpolation" : L"Hardware filtering shader #2: Point filtering"); m_settingslist.SetText(SETTING_SCALE_ENABLED, g_console.fbo_enabled ? L"Custom Scaling/Dual Shaders: ON" : L"Custom Scaling/Dual Shaders: OFF"); @@ -672,8 +672,8 @@ HRESULT CRetroArchSettings::OnNotifyPress( HXUIOBJ hObjPressed, int & bHandled m_settingslist.SetText(SETTING_EMU_MENUS, g_console.menus_hd_enable ? L"Menus: HD" : L"Menus: SD"); break; case SETTING_GAMMA_CORRECTION_ENABLED: - g_console.gamma_correction_enable = !g_console.gamma_correction_enable; - m_settingslist.SetText(SETTING_GAMMA_CORRECTION_ENABLED, g_console.gamma_correction_enable ? L"Gamma correction: ON" : L"Gamma correction: OFF"); + g_console.gamma_correction = g_console.gamma_correction ? 0 : 1; + m_settingslist.SetText(SETTING_GAMMA_CORRECTION_ENABLED, g_console.gamma_correction ? L"Gamma correction: ON" : L"Gamma correction: OFF"); if(g_console.info_msg_enable) rarch_settings_msg(S_MSG_RESTART_RARCH, S_DELAY_180); break; diff --git a/360/xdk_d3d9.cpp b/360/xdk_d3d9.cpp index 87fba8ff55..acf656d7e2 100644 --- a/360/xdk_d3d9.cpp +++ b/360/xdk_d3d9.cpp @@ -456,13 +456,13 @@ static void xdk_d3d_init_fbo(xdk_d3d_video_t *d3d) } d3d->d3d_render_device->CreateTexture(512 * g_settings.video.fbo_scale_x, 512 * g_settings.video.fbo_scale_y, - 1, 0, g_console.gamma_correction_enable ? ( D3DFORMAT )MAKESRGBFMT( D3DFMT_A8R8G8B8 ) : D3DFMT_A8R8G8B8, + 1, 0, g_console.gamma_correction ? ( D3DFORMAT )MAKESRGBFMT( D3DFMT_A8R8G8B8 ) : D3DFMT_A8R8G8B8, 0, &d3d->lpTexture_ot , NULL ); d3d->d3d_render_device->CreateRenderTarget(512 * g_settings.video.fbo_scale_x, 512 * g_settings.video.fbo_scale_y, - g_console.gamma_correction_enable ? ( D3DFORMAT )MAKESRGBFMT( D3DFMT_A8R8G8B8 ) : D3DFMT_A8R8G8B8, D3DMULTISAMPLE_NONE, + g_console.gamma_correction ? ( D3DFORMAT )MAKESRGBFMT( D3DFMT_A8R8G8B8 ) : D3DFMT_A8R8G8B8, D3DMULTISAMPLE_NONE, 0, 0, &d3d->lpSurface, NULL); d3d->lpTexture_ot_as16srgb = *d3d->lpTexture_ot; @@ -504,7 +504,7 @@ static void *xdk_d3d_init(const video_info_t *video, const input_driver_t **inpu d3d->d3dpp.BackBufferWidth = d3d->video_mode.fIsHiDef ? 1280 : 640; d3d->d3dpp.BackBufferHeight = d3d->video_mode.fIsHiDef ? 720 : 480; - if(g_console.gamma_correction_enable) + if(g_console.gamma_correction) { d3d->d3dpp.BackBufferFormat = g_console.color_format ? (D3DFORMAT)MAKESRGBFMT(D3DFMT_A8R8G8B8) : (D3DFORMAT)MAKESRGBFMT(D3DFMT_LIN_A1R5G5B5); d3d->d3dpp.FrontBufferFormat = (D3DFORMAT)MAKESRGBFMT(D3DFMT_LE_X8R8G8B8); diff --git a/console/rarch_console_config.c b/console/rarch_console_config.c index 2278ac22fa..a6b9ea8ec6 100644 --- a/console/rarch_console_config.c +++ b/console/rarch_console_config.c @@ -98,9 +98,9 @@ void rarch_config_load(const char * conf_name, const char * libretro_dir_path, c CONFIG_GET_INT_CONSOLE(zip_extract_mode, "zip_extract_mode"); #endif #ifdef _XBOX360 - CONFIG_GET_BOOL_CONSOLE(gamma_correction_enable, "gamma_correction_enable"); CONFIG_GET_INT_CONSOLE(color_format, "color_format"); #endif + CONFIG_GET_BOOL_CONSOLE(gamma_correction, "gamma_correction"); #ifdef _XBOX1 CONFIG_GET_INT_CONSOLE(flicker_filter, "fliker_filter"); CONFIG_GET_BOOL_CONSOLE(soft_display_filter_enable, "soft_display_filter_enable"); @@ -156,8 +156,8 @@ void rarch_config_save(const char * conf_name) #endif config_set_bool(conf, "overscan_enable", g_console.overscan_enable); config_set_bool(conf, "screenshots_enable", g_console.screenshots_enable); + config_set_bool(conf, "gamma_correction", g_console.gamma_correction); #ifdef _XBOX360 - config_set_bool(conf, "gamma_correction_enable", g_console.gamma_correction_enable); config_set_int(conf, "color_format", g_console.color_format); #endif #ifdef _XBOX1 diff --git a/console/rarch_console_settings.c b/console/rarch_console_settings.c index aad9a1d802..8101230fae 100644 --- a/console/rarch_console_settings.c +++ b/console/rarch_console_settings.c @@ -384,7 +384,9 @@ void rarch_settings_set_default (const input_driver_t *input) g_console.info_msg_enable = true; #ifdef _XBOX360 g_console.color_format = 0; - g_console.gamma_correction_enable = 1; +#endif +#if defined(_XBOX360) || defined(GEKKO) + g_console.gamma_correction = 1; #endif #ifdef _XBOX1 g_console.flicker_filter = 1; diff --git a/console/rgui/rgui.c b/console/rgui/rgui.c index 06f4296b42..18060985df 100644 --- a/console/rgui/rgui.c +++ b/console/rgui/rgui.c @@ -319,6 +319,9 @@ static void render_text(rgui_handle_t *rgui) case RGUI_SETTINGS_VIDEO_FILTER: snprintf(type_str, sizeof(type_str), g_settings.video.smooth ? "Bilinear filtering" : "Point filtering"); break; + case RGUI_SETTINGS_VIDEO_GAMMA: + snprintf(type_str, sizeof(type_str), "%d", g_console.gamma_correction); + break; case RGUI_SETTINGS_VIDEO_ROTATION: { char rotate_msg[64]; @@ -378,9 +381,19 @@ static void render_text(rgui_handle_t *rgui) render_messagebox(rgui, msg_queue_pull(g_extern.msg_queue)); } +#ifdef GEKKO +#define MAX_GAMMA_SETTING 2 +#else +#define MAX_GAMMA_SETTING 1 +#endif + static void rgui_settings_toggle_setting(rgui_file_type_t setting, rgui_action_t action, rgui_file_type_t menu_type) { unsigned port = menu_type - RGUI_SETTINGS_CONTROLLER_1; +#ifdef GEKKO + gx_video_t *gx = (gx_video_t*)driver.video_data; +#endif + switch (setting) { case RGUI_SETTINGS_VIDEO_FILTER: @@ -389,6 +402,35 @@ static void rgui_settings_toggle_setting(rgui_file_type_t setting, rgui_action_t else rarch_settings_change(S_HW_TEXTURE_FILTER); break; + case RGUI_SETTINGS_VIDEO_GAMMA: + if (action == RGUI_ACTION_START) + { + g_console.gamma_correction = 0; +#ifdef GEKKO + gx->should_resize = true; +#endif + } + else if (action == RGUI_ACTION_LEFT) + { + if(g_console.gamma_correction > 0) + { + g_console.gamma_correction--; +#ifdef GEKKO + gx->should_resize = true; +#endif + } + } + else if (action == RGUI_ACTION_RIGHT) + { + if(g_console.gamma_correction < MAX_GAMMA_SETTING) + { + g_console.gamma_correction++; +#ifdef GEKKO + gx->should_resize = true; +#endif + } + } + break; case RGUI_SETTINGS_VIDEO_ROTATION: if (action == RGUI_ACTION_START) { @@ -500,6 +542,7 @@ static void rgui_settings_populate_entries(rgui_handle_t *rgui) rgui_list_clear(rgui->folder_buf); RGUI_MENU_ITEM("Hardware filtering", RGUI_SETTINGS_VIDEO_FILTER); + RGUI_MENU_ITEM("Gamma", RGUI_SETTINGS_VIDEO_GAMMA); RGUI_MENU_ITEM("Rotation", RGUI_SETTINGS_VIDEO_ROTATION); RGUI_MENU_ITEM("Mute Audio", RGUI_SETTINGS_AUDIO_MUTE); RGUI_MENU_ITEM("Audio Control Rate", RGUI_SETTINGS_AUDIO_CONTROL_RATE); diff --git a/console/rgui/rgui.h b/console/rgui/rgui.h index 0f7a895300..7f79cca320 100644 --- a/console/rgui/rgui.h +++ b/console/rgui/rgui.h @@ -34,6 +34,7 @@ typedef enum // settings options are done here too RGUI_SETTINGS_VIDEO_FILTER, + RGUI_SETTINGS_VIDEO_GAMMA, RGUI_SETTINGS_VIDEO_ROTATION, RGUI_SETTINGS_AUDIO_MUTE, RGUI_SETTINGS_AUDIO_CONTROL_RATE, diff --git a/general.h b/general.h index cae185b275..654f859ed4 100644 --- a/general.h +++ b/general.h @@ -193,10 +193,10 @@ struct settings #ifdef RARCH_CONSOLE typedef struct { - uint32_t x; - uint32_t y; - uint32_t width; - uint32_t height; + unsigned x; + unsigned y; + unsigned width; + unsigned height; } rarch_viewport_t; struct console_settings @@ -218,7 +218,6 @@ struct console_settings #endif bool initialize_rarch_enable; bool info_msg_enable; - bool gamma_correction_enable; bool ingame_menu_enable; bool menu_enable; bool overscan_enable; @@ -227,31 +226,32 @@ struct console_settings bool throttle_enable; bool triple_buffering_enable; float overscan_amount; - uint32_t aspect_ratio_index; + unsigned aspect_ratio_index; struct { rarch_viewport_t custom_vp; } viewports; - uint32_t emulator_initialized; - uint32_t external_launcher_support; - uint32_t screen_orientation; - uint32_t current_resolution_index; - uint32_t current_resolution_id; - uint32_t ingame_menu_item; - uint32_t initial_resolution_id; - uint32_t map_dpad_to_stick; - uint32_t mode_switch; - uint32_t sound_mode; + unsigned gamma_correction; + unsigned emulator_initialized; + unsigned external_launcher_support; + unsigned screen_orientation; + unsigned current_resolution_index; + unsigned current_resolution_id; + unsigned ingame_menu_item; + unsigned initial_resolution_id; + unsigned map_dpad_to_stick; + unsigned mode_switch; + unsigned sound_mode; uint32_t *supported_resolutions; - uint32_t supported_resolutions_count; - uint32_t control_timer_expiration_frame_count; - uint32_t timer_expiration_frame_count; - uint32_t input_loop; + unsigned supported_resolutions_count; + unsigned control_timer_expiration_frame_count; + unsigned timer_expiration_frame_count; + unsigned input_loop; #ifdef HAVE_ZLIB - uint32_t zip_extract_mode; + unsigned zip_extract_mode; #endif #ifdef _XBOX - uint32_t color_format; + unsigned color_format; DWORD volume_device_type; #endif char cgp_path[PATH_MAX]; diff --git a/gx/gx_video.c b/gx/gx_video.c index 968fa32a64..5112e56967 100644 --- a/gx/gx_video.c +++ b/gx/gx_video.c @@ -226,7 +226,7 @@ static void gx_start(void) setup_video_mode(mode); GX_Init(gx_fifo, sizeof(gx_fifo)); - GX_SetDispCopyGamma(GX_GM_1_0); + GX_SetDispCopyGamma(g_console.gamma_correction); GX_SetCullMode(GX_CULL_NONE); GX_SetClipMode(GX_CLIP_DISABLE); @@ -421,6 +421,7 @@ static bool wii_frame(void *data, const void *frame, { gx_video_t *gx = (gx_video_t*)driver.video_data; bool menu_render = gx->menu_render; + bool should_resize = gx->should_resize; (void)data; (void)msg; @@ -430,6 +431,12 @@ static bool wii_frame(void *data, const void *frame, gx->frame_count++; + if(should_resize) + { + GX_SetDispCopyGamma(g_console.gamma_correction); + gx->should_resize = false; + } + while (g_vsync && !g_draw_done) LWP_ThreadSleep(g_video_cond); diff --git a/gx/gx_video.h b/gx/gx_video.h index 8a1b5bd5b7..118f670ab2 100644 --- a/gx/gx_video.h +++ b/gx/gx_video.h @@ -19,6 +19,7 @@ typedef struct gx_video { bool menu_render; + bool should_resize; uint32_t frame_count; uint32_t *menu_data; } gx_video_t;