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

📄 gpcdrv.c

📁 一个操作系统源代码 用于嵌入式设备 在Vc++环境下仿真 成功移植到多款处理器上
💻 C
📖 第 1 页 / 共 4 页
字号:
//-------------------------------------------------------------------------
void seInvRec(GC *gc, SHORT x, SHORT y, SHORT width, SHORT height)
{
	PIXEL	*lineAd;
	CHAR	bitOffset;

//	TurnOffLCD();			//Julias 2002/5/7
	GetPixelPosition( &lineAd, &bitOffset, gc->vram, x, y );
	InvertBlock( lineAd, bitOffset, width, height, gc->vram );
}


//-------------------------------------------------------------------------
// Function name  :void seWrite2LCD()
// 
// Description    : write specified rectangular image area to lcd
//
// Parameters:
//     x1: Top left x-coordinate of the rectangular image area
//     y1: Top left y-coordinate of the rectangular image area
//	   x2: Bottom right x-coordinate of the rectangular image area
//	   y2: Bottom right y-coordinate of the rectangular image area
//     initAd: the initial address of the rectangular image area in the vram
//     Lwidth: the width of the logical display width
//     
// 
// No return value
//-------------------------------------------------------------------------
/*
void seWrite2LCD( VRAM *vram, BYTE bitOffset)
{
	*(unsigned long *)(LSSA) = (DWORD)(vram->ad);			//(LSSA)设置写入的内存区的首地址
	*(unsigned char *)(LVPW) = vram->widthInPixel>>3;		//(LVPW)
	*(unsigned char *)(LCKCON) = 0xc2;			//enable LCDC,每次读4个时钟周期的数据

	*(unsigned char *)(PFSEL) |=0x40;
	*(unsigned char *)(PFDIR) |=0x40;
	*(unsigned char *)(PFDATA) |= 0x40;	  			// 开中断
}
*/
/*
void seWrite2LCD( SHORT x1, SHORT x2, SHORT y1, SHORT y2, PWORD initAd, WORD Lwidth )
{
	SHORT i, j;
	WORD ColorIndex;
		
	//vDisableInterrupt();
	*(volatile unsigned char *)LCD_Command = 0x75;		// Page Address Set       
	*(volatile unsigned char *)LCD_Data = (unsigned char)y1;                                       
	*(volatile unsigned char *)LCD_Data = (unsigned char)y2;                                       

	*(volatile unsigned char *)LCD_Command = 0x15;		// Column Address Set
 	*(volatile unsigned char *)LCD_Data = (unsigned char)x1;		                          					
    *(volatile unsigned char *)LCD_Data = (unsigned char)x2;    
 	
 	*(volatile unsigned char *)LCD_Command = 0x5C;
 	for( j = y1; j <= y2; j++ )
 		for( i = x1; i <= x2; i++ )
		{
			ColorIndex = *(initAd + (j - y1) * Lwidth + (i - x1));
			*(volatile unsigned short *)LCD_Data = ColorIndex; 
		}
	*(volatile PCHAR)LCD_Command = 0x25;		//NOP command     
	//vEnableInterrupt();
}
*/
//-------------------------------------------------------------------------
//    seText()
//
//  Draw text in the x, y with text's length.
//  8bit per pixel
//
//  Parameters:
//      x       - Position X of start text.
//      y       - Position Y of start text.
//      text   - Point to text.
//      length - length of text.
//   No return value
//-------------------------------------------------------------------------
void seText( GC * gc, SHORT x, SHORT y, PBYTE text, SHORT length )
{
    SHORT i;
    DWORD ulFont2Start, font1size, font2size;
    PHYIMAGEINFO pii;
	PIXEL frtcolor, bkcolor;

	seRGBtoIndex( (DWORD)(GPC_YELLOW), &frtcolor );
	seRGBtoIndex( (DWORD)(gc->bk_color), &bkcolor );

    pii.method = GPC_REPLACE_STYLE;
	pii.mode = GPC_TRANSPARENT_STYLE;
    pii.ColorIndex = frtcolor;
    pii.BkColorIndex = bkcolor;

	if( gc->font->Font1 != 0 )
		font1size = gc->font->Font1Height * ( ( gc->font->Font1Width + 7 )>>3 );
	else
		font1size = 0;

	if( gc->font->Font1 != 0 )
		font2size = gc->font->Font2Height * ( ( gc->font->Font2Width + 7 )>>3 );
	else
		font2size = 0;

//	TurnOffLCD();			//Julias 2002/5/7
    for( i = 0; i < length ; i++ )
    {
        pii.x = x;
        pii.y = y;
        // Check Font Byte ( 1:1Byte, 2:2Byte )
        switch( gpcCheckFontByte( text + i ) )
        {
            case 1:
                // 2000.04.20 Add by Shin :: Check No Font
                if( font1size == 0 )
                    continue;
                pii.buffer = gc->font->Font1 + font1size * ( text[i] - ' ' );
                pii.width = gc->font->Font1Width;
                pii.height = gc->font->Font1Height;
                break;
            case 2:
                // 2000.04.20 Add by Shin :: Check No Font
                i++;
				if( font2size == 0 )
                    continue;
                // Count Font2 patten Start Point
				if( i >= length ) 
					continue;
				ulFont2Start = ( *( text + i - 1 )- 161 )*94 + ( *( text + i )- 161 );
                //if( ulFont2Start )
				//	continue;
				pii.buffer = gc->font->Font2 + ulFont2Start * font2size; 
                pii.width = gc->font->Font2Width;
                pii.height = gc->font->Font2Height;
                break;
            default:
                break;
        }

//2001.10.25
	   if ( (pii.x + pii.width) <= gc->width )
        	  seSetMonoImage( gc, &pii );
	   else
        	  break;
        	  
        x += pii.width;
    }
}

