diff --git a/polymer/eduke32/build/include/build.h b/polymer/eduke32/build/include/build.h index b9961f4e2..0a077c5da 100644 --- a/polymer/eduke32/build/include/build.h +++ b/polymer/eduke32/build/include/build.h @@ -1051,6 +1051,7 @@ int32_t preinitengine(void); // a partial setup of the engine used for launch int32_t initengine(void); void uninitengine(void); void initspritelists(void); +int32_t loadlookups(int32_t fp, uint8_t **basepaltabptr); int32_t loadboard(const char *filename, char flags, vec3_t *dapos, int16_t *daang, int16_t *dacursectnum); int32_t loadmaphack(const char *filename); void delete_maphack_lights(); diff --git a/polymer/eduke32/build/src/engine.c b/polymer/eduke32/build/src/engine.c index 6155edefa..a535bccea 100644 --- a/polymer/eduke32/build/src/engine.c +++ b/polymer/eduke32/build/src/engine.c @@ -8140,6 +8140,59 @@ static int32_t loadpalette(void) return 0; } +// Load LOOKUP.DAT, which contains lookup tables and additional base palettes. +// +// : kopen4load file handle +// +// basepaltabptr[j], for 1 <= j <= 5 must point to 768 addressable +// bytes each: the additional base palettes (water, slime, ...) will be +// written there. +// +// Returns: +// - if generated fog shade tables, their first palnum P (fog pals are [P .. P+3]) +// - on error, -1 +int32_t loadlookups(int32_t fp, uint8_t **basepaltabptr) +{ + uint8_t numlookups; + char remapbuf[256]; + int32_t j; + + if (kread(fp, &numlookups, 1) != 1) + return -1; + + for (j=numlookups+1; j must be in [0 .. 255]. diff --git a/polymer/eduke32/source/astub.c b/polymer/eduke32/source/astub.c index e86bd6335..d545751d5 100644 --- a/polymer/eduke32/source/astub.c +++ b/polymer/eduke32/source/astub.c @@ -2842,47 +2842,31 @@ static inline void SpriteName(int16_t spritenum, char *lo2) Bstrcpy(lo2, names[sprite[spritenum].picnum]); }// end SpriteName -static void ReadPaletteTable(void) +// Returns: did error? +static int32_t ReadPaletteTable(void) { - int32_t i,j,fp; - char lookup_num; - - for (i=1; i=0; j--) - { - uint8_t look_pos; - - kread(fp, &look_pos, 1); - kread(fp, tempbuf, 256); - makepalookup(look_pos, tempbuf, 0,0,0, 1); - } - - g_numRealPalettes++; - makepalookup(g_numRealPalettes, NULL, 15, 15, 15, 1); - makepalookup(g_numRealPalettes + 1, NULL, 15, 0, 0, 1); - makepalookup(g_numRealPalettes + 2, NULL, 0, 15, 0, 1); - makepalookup(g_numRealPalettes + 3, NULL, 0, 0, 15, 1); - - kread(fp,&water_pal[0],768); - kread(fp,&slime_pal[0],768); - kread(fp,&title_pal[0],768); - kread(fp,&dre_alms[0],768); - kread(fp,&ending_pal[0],768); - - palette[765] = palette[766] = palette[767] = 0; - slime_pal[765] = slime_pal[766] = slime_pal[767] = 0; - water_pal[765] = water_pal[766] = water_pal[767] = 0; - + g_numRealPalettes = loadlookups(fp, basepaltable); kclose(fp); + + if (g_numRealPalettes < 0) + G_GameExit("\nERROR loading 'lookup.dat': failed reading enough data."); + + // Make color index 255 of default/water/slime palette black. + Bmemset(&palette[255*3], 0, 3); + Bmemset(&water_pal[255*3], 0, 3); + Bmemset(&slime_pal[255*3], 0, 3); } #define SETBGFLAG(Tilenum) g_tile[Tilenum].flags |= SPRITE_HARDCODED_BADGUY diff --git a/polymer/eduke32/source/game.h b/polymer/eduke32/source/game.h index b12a80dba..8aa78351d 100644 --- a/polymer/eduke32/source/game.h +++ b/polymer/eduke32/source/game.h @@ -299,7 +299,6 @@ extern palette_t DefaultCrosshairColors; extern uint32_t g_frameDelay; -extern uint8_t water_pal[768],slime_pal[768],title_pal[768],dre_alms[768],ending_pal[768]; extern uint8_t *basepaltable[BASEPALCOUNT]; extern int8_t g_noFloorPal[MAXPALOOKUPS]; diff --git a/polymer/eduke32/source/mapster32.h b/polymer/eduke32/source/mapster32.h index b182ef178..e6491894f 100644 --- a/polymer/eduke32/source/mapster32.h +++ b/polymer/eduke32/source/mapster32.h @@ -78,10 +78,13 @@ static void FuncMenu(void); static uint8_t WATERpalette[768], SLIMEpalette[768], TITLEpalette[768]; static uint8_t REALMSpalette[768], BOSS1palette[768]; -static uint8_t *basepaltable[BASEPALCOUNT] = { palette, WATERpalette, SLIMEpalette, TITLEpalette, REALMSpalette, BOSS1palette }; +static uint8_t *basepaltable[BASEPALCOUNT] = { + palette, WATERpalette, SLIMEpalette, + REALMSpalette, TITLEpalette, BOSS1palette, +}; -static char num_tables; +static int32_t num_tables; static int32_t updownunits=1024;