From 64b2856d7ceb0c7f659930fd5fd7296019fa4763 Mon Sep 17 00:00:00 2001 From: Souryo Date: Sun, 3 Jan 2016 11:42:01 -0500 Subject: [PATCH] Reverted start cycle for CPU and fixed initial "period" for DMC - makes "dpcmletterbox" more stable at first, and doesn't break sprdma_and_dmc tests --- Core/CPU.cpp | 4 ++-- Core/DeltaModulationChannel.cpp | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Core/CPU.cpp b/Core/CPU.cpp index f82a5a12..204d8f02 100644 --- a/Core/CPU.cpp +++ b/Core/CPU.cpp @@ -58,7 +58,7 @@ void CPU::Reset(bool softReset) { _state.NMIFlag = false; _state.IRQFlag = 0; - _cycleCount = 0; + _cycleCount = -1; _spriteDmaTransfer = false; _spriteDmaCounter = 0; @@ -110,7 +110,7 @@ void CPU::IncCycleCount() PPU::ExecStatic(); APU::ExecStatic(); - if(!_spriteDmaTransfer) { + if(!_spriteDmaTransfer && !_dmcDmaRunning) { //IRQ flags are ignored during Sprite DMA - fixes irq_and_dma //"it's really the status of the interrupt lines at the end of the second-to-last cycle that matters." diff --git a/Core/DeltaModulationChannel.cpp b/Core/DeltaModulationChannel.cpp index 25c18e10..5b5ad1d6 100644 --- a/Core/DeltaModulationChannel.cpp +++ b/Core/DeltaModulationChannel.cpp @@ -32,6 +32,10 @@ void DeltaModulationChannel::Reset(bool softReset) _bitsRemaining = 8; _silenceFlag = true; _needToRun = false; + + //Not sure if this is accurate, but it seems to make things better rather than worse (for dpcmletterbox) + //"On the real thing, I think the power-on value is 428 (or the equivalent at least - it uses a linear feedback shift register), though only the even/oddness should matter for this test." + _period = (GetNesModel() == NesModel::NTSC ? _dmcPeriodLookupTableNtsc : _dmcPeriodLookupTablePal)[0] - 1; } void DeltaModulationChannel::InitSample()