void sePutChar( GC *gc, PPHYIMAGEINFO ppii )
{
//	const BYTE mask[8] = { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 };
	WORD	mode, nByte, rByte, i, j, k, m;
	PBYTE	buffer;
	WORD	style;
	PIXEL	ColorIndex, BkColorIndex;// ColorIndex1, topx, topy, endx, endy;
	PIXEL	*lineAd, *nextLineAd, *nextPixelPos;
	CHAR	bitOffset, nextLineOffset, nextPixelOffset;
	
	
//	TurnOffLCD();			//Julias 2002/5/7
	GetPixelPosition( &lineAd, &bitOffset, gc->vram, ppii->x, ppii->y );
	ColorIndex = ppii->ColorIndex;
	BkColorIndex = ppii->BkColorIndex;
	mode = ppii->mode;
	buffer = ppii->buffer;
	style = ppii->method;
	
	nByte = ppii->width>>3;
	rByte = ppii->width&0x7;
	
	nextLineAd = lineAd;
	nextLineOffset = bitOffset;
	nextPixelPos = nextLineAd;
	nextPixelOffset = nextLineOffset;
	for( i = 0; i < ppii->height; i++)
	{
		m = 0;
		for( k = 0; k < nByte; k++ )
		{
			for( j = 0; j < 8; j++ )		
			{
				if( buffer[k] & mask[j] )
				{
					PixelOp( nextPixelPos, nextPixelOffset, ColorIndex, style );
    			}
				else
				{
					if( mode != GPC_TRANSPARENT_STYLE )
						PixelOp( nextPixelPos, nextPixelOffset, BkColorIndex, style );
				}
				GetNextPixelPosition( &nextPixelPos, &nextPixelOffset, nextPixelPos, nextPixelOffset );
    			m++;
    		}
    	}
		j =0;
    	for( j = 0; j < rByte; j++ )		
		{
			if( buffer[k] & mask[j] )
			{
				PixelOp( nextPixelPos, nextPixelOffset, ColorIndex, style );
    		}
			else
			{
				if( mode != GPC_TRANSPARENT_STYLE )
					PixelOp( nextPixelPos, nextPixelOffset, BkColorIndex, style );
			}
			GetNextPixelPosition( &nextPixelPos, &nextPixelOffset, nextPixelPos, nextPixelOffset );
    		m++;
    	}
    	buffer += nByte + ( j?1:0 );
		GetNextLine( &nextLineAd, &nextLineOffset, nextLineAd, nextLineOffset, gc->vram );
		nextPixelPos = nextLineAd;
		nextPixelOffset = nextLineOffset;
    }
    
//	topx = ppii->x;
//	topy = ppii->y;
//	endx = topx + ppii->width - 1;
//	endy = topy + ppii->height - 1;
//	if( gc == gSysTcbTbl[ gLcdOwnerTskId-1 ].gc )
//		WRITELCD( ppii->x, ppii->x + ppii->width - 1, ppii->y, ppii->y + ppii->height - 1 )	//WRITELCD( topx, endx, topy, endy )

    return;
}

