From af7d8222a8d3b316e257b86492f98fff7b841cb0 Mon Sep 17 00:00:00 2001 From: Clownacy Date: Thu, 5 Sep 2019 16:42:16 +0100 Subject: [PATCH 1/2] The EXE now has its functions in the exact same order as the original This is crazy. So, MSVC2003 always links the source files in alphabetical order, but for some reason the original EXE ends with the NPC and boss files. Cucky figured out why: Pixel used folders in his Visual Studio project - one for NPC code, and one for boss code. With this, the built EXE now has its functions in the exact same order as the original. Hell yeah. I guess now we just have to figure out how to get the variables in the correct order. --- CSE2.vcproj | 200 +++++++++++++++++++++++++++------------------------- 1 file changed, 104 insertions(+), 96 deletions(-) diff --git a/CSE2.vcproj b/CSE2.vcproj index 44194eeb..35ef009c 100644 --- a/CSE2.vcproj +++ b/CSE2.vcproj @@ -229,39 +229,6 @@ - - - - - - - - - - - - - - - - - - - - - - @@ -334,69 +301,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -430,6 +334,110 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Date: Thu, 5 Sep 2019 17:04:07 +0100 Subject: [PATCH 2/2] 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); } }