1
0
Fork 0
forked from len0rd/rockbox

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
This commit is contained in:
Jens Arnold 2006-02-06 16:04:01 +00:00
parent d036e97d38
commit e6e8aa9519
7 changed files with 22 additions and 70 deletions

View file

@ -215,6 +215,7 @@ struct codec_api ci = {
/* new stuff at the end, sort into place next time /* new stuff at the end, sort into place next time
the API gets incompatible */ the API gets incompatible */
memmove,
}; };
int codec_load_ram(char* codecptr, int size, void* ptr2, int bufwrap, int codec_load_ram(char* codecptr, int size, void* ptr2, int bufwrap,

View file

@ -85,7 +85,7 @@
#define CODEC_MAGIC 0x52434F44 /* RCOD */ #define CODEC_MAGIC 0x52434F44 /* RCOD */
/* increase this every time the api struct changes */ /* increase this every time the api struct changes */
#define CODEC_API_VERSION 3 #define CODEC_API_VERSION 4
/* update this to latest version if a change to the api struct breaks /* update this to latest version if a change to the api struct breaks
backwards compatibility (and please take the opportunity to sort in any backwards compatibility (and please take the opportunity to sort in any
@ -292,6 +292,7 @@ struct codec_api {
/* new stuff at the end, sort into place next time /* new stuff at the end, sort into place next time
the API gets incompatible */ the API gets incompatible */
void* (*memmove)(void *out, const void *in, size_t n);
}; };
/* codec header */ /* codec header */

View file

@ -132,16 +132,9 @@ void* memchr(const void *s, int c, size_t n)
return(local_rb->memchr(s,c,n)); return(local_rb->memchr(s,c,n));
} }
void* memmove(void *s1, const void *s2, size_t n) void *memmove(void *dest, const void *src, size_t n)
{ {
char* dest=(char*)s1; return(local_rb->memmove(dest,src,n));
char* src=(char*)s2;
size_t i;
for (i=0;i<n;i++)
dest[i]=src[i];
return(dest);
} }
void qsort(void *base, size_t nmemb, size_t size, void qsort(void *base, size_t nmemb, size_t size,

View file

@ -384,6 +384,7 @@ static const struct plugin_api rockbox_api = {
lcd_bitmap_transparent_part, lcd_bitmap_transparent_part,
lcd_bitmap_transparent, lcd_bitmap_transparent,
#endif #endif
memmove,
}; };
int plugin_load(const char* plugin, void* parameter) int plugin_load(const char* plugin, void* parameter)

View file

@ -97,7 +97,7 @@
#define PLUGIN_MAGIC 0x526F634B /* RocK */ #define PLUGIN_MAGIC 0x526F634B /* RocK */
/* increase this every time the api struct changes */ /* increase this every time the api struct changes */
#define PLUGIN_API_VERSION 5 #define PLUGIN_API_VERSION 6
/* update this to latest version if a change to the api struct breaks /* update this to latest version if a change to the api struct breaks
backwards compatibility (and please take the opportunity to sort in any backwards compatibility (and please take the opportunity to sort in any
@ -451,6 +451,7 @@ struct plugin_api {
void (*lcd_bitmap_transparent)(const fb_data *src, int x, int y, void (*lcd_bitmap_transparent)(const fb_data *src, int x, int y,
int width, int height); int width, int height);
#endif #endif
void* (*memmove)(void *out, const void *in, size_t n);
}; };
/* plugin header */ /* plugin header */

View file

@ -29,29 +29,6 @@
#ifdef HAVE_LCD_BITMAP /* and also not for the Player */ #ifdef HAVE_LCD_BITMAP /* and also not for the Player */
#include "gray.h" #include "gray.h"
/* FIXME: intermediate solution until we have properly optimised memmove() */
static void *my_memmove(void *dst0, const void *src0, size_t len0)
{
char *dst = (char *) dst0;
char *src = (char *) src0;
if (dst <= src)
{
while (len0--)
*dst++ = *src++;
}
else
{
dst += len0;
src += len0;
while (len0--)
*(--dst) = *(--src);
}
return dst0;
}
/*** Scrolling ***/ /*** Scrolling ***/
/* Scroll left */ /* Scroll left */
@ -68,7 +45,7 @@ void gray_scroll_left(int count)
blank = (_gray_info.drawmode & DRMODE_INVERSEVID) ? blank = (_gray_info.drawmode & DRMODE_INVERSEVID) ?
_gray_info.fg_brightness : _gray_info.bg_brightness; _gray_info.fg_brightness : _gray_info.bg_brightness;
my_memmove(_gray_info.cur_buffer, _gray_info.cur_buffer + shift, length); _gray_rb->memmove(_gray_info.cur_buffer, _gray_info.cur_buffer + shift, length);
_gray_rb->memset(_gray_info.cur_buffer + length, blank, shift); _gray_rb->memset(_gray_info.cur_buffer + length, blank, shift);
} }
@ -86,7 +63,7 @@ void gray_scroll_right(int count)
blank = (_gray_info.drawmode & DRMODE_INVERSEVID) ? blank = (_gray_info.drawmode & DRMODE_INVERSEVID) ?
_gray_info.fg_brightness : _gray_info.bg_brightness; _gray_info.fg_brightness : _gray_info.bg_brightness;
my_memmove(_gray_info.cur_buffer + shift, _gray_info.cur_buffer, length); _gray_rb->memmove(_gray_info.cur_buffer + shift, _gray_info.cur_buffer, length);
_gray_rb->memset(_gray_info.cur_buffer, blank, shift); _gray_rb->memset(_gray_info.cur_buffer, blank, shift);
} }
@ -107,7 +84,7 @@ void gray_scroll_up(int count)
do do
{ {
my_memmove(data, data + count, length); _gray_rb->memmove(data, data + count, length);
_gray_rb->memset(data + length, blank, count); _gray_rb->memset(data + length, blank, count);
data += _gray_info.height; data += _gray_info.height;
} }
@ -131,7 +108,7 @@ void gray_scroll_down(int count)
do do
{ {
my_memmove(data + count, data, length); _gray_rb->memmove(data + count, data, length);
_gray_rb->memset(data, blank, count); _gray_rb->memset(data, blank, count);
data += _gray_info.height; data += _gray_info.height;
} }
@ -161,7 +138,7 @@ void gray_ub_scroll_left(int count)
+ MULU16(_gray_info.plane_size, _gray_info.depth); + MULU16(_gray_info.plane_size, _gray_info.depth);
do do
{ {
my_memmove(ptr_row, ptr_row + count, length); _gray_rb->memmove(ptr_row, ptr_row + count, length);
_gray_rb->memset(ptr_row + length, 0, count); _gray_rb->memset(ptr_row + length, 0, count);
ptr_row += _gray_info.plane_size; ptr_row += _gray_info.plane_size;
} }
@ -193,7 +170,7 @@ void gray_ub_scroll_right(int count)
+ MULU16(_gray_info.plane_size, _gray_info.depth); + MULU16(_gray_info.plane_size, _gray_info.depth);
do do
{ {
my_memmove(ptr_row + count, ptr_row, length); _gray_rb->memmove(ptr_row + count, ptr_row, length);
_gray_rb->memset(ptr_row, 0, count); _gray_rb->memset(ptr_row, 0, count);
ptr_row += _gray_info.plane_size; ptr_row += _gray_info.plane_size;
} }

