summaryrefslogtreecommitdiffstats
path: root/uisimulator
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2005-07-06 22:58:02 +0000
committerJens Arnold <amiconn@rockbox.org>2005-07-06 22:58:02 +0000
commitf894a4c2691fbde1758a05407cb5eadcaec4a6c8 (patch)
tree46cb7ce63c794020175ab251cf0299663be8bf3c /uisimulator
parent1076eb1d2720b88757616f642be0c39c6a3b76df (diff)
downloadrockbox-f894a4c2691fbde1758a05407cb5eadcaec4a6c8.tar.gz
rockbox-f894a4c2691fbde1758a05407cb5eadcaec4a6c8.tar.bz2
rockbox-f894a4c2691fbde1758a05407cb5eadcaec4a6c8.zip
4-shades greyscale graphics core for iriver H1x0. 4-grey rockbox logo and light grey background in splash() boxes. Simplified the splash() box creation as the new graphics core does clipping. Adapted screendump feature and added flexible preprocessing to construct the bmp header. Rockboy now uses 4-grey mode as well. 4-grey support for win32 simulator. Fixed win32 player sim to not use double bitmap conversion via a recorder-like framebuffer, and correctly display double-height text. X11 simulator temporarily adapted. The display won't be distorted, but it still shows b&w only.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7046 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'uisimulator')
-rw-r--r--uisimulator/win32/lcd-win32.c161
-rw-r--r--uisimulator/win32/lcd-win32.h20
-rw-r--r--uisimulator/win32/uisw32.c2
-rw-r--r--uisimulator/x11/lcd-x11.c42
4 files changed, 132 insertions, 93 deletions
diff --git a/uisimulator/win32/lcd-win32.c b/uisimulator/win32/lcd-win32.c
index ef85214e8f..11296884b7 100644
--- a/uisimulator/win32/lcd-win32.c
+++ b/uisimulator/win32/lcd-win32.c
@@ -23,33 +23,28 @@
#include "lcd.h"
#include "lcd-playersim.h"
-unsigned char lcd_framebuffer[LCD_HEIGHT/8][LCD_WIDTH]; /* the display */
char bitmap[LCD_HEIGHT][LCD_WIDTH]; /* the ui display */
-BITMAPINFO2 bmi =
+RGBQUAD color_zero = {UI_LCD_BGCOLORLIGHT, 0};
+RGBQUAD color_max = {0, 0, 0, 0};
+
+BITMAPINFO256 bmi =
{
{sizeof (BITMAPINFOHEADER),
LCD_WIDTH, -LCD_HEIGHT, 1, 8,
BI_RGB, 0, 0, 0, 2, 2,
},
- {
- //{UI_LCD_BGCOLOR, 0}, /* green background color */
- {UI_LCD_BGCOLORLIGHT, 0}, /* green background color */
- {UI_LCD_BLACK, 0} /* black color */
- }
-
+ {} /* colour lookup table gets filled later */
}; /* bitmap information */
-#ifdef HAVE_LCD_CHARCELLS
-/* Defined in lcd-playersim.c */
-extern void lcd_print_char(int x, int y);
-extern bool lcd_display_redraw;
-extern unsigned char hardware_buffer_lcd[11][2];
-static unsigned char lcd_buffer_copy[11][2];
-#endif
+#ifdef HAVE_LCD_BITMAP
+
+#if LCD_DEPTH == 1
+extern unsigned char lcd_framebuffer[LCD_HEIGHT/8][LCD_WIDTH]; /* the display */
+#elif LCD_DEPTH == 2
+extern unsigned char lcd_framebuffer[LCD_HEIGHT/4][LCD_WIDTH]; /* the display */
+#endif
-/* lcd_update()
- update lcd */
void lcd_update()
{
int x, y;
@@ -58,26 +53,13 @@ void lcd_update()
if (hGUIWnd == NULL)
_endthread ();
-#ifdef HAVE_LCD_CHARCELLS
- for (y = 0; y < 2; y++)
- {
- for (x = 0; x < 11; x++)
- {
- if (lcd_display_redraw ||
- lcd_buffer_copy[x][y] != hardware_buffer_lcd[x][y])
- {
- lcd_buffer_copy[x][y] = hardware_buffer_lcd[x][y];
- lcd_print_char(x, y);
- }
- }
- }
-
- lcd_display_redraw = false;
-#endif
-
for (x = 0; x < LCD_WIDTH; x++)
for (y = 0; y < LCD_HEIGHT; y++)
+#if LCD_DEPTH == 1
bitmap[y][x] = ((lcd_framebuffer[y/8][x] >> (y & 7)) & 1);
+#elif LCD_DEPTH == 2
+ bitmap[y][x] = ((lcd_framebuffer[y/4][x] >> (2 * (y & 3))) & 3);
+#endif
/* Invalidate only the window part that actually did change */
GetClientRect (hGUIWnd, &r);
@@ -108,7 +90,11 @@ void lcd_update_rect(int x_start, int y_start,
for (x = x_start; x < xmax; x++)
for (y = y_start; y < ymax; y++)
+#if LCD_DEPTH == 1
bitmap[y][x] = ((lcd_framebuffer[y/8][x] >> (y & 7)) & 1);
+#elif LCD_DEPTH == 2
+ bitmap[y][x] = ((lcd_framebuffer[y/4][x] >> (2 * (y & 3))) & 3);
+#endif
/* Invalidate only the window part that actually did change */
GetClientRect (hGUIWnd, &r);
@@ -136,37 +122,55 @@ void lcd_remote_update_rect(int x_start, int y_start,
(void)width;
(void)height;
}
+#endif /* HAVE_LCD_BITMAP */
-/* lcd_backlight()
- set backlight state of lcd */
-void lcd_backlight (bool on)
+#ifdef HAVE_LCD_CHARCELLS
+/* Defined in lcd-playersim.c */
+extern void lcd_print_char(int x, int y);
+extern bool lcd_display_redraw;
+extern unsigned char hardware_buffer_lcd[11][2];
+static unsigned char lcd_buffer_copy[11][2];
+
+void lcd_update()
{
- if (on)
+ int x, y;
+ bool changed = false;
+ RECT r;
+
+ if (hGUIWnd == NULL)
+ _endthread ();
+
+ for (y = 0; y < 2; y++)
{
- RGBQUAD blon = {UI_LCD_BGCOLORLIGHT, 0};
- bmi.bmiColors[0] = blon;
+ for (x = 0; x < 11; x++)
+ {
+ if (lcd_display_redraw ||
+ lcd_buffer_copy[x][y] != hardware_buffer_lcd[x][y])
+ {
+ lcd_buffer_copy[x][y] = hardware_buffer_lcd[x][y];
+ lcd_print_char(x, y);
+ changed = true;
+ }
+ }
}
- else
+ if (changed)
{
- RGBQUAD blon = {UI_LCD_BGCOLOR, 0};
- bmi.bmiColors[0] = blon;
+ /* Invalidate only the window part that actually did change */
+ GetClientRect (hGUIWnd, &r);
+ r.left = UI_LCD_POSX * r.right / UI_WIDTH;
+ r.top = UI_LCD_POSY * r.bottom / UI_HEIGHT;
+ r.right = (UI_LCD_POSX + UI_LCD_WIDTH) * r.right / UI_WIDTH;
+ r.bottom = (UI_LCD_POSY + UI_LCD_HEIGHT) * r.bottom / UI_HEIGHT;
+ InvalidateRect (hGUIWnd, &r, FALSE);
}
-
- InvalidateRect (hGUIWnd, NULL, FALSE);
+ lcd_display_redraw = false;
}
void drawdots(int color, struct coordinate *points, int count)
{
while (count--)
{
- if (color)
- {
- DRAW_PIXEL(points[count].x, points[count].y);
- }
- else
- {
- CLEAR_PIXEL(points[count].x, points[count].y);
- }
+ bitmap[points[count].y][points[count].x] = color;
}
}
@@ -181,17 +185,50 @@ void drawrectangles(int color, struct rectangle *points, int count)
for (x = points[count].x, ix = 0; ix < points[count].width; x++, ix++)
{
- for (y = points[count].y, iy = 0; iy < points[count].width; y++, iy++)
+ for (y = points[count].y, iy = 0; iy < points[count].height; y++, iy++)
{
- if (color)
- {
- DRAW_PIXEL(x, y);
- }
- else
- {
- CLEAR_PIXEL(x, y);
- }
+ bitmap[y][x] = color;
}
}
}
}
+#endif /* HAVE_LCD_CHARCELLS */
+
+#if 0
+/* set backlight state of lcd */
+void lcd_backlight (bool on)
+{
+ if (on)
+ color_zero = {UI_LCD_BGCOLORLIGHT, 0};
+ else
+ color_zero = {UI_LCD_BGCOLOR, 0};
+
+ lcdcolors(0, (1<<LCD_DEPTH), &color_zero, &color_max);
+ InvalidateRect (hGUIWnd, NULL, FALSE);
+}
+#endif
+
+/* set a range of bitmap indices to a gradient from startcolour to endcolour */
+void lcdcolors(int index, int count, RGBQUAD *start, RGBQUAD *end)
+{
+ int i;
+ count--;
+ for (i = 0; i <= count; i++)
+ {
+ bmi.bmiColors[i+index].rgbRed = start->rgbRed
+ + (end->rgbRed - start->rgbRed) * i / count;
+ bmi.bmiColors[i+index].rgbGreen = start->rgbGreen
+ + (end->rgbGreen - start->rgbGreen) * i / count;
+ bmi.bmiColors[i+index].rgbBlue = start->rgbBlue
+ + (end->rgbBlue - start->rgbBlue) * i / count;
+ }
+}
+
+/* initialise simulator lcd driver */
+void simlcdinit(void)
+{
+ bmi.bmiHeader.biClrUsed = (1<<LCD_DEPTH);
+ bmi.bmiHeader.biClrImportant = (1<<LCD_DEPTH);
+ lcdcolors(0, (1<<LCD_DEPTH), &color_zero, &color_max);
+}
+
diff --git a/uisimulator/win32/lcd-win32.h b/uisimulator/win32/lcd-win32.h
index d2627e6a53..26a47208e5 100644
--- a/uisimulator/win32/lcd-win32.h
+++ b/uisimulator/win32/lcd-win32.h
@@ -23,24 +23,16 @@
#include "uisw32.h"
#include "lcd.h"
-// BITMAPINFO2
+// BITMAPINFO256
typedef struct
{
BITMAPINFOHEADER bmiHeader;
- RGBQUAD bmiColors[2];
-} BITMAPINFO2;
+ RGBQUAD bmiColors[256];
+} BITMAPINFO256;
-#ifdef HAVE_LCD_BITMAP
-
-extern unsigned char display[LCD_WIDTH][LCD_HEIGHT/8]; // the display
-#else
-#define DISP_X 112
-#define DISP_Y 64
-#endif
-
-
-extern char bitmap[LCD_HEIGHT][LCD_WIDTH]; // the ui display
-extern BITMAPINFO2 bmi; // bitmap information
+extern char bitmap[LCD_HEIGHT][LCD_WIDTH]; // the ui display
+extern BITMAPINFO256 bmi; // bitmap information
+void simlcdinit(void);
#endif // #ifndef __LCDWIN32_H__
diff --git a/uisimulator/win32/uisw32.c b/uisimulator/win32/uisw32.c
index 9401153408..fb581c0cf1 100644
--- a/uisimulator/win32/uisw32.c
+++ b/uisimulator/win32/uisw32.c
@@ -239,6 +239,8 @@ BOOL GUIStartup ()
if (hGUIWnd == NULL)
return FALSE;
+
+ simlcdinit();
return TRUE;
}
diff --git a/uisimulator/x11/lcd-x11.c b/uisimulator/x11/lcd-x11.c
index 1ee15f9169..d538cee9df 100644
--- a/uisimulator/x11/lcd-x11.c
+++ b/uisimulator/x11/lcd-x11.c
@@ -40,11 +40,19 @@
#include "lcd-x11.h"
#include "lcd-playersim.h"
-extern unsigned char lcd_framebuffer[LCD_HEIGHT/8][LCD_WIDTH];
+#if LCD_DEPTH == 2
+#define YBLOCK 4
+#define BITOFFS 1 /* take the MSB of each pixel */
+#else
+#define YBLOCK 8
+#define BITOFFS 0
+#endif
+
extern void screen_resized(int width, int height);
#ifdef HAVE_LCD_BITMAP
-unsigned char lcd_framebuffer_copy[LCD_HEIGHT/8][LCD_WIDTH];
+extern unsigned char lcd_framebuffer[LCD_HEIGHT/YBLOCK][LCD_WIDTH];
+unsigned char lcd_framebuffer_copy[LCD_HEIGHT/YBLOCK][LCD_WIDTH];
void lcd_update (void)
{
@@ -55,21 +63,21 @@ void lcd_update (void)
int cp=0;
struct coordinate clearpoints[LCD_WIDTH * LCD_HEIGHT];
- for(y=0; y<LCD_HEIGHT; y+=8) {
+ for(y=0; y<LCD_HEIGHT; y+=YBLOCK) {
for(x=0; x<LCD_WIDTH; x++) {
- if(lcd_framebuffer[y/8][x] || lcd_framebuffer_copy[y/8][x]) {
+ if(lcd_framebuffer[y/YBLOCK][x] || lcd_framebuffer_copy[y/YBLOCK][x]) {
/* one or more bits/pixels are changed */
unsigned char diff =
- lcd_framebuffer[y/8][x] ^ lcd_framebuffer_copy[y/8][x];
+ lcd_framebuffer[y/YBLOCK][x] ^ lcd_framebuffer_copy[y/YBLOCK][x];
- for(bit=0; bit<8; bit++) {
- if(lcd_framebuffer[y/8][x]&(1<<bit)) {
+ for(bit=0; bit<YBLOCK; bit++) {
+ if(lcd_framebuffer[y/YBLOCK][x]&(1<<(bit*LCD_DEPTH+BITOFFS))) {
/* set a dot */
points[p].x = x + MARGIN_X;
points[p].y = y+bit + MARGIN_Y;
p++; /* increase the point counter */
}
- else if(diff &(1<<bit)) {
+ else if(diff &(1<<(bit*LCD_DEPTH+BITOFFS))) {
/* clear a dot */
clearpoints[cp].x = x + MARGIN_X;
clearpoints[cp].y = y+bit + MARGIN_Y;
@@ -110,33 +118,33 @@ void lcd_update_rect(int x_start, int y_start,
fprintf(stderr, "%04d: lcd_update_rect(%d, %d, %d, %d)\n",
counter++, x_start, y_start, width, height);
#endif
- /* The Y coordinates have to work on even 8 pixel rows */
- ymax = (yline + height)/8;
- yline /= 8;
+ /* The Y coordinates have to work on even YBLOCK pixel rows */
+ ymax = (yline + height)/YBLOCK;
+ yline /= YBLOCK;
xmax = x_start + width;
if(xmax > LCD_WIDTH)
xmax = LCD_WIDTH;
- if(ymax >= LCD_HEIGHT/8)
- ymax = LCD_HEIGHT/8-1;
+ if(ymax >= LCD_HEIGHT/YBLOCK)
+ ymax = LCD_HEIGHT/YBLOCK-1;
for(; yline<=ymax; yline++) {
- y = yline * 8;
+ y = yline * YBLOCK;
for(x=x_start; x<xmax; x++) {
if(lcd_framebuffer[yline][x] || lcd_framebuffer_copy[yline][x]) {
/* one or more bits/pixels are changed */
unsigned char diff =
lcd_framebuffer[yline][x] ^ lcd_framebuffer_copy[yline][x];
- for(bit=0; bit<8; bit++) {
- if(lcd_framebuffer[yline][x]&(1<<bit)) {
+ for(bit=0; bit<YBLOCK; bit++) {
+ if(lcd_framebuffer[yline][x]&(1<<(bit*LCD_DEPTH+BITOFFS))) {
/* set a dot */
points[p].x = x + MARGIN_X;
points[p].y = y+bit + MARGIN_Y;
p++; /* increase the point counter */
}
- else if(diff &(1<<bit)) {
+ else if(diff &(1<<(bit*LCD_DEPTH+BITOFFS))) {
/* clear a dot */
clearpoints[cp].x = x + MARGIN_X;
clearpoints[cp].y = y+bit + MARGIN_Y;