X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=Pico%2FMisc.c;h=a458f4de120f4c2a36a3e59fab7c7d2280dddfcd;hb=70357ce52578dee0dd3b3663902cf872c3d34258;hp=38c381dd1861b33263db06a1238237f88b49624f;hpb=7d4906bfc93ced40a544534f433f06b00add52b0;p=picodrive.git diff --git a/Pico/Misc.c b/Pico/Misc.c index 38c381d..a458f4d 100644 --- a/Pico/Misc.c +++ b/Pico/Misc.c @@ -316,8 +316,30 @@ PICO_INTERNAL void SRAMUpdPending(unsigned int a, unsigned int d) #ifndef _ASM_MISC_C +typedef struct +{ + int b0; + int b1; + int b2; + int b3; + int b4; + int b5; + int b6; + int b7; +} intblock; + PICO_INTERNAL_ASM void memcpy16(unsigned short *dest, unsigned short *src, int count) { + if (((int)dest & (int)src & 3) == 0) + { + if (count >= 32) { + memcpy32((int *)dest, (int *)src, count/2); + count&=1; + } else { + for (; count >= 2; count -= 2, dest+=2, src+=2) + *(int *)dest = *(int *)src; + } + } while (count--) *dest++ = *src++; } @@ -334,6 +356,12 @@ PICO_INTERNAL_ASM void memcpy16bswap(unsigned short *dest, void *src, int count) PICO_INTERNAL_ASM void memcpy32(int *dest, int *src, int count) { + intblock *bd = (intblock *) dest, *bs = (intblock *) src; + + for (; count >= sizeof(*bd)/4; count -= sizeof(*bd)/4) + *bd++ = *bs++; + + dest = (int *)bd; src = (int *)bs; while (count--) *dest++ = *src++; } @@ -341,6 +369,10 @@ PICO_INTERNAL_ASM void memcpy32(int *dest, int *src, int count) PICO_INTERNAL_ASM void memset32(int *dest, int c, int count) { + for (; count >= 8; count -= 8, dest += 8) + dest[0] = dest[1] = dest[2] = dest[3] = + dest[4] = dest[5] = dest[6] = dest[7] = c; + while (count--) *dest++ = c; }