From e854a759f8a1c66da933b32eccdcc3501b0582e0 Mon Sep 17 00:00:00 2001 From: Brandon Wright Date: Sat, 9 Mar 2019 17:16:54 -0600 Subject: [PATCH] Fix Chou Aniki. Remove hack. --- cpuexec.cpp | 9 +++++++-- cpuops.cpp | 4 ++-- memmap.cpp | 2 -- ppu.cpp | 3 +-- snes9x.h | 7 ++++--- 5 files changed, 14 insertions(+), 11 deletions(-) diff --git a/cpuexec.cpp b/cpuexec.cpp index cba037e7..cd2b1ba1 100644 --- a/cpuexec.cpp +++ b/cpuexec.cpp @@ -24,9 +24,14 @@ void S9xMainLoop (void) #define CHECK_FOR_IRQ_CHANGE() \ if (Timings.IRQFlagChanging) \ { \ - if (Timings.IRQFlagChanging == IRQ_CLEAR_FLAG) \ + if (Timings.IRQFlagChanging & IRQ_TRIGGER_NMI) \ + { \ + CPU.NMIPending = TRUE; \ + Timings.NMITriggerPos = CPU.Cycles + 6; \ + } \ + if (Timings.IRQFlagChanging & IRQ_CLEAR_FLAG) \ ClearIRQ(); \ - else if (Timings.IRQFlagChanging == IRQ_SET_FLAG) \ + else if (Timings.IRQFlagChanging & IRQ_SET_FLAG) \ SetIRQ(); \ Timings.IRQFlagChanging = IRQ_NONE; \ } diff --git a/cpuops.cpp b/cpuops.cpp index f200068b..b2342bae 100644 --- a/cpuops.cpp +++ b/cpuops.cpp @@ -1452,7 +1452,7 @@ static void Op58 (void) AddCycles(ONE_CYCLE); #ifndef SA1_OPCODES - Timings.IRQFlagChanging = IRQ_CLEAR_FLAG; + Timings.IRQFlagChanging |= IRQ_CLEAR_FLAG; #else ClearIRQ(); #endif @@ -1464,7 +1464,7 @@ static void Op78 (void) AddCycles(ONE_CYCLE); #ifndef SA1_OPCODES - Timings.IRQFlagChanging = IRQ_SET_FLAG; + Timings.IRQFlagChanging |= IRQ_SET_FLAG; #else SetIRQ(); #endif diff --git a/memmap.cpp b/memmap.cpp index 392efceb..7d18f2f9 100644 --- a/memmap.cpp +++ b/memmap.cpp @@ -3614,8 +3614,6 @@ void CMemory::ApplyROMFixes (void) { //if (match_id("AVCJ")) // Rendering Ranger R2 // Timings.APUSpeedup = 2; - if (match_id("AANJ")) // Chou Aniki - Timings.APUSpeedup = -3; if (match_na("CIRCUIT USA")) Timings.APUSpeedup = 3; diff --git a/ppu.cpp b/ppu.cpp index 6bca9dc4..50446f3f 100644 --- a/ppu.cpp +++ b/ppu.cpp @@ -1403,8 +1403,7 @@ void S9xSetCPU (uint8 Byte, uint16 Address) { // FIXME: triggered at HC+=6, checked just before the final CPU cycle, // then, when to call S9xOpcode_NMI()? - CPU.NMIPending = TRUE; - Timings.NMITriggerPos = CPU.Cycles + 6 + 6; + Timings.IRQFlagChanging |= IRQ_TRIGGER_NMI; #ifdef DEBUGGER if (Settings.TraceHCEvent) diff --git a/snes9x.h b/snes9x.h index e096a1de..82d3aaf3 100644 --- a/snes9x.h +++ b/snes9x.h @@ -157,9 +157,10 @@ enum enum { - IRQ_NONE = 0, - IRQ_SET_FLAG = 1, - IRQ_CLEAR_FLAG = 2 + IRQ_NONE = 0x0, + IRQ_SET_FLAG = 0x1, + IRQ_CLEAR_FLAG = 0x2, + IRQ_TRIGGER_NMI = 0x4 }; struct STimings