darkengine

darkengine is a PC port of Thief: The Dark Project that restores the Dark Engine sources for Windows, macOS, Linux, and Android.

README

Thief: Dark Engine Restored for Windows, macOS, Linux, and Android

This repository restores the historical Dark Engine sources as a portable, working codebase for the Thief and Thief 2 games. It builds the ThiefRunner game executable on Windows, macOS, Linux, and Android, plus work-in-progress DromEd mission viewer and editor ports. The engine core is shared across platforms; operating-system, rendering, input, audio, movie, and filesystem services are supplied by platform backends. The engine experimentally implements many of the anonymously created but closed-source NewDark extensions.

The desktop game runner is now fairly stable and has been tested on Windows, Linux, and macOS. Compatibility still varies by mission and script module; Android and DromEd remain under active development.

The NewDark compatibility plan, feature matrix, and script contracts track the remaining work and distinguish implemented features from verified compatibility.

The repository does not include retail missions, movies, sounds, scripts, or other game assets. A legally obtained installation of Thief: The Dark Project, Thief Gold, or Thief II: The Metal Age is required.

Development disclosure: This restoration has made extensive use of supervised AI coding assistants, including OpenAI Codex, for implementation, porting, debugging, testing, and documentation. A human maintainer directs the work, reviews the resulting changes, and remains responsible for what is accepted into the project. AI-assisted changes receive the same build and runtime validation as other changes, but that review cannot guarantee the absence of defects.

Table of contents

Screenshots

These captures were produced during local runtime verification with external retail game data. The data shown in the captures is not included in the repository.

Gameplay and inventory HUD

Thief 2 gameplay and inventory HUD

In-game menu

Thief 2 in-game menu

Automap

Thief 2 automap

Platform status

CapabilityWindows x86Windows x64macOSLinux x64Android ARM64
Thief 2PlayablePlayable; broader validation ongoingPlayable; runtime testedPlayable; runtime testedPlayable early port
Thief Gold/TDPPlayable; less stable than Thief 2Playable; less stable than Thief 2Build target; runtime unvalidatedPlayable early port; less stable than Thief 2Playable early port; less stable than Thief 2
Thief FMsPlayable subset; less stable than Gold/TDPPlayable subset; less stable than Gold/TDPBuild target; runtime unvalidatedPlayable subset; less stable than Gold/TDPPlayable subset; less stable than Gold/TDP
System Shock 2Unsupported; source availableUnsupported; source availableUnsupported; source availableUnsupported; source availableUnsupported; source available
DromEdViewer and playtestViewer and playtest; broader validation ongoingViewer/playtest portEarly viewer/playtest portNot built
GraphicsSDL3/VulkanSDL3/VulkanSDL3/VulkanSDL3/VulkanSDL3/Vulkan
AudioOpenALOpenALOpenAL frameworkOpenAL SoftOpenAL Soft/OpenSL
MoviesFFmpegFFmpegFFmpegFFmpegFFmpeg
Legacy .osm scriptsNative PE32 modulesIA-32 compatibility runtimePartial IA-32 compatibility runtimePartial IA-32 compatibility runtimePartial IA-32 compatibility runtime
Squirrel scriptsNative Squirrel 3.2 providerNative Squirrel 3.2 providerNative Squirrel 3.2 providerNative Squirrel 3.2 providerNative Squirrel 3.2 provider
Build systemCMake SDL3/VulkanCMake SDL3/VulkanCMake and NinjaCMake and NinjaGradle, CMake, and Android NDK

The legacy .osm row refers to ordinary compiled mission script modules. NewDark's squirrel.osm is not loaded through that compatibility path: on all five targets it is replaced by the engine's native Squirrel 3.2 provider, which loads the FM's loose sq_scripts/*.nut sources directly.

The source tree also contains historical System Shock 2 code, but this project does not currently provide or validate a System Shock 2 build target.

The x86 builds are the established target; native x64 builds compile and run but remain under active runtime validation. In particular, x64 relies on the IA-32 interpreter and service bridge for 32-bit mission .osm binaries, while many NewDark FMs rely on the newer Squirrel provider. Both compatibility layers need broader mission coverage. Windows, Linux, and macOS have been tested in gameplay; this does not establish compatibility with every mission or fan mission. The Linux CMake target builds a native 64-bit ELF executable.

