]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
Improved PAL/NTSC scaling, added option that always scales NTSC only.
authorToni Wilen <twilen@winuae.net>
Sun, 27 Jul 2025 16:37:39 +0000 (19:37 +0300)
committerToni Wilen <twilen@winuae.net>
Sun, 27 Jul 2025 16:37:39 +0000 (19:37 +0300)
include/options.h
od-win32/rp.cpp
od-win32/win32_scaler.cpp

index 48bdcd2c4e73e0feb797f433bffe40f826b7ff73..02ec58763750199b046acb17c1777d936e02b1cd 100644 (file)
@@ -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];
index 1516281ff1e3aea58aacb95118af144489283555..a55ddf08e0bc6cf9b9312ef8295aeed1f1e195fd 100644 (file)
@@ -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) {
index 699ad3c95294536463d2a61fc68f2a07bb13471c..9215e0384dbd94f16d32c3a6098a3166c1fd54f1 100644 (file)
@@ -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) {