diff --git a/pcsx2/Interpreter.cpp b/pcsx2/Interpreter.cpp index c6b557d251..49287200d1 100644 --- a/pcsx2/Interpreter.cpp +++ b/pcsx2/Interpreter.cpp @@ -391,10 +391,17 @@ static void intExecute() static void intExecuteBiosStub() { g_EEFreezeRegs = false; - Console.WriteLn( Color_StrongGreen, "(R5900-Interp) Executing Bios Stub..." ); - while( (cpuRegs.pc != 0x00200008) && (cpuRegs.pc != 0x00100008) ) { - execI(); - } + + // We need to be weary of events that could occur during vsyncs, which means + // making sure to exit this function for ExitCpuExecute. The calling function + // will update UI status, and then re-enter if the bios stub execution criteria + // wasn't met yet. + + try { + while( (cpuRegs.pc != 0x00200008) && (cpuRegs.pc != 0x00100008) ) { + execI(); + } + } catch( Exception::ExitCpuExecute& ) { } // ... some maual bios injection hack from a century ago, me thinks. Leaving the // code intact for posterity. --air @@ -409,8 +416,6 @@ static void intExecuteBiosStub() // fwrite(PS2MEM_PSX, 0x80000, 1, f); // fclose(f); // } - - Console.WriteLn( Color_StrongGreen, "(R5900-Interp) Execute Bios Stub Complete"); } static void intCheckExecutionState() diff --git a/pcsx2/System/SysCoreThread.cpp b/pcsx2/System/SysCoreThread.cpp index e1c033b016..23d995fe7f 100644 --- a/pcsx2/System/SysCoreThread.cpp +++ b/pcsx2/System/SysCoreThread.cpp @@ -249,7 +249,7 @@ void SysCoreThread::_reset_stuff_as_needed() } if( m_resetVsyncTimers ) - { +{ UpdateVSyncRate(); frameLimitReset(); m_resetVsyncTimers = false; @@ -313,7 +313,19 @@ void SysCoreThread::CpuInitializeMess() // effects). SetCPUState( EmuConfig.Cpu.sseMXCSR, EmuConfig.Cpu.sseVUMXCSR ); - Cpu->ExecuteBiosStub(); + + Console.WriteLn( Color_StrongGreen, "(PCSX2 Core) Executing Bios Stub..." ); + + do { + // Even the BiosStub invokes vsyncs, so we need to be weary of state + // changes and premature loop exits, and re-enter the stub executer until + // the critera is met. + + StateCheckInThread(); + Cpu->ExecuteBiosStub(); + } while( cpuRegs.pc != 0x00200008 && cpuRegs.pc != 0x00100008 ); + + Console.WriteLn( Color_StrongGreen, "(PCSX2 Core) Execute Bios Stub Complete"); loadElfFile( elf_file ); } diff --git a/pcsx2/x86/ix86-32/iR5900-32.cpp b/pcsx2/x86/ix86-32/iR5900-32.cpp index 8bfc45bbf0..1ac4733ced 100644 --- a/pcsx2/x86/ix86-32/iR5900-32.cpp +++ b/pcsx2/x86/ix86-32/iR5900-32.cpp @@ -735,16 +735,9 @@ static void recExecute() static void recExecuteBiosStub() { - Console.WriteLn( Color_StrongGreen, "(R5900-32) Executing Bios Stub..." ); g_ExecBiosHack = true; - recExecute(); - pxAssertDev( cpuRegs.pc == 0x00200008 || cpuRegs.pc == 0x00100008, - "Bios stub execution terminated on an abnormal address." - ); - g_ExecBiosHack = false; - Console.WriteLn( Color_StrongGreen, "(R5900-32) Execute Bios Stub Complete"); // Reset the EErecs here, because the bios generates "slow" blocks that have // g_ExecBiosHack checks in them. This deletes them so that the recs replace them