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

📄 gpctest.c

📁 一个操作系统源代码 用于嵌入式设备 在Vc++环境下仿真 成功移植到多款处理器上
💻 C
字号:
#include <ppsm.h>
#include <sys\gpc.h>
#include <resource\bitmap.h>
#include <sys\vramop.h>

//-------------------------------GpcTest-------------------------------
void SysGpcTest( DWORD pGC )
{
	int		i;
 	DWORD	hbmp;
 	BITMAP	*bitmap;
	char	texte[] = "Weep not for the past, fear not for the future";
	char	textc[] = "浮云游子意,落日故人情。挥手自兹去,萧萧班马鸣。";
//	unsigned short	Minute1, Second1, Minute2, Second2, times1, times2;
	PIXEL	*bm = GetBlock( 160, 240 );
/*	PPOINTS	pointPtrup[3], pointPtrdown[3];

	pointPtrup[0]->x = 80;
	pointPtrup[0]->y = 30;
	pointPtrup[1]->x = 12;
	pointPtrup[1]->x = 170;
	pointPtrup[2]->x = 148;
	pointPtrup[2]->y = 170;
	pointPtrdown[0]->x = 12;
	pointPtrdown[0]->y = 90;
	pointPtrdown[1]->x = 148;
	pointPtrdown[1]->y = 90;
	pointPtrdown[2]->x = 80;
	pointPtrdown[2]->y = 210;

*/

///////////////////////////////////////////////////////////////////////
/*	BMPHEADER	*info;
	BITMAP		*bmp;
	VRAM		*desData;	
	PIXEL		*dataAd, *LineAd;
	DWORD		j, k;
	CHAR		desOffset, LineOffset;
//	CHAR		num, r;
	PIXEL		palette[4] = { 0x00000000, 0x00555555, 0x00eeeeee, 0x00ffffff };//palette;
	
	bmp = (BITMAP *)SysLmalloc( sizeof( BITMAP ) );

	bmp->info.type = 0x4d42;
	bmp->info.width = 0x96;
	bmp->info.height = 0x3a;
	bmp->info.bitcount = 0x01;
	bmp->info.flag = 0x00;
	bmp->info.colorused = 0x02;
	bmp->info.offset = 0x10;
//	bmp->palette = seGetSysPalette( bmp->info.bitcount );
	bmp->palette = palette;

	desData = GetVRAM( bmp->info.width, bmp->info.height );
	bmp->data = desData;
	dataAd = desData->ad;
	LineAd = desData->ad;
	LineOffset = 0;
	desOffset = 0;

	for ( j = 0; j < bmp->info.height; j++ )
	{
		for ( k = 0; k < bmp->info.width; k += 32 )
		{
			if( k < bmp->info.width )
			{
				*dataAd = 0x0123;
				dataAd++;
				k += 4;
			}
			if( k < bmp->info.width )
			{
				*dataAd = 0x4567;
				dataAd++;
				k += 4;
			}
			if( k < bmp->info.width )
			{
				*dataAd = 0x89ab;
				dataAd++;
				k += 4;
			}
			if( k < bmp->info.width )
			{
				*dataAd = 0xcdef;
				dataAd++;
				k += 4;
			}
		}
	}

*/




//测试
	ClearScreen( pGC, GPC_WHITE );
//----------------------------------------------------画水平线----------------------------------------------------
	for ( i = 0; i < 60; i++ )
	{
		DrawHorz( pGC, GPC_BLACK, i, i, 160-2*i, GPC_SOLID_LINE, GPC_XOR_STYLE );
		DrawHorz( pGC, GPC_BLACK, i,( 60 + i ), 160-2*i, GPC_DASH_LINE, GPC_XOR_STYLE );
		DrawHorz( pGC, GPC_BLACK, i,( 120 + i ), 160-2*i, GPC_DOT_LINE, GPC_REPLACE_STYLE );
		DrawHorz( pGC, GPC_BLACK, i,( 180 + i ), 160-2*i, GPC_DASHDOT_LINE, GPC_REPLACE_STYLE );
	}
	for ( i = 60; i > 0; i-- )
	{
		DrawHorz( pGC, GPC_BLACK, i, i, 160-2*i, GPC_SOLID_LINE, GPC_XOR_STYLE );
		DrawHorz( pGC, GPC_BLACK, i,( 60 + i ), 160-2*i, GPC_DASH_LINE, GPC_XOR_STYLE );
		DrawHorz( pGC, GPC_BLACK, i,( 120 + i ), 160-2*i, GPC_DOT_LINE, GPC_REPLACE_STYLE );
		DrawHorz( pGC, GPC_BLACK, i,( 180 + i ), 160-2*i, GPC_DASHDOT_LINE, GPC_REPLACE_STYLE );
	}
	ClearScreen( pGC, GPC_WHITE );

//----------------------------------------------------画垂直线---------------------------------------------------
	for ( i = 0; i < 40; i++ )
	{
		DrawVert(pGC, GPC_BLACK, i, i, 240-2*i, GPC_SOLID_LINE, GPC_REPLACE_STYLE );
		DrawVert(pGC, GPC_BLACK, 40 + i, i, 240-2*i, GPC_DASH_LINE, GPC_REPLACE_STYLE );
		DrawVert(pGC, GPC_WHITE, 80 + i, i, 240-2*i, GPC_DOT_LINE, GPC_REPLACE_STYLE );
		DrawVert(pGC, GPC_BLACK, 120 + i, i, 240-2*i, GPC_DASHDOT_LINE, GPC_REPLACE_STYLE );
	}
	for ( i = 39; i > 0; i-- )
	{
		DrawVert(pGC, GPC_BLACK, i, 0, 240, GPC_SOLID_LINE, GPC_XOR_STYLE );
		DrawVert(pGC, GPC_WHITE, 40 + i, 0, 240, GPC_DASH_LINE, GPC_OR_STYLE );
		DrawVert(pGC, GPC_BLACK, 80 + i, 0, 240, GPC_DOT_LINE, GPC_AND_STYLE );
		DrawVert(pGC, GPC_BLACK, 120 + i, 0, 240, GPC_DASHDOT_LINE, GPC_NOT_STYLE );
	}
	ClearScreen( pGC, GPC_WHITE );

//----------------------------------------------------画圆----------------------------------------------------
	for ( i = 1; i < 41; i++ )
	{
		DrawCircle( pGC, GPC_BLACK, 50, 80, 2 * i, GPC_REPLACE_STYLE );
		DrawCircle( pGC, GPC_MAGENTA, 50, 160, 2 * i, GPC_REPLACE_STYLE );
		DrawCircle( pGC, GPC_BLUE, 110, 80, 2 * i, GPC_REPLACE_STYLE );
		DrawCircle( pGC, GPC_RED, 110, 160, 2 * i, GPC_REPLACE_STYLE );
	}
	for ( i = 40; i > 0; i-- )
	{
		DrawCircle( pGC, GPC_BLACK, 50, 80, 2 * i, GPC_XOR_STYLE );
		DrawCircle( pGC, GPC_WHITE, 50, 160, 2 * i, GPC_OR_STYLE );
		DrawCircle( pGC, GPC_BLACK, 100, 80, 2 * i, GPC_AND_STYLE );
		DrawCircle( pGC, GPC_BLACK, 100, 160, 2 * i, GPC_NOT_STYLE );
	}
	ClearRec( pGC,  GPC_BLACK, 0, 0, 159, 239, GPC_REPLACE_STYLE );
	InvRec( pGC, 0, 0, 159, 239 );
	ClearScreen( pGC, GPC_WHITE );

//----------------------------------------------------画椭圆----------------------------------------------------
	for ( i = 1; i < 41; i++ )
	{
		DrawEllipse( pGC, GPC_MAGENTA, 80, 120, 2 * i, 40 + 2 * i, GPC_REPLACE_STYLE );
		DrawEllipse( pGC, GPC_MAGENTA, 80, 120, 10 + 2 * i, 2 * i, GPC_REPLACE_STYLE );
	}
	for ( i = 40; i > 0; i-- )
	{
		DrawEllipse( pGC, GPC_MAGENTA, 80, 120, 2 * i, 40 + 2 * i, GPC_XOR_STYLE );
		DrawEllipse( pGC, GPC_BLACK, 80, 120, 10 + 2 * i, 2 * i, GPC_AND_STYLE );
	}
	ClearScreen( pGC, GPC_WHITE );


//----------------------------------------------------画斜线----------------------------------------------------
	for ( i = 0; i < 15; i++ )
	{
		DrawLine( pGC, GPC_BLACK,( 2 * i ), 0, ( 30 - 2 * i ), 239, GPC_SOLID_LINE, GPC_REPLACE_STYLE );
		DrawLine( pGC, GPC_RED, ( 30 + 2 * i ), 0, ( 60 - 2 * i ), 239, GPC_DASH_LINE, GPC_REPLACE_STYLE );
		DrawLine( pGC, GPC_WHITE,( 60 + 2 * i ), 0, ( 90 - 2 * i ), 239, GPC_DOT_LINE, GPC_REPLACE_STYLE );
		DrawLine( pGC, GPC_GREEN, ( 90 + 2 * i ), 0, ( 120 - 2 * i ), 239, GPC_DASHDOT_LINE, GPC_REPLACE_STYLE );
		DrawLine( pGC, GPC_YELLOW, ( 120 + 2 * i ), 0, ( 150 - 2 * i ), 239, GPC_SOLID_LINE, GPC_REPLACE_STYLE );
	}
	for ( i = 15; i > 0; i-- )
	{
		DrawLine( pGC, GPC_BLACK, 2 * i, 0, ( 30 - 2 * i ), 239, GPC_SOLID_LINE, GPC_XOR_STYLE );
		DrawLine( pGC, GPC_WHITE, ( 30 + 2 * i ), 0, ( 60 - 2 * i ), 239, GPC_DOT_LINE, GPC_OR_STYLE );
		DrawLine( pGC, GPC_BLUE,( 60 + 2 * i ), 0, ( 90 - 2 * i ), 239, GPC_DOT_LINE, GPC_AND_STYLE );
		DrawLine( pGC, GPC_GREEN, ( 90 + 2 * i ), 0, ( 120 - 2 * i ), 239, GPC_DASHDOT_LINE, GPC_NOT_STYLE );
		DrawLine( pGC, GPC_RED, ( 120 + 2 * i ), 0, ( 150 - 2 * i ), 239, GPC_SOLID_LINE, GPC_REPLACE_STYLE );
	}
	ClearScreen( pGC, GPC_WHITE );

//----------------------------------------------------画位图----------------------------------------------------


	hbmp = LoadBitmap( bluefire929, NULL );
	bitmap = (BITMAP *)hbmp;
//	hbmp = (DWORD)bmp;
//	bitmap = bmp;
//	DrawMonoImage( pGC, bitmap->data->ad, 10, 10, bitmap->info.width, bitmap->info.height, GPC_BLACK, GPC_WHITE );

//	Minute1 = Read_Minute();
//	Second1 = Read_Second();
//	for ( i = 0; i < 100; i++ )
	{
		DrawMonoImage( pGC, bluefire929, 10, 120, bitmap->info.width, bitmap->info.height, GPC_BLACK, GPC_WHITE );
//		DrawMonoImage( pGC, bluefire929, 10, 120, ( bitmap->info.width ) >> 1, ( bitmap->info.height ) >> 1, GPC_BLACK, GPC_WHITE );
	}
//	Minute2 = Read_Minute();
//	Second2 = Read_Second();
//	times1 = ( Minute2 - Minute1 ) * 60 + Second2 - Second1;

//	Minute1 = Read_Minute();
//	Second1 = Read_Second();
//	for ( i = 0; i < 100; i++ )
	{
		DisplayBMP( pGC, 5, 150, hbmp );
	}
//	Minute2 = Read_Minute();
//	Second2 = Read_Second();
//	times2 = ( Minute2 - Minute1 ) * 60 + Second2 - Second1;

 	SaveRec( pGC, bm, 10, 120, 100, 40, 0 );
	ClearScreen( pGC, GPC_WHITE );
	PutRec( pGC, bm, 0, 80, 100, 40, GPC_REPLACE_STYLE, 0 );
// 	ClearRec( pGC, GPC_BLACK, 10, 10, 100, 100, GPC_REPLACE_STYLE );
//	SaveRec( pGC, bm, 10, 10, 100, 100, 0 );
//	PutRec( pGC, bm, 5, 80, 100, 100, GPC_REPLACE_STYLE, 0 );
//	DisplayBMP( pGC, 6, 150, hbmp );
	ClearScreen( pGC, GPC_WHITE );

//	DisplayBMPEx( pGC, 100, 10, hbmp, GPC_REPLACE_STYLE, GPC_BLUE );
	FreeBitmap( hbmp );

//----------------------------------------------------画矩形----------------------------------------------------

	SetDotWidth( pGC, 4, NULL );
	for ( i = 0; i < 5; i++ )
	{
		DrawRec( pGC, GPC_BLACK, ( 80 - 5 * i ), ( 120 -  i * 5 ), ( 80 + 5 * i ), ( 120 + 5 * i ), GPC_SOLID_LINE, GPC_REPLACE_STYLE );
		DrawRec( pGC, GPC_RED, ( 60 - 5 * i ), ( 90 -  i * 5 ), ( 100 + 5 * i ), ( 150 + 5 * i ), GPC_DASH_LINE, GPC_REPLACE_STYLE );
		DrawRec( pGC, GPC_BLUE, ( 40 - 5 * i ), ( 60 -  i * 5 ), ( 120 + 5 * i ), ( 180 + 5 * i ), GPC_DOT_LINE, GPC_REPLACE_STYLE );
		DrawRec( pGC, GPC_BLACK, ( 20 - 5 * i ), ( 30 -  i * 5 ), ( 140 + 5 * i ), ( 210 + 5 * i ), GPC_DASHDOT_LINE, GPC_REPLACE_STYLE );
	}
	for ( i = 4; i > 0; i-- )
	{
		DrawRec( pGC, GPC_BLACK, ( 80 - 5 * i ), ( 120 -  i * 5 ), ( 80 + 5 * i ), ( 120 + 5 * i ), GPC_SOLID_LINE, GPC_XOR_STYLE );
		DrawRec( pGC, GPC_WHITE, ( 60 - 5 * i ), ( 90 -  i * 5 ), ( 100 + 5 * i ), ( 150 + 5 * i ), GPC_DASH_LINE, GPC_OR_STYLE );
		DrawRec( pGC, GPC_BLACK, ( 40 - 5 * i ), ( 60 -  i * 5 ), ( 120 + 5 * i ), ( 180 + 5 * i ), GPC_DOT_LINE, GPC_AND_STYLE );
		DrawRec( pGC, GPC_BLACK, ( 20 - 5 * i ), ( 30 -  i * 5 ), ( 140 + 5 * i ), ( 210 + 5 * i ), GPC_DASHDOT_LINE, GPC_NOT_STYLE );
	}
	SetDotWidth( pGC, 1, NULL );
	ClearScreen( pGC, GPC_WHITE );

//----------------------------------------------------写字---------------------------------------------------
	SysDrawText(pGC, GPC_BLACK, 10, 100, 150, 160, (PBYTE)texte, GPC_REPLACE_STYLE);
	SysTextOut(pGC, GPC_BLUE, 50, 10, (PBYTE)texte, GPC_REPLACE_STYLE);
	SysDrawText(pGC, GPC_BLACK, 10, 130, 86, 239, (PBYTE)textc, GPC_REPLACE_STYLE);
	SysTextOut(pGC, GPC_BLACK, 50, 50, (PBYTE)textc, GPC_REPLACE_STYLE);
	ClearScreen( pGC, GPC_WHITE );

//----------------------------------------------------画矢量---------------------------------------------------
//	DrawVector( pGC, GPC_MAROON, 3, pointPtrup, GPC_REPLACE_STYLE, 1 );
//	DrawVector( pGC, GPC_MAROON, 3, pointPtrdown, GPC_REPLACE_STYLE, 1 );
	ClearScreen( pGC, GPC_WHITE );

//----------------------------------------------------综合---------------------------------------------------

	//十字架
	GroupOn( pGC );
	ClearScreen( pGC, GPC_BLACK );
	for ( i = 0; i < 28; i++ )
	{
		DrawVert( pGC, GPC_RED, ( 59 + i ), 0, 240, GPC_SOLID_LINE, GPC_REPLACE_STYLE );
		DrawHorz( pGC, GPC_RED, 0, ( 99 + i ), 160, GPC_SOLID_LINE, GPC_REPLACE_STYLE );
	}
	GroupOff( pGC, 0, 0, 159, 239);
	ClearScreen( pGC, GPC_WHITE );

	//三叶草	
	for ( i = 0; i < 20; i++ )
	{
		DrawCircle( pGC, GPC_GREEN, 80, 110, i, GPC_REPLACE_STYLE );
		DrawCircle( pGC, GPC_GREEN, 70, 130, i, GPC_REPLACE_STYLE );
		DrawCircle( pGC, GPC_GREEN, 90, 130, i, GPC_REPLACE_STYLE );
		DrawVert( pGC, GPC_GREEN, ( 70 + i ), 120, 50, GPC_SOLID_LINE, GPC_REPLACE_STYLE );
	}
	ClearScreen( pGC, GPC_WHITE );

	//六芒星	
	DrawLine( pGC, GPC_BLACK, 80, 30, 12, 170, GPC_SOLID_LINE, GPC_REPLACE_STYLE );
	DrawLine( pGC, GPC_BLACK, 12, 170, 148, 170, GPC_SOLID_LINE, GPC_REPLACE_STYLE );
	DrawLine( pGC, GPC_BLACK, 80, 30, 148, 170, GPC_SOLID_LINE, GPC_REPLACE_STYLE );
	DrawLine( pGC, GPC_BLACK, 12, 90, 148, 90, GPC_SOLID_LINE, GPC_REPLACE_STYLE );
	DrawLine( pGC, GPC_BLACK, 12, 90, 80, 210, GPC_SOLID_LINE, GPC_REPLACE_STYLE );
	DrawLine( (DWORD)pGC, GPC_BLACK, 148, 90, 80, 210, GPC_SOLID_LINE, GPC_REPLACE_STYLE );

	Lfree( bm );
}

⌨️ 快捷键说明

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