From 942a9e086a077535fdc2adabfe6bf44215d6eea7 Mon Sep 17 00:00:00 2001 From: "andres.delikat" Date: Sat, 27 Aug 2011 15:49:16 +0000 Subject: [PATCH] Add a SoundOn flag to the nes core and hook to the sound on/off in sound config. the flag bypasses the apu.run function. the apu read/writes are still going, and seems to be TAS safe to do this --- BizHawk.Emulation/Consoles/Nintendo/NES/Core.cs | 5 +++-- BizHawk.MultiClient/Sound.cs | 11 +++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/BizHawk.Emulation/Consoles/Nintendo/NES/Core.cs b/BizHawk.Emulation/Consoles/Nintendo/NES/Core.cs index 605278d34b..dfe32bf5b0 100644 --- a/BizHawk.Emulation/Consoles/Nintendo/NES/Core.cs +++ b/BizHawk.Emulation/Consoles/Nintendo/NES/Core.cs @@ -22,7 +22,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo string game_name; //friendly name exposed to user and used as filename base CartInfo cart; //the current cart prototype. should be moved into the board, perhaps INESBoard board; //the board hardware that is currently driving things - + public bool SoundOn = true; bool _irq_apu, _irq_cart; public bool irq_apu { get { return _irq_apu; } set { _irq_apu = value; sync_irq(); } } public bool irq_cart { get { return _irq_cart; } set { _irq_cart = value; sync_irq(); } } @@ -113,7 +113,8 @@ namespace BizHawk.Emulation.Consoles.Nintendo cpu_cycles -= todo; cpu_accumulate -= 48*todo; cpu.Execute(todo); - apu.Run(todo); + if (SoundOn) + apu.Run(todo); ppu.PostCpuInstruction(todo); } } diff --git a/BizHawk.MultiClient/Sound.cs b/BizHawk.MultiClient/Sound.cs index a1c457c27c..5f2125b7e3 100644 --- a/BizHawk.MultiClient/Sound.cs +++ b/BizHawk.MultiClient/Sound.cs @@ -3,6 +3,8 @@ using BizHawk.Emulation.Sound; using SlimDX.DirectSound; using SlimDX.Multimedia; +using BizHawk.Emulation.Consoles.Nintendo; + namespace BizHawk.MultiClient { public class Sound : IDisposable @@ -174,6 +176,15 @@ namespace BizHawk.MultiClient DSoundBuffer.Volume = -5000; else DSoundBuffer.Volume = 0 - ((100 - Global.Config.SoundVolume) * 15); + + if (Global.Emulator is NES) + { + NES n = Global.Emulator as NES; + if (Global.Config.SoundEnabled == false) + n.SoundOn = false; + else + n.SoundOn = true; + } } } } \ No newline at end of file