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

📄 gpc.h

📁 一个操作系统源代码 用于嵌入式设备 在Vc++环境下仿真 成功移植到多款处理器上
💻 H
📖 第 1 页 / 共 2 页
字号:
#define gpcCheckFontByte(text)  \
	( ( *(text) >= 0x20 && *(text) <=0x7e )? 1 :\
	 (( *(text)>=0xa0 && *(text)<=0xfe ) ? 2 : 0 ) )
#endif

//by zhuli 2002.2.3 
//convert the types of x and y from WORD to SHORT before compare to 0 By zl 2002.4.3
// longn_qi 2002/04/25 move it here
extern BOOL Write2LCD( WORD x1, WORD y1, WORD x2, WORD y2, VRAM *initAd );

//#ifdef	DMA_MODE
//#define WRITELCD( x1, y1, x2, y2 )	seWrite2LCD( pGC->vram, 0 );
//#else
#define WRITELCD( x1, y1, x2, y2 ) \
{\
	short px1, px2, py1, py2;\
	px1 = (x1) - pGC->lcd_x;\
	px2 = (x2) - pGC->lcd_x;\
	py1 = (y1) - pGC->lcd_y;\
	py2 = (y2) - pGC->lcd_y;\
	if(!( (SHORT)(x2) < 0 ||(SHORT) (y2) < 0 || (x1) > PHY_LCD_W - 1 || (y1) > PHY_LCD_H - 1 ))\
	{\
		px1 = ( px1 < 0 )? 0 : px1;\
		py1 = ( py1 < 0 )? 0 : py1;\
		px2 = ( px2 >= PHY_LCD_W )? PHY_LCD_W-1 : px2;\
		py2 = ( py2 >= PHY_LCD_H )? PHY_LCD_H-1 : py2;\
		Write2LCD( px1, py1, px2, py2, pGC->vram );\
	}\
}
//#endif

// 位图的状态标志位
#define GPC_BMP_PALETTE_FLAG	0x01
#define GPC_BMP_COMPRESS_FLAG	0x02

//位图头信息结构
typedef struct
{
    WORD    type;			// 位图的标识符,必须是GPC_BMP_SYMBOL = 0x4D42 ('BM')
    WORD    width;			// 位图的宽度(像素单位)
    WORD    height;			// 位图的高度(像素单位)
    BYTE    bitcount;		// 位图的像素深度(bits/pixel)
    BYTE    flag;			// 位图的状态标志位
							// |7|6|5|4|3|2|1|0|
							// 0位:是否使用自定义调色板(1=使用自定义调色板,0=使用系统调色板)
							// 1位:是否压缩(1=使用压缩算法,0=不使用压缩算法)
    DWORD   colorused;		// 位图实际使用到的颜色数
    DWORD	offset;			// 数据区的偏移量
}BMPHEADER;

//位图结构
typedef struct
{
	BMPHEADER	info;		// 位图头信息
	DWORD		*palette;	// 位图调色板
	VRAM		*data;		// 位图数据DIB
}BITMAP;

//单色位图结构
typedef struct tagPHYIMAGEINFO
{
    SHORT		x;						// 单色位图左上角x坐标
    SHORT		y;						// 单色位图左上角y坐标
    SHORT		width;					// 单色位图宽度
    SHORT		height;					// 单色位图高度
    PBYTE		buffer;					// 单色位图缓冲区首地址
    WORD		method;					// 单色位图前景色操作(参见line style宏)
	WORD		mode;					// 单色位图背景色模式(参见extern style宏)
    PIXEL		ColorIndex;				// 单色位图前景色(索引值)
    PIXEL		BkColorIndex;			// 单色位图背景色(索引值,透明背景模式下该值无效)
} PHYIMAGEINFO, *PPHYIMAGEINFO;

//字体结构
typedef struct tagFont
{
	PBYTE		Font1;					// 英文字库首地址
    BYTE  		Font1Width;				// 英文字宽
    BYTE  		Font1Height;			// 英文字高
    PBYTE  		Font2;					// 汉字字库首地址
    BYTE  		Font2Width;				// 汉字字宽
    BYTE 		Font2Height;			// 汉字字高
}FONT, *PFONT;

//软光标结构
typedef struct tagCursor
{
	WORD		symbol;					// 光标结构标识符,必须是0x4353('CS')
    WORD		x;						// 光标x坐标
    WORD		y;						// 光标y坐标
    WORD		width;					// 光标宽度
    WORD		height;					// 光标高度
    BYTE		status;					// 光标状态
	BOOL		flag;					// 光标标志
    WORD		frequency;				// 光标闪烁频率
    BYTE		style;					// 光标风格
	DWORD		t_id;					// 软定时器ID
}CURSOR;

