forked from len0rd/rockbox
Beginnings of a library complementing the core LCD functions. First function: filled triangle drawing.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7128 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
89d6e950fd
commit
937725f674
3 changed files with 146 additions and 0 deletions
|
@ -31,6 +31,9 @@ gray_set_foreground.c
|
||||||
gray_setfont.c
|
gray_setfont.c
|
||||||
gray_verline.c
|
gray_verline.c
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef HAVE_LCD_BITMAP
|
||||||
|
xlcd.c
|
||||||
|
#endif
|
||||||
#ifdef HAVE_LCD_CHARCELLS
|
#ifdef HAVE_LCD_CHARCELLS
|
||||||
playergfx.c
|
playergfx.c
|
||||||
#endif
|
#endif
|
||||||
|
|
109
apps/plugins/lib/xlcd.c
Normal file
109
apps/plugins/lib/xlcd.c
Normal file
|
@ -0,0 +1,109 @@
|
||||||
|
/***************************************************************************
|
||||||
|
* __________ __ ___.
|
||||||
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||||
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||||
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||||
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||||
|
* \/ \/ \/ \/ \/
|
||||||
|
* $Id$
|
||||||
|
*
|
||||||
|
* Additional LCD routines not present in the core itself
|
||||||
|
*
|
||||||
|
* 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_BITMAP
|
||||||
|
|
||||||
|
/*** globals ***/
|
||||||
|
|
||||||
|
static struct plugin_api *local_rb = NULL; /* global api struct pointer */
|
||||||
|
|
||||||
|
/*** functions ***/
|
||||||
|
|
||||||
|
/* library init */
|
||||||
|
void xlcd_init(struct plugin_api* newrb)
|
||||||
|
{
|
||||||
|
local_rb = newrb;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* draw a filled triangle */
|
||||||
|
void xlcd_filltriangle(int x1, int y1, int x2, int y2, int x3, int y3)
|
||||||
|
{
|
||||||
|
int x, y;
|
||||||
|
long fp_y1, fp_y2, fp_dy1, fp_dy2;
|
||||||
|
|
||||||
|
/* sort vertices by increasing x value */
|
||||||
|
if (x1 > x3)
|
||||||
|
{
|
||||||
|
if (x2 < x3) /* x2 < x3 < x1 */
|
||||||
|
{
|
||||||
|
x = x1; x1 = x2; x2 = x3; x3 = x;
|
||||||
|
y = y1; y1 = y2; y2 = y3; y3 = y;
|
||||||
|
}
|
||||||
|
else if (x2 > x1) /* x3 < x1 < x2 */
|
||||||
|
{
|
||||||
|
x = x1; x1 = x3; x3 = x2; x2 = x;
|
||||||
|
y = y1; y1 = y3; y3 = y2; y2 = y;
|
||||||
|
}
|
||||||
|
else /* x3 <= x2 <= x1 */
|
||||||
|
{
|
||||||
|
x = x1; x1 = x3; x3 = x;
|
||||||
|
y = y1; y1 = y3; y3 = y;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (x2 < x1) /* x2 < x1 <= x3 */
|
||||||
|
{
|
||||||
|
x = x1; x1 = x2; x2 = x;
|
||||||
|
y = y1; y1 = y2; y2 = y;
|
||||||
|
}
|
||||||
|
else if (x2 > x3) /* x1 <= x3 < x2 */
|
||||||
|
{
|
||||||
|
x = x2; x2 = x3; x3 = x;
|
||||||
|
y = y2; y2 = y3; y3 = y;
|
||||||
|
}
|
||||||
|
/* else already sorted */
|
||||||
|
}
|
||||||
|
|
||||||
|
if (x1 < x3) /* draw */
|
||||||
|
{
|
||||||
|
fp_dy1 = ((y3 - y1) << 16) / (x3 - x1);
|
||||||
|
fp_y1 = (y1 << 16) + (1<<15) + (fp_dy1 >> 1);
|
||||||
|
|
||||||
|
if (x1 < x2) /* first part */
|
||||||
|
{
|
||||||
|
fp_dy2 = ((y2 - y1) << 16) / (x2 - x1);
|
||||||
|
fp_y2 = (y1 << 16) + (1<<15) + (fp_dy2 >> 1);
|
||||||
|
for (x = x1; x < x2; x++)
|
||||||
|
{
|
||||||
|
local_rb->lcd_vline(x, fp_y1 >> 16, fp_y2 >> 16);
|
||||||
|
fp_y1 += fp_dy1;
|
||||||
|
fp_y2 += fp_dy2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (x2 < x3) /* second part */
|
||||||
|
{
|
||||||
|
fp_dy2 = ((y3 - y2) << 16) / (x3 - x2);
|
||||||
|
fp_y2 = (y2 << 16) + (1<<15) + (fp_dy2 >> 1);
|
||||||
|
for (x = x2; x < x3; x++)
|
||||||
|
{
|
||||||
|
local_rb->lcd_vline(x, fp_y1 >> 16, fp_y2 >> 16);
|
||||||
|
fp_y1 += fp_dy1;
|
||||||
|
fp_y2 += fp_dy2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* HAVE_LCD_BITMAP */
|
||||||
|
|
34
apps/plugins/lib/xlcd.h
Normal file
34
apps/plugins/lib/xlcd.h
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
/***************************************************************************
|
||||||
|
* __________ __ ___.
|
||||||
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||||
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||||
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||||
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||||
|
* \/ \/ \/ \/ \/
|
||||||
|
* $Id$
|
||||||
|
*
|
||||||
|
* Additional LCD routines not present in the core itself
|
||||||
|
*
|
||||||
|
* 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 __XLCD_H__
|
||||||
|
#define __XLCD_H__
|
||||||
|
|
||||||
|
#include "plugin.h"
|
||||||
|
|
||||||
|
#ifdef HAVE_LCD_BITMAP
|
||||||
|
|
||||||
|
void xlcd_init(struct plugin_api* newrb);
|
||||||
|
void xlcd_filltriangle(int x1, int y1, int x2, int y2, int x3, int y3);
|
||||||
|
|
||||||
|
#endif /* HAVE_LCD_BITMAP */
|
||||||
|
#endif /* __XLCD_H__ */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue