Weekend Project: Wing Commander External Display

Cobbling together a numerical display and hooking it up to a classic PC game.

In the Wing Commander CIC Discord server the other day, we were having a conversation about those elaborate flight simulator home cockpits that extreme enthusiasts of that genre put together. Things like toggle switches, fuel gauges, LCD panels etc. are not uncommon. Why has nobody ever attempted such a thing in the Wing Commander community before?

Something like this! A bit elaborate for my taste but I love the commitment to the craft!

Wing Commander, a space combat simulator from the early 1990s, would really lend itself to this kind of treatment. The game’s interface takes place in a cockpit of a space fighter in the year 2654. Obviously one reason something like this hasn’t been attempted is the year of release. Though there’s a thriving community, early 90s MS-DOS software isn’t necessarily the easiest thing to pick apart and wrap in modern hardware.

Example of an in-game cockpit. Numerical gauges are highlighted in yellow, Boolean on/off indicators are highlighted in magenta, and graduated gauges are highlighted in red.

Some of the community members expressed interest in designing custom controls and hardware, so I took it upon myself to figure out what exactly it would entail. There are a ton of peripherals that were made (mostly by Logitech/Saitek) specifically for use with MS Flight Simulator. These great enclosed panels with things like analog fuel gauges, toggle switches, control knobs, numerical readouts and so on. Unfortunately they are both expensive and not well-supported by the manufacturer. No developer information or APIs could be found at their website and preliminary research suggested they can only be used with Flight Simulator without extensive software modding.

Inspired by some efforts done by players in the Kerbal Space Program community, I decided to use an Arduino as a controller. It allows simple serial communication and is inexpensive and very extensible. I also happened to have an Arduino project starter kit that had been sitting on a shelf untouched for months waiting for the day to come.

Inspiration in the form of a control panel for Kerbal Space Program designed by KSP community member “Sputnix”

I needed to learn a bunch about how Arduino works. I’ve never used one before this project and the platform was largely unknown to me. The sketches are written in what I believe is C/C++ and uploaded via USB to the controller which runs independently on the board. I also did a fair amount of tutorials and research on basic circuit theory and components, a field I’ve touched on but is largely outside of my wheelhouse.

Eventually I got a sketch written that reads a single value from the serial connection to my desktop PC via USB and displays the number on a 4-digit LED display.

Functional prototype of the Arduino displaying a value sent over USB from host PC.

I had previous experience pulling data from Wing Commander in a project that I will write a blog about some day so the host PC’s side of the project was relatively easy to breeze through. I utilized Cheat Engine, a program that streamlines the process of searching a process’s memory for data and isolating the memory addresses for repeated use.

Some parts of this didn’t go as well as I would have liked. I wanted to be able to pull both the “set” speed of the player’s ship as well as the “actual” speed. Wing Commander is a 3-dimensional simulator with a realistic physics simulator. The player is able to set their ship’s throttle to a desired speed, say 400kps.

Unconfirmed speculation follows: the game likely applies this by scaling a normalized 3D velocity vector to the desired speed. So as the player rotates the ship’s orientation with the joystick, it generates a new acceleration vector for the x/y/z velocity. As it attempts to correct the velocity to compensate for the movement, the actual velocity of the player decreases as the rotation stabilizes and the velocity pulls into a straight line in one direction.

For a much better and more thorough explanation of this type of system, try Daniel Shiffman’s series on autonomous agents and steering behavior on YouTube. Regardless, it isn’t as simple as just pulling a single byte from memory and requires more information about the game’s architecture. Perhaps some persistence in the future or help from the community could help mine the data further.

However, the set player speed is stored as a single byte in the game’s memory and is very easy to pull once you know where it is. I was able to throw together a command line interface that continuously polls the game’s memory for velocity and send the data to the Arduino for display!

A quick demo I recorded of me playing a bit of the game. The webcam in the bottom left corner shows the display being updated in real time.

Overall I’m very proud of this little thing! I’m already considering some more options to explore. Plans for the future include:

  • Use an integrated circuit to drive the display to free up pins on the Arduino.
  • Implement some of the other elements of the in-game cockpit. How cool would it be to have a display that shows your afterburner fuel level, or a warning light that flashes when you should eject and avoid a game over, or indicators of your shield and armor levels? Some of these are more easily doable than others, but I feel like it’s possible!
  • Are inputs possible? Could I press a button on a housing and engage the Autopilot in the game? Maybe!

The source code for the Arduino sketch as well as the CLI program are available on my Github account. Please feel free to contact me via email or on the CIC’s Discord if you have any ideas, suggestions, or want to collaborate!