/*
	Ninja Library
	
	COPYRIGHT (C) SEGA ENTERPRISES,LTD.

*/
#ifndef _NJSYSTEM_H_
#define _NJSYSTEM_H_


/*--------------------------------------*/
/*      Render Mode Define              */
/*--------------------------------------*/

#define NJD_POLYGON_NOCULLING				0x00000000
#define NJD_POLYGON_CULLINGSMALL			0x08000000
#define NJD_POLYGON_CULLINGACW				0x10000000
#define NJD_POLYGON_CULLINGCW				0x18000000

#define NJD_SOURCE_COLOR					0
#define NJD_DESTINATION_COLOR				1
#define NJD_COLOR_BLENDING_BOTHINVALPHA		0
#define NJD_COLOR_BLENDING_BOTHSRCALPHA		1
#define NJD_COLOR_BLENDING_DESTALPHA		2
#define NJD_COLOR_BLENDING_DESTCOLOR		3
#define NJD_COLOR_BLENDING_INVDESTALPHA		4
#define NJD_COLOR_BLENDING_INVDESTCOLOR		5
#define NJD_COLOR_BLENDING_INVSRCALPHA		6
#define NJD_COLOR_BLENDING_INVSRCCOLOR		7
#define NJD_COLOR_BLENDING_SRCALPHA			8
#define NJD_COLOR_BLENDING_SRCCOLOR			9
#define NJD_COLOR_BLENDING_ONE				10
#define NJD_COLOR_BLENDING_ZERO				11

#define NJD_TEX_SHADING_MODE_DECAL			0x00000000
#define NJD_TEX_SHADING_MODE_MODULATE		0x00000040
#define NJD_TEX_SHADING_MODE_DECALALPHA		0x00000080
#define NJD_TEX_SHADING_MODE_MODULATEALPHA	0x000000c0

#define NJD_CLIP_DISABLE					0
#define NJD_CLIP_RESERVE					1
#define NJD_CLIP_INSIDE						2
#define NJD_CLIP_OUTSIDE					3

#define	NJD_TEXTUREFILTER_POINT_SAMPLE		0x00000000
#define	NJD_TEXTUREFILTER_BILINEAR			0x00002000
#define	NJD_TEXTUREFILTER_TRILINEAR_A		0x00004000
#define	NJD_TEXTUREFILTER_TRILINEAR_B		0x00006000

#define	NJD_TEXTURECLAMP_NOCLAMP			0x00000000
#define	NJD_TEXTURECLAMP_CLAMP_V			0x00008000
#define	NJD_TEXTURECLAMP_CLAMP_U			0x00010000
#define	NJD_TEXTURECLAMP_CLAMP_UV			0x00018000

#define	NJD_TEXTUREFLIP_NOFLIP				0x00000000
#define	NJD_TEXTUREFLIP_FLIP_V				0x00020000
#define	NJD_TEXTUREFLIP_FLIP_U				0x00040000
#define	NJD_TEXTUREFLIP_FLIP_UV				0x00060000

#define	NJD_MODIFIER_INSIDE					0x20000000
#define	NJD_MODIFIER_OUTSIDE				0x40000000

/*--------------------------------------*/
/*    RenderStatus Define			    */
/*--------------------------------------*/
#define NJD_STATUS_UNDER_DMA 				(0x0100)
#define NJD_STATUS_FINISH_DMA 				(0x0101)
#define NJD_STATUS_UNDER_RENDER 			(102L)
#define NJD_STATUS_FINISH_RENDER 			(103L)
#define NJD_STATUS_UNDER_DISPLAY 			(104L)
#define NJD_STATUS_FINISH_ALL_SEQUENCE 		(105L)

/*--------------------------------------*/
/*    Start Status          		    */
/*--------------------------------------*/
#define NJD_START_OK		 				(0)
#define NJD_START_WAIT_FOR_TEXTURE_DMA		(1)
#define NJD_START_WAIT_FOR_BUFFER_UNLOCK	(2)

/*--------------------------------------*/
/*    Virtical Filter Mode			    */
/*--------------------------------------*/

#define NJD_VIRTICAL_FILTER_NO_FILTER		(0)
#define NJD_VIRTICAL_FILTER_NORMAL			(1)
#define NJD_VIRTICAL_FILTER_SQUARE_PIXEL	(2)
#define NJD_VIRTICAL_FILTER_VGA				(3)

/*--------------------------------------*/
/*      FRAME BUFFER MODE               */
/*--------------------------------------*/
#define	NJD_FRAMEBUFFER_MODE_RGB565				0
#define	NJD_FRAMEBUFFER_MODE_RGB555				1
#define	NJD_FRAMEBUFFER_MODE_ARGB1555			3
#define	NJD_FRAMEBUFFER_MODE_RGB888				4
#define	NJD_FRAMEBUFFER_MODE_ARGB8888			5

/*--------------------------------------*/
/*      SCREEN RESOLUTION               */
/*--------------------------------------*/
#define NJD_DSP_NTSC		(0x0)
#define NJD_DSP_VGA			(0x1)
#define NJD_DSP_PAL			(0x2)

#define NJD_DSP_NONINTER 	(0x00)
#define NJD_DSP_INTER    	(0x04)
#define NJD_DSP_PSINTER  	(0x08)

#define NJD_DSP_WIDTH_320	(0x000)
#define NJD_DSP_WIDTH_640	(0x010)

