Porting DOS games to modern platforms

General discussion for all topics related to DOS, Windows, Linux, consoles, etc. Anything to do with games.
Post Reply
gabonator
Newbie
Newbie
Posts: 6
Joined: Sun Dec 27, 2020 6:59 am

Porting DOS games to modern platforms

Post by gabonator »

Hello guys,

few years ago I made an experiment where I translated the disassembled code of a game (Alley Cat, Star Goose) into C++ or Javascript. It was just a proof of concept and a lot of things needed to be fixed by hand. I sporadically returned to this experiment to improve the translation process. Now it has became quite powerful and standalone and this is a result (Star goose in swift):

https://youtu.be/IaZiQrUdR9s

Anyone interested in this topic? Anyone who would like to contribute to this project? It is in C++ and there are still a lot of things to be improved. Currently I am finetuning the conversion tool to port the Xenon2 game and I am looking to extend the compatibility to Borland C applications.

Gabriel
User avatar
MrFlibble
Demoniac Demo maniac
Demoniac Demo maniac
Posts: 3730
Joined: Sun Dec 05, 2010 11:39 am

Porting DOS games to modern platforms

Post by MrFlibble »

Hi, and welcome to the forums! I fixed the YT link for you.

Did I understand correctly that your tool can work with multiple different games?

I know of several successful projects that rebuilt the code of DOS games from disassembled binaries: OpenDUNE, OpenFodder, SDLPoP, Omnispeak to name a few. But I believe each of them required some meticulous work with the disassembled code and could not become a base for putting more games through the same process (save for the manual skills acquired by the respective authors that is).

You might also find this topic of interest:
https://www.dosgames.com/forum/viewtopic.php?t=27053
gabonator
Newbie
Newbie
Posts: 6
Joined: Sun Dec 27, 2020 6:59 am

Porting DOS games to modern platforms

Post by gabonator »

Yes, exactly like that. The idea behind this project is to have a tool which can be used on any DOS application. But from my research (tested about 10 games), not every game can be ported easily. Currently it supports apps written in raw assembly and it highly depends on how the game was programmed - if the author uses some tricks for the program flow extensively (indirect calls) or some flags related operations, a lot od manual fixing is required. Star goose is very nicely written and whole application can be converted into working form almost automatically. Currently I am trying to finetune the process for a set of chosen games, write tutorial how to use these tools and then extend the support to Borland Pascal and Borland C applications.

Thank you for the links, porting commander keen was on my todo list :)
User avatar
MrFlibble
Demoniac Demo maniac
Demoniac Demo maniac
Posts: 3730
Joined: Sun Dec 05, 2010 11:39 am

Porting DOS games to modern platforms

Post by MrFlibble »

That's some very nice project, please keep us updated and good luck!
gabonator
Newbie
Newbie
Posts: 6
Joined: Sun Dec 27, 2020 6:59 am

Porting DOS games to modern platforms

Post by gabonator »

Yes, but there are some requirements though, the game binary cannot be packed or protected. In those old days there were various tricks to protect the games from copying and the hacker groups either produced "vigrin" binary of the game, or they made resident app that cracks the game during execution. Some games used even more crazy methods to protect (e.g. Storm lord which decodes just the instruction that are being executed and then encodes them back). So if there are some guys who had experience in cracking of ancient games, I would appreciate their help with finding or producing unprotected binaries (storm lord, titus the fox, arkanoid2).

The tool produces C++ code from assembly, but it requires some light skills with IDA - sometimes the disassembler does not identify all parts of the code. Especially when the game jumps to some memory location through indirect call or indirect jump. So it takes few iterations:
- unpack executable (if applicable)
- extract data segment (or whole binary blob from exe)
- ida disassembly
- cicoparser conversion asm to c++
- create host application which loads the data segment and handles dos/bios/video/input/filesystem stuff (I usually recycle it from previous project and add missing parts)
- run the app, fix parts of code where cicoparcer left marks (it will stop execution when it hits the mark and you will need to fix it, if using visual studio with edit&continue feature, it is really quick task)
- implement missing dos/other calls
- identify missing parts of code during execution of the freshly made app (indirect calls)
- ida - mark missing parts as code and generate assembly again
- convert
- build & test
- repeat if necessary

