From 330704a5e9ab9cd618667401402766e2e47112bb Mon Sep 17 00:00:00 2001 From: Gregory Hainaut Date: Thu, 12 Nov 2015 10:20:24 +0100 Subject: [PATCH] pcsx2: apply patch when first block is compiled Previous behavior apply the patch when first block is executed (it is already too late) V2: First tentative crash some games :( Fix #627 --- pcsx2/x86/ix86-32/iR5900-32.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/pcsx2/x86/ix86-32/iR5900-32.cpp b/pcsx2/x86/ix86-32/iR5900-32.cpp index 5e088c669f..34417a2ace 100644 --- a/pcsx2/x86/ix86-32/iR5900-32.cpp +++ b/pcsx2/x86/ix86-32/iR5900-32.cpp @@ -33,6 +33,7 @@ #include "Elfheader.h" #include "../DebugTools/Breakpoints.h" +#include "Patch.h" #if !PCSX2_SEH # include @@ -1739,8 +1740,17 @@ static void __fastcall recRecompile( const u32 startpc ) } // this is the only way patches get applied, doesn't depend on a hack - if (HWADDR(startpc) == ElfEntry) + if (HWADDR(startpc) == ElfEntry) { xCALL(eeGameStarting); + // Apply patch as soon as possible. Normally it is done in + // eeGameStarting but first block is already compiled. + // + // First tentative was to call eeGameStarting directly (not through the + // recompiler) but it crashes some games (GT4, DMC3). It is either a + // thread issue or linked to the various components reset. + if (EmuConfig.EnablePatches) ApplyPatch(0); + if (EmuConfig.EnableCheats) ApplyCheat(0); + } g_branch = 0;