#define NJD_DSP_HEIGHT_240	(0x000)
#define NJD_DSP_HEIGHT_480	(0x020)
#define NJD_DSP_HEIGHT_NRM	(0x000)
#define NJD_DSP_HEIGHT_EXT	(0x040)


#define NJD_DSP_ANTI							(0x00010000)
#define NJD_PALEXT_HEIGHT_RATIO_1_033			(0x00000000)
#define NJD_PALEXT_HEIGHT_RATIO_1_066			(0x00020000)
#define NJD_PALEXT_HEIGHT_RATIO_1_100			(0x00040000)
#define NJD_PALEXT_HEIGHT_RATIO_1_133			(0x00060000)
#define NJD_PALEXT_HEIGHT_RATIO_1_166			(0x00080000)

#define NJD_DSP_AUTO							(0x80000000)
#define NJD_DSP_PAL60							(0x40000000)

#define NJD_DSP_320x240		(NJD_DSP_WIDTH_320|NJD_DSP_HEIGHT_240)
#define NJD_DSP_640x240		(NJD_DSP_WIDTH_640|NJD_DSP_HEIGHT_240)
#define NJD_DSP_320x480		(NJD_DSP_WIDTH_320|NJD_DSP_HEIGHT_480)
#define NJD_DSP_640x480		(NJD_DSP_WIDTH_640|NJD_DSP_HEIGHT_480)
#define NJD_DSP_640x240_EXT	(NJD_DSP_WIDTH_640 | NJD_DSP_HEIGHT_240 | NJD_DSP_HEIGHT_EXT)
#define NJD_DSP_640x480_EXT	(NJD_DSP_WIDTH_640 | NJD_DSP_HEIGHT_480 | NJD_DSP_HEIGHT_EXT)

#define	NJD_RESOLUTION_VGA					(NJD_DSP_VGA|NJD_DSP_NONINTER|NJD_DSP_640x480)
#define	NJD_RESOLUTION_320x240_NTSCNI		(NJD_DSP_NTSC|NJD_DSP_NONINTER|NJD_DSP_320x240)
#define	NJD_RESOLUTION_320x240_NTSCI		(NJD_DSP_NTSC|NJD_DSP_INTER   |NJD_DSP_320x240)
#define	NJD_RESOLUTION_640x240_NTSCNI		(NJD_DSP_NTSC|NJD_DSP_NONINTER|NJD_DSP_640x240)
#define	NJD_RESOLUTION_640x240_NTSCI		(NJD_DSP_NTSC|NJD_DSP_INTER   |NJD_DSP_640x240)
#define	NJD_RESOLUTION_320x480_NTSCNI_FF 	(NJD_DSP_NTSC|NJD_DSP_NONINTER|NJD_DSP_320x480)
#define	NJD_RESOLUTION_320x480_NTSCNI		(NJD_DSP_NTSC|NJD_DSP_PSINTER |NJD_DSP_320x480)
#define	NJD_RESOLUTION_320x480_NTSCI		(NJD_DSP_NTSC|NJD_DSP_INTER   |NJD_DSP_320x480)
#define	NJD_RESOLUTION_640x480_NTSCNI_FF 	(NJD_DSP_NTSC|NJD_DSP_NONINTER|NJD_DSP_640x480)
#define NJD_RESOLUTION_640x480_NTSCNI	 	(NJD_DSP_NTSC|NJD_DSP_PSINTER |NJD_DSP_640x480)
#define	NJD_RESOLUTION_640x480_NTSCI		(NJD_DSP_NTSC|NJD_DSP_INTER   |NJD_DSP_640x480)
#define	NJD_RESOLUTION_320x240_PALNI		(NJD_DSP_PAL |NJD_DSP_NONINTER|NJD_DSP_320x240)
#define	NJD_RESOLUTION_320x240_PALI			(NJD_DSP_PAL |NJD_DSP_INTER   |NJD_DSP_320x240)
#define	NJD_RESOLUTION_640x240_PALNI		(NJD_DSP_PAL |NJD_DSP_NONINTER|NJD_DSP_640x240)
#define	NJD_RESOLUTION_640x240_PALI			(NJD_DSP_PAL |NJD_DSP_INTER   |NJD_DSP_640x240)
#define	NJD_RESOLUTION_320x480_PALNI_FF		(NJD_DSP_PAL |NJD_DSP_NONINTER|NJD_DSP_320x480)
#define	NJD_RESOLUTION_320x480_PALNI		(NJD_DSP_PAL |NJD_DSP_PSINTER |NJD_DSP_320x480)
#define	NJD_RESOLUTION_320x480_PALI			(NJD_DSP_PAL |NJD_DSP_INTER   |NJD_DSP_320x480)
#define	NJD_RESOLUTION_640x480_PALNI_FF		(NJD_DSP_PAL |NJD_DSP_NONINTER|NJD_DSP_640x480)
#define	NJD_RESOLUTION_640x480_PALNI		(NJD_DSP_PAL |NJD_DSP_PSINTER |NJD_DSP_640x480)
#define	NJD_RESOLUTION_640x480_PALI			(NJD_DSP_PAL |NJD_DSP_INTER   |NJD_DSP_640x480)

