forked from len0rd/rockbox
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
This commit is contained in:
parent
7bef453e03
commit
7e4902bf6b
3 changed files with 23 additions and 19 deletions
|
@ -499,28 +499,28 @@ float FloatNoSwap (float f)
|
|||
}
|
||||
|
||||
// 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 @@ float ReadLittleFloat (char *f)
|
|||
return dat2.f;
|
||||
}
|
||||
|
||||
float ReadBigFloat (char *f)
|
||||
float ReadBigFloat (unsigned char *f)
|
||||
{
|
||||
union
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue