private void RunCpuOne() { cpu_stepcounter++; if (cpu_stepcounter == cpu_sequence[cpu_step]) { cpu_step++; cpu_step &= 31; cpu_stepcounter = 0; if (sprdma_countdown > 0) { sprdma_countdown--; if (sprdma_countdown == 0) { //its weird that this is 514.. normally itd be 512 (and people would say its wrong) or 513 (and people would say its right) //but 514 passes test 4-irq_and_dma cpu_deadcounter += 514; } } if (cpu_deadcounter > 0) { cpu_deadcounter--; } else { cpu.IRQ = _irq_apu || board.IRQSignal; cpu.ExecuteOne(); } apu.RunOne(); board.ClockCPU(); ppu.PostCpuInstructionOne(); } }
internal void RunCpuOne() { cpu_stepcounter++; if (cpu_stepcounter == cpu_sequence[cpu_step]) { cpu_step++; if (cpu_step == 5) { cpu_step = 0; } cpu_stepcounter = 0; if (sprdma_countdown > 0) { sprdma_countdown--; if (sprdma_countdown == 0) { //its weird that this is 514.. normally itd be 512 (and people would say its wrong) or 513 (and people would say its right) //but 514 passes test 4-irq_and_dma // according to nesdev wiki, http://wiki.nesdev.com/w/index.php/PPU_OAM this is 513 on even cycles and 514 on odd cycles // TODO: Implement that cpu_deadcounter += 514; } } if (apu.dmc_dma_countdown > 0) { cpu.RDY = false; apu.dmc_dma_countdown--; if (apu.dmc_dma_countdown == 0) { apu.RunDMCFetch(); cpu.RDY = true; } if (apu.dmc_dma_countdown == 0) { apu.dmc_dma_countdown = -1; } } if (cpu_deadcounter > 0) { cpu_deadcounter--; } else { cpu.IRQ = _irq_apu || Board.IRQSignal; cpu.ExecuteOne(); } ppu.ppu_open_bus_decay(0); apu.RunOne(); Board.ClockCPU(); ppu.PostCpuInstructionOne(); } }
internal void RunCpuOne() { cpu_stepcounter++; if (cpu_stepcounter == cpu_sequence[cpu_step]) { cpu_step++; if (cpu_step == 5) { cpu_step = 0; } cpu_stepcounter = 0; /////////////////////////// // OAM DMA start /////////////////////////// if (sprdma_countdown > 0) { sprdma_countdown--; if (sprdma_countdown == 0) { if (cpu.TotalExecutedCycles % 2 == 0) { cpu_deadcounter = 2; } else { cpu_deadcounter = 1; } oam_dma_exec = true; cpu.RDY = false; oam_dma_index = 0; special_case_delay = true; } } if (oam_dma_exec && apu.dmc_dma_countdown != 1 && !dmc_realign) { if (cpu_deadcounter == 0) { if (oam_dma_index % 2 == 0) { oam_dma_byte = ReadMemory(oam_dma_addr); oam_dma_addr++; } else { WriteMemory(0x2004, oam_dma_byte); } oam_dma_index++; if (oam_dma_index == 512) { oam_dma_exec = false; } } else { cpu_deadcounter--; } } else if (apu.dmc_dma_countdown == 1) { dmc_realign = true; } else if (dmc_realign) { dmc_realign = false; } ///////////////////////////// // OAM DMA end ///////////////////////////// ///////////////////////////// // dmc dma start ///////////////////////////// if (apu.dmc_dma_countdown > 0) { cpu.RDY = false; dmc_dma_exec = true; apu.dmc_dma_countdown--; if (apu.dmc_dma_countdown == 0) { apu.RunDMCFetch(); dmc_dma_exec = false; apu.dmc_dma_countdown = -1; do_the_reread = true; } } ///////////////////////////// // dmc dma end ///////////////////////////// apu.RunOne(true); if (cpu.RDY && !IRQ_delay) { cpu.IRQ = _irq_apu || Board.IRQSignal; } else if (special_case_delay || apu.dmc_dma_countdown == 3) { cpu.IRQ = _irq_apu || Board.IRQSignal; special_case_delay = false; } cpu.ExecuteOne(); apu.RunOne(false); if (ppu.double_2007_read > 0) { ppu.double_2007_read--; } if (do_the_reread && cpu.RDY) { do_the_reread = false; } if (IRQ_delay) { IRQ_delay = false; } if (!dmc_dma_exec && !oam_dma_exec && !cpu.RDY) { cpu.RDY = true; IRQ_delay = true; } ppu.ppu_open_bus_decay(0); Board.ClockCPU(); ppu.PostCpuInstructionOne(); } }