about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorYang Liu <numbksco@gmail.com>2025-10-22 03:02:06 +0800
committerGitHub <noreply@github.com>2025-10-21 21:02:06 +0200
commit6c1fce4a014c1395ceaf1ca3eb34b85a8b2f3d9b (patch)
tree056553f96663f068b94408f2b59931fb6cf358c4
parent79efa2d8e57106afe488af4dd394e66ae579f155 (diff)
downloadbox64-6c1fce4a014c1395ceaf1ca3eb34b85a8b2f3d9b.tar.gz
box64-6c1fce4a014c1395ceaf1ca3eb34b85a8b2f3d9b.zip
[DYNAREC] Fixed native_fprem/native_fprem1 (fixed the camera issue of FlatOut/FlatOut2) (#3083)
-rw-r--r--src/dynarec/dynarec_native_functions.c47
1 files changed, 12 insertions, 35 deletions
diff --git a/src/dynarec/dynarec_native_functions.c b/src/dynarec/dynarec_native_functions.c
index d0a20b1c..8b72233e 100644
--- a/src/dynarec/dynarec_native_functions.c
+++ b/src/dynarec/dynarec_native_functions.c
@@ -80,24 +80,12 @@ void native_fxtract(x64emu_t* emu)
 }
 void native_fprem(x64emu_t* emu)
 {
-    int e0, e1;
-    int64_t ll;
-    frexp(ST0.d, &e0);
-    frexp(ST1.d, &e1);
-    int32_t tmp32s = e0 - e1;
-    if(tmp32s<64)
-    {
-        ll = (int64_t)floor(ST0.d/ST1.d);
-        ST0.d = ST0.d - (ST1.d*ll);
-        emu->sw.f.F87_C2 = 0;
-        emu->sw.f.F87_C1 = (ll&1)?1:0;
-        emu->sw.f.F87_C3 = (ll&2)?1:0;
-        emu->sw.f.F87_C0 = (ll&4)?1:0;
-    } else {
-        ll = (int64_t)(floor((ST0.d/ST1.d))/exp2(tmp32s - 32));
-        ST0.d = ST0.d - ST1.d*ll*exp2(tmp32s - 32);
-        emu->sw.f.F87_C2 = 1;
-    }
+    int64_t ll = (int64_t)trunc(ST0.d / ST1.d);
+    ST0.d = ST0.d - (ST1.d * ll);
+    emu->sw.f.F87_C2 = 0;
+    emu->sw.f.F87_C1 = (ll & 1) ? 1 : 0;
+    emu->sw.f.F87_C3 = (ll & 2) ? 1 : 0;
+    emu->sw.f.F87_C0 = (ll & 4) ? 1 : 0;
 }
 void native_fyl2xp1(x64emu_t* emu)
 {
@@ -284,23 +272,12 @@ void native_frstor16(x64emu_t* emu, uint8_t* ed)
 void native_fprem1(x64emu_t* emu)
 {
     int e0, e1;
-    int64_t ll;
-    frexp(ST0.d, &e0);
-    frexp(ST1.d, &e1);
-    int32_t tmp32s = e0 - e1;
-    if(tmp32s<64)
-    {
-        ll = (int64_t)round(ST0.d/ST1.d);
-        ST0.d = ST0.d - (ST1.d*ll);
-        emu->sw.f.F87_C2 = 0;
-        emu->sw.f.F87_C1 = (ll&1)?1:0;
-        emu->sw.f.F87_C3 = (ll&2)?1:0;
-        emu->sw.f.F87_C0 = (ll&4)?1:0;
-    } else {
-        ll = (int64_t)(trunc((ST0.d/ST1.d))/exp2(tmp32s - 32));
-        ST0.d = ST0.d - ST1.d*ll*exp2(tmp32s - 32);
-        emu->sw.f.F87_C2 = 1;
-    }
+    int64_t ll = (int64_t)round(ST0.d / ST1.d);
+    ST0.d = ST0.d - (ST1.d * ll);
+    emu->sw.f.F87_C2 = 0;
+    emu->sw.f.F87_C1 = (ll & 1) ? 1 : 0;
+    emu->sw.f.F87_C3 = (ll & 2) ? 1 : 0;
+    emu->sw.f.F87_C0 = (ll & 4) ? 1 : 0;
 }
 
 const uint8_t ff_mult2[4][256] = {