displayreset_delayed |= 16 | 8 | 4 | 2;
}
-void compute_framesync(void)
+static bool line_is_doubled(void)
{
- struct vidbuf_description *vidinfo = &adisplays[0].gfxvidinfo;
- struct amigadisplay *ad = &adisplays[0];
- int islace = interlace_seen ? 1 : 0;
- int isntsc = (beamcon0 & BEAMCON0_PAL) ? 0 : 1;
- bool found = false;
-
- if (islace) {
- vblank_hz = vblank_hz_lace;
- } else if (lof_store) {
- vblank_hz = vblank_hz_lof;
- } else {
- vblank_hz = vblank_hz_shf;
+ if (doflickerfix_active()) {
+ return true;
}
+ if (!interlace_seen && doublescan <= 0 && currprefs.gfx_vresolution && currprefs.gfx_pscanlines > 1) {
+ return true;
+ }
+ if ((doublescan <= 0 || interlace_seen > 0) && currprefs.gfx_vresolution && currprefs.gfx_iscanlines) {
+ return true;
+ }
+ if (currprefs.gfx_vresolution && (doublescan <= 0 || interlace_seen > 0)) {
+ return true;
+ }
+ return false;
+}
- set_drawbuffer();
- struct vidbuffer *vb = vidinfo->inbuffer;
-
- vblank_hz = target_adjust_vblank_hz(0, vblank_hz);
-
- struct chipset_refresh *cr = get_chipset_refresh(&currprefs);
- while (cr) {
- float v = -1;
- if (!ad->picasso_on && !ad->picasso_requested_on) {
- if (isvsync_chipset ()) {
- if (!currprefs.gfx_variable_sync) {
- if (cr->index == CHIPSET_REFRESH_PAL || cr->index == CHIPSET_REFRESH_NTSC) {
- if ((fabs(vblank_hz - 50.0f) < 1 || fabs(vblank_hz - 60.0f) < 1 || fabs(vblank_hz - 100.0) < 1 || fabs(vblank_hz - 120.0f) < 1) && currprefs.gfx_apmode[0].gfx_vsync == 2 && currprefs.gfx_apmode[0].gfx_fullscreen > 0) {
- vsync_switchmode(0, (int)vblank_hz);
- }
- }
- if (isvsync_chipset() < 0) {
+static void update_display_vars(void)
+{
+ struct vidbuf_description* vidinfo = &adisplays[0].gfxvidinfo;
+ struct vidbuffer* vb = vidinfo->inbuffer;
+ int isntsc = (beamcon0 & BEAMCON0_PAL) ? 0 : 1;
+ int islace = interlace_seen ? 1 : 0;
+ int res = GET_RES_AGNUS(bplcon0);
+ int eres = 0;
- float v2;
- v2 = target_getcurrentvblankrate(0);
- if (!cr->locked)
- v = v2;
- } else if (isvsync_chipset() > 0) {
- if (currprefs.gfx_apmode[0].gfx_refreshrate) {
- v = (float)abs(currprefs.gfx_apmode[0].gfx_refreshrate);
- }
- }
- }
- } else {
- if (cr->locked == false) {
- changed_prefs.chipset_refreshrate = currprefs.chipset_refreshrate = vblank_hz;
- cfgfile_parse_lines (&changed_prefs, cr->commands, -1);
- if (cr->commands[0]) {
- write_log(_T("CMD1: '%s'\n"), cr->commands);
- }
- break;
- } else {
- v = cr->rate;
- }
- }
- if (v < 0)
- v = cr->rate;
- if (v > 0) {
- changed_prefs.chipset_refreshrate = currprefs.chipset_refreshrate = v;
- cfgfile_parse_lines (&changed_prefs, cr->commands, -1);
- if (cr->commands[0]) {
- write_log(_T("CMD2: '%s'\n"), cr->commands);
- }
+ doublescan = 0;
+ doublescan2x = 0;
+ if (currprefs.gfx_scandoubler && doublescan == 0) {
+ doublescan = -1;
+ }
+ int hpixels = maxhpos_display * 2;
+ if (currprefs.gfx_resolution == RES_LORES) {
+ hpixels /= 2;
+ } else if (currprefs.gfx_resolution == RES_SUPERHIRES) {
+ hpixels *= 2;
+ }
+ int vpixels = vsync_lines - minfirstline;
+ int hpixelsd = hpixels * 85 / 100;
+ if (hpixelsd < vpixels) {
+ doublescan = 1;
+ if (programmedmode == 2) {
+ programmedmode = 1;
+ }
+ hpixelsd *= 2;
+ }
+ if (currprefs.gfx_keep_aspect) {
+ bool dbl = line_is_doubled();
+ if (dbl) {
+ vpixels *= 2;
+ }
+ if (hpixelsd < vpixels) {
+ doublescan2x = 1;
+ hpixelsd *= 2;
+ if (hpixelsd < vpixels) {
+ doublescan2x = 2;
}
- } else {
- if (cr->locked == false)
- v = vblank_hz;
- else
- v = cr->rate;
- changed_prefs.chipset_refreshrate = currprefs.chipset_refreshrate = v;
- cfgfile_parse_lines (&changed_prefs, cr->commands, -1);
- if (cr->commands[0]) {
- write_log(_T("CMD3: '%s'\n"), cr->commands);
+ } else if (hpixelsd > vpixels * 2) {
+ doublescan2x = -1;
+ if (hpixelsd > vpixels * 4) {
+ doublescan2x = -2;
}
}
- found = true;
- break;
- }
- if (!found) {
- changed_prefs.chipset_refreshrate = currprefs.chipset_refreshrate = vblank_hz;
}
- stored_chipset_refresh = cr;
- vb->inxoffset = -1;
- vb->inyoffset = -1;
-
- int res = GET_RES_AGNUS(bplcon0);
- int eres = 0;
int res2 = currprefs.gfx_resolution;
if (currprefs.gfx_extraheight > 0) {
vb->extraheight = currprefs.gfx_extraheight << vres2;
}
+
int vblines = current_linear_vblank_lines;
if (currprefs.cs_hvcsync >= HVSYNC_SYNCPOS) {
vblines = LINES_AFTER_VSYNC;
hblank_hz = (currprefs.ntscmode ? CHIPSET_CLOCK_NTSC : CHIPSET_CLOCK_PAL) / (maxhpos + (linetoggle ? 0.5f : 0.0f));
- write_log(_T("%s mode%s%s V=%.4fHz H=%0.4fHz (%dx%d+%d) IDX=%d (%s) D=%d RTG=%d/%d\n"),
- isntsc ? _T("NTSC") : _T("PAL"),
- islace ? _T(" lace") : _T(""),
- doublescan > 0 ? _T(" dblscan") : _T(""),
- vblank_hz,
- hblank_hz,
- maxhpos, maxvpos, lof_store ? 1 : 0,
- cr ? cr->index : -1,
- cr != NULL && cr->label != NULL ? cr->label : _T("<?>"),
- currprefs.gfx_apmode[ad->picasso_on ? 1 : 0].gfx_display, ad->picasso_on, ad->picasso_requested_on
- );
-
#ifdef PICASSO96
init_hz_p96(0);
#endif
resetfulllinestate();
}
-static bool line_is_doubled(void)
+
+void compute_framesync(void)
{
- if (doflickerfix_active()) {
- return true;
- }
- if (!interlace_seen && doublescan <= 0 && currprefs.gfx_vresolution && currprefs.gfx_pscanlines > 1) {
- return true;
+ struct vidbuf_description *vidinfo = &adisplays[0].gfxvidinfo;
+ struct amigadisplay *ad = &adisplays[0];
+ int isntsc = (beamcon0 & BEAMCON0_PAL) ? 0 : 1;
+ int islace = interlace_seen ? 1 : 0;
+ bool found = false;
+
+ if (islace) {
+ vblank_hz = vblank_hz_lace;
+ } else if (lof_store) {
+ vblank_hz = vblank_hz_lof;
+ } else {
+ vblank_hz = vblank_hz_shf;
}
- if ((doublescan <= 0 || interlace_seen > 0) && currprefs.gfx_vresolution && currprefs.gfx_iscanlines) {
- return true;
+
+ set_drawbuffer();
+ struct vidbuffer *vb = vidinfo->inbuffer;
+
+ vblank_hz = target_adjust_vblank_hz(0, vblank_hz);
+
+ struct chipset_refresh *cr = get_chipset_refresh(&currprefs);
+ while (cr) {
+ float v = -1;
+ if (!ad->picasso_on && !ad->picasso_requested_on) {
+ if (isvsync_chipset ()) {
+ if (!currprefs.gfx_variable_sync) {
+ if (cr->index == CHIPSET_REFRESH_PAL || cr->index == CHIPSET_REFRESH_NTSC) {
+ if ((fabs(vblank_hz - 50.0f) < 1 || fabs(vblank_hz - 60.0f) < 1 || fabs(vblank_hz - 100.0) < 1 || fabs(vblank_hz - 120.0f) < 1) && currprefs.gfx_apmode[0].gfx_vsync == 2 && currprefs.gfx_apmode[0].gfx_fullscreen > 0) {
+ vsync_switchmode(0, (int)vblank_hz);
+ }
+ }
+ if (isvsync_chipset() < 0) {
+
+ float v2;
+ v2 = target_getcurrentvblankrate(0);
+ if (!cr->locked)
+ v = v2;
+ } else if (isvsync_chipset() > 0) {
+ if (currprefs.gfx_apmode[0].gfx_refreshrate) {
+ v = (float)abs(currprefs.gfx_apmode[0].gfx_refreshrate);
+ }
+ }
+ }
+ } else {
+ if (cr->locked == false) {
+ changed_prefs.chipset_refreshrate = currprefs.chipset_refreshrate = vblank_hz;
+ cfgfile_parse_lines (&changed_prefs, cr->commands, -1);
+ if (cr->commands[0]) {
+ write_log(_T("CMD1: '%s'\n"), cr->commands);
+ }
+ break;
+ } else {
+ v = cr->rate;
+ }
+ }
+ if (v < 0)
+ v = cr->rate;
+ if (v > 0) {
+ changed_prefs.chipset_refreshrate = currprefs.chipset_refreshrate = v;
+ cfgfile_parse_lines (&changed_prefs, cr->commands, -1);
+ if (cr->commands[0]) {
+ write_log(_T("CMD2: '%s'\n"), cr->commands);
+ }
+ }
+ } else {
+ if (cr->locked == false)
+ v = vblank_hz;
+ else
+ v = cr->rate;
+ changed_prefs.chipset_refreshrate = currprefs.chipset_refreshrate = v;
+ cfgfile_parse_lines (&changed_prefs, cr->commands, -1);
+ if (cr->commands[0]) {
+ write_log(_T("CMD3: '%s'\n"), cr->commands);
+ }
+ }
+ found = true;
+ break;
}
- if (currprefs.gfx_vresolution && (doublescan <= 0 || interlace_seen > 0)) {
- return true;
+ if (!found) {
+ changed_prefs.chipset_refreshrate = currprefs.chipset_refreshrate = vblank_hz;
}
- return false;
+ stored_chipset_refresh = cr;
+ vb->inxoffset = -1;
+ vb->inyoffset = -1;
+
+ update_display_vars();
+
+ write_log(_T("%s mode%s%s V=%.4fHz H=%0.4fHz (%dx%d+%d) IDX=%d (%s) D=%d RTG=%d/%d\n"),
+ isntsc ? _T("NTSC") : _T("PAL"),
+ islace ? _T(" lace") : _T(""),
+ doublescan > 0 ? _T(" dblscan") : _T(""),
+ vblank_hz,
+ hblank_hz,
+ maxhpos, maxvpos, lof_store ? 1 : 0,
+ cr ? cr->index : -1,
+ cr != NULL && cr->label != NULL ? cr->label : _T("<?>"),
+ currprefs.gfx_apmode[ad->picasso_on ? 1 : 0].gfx_display, ad->picasso_on, ad->picasso_requested_on
+ );
}
/* set PAL/NTSC or custom timing variables */
beamcon0 = new_beamcon0;
- doublescan = 0;
- doublescan2x = 0;
programmedmode = 0;
lines_after_beamcon_change = 5;
if (!isntsc) {
maxvpos = MAXVPOS_PAL;
maxhpos = MAXHPOS_PAL;
- //minfirstline = VBLANK_STOP_PAL;
vblank_hz_nom = vblank_hz = CHIPSET_CLOCK_PAL / ((float)display_maxvpos * display_maxhpos);
} else {
maxvpos = MAXVPOS_NTSC;
maxhpos = MAXHPOS_NTSC;
- //minfirstline = VBLANK_STOP_NTSC;
vblank_hz_nom = vblank_hz = CHIPSET_CLOCK_NTSC / ((float)display_maxvpos * display_maxhpos);
halfhpos = (beamcon0 & BEAMCON0_LOLDIS) ? 0 : 0.5f;
}
vblank_hz_lof = clk / ((display_maxvpos + 1.0f) * (display_maxhpos + halfhpos));
vblank_hz_lace = clk / ((display_maxvpos + 0.5f) * (display_maxhpos + halfhpos));
-#if 0
- display_hstart_cyclewait_end = 4;
- if (beamcon0_has_hsync) {
- int hblen = current_linear_hblen * 2;
- display_hstart_cyclewait = 4;
- if (currprefs.gfx_overscanmode >= OVERSCANMODE_ULTRA) {
- display_hstart_cyclewait_end = 0;
- } else {
- if (aexthblanken && !(beamcon0 & BEAMCON0_VARBEAMEN) && hblen > 0) {
- maxhpos_display = maxhpos - ((hblen + 1) / 2);
- hsstop_detect = current_linear_hs_hb_dist * 2 + 4;
- display_hstart_cyclewait_end += hblen / 2 - 4;
- display_hstart_cyclewait = current_linear_hs_hb_dist;
- if (display_hstart_cyclewait < 0) {
- display_hstart_cyclewait = 0;
- }
- display_hstart_cyclewait_end = hblen / 2 - display_hstart_cyclewait;
- display_hstart_cyclewait += 1;
- } else {
- // hardwired
- int hbstrtx = 0x10;
- int hbstopx = ecs_denise ? 0x5d : 0x5e;
- int hblen = hbstopx - hbstrtx;
- maxhpos_display = maxhpos - (hblen / 2);
- if (beamcon0_has_hsync) {
- hsstop_detect = hsstrt * 2;
- } else {
- hsstop_detect = hsstop_detect2;
- }
-
- display_hstart_cyclewait = hbstopx / 2 - hsstrt;
- //display_hstart_cyclewait += hsstrt_delay;
- }
- }
- } else {
- display_hstart_cyclewait = 0;
- display_hstart_cyclewait_end = 0;
- if (currprefs.gfx_overscanmode == OVERSCANMODE_BROADCAST) {
- display_hstart_cyclewait = 32;
- display_hstart_cyclewait_end = 9;
- } else if (currprefs.gfx_overscanmode <= OVERSCANMODE_OVERSCAN) {
- display_hstart_cyclewait = 32;
- display_hstart_cyclewait_end = 10;
- } else if (currprefs.gfx_overscanmode == OVERSCANMODE_EXTREME) {
- display_hstart_cyclewait = 22;
- display_hstart_cyclewait_end = 5;
- }
- }
-#endif
-
if (beamcon0 & BEAMCON0_VARBEAMEN) {
// programmable scanrates (ECS Agnus)
if (vtotal >= MAXVPOS) {
int hsylen = current_agnus_hslen_cck;
hsylen *= 2;
hsylen += currprefs.cs_hsyncadjust / 4;
- //hsstop_detect = hbe;
if (hbe < hsylen) {
hbe = hsylen;
}
maxhpos_display = hsync_ccks * 2;
display_hstart_cyclewait_start = 0;
display_hstart_cyclewait_end = 0;
- //minfirstline = 0;
}
if (display_hstart_cyclewait_start < 0) {
denisehtotal += 1 << (CCK_SHRES_SHIFT - 1);
}
-#if 0
- // calculate max possible display width in lores pixels
- if ((beamcon0 & BEAMCON0_VARBEAMEN) && beamcon0_has_hsync) {
- int hsstrt_delay = 2;
- display_hstart_cyclewait = 0;
- display_hstart_cyclewait_end = 0;
- // assume VGA-like monitor if VARBEAMEN
- if (currprefs.gfx_overscanmode >= OVERSCANMODE_ULTRA) {
- maxhpos_display = maxhpos + 7;
- if (beamcon0_has_hsync) {
- hsstop_detect = hsstrt * 2;
- if (hsstop_detect > maxhpos / 2 * 2 || hsstop_detect < 4 * 2) {
- hsstop_detect = 4 * 2;
- }
- } else {
- hsstop_detect = 4 * 2;
- }
- minfirstline = 0;
- } else {
- //int hblen = current_linear_hblen * 2;
-
- if (aexthblanken && hblen > 0) {
-
- maxhpos_display = maxhpos - ((hblen + 1) / 2);
- hsstop_detect = hbe;
- display_hstart_cyclewait_end += hblen / 2;
- display_hstart_cyclewait = hbe / 2;
- if (display_hstart_cyclewait < 0) {
- display_hstart_cyclewait = 0;
- }
- display_hstart_cyclewait_end = hblen / 2 - display_hstart_cyclewait;
- display_hstart_cyclewait += 1;
-
- } else {
-
- // hardwired
- int hbstrtx = 0x10;
- int hbstopx = ecs_denise ? 0x5d : 0x5e;
- int hblen = hbstopx - hbstrtx;
- maxhpos_display = maxhpos - (hblen / 2);
- if (beamcon0_has_hsync) {
- hsstop_detect = hsstrt * 2;
- } else {
- hsstop_detect = hsstop_detect2;
- }
-
- display_hstart_cyclewait = hbstopx / 2 - hsstrt;
- display_hstart_cyclewait += hsstrt_delay;
- }
-
- if (currprefs.gfx_overscanmode >= OVERSCANMODE_EXTREME) {
- int diff = (maxhpos - 2) - maxhpos_display;
- if (diff > 0) {
- hsstop_detect -= (diff / 2) * 2;
- }
- maxhpos_display = maxhpos - 2;
- }
-
- maxhpos_display *= 2;
- if (display_hstart_cyclewait_end < 0) {
- display_hstart_cyclewait_end = 0;
- }
- }
-
- } else if (!(beamcon0 & BEAMCON0_VARBEAMEN)) {
-
- maxhpos_display = maxhpos - (hblen / 2);
- maxhpos_display *= 2;
- maxhpos_display++;
- hsstop_detect = hbe;
- display_hstart_cyclewait = hbe / 2 + 3;
- if (display_hstart_cyclewait < 0) {
- display_hstart_cyclewait = 0;
- }
- display_hstart_cyclewait_end = hblen / 2 - display_hstart_cyclewait + 1;
- display_hstart_cyclewait += 1;
-
-
- //maxhpos_display = AMIGA_WIDTH_MAX;
- //hsstop_detect = hsstop_detect2;
-
- if (beamcon0 & bemcon0_hsync_mask) {
- if (currprefs.gfx_overscanmode < OVERSCANMODE_BROADCAST) {
- hsstop_detect += 7;
- } else if (currprefs.gfx_overscanmode == OVERSCANMODE_BROADCAST) {
- hsstop_detect += 5;
- } else if (currprefs.gfx_overscanmode >= OVERSCANMODE_ULTRA) {
- maxhpos_display += EXTRAWIDTH_ULTRA;
- minfirstline = 0;
- hsstop_detect = hsyncstartpos_start_cycles * 2 - 4;
- }
- } else {
-
- if (currprefs.gfx_overscanmode >= OVERSCANMODE_ULTRA) {
- maxhpos_display += EXTRAWIDTH_ULTRA;
- hsstop_detect = 18 * 2;
- minfirstline = 1;
- }
- }
-
- }
-
- if (!(beamcon0 & BEAMCON0_VARBEAMEN) || !beamcon0_has_hsync) {
- if (currprefs.gfx_overscanmode < OVERSCANMODE_BROADCAST) {
- // one pixel row missing from right border if OCS
- if (!ecs_denise) {
- maxhpos_display--;
- }
- minfirstline++;
- if (maxvpos_display_vsync > 0) {
- maxvpos_display_vsync--;
- } else {
- maxvpos_display--;
- }
- } else if (currprefs.gfx_overscanmode == OVERSCANMODE_EXTREME) {
- maxhpos_display += EXTRAWIDTH_EXTREME;
- hsstop_detect -= 4;
- } else if (currprefs.gfx_overscanmode == OVERSCANMODE_BROADCAST) {
- maxhpos_display += EXTRAWIDTH_BROADCAST;
- hsstop_detect -= 1;
- }
- }
-#endif
-
if (currprefs.gfx_extrawidth > 0) {
maxhpos_display += currprefs.gfx_extrawidth;
}
display_vblankend_skip = 2;
}
-#if 0
- if ((beamcon0 & BEAMCON0_VARVBEN) && (beamcon0 & bemcon0_vsync_mask)) {
- if (minfirstline < vsync_startline) {
- minfirstline = vsync_startline;
- minfirstline++;
- }
- if (minfirstline > vsync_lines / 2) {
- minfirstline = vsync_startline;
- minfirstline++;
- }
- } else if (beamcon0 & BEAMCON0_VARVBEN) {
- if (minfirstline > vbstop) {
- minfirstline = vbstop;
- if (minfirstline < 3) {
- minfirstline = 3;
- }
- }
- }
-#endif
if (beamcon0 & (BEAMCON0_VARVBEN | bemcon0_vsync_mask)) {
programmedmode = 2;
}
- int eh = currprefs.gfx_extraheight;
- if (eh > 0) {
- if (beamcon0 & bemcon0_vsync_mask) {
- minfirstline -= eh / 2;
- } else {
- minfirstline -= eh / 2;
- }
- }
-
if (display_hstart_cyclewait_end < 0) {
display_hstart_cyclewait_end = 0;
}
-// if (minfirstline < vsync_startline) {
-// minfirstline = vsync_startline;
-// }
-// if (minfirstline >= vsync_lines) {
-// minfirstline = vsync_lines - 1;
-// }
-// if (beamcon0 & bemcon0_vsync_mask) {
-// if (minfirstline < vsync_startline) {
-// minfirstline = vsync_startline;
-// }
-// }
-
if (beamcon0 & BEAMCON0_VARBEAMEN) {
float half = (beamcon0 & BEAMCON0_PAL) ? 0: ((beamcon0 & BEAMCON0_LOLDIS) ? 0 : 0.5f);
vblank_hz_nom = vblank_hz = clk / (vsync_lines * (hsync_ccks + half));
programmedmode = 2;
}
- int hpixels = maxhpos_display * 2;
- if (currprefs.gfx_resolution == RES_LORES) {
- hpixels /= 2;
- } else if (currprefs.gfx_resolution == RES_SUPERHIRES) {
- hpixels *= 2;
- }
- int vpixels = vsync_lines - minfirstline;
- int hpixelsd = hpixels * 85 / 100;
- if (hpixelsd < vpixels) {
- doublescan = 1;
- if (programmedmode == 2) {
- programmedmode = 1;
- }
- hpixelsd *= 2;
- }
- if (currprefs.gfx_keep_aspect) {
- bool dbl = line_is_doubled();
- if (dbl) {
- vpixels *= 2;
- }
- if (hpixelsd < vpixels) {
- doublescan2x = 1;
- hpixelsd *= 2;
- if (hpixelsd < vpixels) {
- doublescan2x = 2;
- }
- } else if (hpixelsd > vpixels * 2) {
- doublescan2x = -1;
- if (hpixelsd > vpixels * 4) {
- doublescan2x = -2;
- }
- }
- }
-
if (maxvpos_nom >= MAXVPOS) {
maxvpos_nom = MAXVPOS;
}
if (maxvpos_display >= MAXVPOS) {
maxvpos_display = MAXVPOS;
}
- if (currprefs.gfx_scandoubler && doublescan == 0) {
- doublescan = -1;
- }
+
/* limit to sane values */
if (vblank_hz < 10) {
vblank_hz = 10;
if (beamcon0_has_hsync) {
count_hsyncs(hsstrt, hsstop);
} else {
- count_hsyncs(35, 18);
+ count_hsyncs(18, 35);
}
if (programmed_register_accessed_v && programmed_register_accessed_h) {
if (hcenter < maxhpos) {