In the early 90s, one company was at the forefront of PC gaming progress: Origin Systems . Her slogan was “We create worlds” and, hell, they corresponded to him: the Ultima , Crusader and Wing Commander series shook the players' imagination.
Creating one of the games took four years and more than a million man-hours: Strike Commander . The famous flight simulator had its own 3D engine called RealSpace , in which technologies first appeared, today taken for granted: texture mapping, Guro shading, changing the level of detail and color dithering.
My old dream was to play it in a virtual reality helmet. Thanks to Oculus Rift, this fantasy has become one more step closer to reality. ')
But, as it turned out, the source code of the game was lost and will never be released, so I decided to do reverse engineering.
At the time of publication of this article, my project is not finished yet, but I want to share the techniques that allowed me to make this:
this:
... and maybe inspire someone to join my adventure.
To Strike Commander
In the early 90s, flight simulators were good, but Falcon 3.0 or Flight simulator 4.0 were more focused on the accuracy of the flight model, rather than beautiful visualization:
There were a lot of flight simulators on the market, and few noticed that in 1990, Origin Systems announced the creation of a new game. But that all changed after the CES 1991 exhibition in Chicago, where a demo was shown. No one could believe that there would be elements in the game that were present at that time only in the Air Force flight simulators: texture mapping, Guro shading, fog and many others. The screenshots show technologies that have greatly overtaken their competitors:
After 1991, many began to wait for the game. Not only because of the amazing engine and exciting plot - RealSpace initially supported additional equipment, very expensive and fragile accessories, desired by any fan of flight simulators - THRUSTMASTER WEAPON CONTROL SYSTEM and THRUSTMASTER FLIGHT CONTROL SYSTEM:
You could even connect THRUSTMASTER RUDDER:
But that was not all: the game supported the virtual cockpit. The four-direction ThrustMaster mini-joystick allows you to move the pilot's head and follow ground objects / enemy aircraft without the need for a virtual reality helmet:
1993: first contact
The game and its three-dimensional engine simply “blew up the brain”, but they needed an incredibly powerful machine:
IBM PC 486-DX2 66 MHz
4 MB of RAM
At least 38 MB on hard disk
The game was delivered on eleven floppy disks of 1.44 MB each.
If we draw an analogy with the modern technological level, then the recommended configuration would be as follows:
CPU with 8 cores and 16 GB of RAM.
Two Nvidia Titan video processors.
Mandatory installation of 1000 GB.
The game comes on five BluRay.
And just to buy the game was not enough, I had to go through the installation process! Opening the box, the user saw 8 floppy disks (+3 for Speech Pack):
Interesting fact: notice that the poster shows the release date: Christmas 1991. The game was completed only in 1993 after a long process, which Chris Robert called "The Apocalypse Today," computer games. "
Unpacking the game from floppy to hard disk and changing 13 disks took a good half hour. And when you already thought that everything was over, the game began to generate all the cards. The size of the game increased from 24 MB to 38 MB: four times as much as any other game of that time.
Interesting fact: the card was generated from one seed (whole number) inserted into the algorithm for generating pseudo-random numbers. It was a skillful technique, which made it possible to avoid an increase in the amount of data on the disks by generating a card after installation. If you are interested in the details of this technique, I recommend reading the book The Backroom Boys and the chapter on the game Frontier Elite.
On the 386th PC, the card generation took ONE HOUR. But Origin Systems thought of delivering an excellent hundred-page magazine with the game box in the gloomy entourage of the 2012 game world. Thanks to Sudden Death, the whole process became less painful (note that on page 38 there are fake ads promising the release of Strike Commander by Christmas 2013).
Strike Commander!
Finally, after these steps, players could enjoy the game ... in April 1993! Despite the fact that the game was delayed for two years, it had everything that Origin had promised, and it sold very well. Many spent long nights fighting battles, even though the game was supposed to look like this:
... at the minimum settings, it looked like this:
In general, this was enough to attract pilots and create good memories.
Lost source code
After the release of Oculus Rift, my interest in Strike Commander increased again: a suitable “iron” appeared. Since the game was 20 years old, I expected that the source code was already released, but quickly came across a story about the sad withering history of Origin Systems.
In September 1992, Origin Systems was bought by Electronic Arts and around 1999, all projects were canceled due to poor sales of Ultima 9. The company had to focus on another area in which it, too, was a pioneer: MMORPG Ultima Online . Many people believe that the source codes and versions on the "gold" of all finished games are stored somewhere in the depths of the EA repository. But contacting people from the Wing Commander CIC , I found out that all the source code disappeared after the closure of the company.
Today it is hard to believe, but at that time developers and companies were more interested in new games, and not in preserving the “old stuff”, there was no nostalgia factor yet, there was no big database of fans and such stores as the modern Good Old Games . Many stories can illustrate the level of “primitiveness” of control over source codes, but perhaps the best is the “ZAP SC” story at 15 minutes 14 seconds:
On the first day of work, one developer managed to delete the entire source tree of the 900 MB Strike Commander. The IT department spent 72 hours recovering everything from the developers' machines. The interview also mentions that the Wing Commander code 1 and 2 was transmitted on floppy disks: they had no network before Strike Commander!
An interesting fact: an unexpected turn of events - part of the source code was recently found by former Origin developers: The Wing Commander CIC stores an offline archive in which the source codes of Wing Commander I and Wing Commander III are stored. The people who worked on Ultima 8 were offered (but rejected) the source code "Ultima 8: Pagan" by an anonymous source . As for Strike Commander, I have never heard of anyone staying.
Reverse engineering: is it possible?
Over the years, many teams managed to work on Origin Systems games and achieved excellent results:
In Pentagram , Ultima VIII: Pagan is recreated (I advise you to look at the code, the design, based on the actors that are processes inside the core, is beautiful).
How long and hard can it be? After talking with Gregory Montoire, who did almost the entire reverse development of Another World , I realized that by working for an hour per evening, I could reverse 10 KB of assembler code back to C in a month. Strike Commander has many executable files, and the initial discouraging estimate of time was:
It was frustrating: if someone started work in 1993, he would have finished six years ago, and it would be enough for me to do git clone ! But by running IDA and examining the files a bit, I realized that not everything needs to be reversed: the 3D engine is completely in STRIKE.EXE and a small team can cope with it in a reasonable time.
Road map
The roadmap that I originally drew for Strike Commander reverse engineering was:
Collect as much documentation as possible.
Understand the global architecture of Strike Commander.
Perform reverse development of game resources.
Document stage 3 and extrapolate (Visual Surface Determination, Level Of Detail, etc.)
Re-implement the 3D engine and build NEO_STRIKE.EXE
Add support for Oculus Rift VR devices.
And I set to work.
Part 2. Architecture and documentation
Architecture
Strike Commander does not consist of a single monolithic executable file. To ensure the gameplay together six executable files. The basic idea is similar to that studied in the review of the Second Reality code . There are several ways to explain the use of several .exe files:
Optimization of teamwork (each employee could work on his part without affecting others).
Programs because of the real DOS mode were limited to 640 kilobytes of RAM. A large monolithic executable file would increase the exchange of data with the disk or it would not load at all.
After studying in IDA, it turned out that in each executable file, the DOS 21h system call is used to load and launch other .EXE . For example, the scene mode that OPTTEST.EXE dialogs and cinematic inserts is OPTTEST.EXE . It removes itself from RAM and loads / launches STRIKE.EXE when 3D mode is needed.
DosBOX was very useful for researching and studying the components responsible for each of the Strike Commander parts. The name of the currently running executable file is shown in the window title:
Executable file
Screenshot
Notes
INSTALL.EXE
Module running MKGAME.EXE
MKGAME.EXE
This installer:
Creates a boot disk.
Identifies the sound card.
Performs copy protection (a question with an answer in the Sudden Death magazine).
Unpacks 8 floppy disks.
MKTERR.EXE
Map generator, which creates all map elements and groups them in PAK:
ALASKA.PAK
ANDMAL1.PAK
ANDMAL2.PAK
ARENA.PAK
CANYON.PAK
EGYPT.PAK
EUROPE.PAK
MAPDATA.PAK
MAURITAN.PAK
QUEBEC.PAK
RHODEI.PAK
SANFRAN.PAK
TURKEY.PAK
OPTTEST.EXE
Responsible for all in-game dialogues, cinematic inserts, menus, the choice of weapons in the hangar and viewing objects.
SC.EXE
The way in which the game starts. It usually loads and executes OPTTEST.EXE .
STRIKE.EXE
Three-dimensional RealSpace engine. Responsible for the active phase of the game process.
Note: if you delete the PAK card archive, STRIKE.EXE detects the absence of the file and automatically launches MKTERR.EXE to generate the card. That is, most of the work happens in OPTTEST.EXE and STRIKE.EXE . But we have not figured out how the parameters are passed between them. The DOS 21h system call allows you to use command line parameters, store data in a specific memory page, and you can save the state of the game on your hard disk. IDA will tell us how it is in our case.
While not working on them. Probably all of them are in exe.
Considering the time and documentation found in the playters manual, I think that there is not a simple decision tree. Probably hierarchical finite automata.
Nothing yet! I strongly hoped that the game uses a SCUMM style virtual machine. This part is performed by OPTTEST.EXE
Palettes
The effects of the palette will probably be difficult to recreate: when the pilot experiences too much overload, the screen turns gray (and then dark if it gets even more G). This is implemented by interpolation between palettes. This is where a shader can help.
Oculus Rift support
Work on the integration of Oculus Rift has not yet begun. [approx.Lane: the last commit in the Github project is dated October last year, so it seems, alas ...]