From 134a2a07e544d61278b95243a5fa3d2c198e48f4 Mon Sep 17 00:00:00 2001 From: Sour Date: Thu, 30 Aug 2018 22:26:38 -0400 Subject: [PATCH] Sunsoft 5B: Fixed audio period (was off by 1) --- Core/Sunsoft5bAudio.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Core/Sunsoft5bAudio.h b/Core/Sunsoft5bAudio.h index d0cdf1d9..93ddbae8 100644 --- a/Core/Sunsoft5bAudio.h +++ b/Core/Sunsoft5bAudio.h @@ -12,7 +12,7 @@ private: uint8_t _currentRegister; uint8_t _registers[0x10]; int16_t _lastOutput; - uint16_t _timer[3]; + int16_t _timer[3]; uint8_t _toneStep[3]; bool _processTick; @@ -54,8 +54,8 @@ private: void UpdateChannel(int channel) { _timer[channel]--; - if(_timer[channel] == 0) { - _timer[channel] = GetPeriod(channel) + 1; + if(_timer[channel] <= 0) { + _timer[channel] = GetPeriod(channel); _toneStep[channel] = (_toneStep[channel] + 1) & 0x0F; } } @@ -78,7 +78,7 @@ protected: { BaseExpansionAudio::StreamState(saving); - ArrayInfo timer{ _timer, 3 }; + ArrayInfo timer{ _timer, 3 }; ArrayInfo registers{ _registers, 0x10 }; ArrayInfo toneStep{ _toneStep, 3 }; Stream(timer, registers, toneStep, _currentRegister, _lastOutput, _processTick);