summaryrefslogtreecommitdiff
path: root/apps/plugins/lib/playergfx.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/lib/playergfx.c')
-rw-r--r--apps/plugins/lib/playergfx.c60
1 files changed, 53 insertions, 7 deletions
diff --git a/apps/plugins/lib/playergfx.c b/apps/plugins/lib/playergfx.c
index 01dfca42ad..0289e7acc8 100644
--- a/apps/plugins/lib/playergfx.c
+++ b/apps/plugins/lib/playergfx.c
@@ -29,9 +29,15 @@ static struct plugin_api *pgfx_rb = NULL; /* global api struct pointer */
29static int char_width; 29static int char_width;
30static int char_height; 30static int char_height;
31static int pixel_height; 31static int pixel_height;
32static int pixel_width;
32static unsigned char gfx_chars[8]; 33static unsigned char gfx_chars[8];
33static unsigned char gfx_buffer[56]; 34static unsigned char gfx_buffer[56];
34 35
36/* Private function declarations */
37static void linefunc(int x1, int y1, int x2, int y2,
38 void (*pixelfunc)(int x, int y));
39
40/* Implementation */
35 41
36bool pgfx_init(struct plugin_api* newrb, int cwidth, int cheight) 42bool pgfx_init(struct plugin_api* newrb, int cwidth, int cheight)
37{ 43{
@@ -44,7 +50,8 @@ bool pgfx_init(struct plugin_api* newrb, int cwidth, int cheight)
44 char_width = cwidth; 50 char_width = cwidth;
45 char_height = cheight; 51 char_height = cheight;
46 pixel_height = 7 * char_height; 52 pixel_height = 7 * char_height;
47 53 pixel_width = 5 * char_width;
54
48 for (i = 0; i < cwidth * cheight; i++) 55 for (i = 0; i < cwidth * cheight; i++)
49 { 56 {
50 if ((gfx_chars[i] = pgfx_rb->lcd_get_locked_pattern()) == 0) 57 if ((gfx_chars[i] = pgfx_rb->lcd_get_locked_pattern()) == 0)
@@ -69,16 +76,20 @@ void pgfx_release(void)
69void pgfx_display(int cx, int cy) 76void pgfx_display(int cx, int cy)
70{ 77{
71 int i, j; 78 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 79
77 for (i = 0; i < char_width; i++) 80 for (i = 0; i < char_width; i++)
78 for (j = 0; j < char_height; j++) 81 for (j = 0; j < char_height; j++)
79 pgfx_rb->lcd_putc(cx + i, cy + j, gfx_chars[char_height * i + j]); 82 pgfx_rb->lcd_putc(cx + i, cy + j, gfx_chars[char_height * i + j]);
80} 83}
81 84
85void pgfx_update(void)
86{
87 int i;
88
89 for (i = 0; i < char_width * char_height; i++)
90 pgfx_rb->lcd_define_pattern(gfx_chars[i], gfx_buffer + 7 * i);
91}
92
82void pgfx_clear_display(void) 93void pgfx_clear_display(void)
83{ 94{
84 pgfx_rb->memset(gfx_buffer, 0, char_width * pixel_height); 95 pgfx_rb->memset(gfx_buffer, 0, char_width * pixel_height);
@@ -89,7 +100,13 @@ void pgfx_drawpixel(int x, int y)
89 gfx_buffer[pixel_height * (x/5) + y] |= 0x10 >> (x%5); 100 gfx_buffer[pixel_height * (x/5) + y] |= 0x10 >> (x%5);
90} 101}
91 102
92void pgfx_drawline(int x1, int y1, int x2, int y2) 103void pgfx_invertpixel(int x, int y)
104{
105 gfx_buffer[pixel_height * (x/5) + y] ^= 0x10 >> (x%5);
106}
107
108static void linefunc(int x1, int y1, int x2, int y2,
109 void (*pixelfunc)(int x, int y))
93{ 110{
94 int numpixels; 111 int numpixels;
95 int i; 112 int i;
@@ -140,7 +157,7 @@ void pgfx_drawline(int x1, int y1, int x2, int y2)
140 157
141 for (i = 0; i < numpixels; i++) 158 for (i = 0; i < numpixels; i++)
142 { 159 {
143 pgfx_drawpixel(x, y); 160 pixelfunc(x, y);
144 161
145 if (d < 0) 162 if (d < 0)
146 { 163 {
@@ -157,4 +174,33 @@ void pgfx_drawline(int x1, int y1, int x2, int y2)
157 } 174 }
158} 175}
159 176
177void pgfx_drawline(int x1, int y1, int x2, int y2)
178{
179 linefunc(x1, y1, x2, y2, pgfx_drawpixel);
180}
181
182void pgfx_invertline(int x1, int y1, int x2, int y2)
183{
184 linefunc(x1, y1, x2, y2, pgfx_invertpixel);
185}
186
187void pgfx_invertrect (int x, int y, int nx, int ny)
188{
189 int i, j;
190
191 if (x > pixel_width)
192 return;
193 if (y > pixel_height)
194 return;
195
196 if (x + nx > pixel_width)
197 nx = pixel_width - x;
198 if (y + ny > pixel_height)
199 ny = pixel_height - y;
200
201 for (i = 0; i < nx; i++)
202 for (j = 0; j < ny; j++)
203 pgfx_invertpixel(x + i, y + j);
204}
205
160#endif /* HAVE_LCD_CHARCELLS */ 206#endif /* HAVE_LCD_CHARCELLS */