But the best part of this is - you can alter the game in any way - you have everything in control. For example I ported CDMAN to wasm, so it can run in web browser. And to provide mouse/touch support, I made small extension which handles touches and calculates shortest distance for the pacman to reach the destination.

https://rawgit.valky.eu/gabonator/Proje ... index.html

and here is source code for those who would like to see more:
https://github.com/gabonator/Projects/t ... man/source
User avatar
Frenkel
Way too much free time
Way too much free time
Posts: 545
Joined: Wed May 05, 2004 7:47 am
Location: Netherlands

Porting DOS games to modern platforms

Post by Frenkel »

gabonator wrote: So if there are some guys who had experience in cracking of ancient games, I would appreciate their help with finding or producing unprotected binaries (storm lord, titus the fox, arkanoid2).
For Titus the Fox, you could try http://ttf.mine.nu/
Groeten van Frenkel
Visit us at the Official S&F Prod. Homepage
gabonator
Newbie
Newbie
Posts: 6
Joined: Sun Dec 27, 2020 6:59 am

Porting DOS games to modern platforms

Post by gabonator »

I have partially ported another game - this time I have used C++ to javascript converter instead of C++ compiled into WASM. Still has some issues, but playable:

Rick Dangerous 2
https://l.valky.eu/dosrick2
User avatar
MrFlibble
Demoniac Demo maniac
Demoniac Demo maniac
Posts: 3730
Joined: Sun Dec 05, 2010 11:39 am

Porting DOS games to modern platforms

Post by MrFlibble »

If you haven't already, maybe it'd be a good idea to post your results at VOGONS.
gabonator
Newbie
Newbie
Posts: 6
Joined: Sun Dec 27, 2020 6:59 am

Porting DOS games to modern platforms

Post by gabonator »

Thank you for suggestion, I posted it there as well. Just for update, here is Xenon2 ported to javascript (just first level):

http://x.valky.eu/xenon2js
User avatar
MrFlibble
Demoniac Demo maniac
Demoniac Demo maniac
Posts: 3730
Joined: Sun Dec 05, 2010 11:39 am

Porting DOS games to modern platforms

Post by MrFlibble »

Nice progress!
User avatar
Frenkel
Way too much free time
Way too much free time
Posts: 545
Joined: Wed May 05, 2004 7:47 am
Location: Netherlands

Porting DOS games to modern platforms

Post by Frenkel »

Frenkel wrote:
gabonator wrote: So if there are some guys who had experience in cracking of ancient games, I would appreciate their help with finding or producing unprotected binaries (storm lord, titus the fox, arkanoid2).
For Titus the Fox, you could try http://ttf.mine.nu/
And the demo version of Titus the Fox.
Groeten van Frenkel
Visit us at the Official S&F Prod. Homepage
gabonator
Newbie
Newbie
Posts: 6
Joined: Sun Dec 27, 2020 6:59 am

Porting DOS games to modern platforms

Post by gabonator »

I have finally found some time to make a demonstration video how a game can be completely rewritten into C++ in less than 25 minutes: https://www.youtube.com/watch?v=4fAeUx8A-OE
User avatar
MrFlibble
Demoniac Demo maniac
Demoniac Demo maniac
Posts: 3730
Joined: Sun Dec 05, 2010 11:39 am

Porting DOS games to modern platforms

Post by MrFlibble »

Hey, that's very cool, thanks for sharing!

Previously you mentioned that some games lend themselves to this kind of reverse-engineering better than others, depending on the way they were coded. Can you give any more guidelines as to which games would have a higher probability of successful reverse-engineering with minimal user input? I guess that stuff like Doom or Daggerfall would not be easy (we don't need to reverse-engineer Doom, I'm just naming it as an example).
Post Reply