iPod: Fix the lcd_update_rect() function for the Color LCD, ensure rect is word-aligned and minor cosmetic cleanup

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8066 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Dave Chapman 2005-11-25 23:11:01 +00:00
parent 9589324082
commit 1946922c61

View file

@ -185,68 +185,73 @@ void lcd_blit(const fb_data* data, int x, int by, int width,
/* Update a fraction of the display. */ /* Update a fraction of the display. */
void lcd_update_rect(int x, int y, int width, int height) void lcd_update_rect(int x, int y, int width, int height)
{ {
int rect1, rect2, rect3, rect4; int y0, x0, y1, x1;
int newx,newwidth;
unsigned long *addr = (unsigned long *)lcd_framebuffer; unsigned long *addr = (unsigned long *)lcd_framebuffer;
/* TODO: Ensure x is even - so we read 32-bit aligned data from /* Ensure x and width are both even - so we can read 32-bit aligned
lcd_framebuffer */ data from lcd_framebuffer */
newx=x&~1;
newwidth=width&~1;
if (newx+newwidth < x+width) { newwidth+=2; }
x=newx; width=newwidth;
/* calculate the drawing region */ /* calculate the drawing region */
#if CONFIG_LCD == LCD_IPODCOLOR #if CONFIG_LCD == LCD_IPODNANO
rect1 = x; /* start vert */ y0 = x; /* start horiz */
rect2 = (LCD_WIDTH - 1) - y; /* start horiz */ x0 = y; /* start vert */
rect3 = (x + height) - 1; /* end vert */ y1 = (x + width) - 1; /* max horiz */
rect4 = (rect2 - width) + 1; /* end horiz */ x1 = (y + height) - 1; /* max vert */
#else #elif CONFIG_LCD == LCD_IPODCOLOR
rect1 = y; /* start horiz */ y0 = y; /* start vert */
rect2 = x; /* start vert */ x0 = (LCD_WIDTH - 1) - x; /* start horiz */
rect3 = (y + width) - 1; /* max horiz */ y1 = (y + height) - 1; /* end vert */
rect4 = (x + height) - 1; /* max vert */ x1 = (x0 - width) + 1; /* end horiz */
#endif #endif
/* setup the drawing region */ /* setup the drawing region */
if (lcd_type == 0) { if (lcd_type == 0) {
lcd_cmd_data(0x12, rect1); /* start vert */ lcd_cmd_data(0x12, y0); /* start vert */
lcd_cmd_data(0x13, rect2); /* start horiz */ lcd_cmd_data(0x13, x0); /* start horiz */
lcd_cmd_data(0x15, rect3); /* end vert */ lcd_cmd_data(0x15, y1); /* end vert */
lcd_cmd_data(0x16, rect4); /* end horiz */ lcd_cmd_data(0x16, x1); /* end horiz */
} else { } else {
/* swap max horiz < start horiz */ /* swap max horiz < start horiz */
if (rect3 < rect1) { if (y1 < y0) {
int t; int t;
t = rect1; t = y0;
rect1 = rect3; y0 = y1;
rect3 = t; y1 = t;
} }
/* swap max vert < start vert */ /* swap max vert < start vert */
if (rect4 < rect2) { if (x1 < x0) {
int t; int t;
t = rect2; t = x0;
rect2 = rect4; x0 = x1;
rect4 = t; x1 = t;
} }
/* max horiz << 8 | start horiz */ /* max horiz << 8 | start horiz */
lcd_cmd_data(LCD_CNTL_HORIZ_RAM_ADDR_POS, (rect3 << 8) | rect1); lcd_cmd_data(LCD_CNTL_HORIZ_RAM_ADDR_POS, (y1 << 8) | y0);
/* max vert << 8 | start vert */ /* max vert << 8 | start vert */
lcd_cmd_data(LCD_CNTL_VERT_RAM_ADDR_POS, (rect4 << 8) | rect2); lcd_cmd_data(LCD_CNTL_VERT_RAM_ADDR_POS, (x1 << 8) | x0);
/* start vert = max vert */ /* start vert = max vert */
#if CONFIG_LCD == LCD_IPODCOLOR #if CONFIG_LCD == LCD_IPODCOLOR
rect2 = rect4; x0 = x1;
#endif #endif
/* position cursor (set AD0-AD15) */ /* position cursor (set AD0-AD15) */
/* start vert << 8 | start horiz */ /* start vert << 8 | start horiz */
lcd_cmd_data(LCD_CNTL_RAM_ADDR_SET, (rect2 << 8) | rect1); lcd_cmd_data(LCD_CNTL_RAM_ADDR_SET, ((x0 << 8) | y0));
/* start drawing */ /* start drawing */
lcd_send_lo(0x0); lcd_send_lo(0x0);
lcd_send_lo(LCD_CNTL_WRITE_TO_GRAM); lcd_send_lo(LCD_CNTL_WRITE_TO_GRAM);
} }
addr += x * LCD_WIDTH + y/2; addr = (unsigned long*)&lcd_framebuffer[y][x];
while (height > 0) { while (height > 0) {
int c, r; int c, r;