diff --git a/bsnes/emulator/emulator.hpp b/bsnes/emulator/emulator.hpp index 7f56327d..b7971618 100644 --- a/bsnes/emulator/emulator.hpp +++ b/bsnes/emulator/emulator.hpp @@ -29,7 +29,7 @@ using namespace nall; namespace Emulator { static const string Name = "bsnes"; - static const string Version = "112.8"; + static const string Version = "112.9"; static const string Author = "byuu"; static const string License = "GPLv3"; static const string Website = "https://byuu.org"; diff --git a/bsnes/sfc/cpu/cpu.hpp b/bsnes/sfc/cpu/cpu.hpp index 154270c6..e4046538 100644 --- a/bsnes/sfc/cpu/cpu.hpp +++ b/bsnes/sfc/cpu/cpu.hpp @@ -52,7 +52,8 @@ struct CPU : Processor::WDC65816, Thread, PPUcounter { alwaysinline auto dmaEdge() -> void; //irq.cpp - alwaysinline auto pollInterrupts() -> void; + alwaysinline auto pollNMI() -> void; + alwaysinline auto pollIRQ() -> void; auto nmitimenUpdate(uint8 data) -> void; auto rdnmi() -> bool; auto timeup() -> bool; diff --git a/bsnes/sfc/cpu/io.cpp b/bsnes/sfc/cpu/io.cpp index 25c32489..2b9667af 100644 --- a/bsnes/sfc/cpu/io.cpp +++ b/bsnes/sfc/cpu/io.cpp @@ -191,20 +191,24 @@ auto CPU::writeCPU(uint addr, uint8 data) -> void { io.htime = (io.htime >> 2) - 1; io.htime = io.htime & 0x100 | data << 0; io.htime = (io.htime + 1) << 2; + pollIRQ(); //unverified return; case 0x4208: //HTIMEH io.htime = (io.htime >> 2) - 1; io.htime = io.htime & 0x0ff | (data & 1) << 8; io.htime = (io.htime + 1) << 2; + pollIRQ(); //unverified return; case 0x4209: //VTIMEL io.vtime = io.vtime & 0x100 | data << 0; + pollIRQ(); //unverified return; case 0x420a: //VTIMEH io.vtime = io.vtime & 0x0ff | (data & 1) << 8; + pollIRQ(); //unverified return; case 0x420b: //DMAEN diff --git a/bsnes/sfc/cpu/irq.cpp b/bsnes/sfc/cpu/irq.cpp index b9564ba1..60d9979d 100644 --- a/bsnes/sfc/cpu/irq.cpp +++ b/bsnes/sfc/cpu/irq.cpp @@ -1,9 +1,10 @@ -//called once every four clock cycles; +//pollNMI() and pollIRQ() are called once every four clock cycles; //as NMI steps by scanlines (divisible by 4) and IRQ by PPU 4-cycle dots. // //ppu.(vh)counter(n) returns the value of said counters n-clocks before current time; //it is used to emulate hardware communication delay between opcode and interrupt units. -auto CPU::pollInterrupts() -> void { + +auto CPU::pollNMI() -> void { //NMI hold if(status.nmiHold.lower() && io.nmiEnable) { status.nmiTransition = 1; @@ -13,7 +14,9 @@ auto CPU::pollInterrupts() -> void { if(status.nmiValid.flip(vcounter(2) >= ppu.vdisp())) { if(status.nmiLine = status.nmiValid) status.nmiHold = 1; //hold /NMI for four cycles } +} +auto CPU::pollIRQ() -> void { //IRQ hold status.irqHold = 0; if(status.irqLine && io.irqEnable) { diff --git a/bsnes/sfc/cpu/timing.cpp b/bsnes/sfc/cpu/timing.cpp index d53c7b0d..ce6f973b 100644 --- a/bsnes/sfc/cpu/timing.cpp +++ b/bsnes/sfc/cpu/timing.cpp @@ -11,7 +11,7 @@ auto CPU::joypadCounter() const -> uint { auto CPU::stepOnce() -> void { counter.cpu += 2; tick(); - if(hcounter() & 2) pollInterrupts(); + if(hcounter() & 2) pollNMI(), pollIRQ(); if(joypadCounter() == 0) joypadEdge(); }