
Some things only get better over the years. For example, classic games designed in the DOS era are fascinating. Each one of them is a piece product made with great love. Unfortunately, the DOS platform is a thing of the past, and great products go along with it. Return them to the modern world - is this not a real gift?
How? Very simple! An interested reader, of course, remembers the emscripten project, thanks to which C ++ code can be converted to JavaScript to work in a browser. It was with his help that DOOM, Dune 2, TTD, X-COM and many others were adapted for the browser. However, this path is long and difficult. One project can take up to six months. And if you want everything at once? Is there any other way?
em-dosbox
There is another way - use DosBox. Indeed, why port each project separately, when you can port the entire DOS platform (to be exact, an MS-DOS emulator). This brilliant idea embodied
Boris Gjenero in the project
em-dosbox . This is a DosBox javascript port made using emscripten.
')
So, now I will tell you how to transfer “almost any” DOS program to the browser.
Ingredients:
- Browser
- em-dosbox (dosbox.js)
- The program works correctly in DosBox

During operation, the browser loads dosbox.js and a data packet with the program (usually a binary file with the packed directory of the source program). The dosbox.js script is nothing more than DosBox ported to JavaScript, when executed it emulates a DOS platform running a program in it.
Compiling dosbox.js
It's simple. Clone the em-dosbox repository and compile with autotools and make
git clone https://github.com/dreamlayers/em-dosbox.git cd em-dosbox ./configure make
If successful,
dosbox.html and
dosbox.js appear in the
src folder
.Improve em-dosbox performanceAdd
dosbox - memory-init-file 0 option to
dosbox_LDFLAGS in
src / Makefile.am . This option disables the generation of a memory file that is used to speed up loading. In our case, this file will be about thirty megabytes in size, which is not applicable for the browser.
dosbox_LDFLAGS = -s TOTAL_MEMORY=67108864 --pre-js pre.js --memory-init-file 0
I recommend replacing the
src / dosbox.cpp file
emscripten_set_main_loop(em_main_loop, 100, 1);
on
emscripten_set_main_loop(em_main_loop, 0, 1);
This edit will increase productivity by an order of magnitude. But you need to take into account that the target program must be smart enough and able to run at the same speed regardless of the computer performance, otherwise your program will run too fast.
To speed up the emulator, add lines to the
main function in the
src / gui / sdlmain.cpp file :
#ifdef EMSCRIPTEN EM_ASM("SDL.defaults.copyOnLock = false; SDL.defaults.discardOnLock = true; SDL.defaults.opaqueFrontBuffer = false;"); #endif
Packaging program
em-dosbox comes with a script that allows you to package the program directory into a binary file that can be used with dosbox.js. For example, to get a batch file for a Dune 2 game, just run:
If successful, the files
dune2.html and
dune2.data will be created. The HTML file is created using the
dosbox.html template (I remind you that it is in the
src folder).
Change dosbox settingsBy default, dosbox will be launched with the standard configuration. To change it, simply create a
dosbox.conf file in the program
folder . And modify the build script as follows:
Launch
So, we have three files:
- program.html
- program.data
- dosbox.js
Placing them on the server, we can run the program in the browser.
Happy New Year.
50 New Year's gifts.List of adapted gamesThe following games have been adapted for the browser using the em-dosbox:
- Abuse
- Alley cat
- Another world
- Arcade volleyball
- Arkanoid
- Battle chess
- Budokan: The Martial Spirit
- Cd man
- Colorado
- Dangerous Dave in the Haunted Mansion
- Deathtrack
- Digger
- Disney's Duck Tales: The Quest for Gold
- Doom
- Doom 2
- Dune 2
- Dyna blaster
- Earthworm Jim 2
- Fire & Forget II
- Goblins 1-3
- Golden ax
- Heretic: Shadow of the Serpent Riders
- Incredible Machine
- The
- IndyCar racing
- Krypton egg
- Lamborghini: American Challenge
- Lode runner
- Lost vikings
- The
- Metal mutant
- Micro machines
- Mine bombers
- Mortal kombat
- Pac-man
- Prehistorik
- Prehistorik 2
- Prince of Persia
- Scorched Earth: The Mother of All Games
- SimCity
- Stunts
- Supaplex
- Test drive
- Tetris
- Tower toppler
- Tyrian 2000
- Ugh!
- WarCraft: Orcs & Humans
- Wings of fury
- Winter Supersports 92
- Wolfenstein 3d
- Xonix