From 7f7553bef25fa9f0f5a0f69b3d7a58527cc3ee97 Mon Sep 17 00:00:00 2001 From: Clownacy Date: Thu, 5 Sep 2019 17:04:07 +0100 Subject: [PATCH] An accuracy improvement in Triangle.cpp This one's weird: it doesn't affect the actual generation of ASM in the function, but rather it affects the ASM of sinf and cosf. You see, sinf and cosf are static - they're built right into the EXE. Since the previous code used cosf and sinf, they were embedded into the EXE, and InitTriangleTable would call them directly. However, this isn't what the original EXE does: instead, InitTriangleTable calls an intermediary function, that in turn calls the real cosf and sinf. Turns out this strange code generation is caused by calling cos and sin instead of cosf and sinf, but still using float parameters. --- src/Triangle.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Triangle.cpp b/src/Triangle.cpp index e5290d9d..f5e4b9e6 100644 --- a/src/Triangle.cpp +++ b/src/Triangle.cpp @@ -21,7 +21,7 @@ void InitTriangleTable() for (i = 0; i < 0x21; ++i) { a = (float)(i * 6.2831855f / 256.0f); - b = sinf(a) / cosf(a); + b = sin(a) / cos(a); gTan[i] = (short)(b * 8192.0f); } }