From 8158233b55bbe43e22193533a230907f334550cf Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Sun, 21 Feb 2016 14:06:03 +0200 Subject: [PATCH] Add current resolution to displaydata config system. --- cfgfile.cpp | 175 +++++++++++++++++++++++++++++++++------------------- custom.cpp | 1 + drawing.cpp | 30 +++++---- 3 files changed, 131 insertions(+), 75 deletions(-) diff --git a/cfgfile.cpp b/cfgfile.cpp index 67bdb6aa..60a68a1b 100644 --- a/cfgfile.cpp +++ b/cfgfile.cpp @@ -1725,9 +1725,9 @@ void cfgfile_save_options (struct zfile *f, struct uae_prefs *p, int type) cfgfile_write (f, _T("chipset_refreshrate"), _T("%f"), p->chipset_refreshrate); for (int i = 0; i < MAX_CHIPSET_REFRESH_TOTAL; i++) { - if (p->cr[i].rate <= 0) - continue; struct chipset_refresh *cr = &p->cr[i]; + if (!cr->inuse) + continue; cr->index = i; _stprintf (tmp, _T("%f"), cr->rate); TCHAR *s = tmp + _tcslen (tmp); @@ -1747,6 +1747,16 @@ void cfgfile_save_options (struct zfile *f, struct uae_prefs *p, int type) _tcscat (s, _T(",lace")); else if (cr->lace == 0) _tcscat (s, _T(",nlace")); + if ((cr->resolution & 7) != 7) { + if (cr->resolution & 1) + _tcscat(s, _T(",lores")); + if (cr->resolution & 2) + _tcscat(s, _T(",hires")); + if (cr->resolution & 4) + _tcscat(s, _T(",shres")); + if (cr->resolution_pct > 0 && cr->resolution_pct < 100) + s += _stprintf(s, _T("rpct=%d"), cr->resolution_pct); + } if (cr->framelength > 0) _tcscat (s, _T(",lof")); else if (cr->framelength == 0) @@ -1757,8 +1767,13 @@ void cfgfile_save_options (struct zfile *f, struct uae_prefs *p, int type) _tcscat (s, _T(",nvsync")); if (cr->rtg) _tcscat (s, _T(",rtg")); + if (cr->filterprofile[0]) { + TCHAR *se = cfgfile_escape(cr->filterprofile, _T(","), true); + s += _stprintf(s, _T(",filter=%s"), cr->filterprofile); + xfree(se); + } if (cr->commands[0]) { - _tcscat (s, _T(",")); + _tcscat (s, _T(",cmd=")); _tcscat (s, cr->commands); for (int j = 0; j < _tcslen (s); j++) { if (s[j] == '\n') @@ -2958,7 +2973,13 @@ static int cfgfile_parse_host (struct uae_prefs *p, TCHAR *option, TCHAR *value) } } } - if (!_tcscmp (value, _T("direct3d"))) { + if (!_tcscmp(value, _T("none"))) { + gf->gfx_filtershader[2 * MAX_FILTERSHADERS][0] = 0; + for (int i = 0; i < 2 * MAX_FILTERSHADERS; i++) { + gf->gfx_filtershader[i][0] = 0; + gf->gfx_filtermask[i][0] = 0; + } + } else if (!_tcscmp (value, _T("direct3d"))) { p->gfx_api = 1; // forwards compatibiity } else { int i = 0; @@ -3227,11 +3248,13 @@ static int cfgfile_parse_host (struct uae_prefs *p, TCHAR *option, TCHAR *value) _tcsncpy (tmpbuf, value, sizeof tmpbuf / sizeof (TCHAR) - 1); tmpbuf[sizeof tmpbuf / sizeof (TCHAR) - 1] = '\0'; - int vert = -1, horiz = -1, lace = -1, ntsc = -1, framelength = -1, vsync = -1; + int vert = -1, horiz = -1, lace = -1, ntsc = -1, framelength = -1, vsync = -1, hres = 0; bool locked = false; bool rtg = false; + bool cmdmode = false; double rate = -1; - TCHAR cmd[MAX_DPATH], label[16] = { 0 }; + int rpct = 0; + TCHAR cmd[MAX_DPATH], filter[64] = { 0 }, label[16] = { 0 }; TCHAR *tmpp = tmpbuf; TCHAR *end = tmpbuf + _tcslen (tmpbuf); cmd[0] = 0; @@ -3247,70 +3270,96 @@ static int cfgfile_parse_host (struct uae_prefs *p, TCHAR *option, TCHAR *value) equals++; *next = 0; - if (rate < 0) - rate = _tstof (tmpp); - else if (!_tcsnicmp (tmpp, _T("v="), 2)) - vert = _tstol (equals); - else if (!_tcsnicmp (tmpp, _T("h="), 2)) - horiz = _tstol (equals); - else if (!_tcsnicmp (tmpp, _T("t="), 2)) - _tcsncpy (label, equals, sizeof label / sizeof (TCHAR) - 1); - else if (equals) { - if (_tcslen (cmd) + _tcslen (tmpp) + 2 < sizeof (cmd) / sizeof (TCHAR)) { - _tcscat (cmd, tmpp); - _tcscat (cmd, _T("\n")); + if (cmdmode) { + if (_tcslen(cmd) + _tcslen(tmpp) + 2 < sizeof(cmd) / sizeof(TCHAR)) { + _tcscat(cmd, tmpp); + _tcscat(cmd, _T("\n")); + } + } else { + if (!_tcsnicmp(tmpp, _T("cmd="), 4)) { + cmdmode = true; + tmpp += 4; } + if (rate < 0) + rate = _tstof(tmpp); + else if (!_tcsnicmp(tmpp, _T("v="), 2)) + vert = _tstol(equals); + else if (!_tcsnicmp(tmpp, _T("h="), 2)) + horiz = _tstol(equals); + else if (!_tcsnicmp(tmpp, _T("t="), 2)) + _tcsncpy(label, equals, sizeof label / sizeof(TCHAR) - 1); + else if (!_tcsnicmp(tmpp, _T("filter="), 7)) + _tcsncpy(filter, equals, sizeof filter / sizeof(TCHAR) - 1); + else if (!_tcsnicmp(tmpp, _T("rpct="), 5)) + rpct = _tstol(equals); + else if (equals) { + if (_tcslen(cmd) + _tcslen (tmpp) + 2 < sizeof (cmd) / sizeof (TCHAR)) { + _tcscat(cmd, tmpp); + _tcscat(cmd, _T("\n")); + } + } + if (!_tcsnicmp(tmpp, _T("locked"), 4)) + locked = true; + if (!_tcsnicmp(tmpp, _T("nlace"), 5)) + lace = 0; + if (!_tcsnicmp(tmpp, _T("lace"), 4)) + lace = 1; + if (!_tcsnicmp(tmpp, _T("lores"), 5)) + hres |= 1 << RES_LORES; + if (!_tcsnicmp(tmpp, _T("hires"), 5)) + hres |= 1 << RES_HIRES; + if (!_tcsnicmp(tmpp, _T("shres"), 5)) + hres |= 1 << RES_SUPERHIRES; + if (!_tcsnicmp(tmpp, _T("nvsync"), 5)) + vsync = 0; + if (!_tcsnicmp(tmpp, _T("vsync"), 4)) + vsync = 1; + if (!_tcsnicmp(tmpp, _T("ntsc"), 4)) + ntsc = 1; + if (!_tcsnicmp(tmpp, _T("pal"), 3)) + ntsc = 0; + if (!_tcsnicmp(tmpp, _T("lof"), 3)) + framelength = 1; + if (!_tcsnicmp(tmpp, _T("shf"), 3)) + framelength = 0; + if (!_tcsnicmp(tmpp, _T("rtg"), 3)) + rtg = true; } - if (!_tcsnicmp (tmpp, _T("locked"), 4)) - locked = true; - if (!_tcsnicmp (tmpp, _T("nlace"), 5)) - lace = 0; - if (!_tcsnicmp (tmpp, _T("lace"), 4)) - lace = 1; - if (!_tcsnicmp (tmpp, _T("nvsync"), 5)) - vsync = 0; - if (!_tcsnicmp (tmpp, _T("vsync"), 4)) - vsync = 1; - if (!_tcsnicmp (tmpp, _T("ntsc"), 4)) - ntsc = 1; - if (!_tcsnicmp (tmpp, _T("pal"), 3)) - ntsc = 0; - if (!_tcsnicmp (tmpp, _T("lof"), 3)) - framelength = 1; - if (!_tcsnicmp (tmpp, _T("shf"), 3)) - framelength = 0; - if (!_tcsnicmp (tmpp, _T("rtg"), 3)) - rtg = true; tmpp = next; if (tmpp >= end) break; tmpp++; } - if (rate > 0) { - for (int i = 0; i < MAX_CHIPSET_REFRESH; i++) { - if (_tcscmp (option, _T("displaydata_pal")) == 0) { - i = CHIPSET_REFRESH_PAL; - p->cr[i].rate = -1; - _tcscpy (label, _T("PAL")); - } else if (_tcscmp (option, _T("displaydata_ntsc")) == 0) { - i = CHIPSET_REFRESH_NTSC; - p->cr[i].rate = -1; - _tcscpy (label, _T("NTSC")); - } - if (p->cr[i].rate <= 0) { - p->cr[i].horiz = horiz; - p->cr[i].vert = vert; - p->cr[i].lace = lace; - p->cr[i].ntsc = ntsc; - p->cr[i].vsync = vsync; - p->cr[i].locked = locked; - p->cr[i].rtg = rtg; - p->cr[i].framelength = framelength; - p->cr[i].rate = rate; - _tcscpy (p->cr[i].commands, cmd); - _tcscpy (p->cr[i].label, label); - break; - } + for (int i = 0; i < MAX_CHIPSET_REFRESH; i++) { + struct chipset_refresh *cr = &p->cr[i]; + if (_tcscmp (option, _T("displaydata_pal")) == 0) { + i = CHIPSET_REFRESH_PAL; + cr->rate = -1; + _tcscpy (label, _T("PAL")); + } else if (_tcscmp (option, _T("displaydata_ntsc")) == 0) { + i = CHIPSET_REFRESH_NTSC; + cr->rate = -1; + _tcscpy (label, _T("NTSC")); + } + if (!cr->inuse) { + cr->inuse = true; + cr->horiz = horiz; + cr->vert = vert; + cr->lace = lace; + cr->resolution = hres ? hres : 1 + 2 + 4; + cr->resolution_pct = rpct; + cr->ntsc = ntsc; + cr->vsync = vsync; + cr->locked = locked; + cr->rtg = rtg; + cr->framelength = framelength; + cr->rate = rate; + _tcscpy(cr->commands, cmd); + _tcscpy(cr->label, label); + TCHAR *se = cfgfile_unescape(filter, NULL); + _tcscpy(cr->filterprofile, se); + xfree(se); + break; } } return 1; diff --git a/custom.cpp b/custom.cpp index dda4bd5a..5c3e55d0 100644 --- a/custom.cpp +++ b/custom.cpp @@ -3928,6 +3928,7 @@ struct chipset_refresh *get_chipset_refresh (void) (cr->vert < 0 || cr->vert == maxvpos_display) && (cr->ntsc < 0 || (cr->ntsc > 0 && isntsc) || (cr->ntsc == 0 && !isntsc)) && (cr->lace < 0 || (cr->lace > 0 && islace) || (cr->lace == 0 && !islace)) && + (cr->resolution == 0 || cr->resolution == 7 || (cr->resolution & (1 << detected_screen_resolution))) && (cr->framelength < 0 || (cr->framelength > 0 && lof_store) || (cr->framelength == 0 && !lof_store) || (cr->framelength >= 0 && islace)) && ((cr->rtg && picasso_on) || (!cr->rtg && !picasso_on)) && (cr->vsync < 0 || (cr->vsync > 0 && isvsync_chipset ()) || (cr->vsync == 0 && !isvsync_chipset ()))) diff --git a/drawing.cpp b/drawing.cpp index c7a214e0..5a78aaef 100644 --- a/drawing.cpp +++ b/drawing.cpp @@ -96,7 +96,9 @@ static int res_shift; static int linedbl, linedbld; -int interlace_seen = 0; +int interlace_seen; +int detected_screen_resolution; + #define AUTO_LORES_FRAMES 10 static int can_use_lores = 0, frame_res, frame_res_lace; static int resolution_count[RES_MAX + 1], lines_count; @@ -3167,18 +3169,22 @@ static void init_drawing_frame (void) int i, maxline; static int frame_res_old; - if (currprefs.gfx_resolution == changed_prefs.gfx_resolution && lines_count > 0) { - int largest_count = 0; - int largest_count_res = 0; - int largest_res = 0; - for (int i = 0; i <= RES_MAX; i++) { - if (resolution_count[i]) - largest_res = i; - if (resolution_count[i] >= largest_count) { - largest_count = resolution_count[i]; - largest_count_res = i; - } + int largest_res = 0; + int largest_count = 0; + int largest_count_res = 0; + for (int i = 0; i <= RES_MAX; i++) { + if (resolution_count[i]) + largest_res = i; + if (resolution_count[i] >= largest_count) { + largest_count = resolution_count[i]; + largest_count_res = i; } + } + if (currprefs.gfx_resolution == changed_prefs.gfx_resolution && lines_count > 0) { + detected_screen_resolution = largest_res; + } + + if (currprefs.gfx_resolution == changed_prefs.gfx_resolution && lines_count > 0) { if (currprefs.gfx_autoresolution_vga && programmedmode && gfxvidinfo.gfx_resolution_reserved >= RES_HIRES && gfxvidinfo.gfx_vresolution_reserved >= VRES_DOUBLE) { if (largest_res == RES_SUPERHIRES && (gfxvidinfo.gfx_resolution_reserved < RES_SUPERHIRES || gfxvidinfo.gfx_vresolution_reserved < 1)) { -- 2.47.3