[Scummvm-cvs-logs] CVS: scummvm/scumm/smush codec37.cpp,1.10,1.11

Max Horn max at quendi.de
Sun Mar 2 12:46:05 CET 2003


At 12:15 Uhr -0800 02.03.2003, Marcus Comstedt wrote:
>Update of /cvsroot/scummvm/scummvm/scumm/smush
>In directory sc8-pr-cvs1:/tmp/cvs-serv3109
>
>Modified Files:
>	codec37.cpp
>Log Message:
>Handle architectures which need alignment for 32bit memory access...
>
>Index: codec37.cpp
>===================================================================
>RCS file: /cvsroot/scummvm/scummvm/scumm/smush/codec37.cpp,v
>retrieving revision 1.10
>retrieving revision 1.11
>diff -u -d -r1.10 -r1.11
>--- codec37.cpp	28 Feb 2003 20:33:06 -0000	1.10
>+++ codec37.cpp	2 Mar 2003 20:15:22 -0000	1.11
>@@ -288,14 +288,56 @@
>  		do {
>  			int32 code = *src++;
>  			if (code == 0xFD) {
>+#if defined(SCUMM_NEED_ALIGNMENT)
>+				t = *src++;
>+				(dst + pitch * 0)[0] = t;
>+				(dst + pitch * 0)[1] = t;
>+				(dst + pitch * 0)[2] = t;
>+				(dst + pitch * 0)[3] = t;
>+				(dst + pitch * 1)[0] = t;
>+				(dst + pitch * 1)[1] = t;
>+				(dst + pitch * 1)[2] = t;
>+				(dst + pitch * 1)[3] = t;
>+				(dst + pitch * 2)[0] = t;
>+				(dst + pitch * 2)[1] = t;
>+				(dst + pitch * 2)[2] = t;
>+				(dst + pitch * 2)[3] = t;
>+				(dst + pitch * 3)[0] = t;
>+				(dst + pitch * 3)[1] = t;
>+				(dst + pitch * 3)[2] = t;
>+				(dst + pitch * 3)[3] = t;
>+#else
>  				t = *src++;
>  				t += (t << 8) + (t << 16) + (t << 24);
>  				*(uint32*)(dst + pitch * 0) = t;
>  				*(uint32*)(dst + pitch * 1) = t;
>  				*(uint32*)(dst + pitch * 2) = t;
>  				*(uint32*)(dst + pitch * 3) = t;
>+#endif

[... more similiar code ... ]

Uh, that's pretty ugly and hard to maintain... I already see the 
typos sneaking in whenever we have to fix something here. Why not use 
clean simple nested look for the SCUMM_NEED_ALIGNMENT variants? Any 
reasonable compiler should automatically unroll them, shouldn't it? 
I.e something lie

   t = *src++;
#if defined(SCUMM_NEED_ALIGNMENT)
   for (int i = 0; i < 4; i++)
     for (int j = 0; j < 4; j++)
       (dst + pitch * i)[j] = t;
#else
  ...
#endif




Bye,

Max




More information about the Scummvm-git-logs mailing list