diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/SoundOuput/AY38912.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/SoundOuput/AY38912.cs
index 8dcde1e0ee..7443c43dd3 100644
--- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/SoundOuput/AY38912.cs
+++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/SoundOuput/AY38912.cs
@@ -60,6 +60,9 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
_tStatesPerSample = 79;
_samplesPerFrame = _tStatesPerFrame / _tStatesPerSample;
_AYCyclesPerFrame = _tStatesPerFrame / AY_SAMPLE_RATE;
+
+ _samples = new short[_samplesPerFrame * 2];
+ _nsamp = _samplesPerFrame;
}
#endregion
@@ -110,11 +113,11 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
// the stereo _samples buffer should already have been processed as a part of
// ISoundProvider at the end of the last frame
- _samples = new short[_samplesPerFrame * 2];
- _nsamp = _samplesPerFrame;
+ //_samples = new short[_samplesPerFrame * 2];
+ //_nsamp = _samplesPerFrame;
_sampleCounter = 0;
- Init(44100, _tStatesPerFrame);
+ //Init(44100, _tStatesPerFrame);
}
public void EndFrame()
diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/SoundOuput/Buzzer.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/SoundOuput/Buzzer.cs
index d751189fae..04e5b53222 100644
--- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/SoundOuput/Buzzer.cs
+++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/SoundOuput/Buzzer.cs
@@ -123,6 +123,9 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
///
public void ProcessPulseValue(bool fromTape, bool earPulse)
{
+ if (!_machine._renderSound)
+ return;
+
if (!fromTape && _tapeMode)
{
// tape mode is active but the pulse value came from an OUT instruction
diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/SpectrumBase.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/SpectrumBase.cs
index 28df887d46..444a22a46c 100644
--- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/SpectrumBase.cs
+++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/SpectrumBase.cs
@@ -76,25 +76,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
/// Holds the currently selected joysticks
///
public virtual IJoystick[] JoystickCollection { get; set; }
-
- /*
- ///
- /// Joystick device 1
- ///
- public virtual IJoystick Joystick1 { get; set; }
-
- ///
- /// Joystick device 2
- ///
- public virtual IJoystick Joystick2 { get; set; }
-
- ///
- /// Joystick device 3
- ///
- public virtual IJoystick Joystick3 { get; set; }
-
- */
-
+
///
/// Signs whether the frame has ended
///
@@ -125,6 +107,12 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
///
public virtual int CurrentFrameCycle => CPU.TotalExecutedCycles - LastFrameStartCPUTick;
+ ///
+ /// Non-Deterministic bools
+ ///
+ public bool _render;
+ public bool _renderSound;
+
///
/// Mask constants
///
@@ -138,14 +126,20 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
///
/// Executes a single frame
///
- public virtual void ExecuteFrame()
+ public virtual void ExecuteFrame(bool render, bool renderSound)
{
InputRead = false;
+ _render = render;
+ _renderSound = renderSound;
FrameCompleted = false;
- BuzzerDevice.StartFrame();
- if (AYDevice != null)
- AYDevice.StartFrame();
+
+ if (_renderSound)
+ {
+ BuzzerDevice.StartFrame();
+ if (AYDevice != null)
+ AYDevice.StartFrame();
+ }
PollInput();
@@ -158,18 +152,22 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
CPU.ExecuteOne();
// update AY
- if (AYDevice != null)
- AYDevice.UpdateSound(CurrentFrameCycle);
+ if (_renderSound)
+ {
+ if (AYDevice != null)
+ AYDevice.UpdateSound(CurrentFrameCycle);
+ }
}
// we have reached the end of a frame
LastFrameStartCPUTick = CPU.TotalExecutedCycles - OverFlow;
// paint the buffer if needed
- if (ULADevice.needsPaint)
+ if (ULADevice.needsPaint && _render)
ULADevice.UpdateScreenBuffer(ULADevice.FrameLength);
- BuzzerDevice.EndFrame();
+ if (_renderSound)
+ BuzzerDevice.EndFrame();
//TapeDevice.CPUFrameCompleted();
diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ULABase.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ULABase.cs
index 1604006525..e10bdd16c0 100644
--- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ULABase.cs
+++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ULABase.cs
@@ -315,7 +315,10 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
_machine.CPU.FlagI = true;
// Signal the start of ULA processing
- ULAUpdateStart();
+ if (_machine._render)
+ ULAUpdateStart();
+
+ CalcFlashCounter();
}
#endregion
@@ -383,7 +386,13 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
screenByteCtr = DisplayStart;
lastTState = actualULAStart;
needsPaint = true;
+ }
+ ///
+ /// Flash processing
+ ///
+ public void CalcFlashCounter()
+ {
flashCounter++;
if (flashCounter > 15)
diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.IEmulator.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.IEmulator.cs
index c318876694..33bcc68276 100644
--- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.IEmulator.cs
+++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.IEmulator.cs
@@ -13,6 +13,15 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
{
_controller = controller;
+ bool ren = render;
+ bool renSound = renderSound;
+
+ if (DeterministicEmulation)
+ {
+ ren = true;
+ renSound = true;
+ }
+
_isLag = true;
if (_tracer.Enabled)
@@ -24,7 +33,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
_cpu.TraceCallback = null;
}
- _machine.ExecuteFrame();
+ _machine.ExecuteFrame(ren, renSound);
if (_isLag)
{
@@ -36,7 +45,13 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
public string SystemId => "ZXSpectrum";
- public bool DeterministicEmulation => true;
+ private bool deterministicEmulation;
+ public bool DeterministicEmulation
+ {
+ get { return deterministicEmulation; }
+ }
+
+ //public bool DeterministicEmulation => true;
public void ResetCounters()
{
diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.ISettable.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.ISettable.cs
index 8ad6ab5b1e..059a2fcaa1 100644
--- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.ISettable.cs
+++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.ISettable.cs
@@ -72,6 +72,11 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
public class ZXSpectrumSyncSettings
{
+ [DisplayName("Deterministic Emulation")]
+ [Description("If true, the core agrees to behave in a completely deterministic manner")]
+ [DefaultValue(true)]
+ public bool DeterministicEmulation { get; set; }
+
[DisplayName("Spectrum model")]
[Description("The model of spectrum to be emulated")]
[DefaultValue(MachineType.ZXSpectrum48)]
diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.cs
index b8d3749514..4656ba6fa2 100644
--- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.cs
+++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.cs
@@ -50,6 +50,8 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
joysticks.Add(((ZXSpectrumSyncSettings)syncSettings as ZXSpectrumSyncSettings).JoystickType2);
joysticks.Add(((ZXSpectrumSyncSettings)syncSettings as ZXSpectrumSyncSettings).JoystickType3);
+ deterministicEmulation = ((ZXSpectrumSyncSettings)syncSettings as ZXSpectrumSyncSettings).DeterministicEmulation;
+
switch (SyncSettings.MachineType)
{
case MachineType.ZXSpectrum16:
diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/readme.md b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/readme.md
index 621411f812..6cc05397c2 100644
--- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/readme.md
+++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/readme.md
@@ -18,6 +18,7 @@ At the moment this is very experimental and is still actively being worked on.
* IStatable
* ISettable core settings
* IDebuggable (for what it's worth)
+* DeterministicEmulation as a SyncSetting
* Tape auto-loading routines (as a setting)
### Work in progress