📄 lcd6642x.lst
字号:
int Pos = 3-(x&3);
U8 Data;
SET_X0(xByte);
SET_Y0(y);
READ_VMEM0(Data);
return 3&(Data>>(Pos<<1));
}
static PIXELCOLOR _GetPixel(int x, int y) {
return _GetPixel0(LOG2PHYS((x-LCD_XORG0),(y-LCD_YORG0)));
}
static void XorPixel(int x, int y) {
PIXELCOLOR Index = _GetPixel(x,y);
_SetPixel(x,y, LCD_NUM_COLORS-1-Index);
}
static void XorPixel_Data(int x, int y, PIXELCOLOR c) {
PIXELCOLOR Index = _GetPixel(x,y);
_SetPixel(x,y,Index^c);
}
/*
*********************************************************
C51 COMPILER V8.05a LCD6642X 04/11/2008 14:19:24 PAGE 11
*
* LCD_L0_GetPixelIndex
*
*********************************************************
*/
unsigned LCD_L0_GetPixelIndex(int x, int y) {
return _GetPixel(x,y);
}
/*
*********************************************************
* *
* LCD_L0_XorPixel *
* *
*********************************************************
Purpose: This routine is called by emWin. It writes 1 pixel into the
display.
*/
void LCD_L0_XorPixel(int x, int y) {
XORPIXEL(x, y);
}
/*
*********************************************************
* *
* LCD_L0_SetPixelIndex *
* *
*********************************************************
Purpose: This routine is called by emWin. It writes 1 pixel into the
display.
*/
void LCD_L0_SetPixelIndex(int x, int y, int ColorIndex) {
SETPIXEL(x, y, ColorIndex);
}
/*
*********************************************************
* *
* LCD_L0_DrawHLine unoptimized *
* *
*********************************************************
*/
void LCD_L0_DrawHLine (int x0, int y, int x1) {
if (GUI_Context.DrawMode & LCD_DRAWMODE_XOR) {
while (x0 <= x1) {
XORPIXEL(x0, y);
x0++;
}
} else {
while (x0 <= x1) {
SETPIXEL(x0, y, COLOR);
x0++;
}
}
}
C51 COMPILER V8.05a LCD6642X 04/11/2008 14:19:24 PAGE 12
/*
*********************************************************
*
* LCD_L0_DrawVLine, optimized
*
*********************************************************
*/
#if (LCD_OPTIMIZE) \
&& (LCD_BITSPERPIXEL == 2) \
&& (LCD_SWAP_XY ==1) \
&& (LCD_MIRROR_X==1) \
&& (LCD_MIRROR_Y==0) \
&& (!defined (LCD_LUT_SEG))
void LCD_L0_DrawVLine (int x, int y0, int y1) {
U8 ColorMask, OrMask, AndMask, Data;
int y = LCD_XSIZE - x - 1;
int x0 = y0;
int x1 = y1;
int x0Byte = x0 >> 2;
int x1Byte = (x1 + 1) >> 2;
int NumBytes = x1Byte - x0Byte;
SET_X_INCREMENT();
SET_Y0(y);
SET_X0(x0Byte);
ColorMask = COLOR + (COLOR<<2) + (COLOR<<4) + (COLOR<<6);
if (x0 & 3) {
int Pos = (x0 & 3) << 1;
AndMask = 0xff << (8 - Pos);
OrMask = ColorMask >> Pos;
READ_VMEM0(Data);
if (x0Byte == (x1 >> 2)) {
if ((x1 & 3) != 3) {
int Pos = ((x1 + 1) & 3) << 1;
AndMask |= 0xff >> Pos;
OrMask &= ColorMask << (8 - Pos);
}
NumBytes = 0;
}
if (GUI_Context.DrawMode & LCD_DRAWMODE_XOR) {
Data ^= (0xff & ~AndMask);
} else {
Data &= AndMask;
Data |= OrMask;
}
WRITE_VMEM0(Data);
if (!NumBytes) {
SET_Y_INCREMENT();
return;
}
--NumBytes;
}
if (NumBytes) {
if (GUI_Context.DrawMode & LCD_DRAWMODE_XOR) {
do {
READ_VMEM0(Data);
Data ^= 0xff;
WRITE_VMEM0(Data);
} while(--NumBytes);
} else {
C51 COMPILER V8.05a LCD6642X 04/11/2008 14:19:24 PAGE 13
LCD_WRITE_REG00(4);
#if LCD_CACHE
memset(&aState[0].aaVMem[aState[0].y][aState[0].x], ColorMask, NumBytes);
#endif
aState[0].x += NumBytes;
do {
LCD_WRITE_REG01(ColorMask);
} while(--NumBytes);
}
}
if ((x1 + 1) & 3) {
int Pos = ((x1 + 1) & 3) << 1;
AndMask = 0xff >> Pos;
OrMask = ColorMask << (8 - Pos);
READ_VMEM0(Data);
if (GUI_Context.DrawMode & LCD_DRAWMODE_XOR) {
Data ^= (0xff & ~AndMask);
} else {
Data &= AndMask;
Data |= OrMask;
}
WRITE_VMEM0(Data);
}
SET_Y_INCREMENT();
}
/*
*********************************************************
*
* LCD_L0_DrawVLine no optimization
*
*********************************************************
*/
#else
void LCD_L0_DrawVLine (int x, int y0, int y1) {
if (GUI_Context.DrawMode & LCD_DRAWMODE_XOR) {
while (y0 <= y1) {
XORPIXEL(x, y0);
y0++;
}
} else {
while (y0 <= y1) {
SETPIXEL(x, y0, COLOR);
y0++;
}
}
}
#endif
/*********************************************************************
*
* LCD_FillRect
*
**********************************************************************
*/
#if LCD_SWAP_XY
void LCD_L0_FillRect(int x, int y0, int x1, int y1) {
C51 COMPILER V8.05a LCD6642X 04/11/2008 14:19:24 PAGE 14
for (; x <= x1; x++) {
LCD_L0_DrawVLine(x,y0, y1);
}
}
#else
void LCD_L0_FillRect(int x0, int y0, int x1, int y1) {
for (; y0 <= y1; y0++) {
LCD_L0_DrawHLine(x0,y0, x1);
}
}
#endif
/*
*********************************************************
*
* Draw Bitmap 1 BPP, optimized
*
*********************************************************
*/
#if (LCD_OPTIMIZE) \
&& (LCD_BITSPERPIXEL == 2) \
&& (LCD_SWAP_XY ==1) \
&& (LCD_MIRROR_X==1) \
&& (LCD_MIRROR_Y==0) \
&& (!defined (LCD_LUT_SEG))
static void DrawBitLine1BPP_Swap(
int x,
int y,
U8 const * pData,
int ysize,
const U8 * pTrans,
int BytesPerLine,
U8 Pos)
{
LCD_PIXELINDEX Index0 = *(pTrans+0);
LCD_PIXELINDEX Index1 = *(pTrans+1);
int i;
int y0 = LCD_XSIZE - x - 1;
int x0 = y;
int x0Byte = y >> 2;
U8 Buffer, DataMask, Index, Data, ShiftPos, BufferMask, Pixel;
U8 BufferValid = 0;
SET_Y0(y0);
SET_X0(x0Byte);
ShiftPos = Pos & 7;
BufferMask = 0xC0 >> ((x0 & 3) << 1);
DataMask = 0x80 >> ShiftPos;
for (i = 0; i < ysize; i++, pData += BytesPerLine) {
if (!BufferValid) {
READ_VMEM0(Buffer);
BufferValid = 1;
}
switch (GUI_Context.DrawMode) {
case LCD_DRAWMODE_NORMAL:
case LCD_DRAWMODE_REV:
Buffer &= ~BufferMask;
Index = *(pTrans + ((*pData & DataMask) >> (7 - ShiftPos)));
Data = Index << (6 - (((i + x0) & 3) << 1));
Buffer |= Data;
break;
C51 COMPILER V8.05a LCD6642X 04/11/2008 14:19:24 PAGE 15
case LCD_DRAWMODE_XOR:
Pixel = (*pData & DataMask) >> (7 - ShiftPos);
if (Pixel) {
Data = 3 << (6 - (((i + x0) & 3) << 1));
Buffer ^= Data;
}
break;
case LCD_DRAWMODE_TRANS:
Pixel = (*pData & DataMask) >> (7 - ShiftPos);
if (Pixel) {
Index = *(pTrans + Pixel);
Buffer &= ~BufferMask;
Data = Index << (6 - (((i + x0) & 3) << 1));
Buffer |= Data;
}
break;
}
if (BufferMask == 3) {
BufferMask = 0xC0;
BufferValid = 0;
WRITE_VMEM0(Buffer);
} else {
BufferMask >>= 2;
}
}
if (BufferValid) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -