From 934a3ae266883bf282c732ecfa88c6fd0801721d Mon Sep 17 00:00:00 2001 From: alyosha-tas Date: Sat, 8 Jan 2022 19:53:47 -0500 Subject: [PATCH] NESHawk: proper DMC address wrap --- .../Consoles/Nintendo/NES/APU.cs | 4 ++-- .../Consoles/Nintendo/NES/NES.Core.cs | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/APU.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/APU.cs index 65b41873a1..337ad9c43d 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/APU.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/APU.cs @@ -957,8 +957,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES sample_buffer_filled = true; sample_address = (ushort)(sample_address + 1); - //sample address wraps to 0xC000 - if (sample_address == 0) { sample_address = 0xC000;} + //sample address wraps to 0x8000, even though this cannot be reached by write to address reg + if (sample_address == 0) { sample_address = 0x8000; } // Console.WriteLine(sample_length); // Console.WriteLine(user_length); diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.Core.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.Core.cs index 206c038ffd..b5a3d968ec 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.Core.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.Core.cs @@ -532,22 +532,22 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES do_the_reread_2007++; } */ - if ((apu.dmc.sample_address & 0x401F) != 0x4016) + if ((apu.dmc.sample_address & 0x1F) != 0x16) { do_the_reread_cont_1++; } - if ((apu.dmc.sample_address & 0x401F) == 0x4016) + if ((apu.dmc.sample_address & 0x1F) == 0x16) { reread_opp_4016++; } - if ((apu.dmc.sample_address & 0x401F) != 0x4017) + if ((apu.dmc.sample_address & 0x1F) != 0x17) { do_the_reread_cont_2++; } - if ((apu.dmc.sample_address & 0x401F) == 0x4017) + if ((apu.dmc.sample_address & 0x1F) == 0x17) { reread_opp_4017++; } @@ -582,7 +582,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES cpu.IRQ = _irq_apu || Board.IrqSignal; // DMC was started in the APU, but in this case it only lasts 1 cycle and is then aborted, so put this here - // TODO: should this clock controllers? + // NOTE: for some famicoms, this will also clock controllers, this will need to be handled if emulating additional models if (apu.dmc.fill_glitch_2_end) { apu.dmc_dma_countdown = -1;