Implemented DeterministicEmulation as a syncsetting and if this is set to false, audio and video devices respect the render and renderSound IEmulator bools
This commit is contained in:
parent
34663445f8
commit
fbbd75b3ab
|
@ -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()
|
||||
|
|
|
@ -123,6 +123,9 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
|||
/// <param name="earPulse"></param>
|
||||
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
|
||||
|
|
|
@ -76,25 +76,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
|||
/// Holds the currently selected joysticks
|
||||
/// </summary>
|
||||
public virtual IJoystick[] JoystickCollection { get; set; }
|
||||
|
||||
/*
|
||||
/// <summary>
|
||||
/// Joystick device 1
|
||||
/// </summary>
|
||||
public virtual IJoystick Joystick1 { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Joystick device 2
|
||||
/// </summary>
|
||||
public virtual IJoystick Joystick2 { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Joystick device 3
|
||||
/// </summary>
|
||||
public virtual IJoystick Joystick3 { get; set; }
|
||||
|
||||
*/
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Signs whether the frame has ended
|
||||
/// </summary>
|
||||
|
@ -125,6 +107,12 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
|||
/// </summary>
|
||||
public virtual int CurrentFrameCycle => CPU.TotalExecutedCycles - LastFrameStartCPUTick;
|
||||
|
||||
/// <summary>
|
||||
/// Non-Deterministic bools
|
||||
/// </summary>
|
||||
public bool _render;
|
||||
public bool _renderSound;
|
||||
|
||||
/// <summary>
|
||||
/// Mask constants
|
||||
/// </summary>
|
||||
|
@ -138,14 +126,20 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
|||
/// <summary>
|
||||
/// Executes a single frame
|
||||
/// </summary>
|
||||
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();
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Flash processing
|
||||
/// </summary>
|
||||
public void CalcFlashCounter()
|
||||
{
|
||||
flashCounter++;
|
||||
|
||||
if (flashCounter > 15)
|
||||
|
|
|
@ -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()
|
||||
{
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue