⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 display.c

📁 GSM手机设计软件代码
💻 C
📖 第 1 页 / 共 5 页
字号:
					{
						xOfs=0;
						while (xOfs < sx)
						{
							dspl_show_bitmap(px+xOfs, py+yOfs, bgdBmp, SHOWBITMAP_NORMAL );
							xOfs=xOfs+bgdBmp->width;
						}
						yOfs=yOfs+bgdBmp->height;
					}
					break;
		}
		dspl_SetWindow(x1,y1,x2,y2 );
	}

/*	switch (format)
	{
		case 0:
		default:
		break;
	}*/
	return DRV_OK;
}
static int win_x1, win_x2, win_y1, win_y2;

//Set-up area to be drawn in - limit window to the size of the screen
//Inputs in_x1/y1 - first column/row that can be drawn on
//		in_x2/y2 - last column/row
//NB:-	inputs are the same as used to clear/draw rectangles BUT
//		values stored in win_x2/y2 are +1 to ensure values are treated the same as scrX/Y
GLOBAL UBYTE dspl_SetWindow(USHORT   in_X1,
                         USHORT   in_Y1,
                         USHORT   in_X2,
                         USHORT   in_Y2)
{
int sizeX,sizeY;

	scrSize (&sizeX, &sizeY);
	if (in_X1>0)
		win_x1 = in_X1;
	else
		win_x1 = 0;
	if (in_Y1>0)
		win_y1 = in_Y1;
	else
		win_y1 = 0;
	if (in_X2<sizeX)
		win_x2 = in_X2+1;
	else
		win_x2 = sizeX;
	if (in_Y2<sizeY)
		win_y2 = in_Y2+1;
	else
		win_y2 = sizeY;
	return DRV_OK;

}

GLOBAL UBYTE dspl_ResetWindow( void )
{
	win_x1 = 0;
	win_y1 = 0;
	scrSize (&win_x2, &win_y2);

	return DRV_OK;

}

GLOBAL UBYTE dspl_GetWindow(USHORT* x1,USHORT* y1,USHORT* x2,USHORT* y2 )
{
	*x1= win_x1;
	*x2= win_x2;
	*y1= win_y1;
	*y2= win_y2;
	return DRV_OK;
	
}


/*******************************************************************
 *                                                                 *
 * PART II: Workaround for Graphical Displays                      *
 *                                                                 *
 *******************************************************************/

#ifdef DSAMPLE
/*GW 21/02/03 - There is an unused long word at the end of each line for the new drivers for some good reason I'm sure.*/
#ifdef DSAMPLE_COLOUR16
#define LCD_COL   (R2D_WIDTH+1)                      /* display size+32 bits    */
#else
#define LCD_COL   (R2D_WIDTH)                      /* display size             */
#endif
#define LCD_ROW 	(R2D_HEIGHT)
#define HEADER_INFO (3)
#define DISPLAY_SIZE (LCD_ROW*LCD_ROW_NUM_LWORDS)
static char scratch [100];      /* command buffer - does not support output of new display  */
#ifndef DSAMPLE_LITE
unsigned char bgdColourArray[LCD_COL*4];
#endif
#endif

#ifdef CSAMPLE
#define LCD_COL 84                      /* display size             */
#define LCD_ROW 48
#define LCD_COL_NUM_LWORDS ((LCD_ROW+31)/32) /* col size in longwords         */
#endif //CSAMPLE

#ifdef BSAMPLE
#define LCD_COL 84                     /* display size             */
#define LCD_COL_B ((LCD_COL+7)/8)       /* row size in byte         */
#define LCD_ROW 48
#define DISPL_DIV 4
#endif

/*
LCD_ROW_NUM_LWORDS - number of long words used to store a row of pixels
BYTEPERPIXEL - number of bytes used to store apixel on-screen
*/

