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
  • 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
  • Setting

    Setting "image-rendering: pixelated" on the canvas?

    I gave "image-rendering: pixelated" a try on via the Chrome dev tools and IMO it improves the quality of low res games in full screen significantly. (By default they look pixelated and blurry at the same time.) [note: currently works only in Chrome and Opera, but support should improve]

    I wonder what others think: would setting this on the em-dosbox canvas by default or optionally be a worthwhile improvement?

    If there is interest I'd put together a pull request

    opened by DerKoun 5
  • em-dosbox: outdated?

    em-dosbox: outdated?

    Here on Github, it says "forked from Henne/dosbox-svn". But when I visit that, I see the last DOSBox SVN commit they mirrored was from 2012 (specifically r3798)

    Current DOSBox SVN is on r3989 (2016-06-24 21:21). Any plans to sync to latest? Or am I misunderstanding the situation?

    If you're looking for a current one to sync against, svn2github's is pretty nice:

    opened by stilett0 4
  • can't compile

    can't compile

    dos_programs.cpp:85:20: error: non-constant-expression cannot be narrowed from type 'int' to 'char' in initializer list [-Wc++11-narrowing] char root[7] = {'A'+d,':','\','','.','',0}; ^~~~~ dos_programs.cpp:85:20: note: insert an explicit cast to silence this issue char root[7] = {'A'+d,':','\','','.','',0}; ^~~~~ static_cast( ) dos_programs.cpp:1601:22: error: use of undeclared identifier 'emscripten_sleep_with_yield' while (!fetchdone) emscripten_sleep_with_yield(10); ^ 2 errors generated.

    opened by iocmet 0
  • 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
  • version.h has syntax errors.

    version.h has syntax errors.

    The version.h file produced from:

    	python ../include/version.h .. $(CXX)

    Apparently has syntax errors

    In file included from callback.cpp:20:
    In file included from /usr/local/Cellar/emscripten/1.39.18/libexec/system/include/libcxx/stdlib.h:100:
    In file included from /usr/local/Cellar/emscripten/1.39.18/libexec/system/include/libcxx/math.h:311:
    In file included from /usr/local/Cellar/emscripten/1.39.18/libexec/system/include/libcxx/type_traits:418:
    ../../version:1:1: error: expected unqualified-id
    In file included from callback.cpp:20:
    In file included from /usr/local/Cellar/emscripten/1.39.18/libexec/system/include/libcxx/stdlib.h:100:
    In file included from /usr/local/Cellar/emscripten/1.39.18/libexec/system/include/libcxx/math.h:312:
    In file included from /usr/local/Cellar/emscripten/1.39.18/libexec/system/include/libcxx/limits:121:
    ../../version:1:1: error: expected unqualified-id
    opened by kevzettler 1
  • configure: error: C compiler cannot create executables

    configure: error: C compiler cannot create executables

    I am trying to make a build. At the

    emconfigure ./configure

    part, it gives me an error of

    configure: ./configure configure: auto-detected use of Emscripten checking build system type... x86_64-pc-linux-gnu checking host system type... none-none-none checking for a BSD-compatible install... /usr/bin/install: setting permissions for '/mnt/c/users/pisaucer/downloads/em-dosbox-em-dosbox-svn-sdl2/conftest.dir/': Operation not permitted /usr/bin/install: setting permissions for '/mnt/c/users/pisaucer/downloads/em-dosbox-em-dosbox-svn-sdl2/conftest.dir/conftest.two': Operation not permitted ./install-sh -c checking whether build environment is sane... yes checking for a thread-safe mkdir -p... /bin/mkdir -p checking for gawk... gawk checking whether make sets $(MAKE)... yes checking whether make supports nested variables... yes checking whether make sets $(MAKE)... (cached) yes checking for gcc... /home/pisaucer/emsdk/upstream/emscripten/emcc checking whether the C compiler works... no configure: error: in /mnt/c/users/pisaucer/downloads/em-dosbox-em-dosbox-svn-sdl2': configure: error: C compiler cannot create executables Seeconfig.log' for more details

    I was wondering if anyone can point me in the right direction. I am using windows 10 pro with

    Distributor ID: Ubuntu Description: Ubuntu 18.04.4 LTS Release: 18.04 Codename: bionic

    Any help will be greatly appreciated. My config.log is attached config.log

    opened by PiSaucer 2
  • 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 [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 0
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 16 Jun 22, 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.5k Jun 19, 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. 29 Jun 29, 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.2k Jun 28, 2022
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 966 Jun 19, 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 70 Jun 19, 2022
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 41 Jun 23, 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 Jun 19, 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 152 Jun 24, 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 102 Jun 16, 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 12 Jun 7, 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 10 Apr 15, 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 129 Jun 27, 2022
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 Jun 26, 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 218 Jun 27, 2022
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 40 May 27, 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 71 Jun 19, 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 97 Jun 25, 2022