summaryrefslogtreecommitdiff
path: root/apps/plugins/lib
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2005-02-10 21:12:59 +0000
committerJens Arnold <amiconn@rockbox.org>2005-02-10 21:12:59 +0000
commitc552e03c90859d476a5fbfe03b17e40ce21ef2fc (patch)
treef2577979b265c1904423c79f76d128f3b6653143 /apps/plugins/lib
parent037083af2d99e1b82d9a11a2713c5a88ba0015ef (diff)
downloadrockbox-c552e03c90859d476a5fbfe03b17e40ce21ef2fc.zip
rockbox-c552e03c90859d476a5fbfe03b17e40ce21ef2fc.tar.gz
rockbox-c552e03c90859d476a5fbfe03b17e40ce21ef2fc.tar.bz2
rockbox-c552e03c90859d476a5fbfe03b17e40ce21ef2fc.tar.xz
Beginnings of a graphics library for the player LCD. So far the only drawing functions are clear_display(), drawpixel() and drawline().
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@5882 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/lib')
-rw-r--r--apps/plugins/lib/SOURCES3
-rw-r--r--apps/plugins/lib/playergfx.c160
-rw-r--r--apps/plugins/lib/playergfx.h37
3 files changed, 200 insertions, 0 deletions
diff --git a/apps/plugins/lib/SOURCES b/apps/plugins/lib/SOURCES
index 3873d26..8bd47a2 100644
--- a/apps/plugins/lib/SOURCES
+++ b/apps/plugins/lib/SOURCES
@@ -30,3 +30,6 @@ gray_set_foreground.c
gray_setfont.c
gray_verline.c
#endif
+#ifdef HAVE_LCD_CHARCELLS
+playergfx.c
+#endif
diff --git a/apps/plugins/lib/playergfx.c b/apps/plugins/lib/playergfx.c
new file mode 100644
index 0000000..01dfca4
--- /dev/null
+++ b/apps/plugins/lib/playergfx.c
@@ -0,0 +1,160 @@
+/***************************************************************************
+* __________ __ ___.
+* Open \______ \ ____ ____ | | _\_ |__ _______ ___
+* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+* \/ \/ \/ \/ \/
+* $Id$
+*
+* Bitmap graphics on player LCD!
+*
+* Copyright (C) 2005 Jens Arnold
+*
+* All files in this archive are subject to the GNU General Public License.
+* See the file COPYING in the source tree root for full license agreement.
+*
+* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+* KIND, either express or implied.
+*
+****************************************************************************/
+
+#include "plugin.h"
+
+#ifdef HAVE_LCD_CHARCELLS /* Player only :) */
+#include "playergfx.h"
+
+/* Global variables */
+static struct plugin_api *pgfx_rb = NULL; /* global api struct pointer */
+static int char_width;
+static int char_height;
+static int pixel_height;
+static unsigned char gfx_chars[8];
+static unsigned char gfx_buffer[56];
+
+
+bool pgfx_init(struct plugin_api* newrb, int cwidth, int cheight)
+{
+ int i;
+
+ if (((unsigned) cwidth * (unsigned) cheight) > 8 || (unsigned) cheight > 2)
+ return false;
+
+ pgfx_rb = newrb;
+ char_width = cwidth;
+ char_height = cheight;
+ pixel_height = 7 * char_height;
+
+ for (i = 0; i < cwidth * cheight; i++)
+ {
+ if ((gfx_chars[i] = pgfx_rb->lcd_get_locked_pattern()) == 0)
+ {
+ pgfx_release();
+ return false;
+ }
+ }
+
+ return true;
+}
+
+void pgfx_release(void)
+{
+ int i;
+
+ for (i = 0; i < 8; i++)
+ if (gfx_chars[i])
+ pgfx_rb->lcd_unlock_pattern(gfx_chars[i]);
+}
+
+void pgfx_display(int cx, int cy)
+{
+ 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 (j = 0; j < char_height; j++)
+ pgfx_rb->lcd_putc(cx + i, cy + j, gfx_chars[char_height * i + j]);
+}
+
+void pgfx_clear_display(void)
+{
+ pgfx_rb->memset(gfx_buffer, 0, char_width * pixel_height);
+}
+
+void pgfx_drawpixel(int x, int y)
+{
+ gfx_buffer[pixel_height * (x/5) + y] |= 0x10 >> (x%5);
+}
+
+void pgfx_drawline(int x1, int y1, int x2, int y2)
+{
+ int numpixels;
+ int i;
+ int deltax, deltay;
+ int d, dinc1, dinc2;
+ int x, xinc1, xinc2;
+ int y, yinc1, yinc2;
+
+ deltax = abs(x2 - x1);
+ deltay = abs(y2 - y1);
+ xinc2 = 1;
+ yinc2 = 1;
+
+ if (deltax >= deltay)
+ {
+ numpixels = deltax;
+ d = 2 * deltay - deltax;
+ dinc1 = deltay * 2;
+ dinc2 = (deltay - deltax) * 2;
+ xinc1 = 1;
+ yinc1 = 0;
+ }
+ else
+ {
+ numpixels = deltay;
+ d = 2 * deltax - deltay;
+ dinc1 = deltax * 2;
+ dinc2 = (deltax - deltay) * 2;
+ xinc1 = 0;
+ yinc1 = 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++)
+ {
+ pgfx_drawpixel(x, y);
+
+ if (d < 0)
+ {
+ d += dinc1;
+ x += xinc1;
+ y += yinc1;
+ }
+ else
+ {
+ d += dinc2;
+ x += xinc2;
+ y += yinc2;
+ }
+ }
+}
+
+#endif /* HAVE_LCD_CHARCELLS */
diff --git a/apps/plugins/lib/playergfx.h b/apps/plugins/lib/playergfx.h
new file mode 100644
index 0000000..761c75f
--- /dev/null
+++ b/apps/plugins/lib/playergfx.h
@@ -0,0 +1,37 @@
+/***************************************************************************
+* __________ __ ___.
+* Open \______ \ ____ ____ | | _\_ |__ _______ ___
+* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+* \/ \/ \/ \/ \/
+* $Id$
+*
+* Bitmap graphics on player LCD!
+*
+* Copyright (C) 2005 Jens Arnold
+*
+* All files in this archive are subject to the GNU General Public License.
+* See the file COPYING in the source tree root for full license agreement.
+*
+* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+* KIND, either express or implied.
+*
+****************************************************************************/
+
+#ifndef __PGFX_H__
+#define __PGFX_H__
+
+#include "plugin.h"
+
+#ifdef HAVE_LCD_CHARCELLS /* Player only :) */
+
+bool pgfx_init(struct plugin_api* newrb, int cwidth, int cheight);
+void pgfx_release(void);
+void pgfx_display(int cx, int cy);
+void pgfx_clear_display(void);
+void pgfx_drawpixel(int x, int y);
+void pgfx_drawline(int x1, int y1, int x2, int y2);
+
+#endif /* HAVE_LCD_CHARCELLS */
+#endif /* __PGFX_H__ */