2
File formats structures
ABelliqueux edited this page 2021-08-08 18:23:36 +02:00

File formats structures

TIM

See http://psx.arthus.net/sdk/Psy-Q/DOCS/FileFormat47.pdf , p.179

typedef struct RGB_PIX {
    u_int  R:5, G:5, B:5, STP:1;
    } RGB_PIX;
    
// Some structures to handle TIM files 
typedef struct PIXEL {
    u_long bnum;
    u_short DX, DY;
    u_short W, H;
    RGB_PIX data[]; 
} PIXEL;

typedef struct CLUT {
    u_long bnum;
    u_short DX, DY;
    u_short W, H;
    u_short clut[]; 
} CLUT;

typedef struct TIM_FILE_CLUT{
    u_long ID;
    u_long flag;
    u_long clut;
    PIXEL pixel[];
} TIM_FILE_CLUT;

typedef struct TIM_FILE{
    u_long ID;
    u_long flag;
    PIXEL pixel[];
} TIM_FILE;

TMD

WIP

See http://psx.arthus.net/sdk/Psy-Q/DOCS/FileFormat47.pdf , p.71

typedef struct TMD_HEADER {
    u_long ID;       // TMD file version - current is 0x00000041
    u_long flags;    // LSB (FIXP) is either 0 or 1, all other bits are 0
    u_long nobj;     // Number of objects in TMD
} TMD_HEADER;

struct TMD_OBJECT {
    u_long *vert_top;       // Start address of a vertex - if FIXP is 1, absolute address, else, relative to object's block address
    u_long n_vert;          // Number of vertices
    u_long *normal top;     // Start address of a normal  - if FIXP is 1, absolute address, else, relative to object's block address
    u_long n_normal;        // Number of normals
    u_long *primitive top;  // Start address of a primitive  - if FIXP is 1, absolute address, else, relative to object's block address
    u_long n_primitive;     // Number of primitives
    long scale;             // Scaling factor - scale value is scale factor^2 . -1 is 1/2.
} TMD_OBJECT;

struct TMD_PACKET {
    u_short mode, flag;
    u_short ilen;           // data section length in words
    u_short olen;           // word length
    u_long data;
    } TMD_PACKET;
struct TMD_VERTEX {
    short vx, vy, vz;
    short pad;
} TMD_VERTEX;

struct TMD_NORMAL {
    short vx, vy, vz;       // fixed point value with scale 1.0 == 4096
    short pad;
} TMD_NORMAL;

typedef struct TMD_FILE {
    TMD_HEADER header;
    TMD_OBJECT objTable[];  // objTable has length TMD_HEADER.nobj
    TMD_PACKET primitive[]; // primtive has length TM_PACKET.ilen
    TMD_VERTEX vertex;
    TMD_NORMAL normal;
} TMD_FILE;