#define	NJD_RESOLUTION_VGA_ANTI					(NJD_RESOLUTION_VGA				 |NJD_DSP_ANTI)
#define	NJD_RESOLUTION_320x240_NTSCNI_ANTI		(NJD_RESOLUTION_320x240_NTSCNI	 |NJD_DSP_ANTI)
#define	NJD_RESOLUTION_320x240_NTSCI_ANTI		(NJD_RESOLUTION_320x240_NTSCI	 |NJD_DSP_ANTI)
#define	NJD_RESOLUTION_640x240_NTSCNI_ANTI		(NJD_RESOLUTION_640x240_NTSCNI	 |NJD_DSP_ANTI)
#define	NJD_RESOLUTION_640x240_NTSCI_ANTI		(NJD_RESOLUTION_640x240_NTSCI	 |NJD_DSP_ANTI)
#define	NJD_RESOLUTION_320x480_NTSCNI_FF_ANTI 	(NJD_RESOLUTION_320x480_NTSCNI_FF|NJD_DSP_ANTI)
#define	NJD_RESOLUTION_320x480_NTSCNI_ANTI		(NJD_RESOLUTION_320x480_NTSCNI	 |NJD_DSP_ANTI)
#define	NJD_RESOLUTION_320x480_NTSCI_ANTI		(NJD_RESOLUTION_320x480_NTSCI	 |NJD_DSP_ANTI)
#define	NJD_RESOLUTION_640x480_NTSCNI_FF_ANTI 	(NJD_RESOLUTION_640x480_NTSCNI_FF|NJD_DSP_ANTI)
#define NJD_RESOLUTION_640x480_NTSCNI_ANTI	 	(NJD_RESOLUTION_640x480_NTSCNI	 |NJD_DSP_ANTI)
#define	NJD_RESOLUTION_640x480_NTSCI_ANTI		(NJD_RESOLUTION_640x480_NTSCI	 |NJD_DSP_ANTI)
#define	NJD_RESOLUTION_320x240_PALNI_ANTI		(NJD_RESOLUTION_320x240_PALNI	 |NJD_DSP_ANTI)
#define	NJD_RESOLUTION_320x240_PALI_ANTI		(NJD_RESOLUTION_320x240_PALI	 |NJD_DSP_ANTI)
#define	NJD_RESOLUTION_640x240_PALNI_ANTI		(NJD_RESOLUTION_640x240_PALNI	 |NJD_DSP_ANTI)
#define	NJD_RESOLUTION_640x240_PALI_ANTI		(NJD_RESOLUTION_640x240_PALI	 |NJD_DSP_ANTI)
#define	NJD_RESOLUTION_320x480_PALNI_FF_ANTI	(NJD_RESOLUTION_320x480_PALNI_FF |NJD_DSP_ANTI)
#define	NJD_RESOLUTION_320x480_PALNI_ANTI		(NJD_RESOLUTION_320x480_PALNI	 |NJD_DSP_ANTI)
#define	NJD_RESOLUTION_320x480_PALI_ANTI		(NJD_RESOLUTION_320x480_PALI	 |NJD_DSP_ANTI)
#define	NJD_RESOLUTION_640x480_PALNI_FF_ANTI	(NJD_RESOLUTION_640x480_PALNI_FF |NJD_DSP_ANTI)
#define	NJD_RESOLUTION_640x480_PALNI_ANTI		(NJD_RESOLUTION_640x480_PALNI	 |NJD_DSP_ANTI)
#define	NJD_RESOLUTION_640x480_PALI_ANTI		(NJD_RESOLUTION_640x480_PALI	 |NJD_DSP_ANTI)

#define NJD_RESOLUTION_320x240_VGA       	(NJD_DSP_VGA |NJD_DSP_NONINTER|NJD_DSP_320x240)
#define NJD_RESOLUTION_320x480_VGA       	(NJD_DSP_VGA |NJD_DSP_NONINTER|NJD_DSP_320x480)
#define NJD_RESOLUTION_640x240_VGA       	(NJD_DSP_VGA |NJD_DSP_NONINTER|NJD_DSP_640x240)
#define	NJD_RESOLUTION_640x480_VGA			(NJD_DSP_VGA|NJD_DSP_NONINTER|NJD_DSP_640x480)
#define NJD_RESOLUTION_320x240_VGA_ANTI       	(NJD_RESOLUTION_320x240_VGA		 |NJD_DSP_ANTI)
#define NJD_RESOLUTION_320x480_VGA_ANTI       	(NJD_RESOLUTION_320x480_VGA		 |NJD_DSP_ANTI)
#define NJD_RESOLUTION_640x240_VGA_ANTI       	(NJD_RESOLUTION_640x240_VGA		 |NJD_DSP_ANTI)
#define NJD_RESOLUTION_640x480_VGA_ANTI       	(NJD_RESOLUTION_640x480_VGA		 |NJD_DSP_ANTI)

#define NJD_RESOLUTION_640x248_PALNI	(NJD_DSP_PAL |NJD_DSP_NONINTER |NJD_DSP_640x240_EXT|NJD_PALEXT_HEIGHT_RATIO_1_033)
#define NJD_RESOLUTION_640x256_PALNI	(NJD_DSP_PAL |NJD_DSP_NONINTER |NJD_DSP_640x240_EXT|NJD_PALEXT_HEIGHT_RATIO_1_066)
#define NJD_RESOLUTION_640x264_PALNI	(NJD_DSP_PAL |NJD_DSP_NONINTER |NJD_DSP_640x240_EXT|NJD_PALEXT_HEIGHT_RATIO_1_100)
#define NJD_RESOLUTION_640x272_PALNI	(NJD_DSP_PAL |NJD_DSP_NONINTER |NJD_DSP_640x240_EXT|NJD_PALEXT_HEIGHT_RATIO_1_133)
#define NJD_RESOLUTION_640x280_PALNI	(NJD_DSP_PAL |NJD_DSP_NONINTER |NJD_DSP_640x240_EXT|NJD_PALEXT_HEIGHT_RATIO_1_166)

