// TMD structure definitions etc. // You will not usually need this file -- it is most likely you // will be using an include in your program almost identical to // this. I have just included this in the TMD_check.zip file // incase the include file you use does not have every definition // required -- if so you can cut/paste them from here into your // include file. // (C) 1997 by Sony Computer Entertainment (by S. Ashley 9th Jan 97) // for decoding primative mode #define IIP 0x10 // gouraud shading #define QUAD 0x08 // 4 sided #define TME 0x04 // textured #define ABE 0x02 // semi transparency on #define TGE 0x01 // brightness calculation off // flags for primatives #define GRD 0x04 // gradation #define FCE 0x02 // 2 sided #define LGT 0x01 // no light source calculation // primative modes #define F_3 0x20 // Triangle No-texture #define F_3G 0x20 // Triangle No-texture gradation #define F_3T 0x24 // Triangle Texture #define G_3 0x30 // triangle gouraud #define G_3G 0x30 // triangle gouraud gradation #define G_3T 0x34 // triangle gouraud texture #define F_3_NL 0x21 // triangle no texture no light #define F_3T_NL 0x25 // triangle texture no light #define G_3_NL 0x31 // triangle gouraud no texture no light #define G_3T_NL 0x35 // triangle gouraud texture no light #define F_4 0x28 // Quadangle No-texture #define F_4G 0x28 // Quadangle No-texture gradation #define F_4T 0x2c // Quadangle Texture #define G_4 0x38 // quad gouraud #define G_4G 0x38 // quad gouraud gradation #define G_4T 0x3c // quad gouraud texture #define F_4_NL 0x29 // quad no texture no light #define F_4T_NL 0x2d // quad texture no light #define G_4_NL 0x39 // quad gouraud no texture no light #define G_4T_NL 0x3d // quad gouraud texture no light #define SL 0x40 // straight line no gradation #define SL_G 0x50 // straight line gradation // TMD is made up of header, object tables (one for each object), // primative table, vertices table and normals table typedef struct { u_long id; // 0x00000041 u_long flag; // 1 if addresses real, 0 if offset u_long nobjs; // number of objects in TMD } TMD_HDR; typedef struct { u_long *vert_top; // vertices table u_long n_vert; // number of vertices u_long *norm_top; // normal table u_long n_norm; // number of normals u_long *prim_top; // primatives table u_long n_prim; // number of primatives long scale; // not used } TMD_OBJ; // primative table is made up of a collection of primatives headers, // with their primative data typedef struct { u_char olen, ilen, flag, mode; } PRIM_HDR; //typedef struct // { // short vx, vy; // short vz, pad; // } TMD_VERT; //typedef struct // { // short nx, ny; // short nz, pad; // } TMD_NORM; // .... I'm just using SVECTOR instead of these // TMD_VERT & TMD_NORM structures now to make it // easier to ship vectors to various maths routines etc. // since they are byte-for-byte the same anyway. // normals and vertices are indices for the normal and vertex tables // r0, g0, b0 are colour values // mode2 is just a repetition of the mode data used as a filler typedef struct // ilen 3 olen 4 { u_char r0, g0, b0, mode2; u_short norm0, vert0; u_short vert1, vert2; } TMD_F_3; // pad0, pad1 are just padding typedef struct // ilen 5 olen 6 { u_char r0, g0, b0, mode2; u_char r1, g1, b1, pad0; u_char r2, g2, b2, pad1; u_short norm0, vert0; u_short vert1, vert2; } TMD_F_3G; // CBA clutY * 64 + clutX / 16 // TSB texture page + semitrans rate (0..3) << 5 + colour mode (0..2) << 7 // u, v are texture page coordinates typedef struct // ilen 5 olen 7 { u_char u0, v0; u_short cba; u_char u1, v1; u_short tsb; u_char u2, v2; u_short pad; u_short norm0, vert0; u_short vert1, vert2; } TMD_F_3T; typedef struct // ilen 4 olen 5 { u_char r0, g0, b0, mode2; u_short norm0, vert0; u_short vert1, vert2; u_short vert3, pad; } TMD_F_4; typedef struct // ilen 7 olen 8 { u_char r0, g0, b0, mode2; u_char r1, g1, b1, pad0; u_char r2, g2, b2, pad1; u_char r3, g3, b3, pad2; u_short norm0, vert0; u_short vert1, vert2; u_short vert3, pad3; } TMD_F_4G; typedef struct // ilen 7 olen 9 { u_char u0, v0; u_short cba; u_char u1, v1; u_short tsb; u_char u2, v2; u_short pad0; u_char u3, v3; u_short pad1; u_short norm0, vert0; u_short vert1, vert2; u_short vert3, pad2; } TMD_F_4T; typedef struct // ilen 4 olen 6 { u_char r0, g0, b0, mode2; u_short norm0, vert0; u_short norm1, vert1; u_short norm2, vert2; } TMD_G_3; typedef struct // ilen 6 olen 6 { u_char r0, g0, b0, mode2; u_char r1, g1, b1, pad0; u_char r2, g2, b2, pad1; u_short norm0, vert0; u_short norm1, vert1; u_short norm2, vert2; } TMD_G_3G; typedef struct // ilen 6 olen 9 { u_char u0, v0; u_short cba; u_char u1, v1; u_short tsb; u_char u2, v2; u_short pad; u_short norm0, vert0; u_short norm1, vert1; u_short norm2, vert2; } TMD_G_3T; typedef struct // ilen 5 olen 8 { u_char r0, g0, b0, mode2; u_short norm0, vert0; u_short norm1, vert1; u_short norm2, vert2; u_short norm3, vert3; } TMD_G_4; typedef struct // ilen 8 olen 8 { u_char r0, g0, b0, mode2; u_char r1, g1, b1, pad0; u_char r2, g2, b2, pad1; u_char r3, g3, b3, pad2; u_short norm0, vert0; u_short norm1, vert1; u_short norm2, vert2; u_short norm3, vert3; } TMD_G_4G; typedef struct // ilen 8 olen 12 { u_char u0, v0; u_short cba; u_char u1, v1; u_short tsb; u_char u2, v2; u_short pad0; u_char u3, v3; u_short pad1; u_short norm0, vert0; u_short norm1, vert1; u_short norm2, vert2; u_short norm3, vert3; } TMD_G_4T; typedef struct // ilen 3 olen 4 { u_char r0, g0, b0, mode2; u_short vert0, vert1; u_short vert2, pad; } TMD_F_3_NL; typedef struct // ilen 6 olen 7 { u_char u0, v0; u_short cba; u_char u1, v1; u_short tsb; u_char u2, v2; u_short pad0; u_char r0, g0, b0, pad1; u_short vert0, vert1; u_short vert2, pad2; } TMD_F_3T_NL; typedef struct // ilen 5 olen 6 { u_char r0, g0, b0, mode2; u_char r1, g1, b1, pad0; u_char r2, g2, b2, pad1; u_short vert0, vert1; u_short vert2, pad2; } TMD_G_3_NL; typedef struct // ilen 8 olen 9 { u_char u0, v0; u_short cba; u_char u1, v1; u_short tsb; u_char u2, v2; u_short pad0; u_char r0, g0, b0, pad1; u_char r1, g1, b1, pad2; u_char r2, g2, b2, pad3; u_short vert0, vert1; u_short vert2, pad4; } TMD_G_3T_NL; typedef struct // ilen 3 olen 5 { u_char r0, g0, b0, mode2; u_short vert0, vert1; u_short vert2, vert3; } TMD_F_4_NL; typedef struct // ilen 7 olen 9 { u_char u0, v0; u_short cba; u_char u1, v1; u_short tsb; u_char u2, v2; u_short pad0; u_char u3, v3; u_short pad1; u_char r0, g0, b0, pad2; u_short vert0, vert1; u_short vert2, vert3; } TMD_F_4T_NL; typedef struct // ilen 6 olen 8 { u_char r0, g0, b0, mode2; u_char r1, g1, b1, pad0; u_char r2, g2, b2, pad1; u_char r3, g3, b3, pad2; u_short vert0, vert1; u_short vert2, vert3; } TMD_G_4_NL; typedef struct // ilen 10 olen 12 { u_char u0, v0; u_short cba; u_char u1, v1; u_short tsb; u_char u2, v2; u_short pad0; u_char u3, v3; u_short pad1; u_char r0, g0, b0, pad2; u_char r1, g1, b1, pad3; u_char r2, g2, b2, pad4; u_char r3, g3, b3, pad5; u_short vert0, vert1; u_short vert2, vert3; } TMD_G_4T_NL; typedef struct // ilen 2 olen 3 { u_char r0, g0, b0, mode2; u_short vert0, vert1; } TMD_SL; typedef struct // ilen 3 olen 4 { u_char r0, g0, b0, mode2; u_char r1, g1, b1, pad; u_short vert0, vert1; } TMD_SL_G;