diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ULABase.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ULABase.cs
index 657a255adf..d6e3b1ef66 100644
--- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ULABase.cs
+++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ULABase.cs
@@ -69,11 +69,11 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
///
/// T-State at which to start applying contention
///
- protected int contentionStartPeriod;
+ public int contentionStartPeriod;
///
/// T-State at which to end applying contention
///
- protected int contentionEndPeriod;
+ public int contentionEndPeriod;
///
/// T-State memory contention delay mapping
///
@@ -102,7 +102,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
///
/// Table that stores T-State to screen/attribute address values
///
- protected short[] floatingBusTable;
+ public short[] floatingBusTable;
///
/// Cycle at which the last render update took place
///
diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum48K/ZX48.Port.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum48K/ZX48.Port.cs
index c5bfd6f4d8..c8ad708a67 100644
--- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum48K/ZX48.Port.cs
+++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum48K/ZX48.Port.cs
@@ -30,6 +30,8 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
}
else if (lowBitReset)
{
+ CPU.TotalExecutedCycles += ULADevice.contentionTable[CurrentFrameCycle];
+
// Even I/O address so get input
// The high byte indicates which half-row of keys is being polled
/*
@@ -115,7 +117,27 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
// Kemptson Mouse
- // if unused port the floating memory bus should be returned (still todo)
+ // if unused port the floating memory bus should be returned
+
+ // Floating bus is read on the previous cycle
+ int _tStates = CurrentFrameCycle - 1;
+
+ // if we are on the top or bottom border return 0xff
+ if ((_tStates < ULADevice.contentionStartPeriod) || (_tStates > ULADevice.contentionEndPeriod))
+ {
+ result = 0xff;
+ }
+ else
+ {
+ if (ULADevice.floatingBusTable[_tStates] < 0)
+ {
+ result = 0xff;
+ }
+ else
+ {
+ result = ReadBus((ushort)ULADevice.floatingBusTable[_tStates]);
+ }
+ }
}
return (byte)result;