Please note: this blog has been migrated to a new location at https://jakesgordon.com. All new writing will be published over there, existing content has been left here for reference, but will no longer be updated (as of Nov 2023)

Boulderdash Cave Data

Sat, Oct 29, 2011

Previously, I released an experimental javascript Boulderdash game and promised to write up some articles about how the game works:


The topics I wanted to cover include:

So, lets finish up by talking about the Boulderdash cave data…

Decoding the c64 Cave Data

The c64 had a very restrictive amount of memory, every byte had to be made to count. While it has 64k memory only about 35k was available for programs.

The boulderdash caves consist of 880 cells (40x22), and there are 20 levels, so even if each cell only required a single byte, a verbose definition of all 20 levels would take over 17k - that would be a really tight squeeze once you add all the game code and graphics.

So to save space, caves are not defined as a fully expanded 40x22 array of bytes.

Instead they are declared with 2 parts:

This allows caves to be defined very compactly, for example level 1 consists of:

This can all be stored in about 25 bytes

The exact format used has been described in detail by Jeff Bevis and Peter Broadribb, who also wrote the original decodecaves.c program and then described the decoded cave data.

Summary

In hindsight, I could have just taken the already decoded data and simply reformatted it manually into JSON format…

… but for some reason I decided to port the decodecaves.c program to javascript, and thats what you will see in the caves.js source file. This could come in useful if we were to expand our javascript version to be able to load in other caves, such as those from Boulderdash 2 or 3, or the construction kit.

And that just about wraps it up for Boulderdash!

To summarize, we have looked at:

Enjoy!

More information…

Game specs…