Dangerous Dave Level format
Each level is stored in the following structure:
|BYTE path||Path data|
|BYTE tiles[100*10]||Tile data, left to right, top to bottom|
The 1000 bytes of tile data are followed by 24 bytes of unused data to bring the chunk up to a nice round 1024 bytes.
This block of data is used to specify a path for creatures to follow. It is an array of up to 128 X,Y coordinate pairs, with each pair being a signed 8-bit integer (so two bytes * 128 pairs == 256 bytes max.) Each value dictates the number of pixels the creature should move in both the X and Y direction. The end of the path is signified by storing 0xEA in both coordinates, and upon reaching this point the path repeats from the beginning. An example path might be
05 03 FB FD EA EA
05 03 # Move five pixels to the right and three pixels down FB FD # Move five pixels left and three pixels up, i.e. return to the original position EA EA # End of path
This would cause the creature to oscillate between two points. (Since the values are signed, 0xFF == -1, 0xFE == -2, etc.)
Since the paths consist of relative movement instructions, a path that does not return the creature to its starting point at termination will cause the creature to gradually migrate off the edge of the level, as the misalignment accumulates after each loop iteration. However this could be used for creative effect, as the creature will then reappear at the opposite edge of the level.
It appears that only one path can be defined in each level, and all creatures follow it the same (although as the path consists of relative movement instructions, the creatures can trace out the same path at different locations in the level.)
The level consists of 1000 bytes of tile data, one byte per tile arranged in a 100x10 array.
The byte values are indices into the tileset, so a byte of value 0x02 means tile number 2 should be drawn in that location (with tile number 0 being the first image in the tileset.) Tile number 0 is actually a black square, so a byte value of 0x00 is used for empty space the player can walk in.
Both the player starting point and the creatures which appear in each level are hard coded as follows, with (0,0) being the top-left corner of the level and (99,9) being the lower right tile:
|3||3||(2,5)||Spiders at (44,4) and (59,4) - each spider is ~2x2 tiles in size|
|5||5||(2,8)||3x Suns at TODO|
|8 warp||6||(71,0)||None / shares with level 6|
The level chunk is the "file" the level appears in (because some levels share the same files.)
The initial investigation and tile data documentation was done by Levellass, with Malvineous discovering how the path data works. If you find this information helpful in a project you're working on, please give credit where credit is due. (A link back to this wiki would be nice too!)