]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
Support RTG integer scaling 1/x Filter panel option.
authorToni Wilen <twilen@winuae.net>
Tue, 30 Jun 2026 18:54:39 +0000 (21:54 +0300)
committerToni Wilen <twilen@winuae.net>
Tue, 30 Jun 2026 18:54:39 +0000 (21:54 +0300)
od-win32/win32gfx.cpp
od-win32/win32gui.cpp

index 97d0802ded2ec01063aa3066585ace8d902137ff..9a8d0d0b6271335508d1d8ce47dffc5a3b58ece3 100644 (file)
@@ -1497,25 +1497,50 @@ void getrtgfilterdata(int monid, struct displayscale *ds)
        float my = (float)mon->currentmode.native_height / srcheight;
 
        if (mon->scalepicasso == RTG_MODE_INTEGER_SCALE) {
-               int divx = mon->currentmode.native_width / srcwidth;
-               int divy = mon->currentmode.native_height / srcheight;
-               float mul = (float)(!divx || !divy ? 1 : (divx > divy ? divy : divx));
-               if (!divx || !divy) {
+               float fdivx = (float)mon->currentmode.native_width / srcwidth;
+               float fdivy = (float)mon->currentmode.native_height / srcheight;
+               float fmul = (float)(fdivx < 1.0 || fdivy < 1.0 ? 1 : (fdivx > fdivy ? fdivy : fdivx));
+               int mul = (int)(fmul * (1 << (currprefs.gf[GF_RTG].gfx_filter_integerscalelimit)));
+               fmul = (float)mul / (1 << (currprefs.gf[GF_RTG].gfx_filter_integerscalelimit));
+               if (fdivx < 1.0 || fdivy < 1.0) {
+                       float adjust = 0.5f / (1 << (currprefs.gf[GF_RTG].gfx_filter_integerscalelimit));
+                       fmul = 1.0f;
+                       float prevfmul = fmul;
+                       for(;;) {
+                               if (fmul <= adjust) {
+                                       adjust /= 2.0f;
+                                       if (adjust < 0.10f) {
+                                               break;
+                                       }
+                               }
+                               fmul -= adjust;
+                               if (fmul < 0.10f) {
+                                       fmul = 0.10f;
+                                       break;
+                               }
+                               if ((float)mon->currentmode.native_width / srcwidth > 2 * fmul || ((float)mon->currentmode.native_height / srcheight > 2 * fmul)) {
+                                       fmul = prevfmul;
+                                       break;
+                               }
+                               prevfmul = fmul;
+                       }
+#if 0
                        if ((float)mon->currentmode.native_width / srcwidth <= 0.95f || ((float)mon->currentmode.native_height / srcheight <= 0.95f)) {
-                               mul = 0.5f;
+                               fmul = 1.0f / 2.0f;
                        }
                        if ((float)mon->currentmode.native_width / srcwidth <= 0.45f || ((float)mon->currentmode.native_height / srcheight <= 0.45f)) {
-                               mul = 0.25f;
+                               fmul = 1.0f / 4.0f;
                        }
+#endif
                }
-               ds->outwidth = (int)(mon->currentmode.native_width / mul);
-               ds->outheight = (int)(mon->currentmode.native_height / mul);
-               int xx = (int)((mon->currentmode.native_width / mul - srcwidth) / 2);
-               int yy = (int)((mon->currentmode.native_height / mul - srcheight) / 2);
+               ds->outwidth = (int)(mon->currentmode.native_width / fmul);
+               ds->outheight = (int)(mon->currentmode.native_height / fmul);
+               int xx = (int)((mon->currentmode.native_width / fmul - srcwidth) / 2);
+               int yy = (int)((mon->currentmode.native_height / fmul - srcheight) / 2);
                picasso_offset_x = -xx;
                picasso_offset_y = -yy;
-               mx = mul;
-               my = mul;
+               mx = fmul;
+               my = fmul;
                outwidth = srcwidth;
                outheight = srcheight;
                ds->mode = 1;
index cfca462b3555a823db3d2abad898896fbd724911..6ad2da7b1b2c46892568f72ea1546ff04f6a8b64 100644 (file)
@@ -20474,15 +20474,16 @@ static void enable_for_hw3ddlg (HWND hDlg)
        int scalemode = workprefs.gf[filter_nativertg].gfx_filter_autoscale;
        int vv = FALSE, vv2 = FALSE, vv3 = FALSE, vv4 = FALSE;
        int as = FALSE;
+       bool rtg = filter_nativertg == GF_RTG;
 
        v = vv = vv2 = vv3 = vv4 = TRUE;
-       if (filter_nativertg == 1) {
+       if (rtg) {
                vv4 = FALSE;
        }
        if (scalemode == AUTOSCALE_STATIC_AUTO || scalemode == AUTOSCALE_STATIC_NOMINAL || scalemode == AUTOSCALE_STATIC_MAX)
                as = TRUE;
 
-       if (filter_nativertg == 2) {
+       if (filter_nativertg == GF_INTERLACE) {
                ew(hDlg, IDC_FILTERENABLE, TRUE);
                setchecked(hDlg, IDC_FILTERENABLE, gf->enable);
        } else {
@@ -20514,7 +20515,8 @@ static void enable_for_hw3ddlg (HWND hDlg)
        ew(hDlg, IDC_FILTERPRESETLOAD, filterpreset_selected > 0);
        ew(hDlg, IDC_FILTERPRESETDELETE, filterpreset_selected > 0 && filterpreset_builtin < 0);
 
-       ew(hDlg, IDC_FILTERINTEGER, scalemode == AUTOSCALE_INTEGER || scalemode == AUTOSCALE_INTEGER_AUTOSCALE);
+       ew(hDlg, IDC_FILTERINTEGER, (!rtg && (scalemode == AUTOSCALE_INTEGER || scalemode == AUTOSCALE_INTEGER_AUTOSCALE)) ||
+               (rtg && scalemode == RTG_MODE_INTEGER_SCALE));
 }
 
 static const TCHAR *filtermultnames[] = {