Saturday, May 2, 2015

Run Heroes2 in a browser

DOSbox games in a browser!

I recently bought a copy of Heroes of Might and Magic 2: The Succession Wars, 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 archive.org, 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 https://github.com/samrussell/emscripten-docker
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 https://github.com/dreamlayers/em-dosbox

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

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

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:

./packager.py heroes2 /volume/homm HEROES2.EXE

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

dosbox.html
dosbox.html.mem
dosbox.js
heroes2.data
heroes2.html

In that directory, fire up a webserver

python -m SimpleHTTPServer 8000

Then log in and play


http://127.0.0.1:8000/heroes2.html


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