diff --git a/src/BizHawk.Emulation.Cores/CPUs/MOS 6502X/Execute.cs b/src/BizHawk.Emulation.Cores/CPUs/MOS 6502X/Execute.cs index 9896ad40f4..95f4aa9dc8 100644 --- a/src/BizHawk.Emulation.Cores/CPUs/MOS 6502X/Execute.cs +++ b/src/BizHawk.Emulation.Cores/CPUs/MOS 6502X/Execute.cs @@ -581,7 +581,10 @@ namespace BizHawk.Emulation.Cores.Components.M6502 } } - Fetch1_Real(); + mi = 0; + opcode = VOP_Fetch1_NoInterrupt; + + Fetch1_Real(); } private void Fetch1_Real() diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/APU.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/APU.cs index 1021745aba..23ad0d87a6 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/APU.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/APU.cs @@ -746,7 +746,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES // when called due to empty bueffer while DMC running, there is no delay nes.cpu.RDY = false; nes.dmc_dma_exec = true; - nes.DMC_just_started = true; if (fill_glitch_2) { 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 d40a496c0d..533e6cf705 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.Core.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.Core.cs @@ -447,15 +447,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public byte oam_dma_byte; public bool dmc_dma_exec = false; public bool dmc_realign; - public bool IRQ_delay; public bool reread_trigger; public int do_the_reread_2002, do_the_reread_2007, do_the_reread_cont_1, do_the_reread_cont_2; public int reread_opp_4016, reread_opp_4017; public byte DB; //old data bus values from previous reads - // DMA's delay IRQ's by one cycle after finished, but allow them on the same cycle if just started - public bool DMC_just_started; - public bool OAM_just_started; - public bool ppu_nmi; internal void RunCpuOne() { @@ -514,8 +509,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES apu.DMC_RDY_check = -1; } - if (!dmc_dma_exec) { DMC_just_started = true; } - cpu.RDY = false; dmc_dma_exec = true; apu.dmc_dma_countdown--; @@ -586,37 +579,16 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES // dmc dma end ///////////////////////////// apu.RunOneFirst(); - - if (cpu.RDY && !IRQ_delay) + + 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? + if (apu.dmc.fill_glitch_2) { - cpu.IRQ = _irq_apu || Board.IrqSignal; - if (ppu_nmi) - { - cpu.NMI = ppu_nmi; - ppu_nmi = false; - } - - } - else if (OAM_just_started || DMC_just_started) - { - cpu.IRQ = _irq_apu || Board.IrqSignal; - if (ppu_nmi) - { - cpu.NMI = ppu_nmi; - ppu_nmi = false; - } - - OAM_just_started = false; - DMC_just_started = false; - - // 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? - if (apu.dmc.fill_glitch_2) - { - apu.dmc_dma_countdown = -1; - dmc_dma_exec = false; - apu.dmc.fill_glitch_2 = false; - } + apu.dmc_dma_countdown = -1; + dmc_dma_exec = false; + apu.dmc.fill_glitch_2 = false; } cpu.ExecuteOne(); @@ -644,12 +616,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES reread_trigger = false; } - IRQ_delay = false; - if (!cpu.RDY && !dmc_dma_exec && !oam_dma_exec) { cpu.RDY = true; - IRQ_delay = true; } } @@ -843,7 +812,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES oam_dma_exec = true; cpu.RDY = false; oam_dma_index = 0; - OAM_just_started = true; } } break; diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.IStatable.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.IStatable.cs index 7c2b8ed10e..61f179eb74 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.IStatable.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.IStatable.cs @@ -29,7 +29,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES ser.Sync(nameof(oam_dma_byte), ref oam_dma_byte); ser.Sync(nameof(dmc_dma_exec), ref dmc_dma_exec); ser.Sync(nameof(dmc_realign), ref dmc_realign); - ser.Sync(nameof(IRQ_delay), ref IRQ_delay); ser.Sync(nameof(reread_trigger), ref reread_trigger); ser.Sync(nameof(do_the_reread_2002), ref do_the_reread_2002); ser.Sync(nameof(do_the_reread_2007), ref do_the_reread_2007); @@ -37,9 +36,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES ser.Sync(nameof(do_the_reread_cont_2), ref do_the_reread_cont_2); ser.Sync(nameof(reread_opp_4016), ref reread_opp_4016); ser.Sync(nameof(reread_opp_4017), ref reread_opp_4017); - ser.Sync(nameof(OAM_just_started), ref OAM_just_started); - ser.Sync(nameof(DMC_just_started), ref DMC_just_started); - ser.Sync(nameof(ppu_nmi), ref ppu_nmi); // VS related ser.Sync("VS", ref _isVS); diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/PPU.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/PPU.cs index 20476c7428..aa405a8dad 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/PPU.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/PPU.cs @@ -423,7 +423,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES NMI_PendingInstructions--; if (NMI_PendingInstructions <= 0) { - nes.ppu_nmi = true; + nes.cpu.NMI = true; } } } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/PPU.run.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/PPU.run.cs index 19e3fc1ed8..e80233da8c 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/PPU.run.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/PPU.run.cs @@ -175,7 +175,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES } else if (ppur.status.cycle == (3 + NMI_offset) && ppur.status.sl == 241 + preNMIlines) { - if (nmi_destiny) { nes.ppu_nmi = true; } + if (nmi_destiny) { nes.cpu.NMI = true; } nes.Board.AtVsyncNmi(); }