Removed DCFilter

This commit is contained in:
Asnivor 2018-03-07 17:40:15 +00:00
parent fbbd75b3ab
commit 74423041f3
15 changed files with 81 additions and 20 deletions

View File

@ -266,6 +266,7 @@
<Compile Include="Computers\SinclairSpectrum\Hardware\Datacorder\DatacorderDevice.cs" />
<Compile Include="Computers\SinclairSpectrum\Hardware\Input\IKeyboard.cs" />
<Compile Include="Computers\SinclairSpectrum\Hardware\Input\KempstonJoystick.cs" />
<Compile Include="Computers\SinclairSpectrum\Hardware\SoundOuput\IBeeperDevice.cs" />
<Compile Include="Computers\SinclairSpectrum\Machine\ULABase.cs" />
<Compile Include="Computers\SinclairSpectrum\Machine\ZXSpectrum128K\ZX128.ULA.cs" />
<Compile Include="Computers\SinclairSpectrum\Machine\ZXSpectrum16K\ZX16.cs" />

View File

@ -18,7 +18,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
private SpectrumBase _machine { get; set; }
private Z80A _cpu { get; set; }
private Buzzer _buzzer { get; set; }
private IBeeperDevice _buzzer { get; set; }
/// <summary>
/// Default constructor
@ -369,8 +369,6 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
/// <returns></returns>
public bool GetEarBit(long cpuCycle)
{
// decide how many cycles worth of data we are capturing
long cycles = cpuCycle - _lastCycle;

View File

@ -15,7 +15,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
/// For the purposes of emulation this devices is locked to a frame
/// a list of Pulses is built up over the course of the frame and outputted at the end of the frame
/// </summary>
public class Buzzer : ISoundProvider
public class Buzzer : ISoundProvider, IBeeperDevice
{
/// <summary>
/// Supplied values are right for 48K spectrum
@ -99,6 +99,30 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
/*
// set the tstatesperframe
_tStatesPerFrame = tStatesPerFrame;
// calculate actual refresh rate
double refresh = (double)_machine.ULADevice.ClockSpeed / (double)_tStatesPerFrame;
// how many samples per frame are expected by ISoundProvider (at 44.1KHz)
_samplesPerFrame = 880;// (int)((double)sampleRate / (double)refresh);
// set the sample rate
_sampleRate = sampleRate;
// calculate samples per frame (what ISoundProvider will be expecting at 44100)
//_samplesPerFrame = (int)((double)_tStatesPerFrame / (double)refresh);
// calculate tstates per sameple
_tStatesPerSample = 79;// _tStatesPerFrame / _samplesPerFrame;
/*
// get divisors
var divs = from a in Enumerable.Range(2, _tStatesPerFrame / 2)
where _tStatesPerFrame % a == 0
@ -109,8 +133,8 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
// get _samplesPerFrame
_samplesPerFrame = _tStatesPerFrame / _tStatesPerSample;
*/
*/
Pulses = new List<Pulse>(1000);
}

View File

@ -0,0 +1,24 @@
using BizHawk.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
{
public interface IBeeperDevice
{
void Init(int sampleRate, int tStatesPerFrame);
void ProcessPulseValue(bool fromTape, bool earPulse);
void StartFrame();
void EndFrame();
void SetTapeMode(bool tapeMode);
void SyncState(Serializer ser);
}
}

View File

@ -30,6 +30,15 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
/// <param name="port"></param>
/// <param name="value"></param>
public abstract void WritePort(ushort port, byte value);
/// <summary>
/// Increments the CPU totalCycles counter by the tStates value specified
/// </summary>
/// <param name="tStates"></param>
public virtual void PortContention(int tStates)
{
CPU.TotalExecutedCycles += tStates;
}
}
}

View File

@ -55,7 +55,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
/// <summary>
/// The spectrum buzzer/beeper
/// </summary>
public Buzzer BuzzerDevice { get; set; }
public IBeeperDevice BuzzerDevice { get; set; }
/// <summary>
/// Device representing the AY-3-8912 chip found in the 128k and up spectrums

View File

@ -445,7 +445,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
}
//the additional 1 tstate is required to get correct number of bytes to output in ircontention.sna
elapsedTStates = (_tstates + 1 - lastTState);
elapsedTStates = (_tstates + 1 - lastTState) - 1;
//It takes 4 tstates to write 1 byte. Or, 2 pixels per t-state.

View File

@ -170,7 +170,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
}
// update ULA screen buffer if necessary
if ((addr & 49152) == 16384)
if ((addr & 49152) == 16384 && _render)
ULADevice.UpdateScreenBuffer(CurrentFrameCycle);
}

View File

@ -40,7 +40,6 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
KeyboardDevice = new StandardKeyboard(this);
InitJoysticks(joysticks);
//KempstonDevice = new KempstonJoystick(this);
TapeDevice = new DatacorderDevice();
TapeDevice.Init(this);

View File

@ -310,7 +310,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
}
// update ULA screen buffer if necessary
if ((addr & 49152) == 16384)
if ((addr & 49152) == 16384 && _render)
ULADevice.UpdateScreenBuffer(CurrentFrameCycle);
}

View File

@ -40,7 +40,6 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
KeyboardDevice = new StandardKeyboard(this);
InitJoysticks(joysticks);
//KempstonDevice = new KempstonJoystick(this);
TapeDevice = new DatacorderDevice();
TapeDevice.Init(this);

View File

@ -65,7 +65,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
bank[index] = value;
// update ULA screen buffer if necessary
if ((addr & 49152) == 16384)
if ((addr & 49152) == 16384 && _render)
ULADevice.UpdateScreenBuffer(CurrentFrameCycle);
}

View File

@ -17,6 +17,11 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
{
InputRead = true;
// It takes four T states for the Z80 to read a value from an I/O port, or write a value to a port
// (not including added ULA contention)
// The Bizhawk Z80A implementation appears to not consume any T-States for this operation
PortContention(4);
int result = 0xFF;
// Check whether the low bit is reset
@ -171,6 +176,12 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
/// <param name="value"></param>
public override void WritePort(ushort port, byte value)
{
// It takes four T states for the Z80 to read a value from an I/O port, or write a value to a port
// (not including added ULA contention)
// The Bizhawk Z80A implementation appears to not consume any T-States for this operation
PortContention(4);
// Check whether the low bit is reset
// Technically the ULA should respond to every even I/O address
bool lowBitReset = (port & 0x01) == 0;

View File

@ -32,14 +32,10 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
InitJoysticks(joysticks);
//KempstonDevice = new KempstonJoystick(this);
TapeDevice = new DatacorderDevice();
TapeDevice.Init(this);
InitializeMedia(files);
//TapeDevice.LoadTape(file);
}
#endregion

View File

@ -94,12 +94,12 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
ser.Register<IDisassemblable>(_cpu);
ser.Register<IVideoProvider>(_machine.ULADevice);
SoundMixer = new SoundProviderMixer(_machine.BuzzerDevice);
SoundMixer = new SoundProviderMixer((ISoundProvider)_machine.BuzzerDevice);
if (_machine.AYDevice != null)
SoundMixer.AddSource(_machine.AYDevice);
dcf = new DCFilter(SoundMixer, 256);
ser.Register<ISoundProvider>(dcf);
//dcf = new DCFilter(SoundMixer, 256);
ser.Register<ISoundProvider>(SoundMixer);