mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-13 18:17:39 -04:00
More compact screendump routines for core and greylib. The core routine might be a little slower for vertically packed mono and greyscale displays, the greylib one should be faster in all cases. * Reduce stack usage of greyscale screendump on the Clip* Rename a macro in the bitmap LCD simulation.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19959 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
a12c2d59ad
commit
309a3c4590
3 changed files with 177 additions and 199 deletions
179
apps/misc.c
179
apps/misc.c
|
@ -425,21 +425,23 @@ static void (*screen_dump_hook)(int fh) = NULL;
|
||||||
|
|
||||||
void screen_dump(void)
|
void screen_dump(void)
|
||||||
{
|
{
|
||||||
int fh;
|
int fd, y;
|
||||||
char filename[MAX_PATH];
|
char filename[MAX_PATH];
|
||||||
int bx, by;
|
|
||||||
|
fb_data *src;
|
||||||
#if LCD_DEPTH == 1
|
#if LCD_DEPTH == 1
|
||||||
static unsigned char line_block[8][BMP_LINESIZE];
|
unsigned mask;
|
||||||
#elif LCD_DEPTH == 2
|
unsigned val;
|
||||||
#if LCD_PIXELFORMAT == HORIZONTAL_PACKING
|
#elif (LCD_DEPTH == 2) && (LCD_PIXELFORMAT != HORIZONTAL_PACKING)
|
||||||
static unsigned char line_block[BMP_LINESIZE];
|
int shift;
|
||||||
#elif LCD_PIXELFORMAT == VERTICAL_PACKING
|
unsigned val;
|
||||||
static unsigned char line_block[4][BMP_LINESIZE];
|
|
||||||
#elif LCD_PIXELFORMAT == VERTICAL_INTERLEAVED
|
|
||||||
static unsigned char line_block[8][BMP_LINESIZE];
|
|
||||||
#endif
|
#endif
|
||||||
#elif LCD_DEPTH == 16
|
#if LCD_DEPTH <= 8
|
||||||
static unsigned short line_block[BMP_LINESIZE/2];
|
unsigned char *dst, *dst_end;
|
||||||
|
unsigned char linebuf[BMP_LINESIZE];
|
||||||
|
#elif LCD_DEPTH <= 16
|
||||||
|
unsigned short *dst, *dst_end;
|
||||||
|
unsigned short linebuf[BMP_LINESIZE/2];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if CONFIG_RTC
|
#if CONFIG_RTC
|
||||||
|
@ -449,132 +451,97 @@ void screen_dump(void)
|
||||||
IF_CNFN_NUM_(, NULL));
|
IF_CNFN_NUM_(, NULL));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
fh = creat(filename);
|
fd = creat(filename);
|
||||||
if (fh < 0)
|
if (fd < 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (screen_dump_hook)
|
if (screen_dump_hook)
|
||||||
{
|
{
|
||||||
screen_dump_hook(fh);
|
screen_dump_hook(fd);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
write(fh, bmpheader, sizeof(bmpheader));
|
write(fd, bmpheader, sizeof(bmpheader));
|
||||||
|
|
||||||
/* BMP image goes bottom up */
|
/* BMP image goes bottom up */
|
||||||
|
for (y = LCD_HEIGHT - 1; y >= 0; y--)
|
||||||
|
{
|
||||||
|
memset(linebuf, 0, BMP_LINESIZE);
|
||||||
|
|
||||||
|
#if defined(HAVE_LCD_SPLIT) && (LCD_SPLIT_LINES == 2)
|
||||||
|
if (y == LCD_SPLIT_POS - 1)
|
||||||
|
{
|
||||||
|
write(fd, linebuf, BMP_LINESIZE);
|
||||||
|
write(fd, linebuf, BMP_LINESIZE);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
dst = linebuf;
|
||||||
|
|
||||||
#if LCD_DEPTH == 1
|
#if LCD_DEPTH == 1
|
||||||
for (by = LCD_FBHEIGHT - 1; by >= 0; by--)
|
dst_end = dst + LCD_WIDTH/2;
|
||||||
{
|
src = lcd_framebuffer[y >> 3];
|
||||||
unsigned char *src = &lcd_framebuffer[by][0];
|
mask = 1 << (y & 7);
|
||||||
unsigned char *dst = &line_block[7][0];
|
|
||||||
|
|
||||||
memset(line_block, 0, sizeof(line_block));
|
do
|
||||||
|
|
||||||
#ifdef HAVE_LCD_SPLIT
|
|
||||||
if (by == (LCD_SPLIT_POS/8 - 1))
|
|
||||||
write(fh, line_block, LCD_SPLIT_LINES * sizeof(line_block[0]));
|
|
||||||
#endif
|
|
||||||
for (bx = LCD_WIDTH/2; bx > 0; bx--)
|
|
||||||
{
|
{
|
||||||
unsigned char *dst_blk = dst++;
|
val = (*src++ & mask) ? 0x10 : 0;
|
||||||
unsigned src_byte0 = *src++ << 4;
|
val |= (*src++ & mask) ? 0x01 : 0;
|
||||||
unsigned src_byte1 = *src++;
|
|
||||||
int iy;
|
|
||||||
|
|
||||||
for (iy = 8; iy > 0; iy--)
|
|
||||||
{
|
|
||||||
*dst_blk = (src_byte0 & 0x10)
|
|
||||||
| (src_byte1 & 0x01)
|
|
||||||
#ifdef HAVE_LCD_SPLIT
|
#ifdef HAVE_LCD_SPLIT
|
||||||
| (by < (LCD_SPLIT_POS/8) ? 0x22 : 0)
|
if (y < LCD_SPLIT_POS)
|
||||||
|
val |= 0x22;
|
||||||
#endif
|
#endif
|
||||||
;
|
*dst++ = val;
|
||||||
src_byte0 >>= 1;
|
|
||||||
src_byte1 >>= 1;
|
|
||||||
dst_blk -= BMP_LINESIZE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
while (dst < dst_end);
|
||||||
|
|
||||||
write(fh, line_block, sizeof(line_block));
|
|
||||||
}
|
|
||||||
#elif LCD_DEPTH == 2
|
#elif LCD_DEPTH == 2
|
||||||
|
dst_end = dst + LCD_WIDTH/2;
|
||||||
|
|
||||||
#if LCD_PIXELFORMAT == HORIZONTAL_PACKING
|
#if LCD_PIXELFORMAT == HORIZONTAL_PACKING
|
||||||
for (by = LCD_FBHEIGHT - 1; by >= 0; by--)
|
src = lcd_framebuffer[y];
|
||||||
{
|
|
||||||
unsigned char *src = &lcd_framebuffer[by][0];
|
|
||||||
unsigned char *dst = line_block;
|
|
||||||
|
|
||||||
memset(line_block, 0, sizeof(line_block));
|
do
|
||||||
for (bx = LCD_FBWIDTH; bx > 0; bx--)
|
|
||||||
{
|
{
|
||||||
unsigned src_byte = *src++;
|
unsigned data = *src++;
|
||||||
|
|
||||||
*dst++ = ((src_byte >> 2) & 0x30) | ((src_byte >> 4) & 0x03);
|
*dst++ = (data >> 2) & 0x30 | (data >> 4) & 0x03;
|
||||||
*dst++ = ((src_byte << 2) & 0x30) | (src_byte & 0x03);
|
*dst++ = (data << 2) & 0x30 | data & 0x03;
|
||||||
}
|
}
|
||||||
|
while (dst < dst_end);
|
||||||
|
|
||||||
write(fh, line_block, sizeof(line_block));
|
|
||||||
}
|
|
||||||
#elif LCD_PIXELFORMAT == VERTICAL_PACKING
|
#elif LCD_PIXELFORMAT == VERTICAL_PACKING
|
||||||
for (by = LCD_FBHEIGHT - 1; by >= 0; by--)
|
src = lcd_framebuffer[y >> 2];
|
||||||
{
|
shift = 2 * (y & 3);
|
||||||
unsigned char *src = &lcd_framebuffer[by][0];
|
|
||||||
unsigned char *dst = &line_block[3][0];
|
|
||||||
|
|
||||||
memset(line_block, 0, sizeof(line_block));
|
do
|
||||||
for (bx = LCD_WIDTH/2; bx > 0; bx--)
|
|
||||||
{
|
{
|
||||||
unsigned char *dst_blk = dst++;
|
val = ((*src++ >> shift) & 3) << 4;
|
||||||
unsigned src_byte0 = *src++ << 4;
|
val |= ((*src++ >> shift) & 3);
|
||||||
unsigned src_byte1 = *src++;
|
*dst++ = val;
|
||||||
int iy;
|
|
||||||
|
|
||||||
for (iy = 4; iy > 0; iy--)
|
|
||||||
{
|
|
||||||
*dst_blk = (src_byte0 & 0x30) | (src_byte1 & 0x03);
|
|
||||||
src_byte0 >>= 2;
|
|
||||||
src_byte1 >>= 2;
|
|
||||||
dst_blk -= BMP_LINESIZE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
while (dst < dst_end);
|
||||||
|
|
||||||
write(fh, line_block, sizeof(line_block));
|
|
||||||
}
|
|
||||||
#elif LCD_PIXELFORMAT == VERTICAL_INTERLEAVED
|
#elif LCD_PIXELFORMAT == VERTICAL_INTERLEAVED
|
||||||
for (by = LCD_FBHEIGHT - 1; by >= 0; by--)
|
src = lcd_framebuffer[y >> 3];
|
||||||
{
|
shift = y & 7;
|
||||||
const fb_data *src = &lcd_framebuffer[by][0];
|
|
||||||
unsigned char *dst = &line_block[7][0];
|
|
||||||
|
|
||||||
memset(line_block, 0, sizeof(line_block));
|
do
|
||||||
for (bx = LCD_WIDTH/2; bx > 0; bx--)
|
|
||||||
{
|
{
|
||||||
unsigned char *dst_blk = dst++;
|
unsigned data = (*src++ >> shift) & 0x0101;
|
||||||
unsigned src_data0 = *src++ << 4;
|
|
||||||
unsigned src_data1 = *src++;
|
|
||||||
int iy;
|
|
||||||
|
|
||||||
for (iy = 8; iy > 0; iy--)
|
val = (((data >> 7) | data) & 3) << 4;
|
||||||
{
|
data = (*src++ >> shift) & 0x0101;
|
||||||
*dst_blk = (src_data0 & 0x10) | (src_data1 & 0x01)
|
val |= ((data >> 7) | data) & 3;
|
||||||
| ((src_data0 & 0x1000) | (src_data1 & 0x0100)) >> 7;
|
*dst++ = val;
|
||||||
src_data0 >>= 1;
|
|
||||||
src_data1 >>= 1;
|
|
||||||
dst_blk -= BMP_LINESIZE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
while (dst < dst_end);
|
||||||
|
|
||||||
write(fh, line_block, sizeof(line_block));
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
#elif LCD_DEPTH == 16
|
#elif LCD_DEPTH == 16
|
||||||
for (by = LCD_HEIGHT - 1; by >= 0; by--)
|
dst_end = dst + LCD_WIDTH;
|
||||||
{
|
src = lcd_framebuffer[y];
|
||||||
unsigned short *src = &lcd_framebuffer[by][0];
|
|
||||||
unsigned short *dst = line_block;
|
do
|
||||||
|
|
||||||
memset(line_block, 0, sizeof(line_block));
|
|
||||||
for (bx = LCD_WIDTH; bx > 0; bx--)
|
|
||||||
{
|
{
|
||||||
#if (LCD_PIXELFORMAT == RGB565SWAPPED)
|
#if (LCD_PIXELFORMAT == RGB565SWAPPED)
|
||||||
/* iPod LCD data is big endian although the CPU is not */
|
/* iPod LCD data is big endian although the CPU is not */
|
||||||
|
@ -583,13 +550,13 @@ void screen_dump(void)
|
||||||
*dst++ = htole16(*src++);
|
*dst++ = htole16(*src++);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
while (dst < dst_end);
|
||||||
|
|
||||||
write(fh, line_block, sizeof(line_block));
|
|
||||||
}
|
|
||||||
#endif /* LCD_DEPTH */
|
#endif /* LCD_DEPTH */
|
||||||
|
write(fd, linebuf, BMP_LINESIZE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
close(fd);
|
||||||
close(fh);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void screen_dump_set_hook(void (*hook)(int fh))
|
void screen_dump_set_hook(void (*hook)(int fh))
|
||||||
|
|
|
@ -708,10 +708,10 @@ void grey_deferred_lcd_update(void)
|
||||||
/*** Screenshot ***/
|
/*** Screenshot ***/
|
||||||
|
|
||||||
#ifdef HAVE_LCD_SPLIT
|
#ifdef HAVE_LCD_SPLIT
|
||||||
#define GRADIENT_MAX 127
|
#define NUM_SHADES 128
|
||||||
#define BMP_NUMCOLORS 256
|
#define BMP_NUMCOLORS 256
|
||||||
#else
|
#else
|
||||||
#define GRADIENT_MAX 128
|
#define NUM_SHADES 129
|
||||||
#define BMP_NUMCOLORS 129
|
#define BMP_NUMCOLORS 129
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -754,7 +754,7 @@ static const unsigned char colorindex[4] = {128, 85, 43, 0};
|
||||||
static void grey_screendump_hook(int fd)
|
static void grey_screendump_hook(int fd)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int x, y, gx, gy;
|
int y, gx, gy;
|
||||||
#if LCD_PIXELFORMAT == VERTICAL_PACKING
|
#if LCD_PIXELFORMAT == VERTICAL_PACKING
|
||||||
#if LCD_DEPTH == 1
|
#if LCD_DEPTH == 1
|
||||||
unsigned val;
|
unsigned val;
|
||||||
|
@ -766,45 +766,50 @@ static void grey_screendump_hook(int fd)
|
||||||
unsigned data;
|
unsigned data;
|
||||||
int shift;
|
int shift;
|
||||||
#endif /* LCD_PIXELFORMAT */
|
#endif /* LCD_PIXELFORMAT */
|
||||||
fb_data *lcdptr;
|
fb_data *src;
|
||||||
unsigned char *clut_entry;
|
unsigned char *gsrc;
|
||||||
unsigned char linebuf[MAX(4*BMP_NUMCOLORS,BMP_LINESIZE)];
|
unsigned char *dst, *dst_end;
|
||||||
|
unsigned char linebuf[MAX(4*NUM_SHADES,BMP_LINESIZE)];
|
||||||
|
|
||||||
rb->write(fd, bmpheader, sizeof(bmpheader)); /* write header */
|
rb->write(fd, bmpheader, sizeof(bmpheader)); /* write header */
|
||||||
|
|
||||||
/* build clut */
|
/* build clut */
|
||||||
rb->memset(linebuf, 0, 4*BMP_NUMCOLORS);
|
rb->memset(linebuf, 0, 4*NUM_SHADES);
|
||||||
clut_entry = linebuf;
|
dst = linebuf;
|
||||||
|
|
||||||
for (i = 0; i <= GRADIENT_MAX; i++)
|
for (i = 0; i < NUM_SHADES; i++)
|
||||||
{
|
{
|
||||||
*clut_entry++ = (_GREY_MULUQ(BLUE_CMP(LCD_BL_BRIGHTCOLOR)
|
*dst++ = (_GREY_MULUQ(BLUE_CMP(LCD_BL_BRIGHTCOLOR)
|
||||||
-BLUE_CMP(LCD_BL_DARKCOLOR), i) >> 7)
|
-BLUE_CMP(LCD_BL_DARKCOLOR), i) >> 7)
|
||||||
+ BLUE_CMP(LCD_BL_DARKCOLOR);
|
+ BLUE_CMP(LCD_BL_DARKCOLOR);
|
||||||
*clut_entry++ = (_GREY_MULUQ(GREEN_CMP(LCD_BL_BRIGHTCOLOR)
|
*dst++ = (_GREY_MULUQ(GREEN_CMP(LCD_BL_BRIGHTCOLOR)
|
||||||
-GREEN_CMP(LCD_BL_DARKCOLOR), i) >> 7)
|
-GREEN_CMP(LCD_BL_DARKCOLOR), i) >> 7)
|
||||||
+ GREEN_CMP(LCD_BL_DARKCOLOR);
|
+ GREEN_CMP(LCD_BL_DARKCOLOR);
|
||||||
*clut_entry++ = (_GREY_MULUQ(RED_CMP(LCD_BL_BRIGHTCOLOR)
|
*dst++ = (_GREY_MULUQ(RED_CMP(LCD_BL_BRIGHTCOLOR)
|
||||||
-RED_CMP(LCD_BL_DARKCOLOR), i) >> 7)
|
-RED_CMP(LCD_BL_DARKCOLOR), i) >> 7)
|
||||||
+ RED_CMP(LCD_BL_DARKCOLOR);
|
+ RED_CMP(LCD_BL_DARKCOLOR);
|
||||||
clut_entry++;
|
dst++;
|
||||||
}
|
}
|
||||||
|
rb->write(fd, linebuf, 4*NUM_SHADES);
|
||||||
|
|
||||||
#ifdef HAVE_LCD_SPLIT
|
#ifdef HAVE_LCD_SPLIT
|
||||||
for (i = 0; i <= GRADIENT_MAX; i++)
|
dst = linebuf;
|
||||||
|
|
||||||
|
for (i = 0; i <= NUM_SHADES; i++)
|
||||||
{
|
{
|
||||||
*clut_entry++ = (_GREY_MULUQ(BLUE_CMP(LCD_BL_BRIGHTCOLOR_2)
|
*dst++ = (_GREY_MULUQ(BLUE_CMP(LCD_BL_BRIGHTCOLOR_2)
|
||||||
-BLUE_CMP(LCD_BL_DARKCOLOR_2), i) >> 7)
|
-BLUE_CMP(LCD_BL_DARKCOLOR_2), i) >> 7)
|
||||||
+ BLUE_CMP(LCD_BL_DARKCOLOR_2);
|
+ BLUE_CMP(LCD_BL_DARKCOLOR_2);
|
||||||
*clut_entry++ = (_GREY_MULUQ(GREEN_CMP(LCD_BL_BRIGHTCOLOR_2)
|
*dst++ = (_GREY_MULUQ(GREEN_CMP(LCD_BL_BRIGHTCOLOR_2)
|
||||||
-GREEN_CMP(LCD_BL_DARKCOLOR_2), i) >> 7)
|
-GREEN_CMP(LCD_BL_DARKCOLOR_2), i) >> 7)
|
||||||
+ GREEN_CMP(LCD_BL_DARKCOLOR_2);
|
+ GREEN_CMP(LCD_BL_DARKCOLOR_2);
|
||||||
*clut_entry++ = (_GREY_MULUQ(RED_CMP(LCD_BL_BRIGHTCOLOR_2)
|
*dst++ = (_GREY_MULUQ(RED_CMP(LCD_BL_BRIGHTCOLOR_2)
|
||||||
-RED_CMP(LCD_BL_DARKCOLOR_2), i) >> 7)
|
-RED_CMP(LCD_BL_DARKCOLOR_2), i) >> 7)
|
||||||
+ RED_CMP(LCD_BL_DARKCOLOR_2);
|
+ RED_CMP(LCD_BL_DARKCOLOR_2);
|
||||||
clut_entry++;
|
dst++;
|
||||||
}
|
}
|
||||||
|
rb->write(fd, linebuf, 4*NUM_SHADES);
|
||||||
#endif
|
#endif
|
||||||
rb->write(fd, linebuf, 4*BMP_NUMCOLORS);
|
|
||||||
|
|
||||||
/* BMP image goes bottom -> top */
|
/* BMP image goes bottom -> top */
|
||||||
for (y = LCD_HEIGHT - 1; y >= 0; y--)
|
for (y = LCD_HEIGHT - 1; y >= 0; y--)
|
||||||
|
@ -819,116 +824,122 @@ static void grey_screendump_hook(int fd)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
dst = linebuf;
|
||||||
|
dst_end = dst + LCD_WIDTH;
|
||||||
gy = y - _grey_info.y;
|
gy = y - _grey_info.y;
|
||||||
|
gx = -_grey_info.x;
|
||||||
|
|
||||||
#if LCD_PIXELFORMAT == HORIZONTAL_PACKING
|
#if LCD_PIXELFORMAT == HORIZONTAL_PACKING
|
||||||
|
gsrc = _grey_info.values + _GREY_MULUQ(_grey_info.width, gy);
|
||||||
|
|
||||||
#if LCD_DEPTH == 2
|
#if LCD_DEPTH == 2
|
||||||
lcdptr = rb->lcd_framebuffer + _GREY_MULUQ(LCD_FBWIDTH, y);
|
src = rb->lcd_framebuffer + _GREY_MULUQ(LCD_FBWIDTH, y);
|
||||||
|
|
||||||
for (x = 0; x < LCD_WIDTH; x += 4)
|
do
|
||||||
{
|
{
|
||||||
gx = x - _grey_info.x;
|
|
||||||
|
|
||||||
if (((unsigned)gy < (unsigned)_grey_info.height)
|
if (((unsigned)gy < (unsigned)_grey_info.height)
|
||||||
&& ((unsigned)gx < (unsigned)_grey_info.width))
|
&& ((unsigned)gx < (unsigned)_grey_info.width))
|
||||||
{
|
{
|
||||||
unsigned char *src = _grey_info.values
|
*dst++ = *gsrc++;
|
||||||
+ _GREY_MULUQ(_grey_info.width, gy) + gx;
|
*dst++ = *gsrc++;
|
||||||
for (i = 0; i < 4; i++)
|
*dst++ = *gsrc++;
|
||||||
linebuf[x + i] = *src++;
|
*dst++ = *gsrc++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
unsigned data = *lcdptr;
|
unsigned data = *src;
|
||||||
linebuf[x] = colorindex[(data >> 6) & 3];
|
*dst++ = colorindex[(data >> 6) & 3];
|
||||||
linebuf[x + 1] = colorindex[(data >> 4) & 3];
|
*dst++ = colorindex[(data >> 4) & 3];
|
||||||
linebuf[x + 2] = colorindex[(data >> 2) & 3];
|
*dst++ = colorindex[(data >> 2) & 3];
|
||||||
linebuf[x + 3] = colorindex[data & 3];
|
*dst++ = colorindex[data & 3];
|
||||||
}
|
}
|
||||||
lcdptr++;
|
gx++, src++;
|
||||||
}
|
}
|
||||||
|
while (dst < dst_end);
|
||||||
|
|
||||||
#endif /* LCD_DEPTH */
|
#endif /* LCD_DEPTH */
|
||||||
#elif LCD_PIXELFORMAT == VERTICAL_PACKING
|
#elif LCD_PIXELFORMAT == VERTICAL_PACKING
|
||||||
|
gsrc = _grey_info.values + (~gy & _GREY_BMASK)
|
||||||
|
+ _GREY_MULUQ(_grey_info.width, gy & ~_GREY_BMASK);
|
||||||
|
|
||||||
#if LCD_DEPTH == 1
|
#if LCD_DEPTH == 1
|
||||||
mask = 1 << (y & 7);
|
mask = 1 << (y & 7);
|
||||||
lcdptr = rb->lcd_framebuffer + _GREY_MULUQ(LCD_WIDTH, y >> 3);
|
src = rb->lcd_framebuffer + _GREY_MULUQ(LCD_WIDTH, y >> 3);
|
||||||
|
|
||||||
for (x = 0; x < LCD_WIDTH; x++)
|
do
|
||||||
{
|
{
|
||||||
gx = x - _grey_info.x;
|
|
||||||
|
|
||||||
if (((unsigned)gy < (unsigned)_grey_info.height)
|
if (((unsigned)gy < (unsigned)_grey_info.height)
|
||||||
&& ((unsigned)gx < (unsigned)_grey_info.width))
|
&& ((unsigned)gx < (unsigned)_grey_info.width))
|
||||||
{
|
{
|
||||||
val = _grey_info.values[_GREY_MULUQ(_grey_info.width,
|
val = *gsrc;
|
||||||
gy & ~_GREY_BMASK)
|
|
||||||
+ (gx << _GREY_BSHIFT)
|
|
||||||
+ (~gy & _GREY_BMASK)];
|
|
||||||
#ifdef HAVE_LCD_SPLIT
|
#ifdef HAVE_LCD_SPLIT
|
||||||
val -= val >> 7;
|
val -= val >> 7;
|
||||||
#endif
|
#endif
|
||||||
|
gsrc += _GREY_BSIZE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#ifdef HAVE_NEGATIVE_LCD
|
#ifdef HAVE_NEGATIVE_LCD
|
||||||
val = (*lcdptr & mask) ? GRADIENT_MAX : 0;
|
val = (*src & mask) ? (NUM_SHADES-1) : 0;
|
||||||
#else
|
#else
|
||||||
val = (*lcdptr & mask) ? 0 : GRADIENT_MAX;
|
val = (*src & mask) ? 0 : (NUM_SHADES-1);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#ifdef HAVE_LCD_SPLIT
|
#ifdef HAVE_LCD_SPLIT
|
||||||
if (y < LCD_SPLIT_POS)
|
if (y < LCD_SPLIT_POS)
|
||||||
val |= 0x80;
|
val |= 0x80;
|
||||||
#endif
|
#endif
|
||||||
linebuf[x] = val;
|
*dst++ = val;
|
||||||
lcdptr++;
|
gx++, src++;
|
||||||
}
|
}
|
||||||
|
while (dst < dst_end);
|
||||||
|
|
||||||
#elif LCD_DEPTH == 2
|
#elif LCD_DEPTH == 2
|
||||||
shift = 2 * (y & 3);
|
shift = 2 * (y & 3);
|
||||||
lcdptr = rb->lcd_framebuffer + _GREY_MULUQ(LCD_WIDTH, y >> 2);
|
src = rb->lcd_framebuffer + _GREY_MULUQ(LCD_WIDTH, y >> 2);
|
||||||
|
|
||||||
for (x = 0; x < LCD_WIDTH; x++)
|
do
|
||||||
{
|
{
|
||||||
gx = x - _grey_info.x;
|
|
||||||
|
|
||||||
if (((unsigned)gy < (unsigned)_grey_info.height)
|
if (((unsigned)gy < (unsigned)_grey_info.height)
|
||||||
&& ((unsigned)gx < (unsigned)_grey_info.width))
|
&& ((unsigned)gx < (unsigned)_grey_info.width))
|
||||||
{
|
{
|
||||||
linebuf[x] = _grey_info.values[_GREY_MULUQ(_grey_info.width,
|
*dst++ = *gsrc;
|
||||||
gy & ~_GREY_BMASK)
|
gsrc += _GREY_BSIZE;
|
||||||
+ (gx << _GREY_BSHIFT)
|
|
||||||
+ (~gy & _GREY_BMASK)];
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
linebuf[x] = colorindex[(*lcdptr >> shift) & 3];
|
*dst++ = colorindex[(*src >> shift) & 3];
|
||||||
}
|
}
|
||||||
lcdptr++;
|
gx++, src++;
|
||||||
}
|
}
|
||||||
|
while (dst < dst_end);
|
||||||
|
|
||||||
#endif /* LCD_DEPTH */
|
#endif /* LCD_DEPTH */
|
||||||
#elif LCD_PIXELFORMAT == VERTICAL_INTERLEAVED
|
#elif LCD_PIXELFORMAT == VERTICAL_INTERLEAVED
|
||||||
|
gsrc = _grey_info.values + (~gy & _GREY_BMASK)
|
||||||
|
+ _GREY_MULUQ(_grey_info.width, gy & ~_GREY_BMASK);
|
||||||
|
|
||||||
#if LCD_DEPTH == 2
|
#if LCD_DEPTH == 2
|
||||||
shift = y & 7;
|
shift = y & 7;
|
||||||
lcdptr = rb->lcd_framebuffer + _GREY_MULUQ(LCD_WIDTH, y >> 3);
|
src = rb->lcd_framebuffer + _GREY_MULUQ(LCD_WIDTH, y >> 3);
|
||||||
|
|
||||||
for (x = 0; x < LCD_WIDTH; x++)
|
do
|
||||||
{
|
{
|
||||||
gx = x - _grey_info.x;
|
|
||||||
|
|
||||||
if (((unsigned)gy < (unsigned)_grey_info.height)
|
if (((unsigned)gy < (unsigned)_grey_info.height)
|
||||||
&& ((unsigned)gx < (unsigned)_grey_info.width))
|
&& ((unsigned)gx < (unsigned)_grey_info.width))
|
||||||
{
|
{
|
||||||
linebuf[x] = _grey_info.values[_GREY_MULUQ(_grey_info.width,
|
*dst++ = *gsrc;
|
||||||
gy & ~_GREY_BMASK)
|
gsrc += _GREY_BSIZE;
|
||||||
+ (gx << _GREY_BSHIFT)
|
|
||||||
+ (~gy & _GREY_BMASK)];
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
data = (*lcdptr >> shift) & 0x0101;
|
data = (*src >> shift) & 0x0101;
|
||||||
linebuf[x] = colorindex[((data >> 7) | data) & 3];
|
*dst++ = colorindex[((data >> 7) | data) & 3];
|
||||||
}
|
}
|
||||||
lcdptr++;
|
gx++, src++;
|
||||||
}
|
}
|
||||||
|
while (dst < dst_end);
|
||||||
|
|
||||||
#endif /* LCD_DEPTH */
|
#endif /* LCD_DEPTH */
|
||||||
#endif /* LCD_PIXELFORMAT */
|
#endif /* LCD_PIXELFORMAT */
|
||||||
|
|
||||||
|
|
|
@ -59,9 +59,9 @@ SDL_Color lcd_color2_bright = {RED_CMP(LCD_BRIGHTCOLOR_2),
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_LCD_SPLIT
|
#ifdef HAVE_LCD_SPLIT
|
||||||
#define GRADIENT_MAX 127
|
#define NUM_SHADES 128
|
||||||
#else
|
#else
|
||||||
#define GRADIENT_MAX 128
|
#define NUM_SHADES 129
|
||||||
#endif
|
#endif
|
||||||
#endif /* LCD_DEPTH <= 8 */
|
#endif /* LCD_DEPTH <= 8 */
|
||||||
|
|
||||||
|
@ -78,9 +78,9 @@ static unsigned long get_lcd_pixel(int x, int y)
|
||||||
{
|
{
|
||||||
#if LCD_DEPTH == 1
|
#if LCD_DEPTH == 1
|
||||||
#ifdef HAVE_NEGATIVE_LCD
|
#ifdef HAVE_NEGATIVE_LCD
|
||||||
return (lcd_framebuffer[y/8][x] & (1 << (y & 7))) ? GRADIENT_MAX : 0;
|
return (lcd_framebuffer[y/8][x] & (1 << (y & 7))) ? (NUM_SHADES-1) : 0;
|
||||||
#else
|
#else
|
||||||
return (lcd_framebuffer[y/8][x] & (1 << (y & 7))) ? 0 : GRADIENT_MAX;
|
return (lcd_framebuffer[y/8][x] & (1 << (y & 7))) ? 0 : (NUM_SHADES-1);
|
||||||
#endif
|
#endif
|
||||||
#elif LCD_DEPTH == 2
|
#elif LCD_DEPTH == 2
|
||||||
#if LCD_PIXELFORMAT == HORIZONTAL_PACKING
|
#if LCD_PIXELFORMAT == HORIZONTAL_PACKING
|
||||||
|
@ -122,17 +122,17 @@ void sim_backlight(int value)
|
||||||
#if LCD_DEPTH <= 8
|
#if LCD_DEPTH <= 8
|
||||||
if (value > 0) {
|
if (value > 0) {
|
||||||
sdl_set_gradient(lcd_surface, &lcd_bl_color_dark,
|
sdl_set_gradient(lcd_surface, &lcd_bl_color_dark,
|
||||||
&lcd_bl_color_bright, 0, GRADIENT_MAX+1);
|
&lcd_bl_color_bright, 0, NUM_SHADES);
|
||||||
#ifdef HAVE_LCD_SPLIT
|
#ifdef HAVE_LCD_SPLIT
|
||||||
sdl_set_gradient(lcd_surface, &lcd_bl_color2_dark,
|
sdl_set_gradient(lcd_surface, &lcd_bl_color2_dark,
|
||||||
&lcd_bl_color2_bright, GRADIENT_MAX+1, GRADIENT_MAX+1);
|
&lcd_bl_color2_bright, NUM_SHADES, NUM_SHADES);
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
sdl_set_gradient(lcd_surface, &lcd_color_dark,
|
sdl_set_gradient(lcd_surface, &lcd_color_dark,
|
||||||
&lcd_color_bright, 0, GRADIENT_MAX+1);
|
&lcd_color_bright, 0, NUM_SHADES);
|
||||||
#ifdef HAVE_LCD_SPLIT
|
#ifdef HAVE_LCD_SPLIT
|
||||||
sdl_set_gradient(lcd_surface, &lcd_color2_dark,
|
sdl_set_gradient(lcd_surface, &lcd_color2_dark,
|
||||||
&lcd_color2_bright, GRADIENT_MAX+1, GRADIENT_MAX+1);
|
&lcd_color2_bright, NUM_SHADES, NUM_SHADES);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
sdl_gui_update(lcd_surface, 0, 0, SIM_LCD_WIDTH, SIM_LCD_HEIGHT,
|
sdl_gui_update(lcd_surface, 0, 0, SIM_LCD_WIDTH, SIM_LCD_HEIGHT,
|
||||||
|
@ -162,17 +162,17 @@ void sim_lcd_init(void)
|
||||||
#if LCD_DEPTH <= 8
|
#if LCD_DEPTH <= 8
|
||||||
#ifdef HAVE_BACKLIGHT
|
#ifdef HAVE_BACKLIGHT
|
||||||
sdl_set_gradient(lcd_surface, &lcd_bl_color_dark,
|
sdl_set_gradient(lcd_surface, &lcd_bl_color_dark,
|
||||||
&lcd_bl_color_bright, 0, GRADIENT_MAX+1);
|
&lcd_bl_color_bright, 0, NUM_SHADES);
|
||||||
#ifdef HAVE_LCD_SPLIT
|
#ifdef HAVE_LCD_SPLIT
|
||||||
sdl_set_gradient(lcd_surface, &lcd_bl_color2_dark,
|
sdl_set_gradient(lcd_surface, &lcd_bl_color2_dark,
|
||||||
&lcd_bl_color2_bright, GRADIENT_MAX+1, GRADIENT_MAX+1);
|
&lcd_bl_color2_bright, NUM_SHADES, NUM_SHADES);
|
||||||
#endif
|
#endif
|
||||||
#else /* !HAVE_BACKLIGHT */
|
#else /* !HAVE_BACKLIGHT */
|
||||||
sdl_set_gradient(lcd_surface, &lcd_color_dark,
|
sdl_set_gradient(lcd_surface, &lcd_color_dark,
|
||||||
&lcd_color_bright, 0, GRADIENT_MAX+1);
|
&lcd_color_bright, 0, NUM_SHADES);
|
||||||
#ifdef HAVE_LCD_SPLIT
|
#ifdef HAVE_LCD_SPLIT
|
||||||
sdl_set_gradient(lcd_surface, &lcd_color2_dark,
|
sdl_set_gradient(lcd_surface, &lcd_color2_dark,
|
||||||
&lcd_color2_bright, GRADIENT_MAX+1, GRADIENT_MAX+1);
|
&lcd_color2_bright, NUM_SHADES, NUM_SHADES);
|
||||||
#endif
|
#endif
|
||||||
#endif /* !HAVE_BACKLIGHT */
|
#endif /* !HAVE_BACKLIGHT */
|
||||||
#endif /* LCD_DEPTH < 8 */
|
#endif /* LCD_DEPTH < 8 */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue