diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a8dca6f --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.obj diff --git a/objdiff/Makefile b/objdiff/Makefile new file mode 100644 index 0000000..165c483 --- /dev/null +++ b/objdiff/Makefile @@ -0,0 +1,10 @@ +all: src/Jet2.obj + +# Simple inference rule for producing object files +.SUFFIXES: .cpp .obj +.cpp.obj: + CL.EXE /nologo /Wall /TP /W3 /O2 /G6 /MT /GX /Fo$@ /c $< + +# Header files used for each object +src/Jet2.obj: src/Core.hpp src/D3D.hpp src/MMatrix.hpp src/Std.hpp\ + src/Win32.hpp diff --git a/objdiff/objdiff.json b/objdiff/objdiff.json new file mode 100644 index 0000000..a0b3221 --- /dev/null +++ b/objdiff/objdiff.json @@ -0,0 +1,22 @@ +{ + "custom_make": "NMAKE.EXE", + "watch_patterns": [ + "*.cpp", + "*.hpp" + ], + "units": [ + { + "name": "Jet2", + "target_path": "target/Jet2.obj", + "base_path": "src/Jet2.obj", + "complete": true, + "metadata": { + "source_path": "src/Jet2.cpp" + }, + "symbol_mappings": { + "FUN_00187710": "$L514", + "FUN_0018771b": "$L522" + } + } + ] +} \ No newline at end of file diff --git a/src/Core.cpp b/objdiff/src/Core.cpp similarity index 100% rename from src/Core.cpp rename to objdiff/src/Core.cpp diff --git a/src/Core.hpp b/objdiff/src/Core.hpp similarity index 77% rename from src/Core.hpp rename to objdiff/src/Core.hpp index 830913b..faf54f4 100644 --- a/src/Core.hpp +++ b/objdiff/src/Core.hpp @@ -1,20 +1,27 @@ +/* JSRF Decompilation: Core.hpp +Game and GameObj classes that form the foundation of the JSRF game code. +*/ + #ifndef CORE_HPP +#define CORE_HPP + +#include "D3D.hpp" +#include "MMatrix.hpp" +#include "Std.hpp" +#include "Win32.hpp" -typedef bool32 unsigned; // Need to find a clean way of representing this - -typedef Mat4 D3DVECTOR4[4]; // Should probably be defined somewhere else - -struct GraphicsPerformanceCounters { // Would come from header with Graphics COM object +// TODO; move to header for Graphics COM object in Smilebit libraries +struct GraphicsPerformanceCounters { unsigned fps; unsigned trianglesPerSecond; unsigned frameTriangleCnt; unsigned unknown0xC; unsigned unknown0x10; unsigned unknown0x14; -} +}; -// Base class of most objects +// Base class of most objects (and everything in g_game->objects) class GameObj { enum GameObjFlags { GOF_SOMETHINGLINKED_ALTLIST = 1 << 0, @@ -93,38 +100,38 @@ extern class Game { unsigned * unknown0xC; int initState; unsigned unknown0x14; - bool32 drawProfilingInfo; + BOOL drawProfilingInfo; int unknown0x1C; - bool32 logosStarted; - bool32 fatalErr; + BOOL logosStarted; + BOOL fatalErr; D3DCOLOR colour; D3DCOLOR ambientColour; D3DCOLOR shadowColour; D3DCOLOR bgColour; D3DCOLOR bgColourFallback; - bool32 useFallbackBgColour; + BOOL useFallbackBgColour; // Game state used to select GameObj methods to call in main loop // If multiple states are acivated, the precedence is // coveredPause > Event > FreezeCam > UncoveredPause > Default - bool32 coveredPause; // Game paused with world not visible - bool32 event; // Events (cutscenes) - bool32 freezeCam; // Time-frozen camera shots - bool32 uncoveredPause; // Game paused with world visible, or + BOOL coveredPause; // Game paused with world not visible + BOOL event; // Events (cutscenes) + BOOL freezeCam; // Time-frozen camera shots + BOOL uncoveredPause; // Game paused with world visible, or // automatic pause at start of mission - bool32 setCoveredPauseNextFrame; - bool32 unsetCoveredPauseNextFrame; - bool32 setEventNextFrame; - bool32 unsetEventNextFrame; - bool32 setFreezeCamNextFrame; - bool32 unsetFreezeCamNextFrame; - bool32 setUncoveredPauseNextFrame; - bool32 unsetUncoveredPauseNextFrame; + BOOL setCoveredPauseNextFrame; + BOOL unsetCoveredPauseNextFrame; + BOOL setEventNextFrame; + BOOL unsetEventNextFrame; + BOOL setFreezeCamNextFrame; + BOOL unsetFreezeCamNextFrame; + BOOL setUncoveredPauseNextFrame; + BOOL unsetUncoveredPauseNextFrame; unsigned unknown0x70; - bool32 skipDraw; + BOOL skipDraw; int zeroedByExec; GraphicsPerformanceCounters perfCounters; @@ -150,8 +157,6 @@ extern class Game { GameObj * linkedListsByKeyHeads [256]; GameObj * * linkedListByKeyEndNexts[256]; - unsigned unknown0x87B4; - LARGE_INTEGER execPerfCount; LARGE_INTEGER drawPerfCount; @@ -175,7 +180,9 @@ public: Game(unsigned *, unsigned); virtual ~Game(); - // TODO: methods + void initExecRootObj(); + void mainLoop(); + // TODO: other methods } * g_game; diff --git a/objdiff/src/D3D.hpp b/objdiff/src/D3D.hpp new file mode 100644 index 0000000..e6d36b8 --- /dev/null +++ b/objdiff/src/D3D.hpp @@ -0,0 +1,16 @@ +/* JSRF Decompilation: D3D.hpp +Direct3D8 declarations. +*/ + +#ifndef D3D_HPP +#define D3D_HPP + +#include "Win32.hpp" + + +typedef DWORD D3DCOLOR; + +struct D3DVECTOR { float x, y, z ; }; +struct D3DVECTOR4 { float x, y, z, w; }; + +#endif diff --git a/src/Jet2.cpp b/objdiff/src/Jet2.cpp similarity index 93% rename from src/Jet2.cpp rename to objdiff/src/Jet2.cpp index 1ffca17..65d8fbd 100644 --- a/src/Jet2.cpp +++ b/objdiff/src/Jet2.cpp @@ -1,3 +1,5 @@ +#pragma bss_seg(".data") + #include "Core.hpp" diff --git a/src/MMatrix.cpp b/objdiff/src/MMatrix.cpp similarity index 100% rename from src/MMatrix.cpp rename to objdiff/src/MMatrix.cpp diff --git a/objdiff/src/MMatrix.hpp b/objdiff/src/MMatrix.hpp new file mode 100644 index 0000000..a2ef473 --- /dev/null +++ b/objdiff/src/MMatrix.hpp @@ -0,0 +1,14 @@ +/* JSRF Decompilation: MMatrix.hpp +Smilebit's stack-based matrix math library. +*/ + +#ifndef MMATRIX_HPP +#define MMATRIX_HPP + +#include "D3D.hpp" + + +// 4x4 matrix type +typedef D3DVECTOR4 Mat4[4]; + +#endif diff --git a/objdiff/src/Std.hpp b/objdiff/src/Std.hpp new file mode 100644 index 0000000..1f4fa01 --- /dev/null +++ b/objdiff/src/Std.hpp @@ -0,0 +1,12 @@ +/* JSRF Decompilation: Std.hpp +C(++) standard library definitions. Implemented in the repository instead of +linking to an outside stdlib to ensure consistency (this may not actually be +possible to accomplish, but we'll go for it for now). +*/ + +#ifndef STD_HPP +#define STD_HPP + +#define NULL 0 + +#endif diff --git a/objdiff/src/Win32.hpp b/objdiff/src/Win32.hpp new file mode 100644 index 0000000..d4ab8d2 --- /dev/null +++ b/objdiff/src/Win32.hpp @@ -0,0 +1,40 @@ +/* JSRF Decompilation: Win32.hpp +Definitions normally provided by Windows headers. +*/ + +#ifndef WIN32_HPP +#define WIN32_HPP + +// The famous Win32 typedefs +typedef unsigned char UCHAR; +typedef char CHAR; +typedef unsigned short USHORT; +typedef short SHORT; +typedef unsigned int UINT; +typedef int INT; +typedef unsigned long ULONG; +typedef long LONG; +typedef unsigned __int64 ULONGLONG; +typedef __int64 LONGLONG; + +typedef unsigned char BYTE; +typedef unsigned short WORD; +typedef unsigned long DWORD; + +typedef int BOOL; +typedef float FLOAT; + +// 64-bit integer compatibility type +union LARGE_INTEGER { + struct { + DWORD LowPart; + LONG HighPart; + }; + struct { + DWORD LowPart; + LONG HighPart; + } u; + LONGLONG QuadPart; +}; + +#endif diff --git a/objdiff/target/.gitkeep b/objdiff/target/.gitkeep new file mode 100644 index 0000000..e69de29