An Emscripten port of DOSBox


DOSBox ported to Emscripten


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.


Em-DOSBox runs most games successfully in web browsers. Although DOSBox has not been fully re-structured for running as an Emscripten main loop, most functionality is available thanks to emterpreter sync. A few programs can still run into problems due to paging exceptions.

Other issues

  • Game save files are written into the Emscripten file system, which is by default an in-memory file system. Saved games will be lost when you close the web page.
  • Compiling in Windows is not supported. The build process requires a Unix-like environment due to use of GNU Autotools. See Emscripten issue 2208.
  • Emscripten issue 1909 used to make large switch statements highly inefficient. It seems fixed now, but V8 JavaScript Engine issue 2275 prevents large switch statements from being optimized. Because of this, the simple, normal and prefetch cores are automatically transformed. Case statements for x86 instructions become functions, and an array of function pointers is used instead of the switch statements. The --enable-funarray configure option controls this and defaults to yes.
  • The same origin policy prevents access to data files when running via a file:// URL in some browsers. Use a web server such as python -m SimpleHTTPServer instead.
  • 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.
  • The FPU code uses doubles and does not provide full 80 bit precision. DOSBox can only give full precision when running on an x86 CPU.


Use the latest stable version of Emscripten (from the master branch). For more information see the the Emscripten installation instructions. Em-DOSBox depends on bug fixes and new features found in recent versions of Emscripten. Some Linux distributions have packages with old versions, which should not be used.

First, create ./configure by running ./ Then configure with emconfigure ./configure and build with make. This will create src/dosbox.js which contains DOSBox and src/dosbox.html, 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.

This branch supports SDL 2 and uses it by default. Emscripten will automatically fetch SDL 2 from Emscripten Ports and build it. Use of make -j to speed up compilation by running multiple Emscripten processes in parallel may break this. Once SDL 2 has been built by Emscripten, you can use make -j. To use a different pre-built copy of Emscripten SDL 2, specify a path as in emconfigure ./configure --with-sdl2=/path/to/SDL-emscripten. To use SDL 1, give a --with-sdl2=no or --without-sdl2 argument to ./configure.

Emscripten emterpreter sync is used by default. This enables more DOSBox features to work, but requires an Emscripten version after 1.29.4 and may cause a small performance penalty. To disable use of emterpreter sync, add the --disable-sync argument to ./configure. When sync is used, the Emscripten memory initialization file is enabled, which means dosbox.html.mem needs to be in the same folder as dosbox.js. The memory initialization file is large. Serve it in compressed format to save bandwidth.


WebAssembly is a binary format which is meant to be a more efficient replacement for asm.js. To build to WebAssembly instead of asm.js, the -s WASM=1 option needs to be added to the final emcc link command. There is no need to rebuild the object files. You can do this using the --enable-wasm option when running ./configure. Since WebAssembly is still under very active development, use the latest incoming Emscripten and browser development builds like Firefox Nightly and Chrome Canary.

Building with WebAssembly changes the dosbox.html file. Files packaged using a dosbox.html without WebAssembly will not work with a WebAssembly build.

Running DOS Programs

To run DOS programs, you need to provide a suitable web page, load files into the Emscripten file system, and give command line arguments to DOSBox. The simplest method is by using the included packager tools.

The normal packager tool is src/, which runs the Emscripten packager. It requires dosbox.html, which is created when building Em-DOSBox. If you do not have Emscripten installed, you need to use src/ instead. Any packager or repackager HTML output file can be used as a template for the repackager. Name it template.html and put it in the same directory as

The following instructions assume use of the normal packager. If using repackager, replace with You need Python 2 to run either packager.

If you have a single DOS executable such as Gwbasic.exe, place it in the same src directory as and package it using:

./ gwbasic Gwbasic.exe

This creates gwbasic.html and Placing those in the same directory as dosbox.js and viewing gwbasic.html will run the program in a web browser:

Some browsers have a same origin policy that prevents access to the required data files while using file:// URLs. To get around this you can use Python's built in Really Simple HTTP Server and point the browser to http://localhost:8000.

