Playstation TMD
TMD
- Format Type : 3d Model
- Endian Order : Little Endian
Format Specifications
TMD FILE FORMAT
HEADER - One per TMD
{
u_long id; - version of TMD. Always 0x00000041
u_long flags; - Indicates when addresses are relative or explicit
u_long nobj; - number of objects in the TMD
} HEADER;
OBJECT LIST - One per object in the TMD
{
u_long *vert_top; - start address of vertex list
u_long n_vert; - number of vertices in the object
u_long *normal_top; - start address of normal list
u_long n_normal; - number of normals in the object
u_long *primitive_top; - start address of primitive list
u_long n_primitive; - number of primitives in the object
long scale; - ignored
} OBJECT;
PRIMITIVE LIST - One per primitive per object in the TMD
{
u_char olen; - word length of the drawing primitive created by GPU
u_char ilen; - word length of the packet data section
u_char flag; - options when rendering
u_char mode; - indicates type of primitive
} PRIMITIVE_HEADER;
?? PACKET; - variable in length and content (see later for list)
VERTEX LIST - One per vertex per object in the TMD
{
short vx; - X value of vertex
short vy; - Y value of vertex
short vz; - Z value of vertex
short pad; - ignored
} VERTEX;
NORMAL LIST - One per normal per object in the TMD
{
short nx; - X value of normal
short ny; - Y value of normal
short nz; - Z value of normal
short pad; - ignored
} NORMAL;
PACKET LIST FORMAT
Note
When mode and flag are set with the values shown here, they default
to creating a one-sided primitive that will be rendered with no
semitransparency. To alter these, see earlier notes.
Pigment refers to the inherent colour of the primitive, before
lightsources alter the appearance on screen. A gradient pigment has
a different RGB value at each vertex, and by using the same
interpolation algorithm that gouraud shading uses, a smooth
transition between colours is achieved.
LIST OF PRIMITIVES INCLUDED SO FAR 3 SIDED, FLAT SHADING, FLAT PIGMENT 3 SIDED, GOURAUD SHADING, FLAT PIGMENT 3 SIDED, FLAT SHADING, GRADIENT PIGMENT 3 SIDED, GOURAUD SHADING, GRADIENT PIGMENT 3 SIDED, TEXTURED, FLAT SHADING, NO PIGMENT 3 SIDED, TEXTURED, GOURAUD SHADING, NO PIGMENT 3 SIDED, NO SHADING, FLAT PIGMENT 3 SIDED, NO SHADING, GRADIENT PIGMENT 3 SIDED, TEXTURED, NO SHADING, FLAT PIGMENT 3 SIDED, TEXTURED, NO SHADING, GRADIENT PIGMENT
3 SIDED, FLAT SHADING, FLAT PIGMENT
olen = 0x04; ilen =0x03; flag =0x00; mode =0x20;
{
u_char R, G, B; - pigment of polygon
u_char mode2; - same as mode (above)
u_short Normal0; - index value of normal element
u_short Vertex0; - index value of vertex element
u_short Vertex1;
u_short Vertex2;
} TMD_3_FS_FP;
3 SIDED, GOURAUD SHADING, FLAT PIGMENT
olen = 0x06; ilen =0x04; flag =0x00; mode =0x30;
{
u_char R, G, B; - pigment of polygon
u_char mode2; - same as mode (above)
u_short Normal0; - index value of normal element
u_short Vertex0; - index value of vertex element
u_short Normal1;
u_short Vertex1;
u_short Normal2;
u_short Vertex2;
} TMD_3_GS_FP;
3 SIDED, FLAT SHADING, GRADIENT PIGMENT
olen = 0x06; ilen =0x05; flag =0x04; mode =0x20;
{
u_char R0, G0, B0; - pigment of polygon at Vertex0
u_char mode2; - same as mode (above)
u_char R1, G1, B1; - pigment of polygon at Vertex1
u_char pad1; - ignored
u_char R2, G2, B2; - pigment of polygon at Vertex2
u_char pad2; - ignored
u_short Normal0; - index value of normal element
u_short Vertex0; - index value of vertex element
u_short Vertex1;
u_short Vertex2;
} TMD_3_FS_GP;
3 SIDED, GOURAUD SHADING, GRADIENT PIGMENT
olen = 0x06; ilen =0x06; flag =0x04; mode =0x30;
{
u_char R0, G0, B0; - pigment of polygon at Vertex0
u_char mode2; - same as mode (above)
u_char R1, G1, B1; - pigment of polygon at Vertex1
u_char pad1; - ignored
u_char R2, G2, B2; - pigment of polygon at Vertex2
u_char pad2; - ignored
u_short Normal0; - index value of normal element
u_short Vertex0; - index value of vertex element
u_short Normal1;
u_short Vertex1;
u_short Normal2;
u_short Vertex2;
} TMD_3_GS_GP;
3 SIDED, TEXTURED, FLAT SHADING, NO PIGMENT
olen = 0x07; ilen =0x05; flag =0x00; mode =0x24;
{
u_char U0, V0; - X and Y coordinate of texture for Vertex0
u_short CBA; - position of CLUT for texture in VRAM (see earlier)
u_char U1, V1; - X and Y coordinate of texture for Vertex1
u_short TSB; - information about texture in VRAM (see earlier)
u_char U2, V2; - X and Y coordinate of texture for Vertex2
u_short pad; - ignored
u_short Normal; - index value of normal element
u_short Vertex0; - index value of vertex element
u_short Vertex1;
u_short Vertex2;
} TMD_3_TX_FS_NP;
3 SIDED, TEXTURED, GOURAUD SHADING, NO PIGMENT
olen = 0x9; ilen =0x06; flag =0x00; mode =0x34;
{
u_char U0, V0; - X and Y coordinate of texture for Vertex0
u_short CBA; - position of CLUT for texture in VRAM (see earlier)
u_char U1, V1; - X and Y coordinate of texture for Vertex1
u_short TSB; - information about texture in VRAM (see earlier)
u_char U2, V2; - X and Y coordinate of texture for Vertex2
u_short pad; - ignored
u_short Normal0; - index value of normal element
u_short Vertex0; - index value of vertex element
u_short Normal1;
u_short Vertex1;
u_short Normal2;
u_short Vertex2;
} TMD_3_TX_GS_NP;
3 SIDED, NO SHADING, FLAT PIGMENT
olen = 0x04; ilen =0x03; flag =0x01; mode =0x21;
{
u_char R, G, B; - pigment of polygon
u_char mode2; - same as mode (above)
u_short Vertex0; - index value of vertex element
u_short Vertex1;
u_short Vertex2;
u_short pad; - ignored
} TMD_3_NS_FP;
3 SIDED, NO SHADING, GRADIENT PIGMENT
olen = 0x06; ilen =0x05; flag =0x01; mode =0x35;
{
u_char R0, G0, B0; - pigment of polygon at Vertex0
u_char mode2; - same as mode (above)
u_char R1, G1, B1; - pigment of polygon at Vertex1
u_char pad1; - ignored
u_char R2, G2, B2; - pigment of polygon at Vertex2
u_char pad2; - ignored
u_short Vertex0; - index value of vertex element
u_short Vertex1;
u_short Vertex2;
u_short pad; - ignored
} TMD_3_NS_GP;
3 SIDED, TEXTURED, NO SHADING, FLAT PIGMENT
olen = 0x07; ilen =0x06; flag =0x01; mode =0x25;
{
u_char U0, V0; - X and Y coordinate of texture for Vertex0
u_short CBA; - position of CLUT for texture in VRAM (see earlier)
u_char U1, V1; - X and Y coordinate of texture for Vertex1
u_short TSB; - information about texture in VRAM (see earlier)
u_char U2, V2; - X and Y coordinate of texture for Vertex2
u_short pad1; - ignored
u_char R, G, B; - pigment of polygon
u_char pad2; - ignored
u_short Vertex0; - index value of vertex element
u_short Vertex1;
u_short Vertex2;
u_short pad; - ignored
} TMD_3_TX_NS_FP;
3 SIDED, TEXTURED, NO SHADING, GRADIENT PIGMENT
olen = 0x9; ilen =0x08; flag =0x01; mode =0x35;
{
u_char U0, V0; - X and Y coordinate of texture for Vertex0
u_short CBA; - position of CLUT for texture in VRAM (see earlier)
u_char U1, V1; - X and Y coordinate of texture for Vertex1
u_short TSB; - information about texture in VRAM (see earlier)
u_char U2, V2; - X and Y coordinate of texture for Vertex2
u_short pad1; - ignored
u_char R0, G0, B0; - pigment of polygon at Vertex0
u_char pad2; - ignored
u_char R1, G1, B1; - pigment of polygon at Vertex1
u_char pad3; - ignored
u_char R2, G2, B2; - pigment of polygon at Vertex2
u_char pad4; - ignored
u_short Vertex0; - index value of vertex element
u_short Vertex1;
u_short Vertex2;
u_short pad; - ignored
} TMD_3_TX_NS_GP;
primitive List S MEMBER VARIABLES FORMAT
U_CHAR FLAG - options for primitive
{
bit 0; - LGT. Light source calculation
0 - On. Light source calculation is carried out
1 - Off. Light source calculation is not carried out
bit 1; - FCE. Determines if primitive is one or two faced
0 - Primitive has one face
1 - Primitive has two faces
bit 2; - GRD. Determines single or gradient pigment
0 - Primitive has one solid pigment
1 - Primitive has different pigments at each vertex
bits 3-7; - ignored
}
Note Most of these bits are set or cleared according to which type of primitive is being created. Messing around with these may cause unexpected drawing or crashes. The only bit you may want to edit manually is FCE.
U_CHAR MODE - options for primitive
{
bit 0; - TGE. Brightness calculation at time of calculation
0 - On. Calculates light
1 - Off. Draws texture as is (without lighting)
bit 1; - ABE. Activates translucency when rendered
0 - Off. Primitive is rendered solid.
1 - On. Primitive is rendered semitranslucent.
bit 2; - TME. Sets whether a texture is used or not
0 - Off. No texture is rendered.
1 - On. A texture is rendered.
bit 3; - displays whether a 3 or 4 sided polygon
0 - 3 sided polygon
1 - 4 sided polygon
bit 4; - IIP. Shading mode
0 - Flat shading
1 - Gouraud shading
bits 5-7; - Code. Defines which sort of entity to draw.
0 - Polygon (3 sided or 4 sided)
1 - Straight line
2 - Sprite
}
Possible values of ABR (semitransparency method) Note Most of these bits are set or cleared according to which type of primitive is being created. Messing around with these may cause unexpected drawing or crashes. The only bit you may want to edit manually is ABE. For semitransparency to be used when the TMD is rendered, bit 30 of the GsDOBJs attribute member must be set. To control the semitransparency method, alter the ABR bits of the primitives TSB member (see below).
U_SHORT CBA - position of CLUT in VRAM for primitives with textures
{
bits 0-5; - upper 6 bits of 10 bits of X coordinate value
for CLUT in VRAM
bits 6-14; - 9 bits of Y coordinate value for CLUT in VRAM
bit 15; - ignored
}
For example -
u_long CLUT_X_POS = 640; u_long CLUT_Y_POS = 480; u_short CBA = (CLUT_X_POS >> 4) + (CLUT_Y_POS << 6);
U_SHORT TSB - information about image for primitives with textures
{
bits 0-4; - texture page number of texture
bits 5-6; - ABR. Semitransparency method (see below)
bits 7-8; - TPF. Colour mode of the texture (see below)
bits 9-15; - ignored
}
Possible values of ABR (semitransparency method) Note For semitransparency to be used when the TMD is rendered, bit 30 of the GsDOBJ s attribute member must be set, and the ABE bit of the primitive s mode member must be set (see above).
0 - 50% background +50% polygon 1 - 100% background +100% polygon 2 - 100% background - 100% polygon 3 - 100% background + 25% polygon
Possible values of TPF (colour mode)
0 - 4 bit texture and CLUT 1 - 8 bit texture and CLUT 2 - 15 bit texture with no CLUT
For example -
u_long IMG_X_POS = 640; u_long IMG_Y_POS = 0; u_long ABR = 1; // 100% back + 100% polygon u_long TPF = 0; // 16 colour texture u_short TXT_TPAGE; TXT_TPAGE = GetTPage((int) TPF, (int) ABR, IMG_X_POS, IMG_Y_POS); u_short TSB = (TXT_TPAGE) + (ABR << 5) + (TPF << 7);
MultiEx BMS Script
Not written yet.
Notes and Comments
None.
Games
List of games using this file format:
- //TODO
Compatible Programs
- //TODO