![banner](https://private-user-images.githubusercontent.com/11459433/331739564-eea5c05c-8175-4417-9fed-990ca22190e5.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTg3OTY3ODgsIm5iZiI6MTcxODc5NjQ4OCwicGF0aCI6Ii8xMTQ1OTQzMy8zMzE3Mzk1NjQtZWVhNWMwNWMtODE3NS00NDE3LTlmZWQtOTkwY2EyMjE5MGU1LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA2MTklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNjE5VDExMjgwOFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTQ4M2FlNmM0OGMzMWI2ZjVkYWUwZjgzZTU4M2FhMTdmNDdjMTUwZDI2MDgwYTBmZjk2NjdhOGE4ZjNhNWY3ZTYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.QH7Wqoj389SpNtAotO5HrO84HjESL2WpA-Drto58aMU)
The reverse engineered DOS game ShortLine v1.1. (DOKA 1992)
The original game can be downloaded from the link below (version 1.1): https://www.old-games.ru/game/download/1232.html
![reSL](https://private-user-images.githubusercontent.com/11459433/331741201-35f3f24b-b513-44ed-a5a8-17c03803bbab.gif?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTg3OTY3ODgsIm5iZiI6MTcxODc5NjQ4OCwicGF0aCI6Ii8xMTQ1OTQzMy8zMzE3NDEyMDEtMzVmM2YyNGItYjUxMy00NGVkLWE1YTgtMTdjMDM4MDNiYmFiLmdpZj9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA2MTklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNjE5VDExMjgwOFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPThmNGFmNTI4Y2FiZmUzMDZjNTRlYmVlYmJhOTNlMzkzMGM5MmE1MTIwNzVmNTQ0M2VlZTllNTc1NGNjMjY2NmImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.nCCDqXlDzoQagmmOMtwr9sjSdyBrlyMfTisYyzQWWCw)
- Disassembled most of the binary code.
- Reimplemented in C++ some functions:
- loading the state from original game save files.
- drawing the world (all objects on the game field).
- drawing the game field header.
- loading the original game records file and drawing records screen.
- train movement logic
This project does not pursue any profit and will not be used for commercial purposes. The goal of the project is to gain fun and experience, as well as to port my favorite childhood game to modern mobile platforms, adapt it to touch controls.
I initially started reverse engeneering the second version. But I soon realized that:
- this game is a bit different from the one I played in childhood.
- moreover it works much worse - there are no animations, the screen blinks when switching menus.
- v2.0 is written on Pascal using BGI library. But v1.1 is written on TurboC using assembler parts for working with graphics and to implement some tricky mechanics (ShortLine even uses coroutines written on assembler!).
So, v1.1 works better and it's much more interesting to decompile.
md5 hash of the file I decompiled (see the link to download above):
d3516ca38a6e17a7326141794a041212 SL.EXE
I use Ghidra as a main tool: https://github.com/NationalSecurityAgency/ghidra
At the first step I want to restore the code as close to original program as possible. At this stage it's useful to use a code structure that is close to the original. Thus, I even currently use an ineffective "emulator" of the VGA adapter instead of normal graphics functions.
Every function/global variable has a comment like /* 18fa:08d6 */
. This is an address of the function/variable in the original binary. It helps a lot not to be confused while working and also might be interesting for newbies who want to compare the restored code with how it looks in the decompiler.
![Снимок экрана 2024-05-04 в 01 45 21](https://private-user-images.githubusercontent.com/11459433/327897535-8573c2d1-270a-4dd9-b9cf-f0b8bc43b311.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTg3OTY3ODgsIm5iZiI6MTcxODc5NjQ4OCwicGF0aCI6Ii8xMTQ1OTQzMy8zMjc4OTc1MzUtODU3M2MyZDEtMjcwYS00ZGQ5LWI5Y2YtZjBiOGJjNDNiMzExLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA2MTklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNjE5VDExMjgwOFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWU2MTU4MmFjNGZkODBkZTc0ZDkzMzYzMDE5MGY3MDU5YmUwMTg0N2M5NzEzOWM2YjdmNDE5NzMzY2RiMzMwMGQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.VuLskdh3zSvqxvWBqgQu_IyXszq6RZR-hUX3jghIW4Y)
After all the code has been rewritten, in the second stage, I will optimize the code for modern platforms and adapt the game to a touch interface.
To build reSL you will need:
Open the Terminal application and execute the following instructions:
# install dependencies
brew install cmake sdl2
# prepare the build folder
mkdir -p build && cd build
# run cmake
cmake -DCMAKE_BUILD_TYPE=Release ..
# build the project
cmake --build . -j4
# enjoy!
./resl
Open the terminal application and execute the following instructions:
# install dependencies
sudo apt install -y cmake libsdl2-dev
# prepare the build folder
mkdir -p build && cd build
# run cmake
cmake -DCMAKE_BUILD_TYPE=Release ..
# build the project
cmake --build . -j4
# enjoy!
./resl
The original game was created by Doka in 1992.
So, it's very old and now it's not clear how to contact the authors to get permission to reverse engineer their product. I hope they don't mind me giving the game a second life and adapting it to modern platforms.
I don't plan to make any profit, this project is just for fun. The rights to all algorithms in the restored code belong to the authors of the original game (Andrei Snegov, DOKA).