GitHub - neuromancer/wc2-re: Wing Commander 2 source reconstruction and SDL2 port

GitHub

6 min read Original article ↗

This project recreates the source of Wing Commander II as shipped in Wing Commander: The Kilrathi Saga (1996). The reconstructed game core is C, the ix audio library is C++, and the reference build uses Microsoft Visual C++ 4.1 under wibo to reproduce the original Win32 WC2.EXE.

A native SDL2 port and optional graphical launcher are available for Windows, Linux, and macOS. They support Kilrathi Saga data and have partial support for the original DOS game data.

No retail game data files are included.

If you find this project useful, you can support its development through GitHub Sponsors.

Status

The reconstruction is materially complete: the source compiles and links as WC2.EXE, and the remaining work is focused on fidelity refinements, validation, and portability polish rather than missing major systems. make report compares 1,501 functions against the retail executable and averages 98.02% machine-code similarity.

The SDL2 port runs the title sequence, campaign intro, pilot database, save/load menus, cutscenes, and spaceflight, including firing, targeting, cockpit displays, and music. A DOS install plays its own AdLib music and synthesized OriginFX sound effects instead of the Kilrathi Saga streams and waves. The optional OpenGL renderer redraws space objects at output resolution while retaining the original indexed cockpit, HUD, and palette effects.

Screenshots

The game captures were taken through DREAMM at the original 320x200 resolution.

Title menu Opening sequence
Wing Commander II: Vengeance of the Kilrathi title menu Kilrathi figure in the Wing Commander II opening sequence
Cockpit navigation External flight sequence
Cockpit navigation display during spaceflight Two fighters during an external flight sequence

Download and run the SDL2 port

Download the archive for your platform from GitHub Releases. Extract its contents into an installed Kilrathi Saga or DOS Wing Commander II directory and keep the bundled runtime libraries beside the executable. Start it with that directory as the working directory:

# macOS or Linux
cd /path/to/WC2
./wc2-modern
# Windows PowerShell
cd C:\path\to\WC2
.\wc2-modern.exe

The release executable includes the graphical launcher. Starting without arguments opens it automatically. Supplying any command-line arguments starts the game directly unless --gui is also present.

Fixes and features

The native port includes these fixes and optional features:

Fix or feature Enable with
Kilrathi Saga or DOS game data, detected automatically always on
Original orchestral startup and logo sequence, when its data is present always on
Original cinematic captions alongside Speech Pack dialogue, with either data set always on
Resizable window, fullscreen toggle, and mouse capture always on
Aspect-correct 4:3 presentation and pointer mapping always on
Mouse-wheel throttle control during spaceflight always on
Esc pauses during spaceflight when communications are closed always on
Pointer confined only during unpaused, focused spaceflight always on
Automatic SDL gamepad mappings and hot-plug support always on
Background planets drawn with their own sprite and scale (WCDX fix) always on
Static on knocked-out cockpit displays always on
Neutral adaptive difficulty and half-size asteroid collision radii --balanced-difficulty
OpenGL space objects rendered at output resolution --enhanced
Authentic 16-colour EGA dithering from the DOS installer --ega
Heavy-weapon, damage, collision, and afterburner rumble --joystick-rumble
WCAT-style four-button joystick layouts --joystick-mode=4button-2axis or 4button-4axis
Twin-stick, HOTAS, throttle, and rudder layouts --joystick-axes=<layout>
Joystick diagnostics on stderr --joystick-debug
Frame-rate counter -f
Cockpitless view -c
Optional graphical launcher no arguments, or --gui with other options

Options can be combined:

./wc2-modern --ega --enhanced --joystick-rumble \
  --joystick-mode=4button-4axis

Enhanced renderer

The optional OpenGL renderer keeps the original indexed artwork, palettes, cockpit, HUD, and text while redrawing the ordered space-object layer at output resolution. The original software renderer remains the default; objects that cannot use the enhanced path fall back to it automatically. See the SDL2 port documentation for implementation details.

