Re: Restoration of a few games' EXEs versions
Posted: August 30th, 2015, 1:05 pm
This is very interesting! Amazing work on restoring Super 3D Noah's Ark!
Keeping the classics alive... together
https://classicdosgames.com/forum/
Thanks for showing interest in this work!MrFlibble wrote:This is very interesting! Amazing work on restoring Super 3D Noah's Ark!
This is a nice idea and can be good for a challenge. One possible difficulty is that I've dealt only with 16-bit real mode applications for DOS built using Borland C++ 2.0/3.0/3.1 so far. ROTT and Greed surely don't seem to fit in this category. There may also be a little bit of difficulty in the case of ROTT as the DOS/4GW extender appears to be built-in the EXE. It is at least separate for Greed, though.MrFlibble wrote:BTW, would you be interested in restoring executables for the different versions of Rise of the Triad and In Pursuit of Greed? I think In Pursuit of Greed could be interesting because the game changed quite a lot from the early demo versions to the final release.
This is also an interesting idea, although I don't see myself doing this any time soon.On another note, do you plan to make an enhanced DOS port of Wolf3D based on your findings generally and the restored S3DNA code in particular?
Code: Select all
diff -r 789c61553acd w3d_plus/ID_SD.C
--- a/w3d_plus/ID_SD.C Fri Aug 28 16:36:20 2015 +0300
+++ b/w3d_plus/ID_SD.C Wed Sep 23 00:40:22 2015 +0300
@@ -2126,9 +2126,9 @@
{
case 0x51:
length = MIDI_VarLength();
- tempo = ((long)(*midiData)<<16) + (long)((*(midiData+1))<<8) + (*(midiData+2));
+ tempo = ((long)(*midiData)<<16) + ((long)(*(midiData+1))<<8) + (*(midiData+2));
midiTimeScale = (double)tempo/2.74176e5;
- midiTimeScale *= 1.1;
+ //midiTimeScale *= 1.1;
midiData += length;
break;
case 0x2F:
You're welcome!MrFlibble wrote:Thanks for the update! This is some really cool research.
As hinted in this topic beforehand, I think it usually is not very interesting for the audience (and the programmer) to have a list all differences between versions, smaller or larger, in a change log. I do guess, though,that all changes can be found for games being open source from the very beginning, especially with sources being updated in a central public repository. Open source ports of games originally available with no source codes are probably covered as well.BTW, do you know if any similar detailed descriptions of code "evolution" exist for other games? The Cutting Room Floor Wiki aims to catalogue differences in assets/media, but frankly I don't know anything related to code except listing differences that can be observed in game behaviour.
While this can surely be tempting (although it depends on the mood), and these games are also based on Wolf3D, I'm afraid that I probably won't take care of any of these soon.MrFlibble wrote:I think I forgot to ask, do you have plans to process the executables of Corridor7 and Operation Body Count in a similar fashion?
This greatly depends on multiple factors, including:If I understood your method correctly, you have combined reverse-engineering of game executables with references to the source code. I wonder how more difficult it would be to restore the code from scratch, without any source code?
I feel like the time to do the work is a combination of more than one factor, so it can be a bit difficult to estimate. Maybe about half a year for an early game from ~1990, *if* there no use of features like encryption, and it doesn't take a lot of time to figure out file formats in use (already knowing these is of course the simplest case); Oh, and that's under the assumption that, on average, at least a few hours are spent on this per day, of course.For example, Bethesda Softworks' The Elder Scrolls: Arena and The Terminator: Rampage use a 2.5D engine with a feature set largely similar to the Wolf3D engine. How much work do you estimate it would require to recreate the source code of these games by decompiling/reverse-engineering the respective executables (not necessarily with the aim of getting the code to compile back into byte-by-byte identical EXEs)?
Apparently, this is a viable alternative to decompilation of the executable. Hendricks266 suggested that he plans on producing a version of Blood (and possibly other Build engine games) that runs natively on modern systems in a similar fashion.The problem with remaking games is that usually the remakes are abandoned at some stage and never finished. This means that all the work put into such remake is lost, as it usually isn't finished enoughly to be used. Making games requires lots of time, and often volunteers do not have enough will to finish the project.
Bearing this in mind, I've decided I won't try to remake the game from start. Instead, I've learned binary formats of EXE and DLL files, and modified the Dungeon Keeper executable file to become a DLL.
With my new DLL, I was able to create very simple executable file which may be used as complete code to run the game. Now I'm incrementally rewriting DK; functions which are not yet rewritten are called from the DLL, so the project functions like whole game, even though it wasn't completely rewritten yet.
Many functions are already rewritten and fixed. Structure of the code allows to take advantages of every rewritten part, by fixing bugs and making new functions. The project is open-source, and its code is downloadable here. [emphasis added]
I think that in Hendricks266's example, the idea is running the engine code (which is open source) as-is, while most of the Blood-specific code (from BLOOD.EXE) will be run under an x86 emulator. Some JIT compilation may be used for the latter. Basically, it's a mix of emulated/translated x86 and native code, while hardware accesses (e.g., port reads/writes) are appropriately translated.K1n9_Duk3 wrote:I doubt that turning DOS executables into DLLs is going to work, at least as far as executing low-level hardware stuff is concerned. On WinXP and above, you can't even read/write ports from a Win32 program. Only device drivers are allowed to execute such instructions. I don't know a thing about the structure of a DLLs and EXEs, so I can't say if it would be possible to actually convert a DOS executable into a Windows DLL in the first place.
It is great to read about this from you! This includes the point about learning x86 assembly and DOS-related stuff on the way. I do share the sentiment, that getting something like this to compile is less difficult than getting it to compile *and* run well.As for recreating source code from scratch, I can confirm that it would take roughly half a year to get something decent. My first attept at disassembling a game and porting the assembly code back to C code took about two months. The game's file formats were already well documented, but I had never written any x86 assembly code before, nor had I programmed any DOS games in C. I used a manual to look up what each assembly instruction does, and I wrote little test programs and disassembled them to figure out how the compiler translates certain code patterns into assembly code. After those two months, I had code that compiled properly, but it had tons of bugs.
Oh yeah, these are all true. There are cases in which a sufficiently similar EXE (say, differing by just 1000 bytes) may be ok, but getting even to that is quite a challenge, especially without having original sources. As it should be clear for some, in order to even try and reproduce original machine code as-is, there are various factors that one should take into account, apart from the source code itself; These are project settings and versions of tools in use (e.g., compiler and linker), if not more than these.The biggest issue is that when you are manually converting assembly code into C code, you are bound to make mistakes here and there. Unless you manage to reproduce the original EXE byte-by-byte, you can't say for sure that the C code you created is equivalent to the C code that was used to build the original EXE. That's actually one of the big problems in computer science. If you're lucky, the game has a demo record/playback feature that makes it easier to detect where the new EXE differs from the old one.
Heh, I forgot that there's a topic about the Keen 1-3 recreation in these forums! Re-using the demo routines surely made me discover a few differences from vanilla Keen 1-3, including some jump height miscalculations, as-well-as a minor episode-specific thing in Vorticon's behaviors (Vorticon's state changes to "jumping" upon falling from a floor, but only in Keen 2-3).When NY00123 (and others) were working on the Commander Keen 1-3 recreation, they actually made a patch that unlocked the demo record/playback routines in the original executable, so that the reimplementation could be tested against the original game. But that will only prove that the new EXE differs. It can't actually prove that the new EXE is equivalent to the old one.
This reminds me of a case where I had to force some right shift being signed, or maybe unsigned; I don't recall now. This was required in order to make a bridge in some Keen 2 level operate as expected (when using a switch).In some cases, I had to disassemble my new executable to track down the bugs. Stupid stuff like having to use "myfunction((x >> 8))" instead of "myfunction(x >> 8)" because the stupid compiler decided to convert x to a byte value before doing the shift operation...
Heh, these ideas have surely been tempting; Especially the fact that DOS support was "skipped" while doing Chocolate Keen.K1n9_Duk3 wrote:Speaking of Keen 1-3, did you ever intend to recreate the original EXE versions for that or at least port Chocolate Keen back to DOS?