Reduce /A13 aliasing

PPU /A13 changes at the PPU's clock rate, which is 3x that of the CPU
clock rate.
This commit is contained in:
Persune 2021-08-14 20:36:24 +08:00
parent 5077180c55
commit 212f17215c
4 changed files with 5 additions and 4 deletions

View file

@ -473,7 +473,8 @@ void Console::ProcessCpuClock()
void Console::ProcessInterferenceAudio()
{
_InvA13 = (_ppu->_A13pinLow == 1) ? 0 : 1; // invert relative to 2A03
_InvA13 = _ppu->_A13pinLowSum;
_ppu->_A13pinLowSum = 0;
_controlManager->GetInvOE1(_controlManager->_address);
_InvOE1 = (_controlManager->_OE1pinLow == 1) ? 0 : 1; // invert relative to 2A03

View file

@ -466,7 +466,7 @@ void PPU::WriteRAM(uint16_t addr, uint8_t value)
void PPU::GetInvA13()
{
// pull level high when PPU/VRAM addr bit 13 is low
_A13pinLow = (_ppuBusAddress & 0x2000) ? 0 : 1;
_A13pinLowSum += (_ppuBusAddress & 0x2000) ? 1 : 0; // invert relative to 2A03
}
uint8_t PPU::ReadPaletteRAM(uint16_t addr)

View file

@ -180,7 +180,7 @@ class PPU : public IMemoryHandler, public Snapshotable
static constexpr int32_t OutputBufferSize = 256*240*2;
static constexpr int32_t OamDecayCycleCount = 3000;
uint8_t _A13pinLow;
uint8_t _A13pinLowSum;
PPU(shared_ptr<Console> console);
virtual ~PPU();

View file

@ -277,7 +277,7 @@ int16_t SoundMixer::GetOutputVolume(bool forRightChannel)
#endif
GetChannelOutput(AudioChannel::EPSM_L, forRightChannel) * 4 +
GetChannelOutput(AudioChannel::EPSM_R, forRightChannel) * 4 +
GetChannelOutput(AudioChannel::InvA13, forRightChannel) * 20 +
(GetChannelOutput(AudioChannel::InvA13, forRightChannel) * 20) / 3.0 + // 3 PPU samples per CPU clock
GetChannelOutput(AudioChannel::InvOE1, forRightChannel) * 1000
);
}