/*---------------------------------------------------------------------------

    NVG header(Low level graphics library for Xbox)

    Copyright (C) 2002, 2003 SEGA Corporation Creative Center Graphics Sect.
    All Rights Reserved.

    Module  : NVG header
    File    : nvx.h
    Create  : 2002/04/02
    Modify  : 2002/06/27
    Modify  : 2004/06/16 DX8,DX9版統合
    Modify  : 2004/07/20 XENON用に修正
    Modify  : 2004/08/05 NND_PLATFORM_XENON追加
    Modify  : 2004/10/25 NVS_XVROBJ,NVS_XVRHEADER構造体にunionを追加
    Modify  : 2008/05/21 NND_PLATFORM_DXG20追加
    Version : 1.17.61
    Note    : 

---------------------------------------------------------------------------*/

#ifndef __NVX_H__
#define __NVX_H__

//-----------------------------------------------------------------------------------
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */

//-----------------------------------------------------------------------------------
/*--------------------------------------*/
/*      Texture Define                  */
/*--------------------------------------*/
#define NVD_GLOBAXINDEX_FIRST_VAL 		(0xFFFFFFFF)

#define NVD_GLOBALINDEX_TAG				'XIBG'
#define NVD_PVRTEXTURE_TAG				'TRVP'
#define NVD_PALETTE_TAG 				'LPVP'

/* Texture Attr */
/*
|31 -  21|20 - 17|16          |15 - 0|
 texattr reserved texcontinue  pvmentryId
*/
#define NVD_TEXATTR_TYPE_FILE			0
#define NVD_TEXATTR_TYPE_MEMORY			BIT_30
#define NVD_TEXATTR_TYPE_SURFACE		BIT_27
#define NVD_TEXATTR_TYPE_SYSAREA		BIT_26

#define NVD_TEXATTR_READAREA_MASK		(BIT_31)
#define NVD_TEXATTR_READTYPE_MASK		(BIT_30|BIT_28|BIT_27|BIT_26)

#define NVD_TEXATTR_PALGLOBALINDEX		BIT_24
#define NVD_TEXATTR_GLOBALINDEX			BIT_23

#define NVD_TEXATTR_REGISTRATION		BIT_21
#define NVD_TEXATTR_HEADER				BIT_20
#define NVD_TEXATTR_MASK				0xFFFE0000

#define NVD_TEXATTR_TEXCONTINUE			BIT_16


/*
	texaddr
	|31 - 26|25   -     0|
	  bank    globalIndex
*/
#define NVD_TEXBANK_SHIFT			(26)
#define NVD_TEXBANK_MASK			(0xFC000000)
#define NVD_TEXPALGLOBAL_MASK		(0x03FFFFFF)

// for XBOX(DirectX8)
#define NVD_TEXFMT_XBOX                 (0x7000)
#define NVD_TEXFMT_XBOX_MM              (0x7100)
#define NVD_TEXFMT_XBOX_LINEAR          (0x7200)
#define NVD_TEXFMT_XBOX_DXT1            (0x7300)
#define NVD_TEXFMT_XBOX_DXT1_MM         (0x7400)
#define NVD_TEXFMT_XBOX_DXT2            (0x7500)
#define NVD_TEXFMT_XBOX_DXT2_MM         (0x7600)
#define NVD_TEXFMT_XBOX_DXT3            (0x7700)
#define NVD_TEXFMT_XBOX_DXT3_MM         (0x7800)
#define NVD_TEXFMT_XBOX_DXT4            (0x7900)
#define NVD_TEXFMT_XBOX_DXT4_MM         (0x7A00)
#define NVD_TEXFMT_XBOX_DXT5            (0x7B00)
#define NVD_TEXFMT_XBOX_DXT5_MM         (0x7C00)

