diff options
author | Jörg Hohensohn <hohensoh@rockbox.org> | 2003-12-23 23:41:45 +0000 |
---|---|---|
committer | Jörg Hohensohn <hohensoh@rockbox.org> | 2003-12-23 23:41:45 +0000 |
commit | 5040cc53ec0e0281b2824b3a82d360adc60eff4c (patch) | |
tree | 80abb5a51247bb69aa69b1f98b922aa20a875779 | |
parent | 2d720b2a7968666bfc315026c8a69b8a762aa058 (diff) | |
download | rockbox-5040cc53ec0e0281b2824b3a82d360adc60eff4c.tar.gz rockbox-5040cc53ec0e0281b2824b3a82d360adc60eff4c.zip |
Screen buffer transposed, such that bytes in X-direction are consecutive. This enables my turbocharged lcd_write_data() for regular screen updates. Please check the X11 sim, Win32 works.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@4177 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | apps/misc.c | 4 | ||||
-rw-r--r-- | firmware/drivers/lcd-recorder.c | 39 | ||||
-rw-r--r-- | firmware/drivers/serial.c | 2 | ||||
-rw-r--r-- | firmware/export/lcd.h | 8 | ||||
-rw-r--r-- | uisimulator/win32/lcd-win32.c | 6 | ||||
-rw-r--r-- | uisimulator/x11/lcd-x11.c | 18 |
6 files changed, 40 insertions, 37 deletions
diff --git a/apps/misc.c b/apps/misc.c index 69cb7d3174..be1c3202fb 100644 --- a/apps/misc.c +++ b/apps/misc.c | |||
@@ -103,7 +103,7 @@ int main(int argc, char **argv) | |||
103 | #endif | 103 | #endif |
104 | 104 | ||
105 | #ifdef SCREENDUMP | 105 | #ifdef SCREENDUMP |
106 | extern unsigned char lcd_framebuffer[LCD_WIDTH][LCD_HEIGHT/8]; | 106 | extern unsigned char lcd_framebuffer[LCD_HEIGHT/8][LCD_WIDTH]; |
107 | static unsigned char bmpheader[] = | 107 | static unsigned char bmpheader[] = |
108 | { | 108 | { |
109 | 0x42, 0x4d, 0x3e, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, | 109 | 0x42, 0x4d, 0x3e, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, |
@@ -131,7 +131,7 @@ void screen_dump(void) | |||
131 | { | 131 | { |
132 | for(x = 0;x < LCD_WIDTH;x++) | 132 | for(x = 0;x < LCD_WIDTH;x++) |
133 | { | 133 | { |
134 | buf[i++] = lcd_framebuffer[x][y]; | 134 | buf[i++] = lcd_framebuffer[y][x]; |
135 | } | 135 | } |
136 | } | 136 | } |
137 | 137 | ||
diff --git a/firmware/drivers/lcd-recorder.c b/firmware/drivers/lcd-recorder.c index 9cc677ce15..910f1dc693 100644 --- a/firmware/drivers/lcd-recorder.c +++ b/firmware/drivers/lcd-recorder.c | |||
@@ -107,7 +107,7 @@ static int curfont = FONT_SYSFIXED; | |||
107 | static int xoffset = 0; /* needed for flip */ | 107 | static int xoffset = 0; /* needed for flip */ |
108 | #endif | 108 | #endif |
109 | 109 | ||
110 | unsigned char lcd_framebuffer[LCD_WIDTH][LCD_HEIGHT/8]; | 110 | unsigned char lcd_framebuffer[LCD_HEIGHT/8][LCD_WIDTH]; |
111 | 111 | ||
112 | /* All zeros and ones bitmaps for area filling */ | 112 | /* All zeros and ones bitmaps for area filling */ |
113 | static unsigned char zeros[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; | 113 | static unsigned char zeros[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; |
@@ -166,7 +166,6 @@ void lcd_init (void) | |||
166 | 166 | ||
167 | /* Performance function that works with an external buffer | 167 | /* Performance function that works with an external buffer |
168 | note that y and height are in 8-pixel units! */ | 168 | note that y and height are in 8-pixel units! */ |
169 | void lcd_blit (unsigned char* p_data, int x, int y, int width, int height, int stride) __attribute__ ((section (".icode"))); | ||
170 | void lcd_blit (unsigned char* p_data, int x, int y, int width, int height, int stride) | 169 | void lcd_blit (unsigned char* p_data, int x, int y, int width, int height, int stride) |
171 | { | 170 | { |
172 | /* Copy display bitmap to hardware */ | 171 | /* Copy display bitmap to hardware */ |
@@ -189,7 +188,7 @@ void lcd_blit (unsigned char* p_data, int x, int y, int width, int height, int s | |||
189 | void lcd_update (void) __attribute__ ((section (".icode"))); | 188 | void lcd_update (void) __attribute__ ((section (".icode"))); |
190 | void lcd_update (void) | 189 | void lcd_update (void) |
191 | { | 190 | { |
192 | int x, y; | 191 | int y; |
193 | 192 | ||
194 | /* Copy display bitmap to hardware */ | 193 | /* Copy display bitmap to hardware */ |
195 | for (y = 0; y < LCD_HEIGHT/8; y++) | 194 | for (y = 0; y < LCD_HEIGHT/8; y++) |
@@ -198,8 +197,7 @@ void lcd_update (void) | |||
198 | lcd_write (true, LCD_CNTL_HIGHCOL | ((xoffset>>4) & 0xf)); | 197 | lcd_write (true, LCD_CNTL_HIGHCOL | ((xoffset>>4) & 0xf)); |
199 | lcd_write (true, LCD_CNTL_LOWCOL | (xoffset & 0xf)); | 198 | lcd_write (true, LCD_CNTL_LOWCOL | (xoffset & 0xf)); |
200 | 199 | ||
201 | for (x = 0; x < LCD_WIDTH; x++) | 200 | lcd_write_data (lcd_framebuffer[y], LCD_WIDTH); |
202 | lcd_write (false, lcd_framebuffer[x][y]); | ||
203 | } | 201 | } |
204 | } | 202 | } |
205 | 203 | ||
@@ -211,17 +209,15 @@ void lcd_update_rect (int x_start, int y, | |||
211 | int width, int height) | 209 | int width, int height) |
212 | { | 210 | { |
213 | int ymax; | 211 | int ymax; |
214 | int xmax; | ||
215 | int x; | ||
216 | 212 | ||
217 | /* The Y coordinates have to work on even 8 pixel rows */ | 213 | /* The Y coordinates have to work on even 8 pixel rows */ |
218 | ymax = (y + height)/8; | 214 | ymax = (y + height-1)/8; |
219 | y /= 8; | 215 | y /= 8; |
220 | 216 | ||
221 | xmax = x_start + width; | 217 | if(x_start + width > LCD_WIDTH) |
222 | 218 | width = LCD_WIDTH - x_start; | |
223 | if(xmax > LCD_WIDTH) | 219 | if (width <= 0) |
224 | xmax = LCD_WIDTH; | 220 | return; /* nothing left to do, 0 is harmful to lcd_write_data() */ |
225 | if(ymax >= LCD_HEIGHT/8) | 221 | if(ymax >= LCD_HEIGHT/8) |
226 | ymax = LCD_HEIGHT/8-1; | 222 | ymax = LCD_HEIGHT/8-1; |
227 | 223 | ||
@@ -232,8 +228,7 @@ void lcd_update_rect (int x_start, int y, | |||
232 | lcd_write (true, LCD_CNTL_HIGHCOL | (((x_start+xoffset)>>4) & 0xf)); | 228 | lcd_write (true, LCD_CNTL_HIGHCOL | (((x_start+xoffset)>>4) & 0xf)); |
233 | lcd_write (true, LCD_CNTL_LOWCOL | ((x_start+xoffset) & 0xf)); | 229 | lcd_write (true, LCD_CNTL_LOWCOL | ((x_start+xoffset) & 0xf)); |
234 | 230 | ||
235 | for (x = x_start; x < xmax; x++) | 231 | lcd_write_data (&lcd_framebuffer[y][x_start], width); |
236 | lcd_write (false, lcd_framebuffer[x][y]); | ||
237 | } | 232 | } |
238 | } | 233 | } |
239 | 234 | ||
@@ -459,7 +454,15 @@ void lcd_bitmap (unsigned char *src, int x, int y, int nx, int ny, | |||
459 | ny = LCD_HEIGHT - y; | 454 | ny = LCD_HEIGHT - y; |
460 | 455 | ||
461 | shift = y & 7; | 456 | shift = y & 7; |
462 | dst2 = &lcd_framebuffer[x][y/8]; | 457 | dst2 = &lcd_framebuffer[y/8][x]; |
458 | |||
459 | /* short cut for byte aligned match (e.g. standard text) */ | ||
460 | if (!shift && ny==8) | ||
461 | { | ||
462 | memcpy(dst2, src, nx); | ||
463 | return; | ||
464 | } | ||
465 | |||
463 | ny += shift; | 466 | ny += shift; |
464 | 467 | ||
465 | /* Calculate bit masks */ | 468 | /* Calculate bit masks */ |
@@ -479,7 +482,7 @@ void lcd_bitmap (unsigned char *src, int x, int y, int nx, int ny, | |||
479 | for (x = 0; x < nx; x++) | 482 | for (x = 0; x < nx; x++) |
480 | { | 483 | { |
481 | dst = dst2; | 484 | dst = dst2; |
482 | dst2 += LCD_HEIGHT/8; | 485 | dst2++; |
483 | data = 0; | 486 | data = 0; |
484 | y = 0; | 487 | y = 0; |
485 | 488 | ||
@@ -489,7 +492,7 @@ void lcd_bitmap (unsigned char *src, int x, int y, int nx, int ny, | |||
489 | data = *src++ << shift; | 492 | data = *src++ << shift; |
490 | *dst = (*dst & mask) | data; | 493 | *dst = (*dst & mask) | data; |
491 | data >>= 8; | 494 | data >>= 8; |
492 | dst++; | 495 | dst += LCD_WIDTH; |
493 | 496 | ||
494 | /* Intermediate rows */ | 497 | /* Intermediate rows */ |
495 | for (y = 8; y < ny-8; y += 8) | 498 | for (y = 8; y < ny-8; y += 8) |
@@ -497,7 +500,7 @@ void lcd_bitmap (unsigned char *src, int x, int y, int nx, int ny, | |||
497 | data |= *src++ << shift; | 500 | data |= *src++ << shift; |
498 | *dst = (*dst & mask2) | data; | 501 | *dst = (*dst & mask2) | data; |
499 | data >>= 8; | 502 | data >>= 8; |
500 | dst++; | 503 | dst += LCD_WIDTH; |
501 | } | 504 | } |
502 | } | 505 | } |
503 | 506 | ||
diff --git a/firmware/drivers/serial.c b/firmware/drivers/serial.c index bc32dde5eb..5aae38e58c 100644 --- a/firmware/drivers/serial.c +++ b/firmware/drivers/serial.c | |||
@@ -177,7 +177,7 @@ static void screen_dump(void) | |||
177 | { | 177 | { |
178 | for(x = 0;x < LCD_WIDTH;x++) | 178 | for(x = 0;x < LCD_WIDTH;x++) |
179 | { | 179 | { |
180 | serial_tx(lcd_framebuffer[x][y]); | 180 | serial_tx(lcd_framebuffer[y][x]); |
181 | } | 181 | } |
182 | } | 182 | } |
183 | set_irq_level(level); | 183 | set_irq_level(level); |
diff --git a/firmware/export/lcd.h b/firmware/export/lcd.h index c81d2de2b3..733efdded3 100644 --- a/firmware/export/lcd.h +++ b/firmware/export/lcd.h | |||
@@ -111,14 +111,14 @@ void lcd_remove_cursor(void); | |||
111 | #define LCD_HEIGHT 64 /* Display height in pixels */ | 111 | #define LCD_HEIGHT 64 /* Display height in pixels */ |
112 | #endif | 112 | #endif |
113 | 113 | ||
114 | #define DRAW_PIXEL(x,y) lcd_framebuffer[(x)][(y)/8] |= (1<<((y)&7)) | 114 | #define DRAW_PIXEL(x,y) lcd_framebuffer[(y)/8][(x)] |= (1<<((y)&7)) |
115 | #define CLEAR_PIXEL(x,y) lcd_framebuffer[(x)][(y)/8] &= ~(1<<((y)&7)) | 115 | #define CLEAR_PIXEL(x,y) lcd_framebuffer[(y)/8][(x)] &= ~(1<<((y)&7)) |
116 | #define INVERT_PIXEL(x,y) lcd_framebuffer[(x)][(y)/8] ^= (1<<((y)&7)) | 116 | #define INVERT_PIXEL(x,y) lcd_framebuffer[(y)/8][(x)] ^= (1<<((y)&7)) |
117 | 117 | ||
118 | /* | 118 | /* |
119 | * Memory copy of display bitmap | 119 | * Memory copy of display bitmap |
120 | */ | 120 | */ |
121 | extern unsigned char lcd_framebuffer[LCD_WIDTH][LCD_HEIGHT/8]; | 121 | extern unsigned char lcd_framebuffer[LCD_HEIGHT/8][LCD_WIDTH]; |
122 | 122 | ||
123 | extern void lcd_setmargins(int xmargin, int ymargin); | 123 | extern void lcd_setmargins(int xmargin, int ymargin); |
124 | extern int lcd_getxmargin(void); | 124 | extern int lcd_getxmargin(void); |
diff --git a/uisimulator/win32/lcd-win32.c b/uisimulator/win32/lcd-win32.c index dcdb16f1f1..243e83dd2e 100644 --- a/uisimulator/win32/lcd-win32.c +++ b/uisimulator/win32/lcd-win32.c | |||
@@ -23,7 +23,7 @@ | |||
23 | #include "lcd.h" | 23 | #include "lcd.h" |
24 | #include "lcd-playersim.h" | 24 | #include "lcd-playersim.h" |
25 | 25 | ||
26 | unsigned char lcd_framebuffer[LCD_WIDTH][LCD_HEIGHT/8]; /* the display */ | 26 | unsigned char lcd_framebuffer[LCD_HEIGHT/8][LCD_WIDTH]; /* the display */ |
27 | char bitmap[LCD_HEIGHT][LCD_WIDTH]; /* the ui display */ | 27 | char bitmap[LCD_HEIGHT][LCD_WIDTH]; /* the ui display */ |
28 | 28 | ||
29 | BITMAPINFO2 bmi = | 29 | BITMAPINFO2 bmi = |
@@ -80,7 +80,7 @@ void lcd_update() | |||
80 | 80 | ||
81 | for (x = 0; x < LCD_WIDTH; x++) | 81 | for (x = 0; x < LCD_WIDTH; x++) |
82 | for (y = 0; y < LCD_HEIGHT; y++) | 82 | for (y = 0; y < LCD_HEIGHT; y++) |
83 | bitmap[y][x] = ((lcd_framebuffer[x][y/8] >> (y & 7)) & 1); | 83 | bitmap[y][x] = ((lcd_framebuffer[y/8][x] >> (y & 7)) & 1); |
84 | 84 | ||
85 | InvalidateRect (hGUIWnd, NULL, FALSE); | 85 | InvalidateRect (hGUIWnd, NULL, FALSE); |
86 | 86 | ||
@@ -107,7 +107,7 @@ void lcd_update_rect(int x_start, int y_start, | |||
107 | 107 | ||
108 | for (x = x_start; x < xmax; x++) | 108 | for (x = x_start; x < xmax; x++) |
109 | for (y = y_start; y < ymax; y++) | 109 | for (y = y_start; y < ymax; y++) |
110 | bitmap[y][x] = ((lcd_framebuffer[x][y/8] >> (y & 7)) & 1); | 110 | bitmap[y][x] = ((lcd_framebuffer[y/8][x] >> (y & 7)) & 1); |
111 | 111 | ||
112 | /* Bagder: If I only knew how, I would make this call only invalidate | 112 | /* Bagder: If I only knew how, I would make this call only invalidate |
113 | the actual rectangle we want updated here, this NULL thing here will | 113 | the actual rectangle we want updated here, this NULL thing here will |
diff --git a/uisimulator/x11/lcd-x11.c b/uisimulator/x11/lcd-x11.c index 023f06240c..c02b3e383f 100644 --- a/uisimulator/x11/lcd-x11.c +++ b/uisimulator/x11/lcd-x11.c | |||
@@ -39,12 +39,12 @@ | |||
39 | #include "lcd-x11.h" | 39 | #include "lcd-x11.h" |
40 | #include "lcd-playersim.h" | 40 | #include "lcd-playersim.h" |
41 | 41 | ||
42 | extern unsigned char lcd_framebuffer[LCD_WIDTH][LCD_HEIGHT/8]; | 42 | extern unsigned char lcd_framebuffer[LCD_HEIGHT/8][LCD_WIDTH]; |
43 | extern void screen_resized(int width, int height); | 43 | extern void screen_resized(int width, int height); |
44 | extern Display *dpy; | 44 | extern Display *dpy; |
45 | 45 | ||
46 | #ifdef HAVE_LCD_BITMAP | 46 | #ifdef HAVE_LCD_BITMAP |
47 | unsigned char lcd_framebuffer_copy[LCD_WIDTH][LCD_HEIGHT/8]; | 47 | unsigned char lcd_framebuffer_copy[LCD_HEIGHT/8][LCD_WIDTH]; |
48 | 48 | ||
49 | static int counter; | 49 | static int counter; |
50 | 50 | ||
@@ -66,13 +66,13 @@ void lcd_update (void) | |||
66 | 66 | ||
67 | for(y=0; y<LCD_HEIGHT; y+=8) { | 67 | for(y=0; y<LCD_HEIGHT; y+=8) { |
68 | for(x=0; x<LCD_WIDTH; x++) { | 68 | for(x=0; x<LCD_WIDTH; x++) { |
69 | if(lcd_framebuffer[x][y/8] || lcd_framebuffer_copy[x][y/8]) { | 69 | if(lcd_framebuffer[y/8][x] || lcd_framebuffer_copy[y/8][x]) { |
70 | /* one or more bits/pixels are changed */ | 70 | /* one or more bits/pixels are changed */ |
71 | unsigned char diff = | 71 | unsigned char diff = |
72 | lcd_framebuffer[x][y/8] ^ lcd_framebuffer_copy[x][y/8]; | 72 | lcd_framebuffer[y/8][x] ^ lcd_framebuffer_copy[y/8][x]; |
73 | 73 | ||
74 | for(bit=0; bit<8; bit++) { | 74 | for(bit=0; bit<8; bit++) { |
75 | if(lcd_framebuffer[x][y/8]&(1<<bit)) { | 75 | if(lcd_framebuffer[y/8][x]&(1<<bit)) { |
76 | /* set a dot */ | 76 | /* set a dot */ |
77 | points[p].x = x + MARGIN_X; | 77 | points[p].x = x + MARGIN_X; |
78 | points[p].y = y+bit + MARGIN_Y; | 78 | points[p].y = y+bit + MARGIN_Y; |
@@ -131,13 +131,13 @@ void lcd_update_rect(int x_start, int y_start, | |||
131 | for(; yline<=ymax; yline++) { | 131 | for(; yline<=ymax; yline++) { |
132 | y = yline * 8; | 132 | y = yline * 8; |
133 | for(x=x_start; x<xmax; x++) { | 133 | for(x=x_start; x<xmax; x++) { |
134 | if(lcd_framebuffer[x][yline] || lcd_framebuffer_copy[x][yline]) { | 134 | if(lcd_framebuffer[yline][x] || lcd_framebuffer_copy[yline][x]) { |
135 | /* one or more bits/pixels are changed */ | 135 | /* one or more bits/pixels are changed */ |
136 | unsigned char diff = | 136 | unsigned char diff = |
137 | lcd_framebuffer[x][yline] ^ lcd_framebuffer_copy[x][yline]; | 137 | lcd_framebuffer[yline][x] ^ lcd_framebuffer_copy[yline][x]; |
138 | 138 | ||
139 | for(bit=0; bit<8; bit++) { | 139 | for(bit=0; bit<8; bit++) { |
140 | if(lcd_framebuffer[x][yline]&(1<<bit)) { | 140 | if(lcd_framebuffer[yline][x]&(1<<bit)) { |
141 | /* set a dot */ | 141 | /* set a dot */ |
142 | points[p].x = x + MARGIN_X; | 142 | points[p].x = x + MARGIN_X; |
143 | points[p].y = y+bit + MARGIN_Y; | 143 | points[p].y = y+bit + MARGIN_Y; |
@@ -152,7 +152,7 @@ void lcd_update_rect(int x_start, int y_start, | |||
152 | } | 152 | } |
153 | 153 | ||
154 | /* update the copy */ | 154 | /* update the copy */ |
155 | lcd_framebuffer_copy[x][yline] = lcd_framebuffer[x][yline]; | 155 | lcd_framebuffer_copy[yline][x] = lcd_framebuffer[yline][x]; |
156 | } | 156 | } |
157 | } | 157 | } |
158 | } | 158 | } |