J2T File Format

This is the format used by Jazz Jackrabbit 2 tilesets.

File header

The data sections are compressed with zlib.

struct TILE_Header {
    char Copyright[ 180];
    char Magic[ 4] = "TILE";
    long Signature = 0xAFBEADDE
    char Title[ 32];
    short Version;  //0x200 for v1.23 and below, 0x201 for v1.24
    long FileSize;
    long CRC32;
    long CData1;    //compressed size of Data1
    long UData1;    //uncompressed size of Data1
    long CData2;    //compressed size of Data2
    long UData2;    //uncompressed size of Data2
    long CData3;    //compressed size of Data3
    long UData3;    //uncompressed size of Data3
    long CData4;    //compressed size of Data4
    long UData4;    //uncompressed size of Data4

Data1 (Tileset Info)

If the set is from 1.23 or 1.10o/Battery Check, then MAX_TILES is 1024 and the size of the buffer is 27652. If it’s from 1.24 or A Gigantic Adventure, then MAX_TILES is 4096 and the size of the buffer is 107524.

struct TilesetInfo {
    long PaletteColor[ 256];        //arranged RGBA
    long TileCount;                 //number of tiles, always a multiple of 10
    char FullyOpaque[MAX_TILES];    //1 if no transparency at all, otherwise 0
    char Unknown1[MAX_TILES];       //appears to be all zeros
    long ImageAddress[MAX_TILES];
    long Unknown2[MAX_TILES];       //appears to be all zeros
    long TMaskAddress[MAX_TILES];   //Transparency masking, for bitblt
    long Unknown3[MAX_TILES];       //appears to be all zeros
    long MaskAddress[MAX_TILES];    //Clipping or tile mask
    long FMaskAddress[MAX_TILES];   //flipped version of the above

The Address fields refer to the address or offset in their corresponding buffers from which to start reading.

Specifically, ImageAddress reads from Data2, TMaskAddress reads from Data3, MaskAddress and FMaskAddress reads from Data4, and you should probably memorise this to avoid confusion later on. If you are planning to make a tileset extractor of some sort, you would probably need only to use ImageAddress and MaskAddress.

Data2 (Image Address)

Each image is 1024 bytes long, uncompressed. Each byte represents a palette index, so you have a 32*32 picture just by reading each byte as a pixel. Note that each image here is unique, so for example if your tileset has a blank space in say, tile #42, then ImageAddress[ 42] will be equal to zero (offset zero in the Data2 buffer).

Data3 (Transparency Mask)

This is arranged in the same way as Data3.
Edit: It’s similar, but not exact same.

Data4 (Clipping Mask)

Similar to Data2, except each mask is 128 bytes. This is because the mask is only 1 bit-per-pixel (black or white). If you are trying to extract mask information into a picture for the first time, expect some problems with bit orders; I can’t remember whether it reads MSB-first or LSB-first.


Remember that Data2 is not equivalent to the actual tileset graphics as seen in JCS, and Data4 is not the mask either. Data2 simply contains an image of each unique tile in the set, likewise with Data4. You must read Data1 if you want to find out exactly what image and mask a particular tile# has.

Related content outside the wiki