//图形上下文结构(Graphic Context)
typedef  struct  _gc{
	DWORD		frt_color;				// 前景色 current color
	DWORD		bk_color;				// 背景色 BackGround Color for gpcDrawText
	DWORD		fillmode;				// 填充模式
	WORD		dotwidth;				// 当前线宽 current dotwidth
	WORD		status;					// 状态(是否拥有LCD?)whether the task can use the LCD
	WORD		width;					// 屏幕宽(逻辑)logical display width
	WORD		height;					// 屏幕高(逻辑)ligical display heigth
	FONT		*font;					// 字体结构
	CURSOR		*cursor;				// 软光标
	VRAM		*vram;					// vram指针
	WORD		symbol;					// 结构标识符,必须是0x4743('GC')
	WORD		lcd_x;					// 物理屏幕在逻辑屏幕上的坐标
	WORD		lcd_y;					// 物理屏幕在逻辑屏幕上的坐标
	WORD		reserved;				// 保留(对齐边界)
	WORD		reserved1;				// 保留(对齐边界)
	WORD		group_operation;			//是否进行组操作,既是否在一个矩形区域中进行多次画图操作 2002.2.4
}GC; 

// 字库头结构
typedef struct _tagFontHeader
{
	BYTE		symbol[6];				//字库标志(“FONTX2”)
	BYTE		reserved[8];			//保留未用
	BYTE		width;					//字宽
	BYTE		height;					//字高
}FONTHEADER, *PFONTHEADER;

EXTERN	ID		gLcdOwnerTskId;

EXTERN const char dot2[2][2];
EXTERN const char dot3[3][3];
EXTERN const char dot4[4][4];
EXTERN const char dot5[5][5];
EXTERN const char dot6[6][6];
EXTERN const char dot7[7][7];
EXTERN const char dot8[8][8];
EXTERN const char dot9[9][9];
EXTERN const char dot10[10][10];

EXTERN const unsigned char GPCFONT11A[];
EXTERN const unsigned char GPCFONT11K[];

EXTERN BYTE		ENGLISH_CHAR_WIDTH;
EXTERN BYTE		ENGLISH_CHAR_HEIGHT;
EXTERN BYTE		CHINESE_CHAR_WIDTH;
EXTERN BYTE		CHINESE_CHAR_HEIGHT;	

EXTERN PBYTE	ENGLISH_CHAR_ENTRY;
EXTERN PBYTE	CHINESE_CHAR_ENTRY;

#define MAX_DOT_WIDTH 10              //maximun of dotwidth
 
//定义点(x,y)在vram中的存储位置
// A	vram的首地址
// x,y	点坐标
// W	vram的宽度
//#define VRAM(A, x, y, W) ( *( (A)+(y)*(W)+(x) ) )



//判断STATUS的状态
//#define LCD_FRONT_END 1
//#define LCD_BACK_END 0


//画点的宏。其中包括了Style,ColorIndex。应在外部已经定义好了ColorIndex,ColorIndex1
#define SETPIXEL(x, y) \
	switch ( style )\
  	{\
		case GPC_REPLACE_STYLE :case GPC_COPY_STYLE :VRAM(gc->vram, (x), (y), gc->width) = ColorIndex;break; \
		case GPC_AND_STYLE :VRAM(gc->vram, (x), (y), gc->width) &= ColorIndex;break;  \
		case GPC_OR_STYLE :VRAM(gc->vram, (x), (y), gc->width) |= ColorIndex;break;\
		case GPC_XOR_STYLE :VRAM(gc->vram, (x), (y), gc->width) ^= ColorIndex;break;\
		case GPC_NOT_STYLE :VRAM(gc->vram, (x), (y), gc->width) =  ~ ColorIndex;break;\
  	}

struct _systcb;

extern struct _systcb gSysTcbTb[];
extern ID	gLcdOwnerTskId;

extern DWORD SysPalette0[];

#define	SysGetCurGC()	(( DWORD )gSysTcbTbl[gLcdOwnerTskId-1].gc)

//----------------------------------------------------------------------


///////////////////////////////////////////////////////////////
//  Function Declare Section 
///////////////////////////////////////////////////////////////

PUBLIC DWORD SysInitGC(WORD vramWidth, WORD vramHeight);
PUBLIC DWORD SysGetGC(void);
PUBLIC STATUS SysFreeGC(DWORD gc);
PUBLIC WORD SysGetDisplayX(void);
PUBLIC WORD SysGetDisplayY(void);
PUBLIC WORD SysGetLogicalX(DWORD GC);
PUBLIC WORD SysGetLogicalY(DWORD GC);
PUBLIC STATUS SysGroupOn( DWORD GC );	//by zhuli 2002.2.4
PUBLIC STATUS SysGroupOff( DWORD PGC, WORD xSrc, WORD ySrc, WORD xDest, WORD yDest);	//by zhuli 2002.2.4


