Saturday, May 2, 2015

Run Heroes2 in a browser

DOSbox games in a browser!

I recently bought a copy of Heroes2, and I'm expecting that you've done the same (although not necessarily recently, since the game was released last century). You may have seen some of the work that's been done with old abandonware in DOSbox on, and this is an extension of that.

Porting to asm.js with Docker

To get started, fire up your dev machine. I'm using an Ubuntu 14.04 server VM in VirtualBox here, with Windows 7 underneath.

git clone
cd emscripten-docker
sudo ./build emscripten-ubuntu

That will take some time. While it's running, open another tab and download em-dosbox:

cd emscripten-docker/volume
git clone

When both are finished, go back to the first tab:

sudo ./run
cd /volume/em-dosbox/
/emsdk_portable/emscripten/master/emconfigure ./configure

You now have a build of DOSbox. We can then add our Heroes2 files.

Porting Heroes2

Run the GOG installer and remember the directory it installs to. Find that directory, copy the whole thing, and dump it into the emscripten-docker/volume on your dev machine.

At the time of writing, em-DOSbox is only version 0.70, and it doesn't have CD support. From here on in, I'm assuming that you've patched HEROES2.EXE to work without the CD (although once there is a version of em-DOSbox with CD support feel free to play with imgmount)

In your docker instance, get into the /volume/em-dosbox/src directory. Run the packager as follows:

./ heroes2 /volume/homm HEROES2.EXE

Then copy out the following 5 files into a folder of your choice:


In that directory, fire up a webserver

python -m SimpleHTTPServer 8000

Then log in and play

Next steps

I'd be keen to get CDROM support going! But that's a minor thing (and leaving out the CDROM saves us 200MB on the download, and this helps speed things up a little at load time).

I'm also keen to figure out how to get save files and network games running. Save files would presumably need some cleverness pushing stuff back to a server somewhere (integrate with dropbox/drive?), and networking would be interesting too - maybe patch some com support into dosbox and then send packets over twitter or something?

No comments:

Post a Comment