From 61b4e3745ff82117dd546ac7b8cc8d41801070e3 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Sun, 1 May 2022 23:57:53 -0500 Subject: [PATCH] NES: NSFPlay muting --- src/engine/platform/nes.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/engine/platform/nes.cpp b/src/engine/platform/nes.cpp index 9f44ebe0..e353b26d 100644 --- a/src/engine/platform/nes.cpp +++ b/src/engine/platform/nes.cpp @@ -150,7 +150,7 @@ void DivPlatformNES::acquire_NSFPlay(short* bufL, short* bufR, size_t start, siz nes1_NP->Render(out1); nes2_NP->Render(out2); - int sample=out1[0]+out1[1]+out2[0]+out2[1]; + int sample=(out1[0]+out1[1]+out2[0]+out2[1])<<1; if (sample>32767) sample=32767; if (sample<-32768) sample=-32768; bufL[i]=sample; @@ -505,7 +505,12 @@ int DivPlatformNES::dispatch(DivCommand c) { void DivPlatformNES::muteChannel(int ch, bool mute) { isMuted[ch]=mute; - if (!useNP) nes->muted[ch]=mute; + if (useNP) { + nes1_NP->SetMask(((int)isMuted[0])|(isMuted[1]<<1)); + nes2_NP->SetMask(((int)isMuted[2])|(isMuted[3]<<1)|(isMuted[4]<<2)); + } else { + nes->muted[ch]=mute; + } } void DivPlatformNES::forceIns() { @@ -555,6 +560,8 @@ void DivPlatformNES::reset() { if (useNP) { nes1_NP->Reset(); nes2_NP->Reset(); + nes1_NP->SetMask(((int)isMuted[0])|(isMuted[1]<<1)); + nes2_NP->SetMask(((int)isMuted[2])|(isMuted[3]<<1)|(isMuted[4]<<2)); } else { apu_turn_on(nes,apuType); nes->apu.cpu_cycles=0;