PUBLIC STATUS SysSetDotWidth(DWORD pGC, WORD newWidth, PWORD oldWidth);
PUBLIC STATUS SysClearScreen(DWORD pGC, DWORD rgb);
PUBLIC STATUS SysDrawDot(DWORD pGC, DWORD rgb, WORD xPos, WORD yPos, WORD style);
PUBLIC STATUS SysDrawHorz(DWORD pGC, DWORD rgb, WORD xSrc, WORD ySrc, WORD width, WORD dotLine, WORD style);
PUBLIC STATUS SysDrawVert(DWORD pGC, DWORD rgb, WORD xSrc, WORD ySrc, WORD height, WORD dotLine, WORD style);
PUBLIC STATUS SysDrawLine(DWORD pGC, DWORD rgb, WORD xSrc, WORD ySrc, WORD xDest, WORD yDest, WORD dotLine, WORD style);
PUBLIC STATUS SysDrawRec(DWORD pGC, DWORD rgb, WORD xSrc, WORD ySrc, WORD xDest, WORD yDest, WORD dotLine, WORD style);
PUBLIC STATUS SysDrawCircle(DWORD pGC, DWORD rgb, WORD xCenter, WORD yCenter, WORD radius, WORD style);
PUBLIC STATUS SysDrawEllipse(DWORD pGC, DWORD rgb, WORD xCenter, WORD yCenter, WORD xLength, WORD yLength, WORD style);
PUBLIC STATUS SysDrawVector(DWORD pGC, DWORD rgb, WORD numberOfPoints, PPOINTS pointPtr, WORD style, WORD mode);
//PUBLIC STATUS SysPutRec(DWORD pGC, PWORD bitmap, WORD xSrc, WORD ySrc, WORD width, WORD height, WORD style, WORD reserved);
PUBLIC STATUS SysPutRec(DWORD pGC, PIXEL *bitmap, WORD xSrc, WORD ySrc, WORD width, WORD height, WORD style, WORD reserved);
//PUBLIC STATUS SysSaveRec(DWORD pGC, PWORD bitmap, WORD xSrc, WORD ySrc, WORD width, WORD height, WORD reserved);
PUBLIC STATUS SysSaveRec(DWORD pGC, PIXEL *bitmap, WORD xSrc, WORD ySrc, WORD width, WORD height, WORD reserved);
PUBLIC STATUS SysClearRec(DWORD pGC,  DWORD rgb, WORD xSrc, WORD ySrc, WORD width, WORD height, WORD style);
PUBLIC STATUS SysInvRec(DWORD pGC, WORD xSrc, WORD ySrc, WORD width, WORD height );
PUBLIC STATUS SysDrawText(DWORD pGC, DWORD rgb, WORD xSrc, WORD ySrc, WORD xDes, WORD yDes, PBYTE text, WORD style);
PUBLIC STATUS SysTextOut(DWORD pGC, DWORD rgb, WORD xSrc, WORD ySrc, PBYTE text, WORD style);
PUBLIC STATUS SysSetColor(DWORD pGC, DWORD rgb);
PUBLIC STATUS SysSetBkColor(DWORD pGC, DWORD rgb);
PUBLIC STATUS SysDrawMonoImage( DWORD pGC, PBYTE bitmap, WORD xSrc, WORD ySrc, WORD width, WORD height, DWORD frntColor, DWORD bkColor );
PUBLIC STATUS SysTextOutEx(DWORD gc, DWORD rgb, WORD xSrc, WORD ySrc, PBYTE text, WORD length, WORD style, WORD exstyle, DWORD bkrgb);
PUBLIC STATUS SysSetBkFillMode( DWORD pGC, DWORD style );

PUBLIC STATUS SysInitFont( void );
PUBLIC STATUS SysGetFont( DWORD pGC, PBYTE font1, PBYTE font2 );
PUBLIC STATUS SysSetFont( DWORD pGC, PBYTE font1, PBYTE font2 );
PUBLIC STATUS SysGetFontSize( DWORD pGC, PBYTE font1_W, PBYTE font1_H, PBYTE font2_W, PBYTE font2_H );

PUBLIC WORD SysAlignString( PBYTE string, WORD winXSrc, WORD winXWidth, BYTE align );
 
PUBLIC STATUS SysSetCursorPosition( DWORD pGC, WORD xPos, WORD yPos );
PUBLIC STATUS SysSetCursorSize( DWORD pGC, WORD cursorWidth, WORD cursorHeight );
PUBLIC STATUS SysSetCursorStatus( DWORD pGC, BYTE status );  
PUBLIC STATUS SysSetCursorBlinkFrequency(DWORD pGC, WORD frequency );     
PUBLIC STATUS SysSetCursorStyle( DWORD pGC, BYTE cursorstyle );
PUBLIC STATUS SysCreateCursor( DWORD pGC, WORD xPos, WORD yPos, WORD cursorWidth, WORD cursorHeight, BYTE status,\
                     WORD frequency, BYTE cursorstyle );
