From d0b027360a405301091193b1f3cbd1b2f51822d6 Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Fri, 27 Feb 2026 18:20:21 +0200 Subject: [PATCH] blank / sync monitor size/position detection --- cfgfile.cpp | 4 +-- custom.cpp | 67 +++++++++++++++++------------------ include/options.h | 8 +++++ od-win32/resources/resource.h | 3 ++ od-win32/resources/winuae.rc | 11 +++--- od-win32/win32_scaler.cpp | 2 +- od-win32/win32gui.cpp | 6 ++++ 7 files changed, 59 insertions(+), 42 deletions(-) diff --git a/cfgfile.cpp b/cfgfile.cpp index 745eccf9..09e8ec66 100644 --- a/cfgfile.cpp +++ b/cfgfile.cpp @@ -258,7 +258,7 @@ static const TCHAR *cycleexact[] = { _T("false"), _T("memory"), _T("true"), 0 } static const TCHAR *unmapped[] = { _T("floating"), _T("zero"), _T("one"), 0 }; static const TCHAR *ciatype[] = { _T("default"), _T("391078-01"), 0 }; static const TCHAR *debugfeatures[] = { _T("segtracker"), _T("fsdebug"), 0 }; -static const TCHAR *hvcsync[] = { _T("hvcsync"), _T("csync"), _T("hvsync"), 0 }; +static const TCHAR *hvcsync[] = { _T("hvcsync"), _T("csync"), _T("hvsync"), _T("hvcsync_s"), _T("csync_s"), _T("hvsync_s"), 0 }; static const TCHAR *eclocksync[] = { _T("default"), _T("68000"), _T("Gayle"), _T("68000_opt"), 0 }; static const TCHAR *agnusmodel[] = { _T("default"), _T("velvet"), _T("a1000"), _T("ocs"), _T("ecs"), _T("aga"), 0 }; static const TCHAR *agnussize[] = { _T("default"), _T("512k"), _T("1m"), _T("2m"), 0 }; @@ -8629,7 +8629,7 @@ void default_prefs (struct uae_prefs *p, bool reset, int type) p->cs_ciatodbug = false; p->cs_unmapped_space = 0; p->cs_color_burst = false; - p->cs_hvcsync = false; + p->cs_hvcsync = 0; p->cs_ciatype[0] = 0; p->cs_ciatype[1] = 0; p->cs_memorypatternfill = true; diff --git a/custom.cpp b/custom.cpp index 0f3a547f..3e239faf 100644 --- a/custom.cpp +++ b/custom.cpp @@ -1682,10 +1682,11 @@ void compute_framesync(void) if (currprefs.gfx_extraheight > 0) { vb->extraheight = currprefs.gfx_extraheight << vres2; } - if (currprefs.gfx_overscanmode >= OVERSCANMODE_EXTREME) { - vb->extrawidth = -1; + int vblines = current_linear_vblank_lines; + if (currprefs.cs_hvcsync >= HVSYNC_SYNCPOS) { + vblines = LINES_AFTER_VSYNC; } - int maxv = current_linear_vpos - (current_linear_vblank_lines - display_vblankstart_skip) + display_vblankend_skip + 1; + int maxv = current_linear_vpos - (vblines - display_vblankstart_skip) + display_vblankend_skip + 1; linear_vpos_vb_end = current_linear_vpos_vb_end - display_vblankstart_skip - 1; if (currprefs.gfx_overscanmode >= OVERSCANMODE_ULTRA) { maxv = current_linear_vpos; @@ -1794,10 +1795,10 @@ static void init_beamcon0(void) } beamcon0_pal = !isntsc; - if (currprefs.cs_hvcsync == 0) { + if (currprefs.cs_hvcsync == HVSYNC_COMBINED || currprefs.cs_hvcsync == HVSYNC_COMBINED_SYNC) { bemcon0_hsync_mask = BEAMCON0_VARHSYEN | BEAMCON0_VARCSYEN; bemcon0_vsync_mask = BEAMCON0_VARVSYEN | BEAMCON0_VARCSYEN; - } else if (currprefs.cs_hvcsync == 1) { + } else if (currprefs.cs_hvcsync == HVSYNC_CSYNC || currprefs.cs_hvcsync == HVSYNC_CSYNC_SYNC) { bemcon0_hsync_mask = BEAMCON0_VARCSYEN; bemcon0_vsync_mask = BEAMCON0_VARCSYEN; } else { @@ -1904,14 +1905,16 @@ static void init_beamcon0(void) maxvpos_nom = maxvpos; maxvpos_display = vsync_lines; - // get hblank start and end (relative to HSYNC start) - int hbs = 0, hbe = 0, hblen = 0, total = 0; - denise_get_hboffsets(&hbs, &hbe, &hblen, &total); - // convert to lores pixels - hblen /= 4; - hbs /= 4; - hbe /= 4; - total /= 4; + int hbs = -1, hbe = -1, hblen = 0, total = 0; + if (currprefs.cs_hvcsync < HVSYNC_SYNCPOS && currprefs.gfx_overscanmode < OVERSCANMODE_EXTREME) { + // get hblank start and end (relative to HSYNC start) + denise_get_hboffsets(&hbs, &hbe, &hblen, &total); + // convert to lores pixels + hblen /= 4; + hbs /= 4; + hbe /= 4; + total /= 4; + } int hsylen = current_agnus_hslen_cck; hsylen += CCKS_AFTER_HSYNC; hsylen *= 2; @@ -1937,18 +1940,6 @@ static void init_beamcon0(void) } else { maxvpos_display--; } - } else if (currprefs.gfx_overscanmode == OVERSCANMODE_EXTREME) { - int ev = 42; - int l = 0; - if (hbe > ev) { - l = hbe - ev; - hbe = ev; - hblen -= l; - } - maxhpos_display = hsync_ccks * 2 - hblen; - hbs += 6 * 2; - display_hstart_cyclewait_start = hbe / 2; - display_hstart_cyclewait_end = -hbs / 2; } else if (currprefs.gfx_overscanmode == OVERSCANMODE_BROADCAST) { maxhpos_display += 7; } else if (currprefs.gfx_overscanmode >= OVERSCANMODE_ULTRA) { @@ -2107,7 +2098,13 @@ static void init_beamcon0(void) minfirstline = 0; } - minfirstline_linear = linear_vpos_vblank_end; + int vbstart = linear_vpos_vblank_end; + if (currprefs.cs_hvcsync >= HVSYNC_SYNCPOS) { + vbstart = LINES_AFTER_VSYNC; + minfirstline = vbstart; + } + + minfirstline_linear = vbstart; maxvpos_display_vsync = 0; display_vblankstart_skip = 0; display_vblankend_skip = 0; @@ -2120,7 +2117,7 @@ static void init_beamcon0(void) } else if (currprefs.gfx_overscanmode == OVERSCANMODE_EXTREME) { minfirstline_linear -= EXTRAHEIGHT_EXTREME / 2; minfirstline -= EXTRAHEIGHT_EXTREME / 2; - display_vblankstart_skip = linear_vpos_vblank_end; + display_vblankstart_skip = vbstart; display_vblankend_skip = 3; maxvpos_display_vsync += 2; } else if (currprefs.gfx_overscanmode == OVERSCANMODE_BROADCAST) { @@ -4566,7 +4563,7 @@ static void cursorsprite(struct sprite *s) static int calculate_linetype(int vp) { - int lineno = vp - linear_vb_offset; + int lineno = vp - (currprefs.cs_hvcsync >= HVSYNC_SYNCPOS ? LINES_AFTER_VSYNC : linear_vb_offset); nextline_how = nln_normal; if (doflickerfix_active()) { lineno *= 2; @@ -5289,14 +5286,14 @@ static void check_no_signal(void) nosignal_trigger = true; } // Inverted CSYNC - if ((beamcon0 & BEAMCON0_CSYTRUE) && currprefs.cs_hvcsync == 1) { + if ((beamcon0 & BEAMCON0_CSYTRUE) && (currprefs.cs_hvcsync == HVSYNC_CSYNC || currprefs.cs_hvcsync == HVSYNC_CSYNC_SYNC)) { nosignal_trigger = true; } // BLANKEN set: horizontal blanking is merged with CSYNC - if ((beamcon0 & BEAMCON0_BLANKEN) && currprefs.cs_hvcsync == 1) { + if ((beamcon0 & BEAMCON0_BLANKEN) && (currprefs.cs_hvcsync == HVSYNC_CSYNC || currprefs.cs_hvcsync == HVSYNC_CSYNC_SYNC)) { nosignal_trigger = true; } - if ((beamcon0 & BEAMCON0_CSCBEN) && currprefs.cs_hvcsync == 2) { + if ((beamcon0 & BEAMCON0_CSCBEN) && (currprefs.cs_hvcsync == HVSYNC_HVSYNC || currprefs.cs_hvcsync == HVSYNC_HVSYNC_SYNC)) { nosignal_trigger = true; } if (beamcon0 & BEAMCON0_VARBEAMEN) { @@ -5308,7 +5305,7 @@ static void check_no_signal(void) } // CSY output is invalid (no vsync part included) if HTOTAL is too small + hardwired CSYNC. int csyh = (beamcon0 & 0x20) ? 0x8c : 0x8d; - if (htotal < csyh && !(beamcon0 & BEAMCON0_VARCSYEN) && currprefs.cs_hvcsync == 1) { + if (htotal < csyh && !(beamcon0 & BEAMCON0_VARCSYEN) && (currprefs.cs_hvcsync == HVSYNC_CSYNC || currprefs.cs_hvcsync == HVSYNC_CSYNC_SYNC)) { nosignal_trigger = true; } } @@ -6613,19 +6610,19 @@ static void hsync_handler(bool vs) inputdevice_read_msg(true); vsync_display_render(); vsync_display_rendered = false; - if (currprefs.cs_hvcsync == 0) { + if ((currprefs.cs_hvcsync == HVSYNC_COMBINED || currprefs.cs_hvcsync == HVSYNC_COMBINED_SYNC)) { if (beamcon0 & (BEAMCON0_VARVSYEN | BEAMCON0_VARCSYEN)) { lof_display = lof_pdetect; } else { lof_display = lof_detect; } - } else if (currprefs.cs_hvcsync == 1) { + } else if (currprefs.cs_hvcsync == HVSYNC_CSYNC || currprefs.cs_hvcsync == HVSYNC_CSYNC_SYNC) { if (beamcon0 & BEAMCON0_VARCSYEN) { lof_display = lof_pdetect; } else { lof_display = lof_detect; } - } else if (currprefs.cs_hvcsync == 2) { + } else if (currprefs.cs_hvcsync == HVSYNC_HVSYNC || currprefs.cs_hvcsync == HVSYNC_HVSYNC_SYNC) { if (beamcon0 & BEAMCON0_VARVSYEN) { lof_display = lof_pdetect; } else { diff --git a/include/options.h b/include/options.h index b2ef2895..e83cdede 100644 --- a/include/options.h +++ b/include/options.h @@ -515,6 +515,14 @@ struct monconfig #define DISPLAY_OPTIMIZATIONS_PARTIAL 1 #define DISPLAY_OPTIMIZATIONS_NONE 2 +#define HVSYNC_COMBINED 0 +#define HVSYNC_CSYNC 1 +#define HVSYNC_HVSYNC 2 +#define HVSYNC_SYNCPOS 3 +#define HVSYNC_COMBINED_SYNC 3 +#define HVSYNC_CSYNC_SYNC 4 +#define HVSYNC_HVSYNC_SYNC 5 + struct uae_prefs { struct strlist *all_lines; diff --git a/od-win32/resources/resource.h b/od-win32/resources/resource.h index 1634fb17..f77d59c9 100644 --- a/od-win32/resources/resource.h +++ b/od-win32/resources/resource.h @@ -444,6 +444,9 @@ #define IDS_DISPLAY_OPTIMIZATION_NONE 450 #define IDS_KEYBOARD_DISCONNECTED 451 #define IDS_KEYBOARD_HIGHLEVEL 452 +#define IDS_SYNCMODE_COMBINED2 453 +#define IDS_SYNCMODE_CSYNC2 454 +#define IDS_SYNCMODE_HVSYNC2 455 #define IDS_QS_MODELS 1000 #define IDS_QS_MODEL_A500 1001 #define IDS_QS_MODEL_A500P 1002 diff --git a/od-win32/resources/winuae.rc b/od-win32/resources/winuae.rc index c1ab679d..f96af3b8 100644 --- a/od-win32/resources/winuae.rc +++ b/od-win32/resources/winuae.rc @@ -779,7 +779,7 @@ BEGIN "Button",BS_AUTOCHECKBOX | WS_TABSTOP,234,23,150,10 CONTROL "Wait for Blitter [] Compatibility hack for programs that don't wait for the blitter correctly, causing graphics corruption if CPU is too fast.",IDC_BLITWAIT, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,234,35,150,10 - LTEXT "Monitor sync source:",IDC_STATIC,242,96,101,9 + LTEXT "Monitor sync / positioning mode:",IDC_STATIC,242,96,101,9 COMBOBOX IDC_CS_HVCSYNC,237,108,147,75,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP LTEXT "Video port display hardware:",IDC_STATIC,241,123,117,15,SS_CENTERIMAGE COMBOBOX IDC_MONITOREMU,237,141,147,65,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP @@ -2216,9 +2216,12 @@ BEGIN IDS_SCREEN_NATIVELACE "Native (Interlaced)" IDS_PORT_AUTOFIRE_TOGGLENOAF "No autofire (toggle)" IDS_DEFAULT_WINUAECUSTOM "Custom" - IDS_SYNCMODE_COMBINED "Combined" - IDS_SYNCMODE_CSYNC "Composite Sync" - IDS_SYNCMODE_HVSYNC "H/V Sync" + IDS_SYNCMODE_COMBINED "Combined + Blanking" + IDS_SYNCMODE_CSYNC "Composite Sync + Blanking" + IDS_SYNCMODE_HVSYNC "H/V Sync + Blanking" + IDS_SYNCMODE_COMBINED2 "Combined + Sync" + IDS_SYNCMODE_CSYNC2 "Composite Sync + Sync" + IDS_SYNCMODE_HVSYNC2 "H/V Sync + Sync" IDS_MEMINFO "Configured 32-bit address space: %dM, reserved: %dM, Z3 available: %dM (UAE), %dM (Real)" IDS_INPUTINVERT "Invert" IDS_BOARDTYPE "Type" diff --git a/od-win32/win32_scaler.cpp b/od-win32/win32_scaler.cpp index 83839ce7..c97636d5 100644 --- a/od-win32/win32_scaler.cpp +++ b/od-win32/win32_scaler.cpp @@ -669,7 +669,7 @@ void getfilterdata(int monid, struct displayscale *ds) } } else { -skipcont: + int cw = avidinfo->drawbuffer.inwidth; int ch = avidinfo->drawbuffer.inheight; set_custom_limits(cw, ch, 0, 0, true); diff --git a/od-win32/win32gui.cpp b/od-win32/win32gui.cpp index 5c048a25..4aa182e5 100644 --- a/od-win32/win32gui.cpp +++ b/od-win32/win32gui.cpp @@ -9465,6 +9465,12 @@ static INT_PTR CALLBACK ChipsetDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPAR xSendDlgItemMessage(hDlg, IDC_CS_HVCSYNC, CB_ADDSTRING, 0, (LPARAM)buffer); WIN32GUI_LoadUIString(IDS_SYNCMODE_HVSYNC, buffer, sizeof buffer / sizeof(TCHAR)); xSendDlgItemMessage(hDlg, IDC_CS_HVCSYNC, CB_ADDSTRING, 0, (LPARAM)buffer); + WIN32GUI_LoadUIString(IDS_SYNCMODE_COMBINED2, buffer, sizeof buffer / sizeof(TCHAR)); + xSendDlgItemMessage(hDlg, IDC_CS_HVCSYNC, CB_ADDSTRING, 0, (LPARAM)buffer); + WIN32GUI_LoadUIString(IDS_SYNCMODE_CSYNC2, buffer, sizeof buffer / sizeof(TCHAR)); + xSendDlgItemMessage(hDlg, IDC_CS_HVCSYNC, CB_ADDSTRING, 0, (LPARAM)buffer); + WIN32GUI_LoadUIString(IDS_SYNCMODE_HVSYNC2, buffer, sizeof buffer / sizeof(TCHAR)); + xSendDlgItemMessage(hDlg, IDC_CS_HVCSYNC, CB_ADDSTRING, 0, (LPARAM)buffer); #ifndef AGA ew(hDlg, IDC_AGA, FALSE); -- 2.47.3