//------------------------------------ // Adapted from programs written by // R.Swan who edited them from code // that is (C) Sony Computer // Entertainment. Origional author // S. Ashley 7th Aug 97 //------------------------------------ #include #define TX_NS_GP_QUAD (0x3d) //------------------------------------ // Structures //------------------------------------ typedef struct { u_long id; u_long flag; u_long nobj; } HEADER; typedef struct { u_long *vert_top; u_long n_vert; u_long *normal_top; u_long n_normal; u_long *primitive_top; u_long n_primitive; long scale; } OBJECT; typedef struct { short vx, vy, vz; short padding; } VERTEX; typedef struct { short nx, ny, nz; short padding; } NORMAL; typedef struct { u_char r, g, b; } COLOUR; typedef struct { u_short x0, y0; u_short x1, y1; u_short x2, y2; u_short x3, y3; int pmode; u_short cx, cy; } TEXTURE; typedef struct { u_char olen, ilen, flag, mode; u_char u0, v0; u_short cba; u_char u1, v1; u_short tsb; u_char u2, v2; u_short padding1; u_char u3, v3; u_short padding2; u_char r0, g0, b0, padding3; u_char r1, g1, b1, padding4; u_char r2, g2, b2, padding5; u_char r3, g3, b3, padding6; u_short vert0, vert1, vert2, vert3; } TX_NS_GP_QUAD_FACE; //------------------------------------ // Macro's //------------------------------------ #define SetTmdHeader(h) \ (h)->id = 0x41, \ (h)->flag = 1, \ (h)->nobj = 1 #define SetObjectData(o) \ (o)->vert_top = VERTEX_START, \ (o)->n_vert = VERTEX_QUANTITY, \ (o)->normal_top = NORMAL_START, \ (o)->n_normal = NORMAL_QUANTITY, \ (o)->primitive_top = PRIMITIVE_START, \ (o)->n_primitive = PRIMITIVE_QUANTITY, \ (o)->scale = 0 #define SetPrimitiveHeader(h, _m, _f, _i, _o) \ (h)->mode = (_m), \ (h)->flag = (_f), \ (h)->ilen = (_i), \ (h)->olen = (_o) #define SetColour0() \ newPoly->r0 = (COLOUR_LUT+c0)->r, \ newPoly->g0 = (COLOUR_LUT+c0)->g, \ newPoly->b0 = (COLOUR_LUT+c0)->b #define SetColour1() \ newPoly->r1 = (COLOUR_LUT+c1)->r, \ newPoly->g1 = (COLOUR_LUT+c1)->g, \ newPoly->b1 = (COLOUR_LUT+c1)->b #define SetColour2() \ newPoly->r2 = (COLOUR_LUT+c2)->r, \ newPoly->g2 = (COLOUR_LUT+c2)->g, \ newPoly->b2 = (COLOUR_LUT+c2)->b #define SetColour3() \ newPoly->r3 = (COLOUR_LUT+c3)->r, \ newPoly->g3 = (COLOUR_LUT+c3)->g, \ newPoly->b3 = (COLOUR_LUT+c3)->b #define SetVertex(v, _x, _y, _z) \ (v)->vx = (_x), \ (v)->vy = (_y), \ (v)->vz = (_z) #define SetNormal(n, _x, _y, _z) \ (n)->nx = (_x), \ (n)->ny = (_y), \ (n)->nz = (_z) #define SetColour(c, _r, _g, _b) \ (c)->r = (_r), \ (c)->g = (_g), \ (c)->b = (_b) #define SetTexture(t, _x0, _y0, _x1, _y1, _x2, _y2, _x3, _y3, _pmode, _cx, _cy) \ (t)->x0 = (_x0), \ (t)->y0 = (_y0), \ (t)->x1 = (_x1), \ (t)->y1 = (_y1), \ (t)->x2 = (_x2), \ (t)->y2 = (_y2), \ (t)->x3 = (_x3), \ (t)->y3 = (_y3), \ (t)->pmode = (_pmode), \ (t)->cx = (_cx), \ (t)->cy = (_cy) //------------------------------------ // Function types //------------------------------------ void PrepareTMD(u_long address, VERTEX *vertex, COLOUR *colour, TEXTURE *texture); u_long *FinishTMD(void); void SetTX_NS_GP_QUAD(u_short v0, u_short v1, u_short v2, u_short v3, u_long c0, u_long c1, u_long c2, u_long c3, u_long t0); void SetTextureQuad(TX_NS_GP_QUAD_FACE *newPoly, u_long textureNum);