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.
This commit is contained in:
Clownacy 2019-09-05 17:04:07 +01:00
parent af7d8222a8
commit 7f7553bef2

View file

@ -21,7 +21,7 @@ void InitTriangleTable()
for (i = 0; i < 0x21; ++i) for (i = 0; i < 0x21; ++i)
{ {
a = (float)(i * 6.2831855f / 256.0f); a = (float)(i * 6.2831855f / 256.0f);
b = sinf(a) / cosf(a); b = sin(a) / cos(a);
gTan[i] = (short)(b * 8192.0f); gTan[i] = (short)(b * 8192.0f);
} }
} }