#define CHECK_LIMITS /*Add bounds checks to code */
/*******************************************************************************
 $Macro:    	DSPL_SET_BITCOLOUR
 $Description:	This macro sets the colour of the bit at the provided long word address
 $Returns:		None.
 $Arguments:	x - x position of pixel (may be unused)
 				j - 32 bit offset within array of the pixel to be set
 				col - colour (in LCD format) of the pixel to be set
 				txt - debug text for traces - used if 'j' is bounds checked first.
*******************************************************************************/
/*******************************************************************************
 $Macro:    	DSPL_GET_LWORD
 $Description:	This macro
 $Returns:		The 32bit offset of the word containing the pixel
 $Arguments:	px - x position of pixel
 				py - y position of pixel
*******************************************************************************/
/*******************************************************************************
 $Macro:    	DSPL_GET_BYTE
 $Description:	This macro
 $Returns:		The 8bit offset of the word containing the pixel
 $Arguments:	px - x position of pixel
 				py - y position of pixel
*******************************************************************************/
/*******************************************************************************
 $Macro:    	DSPL_GET_BITCOLOUR
 $Description:	This macro
 $Returns:		The colour in LCD format of the RGB input
 $Arguments:	col - 32 bit RGB colour value
*******************************************************************************/
/*******************************************************************************
 $Macro:    	DSPL_SET_XYBIT_COLOUR
 $Description:	This macro
 $Returns:		None
 $Arguments:	x,y - posiiton of pixel to be set
 				col - 0 =clear bixel, anything else - set pixel
 				txt - trace for debug (if position is out-of-range)
*******************************************************************************/

#ifdef DSAMPLE_LITE
#define LCD_ROW_NUM_LWORDS ((LCD_COL+31)/32) /* col size in longwords         */
#define BYTEPERPIXEL (1/8 - unused)
#ifdef CHECK_LIMITS
#define DSPL_SET_BITCOLOUR(x,j,col,txt) \
{\
if (((j)>=0) && ((j)<DISPLAY_SIZE)) \
{\
	int m_px = 1 << (x & 0x1F);\
	if (col)  picture_col[j] = picture_col[j] | (m_px);\
	else    picture_col[j] = picture_col[j]  & (~m_px);\
}else {mmi_trace(txt);}\
}
#define DSPL_SET_XYBIT_COLOUR(x,y,col,txt) \
{\
	int m_px = 1 << (x & 0x1F);\
	int word = DSPL_GET_LWORD(x,y);\
	if (((word)>=0) && ((word)<DISPLAY_SIZE)) \
	{\
		if (col) word = word | m_px;\
		else word = word & (~m_px);\
	}\
}

#else
#define DSPL_SET_BITCOLOUR(x,j,col,txt) \
{\
	int m_px = 1 << (x & 0x1F);\
	if (col) picture_col[j] = picture_col[j] | (m_px);\
	else  picture_col[j] = picture_col[j]  & (~m_px);\
}
#define DSPL_SET_XYBIT_COLOUR(x,y,col,txt) \
{\
	int m_px = 1 << (x & 0x1F);\
	int word = DSPL_GET_LWORD(x,y);\
	if (col) word = word | m_px;\
	else word = word & (~m_px);\
}

#endif
#define DSPL_GET_LWORD(px,py) ((py)*LCD_ROW_NUM_LWORDS + ((px)/32))
#define DSPL_GET_BYTE(px,py) (((py)*4)*LCD_ROW_NUM_LWORDS + ((px)/8))
#define DSPL_GET_BITCOLOUR(col32) (not used!)
#define DSPL_GET_PIXELCOLOUR(col32) (not used!)
#endif //DSAMPLE_LITE

