Weirdness removal in G_LoadExtraPalettes (which reads lookup.dat).

- replace bit tweaking for big endian archs with clear code
- allow palette lookups >= 128, previously we read into a signed byte

git-svn-id: https://svn.eduke32.com/eduke32@2503 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2012-03-20 18:31:37 +00:00
parent 97020caf73
commit 8a50b75de2

View file

@ -9475,20 +9475,19 @@ static inline void G_CheckGametype(void)
static void G_LoadExtraPalettes(void)
{
int32_t j,fp;
int8_t look_pos;
char *lookfn = "lookup.dat";
int32_t j, fp;
uint8_t tmpbyte;
fp = kopen4loadfrommod(lookfn,0);
fp = kopen4loadfrommod("lookup.dat", 0);
if (fp != -1)
kread(fp,(char *)&g_numRealPalettes,1);
kread(fp, &tmpbyte, 1);
else
G_GameExit("\nERROR: File 'lookup.dat' not found.");
g_numRealPalettes = tmpbyte;
#if defined(__APPLE__) && B_BIG_ENDIAN != 0
// this is almost as bad as just setting the value to 25 :P
g_numRealPalettes = ((g_numRealPalettes * 0x80200802ULL) & 0x0884422110ULL) * 0x0101010101ULL >> 32;
// g_numRealPalettes = ((g_numRealPalettes * 0x80200802ULL) & 0x0884422110ULL) * 0x0101010101ULL >> 32;
#endif
for (j = 0; j < 256; j++)
@ -9499,9 +9498,11 @@ static void G_LoadExtraPalettes(void)
for (j=g_numRealPalettes-1; j>=0; j--)
{
kread(fp,(char *)&look_pos,1);
kread(fp,tempbuf,256);
makepalookup((int32_t)look_pos,tempbuf,0,0,0,1);
uint8_t look_pos;
kread(fp, &look_pos, 1);
kread(fp, tempbuf, 256);
makepalookup(look_pos, tempbuf, 0,0,0, 1);
}
for (j = 255; j>=0; j--)