diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/SpectrumBase.Memory.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/SpectrumBase.Memory.cs
index e625ecae77..5a21a8db42 100644
--- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/SpectrumBase.Memory.cs
+++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/SpectrumBase.Memory.cs
@@ -32,12 +32,6 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
public byte[] RAM6 = new byte[0x4000]; // Bank 6
public byte[] RAM7 = new byte[0x4000]; // Bank 7
- ///
- /// Represents the addressable memory space of the spectrum
- /// All banks for the emulated system should be added during initialisation
- ///
- public Dictionary Memory = new Dictionary();
-
///
/// Simulates reading from the bus
/// Paging should be handled here
diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum16K/ZX16.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum16K/ZX16.cs
index 7d79f80544..f310b9f7de 100644
--- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum16K/ZX16.cs
+++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum16K/ZX16.cs
@@ -51,17 +51,18 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
public override byte ReadBus(ushort addr)
{
int divisor = addr / 0x4000;
+ var index = addr % 0x4000;
+
// paging logic goes here
- if (divisor > 1)
+ switch (divisor)
{
- // memory does not exist
- return 0xff;
+ case 0: return ROM0[index];
+ case 1: return RAM0[index];
+ default:
+ // memory does not exist
+ return 0xff;
}
-
- var bank = Memory[divisor];
- var index = addr % 0x4000;
- return bank[index];
}
///
@@ -73,17 +74,23 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
public override void WriteBus(ushort addr, byte value)
{
int divisor = addr / 0x4000;
+ var index = addr % 0x4000;
+
// paging logic goes here
- if (divisor > 1)
+ switch (divisor)
{
- // memory does not exist
- return;
+ case 0:
+ // cannot write to ROM
+ break;
+ case 1:
+ RAM0[index] = value;
+ break;
}
- var bank = Memory[divisor];
- var index = addr % 0x4000;
- bank[index] = value;
+ // update ULA screen buffer if necessary
+ if ((addr & 49152) == 16384 && _render)
+ ULADevice.UpdateScreenBuffer(CurrentFrameCycle);
}
///
@@ -97,8 +104,6 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
if (ULADevice.IsContended(addr))
CPU.TotalExecutedCycles += ULADevice.contentionTable[CurrentFrameCycle];
- CPU.TotalExecutedCycles += 3;
-
var data = ReadBus(addr);
return data;
}
@@ -115,25 +120,9 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
if (ULADevice.IsContended(addr))
CPU.TotalExecutedCycles += ULADevice.contentionTable[CurrentFrameCycle];
- CPU.TotalExecutedCycles += 3;
-
WriteBus(addr, value);
}
- /*
- public override void ReInitMemory()
- {
- if (Memory.ContainsKey(0))
- Memory[0] = ROM0;
- else
- Memory.Add(0, ROM0);
-
- if (Memory.ContainsKey(1))
- Memory[1] = RAM1;
- else
- Memory.Add(1, RAM1);
- }
- */
-
+
///
/// Sets up the ROM
///
diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum48K/ZX48.Memory.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum48K/ZX48.Memory.cs
index 8b9427d66b..bef6b97317 100644
--- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum48K/ZX48.Memory.cs
+++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum48K/ZX48.Memory.cs
@@ -99,8 +99,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
public override byte ReadMemory(ushort addr)
{
if (ULADevice.IsContended(addr))
- CPU.TotalExecutedCycles += ULADevice.contentionTable[CurrentFrameCycle];
-
+ CPU.TotalExecutedCycles += ULADevice.contentionTable[CurrentFrameCycle];
var data = ReadBus(addr);
return data;
diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.cs
index bb116f8922..cb294a8146 100644
--- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.cs
+++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.cs
@@ -16,7 +16,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
isPorted: false,
isReleased: false)]
[ServiceNotApplicable(typeof(IDriveLight))]
- public partial class ZXSpectrum : IDebuggable, IInputPollable, IStatable, IRegionable
+ public partial class ZXSpectrum : IRegionable
{
public ZXSpectrum(CoreComm comm, IEnumerable files, List game, object settings, object syncSettings)
{
@@ -85,8 +85,8 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
_cpu.MemoryCallbacks = MemoryCallbacks;
- //HardReset = _machine.HardReset;
- //SoftReset = _machine.SoftReset;
+ HardReset = _machine.HardReset;
+ SoftReset = _machine.SoftReset;
_cpu.FetchMemory = _machine.ReadMemory;
_cpu.ReadMemory = _machine.ReadMemory;
@@ -102,19 +102,17 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
SoundMixer = new SoundProviderMixer((ISoundProvider)_machine.BuzzerDevice);
if (_machine.AYDevice != null)
SoundMixer.AddSource(_machine.AYDevice);
-
- //dcf = new DCFilter(SoundMixer, 256);
+
ser.Register(SoundMixer);
-
- //HardReset();
+ HardReset();
SetupMemoryDomains();
}
- //public Action HardReset;
- //public Action SoftReset;
+ public Action HardReset;
+ public Action SoftReset;
private readonly Z80A _cpu;
private readonly TraceBuffer _tracer;
@@ -123,11 +121,8 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
private List _gameInfo;
- private SoundProviderMixer SoundMixer;
-
- private DCFilter dcf;
-
- //private byte[] _file;
+ private SoundProviderMixer SoundMixer;
+
private readonly List _files;
public bool DiagRom = false;