Restoration of a few games' EXEs versions
Posted: July 8th, 2015, 2:45 pm
UPDATE (Dec 25th 2015): This is a generic notice stating that this post does not have to be edited after any update to the repository or this topic; And so, possibly mentioning in this post for the last time, the update for today is the addition of versions 1.0 and 2.0 (1 and 6 episodes releases) of Blake Stone: Aliens of Gold.
UPDATE (August 28th 2015): The "wolf3d" subdirectory has been renamed "w3d_plus", now that the same codebase can be used to recreate (ignoring debugging information differences) the EXE for the DOS port of Super 3-D Noah's Ark, v1.0. The same applies to the .diff file. Other than this edit, I haven't touched the original post.
Hi,
There's been a bit weird project of mine hosted here: https://bitbucket.org/NY00123/gamesrc-ver-recreation/
I'm going to quote-and-edit some of the texts originally written by me here: http://wolf3d.darkbb.com/t3302-wolf3d-s ... estoration
There's also a relevant topic in this place: http://diehardwolfers.areyep.com/viewtopic.php?t=7098
Let's begin with telling how did I get to all of that.
Back in September of 2014, following a campaign to acquire the rights to publish the "lost" episode of Commander Keen known as "Keen Dreams", original sources for this episode were made available. These include sources not just for one, but apparently all versions of Keen Dreams originally made in the 90s for DOS, with the possible exception of 1.93 (which isn't that different from 1.92 anyway and could also be reconstructed).
It looked to me like the sources were in a relatively good state, and that the released forms were not greatly different from the originals. It's also stated that Borland C++ 2.0 was originally used to build the EXEs, and it also looks clear that a lot of the EXEs were originally packed using LZEXE 0.91.
Therefore, I decided to have a little attempt, using Borland C++ 2.0 and LZEXE 0.91 to build and pack version 1.13 (Shareware release). Turns out, I got the exact same EXE as created in 1992, byte-by-byte. I also got such results with at least a few other versions.
This looks like the main motivation behind starting the "gamesrc-ver-recreation" repository above (although originally under a different location). I think that initially, I wanted to try and recreate the Catacomb Abyss v1.13 EXE. Eventually, this followed with the Catacomb 3-D v1.0 EXE and the Catacomb Abyss v1.24 EXE. To compare, the Catacombs sources as released on June of 2014 can be used to build the Catacomb 3-D v1.22 EXE, as well as an EXE *very* close to Catacomb Abyss v1.24. However, for some reason, in order to get exactly the original v1.24 EXE, STARTTILE8 has to be edited in GFXE_ABS.EQU, but not in GFXE_ABS.H (there's some function in ID_VW_AE.ASM which shouldn't be called but is compiled into the EXE, for which this has an effect). The exact same edit is also required for recreation of the v1.13 EXE.
Eventually, I decided to fiddle with the Wolf3D/SOD sources for similar purposes, gradually adding projects for recreation of certain EXEs over time. With a few exceptions, the right tools can now be used to build original EXEs from the sources above, byte-by-byte. The EXEs I refer to are these:
- Wolfenstein 3D Shareware v1.0+1.1+1.2+1.4, Apogee releases (with cheats).
- Wolfenstein 3D Registered v1.1+1.2+1.4, Apogee releases (with cheats).
- Wolfenstein 3D Registered v1.4, early GT Interactive release.
- Wolfenstein 3D Registered v1.4, ID Software release (same EXE as in the early
GT Interactive release, except for a different logo in the signon screen).
- Wolfenstein 3D Registered v1.4, late GT Interactive release
(no three-letter code is shown after completing an episode).
- Wolfenstein 3D Registered v1.4, Activision release.
- Spear of Destiny demo v1.0, FormGen release.
- Spear of Destiny versions 1.0 (possibly with a different BSS section size) and 1.4, FormGen releases (copy protected).
- Spear of Destiny v1.4, Activision release (no copy protection).
It should be noted that the original SOD v1.0 EXE, as well as the originally released Activision EXEs (as currently available from Steam), appear to be a bit different. The former has the "LZ91" string from its first 32 bytes replaced with NUL bytes, while the latter two have "shifted" LZEXE signatures. In addition, the very beginning of the SOD v1.0 EXE has a couple of bytes differing from what you may currently get from the sources, implying an increased so-called "BSS section". The STRIPBSS tool included in the same repository wasn't made with this in mind, and I'm not sure about this. However, apparently it was very common to use modified EXEs in which the copy protection is skipped or removed, and this may further add some confusion.
There are also a few EXEs which are *not* reproduced by any project above, and there are great chances they won't be (but at least we have all of the above!):
- A release of SOD v1.4 made for FormGen, mistakenly labelled as v1.0 in the signon screen. (If it's just the v1.4 FormGen EXE, but with another signon screen, then it should be relatively easy to recreate it now.)
- Any translated release.
Later, I also got to recreate EXEs originally distributed as parts of some versions of Blake Stone, including Aliens of Gold. The currently available versions are these:
- Blake Stone: Aliens of Gold v2.1+3.0, Shareware and Registered releases.
- Blake Stone: Planet Strike v1.00+1.01.
Not remembering a lot from the two Blake Stone games, I thought that I may encounter quite large differences and a lot of code pieces removed. Turns out this wasn't really the case. 3D_MAIN.C has a couple of AOG-specific functions related to player alignment, and the AOG implementations of ShowOverhead and InputFloor have great differences from the PS implementations, but a lot is really the same. There are also a few commented out AOG-specific code pieces in the released Planet Strike sources, like Vital sprite definitions. Interestingly, there are at least a few occasion in which AOG-specific line codes apparently has different indentation (when compared to similar codebases). Furthermore, this is probably known, but it looks like the vital was "transformed" into the rotating cube during the development of Planet Strike.
As expected, though, I think that Planet Strike was started as a separate branch even before Aliens of Gold v2.1 was released. As a hint of that, the implementation of CA_LoadAllSounds in Planet Strike is the same as in the Catacomb 3-D sources, while there are minor edits in Aliens of Gold (at least in versions 2.1 and 3.0).
About all games:
I grabbed and modified GFXV_APO.H from Wolf4SDL by Moritz "Ripper" Kroll, for the restoration of Wolfenstein 3D Apogee EXEs. Similarly, I used GFXV_BS1.H definitions from the bstone port by Boris Bendovsky. I also "borrowed" a few song definitions in the very beginning from the same port. Regarding AOG restoration in general, most of the source code recreation was done using earlier research work by Braden Obrzut.
Unfortunately, there aren't exactly tools I'm aware of that can automatically compare two EXEs from different revisions of very similar source codes, given the EXEs and one source code revision as an input. Hence, the differences had to be manually located. There are still enough ways to ease the work, though. Obviously disassemblers can be used so we don't have to look just at machine code. Furthermore, Borland C++'s linker can generate a MAP file that shows the locations of most functions and variables in the EXE (as segment:offset pairs).
It's not just a matter of modifying the C/H/ASM/EQU files themselves, though. Project settings (like optimizations) had to be guessed for at least 2-3 projects, the ordering of a few source files to had to change in certain projects, there are files that should be removed from some projects (possibly most), and the Wolf3D GAMEPAL data has to be linked in different ways for different projects (either into its own segment, or as a part of the data segment).
Finally, these are still not exactly the original revisions of the sources, since we don't have access to them. However, what can be done now, is telling differences between versions as expressed in the compiled EXE files (e.g., the differences in secret elevator handling between Shareware versions 1.1 and 1.2 of Wolf3D, although these were basically known for a while).
UPDATE (August 28th 2015): The "wolf3d" subdirectory has been renamed "w3d_plus", now that the same codebase can be used to recreate (ignoring debugging information differences) the EXE for the DOS port of Super 3-D Noah's Ark, v1.0. The same applies to the .diff file. Other than this edit, I haven't touched the original post.
Hi,
There's been a bit weird project of mine hosted here: https://bitbucket.org/NY00123/gamesrc-ver-recreation/
I'm going to quote-and-edit some of the texts originally written by me here: http://wolf3d.darkbb.com/t3302-wolf3d-s ... estoration
There's also a relevant topic in this place: http://diehardwolfers.areyep.com/viewtopic.php?t=7098
Let's begin with telling how did I get to all of that.
Back in September of 2014, following a campaign to acquire the rights to publish the "lost" episode of Commander Keen known as "Keen Dreams", original sources for this episode were made available. These include sources not just for one, but apparently all versions of Keen Dreams originally made in the 90s for DOS, with the possible exception of 1.93 (which isn't that different from 1.92 anyway and could also be reconstructed).
It looked to me like the sources were in a relatively good state, and that the released forms were not greatly different from the originals. It's also stated that Borland C++ 2.0 was originally used to build the EXEs, and it also looks clear that a lot of the EXEs were originally packed using LZEXE 0.91.
Therefore, I decided to have a little attempt, using Borland C++ 2.0 and LZEXE 0.91 to build and pack version 1.13 (Shareware release). Turns out, I got the exact same EXE as created in 1992, byte-by-byte. I also got such results with at least a few other versions.
This looks like the main motivation behind starting the "gamesrc-ver-recreation" repository above (although originally under a different location). I think that initially, I wanted to try and recreate the Catacomb Abyss v1.13 EXE. Eventually, this followed with the Catacomb 3-D v1.0 EXE and the Catacomb Abyss v1.24 EXE. To compare, the Catacombs sources as released on June of 2014 can be used to build the Catacomb 3-D v1.22 EXE, as well as an EXE *very* close to Catacomb Abyss v1.24. However, for some reason, in order to get exactly the original v1.24 EXE, STARTTILE8 has to be edited in GFXE_ABS.EQU, but not in GFXE_ABS.H (there's some function in ID_VW_AE.ASM which shouldn't be called but is compiled into the EXE, for which this has an effect). The exact same edit is also required for recreation of the v1.13 EXE.
Eventually, I decided to fiddle with the Wolf3D/SOD sources for similar purposes, gradually adding projects for recreation of certain EXEs over time. With a few exceptions, the right tools can now be used to build original EXEs from the sources above, byte-by-byte. The EXEs I refer to are these:
- Wolfenstein 3D Shareware v1.0+1.1+1.2+1.4, Apogee releases (with cheats).
- Wolfenstein 3D Registered v1.1+1.2+1.4, Apogee releases (with cheats).
- Wolfenstein 3D Registered v1.4, early GT Interactive release.
- Wolfenstein 3D Registered v1.4, ID Software release (same EXE as in the early
GT Interactive release, except for a different logo in the signon screen).
- Wolfenstein 3D Registered v1.4, late GT Interactive release
(no three-letter code is shown after completing an episode).
- Wolfenstein 3D Registered v1.4, Activision release.
- Spear of Destiny demo v1.0, FormGen release.
- Spear of Destiny versions 1.0 (possibly with a different BSS section size) and 1.4, FormGen releases (copy protected).
- Spear of Destiny v1.4, Activision release (no copy protection).
It should be noted that the original SOD v1.0 EXE, as well as the originally released Activision EXEs (as currently available from Steam), appear to be a bit different. The former has the "LZ91" string from its first 32 bytes replaced with NUL bytes, while the latter two have "shifted" LZEXE signatures. In addition, the very beginning of the SOD v1.0 EXE has a couple of bytes differing from what you may currently get from the sources, implying an increased so-called "BSS section". The STRIPBSS tool included in the same repository wasn't made with this in mind, and I'm not sure about this. However, apparently it was very common to use modified EXEs in which the copy protection is skipped or removed, and this may further add some confusion.
There are also a few EXEs which are *not* reproduced by any project above, and there are great chances they won't be (but at least we have all of the above!):
- A release of SOD v1.4 made for FormGen, mistakenly labelled as v1.0 in the signon screen. (If it's just the v1.4 FormGen EXE, but with another signon screen, then it should be relatively easy to recreate it now.)
- Any translated release.
Later, I also got to recreate EXEs originally distributed as parts of some versions of Blake Stone, including Aliens of Gold. The currently available versions are these:
- Blake Stone: Aliens of Gold v2.1+3.0, Shareware and Registered releases.
- Blake Stone: Planet Strike v1.00+1.01.
Not remembering a lot from the two Blake Stone games, I thought that I may encounter quite large differences and a lot of code pieces removed. Turns out this wasn't really the case. 3D_MAIN.C has a couple of AOG-specific functions related to player alignment, and the AOG implementations of ShowOverhead and InputFloor have great differences from the PS implementations, but a lot is really the same. There are also a few commented out AOG-specific code pieces in the released Planet Strike sources, like Vital sprite definitions. Interestingly, there are at least a few occasion in which AOG-specific line codes apparently has different indentation (when compared to similar codebases). Furthermore, this is probably known, but it looks like the vital was "transformed" into the rotating cube during the development of Planet Strike.
As expected, though, I think that Planet Strike was started as a separate branch even before Aliens of Gold v2.1 was released. As a hint of that, the implementation of CA_LoadAllSounds in Planet Strike is the same as in the Catacomb 3-D sources, while there are minor edits in Aliens of Gold (at least in versions 2.1 and 3.0).
About all games:
I grabbed and modified GFXV_APO.H from Wolf4SDL by Moritz "Ripper" Kroll, for the restoration of Wolfenstein 3D Apogee EXEs. Similarly, I used GFXV_BS1.H definitions from the bstone port by Boris Bendovsky. I also "borrowed" a few song definitions in the very beginning from the same port. Regarding AOG restoration in general, most of the source code recreation was done using earlier research work by Braden Obrzut.
Unfortunately, there aren't exactly tools I'm aware of that can automatically compare two EXEs from different revisions of very similar source codes, given the EXEs and one source code revision as an input. Hence, the differences had to be manually located. There are still enough ways to ease the work, though. Obviously disassemblers can be used so we don't have to look just at machine code. Furthermore, Borland C++'s linker can generate a MAP file that shows the locations of most functions and variables in the EXE (as segment:offset pairs).
It's not just a matter of modifying the C/H/ASM/EQU files themselves, though. Project settings (like optimizations) had to be guessed for at least 2-3 projects, the ordering of a few source files to had to change in certain projects, there are files that should be removed from some projects (possibly most), and the Wolf3D GAMEPAL data has to be linked in different ways for different projects (either into its own segment, or as a part of the data segment).
Finally, these are still not exactly the original revisions of the sources, since we don't have access to them. However, what can be done now, is telling differences between versions as expressed in the compiled EXE files (e.g., the differences in secret elevator handling between Shareware versions 1.1 and 1.2 of Wolf3D, although these were basically known for a while).