python -m SimpleHTTPServer 8000

If you need to package a collection of DOS files. Place all the files in a single directory and package that directory with the executable specified. For example, if Major Stryker's files are in the subdirectory src/major_stryker and it's launched using STRYKER.EXE you would package it using:

./ stryker major_stryker STRYKER.EXE

Again, place the created stryker.html and files in the same directory as dosbox.js and view stryker.html to run the game in browser.

You can also include a DOSBox configuration file that will be acknowledged by the emulator to modify any speed, audio or graphic settings. Simply include a dosbox.conf text file in the package directory before you run ./

To attempt to run Major Stryker in CGA graphics mode, you would create the configuration file /src/major_stryker/dosbox.conf and include this body of text:


Then package it using:

./ stryker-cga major_stryker STRYKER.EXE


Most of the credit belongs to the DOSBox crew. They created DOSBox and made it compatible with a wide variety of DOS games. Ismail Khatib got DOSBox to compile with Emscripten, but didn't get it to work. Boris Gjenero started with that and got it to work. Then, Boris re-implemented Ismail's changes a cleaner way, fixed issues and improved performance to make many games usable in web browsers. Meanwhile, Alon Zakai quickly fixed Emscripten bugs which were encountered and added helpful Emscripten features.

  • EmDosBox does not work on 32 bit version of Chrome

    EmDosBox does not work on 32 bit version of Chrome

    I tried games from on different computers, but I can't run these games on 32bit version of Chrome on Windows 10 and 7. But 64bit version works well. Do you have this problem too ?

    opened by MartySVK 16
  • Broken resolution (scaling artifacts or something)

    Broken resolution (scaling artifacts or something)

    With empty dosbox.conf and otherwise default settings of anything:


    Somehow output resolution of canvas does not match internal resolution. Please help identify cause. This is not due to scaling on CSS/DOM side, because contains these artifacts too. Therefore it happens somewhere before..

    opened by xpl 13
  • dosbox.js and dosbox.html packaging problem.

    dosbox.js and dosbox.html packaging problem.

    I would like to question regarding em-scripten. I do not speak much English.Please understand.

    I want use em-dosbox very strongly. but, im cannot this program. Im not programmer. That(em-scripten) is so hard to me.

    I tried packaging with em-scripten.(my step below)

    1. install em-scripten. (*cf : my system : windows7)
    2. download and extract em-dosbox0.74 to "C:\temp\em-dosbox-dosbox-0.74"
    3. run cmd , and prompt move "C:\temp\em-dosbox-dosbox-0.74"
    4. typing "emconfigure ./configure"

    then, error code printed.(below)

    D:\Temp\em-dosbox-dosbox-0.74>emconfigure ./configure ERROR root: Exception thrown when invoking Popen in configure with args: "./configure"! Traceback (most recent call last): File "C:\Program Files\Emscripten\emscripten\1.12.0\emconfigure", line 24, in shared.Building.configure(sys.argv[1:]) File "C:\Program Files\Emscripten\emscripten\1.12.0\tools\", line 1087, in configure process = Popen(args, stdout=stdout, stderr=stderr, env=env) File "C:\Program Files\Emscripten\python\\lib\", line 711, in init errread, errwrite) File "C:\Program Files\Emscripten\python\\lib\", line 948, in _execute_child startupinfo) WindowsError: [Error 2]


    I was so confused right now. I can not imagine what the error is resolved at all, whether to do.

    Can you provide an easy guide for beginners?

    opened by heonybaby 13
  • iOS issue with em-dosbox

    iOS issue with em-dosbox


    I'm using em-dosbox on my site It works great in every environment except iOS. The programs just seem to crash after a few seconds. I'm thinking it could be related to memory. Can you check out on an iOS device and let me know what you think the issue could be?

    opened by byte4byte 7
  • Compiler frontend failed to generate LLVM bitcode, halting

    Compiler frontend failed to generate LLVM bitcode, halting

    Hello, after using this tuto ( for installing em-dosbox , I get an error when I try to make. The error is : dosbox.cpp:398:3: error: use of undeclared identifier 'emscripten_force_exit' emscripten_force_exit(em_exitarg); 1 error generated Could you help me please.

    opened by DiGGeR2 7
  • Internet Explorer 11: Exception thrown - 'isScreen' is undefined

    Internet Explorer 11: Exception thrown - 'isScreen' is undefined

    I compiled em-dosbox according to the instructions in the Wiki. After that I tried to run a pure instance of DOSBox (without any additional software), just using the default dosbox.html file. It will run without any problem in Chrome or Firefox, however an Exception will be thrown when using Internet Explorer 11 in Windows 7.

    "isScreen" is undefined
    dosbox.js Line 1 Column 28211

    The status bar just displays that an Exception had been thrown, the DOSBox canvas will remain empty.

    opened by ghost 6
  • shared:ERROR: emcc: EMTERPRETIFY is not supported by the LLVM wasm backend

    shared:ERROR: emcc: EMTERPRETIFY is not supported by the LLVM wasm backend

    shared:ERROR: emcc: EMTERPRETIFY is not supported by the LLVM wasm backend

    Getting this error. If I compile with --DISABLE-SYNC it completes but the result doesn't work. What version of Emscripten should I use to compile. I tried a few different releases but get different errors every time. This is with latest-upstream

    opened by chronic8000 5
  • save the state of a running application/game

    save the state of a running application/game

    Seen in the code there are methods 'pause MainLoop', 'resume MainLoop'. Is it possible to save the state of a running application/game to the next start DOSBOX be able to start from the same place?

    opened by KuznetsovVN 5
  • Corrupt visuals with new emscripten

    Corrupt visuals with new emscripten

    screenshot showing corrupt characters, and the fact the drive wasn't mounted

    I upgraded to emscripten 1.35.0 because I wanted to see if that would mean better performance etc.

    This lead to corrupt onscreen characters. Is this perhaps an issue with emscripten itself?

    opened by hikari-no-yume 5
  • ISO file support in CDROM module

    ISO file support in CDROM module

    I believe you can safely re-enable ISO support in em-dosbox. The mutex functionality isn't supported in the SDL2 port, but that's partly because Javascript is inherently single threaded. The necessary functionality is in the language itself.

    Give this a try and see if it meets with your approval.

    opened by jbanes 5
  • emdosbox boot from a diskette image is possible?

    emdosbox boot from a diskette image is possible?

    Hello! I am following your project and I am very excited to be more advanced tests!

    First, I need to know if I can boot en-dosbox with an image of floppy or hard drive? If possible which way to do this? as emdosbox upload a file "dosbox.conf"? I tested and I could not success. I created a folder "/boot" and inside copied an image of floppy (BOOT98.IMG) and dosbox.conf also. But to try to compile I get an error that is missing a third parameter?

    My command is: ./ novoboot boot ("novoboot" is a folder compiled, "boot" is a folder name.)

    root@em-dosbox:~/em-dosbox/src# ls 1Feitos dosbox.cpp fpu pre.js 1loader dosbox.html gui boot dosbox.ico hardware misc shell cpu dosbox.js ints debug dosbox.o libs winres.rc dos emterpretify.txt Makefile platform

    root@em-dosbox:~/em-dosbox/src# ./ novoboot boot

    When packaging directory, supply file to run as 3rd argument.

    The dosbox.conf file is:

    [dosbox] memsize=64 machine=svga_s3 [cpu] cycles=max core=auto [autoexec] imgmount a "BOOT98.IMG" -t floppy boot -l a

    I test it under dosbox-0.74 official release and run ok! My intention is load under emdosbox small hard-disk image with vintage OS´s. If possible, I can create the packages (using under Windows 7 64? Sorry for my writing, I am using the translator. Thank you in advance!

    opened by felixcatx 5
  • Why I abandoned this

    Why I abandoned this

    In the distant past I spent a lot of time playing MS-DOS games. After I started university in 1995, it was already more about revisiting old favourites than about simply playing games. For years after university I still had an old PC with DOS games, using it rarely, and eventually not using it anymore. I also have a DOS games directory on my current PCs, and DOSBox installed, but I practically never run it. I've probably spent less than an hour in DOSBox over the last year, and virtually no time running it in a web browser. I recently fixed the old PC with DOS games, and I still don't care about gaming there.

    When I started this port I was already practically done with DOS gaming, but porting DOSBox to the web was an interesting challenge and a way to leverage any remaining interest in DOS. I loved doing that initially. But after it became popular my own experience became more about pleasing others than about doing something I loved.

    I feel bad about not even reading issues posted on here. But I feel worse about doing work for free only out of a sense of obligation. I don't know how this could become something I love doing again.

    opened by dreamlayers 3
  • em-dosbox compile fix

    em-dosbox compile fix

    used the advice from here[email protected]/msg08678.html

    opened up codeblocks imported all the src files then replaced the instances

    had to modify the makefile to use .bc instead of html so a --preload-file can be attached to it.

    used this line am__append_1 = -s ASYNCIFY=1 -s EMTERPRET[email protected] -s FETCH=1 --preload-file media/

    was not able to compile the bc to html and have it work so the preload was added during build. for some reason it needs a folder probably as a filesystem before the packager html's can be loaded

    opened by netpipe 0
  • friendlier window title

    friendlier window title

    I came across this playing the excellent MS-DOS Game collection at the Internet Archive, great work! I was confused by the games there putting, e.g. "DOSBox SVN, CPU speed: 3000 cycles, Frameskip 0, Program: STUNT" in the window title (thus browser tab and browser history). Tabs and dropdowns cut off the end of this so you don't see what program you're running and it's quite confusing.

    Em-DOSBox's GFX_SetTitle() in src/gui/sdlmain.cpp sets the title to the nerdy "DOSBox %s, CPU speed: %8d cycles, Frameskip %2d, Program: %8s",VERSION,internal_cycles,internal_frameskip,RunningProgram) a friendlier layout with the key information first would be "STUNT running in Em-DOSBox v. SVN (CPU speed: 3000 cycles, Frameskip 0)

    (the misleading version "number" SVN comes from src/platform/visualc/config.h).

    opened by skierpage 1
  • working offline html?

    working offline html?

    HTML Js dos in a folder drag into browser? How can i do this. before you give me npx commands where do i inject those when i do it on npm its says i does not have permission to install stuff

    opened by ghost 0
  • Recipe for target 'dosbox.html' failed

    Recipe for target 'dosbox.html' failed

    I got Emscripten using emsdk.

    I have confirmed that Emscripten works fine via a test that Emscripten has.

    The exact error looks likes this: ERROR:root:'/home/user/emsdk/emsdk/clang/e1.38.12_64bit/binaryen/bin/asm2wasm dosbox.temp.asm.js --total-memory=134217728 --trap-mode=allow -03 --mem-init=dosbox.html.mem --mem-base=1024 -o dosbox.wasm' failed

    It is able to output dosbox.js but after the error message appears the file is deleted.

    The directory contains dosbox.html.mem, and dosbox.js.orig.js as well.

    Edit: I'm using the latest LTS version of Ubuntu (64bit).

    opened by xubiod 2
Boris Gjenero
Boris Gjenero
A single header C++ wasm frontend library leveraging Emscripten

Livid Livid is a single header C++ wasm frontend library leveraging Emscripten. Usage The code looks something like this: #include "livid/livid.hpp" #

Mohammed Alyousef 19 Nov 26, 2022
Cross-platform, Serial Port library written in C++

Serial Communication Library (Linux and OS X) (Windows) This is a cross-platform library for interfacing with rs-232 serial like ports written in C++.

William Woodall 1.7k Dec 30, 2022
Lean4 port of Arduino balance car controller

lean4-balance-car This is a small proof-of-concept exercise to show a Lean 4 program controlling a real robotics platform which requires low latency c

Galois, Inc. 31 Jul 11, 2022
QEMU port for t8030

QEMU README QEMU is a generic and open source machine & userspace emulator and virtualizer. QEMU is capable of emulating a complete machine in softwar

null 1.7k Jan 4, 2023
C++11 port of docopt

docopt.cpp: A C++11 Port Contents docopt creates beautiful command-line interfaces Isn't it awesome how getopt (and boost::program_options for you fan

null 983 Dec 26, 2022
Trial port of the rtf_433 Library for use with OpenMQTTGateway on a ESP32 and a CC1101 Transceiver

This is an attempt at creating an Arduino library for use on ESP32 boards with a CC1101 transceiver with the device decoders from the rtl_433 package.

Northern Man 92 Jan 3, 2023
Port of my M5Stack Core 2 audio monitor project to generic ESP32s with TFT screens

ESP32 Audio Monitor This is a port of this project to work with any ESP32 device with a TFT display. You can watch a video explainer here (YouTube) wh

atomic14 47 Nov 9, 2022
Doom port for InfOS - the University of Edinburgh Informatics research operating system used in the UG3 OS course

Doom on InfOS InfOS is the Informatics research operating system, designed specifically for the UG3 Operating Systems course. This project aims to por

Cheng Kai 14 Aug 20, 2022
Port of Golang channels to C++

Copper is a C++ library of a powerful queue object for communication between threads. It is based on Go's channels and follows the quote: Don't commun

null 155 Dec 20, 2022
NDS port of the uxn virtual machine

uxnds Quick and simple port of the uxn virtual machine to the NDS console. By default, uxnds will run /uxn/boot.rom. It also supports reading files fr

Adrian Siekierka 106 Dec 12, 2022
High Quality DeNoise 3D is an AviSynth port of the MPlayer filter of the same name

High Quality DeNoise 3D is an AviSynth port of the MPlayer filter of the same name. It performs a 3-way low-pass filter, which can completely remove high-frequency noise while minimizing blending artifacts.

null 13 Oct 3, 2022
A fast and small port of Zstandard to WASM.

Zstandard WASM A fast and small port of Zstandard to WASM. (Decompress-only for now). Features Fast: Zstandard has been compiled with the -03 flag, so

Fabio Spampinato 13 Nov 9, 2022
This is the Arduino® compatible port of the AIfES machine learning framework, developed and maintained by Fraunhofer Institute for Microelectronic Circuits and Systems.

AIfES for Arduino® AIfES (Artificial Intelligence for Embedded Systems) is a platform-independent and standalone AI software framework optimized for e

null 166 Jan 4, 2023
Doom port to the Ikea Tradfri RGB1923R5 and any device using Silicon labs EFR32MG21 based modules

MG21DOOM Doom port to the Ikea Tradfri RGB1923R5 lamp and any device using Silicon labs EFR32MG21 based modules. Coded by Nicola Wrachien. WARNING Do

null 20 Aug 2, 2022
A port of the Uxn virtual machine to the ESP32

Uxn An assembler and emulator for the Uxn stack-machine, written in ANSI C. Build Linux To build the Uxn emulator, you must have SDL2. If you wish to

Maxime ANDRÉ 27 Mar 24, 2022
Moonlight port for Nintendo Switch

Moonlight-Switch Moonlight-Switch is a port of Moonlight Game Streaming Project for Nintendo Switch. Thanks a lot to Rock88 and his Moonlight-NX, lots

Vinogradov Daniil 313 Jan 5, 2023
Hobbyist Operating System targeting x86_64 systems. Includes userspace, Virtual File System, An InitFS (tarfs), Lua port, easy porting, a decent LibC and LibM, and a shell that supports: piping, file redirection, and more.

SynnixOS Epic Hobby OS targeting x86_64 CPUs, it includes some hacked together functionality for most essential OSs although, with interactivity via Q

RaidTheWeb 42 Oct 28, 2022
Fix for various issues in the PC port of Ace Attorney Chronicles.

Hackfix for a few issues in the PC port - Animation framerate can now be set to arbitrary rate. (defaults to 60 but can be freely adjusted in the ini

Admiral H. Curtiss 82 Nov 28, 2022
This is a C port of Stefan Hirschmann's NoteBook FanControl.

It provides the same utilities with the same interfaces as the original NBFC, although the implementation differs.

null 161 Jan 2, 2023