#define NJD_RESOLUTION_640x496_PALNI	(NJD_DSP_PAL |NJD_DSP_PSINTER |NJD_DSP_640x480_EXT|NJD_PALEXT_HEIGHT_RATIO_1_033)
#define NJD_RESOLUTION_640x512_PALNI	(NJD_DSP_PAL |NJD_DSP_PSINTER |NJD_DSP_640x480_EXT|NJD_PALEXT_HEIGHT_RATIO_1_066)
#define NJD_RESOLUTION_640x528_PALNI	(NJD_DSP_PAL |NJD_DSP_PSINTER |NJD_DSP_640x480_EXT|NJD_PALEXT_HEIGHT_RATIO_1_100)
#define NJD_RESOLUTION_640x544_PALNI	(NJD_DSP_PAL |NJD_DSP_PSINTER |NJD_DSP_640x480_EXT|NJD_PALEXT_HEIGHT_RATIO_1_133)
#define NJD_RESOLUTION_640x560_PALNI	(NJD_DSP_PAL |NJD_DSP_PSINTER |NJD_DSP_640x480_EXT|NJD_PALEXT_HEIGHT_RATIO_1_166)

#define NJD_RESOLUTION_640x496_PALI	(NJD_DSP_PAL |NJD_DSP_INTER |NJD_DSP_640x480_EXT|NJD_PALEXT_HEIGHT_RATIO_1_033)
#define NJD_RESOLUTION_640x512_PALI	(NJD_DSP_PAL |NJD_DSP_INTER |NJD_DSP_640x480_EXT|NJD_PALEXT_HEIGHT_RATIO_1_066)
#define NJD_RESOLUTION_640x528_PALI	(NJD_DSP_PAL |NJD_DSP_INTER |NJD_DSP_640x480_EXT|NJD_PALEXT_HEIGHT_RATIO_1_100)
#define NJD_RESOLUTION_640x544_PALI	(NJD_DSP_PAL |NJD_DSP_INTER |NJD_DSP_640x480_EXT|NJD_PALEXT_HEIGHT_RATIO_1_133)
#define NJD_RESOLUTION_640x560_PALI	(NJD_DSP_PAL |NJD_DSP_INTER |NJD_DSP_640x480_EXT|NJD_PALEXT_HEIGHT_RATIO_1_166)

#define NJD_RESOLUTION_640x248_PALNI_ANTI	(NJD_RESOLUTION_640x248_PALNI|NJD_DSP_ANTI)
#define NJD_RESOLUTION_640x256_PALNI_ANTI	(NJD_RESOLUTION_640x256_PALNI|NJD_DSP_ANTI)
#define NJD_RESOLUTION_640x264_PALNI_ANTI	(NJD_RESOLUTION_640x264_PALNI|NJD_DSP_ANTI)
#define NJD_RESOLUTION_640x272_PALNI_ANTI	(NJD_RESOLUTION_640x272_PALNI|NJD_DSP_ANTI)
#define NJD_RESOLUTION_640x280_PALNI_ANTI	(NJD_RESOLUTION_640x280_PALNI|NJD_DSP_ANTI)

#define NJD_RESOLUTION_640x496_PALNI_ANTI	(NJD_RESOLUTION_640x496_PALNI|NJD_DSP_ANTI)
#define NJD_RESOLUTION_640x512_PALNI_ANTI	(NJD_RESOLUTION_640x512_PALNI|NJD_DSP_ANTI)
#define NJD_RESOLUTION_640x528_PALNI_ANTI	(NJD_RESOLUTION_640x528_PALNI|NJD_DSP_ANTI)
#define NJD_RESOLUTION_640x544_PALNI_ANTI	(NJD_RESOLUTION_640x544_PALNI|NJD_DSP_ANTI)
#define NJD_RESOLUTION_640x560_PALNI_ANTI	(NJD_RESOLUTION_640x560_PALNI|NJD_DSP_ANTI)

#define NJD_RESOLUTION_640x496_PALI_ANTI	(NJD_RESOLUTION_640x496_PALI|NJD_DSP_ANTI)
#define NJD_RESOLUTION_640x512_PALI_ANTI	(NJD_RESOLUTION_640x512_PALI|NJD_DSP_ANTI)
#define NJD_RESOLUTION_640x528_PALI_ANTI	(NJD_RESOLUTION_640x528_PALI|NJD_DSP_ANTI)
#define NJD_RESOLUTION_640x544_PALI_ANTI	(NJD_RESOLUTION_640x544_PALI|NJD_DSP_ANTI)
#define NJD_RESOLUTION_640x560_PALI_ANTI	(NJD_RESOLUTION_640x560_PALI|NJD_DSP_ANTI)

