First post, by dreamlayers
I've been working on an Emscripten port of DOSBox. I started a branch from the SVN revision closest to 0.74. It is published as the em-dosbox-0.74 branch at my em-dosbox repository on GitHub.
I wouldn't call it complete, but it runs many games well in Firefox. Chrome's JavaScript interpreter runs asm.js more slowly, but it can still run many real mode games with only minor sound glitches. Here are some demos:
- Major Stryker (full version, now released as freeware)
- Squarez (also freeware)
- Duke Nukem 1 (the first, shareware episode)
- Doom (the first shareware episode)
The biggest difficulty when porting to Emscripten is that you must return control to the browser for the page to be updated. If you don't return control, Firefox freezes. There isn't any function you can call to accomplish this. (SDL_Delay() and usleep() will just busy wait.) My port uses a simple hack, causing the second DOSBOX_RunMachine() call to set up the Emscripten main loop. So, you can run mount once to gain access to files, and then you can run the desired executable via the main loop. The shell still cannot be used interactively. The src/packager.py script can create the files needed to run games. It's not ideal, but it can run a lot of things, even Windows 3.1. The possibility of DOSBOX_RunMachine() nesting makes a proper solution tricky.
The port also includes a Python script which transforms the CPU cores, using an array of function pointers instead of the main switch statement, with cases transformed into functions. This runs a lot faster in Chrome, because it can't optimize large switch statements. It even seems to run a bit faster in Firefox.
More information is available in README.md on GitHub.