--ega converts the completed 320x200 indexed frame through the authentic WC2 DOS installer dither table and standard EGA palette. It works with either renderer. When combined with --enhanced, OpenGL still handles presentation and scaling, but high-resolution space-object redrawing is disabled so the EGA conversion is applied consistently to the whole frame.

Cockpit flight External flight sequence
Enhanced renderer showing a nearby ship and engine glow from the cockpit Enhanced renderer showing two ships during an external flight sequence

SDL2 port controls

Shortcut Action
Cmd+Enter (macOS) Toggle fullscreen
Alt+Enter (Windows and Linux) Toggle fullscreen
Cmd+Q (macOS) Quit the game
Mouse wheel (spaceflight) Increase or decrease speed
Esc (spaceflight) Close communications, or pause
Gamepad Start (spaceflight) Pause or resume
Gamepad Back Escape/back
Gamepad Y (Y/N prompts) Confirm Yes

The default joystick mode retains the original two-axis, two-button controls. The optional four-button modes add dedicated afterburner, target, weapon, navigation, autopilot, communications, and speed controls. See the SDL2 port documentation for the full gamepad, twin-stick, and HOTAS layouts.

Build from source

Clone the submodules first:

git submodule update --init --recursive

SDL2 port

Install a C/C++ compiler plus the SDL2 and LZO2 development packages, then run:

The executable is written to out-modern/wc2-modern (or out-modern/wc2-modern.exe on Windows). make run-modern launches it with Kilrathi Saga data in data/wc2-full; make run-modern-dos uses DOS data in data/dos.

Optional graphical launcher

The optional Slint launcher works on Windows, Linux, and macOS. It is linked statically into a separate executable, so the normal SDL2 build retains the same dependencies. The capture below shows it running natively on macOS.

Wing Commander II graphical launcher on macOS

Building it additionally requires CMake 3.21 or newer and Rust 1.88 or newer. On Linux, install the D-Bus development files as well; the folder picker uses the desktop portal instead of GTK:

make -j modern-gui
out-modern/wc2-modern-gui

make run-modern-gui opens it with the repository's Kilrathi Saga data path. The launcher has a native folder picker and validates the selected DOS or Kilrathi Saga directory before starting the game. Its central title artwork is decoded from the final WC2LOGO.VGA menu layers with BRIEF.PAL, cropped to a small 247x101 image, and embedded in the executable. Slint 1.16.1 and Native File Dialog Extended 1.3.0 are fetched at pinned tags and linked statically into wc2-modern-gui. Release archives install that integrated build under the usual wc2-modern name; SDL2 and the other platform runtime libraries remain dynamic.

Reconstructed Win32 build

The default target downloads and checksum-verifies the MSVC 4.1 package, then builds WC2.EXE, WC2.map, and compiler-generated assembly under out/. The original executable is not required to compile it:

To run it, provide a Kilrathi Saga disc image. The Makefile substitutes the reconstructed executable and launches it under DREAMM:

make run ISO=/path/to/kilrathi-saga.iso

Use make run-original for the retail executable in the same environment, and make debug to start DREAMM's debugger.

Reconstruction workflow

binary-comp is required only for comparison and verification commands:

python3 -m pip install "binary-comp[all] @ git+https://github.com/gg-sl-oss/binary-comp.git"
make compare-func FUNC=WinMain
make verify

These look for the retail executable at ../releases/win32/WC2.EXE; set ORIGINAL_SRC to point elsewhere.

Contributor references:

Acknowledgements

Special thanks to:

  • Origin Systems, who created Wing Commander II and developed its Kilrathi Saga port;
  • Electronic Arts for publishing Wing Commander: The Kilrathi Saga;
  • GOG for keeping Wing Commander 1 + 2 readily available;
  • AllTinker for the W.C.A.T. overhaul, whose fixes and analysis of the DOS release have been valuable references;
  • the WCDX project for its pioneering compatibility work on the Kilrathi Saga release; and
  • Aaron Giles for the DREAMM emulator, used to run and study the original release, and ymfm, which powers the SDL2 port's AdLib emulation.

License

See LICENSE. OpenAI Codex and Anthropic Claude were used during the reconstruction.