#define	NJD_RESOLUTION_320x240_PAL60_NI		(NJD_RESOLUTION_320x240_NTSCNI|NJD_DSP_PAL60)
#define	NJD_RESOLUTION_320x240_PAL60_I		(NJD_RESOLUTION_320x240_NTSCI|NJD_DSP_PAL60)
#define	NJD_RESOLUTION_640x240_PAL60_NI		(NJD_RESOLUTION_640x240_NTSCNI|NJD_DSP_PAL60)
#define	NJD_RESOLUTION_640x240_PAL60_I		(NJD_RESOLUTION_640x240_NTSCI|NJD_DSP_PAL60)
#define	NJD_RESOLUTION_320x480_PAL60_I_FF 	(NJD_RESOLUTION_320x480_NTSCNI_FF|NJD_DSP_PAL60)
#define	NJD_RESOLUTION_320x480_PAL60_NI		(NJD_RESOLUTION_320x480_NTSCNI|NJD_DSP_PAL60)
#define	NJD_RESOLUTION_320x480_PAL60_I		(NJD_RESOLUTION_320x480_NTSCI|NJD_DSP_PAL60)
#define	NJD_RESOLUTION_640x480_PAL60_NI_FF 	(NJD_RESOLUTION_640x480_NTSCNI_FF|NJD_DSP_PAL60)
#define NJD_RESOLUTION_640x480_PAL60_NI	 	(NJD_RESOLUTION_640x480_NTSCNI|NJD_DSP_PAL60)
#define	NJD_RESOLUTION_640x480_PAL60_I		(NJD_RESOLUTION_640x480_NTSCI|NJD_DSP_PAL60)

#define	NJD_RESOLUTION_320x240_PAL60_NI_ANTI		(NJD_RESOLUTION_320x240_NTSCNI_ANTI|NJD_DSP_PAL60)
#define	NJD_RESOLUTION_320x240_PAL60_I_ANTI		(NJD_RESOLUTION_320x240_NTSCI_ANTI|NJD_DSP_PAL60)
#define	NJD_RESOLUTION_640x240_PAL60_NI_ANTI		(NJD_RESOLUTION_640x240_NTSCNI_ANTI|NJD_DSP_PAL60)
#define	NJD_RESOLUTION_640x240_PAL60_I_ANTI		(NJD_RESOLUTION_640x240_NTSCI_ANTI|NJD_DSP_PAL60)
#define	NJD_RESOLUTION_320x480_PAL60_NI_FF_ANTI 	(NJD_RESOLUTION_320x480_NTSCNI_FF_ANTI|NJD_DSP_PAL60)
#define	NJD_RESOLUTION_320x480_PAL60_NI_ANTI		(NJD_RESOLUTION_320x480_NTSCNI_ANTI|NJD_DSP_PAL60)
#define	NJD_RESOLUTION_320x480_PAL60_I_ANTI		(NJD_RESOLUTION_320x480_NTSCI_ANTI|NJD_DSP_PAL60)
#define	NJD_RESOLUTION_640x480_PAL60_NI_FF_ANTI 	(NJD_RESOLUTION_640x480_NTSCNI_FF_ANTI|NJD_DSP_PAL60)
#define NJD_RESOLUTION_640x480_PAL60_NI_ANTI	 	(NJD_RESOLUTION_640x480_NTSCNI_ANTI|NJD_DSP_PAL60)
#define	NJD_RESOLUTION_640x480_PAL60_I_ANTI		(NJD_RESOLUTION_640x480_NTSCI_ANTI|NJD_DSP_PAL60)

#define	NJD_RESOLUTION_320x240_AUTO_NI		(NJD_DSP_AUTO|NJD_DSP_NONINTER|NJD_DSP_320x240)
#define	NJD_RESOLUTION_320x240_AUTO_I		(NJD_DSP_AUTO|NJD_DSP_INTER   |NJD_DSP_320x240)
#define	NJD_RESOLUTION_640x240_AUTO_NI		(NJD_DSP_AUTO|NJD_DSP_NONINTER|NJD_DSP_640x240)
#define	NJD_RESOLUTION_640x240_AUTO_I		(NJD_DSP_AUTO|NJD_DSP_INTER   |NJD_DSP_640x240)
#define	NJD_RESOLUTION_320x480_AUTO_NI_FF 	(NJD_DSP_AUTO|NJD_DSP_NONINTER|NJD_DSP_320x480)
#define	NJD_RESOLUTION_320x480_AUTO_NI		(NJD_DSP_AUTO|NJD_DSP_PSINTER |NJD_DSP_320x480)
#define	NJD_RESOLUTION_320x480_AUTO_I		(NJD_DSP_AUTO|NJD_DSP_INTER   |NJD_DSP_320x480)
#define	NJD_RESOLUTION_640x480_AUTO_NI_FF 	(NJD_DSP_AUTO|NJD_DSP_NONINTER|NJD_DSP_640x480)
#define NJD_RESOLUTION_640x480_AUTO_NI	 	(NJD_DSP_AUTO|NJD_DSP_PSINTER |NJD_DSP_640x480)
#define	NJD_RESOLUTION_640x480_AUTO_I		(NJD_DSP_AUTO|NJD_DSP_INTER   |NJD_DSP_640x480)