void seDrawImage(GC *gc, SHORT x, SHORT y, SHORT width, SHORT height , VRAM *buffer, WORD style, WORD trColor )
{	
	SHORT i, j; //x1 ,y1 ,x2 ,y2 , topx, topy;
	PIXEL ColorIndex;
	WORD bkmode = HIWORD( gc->fillmode );
	PIXEL	*lineAd, *nextDesLineAd, *nextSrcLineAd, *nextDesPixelPos, *nextSrcPixelPos;
	CHAR	bitOffset, nextDesLineOffset, nextSrcLineOffset, nextDesPixelOffset, nextSrcPixelOffset;
	
//	x1 = x < ( x + width ) ? x : ( x + width );
//	x2 = x < ( x + width ) ? ( x + width ) : x;
//	y1 = y < ( y + height ) ? y : ( y + height );
//	y2 = y < ( y + height ) ? ( y + height ) : y;
//	IniAdd = gc->vram + y * gc->width + x;

//	TurnOffLCD();			//Julias 2002/5/7
	GetPixelPosition( &lineAd, &bitOffset, gc->vram, x, y );
	
   	nextDesLineAd = lineAd;
	nextDesLineOffset = bitOffset;
	nextSrcLineAd = buffer->ad;
	nextSrcLineOffset = 0;
	for( i = y; i < y + height; i++ )	//for( j = y1; j < y2; j++ )
	{
		nextSrcPixelPos = nextSrcLineAd;
		nextSrcPixelOffset = nextSrcLineOffset;
		nextDesPixelPos = nextDesLineAd;
		nextDesPixelOffset = nextDesLineOffset;
		for( j = 0; j < width; j++ )	//for( i = x; i < x + width; i++ )	//for( i = x1; i < x2; i++ )
		{	
			newGetPixel( &ColorIndex, nextSrcPixelPos, nextSrcPixelOffset );
			if( ColorIndex != trColor )
			{
				PixelOp( nextDesPixelPos, nextDesPixelOffset, ColorIndex, style );
			}
			else
			{
				PixelOp( nextDesPixelPos, nextDesPixelOffset, ColorIndex, bkmode );
			}
		  	GetNextPixelPosition( &nextSrcPixelPos, &nextSrcPixelOffset, nextSrcPixelPos, nextSrcPixelOffset );
		  	GetNextPixelPosition( &nextDesPixelPos, &nextDesPixelOffset, nextDesPixelPos, nextDesPixelOffset );
		}
		GetNextLine( &nextSrcLineAd, &nextSrcLineOffset, nextSrcLineAd, nextSrcLineOffset, buffer );
		GetNextLine( &nextDesLineAd, &nextDesLineOffset, nextDesLineAd, nextDesLineOffset, gc->vram );
	}

//	topx = x1;
//	topy = y1;
//	if( gc == gSysTcbTbl[ gLcdOwnerTskId-1 ].gc )
//		WRITELCD( x, x + width -1, y, y + height - 1 )
}




