CPU IRQ improvement to fix Shin Nihon Pro Wrestling Kouhin '95
This commit is contained in:
byuu 2019-11-08 15:56:27 +09:00
parent f1108408a8
commit 5775155714
5 changed files with 13 additions and 5 deletions

View File

@ -29,7 +29,7 @@ using namespace nall;
namespace Emulator { namespace Emulator {
static const string Name = "bsnes"; 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 Author = "byuu";
static const string License = "GPLv3"; static const string License = "GPLv3";
static const string Website = "https://byuu.org"; static const string Website = "https://byuu.org";

View File

@ -52,7 +52,8 @@ struct CPU : Processor::WDC65816, Thread, PPUcounter {
alwaysinline auto dmaEdge() -> void; alwaysinline auto dmaEdge() -> void;
//irq.cpp //irq.cpp
alwaysinline auto pollInterrupts() -> void; alwaysinline auto pollNMI() -> void;
alwaysinline auto pollIRQ() -> void;
auto nmitimenUpdate(uint8 data) -> void; auto nmitimenUpdate(uint8 data) -> void;
auto rdnmi() -> bool; auto rdnmi() -> bool;
auto timeup() -> bool; auto timeup() -> bool;

View File

@ -191,20 +191,24 @@ auto CPU::writeCPU(uint addr, uint8 data) -> void {
io.htime = (io.htime >> 2) - 1; io.htime = (io.htime >> 2) - 1;
io.htime = io.htime & 0x100 | data << 0; io.htime = io.htime & 0x100 | data << 0;
io.htime = (io.htime + 1) << 2; io.htime = (io.htime + 1) << 2;
pollIRQ(); //unverified
return; return;
case 0x4208: //HTIMEH case 0x4208: //HTIMEH
io.htime = (io.htime >> 2) - 1; io.htime = (io.htime >> 2) - 1;
io.htime = io.htime & 0x0ff | (data & 1) << 8; io.htime = io.htime & 0x0ff | (data & 1) << 8;
io.htime = (io.htime + 1) << 2; io.htime = (io.htime + 1) << 2;
pollIRQ(); //unverified
return; return;
case 0x4209: //VTIMEL case 0x4209: //VTIMEL
io.vtime = io.vtime & 0x100 | data << 0; io.vtime = io.vtime & 0x100 | data << 0;
pollIRQ(); //unverified
return; return;
case 0x420a: //VTIMEH case 0x420a: //VTIMEH
io.vtime = io.vtime & 0x0ff | (data & 1) << 8; io.vtime = io.vtime & 0x0ff | (data & 1) << 8;
pollIRQ(); //unverified
return; return;
case 0x420b: //DMAEN case 0x420b: //DMAEN

View File

@ -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. //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; //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. //it is used to emulate hardware communication delay between opcode and interrupt units.
auto CPU::pollInterrupts() -> void {
auto CPU::pollNMI() -> void {
//NMI hold //NMI hold
if(status.nmiHold.lower() && io.nmiEnable) { if(status.nmiHold.lower() && io.nmiEnable) {
status.nmiTransition = 1; status.nmiTransition = 1;
@ -13,7 +14,9 @@ auto CPU::pollInterrupts() -> void {
if(status.nmiValid.flip(vcounter(2) >= ppu.vdisp())) { if(status.nmiValid.flip(vcounter(2) >= ppu.vdisp())) {
if(status.nmiLine = status.nmiValid) status.nmiHold = 1; //hold /NMI for four cycles if(status.nmiLine = status.nmiValid) status.nmiHold = 1; //hold /NMI for four cycles
} }
}
auto CPU::pollIRQ() -> void {
//IRQ hold //IRQ hold
status.irqHold = 0; status.irqHold = 0;
if(status.irqLine && io.irqEnable) { if(status.irqLine && io.irqEnable) {

View File

@ -11,7 +11,7 @@ auto CPU::joypadCounter() const -> uint {
auto CPU::stepOnce() -> void { auto CPU::stepOnce() -> void {
counter.cpu += 2; counter.cpu += 2;
tick(); tick();
if(hcounter() & 2) pollInterrupts(); if(hcounter() & 2) pollNMI(), pollIRQ();
if(joypadCounter() == 0) joypadEdge(); if(joypadCounter() == 0) joypadEdge();
} }