#define NJD_RESOLUTION_640x248_AUTO_NI	(NJD_DSP_AUTO |NJD_DSP_NONINTER |NJD_DSP_640x240_EXT|NJD_PALEXT_HEIGHT_RATIO_1_033)
#define NJD_RESOLUTION_640x256_AUTO_NI	(NJD_DSP_AUTO |NJD_DSP_NONINTER |NJD_DSP_640x240_EXT|NJD_PALEXT_HEIGHT_RATIO_1_066)
#define NJD_RESOLUTION_640x264_AUTO_NI	(NJD_DSP_AUTO |NJD_DSP_NONINTER |NJD_DSP_640x240_EXT|NJD_PALEXT_HEIGHT_RATIO_1_100)
#define NJD_RESOLUTION_640x272_AUTO_NI	(NJD_DSP_AUTO |NJD_DSP_NONINTER |NJD_DSP_640x240_EXT|NJD_PALEXT_HEIGHT_RATIO_1_133)
#define NJD_RESOLUTION_640x280_AUTO_NI	(NJD_DSP_AUTO |NJD_DSP_NONINTER |NJD_DSP_640x240_EXT|NJD_PALEXT_HEIGHT_RATIO_1_166)

#define NJD_RESOLUTION_640x496_AUTO_NI	(NJD_DSP_AUTO |NJD_DSP_PSINTER |NJD_DSP_640x480_EXT|NJD_PALEXT_HEIGHT_RATIO_1_033)
#define NJD_RESOLUTION_640x512_AUTO_NI	(NJD_DSP_AUTO |NJD_DSP_PSINTER |NJD_DSP_640x480_EXT|NJD_PALEXT_HEIGHT_RATIO_1_066)
#define NJD_RESOLUTION_640x528_AUTO_NI	(NJD_DSP_AUTO |NJD_DSP_PSINTER |NJD_DSP_640x480_EXT|NJD_PALEXT_HEIGHT_RATIO_1_100)
#define NJD_RESOLUTION_640x544_AUTO_NI	(NJD_DSP_AUTO |NJD_DSP_PSINTER |NJD_DSP_640x480_EXT|NJD_PALEXT_HEIGHT_RATIO_1_133)
#define NJD_RESOLUTION_640x560_AUTO_NI	(NJD_DSP_AUTO |NJD_DSP_PSINTER |NJD_DSP_640x480_EXT|NJD_PALEXT_HEIGHT_RATIO_1_166)

#define NJD_RESOLUTION_640x496_AUTO_I	(NJD_DSP_AUTO |NJD_DSP_INTER |NJD_DSP_640x480_EXT|NJD_PALEXT_HEIGHT_RATIO_1_033)
#define NJD_RESOLUTION_640x512_AUTO_I	(NJD_DSP_AUTO |NJD_DSP_INTER |NJD_DSP_640x480_EXT|NJD_PALEXT_HEIGHT_RATIO_1_066)
#define NJD_RESOLUTION_640x528_AUTO_I	(NJD_DSP_AUTO |NJD_DSP_INTER |NJD_DSP_640x480_EXT|NJD_PALEXT_HEIGHT_RATIO_1_100)
#define NJD_RESOLUTION_640x544_AUTO_I	(NJD_DSP_AUTO |NJD_DSP_INTER |NJD_DSP_640x480_EXT|NJD_PALEXT_HEIGHT_RATIO_1_133)
#define NJD_RESOLUTION_640x560_AUTO_I	(NJD_DSP_AUTO |NJD_DSP_INTER |NJD_DSP_640x480_EXT|NJD_PALEXT_HEIGHT_RATIO_1_166)

#define	NJD_RESOLUTION_320x240_AUTO_NI_ANTI		(NJD_DSP_AUTO|NJD_RESOLUTION_320x240_AUTO_NI	|NJD_DSP_ANTI)
#define	NJD_RESOLUTION_320x240_AUTO_I_ANTI		(NJD_DSP_AUTO|NJD_RESOLUTION_320x240_AUTO_I   	|NJD_DSP_ANTI)
#define	NJD_RESOLUTION_640x240_AUTO_NI_ANTI		(NJD_DSP_AUTO|NJD_RESOLUTION_640x240_AUTO_NI	|NJD_DSP_ANTI)
#define	NJD_RESOLUTION_640x240_AUTO_I_ANTI		(NJD_DSP_AUTO|NJD_RESOLUTION_640x240_AUTO_I   	|NJD_DSP_ANTI)
#define	NJD_RESOLUTION_320x480_AUTO_NI_FF_ANTI 	(NJD_DSP_AUTO|NJD_RESOLUTION_320x480_AUTO_NI_FF	|NJD_DSP_ANTI)
#define	NJD_RESOLUTION_320x480_AUTO_NI_ANTI		(NJD_DSP_AUTO|NJD_RESOLUTION_320x480_AUTO_NI 	|NJD_DSP_ANTI)
#define	NJD_RESOLUTION_320x480_AUTO_I_ANTI		(NJD_DSP_AUTO|NJD_RESOLUTION_320x480_AUTO_I   	|NJD_DSP_ANTI)
#define	NJD_RESOLUTION_640x480_AUTO_NI_FF_ANTI 	(NJD_DSP_AUTO|NJD_RESOLUTION_640x480_AUTO_NI_FF	|NJD_DSP_ANTI)
#define NJD_RESOLUTION_640x480_AUTO_NI_ANTI	 	(NJD_DSP_AUTO|NJD_RESOLUTION_640x480_AUTO_NI 	|NJD_DSP_ANTI)
#define	NJD_RESOLUTION_640x480_AUTO_I_ANTI		(NJD_DSP_AUTO|NJD_RESOLUTION_640x480_AUTO_I   	|NJD_DSP_ANTI)

