From 5040cc53ec0e0281b2824b3a82d360adc60eff4c Mon Sep 17 00:00:00 2001 From: Jörg Hohensohn Date: Tue, 23 Dec 2003 23:41:45 +0000 Subject: 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 --- apps/misc.c | 4 ++-- firmware/drivers/lcd-recorder.c | 39 +++++++++++++++++++++------------------ firmware/drivers/serial.c | 2 +- firmware/export/lcd.h | 8 ++++---- uisimulator/win32/lcd-win32.c | 6 +++--- 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) #endif #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[] = { 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++) { - buf[i++] = lcd_framebuffer[x][y]; + buf[i++] = lcd_framebuffer[y][x]; } } 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; static int xoffset = 0; /* needed for flip */ #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 */ 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 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) { /* 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) { - int x, y; + int y; /* Copy display bitmap to hardware */ 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_LOWCOL | (xoffset & 0xf)); - for (x = 0; x < LCD_WIDTH; x++) - lcd_write (false, lcd_framebuffer[x][y]); + lcd_write_data (lcd_framebuffer[y], LCD_WIDTH); } } @@ -211,17 +209,15 @@ void lcd_update_rect (int x_start, int y, int width, int height) { int ymax; - int xmax; - int x; /* The Y coordinates have to work on even 8 pixel rows */ - ymax = (y + height)/8; + ymax = (y + height-1)/8; y /= 8; - xmax = x_start + width; - - if(xmax > LCD_WIDTH) - xmax = LCD_WIDTH; + if(x_start + width > LCD_WIDTH) + width = LCD_WIDTH - x_start; + if (width <= 0) + return; /* nothing left to do, 0 is harmful to lcd_write_data() */ if(ymax >= LCD_HEIGHT/8) 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_LOWCOL | ((x_start+xoffset) & 0xf)); - for (x = x_start; x < xmax; x++) - lcd_write (false, lcd_framebuffer[x][y]); + lcd_write_data (&lcd_framebuffer[y][x_start], width); } } @@ -459,7 +454,15 @@ void lcd_bitmap (unsigned char *src, int x, int y, int nx, int ny, ny = LCD_HEIGHT - y; 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; /* 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++) { dst = dst2; - dst2 += LCD_HEIGHT/8; + dst2++; data = 0; y = 0; @@ -489,7 +492,7 @@ void lcd_bitmap (unsigned char *src, int x, int y, int nx, int ny, data = *src++ << shift; *dst = (*dst & mask) | data; data >>= 8; - dst++; + dst += LCD_WIDTH; /* Intermediate rows */ 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; *dst = (*dst & mask2) | data; data >>= 8; - dst++; + dst += LCD_WIDTH; } } 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) { for(x = 0;x < LCD_WIDTH;x++) { - serial_tx(lcd_framebuffer[x][y]); + serial_tx(lcd_framebuffer[y][x]); } } 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); #define LCD_HEIGHT 64 /* Display height in pixels */ #endif -#define DRAW_PIXEL(x,y) lcd_framebuffer[(x)][(y)/8] |= (1<<((y)&7)) -#define CLEAR_PIXEL(x,y) lcd_framebuffer[(x)][(y)/8] &= ~(1<<((y)&7)) -#define INVERT_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[(y)/8][(x)] &= ~(1<<((y)&7)) +#define INVERT_PIXEL(x,y) lcd_framebuffer[(y)/8][(x)] ^= (1<<((y)&7)) /* * 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 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 @@ #include "lcd.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 */ BITMAPINFO2 bmi = @@ -80,7 +80,7 @@ void lcd_update() for (x = 0; x < LCD_WIDTH; x++) 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); @@ -107,7 +107,7 @@ void lcd_update_rect(int x_start, int y_start, for (x = x_start; x < xmax; x++) 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 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 @@ #include "lcd-x11.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 Display *dpy; #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; @@ -66,13 +66,13 @@ void lcd_update (void) for(y=0; y