]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
Integer scaling horizontal/vertical aspect fix
authorToni Wilen <twilen@winuae.net>
Tue, 8 Apr 2025 15:46:58 +0000 (18:46 +0300)
committerToni Wilen <twilen@winuae.net>
Tue, 8 Apr 2025 15:46:58 +0000 (18:46 +0300)
drawing.cpp
include/drawing.h
od-win32/screenshot.cpp
od-win32/win32_scaler.cpp
od-win32/win32gfx.cpp

index 044d22f724219ca0ee1f60f0ea889f7ed9577cb9..adf92ce9f7df03ecacdb6a3b5b20376ddffa0393 100644 (file)
@@ -754,7 +754,7 @@ void store_custom_limits(int w, int h, int x, int y)
 #endif
 }
 
-int get_custom_limits(int *pw, int *ph, int *pdx, int *pdy, int *prealh)
+int get_custom_limits(int *pw, int *ph, int *pdx, int *pdy, int *prealh, int *hres, int *vres)
 {
        struct vidbuf_description *vidinfo = &adisplays[0].gfxvidinfo;
        int w, h, dx, dy, y1, y2, dbl1, dbl2;
@@ -765,6 +765,9 @@ int get_custom_limits(int *pw, int *ph, int *pdx, int *pdy, int *prealh)
                return 0;
        }
 