#define NJD_RESOLUTION_640x248_AUTO_NI_ANTI	(NJD_RESOLUTION_640x248_AUTO_NI|NJD_DSP_ANTI)
#define NJD_RESOLUTION_640x256_AUTO_NI_ANTI	(NJD_RESOLUTION_640x256_AUTO_NI|NJD_DSP_ANTI)
#define NJD_RESOLUTION_640x264_AUTO_NI_ANTI	(NJD_RESOLUTION_640x264_AUTO_NI|NJD_DSP_ANTI)
#define NJD_RESOLUTION_640x272_AUTO_NI_ANTI	(NJD_RESOLUTION_640x272_AUTO_NI|NJD_DSP_ANTI)
#define NJD_RESOLUTION_640x280_AUTO_NI_ANTI	(NJD_RESOLUTION_640x280_AUTO_NI|NJD_DSP_ANTI)

#define NJD_RESOLUTION_640x496_AUTO_NI_ANTI	(NJD_RESOLUTION_640x496_AUTO_NI|NJD_DSP_ANTI)
#define NJD_RESOLUTION_640x512_AUTO_NI_ANTI	(NJD_RESOLUTION_640x512_AUTO_NI|NJD_DSP_ANTI)
#define NJD_RESOLUTION_640x528_AUTO_NI_ANTI	(NJD_RESOLUTION_640x528_AUTO_NI|NJD_DSP_ANTI)
#define NJD_RESOLUTION_640x544_AUTO_NI_ANTI	(NJD_RESOLUTION_640x544_AUTO_NI|NJD_DSP_ANTI)
#define NJD_RESOLUTION_640x560_AUTO_NI_ANTI	(NJD_RESOLUTION_640x560_AUTO_NI|NJD_DSP_ANTI)

#define NJD_RESOLUTION_640x496_AUTO_I_ANTI	(NJD_RESOLUTION_640x496_AUTO_I|NJD_DSP_ANTI)
#define NJD_RESOLUTION_640x512_AUTO_I_ANTI	(NJD_RESOLUTION_640x512_AUTO_I|NJD_DSP_ANTI)
#define NJD_RESOLUTION_640x528_AUTO_I_ANTI	(NJD_RESOLUTION_640x528_AUTO_I|NJD_DSP_ANTI)
#define NJD_RESOLUTION_640x544_AUTO_I_ANTI	(NJD_RESOLUTION_640x544_AUTO_I|NJD_DSP_ANTI)
#define NJD_RESOLUTION_640x560_AUTO_I_ANTI	(NJD_RESOLUTION_640x560_AUTO_I|NJD_DSP_ANTI)

#define NJD_VIDEO_MASK		(0x00000003)
#define NJD_DSP_INTER_MASK	(0x0000000C)
#define NJD_DSP_MASK		(0x00000FFF)
#define NJD_WIDTH_MASK 		(NJD_DSP_WIDTH_640)
#define NJD_HEIGHT_MASK		(NJD_DSP_HEIGHT_480)
#define NJD_PALEXT_MASK		(0x000E0000)
#define NJD_PALEXT_OFFSET	(17)

#define NJD_SYSTEMMETRICS_VERTEXBUFFER_INFO		(0x00000001)
#define NJD_SYSTEMMETRICS_RENDERPERFORM_INFO	(0x00000002)
#define NJD_SYSTEMMETRICS_TIMEOUT_INFO			(0x00000004)
#define NJD_SYSTEMMETRICS_FRAMEBUFFER_INFO		(0x00000008)
#define NJD_SYSTEMMETRICS_NATIVE_INFO			(0x00000010)

enum	{
	NJD_SYSTEM_CTX	= 0	,
	NJD_DEBUG_CTX		,
	NJD_NINDOWS_CTX		,
	NJD_USER0_CTX		,
	NJD_USER1_CTX		,
	NJD_USER2_CTX		,
	NJD_CONTEXT_MAX
};

typedef struct{
	Uint32	flags;

	/* Render Performance */
	Uint32	nLastRenderTime[8];
	Uint32	nLastDMATime[8];

	/* TimeOut Setting Data */
	Uint32	nCurrentTimeOutCount;
	Uint32	nDMATimeOutCount;
	Uint32	nRenderTimeOutCount;
	Uint32	nOBJOverflowCount;
	Uint32	nParamOverflowCount;

	/* Native Buffer Information */ 
	Uint32	nParamCurrent;
	Uint32	nOBJCurrent;
	Uint32	nOBJLimit;
	Uint32	nParamLimit;

	/* VertexBuffer Information */
	Uint32	VertexBufferSize[8][5];
	Uint32	MaxVertexSize[8][5];

	Uint32	Reserved[16];
} NJS_SYSTEMMETRICS;

typedef struct {
	Bool			bPreSort;
	Sint32			nSize[5];
} NJS_PASS_INFO;

typedef struct {
	void*			pVertexBuffer;
	Uint32			nVertexBufferSize;
	Uint32			nTextureMemorySize;
	Bool			bNoWaitVsync;
	Sint32			nNumOfMaxPass;
	Sint32			nNumOfTextures;
	Sint32			nNumOfSmallVQ;
	NJS_PASS_INFO	sPassInfo[8];
} NJS_VERTEXBUFFER_INFO;

