📜 ⬆️ ⬇️

Reverse engineering game Strike Commander

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:


If we draw an analogy with the modern technological level, then the recommended configuration would be as follows:


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:


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:

INSTALL.EXE 7 793 : 2
MKTERR.EXE 203 744 : 1,5
SC.EXE 20 000 : 1
MKGAME.EXE 131 696 : 1
OPTTEST.EXE 870 528 : 7
STRIKE.EXE 746 304 : 6
=============================================
15 , 7 2 . -.


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:

  1. Collect as much documentation as possible.
  2. Understand the global architecture of Strike Commander.
  3. Perform reverse development of game resources.
  4. Document stage 3 and extrapolate (Visual Surface Determination, Level Of Detail, etc.)
  5. Re-implement the 3D engine and build NEO_STRIKE.EXE
  6. 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:


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.

List of important files


Important files used by the game:

//
16 -rw-r--r-- 1 fabiensanglard staff 7,793 17 Jan 03:02 INSTALL.EXE
264 -rw-r--r-- 1 fabiensanglard staff 131,696 17 Jan 03:02 MKGAME.EXE
400 -rw-r--r-- 1 fabiensanglard staff 203,744 17 Jan 03:03 MKTERR.EXE
1704 -rw-r--r-- 1 fabiensanglard staff 870,528 17 Jan 03:02 OPTTEST.EXE
16 -rw-r--r-- 1 fabiensanglard staff 7,793 17 Jan 03:09 SC.EXE
1464 -rw-r--r-- 1 fabiensanglard staff 746,304 17 Jan 03:03 STRIKE.EXE

//
19832 -rw-r--r-- 1 fabiensanglard staff 10,150,560 17 Jan 03:03 GAMEFLOW.TRE
952 -rw-r--r-- 1 fabiensanglard staff 485,877 17 Jan 03:02 MISC.TRE
1304 -rw-r--r-- 1 fabiensanglard staff 665,456 17 Jan 03:02 MISSIONS.TRE
13544 -rw-r--r-- 1 fabiensanglard staff 6,932,708 17 Jan 03:02 OBJECTS.TRE
1760 -rw-r--r-- 1 fabiensanglard staff 899,145 17 Jan 03:02 SOUND.TRE
3288 -rw-r--r-- 1 fabiensanglard staff 1,681,738 17 Jan 03:02 TEXTURES.TRE

//
2040 -rw-r--r-- 1 fabiensanglard staff 1,042,674 17 Jan 03:05 ALASKA.PAK
2040 -rw-r--r-- 1 fabiensanglard staff 1,042,570 17 Jan 03:04 ANDMAL1.PAK
2040 -rw-r--r-- 1 fabiensanglard staff 1,042,960 17 Jan 03:09 ANDMAL2.PAK
2048 -rw-r--r-- 1 fabiensanglard staff 1,046,382 17 Jan 03:09 ARENA.PAK
2040 -rw-r--r-- 1 fabiensanglard staff 1,043,268 17 Jan 03:06 CANYON.PAK
2032 -rw-r--r-- 1 fabiensanglard staff 1,038,716 17 Jan 03:05 EGYPT.PAK
2024 -rw-r--r-- 1 fabiensanglard staff 1,033,096 17 Jan 03:07 EUROPE.PAK
656 -rw-r--r-- 1 fabiensanglard staff 333,464 17 Jan 03:02 MAPDATA.PAK
2040 -rw-r--r-- 1 fabiensanglard staff 1,044,396 17 Jan 03:03 MAURITAN.PAK
2032 -rw-r--r-- 1 fabiensanglard staff 1,037,798 17 Jan 03:04 QUEBEC.PAK
2040 -rw-r--r-- 1 fabiensanglard staff 1,043,840 17 Jan 03:08 RHODEI.PAK
2048 -rw-r--r-- 1 fabiensanglard staff 1,046,316 17 Jan 03:06 SANFRAN.PAK
2048 -rw-r--r-- 1 fabiensanglard staff 1,045,766 17 Jan 03:08 TURKEY.PAK

//
80 -rw-r--r-- 1 fabiensanglard staff 37,732 17 Jan 03:02 MSFILES.PAK

// 3D-
8 -rw-r--r-- 1 fabiensanglard staff 1,806 17 Jan 03:02 PALETTE.IFF


Documentation Related to Strike Commander




Part 3. Reverse development of resources.


Archive system


The PAK and TRE formats are 100% clear thanks to the Mario specifications .


Archives are easy to manage / unpack with TreArchive and PakArchvive in libRealSpace.

Aircraft


Aircraft are stored in full files in the IFF archives. They are 95% clear. Consist of four key parts:

  1. Aerodynamic properties.
  2. Damage system and life points
  3. Weapon system
  4. Appearance
    1. 3D data
    2. Textures

See JET format specifications .

Cards


Maps are 95% clear. They are stored in X.PAK , but also refer to textures in TEXTURES.TRE . See card format specifications .

See map texture format specifications .

Menu


The menu is 50% clear (visualization, but not logic).

No specifications yet.

Animations


Animations are 50% clear:


See animation format specifications .

Palettes


Palettes are 100% clear: see palette format specifications .

AI / game logic


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.

See a detailed review of all the techniques in the book Arc-Intelligence Intelligence for Games .

Game save


The format of saved games is 75% clear: see the format specifications of saved games .

Part 4. Start the game again.


The Strike Commander rewrite project started. The full source code can be found on github :

git clone https://github.com/fabiensanglard/libRealSpace

Engine




Aircraft / Objects










Menu




Map viewer






Graphic format






Animation Viewer






Gameplay Viewer


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 ...]

Source: https://habr.com/ru/post/339838/


All Articles