From 2063303a4d981c7d8f15cd38e59fce3214a3421b Mon Sep 17 00:00:00 2001 From: gm-matthew <108370479+gm-matthew@users.noreply.github.com> Date: Tue, 22 Nov 2022 01:43:38 +0000 Subject: [PATCH] Wait until IRQ2 is acknowledged before starting IRQ40 sequence. Fixes Ski Champ hanging at FBI screen when region set to USA --- Src/Model3/Model3.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Src/Model3/Model3.cpp b/Src/Model3/Model3.cpp index ca2e7ce..bff690e 100644 --- a/Src/Model3/Model3.cpp +++ b/Src/Model3/Model3.cpp @@ -2041,10 +2041,9 @@ void CModel3::RunMainBoardFrame(void) // Compute display and VBlank timings unsigned ppcCycles = m_config["PowerPCFrequency"].ValueAs() * 1000000; unsigned frameCycles = (unsigned)((float)ppcCycles / 57.524160f); - unsigned gapCycles = (unsigned)((float)frameCycles * 2.5f / 100.0f); // we need a gap between asserting irq2 & irq 0x40 - unsigned offsetCycles = (unsigned)((float)frameCycles * 33.f / 100.0f); - unsigned dispCycles = frameCycles - gapCycles - offsetCycles; - unsigned statusCycles = (unsigned)((float)frameCycles * (0.005f)); + unsigned offsetCycles = (unsigned)((float)frameCycles * 33.f / 100.0f); + unsigned dispCycles = frameCycles - offsetCycles; + unsigned statusCycles = (unsigned)((float)frameCycles * (0.005f)); // we think a frame looks like this on the model 2 // 66% of frame @@ -2069,7 +2068,13 @@ void CModel3::RunMainBoardFrame(void) ppc_execute(offsetCycles); IRQ.Assert(0x02); // start at 33% of the frame - ppc_execute(gapCycles); // need a gap between asserting irqs + + // keep running cycles until IRQ2 is acknowledged + while (IRQ.ReadIRQEnable() & 0x2 && IRQ.ReadIRQState() & 0x2 && dispCycles > 1000) + { + ppc_execute(1000); + dispCycles -= 1000; + } /* * Sound: