Reverse-engineering the game Strike Commander

In the early 90s at the forefront of the progress of PC gaming was one company: Origin Systems. Its slogan was "We create worlds" and hell, they corresponded to him: the series Ultima Crusader Wing Commander captured the imagination of players.

The creation of 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, which first appeared technology, today take for granted: texture mapping, shading to Gouraud, the change in the level of detail and dithering of colors.

My old dream was to play in her virtual reality helmet. Thanks Oculus Rift this dream became one step closer to reality.

But as it turned out, the game source code was lost and never to be released, so I decided to perform the 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 do this:



here it is:



... and maybe inspire someone to join my adventure.

the

To Strike Commander


In the early 90s flight simulators were good, but Falcon 3.0 or Flight simulator 4.0 more focused on the accuracy of the flight model, not the beautiful visualization:





The market had a lot of flight simulators and few noticed that in 1990, Origin Systems announced the creation of a new game. But that all changed after the CES 1991 in Chicago, where he was shown a demo. No one could believe that the game will have elements present at that time only in flight simulation air force: texture mapping, shading to Gouraud, fog and many others. Screenshots visible technology, much ahead of its competitors:









After 1991, the game is waited for by many. Not only because of the amazing engine and an exciting plot — RealSpace initially supported the additional equipment is very expensive and fragile accessories, welcome to any fan of flight simulator — THRUSTMASTER WEAPON CONTROL SYSTEM and THRUSTMASTER FLIGHT CONTROL SYSTEM:





You could even connect the THRUSTMASTER RUDDER:



But that was not all: the game is supported by the virtual cockpit. Mini-ThrustMaster joystick with four directions allows to move the pilot's head and track ground objects/enemy aircraft without having to use a virtual reality helmet:





the

1993: first contact


Game and its three-dimensional engine just "blew up the brain", but they require a very powerful machine:
the
    the
  • IBM PC 486-DX2 66 MHz
  • the
  • 4 MB RAM
  • the
  • at least 38 MB of hard disk
  • the Game was delivered on eleven floppy disks at 1.44 MB.


If to draw an analogy with the modern technological level, the recommended configuration would be:

the
    the
  • CPU with 8 cores and 16 GB of RAM.
  • the
  • Two GPU Nvidia Titan.
  • the
  • the Mandatory installation of 1000 GB.
  • the
  • the Game comes on five Blu-ray disc.

And just buy the game wasn't enough, still had to survive the installation process! After opening the box, the user sees 8 floppy disks (+3 for the Speech Pack):





Interesting fact: notice that the poster specified release date: Christmas 1991. The game was only completed in 1993 after a long process that Chris Robert called "the Apocalypse now of computer games".

Unpacking the game with floppyb on the hard disk and change disks 13 took a good half hour. And when you thought it was over, the game started to generate all the cards. Game size increased from 24 MB to 38 MB: four times more than any other game at the time.



Interesting fact: map was generated from a single seed (integer), is inserted in the algorithm generating pseudo-random numbers. It was a skilled technique, which allowed us to avoid increasing the amount of data on the disks due to the generation of cards after installation. If you are interested in the details of this technique, I recommend reading the book The Backroom Boys and the Chapter about the game Frontier Elite.

On 386-m PC generation card took ONE HOUR. But Origin Systems smart enough to put together with box game great sitestranny magazine in the gloomy surroundings of the world game 2012. Thanks to Sudden Death the whole process was less painful (note that on page 38 there is false advertising, promising the release of Strike Commander for Christmas 2013).

the

Strike Commander !


Finally, after these steps, players can enjoy the game... in April of 1993! Despite the fact that the game was delayed for two years, it was all that was promised the Origin, and it sold very well. Spent many a long night, fighting in battles, despite the fact that the game that was supposed to look like this:



... on minimum settings looked like this:



Overall it was enough to attract pilots and to create good memories.

the

Lost the source code


After the release of the Oculus Rift my interest in Strike Commander again increased: there were suitable "iron". Since the game was 20 years old, I was expecting that the source code is already released, but quickly came across a story about the sad history of decay Origin Systems.

In September 1992, Origin Systems was bought by Electronic Arts and about 1999, all projects were cancelled due to poor sales of Ultima 9. The company had to focus on another area in which she was also a pioneer: MMORPG Ultima Online. Many people believe that the source code and the version on the "gold" of all finished games are stored somewhere in the depths of the vault EA. However, contact with people from Wing Commander CIC, I found that all the source code is lost after the closure of the company.

