?? lcdpage1bpp.lst
字號(hào):
pData += BytesPerLine;
PixelMask <<= 1;
if (!PixelMask || !ysize) {
_VRam[Page][x] = Data;
if (ysize) {
PixelMask = 1;
C51 COMPILER V8.05a LCDPAGE1BPP 04/11/2008 14:19:26 PAGE 12
Data = _VRam[++Page][x];
}
}
}
break;
}
}
/*********************************************
*
* Draw Bitmap 8 BPP (not optimized)
*
**********************************************
*/
#else
static void _DrawBitLine8BPP(int x, int y, U8 const * p, int xsize, const LCD_PIXELINDEX * pTrans) {
LCD_PIXELINDEX Pixel;
switch (GUI_Context.DrawMode & (LCD_DRAWMODE_TRANS | LCD_DRAWMODE_XOR)) {
case 0:
if (pTrans) {
for (; xsize > 0; xsize--, x++, p++) {
Pixel = *p;
LCD_L0_SetPixelIndex(x, y, *(pTrans + Pixel));
}
} else {
for (; xsize > 0; xsize--, x++, p++) {
LCD_L0_SetPixelIndex(x, y, *p);
}
}
break;
case LCD_DRAWMODE_TRANS:
if (pTrans) {
for (; xsize > 0; xsize--, x++, p++) {
Pixel = *p;
if (Pixel) {
LCD_L0_SetPixelIndex(x, y, *(pTrans + Pixel));
}
}
} else {
for (; xsize > 0; xsize--, x++, p++) {
Pixel = *p;
if (Pixel) {
LCD_L0_SetPixelIndex(x, y, Pixel);
}
}
}
break;
}
}
#endif
#endif
/*********************************************
*
* Draw Bitmap 16 BPP
*
**********************************************
*/
C51 COMPILER V8.05a LCDPAGE1BPP 04/11/2008 14:19:26 PAGE 13
#if (LCD_BITSPERPIXEL > 8)
static void _DrawBitLine16BPP(int x, int y, U16 const * p, int xsize, const LCD_PIXELINDEX * pTrans) {
LCD_PIXELINDEX Pixel;
switch (GUI_Context.DrawMode & (LCD_DRAWMODE_TRANS | LCD_DRAWMODE_XOR)) {
case 0:
if (pTrans) {
for (; xsize > 0; xsize--, x++, p++) {
Pixel = *p;
LCD_L0_SetPixelIndex(x, y, *(pTrans + Pixel));
}
} else {
for (; xsize > 0; xsize--, x++, p++) {
LCD_L0_SetPixelIndex(x, y, *p);
}
}
break;
case LCD_DRAWMODE_TRANS:
if (pTrans) {
for (; xsize > 0; xsize--, x++, p++) {
Pixel = *p;
if (Pixel) {
LCD_L0_SetPixelIndex(x, y, *(pTrans + Pixel));
}
}
} else {
for (; xsize > 0; xsize--, x++, p++) {
Pixel = *p;
if (Pixel) {
LCD_L0_SetPixelIndex(x, y, Pixel);
}
}
}
break;
}
}
#endif
/*********************************************************************
*
* Exported functions
*
**********************************************************************
*/
/*********************************************
*
* LCD_L0_SetPixelIndex
*
**********************************************
*/
void LCD_L0_SetPixelIndex(int x, int y, int PixelIndex) {
/* Convert logical into physical coordinates (Dep. on LCDConf.h) */
#if LCD_SWAP_XY | LCD_MIRROR_X | LCD_MIRROR_Y
int xPhys = LOG2PHYS_X(x, y);
int yPhys = LOG2PHYS_Y(x, y);
#else
#define xPhys x
#define yPhys y
#endif
/* Write into hardware */
{
C51 COMPILER V8.05a LCDPAGE1BPP 04/11/2008 14:19:26 PAGE 14
U8 Data = GET_BYTE(yPhys >> 3, xPhys);
U8 AndMask = ~(1 << (yPhys & 7));
U8 OrMask = PixelIndex << (yPhys & 7);
Data &= AndMask;
Data |= OrMask;
SET_PAGE_IF_NEEDED(yPhys >> 3);
SET_OFFSET_IF_NEEDED(xPhys);
WRITE_DATA1(Data);
}
}
/*********************************************
*
* LCD_L0_GetPixelIndex
*
**********************************************
*/
unsigned int LCD_L0_GetPixelIndex(int x, int y) {
/* Convert logical into physical coordinates (Dep. on LCDConf.h) */
#if LCD_SWAP_XY | LCD_MIRROR_X| LCD_MIRROR_Y
int xPhys = LOG2PHYS_X(x, y);
int yPhys = LOG2PHYS_Y(x, y);
#else
#define xPhys x
#define yPhys y
#endif
/* Read from hardware */
{
U8 Data = GET_BYTE(yPhys >> 3, xPhys);
return (Data & (1 << (yPhys & 7))) ? 1 : 0;
}
}
/*********************************************
*
* LCD_L0_XorPixel
*
**********************************************
*/
void LCD_L0_XorPixel(int x, int y) {
LCD_PIXELINDEX PixelIndex = LCD_L0_GetPixelIndex(x, y);
LCD_L0_SetPixelIndex(x, y, LCD_NUM_COLORS - PixelIndex - 1);
}
/*********************************************
*
* LCD_L0_DrawHLine (optimized)
*
**********************************************
*/
#if LCD_OPTIMIZE \
&& !LCD_SWAP_XY \
&& !LCD_MIRROR_X \
&& !LCD_MIRROR_Y
void LCD_L0_DrawHLine (int x0, int y, int x1) {
#if LCD_CACHE
U8 Mask = 1 << (y & 7);
int Page = y >> 3;
C51 COMPILER V8.05a LCDPAGE1BPP 04/11/2008 14:19:26 PAGE 15
U8 * pData = &_VRam[Page][x0];
int NumberOfBytes = x1 - x0 + 1;
SET_PAGE_IF_NEEDED(Page);
SET_OFFSET_IF_NEEDED(x0);
for (; x0 <= x1; x0++) {
if (GUI_Context.DrawMode & LCD_DRAWMODE_XOR) {
_VRam[Page][x0] ^= Mask;
} else {
if (LCD_COLORINDEX) {
_VRam[Page][x0] |= Mask;
} else {
_VRam[Page][x0] &= ~Mask;
}
}
}
WRITE_DATAM(pData, NumberOfBytes);
#else
U8 Mask = 1 << (y & 7);
SET_PAGE_IF_NEEDED(y >> 3);
SET_OFFSET_IF_NEEDED(x0);
for (; x0 <= x1; x0++) {
U8 Data = GET_CURRENT_BYTE();
if (GUI_Context.DrawMode & LCD_DRAWMODE_XOR) {
WRITE_DATA1(Data ^ Mask);
} else {
WRITE_DATA1((LCD_COLORINDEX) ? Data | Mask : Data & ~Mask);
}
}
#endif
}
/*********************************************
*
* LCD_L0_DrawHLine (not optimized)
*
**********************************************
*/
#else
void LCD_L0_DrawHLine (int x0, int y, int x1) {
if (GUI_Context.DrawMode & LCD_DRAWMODE_XOR) {
for (; x0 <= x1; x0++) {
LCD_L0_XorPixel(x0, y);
}
} else {
for (; x0 <= x1; x0++) {
LCD_L0_SetPixelIndex(x0, y, LCD_COLORINDEX);
}
}
}
#endif
/*********************************************
*
* LCD_L0_DrawVLine (optimized)
*
**********************************************
*/
#if LCD_OPTIMIZE \
C51 COMPILER V8.05a LCDPAGE1BPP 04/11/2008 14:19:26 PAGE 16
&& !LCD_SWAP_XY \
&& !LCD_MIRROR_X \
&& !LCD_MIRROR_Y
void LCD_L0_DrawVLine (int x, int y0, int y1) {
int y0_ = y0 & 7;
int y1_ = (y1 + 1) & 7;
if (y0_) {
U8 Data = GET_BYTE(y0 >> 3, x);
U8 Mask = 0xff << y0_;
if ((y0 >> 3) == (y1 >> 3)) {
Mask &= 0xff >> (7 - (y1 & 7));
}
SET_PAGE_IF_NEEDED(y0 >> 3);
SET_OFFSET_IF_NEEDED(x);
if (GUI_Context.DrawMode & LCD_DRAWMODE_XOR) {
WRITE_DATA1(Data ^ Mask);
} else {
WRITE_DATA1((LCD_COLORINDEX) ? Data | Mask : Data & ~Mask);
}
if ((y0 & 0xfff8) == (y1 & 0xfff8)) {
return;
}
}
{
int Page = ((y0 + 7) & 0xfff8) >> 3;
int NumPages = (((y1 + 1) & 0xfff8) >> 3) - Page;
if (NumPages) {
while (NumPages--) {
SET_PAGE_IF_NEEDED(Page++);
SET_OFFSET_IF_NEEDED(x);
if (GUI_Context.DrawMode & LCD_DRAWMODE_XOR) {
WRITE_DATA1(GET_CURRENT_BYTE() ^ 0xff);
} else {
WRITE_DATA1((LCD_COLORINDEX) ? 0xff : 0x00);
}
}
}
}
if (y1_) {
U8 Data = GET_BYTE(y1 >> 3, x);
U8 Mask = 0xff >> (8 - y1_);
SET_PAGE_IF_NEEDED(y1 >> 3);
SET_OFFSET_IF_NEEDED(x);
if (GUI_Context.DrawMode & LCD_DRAWMODE_XOR) {
WRITE_DATA1(Data ^ Mask);
} else {
WRITE_DATA1((LCD_COLORINDEX) ? Data | Mask : Data & ~Mask);
}
}
}
/*********************************************
*
* LCD_L0_DrawVLine (not optimized)
*
**********************************************
*/
#else
void LCD_L0_DrawVLine (int x, int y0, int y1) {
C51 COMPILER V8.05a LCDPAGE1BPP 04/11/2008 14:19:26 PAGE 17
if (GUI_Context.DrawMode & LCD_DRAWMODE_XOR) {
for (; y0 <= y1; y0++) {
LCD_L0_XorPixel(x, y0);
}
} else {
for (; y0 <= y1; y0++) {
LCD_L0_SetPixelIndex(x, y0, LCD_COLORINDEX);
}
}
}
#endif
/*********************************************
*
* LCD_L0_FillRect (optimized)
*
**********************************************
*/
#if LCD_OPTIMIZE \
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -