SMS: Fixed crackling in audio in PAL mode

This commit is contained in:
Sour 2024-11-05 18:19:54 +09:00
parent a72b8bff6e
commit ea917e77c2
3 changed files with 14 additions and 2 deletions

View file

@ -54,7 +54,7 @@ LoadRomResult SmsConsole::LoadRom(VirtualFile& romFile)
_romFormat = RomFormat::Sms;
_model = SmsModel::Sms;
}
_vdp.reset(new SmsVdp());
_memoryManager.reset(new SmsMemoryManager());
_cpu.reset(new SmsCpu());
@ -74,7 +74,7 @@ LoadRomResult SmsConsole::LoadRom(VirtualFile& romFile)
_memoryManager->Init(_emu, this, romData, biosRom, _vdp.get(), _controlManager.get(), _cart.get(), _psg.get(), _fmAudio.get());
_vdp->Init(_emu, this, _cpu.get(), _controlManager.get(), _memoryManager.get());
_cpu->Init(_emu, this, _memoryManager.get());
UpdateRegion(true);
return LoadRomResult::Success;
@ -186,6 +186,7 @@ void SmsConsole::UpdateRegion(bool forceUpdate)
if(_region != region || forceUpdate) {
_region = region;
_vdp->SetRegion(_model == SmsModel::GameGear ? ConsoleRegion::Ntsc : _region);
_psg->SetRegion(_model == SmsModel::GameGear ? ConsoleRegion::Ntsc : _region);
}
}

View file

@ -28,6 +28,15 @@ SmsPsg::SmsPsg(Emulator* emu, SmsConsole* console)
blip_set_rates(_rightChannel, _console->GetMasterClockRate(), SmsPsg::SampleRate);
}
void SmsPsg::SetRegion(ConsoleRegion region)
{
blip_clear(_leftChannel);
blip_clear(_rightChannel);
blip_set_rates(_leftChannel, _console->GetMasterClockRate(), SmsPsg::SampleRate);
blip_set_rates(_rightChannel, _console->GetMasterClockRate(), SmsPsg::SampleRate);
}
void SmsPsg::RunNoise(SmsNoiseChannelState& noise)
{
if(noise.Timer == 0 || --noise.Timer == 0) {

View file

@ -35,6 +35,8 @@ public:
SmsPsgState& GetState() { return _state; }
void SetRegion(ConsoleRegion region);
void Run();
void PlayQueuedAudio();