diff options
author | Jens Arnold <amiconn@rockbox.org> | 2005-02-11 19:35:50 +0000 |
---|---|---|
committer | Jens Arnold <amiconn@rockbox.org> | 2005-02-11 19:35:50 +0000 |
commit | b66f94b03dc6d2d6b9478274ba69607f14cbd39e (patch) | |
tree | 2ff3b5b3ef81b05915449d93e2a0a9273bb6ff98 | |
parent | 707cb7bc049a036f19ae8b89973502cd1752b9d8 (diff) | |
download | rockbox-b66f94b03dc6d2d6b9478274ba69607f14cbd39e.tar.gz rockbox-b66f94b03dc6d2d6b9478274ba69607f14cbd39e.zip |
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
-rw-r--r-- | apps/plugins/lib/playergfx.c | 60 | ||||
-rw-r--r-- | apps/plugins/lib/playergfx.h | 4 |
2 files changed, 57 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 */ | |||
29 | static int char_width; | 29 | static int char_width; |
30 | static int char_height; | 30 | static int char_height; |
31 | static int pixel_height; | 31 | static int pixel_height; |
32 | static int pixel_width; | ||
32 | static unsigned char gfx_chars[8]; | 33 | static unsigned char gfx_chars[8]; |
33 | static unsigned char gfx_buffer[56]; | 34 | static unsigned char gfx_buffer[56]; |
34 | 35 | ||
36 | /* Private function declarations */ | ||
37 | static void linefunc(int x1, int y1, int x2, int y2, | ||
38 | void (*pixelfunc)(int x, int y)); | ||
39 | |||
40 | /* Implementation */ | ||
35 | 41 | ||
36 | bool pgfx_init(struct plugin_api* newrb, int cwidth, int cheight) | 42 | bool 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) | |||
69 | void pgfx_display(int cx, int cy) | 76 | void 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 | ||
85 | void 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 | |||
82 | void pgfx_clear_display(void) | 93 | void 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 | ||
92 | void pgfx_drawline(int x1, int y1, int x2, int y2) | 103 | void pgfx_invertpixel(int x, int y) |
104 | { | ||
105 | gfx_buffer[pixel_height * (x/5) + y] ^= 0x10 >> (x%5); | ||
106 | } | ||
107 | |||
108 | static 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 | ||
177 | void pgfx_drawline(int x1, int y1, int x2, int y2) | ||
178 | { | ||
179 | linefunc(x1, y1, x2, y2, pgfx_drawpixel); | ||
180 | } | ||
181 | |||
182 | void pgfx_invertline(int x1, int y1, int x2, int y2) | ||
183 | { | ||
184 | linefunc(x1, y1, x2, y2, pgfx_invertpixel); | ||
185 | } | ||
186 | |||
187 | void 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 */ |
diff --git a/apps/plugins/lib/playergfx.h b/apps/plugins/lib/playergfx.h index 761c75f82a..929452fb28 100644 --- a/apps/plugins/lib/playergfx.h +++ b/apps/plugins/lib/playergfx.h | |||
@@ -29,9 +29,13 @@ | |||
29 | bool pgfx_init(struct plugin_api* newrb, int cwidth, int cheight); | 29 | bool pgfx_init(struct plugin_api* newrb, int cwidth, int cheight); |
30 | void pgfx_release(void); | 30 | void pgfx_release(void); |
31 | void pgfx_display(int cx, int cy); | 31 | void pgfx_display(int cx, int cy); |
32 | void pgfx_update(void); | ||
32 | void pgfx_clear_display(void); | 33 | void pgfx_clear_display(void); |
33 | void pgfx_drawpixel(int x, int y); | 34 | void pgfx_drawpixel(int x, int y); |
35 | void pgfx_invertpixel(int x, int y); | ||
34 | void pgfx_drawline(int x1, int y1, int x2, int y2); | 36 | void pgfx_drawline(int x1, int y1, int x2, int y2); |
37 | void pgfx_invertline(int x1, int y1, int x2, int y2); | ||
38 | void pgfx_invertrect (int x, int y, int nx, int ny); | ||
35 | 39 | ||
36 | #endif /* HAVE_LCD_CHARCELLS */ | 40 | #endif /* HAVE_LCD_CHARCELLS */ |
37 | #endif /* __PGFX_H__ */ | 41 | #endif /* __PGFX_H__ */ |