summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/misc.c84
-rw-r--r--apps/misc.h12
-rw-r--r--apps/plugin.c2
-rw-r--r--apps/plugin.h6
-rw-r--r--apps/plugins/lib/grey_core.c153
5 files changed, 146 insertions, 111 deletions
diff --git a/apps/misc.c b/apps/misc.c
index 6e871ac..43dfd45 100644
--- a/apps/misc.c
+++ b/apps/misc.c
@@ -344,19 +344,20 @@ int fast_readline(int fd, char *buf, int buf_size, void *parameters,
#if LCD_DEPTH == 16
#define BMP_COMPRESSION 3 /* BI_BITFIELDS */
#define BMP_NUMCOLORS 3
-#else
+#else /* LCD_DEPTH != 16 */
#define BMP_COMPRESSION 0 /* BI_RGB */
#if LCD_DEPTH <= 8
-#define BMP_NUMCOLORS (1 << LCD_DEPTH)
+#ifdef HAVE_LCD_SPLIT
+#define BMP_NUMCOLORS (2 << LCD_DEPTH)
#else
-#define BMP_NUMCOLORS 0
-#endif
+#define BMP_NUMCOLORS (1 << LCD_DEPTH)
#endif
+#else /* LCD_DEPTH > 8 */
+#define BMP_NUMCOLORS 0
+#endif /* LCD_DEPTH > 8 */
+#endif /* LCD_DEPTH != 16 */
-#if LCD_DEPTH == 1
-#define BMP_BPP 1
-#define BMP_LINESIZE ((LCD_WIDTH/8 + 3) & ~3)
-#elif LCD_DEPTH <= 4
+#if LCD_DEPTH <= 4
#define BMP_BPP 4
#define BMP_LINESIZE ((LCD_WIDTH/2 + 3) & ~3)
#elif LCD_DEPTH <= 8
@@ -386,7 +387,7 @@ static const unsigned char bmpheader[] =
0x28, 0x00, 0x00, 0x00, /* Size of (2nd) header */
LE32_CONST(LCD_WIDTH), /* Width in pixels */
- LE32_CONST(LCD_HEIGHT), /* Height in pixels */
+ LE32_CONST(LCD_HEIGHT+LCD_SPLIT_LINES), /* Height in pixels */
0x01, 0x00, /* Number of planes (always 1) */
LE16_CONST(BMP_BPP), /* Bits per pixel 1/4/8/16/24 */
LE32_CONST(BMP_COMPRESSION),/* Compression mode */
@@ -397,22 +398,26 @@ static const unsigned char bmpheader[] =
LE32_CONST(BMP_NUMCOLORS), /* Number of important colours */
#if LCD_DEPTH == 1
-#ifdef MROBE_100
- 2, 2, 94, 0x00, /* Colour #0 */
- 3, 6, 241, 0x00 /* Colour #1 */
-#else
- 0x90, 0xee, 0x90, 0x00, /* Colour #0 */
- 0x00, 0x00, 0x00, 0x00 /* Colour #1 */
+#ifdef HAVE_NEGATIVE_LCD
+ BMP_COLOR(LCD_BL_DARKCOLOR),
+ BMP_COLOR(LCD_BL_BRIGHTCOLOR),
+#ifdef HAVE_LCD_SPLIT
+ BMP_COLOR(LCD_BL_DARKCOLOR_2),
+ BMP_COLOR(LCD_BL_BRIGHTCOLOR_2),
#endif
+#else /* positive display */
+ BMP_COLOR(LCD_BL_BRIGHTCOLOR),
+ BMP_COLOR(LCD_BL_DARKCOLOR),
+#endif /* positive display */
#elif LCD_DEPTH == 2
- 0xe6, 0xd8, 0xad, 0x00, /* Colour #0 */
- 0x99, 0x90, 0x73, 0x00, /* Colour #1 */
- 0x4c, 0x48, 0x39, 0x00, /* Colour #2 */
- 0x00, 0x00, 0x00, 0x00 /* Colour #3 */
+ BMP_COLOR(LCD_BL_BRIGHTCOLOR),
+ BMP_COLOR_MIX(LCD_BL_BRIGHTCOLOR, LCD_BL_DARKCOLOR, 1, 3),
+ BMP_COLOR_MIX(LCD_BL_BRIGHTCOLOR, LCD_BL_DARKCOLOR, 2, 3),
+ BMP_COLOR(LCD_BL_DARKCOLOR),
#elif LCD_DEPTH == 16
0x00, 0xf8, 0x00, 0x00, /* red bitfield mask */
0xe0, 0x07, 0x00, 0x00, /* green bitfield mask */
- 0x1f, 0x00, 0x00, 0x00 /* blue bitfield mask */
+ 0x1f, 0x00, 0x00, 0x00, /* blue bitfield mask */
#endif
};
@@ -461,30 +466,33 @@ void screen_dump(void)
for (by = LCD_FBHEIGHT - 1; by >= 0; by--)
{
unsigned char *src = &lcd_framebuffer[by][0];
- unsigned char *dst = &line_block[0][0];
+ unsigned char *dst = &line_block[7][0];
memset(line_block, 0, sizeof(line_block));
- for (bx = LCD_WIDTH/8; bx > 0; bx--)
+
+#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 dst_mask = 0x80;
- int ix;
+ unsigned char *dst_blk = dst++;
+ unsigned src_byte0 = *src++ << 4;
+ unsigned src_byte1 = *src++;
+ int iy;
- for (ix = 8; ix > 0; ix--)
+ for (iy = 8; iy > 0; iy--)
{
- unsigned char *dst_blk = dst;
- unsigned src_byte = *src++;
- int iy;
-
- for (iy = 8; iy > 0; iy--)
- {
- if (src_byte & 0x80)
- *dst_blk |= dst_mask;
- src_byte <<= 1;
- dst_blk += BMP_LINESIZE;
- }
- dst_mask >>= 1;
+ *dst_blk = (src_byte0 & 0x10)
+ | (src_byte1 & 0x01)
+#ifdef HAVE_LCD_SPLIT
+ | (by < (LCD_SPLIT_POS/8) ? 0x22 : 0)
+#endif
+ ;
+ src_byte0 >>= 1;
+ src_byte1 >>= 1;
+ dst_blk -= BMP_LINESIZE;
}
- dst++;
}
write(fh, line_block, sizeof(line_block));
diff --git a/apps/misc.h b/apps/misc.h
index 22ae484..99e709c 100644
--- a/apps/misc.h
+++ b/apps/misc.h
@@ -93,6 +93,18 @@ void screen_dump(void);
void screen_dump_set_hook(void (*hook)(int fh));
#endif
+/* Make BMP colour map entries from R, G, B triples, without and with blending.
+ * Not within HAVE_LCD_BITMAP because it is also used for the Player sim */
+#define RED_CMP(c) (((c) >> 16) & 0xff)
+#define GREEN_CMP(c) (((c) >> 8) & 0xff)
+#define BLUE_CMP(c) ((c) & 0xff)
+
+#define BMP_COLOR(c) BLUE_CMP(c), GREEN_CMP(c), RED_CMP(c), 0
+#define BMP_COLOR_MIX(c1, c2, num, den) \
+ (BLUE_CMP(c2) - BLUE_CMP(c1)) * (num) / (den) + BLUE_CMP(c1), \
+ (GREEN_CMP(c2) - GREEN_CMP(c1)) * (num) / (den) + GREEN_CMP(c1), \
+ (RED_CMP(c2) - RED_CMP(c1)) * (num) / (den) + RED_CMP(c1), 0
+
bool settings_parseline(char* line, char** name, char** value);
long default_event_handler_ex(long event, void (*callback)(void *), void *parameter);
long default_event_handler(long event);
diff --git a/apps/plugin.c b/apps/plugin.c
index 8828d10..3b14b00 100644
--- a/apps/plugin.c
+++ b/apps/plugin.c
@@ -61,7 +61,7 @@
static unsigned char pluginbuf[PLUGIN_BUFFER_SIZE];
void *sim_plugin_load(char *plugin, void **pd);
void sim_plugin_close(void *pd);
-void sim_lcd_ex_init(int shades, unsigned long (*getpixel)(int, int));
+void sim_lcd_ex_init(unsigned long (*getpixel)(int, int));
void sim_lcd_ex_update_rect(int x, int y, int width, int height);
#else
#define sim_plugin_close(x)
diff --git a/apps/plugin.h b/apps/plugin.h
index 2017bf3..82ce0d6 100644
--- a/apps/plugin.h
+++ b/apps/plugin.h
@@ -126,12 +126,12 @@ void* plugin_get_buffer(size_t *buffer_size);
#define PLUGIN_MAGIC 0x526F634B /* RocK */
/* increase this every time the api struct changes */
-#define PLUGIN_API_VERSION 141
+#define PLUGIN_API_VERSION 142
/* update this to latest version if a change to the api struct breaks
backwards compatibility (and please take the opportunity to sort in any
new function which are "waiting" at the end of the function table) */
-#define PLUGIN_MIN_API_VERSION 141
+#define PLUGIN_MIN_API_VERSION 142
/* plugin return codes */
enum plugin_status {
@@ -474,7 +474,7 @@ struct plugin_api {
#ifdef SIMULATOR
/* special simulator hooks */
#if defined(HAVE_LCD_BITMAP) && LCD_DEPTH < 8
- void (*sim_lcd_ex_init)(int shades, unsigned long (*getpixel)(int, int));
+ void (*sim_lcd_ex_init)(unsigned long (*getpixel)(int, int));
void (*sim_lcd_ex_update_rect)(int x, int y, int width, int height);
#endif
#endif
diff --git a/apps/plugins/lib/grey_core.c b/apps/plugins/lib/grey_core.c
index c73f0cd..a7e8f2a 100644
--- a/apps/plugins/lib/grey_core.c
+++ b/apps/plugins/lib/grey_core.c
@@ -355,6 +355,7 @@ static inline void _deferred_update(void)
* coordinates! */
static unsigned long _grey_get_pixel(int x, int y)
{
+ long val;
int xg = x - _grey_info.x;
int yg = y - _grey_info.y;
#if LCD_PIXELFORMAT == HORIZONTAL_PACKING
@@ -364,7 +365,11 @@ static unsigned long _grey_get_pixel(int x, int y)
+ (xg << _GREY_BSHIFT) + (~yg & _GREY_BMASK);
#endif
- return _grey_info.values[idx] + (1 << LCD_DEPTH);
+ val = _grey_info.values[idx];
+#ifdef HAVE_LCD_SPLIT
+ val -= val >> 7;
+#endif
+ return val;
}
#else /* !SIMULATOR */
@@ -634,9 +639,9 @@ void grey_show(bool enable)
{
_grey_info.flags |= _GREY_RUNNING;
#ifdef SIMULATOR
- rb->sim_lcd_ex_init(129, _grey_get_pixel);
+ rb->sim_lcd_ex_init(_grey_get_pixel);
rb->sim_lcd_ex_update_rect(_grey_info.x, _grey_info.y,
- _grey_info.width, _grey_info.height);
+ _grey_info.width, _grey_info.height);
#else /* !SIMULATOR */
#ifdef NEED_BOOST
rb->cpu_boost(true);
@@ -655,7 +660,7 @@ void grey_show(bool enable)
else if (!enable && (_grey_info.flags & _GREY_RUNNING))
{
#ifdef SIMULATOR
- rb->sim_lcd_ex_init(0, NULL);
+ rb->sim_lcd_ex_init(NULL);
#else /* !SIMULATOR */
rb->timer_unregister();
#if NUM_CORES > 1 /* Make sure the ISR has finished before calling lcd_update() */
@@ -702,9 +707,14 @@ void grey_deferred_lcd_update(void)
/*** Screenshot ***/
-#define BMP_FIXEDCOLORS (1 << LCD_DEPTH)
-#define BMP_VARCOLORS 129
-#define BMP_NUMCOLORS (BMP_FIXEDCOLORS + BMP_VARCOLORS)
+#ifdef HAVE_LCD_SPLIT
+#define GRADIENT_MAX 127
+#define BMP_NUMCOLORS 256
+#else
+#define GRADIENT_MAX 128
+#define BMP_NUMCOLORS 129
+#endif
+
#define BMP_BPP 8
#define BMP_LINESIZE ((LCD_WIDTH + 3) & ~3)
#define BMP_HEADERSIZE (54 + 4 * BMP_NUMCOLORS)
@@ -723,7 +733,7 @@ static const unsigned char bmpheader[] =
0x28, 0x00, 0x00, 0x00, /* Size of (2nd) header */
LE32_CONST(LCD_WIDTH), /* Width in pixels */
- LE32_CONST(LCD_HEIGHT), /* Height in pixels */
+ LE32_CONST(LCD_HEIGHT+LCD_SPLIT_LINES), /* Height in pixels */
0x01, 0x00, /* Number of planes (always 1) */
LE16_CONST(BMP_BPP), /* Bits per pixel 1/4/8/16/24 */
0x00, 0x00, 0x00, 0x00, /* Compression mode, 0 = none */
@@ -732,36 +742,11 @@ static const unsigned char bmpheader[] =
0xc4, 0x0e, 0x00, 0x00, /* Vertical resolution (pixels/meter) */
LE32_CONST(BMP_NUMCOLORS), /* Number of used colours */
LE32_CONST(BMP_NUMCOLORS), /* Number of important colours */
-
- /* Fixed colours */
-#if LCD_DEPTH == 1
- 0x90, 0xee, 0x90, 0x00, /* Colour #0 */
- 0x00, 0x00, 0x00, 0x00 /* Colour #1 */
-#elif LCD_DEPTH == 2
- 0xe6, 0xd8, 0xad, 0x00, /* Colour #0 */
- 0x99, 0x90, 0x73, 0x00, /* Colour #1 */
- 0x4c, 0x48, 0x39, 0x00, /* Colour #2 */
- 0x00, 0x00, 0x00, 0x00 /* Colour #3 */
-#endif
};
-#if LCD_DEPTH == 1
-#ifdef MROBE_100
-#define BMP_RED 241
-#define BMP_GREEN 6
-#define BMP_BLUE 3
-#define BMP_RED_BASE 94
-#define BMP_GREEN_BASE 2
-#define BMP_BLUE_BASE 2
-#else
-#define BMP_RED 0x90
-#define BMP_GREEN 0xee
-#define BMP_BLUE 0x90
-#endif
-#elif LCD_DEPTH == 2
-#define BMP_RED 0xad
-#define BMP_GREEN 0xd8
-#define BMP_BLUE 0xe6
+#if LCD_DEPTH == 2
+/* Only defined for positive, non-split LCD for now */
+static const unsigned char colorindex[4] = {128, 85, 43, 0};
#endif
/* Hook function for core screen_dump() to save the current display
@@ -772,6 +757,7 @@ static void grey_screendump_hook(int fd)
int x, y, gx, gy;
#if LCD_PIXELFORMAT == VERTICAL_PACKING
#if LCD_DEPTH == 1
+ unsigned val;
unsigned mask;
#elif LCD_DEPTH == 2
int shift;
@@ -782,37 +768,57 @@ static void grey_screendump_hook(int fd)
#endif /* LCD_PIXELFORMAT */
fb_data *lcdptr;
unsigned char *clut_entry;
- unsigned char linebuf[MAX(4*BMP_VARCOLORS,BMP_LINESIZE)];
+ unsigned char linebuf[MAX(4*BMP_NUMCOLORS,BMP_LINESIZE)];
rb->write(fd, bmpheader, sizeof(bmpheader)); /* write header */
/* build clut */
- rb->memset(linebuf, 0, 4*BMP_VARCOLORS);
+ rb->memset(linebuf, 0, 4*BMP_NUMCOLORS);
clut_entry = linebuf;
- for (i = 0; i <= 128; i++)
+ for (i = 0; i <= GRADIENT_MAX; i++)
{
-#ifdef MROBE_100
- *clut_entry++ = (_GREY_MULUQ(BMP_BLUE-BMP_BLUE_BASE, i) >> 7) +
- BMP_BLUE_BASE;
- *clut_entry++ = (_GREY_MULUQ(BMP_GREEN-BMP_GREEN_BASE, i) >> 7) +
- BMP_GREEN_BASE;
- *clut_entry++ = (_GREY_MULUQ(BMP_RED-BMP_RED_BASE, i) >> 7) +
- BMP_RED_BASE;
-#else
- *clut_entry++ = _GREY_MULUQ(BMP_BLUE, i) >> 7;
- *clut_entry++ = _GREY_MULUQ(BMP_GREEN, i) >> 7;
- *clut_entry++ = _GREY_MULUQ(BMP_RED, i) >> 7;
-#endif
+ *clut_entry++ = (_GREY_MULUQ(BLUE_CMP(LCD_BL_BRIGHTCOLOR)
+ -BLUE_CMP(LCD_BL_DARKCOLOR), i) >> 7)
+ + BLUE_CMP(LCD_BL_DARKCOLOR);
+ *clut_entry++ = (_GREY_MULUQ(GREEN_CMP(LCD_BL_BRIGHTCOLOR)
+ -GREEN_CMP(LCD_BL_DARKCOLOR), i) >> 7)
+ + GREEN_CMP(LCD_BL_DARKCOLOR);
+ *clut_entry++ = (_GREY_MULUQ(RED_CMP(LCD_BL_BRIGHTCOLOR)
+ -RED_CMP(LCD_BL_DARKCOLOR), i) >> 7)
+ + RED_CMP(LCD_BL_DARKCOLOR);
clut_entry++;
}
- rb->write(fd, linebuf, 4*BMP_VARCOLORS);
+#ifdef HAVE_LCD_SPLIT
+ for (i = 0; i <= GRADIENT_MAX; i++)
+ {
+ *clut_entry++ = (_GREY_MULUQ(BLUE_CMP(LCD_BL_BRIGHTCOLOR_2)
+ -BLUE_CMP(LCD_BL_DARKCOLOR_2), i) >> 7)
+ + BLUE_CMP(LCD_BL_DARKCOLOR_2);
+ *clut_entry++ = (_GREY_MULUQ(GREEN_CMP(LCD_BL_BRIGHTCOLOR_2)
+ -GREEN_CMP(LCD_BL_DARKCOLOR_2), i) >> 7)
+ + GREEN_CMP(LCD_BL_DARKCOLOR_2);
+ *clut_entry++ = (_GREY_MULUQ(RED_CMP(LCD_BL_BRIGHTCOLOR_2)
+ -RED_CMP(LCD_BL_DARKCOLOR_2), i) >> 7)
+ + RED_CMP(LCD_BL_DARKCOLOR_2);
+ clut_entry++;
+ }
+#endif
+ rb->write(fd, linebuf, 4*BMP_NUMCOLORS);
/* BMP image goes bottom -> top */
for (y = LCD_HEIGHT - 1; y >= 0; y--)
{
rb->memset(linebuf, 0, BMP_LINESIZE);
+#if defined(HAVE_LCD_SPLIT) && (LCD_SPLIT_LINES == 2)
+ if (y == LCD_SPLIT_POS - 1)
+ {
+ rb->write(fd, linebuf, BMP_LINESIZE);
+ rb->write(fd, linebuf, BMP_LINESIZE);
+ }
+#endif
+
gy = y - _grey_info.y;
#if LCD_PIXELFORMAT == HORIZONTAL_PACKING
#if LCD_DEPTH == 2
@@ -828,15 +834,15 @@ static void grey_screendump_hook(int fd)
unsigned char *src = _grey_info.values
+ _GREY_MULUQ(_grey_info.width, gy) + gx;
for (i = 0; i < 4; i++)
- linebuf[x + i] = BMP_FIXEDCOLORS + *src++;
+ linebuf[x + i] = *src++;
}
else
{
unsigned data = *lcdptr;
- linebuf[x] = (data >> 6) & 3;
- linebuf[x + 1] = (data >> 4) & 3;
- linebuf[x + 2] = (data >> 2) & 3;
- linebuf[x + 3] = data & 3;
+ linebuf[x] = colorindex[(data >> 6) & 3];
+ linebuf[x + 1] = colorindex[(data >> 4) & 3];
+ linebuf[x + 2] = colorindex[(data >> 2) & 3];
+ linebuf[x + 3] = colorindex[data & 3];
}
lcdptr++;
}
@@ -853,16 +859,27 @@ static void grey_screendump_hook(int fd)
if (((unsigned)gy < (unsigned)_grey_info.height)
&& ((unsigned)gx < (unsigned)_grey_info.width))
{
- linebuf[x] = BMP_FIXEDCOLORS
- + _grey_info.values[_GREY_MULUQ(_grey_info.width,
- gy & ~_GREY_BMASK)
- + (gx << _GREY_BSHIFT)
- + (~gy & _GREY_BMASK)];
+ val = _grey_info.values[_GREY_MULUQ(_grey_info.width,
+ gy & ~_GREY_BMASK)
+ + (gx << _GREY_BSHIFT)
+ + (~gy & _GREY_BMASK)];
+#ifdef HAVE_LCD_SPLIT
+ val -= val >> 7;
+#endif
}
else
{
- linebuf[x] = (*lcdptr & mask) ? 1 : 0;
+#ifdef HAVE_NEGATIVE_LCD
+ val = (*lcdptr & mask) ? GRADIENT_MAX : 0;
+#else
+ val = (*lcdptr & mask) ? 0 : GRADIENT_MAX;
+#endif
}
+#ifdef HAVE_LCD_SPLIT
+ if (y < LCD_SPLIT_POS)
+ val |= 0x80;
+#endif
+ linebuf[x] = val;
lcdptr++;
}
#elif LCD_DEPTH == 2
@@ -876,15 +893,14 @@ static void grey_screendump_hook(int fd)
if (((unsigned)gy < (unsigned)_grey_info.height)
&& ((unsigned)gx < (unsigned)_grey_info.width))
{
- linebuf[x] = BMP_FIXEDCOLORS
- + _grey_info.values[_GREY_MULUQ(_grey_info.width,
+ linebuf[x] = _grey_info.values[_GREY_MULUQ(_grey_info.width,
gy & ~_GREY_BMASK)
+ (gx << _GREY_BSHIFT)
+ (~gy & _GREY_BMASK)];
}
else
{
- linebuf[x] = (*lcdptr >> shift) & 3;
+ linebuf[x] = colorindex[(*lcdptr >> shift) & 3];
}
lcdptr++;
}
@@ -901,8 +917,7 @@ static void grey_screendump_hook(int fd)
if (((unsigned)gy < (unsigned)_grey_info.height)
&& ((unsigned)gx < (unsigned)_grey_info.width))
{
- linebuf[x] = BMP_FIXEDCOLORS
- + _grey_info.values[_GREY_MULUQ(_grey_info.width,
+ linebuf[x] = _grey_info.values[_GREY_MULUQ(_grey_info.width,
gy & ~_GREY_BMASK)
+ (gx << _GREY_BSHIFT)
+ (~gy & _GREY_BMASK)];
@@ -910,7 +925,7 @@ static void grey_screendump_hook(int fd)
else
{
data = (*lcdptr >> shift) & 0x0101;
- linebuf[x] = ((data >> 7) | data) & 3;
+ linebuf[x] = colorindex[((data >> 7) | data) & 3];
}
lcdptr++;
}