← Wed, Nov 4 digest

Show HN: After a decade of reversing, I got co-op working in DOS Wing Commander

read article ↗ hn thread ↗

A developer spent 11 years reverse engineering DOS Wing Commander to implement a peer-to-peer co-op mode playable in the browser via WebRTC.

read it Provides a detailed, step-by-step account of memory hacking, function hooking, and networking implementation for a legacy game.

summary

The author reverse engineered the memory and function calls of DOS Wing Commander over a decade to enable cooperative play. By identifying coordinate and rotation variables in the 640K data segment and creating 'trampolines' to call original game functions, they synchronized game state across a network. The project recently evolved into a browser-based experience using Emscripten, WebRTC for P2P connectivity, and a Go-based lobby system called lobbylink.

key points

  1. Identified player coordinates and rotation by comparing memory snapshots in DOSBox and analyzing byte changes during movement.
  2. Implemented function hooking using 'trampolines' that mimic Borland C++ function frames to avoid crashing the game's overlay loader.
  3. Developed a custom networking protocol using protobufs to sync ship positions, fire events, and mission victory tallies.
  4. Used LLMs to assist with the final porting to Emscripten and the implementation of WebRTC voice chat.

who should read it

Reverse engineers, retro gaming enthusiasts, and developers interested in legacy software modification.

discussion warm

consensus

Commenters are highly impressed by the author's persistence over a decade and the technical ingenuity of the memory hacking process.

best comment by daniel_rh ↗

Author here: in 2015, I was playing the classic Wing Commander in DOSBox and suddenly realized the game state fit in the 64k data segment.

Over ten years my brother and I went through a set of experiments (stop and go, turn, communicate) while probing the memory. We uncovered where the variables were, how to inject calls into the game functions, and how to sync the gamestate across the network, so we can fly the story missions together.

My favorite finding is that the camera lives in entity slot 0x3D, which is possibly a "3D" reference by the original developers.

You can play it at …

The author clarifies the role of AI in the project, distinguishing between the decade of manual reverse engineering and the final AI-assisted porting phase.

Generated by an LLM from the article and thread. Check the sources before relying on it.