Porting DOS games to modern platforms

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

Porting DOS games to modern platforms

Post by gabonator »

you mean this line?

Code: Select all

cmake -DCAPSTONE_BUILD_TESTS=OFF -DCAPSTONE_ARCHITECTURE_DEFAULT=OFF -DCAPSTONE_X86_SUPPORT=ON ..
should be changed to this?

Code: Select all

cmake -G "MinGW Makefiles" -DCAPSTONE_BUILD_TESTS=OFF -DCAPSTONE_ARCHITECTURE_DEFAULT=OFF -DCAPSTONE_X86_SUPPORT=ON ..
Short guide: cicodis places stop(xyz) when not sure how some piece of code should be transformed. This internally triggers an assertion, so you need some IDE to debug it. Some games do not properly mark end of the function and cicodis continues disassembling the data part which follows. In this case you need to pass "-terminator 01ed:fb8f" as in https://github.com/gabonator/Projects/b ... es/cico.sh
Otherwise it should not crash on most real mode games (most games made before 1993). Please send me link to the game you are converting.
Finding the right flags: There is some recommended set of flags, e.g.

Code: Select all

-load 01ed -ctx -reloc -segofscomment -stackguard -recursive start
Load address is set to match how DOSBOX loads the game, so I can compare generated code side by side with dosbox debugger.
Finding the tables - simply run the game and wait util it reaches some "callIndirect" function. It should throw an assertion in Visual Studio, note down the segment and offset (arguments to callIndirect) and add to the commandline

Code: Select all

-indirect 1234:5678
, keep adding missing methods until you will get something like

Code: Select all

-indirect 2da3:0cb7,2a41:0359,2188:3f13,2188:1fb9,2188:2850...
. This is the slowest method, more efficient is to look at the code, understand the jump/call table and add some record like

Code: Select all

-jumptable 1020:42e6 168f:6efb 30 callwords bx
. First address is the address of indirect call, then the address of the table, number of entries, what kind of entries are stored there and which register is used as index. This might be a bit complicated at first, so I recommend the first approach.

To get more familiar with CLI interface, just look for cico.sh scripts in the https://github.com/gabonator/Projects/t ... it/gamelib folder
User avatar
pilipalipeli
Newbie
Newbie
Posts: 2
Joined: Mon Jan 27, 2025 10:49 pm

Porting DOS games to modern platforms

Post by pilipalipeli »

gabonator wrote: you mean this line?
Yes, cmake defaulted to visual studio at first for me, but that seemed to fix it.
Maybe I should switch to using vc++ anyway.
Please send me link to the game you are converting.
I tried to port two games bubble bobble (bubble.exe) and outrun (outega.exe, after unpacking it).

Both of these give me similar error when i attempt to run cicodis with "-load 01ed -ctx -reloc -segofscomment -stackguard -recursive start"
Assertion failed: 0, file ../download/cicodis.cpp, line 1107
043b:7e49 Cannot disassemble in sub_c09e()
I don't really much any clue what I'm doing.
The only game I got working was Goose. (the demo)
The Tetris game compiled, but the game exits when I try to run it. Maybe can't find assets? Not sure.
Other games won't even compile.

I can't get the cico,sh scripts to work properly under windows. I'll try under Linux later.
gabonator
Member
Member
Posts: 13
Joined: Sun Dec 27, 2020 6:59 am

Porting DOS games to modern platforms

Post by gabonator »

Thanks for the cmake fix,

use -trace switch so you can see which was the instruction which couldn't be disassembled. Then add -terminator 1234:5678 with the failing address. Depending on the complexity of the game, there will be some places which need to be fixed manually (see the .patch files in gamelib folder). You will need to run it in some IDE to make the fixing easier.

regarding bubble bobble - bubble.exe is only the loader which executes bubbob.dat (real game binary). You will need to unpack it with UNP first
Post Reply