Third part of graphics api rework. Some small but effective optimisations. Ported remote lcd driver to new api. Preparations for including the low-level functions in the plugin api.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6907 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Jens Arnold 2005-06-29 01:39:50 +00:00
parent 7e11acbce9
commit 576908d36a
10 changed files with 503 additions and 383 deletions

View file

@ -80,7 +80,7 @@ int show_logo( void )
#ifdef HAVE_REMOTE_LCD #ifdef HAVE_REMOTE_LCD
lcd_remote_clear_display(); lcd_remote_clear_display();
lcd_remote_bitmap(rockbox112x37,10,14,112,37, false); lcd_remote_bitmap(rockbox112x37,10,14,112,37);
#endif #endif
snprintf(version, sizeof(version), "Ver. %s", appsversion); snprintf(version, sizeof(version), "Ver. %s", appsversion);

View file

@ -133,32 +133,33 @@ static const struct plugin_api rockbox_api = {
splash, splash,
#ifdef HAVE_REMOTE_LCD #ifdef HAVE_REMOTE_LCD
/* remote lcd */ /* remote lcd */
lcd_remote_set_contrast,
lcd_remote_clear_display, lcd_remote_clear_display,
lcd_remote_puts, lcd_remote_puts,
lcd_remote_puts_scroll, lcd_remote_puts_scroll,
lcd_remote_stop_scroll, lcd_remote_stop_scroll,
lcd_remote_set_contrast, lcd_remote_roll,
lcd_remote_set_drawmode,
lcd_remote_get_drawmode,
lcd_remote_setfont,
lcd_remote_getstringsize,
lcd_remote_drawpixel,
lcd_remote_drawline,
lcd_remote_hline,
lcd_remote_vline,
lcd_remote_drawrect,
lcd_remote_fillrect,
lcd_remote_bitmap_part,
lcd_remote_bitmap,
lcd_remote_putsxy, lcd_remote_putsxy,
lcd_remote_puts_style, lcd_remote_puts_style,
lcd_remote_puts_scroll_style, lcd_remote_puts_scroll_style,
lcd_remote_bitmap, &lcd_remote_framebuffer[0][0],
lcd_remote_drawline,
lcd_remote_clearline,
lcd_remote_drawpixel,
lcd_remote_clearpixel,
lcd_remote_setfont,
font_get,
lcd_remote_clearrect,
lcd_remote_fillrect,
lcd_remote_drawrect,
lcd_remote_invertrect,
lcd_remote_getstringsize,
lcd_remote_update, lcd_remote_update,
lcd_remote_update_rect, lcd_remote_update_rect,
lcd_remote_backlight_on, lcd_remote_backlight_on,
lcd_remote_backlight_off, lcd_remote_backlight_off,
&lcd_remote_framebuffer[0][0],
#endif #endif
/* button */ /* button */
button_get, button_get,

View file

@ -189,35 +189,39 @@ struct plugin_api {
#ifdef HAVE_REMOTE_LCD #ifdef HAVE_REMOTE_LCD
/* remote lcd */ /* remote lcd */
void (*remote_clear_display)(void); void (*lcd_remote_set_contrast)(int x);
void (*remote_puts)(int x, int y, const unsigned char *string); void (*lcd_remote_clear_display)(void);
void (*remote_lcd_puts_scroll)(int x, int y, const unsigned char* string); void (*lcd_remote_puts)(int x, int y, const unsigned char *string);
void (*remote_lcd_stop_scroll)(void); void (*lcd_remote_lcd_puts_scroll)(int x, int y, const unsigned char* string);
void (*remote_set_contrast)(int x); void (*lcd_remote_lcd_stop_scroll)(void);
void (*remote_putsxy)(int x, int y, const unsigned char *string); void (*lcd_remote_roll)(int pixels);
void (*remote_puts_style)(int x, int y, const unsigned char *str, int style);
void (*remote_puts_scroll_style)(int x, int y, const unsigned char* string, void (*lcd_remote_set_drawmode)(int mode);
int style); int (*lcd_remote_get_drawmode)(void);
void (*remote_bitmap)(const unsigned char *src, int x, int y, void (*lcd_remote_setfont)(int font);
int nx, int ny, bool clear); int (*lcd_remote_getstringsize)(const unsigned char *str, int *w, int *h);
void (*remote_drawline)(int x1, int y1, int x2, int y2); void (*lcd_remote_drawpixel)(int x, int y);
void (*remote_clearline)(int x1, int y1, int x2, int y2); void (*lcd_remote_drawline)(int x1, int y1, int x2, int y2);
void (*remote_drawpixel)(int x, int y); void (*lcd_remote_hline)(int x1, int x2, int y);
void (*remote_clearpixel)(int x, int y); void (*lcd_remote_vline)(int x, int y1, int y2);
void (*remote_setfont)(int font); void (*lcd_remote_drawrect)(int x, int y, int nx, int ny);
struct font* (*remote_font_get)(int font); void (*lcd_remote_fillrect)(int x, int y, int nx, int ny);
void (*remote_clearrect)(int x, int y, int nx, int ny); void (*lcd_remote_bitmap_part)(const unsigned char *src, int src_x,
void (*remote_fillrect)(int x, int y, int nx, int ny); int src_y, int stride, int x, int y,
void (*remote_drawrect)(int x, int y, int nx, int ny); int width, int height);
void (*remote_invertrect)(int x, int y, int nx, int ny); void (*lcd_remote_bitmap)(const unsigned char *src, int x, int y, int nx,
int (*remote_getstringsize)(const unsigned char *str, int *w, int *h); int ny);
void (*remote_update)(void); void (*lcd_remote_putsxy)(int x, int y, const unsigned char *string);
void (*remote_update_rect)(int x, int y, int width, int height); void (*lcd_remote_puts_style)(int x, int y, const unsigned char *str, int style);
void (*lcd_remote_puts_scroll_style)(int x, int y, const unsigned char* string,
int style);
unsigned char* lcd_remote_framebuffer;
void (*lcd_remote_update)(void);
void (*lcd_remote_update_rect)(int x, int y, int width, int height);
void (*remote_backlight_on)(void); void (*remote_backlight_on)(void);
void (*remote_backlight_off)(void); void (*remote_backlight_off)(void);
unsigned char* lcd_remote_framebuffer;
#endif #endif
/* button */ /* button */

View file

@ -231,11 +231,11 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) {
rb->lcd_clear_display(); rb->lcd_clear_display();
rb->lcd_bitmap(LOGO, x, y, LOGO_WIDTH, LOGO_HEIGHT); rb->lcd_bitmap(LOGO, x, y, LOGO_WIDTH, LOGO_HEIGHT);
#ifdef REMOTE_LOGO #ifdef REMOTE_LOGO
rb->remote_clear_display(); rb->lcd_remote_clear_display();
rb->remote_bitmap(REMOTE_LOGO, rb->lcd_remote_bitmap(REMOTE_LOGO,
(x * (REMOTE_WIDTH - REMOTE_LOGO_WIDTH)) / (DISPLAY_WIDTH - LOGO_WIDTH), (x * (REMOTE_WIDTH - REMOTE_LOGO_WIDTH)) / (DISPLAY_WIDTH - LOGO_WIDTH),
(y * (REMOTE_HEIGHT - REMOTE_LOGO_HEIGHT)) / (DISPLAY_HEIGHT - LOGO_HEIGHT), (y * (REMOTE_HEIGHT - REMOTE_LOGO_HEIGHT)) / (DISPLAY_HEIGHT - LOGO_HEIGHT),
REMOTE_LOGO_WIDTH, REMOTE_LOGO_HEIGHT, false); REMOTE_LOGO_WIDTH, REMOTE_LOGO_HEIGHT);
#endif #endif
#else #else
pgfx_clear_display(); pgfx_clear_display();
@ -266,7 +266,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) {
#ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_BITMAP
rb->lcd_update(); rb->lcd_update();
#ifdef REMOTE_LOGO #ifdef REMOTE_LOGO
rb->remote_update(); rb->lcd_remote_update();
#endif #endif
#else #else
if (cpos != old_cpos) { if (cpos != old_cpos) {

View file

@ -92,8 +92,10 @@ static void snow_move(void)
#ifdef HAVE_REMOTE_LCD #ifdef HAVE_REMOTE_LCD
if (particles[i][0] <= LCD_REMOTE_WIDTH if (particles[i][0] <= LCD_REMOTE_WIDTH
&& particles[i][1] <= LCD_REMOTE_HEIGHT) { && particles[i][1] <= LCD_REMOTE_HEIGHT) {
rb->remote_clearrect(particles[i][0],particles[i][1], rb->lcd_remote_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);
FLAKE_WIDTH,FLAKE_WIDTH); rb->lcd_remote_fillrect(particles[i][0],particles[i][1],
FLAKE_WIDTH,FLAKE_WIDTH);
rb->lcd_remote_set_drawmode(DRMODE_SOLID);
} }
#endif #endif
switch ((rb->rand()%7)) { switch ((rb->rand()%7)) {
@ -122,8 +124,8 @@ static void snow_move(void)
#ifdef HAVE_REMOTE_LCD #ifdef HAVE_REMOTE_LCD
if (particles[i][0] <= LCD_REMOTE_WIDTH if (particles[i][0] <= LCD_REMOTE_WIDTH
&& particles[i][1] <= LCD_REMOTE_HEIGHT) { && particles[i][1] <= LCD_REMOTE_HEIGHT) {
rb->remote_bitmap(flake,particles[i][0],particles[i][1], rb->lcd_remote_bitmap(flake,particles[i][0],particles[i][1],
FLAKE_WIDTH,FLAKE_WIDTH,true); FLAKE_WIDTH,FLAKE_WIDTH);
} }
#endif #endif
} }
@ -148,7 +150,7 @@ static void snow_init(void)
pgfx_clear_display(); pgfx_clear_display();
#endif #endif
#ifdef HAVE_REMOTE_LCD #ifdef HAVE_REMOTE_LCD
rb->remote_clear_display(); rb->lcd_remote_clear_display();
#endif #endif
} }
@ -175,7 +177,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
pgfx_update(); pgfx_update();
#endif #endif
#ifdef HAVE_REMOTE_LCD #ifdef HAVE_REMOTE_LCD
rb->remote_update(); rb->lcd_remote_update();
#endif #endif
rb->sleep(HZ/20); rb->sleep(HZ/20);

View file

@ -72,9 +72,10 @@ unsigned char lcd_remote_framebuffer[LCD_REMOTE_HEIGHT/8][LCD_REMOTE_WIDTH]
#endif #endif
; ;
static int curfont = FONT_SYSFIXED; static int drawmode = DRMODE_SOLID;
static int xmargin = 0; static int xmargin = 0;
static int ymargin = 0; static int ymargin = 0;
static int curfont = FONT_SYSFIXED;
#ifndef SIMULATOR #ifndef SIMULATOR
static int xoffset; /* needed for flip */ static int xoffset; /* needed for flip */
@ -90,12 +91,6 @@ static int cached_contrast = 32;
static int cached_roll = 0; static int cached_roll = 0;
#endif #endif
/* All zeros and ones bitmaps for area filling */
static const unsigned char zeros[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
static const unsigned char ones[8] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
};
/* scrolling */ /* scrolling */
static volatile int scrolling_lines=0; /* Bitpattern of which lines are scrolling */ static volatile int scrolling_lines=0; /* Bitpattern of which lines are scrolling */
#ifndef SIMULATOR #ifndef SIMULATOR
@ -397,10 +392,10 @@ void lcd_remote_update(void)
return; return;
/* Copy display bitmap to hardware */ /* Copy display bitmap to hardware */
for (y = 0; y < LCD_REMOTE_HEIGHT / 8; y++) for (y = 0; y < LCD_REMOTE_HEIGHT/8; y++)
{ {
lcd_remote_write_command(LCD_REMOTE_CNTL_SET_PAGE_ADDRESS | y); lcd_remote_write_command(LCD_REMOTE_CNTL_SET_PAGE_ADDRESS | y);
lcd_remote_write_command(LCD_REMOTE_CNTL_HIGHCOL | ((xoffset>>4) & 0xf)); lcd_remote_write_command(LCD_REMOTE_CNTL_HIGHCOL | ((xoffset >> 4) & 0xf));
lcd_remote_write_command(LCD_REMOTE_CNTL_LOWCOL | (xoffset & 0xf)); lcd_remote_write_command(LCD_REMOTE_CNTL_LOWCOL | (xoffset & 0xf));
lcd_remote_write_data(lcd_remote_framebuffer[y], LCD_REMOTE_WIDTH); lcd_remote_write_data(lcd_remote_framebuffer[y], LCD_REMOTE_WIDTH);
} }
@ -408,39 +403,49 @@ void lcd_remote_update(void)
/* Update a fraction of the display. */ /* Update a fraction of the display. */
void lcd_remote_update_rect(int, int, int, int) __attribute__ ((section (".icode"))); void lcd_remote_update_rect(int, int, int, int) __attribute__ ((section (".icode")));
void lcd_remote_update_rect(int x_start, int y, int width, int height) void lcd_remote_update_rect(int x, int y, int width, int height)
{ {
int ymax; int ymax;
if (!remote_initialized) if (!remote_initialized)
return; return;
/* 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-1)/8; ymax = (y + height-1) >> 3;
y /= 8; y >>= 3;
if(x_start + width > LCD_REMOTE_WIDTH) if(x + width > LCD_REMOTE_WIDTH)
width = LCD_REMOTE_WIDTH - x_start; width = LCD_REMOTE_WIDTH - x;
if (width <= 0) if (width <= 0)
return; /* nothing left to do, 0 is harmful to lcd_write_data() */ return; /* nothing left to do, 0 is harmful to lcd_write_data() */
if(ymax >= LCD_REMOTE_HEIGHT/8) if(ymax >= LCD_REMOTE_HEIGHT/8)
ymax = LCD_REMOTE_HEIGHT/8-1; ymax = LCD_REMOTE_HEIGHT/8-1;
x += xoffset;
/* Copy specified rectange bitmap to hardware */ /* Copy specified rectange bitmap to hardware */
for (; y <= ymax; y++) for (; y <= ymax; y++)
{ {
lcd_remote_write_command(LCD_REMOTE_CNTL_SET_PAGE_ADDRESS | y); lcd_remote_write_command(LCD_REMOTE_CNTL_SET_PAGE_ADDRESS | y);
lcd_remote_write_command(LCD_REMOTE_CNTL_HIGHCOL lcd_remote_write_command(LCD_REMOTE_CNTL_HIGHCOL | ((x >> 4) & 0xf));
| (((x_start+xoffset)>>4) & 0xf)); lcd_remote_write_command(LCD_REMOTE_CNTL_LOWCOL | (x & 0xf));
lcd_remote_write_command(LCD_REMOTE_CNTL_LOWCOL lcd_remote_write_data(&lcd_remote_framebuffer[y][x], width);
| ((x_start+xoffset) & 0xf));
lcd_remote_write_data(&lcd_remote_framebuffer[y][x_start], width);
} }
} }
#endif /* !SIMULATOR */ #endif /* !SIMULATOR */
/*** parameter handling ***/ /*** parameter handling ***/
void lcd_remote_set_drawmode(int mode)
{
drawmode = mode & (DRMODE_SOLID|DRMODE_INVERSEVID);
}
int lcd_remote_get_drawmode(void)
{
return drawmode;
}
void lcd_remote_setmargins(int x, int y) void lcd_remote_setmargins(int x, int y)
{ {
xmargin = x; xmargin = x;
@ -468,31 +473,98 @@ int lcd_remote_getstringsize(const unsigned char *str, int *w, int *h)
return font_getstringsize(str, w, h, curfont); return font_getstringsize(str, w, h, curfont);
} }
/*** low-level drawing functions ***/
static void setpixel(int x, int y)
{
REMOTE_DRAW_PIXEL(x, y);
}
static void clearpixel(int x, int y)
{
REMOTE_CLEAR_PIXEL(x, y);
}
static void flippixel(int x, int y)
{
REMOTE_INVERT_PIXEL(x, y);
}
static void nopixel(int x, int y)
{
(void)x;
(void)y;
}
lcd_pixelfunc_type* lcd_remote_pixelfuncs[8] = {
flippixel, nopixel, setpixel, setpixel,
nopixel, clearpixel, nopixel, clearpixel
};
static void flipblock(unsigned char *address, unsigned mask, unsigned bits)
{
*address ^= (bits & mask);
}
static void bgblock(unsigned char *address, unsigned mask, unsigned bits)
{
*address &= (bits | ~mask);
}
static void fgblock(unsigned char *address, unsigned mask, unsigned bits)
{
*address |= (bits & mask);
}
static void solidblock(unsigned char *address, unsigned mask, unsigned bits)
{
*address = (*address & ~mask) | (bits & mask);
}
static void flipinvblock(unsigned char *address, unsigned mask, unsigned bits)
{
*address ^= (~bits & mask);
}
static void bginvblock(unsigned char *address, unsigned mask, unsigned bits)
{
*address &= ~(bits & mask);
}
static void fginvblock(unsigned char *address, unsigned mask, unsigned bits)
{
*address |= (~bits & mask);
}
static void solidinvblock(unsigned char *address, unsigned mask, unsigned bits)
{
*address = (*address & ~mask) | (~bits & mask);
}
lcd_blockfunc_type* lcd_remote_blockfuncs[8] = {
flipblock, bgblock, fgblock, solidblock,
flipinvblock, bginvblock, fginvblock, solidinvblock
};
/*** drawing functions ***/ /*** drawing functions ***/
/* Clear the whole display */
void lcd_remote_clear_display(void) void lcd_remote_clear_display(void)
{ {
memset(lcd_remote_framebuffer, 0, sizeof lcd_remote_framebuffer); unsigned bits = (drawmode & DRMODE_INVERSEVID) ? 0xFFu : 0;
memset(lcd_remote_framebuffer, bits, sizeof lcd_remote_framebuffer);
scrolling_lines = 0;
} }
/* Set a single pixel */ /* Set a single pixel */
void lcd_remote_drawpixel(int x, int y) void lcd_remote_drawpixel(int x, int y)
{ {
REMOTE_DRAW_PIXEL(x,y); if (((unsigned)x < LCD_REMOTE_WIDTH) || ((unsigned)y < LCD_REMOTE_HEIGHT))
} lcd_remote_pixelfuncs[drawmode](x, y);
/* Clear a single pixel */
void lcd_remote_clearpixel(int x, int y)
{
REMOTE_CLEAR_PIXEL(x,y);
}
/* Invert a single pixel */
void lcd_remote_invertpixel(int x, int y)
{
REMOTE_INVERT_PIXEL(x,y);
} }
/* Draw a line */
void lcd_remote_drawline(int x1, int y1, int x2, int y2) void lcd_remote_drawline(int x1, int y1, int x2, int y2)
{ {
int numpixels; int numpixels;
@ -501,20 +573,21 @@ void lcd_remote_drawline(int x1, int y1, int x2, int y2)
int d, dinc1, dinc2; int d, dinc1, dinc2;
int x, xinc1, xinc2; int x, xinc1, xinc2;
int y, yinc1, yinc2; int y, yinc1, yinc2;
lcd_pixelfunc_type *pfunc = lcd_remote_pixelfuncs[drawmode];
deltax = abs(x2 - x1); deltax = abs(x2 - x1);
deltay = abs(y2 - y1); deltay = abs(y2 - y1);
xinc2 = 1;
yinc2 = 1;
if(deltax >= deltay) if (deltax >= deltay)
{ {
numpixels = deltax; numpixels = deltax;
d = 2 * deltay - deltax; d = 2 * deltay - deltax;
dinc1 = deltay * 2; dinc1 = deltay * 2;
dinc2 = (deltay - deltax) * 2; dinc2 = (deltay - deltax) * 2;
xinc1 = 1; xinc1 = 1;
xinc2 = 1;
yinc1 = 0; yinc1 = 0;
yinc2 = 1;
} }
else else
{ {
@ -523,19 +596,17 @@ void lcd_remote_drawline(int x1, int y1, int x2, int y2)
dinc1 = deltax * 2; dinc1 = deltax * 2;
dinc2 = (deltax - deltay) * 2; dinc2 = (deltax - deltay) * 2;
xinc1 = 0; xinc1 = 0;
xinc2 = 1;
yinc1 = 1; yinc1 = 1;
yinc2 = 1;
} }
numpixels++; /* include endpoints */ numpixels++; /* include endpoints */
if(x1 > x2) if (x1 > x2)
{ {
xinc1 = -xinc1; xinc1 = -xinc1;
xinc2 = -xinc2; xinc2 = -xinc2;
} }
if(y1 > y2) if (y1 > y2)
{ {
yinc1 = -yinc1; yinc1 = -yinc1;
yinc2 = -yinc2; yinc2 = -yinc2;
@ -544,11 +615,12 @@ void lcd_remote_drawline(int x1, int y1, int x2, int y2)
x = x1; x = x1;
y = y1; y = y1;
for(i=0; i<numpixels; i++) for (i = 0; i < numpixels; i++)
{ {
REMOTE_DRAW_PIXEL(x,y); if (((unsigned)x < LCD_REMOTE_WIDTH) && ((unsigned)y < LCD_REMOTE_HEIGHT))
pfunc(x, y);
if(d < 0) if (d < 0)
{ {
d += dinc1; d += dinc1;
x += xinc1; x += xinc1;
@ -563,255 +635,292 @@ void lcd_remote_drawline(int x1, int y1, int x2, int y2)
} }
} }
void lcd_remote_clearline(int x1, int y1, int x2, int y2) /* Draw a horizontal line (optimised) */
void lcd_remote_hline(int x1, int x2, int y)
{ {
int numpixels; int x;
int i; unsigned char *dst;
int deltax, deltay; unsigned mask;
int d, dinc1, dinc2; lcd_blockfunc_type *bfunc;
int x, xinc1, xinc2;
int y, yinc1, yinc2;
deltax = abs(x2 - x1); /* direction flip */
deltay = abs(y2 - y1); if (x2 < x1)
if(deltax >= deltay)
{ {
numpixels = deltax; x = x1;
d = 2 * deltay - deltax; x1 = x2;
dinc1 = deltay * 2; x2 = x;
dinc2 = (deltay - deltax) * 2;
xinc1 = 1;
xinc2 = 1;
yinc1 = 0;
yinc2 = 1;
}
else
{
numpixels = deltay;
d = 2 * deltax - deltay;
dinc1 = deltax * 2;
dinc2 = (deltax - deltay) * 2;
xinc1 = 0;
xinc2 = 1;
yinc1 = 1;
yinc2 = 1;
}
numpixels++; /* include endpoints */
if(x1 > x2)
{
xinc1 = -xinc1;
xinc2 = -xinc2;
}
if(y1 > y2)
{
yinc1 = -yinc1;
yinc2 = -yinc2;
}
x = x1;
y = y1;
for(i=0; i<numpixels; i++)
{
REMOTE_CLEAR_PIXEL(x,y);
if(d < 0)
{
d += dinc1;
x += xinc1;
y += yinc1;
}
else
{
d += dinc2;
x += xinc2;
y += yinc2;
}
}
}
void lcd_remote_drawrect(int x, int y, int nx, int ny)
{
int i;
if (x > LCD_REMOTE_WIDTH)
{
return;
} }
if (y > LCD_REMOTE_HEIGHT) /* nothing to draw? */
{ if (((unsigned)y >= LCD_REMOTE_HEIGHT) || (x1 >= LCD_REMOTE_WIDTH)
return; || (x2 < 0))
} return;
if (x + nx > LCD_REMOTE_WIDTH)
{
nx = LCD_REMOTE_WIDTH - x;
}
if (y + ny > LCD_REMOTE_HEIGHT) /* clipping */
{ if (x1 < 0)
ny = LCD_REMOTE_HEIGHT - y; x1 = 0;
} if (x2 >= LCD_REMOTE_WIDTH)
x2 = LCD_REMOTE_WIDTH-1;
/* vertical lines */
for (i = 0; i < ny; i++)
{
REMOTE_DRAW_PIXEL(x, (y + i));
REMOTE_DRAW_PIXEL((x + nx - 1), (y + i));
}
/* horizontal lines */
for (i = 0; i < nx; i++)
{
REMOTE_DRAW_PIXEL((x + i),y);
REMOTE_DRAW_PIXEL((x + i),(y + ny - 1));
}
}
/* Clear a rectangular area at (x, y), size (nx, ny) */
void lcd_remote_clearrect(int x, int y, int nx, int ny)
{
int i;
for (i = 0; i < nx; i++)
lcd_remote_bitmap(zeros, x+i, y, 1, ny, true);
}
/* Fill a rectangular area at (x, y), size (nx, ny) */
void lcd_remote_fillrect(int x, int y, int nx, int ny)
{
int i;
for (i = 0; i < nx; i++)
lcd_remote_bitmap(ones, x+i, y, 1, ny, true);
}
/* Invert a rectangular area at (x, y), size (nx, ny) */
void lcd_remote_invertrect(int x, int y, int nx, int ny)
{
int i, j;
if (x > LCD_REMOTE_WIDTH)
return;
if (y > LCD_REMOTE_HEIGHT)
return;
if (x + nx > LCD_REMOTE_WIDTH)
nx = LCD_REMOTE_WIDTH - x;
if (y + ny > LCD_REMOTE_HEIGHT)
ny = LCD_REMOTE_HEIGHT - y;
for (i = 0; i < nx; i++)
for (j = 0; j < ny; j++)
REMOTE_INVERT_PIXEL((x + i), (y + j));
}
void lcd_remote_bitmap(const unsigned char *src, int x, int y, int nx, int ny,
bool clear) __attribute__ ((section (".icode")));
void lcd_remote_bitmap(const unsigned char *src, int x, int y, int nx, int ny,
bool clear)
{
const unsigned char *src_col;
unsigned char *dst, *dst_col;
unsigned int data, mask1, mask2, mask3, mask4;
int stride, shift;
if (((unsigned) x >= LCD_REMOTE_WIDTH) || ((unsigned) y >= LCD_REMOTE_HEIGHT))
{
return;
}
stride = nx; /* otherwise right-clipping will destroy the image */
if (((unsigned) (x + nx)) >= LCD_REMOTE_WIDTH)
{
nx = LCD_REMOTE_WIDTH - x;
}
if (((unsigned) (y + ny)) >= LCD_REMOTE_HEIGHT)
{
ny = LCD_REMOTE_HEIGHT - y;
}
dst = &lcd_remote_framebuffer[y >> 3][x]; bfunc = lcd_remote_blockfuncs[drawmode];
shift = y & 7; dst = &lcd_remote_framebuffer[y>>3][x1];
mask = 1 << (y & 7);
if (!shift && clear) /* shortcut for byte aligned match with clear */
for (x = x1; x <= x2; x++)
bfunc(dst++, mask, 0xFFu);
}
/* Draw a vertical line (optimised) */
void lcd_remote_vline(int x, int y1, int y2)
{
int ny;
unsigned char *dst;
unsigned mask, mask_bottom;
lcd_blockfunc_type *bfunc;
/* direction flip */
if (y2 < y1)
{ {
while (ny >= 8) /* all full rows */ ny = y1;
y1 = y2;
y2 = ny;
}
/* nothing to draw? */
if (((unsigned)x >= LCD_REMOTE_WIDTH) || (y1 >= LCD_REMOTE_HEIGHT)
|| (y2 < 0))
return;
/* clipping */
if (y1 < 0)
y1 = 0;
if (y2 >= LCD_REMOTE_HEIGHT)
y2 = LCD_REMOTE_HEIGHT-1;
bfunc = lcd_remote_blockfuncs[drawmode];
dst = &lcd_remote_framebuffer[y1>>3][x];
ny = y2 - (y1 & ~7);
mask = 0xFFu << (y1 & 7);
mask_bottom = 0xFFu >> (7 - (ny & 7));
for (; ny >= 8; ny -= 8)
{
bfunc(dst, mask, 0xFFu);
dst += LCD_REMOTE_WIDTH;
mask = 0xFFu;
}
mask_bottom &= mask;
bfunc(dst, mask_bottom, 0xFFu);
}
/* Draw a rectangular box */
void lcd_remote_drawrect(int x, int y, int width, int height)
{
if ((width <= 0) || (height <= 0))
return;
int x2 = x + width - 1;
int y2 = y + height - 1;
lcd_remote_vline(x, y, y2);
lcd_remote_vline(x2, y, y2);
lcd_remote_hline(x, x2, y);
lcd_remote_hline(x, x2, y2);
}
/* Fill a rectangular area */
void lcd_remote_fillrect(int x, int y, int width, int height)
{
int ny, i;
unsigned char *dst;
unsigned mask, mask_bottom;
unsigned bits = 0xFFu;
lcd_blockfunc_type *bfunc;
bool fillopt;
/* nothing to draw? */
if ((width <= 0) || (height <= 0) || (x >= LCD_REMOTE_WIDTH)
|| (y >= LCD_REMOTE_HEIGHT) || (x + width <= 0) || (y + height <= 0))
return;
/* clipping */
if (x < 0)
{
width += x;
x = 0;
}
if (y < 0)
{
height += y;
y = 0;
}
if (x + width > LCD_REMOTE_WIDTH)
width = LCD_REMOTE_WIDTH - x;
if (y + height > LCD_REMOTE_HEIGHT)
height = LCD_REMOTE_HEIGHT - y;
fillopt = (drawmode & DRMODE_INVERSEVID) ?
(drawmode & DRMODE_BG) : (drawmode & DRMODE_FG);
if (fillopt &&(drawmode & DRMODE_INVERSEVID))
bits = 0;
bfunc = lcd_remote_blockfuncs[drawmode];
dst = &lcd_remote_framebuffer[y>>3][x];
ny = height - 1 + (y & 7);
mask = 0xFFu << (y & 7);
mask_bottom = 0xFFu >> (7 - (ny & 7));
for (; ny >= 8; ny -= 8)
{
if (fillopt && (mask == 0xFFu))
memset(dst, bits, width);
else
{ {
memcpy(dst, src, nx); unsigned char *dst_row = dst;
for (i = width; i > 0; i--)
bfunc(dst_row++, mask, 0xFFu);
}
dst += LCD_REMOTE_WIDTH;
mask = 0xFFu;
}
mask_bottom &= mask;
if (fillopt && (mask_bottom == 0xFFu))
memset(dst, bits, width);
else
{
for (i = width; i > 0; i--)
bfunc(dst++, mask_bottom, 0xFFu);
}
}
/* About Rockbox' internal bitmap format:
*
* A bitmap contains one bit for every pixel that defines if that pixel is
* black (1) or white (0). Bits within a byte are arranged vertically, LSB
* at top.
* The bytes are stored in row-major order, with byte 0 being top left,
* byte 1 2nd from left etc. The first row of bytes defines pixel rows
* 0..7, the second row defines pixel row 8..15 etc.
*
* This is the same as the internal lcd hw format. */
/* Draw a partial bitmap */
void lcd_remote_bitmap_part(const unsigned char *src, int src_x, int src_y,
int stride, int x, int y, int width, int height)
__attribute__ ((section(".icode")));
void lcd_remote_bitmap_part(const unsigned char *src, int src_x, int src_y,
int stride, int x, int y, int width, int height)
{
int shift, ny, i;
unsigned char *dst;
unsigned mask, mask_bottom;
lcd_blockfunc_type *bfunc;
/* nothing to draw? */
if ((width <= 0) || (height <= 0) || (x >= LCD_REMOTE_WIDTH)
|| (y >= LCD_REMOTE_HEIGHT) || (x + width <= 0) || (y + height <= 0))
return;
/* clipping */
if (x < 0)
{
width += x;
src_x -= x;
x = 0;
}
if (y < 0)
{
height += y;
src_y -= y;
y = 0;
}
if (x + width > LCD_REMOTE_WIDTH)
width = LCD_REMOTE_WIDTH - x;
if (y + height > LCD_REMOTE_HEIGHT)
height = LCD_REMOTE_HEIGHT - y;
src += stride * (src_y >> 3) + src_x; /* move starting point */
src_y &= 7;
y -= src_y;
dst = &lcd_remote_framebuffer[y>>3][x];
shift = y & 7;
ny = height - 1 + shift + src_y;
bfunc = lcd_remote_blockfuncs[drawmode];
mask = 0xFFu << (shift + src_y);
mask_bottom = 0xFFu >> (7 - (ny & 7));
if (shift == 0)
{
bool copyopt = (drawmode == DRMODE_SOLID);
for (; ny >= 8; ny -= 8)
{
if (copyopt && (mask == 0xFFu))
memcpy(dst, src, width);
else
{
const unsigned char *src_row = src;
unsigned char *dst_row = dst;
for (i = width; i > 0; i--)
bfunc(dst_row++, mask, *src_row++);
}
src += stride; src += stride;
dst += LCD_REMOTE_WIDTH; dst += LCD_REMOTE_WIDTH;
ny -= 8; mask = 0xFFu;
} }
if (ny == 0) /* nothing left to do? */ mask_bottom &= mask;
{
return;
}
/* last partial row to do by default routine */
}
ny += shift; if (copyopt && (mask_bottom == 0xFFu))
memcpy(dst, src, width);
/* Calculate bit masks */ else
mask4 = ~(0xfe << ((ny-1) & 7)); /* data mask for last partial row */
if (clear)
{
mask1 = ~(0xff << shift); /* clearing of first partial row */
mask2 = 0; /* clearing of intermediate (full) rows */
mask3 = ~mask4; /* clearing of last partial row */
if (ny <= 8)
{ {
mask3 |= mask1; for (i = width; i > 0; i--)
bfunc(dst++, mask_bottom, *src++);
} }
} }
else else
{ {
mask1 = mask2 = mask3 = 0xff; for (x = 0; x < width; x++)
}
/* Loop for each column */
for (x = 0; x < nx; x++)
{
src_col = src++;
dst_col = dst++;
data = 0;
y = 0;
if (ny > 8)
{ {
/* First partial row */ const unsigned char *src_col = src++;
data = *src_col << shift; unsigned char *dst_col = dst++;
*dst_col = (*dst_col & mask1) | data; unsigned mask_col = mask;
src_col += stride; unsigned data = 0;
dst_col += LCD_REMOTE_WIDTH;
data >>= 8; for (y = ny; y >= 8; y -= 8)
/* Intermediate rows */
for (y = 8; y < ny-8; y += 8)
{ {
data |= *src_col << shift; data |= *src_col << shift;
*dst_col = (*dst_col & mask2) | data;
if (mask_col & 0xFFu)
{
bfunc(dst_col, mask_col, data);
mask_col = 0xFFu;
}
else
mask_col >>= 8;
src_col += stride; src_col += stride;
dst_col += LCD_REMOTE_WIDTH; dst_col += LCD_REMOTE_WIDTH;
data >>= 8; data >>= 8;
} }
}
/* Last partial row */
if (y + shift < ny)
{
data |= *src_col << shift; data |= *src_col << shift;
bfunc(dst_col, mask_col & mask_bottom, data);
} }
*dst_col = (*dst_col & mask3) | (data & mask4);
} }
} }
/* Draw a full bitmap */
void lcd_remote_bitmap(const unsigned char *src, int x, int y, int width,
int height)
{
lcd_remote_bitmap_part(src, 0, 0, width, x, y, width, height);
}
/* put a string at a given pixel position, skipping first ofs pixel columns */ /* put a string at a given pixel position, skipping first ofs pixel columns */
static void lcd_remote_putsxyofs(int x, int y, int ofs, const unsigned char *str) static void lcd_remote_putsxyofs(int x, int y, int ofs, const unsigned char *str)
{ {
@ -820,7 +929,8 @@ static void lcd_remote_putsxyofs(int x, int y, int ofs, const unsigned char *str
while ((ch = *str++) != '\0' && x < LCD_REMOTE_WIDTH) while ((ch = *str++) != '\0' && x < LCD_REMOTE_WIDTH)
{ {
int gwidth, width; int width;
const unsigned char *bits;
/* check input range */ /* check input range */
if (ch < pf->firstchar || ch >= pf->firstchar+pf->size) if (ch < pf->firstchar || ch >= pf->firstchar+pf->size)
@ -828,40 +938,21 @@ static void lcd_remote_putsxyofs(int x, int y, int ofs, const unsigned char *str
ch -= pf->firstchar; ch -= pf->firstchar;
/* get proportional width and glyph bits */ /* get proportional width and glyph bits */
gwidth = pf->width ? pf->width[ch] : pf->maxwidth; width = pf->width ? pf->width[ch] : pf->maxwidth;
width = MIN (gwidth, LCD_REMOTE_WIDTH - x);
if (ofs != 0) if (ofs > width)
{ {
if (ofs > width) ofs -= width;
{ continue;
ofs -= width;
continue;
}
width -= ofs;
} }
if (width > 0) bits = pf->bits + (pf->offset ?
{ pf->offset[ch] : ((pf->height + 7) / 8 * pf->maxwidth * ch));
unsigned int i;
const unsigned char* bits = pf->bits +
(pf->offset ? pf->offset[ch]
: ((pf->height + 7) / 8 * pf->maxwidth * ch));
if (ofs != 0) lcd_remote_bitmap_part(bits, ofs, 0, width, x, y, width - ofs,
{ pf->height);
for (i = 0; i < pf->height; i += 8)
{ x += width - ofs;
lcd_remote_bitmap (bits + ofs, x, y + i, width,
MIN(8, pf->height - i), true);
bits += gwidth;
}
}
else
lcd_remote_bitmap ((unsigned char*) bits, x, y, gwidth,
pf->height, true);
x += width;
}
ofs = 0; ofs = 0;
} }
} }
@ -883,9 +974,10 @@ void lcd_remote_puts(int x, int y, const unsigned char *str)
void lcd_remote_puts_style(int x, int y, const unsigned char *str, int style) void lcd_remote_puts_style(int x, int y, const unsigned char *str, int style)
{ {
int xpos,ypos,w,h; int xpos,ypos,w,h;
int lastmode = lcd_remote_get_drawmode();
/* make sure scrolling is turned off on the line we are updating */ /* make sure scrolling is turned off on the line we are updating */
//scrolling_lines &= ~(1 << y); scrolling_lines &= ~(1 << y);
if(!str || !str[0]) if(!str || !str[0])
return; return;
@ -894,10 +986,14 @@ void lcd_remote_puts_style(int x, int y, const unsigned char *str, int style)
xpos = xmargin + x*w / strlen(str); xpos = xmargin + x*w / strlen(str);
ypos = ymargin + y*h; ypos = ymargin + y*h;
lcd_remote_putsxy(xpos, ypos, str); lcd_remote_putsxy(xpos, ypos, str);
lcd_remote_clearrect(xpos + w, ypos, LCD_REMOTE_WIDTH - (xpos + w), h); lcd_remote_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);
lcd_remote_fillrect(xpos + w, ypos, LCD_REMOTE_WIDTH - (xpos + w), h);
if (style & STYLE_INVERT) if (style & STYLE_INVERT)
lcd_remote_invertrect(xpos, ypos, LCD_REMOTE_WIDTH - xpos, h); {
lcd_remote_set_drawmode(DRMODE_COMPLEMENT);
lcd_remote_fillrect(xpos, ypos, LCD_REMOTE_WIDTH - xpos, h);
}
lcd_remote_set_drawmode(lastmode);
} }
/*** scrolling ***/ /*** scrolling ***/
@ -1008,6 +1104,7 @@ static void scroll_thread(void)
struct scrollinfo* s; struct scrollinfo* s;
int index; int index;
int xpos, ypos; int xpos, ypos;
int lastmode;
/* initialize scroll struct array */ /* initialize scroll struct array */
scrolling_lines = 0; scrolling_lines = 0;
@ -1061,10 +1158,17 @@ static void scroll_thread(void)
s->offset %= s->width; s->offset %= s->width;
} }
lcd_remote_clearrect(xpos, ypos, LCD_REMOTE_WIDTH - xpos, pf->height); lastmode = lcd_remote_get_drawmode();
lcd_remote_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);
lcd_remote_fillrect(xpos, ypos, LCD_REMOTE_WIDTH - xpos, pf->height);
lcd_remote_set_drawmode(DRMODE_SOLID);
lcd_remote_putsxyofs(xpos, ypos, s->offset, s->line); lcd_remote_putsxyofs(xpos, ypos, s->offset, s->line);
if (s->invert) if (s->invert)
lcd_remote_invertrect(xpos, ypos, LCD_REMOTE_WIDTH - xpos, pf->height); {
lcd_remote_set_drawmode(DRMODE_COMPLEMENT);
lcd_remote_fillrect(xpos, ypos, LCD_REMOTE_WIDTH - xpos, pf->height);
}
lcd_remote_set_drawmode(lastmode);
lcd_remote_update_rect(xpos, ypos, LCD_REMOTE_WIDTH - xpos, pf->height); lcd_remote_update_rect(xpos, ypos, LCD_REMOTE_WIDTH - xpos, pf->height);
} }

View file

@ -333,7 +333,7 @@ static void nopixel(int x, int y)
(void)y; (void)y;
} }
lcd_pixelfunc_type* pixelfunc[8] = { lcd_pixelfunc_type* lcd_pixelfuncs[8] = {
flippixel, nopixel, setpixel, setpixel, flippixel, nopixel, setpixel, setpixel,
nopixel, clearpixel, nopixel, clearpixel nopixel, clearpixel, nopixel, clearpixel
}; };
@ -378,7 +378,7 @@ static void solidinvblock(unsigned char *address, unsigned mask, unsigned bits)
*address = (*address & ~mask) | (~bits & mask); *address = (*address & ~mask) | (~bits & mask);
} }
lcd_blockfunc_type* blockfunc[8] = { lcd_blockfunc_type* lcd_blockfuncs[8] = {
flipblock, bgblock, fgblock, solidblock, flipblock, bgblock, fgblock, solidblock,
flipinvblock, bginvblock, fginvblock, solidinvblock flipinvblock, bginvblock, fginvblock, solidinvblock
}; };
@ -398,7 +398,7 @@ void lcd_clear_display(void)
void lcd_drawpixel(int x, int y) void lcd_drawpixel(int x, int y)
{ {
if (((unsigned)x < LCD_WIDTH) || ((unsigned)y < LCD_HEIGHT)) if (((unsigned)x < LCD_WIDTH) || ((unsigned)y < LCD_HEIGHT))
pixelfunc[drawmode](x, y); lcd_pixelfuncs[drawmode](x, y);
} }
/* Draw a line */ /* Draw a line */
@ -410,7 +410,7 @@ void lcd_drawline(int x1, int y1, int x2, int y2)
int d, dinc1, dinc2; int d, dinc1, dinc2;
int x, xinc1, xinc2; int x, xinc1, xinc2;
int y, yinc1, yinc2; int y, yinc1, yinc2;
lcd_pixelfunc_type *pfunc = pixelfunc[drawmode]; lcd_pixelfunc_type *pfunc = lcd_pixelfuncs[drawmode];
deltax = abs(x2 - x1); deltax = abs(x2 - x1);
deltay = abs(y2 - y1); deltay = abs(y2 - y1);
@ -498,7 +498,7 @@ void lcd_hline(int x1, int x2, int y)
if (x2 >= LCD_WIDTH) if (x2 >= LCD_WIDTH)
x2 = LCD_WIDTH-1; x2 = LCD_WIDTH-1;
bfunc = blockfunc[drawmode]; bfunc = lcd_blockfuncs[drawmode];
dst = &lcd_framebuffer[y>>3][x1]; dst = &lcd_framebuffer[y>>3][x1];
mask = 1 << (y & 7); mask = 1 << (y & 7);
@ -532,7 +532,7 @@ void lcd_vline(int x, int y1, int y2)
if (y2 >= LCD_HEIGHT) if (y2 >= LCD_HEIGHT)
y2 = LCD_HEIGHT-1; y2 = LCD_HEIGHT-1;
bfunc = blockfunc[drawmode]; bfunc = lcd_blockfuncs[drawmode];
dst = &lcd_framebuffer[y1>>3][x]; dst = &lcd_framebuffer[y1>>3][x];
ny = y2 - (y1 & ~7); ny = y2 - (y1 & ~7);
mask = 0xFFu << (y1 & 7); mask = 0xFFu << (y1 & 7);
@ -598,7 +598,7 @@ void lcd_fillrect(int x, int y, int width, int height)
(drawmode & DRMODE_BG) : (drawmode & DRMODE_FG); (drawmode & DRMODE_BG) : (drawmode & DRMODE_FG);
if (fillopt &&(drawmode & DRMODE_INVERSEVID)) if (fillopt &&(drawmode & DRMODE_INVERSEVID))
bits = 0; bits = 0;
bfunc = blockfunc[drawmode]; bfunc = lcd_blockfuncs[drawmode];
dst = &lcd_framebuffer[y>>3][x]; dst = &lcd_framebuffer[y>>3][x];
ny = height - 1 + (y & 7); ny = height - 1 + (y & 7);
mask = 0xFFu << (y & 7); mask = 0xFFu << (y & 7);
@ -683,7 +683,7 @@ void lcd_bitmap_part(const unsigned char *src, int src_x, int src_y,
shift = y & 7; shift = y & 7;
ny = height - 1 + shift + src_y; ny = height - 1 + shift + src_y;
bfunc = blockfunc[drawmode]; bfunc = lcd_blockfuncs[drawmode];
mask = 0xFFu << (shift + src_y); mask = 0xFFu << (shift + src_y);
mask_bottom = 0xFFu >> (7 - (ny & 7)); mask_bottom = 0xFFu >> (7 - (ny & 7));
@ -779,7 +779,7 @@ static void lcd_putsxyofs(int x, int y, int ofs, const unsigned char *str)
ofs -= width; ofs -= width;
continue; continue;
} }
bits = pf->bits + (pf->offset ? bits = pf->bits + (pf->offset ?
pf->offset[ch] : ((pf->height + 7) / 8 * pf->maxwidth * ch)); pf->offset[ch] : ((pf->height + 7) / 8 * pf->maxwidth * ch));

