From de2e4e7b925d971a36bd3995cb2e7694659a95c0 Mon Sep 17 00:00:00 2001 From: IanSB Date: Sun, 26 Jul 2020 04:25:55 +0100 Subject: [PATCH] Rework overscan setting into zoom option 0%-100% in 10% steps (interpolation only) Also rename scaling settings --- src/geometry.c | 69 ++++++++++++++++++++++++++++++++--------------- src/osd.c | 29 +++++++++++++------- src/osd.h | 17 +++++++++--- src/rgb_to_hdmi.c | 2 +- 4 files changed, 81 insertions(+), 36 deletions(-) diff --git a/src/geometry.c b/src/geometry.c index 4c477121..a16ca9df 100644 --- a/src/geometry.c +++ b/src/geometry.c @@ -475,29 +475,56 @@ void geometry_get_fb_params(capture_info_t *capinfo) { //log_info("unadjusted integer = %d, %d, %d, %d, %d, %d", geometry_h_offset, geometry_v_offset, geometry_min_h_width, geometry_min_v_height, geometry_max_h_width, geometry_max_v_height); - if (geometry->setup_mode == SETUP_MIN - || (overscan == OVERSCAN_MIN && (geometry->setup_mode == SETUP_NORMAL || geometry->setup_mode == SETUP_CLOCK || geometry->setup_mode == SETUP_FINE))) { - geometry_max_h_width = geometry_min_h_width; - geometry_max_v_height = geometry_min_v_height; + switch (geometry->setup_mode) { + case SETUP_NORMAL: + case SETUP_CLOCK: + case SETUP_FINE: + default: + if (scaling != GSCALING_INTEGER) { + int scaled_min_h_width; + int scaled_min_v_height; + double max_aspect = (double)geometry_max_h_width / (double)geometry_max_v_height; + double min_aspect = (double)geometry_min_h_width / (double)geometry_min_v_height; + if (min_aspect > max_aspect) { + scaled_min_h_width = geometry_min_h_width; + scaled_min_v_height = ((int)((double)scaled_min_h_width / max_aspect)); + if (scaled_min_v_height < geometry_min_v_height) { + scaled_min_v_height = geometry_min_v_height; + } + } else { + scaled_min_v_height = geometry_min_v_height; + scaled_min_h_width = ((int)((double)scaled_min_v_height * max_aspect)); + if (scaled_min_h_width < geometry_min_h_width) { + scaled_min_h_width = geometry_min_h_width; + } + } + geometry_max_h_width = (geometry_max_h_width - ((geometry_max_h_width - scaled_min_h_width) * overscan / (NUM_OVERSCAN - 1))) & 0xfffffff8; + geometry_max_v_height = (geometry_max_v_height - ((geometry_max_v_height - scaled_min_v_height) * overscan / (NUM_OVERSCAN - 1))) & 0xfffffffe; + if (geometry_max_h_width < geometry_min_h_width) { + geometry_max_h_width = geometry_min_h_width; + } + if (geometry_max_v_height < geometry_min_v_height) { + geometry_max_v_height = geometry_min_v_height; + } + geometry_h_offset = geometry_h_offset - (((geometry_max_h_width - geometry_min_h_width) >> 3) << 2); + geometry_v_offset = geometry_v_offset - ((geometry_max_v_height - geometry_min_v_height) >> 1); + geometry_min_h_width = geometry_max_h_width; + geometry_min_v_height = geometry_max_v_height; + } + break; + case SETUP_MIN: + geometry_max_h_width = geometry_min_h_width; + geometry_max_v_height = geometry_min_v_height; + break; + case SETUP_MAX: + geometry_h_offset = geometry_h_offset - (((geometry_max_h_width - geometry_min_h_width) >> 3) << 2); + geometry_v_offset = geometry_v_offset - ((geometry_max_v_height - geometry_min_v_height) >> 1); + geometry_min_h_width = geometry_max_h_width; + geometry_min_v_height = geometry_max_v_height; + break; + } - if (overscan == OVERSCAN_HALF && (geometry->setup_mode == SETUP_NORMAL || geometry->setup_mode == SETUP_CLOCK || geometry->setup_mode == SETUP_FINE)) { - geometry_max_h_width = (((geometry_max_h_width - geometry_min_h_width) >> 1) + geometry_min_h_width) & 0xfffffff8; - geometry_max_v_height = (((geometry_max_v_height - geometry_min_v_height) >> 1) + geometry_min_v_height) & 0xfffffffe; - geometry_h_offset = geometry_h_offset - (((geometry_max_h_width - geometry_min_h_width) >> 3) << 2); - geometry_v_offset = geometry_v_offset - ((geometry_max_v_height - geometry_min_v_height) >> 1); - geometry_min_h_width = geometry_max_h_width; - geometry_min_v_height = geometry_max_v_height; - } - - if (geometry->setup_mode == SETUP_MAX - || (overscan == OVERSCAN_MAX && (geometry->setup_mode == SETUP_NORMAL || geometry->setup_mode == SETUP_CLOCK || geometry->setup_mode == SETUP_FINE)) - || (overscan == OVERSCAN_AUTO && (scaling == GSCALING_MANUAL43 || scaling == GSCALING_MANUAL) && (geometry->setup_mode == SETUP_NORMAL || geometry->setup_mode == SETUP_CLOCK || geometry->setup_mode == SETUP_FINE))) { - geometry_h_offset = geometry_h_offset - (((geometry_max_h_width - geometry_min_h_width) >> 3) << 2); - geometry_v_offset = geometry_v_offset - ((geometry_max_v_height - geometry_min_v_height) >> 1); - geometry_min_h_width = geometry_max_h_width; - geometry_min_v_height = geometry_max_v_height; - } //log_info("adjusted integer = %d, %d, %d, %d, %d, %d", geometry_h_offset, geometry_v_offset, geometry_min_h_width, geometry_min_v_height, geometry_max_h_width, geometry_max_v_height); int h_size43_adj = h_size43; diff --git a/src/osd.c b/src/osd.c index c8ff71c4..e31246d0 100644 --- a/src/osd.c +++ b/src/osd.c @@ -115,7 +115,9 @@ static const char *palette_control_names[] = { "In Band Commands", "CGA NTSC Artifact", "Mono NTSC Artifact", - "Auto NTSC Artifact" + "Auto NTSC Artifact", + "C64 PAL Artifact", + "Atari GTIA" }; static const char *return_names[] = { @@ -158,10 +160,17 @@ static const char *autoswitch_names[] = { }; static const char *overscan_names[] = { - "Auto", - "Maximum", - "Halfway", - "Minimum" + "0%", + "10%", + "20%", + "30%", + "40%", + "50%", + "60%", + "70%", + "80%", + "90%", + "100%" }; static const char *colour_names[] = { @@ -181,11 +190,11 @@ static const char *scaling_names[] = { "Auto", "Integer / Sharp", "Integer / Soft", - "Integer / Very Soft", - "Fill 4:3 / Soft", - "Fill 4:3 / Very Soft", - "Fill All / Soft", - "Fill All / Very Soft" + "Integer / Softer", + "Interpolate 4:3 / Soft", + "Interpolate 4:3 / Softer", + "Interpolate Full / Soft", + "Interpolate Full / Softer" }; static const char *frontend_names_6[] = { diff --git a/src/osd.h b/src/osd.h index e5776729..c42c6d7b 100644 --- a/src/osd.h +++ b/src/osd.h @@ -63,14 +63,23 @@ enum { PALETTECONTROL_NTSCARTIFACT_CGA, PALETTECONTROL_NTSCARTIFACT_BW, PALETTECONTROL_NTSCARTIFACT_BW_AUTO, + // PALETTECONTROL_PALARTIFACT, + // PALETTECONTROL_ATARI_GTIA, NUM_CONTROLS }; enum { - OVERSCAN_AUTO, - OVERSCAN_MAX, - OVERSCAN_HALF, - OVERSCAN_MIN, + OVERSCAN_0, + OVERSCAN_1, + OVERSCAN_2, + OVERSCAN_3, + OVERSCAN_4, + OVERSCAN_5, + OVERSCAN_6, + OVERSCAN_7, + OVERSCAN_8, + OVERSCAN_9, + OVERSCAN_10, NUM_OVERSCAN }; diff --git a/src/rgb_to_hdmi.c b/src/rgb_to_hdmi.c index 86feb4b1..33558eee 100644 --- a/src/rgb_to_hdmi.c +++ b/src/rgb_to_hdmi.c @@ -2050,7 +2050,7 @@ void set_scaling(int mode, int reboot) { if (width > 340 && h_size43 < 1440 && (h_size43 % width) > (width >> 1)) { gscaling = GSCALING_MANUAL43; filtering = FILTERING_SOFT; - set_auto_name("Auto (Fill 4:3 / Soft)"); + set_auto_name("Auto (Interp. 4:3 / Soft)"); osd_refresh(); log_info("Setting 4:3 soft"); } else {