/*****************************************************************************
 * Copyright(C)SEGA 1996-1998/SYSTEM R&D DEPT                                *
 *                                                                           *
 *     VERSION: 0.72alpha1                                                   *
 *     DATE:    1998/02/04                                                   *
 *****************************************************************************/

#ifndef _NJDEF_H_
#define _NJDEF_H_

/********************************************************
 * Ascii
 ********************************************************/
/***  Macro  ***/
#define     ARGB(a, r, g, b)    ((unsigned long)((a)<<24)|(unsigned long)((r)<<16)|(unsigned long)((g)<<8)|(b))
#define     TEXN(texname)                 {(texname), 0x0, 0}
#define     TEXN3(texname, attr, texaddr) {(texname), attr, texaddr}
#define     UV(v, u)            (((((long)(u))<<16)&0xffff0000)|((long)(v))& 0x0000ffff)
#define     val                 65535.0f/360.0000F
#define     ANG(x,y,z)          {(long)(val*(x)),(long)(val*(y)),(long)(val*(z))}
#define     MKEYF(k,x,y,z)      {((Uint32)(k)),((float)(x)),((float)(y)),((float)(z))}
#define     MKEYA(k,x,y,z)      {((Uint32)(k)),((long)(val*(x))),((long)(val*(y))),((long)(val*(z)))}
#define     MKEYAX(k,a,x,y,z)   {((Uint32)(k)),((float)((a))),((float)(x)),((float)(y)),((float)(z))}
#define     MKEYP(k,x)          {((Uint32)(k)),((void *)(x))}

#define     VERT(x,y,z)         (x), (y), (z)
#define     NORM(x,y,z)         (x), (y), (z)
#define     PNORM(x,y,z)        (x), (y), (z)


#ifndef     NULL
#define     NULL                ((void*) 0)
#endif 

/***  Type  ***/
#define    TEXTURE_START
#define    TEXTURENAME          NJS_TEXNAME
#define    TEXTURELIST          NJS_TEXLIST
#define    NO_TEXTURE           0
#define    TEXTURE_END

#define    MATERIAL_START
#define    MATERIAL             NJS_MATERIAL
#define    MATERIAL_LIST        MATERIAL*
#define    MATERIAL_END
#define    MATSTART             {
#define    MATEND               },

#define    OBJECT_START
#define    POLYGON              Uint16
#define    POLYNORMAL           NJS_VECTOR
#define    VERTCOLOR            NJS_COLOR
#define    VERTUV               NJS_COLOR
#define    MESHSET              NJS_MESHSET
#define    MESHSTART            {
#define    MESHEND              },
#define    POINT		NJS_POINT3
#define    NORMAL		NJS_VECTOR
#define    MODEL		NJS_MODEL
#define    OBJECT		NJS_OBJECT
#define    OBJECT_END
#define    MOTION_START
#define    POSITION		NJS_MKEY_F
#define    XROTATION		NJS_MKEY_AX
#define    ROTATION		NJS_MKEY_A
#define    SCALE		NJS_MKEY_F
#define    AXEVECT		NJS_MKEY_AX
#define    POINTER		NJS_MKEY_P
#define    MDATA1		NJS_MDATA1
#define    MDATA2		NJS_MDATA2
#define    MDATA3		NJS_MDATA3
#define    MDATA4		NJS_MDATA4
#define    MOTION		NJS_MOTION
#define    ACTION		NJS_ACTION
#define    MOTION_END
#define    DEFAULT_START
#define    DEFAULT_END
#define    SHAPE_MOTION_START
#define    SHAPE_MOTION_END

#define     START          ={
#define     END            };

/***  Define  ***/
#define    TextureList
#define    TextureNum

#define    Diffuse(a, r, g, b)  ARGB(a, r, g, b)
#define    Specular(a, r, g, b) ARGB(a, r, g, b)
#define    Exponent(exp)        (exp)
#define    AttrTexId(attr, tid) (attr|tid)
#define    AttrFlags(atf)       (atf)

#define    TypeMatId(type, mid) (type|mid)
#define    MeshNum
#define    Meshes
#define    PolyAttrs
#define    PolyNormal
#define    VertColor
#define    VertUV

#define    Points
#define    Normal
#define    Meshset
#define    PointNum
#define    MeshsetNum
#define    Materials
#define    MatNum
#define    Center
#define    Radius

#define    EvalFlags(ef)        (ef)
#define    Model
#define    Position(x, y, z)    (x), (y), (z)
#define    Angle(x, y, z)       ANG(x, y, z)
#define    Scale(x, y, z)       (x), (y), (z)
#define    Child
#define    Sibling

#define    MdataArray
#define    MFrameNum
#define    MotionBit
#define    InterpolFct
#define    ObjectHead
#define    Motion

#define    Strip(flag, len) (flag|len)

/********************************************************
 * Binary
 ********************************************************/
/*
 * chunk name
 */
#define iff_NJINFO  'NJIN'     /* data infomation        */
#define iff_NJD     'NJD '     /* ninja model tree       */
#define iff_NJDO    'NJDO'     /* model offset list      */
#define iff_NJT     'NJT '     /* ninja texlist          */
#define iff_NJTO    'NJTO'     /* texture offset list    */
#define iff_NJM     'NJM '     /* ninja motion           */ 
#define iff_NJMO    'NJMO'     /* motion offset list     */ 

/*
 * texture chunk name
 */
#define iff_PVRT    'PVRT'     /* PowerVR texture        */ 
#define iff_GBIX    'GBIX'     /* globalIndex            */ 
#define iff_PVRI    'PVRI'     /* texture Info           */ 

#endif /* _NJDEF_H_ */
