From 3823c77cb890cfe2618313080b9476d6ee15b6f6 Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Sun, 25 Jul 2021 21:27:12 +0300 Subject: [PATCH] PAL/NTSC scaling non-standard line count support. --- include/custom.h | 2 +- od-win32/win32_scaler.cpp | 56 ++++++++++++++++++++++++++------------- 2 files changed, 38 insertions(+), 20 deletions(-) diff --git a/include/custom.h b/include/custom.h index 777a8582..d510aae9 100644 --- a/include/custom.h +++ b/include/custom.h @@ -238,7 +238,7 @@ void customhack_put(struct customhack *ch, uae_u16 v, int hpos); uae_u16 customhack_get(struct customhack *ch, int hpos); extern void alloc_cycle_ext(int, int); extern void alloc_cycle_blitter(int hpos, uaecptr *ptr, int); -extern bool ispal(void); +extern bool ispal(int *lines); extern bool isvga(void); extern int current_maxvpos(void); extern struct chipset_refresh *get_chipset_refresh(struct uae_prefs*); diff --git a/od-win32/win32_scaler.cpp b/od-win32/win32_scaler.cpp index 153c81ad..5194ea86 100644 --- a/od-win32/win32_scaler.cpp +++ b/od-win32/win32_scaler.cpp @@ -182,16 +182,17 @@ static bool get_aspect(int monid, float *dstratiop, float *srcratiop, float *xmu if (keep_aspect == 1) dstratio = dstratio * 0.93f; } else { + bool isp = ispal(NULL); if (currprefs.ntscmode) { dstratio = dstratio * 1.21f; - if (keep_aspect == 2 && ispal()) + if (keep_aspect == 2 && isp) dstratio = dstratio * 0.93f; - else if (keep_aspect == 1 && !ispal()) + else if (keep_aspect == 1 && !isp) dstratio = dstratio * 0.98f; } else { - if (keep_aspect == 2 && ispal()) + if (keep_aspect == 2 && isp) dstratio = dstratio * 0.95f; - else if (keep_aspect == 1 && !ispal()) + else if (keep_aspect == 1 && !isp) dstratio = dstratio * 0.95f; } } @@ -578,7 +579,7 @@ void getfilterrect2(int monid, RECT *sr, RECT *dr, RECT *zr, int dst_width, int ww = currprefs.gfx_xcenter_size; if (currprefs.gfx_ycenter_size >= 0) hh = currprefs.gfx_ycenter_size; - if (scalemode == oscalemode) { + if (scalemode == oscalemode && !useold) { int oldwinw = gmc->gfx_size_win.width; int oldwinh = gmc->gfx_size_win.height; gmh->gfx_size_win.width = ww; @@ -668,22 +669,39 @@ cont: } - if (currprefs.ntscmode) { - if (palntscadjust && ispal()) { - dstratio = dstratio * (625 / 525.0); + { + float palntscratio = dstratio; + int l = 0; + bool isp = ispal(&l); + if (abs(l - 262) <= 5) { + l = 262; } - if (keep_aspect == 2 && ispal ()) - dstratio = dstratio * 0.93f; - else if (keep_aspect == 1 && !ispal ()) - dstratio = dstratio * 0.98f; - } else { - if (palntscadjust && !ispal()) { - dstratio = dstratio * (625 / 525.0); + if (abs(l - 312) <= 5) { + l = 312; + } + float ll = l * 2 + 1; + if (currprefs.ntscmode) { + if (palntscadjust && isp) { + palntscratio = palntscratio * (ll / 525.0); + } + 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 * (625.0 / ll); + } + 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 (keep_aspect == 2 && ispal ()) - dstratio = dstratio * 0.95f; - else if (keep_aspect == 1 && !ispal ()) - dstratio = dstratio * 0.95f; } if (srcratio > dstratio) { -- 2.47.3