summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2006-02-06 16:04:01 +0000
committerJens Arnold <amiconn@rockbox.org>2006-02-06 16:04:01 +0000
commite6e8aa95197040d5f9e7125819a0a7f047a83f24 (patch)
tree74665c48ddd0f90067101570fd1bed26f9783a04
parentd036e97d3816ac2bc0eefc57bc033bd5fbbbf0f9 (diff)
downloadrockbox-e6e8aa95197040d5f9e7125819a0a7f047a83f24.tar.gz
rockbox-e6e8aa95197040d5f9e7125819a0a7f047a83f24.zip
Added memmove() to codec API & plugin API, and changed codeclib and plugin libs to use it.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8602 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/codecs.c1
-rw-r--r--apps/codecs.h3
-rw-r--r--apps/codecs/lib/codeclib.c11
-rw-r--r--apps/plugin.c1
-rw-r--r--apps/plugin.h3
-rw-r--r--apps/plugins/lib/gray_scroll.c35
-rw-r--r--apps/plugins/lib/xlcd.c38
7 files changed, 22 insertions, 70 deletions
diff --git a/apps/codecs.c b/apps/codecs.c
index 380816ba40..0301a490d8 100644
--- a/apps/codecs.c
+++ b/apps/codecs.c
@@ -215,6 +215,7 @@ struct codec_api ci = {
215 /* new stuff at the end, sort into place next time 215 /* new stuff at the end, sort into place next time
216 the API gets incompatible */ 216 the API gets incompatible */
217 217
218 memmove,
218}; 219};
219 220
220int codec_load_ram(char* codecptr, int size, void* ptr2, int bufwrap, 221int codec_load_ram(char* codecptr, int size, void* ptr2, int bufwrap,
diff --git a/apps/codecs.h b/apps/codecs.h
index 6e2ef9882c..00f0f64733 100644
--- a/apps/codecs.h
+++ b/apps/codecs.h
@@ -85,7 +85,7 @@
85#define CODEC_MAGIC 0x52434F44 /* RCOD */ 85#define CODEC_MAGIC 0x52434F44 /* RCOD */
86 86
87/* increase this every time the api struct changes */ 87/* increase this every time the api struct changes */
88#define CODEC_API_VERSION 3 88#define CODEC_API_VERSION 4
89 89
90/* update this to latest version if a change to the api struct breaks 90/* update this to latest version if a change to the api struct breaks
91 backwards compatibility (and please take the opportunity to sort in any 91 backwards compatibility (and please take the opportunity to sort in any
@@ -292,6 +292,7 @@ struct codec_api {
292 /* new stuff at the end, sort into place next time 292 /* new stuff at the end, sort into place next time
293 the API gets incompatible */ 293 the API gets incompatible */
294 294
295 void* (*memmove)(void *out, const void *in, size_t n);
295}; 296};
296 297
297/* codec header */ 298/* codec header */
diff --git a/apps/codecs/lib/codeclib.c b/apps/codecs/lib/codeclib.c
index 1f070e8eac..917970ba8d 100644
--- a/apps/codecs/lib/codeclib.c
+++ b/apps/codecs/lib/codeclib.c
@@ -132,16 +132,9 @@ void* memchr(const void *s, int c, size_t n)
132 return(local_rb->memchr(s,c,n)); 132 return(local_rb->memchr(s,c,n));
133} 133}
134 134
135void* memmove(void *s1, const void *s2, size_t n) 135void *memmove(void *dest, const void *src, size_t n)
136{ 136{
137 char* dest=(char*)s1; 137 return(local_rb->memmove(dest,src,n));
138 char* src=(char*)s2;
139 size_t i;
140
141 for (i=0;i<n;i++)
142 dest[i]=src[i];
143
144 return(dest);
145} 138}
146 139
147void qsort(void *base, size_t nmemb, size_t size, 140void qsort(void *base, size_t nmemb, size_t size,
diff --git a/apps/plugin.c b/apps/plugin.c
index 774ae547a3..3e099253dc 100644
--- a/apps/plugin.c
+++ b/apps/plugin.c
@@ -384,6 +384,7 @@ static const struct plugin_api rockbox_api = {
384 lcd_bitmap_transparent_part, 384 lcd_bitmap_transparent_part,
385 lcd_bitmap_transparent, 385 lcd_bitmap_transparent,
386#endif 386#endif
387 memmove,
387}; 388};
388 389
389int plugin_load(const char* plugin, void* parameter) 390int plugin_load(const char* plugin, void* parameter)
diff --git a/apps/plugin.h b/apps/plugin.h
index 1998bcf315..952bdc8846 100644
--- a/apps/plugin.h
+++ b/apps/plugin.h
@@ -97,7 +97,7 @@
97#define PLUGIN_MAGIC 0x526F634B /* RocK */ 97#define PLUGIN_MAGIC 0x526F634B /* RocK */
98 98
99/* increase this every time the api struct changes */ 99/* increase this every time the api struct changes */
100#define PLUGIN_API_VERSION 5 100#define PLUGIN_API_VERSION 6
101 101
102/* update this to latest version if a change to the api struct breaks 102/* update this to latest version if a change to the api struct breaks
103 backwards compatibility (and please take the opportunity to sort in any 103 backwards compatibility (and please take the opportunity to sort in any
@@ -451,6 +451,7 @@ struct plugin_api {
451 void (*lcd_bitmap_transparent)(const fb_data *src, int x, int y, 451 void (*lcd_bitmap_transparent)(const fb_data *src, int x, int y,
452 int width, int height); 452 int width, int height);
453#endif 453#endif
454 void* (*memmove)(void *out, const void *in, size_t n);
454}; 455};
455 456
456/* plugin header */ 457/* plugin header */
diff --git a/apps/plugins/lib/gray_scroll.c b/apps/plugins/lib/gray_scroll.c
index 341024a67e..89ca2f37c3 100644
--- a/apps/plugins/lib/gray_scroll.c
+++ b/apps/plugins/lib/gray_scroll.c
@@ -29,29 +29,6 @@
29#ifdef HAVE_LCD_BITMAP /* and also not for the Player */ 29#ifdef HAVE_LCD_BITMAP /* and also not for the Player */
30#include "gray.h" 30#include "gray.h"
31 31
32/* FIXME: intermediate solution until we have properly optimised memmove() */
33static void *my_memmove(void *dst0, const void *src0, size_t len0)
34{
35 char *dst = (char *) dst0;
36 char *src = (char *) src0;
37
38 if (dst <= src)
39 {
40 while (len0--)
41 *dst++ = *src++;
42 }
43 else
44 {
45 dst += len0;
46 src += len0;
47
48 while (len0--)
49 *(--dst) = *(--src);
50 }
51
52 return dst0;
53}
54
55/*** Scrolling ***/ 32/*** Scrolling ***/
56 33
57/* Scroll left */ 34/* Scroll left */
@@ -68,7 +45,7 @@ void gray_scroll_left(int count)
68 blank = (_gray_info.drawmode & DRMODE_INVERSEVID) ? 45 blank = (_gray_info.drawmode & DRMODE_INVERSEVID) ?
69 _gray_info.fg_brightness : _gray_info.bg_brightness; 46 _gray_info.fg_brightness : _gray_info.bg_brightness;
70 47
71 my_memmove(_gray_info.cur_buffer, _gray_info.cur_buffer + shift, length); 48 _gray_rb->memmove(_gray_info.cur_buffer, _gray_info.cur_buffer + shift, length);
72 _gray_rb->memset(_gray_info.cur_buffer + length, blank, shift); 49 _gray_rb->memset(_gray_info.cur_buffer + length, blank, shift);
73} 50}
74 51
@@ -86,7 +63,7 @@ void gray_scroll_right(int count)
86 blank = (_gray_info.drawmode & DRMODE_INVERSEVID) ? 63 blank = (_gray_info.drawmode & DRMODE_INVERSEVID) ?
87 _gray_info.fg_brightness : _gray_info.bg_brightness; 64 _gray_info.fg_brightness : _gray_info.bg_brightness;
88 65
89 my_memmove(_gray_info.cur_buffer + shift, _gray_info.cur_buffer, length); 66 _gray_rb->memmove(_gray_info.cur_buffer + shift, _gray_info.cur_buffer, length);
90 _gray_rb->memset(_gray_info.cur_buffer, blank, shift); 67 _gray_rb->memset(_gray_info.cur_buffer, blank, shift);
91} 68}
92 69
@@ -107,7 +84,7 @@ void gray_scroll_up(int count)
107 84
108 do 85 do
109 { 86 {
110 my_memmove(data, data + count, length); 87 _gray_rb->memmove(data, data + count, length);
111 _gray_rb->memset(data + length, blank, count); 88 _gray_rb->memset(data + length, blank, count);
112 data += _gray_info.height; 89 data += _gray_info.height;
113 } 90 }
@@ -131,7 +108,7 @@ void gray_scroll_down(int count)
131 108
132 do 109 do
133 { 110 {
134 my_memmove(data + count, data, length); 111 _gray_rb->memmove(data + count, data, length);
135 _gray_rb->memset(data, blank, count); 112 _gray_rb->memset(data, blank, count);
136 data += _gray_info.height; 113 data += _gray_info.height;
137 } 114 }
@@ -161,7 +138,7 @@ void gray_ub_scroll_left(int count)
161 + MULU16(_gray_info.plane_size, _gray_info.depth); 138 + MULU16(_gray_info.plane_size, _gray_info.depth);
162 do 139 do
163 { 140 {
164 my_memmove(ptr_row, ptr_row + count, length); 141 _gray_rb->memmove(ptr_row, ptr_row + count, length);
165 _gray_rb->memset(ptr_row + length, 0, count); 142 _gray_rb->memset(ptr_row + length, 0, count);
166 ptr_row += _gray_info.plane_size; 143 ptr_row += _gray_info.plane_size;
167 } 144 }
@@ -193,7 +170,7 @@ void gray_ub_scroll_right(int count)
193 + MULU16(_gray_info.plane_size, _gray_info.depth); 170 + MULU16(_gray_info.plane_size, _gray_info.depth);
194 do 171 do
195 { 172 {
196 my_memmove(ptr_row + count, ptr_row, length); 173 _gray_rb->memmove(ptr_row + count, ptr_row, length);
197 _gray_rb->memset(ptr_row, 0, count); 174 _gray_rb->memset(ptr_row, 0, count);
198 ptr_row += _gray_info.plane_size; 175 ptr_row += _gray_info.plane_size;
199 } 176 }
diff --git a/apps/plugins/lib/xlcd.c b/apps/plugins/lib/xlcd.c
index 33d807f2f3..a842cf5eb7 100644
--- a/apps/plugins/lib/xlcd.c
+++ b/apps/plugins/lib/xlcd.c
@@ -106,28 +106,6 @@ void xlcd_filltriangle(int x1, int y1, int x2, int y2, int x3, int y3)
106} 106}
107 107
108#if LCD_DEPTH >= 8 108#if LCD_DEPTH >= 8
109/* FIXME: intermediate solution until we have properly optimised memmove() */
110static void *my_memmove(void *dst0, const void *src0, size_t len0)
111{
112 char *dst = (char *) dst0;
113 char *src = (char *) src0;
114
115 if (dst <= src)
116 {
117 while (len0--)
118 *dst++ = *src++;
119 }
120 else
121 {
122 dst += len0;
123 src += len0;
124
125 while (len0--)
126 *(--dst) = *(--src);
127 }
128
129 return dst0;
130}
131 109
132void xlcd_scroll_left(int count) 110void xlcd_scroll_left(int count)
133{ 111{
@@ -143,7 +121,7 @@ void xlcd_scroll_left(int count)
143 121
144 do 122 do
145 { 123 {
146 my_memmove(data, data + count, length * sizeof(fb_data)); 124 local_rb->memmove(data, data + count, length * sizeof(fb_data));
147 data += LCD_WIDTH; 125 data += LCD_WIDTH;
148 } 126 }
149 while (data < data_end); 127 while (data < data_end);
@@ -168,7 +146,7 @@ void xlcd_scroll_right(int count)
168 146
169 do 147 do
170 { 148 {
171 my_memmove(data + count, data, length * sizeof(fb_data)); 149 local_rb->memmove(data + count, data, length * sizeof(fb_data));
172 data += LCD_WIDTH; 150 data += LCD_WIDTH;
173 } 151 }
174 while (data < data_end); 152 while (data < data_end);
@@ -188,9 +166,9 @@ void xlcd_scroll_up(int count)
188 166
189 length = LCD_HEIGHT - count; 167 length = LCD_HEIGHT - count;
190 168
191 my_memmove(local_rb->lcd_framebuffer, 169 local_rb->memmove(local_rb->lcd_framebuffer,
192 local_rb->lcd_framebuffer + count * LCD_WIDTH, 170 local_rb->lcd_framebuffer + count * LCD_WIDTH,
193 length * LCD_WIDTH * sizeof(fb_data)); 171 length * LCD_WIDTH * sizeof(fb_data));
194 172
195 oldmode = local_rb->lcd_get_drawmode(); 173 oldmode = local_rb->lcd_get_drawmode();
196 local_rb->lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID); 174 local_rb->lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);
@@ -207,9 +185,9 @@ void xlcd_scroll_down(int count)
207 185
208 length = LCD_HEIGHT - count; 186 length = LCD_HEIGHT - count;
209 187
210 my_memmove(local_rb->lcd_framebuffer + count * LCD_WIDTH, 188 local_rb->memmove(local_rb->lcd_framebuffer + count * LCD_WIDTH,
211 local_rb->lcd_framebuffer, 189 local_rb->lcd_framebuffer,
212 length * LCD_WIDTH * sizeof(fb_data)); 190 length * LCD_WIDTH * sizeof(fb_data));
213 191
214 oldmode = local_rb->lcd_get_drawmode(); 192 oldmode = local_rb->lcd_get_drawmode();
215 local_rb->lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID); 193 local_rb->lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);