The Tiles File Format

Introduction

One of the common tasks in game development is to arrange image files into sets of rectangular areas, which are called tiles. Tiles are generally used in classic 2D games, but even in modern 3D games, a common task is still arranging two-dimensional textures into texture atlasses in a similar fashion.

The RATR0 tiles format in its current form simply defines a regular grid of rectangles on top of an image file. Since its initial and primary target platform is the Commodore Amiga OCS (Original Chip Set) hardware, the default settings of the ratr0-maketiles utility will generate image information that can be easily used on this platform.

However the file format was designed to be flexible enough to support a variety of platforms and graphics technologies.

Specification

Palette Data

Following the file header is a block consisting of the palette entries. If the colors are decoded in 12 bit (4 bit per color), this block will have the size (palette_size * 2) bytes, if they are decoded as 1 byte triplets per color (24 bit) the size of the block will be (palette_size * 3) bytes

Image Data

Immediately following the palette data is the image data encoding as depth planes. This data is of the size ((width * height * depth) / 8) bytes. If bit 3 of flags is set, there will be an additional plane containing the mask data, which is a bitwise “OR” of all the image bit planes