From 34bc1d90ec1b9153718a3cbb52ea416aee22e3e3 Mon Sep 17 00:00:00 2001 From: loserkidsblink <136970488+loserkidsblink@users.noreply.github.com> Date: Sat, 7 Nov 2026 20:14:22 -0500 Subject: [PATCH] Match mt_common.cpp --- config/RSBE01_02/splits.txt | 4 ++++ configure.py | 1 + src/sora/mt/mt_common.cpp | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+) create mode 100644 src/sora/mt/mt_common.cpp diff --git a/config/RSBE01_02/splits.txt b/config/RSBE01_02/splits.txt index 6dfc754131..b88f574b8c 100644 --- a/config/RSBE01_02/splits.txt +++ b/config/RSBE01_02/splits.txt @@ -137,6 +137,10 @@ sora/gf/gf_monitor.cpp: sora/gf/gf_resource_loader.cpp: .text start:0x8003D864 end:0x8003DB08 +sora/mt/mt_common.cpp: + .text start:0x8003DB08 end:0x8003DBA8 + .sdata2 start:0x805A16F8 end:0x805A1708 + sora/mt/mt_vector.cpp: .text start:0x8003DBA8 end:0x8003E244 .sdata2 start:0x805A1708 end:0x805A1728 diff --git a/configure.py b/configure.py index a389e75427..a00a2e6606 100755 --- a/configure.py +++ b/configure.py @@ -886,6 +886,7 @@ def NW4RObject(completed, name, **options): Object(Matching, "sora/gf/gf_capture_util.cpp"), Object(Matching, "sora/gf/gf_monitor.cpp"), Object(Matching, "sora/gf/gf_resource_loader.cpp"), + Object(Matching, "sora/mt/mt_common.cpp"), Object(Matching, "sora/mt/mt_vector.cpp"), Object(Matching, "sora/mt/mt_vector_old.cpp"), Object(Matching, "sora/mt/mt_prng.cpp", extra_cflags=["-RTTI off"]), diff --git a/src/sora/mt/mt_common.cpp b/src/sora/mt/mt_common.cpp new file mode 100644 index 0000000000..c540d75d37 --- /dev/null +++ b/src/sora/mt/mt_common.cpp @@ -0,0 +1,36 @@ +#include +#include +#include + +float mtSqrtf(register float x) { + if (x > 0.0f) { + register float y; +#ifdef MATCHING + asm { + frsqrte y, x + } +#else + y = 1.0f / sqrtf(x); +#endif + y = 0.5f * y * (3.0f - x * (y * y)); + y = 0.5f * y * (3.0f - x * (y * y)); + return y * x; + } + return 0.0f; +} + +float rsqrtf(register float x) { + if (x < FLT_EPSILON) + return 0.0f; + register float y; +#ifdef MATCHING + asm { + frsqrte y, x + } +#else + y = 1.0f / sqrtf(x); +#endif + y = 0.5f * y * (3.0f - x * (y * y)); + y = 0.5f * y * (3.0f - x * (y * y)); + return y; +}