quake: fix errorneous endian-correcting reads

ef9ee89 introduced Read{Big,Little}{Short,Long,Float} functions to safely
read a value in memory. These incorrectly take char*, which causes them to
output erroneous 0xff bytes when given bytes with bit 7 set.

Change-Id: I9531172301aecfdacae405d2f782f662608ce6df
diff --git a/apps/plugins/sdl/progs/quake/common.c b/apps/plugins/sdl/progs/quake/common.c
index 5e842b0..5191af8 100644
--- a/apps/plugins/sdl/progs/quake/common.c
+++ b/apps/plugins/sdl/progs/quake/common.c
@@ -499,28 +499,28 @@
 }
 
 // safe for unaligned accesses
-short   ReadLittleShort (char *l)
+short   ReadLittleShort (unsigned char *l)
 {
     return *(l + 0) | (*(l + 1) << 8);
 }
 
-short   ReadBigShort (char *l)
+short   ReadBigShort (unsigned char *l)
 {
     return *(l + 1) | (*(l + 0) << 8);
 }
 
-int    ReadLittleLong (char *l)
+int    ReadLittleLong (unsigned char *l)
 {
     return *(l + 0) | (*(l + 1) << 8) | (*(l + 2) << 16) | (*(l + 3) << 24);
 }
 
-int ReadBigLong (char *l)
+int ReadBigLong (unsigned char *l)
 {
     return *(l + 3) | (*(l + 2) << 8) | (*(l + 1) << 16) | (*(l + 0) << 24);
 }
 
 // same
-float ReadLittleFloat (char *f)
+float ReadLittleFloat (unsigned char *f)
 {
 	union
 	{
@@ -536,7 +536,7 @@
 	return dat2.f;
 }
 
-float ReadBigFloat (char *f)
+float ReadBigFloat (unsigned char *f)
 {
 	union
 	{
diff --git a/apps/plugins/sdl/progs/quake/common.h b/apps/plugins/sdl/progs/quake/common.h
index 8c6ab3a..5f44b9f 100644
--- a/apps/plugins/sdl/progs/quake/common.h
+++ b/apps/plugins/sdl/progs/quake/common.h
@@ -96,21 +96,21 @@
 extern  float   (*BigFloat) (float l);
 extern  float   (*LittleFloat) (float l);
 
-#define LittleShortUnaligned(x) ReadLittleShort(((char*)(&(x))))
-#define BigShortUnaligned(x) ReadBigShort(((char*)&(x)))
-#define LittleLongUnaligned(x) ReadLittleLong(((char*)&(x)))
-#define BigLongUnaligned(x) ReadBigLong(((char*)&(x)))
-#define LittleFloatUnaligned(x) ReadLittleFloat(((char*)&(x)))
-#define BigFloatUnaligned(x) ReadBigFloat(((char*)&(x))
+#define LittleShortUnaligned(x) ReadLittleShort(((unsigned char*)(&(x))))
+#define BigShortUnaligned(x) ReadBigShort(((unsigned char*)&(x)))
+#define LittleLongUnaligned(x) ReadLittleLong(((unsigned char*)&(x)))
+#define BigLongUnaligned(x) ReadBigLong(((unsigned char*)&(x)))
+#define LittleFloatUnaligned(x) ReadLittleFloat(((unsigned char*)&(x)))
+#define BigFloatUnaligned(x) ReadBigFloat(((unsigned char*)&(x))
 
 
 // for unaligned
-short	ReadBigShort (char *l);
-short	ReadLittleShort (char *l);
-int	ReadBigLong (char *l);
-int	ReadLittleLong (char *l);
-float	ReadBigFloat (char *l);
-float	ReadLittleFloat (char *l);
+short	ReadBigShort (unsigned char *l);
+short	ReadLittleShort (unsigned char *l);
+int	ReadBigLong (unsigned char *l);
+int	ReadLittleLong (unsigned char *l);
+float	ReadBigFloat (unsigned char *l);
+float	ReadLittleFloat (unsigned char *l);
 
 //============================================================================
 
diff --git a/apps/plugins/sdl/progs/quake/model.c b/apps/plugins/sdl/progs/quake/model.c
index 4c16c7f..5ac6dc6 100644
--- a/apps/plugins/sdl/progs/quake/model.c
+++ b/apps/plugins/sdl/progs/quake/model.c
@@ -1165,7 +1165,11 @@
 	mod_base = (byte *)header;
 
 	for (i=0 ; i<sizeof(dheader_t)/4 ; i++)
-		((int *)header)[i] = LittleLongUnaligned ( ((int *)header)[i]);
+        {
+            int before = ((int*)header)[i];
+		((int *)header)[i] = LittleLongUnaligned ( ((int *)header) [i]);
+                assert(((int*)header)[i] == before); // sanity check of our *Unaligned routines
+        }
 
 // load into heap