From a9bf3cf58a7d5f311bcb868e698403162c8d8dc9 Mon Sep 17 00:00:00 2001 From: goyuken Date: Fri, 14 Dec 2012 22:29:27 +0000 Subject: [PATCH] nes: apu: implement "better" mixing scheme (as recommended by nesdev) in the hope of passing some apu_mixer tests. no change in any of the tests, so change backed out (committed as comments only). from what i understand, it's just as likely that the tests are failing to small channel timing problems as mixer problems. --- .../Consoles/Nintendo/NES/APU.cs | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/BizHawk.Emulation/Consoles/Nintendo/NES/APU.cs b/BizHawk.Emulation/Consoles/Nintendo/NES/APU.cs index c67598fea6..dbba0c06c0 100644 --- a/BizHawk.Emulation/Consoles/Nintendo/NES/APU.cs +++ b/BizHawk.Emulation/Consoles/Nintendo/NES/APU.cs @@ -1088,6 +1088,25 @@ namespace BizHawk.Emulation.Consoles.Nintendo int oldmix = 0; + // http://wiki.nesdev.com/w/index.php/APU_Mixer + // in the end, doesn't help pass any tests, so canned + /* + static readonly int[] pulse_table; + static readonly int[] tnd_table; + static APU() + { + const double scale = 43803.0; + + pulse_table = new int[31]; + tnd_table = new int[203]; + pulse_table[0] = tnd_table[0] = 0; + for (int i = 1; i < pulse_table.Length; i++) + pulse_table[i] = (int)Math.Round(scale * 95.52 / (8128.0 / i + 100.0)); + for (int i = 1; i < tnd_table.Length; i++) + tnd_table[i] = (int)Math.Round(scale * 163.67 / (24329.0 / i + 100.0)); + } + */ + void EmitSample() { if (recalculate) @@ -1119,6 +1138,9 @@ namespace BizHawk.Emulation.Consoles.Nintendo int pulse_out = 376 * (s_pulse0 + s_pulse1); int tnd_out = 426 * s_tri + 247 * s_noise + 167 * s_dmc; int mix = pulse_out + tnd_out; + //int pulse_out = pulse_table[s_pulse0 + s_pulse1]; + //int tnd_out = tnd_table[3 * s_tri + 2 * s_noise + s_dmc]; + //int mix = pulse_out + tnd_out; dlist.Add(new Delta(sampleclock, mix - oldmix)); oldmix = mix;