Escape From Dungeon escaped to the web
We’re driving to family vacation. Actually my wife is driving. I’m in the passenger seat. I passed some time by putting a Win95 Visual Basic game that I made back in high school on the web: foote.pub/dungeon.
Graphics by MS Paint
This is from the beginning of my senior year. It was the first year my high school offered a Visual Basic programming class. The teacher did a good job with the basics, but I was self-taught otherwise. Which is apparent if you are old enough to notice all the VB hacks I strung together to make this game.
I wish I still had the source code. This was long before I learned any programming patterns or development techniques; I remember thinking the code was a mess. Regardless, I’m thankful my brother was able to keep track of a copy of the binary all these years.
Notes: VB6 to the web
Anyway, foote.pub/dungeon is essentially Win95 running in a Wasm-based emulator that auto-loads a system state file with the game running. Here are some notes on how I got it working.
- Emulation is based on copy/v86. This is a Wasm-based x86 emulator. It is a really cool project, and the foundation here.
- The emulator is backed by an image of Win95 OSR2
- All files loaded to the emulator system state were saved to an .iso and loaded as a CD-ROM
- The VB6 runtime - installed
- A patched version of the Escape From Dungeon binary (Dungeon1.exe)
- (I fiddled with several other things to make this work before I arrived on this tidy set of prerequisites :)
- The binary is patched to remove a swear word. At the good advice of my daughter who was play testing 👧🏻
- VB6 uses UTF-16le-encoded strings, which are length-prefixed. So I just replaced the word with a string of equal length to avoid breaking (using xxd, sed etc.).
- The Win95 image is broken into a set of 256kb files. The emulator downloads them on demand. Cached via CDN.
- The system state file is ~100mb blob. Also cached but its a dog e.g on mobile
- This is not mobile-friendly. Besides the state file size, the emulator input doesn’t work well with a touchscreen
- foote.pub/dungeon maps to foote.pub/examples/dungeon via a CDN, to keep things tidy in my filesystem
Final boss
Hope everyone is doing well out there ☀️