From 2f7de1d23d819525772c185ac5f6a00ac9e482cb Mon Sep 17 00:00:00 2001 From: OBattler Date: Thu, 14 Aug 2025 13:13:32 +0200 Subject: [PATCH] EGA, MDA, and Sigma: Fix timings. --- src/video/vid_ega.c | 5 +++-- src/video/vid_mda.c | 4 ++-- src/video/vid_sigma.c | 7 +++++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/video/vid_ega.c b/src/video/vid_ega.c index 26bb38991..5a552ab6d 100644 --- a/src/video/vid_ega.c +++ b/src/video/vid_ega.c @@ -643,9 +643,10 @@ ega_recalctimings(ega_t *ega) crtcconst *= mdiv; } else { if (ega->vidclock) - crtcconst = (ega->seqregs[1] & 1) ? MDACONST : (MDACONST * (9.0 / 8.0)); + crtcconst = (cpuclock / 16257000.0 * (double) (1ULL << 32)); else - crtcconst = (ega->seqregs[1] & 1) ? CGACONST : (CGACONST * (9.0 / 8.0)); + crtcconst = (cpuclock / (157500000.0 / 11.0) * (double) (1ULL << 32)); + crtcconst *= mdiv; } ega->dot_clock = crtcconst / mdiv; diff --git a/src/video/vid_mda.c b/src/video/vid_mda.c index be6a8b6b8..1065df8a8 100644 --- a/src/video/vid_mda.c +++ b/src/video/vid_mda.c @@ -130,8 +130,8 @@ mda_recalctimings(mda_t *mda) double _dispontime; double _dispofftime; double disptime; - disptime = mda->crtc[MDA_CRTC_HTOTAL] + 1; - _dispontime = mda->crtc[MDA_CRTC_HDISP]; + disptime = (mda->crtc[MDA_CRTC_HTOTAL] + 1) << 1; + _dispontime = (mda->crtc[MDA_CRTC_HDISP]) << 1; _dispofftime = disptime - _dispontime; _dispontime *= MDACONST; _dispofftime *= MDACONST; diff --git a/src/video/vid_sigma.c b/src/video/vid_sigma.c index d67b13c0d..9f71773ad 100644 --- a/src/video/vid_sigma.c +++ b/src/video/vid_sigma.c @@ -234,6 +234,8 @@ sigma_out(uint16_t addr, uint8_t val, void *priv) case 0x2D8: sigma->sigmamode = val; + sigma->fullchange = changeframecount; + sigma_recalctimings(sigma); return; case 0x2D9: sigma->sigma_ctl = val; @@ -392,6 +394,7 @@ sigma_recalctimings(sigma_t *sigma) double disptime; double _dispontime; double _dispofftime; + double crtcconst = (cpuclock / 22440000.0 * (double) (1ULL << 32)) * 8.0; if (sigma->sigmamode & MODE_80COLS) { disptime = (sigma->crtc[0] + 1) << 1; @@ -402,8 +405,8 @@ sigma_recalctimings(sigma_t *sigma) } _dispofftime = disptime - _dispontime; - _dispontime *= CGACONST; - _dispofftime *= CGACONST; + _dispontime *= crtcconst; + _dispofftime *= crtcconst; sigma->dispontime = (uint64_t) (_dispontime); sigma->dispofftime = (uint64_t) (_dispofftime); }