📄 lcdmem.c
字号:
SETPIXEL(x+0, y, *(pTrans+(pixels>>6)));
if (!--xsize)
return;
WriteTBit1:
if (pixels&(3<<4))
SETPIXEL(x+1, y, *(pTrans+(3&(pixels>>4))));
if (!--xsize)
return;
WriteTBit2:
if (pixels&(3<<2))
SETPIXEL(x+2, y, *(pTrans+(3&(pixels>>2))));
if (!--xsize)
return;
WriteTBit3:
if (pixels&(3<<0))
SETPIXEL(x+3, y, *(pTrans+(3&(pixels))));
if (!--xsize)
return;
pixels = *(++p);
x+=4;
goto WriteTBit0;
}
#endif
#endif
/*********************************************************************
*
* _DrawBitLine4BPP
*/
#if (LCD_MAX_LOG_COLORS > 4)
static void _DrawBitLine4BPP(int x, int y, U8 const GUI_UNI_PTR *p, int Diff, int xsize, const LCD_PIXELINDEX*pTrans) {
PIXELCOLOR pixels;
/*
Jump to right entry point
*/
pixels = *p;
if (GUI_Context.DrawMode & LCD_DRAWMODE_TRANS) {
if ((Diff&1) ==0) {
goto WriteTBit0;
} else {
goto WriteTBit1;
}
} else {
if ((Diff&1) ==0) {
goto WriteBit0;
} else {
goto WriteBit1;
}
}
/*
Write without transparency
*/
WriteBit0:
SETPIXEL(x+0, y, *(pTrans+(pixels>>4)));
if (!--xsize)
return;
WriteBit1:
SETPIXEL(x+1, y, *(pTrans+(pixels&0xf)));
if (!--xsize)
return;
x+=2;
pixels = *(++p);
goto WriteBit0;
/*
Write with transparency
*/
WriteTBit0:
if (pixels>>4)
SETPIXEL(x+0, y, *(pTrans+(pixels>>4)));
if (!--xsize)
return;
WriteTBit1:
if (pixels&0xf)
SETPIXEL(x+1, y, *(pTrans+(pixels&0xf)));
if (!--xsize)
return;
x+=2;
pixels = *(++p);
goto WriteTBit0;
}
#endif
/*********************************************************************
*
* _DrawBitLine8BPP
*/
static void _DrawBitLine8BPP(int x, int y, U8 const GUI_UNI_PTR *p, int xsize, const LCD_PIXELINDEX*pTrans) {
PIXELCOLOR Pixels;
if (pTrans != aID) {
do {
Pixels = *p;
SETPIXEL(x, y, *(pTrans + Pixels));
xsize--;
x++;
p++;
} while (xsize > 0);
} else {
do {
SETPIXEL(x, y, *p);
xsize--;
x++;
p++;
} while (xsize > 0);
}
}
/*********************************************************************
*
* Exported code
*
**********************************************************************
*/
/*********************************************************************
*
* LCD_L0_XorPixel
*/
void LCD_L0_XorPixel(int x, int y) {
XORPIXEL(x, y);
}
/*********************************************************************
*
* LCD_L0_SetPixelIndex
*/
void LCD_L0_SetPixelIndex(int x, int y, int ColorIndex) {
SETPIXEL(x, y, ColorIndex);
}
/*********************************************************************
*
* LCD_L0_GetPixelIndex
*/
unsigned int LCD_L0_GetPixelIndex(int x, int y) {
return GETPIXEL(x,y);
}
/*********************************************************************
*
* LCD_L0_DrawHLine
*/
#if (!LCD_SWAP_XY)
void LCD_L0_DrawHLine (int x0, int y, int x1) {
int Off0, Off1;
U8 EndMask;
#if LCD_MIRROR_X
{
int t = (LCD_XSIZE-1-(x0));
x0 = (LCD_XSIZE-1-(x1));
x1 = t;
}
#endif
#if LCD_MIRROR_Y
y = (LCD_YSIZE-1-(y));
#endif
EndMask = ~aMask[1+((x1)&7)];
Off0 = y*LCD_BYTESPERLINE+(x0>>3);
Off1 = y*LCD_BYTESPERLINE+(x1>>3);
if (GUI_Context.DrawMode & LCD_DRAWMODE_XOR) {
if (Off0==Off1) {
U8 Data = aMask[x0&7] & EndMask;
LCD_VRam[0][Off0] ^= Data;
#if LCD_BITSPERPIXEL == 2
LCD_VRam[1][Off0] ^= Data;
#endif
} else {
U8 Data = aMask[x0&7];
LCD_VRam[0][Off0] ^= Data;
#if LCD_BITSPERPIXEL == 2
LCD_VRam[1][Off0] ^= Data;
#endif
for (Off0++;Off0<Off1; Off0++) {
LCD_VRam[0][Off0] ^= 255;
#if LCD_BITSPERPIXEL == 2
LCD_VRam[1][Off0] ^= 255;
#endif
}
LCD_VRam[0][Off0] ^= EndMask;
#if LCD_BITSPERPIXEL == 2
LCD_VRam[1][Off0] ^= EndMask;
#endif
}
} else {
if (Off0==Off1) {
U8 Data = aMask[x0&7] & EndMask;
if (COLOR &1) LCD_VRam[0][Off0] |= Data;
else LCD_VRam[0][Off0] &= ~Data;
#if LCD_BITSPERPIXEL == 2
if (COLOR &2) LCD_VRam[1][Off0] |= Data;
else LCD_VRam[1][Off0] &= ~Data;
#endif
} else {
U8 Data = aMask[x0&7];
if (COLOR &1) LCD_VRam[0][Off0] |= Data;
else LCD_VRam[0][Off0] &= ~Data;
#if LCD_BITSPERPIXEL == 2
if (COLOR &2) LCD_VRam[1][Off0] |= Data;
else LCD_VRam[1][Off0] &= ~Data;
#endif
while (++Off0<Off1) {
LCD_VRam[0][Off0] = (COLOR &1) ? 255 : 0;
#if LCD_BITSPERPIXEL == 2
LCD_VRam[1][Off0] = (COLOR &2) ? 255 : 0;
#endif
}
if (COLOR &1) LCD_VRam[0][Off0] |= EndMask;
else LCD_VRam[0][Off0] &= ~EndMask;
#if LCD_BITSPERPIXEL == 2
if (COLOR &2) LCD_VRam[1][Off0] |= EndMask;
else LCD_VRam[1][Off0] &= ~EndMask;
#endif
}
}
}
#else
#if LCD_ALLOW_NON_OPTIMIZED_MODE == 0
#error Non-optimized mode. Please select an other mode, define LCD_ALLOW_NON_OPTIMIZED_MODE in LCDCOnf.h or contact info@micrium.com.
#endif
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++;
}
}
}
#endif
/*********************************************************************
*
* LCD_L0_DrawVLine
*/
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++;
}
}
}
/*********************************************************************
*
* LCD_L0_FillRect
*/
void LCD_L0_FillRect(int x0, int y0, int x1, int y1) {
for (; y0 <= y1; y0++) {
LCD_L0_DrawHLine(x0,y0, x1);
}
}
/*********************************************************************
*
* LCD_L0_DrawBitmap
*/
void LCD_L0_DrawBitmap (int x0, int y0,
int xsize, int ysize,
int BitsPerPixel,
int BytesPerLine,
const U8 GUI_UNI_PTR * pData, int Diff,
const LCD_PIXELINDEX* pTrans)
{
int i;
/* Use aID for bitmaps without palette */
if (!pTrans) {
pTrans = aID;
}
/* Use DrawBitLineXBPP */
#if (!LCD_MIRROR_X) && \
(!LCD_MIRROR_Y) && \
(!LCD_SWAP_XY) && \
(LCD_BITSPERPIXEL == 1)
if (BitsPerPixel == 1) {
LCD_PIXELINDEX Index0 = *(pTrans + 0);
LCD_PIXELINDEX Index1 = *(pTrans + 1);
x0 += Diff;
if ((Index0 == Index1) && (!(GUI_Context.DrawMode & (LCD_DRAWMODE_TRANS | LCD_DRAWMODE_XOR)))) {
LCD_PIXELINDEX ColorIndexOld = COLOR;
COLOR = Index0;
LCD_L0_FillRect(x0, y0, x0 + xsize - 1, y0 + ysize - 1);
COLOR = ColorIndexOld;
return;
}
_DrawBitMap1BPP(x0, y0, pData, Diff, xsize, ysize, BytesPerLine);
} else {
#endif
for (i=0; i<ysize; i++) {
switch (BitsPerPixel) {
#if (LCD_MIRROR_X) || \
(LCD_MIRROR_Y) || \
(LCD_SWAP_XY) || \
(LCD_BITSPERPIXEL != 1)
case 1:
_DrawBitLine1BPP(x0, i+y0, pData, Diff, xsize, pTrans);
break;
#endif
#if (LCD_MAX_LOG_COLORS > 2)
case 2:
_DrawBitLine2BPP(x0, i+y0, pData, Diff, xsize, pTrans);
break;
#endif
#if (LCD_MAX_LOG_COLORS > 4)
case 4:
_DrawBitLine4BPP(x0, i+y0, pData, Diff, xsize, pTrans);
break;
#endif
case 8:
_DrawBitLine8BPP(x0, i+y0, pData, xsize, pTrans);
break;
}
pData += BytesPerLine;
}
#if (!LCD_MIRROR_X) && \
(!LCD_MIRROR_Y) && \
(!LCD_SWAP_XY) && \
(LCD_BITSPERPIXEL == 1)
}
#endif
}
/*********************************************************************
*
* LCD_L0_DrawBitmap
*/
#if LCD_SUPPORT_SETORG
void LCD_L0_SetOrg(int x, int y) {
int i;
int Off;
if (y>(LCD_VYSIZE_PHYS-LCD_YSIZE_PHYS))
y = LCD_VYSIZE_PHYS-LCD_YSIZE_PHYS;
Off = y*LCD_BYTESPERLINE+(x>>3);
for (i=0; i<LCD_BITSPERPIXEL; i++) {
LCD__apVRam[i] = & LCD_VRam[i][0] +Off;
}
}
#endif
/*********************************************************************
*
* LCD_L0_DrawBitmap
The following routines are implemented, but have no functionility
at this point. The reason is that these functions are supposed
to supervise the hardware, which for obvious reasons can not be
done in a simulation.
*/
#if LCD_VERIFY
int LCD_GetErrStat(void) {
return 0;
}
void LCD_ClrErrStat(void) {
}
int LCD_GetErrCnt (void) {
return 0;
}
#endif
/*********************************************************************
*
* LCD_L0_On
* LCD_L0_Off
These funtions are not implemented for this driver, they
have to be in the external modul which refreshes the LCD
regularily.
*/
#ifndef WIN32
void LCD_L0_Off (void) {
#ifdef LCD_OFF
LCD_OFF();
#endif
}
#endif
#ifndef WIN32
void LCD_L0_On (void) {
#ifdef LCD_ON
LCD_ON();
#endif
}
#endif
/*********************************************************************
*
* LCD_L0_ReInit
ReInit contains all of the code that can be re-executed at any point without
changing or even disturbing what can be seen on the LCD.
Note that it is also used as a subroutine by LCD_Init().
*/
void LCD_L0_ReInit(void) {}
/*********************************************************************
*
* LCD_L0_Init
*/
int LCD_L0_Init(void) {
LCD_L0_Off();
LCD_L0_ReInit();
LCD_L0_SetOrg(0,0);
/* Clear entire video RAM */
LCD_L0_On();
return 0;
}
/*********************************************************************
*
* LCD_L0_SetLUTEntry
*/
void LCD_L0_SetLUTEntry(U8 Pos, LCD_COLOR color) {
LCD_USE_PARA(Pos);
LCD_USE_PARA(color);
}
/*********************************************************************
*
* LCD_L0_GetDevFunc
*/
void * LCD_L0_GetDevFunc(int Index) {
GUI_USE_PARA(Index);
return NULL;
}
#else
void LCDMem_c(void);
void LCDMem_c(void) { } /* avoid empty object files */
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -