1
0
Fork 0
forked from len0rd/rockbox

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
This commit is contained in:
Jörg Hohensohn 2003-12-23 23:41:45 +00:00
parent 2d720b2a79
commit 5040cc53ec
6 changed files with 40 additions and 37 deletions

View file

@ -103,7 +103,7 @@ int main(int argc, char **argv)
#endif #endif
#ifdef SCREENDUMP #ifdef SCREENDUMP
extern unsigned char lcd_framebuffer[LCD_WIDTH][LCD_HEIGHT/8]; extern unsigned char lcd_framebuffer[LCD_HEIGHT/8][LCD_WIDTH];
static unsigned char bmpheader[] = static unsigned char bmpheader[] =
{ {
0x42, 0x4d, 0x3e, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x42, 0x4d, 0x3e, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x00,
@ -131,7 +131,7 @@ void screen_dump(void)
{ {
for(x = 0;x < LCD_WIDTH;x++) for(x = 0;x < LCD_WIDTH;x++)
{ {
buf[i++] = lcd_framebuffer[x][y]; buf[i++] = lcd_framebuffer[y][x];
} }
} }

View file

@ -107,7 +107,7 @@ static int curfont = FONT_SYSFIXED;
static int xoffset = 0; /* needed for flip */ static int xoffset = 0; /* needed for flip */
#endif #endif
unsigned char lcd_framebuffer[LCD_WIDTH][LCD_HEIGHT/8]; unsigned char lcd_framebuffer[LCD_HEIGHT/8][LCD_WIDTH];
/* All zeros and ones bitmaps for area filling */ /* All zeros and ones bitmaps for area filling */
static unsigned char zeros[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; static unsigned char zeros[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
@ -166,7 +166,6 @@ void lcd_init (void)
/* Performance function that works with an external buffer /* Performance function that works with an external buffer
note that y and height are in 8-pixel units! */ note that y and height are in 8-pixel units! */
void lcd_blit (unsigned char* p_data, int x, int y, int width, int height, int stride) __attribute__ ((section (".icode")));
void lcd_blit (unsigned char* p_data, int x, int y, int width, int height, int stride) void lcd_blit (unsigned char* p_data, int x, int y, int width, int height, int stride)
{ {
/* Copy display bitmap to hardware */ /* 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
void lcd_update (void) __attribute__ ((section (".icode"))); void lcd_update (void) __attribute__ ((section (".icode")));
void lcd_update (void) void lcd_update (void)
{ {
int x, y; int y;
/* Copy display bitmap to hardware */ /* Copy display bitmap to hardware */
for (y = 0; y < LCD_HEIGHT/8; y++) for (y = 0; y < LCD_HEIGHT/8; y++)
@ -198,8 +197,7 @@ void lcd_update (void)
lcd_write (true, LCD_CNTL_HIGHCOL | ((xoffset>>4) & 0xf)); lcd_write (true, LCD_CNTL_HIGHCOL | ((xoffset>>4) & 0xf));
lcd_write (true, LCD_CNTL_LOWCOL | (xoffset & 0xf)); lcd_write (true, LCD_CNTL_LOWCOL | (xoffset & 0xf));
for (x = 0; x < LCD_WIDTH; x++) lcd_write_data (lcd_framebuffer[y], LCD_WIDTH);
lcd_write (false, lcd_framebuffer[x][y]);
} }
} }
@ -211,17 +209,15 @@ void lcd_update_rect (int x_start, int y,
int width, int height) int width, int height)
{ {
int ymax; int ymax;
int xmax;
int x;
/* The Y coordinates have to work on even 8 pixel rows */ /* The Y coordinates have to work on even 8 pixel rows */
ymax = (y + height)/8; ymax = (y + height-1)/8;
y /= 8; y /= 8;
xmax = x_start + width; if(x_start + width > LCD_WIDTH)
width = LCD_WIDTH - x_start;
if(xmax > LCD_WIDTH) if (width <= 0)
xmax = LCD_WIDTH; return; /* nothing left to do, 0 is harmful to lcd_write_data() */
if(ymax >= LCD_HEIGHT/8) if(ymax >= LCD_HEIGHT/8)
ymax = LCD_HEIGHT/8-1; ymax = LCD_HEIGHT/8-1;
@ -232,8 +228,7 @@ void lcd_update_rect (int x_start, int y,
lcd_write (true, LCD_CNTL_HIGHCOL | (((x_start+xoffset)>>4) & 0xf)); lcd_write (true, LCD_CNTL_HIGHCOL | (((x_start+xoffset)>>4) & 0xf));
lcd_write (true, LCD_CNTL_LOWCOL | ((x_start+xoffset) & 0xf)); lcd_write (true, LCD_CNTL_LOWCOL | ((x_start+xoffset) & 0xf));
for (x = x_start; x < xmax; x++) lcd_write_data (&lcd_framebuffer[y][x_start], width);
lcd_write (false, lcd_framebuffer[x][y]);
} }
} }
@ -459,7 +454,15 @@ void lcd_bitmap (unsigned char *src, int x, int y, int nx, int ny,
ny = LCD_HEIGHT - y; ny = LCD_HEIGHT - y;
shift = y & 7; shift = y & 7;
dst2 = &lcd_framebuffer[x][y/8]; dst2 = &lcd_framebuffer[y/8][x];
/* short cut for byte aligned match (e.g. standard text) */
if (!shift && ny==8)
{
memcpy(dst2, src, nx);
return;
}
ny += shift; ny += shift;
/* Calculate bit masks */ /* Calculate bit masks */
@ -479,7 +482,7 @@ void lcd_bitmap (unsigned char *src, int x, int y, int nx, int ny,
for (x = 0; x < nx; x++) for (x = 0; x < nx; x++)
{ {
dst = dst2; dst = dst2;
dst2 += LCD_HEIGHT/8; dst2++;
data = 0; data = 0;
y = 0; y = 0;
@ -489,7 +492,7 @@ void lcd_bitmap (unsigned char *src, int x, int y, int nx, int ny,
data = *src++ << shift; data = *src++ << shift;
*dst = (*dst & mask) | data; *dst = (*dst & mask) | data;
data >>= 8; data >>= 8;
dst++; dst += LCD_WIDTH;
/* Intermediate rows */ /* Intermediate rows */
for (y = 8; y < ny-8; y += 8) 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,
data |= *src++ << shift; data |= *src++ << shift;
*dst = (*dst & mask2) | data; *dst = (*dst & mask2) | data;
data >>= 8; data >>= 8;
dst++; dst += LCD_WIDTH;
} }
} }

View file

@ -177,7 +177,7 @@ static void screen_dump(void)
{ {
for(x = 0;x < LCD_WIDTH;x++) for(x = 0;x < LCD_WIDTH;x++)
{ {
serial_tx(lcd_framebuffer[x][y]); serial_tx(lcd_framebuffer[y][x]);
} }
} }
set_irq_level(level); set_irq_level(level);

View file

@ -111,14 +111,14 @@ void lcd_remove_cursor(void);
#define LCD_HEIGHT 64 /* Display height in pixels */ #define LCD_HEIGHT 64 /* Display height in pixels */
#endif #endif
#define DRAW_PIXEL(x,y) lcd_framebuffer[(x)][(y)/8] |= (1<<((y)&7)) #define DRAW_PIXEL(x,y) lcd_framebuffer[(y)/8][(x)] |= (1<<((y)&7))
#define CLEAR_PIXEL(x,y) lcd_framebuffer[(x)][(y)/8] &= ~(1<<((y)&7)) #define CLEAR_PIXEL(x,y) lcd_framebuffer[(y)/8][(x)] &= ~(1<<((y)&7))
#define INVERT_PIXEL(x,y) lcd_framebuffer[(x)][(y)/8] ^= (1<<((y)&7)) #define INVERT_PIXEL(x,y) lcd_framebuffer[(y)/8][(x)] ^= (1<<((y)&7))
/* /*
* Memory copy of display bitmap * Memory copy of display bitmap
*/ */
extern unsigned char lcd_framebuffer[LCD_WIDTH][LCD_HEIGHT/8]; extern unsigned char lcd_framebuffer[LCD_HEIGHT/8][LCD_WIDTH];
extern void lcd_setmargins(int xmargin, int ymargin); extern void lcd_setmargins(int xmargin, int ymargin);
extern int lcd_getxmargin(void); extern int lcd_getxmargin(void);

View file

@ -23,7 +23,7 @@
#include "lcd.h" #include "lcd.h"
#include "lcd-playersim.h" #include "lcd-playersim.h"
unsigned char lcd_framebuffer[LCD_WIDTH][LCD_HEIGHT/8]; /* the display */ unsigned char lcd_framebuffer[LCD_HEIGHT/8][LCD_WIDTH]; /* the display */
char bitmap[LCD_HEIGHT][LCD_WIDTH]; /* the ui display */ char bitmap[LCD_HEIGHT][LCD_WIDTH]; /* the ui display */
BITMAPINFO2 bmi = BITMAPINFO2 bmi =
@ -80,7 +80,7 @@ void lcd_update()
for (x = 0; x < LCD_WIDTH; x++) for (x = 0; x < LCD_WIDTH; x++)
for (y = 0; y < LCD_HEIGHT; y++) for (y = 0; y < LCD_HEIGHT; y++)
bitmap[y][x] = ((lcd_framebuffer[x][y/8] >> (y & 7)) & 1); bitmap[y][x] = ((lcd_framebuffer[y/8][x] >> (y & 7)) & 1);
InvalidateRect (hGUIWnd, NULL, FALSE); InvalidateRect (hGUIWnd, NULL, FALSE);
@ -107,7 +107,7 @@ void lcd_update_rect(int x_start, int y_start,
for (x = x_start; x < xmax; x++) for (x = x_start; x < xmax; x++)
for (y = y_start; y < ymax; y++) for (y = y_start; y < ymax; y++)
bitmap[y][x] = ((lcd_framebuffer[x][y/8] >> (y & 7)) & 1); bitmap[y][x] = ((lcd_framebuffer[y/8][x] >> (y & 7)) & 1);
/* Bagder: If I only knew how, I would make this call only invalidate /* Bagder: If I only knew how, I would make this call only invalidate
the actual rectangle we want updated here, this NULL thing here will the actual rectangle we want updated here, this NULL thing here will

View file

@ -39,12 +39,12 @@
#include "lcd-x11.h" #include "lcd-x11.h"
#include "lcd-playersim.h" #include "lcd-playersim.h"
extern unsigned char lcd_framebuffer[LCD_WIDTH][LCD_HEIGHT/8]; extern unsigned char lcd_framebuffer[LCD_HEIGHT/8][LCD_WIDTH];
extern void screen_resized(int width, int height); extern void screen_resized(int width, int height);
extern Display *dpy; extern Display *dpy;
#ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_BITMAP
unsigned char lcd_framebuffer_copy[LCD_WIDTH][LCD_HEIGHT/8]; unsigned char lcd_framebuffer_copy[LCD_HEIGHT/8][LCD_WIDTH];
static int counter; static int counter;
@ -66,13 +66,13 @@ void lcd_update (void)
for(y=0; y<LCD_HEIGHT; y+=8) { for(y=0; y<LCD_HEIGHT; y+=8) {
for(x=0; x<LCD_WIDTH; x++) { for(x=0; x<LCD_WIDTH; x++) {
if(lcd_framebuffer[x][y/8] || lcd_framebuffer_copy[x][y/8]) { if(lcd_framebuffer[y/8][x] || lcd_framebuffer_copy[y/8][x]) {
/* one or more bits/pixels are changed */ /* one or more bits/pixels are changed */
unsigned char diff = unsigned char diff =
lcd_framebuffer[x][y/8] ^ lcd_framebuffer_copy[x][y/8]; lcd_framebuffer[y/8][x] ^ lcd_framebuffer_copy[y/8][x];
for(bit=0; bit<8; bit++) { for(bit=0; bit<8; bit++) {
if(lcd_framebuffer[x][y/8]&(1<<bit)) { if(lcd_framebuffer[y/8][x]&(1<<bit)) {
/* set a dot */ /* set a dot */
points[p].x = x + MARGIN_X; points[p].x = x + MARGIN_X;
points[p].y = y+bit + MARGIN_Y; points[p].y = y+bit + MARGIN_Y;
@ -131,13 +131,13 @@ void lcd_update_rect(int x_start, int y_start,
for(; yline<=ymax; yline++) { for(; yline<=ymax; yline++) {
y = yline * 8; y = yline * 8;
for(x=x_start; x<xmax; x++) { for(x=x_start; x<xmax; x++) {
if(lcd_framebuffer[x][yline] || lcd_framebuffer_copy[x][yline]) { if(lcd_framebuffer[yline][x] || lcd_framebuffer_copy[yline][x]) {
/* one or more bits/pixels are changed */ /* one or more bits/pixels are changed */
unsigned char diff = unsigned char diff =
lcd_framebuffer[x][yline] ^ lcd_framebuffer_copy[x][yline]; lcd_framebuffer[yline][x] ^ lcd_framebuffer_copy[yline][x];
for(bit=0; bit<8; bit++) { for(bit=0; bit<8; bit++) {
if(lcd_framebuffer[x][yline]&(1<<bit)) { if(lcd_framebuffer[yline][x]&(1<<bit)) {
/* set a dot */ /* set a dot */
points[p].x = x + MARGIN_X; points[p].x = x + MARGIN_X;
points[p].y = y+bit + MARGIN_Y; points[p].y = y+bit + MARGIN_Y;
@ -152,7 +152,7 @@ void lcd_update_rect(int x_start, int y_start,
} }
/* update the copy */ /* update the copy */
lcd_framebuffer_copy[x][yline] = lcd_framebuffer[x][yline]; lcd_framebuffer_copy[yline][x] = lcd_framebuffer[yline][x];
} }
} }
} }