View file

@ -106,28 +106,6 @@ void xlcd_filltriangle(int x1, int y1, int x2, int y2, int x3, int y3)
} }
#if LCD_DEPTH >= 8 #if LCD_DEPTH >= 8
/* FIXME: intermediate solution until we have properly optimised memmove() */
static void *my_memmove(void *dst0, const void *src0, size_t len0)
{
char *dst = (char *) dst0;
char *src = (char *) src0;
if (dst <= src)
{
while (len0--)
*dst++ = *src++;
}
else
{
dst += len0;
src += len0;
while (len0--)
*(--dst) = *(--src);
}
return dst0;
}
void xlcd_scroll_left(int count) void xlcd_scroll_left(int count)
{ {
@ -143,7 +121,7 @@ void xlcd_scroll_left(int count)
do do
{ {
my_memmove(data, data + count, length * sizeof(fb_data)); local_rb->memmove(data, data + count, length * sizeof(fb_data));
data += LCD_WIDTH; data += LCD_WIDTH;
} }
while (data < data_end); while (data < data_end);
@ -168,7 +146,7 @@ void xlcd_scroll_right(int count)
do do
{ {
my_memmove(data + count, data, length * sizeof(fb_data)); local_rb->memmove(data + count, data, length * sizeof(fb_data));
data += LCD_WIDTH; data += LCD_WIDTH;
} }
while (data < data_end); while (data < data_end);
@ -188,9 +166,9 @@ void xlcd_scroll_up(int count)
length = LCD_HEIGHT - count; length = LCD_HEIGHT - count;
my_memmove(local_rb->lcd_framebuffer, local_rb->memmove(local_rb->lcd_framebuffer,
local_rb->lcd_framebuffer + count * LCD_WIDTH, local_rb->lcd_framebuffer + count * LCD_WIDTH,
length * LCD_WIDTH * sizeof(fb_data)); length * LCD_WIDTH * sizeof(fb_data));
oldmode = local_rb->lcd_get_drawmode(); oldmode = local_rb->lcd_get_drawmode();
local_rb->lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID); local_rb->lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);
@ -207,9 +185,9 @@ void xlcd_scroll_down(int count)
length = LCD_HEIGHT - count; length = LCD_HEIGHT - count;
my_memmove(local_rb->lcd_framebuffer + count * LCD_WIDTH, local_rb->memmove(local_rb->lcd_framebuffer + count * LCD_WIDTH,
local_rb->lcd_framebuffer, local_rb->lcd_framebuffer,
length * LCD_WIDTH * sizeof(fb_data)); length * LCD_WIDTH * sizeof(fb_data));
oldmode = local_rb->lcd_get_drawmode(); oldmode = local_rb->lcd_get_drawmode();
local_rb->lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID); local_rb->lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);