X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?p=fceu.git;a=blobdiff_plain;f=memory.c;h=8fb701d1a9a093b9a4ab36c13989f73b2521129b;hp=bec72700d7d7e52bbb8983d2cd7b84bab5e0ffe2;hb=c0bf6f9f02a2b6afb961a7e9195e2168d7e9cecf;hpb=c62d28102c77e19c291c78bf6bf7f0a81abd54b9 diff --git a/memory.c b/memory.c index bec7270..8fb701d 100644 --- a/memory.c +++ b/memory.c @@ -40,6 +40,8 @@ void FCEU_free(void *ptr) // Might do something with this and FCEU_malloc later free(ptr); } + + void FASTAPASS(3) FCEU_memmove(void *d, void *s, uint32 l) { uint32 x; @@ -51,17 +53,32 @@ void FASTAPASS(3) FCEU_memmove(void *d, void *s, uint32 l) t|=(int)l; if(t&3) // Not 4-byte aligned and/or length is not a multiple of 4. + { + uint8 *tmpd, *tmps; + + tmpd = d; + tmps = s; + for(x=l;x;x--) // This could be optimized further, though(more tests could be performed). { - *(uint8*)d=*(uint8 *)s; - ((uint8 *)d)++; - ((uint8 *)s)++; + *tmpd=*tmps; + tmpd++; + tmps++; + } } else + { + uint32 *tmpd, *tmps; + + tmpd = d; + tmps = s; + for(x=l>>2;x;x--) { - *(uint32*)d=*(uint32*)s; - ((uint32 *)d)++; - ((uint32 *)s)++; + *tmpd=*tmps; + tmpd++; + tmps++; } } +} +