From 68fc776fa7fef38588ec7296fa2ee08145ad211d Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Sun, 4 Oct 2015 10:32:15 +0200 Subject: [PATCH] Work around some crashes I got trying to load a GTA:LCS savestate from 2014. However, the savestate still loads to a black screen, although background audio is working. --- Core/HLE/sceGe.cpp | 5 +++++ Core/MIPS/x86/Jit.cpp | 12 ++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/Core/HLE/sceGe.cpp b/Core/HLE/sceGe.cpp index fc676eb5d7..e3451286c3 100644 --- a/Core/HLE/sceGe.cpp +++ b/Core/HLE/sceGe.cpp @@ -66,6 +66,11 @@ public: GeIntrHandler() : IntrHandler(PSP_GE_INTR) {} bool run(PendingInterrupt& pend) override { + if (ge_pending_cb.empty()) { + ERROR_LOG_REPORT(SCEGE, "Unable to run GE interrupt: no pending interrupt"); + return false; + } + GeInterruptData intrdata = ge_pending_cb.front(); DisplayList* dl = gpu->getList(intrdata.listid); diff --git a/Core/MIPS/x86/Jit.cpp b/Core/MIPS/x86/Jit.cpp index e381efc04e..de02a2802e 100644 --- a/Core/MIPS/x86/Jit.cpp +++ b/Core/MIPS/x86/Jit.cpp @@ -603,15 +603,23 @@ void Jit::Comp_ReplacementFunc(MIPSOpcode op) } } + // Hack for old savestates: Avoid stack overflow (MIPSCompileOp/CompReplacementFunc) + // Not sure about the cause. + Memory::Opcode origInstruction = Memory::Read_Instruction(GetCompilerPC(), true); + if (origInstruction.encoding == op.encoding) { + ERROR_LOG(HLE, "Replacement broken (savestate problem?): %08x", op.encoding); + return; + } + if (disabled) { - MIPSCompileOp(Memory::Read_Instruction(GetCompilerPC(), true)); + MIPSCompileOp(origInstruction); } else if (entry->jitReplaceFunc) { MIPSReplaceFunc repl = entry->jitReplaceFunc; int cycles = (this->*repl)(); if (entry->flags & (REPFLAG_HOOKENTER | REPFLAG_HOOKEXIT)) { // Compile the original instruction at this address. We ignore cycles for hooks. - MIPSCompileOp(Memory::Read_Instruction(GetCompilerPC(), true)); + MIPSCompileOp(origInstruction); } else { FlushAll(); MOV(32, R(ECX), M(&mips_->r[MIPS_REG_RA]));