Today it's hard to believe, but at that time, developers and companies were more interested in new games, and not the preservation of the "old" factor of nostalgia has not been, was not a large base of fans and such stores as modern Good Old Games. To illustrate the level of "primitiveness" control source is many stories, but perhaps the best story is "ZAP SC" 15 minutes 14 seconds

In the first day one developer managed to remove all source tree Strike Commander 900 MB. The it Department spent 72 hours on the restoration of all machines of developers. In an interview also mentioned that the code Wing Commander 1 and 2 were transferred on floppy disks: to Strike Commander, they had no network!

Interesting fact: unexpected turn of events — part of the source code was recently found former Origin developers: Wing Commander CIC keeps an offline archive that stores source code Wing Commander I and Wing Commander III. People who worked on Ultima 8, anonymous source was proposed (but rejected) the source code of "Ultima 8: Pagan". As for Strike Commander, I never heard that someone he left.

the

Reverse-engineering: is it possible?


Over the years, many teams worked on the games Origin Systems and achieved excellent results:

the
How long and how hard can it be? After talking with Gregory Montoir who performed almost the entire reverse engineering Another World, I realized that working for an hour a night, you can reverse a 10 KB Assembly code in C for the month. In Strike Commander a lot of executables, and discouraging initial time estimation was:

INSTALL.EXE 7 793 bytes : 2 weeks
MKTERR.EXE 203 744 bytes : 1.5 years
SC.EXE 20 000 bytes : 1 month
MKGAME.EXE 131 696 byte : 1 year
OPTTEST.EXE 870 528 byte : 7 years
STRIKE.EXE 746 304 bytes : 6 years
=============================================
15 years, 7 months and 2 weeks. Uh-Oh.


It might upset: if anyone started in 1993, ended six years ago, and I only had to do git clone! But launching IDA and a little after examining the files, I realized that the reverse need not all: a 3D-engine is entirely in STRIKE.EXE and a small team will be able to cope with it in a reasonable time.

the

roadmap


A road map, which I originally drew for reverse engineering Strike Commander, was this:

    the
  1. to Gather as much documentation.
  2. the
  3. to Understand the global architecture of Strike Commander.
  4. the
  5. to Perform reverse engineering of game resources.
  6. the
  7. to Document the stage 3 and extrapolate (Visual Surface Determination, Level Of Detail, etc.)
  8. the
  9. Re-implement the 3D engine and to collect NEO_STRIKE.EXE
  10. the
  11. to Add support for VR device Oculus Rift.

And I started to work.

the

Part 2. Architecture and documentation


the

Architecture


Strike Commander does not consist of one monolithic executable. To ensure the gameplay together are six executable files. The basic idea is similar to studied the Second Reality code review. Can you explain the use of multiple. EXE files:

the
    the
  • Optimisation of cooperation in the team (each employee might work on my part without affecting others).
  • the
  • Programs for real mode DOS was limited to 640 kilobytes of RAM. Big monolithic executable file would lead to increased data exchange with the drive or it would not have loaded.

After studying in IDA was found that each executable file using the system call to DOS 21h to download and run other .EXE. For example, a scene mode that enables the processing of the dialogues and cinematic cut-scenes OPTTEST.EXE. It removes itself from RAM and loads/runs the STRIKE.EXE, when the necessary three-dimensional mode.
For research and study of the components responsible for each part of Strike Commander has been very useful DosBOX. The name of the current running executable is shown in the title bar of the window:

the the the the the the the
Executable
Screenshot
notes
INSTALL.EXE

Module that runs MKGAME.EXE
MKGAME.EXE



This installer:
the
    the
  • Creates the boot disk.
  • the
  • Defines a sound card.
  • the
  • does the copy protection (the magazine in Sudden Death).
  • the
  • Unpacks 8 floppy disks.

MKTERR.EXE




card Generator creates all map elements and groups them in PAK
the
    the
  • ALASKA.PAK
  • the
  • ANDMAL1.PAK
  • the
  • ANDMAL2.PAK
  • the
  • ARENA.PAK
  • the
  • CANYON.PAK
  • the
  • EGYPT.PAK
  • the
  • EUROPE.PAK
  • the
  • MAPDATA.PAK
  • the
  • MAURITAN.PAK
  • the
  • QUEBEC.PAK
  • the
  • RHODEI.PAK
  • the
  • SANFRAN.PAK
  • the
  • TURKEY.PAK
OPTTEST.EXE



