📄 lcdslin.c
字号:
*/
WriteTBit0:
if (pixels&(1<<7)) SETPIXEL(x+0, y, Index1);
if (!--xsize)
return;
WriteTBit1:
if (pixels&(1<<6)) SETPIXEL(x+1, y, Index1);
if (!--xsize)
return;
WriteTBit2:
if (pixels&(1<<5)) SETPIXEL(x+2, y, Index1);
if (!--xsize)
return;
WriteTBit3:
if (pixels&(1<<4)) SETPIXEL(x+3, y, Index1);
if (!--xsize)
return;
WriteTBit4:
if (pixels&(1<<3)) SETPIXEL(x+4, y, Index1);
if (!--xsize)
return;
WriteTBit5:
if (pixels&(1<<2)) SETPIXEL(x+5, y, Index1);
if (!--xsize)
return;
WriteTBit6:
if (pixels&(1<<1)) SETPIXEL(x+6, y, Index1);
if (!--xsize)
return;
WriteTBit7:
if (pixels&(1<<0)) SETPIXEL(x+7, y, Index1);
if (!--xsize)
return;
x+=8;
pixels = *(++p);
goto WriteTBit0;
/*
Write without transparency
*/
WriteBit0:
SETPIXEL(x+0, y, (pixels&(1<<7)) ? Index1 : Index0);
if (!--xsize)
return;
WriteBit1:
SETPIXEL(x+1, y, (pixels&(1<<6)) ? Index1 : Index0);
if (!--xsize)
return;
WriteBit2:
SETPIXEL(x+2, y, (pixels&(1<<5)) ? Index1 : Index0);
if (!--xsize)
return;
WriteBit3:
SETPIXEL(x+3, y, (pixels&(1<<4)) ? Index1 : Index0);
if (!--xsize)
return;
WriteBit4:
SETPIXEL(x+4, y, (pixels&(1<<3)) ? Index1 : Index0);
if (!--xsize)
return;
WriteBit5:
SETPIXEL(x+5, y, (pixels&(1<<2)) ? Index1 : Index0);
if (!--xsize)
return;
WriteBit6:
SETPIXEL(x+6, y, (pixels&(1<<1)) ? Index1 : Index0);
if (!--xsize)
return;
WriteBit7:
SETPIXEL(x+7, y, (pixels&(1<<0)) ? Index1 : Index0);
if (!--xsize)
return;
x+=8;
pixels = *(++p);
goto WriteBit0;
/*
Write XOR mode
*/
WriteXBit0:
if (pixels&(1<<7))
XORPIXEL(x+0, y);
if (!--xsize)
return;
WriteXBit1:
if (pixels&(1<<6))
XORPIXEL(x+1, y);
if (!--xsize)
return;
WriteXBit2:
if (pixels&(1<<5))
XORPIXEL(x+2, y);
if (!--xsize)
return;
WriteXBit3:
if (pixels&(1<<4))
XORPIXEL(x+3, y);
if (!--xsize)
return;
WriteXBit4:
if (pixels&(1<<3))
XORPIXEL(x+4, y);
if (!--xsize)
return;
WriteXBit5:
if (pixels&(1<<2))
XORPIXEL(x+5, y);
if (!--xsize)
return;
WriteXBit6:
if (pixels&(1<<1))
XORPIXEL(x+6, y);
if (!--xsize)
return;
WriteXBit7:
if (pixels&(1<<0))
XORPIXEL(x+7, y);
if (!--xsize)
return;
x+=8;
pixels = *(++p);
goto WriteXBit0;
}
#endif
/*
*********************************************************
* *
* Draw Bitmap 2 BPP *
* *
*********************************************************
*/
#if (LCD_MAX_LOG_COLORS > 2)
static void DrawBitLine2BPP(int x, int y, U8 const*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) switch (Diff&3) {
case 0:
goto WriteTBit0;
case 1:
goto WriteTBit1;
case 2:
goto WriteTBit2;
default:
goto WriteTBit3;
} else switch (Diff&3) {
case 0:
goto WriteBit0;
case 1:
goto WriteBit1;
case 2:
goto WriteBit2;
default:
goto WriteBit3;
}
/*
Write without transparency
*/
WriteBit0:
SETPIXEL(x+0, y, *(pTrans+(pixels>>6)));
if (!--xsize)
return;
WriteBit1:
SETPIXEL(x+1, y, *(pTrans+(3&(pixels>>4))));
if (!--xsize)
return;
WriteBit2:
SETPIXEL(x+2, y, *(pTrans+(3&(pixels>>2))));
if (!--xsize)
return;
WriteBit3:
SETPIXEL(x+3, y, *(pTrans+(3&(pixels))));
if (!--xsize)
return;
pixels = *(++p);
x+=4;
goto WriteBit0;
/*
Write with transparency
*/
WriteTBit0:
if (pixels&(3<<6))
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
/*
*********************************************************
* *
* Draw Bitmap 4 BPP *
* *
*********************************************************
*/
#if (LCD_MAX_LOG_COLORS > 4)
static void DrawBitLine4BPP(int x, int y, U8 const*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;
goto WriteTBit1;
} else {
if ((Diff&1) ==0)
goto WriteBit0;
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
/*
*********************************************************
* *
* Draw Bitmap 8 BPP (256 colors) *
* *
* Default (no optimization) *
* *
*********************************************************
*/
#if (LCD_MAX_LOG_COLORS > 16)
static void DrawBitLine8BPP(int x, int y, U8 const*p, int xsize, const LCD_PIXELINDEX*pTrans) {
LCD_PIXELINDEX pixel;
/*
Do x-Clipping
*/
if ((GUI_Context.DrawMode & LCD_DRAWMODE_TRANS)==0) {
while (xsize > 0) {
pixel = *p;
SETPIXEL(x+0, y, *(pTrans+pixel));
xsize--;
x++;
p++;
}
} else { /* Handle transparent bitmap */
while (xsize > 0) {
pixel = *p;
if (pixel)
SETPIXEL(x+0, y, *(pTrans+pixel));
xsize--;
x++;
p++;
}
}
}
#endif
/*
*********************************************************
* *
* Universal draw Bitmap routine *
* *
*********************************************************
*/
void LCD_L0_DrawBitmap (int x0, int y0,
int xsize, int ysize,
int BitsPerPixel,
int BytesPerLine,
const U8* pData, int Diff,
const LCD_PIXELINDEX* pTrans)
{
int i;
if (!pTrans)
pTrans = LCD_ConversionTable;
/*
Use DrawBitLineXBPP
*/
for (i=0; i<ysize; i++) {
switch (BitsPerPixel) {
case 1:
DrawBitLine1BPP(x0, i+y0, pData, Diff, xsize, pTrans);
break;
#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
#if (LCD_MAX_LOG_COLORS > 16)
case 8:
DrawBitLine8BPP(x0, i+y0, pData, xsize, pTrans);
break;
#endif
}
pData += BytesPerLine;
}
}
/********************************************************
*
* LCD_L0_SetOrg
*
*********************************************************
Purpose: Sets the original position of the virtual display.
Has no function at this point with the PC-driver.
*/
int OrgX, OrgY;
void LCD_L0_SetOrg(int x, int y) {
OrgX = x;
OrgY = y;
}
/*
*********************************************************
* *
* Support for verification *
* *
*********************************************************
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_SUPPORT_VERIFY
int LCD_GetErrStat(void) {
return 0;
}
void LCD_ClrErrStat(void) {
}
int LCD_GetErrCnt (void) {
return 0;
}
#endif
/*
*********************************************************
* *
* Copy rectangle *
* *
*********************************************************
This function is used for scrolling. If scrolling is not required
(as is sometimes the case) this routine can be eliminated via
configuration switch.
*/
#if LCD_SUPPORT_COPYRECT
static void Copy_Line (int y,int x0,int x1,int dx,int dy) {
if (dy >=0) {
int x;
for (x=x0; x<=x1; x++) {
_SetPixel(x+dx, y+dy, _GetPixel(x,y));
}
} else {
int x;
for (x=x1; x>=x0; x--) {
_SetPixel(x+dx, y+dy, _GetPixel(x,y));
}
}
}
void LCD_CopyRect (int x0, int y0, int x1, int y1, int dx, int dy) {
if (dy >=0) {
int y;
for (y=y0; y<=y1; y++) {
Copy_Line (y,x0,x1,dx,dy);
}
} else {
int y;
for (y=y1; y>=y0; y--) {
Copy_Line (y,x0,x1,dx,dy);
}
}
}
#endif
/*
*********************************************************
* *
* LCD_SetPaletteEntry *
* *
*********************************************************
*/
void LCD_L0_SetLUTEntry(U8 Pos, LCD_COLOR color) {
Pos=Pos;
color=color;
}
/*
*********************************************************
* *
* LCD_On *
* LCD_Off *
* *
*********************************************************
*/
void LCD_Off (void) {
#ifdef LCD_OFF
LCD_OFF();
#endif
}
void LCD_On (void) {
#ifdef LCD_ON
LCD_ON();
#endif
}
unsigned int LCD_L0_GetPixelIndex(int x, int y) {
return GETPIXEL(x,y);
}
/*
*********************************************************
* *
* LCD_Init : Init the display *
* *
*********************************************************
*/
int LCD_L0_Init(void) {
/* Controller independent */
#if LCD_WATCHDOG_TRIGGERCNT
WatchdogTriggerCnt =0;
#endif
/* Controller initialisation */
LCD_FirstInit();
LCD_L0_ReInit();
LCD_Adr=0xffff;
/* Init successfull */
return 0;
}
#else
void LCDSLin(void) { } /* avoid empty object files */
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -