From d09d215aa0a38955968563a4f4a09aa71dfd60d7 Mon Sep 17 00:00:00 2001 From: feos Date: Thu, 5 Jun 2025 16:51:58 +0300 Subject: [PATCH] dosbox: don't shrink the image it'd arguably make sense to shrink, if we could downscale it with some smooth algo. this is based on the fact that on a CRT monitor you also see scanlines at fixed thickness (unless you adjust the output) and only width is variable (and depends on pixel density + size of overscan). so upscaling 240p by exactly 2 and then adjusting with made sense on the paper (and it's what we do for CRT encodes). but hawk can't default to a smooth algo, and it can't only apply it on shrink while everything is resized using point. so it's better to just never shrink and let height also be variable. that's kinda what everyone else is doing anyway. --- .../Computers/DOS/DOSBox.cs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/BizHawk.Emulation.Cores/Computers/DOS/DOSBox.cs b/src/BizHawk.Emulation.Cores/Computers/DOS/DOSBox.cs index e3ff96b01a..635b71a023 100644 --- a/src/BizHawk.Emulation.Cores/Computers/DOS/DOSBox.cs +++ b/src/BizHawk.Emulation.Cores/Computers/DOS/DOSBox.cs @@ -37,6 +37,10 @@ namespace BizHawk.Emulation.Cores.Computers.DOS private readonly List _romAssets; private readonly List _discAssets; private const int _messageDuration = 4; + private const double _wAspect = 4.0; + private const double _hAspect = 3.0; + private int _correctedWidth = LibDOSBox.VGA_MAX_WIDTH; + private int _correctedHeight = LibDOSBox.VGA_MAX_HEIGHT; // Drive management variables private List _floppyDiskImageFiles = new List(); @@ -54,8 +58,9 @@ namespace BizHawk.Emulation.Cores.Computers.DOS private List _cdRomFileNames = new List(); private Dictionary _cdRomFileToReaderMap = new Dictionary(); private readonly LibDOSBox.CDReadCallback _CDReadCallback; - - public override int VirtualWidth => BufferHeight * 4 / 3; + + public override int VirtualWidth => _correctedWidth; + public override int VirtualHeight => _correctedHeight; // Image selection / swapping variables @@ -537,6 +542,12 @@ namespace BizHawk.Emulation.Cores.Computers.DOS { DriveLightOn = _libDOSBox.GetDriveActivityFlag(); + // never shrink the virtual buffer + _correctedHeight = BufferWidth > BufferHeight * _wAspect / _hAspect + ? (int)Math.Round(BufferWidth * _hAspect / _wAspect) + : BufferHeight; + _correctedWidth = (int)Math.Round(VirtualHeight * _wAspect / _hAspect); + // Checking refresh rate base on the reported refresh rate updates var currentRefreshRateNumerator = VsyncNumerator; var currentRefreshRateDenominator = VsyncDenominator;