#ifdef DSAMPLE_COLOUR32
#define LCD_ROW_NUM_LWORDS (LCD_COL) /* col size in longwords         */
#define BYTEPERPIXEL 4
#ifdef CHECK_LIMITS
//safe version-includes trace for errors
#define DSPL_SET_BITCOLOUR(x,j,col,txt) {if (((j)>=0) && ((j)<DISPLAY_SIZE)) picture_col[j] = (col); else {mmi_trace(txt);}}
#else
#define DSPL_SET_BITCOLOUR(x,j,col,txt) {picture_col[j] = (col);}//faster version - no bounds check
#endif
#define DSPL_GET_LWORD(px,py) ((py)*LCD_ROW_NUM_LWORDS + (px))
#define DSPL_GET_BYTE(px,py) (((py)*4)*LCD_ROW_NUM_LWORDS + ((px)*4))
#define DSPL_GET_BITCOLOUR(col32) (~(((((col32) &0x00F80000)  >> 8) | (((col32) &0x0000FC00)	>> 5) | (((col32) &0x000000F8)	>> 3))))
#define DSPL_GET_PIXELCOLOUR(col32) (((((col32)<<8) &0x00F80000) | (((col32)<<5) &0x0000FC00) | (((col32)<<3) &0x000000F8)))
#endif

#ifdef DSAMPLE_COLOUR16
#define LCD_ROW_NUM_LWORDS ((LCD_COL+1)/2) /* col size in longwords         */
#define BYTEPERPIXEL 2
#ifdef PIXEL_0_IN_LSW
#ifdef CHECK_LIMITS
#define DSPL_SET_BITCOLOUR(x,j,col,txt) \
{\
if (((j)>=0) && ((j)<DISPLAY_SIZE)) \
{	if ((x)&0x01)\
		picture_col[j] = (picture_col[j] & 0xFFFF0000) | (col & 0x0000FFFF);\
	else\
		picture_col[j] = (picture_col[j] & 0x0000FFFF) | ((col <<16) & 0xFFFF0000);\
}else {mmi_trace(txt);}\
}
#else
#define DSPL_SET_BITCOLOUR(x,j,col,txt) \
{	if ((x)&0x01)\
		picture_col[j] = (picture_col[j] & 0xFFFF0000) | (col & 0x0000FFFF);\
	else\
		picture_col[j] = (picture_col[j] & 0x0000FFFF) | ((col <<16) & 0xFFFF0000);\
}
#endif
#else
#ifdef CHECK_LIMITS
#define DSPL_SET_BITCOLOUR(x,j,col,txt) \
{\
if (((j)>=0) && ((j)<DISPLAY_SIZE)) \
{	if ((x)&0x01)\
		picture_col[j] = (picture_col[j] & 0x0000FFFF) | ((col <<16) & 0xFFFF0000);\
	else\
		picture_col[j] = (picture_col[j] & 0xFFFF0000) | (col & 0x0000FFFF);\
}else {mmi_trace(txt);}\
}
#else
#define DSPL_SET_BITCOLOUR(x,j,col,txt) \
{	if ((x)&0x01)\
		picture_col[j] = (picture_col[j] & 0x0000FFFF) | ((col <<16) & 0xFFFF0000);\
	else\
		picture_col[j] = (picture_col[j] & 0xFFFF0000) | (col & 0x0000FFFF);\
}
#endif

#endif
//GW Added () round 'px' in definition below
#define DSPL_GET_LWORD(px,py) ((py)*LCD_ROW_NUM_LWORDS + ((px)/2))
#define DSPL_GET_BYTE(px,py) (((py)*4)*LCD_ROW_NUM_LWORDS + ((px)*2))
#define DSPL_GET_BITCOLOUR(col32) (~(((((col32) &0x00F80000)  >> 8) | (((col32) &0x0000FC00)	>> 5) | (((col32) &0x000000F8)	>> 3))))
#define DSPL_GET_PIXELCOLOUR(col32) (((((col32)<<8) &0x00F80000) | (((col32)<<5) &0x0000FC00) | (((col32)<<3) &0x000000F8)))
#endif

// 3 words of header info for 'pictures'
#ifdef DSAMPLE_LITE
static UINT32*  picture_bw    = NULL;//Pointer to data in display.
static UINT32*  pictureCopy_bw= NULL;//Pointer to data in display.
#endif//DSAMPLE_LITE

#ifdef DSAMPLE_COLOUR
static UINT32*  picture_col    = NULL;//Pointer to data in display.
static UINT32*  pictureCopy_col= NULL;//Pointer to data in display.
#endif

