Baike.dev
All toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
O

OpenJKDF2

> 编程语言
Open source

A cross-platform reimplementation of JKDF2 in C

733 stars0 likes0 views
WebsiteGitHub

About

A cross-platform reimplementation of JKDF2 in C

OpenJKDF2

Latest Releases | Report a crash or bug

OpenJKDF2 is a function-by-function reimplementation of DF2 in C, with 64-bit ports to Windows 7+, macOS 10.15+, and Linux. Files are organized as closely to the original game as possible, based on symbols from the Grim Fandango Remaster Android/Linux/macOS port, as well as scattered assertions from various other games. It also contains the original versions of byacc and flex used for COG script parsing.

OpenJKDF2 does not include any original game assets; a valid copy of JKDF2 is required and can be purchased from GOG or Steam. The GOG version is recommended, since it is DRM-free and also includes the soundtrack in Ogg Vorbis format. If you'd like to try before you buy, a WebAssembly demo of OpenJKDF2 can be found at https://maxthomas.dev/openjkdf2/.

Support for playing the original soundtrack from Ogg Vorbis files is primarily supported for the GOG and Steam versions of the game assets. Original disk soundtracks can also be loaded from MUSIC/1/Track.ogg and MUSIC/2/Track.ogg for each disk's soundtrack. If files are missing, it will instead attempt to use a GOG track number from MUSIC/Track.ogg. Dumping the soundtrack from disks at install time is planned for a future release of OpenJKDF2, but is not currently implemented.

Platforms

OpenJKDF2 supports the following configurations:

Configuration Renderer Description
64-bit Windows/SDL2 OpenGL 3.3 64-bit Windows compilation with SDL2 and OpenAL. DirectX dependencies are replaced with SDL2 and OpenAL.
MacOS x86_64/AArch64 OpenGL 3.3 64-bit MacOS compilation with SDL2 and OpenAL Soft. All release packages include both Intel and ARM64.
64-bit Linux/SDL2 OpenGL 3.3 64-bit Linux compilation with SDL2 and OpenAL.
ARM64 Android OpenGL ES 3 ARMv8 Android compilation with SDL2 and OpenAL Soft.
Nintendo DSi Custom Nintendo DSi port with hardware rendering, software audio. Extremely RAM-limited, supports emissive palettes.
Dreamcast Custom KallistiOS+Dreamcast port with basic 3D rendering (no emissive palettes), HW accelerated audio including soundtrack and cutscenes. Extremely RAM-limited.
32-bit Windows/SDL2 OpenGL 1.1 Windows compilation with SDL2 and OpenAL Soft. DirectX dependencies are replaced with SDL2 and OpenAL. Targeting Windows XP ~ Windows 7
Emscripten/WebAssembly WebGL 2/OpenGL ES 3 WebAssembly with SDL2 and OpenAL. Runs in a web browser. Since WASM only supports 32-bit pointers, this will likely be less buggy than 64-bit, but less performant.

The following implementations are in-progress or planned:

Configuration Renderer Description Status
iOS Metal? Not a huge priority, but would be nice to have. Not started
Switch libnx OpenGL ES 3 Not a huge priority, but would be nice to have. Not started
32-bit Windows/SDL2 OpenGL 3.3 Windows compilation with SDL2 and OpenAL. DirectX dependencies are replaced with SDL2 and OpenAL. Targeting Windows XP ~ Windows 7 Not started
32-bit Windows/DirectX Direct3D 3 Faithful decompilation with original DirectX bindings/renderer. Not started

The following configurations are deprecated:

Configuration Renderer Description
x86 Linux/SDL2, mmap blobs OpenGL 3.3 32-bit Linux compilation with SDL2 and OpenAL. JK.EXE is memory mapped into the process and used as a "binary blob"; Unimplemented functions will fall back to JK.EXE implementations.
32-bit Linux/SDL2, blobless OpenGL 3.3 32-bit Linux compilation with SDL2 and OpenAL. The output executable is a swap-in replacement for JK.EXE, but will be missing functions and will crash on reaching unimplemented code.
x86 Win32/MinGW DLL Software/DirectX Win32 hooked build, JK.EXE is patched to load df2_reimpl.dll execute hook_init_win before JK.EXE's main function. Unimplemented functions will fall back to JK.EXE implementations. df2_reimpl_kvm.dll is used for the KVM target

Linux building works on AArch64/RPi4 with llvmpipe, but V3D GLES has trouble with palettes.

OpenJKDF2 requires game data from a licensed copy of Jedi Knight: Dark Forces II in order to run; No game assets are provided by OpenJKDF2. On Linux, paths and filenames may be case-sensitive. Your directory structure should look something like this:

…

Building

See here for instructions.

Contributing

Contributions in the form of code cleanup and documentation are highly welcomed. See CONTRIBUTING.md for details on what kinds of cleanup tasks still need to be done. OpenJKDF2 is not currently accepting monetary donations, however detailed bug and crash reports are always appreciated, including bugs/crashes involving mods.

TL;DR: What Isn't Implemented, Yet

  • Load Configuration and Save Configuration in Setup > Controls > Options
  • Using plus or minus to resize the screen (with SDL2, resolution auto-resizes to window size)

Usage with original JK.EXE and DirectX using hooks

See here for instructions.

Methodology

The bulk of research and documentation occurs in IDA. Every function has been identified to a file prefix (ie stdHashTable_) with a corresponding .c/.h file. RenderDroid (rd*) and LEC stdlib (std*) functions are 90% canonically named, based on symbols from Grim Fandango Remastered.

Reverse engineering is a parallel effort between structure documentation and function identification. Once structures are sufficiently documented, Hex-Rays can be used for decompilation. While most Hex-Rays output works outright, many loops and structures require manual intervention. Output is generally cleaned and tidied to remove redunant stack variables or too-deep nesting. sizeof and obvious inlining and macros should also be adjusted as appropriate.

Engine variables and yet-to-be-decompiled functions are referenced using define macros and static function pointers, respectively. Once a file is decompiled enough that an engine variable is no longer referenced by non-decompiled code, the variables can be declared in their respective C files. For decompiled functions which are only referenced by non-decompiled functions, a hook_function call is added in main.c to redirect code execution to df2_reimpl.dll from JK.EXE.

Progress is tracked using analyze.py, output.map and ida_copypaste_funclist_nostdlib.txt: After compiling df2_reimpl.dll, symbols can be compared against the .idb to determine how much of the original .text is actually in use, and how much has been hooked and replaced.

If you'd like a copy of my IDB to examine functions which haven't been decompiled yet (or for any other use), let me know.

Current Progress

Generated using analyze.py. Some filenames may be inaccurate or incomplete (see ida_copypaste_funclist_nostdlib.txt for a full function name listing).

…

See Also

  • OpenJones3D — Sister project decompiling Indiana Jones and the Infernal Machine, which is based on the same engine and internal libraries
  • OpenJK — Community-maintained open-source engine for Jedi Outcast (SP) and Jedi Academy (SP & MP), the sequels to Dark Forces II.

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

C

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言