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

📄 gpcdrv.c

📁 基于东南大学开发的SEP3203的ARM7中的所有驱动
💻 C
📖 第 1 页 / 共 2 页
字号:

	if (x2==x1)
	{//*write stright line*//
		if (y1<y2)
		{
			for (y=y1;y<=y2;y++)
				if( ( mask&0x8000 ) == 0x8000 )
		 		{	VRAM[y][x1]=~VRAM[y][x1];
			 		mask=( mask<<1 )|0x0001 ;
				}
				else
					mask=mask<<1;
		}						
		else 
		{	for (y=y2;y<=y1;y++)
				if( ( mask&0x8000 ) == 0x8000 )
		 		{	VRAM[y][x1]=~VRAM[y][x1];
		 			mask=( mask<<1 )|0x0001 ;
				}
			else
				mask=mask<<1;
		}
	}			
			
	else if (y2==y1)
	{//*write horizental line*//
		if (x1<x2)
		{
			for (x=x1;x<=x2;x++)
				if( ( mask&0x8000 ) == 0x8000 )
		 		{	VRAM[y1][x]=~VRAM[y1][x];
		 			mask=( mask<<1 )|0x0001 ;
				}
				else
					mask=mask<<1;
		}						
		else 
		{
			for (x=x2;x<=x1;x++)
				if( ( mask&0x8000 ) == 0x8000 )
		 		{	VRAM[y1][x]=~VRAM[y1][x];
		 			mask=( mask<<1 )|0x0001 ;
				}
				else
					mask=mask<<1;
		}
	}										
	
	else
	{// * start point definition*//
		if (x1<x2)
		{	x0=x1;
			y0=y1;
			x1=x2;
			y1=y2;
		}
		else
		{	x0=x2;
			y0=y2;
		}
	
		dx=x1-x0;
		if (y0<y1)
		{
			dy=y1-y0;
		    if (dy<dx)
		    {	d=-(2*dy-dx);		/*初始化判别式d*/
		    	incrE=-2*dy;		/*取像素E时判别式的增量*/
		    	incrNE=-2*(dy-dx);	/*取像素NE时判别式的增量*/
		    	x=x0,y=y0;
		    	while (x<=x1)
				{ 
					if( ( mask&0x8000 ) == 0x8000 )
		 			{
						VRAM[y][x]=~VRAM[y][x];
		 				mask=( mask<<1 )|0x0001 ;
					}
					else
						mask=mask<<1;
					if (d>=0)	/*取像素E*/
					{
						d+=incrE;
						x++;
					}
					else	/*取像素NE*/
					{
						d+=incrNE;
						x++;
						y++;
					}
				}
		    }			
		    else 
		    {	d=-(2*dx-dy);		/*初始化判别式d*/
		    	incrE=-2*dx;		/*取像素E时判别式的增量*/
		    	incrNE=-2*(dx-dy);	/*取像素NE时判别式的增量*/
		    	x=x0,y=y0;
		    	while (y<=y1)
		    	{	if( ( mask&0x8000 ) == 0x8000 )
		 			{	VRAM[y][x]=~VRAM[y][x];
		 				mask=( mask<<1 )|0x0001 ;
					}
					else
						mask=mask<<1;
					if (d>=0)	/*取像素E*/
					{	d+=incrE;
						y++;
					}
					else	/*取像素NE*/
					{	d+=incrNE;
						y++;
						x++;
					}
				}
		    }				
		}		
		else 
		{	dy=y0-y1;
			if (dy<dx)
			{	d=-(2*dy-dx);		/*初始化判别式d*/
		    	incrE=-2*dy;		/*取像素E时判别式的增量*/
		    	incrNE=-2*(dy-dx);	/*取像素NE时判别式的增量*/
		    	x=x0,y=y0;
		    	while (x<=x1)
		    	{	if( ( mask&0x8000 ) == 0x8000 )
		 			{	VRAM[y][x]=~VRAM[y][x];
		 				mask=( mask<<1 )|0x0001 ;
					}
					else
						mask=mask<<1;
					if (d>=0)	/*取像素E*/
					{	d+=incrE;
						x++;
					}
					else	/*取像素NE*/
					{	d+=incrNE;
						x++;
						y--;
					}
			 	}
			}	
			else 
		    {	d=-(2*dx-dy);		/*初始化判别式d*/
		    	incrE=-2*dx;		/*取像素E时判别式的增量*/
		    	incrNE=-2*(dx-dy);	/*取像素NE时判别式的增量*/
		    	x=x0,y=y0;
		    	while (y>=y1)
		    	{	if( ( mask&0x8000 ) == 0x8000 )
		 			{	VRAM[y][x]=~VRAM[y][x];
		 				mask=( mask<<1 )|0x0001 ;
					}
					else
						mask=mask<<1;
					if (d>=0)	/*取像素E*/
					{	d+=incrE;
						y--;
					}
					else	/*取像素NE*/
					{	d+=incrNE;
						y--;
						x++;
					}
				}
		    }				
		}		 
	}
	
	
	//return GPC_ERR_OK;	
}

