/*
    Ninja Library

    COPYRIGHT (C) SEGA ENTERSRISES,LTD.
*/

#ifndef _NINJA_CNK2_H_
#define _NINJA_CNK2_H_

/*------------------*/
/*	Define			*/
/*------------------*/

/*	strip flag		*/
#define	NJD_SF_IL		(NJD_FST_IL >> NJD_FST_SHIFT)
#define	NJD_SF_IS		(NJD_FST_IS >> NJD_FST_SHIFT)
#define	NJD_SF_IA		(NJD_FST_IA >> NJD_FST_SHIFT)
#define	NJD_SF_UA		(NJD_FST_UA >> NJD_FST_SHIFT)
#define	NJD_SF_DB		(NJD_FST_DB >> NJD_FST_SHIFT)
#define	NJD_SF_FL		(NJD_FST_FL >> NJD_FST_SHIFT)
#define	NJD_SF_ENV		(NJD_FST_ENV >> NJD_FST_SHIFT)
#define	NJD_SF_MASK		(NJD_FST_MASK >> NJD_FST_SHIFT)

/*	user offset		*/
#define	NJD_UO_MASK		(NJD_UFO_MASK >> NJD_UFO_SHIFT)
#define	NJD_NS_MASK		(~NJD_UFO_MASK)

/*	vertex type		*/
#define	NJD_VERTEX_TYPE_NORMAL		(0)
#define	NJD_VERTEX_TYPE_INTENSITY	(1)
#define	NJD_VERTEX_TYPE_DIFFUSE		(2)
#define	NJD_VERTEX_TYPE_SPECULAR	(3)

/*------------------*/
/*	Structure		*/
/*------------------*/

/** Vertex Buffer	**/
typedef	struct	{
	Sint32	clip;			/* clip flag		*/
	Float	sx;				/* Screen X			*/
	Float	sy;				/* Screen Y			*/
	Float	ooz;			/* One over Z		*/
	NJS_POINT3	point;		/* 3D Point			*/
	Sint16	u,v;			/* model uv			*/
	Sint16	flag,vtype;		/* flag,vetex type	*/
	NJS_VECTOR	vector;		/* Normal vector	*/
	union  {				/*					*/
		Uint32	argb[2];	/* Packed Color		*/
		Float	inten[2];	/* intensity		*/
	} col;					/* color			*/
	Sint32	NinjaFlag;		/* Ninja Flag		*/
	Sint32	UserFlag;		/* User Flag		*/
} NJS_CNK_VERTEX_BUF;



typedef	struct	{
	Float	lx,ly,lz;			/* light vector		*/
	Float	diff,ambi;			/* light intensity	*/
	Sint32	n;					/* vertex num		*/
	void	*vertex;			/* vertex list		*/
	void	*vbuf;				/* work buf address	*/
	void	*sq;				/* work buf sq adrs	*/
	Float	xad,yad;			/* screen distans aspect	*/
	Float	cx,cy;				/* screen center	*/
	Uint32	dmy[3];
} NJS_CNK_EASY_VERTEX;

typedef	struct	{
	Float	lx,ly,lz;			/* light vector		*/
	Float	diff,ambi;			/* light intensity	*/
	Sint32	n;					/* vertex num		*/
	void	*vertex;			/* vertex list		*/
	void	*vbuf;				/* work buf address	*/
	void	*sq;				/* work buf sq adrs	*/
	Float	xad,yad;			/* screen distans aspect	*/
	Float	cx,cy;				/* screen center	*/
	Uint32	dmy[3];
} NJS_CNK_SIMPLE_VERTEX;

typedef	struct	{
	Float	x;
	Float	y;
	Float	ooz;
	Float	inten;
} NJS_CNK_EASY_BUF;

typedef	struct	{
	Float	spec;
	Float	x;
	Float	y;
	Float	ooz;
	Float	nx;
	Float	ny;
	Float	inten;
	Float	z;
} NJS_CNK_SIMPLE_BUF;

typedef	struct	{
	void	*strip;				/* strip data address	*/
	Sint16	sn;					/* strip num			*/
	Sint16	uf;					/* user flag			*/
	void	*vbuf;				/* vbuf address			*/
	void	*sq;				/* vertex list store address	*/
} NJS_CNK_STRIP;


/*
	MACRO (Use Libraly)
*/

/*
	api
*/

Sint32	njCnkModelClip( NJS_CNK_MODEL *model );
void	njCnkSetMaterial( Uint32 data, Uint32 *plist, Float *diff, Float *ambi, Float *spec );

/*
	Easy Model
*/
Int		njCnkEasyVertexVN( NJS_CNK_EASY_VERTEX *p );
Float	*njCnkEasyTextureF( NJS_CNK_STRIP *p );
Float	*njCnkEasyPolygon( NJS_CNK_STRIP *p, Float a, Float r, Float g, Float b );
Float	*njCnkEasyPolygonClip( NJS_CNK_STRIP *p, Float a, Float r, Float g, Float b );
Float	*njCnkEasyTexture( NJS_CNK_STRIP *p, Float div );
Float	*njCnkEasyTextureClip( NJS_CNK_STRIP *p, Float div );
Float	*njCnkEasyTextureNearClip( NJS_CNK_EASY_BUF *p0, NJS_CNK_EASY_BUF *p1, NJS_CNK_EASY_BUF *p2, Float *SQ, Float u0, Float v0, Float u1, Float v1, Float u2, Float v2, Float fwork2);
Float	*njCnkEasyPolygonNearClip( NJS_CNK_EASY_BUF *p0, NJS_CNK_EASY_BUF *p1, NJS_CNK_EASY_BUF *p2, Float *SQ, Float a, Float r, Float g, Float b, Float fwork2);
Float	*njCnkEasyTextureDouble( NJS_CNK_STRIP *p, Float div );
Float	*njCnkEasyTextureDoubleClip( NJS_CNK_STRIP *p, Float div );

/*
	Simple Model
*/
Int		njCnkSimpleVertexVN( NJS_CNK_SIMPLE_VERTEX *p );
Float	*njCnkSimpleTextureF( NJS_CNK_STRIP *p );
Float	*njCnkSimplePolygon( NJS_CNK_STRIP *p, Float a, Float r, Float g, Float b );
Float	*njCnkSimplePolygonClip( NJS_CNK_STRIP *p, Float a, Float r, Float g, Float b );
Float	*njCnkSimpleTexture( NJS_CNK_STRIP *p, Float div );
Float	*njCnkSimpleTextureClip( NJS_CNK_STRIP *p, Float div );
Float	*njCnkSimplePolygonEnv( NJS_CNK_STRIP *p );
Float	*njCnkSimpleTextureEnv( NJS_CNK_STRIP *p );

#endif /* _NINJA_CNK2_H_ */

/*
 * End Of File
 */
