From f1cab4ab17c349eeda8b0ce865e4107dab313200 Mon Sep 17 00:00:00 2001 From: Brandon Wright Date: Sat, 19 May 2018 10:33:26 -0500 Subject: [PATCH] Change NextTimer to NextIRQTimer. Don't subtract a dot in interlaced mode. --- cpu.cpp | 2 +- cpuexec.cpp | 6 +++--- ppu.cpp | 10 +++++----- snes9x.h | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/cpu.cpp b/cpu.cpp index 94057dc1..deebd154 100644 --- a/cpu.cpp +++ b/cpu.cpp @@ -266,7 +266,7 @@ static void S9xSoftResetCPU (void) Timings.H_Max = Timings.H_Max_Master; Timings.V_Max = Timings.V_Max_Master; Timings.NMITriggerPos = 0xffff; - Timings.NextTimer = 0xffff; + Timings.NextIRQTimer = 0xffff; if (Model->_5A22 == 2) Timings.WRAMRefreshPos = SNES_WRAM_REFRESH_HC_v2; else diff --git a/cpuexec.cpp b/cpuexec.cpp index ec23fd3e..687634c1 100644 --- a/cpuexec.cpp +++ b/cpuexec.cpp @@ -229,7 +229,7 @@ void S9xMainLoop (void) } } - if (CPU.Cycles >= Timings.NextTimer || CPU.IRQExternal) + if (CPU.Cycles >= Timings.NextIRQTimer || CPU.IRQExternal) { if (CPU.IRQPending) CPU.IRQPending--; @@ -417,8 +417,8 @@ void S9xDoHEventProcessing (void) CPU.Cycles -= Timings.H_Max; if (Timings.NMITriggerPos != 0xffff) Timings.NMITriggerPos -= Timings.H_Max; - if (Timings.NextTimer != 0xffff) - Timings.NextTimer -= Timings.H_Max; + if (Timings.NextIRQTimer != 0xffff) + Timings.NextIRQTimer -= Timings.H_Max; S9xAPUSetReferenceTime(CPU.Cycles); CPU.V_Counter++; diff --git a/ppu.cpp b/ppu.cpp index 8bfd5a96..b7c44007 100644 --- a/ppu.cpp +++ b/ppu.cpp @@ -288,17 +288,17 @@ static int CyclesUntilNext (int hc, int vc) // Add number of lines total += (vc - vpos) * Timings.H_Max; // If line 240 is in there and we're odd, subtract a dot - if (vpos <= 240 && vc > 240 && Timings.InterlaceField) + if (vpos <= 240 && vc > 240 && Timings.InterlaceField & !IPPU.Interlace) total -= ONE_DOT_CYCLE; } else { total += (Timings.V_Max - vpos) * Timings.H_Max; - if (vpos <= 240 && Timings.InterlaceField) + if (vpos <= 240 && Timings.InterlaceField && !IPPU.Interlace) total -= ONE_DOT_CYCLE; total += (vc) * Timings.H_Max; - if (vc > 240 && !Timings.InterlaceField) + if (vc > 240 && !Timings.InterlaceField && !IPPU.Interlace) total -= ONE_DOT_CYCLE; } @@ -329,11 +329,11 @@ void S9xUpdateIRQPositions (void) if (!PPU.HTimerEnabled && !PPU.VTimerEnabled) { - Timings.NextTimer = 0xffff; + Timings.NextIRQTimer = 0xffff; } else { - Timings.NextTimer = + Timings.NextIRQTimer = CyclesUntilNext (PPU.HTimerEnabled ? PPU.HTimerPosition : 0, PPU.VTimerEnabled ? PPU.VTimerPosition : 0); } diff --git a/snes9x.h b/snes9x.h index 1bf0f778..c41b129c 100644 --- a/snes9x.h +++ b/snes9x.h @@ -346,7 +346,7 @@ struct STimings int32 HDMAInit; int32 HDMAStart; int32 NMITriggerPos; - int32 NextTimer; + int32 NextIRQTimer; int32 IRQTriggerCycles; int32 WRAMRefreshPos; int32 RenderPos;