From b48322222abe1f4fab58c70b443a551c8ab41d3a Mon Sep 17 00:00:00 2001 From: Themaister Date: Thu, 5 May 2011 14:13:12 +0200 Subject: [PATCH] Add overscan cropping. --- config.def.h | 3 +++ general.h | 1 + settings.c | 2 ++ ssnes.c | 16 +++++++++++++++- ssnes.cfg | 3 +++ 5 files changed, 24 insertions(+), 1 deletion(-) diff --git a/config.def.h b/config.def.h index e671f4058a..a912edc37b 100644 --- a/config.def.h +++ b/config.def.h @@ -120,6 +120,9 @@ static const bool video_smooth = true; // On resize and fullscreen, rendering area will stay 4:3 static const bool force_aspect = true; +// Crop overscanned frames (7/8 or 15/15 for interlaced frames). +static const bool crop_overscan = false; + // Font size for on-screen messages. static const unsigned font_size = 48; diff --git a/general.h b/general.h index f1d7e3033e..9259945202 100644 --- a/general.h +++ b/general.h @@ -68,6 +68,7 @@ struct settings bool vsync; bool smooth; bool force_aspect; + bool crop_overscan; float aspect_ratio; char cg_shader_path[256]; char bsnes_shader_path[256]; diff --git a/settings.c b/settings.c index acf6c0d414..1f82900efa 100644 --- a/settings.c +++ b/settings.c @@ -112,6 +112,7 @@ static void set_defaults(void) g_settings.video.vsync = vsync; g_settings.video.smooth = video_smooth; g_settings.video.force_aspect = force_aspect; + g_settings.video.crop_overscan = crop_overscan; g_settings.video.aspect_ratio = SNES_ASPECT_RATIO; g_settings.video.shader_type = SSNES_SHADER_AUTO; @@ -290,6 +291,7 @@ static void parse_config_file(void) CONFIG_GET_BOOL(video.vsync, "video_vsync"); CONFIG_GET_BOOL(video.smooth, "video_smooth"); CONFIG_GET_BOOL(video.force_aspect, "video_force_aspect"); + CONFIG_GET_BOOL(video.crop_overscan, "video_crop_overscan"); CONFIG_GET_DOUBLE(video.aspect_ratio, "video_aspect_ratio"); CONFIG_GET_STRING(video.cg_shader_path, "video_cg_shader"); diff --git a/ssnes.c b/ssnes.c index 9f2f85c8a8..87d897ea25 100644 --- a/ssnes.c +++ b/ssnes.c @@ -82,9 +82,23 @@ static void set_fast_forward_button(bool new_button_state) // Format received is 16-bit 0RRRRRGGGGGBBBBB static void video_frame(const uint16_t *data, unsigned width, unsigned height) { - if ( !g_extern.video_active ) + if (!g_extern.video_active) return; + if (g_settings.video.crop_overscan) + { + if (height == 239) + { + data += 7 * 1024; // Skip 7 top scanlines. + height = 224; + } + else if (height == 478) + { + data += 15 * 512; // Skip 15 top scanlines. + height = 448; + } + } + #ifdef HAVE_FFMPEG if (g_extern.recording) { diff --git a/ssnes.cfg b/ssnes.cfg index 0ff34be814..11443d010c 100644 --- a/ssnes.cfg +++ b/ssnes.cfg @@ -31,6 +31,9 @@ # A floating point value for video aspect ratio (width / height) # video_aspect_ratio = 1.333 +# Forces cropping of overscanned frames. Crops away top 7 scanlines and 8 bottom scanlines. (15/15 for interlaced frames). +# video_crop_overscan = false + # Path to Cg shader. # video_cg_shader = "/path/to/cg/shader.cg"