From f013a038dda405d44f8c17cbd2cdf5827666c193 Mon Sep 17 00:00:00 2001 From: ludwig Date: Tue, 6 Dec 2005 23:11:25 +0000 Subject: use memcpy for copying stuff around to fix alignment problems git-svn-id: svn://svn.icculus.org/quake3/trunk@434 edf5b092-35ff-0310-97b2-ce42778d08ea --- code/client/cl_cin.c | 116 +++++++++++++++------------------------------------ 1 file changed, 34 insertions(+), 82 deletions(-) (limited to 'code') diff --git a/code/client/cl_cin.c b/code/client/cl_cin.c index e15f4a7..3b75c2e 100644 --- a/code/client/cl_cin.c +++ b/code/client/cl_cin.c @@ -333,28 +333,14 @@ long RllDecodeStereoToMono(unsigned char *from,short *to,unsigned int size,char static void move8_32( byte *src, byte *dst, int spl ) { - double *dsrc, *ddst; - int dspl; - - dsrc = (double *)src; - ddst = (double *)dst; - dspl = spl>>3; - - ddst[0] = dsrc[0]; ddst[1] = dsrc[1]; ddst[2] = dsrc[2]; ddst[3] = dsrc[3]; - dsrc += dspl; ddst += dspl; - ddst[0] = dsrc[0]; ddst[1] = dsrc[1]; ddst[2] = dsrc[2]; ddst[3] = dsrc[3]; - dsrc += dspl; ddst += dspl; - ddst[0] = dsrc[0]; ddst[1] = dsrc[1]; ddst[2] = dsrc[2]; ddst[3] = dsrc[3]; - dsrc += dspl; ddst += dspl; - ddst[0] = dsrc[0]; ddst[1] = dsrc[1]; ddst[2] = dsrc[2]; ddst[3] = dsrc[3]; - dsrc += dspl; ddst += dspl; - ddst[0] = dsrc[0]; ddst[1] = dsrc[1]; ddst[2] = dsrc[2]; ddst[3] = dsrc[3]; - dsrc += dspl; ddst += dspl; - ddst[0] = dsrc[0]; ddst[1] = dsrc[1]; ddst[2] = dsrc[2]; ddst[3] = dsrc[3]; - dsrc += dspl; ddst += dspl; - ddst[0] = dsrc[0]; ddst[1] = dsrc[1]; ddst[2] = dsrc[2]; ddst[3] = dsrc[3]; - dsrc += dspl; ddst += dspl; - ddst[0] = dsrc[0]; ddst[1] = dsrc[1]; ddst[2] = dsrc[2]; ddst[3] = dsrc[3]; + int i; + + for(i = 0; i < 8; ++i) + { + memcpy(dst, src, 32); + src += spl; + dst += spl; + } } /****************************************************************************** @@ -367,20 +353,14 @@ static void move8_32( byte *src, byte *dst, int spl ) static void move4_32( byte *src, byte *dst, int spl ) { - double *dsrc, *ddst; - int dspl; - - dsrc = (double *)src; - ddst = (double *)dst; - dspl = spl>>3; - - ddst[0] = dsrc[0]; ddst[1] = dsrc[1]; - dsrc += dspl; ddst += dspl; - ddst[0] = dsrc[0]; ddst[1] = dsrc[1]; - dsrc += dspl; ddst += dspl; - ddst[0] = dsrc[0]; ddst[1] = dsrc[1]; - dsrc += dspl; ddst += dspl; - ddst[0] = dsrc[0]; ddst[1] = dsrc[1]; + int i; + + for(i = 0; i < 4; ++i) + { + memcpy(dst, src, 16); + src += spl; + dst += spl; + } } /****************************************************************************** @@ -393,28 +373,14 @@ static void move4_32( byte *src, byte *dst, int spl ) static void blit8_32( byte *src, byte *dst, int spl ) { - double *dsrc, *ddst; - int dspl; - - dsrc = (double *)src; - ddst = (double *)dst; - dspl = spl>>3; - - ddst[0] = dsrc[0]; ddst[1] = dsrc[1]; ddst[2] = dsrc[2]; ddst[3] = dsrc[3]; - dsrc += 4; ddst += dspl; - ddst[0] = dsrc[0]; ddst[1] = dsrc[1]; ddst[2] = dsrc[2]; ddst[3] = dsrc[3]; - dsrc += 4; ddst += dspl; - ddst[0] = dsrc[0]; ddst[1] = dsrc[1]; ddst[2] = dsrc[2]; ddst[3] = dsrc[3]; - dsrc += 4; ddst += dspl; - ddst[0] = dsrc[0]; ddst[1] = dsrc[1]; ddst[2] = dsrc[2]; ddst[3] = dsrc[3]; - dsrc += 4; ddst += dspl; - ddst[0] = dsrc[0]; ddst[1] = dsrc[1]; ddst[2] = dsrc[2]; ddst[3] = dsrc[3]; - dsrc += 4; ddst += dspl; - ddst[0] = dsrc[0]; ddst[1] = dsrc[1]; ddst[2] = dsrc[2]; ddst[3] = dsrc[3]; - dsrc += 4; ddst += dspl; - ddst[0] = dsrc[0]; ddst[1] = dsrc[1]; ddst[2] = dsrc[2]; ddst[3] = dsrc[3]; - dsrc += 4; ddst += dspl; - ddst[0] = dsrc[0]; ddst[1] = dsrc[1]; ddst[2] = dsrc[2]; ddst[3] = dsrc[3]; + int i; + + for(i = 0; i < 8; ++i) + { + memcpy(dst, src, 32); + src += 32; + dst += spl; + } } /****************************************************************************** @@ -424,23 +390,16 @@ static void blit8_32( byte *src, byte *dst, int spl ) * Description: * ******************************************************************************/ -#define movs double static void blit4_32( byte *src, byte *dst, int spl ) { - movs *dsrc, *ddst; - int dspl; - - dsrc = (movs *)src; - ddst = (movs *)dst; - dspl = spl>>3; - - ddst[0] = dsrc[0]; ddst[1] = dsrc[1]; - dsrc += 2; ddst += dspl; - ddst[0] = dsrc[0]; ddst[1] = dsrc[1]; - dsrc += 2; ddst += dspl; - ddst[0] = dsrc[0]; ddst[1] = dsrc[1]; - dsrc += 2; ddst += dspl; - ddst[0] = dsrc[0]; ddst[1] = dsrc[1]; + int i; + + for(i = 0; i < 4; ++i) + { + memmove(dst, src, 16); + src += 16; + dst += spl; + } } /****************************************************************************** @@ -453,15 +412,8 @@ static void blit4_32( byte *src, byte *dst, int spl ) static void blit2_32( byte *src, byte *dst, int spl ) { - double *dsrc, *ddst; - int dspl; - - dsrc = (double *)src; - ddst = (double *)dst; - dspl = spl>>3; - - ddst[0] = dsrc[0]; - ddst[dspl] = dsrc[1]; + memcpy(dst, src, 8); + memcpy(dst+spl, src+8, 8); } /****************************************************************************** -- cgit v1.2.3