From 315205caa9493ed36a2be718c30fe26e1ec7c2e3 Mon Sep 17 00:00:00 2001 From: Flyinghead Date: Fri, 6 Jul 2018 09:49:39 +0200 Subject: [PATCH] Add setting to disable div32 matching (Pro Pinball Trilogy) div32 matching doesn't handle division by zero and edge cases, which causes crashes with some games. Setting enabled by default for Pro Pinball Trilogy. --- core/hw/sh4/dyna/decoder.cpp | 8 +++++++- core/nullDC.cpp | 4 ++++ core/types.h | 1 + 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/core/hw/sh4/dyna/decoder.cpp b/core/hw/sh4/dyna/decoder.cpp index bd547cc97..acb046512 100644 --- a/core/hw/sh4/dyna/decoder.cpp +++ b/core/hw/sh4/dyna/decoder.cpp @@ -694,6 +694,9 @@ u32 MatchDiv32(u32 pc , Sh4RegType ®1,Sh4RegType ®2 , Sh4RegType ®3) } bool MatchDiv32u(u32 op,u32 pc) { + if (settings.dynarec.DisableDivMatching) + return false; + div_som_reg1=NoReg; div_som_reg2=NoReg; div_som_reg3=NoReg; @@ -713,6 +716,9 @@ bool MatchDiv32u(u32 op,u32 pc) bool MatchDiv32s(u32 op,u32 pc) { + if (settings.dynarec.DisableDivMatching) + return false; + u32 n = GetN(op); u32 m = GetM(op); @@ -1219,4 +1225,4 @@ _end: blk=0; } -#endif \ No newline at end of file +#endif diff --git a/core/nullDC.cpp b/core/nullDC.cpp index ea22174d6..196ca36ef 100755 --- a/core/nullDC.cpp +++ b/core/nullDC.cpp @@ -178,6 +178,9 @@ void LoadSpecialSettings() settings.aica.EGHack = 1; break; } + if (!strncmp("T30701D", reios_product_number, 7)) + // Pro Pinball Trilogy + settings.dynarec.DisableDivMatching = true; } int dc_init(int argc,wchar* argv[]) @@ -291,6 +294,7 @@ void LoadSettings() settings.dynarec.Enable = cfgLoadInt("config","Dynarec.Enabled", 1)!=0; settings.dynarec.idleskip = cfgLoadInt("config","Dynarec.idleskip",1)!=0; settings.dynarec.unstable_opt = cfgLoadInt("config","Dynarec.unstable-opt",0); + settings.dynarec.DisableDivMatching = cfgLoadInt("config", "Dynarec.DisableDivMatching", 0); //disable_nvmem can't be loaded, because nvmem init is before cfg load settings.dreamcast.cable = cfgLoadInt("config","Dreamcast.Cable",3); settings.dreamcast.RTC = cfgLoadInt("config","Dreamcast.RTC",GetRTC_now()); diff --git a/core/types.h b/core/types.h index 2dd52ceea..0c62273a3 100644 --- a/core/types.h +++ b/core/types.h @@ -628,6 +628,7 @@ struct settings_t bool idleskip; bool unstable_opt; bool disable_nvmem; + bool DisableDivMatching; } dynarec; struct