psx.wiki
Log in
Main page
Hardware
Hardware tests
System software
SDKs
File formats
Games
Tools
History
All pages
page
view source
history
View source for TIM (Screen Image Data)
← TIM (Screen Image Data)
You do not have permission to edit this page.
Log in
to edit.
--- title: TIM (Screen Image Data) type: format summary: Image data that can be transferred directly to VRAM. category: File formats info: Extension = .TIM info: ID = 0x10 --- ## Overview The TIM file holds the standard images handled by the PlayStation, and it can be transferred directly to VRAM. It is used both for sprite patterns and for the material of 3D texture mapping.[^ff33] A TIM file holds image data in one of the following modes:[^ff33][^ff34] Table: TIM image data modes | PMODE | Mode | | --- | --- | | 0 | 4-bit CLUT | | 1 | 8-bit CLUT | | 2 | 15-bit direct | | 3 | 24-bit direct | | 4 | Mixed | The VRAM of the PlayStation is based on 16 bits. Only 16-bit and 24-bit data can therefore be transferred directly to the frame buffer for display. Sprite patterns and polygon texture data, however, can use any of the 4-bit, 8-bit and 16-bit modes.[^ff33] ## File Structure A TIM file has a file header (ID) at the top and consists of several blocks. Each item of data is a string of 32-bit binary data, and the data is little endian. In an item of several bytes the bottom byte therefore comes first and holds the lowest address.[^ff33] Table: TIM file blocks | Block | Contents | | --- | --- | | ID | File ID and version number | | FLAG | Pixel mode and CLUT flag | | CLUT | Color lookup tables, present only when CF is 1 | | Pixel | Image data | ## ID The file ID is one word with the following bit configuration:[^ff33][^ff34] Table: TIM file header | Bits | Field | Value | | --- | --- | --- | | 0..7 | ID | 0x10 | | 8..15 | Version No. | 0x00 | | 16..31 | Reserved | All zero | ## Flag The flag is 32 bits of data that describes the file structure. When a single TIM file holds several sprites and textures of different types, PMODE is 4 (mixed) because data of several types is intermingled.[^ff34] Table: TIM flag word | Bits | Field | Contents | | --- | --- | --- | | 0..3 | PMODE | Pixel mode: 0 4-bit CLUT, 1 8-bit CLUT, 2 15-bit direct, 3 24-bit direct, 4 mixed | | 4 | CF | 0 no CLUT section, 1 has CLUT section | | 5..31 | Reserved | All zero | ## CLUT A CLUT is a color palette, and it is used by image data in 4-bit and 8-bit mode. The CF flag in the FLAG block specifies whether the TIM file has a CLUT block. The block opens with its length in bytes (bnum), which is followed by its location in the frame buffer, its size and the entries themselves.[^ff34] Table: CLUT block | Field | Contents | | --- | --- | | bnum | Data length of the CLUT block in bytes, including the 4 bytes of bnum | | DX | X coordinate in the frame buffer | | DY | Y coordinate in the frame buffer | | W | Size of the data in the horizontal direction | | H | Size of the data in the vertical direction | | CLUT 1..n | CLUT entries, 16 bits each | In 4-bit mode one CLUT consists of 16 entries, and in 8-bit mode it consists of 256 entries. On the PlayStation CLUTs are located in the frame buffer, so the CLUT block is handled as a rectangular frame buffer image in which one entry is one pixel. A 4-bit CLUT is therefore an image 16 wide and 1 high, and an 8-bit CLUT is 256 wide and 1 high.[^ff35] One TIM file can hold several CLUTs. In this case the area in which the CLUTs are combined is placed in the CLUT block as a single item of image data.[^ff35] ### CLUT Entry One CLUT entry holds one color. Its structure is as follows:[^ff35] Table: CLUT entry | Bits | Field | Contents | | --- | --- | --- | | 0..4 | R | Red component (5 bits) | | 5..9 | G | Green component (5 bits) | | 10..14 | B | Blue component (5 bits) | | 15 | STP | Transparency control bit | The transparency control bit (STP) is valid when the data is used as sprite or texture data. It controls whether the pixel is transparent in the sprite or polygon that is drawn. If STP is 1 the pixel is semi-transparent, and otherwise it is not transparent. However, a pixel whose R, G, B and STP are all 0 is a transparent color. The relationships are shown in the following table:[^ff35] Table: STP bit function with R G B data | STP/R,G,B | Translucent processing on | Translucent processing off | | --- | --- | --- | | 0/0,0,0 | Transparent | Transparent | | 0/X,X,X | Not transparent | Not transparent | | 1/X,X,X | Semi-transparent | Not transparent | | 1/0,0,0 | Non-transparent black | Non-transparent black | ## Pixel Data Pixel data is the substance of the image. The frame buffer of the PlayStation has a 16-bit structure, so the image data is broken up into 16-bit units. The pixel data block has the following structure:[^ff35][^ff36] Table: Pixel data block | Field | Contents | | --- | --- | | bnum | Data length of the pixel data in bytes, including the 4 bytes of bnum | | DX | Frame buffer x coordinate | | DY | Frame buffer y coordinate | | W | Size of the data in the horizontal direction, in 16-bit units | | H | Size of the data in the vertical direction | | DATA 1..n | Frame buffer data, 16 bits each | Care is needed with the size of the pixel data. W counts 16-bit units, so in 4-bit mode it is 1/4 of the image width and in 8-bit mode it is 1/2. Consequently the width of a 4-bit image must be a multiple of 4, and the width of an 8-bit image must be an even number.[^ff36] ### Frame Buffer Data The structure of one 16-bit item of frame buffer data depends on the image data mode. The table below gives the structure for each mode, and pixels appear on the screen in order from the LSB side.[^ff36][^ff37] Table: Frame buffer data by mode | Mode | Contents of one 16-bit item | | --- | --- | | 4-bit | pix0 in bits 0..3, pix1 in bits 4..7, pix2 in bits 8..11, pix3 in bits 12..15 (CLUT numbers) | | 8-bit | pix0 in the low byte, pix1 in the high byte (CLUT numbers) | | 16-bit | R in bits 0..4, G in bits 5..9, B in bits 10..14, STP in bit 15 | | 24-bit | 3 items hold 2 pixels | In 24-bit mode three items of 16-bit data correspond to two pixels. R0, G0 and B0 are the pixel on the left, and R1, G1 and B1 are the pixel on the right:[^ff37] Table: 24-bit pixel pair | Item | Bits 8..15 | Bits 0..7 | | --- | --- | --- | | 0 | G0 | R0 | | 1 | R1 | B0 | | 2 | B1 | G1 | ## References [^ff33]: Sony Computer Entertainment Inc. File Formats. November 1998. Page 3-3, Figures 150 to 152. [^ff34]: Sony Computer Entertainment Inc. File Formats. November 1998. Page 3-4, Figures 153 and 154. [^ff35]: Sony Computer Entertainment Inc. File Formats. November 1998. Page 3-5, Table 3-1. [^ff36]: Sony Computer Entertainment Inc. File Formats. November 1998. Page 3-6, Figures 156 and 157. [^ff37]: Sony Computer Entertainment Inc. File Formats. November 1998. Page 3-7.