From: Toni Wilen Date: Sun, 27 Jul 2025 16:37:39 +0000 (+0300) Subject: Improved PAL/NTSC scaling, added option that always scales NTSC only. X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=2ae0b8f9d621534d8b198a4717ca17910bf143b8;p=francis%2Fwinuae.git Improved PAL/NTSC scaling, added option that always scales NTSC only. --- diff --git a/include/options.h b/include/options.h index 48bdcd2c..02ec5876 100644 --- a/include/options.h +++ b/include/options.h @@ -625,6 +625,7 @@ struct uae_prefs { int gfx_overscanmode; int gfx_monitorblankdelay; int gfx_rotation; + int gfx_ntscpixels; uae_u32 gfx_bordercolor; struct gfx_filterdata gf[3]; diff --git a/od-win32/rp.cpp b/od-win32/rp.cpp index 1516281f..a55ddf08 100644 --- a/od-win32/rp.cpp +++ b/od-win32/rp.cpp @@ -757,6 +757,7 @@ static void get_screenmode (struct RPScreenMode *sm, struct uae_prefs *p, bool g float hmult, vmult; bool half; bool rtg; + int scalemode = p->gf[0].gfx_filter_autoscale; hres = p->gfx_resolution; vres = p->gfx_vresolution; @@ -844,10 +845,10 @@ static void get_screenmode (struct RPScreenMode *sm, struct uae_prefs *p, bool g if (p->gf[0].gfx_filter_scanlines || p->gfx_pscanlines) m |= RP_SCREENMODE_SCANLINES; - if (p->gfx_xcenter_pos == 0 && p->gfx_ycenter_pos == 0) - cf |= RP_CLIPFLAGS_NOCLIP; - else if (p->gf[0].gfx_filter_autoscale == AUTOSCALE_RESIZE || p->gf[0].gfx_filter_autoscale == AUTOSCALE_NORMAL) + if (scalemode == AUTOSCALE_RESIZE || scalemode == AUTOSCALE_NORMAL || scalemode == AUTOSCALE_INTEGER_AUTOSCALE) cf |= RP_CLIPFLAGS_AUTOCLIP; + else if (p->gfx_xcenter_pos == 0 && p->gfx_ycenter_pos == 0) + cf |= RP_CLIPFLAGS_NOCLIP; } if (full) { @@ -860,6 +861,9 @@ static void get_screenmode (struct RPScreenMode *sm, struct uae_prefs *p, bool g if (p->gf[rtg].gfx_filter_bilinear) { m |= RP_SCREENMODE_INTERPOLATION; } + if (!rtg && p->gfx_ntscpixels) { + m |= RP_SCREENMODE_PIXEL_ORIGINAL_RATIO; + } sm->dwScreenMode = m | (storeflags & (RP_SCREENMODE_SCALING_STRETCH | RP_SCREENMODE_SCALING_SUBPIXEL)); sm->lTargetHeight = 0; @@ -930,6 +934,8 @@ static void set_screenmode (struct RPScreenMode *sm, struct uae_prefs *p) p->gf[0].gfx_filter_right_border = 0; p->gf[0].gfx_filter_bottom_border = 0; p->gf[0].gfx_filter_autoscale = AUTOSCALE_CENTER; + p->gfx_ntscpixels = false; + disp = getdisplay(p, 0); if (log_rp & 2) { @@ -1132,7 +1138,7 @@ static void set_screenmode (struct RPScreenMode *sm, struct uae_prefs *p) if (keepaspect) { p->gf[0].gfx_filter_aspect = -1; - p->gf[0].gfx_filter_keep_autoscale_aspect = 1; + p->gf[0].gfx_filter_keep_autoscale_aspect = integerscale ? 0 : 1; p->gf[0].gfx_filter_keep_aspect = 1; } else { p->gf[0].gfx_filter_aspect = 0; @@ -1196,6 +1202,10 @@ static void set_screenmode (struct RPScreenMode *sm, struct uae_prefs *p) } else { p->gf[0].gfx_filter_bilinear = interpolation_old(sm->dwScreenMode); } + + if (sm->dwScreenMode & RP_SCREENMODE_PIXEL_ORIGINAL_RATIO) { + p->gfx_ntscpixels = true; + } } if (log_rp & 2) { diff --git a/od-win32/win32_scaler.cpp b/od-win32/win32_scaler.cpp index 699ad3c9..9215e038 100644 --- a/od-win32/win32_scaler.cpp +++ b/od-win32/win32_scaler.cpp @@ -676,38 +676,63 @@ cont: } { - float palntscratio = dstratio; - int l = 0; - bool isp = ispal(&l); - if (abs(l - 262) <= 25) { - l = 262; - } - if (abs(l - 312) <= 25) { - l = 312; - } - float ll = l * 2.0f + 1.0f; - if (currprefs.ntscmode) { - if (palntscadjust && isp) { - palntscratio = palntscratio * (525.0f / ll); + int lh = 0; + bool isp = ispal(&lh); + if (lh > 1) { + float palntscratio = dstratio; + float palh = (312 - 25) * 2 + 1.0f; + float ntsch = (262 - 20) * 2 + 1.0f; + float ll = (lh - 23) * 2 + 1.0f; + if (abs(lh - (262 - 20)) <= 22) { + ll = ntsch; } - if (keep_aspect == 2 && isp) { - palntscratio = palntscratio * 0.93f; - } else if (keep_aspect == 1 && !isp) { - palntscratio = palntscratio * 0.98f; + if (abs(lh - (312 - 25)) <= 22) { + ll = palh; } - } else { - if (palntscadjust && !isp) { - palntscratio = palntscratio * (625.0f / ll); + if (currprefs.gfx_ntscpixels) { + if (!isp) { + palntscratio = palntscratio * palh / ll; + } + if (currprefs.ntscmode) { + if (keep_aspect == 2 && isp) { + palntscratio = palntscratio * 0.93f; + } + else if (keep_aspect == 1 && !isp) { + palntscratio = palntscratio * 0.98f; + } + } else { + if (keep_aspect == 2 && isp) { + palntscratio = palntscratio * 0.95f; + } + else if (keep_aspect == 1 && !isp) { + palntscratio = palntscratio * 0.95f; + } + } + } else { + if (currprefs.ntscmode) { + if (palntscadjust && isp) { + palntscratio = palntscratio * ntsch / ll; + } + if (keep_aspect == 2 && isp) { + palntscratio = palntscratio * 0.93f; + } else if (keep_aspect == 1 && !isp) { + palntscratio = palntscratio * 0.98f; + } + } else { + if (palntscadjust && !isp) { + palntscratio = palntscratio * palh / ll; + } + if (keep_aspect == 2 && isp) { + palntscratio = palntscratio * 0.95f; + } else if (keep_aspect == 1 && !isp) { + palntscratio = palntscratio * 0.95f; + } + } } - if (keep_aspect == 2 && isp) { - palntscratio = palntscratio * 0.95f; - } else if (keep_aspect == 1 && !isp) { - palntscratio = palntscratio * 0.95f; + if (palntscratio != dstratio) { + ymult = ymult * palntscratio / dstratio; } } - if (palntscratio != dstratio) { - ymult = ymult * palntscratio / dstratio; - } } if (srcratio > dstratio) {