Boulderdash Cave DataSat, Oct 29, 2011
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:
- random items - using a predictable random number generator, each cell initially contains one of (up to) 4 random items, usually
- placed items - a list of objects, lines or rectangles are overlaid over the random items
This allows caves to be defined very compactly, for example level 1 consists of:
random items - each cell starts off with a chance of being:
- line of
BRICKfrom (1, 9), length = 30, direction = right
- line of
BRICKfrom (9, 16), length = 30, direction = right
PREROCKFORDat (3, 4)
PREOUTBOXat (38, 18)
- line 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.
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
will see in the
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:
- a game loop and rendering loop that are independent.
- a game logic engine that is independent of how it is rendered.
- an HTML5
canvasrenderer for the game engine.
- a decoder to parse the original c64 cave data.
- play the game now
- view the source code
- read more about how it works:
- The original publishers - First Star
- Martijn’s Boulderdash Fan Site
- Arno’s Boulderdash Fan Site
- Boulderdash Common File Format BDCFF
- Boulderdash on the c64
- Boulderdash on Wikipedia