ref: 7f7553bef25fa9f0f5a0f69b3d7a58527cc3ee97
parent: af7d8222a8d3b316e257b86492f98fff7b841cb0
author: Clownacy <Clownacy@users.noreply.github.com>
date: Thu Sep 5 13:04:07 EDT 2019
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.
--- a/src/Triangle.cpp
+++ b/src/Triangle.cpp
@@ -21,7 +21,7 @@
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);
}
}