#ifdef CSAMPLE
#define HEADER_INFO (3)
#define DISPLAY_SIZE (LCD_COL*LCD_COL_NUM_LWORDS)
static UINT32 	display_bw [DISPLAY_SIZE+HEADER_INFO+10];
#ifdef USE_PLOT
static UINT32 	displayCopy_bw [DISPLAY_SIZE+HEADER_INFO+1];   /* copy to flag differences */
#endif
static UINT32*  picture_bw=NULL;//Pointer to data in display.
static UINT32*  pictureCopy_bw= NULL;//Pointer to data in display.
static char scratch [100];      /* command buffer - does not support output of new display  */
#endif //CSAMPLE

#ifdef BSAMPLE
static UBYTE displayScr [LCD_ROW][LCD_COL_B];   /* display buffer           */
static UBYTE displayCopy [LCD_ROW][LCD_COL_B];   /* copy to flag differences */
static char scratch [LCD_ROW*LCD_COL_B*2+100];      /* command buffer           */
#endif //BSAMPLE



static int mobEnabled = 1;              /* mobile simulation disabled      */

extern int mfwExtOut (char *cmd);       /* forward to ext. display  */
UBYTE lcd_output_ready  = TRUE;
UBYTE lcd_output_needed = FALSE;

#define scrHlen 18
static const char *scrHeader = "CONFIG MFWMOB SCR ";

static int scrX, scrY;                  /* display size             */
#if defined (WIN32)
static int mtkEnabled = 0;              /* MMI Toolkit              */
#endif

static int internal = 0;                /* internal use only        */

static int xIndex;                      /* data transfer index      */


static void scrPoint (int px, int py, int col);



/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6103)       MODULE  : DRV_DSPL                   |
| STATE   : code                ROUTINE : dspl_BitBlt                |
+--------------------------------------------------------------------+

  PURPOSE : This function is used to display a bitmap at the
            specified location using the raster operation provided.
            The bitmap format MUST be the same as the display and
            cannot contain any transparent colours
            If the bitmap does not cover the entire screen area, the rest of the
            area is drawn in the background colour provided.

*/
#ifdef DSAMPLE_COLOUR
void fastCopyBitmap(int startX, 	int startY, 	// start position of bitmap
						int bmpSx,	int bmpSy,		//size of bitmap
						char*	srcBitmap,
						int posX,   	int posY,   	// start of area to be copied into
						int sx,     	int sy,     	// size of area to be copied into
						U32 bgd_col,	int bmpFormat)
{
	char * image;
	int image_sx,image_x;
	int bgd_sx_left;
	int bgd_sx_right;
	int i,y;
	char *screen = (char*)picture_col;
	U32 bgdColour;

	if (posX < win_x1)
	{
		sx = sx - (win_x1-posX);
		posX = win_x1;
	}
	if (posX+sx >win_x2)
	{
		sx = win_x2 - posX;
	}
	if (posY < win_y1)
	{
		sy = sy - (win_y1-posY);
		posY = win_y1;
	}
	if (posY+sy >win_y2)
	{
		sy = win_y2 - posY;
	}
{
	char trc[80];
	sprintf(trc,"%d,%d,%d,%d,%d,%d",sx,sy,win_x1,win_y1,win_x2,win_y2);
	mmi_trace(trc);
}
#ifdef DSAMPLE_COLOUR32
	if (bmpFormat != BMP_FORMAT_16BIT_LCD_COLOUR)
#endif
#ifdef DSAMPLE_COLOUR16
	if (bmpFormat != BMP_FORMAT_16BIT_LCD_COMPRESSED_COLOUR)
#endif
	{
		int maxY;
		//Either display as much of the image as possible or as much as will fit.
		if (bmpSy > sy)
			maxY = sy;
		else
			maxY = bmpSy;
		dspl_Clear(posX,posY,(U16)(posX+sx-1),(U16)(posY+sy-1));
		dspl_BitBlt2((s

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -