--- sourceforge.net/trunk/rdesktop/bitmap.c 2004/04/27 09:04:42 681 +++ sourceforge.net/trunk/rdesktop/bitmap.c 2005/03/06 21:11:18 828 @@ -1,7 +1,7 @@ /* rdesktop: A Remote Desktop Protocol client. Bitmap decompression routines - Copyright (C) Matthew Chapman 1999-2002 + Copyright (C) Matthew Chapman 1999-2005 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -31,7 +31,15 @@ #include "rdesktop.h" #define CVAL(p) (*(p++)) -#define CVAL2(p) (*(((uint16*)p)++)) /* for 16 bit */ +#ifdef NEED_ALIGN +#ifdef L_ENDIAN +#define CVAL2(p, v) { v = (*(p++)); v |= (*(p++)) << 8; } +#else +#define CVAL2(p, v) { v = (*(p++)) << 8; v |= (*(p++)); } +#endif /* L_ENDIAN */ +#else +#define CVAL2(p, v) { v = (*((uint16*)p)); p += 2; } +#endif /* NEED_ALIGN */ #define UNROLL8(exp) { exp exp exp exp exp exp exp exp } @@ -330,25 +338,13 @@ insertmix = True; break; case 8: /* Bicolour */ -#ifdef NEED_ALIGNMENT - memcpy(&colour1,&CVAL2(input),2); -#else - colour1 = CVAL2(input); -#endif + CVAL2(input, colour1); case 3: /* Colour */ -#ifdef NEED_ALIGNMENT - memcpy(&colour2,&CVAL2(input),2); -#else - colour2 = CVAL2(input); -#endif + CVAL2(input, colour2); break; case 6: /* SetMix/Mix */ case 7: /* SetMix/FillOrMix */ -#ifdef NEED_ALIGNMENT - memcpy(&mix,&CVAL2(input),2); -#else - mix = CVAL2(input); -#endif + CVAL2(input, mix); opcode -= 5; break; case 9: /* FillOrMix_1 */ @@ -436,11 +432,7 @@ REPEAT(line[x] = colour2) break; case 4: /* Copy */ -#ifdef NEED_ALIGNMENT - REPEAT(memcpy(&line[x],&CVAL2(input),2)) -#else - REPEAT(line[x] = CVAL2(input)) -#endif + REPEAT(CVAL2(input, line[x])) break; case 8: /* Bicolour */ REPEAT