PUBLIC STATUS SysStartCursor( DWORD pGC );    
PUBLIC STATUS SysStopCursor( DWORD pGC );
PUBLIC STATUS SysFreeCursor( DWORD pGC );
PUBLIC STATUS SysAdjustCursorDisp( DWORD pGC );
PUBLIC STATUS SysGetCursorStatus( DWORD gc, PWORD status );

PUBLIC DWORD SysLoadBitmap( BYTE *resource, DWORD *userpal );
PUBLIC void SysFreeBitmap( DWORD hbmp );
PUBLIC DWORD SysGrizzleBitmap( BYTE *resource, DWORD *userpal );

PUBLIC STATUS SysSetBMPPalette( DWORD hbmp, DWORD *palette, DWORD **oldPalette );
PUBLIC STATUS SysSetBMPData( DWORD hbmp, VRAM *data, VRAM **oldData );
PUBLIC STATUS SysModifyBMPPalette( DWORD hbmp, DWORD index, DWORD color, DWORD *oldColor );
PUBLIC STATUS SysDisplayBMP( DWORD gc, WORD x, WORD y, DWORD hbmp );
PUBLIC STATUS SysDisplayBMPEx( DWORD gc, WORD xSrc, WORD ySrc, DWORD hbmp, WORD style, DWORD trColor );

PUBLIC STATUS SysGetBMPPixel( DWORD gc, WORD x, WORD y, DWORD hbmp, DWORD *color );

extern void seSetPixel(GC *gc, SHORT x,SHORT y,PIXEL ColorIndex, WORD style);
extern void seGetPixel(GC *gc, SHORT x, SHORT y, PIXEL *ColorIndex);
extern void seDrawHorzLine(GC *gc, SHORT x,SHORT y,SHORT width,PIXEL ColorIndex,WORD mask, WORD style);
extern void seDrawVertLine(GC *gc, SHORT x,SHORT y,SHORT height,PIXEL ColorIndex,WORD mask, WORD style);
extern void seDrawLine(GC *gc, SHORT x1,SHORT y1,SHORT x2, SHORT y2,PIXEL ColorIndex,WORD mask, WORD style);
extern void seSetMonoImageLine( GC *gc, PPHYIMAGEINFO ppii );
extern void seSetMonoImage( GC *gc, PPHYIMAGEINFO ppii );
extern void sePutChar( GC *gc, PPHYIMAGEINFO ppii );
extern void seSetImage(GC *gc, SHORT x, SHORT y, SHORT width, SHORT height , VRAM *buffer, WORD style);
extern void seGetImage(GC *gc, SHORT x, SHORT y, SHORT width , SHORT height , VRAM *buffer);
extern void seEllipse (GC *gc, SHORT x, SHORT y, SHORT a, SHORT b, PIXEL ColorIndex, WORD style);
extern void seRGBtoIndex(DWORD rgb , PIXEL *index);
extern void seClearRec(GC *gc, SHORT x, SHORT y, SHORT width, SHORT height, PIXEL ColorIndex, WORD style);
extern void seInvRec(GC *gc, SHORT x, SHORT y, SHORT width, SHORT height);
extern void seWrite2LCD( VRAM *vram, BYTE bitOffset);
extern void seDrawImage(GC *gc, SHORT x, SHORT y, SHORT width, SHORT height , VRAM *buffer, WORD style, WORD trColor );

extern void seDrawCircle( GC *gc, SHORT xCenter, SHORT yCenter, SHORT radius, PIXEL ColorIndex, WORD style );

//extern void seText( GC * gc, SHORT x, SHORT y, PBYTE text, SHORT length );
//extern void sePutChar( GC *gc, SHORT xSrc, SHORT ySrc, BYTE char_width, BYTE char_height, PBYTE buffer, WORD ColorIndex, WORD style);

extern void seDisplayBMP( GC *gc, WORD x, WORD y, WORD width, WORD height, BITMAP *bmp );
extern void seDisplayBMPEx( GC *gc, WORD x, WORD y, WORD width, WORD height, BITMAP *bmp, WORD style, PIXEL trIndex );

extern DWORD seGetBMPPixelV( BYTE *pixelPos, BYTE bitOffset, BYTE bits );
extern DWORD *seGetSysPalette( BYTE bitcount );
extern DWORD seBMPIndexToRGB( BYTE bitcount, DWORD index );

extern PIXEL *GetBlock( WORD width, WORD height );

#endif
//----------------------------- The End of the File ----------------------------

⌨️ 快捷键说明

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