diff options
Diffstat (limited to 'apps/plugins')
-rw-r--r-- | apps/plugins/lib/SOURCES | 3 | ||||
-rw-r--r-- | apps/plugins/lib/playergfx.c | 160 | ||||
-rw-r--r-- | apps/plugins/lib/playergfx.h | 37 |
3 files changed, 200 insertions, 0 deletions
diff --git a/apps/plugins/lib/SOURCES b/apps/plugins/lib/SOURCES index 3873d2659b..8bd47a25b0 100644 --- a/apps/plugins/lib/SOURCES +++ b/apps/plugins/lib/SOURCES | |||
@@ -30,3 +30,6 @@ gray_set_foreground.c | |||
30 | gray_setfont.c | 30 | gray_setfont.c |
31 | gray_verline.c | 31 | gray_verline.c |
32 | #endif | 32 | #endif |
33 | #ifdef HAVE_LCD_CHARCELLS | ||
34 | playergfx.c | ||
35 | #endif | ||
diff --git a/apps/plugins/lib/playergfx.c b/apps/plugins/lib/playergfx.c new file mode 100644 index 0000000000..01dfca42ad --- /dev/null +++ b/apps/plugins/lib/playergfx.c | |||
@@ -0,0 +1,160 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Bitmap graphics on player LCD! | ||
11 | * | ||
12 | * Copyright (C) 2005 Jens Arnold | ||
13 | * | ||
14 | * All files in this archive are subject to the GNU General Public License. | ||
15 | * See the file COPYING in the source tree root for full license agreement. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #include "plugin.h" | ||
23 | |||
24 | #ifdef HAVE_LCD_CHARCELLS /* Player only :) */ | ||
25 | #include "playergfx.h" | ||
26 | |||
27 | /* Global variables */ | ||
28 | static struct plugin_api *pgfx_rb = NULL; /* global api struct pointer */ | ||
29 | static int char_width; | ||
30 | static int char_height; | ||
31 | static int pixel_height; | ||
32 | static unsigned char gfx_chars[8]; | ||
33 | static unsigned char gfx_buffer[56]; | ||
34 | |||
35 | |||
36 | bool pgfx_init(struct plugin_api* newrb, int cwidth, int cheight) | ||
37 | { | ||
38 | int i; | ||
39 | |||
40 | if (((unsigned) cwidth * (unsigned) cheight) > 8 || (unsigned) cheight > 2) | ||
41 | return false; | ||
42 | |||
43 | pgfx_rb = newrb; | ||
44 | char_width = cwidth; | ||
45 | char_height = cheight; | ||
46 | pixel_height = 7 * char_height; | ||
47 | |||
48 | for (i = 0; i < cwidth * cheight; i++) | ||
49 | { | ||
50 | if ((gfx_chars[i] = pgfx_rb->lcd_get_locked_pattern()) == 0) | ||
51 | { | ||
52 | pgfx_release(); | ||
53 | return false; | ||
54 | } | ||
55 | } | ||
56 | |||
57 | return true; | ||
58 | } | ||
59 | |||
60 | void pgfx_release(void) | ||
61 | { | ||
62 | int i; | ||
63 | |||
64 | for (i = 0; i < 8; i++) | ||
65 | if (gfx_chars[i]) | ||
66 | pgfx_rb->lcd_unlock_pattern(gfx_chars[i]); | ||
67 | } | ||
68 | |||
69 | void pgfx_display(int cx, int cy) | ||
70 | { | ||
71 | int i, j; | ||
72 | |||
73 | for (i = 0; i < char_width * char_height; i++) | ||
74 | pgfx_rb->lcd_define_pattern(gfx_chars[i], gfx_buffer + 7 * i); | ||
75 | |||
76 | |||
77 | for (i = 0; i < char_width; i++) | ||
78 | for (j = 0; j < char_height; j++) | ||
79 | pgfx_rb->lcd_putc(cx + i, cy + j, gfx_chars[char_height * i + j]); | ||
80 | } | ||
81 | |||
82 | void pgfx_clear_display(void) | ||
83 | { | ||
84 | pgfx_rb->memset(gfx_buffer, 0, char_width * pixel_height); | ||
85 | } | ||
86 | |||
87 | void pgfx_drawpixel(int x, int y) | ||
88 | { | ||
89 | gfx_buffer[pixel_height * (x/5) + y] |= 0x10 >> (x%5); | ||
90 | } | ||
91 | |||
92 | void pgfx_drawline(int x1, int y1, int x2, int y2) | ||
93 | { | ||
94 | int numpixels; | ||
95 | int i; | ||
96 | int deltax, deltay; | ||
97 | int d, dinc1, dinc2; | ||
98 | int x, xinc1, xinc2; | ||
99 | int y, yinc1, yinc2; | ||
100 | |||
101 | deltax = abs(x2 - x1); | ||
102 | deltay = abs(y2 - y1); | ||
103 | xinc2 = 1; | ||
104 | yinc2 = 1; | ||
105 | |||
106 | if (deltax >= deltay) | ||
107 | { | ||
108 | numpixels = deltax; | ||
109 | d = 2 * deltay - deltax; | ||
110 | dinc1 = deltay * 2; | ||
111 | dinc2 = (deltay - deltax) * 2; | ||
112 | xinc1 = 1; | ||
113 | yinc1 = 0; | ||
114 | } | ||
115 | else | ||
116 | { | ||
117 | numpixels = deltay; | ||
118 | d = 2 * deltax - deltay; | ||
119 | dinc1 = deltax * 2; | ||
120 | dinc2 = (deltax - deltay) * 2; | ||
121 | xinc1 = 0; | ||
122 | yinc1 = 1; | ||
123 | } | ||
124 | numpixels++; /* include endpoints */ | ||
125 | |||
126 | if(x1 > x2) | ||
127 | { | ||
128 | xinc1 = -xinc1; | ||
129 | xinc2 = -xinc2; | ||
130 | } | ||
131 | |||
132 | if(y1 > y2) | ||
133 | { | ||
134 | yinc1 = -yinc1; | ||
135 | yinc2 = -yinc2; | ||
136 | } | ||
137 | |||
138 | x = x1; | ||
139 | y = y1; | ||
140 | |||
141 | for (i = 0; i < numpixels; i++) | ||
142 | { | ||
143 | pgfx_drawpixel(x, y); | ||
144 | |||
145 | if (d < 0) | ||
146 | { | ||
147 | d += dinc1; | ||
148 | x += xinc1; | ||
149 | y += yinc1; | ||
150 | } | ||
151 | else | ||
152 | { | ||
153 | d += dinc2; | ||
154 | x += xinc2; | ||
155 | y += yinc2; | ||
156 | } | ||
157 | } | ||
158 | } | ||
159 | |||
160 | #endif /* HAVE_LCD_CHARCELLS */ | ||
diff --git a/apps/plugins/lib/playergfx.h b/apps/plugins/lib/playergfx.h new file mode 100644 index 0000000000..761c75f82a --- /dev/null +++ b/apps/plugins/lib/playergfx.h | |||
@@ -0,0 +1,37 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Bitmap graphics on player LCD! | ||
11 | * | ||
12 | * Copyright (C) 2005 Jens Arnold | ||
13 | * | ||
14 | * All files in this archive are subject to the GNU General Public License. | ||
15 | * See the file COPYING in the source tree root for full license agreement. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #ifndef __PGFX_H__ | ||
23 | #define __PGFX_H__ | ||
24 | |||
25 | #include "plugin.h" | ||
26 | |||
27 | #ifdef HAVE_LCD_CHARCELLS /* Player only :) */ | ||
28 | |||
29 | bool pgfx_init(struct plugin_api* newrb, int cwidth, int cheight); | ||
30 | void pgfx_release(void); | ||
31 | void pgfx_display(int cx, int cy); | ||
32 | void pgfx_clear_display(void); | ||
33 | void pgfx_drawpixel(int x, int y); | ||
34 | void pgfx_drawline(int x1, int y1, int x2, int y2); | ||
35 | |||
36 | #endif /* HAVE_LCD_CHARCELLS */ | ||
37 | #endif /* __PGFX_H__ */ | ||