Responsible for all in-game dialogues, the cinematic insertion, menu, the choice of weapons in the hangar and view objects.
SC.EXE

Method that starts the game. Usually it loads and executes OPTTEST.EXE.
STRIKE.EXE

three-Dimensional RealSpace engine. Responsible for the active phase of the gameplay.

note: if you delete the PAK files of maps, STRIKE.EXE will detect the absence of the file and automatically runs MKTERR.EXE to generate the card. That is, most of the work is happening in OPTTEST.EXE and STRIKE.EXE. But we have not figured out how between the transmitted parameters. System call 21h DOS allows you to use command line parameters, store the data in a certain memory page, and the game state can be saved on the hard disk. IDA will tell us, as is the case in our case.

the

List of files


The important files used by the game:

//Executable files
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

//In resources
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

//Map
2040 -rw-r--r-- 1 fabiensanglard staff 1,042,674 Jan 17 03:05 ALASKA.PAK
2040 -rw-r--r-- 1 fabiensanglard staff 1,042,570 Jan 17 03:04 ANDMAL1.PAK
2040 -rw-r--r-- 1 fabiensanglard staff 1,042,960 Jan 17 03:09 ANDMAL2.PAK
2048 -rw-r--r-- 1 fabiensanglard staff 1,046,382 Jan 17 03:09 ARENA.PAK
2040 -rw-r--r-- 1 fabiensanglard staff 1,043,268 Jan 17 03:06 CANYON.PAK
2032 -rw-r--r-- 1 fabiensanglard staff 1,038,716 Jan 17 03:05 EGYPT.PAK
2024-rw-r--r-- 1 fabiensanglard staff 1,033,096 Jan 17 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 Jan 17 03:04 QUEBEC.PAK
2040 -rw-r--r-- 1 fabiensanglard staff 1,043,840 Jan 17 03:08 RHODEI.PAK
2048 -rw-r--r-- 1 fabiensanglard staff 1,046,316 Jan 17 03:06 SANFRAN.PAK

//Files the initial numbers to generate the cards
80 -rw-r--r-- 1 fabiensanglard staff 37,732 17 Jan 03:02 MSFILES.PAK

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


the

Documentation relating to Strike Commander


the

the

Part 3. Reverse engineering resources.


the

archives


Formats PAK and TRE understood by 100% thanks to specifications Mario.

the
The archives are easy to manage/unpack them using TreArchive and PakArchvive in libRealSpace.

the

the Aircraft


Planes are stored in a fully stocked files in the archives of IFF. They understood 95%. Consist of four key parts:

    the
  1. Aerodynamic properties.
  2. the
  3. damage System and glasses "life"
  4. the
  5. weapon System
  6. the
  7. appearance
      the
    1. Dimensional data
    2. the
    3. Texture

Cm. format specifications JET.

the

Maps


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

Cm. format specifications texture maps.

the

Menu


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

While spec no.

the

Animations


Animation clear 50%:

the
    the
  • Possible rendering and playback of individual layers.
  • the
  • understand the choice of palette used.
  • Unknown to the collector, uniting the layers.


Cm. format specifications animations.

the

Palette


Palettes understood by 100%: see format specifications palettes.

the

AI/game logic



Given the time and documentation found in the manual of playtester, I think that there is not a simple decision tree. Probably, hierarchical finite state machines.

Cm. detailed consideration of all the techniques in the book Arctificial Intelligence for Games.

the

Saving games


The format of saved games clear 75%: see format specification saved games.

the

Part 4. Start the game again.


Started the project of rewriting Strike Commander. Full source code can be found on GitHub:

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

the

the Engine




the

Aircraft/objects










the

Menu




the

map browser






the

graphics Format






the

viewer animation






the

viewer gameplay


Nothing yet! I really hoped that the game uses a virtual machine in the style of SCUMM. This is OPTTEST.EXE

the

Palette


The effects palette will probably be hard to recreate: when the pilot is too large overload, the screen becomes gray (and then dark, if it becomes even more G). This is accomplished by interpolation between the palettes. Here can help the Shader.





the

Oculus Rift Support


Working on the integration of Oculus Rift has not yet started. [note. lane: the latest commit in the Github project dated October of last year, so it seems, alas...]
Article based on information from habrahabr.ru

Comments

Popular posts from this blog

Powershell and Cyrillic in the console (updated)

Active/Passive PostgreSQL Cluster, using Pacemaker, Corosync

Experience with the GPS logger Holux M-241. Working from under Windows, Mac OS X, Linux