From 7a965efd907455e8a00924f176b678a8de656e1c Mon Sep 17 00:00:00 2001 From: OBattler Date: Fri, 23 Aug 2024 06:21:27 +0200 Subject: [PATCH 1/3] Tandy and CGA: Implement the VSync interrupt, fixes Ghostbusters freezing. --- src/machine/m_tandy.c | 2 ++ src/video/vid_cga.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/machine/m_tandy.c b/src/machine/m_tandy.c index d51209123..56982b3bd 100644 --- a/src/machine/m_tandy.c +++ b/src/machine/m_tandy.c @@ -27,6 +27,7 @@ #include <86box/86box.h> #include <86box/timer.h> #include <86box/io.h> +#include <86box/pic.h> #include <86box/pit.h> #include <86box/nmi.h> #include <86box/mem.h> @@ -1215,6 +1216,7 @@ vid_poll(void *priv) vid->dispon = 0; vid->displine = 0; vid->vsynctime = 16; + picint(1 << 5); if (vid->crtc[7]) { if (vid->mode & 1) x = (vid->crtc[1] << 3) + 16; diff --git a/src/video/vid_cga.c b/src/video/vid_cga.c index 2ea07c346..8306edd56 100644 --- a/src/video/vid_cga.c +++ b/src/video/vid_cga.c @@ -28,6 +28,7 @@ #include "cpu.h" #include <86box/io.h> #include <86box/timer.h> +#include <86box/pic.h> #include <86box/pit.h> #include <86box/mem.h> #include <86box/rom.h> @@ -607,6 +608,7 @@ cga_poll(void *priv) cga->cgadispon = 0; cga->displine = 0; cga->vsynctime = 16; + picint(1 << 5); if (cga->crtc[7]) { if (cga->cgamode & 1) x = (cga->crtc[1] << 3) + 16; From 1a961db422bd386535e45ccf172e1cd3d1febb1d Mon Sep 17 00:00:00 2001 From: OBattler Date: Fri, 23 Aug 2024 07:09:35 +0200 Subject: [PATCH 2/3] CGA: Revert the VSync interrupt since the real CGA did not have that. --- src/video/vid_cga.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/video/vid_cga.c b/src/video/vid_cga.c index 8306edd56..2ea07c346 100644 --- a/src/video/vid_cga.c +++ b/src/video/vid_cga.c @@ -28,7 +28,6 @@ #include "cpu.h" #include <86box/io.h> #include <86box/timer.h> -#include <86box/pic.h> #include <86box/pit.h> #include <86box/mem.h> #include <86box/rom.h> @@ -608,7 +607,6 @@ cga_poll(void *priv) cga->cgadispon = 0; cga->displine = 0; cga->vsynctime = 16; - picint(1 << 5); if (cga->crtc[7]) { if (cga->cgamode & 1) x = (cga->crtc[1] << 3) + 16; From 0d43babac83a9a4e185e17a4880bb33d1d349aec Mon Sep 17 00:00:00 2001 From: OBattler Date: Fri, 23 Aug 2024 07:14:43 +0200 Subject: [PATCH 3/3] Tandy: Slow down horizontal sync in low resolution modes. --- src/machine/m_tandy.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/machine/m_tandy.c b/src/machine/m_tandy.c index 56982b3bd..2a7ef2275 100644 --- a/src/machine/m_tandy.c +++ b/src/machine/m_tandy.c @@ -718,8 +718,13 @@ recalc_timings(tandy_t *dev) double _dispofftime; double disptime; - disptime = vid->crtc[0] + 1; - _dispontime = vid->crtc[1]; + if (vid->mode & 1) { + disptime = vid->crtc[0] + 1; + _dispontime = vid->crtc[1]; + } else { + disptime = (vid->crtc[0] + 1) << 1; + _dispontime = vid->crtc[1] << 1; + } _dispofftime = disptime - _dispontime; _dispontime *= CGACONST; @@ -795,7 +800,10 @@ vid_out(uint16_t addr, uint8_t val, void *priv) break; case 0x03d8: + old = vid->mode; vid->mode = val; + if ((old ^ val) & 0x01) + recalc_timings(dev); if (!dev->is_sl2) update_cga16_color(vid->mode); break;