From b0e82d42644bcccc9492b316657bf1c90820d4d8 Mon Sep 17 00:00:00 2001 From: hendricks266 Date: Mon, 28 Jul 2014 06:45:53 +0000 Subject: [PATCH] Split parts of loadlookups() into generatefogpals() and fillemptylookups(), and move Duke-specific LOOKUP.DAT behavior to G_LoadLookups() in source/common.c, which contains the call to loadlookups() as factored out from astub.c and game.c. DONT_BUILD. git-svn-id: https://svn.eduke32.com/eduke32@4564 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/build/include/build.h | 4 +- polymer/eduke32/build/src/engine.c | 36 +++++++------- polymer/eduke32/source/astub.c | 23 +-------- polymer/eduke32/source/common.c | 53 +++++++++++++++++++++ polymer/eduke32/source/common_game.h | 7 +++ polymer/eduke32/source/game.c | 34 ++----------- polymer/eduke32/source/game.h | 1 - polymer/eduke32/source/mapster32.h | 12 ----- polymer/eduke32/source/testgame/src/bstub.c | 1 + polymer/eduke32/source/testgame/src/game.c | 1 + 10 files changed, 88 insertions(+), 84 deletions(-) diff --git a/polymer/eduke32/build/include/build.h b/polymer/eduke32/build/include/build.h index 3317dffba..7d4888886 100644 --- a/polymer/eduke32/build/include/build.h +++ b/polymer/eduke32/build/include/build.h @@ -1064,7 +1064,9 @@ 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 loadlookups(int32_t fp); +int32_t generatefogpals(void); +void fillemptylookups(void); 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 1d4bc7404..958a1267b 100644 --- a/polymer/eduke32/build/src/engine.c +++ b/polymer/eduke32/build/src/engine.c @@ -8160,20 +8160,15 @@ static int32_t loadpalette(void) // // : 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]) -// - if didn't (no room), 0 +// - on success, 0 // - on error, -1 (didn't read enough data) // - -2: error, we already wrote an error message ourselves -int32_t loadlookups(int32_t fp, uint8_t **basepaltabptr) +int32_t loadlookups(int32_t fp) { uint8_t numlookups; char remapbuf[256]; - int32_t j, firstfogpal=0; + int32_t j; if (kread(fp, &numlookups, 1) != 1) return -1; @@ -8197,15 +8192,15 @@ int32_t loadlookups(int32_t fp, uint8_t **basepaltabptr) makepalookup(palnum, remapbuf, 0,0,0, 1); } - for (j=1; j<=5; j++) - { - // Account for TITLE and REALMS swap between basepal number and on-disk order. - // XXX: this reordering is better off as an argument to us. - int32_t basepalnum = (j == 3 || j == 4) ? 4+3-j : j; + return 0; +} - if (kread(fp, basepaltabptr[basepalnum], 768) != 768) - return -1; - } +// Returns: +// - if generated fog shade tables, their first palnum P (fog pals are [P .. P+3]) +// - if didn't (no room), 0 +int32_t generatefogpals(void) +{ + int32_t j, firstfogpal=0; // Find a gap of four consecutive unused pal numbers to generate fog shade tables. for (j=1; j<=255-3; j++) @@ -8220,12 +8215,17 @@ int32_t loadlookups(int32_t fp, uint8_t **basepaltabptr) break; } + return firstfogpal; +} + +void fillemptylookups(void) +{ + int32_t j; + // Alias remaining unused pal numbers to the base shade table. for (j=1; j