/*==============================================================================
	Copyright (C) 2008 IT Access.,Co.Ltd. All Rights Reserved.
	
	This software is the confidential and proprietary information 
	of IT Access.,Co.Ltd.
	
	Note:
		 Interface SH-2A board + LCD board without OS.
	
	2010/04 T.Kou IT-Access

==============================================================================*/

#ifndef _INC_TARGET_TYPES_H
#define	_INC_TARGET_TYPES_H

/*==============================================================================
 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> INCLUDE. <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
==============================================================================*/
#include "GealTypes.h"
#include "GealRsxConfig.h"

/*==============================================================================
 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> CONFIGURATION. <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
==============================================================================*/

#define _PACK_		__attribute__ ((packed))

/*==============================================================================
 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> TYPE. <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
==============================================================================*/
/* Target device context. */

typedef struct _TARGET
{
//	hFrameBuffer	fb;
//	hMouseDevice	ms;
//	hKeyboardDevice	kb;
//	GE_UINT16		wMode;
	GE_UINT16		wX;
	GE_UINT16		wY;
	GE_UINT32		dwLineByte;
//	GE_UINT32		dwSize;
	GE_VOID*		pBits;
} TARGET;


/* RGB Triple structure. */
typedef struct
{
	GE_UINT8		b ;
	GE_UINT8		g ;
	GE_UINT8		r ;
} _PACK_ GE_RGBT ;

/* RGB Quadple structure. */
typedef struct 
{
	GE_UINT8		b;		
	GE_UINT8		g;			
	GE_UINT8		r;			
	GE_UINT8		a;			
} _PACK_ GE_RGBQ;		


/* Target color types */
#if   defined (TARGET_COLOR_RGB32)
	typedef GE_RGBQ			TARGET_COLOR;
#elif defined (TARGET_COLOR_RGB24)
	typedef GE_RGBT			TARGET_COLOR;
#elif defined (TARGET_COLOR_RGB16)
	typedef GE_UINT16		TARGET_COLOR;
#elif defined (TARGET_COLOR_RGB15)
	typedef GE_UINT16		TARGET_COLOR;
#elif defined (TARGET_COLOR_CLUT8)
	typedef GE_UINT8		TARGET_COLOR;
#elif defined (TARGET_COLOR_CLUT4)
	typedef GE_UINT8		TARGET_COLOR;
#elif defined (TARGET_COLOR_MONO)
	typedef GE_UINT8		TARGET_COLOR;
#else
	#error TARGET_COLOR_TYPE error
#endif

// Data order is AABBGGRR.
#define GE_SetColor(r, g, b)								\
						((((GE_COLOR)(b) & 0xFF)       ) |	\
						 (((GE_COLOR)(g) & 0xFF) << 8  ) |	\
						 (((GE_COLOR)(r) & 0xFF) << 16 ))

#define GE_SetColorA(r, g, b, a)							\
						((((GE_COLOR)(b) & 0xFF)       ) |	\
						 (((GE_COLOR)(g) & 0xFF) << 8  ) |	\
						 (((GE_COLOR)(r) & 0xFF) << 16 ) |	\
						 (((GE_COLOR)(a) & 0xFF) << 24 ))

#define GE_GetBValue(color)			((GE_UINT8)(((color)      ) & 0xFF))
#define GE_GetGValue(color)			((GE_UINT8)(((color) >> 8 ) & 0xFF))
#define GE_GetRValue(color)			((GE_UINT8)(((color) >> 16) & 0xFF))
#define GE_GetAValue(color)			((GE_UINT8)(((color) >> 24) & 0xFF))

#define GE_SetBValue(color, val)	(((color) & 0xFFFFFF00) | ((GE_COLOR)(val)      ))
#define GE_SetGValue(color, val)	(((color) & 0xFFFF00FF) | ((GE_COLOR)(val) << 8 ))
#define GE_SetRValue(color, val)	(((color) & 0xFF00FFFF) | ((GE_COLOR)(val) << 16))
#define GE_SetAValue(color, val)	(((color) & 0x00FFFFFF) | ((GE_COLOR)(val) << 24))

#endif		//	_INC_TARGET_TYPES_H
