DOSBox is an open source DOS emulator designed for running old games. Emscripten compiles C/C++ code to JavaScript. This is a version of DOSBox which can be compiled with Emscripten to run in a web browser. It allows running old DOS games and other DOS programs in a web browser.
DOSBox is distributed under the GNU General Public License. See the COPYING file for more information.
Currently, DOSBox compiles and runs various real-mode games successfully. DOSBox has not been fully re-structured for running in a web browser via the Emscripten main loop. The interactive DOS prompt cannot be used and leads to a hang. DOSBox can only run programs via command line arguments.
- Emscripten issue 1975 prevents asm.js compilation in Firefox. It has been [fixed in incoming](https://github.com/kripken/emscripten/commit/04b5c9d3d434e1bf6ab0dab4 2fd27fd4a4dd0721).
- Emscripten issue 1992 prevents HTML files built by src/packager.py from working. It has also been fixed in incoming.
- Emscripten issue 1909 makes some switch statements highly inefficient. The main switch statements used for CPU emulation end up using long chains of comparisons, making DOSBox very slow. This problem does not have a proper fix. This patch is not totally correct, but it can be used and gives good performance in Firefox.
- V8 JavaScript Engine issue
2275 prevents large switch
statements from being optimized. The simple, normal and prefetch cores are
automatically transformed to avoid this issue. Case statements for x86
instructions become functions, and an array of function pointers is used
instead of the switch statements. The
--enable-funarrayconfigure option controls this. - The same origin policy prevents access to data files when running via a
file:// URL in Chrome. Use a web server such as
python -m SimpleHTTPServerinstead. - In Firefox, ensure that dom.max_script_run_time is set to a reasonable value that will allow you to regain control in case of a hang.
- Firefox may use huge amounts of memory when starting asm.js builds which have not been minified.
Ensure that Emscripten has fixes for issues noted above. Use incoming and/or
manually apply patches as needed. Then simply configure with emconfigure ./configure and build with make. This will create src/dosbox.js which
contains DOSBox and src/dosbox.html, which is a web page for use as a
template by the packager. These cannot be used as-is. You need to provide
DOSBox with files to run and command line arguments for running them.
Web pages for running DOS programs can be created using src/packager.py. If
you have an executable which needs no other files such as Gwbasic.exe, you
can package it via ./packager.py gwbasic Gwbasic.exe. That will create
gwbasic.html and gwbasic.data. Placing those in the same directory as
dosbox.js and viewing gwbasic.html will run the program. If you need to
package multiple files, place them in a directory, and package that directory,
specifying which executable to run. For examle, if Major Stryker is in
subdirectory major_stryker, package it using ./packager.py stryker major_stryker STRYKER.EXE. Again, place stryker.html and stryker.data in
the same directory as dosbox.js and view stryker.html to run the game.
Remember that the same origin policy prevent access to data files in some
browsers when using file:// URLs.