📄 lcdmemc.c
字号:
********************************************************* * * * LCD_DrawHLine optimized * * * * Normal display, 6 Bpp * * * **********************************************************/#elif (LCD_OPTIMIZE) \ && (!LCD_MIRROR_X) \ && (!LCD_MIRROR_Y) \ && (!LCD_SWAP_XY) \ && (!LCD_SUPPORT_COMTRANS) \ && (!LCD_SUPPORT_SEGTRANS) \ && (LCD_BITSPERPIXEL == 6)static U8 MaskLeft[8][3] = { { 0xff, 0xff, 0xff}, { 0x1f, 0xff, 0xff}, { 0x03, 0xff, 0xff}, { 0x00, 0x7f, 0xff}, { 0x00, 0x0f, 0xff}, { 0x00, 0x01, 0xff}, { 0x00, 0x00, 0x3f}, { 0x00, 0x00, 0x07}/*!!!0x0e*/};static U8 MaskRight[8][3] = { { 0xe0, 0x00, 0x00}, { 0xfc, 0x00, 0x00}, { 0xff, 0x80, 0x00}, { 0xff, 0xf0, 0x00}, { 0xff, 0xfe, 0x00}, { 0xff, 0xff, 0xc0}, { 0xff, 0xff, 0xf8}, { 0xff, 0xff, 0xff}};static U8* GetMaskRight(int x) { return &MaskRight[(x&7)][0]; }static U8* GetMaskLeft (int x) { return &MaskLeft[(x&7)][0]; }void LCD_L0_DrawHLine (int x0, int y, int x1) { if (x0>x1) return; /* Check if nothing to draw */ if (GUI_Context.DrawMode & LCD_DRAWMODE_XOR) { while (x0 <= x1) { XORPIXEL(x0, y); x0++; } } else { int i; U8 LCD_VRAMTYPE* p0 = OFF2PTR_0(XY2OFF(x0,y)); U8 LCD_VRAMTYPE* p1 = OFF2PTR_1(XY2OFF(x0,y)); U8* pMask = GetMaskLeft(x0); U8 aData[2][3]; U8 aDataMasked[2][3]; U8 c0 = ((COLOR & 0x20) >> 3) + ((COLOR & 0x08) >> 2) + ((COLOR & 0x02) >> 1); U8 c1 = ((COLOR & 0x10) >> 2) + ((COLOR & 0x04) >> 1) + (COLOR & 0x01); aData[0][0] = (c0<<5)|(c0<<2)|(c0>>1); /* hhhgggff */ aData[0][1] = (c0<<7)|(c0<<4)|(c0<<1)|(c0>>2); /* feeedddc */ aData[0][2] = (c0<<6)|(c0<<3)|(c0); /* ccbbbaaa */ aData[1][0] = (c1<<5)|(c1<<2)|(c1>>1); /* hhhgggff */ aData[1][1] = (c1<<7)|(c1<<4)|(c1<<1)|(c1>>2); /* feeedddc */ aData[1][2] = (c1<<6)|(c1<<3)|(c1); /* ccbbbaaa */ for (i=0; i<3; i++, pMask++) { aDataMasked[0][i] = (*(p0+i) &~*pMask) | (aData[0][i] &*pMask); aDataMasked[1][i] = (*(p1+i) &~*pMask) | (aData[1][i] &*pMask); } if ((x0&~7) == (x1&~7)) { /* Do we have to clip left and right side ? */ U8* pMask = GetMaskRight(x1); *(p0+0) = (*(p0+0) &~*(pMask+0)) | (aDataMasked[0][0]&*(pMask+0)); *(p0+1) = (*(p0+1) &~*(pMask+1)) | (aDataMasked[0][1]&*(pMask+1)); *(p0+2) = (*(p0+2) &~*(pMask+2)) | (aDataMasked[0][2]&*(pMask+2)); *(p1+0) = (*(p1+0) &~*(pMask+0)) | (aDataMasked[1][0]&*(pMask+0)); *(p1+1) = (*(p1+1) &~*(pMask+1)) | (aDataMasked[1][1]&*(pMask+1)); *(p1+2) = (*(p1+2) &~*(pMask+2)) | (aDataMasked[1][2]&*(pMask+2)); return; } *p0 = aDataMasked[0][0]; *(p0+1) = aDataMasked[0][1]; *(p0+2) = aDataMasked[0][2]; p0+=3; *p1 = aDataMasked[1][0]; *(p1+1) = aDataMasked[1][1]; *(p1+2) = aDataMasked[1][2]; p1+=3; x0 = (x0&~7)+8;/* Draw optimized portion */ { int Len = (x1-x0+1)>>3; if (Len >0) { x0 += Len<<3; do { *p0 = aData[0][0]; *(p0+1) = aData[0][1]; *(p0+2) = aData[0][2]; p0+=3; *p1 = aData[1][0]; *(p1+1) = aData[1][1]; *(p1+2) = aData[1][2]; p1+=3; } while (--Len); } } /* Draw right portion */ if ((x1&7)!=7) { U8* pMask = GetMaskRight(x1); for (i=0; i<3; i++, pMask++) { *(p0+i) = (*(p0+i) &~*pMask) | (aData[0][i]&*pMask); *(p1+i) = (*(p1+i) &~*pMask) | (aData[1][i]&*pMask); } } }}/* ********************************************************* * * * LCD_DrawHLine * * * * Unoptimized * * * **********************************************************/#elsevoid LCD_L0_DrawHLine(int x0, int y, int x1) { if (x0>x1) return; /* Check if nothing to draw */ 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_DrawVLine * * * * Unoptimized * * * **********************************************************/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++; } }}void LCD_L0_FillRect(int x0, int y0, int x1, int y1) { for (; y0 <= y1; y0++) { LCD_L0_DrawHLine(x0,y0, x1); }}/* *************************************************************** * * * Internal bitmap routines * * * ****************************************************************//* ********************************************* * * * Draw Bitmap 1 BPP * * * **********************************************/static void DrawBitLine1BPP(int x, int y, U8 const*p, int Diff, int xsize, const LCD_PIXELINDEX*pTrans) { LCD_PIXELINDEX pixels; LCD_PIXELINDEX Index0 = *(pTrans+0); LCD_PIXELINDEX Index1 = *(pTrans+1);/*// Jump to right entry point*/ pixels = *p; switch (GUI_Context.DrawMode & (LCD_DRAWMODE_TRANS|LCD_DRAWMODE_XOR)) { case 0:#if (LCD_OPTIMIZE) \ && (!LCD_MIRROR_X) \ && (!LCD_MIRROR_Y) \ && (!LCD_SWAP_XY) \ && (!LCD_SUPPORT_COMTRANS) \ && (!LCD_SUPPORT_SEGTRANS) \ && ((LCD_BITSPERPIXEL == 3) || (LCD_BITSPERPIXEL == 6)) SetPosXY(x+(Diff&7),y);#endif switch (Diff&7) { case 0: goto WriteBit0; case 1: goto WriteBit1; case 2: goto WriteBit2; case 3: goto WriteBit3; case 4: goto WriteBit4; case 5: goto WriteBit5; case 6: goto WriteBit6; case 7: goto WriteBit7; } break; case LCD_DRAWMODE_TRANS: switch (Diff&7) { case 0: goto WriteTBit0; case 1: goto WriteTBit1; case 2: goto WriteTBit2; case 3: goto WriteTBit3; case 4: goto WriteTBit4; case 5: goto WriteTBit5; case 6: goto WriteTBit6; case 7: goto WriteTBit7; } break; case LCD_DRAWMODE_XOR: switch (Diff&7) { case 0: goto WriteXBit0; case 1: goto WriteXBit1; case 2: goto WriteXBit2; case 3: goto WriteXBit3; case 4: goto WriteXBit4; case 5: goto WriteXBit5; case 6: goto WriteXBit6; case 7: goto WriteXBit7; } }/* Write with transparency*/ 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*/#if (LCD_OPTIMIZE) \ && (!LCD_MIRROR_X) \ && (!LCD_MIRROR_Y) \ && (!LCD_SWAP_XY) \ && (!LCD_SUPPORT_COMTRANS) \ && (!LCD_SUPPORT_SEGTRANS) \ && ((LCD_BITSPERPIXEL == 3) || (LCD_BITSPERPIXEL == 6)) WriteBit0: SetNextPixel((pixels&(1<<7)) ? Index1 : Index0); if (!--xsize) return; WriteBit1: SetNextPixel((pixels&(1<<6)) ? Index1 : Index0); if (!--xsize) return; WriteBit2: SetNextPixel((pixels&(1<<5)) ? Index1 : Index0); if (!--xsize) return; WriteBit3: SetNextPixel((pixels&(1<<4)) ? Index1 : Index0); if (!--xsize) return; WriteBit4: SetNextPixel((pixels&(1<<3)) ? Index1 : Index0); if (!--xsize) return; WriteBit5: SetNextPixel((pixels&(1<<2)) ? Index1 : Index0); if (!--xsize) return; WriteBit6: SetNextPixel((pixels&(1<<1)) ? Index1 : Index0); if (!--xsize) return; WriteBit7: SetNextPixel((pixels&(1<<0)) ? Index1 : Index0); if (!--xsize) return; x+=8; pixels = *(++p); goto WriteBit0;#else 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;#endif/* 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);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -