PSX/TIM format

From Final Fantasy Inside
< PSX
Revision as of 21:11, 3 March 2005 by my_wiki>Qhimm

Contents

Introduction

A TIM file is a standard image file format for the Sony PlayStation. The file structure closely mimics the way textures are managed in the frame buffer by the GPU. TIM files are little endian-based.

File layout

A TIM file is made up of three conceptual blocks; the header, the color lookup table (CLUT) and the image data. The CLUT block and the image data block have the same basic layout and are also treated the same way when loading a TIM file into the PlayStation frame buffer. Also, the CLUT block is optional and technically does not need to be present, even when the image data consists of color indices. Such image data is assumed to refer to some color lookup table, but not necessarily one stored in the same TIM file -- on the PlayStation, the actual CLUT used for a set of image data is referred to only by its frame buffer coordinates, not by the file it comes from. In almost all cases though, the CLUT is included in the same TIM file as the image data using it and can thus be assumed to be applicable.


 


Header

The header starts with a 'tag' byte; this value is constant for all TIM files and must be 0x10. The immediately following byte denotes the version of the file format. At present, only version '0' TIM files are known to exist.

The next 32-bit word contains specific flags denoting the basic properties of the TIM file. The BPP (Bits Per Pixel) value denotes the bit depth of the image data, according to the following values:

00  4-bit
01  8-bit
10  16-bit
11  24-bit

The CLP (Color Lookup table Present) flag simply denotes if the CLUT block is present in the TIM file. This flag is typically set when BPP is 00 or 01, and cleared otherwise.

CLUT (color lookup table)

Image data