C64: Fix voume based audio sampling, fix some state bugs

This commit is contained in:
alyosha-tas 2017-12-31 17:30:35 -05:00
parent df8edae97e
commit 06201a1c4f
5 changed files with 25 additions and 7 deletions

View File

@ -34,7 +34,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64
});
}
if (tapeDriveEnabled)
if (tapeDriveEnabled && (_board.TapeDrive.TapeDataDomain != null))
{
domains.AddRange(new[]
{

View File

@ -32,7 +32,8 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Cassette
public override void SyncState(Serializer ser)
{
_tape.SyncState(ser);
if (_tape != null) { _tape.SyncState(ser); }
}
public void Insert(Tape tape)
@ -46,6 +47,19 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Cassette
}
// Exposed for memory domains, should not be used for actual emulation implementation
public override byte[] TapeDataDomain => _tape.TapeDataDomain;
public override byte[] TapeDataDomain
{
get
{
if (_tape != null)
{
return _tape.TapeDataDomain;
}
else
{
return null;
}
}
}
}
}

View File

@ -138,12 +138,13 @@
// we want to only flush the filter when the filter is actually changed, that way
// the FFT will not be impacted by small sample sizes from other changes
if (addr == 15 || addr == 16 || addr==17)
if ((addr == 0x15) || (addr == 0x16) || (addr == 0x17))
{
Flush(true);
}
else if (addr==18)
else if (addr == 0x18)
{
// note: we only want to flush the filter here if the filter components are changing
bool temp1 = (val & 0x10) != 0;
bool temp2 = (val & 0x20) != 0;

View File

@ -49,8 +49,8 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS
{
_mixer = _outputBuffer_not_filtered[i] + _outputBuffer_filtered[i];
_mixer = _mixer >> 7;
_mixer = (_mixer * _volume) >> 4;
_mixer -= _volume << 8;
_mixer = (_mixer * _volume_at_sample_time[i]) >> 4;
_mixer -= _volume_at_sample_time[i] << 8;
if (_mixer > 0x7FFF)
{

View File

@ -41,6 +41,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS
private short[] _outputBuffer;
private int[] _outputBuffer_filtered;
private int[] _outputBuffer_not_filtered;
private int[] _volume_at_sample_time;
private int _outputBufferIndex;
private int filter_index;
private int last_filtered_value;
@ -93,6 +94,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS
_outputBuffer_filtered = new int[sampleRate];
_outputBuffer_not_filtered = new int[sampleRate];
_volume_at_sample_time = new int[sampleRate];
}
// ------------------------------------
@ -190,6 +192,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS
{
_outputBuffer_not_filtered[_outputBufferIndex] = temp_not_filtered;
_outputBuffer_filtered[_outputBufferIndex] = temp_filtered;
_volume_at_sample_time[_outputBufferIndex] = _volume;
_outputBufferIndex++;
}
}