APU: Fixed sound issues when loading a savestate

This commit is contained in:
Souryo 2016-01-15 23:51:27 -05:00
parent 56d2580fbf
commit 8ef9fab489
3 changed files with 10 additions and 8 deletions

View File

@ -55,6 +55,7 @@ void APU::SetNesModel(NesModel model, bool forceInit)
_frameCounter->SetNesModel(model);
_mixer->SetNesModel(model);
_mixer->Reset();
}
}
@ -213,8 +214,6 @@ void APU::Reset(bool softReset)
void APU::StreamState(bool saving)
{
Stream<NesModel>(_nesModel);
Stream<uint32_t>(_currentCycle);
Stream<uint32_t>(_previousCycle);
Stream(_squareChannel[0].get());
Stream(_squareChannel[1].get());
Stream(_triangleChannel.get());
@ -223,6 +222,8 @@ void APU::StreamState(bool saving)
Stream(_frameCounter.get());
if(!saving) {
_currentCycle = 0;
_previousCycle = 0;
SetNesModel(_nesModel, true);
}
}

View File

@ -47,15 +47,14 @@ public:
virtual void StreamState(bool saving)
{
Stream<int8_t>(_lastOutput);
Stream<uint32_t>(_previousCycle);
if(!saving) {
_lastOutput = 0;
_previousCycle = 0;
}
Stream<uint16_t>(_timer);
Stream<uint16_t>(_period);
Stream<NesModel>(_nesModel);
if(!saving) {
_mixer->Reset();
}
}
void SetNesModel(NesModel model)

View File

@ -44,6 +44,8 @@ void SoundMixer::Reset()
_previousOutput = 0;
blip_clear(_blipBuf);
_timestamps.clear();
for(int i = 0; i < 5; i++) {
_volumes[0] = 0;
}