#define NVD_TEXFMT_XBOX_L8              (0x0000)
#define NVD_TEXFMT_XBOX_AL8             (0x0001)
#define NVD_TEXFMT_XBOX_ARGB1555        (0x0002)
#define NVD_TEXFMT_XBOX_XRGB1555        (0x0003)
#define NVD_TEXFMT_XBOX_ARGB4444        (0x0004)
#define NVD_TEXFMT_XBOX_RGB565          (0x0005)
#define NVD_TEXFMT_XBOX_ARGB8888        (0x0006)
#define NVD_TEXFMT_XBOX_XRGB8888        (0x0007)
#define NVD_TEXFMT_XBOX_XLVU8888        (0x0008)
#define NVD_TEXFMT_XBOX_P8              (0x0009)
#define NVD_TEXFMT_XBOX_A8              (0x000A)
#define NVD_TEXFMT_XBOX_AL88            (0x000B)
#define NVD_TEXFMT_XBOX_RGB655          (0x000C)
#define NVD_TEXFMT_XBOX_LVU655          (0x000D)
#define NVD_TEXFMT_XBOX_VU88            (0x000E)
#define NVD_TEXFMT_XBOX_GB88            (0x000F)
#define NVD_TEXFMT_XBOX_RB88            (0x0010)
#define NVD_TEXFMT_XBOX_L16             (0x0011)
#define NVD_TEXFMT_XBOX_V16U16          (0x0012)
#define NVD_TEXFMT_XBOX_RGBA5551        (0x0013)
#define NVD_TEXFMT_XBOX_RGBA4444        (0x0014)
#define NVD_TEXFMT_XBOX_ABGR8888        (0x0015)
#define NVD_TEXFMT_XBOX_QWVU8888        (0x0016)
#define NVD_TEXFMT_XBOX_BGRA8888        (0x0017)
#define NVD_TEXFMT_XBOX_RGBA8888        (0x0018)
#define NVD_TEXFMT_XBOX_YUY2            (0x0019)
#define NVD_TEXFMT_XBOX_UYVY            (0x001A)

#define NVD_TEXFMT_TYPE_MASK           	(0xFF00)


//-----------------------------------------------------------------------------------
// XBOXTEXTUREヘッダ(32バイト)
typedef struct {
	Uint32 Common;
	Uint32 Data;
	Uint32 Lock;
	Uint32 Format;
	Uint32 Size;
	Uint32 Dummy[2];
	Uint32 TexelBytes;
} NVS_XBOXTEXHEADER;

// XVRヘッダ(64バイト)
typedef struct {
	union{
		char   gbix_cnk[4];
		Uint32 gbix_cnk_long;
	};
	Uint32 gbix_next;
	Uint32 gbix;
	Uint32 gbix_pad;
	union{
		char   pvrt_cnk[4];
		Uint32 pvrt_cnk_long;
	};
	Uint32 pvrt_next;
	Uint32 attr;
	Uint16 width;
	Uint16 height;
#if ( NND_PLATFORM == NND_PLATFORM_XB || NND_PLATFORM == NND_PLATFORM_DX8)
	NVS_XBOXTEXHEADER xbTexHeader;
#elif ( NND_PLATFORM == NND_PLATFORM_DX9 || NND_PLATFORM == NND_PLATFORM_XENON || NND_PLATFORM == NND_PLATFORM_DXG20 )
	LPDIRECT3DTEXTURE9 xbTexHeader;
	Uint32 reserved[7];
#endif

} NVS_XVROBJ;

typedef struct {
	union{
		char   gbix_cnk[4];
		Uint32 gbix_cnk_long;
	};
	Uint32 gbix_next;
	Uint32 gbix;
	Uint32 gbix_pad;
	union{
		char   pvrt_cnk[4];
		Uint32 pvrt_cnk_long;
	};
	Uint32 pvrt_next;
	Uint32 attr;
	Uint16 width;
	Uint16 height;
	NVS_XBOXTEXHEADER xbTexHeader;
} NVS_XVRHEADER;

//-----------------------------------------------------------------------------------
#ifdef __cplusplus
}
#endif /* __cplusplus */

#endif //__NVX_H__

/* End of file */
