ZXHawk: Started tapedevice independence implementation
This commit is contained in:
parent
3b9835274a
commit
86dd0b4a06
|
@ -26,7 +26,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public DatacorderDevice()
|
public DatacorderDevice()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -37,13 +37,20 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
||||||
{
|
{
|
||||||
_machine = machine;
|
_machine = machine;
|
||||||
_cpu = _machine.CPU;
|
_cpu = _machine.CPU;
|
||||||
_buzzer = machine.BuzzerDevice;
|
_buzzer = machine.TapeBuzzer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region State Information
|
#region State Information
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Internal counter used to trigger tape buzzer output
|
||||||
|
/// </summary>
|
||||||
|
private int counter = 0;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The index of the current tape data block that is loaded
|
/// The index of the current tape data block that is loaded
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -145,7 +152,9 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
||||||
public void StartFrame()
|
public void StartFrame()
|
||||||
{
|
{
|
||||||
//if (TapeIsPlaying && AutoPlay)
|
//if (TapeIsPlaying && AutoPlay)
|
||||||
//FlashLoad();
|
//FlashLoad();
|
||||||
|
|
||||||
|
_buzzer.ProcessPulseValue(true, currentState);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -160,7 +169,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
||||||
if (_tapeIsPlaying)
|
if (_tapeIsPlaying)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_machine.BuzzerDevice.SetTapeMode(true);
|
_buzzer.SetTapeMode(true);
|
||||||
|
|
||||||
_machine.Spectrum.OSD_TapePlaying();
|
_machine.Spectrum.OSD_TapePlaying();
|
||||||
|
|
||||||
|
@ -215,7 +224,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
||||||
if (!_tapeIsPlaying)
|
if (!_tapeIsPlaying)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_machine.BuzzerDevice.SetTapeMode(false);
|
_buzzer.SetTapeMode(false);
|
||||||
|
|
||||||
_machine.Spectrum.OSD_TapeStopped();
|
_machine.Spectrum.OSD_TapeStopped();
|
||||||
|
|
||||||
|
@ -376,6 +385,27 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Tape Device Methods
|
#region Tape Device Methods
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Runs every frame
|
||||||
|
/// </summary>
|
||||||
|
public void TapeCycle()
|
||||||
|
{
|
||||||
|
if (TapeIsPlaying)
|
||||||
|
{
|
||||||
|
counter++;
|
||||||
|
|
||||||
|
if (counter > 50)
|
||||||
|
{
|
||||||
|
counter = 0;
|
||||||
|
bool state = GetEarBit(_machine.CPU.TotalExecutedCycles);
|
||||||
|
_buzzer.ProcessPulseValue(false, state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Simulates the spectrum 'EAR' input reading data from the tape
|
/// Simulates the spectrum 'EAR' input reading data from the tape
|
||||||
|
@ -534,7 +564,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
||||||
_lastCycle = cpuCycle - (long)cycles;
|
_lastCycle = cpuCycle - (long)cycles;
|
||||||
|
|
||||||
// play the buzzer
|
// play the buzzer
|
||||||
_buzzer.ProcessPulseValue(false, currentState);
|
//_buzzer.ProcessPulseValue(false, currentState);
|
||||||
|
|
||||||
return currentState;
|
return currentState;
|
||||||
}
|
}
|
||||||
|
@ -898,6 +928,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
||||||
public void SyncState(Serializer ser)
|
public void SyncState(Serializer ser)
|
||||||
{
|
{
|
||||||
ser.BeginSection("DatacorderDevice");
|
ser.BeginSection("DatacorderDevice");
|
||||||
|
ser.Sync("counter", ref counter);
|
||||||
ser.Sync("_currentDataBlockIndex", ref _currentDataBlockIndex);
|
ser.Sync("_currentDataBlockIndex", ref _currentDataBlockIndex);
|
||||||
ser.Sync("_position", ref _position);
|
ser.Sync("_position", ref _position);
|
||||||
ser.Sync("_tapeIsPlaying", ref _tapeIsPlaying);
|
ser.Sync("_tapeIsPlaying", ref _tapeIsPlaying);
|
||||||
|
|
|
@ -39,6 +39,11 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public IBeeperDevice BuzzerDevice { get; set; }
|
public IBeeperDevice BuzzerDevice { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A second beeper for the tape
|
||||||
|
/// </summary>
|
||||||
|
public IBeeperDevice TapeBuzzer { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Device representing the AY-3-8912 chip found in the 128k and up spectrums
|
/// Device representing the AY-3-8912 chip found in the 128k and up spectrums
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -142,6 +147,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
||||||
if (_renderSound)
|
if (_renderSound)
|
||||||
{
|
{
|
||||||
BuzzerDevice.StartFrame();
|
BuzzerDevice.StartFrame();
|
||||||
|
TapeBuzzer.StartFrame();
|
||||||
if (AYDevice != null)
|
if (AYDevice != null)
|
||||||
AYDevice.StartFrame();
|
AYDevice.StartFrame();
|
||||||
}
|
}
|
||||||
|
@ -154,7 +160,10 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
||||||
ULADevice.CheckForInterrupt(CurrentFrameCycle);
|
ULADevice.CheckForInterrupt(CurrentFrameCycle);
|
||||||
|
|
||||||
// run a single CPU instruction
|
// run a single CPU instruction
|
||||||
CPU.ExecuteOne();
|
CPU.ExecuteOne();
|
||||||
|
|
||||||
|
// cycle the tape device
|
||||||
|
TapeDevice.TapeCycle();
|
||||||
}
|
}
|
||||||
|
|
||||||
// we have reached the end of a frame
|
// we have reached the end of a frame
|
||||||
|
@ -165,7 +174,10 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
||||||
ULADevice.UpdateScreenBuffer(ULADevice.FrameLength);
|
ULADevice.UpdateScreenBuffer(ULADevice.FrameLength);
|
||||||
|
|
||||||
if (_renderSound)
|
if (_renderSound)
|
||||||
|
{
|
||||||
BuzzerDevice.EndFrame();
|
BuzzerDevice.EndFrame();
|
||||||
|
TapeBuzzer.EndFrame();
|
||||||
|
}
|
||||||
|
|
||||||
if (AYDevice != null)
|
if (AYDevice != null)
|
||||||
AYDevice.EndFrame();
|
AYDevice.EndFrame();
|
||||||
|
@ -329,6 +341,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
||||||
RomData.SyncState(ser);
|
RomData.SyncState(ser);
|
||||||
KeyboardDevice.SyncState(ser);
|
KeyboardDevice.SyncState(ser);
|
||||||
BuzzerDevice.SyncState(ser);
|
BuzzerDevice.SyncState(ser);
|
||||||
|
TapeBuzzer.SyncState(ser);
|
||||||
ULADevice.SyncState(ser);
|
ULADevice.SyncState(ser);
|
||||||
|
|
||||||
if (AYDevice != null)
|
if (AYDevice != null)
|
||||||
|
@ -336,7 +349,6 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
||||||
AYDevice.SyncState(ser);
|
AYDevice.SyncState(ser);
|
||||||
((AYChip)AYDevice as AYChip).PanningConfiguration = Spectrum.Settings.AYPanConfig;
|
((AYChip)AYDevice as AYChip).PanningConfiguration = Spectrum.Settings.AYPanConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ser.Sync("tapeMediaIndex", ref tapeMediaIndex);
|
ser.Sync("tapeMediaIndex", ref tapeMediaIndex);
|
||||||
TapeMediaIndex = tapeMediaIndex;
|
TapeMediaIndex = tapeMediaIndex;
|
||||||
|
|
|
@ -31,6 +31,9 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
||||||
BuzzerDevice = new Buzzer(this);
|
BuzzerDevice = new Buzzer(this);
|
||||||
BuzzerDevice.Init(44100, ULADevice.FrameLength);
|
BuzzerDevice.Init(44100, ULADevice.FrameLength);
|
||||||
|
|
||||||
|
TapeBuzzer = new Buzzer(this);
|
||||||
|
TapeBuzzer.Init(44100, ULADevice.FrameLength);
|
||||||
|
|
||||||
AYDevice = new AYChip(this);
|
AYDevice = new AYChip(this);
|
||||||
AYDevice.Init(44100, ULADevice.FrameLength);
|
AYDevice.Init(44100, ULADevice.FrameLength);
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,9 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
||||||
BuzzerDevice = new Buzzer(this);
|
BuzzerDevice = new Buzzer(this);
|
||||||
BuzzerDevice.Init(44100, ULADevice.FrameLength);
|
BuzzerDevice.Init(44100, ULADevice.FrameLength);
|
||||||
|
|
||||||
|
TapeBuzzer = new Buzzer(this);
|
||||||
|
TapeBuzzer.Init(44100, ULADevice.FrameLength);
|
||||||
|
|
||||||
AYDevice = new AYChip(this);
|
AYDevice = new AYChip(this);
|
||||||
AYDevice.Init(44100, ULADevice.FrameLength);
|
AYDevice.Init(44100, ULADevice.FrameLength);
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,9 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
||||||
BuzzerDevice = new Buzzer(this);
|
BuzzerDevice = new Buzzer(this);
|
||||||
BuzzerDevice.Init(44100, ULADevice.FrameLength);
|
BuzzerDevice.Init(44100, ULADevice.FrameLength);
|
||||||
|
|
||||||
|
TapeBuzzer = new Buzzer(this);
|
||||||
|
TapeBuzzer.Init(44100, ULADevice.FrameLength);
|
||||||
|
|
||||||
AYDevice = new AYChip(this);
|
AYDevice = new AYChip(this);
|
||||||
AYDevice.Init(44100, ULADevice.FrameLength);
|
AYDevice.Init(44100, ULADevice.FrameLength);
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,9 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
||||||
BuzzerDevice = new Buzzer(this);
|
BuzzerDevice = new Buzzer(this);
|
||||||
BuzzerDevice.Init(44100, ULADevice.FrameLength);
|
BuzzerDevice.Init(44100, ULADevice.FrameLength);
|
||||||
|
|
||||||
|
TapeBuzzer = new Buzzer(this);
|
||||||
|
TapeBuzzer.Init(44100, ULADevice.FrameLength);
|
||||||
|
|
||||||
KeyboardDevice = new StandardKeyboard(this);
|
KeyboardDevice = new StandardKeyboard(this);
|
||||||
|
|
||||||
InitJoysticks(joysticks);
|
InitJoysticks(joysticks);
|
||||||
|
|
|
@ -101,6 +101,8 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
||||||
SoundMixer = new SoundProviderMixer((int)(32767 / 10), (ISoundProvider)_machine.BuzzerDevice);
|
SoundMixer = new SoundProviderMixer((int)(32767 / 10), (ISoundProvider)_machine.BuzzerDevice);
|
||||||
if (_machine.AYDevice != null)
|
if (_machine.AYDevice != null)
|
||||||
SoundMixer.AddSource(_machine.AYDevice);
|
SoundMixer.AddSource(_machine.AYDevice);
|
||||||
|
if (_machine.TapeBuzzer != null)
|
||||||
|
SoundMixer.AddSource((ISoundProvider)_machine.TapeBuzzer);
|
||||||
//SoundMixer.Stereo = ((ZXSpectrumSettings)settings as ZXSpectrumSettings).StereoSound;
|
//SoundMixer.Stereo = ((ZXSpectrumSettings)settings as ZXSpectrumSettings).StereoSound;
|
||||||
|
|
||||||
if (_machine.AYDevice != null && _machine.AYDevice.GetType() == typeof(AYChip))
|
if (_machine.AYDevice != null && _machine.AYDevice.GetType() == typeof(AYChip))
|
||||||
|
@ -115,6 +117,12 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
||||||
((Buzzer)_machine.BuzzerDevice as Buzzer).EarVolume = ((ZXSpectrumSettings)settings as ZXSpectrumSettings).EarVolume;
|
((Buzzer)_machine.BuzzerDevice as Buzzer).EarVolume = ((ZXSpectrumSettings)settings as ZXSpectrumSettings).EarVolume;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_machine.TapeBuzzer != null)
|
||||||
|
{
|
||||||
|
((Buzzer)_machine.TapeBuzzer as Buzzer).TapeVolume = ((ZXSpectrumSettings)settings as ZXSpectrumSettings).TapeVolume;
|
||||||
|
//((Buzzer)_machine.TapeBuzzer as Buzzer).EarVolume = ((ZXSpectrumSettings)settings as ZXSpectrumSettings).EarVolume;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
ser.Register<ISoundProvider>(SoundMixer);
|
ser.Register<ISoundProvider>(SoundMixer);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue