Data format (basedata/datalayer)
All data is contiguously stored in a memory bank (see table). Note that the depth is one of these values: 4,8,12, or 16 bit.

OffsetBytesDescription
depth*1depthvalue 1
depth*2depthvalue 2
...


You can read in the data using one of the following code snippets (written in BlitzBasic). The returned value is a tileset frame number. A value of 0 is a transparent tile.

4 bit depth
offset = ((y*sizex+x)/2)
mode = ((y*sizex+x) And 1)*4
value = (PeekByte(bank,offset) Shr mode) And 15

8 bit depth
offset = y*sizex+x
value = PeekByte(bank,offset)

12 bit depth
offset = ((y*sizex+x)*3)/2
mode = ((y*sizex+x) And 1)*4
value = (PeekShort(bank,offset) Shr mode) And 4095

16 bit depth
offset = (y*sizex+x)*2
value = PeekShort(bank,offset)

Animations
The map editor was designed to create compact map-files. Layerdepth can be as small as 4 bits per tile. Such a tile can only store small values (0-15). So how does map editor save animation information in this compact space?

A tile/image with a value of 0 is transparent. All values over 0 are a frame-number in the tileset.

However, if you create 2 animations, values 1 and 2 are used for animations. Higher values are then used for the normal frames. (Note: This may cause some tiles to not be assigned a frame number if their value would go higher than the bit depth can hold.)

You see that all animations are dynamically stored. Look at the figure (green=transparent, red=animation, gray=frame):