From d435282a8baf427da2fc301340e18b50883cb0d5 Mon Sep 17 00:00:00 2001 From: KeybadeBlox Date: Tue, 17 Feb 2026 10:27:50 -0500 Subject: [PATCH] Compile XDK code as C It appears to be all C code (especially the non-C++ parts of the C runtime, of course), so we'll compile it as such. --- decompile/Makefile | 10 ++++++---- decompile/src/JSRF/Core.hpp | 4 ++-- decompile/src/JSRF/GameData.cpp | 2 +- decompile/src/JSRF/GameData.hpp | 2 +- decompile/src/Smilebit/MMatrix.cpp | 2 +- decompile/src/Smilebit/MMatrix.hpp | 2 +- decompile/src/XDK/CRT/{CRT0.cpp => CRT0.c} | 12 ++++++------ decompile/src/XDK/{D3D.hpp => D3D.h} | 19 +++++++++++++++---- decompile/src/XDK/{Win32.hpp => Win32.h} | 18 +++++++++++++++--- 9 files changed, 48 insertions(+), 23 deletions(-) rename decompile/src/XDK/CRT/{CRT0.cpp => CRT0.c} (74%) rename decompile/src/XDK/{D3D.hpp => D3D.h} (55%) rename decompile/src/XDK/{Win32.hpp => Win32.h} (89%) diff --git a/decompile/Makefile b/decompile/Makefile index 8691d92..0be07a0 100644 --- a/decompile/Makefile +++ b/decompile/Makefile @@ -31,17 +31,19 @@ src/JSRF/Jet2.exe: $(OBJ) $(LIB) LIB.EXE /NOLOGO /MACHINE:X86 /DEF:$< /OUT:$@ # Compile object files from source +.c.obj: + CL.EXE /nologo /Wall /W4 /Ogityb0 /GfX /Fo$@ /c $< .cpp.obj: CL.EXE /nologo /Wall /W4 /Ogityb0 /GfX /Fo$@ /c $< # Header files used for each object -src/JSRF/Jet2.obj: src/JSRF/Core.hpp src/Std.hpp src/XDK/D3D.hpp\ - src/XDK/Win32.hpp +src/JSRF/Jet2.obj: src/JSRF/Core.hpp src/Std.hpp src/XDK/D3D.h\ + src/XDK/Win32.h src/JSRF/Core.obj: src/JSRF/Core.hpp src/Smilebit/MMatrix.hpp src/Std.hpp\ - src/XDK/D3D.hpp src/XDK/Win32.hpp + src/XDK/D3D.h src/XDK/Win32.h src/JSRF/GameData.obj: src/JSRF/GameData.hpp -src/XDK/CRT/CRT0.obj: src/XDK/Win32.hpp +src/XDK/CRT/CRT0.obj: src/XDK/Win32.h diff --git a/decompile/src/JSRF/Core.hpp b/decompile/src/JSRF/Core.hpp index 7d4f490..984d5fd 100644 --- a/decompile/src/JSRF/Core.hpp +++ b/decompile/src/JSRF/Core.hpp @@ -7,8 +7,8 @@ Game and GameObj classes that form the foundation of the JSRF game code. #include "../Smilebit/MMatrix.hpp" #include "../Std.hpp" -#include "../XDK/D3D.hpp" -#include "../XDK/Win32.hpp" +#include "../XDK/D3D.h" +#include "../XDK/Win32.h" // TODO; move to header for Graphics COM object in Smilebit libraries diff --git a/decompile/src/JSRF/GameData.cpp b/decompile/src/JSRF/GameData.cpp index e9bba24..0efbbbc 100644 --- a/decompile/src/JSRF/GameData.cpp +++ b/decompile/src/JSRF/GameData.cpp @@ -4,7 +4,7 @@ Save data and closely-related runtime data. #pragma bss_seg(".data") -#include "../XDK/Win32.hpp" +#include "../XDK/Win32.h" #include "GameData.hpp" diff --git a/decompile/src/JSRF/GameData.hpp b/decompile/src/JSRF/GameData.hpp index 75f3e65..0169de2 100644 --- a/decompile/src/JSRF/GameData.hpp +++ b/decompile/src/JSRF/GameData.hpp @@ -5,7 +5,7 @@ Save data and closely-related runtime data. #ifndef GAMEDATA_HPP #define GAMEDATA_HPP -#include "../XDK/Win32.hpp" +#include "../XDK/Win32.h" // Data structure actually saved to disk diff --git a/decompile/src/Smilebit/MMatrix.cpp b/decompile/src/Smilebit/MMatrix.cpp index 83b8e07..1bc46d9 100644 --- a/decompile/src/Smilebit/MMatrix.cpp +++ b/decompile/src/Smilebit/MMatrix.cpp @@ -7,7 +7,7 @@ Smilebit's stack-based matrix math library. #include "../Std.hpp" -#include "../XDK/Win32.hpp" +#include "../XDK/Win32.h" #include "MMatrix.hpp" diff --git a/decompile/src/Smilebit/MMatrix.hpp b/decompile/src/Smilebit/MMatrix.hpp index 788740e..9d7354d 100644 --- a/decompile/src/Smilebit/MMatrix.hpp +++ b/decompile/src/Smilebit/MMatrix.hpp @@ -5,7 +5,7 @@ Smilebit's stack-based matrix math library. #ifndef MMATRIX_HPP #define MMATRIX_HPP -#include "../XDK/D3D.hpp" +#include "../XDK/D3D.h" // 4x4 matrix type diff --git a/decompile/src/XDK/CRT/CRT0.cpp b/decompile/src/XDK/CRT/CRT0.c similarity index 74% rename from decompile/src/XDK/CRT/CRT0.cpp rename to decompile/src/XDK/CRT/CRT0.c index 729e597..bcaf52d 100644 --- a/decompile/src/XDK/CRT/CRT0.cpp +++ b/decompile/src/XDK/CRT/CRT0.c @@ -1,24 +1,24 @@ -/* JSRF Decompilation: XDK/CRT0.cpp +/* JSRF Decompilation: XDK/CRT0.c C runtime initialization. Like other CRT code, there's some magic here with symbols that get special treatment from the compiler and linker. */ -#include "../Win32.hpp" +#include "../Win32.h" // Every program is supposed to have a main(), so we can just assume its // existence with a declaration here -int main(); +int main(void); - void __cdecl mainCRTStartup (); -static DWORD __stdcall mainXapiStartup(LPVOID lpThreadParameter); +void __cdecl mainCRTStartup (void); +DWORD __stdcall mainXapiStartup(LPVOID lpThreadParameter); // Address: 0x00148023 // Matching: no -void __cdecl mainCRTStartup() { +void __cdecl mainCRTStartup(void) { /* The true entrypoint of the game, spawning a thread for the rest to run in The linker automatically sets this function to the entrypoint. */ diff --git a/decompile/src/XDK/D3D.hpp b/decompile/src/XDK/D3D.h similarity index 55% rename from decompile/src/XDK/D3D.hpp rename to decompile/src/XDK/D3D.h index cea0682..325035f 100644 --- a/decompile/src/XDK/D3D.hpp +++ b/decompile/src/XDK/D3D.h @@ -1,11 +1,16 @@ -/* JSRF Decompilation: XDK/D3D.hpp +/* JSRF Decompilation: XDK/D3D.h Direct3D8 declarations. */ -#ifndef D3D_HPP -#define D3D_HPP +#ifndef D3D_H +#define D3D_H -#include "Win32.hpp" +#include "Win32.h" + + +#ifdef __cplusplus +extern "C" { +#endif typedef DWORD D3DCOLOR; @@ -21,4 +26,10 @@ struct D3DRECT { LONG x1, y1, x2, y2; }; + +#ifdef __cplusplus +} +#endif + + #endif diff --git a/decompile/src/XDK/Win32.hpp b/decompile/src/XDK/Win32.h similarity index 89% rename from decompile/src/XDK/Win32.hpp rename to decompile/src/XDK/Win32.h index ab72d1f..8bb6546 100644 --- a/decompile/src/XDK/Win32.hpp +++ b/decompile/src/XDK/Win32.h @@ -1,9 +1,15 @@ -/* JSRF Decompilation: XDK/Win32.hpp +/* JSRF Decompilation: XDK/Win32.h Definitions normally provided by Windows headers. */ -#ifndef WIN32_HPP -#define WIN32_HPP +#ifndef WIN32_H +#define WIN32_H + + +#ifdef __cplusplus +extern "C" { +#endif + // The famous Win32 typedefs typedef unsigned char UCHAR; @@ -55,4 +61,10 @@ LPVOID __stdcall VirtualAlloc( DWORD flProtect ); + +#ifdef __cplusplus +} +#endif + + #endif