The game runner retains mission loading, the game UI, inventory, automap, and the in-game command console. On Windows it also retains the normal startup and movie flow. DromEd can load, inspect, and playtest legacy Thief 2 missions in a resizable window, but should still be treated as a viewer rather than a dependable editor. Editing and mission-authoring integrity are not comprehensively validated, and NewDark formats and features are only partially supported.

Mission compatibility and goals

thief-runner.exe replaces the retail Thief2.exe. It is more than a straight port: the same runner supports all three Thief releases and selected NewDark content, while continuing to read an existing installation in place. It is not a complete NewDark implementation. Compatibility currently breaks down as follows:

  • Thief II is the primary and most-tested target. The stock campaign is playable on every supported platform; Windows x86 remains the reference build, with Windows x64, Linux, and Android receiving progressively broader mission and script validation.
  • Thief Gold and The Dark Project stock missions load through the same runner, with the Dark 1 service layout selected for legacy scripts. Gold has passed initial runner and DromEd smoke tests. TDP and the complete Gold campaign and UI still need broader coverage.
  • Fan missions using retail-era data and legacy .osm scripts are a core compatibility goal. FM-local configuration, NewDark-style path precedence, PNG replacement art, and Ogg Vorbis sounds are supported. Individual FMs may still expose missing script services, formats, or raised engine limits; darkengine-diagnostics.log and mission_compatibility.log record those failures explicitly.
  • NewDark content is partially supported, not promised compatible. The runner understands selected configuration conventions, resources, database extensions, and loose Squirrel 3.2 sources, but it does not implement the complete NewDark service, renderer, object/property, or authoring surface.

Game-save coverage and format limitations are documented separately under Game saves.

The near-term goal is dependable play of all three stock Thief releases and retail-format FMs, followed by measured expansion of NewDark FM compatibility. NewDark-only data should be diagnosed or preserved where possible rather than silently discarded. DromEd remains a viewer/playtest and preservation tool until its editing and round-trip behavior is comprehensively validated.

Cross-platform architecture

The CMake runner uses the shared lgd3d Vulkan renderer through SDL3 on Windows, macOS, Linux, and Android. The Win32 DirectDraw/GDI display provider and renderer stub have been removed. Platform services live in libsrc/platform, with selected Windows and POSIX implementations. Shared editor providers live in src/editor, and both executables use the shared entrypoint in src/entry. DromEd uses uiedit.c on every desktop platform, NFDe native file dialogs, and currently has no native menubar.

Core clocks, dynamic-library loading, memory queries, assertions, clipboard, synchronization, and filesystem operations cross platform_services.h and platform_io.h. The shared engine retains its historical data layouts while the compatibility headers isolate Windows and LP64 ABI differences.