View file

@ -392,7 +392,7 @@ static void nopixel(int x, int y)
(void)y; (void)y;
} }
lcd_pixelfunc_type* pixelfunc[8] = { lcd_pixelfunc_type* lcd_pixelfuncs[8] = {
flippixel, nopixel, setpixel, setpixel, flippixel, nopixel, setpixel, setpixel,
nopixel, clearpixel, nopixel, clearpixel nopixel, clearpixel, nopixel, clearpixel
}; };
@ -437,7 +437,7 @@ static void solidinvblock(unsigned char *address, unsigned mask, unsigned bits)
*address = (*address & ~mask) | (~bits & mask); *address = (*address & ~mask) | (~bits & mask);
} }
lcd_blockfunc_type* blockfunc[8] = { lcd_blockfunc_type* lcd_blockfuncs[8] = {
flipblock, bgblock, fgblock, solidblock, flipblock, bgblock, fgblock, solidblock,
flipinvblock, bginvblock, fginvblock, solidinvblock flipinvblock, bginvblock, fginvblock, solidinvblock
}; };
@ -457,7 +457,7 @@ void lcd_clear_display(void)
void lcd_drawpixel(int x, int y) void lcd_drawpixel(int x, int y)
{ {
if (((unsigned)x < LCD_WIDTH) || ((unsigned)y < LCD_HEIGHT)) if (((unsigned)x < LCD_WIDTH) || ((unsigned)y < LCD_HEIGHT))
pixelfunc[drawmode](x, y); lcd_pixelfuncs[drawmode](x, y);
} }
/* Draw a line */ /* Draw a line */
@ -469,7 +469,7 @@ void lcd_drawline(int x1, int y1, int x2, int y2)
int d, dinc1, dinc2; int d, dinc1, dinc2;
int x, xinc1, xinc2; int x, xinc1, xinc2;
int y, yinc1, yinc2; int y, yinc1, yinc2;
lcd_pixelfunc_type *pfunc = pixelfunc[drawmode]; lcd_pixelfunc_type *pfunc = lcd_pixelfuncs[drawmode];
deltax = abs(x2 - x1); deltax = abs(x2 - x1);
deltay = abs(y2 - y1); deltay = abs(y2 - y1);
@ -557,7 +557,7 @@ void lcd_hline(int x1, int x2, int y)
if (x2 >= LCD_WIDTH) if (x2 >= LCD_WIDTH)
x2 = LCD_WIDTH-1; x2 = LCD_WIDTH-1;
bfunc = blockfunc[drawmode]; bfunc = lcd_blockfuncs[drawmode];
dst = &lcd_framebuffer[y>>3][x1]; dst = &lcd_framebuffer[y>>3][x1];
mask = 1 << (y & 7); mask = 1 << (y & 7);
@ -591,7 +591,7 @@ void lcd_vline(int x, int y1, int y2)
if (y2 >= LCD_HEIGHT) if (y2 >= LCD_HEIGHT)
y2 = LCD_HEIGHT-1; y2 = LCD_HEIGHT-1;
bfunc = blockfunc[drawmode]; bfunc = lcd_blockfuncs[drawmode];
dst = &lcd_framebuffer[y1>>3][x]; dst = &lcd_framebuffer[y1>>3][x];
ny = y2 - (y1 & ~7); ny = y2 - (y1 & ~7);
mask = 0xFFu << (y1 & 7); mask = 0xFFu << (y1 & 7);
@ -657,7 +657,7 @@ void lcd_fillrect(int x, int y, int width, int height)
(drawmode & DRMODE_BG) : (drawmode & DRMODE_FG); (drawmode & DRMODE_BG) : (drawmode & DRMODE_FG);
if (fillopt &&(drawmode & DRMODE_INVERSEVID)) if (fillopt &&(drawmode & DRMODE_INVERSEVID))
bits = 0; bits = 0;
bfunc = blockfunc[drawmode]; bfunc = lcd_blockfuncs[drawmode];
dst = &lcd_framebuffer[y>>3][x]; dst = &lcd_framebuffer[y>>3][x];
ny = height - 1 + (y & 7); ny = height - 1 + (y & 7);
mask = 0xFFu << (y & 7); mask = 0xFFu << (y & 7);
@ -742,7 +742,7 @@ void lcd_bitmap_part(const unsigned char *src, int src_x, int src_y,
shift = y & 7; shift = y & 7;
ny = height - 1 + shift + src_y; ny = height - 1 + shift + src_y;
bfunc = blockfunc[drawmode]; bfunc = lcd_blockfuncs[drawmode];
mask = 0xFFu << (shift + src_y); mask = 0xFFu << (shift + src_y);
mask_bottom = 0xFFu >> (7 - (ny & 7)); mask_bottom = 0xFFu >> (7 - (ny & 7));

View file

@ -26,9 +26,9 @@
#ifdef HAVE_REMOTE_LCD #ifdef HAVE_REMOTE_LCD
#define REMOTE_DRAW_PIXEL(x,y) lcd_remote_framebuffer[(y)/8][(x)] |= (1<<((y)&7)) #define REMOTE_DRAW_PIXEL(x,y) lcd_remote_framebuffer[(y)>>3][(x)] |= (1<<((y)&7))
#define REMOTE_CLEAR_PIXEL(x,y) lcd_remote_framebuffer[(y)/8][(x)] &= ~(1<<((y)&7)) #define REMOTE_CLEAR_PIXEL(x,y) lcd_remote_framebuffer[(y)>>3][(x)] &= ~(1<<((y)&7))
#define REMOTE_INVERT_PIXEL(x,y) lcd_remote_framebuffer[(y)/8][(x)] ^= (1<<((y)&7)) #define REMOTE_INVERT_PIXEL(x,y) lcd_remote_framebuffer[(y)>>3][(x)] ^= (1<<((y)&7))
#define STYLE_DEFAULT 0 #define STYLE_DEFAULT 0
#define STYLE_INVERT 1 #define STYLE_INVERT 1
@ -48,11 +48,11 @@ extern void lcd_remote_stop_scroll(void);
extern void lcd_remote_scroll_speed(int speed); extern void lcd_remote_scroll_speed(int speed);
extern void lcd_remote_scroll_delay(int ms); extern void lcd_remote_scroll_delay(int ms);
extern void lcd_remote_puts_scroll(int x, int y, const unsigned char* string); extern void lcd_remote_puts_scroll(int x, int y, const unsigned char* string);
extern void lcd_remote_puts_scroll_style(int x, int y, const unsigned char* string, extern void lcd_remote_puts_scroll_style(int x, int y,
int style); const unsigned char* string, int style);
extern void lcd_remote_update(void); extern void lcd_remote_update(void);
extern void lcd_remote_update_rect(int x_start, int y, int width, int height); extern void lcd_remote_update_rect(int x, int y, int width, int height);
/* Memory copy of display bitmap */ /* Memory copy of display bitmap */
extern unsigned char lcd_remote_framebuffer[LCD_REMOTE_HEIGHT/8][LCD_REMOTE_WIDTH]; extern unsigned char lcd_remote_framebuffer[LCD_REMOTE_HEIGHT/8][LCD_REMOTE_WIDTH];
@ -60,23 +60,28 @@ extern unsigned char lcd_remote_framebuffer[LCD_REMOTE_HEIGHT/8][LCD_REMOTE_WIDT
extern void lcd_remote_set_invert_display(bool yesno); extern void lcd_remote_set_invert_display(bool yesno);
extern void lcd_remote_set_flip(bool yesno); extern void lcd_remote_set_flip(bool yesno);
extern void lcd_remote_roll(int pixels); extern void lcd_remote_roll(int pixels);
extern void lcd_remote_set_drawmode(int mode);
extern int lcd_remote_get_drawmode(void);
extern void lcd_remote_setmargins(int xmargin, int ymargin); extern void lcd_remote_setmargins(int xmargin, int ymargin);
extern int lcd_remote_getxmargin(void); extern int lcd_remote_getxmargin(void);
extern int lcd_remote_getymargin(void); extern int lcd_remote_getymargin(void);
extern void lcd_remote_setfont(int font); extern void lcd_remote_setfont(int font);
extern int lcd_remote_getstringsize(const unsigned char *str, int *w, int *h); extern int lcd_remote_getstringsize(const unsigned char *str, int *w, int *h);
extern void lcd_remote_drawpixel(int x, int y); extern void lcd_remote_drawpixel(int x, int y);
extern void lcd_remote_clearpixel(int x, int y);
extern void lcd_remote_invertpixel(int x, int y);
extern void lcd_remote_drawline(int x1, int y1, int x2, int y2); extern void lcd_remote_drawline(int x1, int y1, int x2, int y2);
extern void lcd_remote_clearline(int x1, int y1, int x2, int y2); extern void lcd_remote_hline(int x1, int x2, int y);
extern void lcd_remote_drawrect(int x, int y, int nx, int ny); extern void lcd_remote_vline(int x, int y1, int y2);
extern void lcd_remote_clearrect(int x, int y, int nx, int ny); extern void lcd_remote_drawrect(int x, int y, int width, int height);
extern void lcd_remote_fillrect(int x, int y, int nx, int ny); extern void lcd_remote_fillrect(int x, int y, int width, int height);
extern void lcd_remote_invertrect(int x, int y, int nx, int ny); extern void lcd_remote_bitmap_part(const unsigned char *src, int src_x,
int src_y, int stride, int x, int y,
int width, int height);
extern void lcd_remote_bitmap(const unsigned char *src, int x, int y, extern void lcd_remote_bitmap(const unsigned char *src, int x, int y,
int nx, int ny, bool clear); int width, int height);
extern void lcd_remote_putsxy(int x, int y, const unsigned char *string); extern void lcd_remote_putsxy(int x, int y, const unsigned char *string);
extern void lcd_remote_invertscroll(int x, int y); extern void lcd_remote_invertscroll(int x, int y);
extern void lcd_remote_bidir_scroll(int threshold); extern void lcd_remote_bidir_scroll(int threshold);
extern void lcd_remote_scroll_step(int pixels); extern void lcd_remote_scroll_step(int pixels);

View file

@ -122,9 +122,9 @@ extern void lcd_jump_scroll_delay(int ms);
#define DRMODE_SOLID 3 #define DRMODE_SOLID 3
#define DRMODE_INVERSEVID 4 /* used as bit modifier for basic modes */ #define DRMODE_INVERSEVID 4 /* used as bit modifier for basic modes */
#define DRAW_PIXEL(x,y) lcd_framebuffer[(y)/8][(x)] |= (1<<((y)&7)) #define DRAW_PIXEL(x,y) lcd_framebuffer[(y)>>3][(x)] |= (1<<((y)&7))
#define CLEAR_PIXEL(x,y) lcd_framebuffer[(y)/8][(x)] &= ~(1<<((y)&7)) #define CLEAR_PIXEL(x,y) lcd_framebuffer[(y)>>3][(x)] &= ~(1<<((y)&7))
#define INVERT_PIXEL(x,y) lcd_framebuffer[(y)/8][(x)] ^= (1<<((y)&7)) #define INVERT_PIXEL(x,y) lcd_framebuffer[(y)>>3][(x)] ^= (1<<((y)&7))
typedef void lcd_pixelfunc_type(int x, int y); /* for b&w */ typedef void lcd_pixelfunc_type(int x, int y); /* for b&w */
typedef void lcd_blockfunc_type(unsigned char *address, unsigned mask, unsigned bits); typedef void lcd_blockfunc_type(unsigned char *address, unsigned mask, unsigned bits);
@ -144,6 +144,10 @@ extern int lcd_getymargin(void);
extern void lcd_setfont(int font); extern void lcd_setfont(int font);
extern int lcd_getstringsize(const unsigned char *str, int *w, int *h); extern int lcd_getstringsize(const unsigned char *str, int *w, int *h);
/* low level drawing function pointer arrays */
extern lcd_pixelfunc_type* lcd_pixelfuncs[8];
extern lcd_blockfunc_type* lcd_blockfuncs[8];
extern void lcd_drawpixel(int x, int y); extern void lcd_drawpixel(int x, int y);
extern void lcd_drawline(int x1, int y1, int x2, int y2); extern void lcd_drawline(int x1, int y1, int x2, int y2);
extern void lcd_hline(int x1, int x2, int y); extern void lcd_hline(int x1, int x2, int y);