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