//------------------------------------------------------------------------------
// Function name  : seSetMonoImageLine
// Description    : set mono line of a image in buffer onto screen
// No return value
// Argument       : PPHYIMAGEINFO ppii
//                      S16 ppii->x
//                      S16 ppii->y
//                      S16 ppii->width
//                      U8* ppii->buffer
//                      U8  ppii->method
//                      U16 ppii->ColorIndex
//                      U16 ppii->BkColorIndex
// Remarks        : before the line being put, it should be converted to
//                  hardware dependent format. In this driver, a 256 color one.
//                  Generally, this function is always used to implement font
//                  and text function.
// So also        : 
//------------------------------------------------------------------------------
void seSetMonoImageLine( PPHYIMAGEINFO ppii )
{
    U8 TgtLine[160];// the maximum size of a line is width of the screen.
    S16 i, sByte, sBit;
    
    sByte   = 0;
    sBit    = 0x80;
    for(i=0;i<ppii->width;i++)
    {
        if( ppii->buffer[sByte] & sBit )
            TgtLine[i] = (U8)(ppii->ColorIndex);
        else
            TgtLine[i] = (U8)(ppii->BkColorIndex);
        sBit=sBit>>1;
        if( !sBit )
        {
            sBit = 0x80;
            sByte++;
        }
    }
    seSetImage( ppii->x, ppii->y, ppii->width, 1, TgtLine, ppii->method );
}
	
//------------------------------------------------------------------------------
// Function name  : seSetMonoImage
// Description    : 
// No return value
// Argument       : PPHYIMAGEINFO ppii
// Remarks        : 
// So also        : 
//------------------------------------------------------------------------------
void seSetMonoImage( PPHYIMAGEINFO ppii )
{
    S16 height;
    PHYIMAGEINFO pii;
    U8* pImageLineStart;
    S16 sBytesPerLine;

    // get a new physical image information header for put image line
    memcpy( &pii, ppii, sizeof( PHYIMAGEINFO ) );
    // pointer to data of first line
    pImageLineStart = ppii->buffer;
    // bytes per line
    sBytesPerLine = ( ppii->width + 7 ) / 8;

    height=ppii->height;
    while( height-- )
    {
        pii.buffer = pImageLineStart;
        pImageLineStart += sBytesPerLine;
        seSetMonoImageLine( &pii );
        pii.y++;
    }
}

//-------------------------------------------------------------------------
//    seSetImage()
//
//      This function put a device depent image onto the screen. The image buffer format is device relative.
//	The raster operation method defines how the color data for the source recangle is 
//	to be combined with the color data for the destination rectangle to achieve the final color
//  Parameters:
//      x,y: specified the left-up position where the image will be placed
//      width: specified the image width
//		height: specified the image height
//		buffer: the buffer contains the image data
//		method: raster operation method
//  Returns:
//      GPC_ERR_OK
//-------------------------------------------------------------------------
void seSetImage( S16 x, S16 y, S16 width, S16 height , U8 *buffer, U8 method )
{	
	int x1,y1,x2,y2;
	x1 = x;
	y1 = y;
	x2 = x1 + width;
	y2 = y1 + height;
	switch(method)
	{
		case NOT_PUT:
			for (y=y1;y<y2;y++)
				for (x=x1;x<x2;x++)
				{	VRAM[y][x]=!(*buffer);
					buffer++;
				}
			break;
		case XOR_PUT:
			for (y=y1;y<y2;y++)
				for (x=x1;x<x2;x++)
				{	VRAM[y][x]=(*buffer)^VRAM[y][x];
					buffer++;
				}
			break;
		case OR_PUT:
			for (y=y1;y<y2;y++)
				for (x=x1;x<x2;x++)
				{	VRAM[y][x]=(*buffer)|VRAM[y][x];
					buffer++;
				}
			break;
		case AND_PUT:
			for (y=y1;y<y2;y++)
				for (x=x1;x<x2;x++)
				{	VRAM[y][x]=(*buffer)&VRAM[y][x];
					buffer++;
				}
			break;
		default:// COPY_PUT
			for (y=y1;y<y2;y++)
				for (x=x1;x<x2;x++)
				{
					VRAM[y][x]=*buffer;
					buffer++;
				}
	}

  //return GPC_ERR_OK;
}

	
//-------------------------------------------------------------------------
//    seGetImage()
//
//  This function retrieves a block of screen data as an image into a buffer.
//	the image buffer format is device relative.
//
//  Parameters:
//      x,y: specified the left-up position where the image will be placed
//      width: specified the image width
//	height: specified the image height
//	buffer: the buffer contains the image data
//    Returns:
//      GPC_ERR_OK
//-------------------------------------------------------------------------
void seGetImage(S16 x, S16 y, S16 width , S16 height , U8 * buffer)
{
	int x1,y1,x2,y2;
	x1 = x;
	y1 = y;
	x2 = x1 + width;
	y2 = y1 + height;

	for (y=y1;y<y2;y++)
		for (x=x1;x<x2;x++)
		{	*buffer=VRAM[y][x];
			buffer++;
		}

  //  return GPC_ERR_OK;
}


//-------------------------------------------------------------------------
//    seRGBtoIndex()
//
//  This function maps the color value in RGB to a closest color index
//
//  Parameters:
//     rgb: a color value in RGB format to be converted
//     index: retrieves the index value corresponding to the rgb value
//    Returns:
//      GPC_ERR_OK
//-------------------------------------------------------------------------
void seRGBtoIndex(RGB rgb , U16 *index)
{
	unsigned char tempR;
	unsigned char tempG;
	unsigned char tempB;
	tempR = (unsigned char)( rgb >> 16 )& 0xe0;		/*Red color */
	tempG = (unsigned char)( rgb >> 11 )& 0x1c;		/*Green color*/
	tempB = (unsigned char)( rgb >> 6 ) & 0x03;		/*Blue color*/
	*index = tempR|tempG|tempB;

   //return GPC_ERR_OK;
}

⌨️ 快捷键说明

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