Native 64-bit builds include a compatibility runtime for legacy 32-bit .osm script modules. It reads PE32 modules, interprets IA-32 code, and bridges the supported script-manager and engine-service calls into the host process. Every game build provides an in-process Squirrel 3.2 script module for NewDark-style sq_scripts/*.nut sources. It uses the normal Dark script manager and service interfaces in place of the game-specific NewDark squirrel.osm binary. Both bridges are still being expanded and validated against third-party scripts.

Audio uses the shared OpenAL provider on every platform. It supplies positional audio, EFX reverb, and per-source occlusion. The runtime loads OpenAL32.dll on Windows, the system OpenAL framework on macOS, and OpenAL Soft on Linux and Android. sfx_backend auto and sfx_backend openal both select this provider.

Movie playback is exposed through the platform-neutral engine movie API. The shared SDL3 backend in libsrc/actmovie uses FFmpeg for video and audio decoding on desktop platforms and the SDL3/Vulkan presentation surface. Android delegates playback to its native player while retaining the engine's synchronous movie lifecycle.

Legacy PKWARE DCL-compressed resources are decoded in-process with Mark Adler's small blast decoder under 3rdparty/blast; newly written resources use the engine's existing LZW codec. No external compression DLL is required.

Game runner features

The runner currently provides:

  • use of an external retail Thief installation without copying its data;
  • automatic TDP, Gold, Thief II, and current GOG Gold collection-layout detection from the working directory;
  • native display-resolution defaults when the user has not configured a resolution;
  • borderless fullscreen and resizable windowed presentation;
  • the standard Windows splash, startup, movie, and main-menu flow;
  • direct mission startup and unattended frame-limited smoke tests; and
  • a configurable command console, defaulting to : and ; in every mode.

Building and running

Windows
Prerequisites
  • 64-bit Windows 10 or Windows 11.
  • Visual Studio 2026 with MSVC x86/x64 build tools and a Windows 10 or 11 SDK for the supplied Windows presets.
  • CMake 4.2 or later for those presets, MSYS2 Bash and Make, and the Vulkan SDK (including glslc).
  • Bison 3.0 or later on the build host (bison or win_bison on PATH).
  • A retail TDP, Thief Gold, or Thief II installation containing cam.cfg and the stock mission data.

Initialize the pinned source dependencies and configure/build either architecture from a Visual Studio Developer PowerShell with MSYS2 tools on PATH:

git submodule update --init --recursive
cmake --preset windows-x64
cmake --build --preset windows-x64-release

cmake --preset windows-x86
cmake --build --preset windows-x86-release

Visual Studio 2022 can instead be selected explicitly with CMake 3.21 or newer:

cmake -S . -B build-win64 -G "Visual Studio 17 2022" -A x64 -DDARK_BUILD_DROMED=ON
cmake --build build-win64 --config Release --target thief2 dromed

SDL3, zlib, libpng, Squirrel, libogg, libvorbis, FFmpeg, and the PKWARE DCL decoder are built statically from pinned submodules. Install the Vulkan SDK separately; CMake uses its Vulkan package and glslc shader compiler. vcpkg is not required. FFmpeg is compiled with MSVC; MSYS2 supplies its shell utilities and GNU Make, so keep C:\msys64\usr\bin on PATH during both configuration and builds. If Bison is not detected, pass -DBISON_EXECUTABLE=C:/path/to/win_bison.exe when configuring.

Windows uses the same SDL3 surface and Vulkan renderer as macOS and Linux. SDL3 is linked statically into both executables.

The executables are written under build-win32/Release or build-win64/Release as thief-runner.exe and DromEd.exe.

Running

Run from the retail directory, or launch elsewhere and choose the installation when prompted. For the current GOG Gold package, either the common Thief Gold collection folder or one of its runnable child game folders can be selected:

Set-Location 'C:\Games\Thief Gold'
& 'C:\src\darkengine\build-win64\Release\thief-runner.exe'

The chosen game directory is used in place; retail data is not copied. The picker remembers only a starting-folder hint under HKCU\Software\DarkEngineRestored\Launcher. Use Dark-style assignments such as quickstart=MISS1.MIS or auto_stop=60; there are no GNU -- prefixes.

macOS
Prerequisites
  • macOS with Xcode Command Line Tools, CMake 3.21 or later, Ninja, and Bison 3.0 or later (install Homebrew Bison; the system Bison is too old).
  • The Vulkan SDK (including glslc) and CMake submodules; macOS supplies the OpenAL framework.
  • A retail TDP, Thief Gold, or Thief II installation.

With Homebrew:

brew install cmake ninja bison

Initialize source dependencies with git submodule update --init --recursive. Install the Vulkan SDK separately, including glslc.

Build
git submodule update --init --recursive
cmake --preset macos
cmake --build --preset macos-release -j "$(sysctl -n hw.ncpu)"

Non-Windows builds export compile_commands.json into their CMake build directory during configuration, including the macOS and Linux presets and Android native builds.

CMake generates the include, motion-schema, sound-schema, and song parsers from the .y grammars in src/. Generated C files and token headers live in <build-directory>/src/generated/; editing a grammar regenerates its parser automatically. Set BISON_EXECUTABLE if Bison is not on PATH.

The result is build-macos/thief-runner. SDL3, zlib, libpng, Squirrel, libogg, libvorbis, FFmpeg, and blast are built statically from submodules.

Running

Run from the retail game directory. The Vulkan renderer is always used; old game_hardware settings in retail configuration files are ignored:

cd "/path/to/Thief II"
/path/to/darkengine/build-macos/thief-runner quickstart=MISS1.MIS
Linux
Prerequisites
  • A 64-bit Linux distribution, GCC, CMake 3.21 or later, and Ninja.
  • The Vulkan SDK (including glslc) and the standard CMake build tools.
  • OpenAL Soft at runtime, loaded dynamically. Ogg Vorbis decoding is built statically from the pinned submodules.
  • D-Bus development headers for DromEd's native file dialogs, plus a desktop portal with a file chooser backend at runtime.
  • A retail TDP, Thief Gold, or Thief II installation.

For Ubuntu/Debian:

sudo apt update
sudo apt install build-essential cmake ninja-build bison libvulkan-dev glslc \
  libopenal1 libdbus-1-dev xdg-desktop-portal
Build
git submodule update --init --recursive
cmake --preset linux
cmake --build --preset linux-release -j "$(nproc)"

The results are build-linux/thief-runner and, with DARK_BUILD_DROMED=ON, build-linux/DromEd. Platform consolidation details and Linux validation are recorded in the migration notes. SDL3, zlib, libpng, Squirrel, libogg, libvorbis, and FFmpeg are built statically from those submodules.

Running

The launcher accepts the current directory, DARK_GAME_PATH, or game_path=<directory>:

cd "$HOME/Games/Thief 2"
/path/to/darkengine/build-linux/thief-runner quickstart=MISS1.MIS

For uncapped performance measurements, disable both the simulation pacing override and VSync, and allow simulation steps below the legacy 10 ms minimum:

/path/to/darkengine/build-linux/thief-runner quickstart=MISS2.MIS \
  SlowFrame=0 min_frame_time=0 vsync=0

vsync=1 is the default. With vsync=0, Vulkan prefers mailbox presentation, then immediate presentation, and falls back to FIFO if neither is supported. Immediate presentation can tear. SlowFrame and simulation timing defaults remain unchanged; omit these overrides for the normal pacing behavior.

The legacy HUD/menu canvas keeps its original 8/15/16-bit pixels. Vulkan decodes their colors, looks up palettes, filters, and composites them on the GPU. Unchanged canvas rows are retained, and unchanged frame-slot textures are not uploaded again. Hardware game overlays are captured directly from the offscreen canvas, without a full copy into the display buffer or a second capture at page flip. Rectangle flushes commit only their requested pixels; clearing uses previously occupied overlay rows when a complete snapshot is available. Menus, retained editor panes, and uncertain snapshots use the normal fallback path. The legacy UI drawing code still runs on the CPU. See the canvas regression check for pixel comparisons against the previous CPU conversion.

Vulkan texture uploads reuse persistently mapped staging buffers, command buffers, and fences after GPU completion; the idle staging cache is limited to 64 MiB and 64 slots. Texture/sampler descriptors are cached separately for each frame slot, and repeated pipeline, descriptor, viewport, push-constant, and vertex-buffer bindings are skipped within a command buffer. Texture replacement gets a new identity so recorded draws retain their old image.

Run DromEd from the same retail directory. It accepts the same editor command line used on Windows, including deterministic viewport inspection:

/path/to/darkengine/build-linux/DromEd file=MISS1.MIS
/path/to/darkengine/build-linux/DromEd render_test=MISS1.MIS \
  render_test_pos=37.43,100.15,18.97 render_test_angles=-35,90,0

The Linux editor uses SDL for its window, input, and editor prompts, and nativefiledialog-extended through the desktop portal for Open/Save dialogs. The shared editor panes, command console, and keyboard bindings work. Native menu bars are currently disabled on all platforms; use the command console and shortcuts for those commands.

An interactive launch from another directory opens the folder chooser. SDL uses relative-pointer input during gameplay and absolute coordinates in menus, with native Wayland preferred when available. See Game saves for the save location and fallback rules.

Tracy profiling

Tracy v0.15.0 is pinned in 3rdparty/tracy. CPU profiling is optional and is disabled by default. All builds use its headers; the client is linked only when profiling is enabled. Initialize the submodule and enable it for a build:

git submodule update --init 3rdparty/tracy
cmake --preset macos -DDARK_ENABLE_TRACY=ON
cmake --build --preset macos-release

Use the corresponding Linux or Windows presets on those platforms. Launch thief-runner or DromEd normally, then connect the matching Tracy v0.15.0 profiler to localhost:8086. Th