Playstation TMD: Difference between revisions

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

Latest revision as of 22:24, 16 November 2021

TMD


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