hn.today

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

fireflyk64.github.io248 points36 comments
Screenshot of Show HN: After a decade of reversing, I got co-op working in DOS Wing Commander

After eleven years of work, Daniel and his brother Patrick made cooperative play possible in the original DOS version of Wing Commander, turning a childhood workaround - one person flying while another handled weapons - into separate wingmates. The project began in 2015 with a practical reverse-engineering challenge: find the player’s position in DOSBox’s memory so network data could control another ship. By comparing memory dumps while stationary and moving through empty space, they identified position and velocity values, then used the game’s chase camera and controlled experiments to confirm them. They mapped the game’s entity tables, finding 12-byte records for ships and camera data, and traced how the game updates position and orientation each frame.

Directly changing memory proved insufficient for actions such as firing weapons, so the developers learned to call the game’s own functions. Wing Commander’s code used dynamically loaded overlays, which complicated function calls; they built a trampoline in unused string memory to invoke those functions safely and return execution to the game. They also found a reliable main-loop hook and located damage handling, allowing them to prevent the secondary player’s game from duplicating damage. In 2017 they began connecting the two games with a TCP client-server protocol using Protocol Buffers. The finished project lets players fly together in a browser, preserving the original game’s mechanics by coordinating its internal state and invoking its own routines rather than merely simulating a second ship externally.

Read on fireflyk64.github.io36 comments on Hacker News

Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.

More in Programming

The daily digest

Today's best Hacker News stories, summarized and screenshotted, one email a day.