The Hobbit (1982 game) graphics engine in Javascript
There were over 20 illustrations in the game, each covering 2/3 of the screen area. The game itself only occupied 40K and a ZX Spectrum used just under 7K for the graphics memory (bitmap + colour information), so it was clear that you couldn't simply store whole images. Instead, they painted the illustrations from scratch each time, using a small set of graphics primitives, and each illustration was stored as a sequence of drawing instructions compactly encoded as bytes. Since it took many seconds to draw an image, you could easily follow what was happening and understand that this was how it worked.
I always wanted to see how their graphics engine worked, and make it possible to draw the illustrations without running the game in an emulator, but I have only ever found partial disassemblies of the game, and nothing at all about the graphics routines or the format they used. A week or so ago I decided to reverse-engineer it myself, for the hell of it. It turned out to be a bit tricky but not so bad after all. And of course, once I had figured it out, I wanted to reimplement it in a more portable language using a more portable graphics backend, i.e., Javascript and html canvas (something I've never had reason to touch before). This weekend I found some quiet time to implement it, and it works. As far as I have been able to tell, comparing to the game running in an emulator, the screens are rendered pixel perfect. If you too have been playing this game as a kid, you might find it interesting to look at the code on GitHub. Or just use the drop-down menu above to look at the images drawn in real-time in your browser, way faster than an old 3.5MHz Z80 could do it back in the day.
Comments
Thinking a bit about it, I guess these old games are relatively easy to reverse engineer, if nothing else because the amount of code is limited and the hardware it drives isn't all that complicated.
Refused to execute script from 'https://raw.githubusercontent.com/richcarl/hobbitgfx/master/hobbitgfx.js' because its MIME type ('text/plain') is not executable, and strict MIME type checking is enabled.