The Genesis of waterbear

Note: waterbear is an assembler/disassembler for the Dreamcast VMU.

VMU Script

Many years ago, I was watching an episode of Adventures in Game Development, and Falco mentioned that some friends of theirs at Watermelon Games built the VMU game for Pier Solar using a language called VMU Script. The problem was that the source code to the VMU Script compiler had apparently been lost long ago, and there was a bug in the compiler where it would sometimes output a jmp instruction when the target was out of range. They had to work around it by post-processing their source files and replacing jmps with jmpfs.

A sampling of VMU Script commands
vmu-script
?: This is a comment that will not show up in the assembly output
rem:(This is a comment, and will be emitted as a comment in the assembly output)

rem: Initialize the VMU
init

rem: Play a sound at frequency 21.34 Hz
play: 0

rem: Stop playing the sound
stop

This language for the VMU intruigued me, and so I scoured the internet for it. The only real thing I was able to find was a partial copy of the VMU Script website on archive.org.

I've always been interested in programming languages and compilers, and thought that the VMU might be an easy target to start with (I sure was wrong about that). I considered trying to re-implement a VMU Script compiler, but there just wasn't enough information about the language.

Compiler

In any case, after looking at the docs I could find, I thought it would be more fun to come up with my own language. So I started working on it, by first implementing an assembler library. That's right, waterbear was originally only meant to be a library to be used as the backend to a compiler.

I didn't even intend to write a parser for it, but I evenutally did because it made testing easier. But because it was only there for testing purposes, it didn't have any nice features, error messages, etc.

I wrote the original version in Rust, intending to write the whole compiler in Rust, mostly just as an exercise to learn the language. At some point, I switched to OCaml, because it seemed like it would be nicer to work with (GC, no borrow checker, etc.) when implementing a compiler.

Assembler

I later met (in person and on Discord) and became friends with Falco, who was (and still is) working on a VMU emulator called ElysianVMU. He was very interested in working together to create a development environment for the VMU, e.g. bundle the emulator and assembler together, and include support for debugging, etc. To make this integration as easy as possible, I wanted to be able to have EVMU (a C & C++ project) link against waterbear as a library. While this is possible with OCaml, it seemed easier to do it in Rust. So I switched back to Rust.

Around the same time, I met Kresna through Falco, who had been writing VMU games. He was interested in trying out the assembler, and so I started really fleshing out the feature set of waterbear, including support for good error messages, macros, and a disassembler.

To this day I still haven't implemented a programming language for the VMU, but waterbear has turned into a powerful assembler/disassembler, and there are still plenty of new features I intend to implement.

But that compiler will come some day.