void seDrawCircle( GC *gc, SHORT xCenter, SHORT yCenter, SHORT radius, PIXEL ColorIndex, WORD style )
{
	SHORT x, y, d;
	PIXEL *pixelPos;
	CHAR bitOffset;
		
	x = xCenter;
	y = yCenter + radius;
	d = 3 - 2 * radius;

//	TurnOffLCD();			//Julias 2002/5/7
	GetPixelPosition( &pixelPos, &bitOffset, gc->vram, xCenter, (SHORT)(yCenter + radius) );
	PixelOp( pixelPos, bitOffset, ColorIndex, style );
	GetPixelPosition( &pixelPos, &bitOffset, gc->vram, xCenter, (SHORT)(yCenter - radius) );
	PixelOp( pixelPos, bitOffset, ColorIndex, style );
	GetPixelPosition( &pixelPos, &bitOffset, gc->vram, (SHORT)(xCenter - radius), yCenter );
	PixelOp( pixelPos, bitOffset, ColorIndex, style );
	GetPixelPosition( &pixelPos, &bitOffset, gc->vram, (SHORT)(xCenter + radius), yCenter );
	PixelOp( pixelPos, bitOffset, ColorIndex, style );

	do
	{
//		SETPIXEL((SHORT)x, (SHORT)y)	//seSetPixel( pGC, x, y, index, style );
//		SETPIXEL((SHORT)x, (SHORT)(yCenter - (y - yCenter)))		//seSetPixel( pGC, x, (SHORT)(yCenter - (y - yCenter)), index, style );
//		SETPIXEL((SHORT)(xCenter - (x - xCenter)), y)	//seSetPixel( pGC, (SHORT)(xCenter - (x - xCenter)), y, index, style );
//		SETPIXEL((SHORT)(xCenter - (x - xCenter)), (SHORT)(yCenter - (y - yCenter)))	//seSetPixel( pGC, (SHORT)(xCenter - (x - xCenter)), (SHORT)(yCenter - (y - yCenter)), index, style );

		GetPixelPosition( &pixelPos, &bitOffset, gc->vram, x, y );
		PixelOp( pixelPos, bitOffset, ColorIndex, style );
		GetPixelPosition( &pixelPos, &bitOffset, gc->vram, x, (SHORT)(yCenter - (y - yCenter)) );
		PixelOp( pixelPos, bitOffset, ColorIndex, style );
		GetPixelPosition( &pixelPos, &bitOffset, gc->vram, (SHORT)(xCenter - (x - xCenter)), y );
		PixelOp( pixelPos, bitOffset, ColorIndex, style );
		GetPixelPosition( &pixelPos, &bitOffset, gc->vram, (SHORT)(xCenter - (x - xCenter)), (SHORT)(yCenter - (y - yCenter)) );
		PixelOp( pixelPos, bitOffset, ColorIndex, style );

//		SETPIXEL((SHORT)(xCenter + (y - yCenter)), (SHORT)(yCenter + (x - xCenter)))	//seSetPixel( pGC, (SHORT)(xCenter + (y - yCenter)), (SHORT)(yCenter + (x - xCenter)), index, style );
//		SETPIXEL((SHORT)(xCenter + (y - yCenter)), (SHORT)(yCenter - (x - xCenter)))	//seSetPixel( pGC, (SHORT)(xCenter + (y - yCenter)), (SHORT)(yCenter - (x - xCenter)), index, style );   
//		SETPIXEL((SHORT)(xCenter - (y - yCenter)), (SHORT)(yCenter + (x - xCenter)))	//seSetPixel( pGC, (SHORT)(xCenter - (y - yCenter)), (SHORT)(yCenter + (x - xCenter)), index, style );
//		SETPIXEL((SHORT)(xCenter - (y - yCenter)), (SHORT)(yCenter - (x - xCenter)))	//seSetPixel( pGC, (SHORT)(xCenter - (y - yCenter)), (SHORT)(yCenter - (x - xCenter)), index, style );

		GetPixelPosition( &pixelPos, &bitOffset, gc->vram, (SHORT)(xCenter + (y - yCenter)), (SHORT)(yCenter + (x - xCenter )) );
		PixelOp( pixelPos, bitOffset, ColorIndex, style );
		GetPixelPosition( &pixelPos, &bitOffset, gc->vram, (SHORT)(xCenter + (y - yCenter)), (SHORT)(yCenter - (x - xCenter)) );
		PixelOp( pixelPos, bitOffset, ColorIndex, style );
		GetPixelPosition( &pixelPos, &bitOffset, gc->vram, (SHORT)(xCenter - (y - yCenter)), (SHORT)(yCenter + (x - xCenter )) );
		PixelOp( pixelPos, bitOffset, ColorIndex, style );
		GetPixelPosition( &pixelPos, &bitOffset, gc->vram, (SHORT)(xCenter - (y - yCenter)), (SHORT)(yCenter - (x - xCenter)) );
		PixelOp( pixelPos, bitOffset, ColorIndex, style );

		if ( d < 0 )
		{
			d = d + ((x - xCenter) << 2) + 6;
		}
		else
		{
			d = d + (((x - xCenter) - (y - yCenter)) << 2 ) + 10;
			y--;
		}

		x++;
	} 
	while ( (x - xCenter) < (y - yCenter) );

	GetPixelPosition( &pixelPos, &bitOffset, gc->vram, (SHORT)(xCenter + (y - yCenter)), (SHORT)(yCenter + (x - xCenter )) );
	PixelOp( pixelPos, bitOffset, ColorIndex, style );
	GetPixelPosition( &pixelPos, &bitOffset, gc->vram, (SHORT)(xCenter + (y - yCenter)), (SHORT)(yCenter - (x - xCenter)) );
	PixelOp( pixelPos, bitOffset, ColorIndex, style );
	GetPixelPosition( &pixelPos, &bitOffset, gc->vram, (SHORT)(xCenter - (y - yCenter)), (SHORT)(yCenter + (x - xCenter )) );
	PixelOp( pixelPos, bitOffset, ColorIndex, style );
	GetPixelPosition( &pixelPos, &bitOffset, gc->vram, (SHORT)(xCenter - (y - yCenter)), (SHORT)(yCenter - (x - xCenter)) );
	PixelOp( pixelPos, bitOffset, ColorIndex, style );


//	if( gc == gSysTcbTbl[ gLcdOwnerTskId-1 ].gc )
//		WRITELCD( xCenter - radius, xCenter + radius, yCenter - radius, y + radius )
}

⌨️ 快捷键说明

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