typedef struct {
	Float	xad,yad;		/* aspect * dist	*/
	Float   cx,cy;			/* screen center	*/
	Float	ooxad,ooyad;	/* 1.0 / aspect * dist	*/
	Float   dist;			/* screen distance	*/
	Float	ax,ay;			/* aspect			*/
	Float	aspect;			/* aspect ay/ax		*/
	Float   w,h;			/* screen size		*/
} NJS_SCREEN;

typedef struct {
	Float		f_clip;			/* far clip			*/
	Float		n_clip;			/* near clip		*/
	Float		x1,x0,y1,y0;	/* screen clip		*/
	NJS_POINT2	d[2];			/* 2d clip			*/
} NJS_CLIP;



extern  NJS_SCREEN	_nj_screen_;
extern	NJS_CLIP	_nj_clip_;
extern 	Int			_nj_display_mode_;
extern	Int			_nj_frame_mode_;
extern	Int			_nj_waitvsync_count;

extern	Uint32		_nj_control_3d_flag_;

extern Int _nj_frame_size_w;
extern Int _nj_frame_size_h;

extern	void	*_nj_vertex_buf_;
//extern	Int	_nj_vertex_num_;

extern	Int	_nj_calc_vertex_;
extern	Int	_nj_calc_polygon_;
extern	Int	_nj_draw_polygon_;
extern	Uint32	_nj_constant_attr_and_;
extern	Uint32	_nj_constant_attr_or_;
extern	NJS_ARGB	_nj_constant_material_;
extern	Uint32	_nj_cnk_blend_mode_;

/************************/
/*	System				*/
/************************/
void	njChangeTextureMemorySize( Uint32 size );
Sint32	njInitSystem( Int mode, Int frame, Int count );
void	njInitDevice( void );
void	njWaitVBlank( void );
void*	njGetVertexBuffDesc( void );
void*	njGetSystemConfigStruct( void );
void	njInitVertexBufferEx( NJS_VERTEXBUFFER_INFO *pVBInfo );
Uint32	njCalcVertexBufferSize( NJS_VERTEXBUFFER_INFO *pVBInfo );
Sint32	njGetDirectTransferListType( Sint32 nPass );
Sint32	njStartCheck( void );
void	njStartDraw( void );
void	njContinue( void );
Sint32	njRender( void );
Sint32	njGetRenderStatus( Sint32 id );
void	njFrameBufferTextureTurboMode( Int mode );
void 	njSetEORCallback( NJS_INT_FUNC pFunc );
void 	njSetEOVCallback( NJS_INT_FUNC pFunc );
void	njSetHSyncCallback( NJS_INT_FUNC pFunc );
char	*njVersion( void );
void	njExitSystem( void );
void	njSetBackColor( Uint32 col1, Uint32 col2, Uint32 col3 );
void	njSetBackTexture( NJS_TEXTUREH_VTX *vtx );
void	njTextureFilterMode( Int mode );
void	njTextureClampMode( Int mode );
void	njTextureFlipMode( Int mode );
void	njMipmapAdjust( Int level );
void	njSuperSampleMode( Int mode );
void	njPolygonCullingSize( Float size );
void	njPolygonCullingMode( Int mode );
void	njColorBlendingMode( Int target, Int mode );
void	njSpecularMode( Int mode );
void	njIgnoreTextureAlphaMode( Int mode );
void	njTextureShadingMode( Int mode );
void	njSetCheapShadowMode( Int mode );
void	njUserClipping( Int mode, NJS_POINT2 *p );
void	njGetSystemAttr( NJS_SYS_ATTR *attr );
void	njSetSystemAttr( NJS_SYS_ATTR *attr );
void	njStopDisplay( void );
void	njStartDisplay( void );
void	njColorClampMode( Int mode );
void	njSetColorClamp( Uint32 MaxARGB, Uint32 MinARGB );
void	njAdjustDisplay( Sint32 xadjust, Sint32 yadjust );
void	njSetPunchThroughThreshold( Int nThreshold );
void	njSetVirticalFilterMode( Int mode );
void	njSetBorderColor( Uint32 color );
void	njZBufferMode( Int mode );
void	njGetSystemMetrics( NJS_SYSTEMMETRICS *sysm );
void	njSetWaitVsyncCount( Int count );
Int		njGetDisplayMode( void );
Sint32	njSetHSyncLine( Int line );
void	njGetHSyncLine( Int *line );
void	njChangeDisplayDitherMode( Int mode );
void	njAccumlationBufferMode( Int SrcSelect, Int DstSelect );
void	njModifierMode( Int mode );
void	njSetYCoefficient( Sint32 nYCoeff0, Sint32 nYCoeff1 );
void	njSetYCoefficientEx( Float fFilterRate, Float fBrightness );

/************************/
/*	View				*/
/************************/
void	njSetScreen( NJS_SCREEN *s );
void	njSetScreenDist( Float dist );
void	njSetPerspective( Angle ang );
void	njSetScreenCenter( Float x, Float y );
void	njSetAspect( Float ax, Float ay );
void	njClip2D( NJS_POINT2 *v );
void	njClipZ( Float n, Float f );
int		njCalcScreen( NJS_POINT3 *p, Float *sx, Float *sy );

#endif
