summaryrefslogtreecommitdiff
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.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 @@
23#include "lcd.h" 23#include "lcd.h"
24#include "lcd-playersim.h" 24#include "lcd-playersim.h"
25 25
26unsigned char lcd_framebuffer[LCD_HEIGHT/8][LCD_WIDTH]; /* the display */
27char bitmap[LCD_HEIGHT][LCD_WIDTH]; /* the ui display */ 26char bitmap[LCD_HEIGHT][LCD_WIDTH]; /* the ui display */
28 27
29BITMAPINFO2 bmi = 28RGBQUAD color_zero = {UI_LCD_BGCOLORLIGHT, 0};
29RGBQUAD color_max = {0, 0, 0, 0};
30
31BITMAPINFO256 bmi =
30{ 32{
31 {sizeof (BITMAPINFOHEADER), 33 {sizeof (BITMAPINFOHEADER),
32 LCD_WIDTH, -LCD_HEIGHT, 1, 8, 34 LCD_WIDTH, -LCD_HEIGHT, 1, 8,
33 BI_RGB, 0, 0, 0, 2, 2, 35 BI_RGB, 0, 0, 0, 2, 2,
34 }, 36 },
35 { 37 {} /* colour lookup table gets filled later */
36 //{UI_LCD_BGCOLOR, 0}, /* green background color */
37 {UI_LCD_BGCOLORLIGHT, 0}, /* green background color */
38 {UI_LCD_BLACK, 0} /* black color */
39 }
40
41}; /* bitmap information */ 38}; /* bitmap information */
42 39
43#ifdef HAVE_LCD_CHARCELLS 40#ifdef HAVE_LCD_BITMAP
44/* Defined in lcd-playersim.c */ 41
45extern void lcd_print_char(int x, int y); 42#if LCD_DEPTH == 1
46extern bool lcd_display_redraw; 43extern unsigned char lcd_framebuffer[LCD_HEIGHT/8][LCD_WIDTH]; /* the display */
47extern unsigned char hardware_buffer_lcd[11][2]; 44#elif LCD_DEPTH == 2
48static unsigned char lcd_buffer_copy[11][2]; 45extern unsigned char lcd_framebuffer[LCD_HEIGHT/4][LCD_WIDTH]; /* the display */
49#endif 46#endif
50 47
51/* lcd_update()
52 update lcd */
53void lcd_update() 48void lcd_update()
54{ 49{
55 int x, y; 50 int x, y;
@@ -58,26 +53,13 @@ void lcd_update()
58 if (hGUIWnd == NULL) 53 if (hGUIWnd == NULL)
59 _endthread (); 54 _endthread ();
60 55
61#ifdef HAVE_LCD_CHARCELLS
62 for (y = 0; y < 2; y++)
63 {
64 for (x = 0; x < 11; x++)
65 {
66 if (lcd_display_redraw ||
67 lcd_buffer_copy[x][y] != hardware_buffer_lcd[x][y])
68 {
69 lcd_buffer_copy[x][y] = hardware_buffer_lcd[x][y];
70 lcd_print_char(x, y);
71 }
72 }
73 }
74
75 lcd_display_redraw = false;
76#endif
77
78 for (x = 0; x < LCD_WIDTH; x++) 56 for (x = 0; x < LCD_WIDTH; x++)
79 for (y = 0; y < LCD_HEIGHT; y++) 57 for (y = 0; y < LCD_HEIGHT; y++)
58#if LCD_DEPTH == 1
80 bitmap[y][x] = ((lcd_framebuffer[y/8][x] >> (y & 7)) & 1); 59 bitmap[y][x] = ((lcd_framebuffer[y/8][x] >> (y & 7)) & 1);
60#elif LCD_DEPTH == 2
61 bitmap[y][x] = ((lcd_framebuffer[y/4][x] >> (2 * (y & 3))) & 3);
62#endif
81 63
82 /* Invalidate only the window part that actually did change */ 64 /* Invalidate only the window part that actually did change */
83 GetClientRect (hGUIWnd, &r); 65 GetClientRect (hGUIWnd, &r);
@@ -108,7 +90,11 @@ void lcd_update_rect(int x_start, int y_start,
108 90
109 for (x = x_start; x < xmax; x++) 91 for (x = x_start; x < xmax; x++)
110 for (y = y_start; y < ymax; y++) 92 for (y = y_start; y < ymax; y++)
93#if LCD_DEPTH == 1
111 bitmap[y][x] = ((lcd_framebuffer[y/8][x] >> (y & 7)) & 1); 94 bitmap[y][x] = ((lcd_framebuffer[y/8][x] >> (y & 7)) & 1);
95#elif LCD_DEPTH == 2
96 bitmap[y][x] = ((lcd_framebuffer[y/4][x] >> (2 * (y & 3))) & 3);
97#endif
112 98
113 /* Invalidate only the window part that actually did change */ 99 /* Invalidate only the window part that actually did change */
114 GetClientRect (hGUIWnd, &r); 100 GetClientRect (hGUIWnd, &r);
@@ -136,37 +122,55 @@ void lcd_remote_update_rect(int x_start, int y_start,
136 (void)width; 122 (void)width;
137 (void)height; 123 (void)height;
138} 124}
125#endif /* HAVE_LCD_BITMAP */
139 126
140/* lcd_backlight() 127#ifdef HAVE_LCD_CHARCELLS
141 set backlight state of lcd */ 128/* Defined in lcd-playersim.c */
142void lcd_backlight (bool on) 129extern void lcd_print_char(int x, int y);
130extern bool lcd_display_redraw;
131extern unsigned char hardware_buffer_lcd[11][2];
132static unsigned char lcd_buffer_copy[11][2];
133
134void lcd_update()
143{ 135{
144 if (on) 136 int x, y;
137 bool changed = false;
138 RECT r;
139
140 if (hGUIWnd == NULL)
141 _endthread ();
142
143 for (y = 0; y < 2; y++)
145 { 144 {
146 RGBQUAD blon = {UI_LCD_BGCOLORLIGHT, 0}; 145 for (x = 0; x < 11; x++)
147 bmi.bmiColors[0] = blon; 146 {
147 if (lcd_display_redraw ||
148 lcd_buffer_copy[x][y] != hardware_buffer_lcd[x][y])
149 {
150 lcd_buffer_copy[x][y] = hardware_buffer_lcd[x][y];
151 lcd_print_char(x, y);
152 changed = true;
153 }
154 }
148 } 155 }
149 else 156 if (changed)
150 { 157 {
151 RGBQUAD blon = {UI_LCD_BGCOLOR, 0}; 158 /* Invalidate only the window part that actually did change */
152 bmi.bmiColors[0] = blon; 159 GetClientRect (hGUIWnd, &r);
160 r.left = UI_LCD_POSX * r.right / UI_WIDTH;
161 r.top = UI_LCD_POSY * r.bottom / UI_HEIGHT;
162 r.right = (UI_LCD_POSX + UI_LCD_WIDTH) * r.right / UI_WIDTH;
163 r.bottom = (UI_LCD_POSY + UI_LCD_HEIGHT) * r.bottom / UI_HEIGHT;
164 InvalidateRect (hGUIWnd, &r, FALSE);
153 } 165 }
154 166 lcd_display_redraw = false;
155 InvalidateRect (hGUIWnd, NULL, FALSE);
156} 167}
157 168
158void drawdots(int color, struct coordinate *points, int count) 169void drawdots(int color, struct coordinate *points, int count)
159{ 170{
160 while (count--) 171 while (count--)
161 { 172 {
162 if (color) 173 bitmap[points[count].y][points[count].x] = color;
163 {
164 DRAW_PIXEL(points[count].x, points[count].y);
165 }
166 else
167 {
168 CLEAR_PIXEL(points[count].x, points[count].y);
169 }
170 } 174 }
171} 175}
172 176
@@ -181,17 +185,50 @@ void drawrectangles(int color, struct rectangle *points, int count)
181 185
182 for (x = points[count].x, ix = 0; ix < points[count].width; x++, ix++) 186 for (x = points[count].x, ix = 0; ix < points[count].width; x++, ix++)
183 { 187 {
184 for (y = points[count].y, iy = 0; iy < points[count].width; y++, iy++) 188 for (y = points[count].y, iy = 0; iy < points[count].height; y++, iy++)
185 { 189 {
186 if (color) 190 bitmap[y][x] = color;
187 {
188 DRAW_PIXEL(x, y);
189 }
190 else
191 {
192 CLEAR_PIXEL(x, y);
193 }
194 } 191 }
195 } 192 }
196 } 193 }
197} 194}
195#endif /* HAVE_LCD_CHARCELLS */
196
197#if 0
198/* set backlight state of lcd */
199void lcd_backlight (bool on)
200{
201 if (on)
202 color_zero = {UI_LCD_BGCOLORLIGHT, 0};
203 else
204 color_zero = {UI_LCD_BGCOLOR, 0};
205
206 lcdcolors(0, (1<<LCD_DEPTH), &color_zero, &color_max);
207 InvalidateRect (hGUIWnd, NULL, FALSE);
208}
209#endif
210
211/* set a range of bitmap indices to a gradient from startcolour to endcolour */
212void lcdcolors(int index, int count, RGBQUAD *start, RGBQUAD *end)
213{
214 int i;
215 count--;
216 for (i = 0; i <= count; i++)
217 {
218 bmi.bmiColors[i+index].rgbRed = start->rgbRed
219 + (end->rgbRed - start->rgbRed) * i / count;
220 bmi.bmiColors[i+index].rgbGreen = start->rgbGreen
221 + (end->rgbGreen - start->rgbGreen) * i / count;
222 bmi.bmiColors[i+index].rgbBlue = start->rgbBlue
223 + (end->rgbBlue - start->rgbBlue) * i / count;
224 }
225}
226
227/* initialise simulator lcd driver */
228void simlcdinit(void)
229{
230 bmi.bmiHeader.biClrUsed = (1<<LCD_DEPTH);
231 bmi.bmiHeader.biClrImportant = (1<<LCD_DEPTH);
232 lcdcolors(0, (1<<LCD_DEPTH), &color_zero, &color_max);
233}
234
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 @@
23#include "uisw32.h" 23#include "uisw32.h"
24#include "lcd.h" 24#include "lcd.h"
25 25
26// BITMAPINFO2 26// BITMAPINFO256
27typedef struct 27typedef struct
28{ 28{
29 BITMAPINFOHEADER bmiHeader; 29 BITMAPINFOHEADER bmiHeader;
30 RGBQUAD bmiColors[2]; 30 RGBQUAD bmiColors[256];
31} BITMAPINFO2; 31} BITMAPINFO256;
32 32
33#ifdef HAVE_LCD_BITMAP 33extern char bitmap[LCD_HEIGHT][LCD_WIDTH]; // the ui display
34 34extern BITMAPINFO256 bmi; // bitmap information
35extern unsigned char display[LCD_WIDTH][LCD_HEIGHT/8]; // the display
36#else
37#define DISP_X 112
38#define DISP_Y 64
39#endif
40
41
42extern char bitmap[LCD_HEIGHT][LCD_WIDTH]; // the ui display
43extern BITMAPINFO2 bmi; // bitmap information
44 35
36void simlcdinit(void);
45 37
46#endif // #ifndef __LCDWIN32_H__ 38#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 ()
239 239
240 if (hGUIWnd == NULL) 240 if (hGUIWnd == NULL)
241 return FALSE; 241 return FALSE;
242
243 simlcdinit();
242 244
243 return TRUE; 245 return TRUE;
244} 246}
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 @@
40#include "lcd-x11.h" 40#include "lcd-x11.h"
41#include "lcd-playersim.h" 41#include "lcd-playersim.h"
42 42
43extern unsigned char lcd_framebuffer[LCD_HEIGHT/8][LCD_WIDTH]; 43#if LCD_DEPTH == 2
44#define YBLOCK 4
45#define BITOFFS 1 /* take the MSB of each pixel */
46#else
47#define YBLOCK 8
48#define BITOFFS 0
49#endif
50
44extern void screen_resized(int width, int height); 51extern void screen_resized(int width, int height);
45 52
46#ifdef HAVE_LCD_BITMAP 53#ifdef HAVE_LCD_BITMAP
47unsigned char lcd_framebuffer_copy[LCD_HEIGHT/8][LCD_WIDTH]; 54extern unsigned char lcd_framebuffer[LCD_HEIGHT/YBLOCK][LCD_WIDTH];
55unsigned char lcd_framebuffer_copy[LCD_HEIGHT/YBLOCK][LCD_WIDTH];
48 56
49void lcd_update (void) 57void lcd_update (void)
50{ 58{
@@ -55,21 +63,21 @@ void lcd_update (void)
55 int cp=0; 63 int cp=0;
56 struct coordinate clearpoints[LCD_WIDTH * LCD_HEIGHT]; 64 struct coordinate clearpoints[LCD_WIDTH * LCD_HEIGHT];
57 65
58 for(y=0; y<LCD_HEIGHT; y+=8) { 66 for(y=0; y<LCD_HEIGHT; y+=YBLOCK) {
59 for(x=0; x<LCD_WIDTH; x++) { 67 for(x=0; x<LCD_WIDTH; x++) {
60 if(lcd_framebuffer[y/8][x] || lcd_framebuffer_copy[y/8][x]) { 68 if(lcd_framebuffer[y/YBLOCK][x] || lcd_framebuffer_copy[y/YBLOCK][x]) {
61 /* one or more bits/pixels are changed */ 69 /* one or more bits/pixels are changed */
62 unsigned char diff = 70 unsigned char diff =
63 lcd_framebuffer[y/8][x] ^ lcd_framebuffer_copy[y/8][x]; 71 lcd_framebuffer[y/YBLOCK][x] ^ lcd_framebuffer_copy[y/YBLOCK][x];
64 72
65 for(bit=0; bit<8; bit++) { 73 for(bit=0; bit<YBLOCK; bit++) {
66 if(lcd_framebuffer[y/8][x]&(1<<bit)) { 74 if(lcd_framebuffer[y/YBLOCK][x]&(1<<(bit*LCD_DEPTH+BITOFFS))) {
67 /* set a dot */ 75 /* set a dot */
68 points[p].x = x + MARGIN_X; 76 points[p].x = x + MARGIN_X;
69 points[p].y = y+bit + MARGIN_Y; 77 points[p].y = y+bit + MARGIN_Y;
70 p++; /* increase the point counter */ 78 p++; /* increase the point counter */
71 } 79 }
72 else if(diff &(1<<bit)) { 80 else if(diff &(1<<(bit*LCD_DEPTH+BITOFFS))) {
73 /* clear a dot */ 81 /* clear a dot */
74 clearpoints[cp].x = x + MARGIN_X; 82 clearpoints[cp].x = x + MARGIN_X;
75 clearpoints[cp].y = y+bit + MARGIN_Y; 83 clearpoints[cp].y = y+bit + MARGIN_Y;
@@ -110,33 +118,33 @@ void lcd_update_rect(int x_start, int y_start,
110 fprintf(stderr, "%04d: lcd_update_rect(%d, %d, %d, %d)\n", 118 fprintf(stderr, "%04d: lcd_update_rect(%d, %d, %d, %d)\n",
111 counter++, x_start, y_start, width, height); 119 counter++, x_start, y_start, width, height);
112#endif 120#endif
113 /* The Y coordinates have to work on even 8 pixel rows */ 121 /* The Y coordinates have to work on even YBLOCK pixel rows */
114 ymax = (yline + height)/8; 122 ymax = (yline + height)/YBLOCK;
115 yline /= 8; 123 yline /= YBLOCK;
116 124
117 xmax = x_start + width; 125 xmax = x_start + width;
118 126
119 if(xmax > LCD_WIDTH) 127 if(xmax > LCD_WIDTH)
120 xmax = LCD_WIDTH; 128 xmax = LCD_WIDTH;
121 if(ymax >= LCD_HEIGHT/8) 129 if(ymax >= LCD_HEIGHT/YBLOCK)
122 ymax = LCD_HEIGHT/8-1; 130 ymax = LCD_HEIGHT/YBLOCK-1;
123 131
124 for(; yline<=ymax; yline++) { 132 for(; yline<=ymax; yline++) {
125 y = yline * 8; 133 y = yline * YBLOCK;
126 for(x=x_start; x<xmax; x++) { 134 for(x=x_start; x<xmax; x++) {
127 if(lcd_framebuffer[yline][x] || lcd_framebuffer_copy[yline][x]) { 135 if(lcd_framebuffer[yline][x] || lcd_framebuffer_copy[yline][x]) {
128 /* one or more bits/pixels are changed */ 136 /* one or more bits/pixels are changed */
129 unsigned char diff = 137 unsigned char diff =
130 lcd_framebuffer[yline][x] ^ lcd_framebuffer_copy[yline][x]; 138 lcd_framebuffer[yline][x] ^ lcd_framebuffer_copy[yline][x];
131 139
132 for(bit=0; bit<8; bit++) { 140 for(bit=0; bit<YBLOCK; bit++) {
133 if(lcd_framebuffer[yline][x]&(1<<bit)) { 141 if(lcd_framebuffer[yline][x]&(1<<(bit*LCD_DEPTH+BITOFFS))) {
134 /* set a dot */ 142 /* set a dot */
135 points[p].x = x + MARGIN_X; 143 points[p].x = x + MARGIN_X;
136 points[p].y = y+bit + MARGIN_Y; 144 points[p].y = y+bit + MARGIN_Y;
137 p++; /* increase the point counter */ 145 p++; /* increase the point counter */
138 } 146 }
139 else if(diff &(1<<bit)) { 147 else if(diff &(1<<(bit*LCD_DEPTH+BITOFFS))) {
140 /* clear a dot */ 148 /* clear a dot */
141 clearpoints[cp].x = x + MARGIN_X; 149 clearpoints[cp].x = x + MARGIN_X;
142 clearpoints[cp].y = y+bit + MARGIN_Y; 150 clearpoints[cp].y = y+bit + MARGIN_Y;