diff --git a/core/hw/sh4/dyna/driver.cpp b/core/hw/sh4/dyna/driver.cpp index c3468badc..cdb125c9a 100644 --- a/core/hw/sh4/dyna/driver.cpp +++ b/core/hw/sh4/dyna/driver.cpp @@ -74,9 +74,6 @@ static void recSh4_Run() sh4_dyna_rcb=(u8*)&Sh4cntx + sizeof(Sh4cntx); INFO_LOG(DYNAREC, "cntx // fpcb offset: %td // pc offset: %td // pc %08X", (u8*)&sh4rcb.fpcb - sh4_dyna_rcb, (u8*)&sh4rcb.cntx.pc - sh4_dyna_rcb, sh4rcb.cntx.pc); - if (!settings.dynarec.safemode) - NOTICE_LOG(DYNAREC, "Warning: Dynarec safe mode is off"); - if (settings.dynarec.unstable_opt) NOTICE_LOG(DYNAREC, "Warning: Unstable optimizations is on"); diff --git a/core/hw/sh4/dyna/shil_canonical.h b/core/hw/sh4/dyna/shil_canonical.h index 1ce24e938..a50fa2044 100644 --- a/core/hw/sh4/dyna/shil_canonical.h +++ b/core/hw/sh4/dyna/shil_canonical.h @@ -103,8 +103,6 @@ extern "C" f32 fipr_asm(float* fn, float* fm); #include "decoder.h" #include "../sh4_rom.h" - - #define BIN_OP_I_BASE(code,type,rtype) \ shil_canonical \ ( \ @@ -611,35 +609,18 @@ shil_canonical ( u64,f1,(u32 r1, s32 r2, s32 r3), s64 dividend = ((s64)r3 << 32) | r1; - bool negative; - if ((r3 ^ r2) & 0x80000000) - { - // 1's complement -> 2's complement - if (dividend < 0) - dividend++; - negative = true; - } - else - negative = false; + // 1's complement -> 2's complement + if (dividend < 0) + dividend++; s32 quo = (s32)(dividend / r2); s32 rem = dividend - quo * r2; + u32 negative = (r3 ^ r2) & 0x80000000; // 2's complement -> 1's complement if (negative) - { - if (rem < 0 || (rem == 0 && r2 > 0)) - rem--; quo--; - } - else - { - // edge case - if (rem == 0 && dividend < 0 && !(quo & 1)) - { - quo--; - rem += r2; - } - } + else if (r3 < 0) + rem--; u64 rv; ((u32*)&rv)[0]=quo; @@ -671,6 +652,9 @@ u32,f1,(s32 a,s32 b,u32 T), } else { + // 2's complement -> 1's complement + if (b > 0) + a--; if (T & 1) a += b; } diff --git a/core/nullDC.cpp b/core/nullDC.cpp index 698cd22f4..b085cf1e8 100755 --- a/core/nullDC.cpp +++ b/core/nullDC.cpp @@ -712,7 +712,7 @@ void InitSettings() settings.dynarec.Enable = true; settings.dynarec.idleskip = true; settings.dynarec.unstable_opt = false; - settings.dynarec.safemode = true; + settings.dynarec.safemode = false; settings.dynarec.disable_vmem32 = false; settings.dreamcast.cable = 3; // TV composite settings.dreamcast.region = 3; // default diff --git a/core/rend/gui.cpp b/core/rend/gui.cpp index 0ec0e4840..7f4b8e5a6 100644 --- a/core/rend/gui.cpp +++ b/core/rend/gui.cpp @@ -1298,7 +1298,7 @@ static void gui_display_settings() { ImGui::Checkbox("Safe Mode", &settings.dynarec.safemode); ImGui::SameLine(); - ShowHelpMarker("Do not optimize integer division. Recommended"); + ShowHelpMarker("Do not optimize integer division. Not recommended"); #if HOST_CPU == CPU_ARM ImGui::Checkbox("Unstable Optimizations", &settings.dynarec.unstable_opt); ImGui::SameLine(); diff --git a/tests/src/div32_test.cpp b/tests/src/div32_test.cpp index 9a33f222b..2d421dcf5 100644 --- a/tests/src/div32_test.cpp +++ b/tests/src/div32_test.cpp @@ -210,6 +210,8 @@ TEST_F(Div32Test, Div32uTest) div32u(1867228769, 653467280, 0); div32u(1523687288, 32181601, 0); - div32u(3499805483, 1401792939, 29611); + div32u(3499805483u, 1401792939, 29611); + + div32u(0x80000000u, 0x80000000u, 0); }