mirror of
https://github.com/libretro/Mesen.git
synced 2025-02-25 02:50:42 +00:00
APU: Fixed Square 1 sweep bug (fixes Little Red Hood without breaking Super Dodge Ball). Fixed noise channel period (was set to twice the real value)
This commit is contained in:
parent
6aed632123
commit
070f07082e
@ -21,7 +21,7 @@ private:
|
||||
protected:
|
||||
uint16_t _timer = 0;
|
||||
uint16_t _period = 0;
|
||||
uint32_t _clockDivider = 2; //All channels except triangle clock overy other cpu clock
|
||||
uint16_t _periodMultiplier = 1;
|
||||
|
||||
void SetVolume(double volume)
|
||||
{
|
||||
@ -89,13 +89,13 @@ public:
|
||||
while(_previousCycle < targetCycle) {
|
||||
if(_timer == 0) {
|
||||
Clock();
|
||||
_timer = _period;
|
||||
_previousCycle += _clockDivider;
|
||||
_timer = _period * _periodMultiplier;
|
||||
_previousCycle++;
|
||||
} else {
|
||||
uint32_t cyclesToRun = (targetCycle - _previousCycle) / _clockDivider;
|
||||
uint32_t cyclesToRun = targetCycle - _previousCycle;
|
||||
uint16_t skipCount = _timer > cyclesToRun ? cyclesToRun : _timer;
|
||||
_timer -= skipCount;
|
||||
_previousCycle += skipCount * _clockDivider;
|
||||
_previousCycle += skipCount;
|
||||
|
||||
if(cyclesToRun == 0) {
|
||||
break;
|
||||
|
@ -9,7 +9,6 @@ DeltaModulationChannel::DeltaModulationChannel(AudioChannel channel, Blip_Buffer
|
||||
{
|
||||
Instance = this;
|
||||
_memoryManager = memoryManager;
|
||||
_clockDivider = 1;
|
||||
SetVolume(0.42545);
|
||||
}
|
||||
|
||||
|
@ -73,7 +73,7 @@ public:
|
||||
break;
|
||||
|
||||
case 2: //400E
|
||||
_period = (GetNesModel() == NesModel::NTSC ? _noisePeriodLookupTableNtsc : _noisePeriodLookupTablePal)[value & 0x0F];
|
||||
_period = (GetNesModel() == NesModel::NTSC ? _noisePeriodLookupTableNtsc : _noisePeriodLookupTablePal)[value & 0x0F] - 1;
|
||||
_modeFlag = (value & 0x80) == 0x80;
|
||||
break;
|
||||
|
||||
|
@ -31,7 +31,7 @@ private:
|
||||
bool IsMuted()
|
||||
{
|
||||
//A period of t < 8, either set explicitly or via a sweep period update, silences the corresponding pulse channel.
|
||||
return _period < 8 || _sweepTargetPeriod > 0x7FF;
|
||||
return _period < 8 || (!_sweepNegate && _sweepTargetPeriod > 0x7FF);
|
||||
}
|
||||
|
||||
void InitializeSweep(uint8_t regValue)
|
||||
@ -54,7 +54,7 @@ private:
|
||||
_sweepTargetPeriod = _period - shiftResult;
|
||||
if(_isChannel1) {
|
||||
// As a result, a negative sweep on pulse channel 1 will subtract the shifted period value minus 1
|
||||
_sweepTargetPeriod++;
|
||||
_sweepTargetPeriod--;
|
||||
}
|
||||
} else {
|
||||
_sweepTargetPeriod = _period + shiftResult;
|
||||
@ -81,6 +81,7 @@ public:
|
||||
{
|
||||
SetVolume(0.1128);
|
||||
_isChannel1 = isChannel1;
|
||||
_periodMultiplier = 2;
|
||||
}
|
||||
|
||||
virtual void Reset(bool softReset)
|
||||
@ -150,7 +151,7 @@ public:
|
||||
_period |= (value & 0x07) << 8;
|
||||
|
||||
//The sequencer is restarted at the first value of the current sequence.
|
||||
_timer = _period + 1;
|
||||
_timer = _period * 2;
|
||||
_dutyPos = 0;
|
||||
|
||||
//The envelope is also restarted.
|
||||
|
@ -31,7 +31,6 @@ protected:
|
||||
public:
|
||||
TriangleChannel(AudioChannel channel, Blip_Buffer* buffer) : ApuLengthCounter(channel, buffer)
|
||||
{
|
||||
_clockDivider = 1; //Triangle clocks at the same speed as the cpu
|
||||
SetVolume(0.12765);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user