View Single Post
Neobeo

JCF Member

Joined: Sep 2002

Posts: 409

Neobeo is an asset to this forumNeobeo is an asset to this forum

Apr 2, 2006, 01:50 PM
Neobeo is offline
Reply With Quote
The J2T File Format
My time is slowly running out, so we'll cut to the chase.
Code:
struct TILE_Header {
	char Copyright[180];
	char Magic[4] = "TILE";
	long Signature = 0xAFBEADDE //looks like DEADBEAF on a hex editor
	char LevelName[32];
	short Version; //0x200 for v1.23, 0x201 for v1.24
	long FileSize;
	long CRC32;
	long CData1;
	long UData1;
	long CData2;
	long UData2;
	long CData3;
	long UData3;
	long CData4;
	long UData4;
}
Data1 - Tileset Info
For the files I checked so far, this buffer always has a size of 27652 bytes for v1.23, or 107524 bytes for TSF. This is due to it supporting up to 4096 tiles instead of the original 1024.
Code:
#if version = 0x0200 then MAX_TILES = 1024
#if version = 0x0201 then MAX_TILES = 4096

struct TilesetInfo {
	long PaletteColor[256]; //in the format {red, green, blue, zero}
	long TileCount; //number of tiles, always a multiple of 10
	char Unknown[MAX_TILES]; //I suspect this has something to do with transparency; haven't looked at it yet
	char Zeros[MAX_TILES]; //Unsure, all zeros?
	long ImageAddress[MAX_TILES];
	long Zeros[MAX_TILES];
	long TMaskAddress[MAX_TILES]; //Transparency masking, for bitblt
	long Zeros[MAX_TILES];
	long MaskAddress[MAX_TILES]; //Clipping mask, or the "tile mask" as it is called in JCS
	long FMaskAddress[MAX_TILES]; //flipped version of the above
}
First question that comes to your mind is: what are those address thingies? I should probably have called them offsets, but they basically refer to the address in their corresponding buffers from which to start reading.

In specific, 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
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.

Data4 - Clipping Mask
Same notes as Data3.

Other notes
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.

EDIT: Very minor edit, don't ask.
__________________
<TABLE border=1><TR><TD>Facts:
Jazz Sprite Dynamite (JSD)
Tileset Extractor
Neobeo's Firetruck

</TD><TD>Myths:
Jazz Creation Station Plus (JCS+) - 10%
Coming soon - a dedicated server! - 25%
Jazz Sprite Dynamite v2 (JSDv2) - 2%
Another generic single-player level - 0%
</TD></TR></TABLE>

Last edited by Neobeo; Apr 2, 2006 at 02:13 PM.