From 7ced9fdc6a5a218759ab6eb7dc22c154b316a54d Mon Sep 17 00:00:00 2001 From: Asnivor Date: Fri, 8 Jun 2018 13:24:43 +0100 Subject: [PATCH] ZXHawk: 128k HAL10H8 chip crash emulation (INs to paging ports cause floating bus data being used to set the paging registers) --- .../Machine/ZXSpectrum128K/ZX128.Port.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128K/ZX128.Port.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128K/ZX128.Port.cs index 9fe37c4c14..0596dce779 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128K/ZX128.Port.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128K/ZX128.Port.cs @@ -20,6 +20,25 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum int result = 0xFF; + // ports 0x3ffd & 0x7ffd + // traditionally thought to be write-only + if (port == 0x3ffd || port == 0x7ffd) + { + // https://faqwiki.zxnet.co.uk/wiki/ZX_Spectrum_128 + // HAL bugs + // Reads from port 0x7ffd cause a crash, as the 128's HAL10H8 chip does not distinguish between reads and writes to this port, + // resulting in a floating data bus being used to set the paging registers. + + // -asni (2018-06-08) - need this to pass the final portread tests from fusetest.tap + + // get the floating bus value + ULADevice.ReadFloatingBus((int)CurrentFrameCycle, ref result); + // use this to set the paging registers + WritePort(port, (byte)result); + // return the floating bus value + return (byte)result; + } + // check AY if (AYDevice.ReadPort(port, ref result)) return (byte)result;