+       *hres = hresolution;
+       *vres = currprefs.gfx_vresolution;
+
        if (!isnativevidbuf(0)) {
                *pw = vidinfo->inbuffer->outwidth;
                *ph = vidinfo->inbuffer->outheight;
index 55fd2a1f91624a28743da0789f8d35db457f493e..70626384d4a5af4705f4b756488600ec82861229 100644 (file)
@@ -127,6 +127,7 @@ extern void check_custom_limits (void);
 extern void get_custom_topedge (int *x, int *y, bool max);
 extern void get_custom_raw_limits (int *pw, int *ph, int *pdx, int *pdy);
 void get_custom_mouse_limits (int *pw, int *ph, int *pdx, int *pdy, int dbl);
+extern int get_custom_limits(int *pw, int *ph, int *pdx, int *pdy, int *prealh, int *hres, int *vres);
 extern void putpixel(uae_u8 *buf, uae_u8 *genlockbuf, int x, xcolnr c8);
 extern void allocvidbuffer(int monid, struct vidbuffer *buf, int width, int height, int depth);
 extern void freevidbuffer(int monid, struct vidbuffer *buf);
index c70b74c0bebf41931ee6a0bd4e2d1fd51c6e7b24..34894913bdf380fe4e7e9211e676eefec5690994 100644 (file)
@@ -216,8 +216,8 @@ static int screenshot_prepare(int monid, int imagemode, struct vidbuffer *vb, bo
                }
 
                if (!WIN32GFX_IsPicassoScreen(mon) && screenshot_clipmode == 1) {
-                       int cw, ch, cx, cy, crealh = 0;
-                       if (get_custom_limits(&cw, &ch, &cx, &cy, &crealh)) {
+                       int cw, ch, cx, cy, crealh = 0, hres, vres;
+                       if (get_custom_limits(&cw, &ch, &cx, &cy, &crealh, &hres, &vres)) {
                                int maxw = currprefs.screenshot_max_width << currprefs.gfx_resolution;
                                int maxh = currprefs.screenshot_max_height << currprefs.gfx_vresolution;
                                int minw = currprefs.screenshot_min_width << currprefs.gfx_resolution;
index a5f2cd2a8f92034dd76f7a83b0e1efd22325cd1f..90bc93247474472c0efa221e1325e7af70d39286 100644 (file)
@@ -281,6 +281,8 @@ void getfilterdata(int monid, struct displayscale *ds)
 
        if (scalemode) {
                int cw, ch, cx, cy, cv = 0, crealh = 0;
+               int hres = currprefs.gfx_resolution;
+               int vres = currprefs.gfx_vresolution;
                static int oxmult, oymult;
 
                filterxmult = (float)ds->scale;
@@ -340,7 +342,7 @@ void getfilterdata(int monid, struct displayscale *ds)
                                }
 
                                if (scalemode == AUTOSCALE_INTEGER_AUTOSCALE) {
-                                       ok = get_custom_limits (&cw, &ch, &cx, &cy, &crealh) != 0;
+                                       ok = get_custom_limits (&cw, &ch, &cx, &cy, &crealh, &hres, &vres) != 0;
                                        if (ok) {
                                                set_custom_limits(cw, ch, cx, cy, true);
                                                store_custom_limits(cw, ch, cx, cy);
@@ -373,47 +375,34 @@ void getfilterdata(int monid, struct displayscale *ds)
 
                                extraw = 0;
                                extrah = 0;
-                               xmult = 1.0;
-                               ymult = 1.0;
+                               mult = 1.0f;
+                               xmult = 1.0f;
+                               ymult = 1.0f;
                                filter_horiz_zoom = 0;
                                filter_vert_zoom = 0;
                                filter_horiz_zoom_mult = 1.0;
                                filter_vert_zoom_mult = 1.0;
 
-                               float m = 1.0f;
-                               if (manual) {
-                                       if (currprefs.gfx_resolution >= currprefs.gfx_vresolution) {
-                                               m = (float)(1 << (currprefs.gfx_resolution - currprefs.gfx_vresolution));
-                                       } else {
-                                               m = 1.0f / (1 << (currprefs.gfx_vresolution - currprefs.gfx_resolution));
-                                       }
+                               if (hres >= vres) {
+                                       ymult = (float)(1 << (hres - vres));
+                               } else {
+                                       xmult = (float)(1 << (vres - hres));
                                }
 
                                float multadd = 1.0f / (1 << currprefs.gf[idx].gfx_filter_integerscalelimit);
                                if (cw2 > 0 && ch2 > 0) {
-                                       if (cw2 > maxw || ch2 > maxh) {
-                                               while (cw2 / mult - adjw > maxw || ch2 / mult - adjh > maxh) {
+                                       if (cw2 * xmult > maxw || ch2 * ymult > maxh) {
+                                               while (cw2 * xmult / mult - adjw > maxw || ch2 * ymult / mult - adjh > maxh) {
                                                        mult += multadd;
                                                }
-                                               float multx = mult, multy = mult;
-                                               maxw = (int)(maxw * mult);
-                                               maxh = (int)(maxh * mult);
+                                               maxw = (int)((maxw / xmult) * mult);
+                                               maxh = (int)((maxh / ymult) * mult);
                                        } else {
-                                               while (((cw2 * (mult + multadd)) / m) - adjw <= maxw && ch2 * (mult + multadd) - adjh <= maxh) {
+                                               while ((cw2 * (xmult * mult + multadd)) - adjw <= maxw && ch2 * (ymult * mult + multadd) - adjh <= maxh) {
                                                        mult += multadd;
                                                }
-
-                                               float multx = mult, multy = mult;
-                                               // if width is smaller than height, double width (programmed modes)
-                                               if (cw2 * (mult + multadd) - adjw <= maxw && cw2 < ch2) {
-                                                       multx *= 2;
-                                               }
-                                               // if width is >=2.4x height, double height (non-doublescanned superhires)
-                                               if (ch2 * (mult * 2) - adjh <= maxh && cw2 > ch2 * 2.4) {
-                                                       multy *= 2;
-                                               }
-                                               maxw = (int)((maxw + mult - multadd) / multx);
-                                               maxh = (int)((maxh + mult - multadd) / multy);
+                                               maxw = (int)(maxw / (xmult * mult));
+                                               maxh = (int)(maxh / (ymult * mult));
                                        }
                                }
 
@@ -454,14 +443,14 @@ void getfilterdata(int monid, struct displayscale *ds)
 
                } else if (scalemode == AUTOSCALE_CENTER) {
 
-                       cv = get_custom_limits(&cw, &ch, &cx, &cy, &crealh);
+                       cv = get_custom_limits(&cw, &ch, &cx, &cy, &crealh, &hres, &vres);
                        if (cv) {
                                store_custom_limits(cw, ch, cx, cy);
                        }
 
                } else if (scalemode == AUTOSCALE_RESIZE) {
 
-                       cv = get_custom_limits (&cw, &ch, &cx, &cy, &crealh);
+                       cv = get_custom_limits (&cw, &ch, &cx, &cy, &crealh, &hres, &vres);
                        if (cv) {
                                set_custom_limits(cw, ch, cx, cy, false);
                                store_custom_limits(cw, ch, cx, cy);
@@ -470,7 +459,7 @@ void getfilterdata(int monid, struct displayscale *ds)
 
                } else {
 
-                       cv = get_custom_limits (&cw, &ch, &cx, &cy, &crealh);
+                       cv = get_custom_limits (&cw, &ch, &cx, &cy, &crealh, &hres, &vres);
                        if (cv) {
                                set_custom_limits (cw, ch, cx, cy, true);
                                store_custom_limits (cw, ch, cx, cy);
index 70a57a9a48685a47ef0c9f40c2bb7d59bd09b9c6..c1e0a3bb0827de40afa715d248d18f2cec1616ac 100644 (file)
@@ -2377,7 +2377,7 @@ int check_prefs_changed_gfx(void)
                currprefs.gf[0].gfx_filter_autoscale = changed_prefs.gf[0].gfx_filter_autoscale;
                currprefs.gf[2].gfx_filter_autoscale = changed_prefs.gf[2].gfx_filter_autoscale;
 
-               get_custom_limits (NULL, NULL, NULL, NULL, NULL);
+               get_custom_limits (NULL, NULL, NULL, NULL, NULL, NULL, NULL);
                fixup_prefs_dimensions (&changed_prefs);
 
                return 1;