forked from len0rd/rockbox
Split the display & update function in two, and added invertpixel(), invertline() and invertrect().
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@5916 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
707cb7bc04
commit
b66f94b03d
2 changed files with 57 additions and 7 deletions
|
@ -29,9 +29,15 @@ static struct plugin_api *pgfx_rb = NULL; /* global api struct pointer */
|
||||||
static int char_width;
|
static int char_width;
|
||||||
static int char_height;
|
static int char_height;
|
||||||
static int pixel_height;
|
static int pixel_height;
|
||||||
|
static int pixel_width;
|
||||||
static unsigned char gfx_chars[8];
|
static unsigned char gfx_chars[8];
|
||||||
static unsigned char gfx_buffer[56];
|
static unsigned char gfx_buffer[56];
|
||||||
|
|
||||||
|
/* Private function declarations */
|
||||||
|
static void linefunc(int x1, int y1, int x2, int y2,
|
||||||
|
void (*pixelfunc)(int x, int y));
|
||||||
|
|
||||||
|
/* Implementation */
|
||||||
|
|
||||||
bool pgfx_init(struct plugin_api* newrb, int cwidth, int cheight)
|
bool pgfx_init(struct plugin_api* newrb, int cwidth, int cheight)
|
||||||
{
|
{
|
||||||
|
@ -44,7 +50,8 @@ bool pgfx_init(struct plugin_api* newrb, int cwidth, int cheight)
|
||||||
char_width = cwidth;
|
char_width = cwidth;
|
||||||
char_height = cheight;
|
char_height = cheight;
|
||||||
pixel_height = 7 * char_height;
|
pixel_height = 7 * char_height;
|
||||||
|
pixel_width = 5 * char_width;
|
||||||
|
|
||||||
for (i = 0; i < cwidth * cheight; i++)
|
for (i = 0; i < cwidth * cheight; i++)
|
||||||
{
|
{
|
||||||
if ((gfx_chars[i] = pgfx_rb->lcd_get_locked_pattern()) == 0)
|
if ((gfx_chars[i] = pgfx_rb->lcd_get_locked_pattern()) == 0)
|
||||||
|
@ -69,16 +76,20 @@ void pgfx_release(void)
|
||||||
void pgfx_display(int cx, int cy)
|
void pgfx_display(int cx, int cy)
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
|
|
||||||
for (i = 0; i < char_width * char_height; i++)
|
|
||||||
pgfx_rb->lcd_define_pattern(gfx_chars[i], gfx_buffer + 7 * i);
|
|
||||||
|
|
||||||
|
|
||||||
for (i = 0; i < char_width; i++)
|
for (i = 0; i < char_width; i++)
|
||||||
for (j = 0; j < char_height; j++)
|
for (j = 0; j < char_height; j++)
|
||||||
pgfx_rb->lcd_putc(cx + i, cy + j, gfx_chars[char_height * i + j]);
|
pgfx_rb->lcd_putc(cx + i, cy + j, gfx_chars[char_height * i + j]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void pgfx_update(void)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < char_width * char_height; i++)
|
||||||
|
pgfx_rb->lcd_define_pattern(gfx_chars[i], gfx_buffer + 7 * i);
|
||||||
|
}
|
||||||
|
|
||||||
void pgfx_clear_display(void)
|
void pgfx_clear_display(void)
|
||||||
{
|
{
|
||||||
pgfx_rb->memset(gfx_buffer, 0, char_width * pixel_height);
|
pgfx_rb->memset(gfx_buffer, 0, char_width * pixel_height);
|
||||||
|
@ -89,7 +100,13 @@ void pgfx_drawpixel(int x, int y)
|
||||||
gfx_buffer[pixel_height * (x/5) + y] |= 0x10 >> (x%5);
|
gfx_buffer[pixel_height * (x/5) + y] |= 0x10 >> (x%5);
|
||||||
}
|
}
|
||||||
|
|
||||||
void pgfx_drawline(int x1, int y1, int x2, int y2)
|
void pgfx_invertpixel(int x, int y)
|
||||||
|
{
|
||||||
|
gfx_buffer[pixel_height * (x/5) + y] ^= 0x10 >> (x%5);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void linefunc(int x1, int y1, int x2, int y2,
|
||||||
|
void (*pixelfunc)(int x, int y))
|
||||||
{
|
{
|
||||||
int numpixels;
|
int numpixels;
|
||||||
int i;
|
int i;
|
||||||
|
@ -140,7 +157,7 @@ void pgfx_drawline(int x1, int y1, int x2, int y2)
|
||||||
|
|
||||||
for (i = 0; i < numpixels; i++)
|
for (i = 0; i < numpixels; i++)
|
||||||
{
|
{
|
||||||
pgfx_drawpixel(x, y);
|
pixelfunc(x, y);
|
||||||
|
|
||||||
if (d < 0)
|
if (d < 0)
|
||||||
{
|
{
|
||||||
|
@ -157,4 +174,33 @@ void pgfx_drawline(int x1, int y1, int x2, int y2)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void pgfx_drawline(int x1, int y1, int x2, int y2)
|
||||||
|
{
|
||||||
|
linefunc(x1, y1, x2, y2, pgfx_drawpixel);
|
||||||
|
}
|
||||||
|
|
||||||
|
void pgfx_invertline(int x1, int y1, int x2, int y2)
|
||||||
|
{
|
||||||
|
linefunc(x1, y1, x2, y2, pgfx_invertpixel);
|
||||||
|
}
|
||||||
|
|
||||||
|
void pgfx_invertrect (int x, int y, int nx, int ny)
|
||||||
|
{
|
||||||
|
int i, j;
|
||||||
|
|
||||||
|
if (x > pixel_width)
|
||||||
|
return;
|
||||||
|
if (y > pixel_height)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (x + nx > pixel_width)
|
||||||
|
nx = pixel_width - x;
|
||||||
|
if (y + ny > pixel_height)
|
||||||
|
ny = pixel_height - y;
|
||||||
|
|
||||||
|
for (i = 0; i < nx; i++)
|
||||||
|
for (j = 0; j < ny; j++)
|
||||||
|
pgfx_invertpixel(x + i, y + j);
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* HAVE_LCD_CHARCELLS */
|
#endif /* HAVE_LCD_CHARCELLS */
|
||||||
|
|
|
@ -29,9 +29,13 @@
|
||||||
bool pgfx_init(struct plugin_api* newrb, int cwidth, int cheight);
|
bool pgfx_init(struct plugin_api* newrb, int cwidth, int cheight);
|
||||||
void pgfx_release(void);
|
void pgfx_release(void);
|
||||||
void pgfx_display(int cx, int cy);
|
void pgfx_display(int cx, int cy);
|
||||||
|
void pgfx_update(void);
|
||||||
void pgfx_clear_display(void);
|
void pgfx_clear_display(void);
|
||||||
void pgfx_drawpixel(int x, int y);
|
void pgfx_drawpixel(int x, int y);
|
||||||
|
void pgfx_invertpixel(int x, int y);
|
||||||
void pgfx_drawline(int x1, int y1, int x2, int y2);
|
void pgfx_drawline(int x1, int y1, int x2, int y2);
|
||||||
|
void pgfx_invertline(int x1, int y1, int x2, int y2);
|
||||||
|
void pgfx_invertrect (int x, int y, int nx, int ny);
|
||||||
|
|
||||||
#endif /* HAVE_LCD_CHARCELLS */
|
#endif /* HAVE_LCD_CHARCELLS */
|
||||||
#endif /* __PGFX_H__ */
|
#endif /* __PGFX_H__ */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue