Announcing Wasm2Glulx, and a new port of Adventure

I have just released Wasm2Glulx, a tool which translates WebAssembly into Glulx. Wasm2Glulx’s raison d’être is to make it possible to use general-purpose programming languages to develop interactive fiction, while producing portable game files that run seamlessly on existing Glulx interpreters. Wasm2Glulx is plumbing; it is not intended, by itself, to provide a direct, friendly interface for game developers, but rather to be a foundation for the development of new game engines. That said, I have already used it to translate one complete game: a new port of Adventure 2.5, the 430-point version released by Don Woods in 1995.

Despite this being a first release, the tool is already in quite solid shape. It supports the entirety of WebAssembly 1.0, and most of the current 2.0 draft (everything except SIMD). It passes a suite of roughly 24,000 tests, autogenerated from WebAssembly’s official test suite, incidentally catching a handful of Glulx interpreter bugs in the process.

Wasm2Glulx is the first step of the Bedquilt project, my effort to develop a Rust-based interactive fiction engine. While my focus will be on Rust-based tooling from here forward, Wasm2Glulx will always be supported as a standalone and language-agnostic tool, meant to be usable with the output of any compiler that has a WebAssembly backend.

Wasm2Glulx’s manual is up at https://bedquilt.io/manual and includes an FAQ about its technical architecture. Its sources (including the sources for the Adventure port) are at https://github.com/dfoxfranke/bedquilt. The compiled game is available from the IF Archive at https://ifarchive.org/indexes/if-archive/games/glulx/#advent430.ulx

11 Likes

I tried just a few moves. Works fine as far as I can see, and the speed is comparable to the classic Inform 6 port of Adventure. With the accelfunc work you’ve talked about, I’m sure it’ll wind up being much faster.

One quirk: if you type RESTART, it attempts to do a saved-game load. Is this just meant to be a synonym for RESUME?

1 Like

That behavior is carried over from the original 1995 version. I could easily fix it, but this is intended as a warts-and-all reproduction of the original playing experience so I’m not going to.

1 Like

I’ll take that as a “yes”. :)

1 Like

Rather off-topic, but in case it’s helpful: my understanding is that Rust is compiled to LLVM IR, so in theory you could use my LLVM backend for Glulx to bypass going through WebAssembly and possibly generate more efficient code. I haven’t looked at it in years, and definitely don’t have time to maintain it, but feel free to grab any code from it if it’s helpful.

(Actually, taking a look at my local repo, I realize in 2022 I added an assembler so that the backend could produce .ulx files directly instead of Glulx assembly, but never pushed it – if that would be useful to people, I can try to clean it up.)

1 Like

Argh, of course I replied without reading your FAQ, which shows you’ve already thought about everything in my post. Sorry!