mirror of
https://github.com/DrBeef/Raze.git
synced 2024-11-15 08:52:00 +00:00
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
This commit is contained in:
parent
cf4473c4d7
commit
b0e82d4264
10 changed files with 88 additions and 84 deletions
|
@ -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();
|
||||
|
|
|
@ -8160,20 +8160,15 @@ static int32_t loadpalette(void)
|
|||
//
|
||||
// <fp>: 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<MAXPALOOKUPS; j++)
|
||||
if (!palookup[j])
|
||||
makepalookup(j, NULL, 0,0,0, 1);
|
||||
|
||||
return firstfogpal;
|
||||
}
|
||||
|
||||
// Finds a color index in [0 .. lastokcol] closest to (r, g, b).
|
||||
|
|
|
@ -2343,33 +2343,12 @@ static inline void SpriteName(int16_t spritenum, char *lo2)
|
|||
// Returns: did error?
|
||||
static int32_t ReadPaletteTable(void)
|
||||
{
|
||||
int32_t fp;
|
||||
|
||||
// Make base shade table at shade 0 into the identity map.
|
||||
// (In the shade table of Duke3D's PALETTE.DAT, palookup[0][239]==143.)
|
||||
// This makes it possible to sensibly use Lunatic's engine.saveLookupDat().
|
||||
palookup[0][239] = 239;
|
||||
|
||||
if ((fp=kopen4load("lookup.dat",0)) == -1)
|
||||
{
|
||||
if ((fp=kopen4load("lookup.dat",1)) == -1)
|
||||
{
|
||||
initprintf("LOOKUP.DAT not found\n");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
g_firstFogPal = loadlookups(fp, basepaltable);
|
||||
kclose(fp);
|
||||
|
||||
if (g_firstFogPal < 0)
|
||||
{
|
||||
if (g_firstFogPal == -1)
|
||||
initprintf("ERROR loading PALOOKUP.DAT: failed reading enough data\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return G_LoadLookups();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -739,3 +739,56 @@ void G_DoAutoload(const char *dirname)
|
|||
Bsnprintf(buf, sizeof(buf), "autoload/%s", dirname);
|
||||
G_LoadGroupsInDir(buf);
|
||||
}
|
||||
|
||||
//////////
|
||||
|
||||
static uint8_t water_pal[768], slime_pal[768], title_pal[768], dre_alms[768], ending_pal[768];
|
||||
|
||||
uint8_t *basepaltable[BASEPALCOUNT] = {
|
||||
palette, water_pal, slime_pal,
|
||||
dre_alms, title_pal, ending_pal,
|
||||
NULL /*anim_pal*/
|
||||
};
|
||||
|
||||
int32_t g_firstFogPal;
|
||||
|
||||
int32_t G_LoadLookups(void)
|
||||
{
|
||||
int32_t fp, j;
|
||||
|
||||
if ((fp=kopen4loadfrommod("lookup.dat",0)) == -1)
|
||||
{
|
||||
if ((fp=kopen4loadfrommod("lookup.dat",1)) == -1)
|
||||
{
|
||||
initprintf("ERROR: File \"lookup.dat\" not found.\n");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
j = loadlookups(fp);
|
||||
|
||||
if (j < 0)
|
||||
{
|
||||
if (j == -1)
|
||||
initprintf("ERROR loading \"lookup.dat\": failed reading enough data.\n");
|
||||
return 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;
|
||||
|
||||
if (kread(fp, basepaltable[basepalnum], 768) != 768)
|
||||
return -1;
|
||||
}
|
||||
|
||||
kclose(fp);
|
||||
|
||||
g_firstFogPal = generatefogpals();
|
||||
|
||||
fillemptylookups();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -106,4 +106,11 @@ extern const char * G_GetInstallPath(int32_t insttype);
|
|||
void G_LoadGroupsInDir(const char *dirname);
|
||||
void G_DoAutoload(const char *dirname);
|
||||
|
||||
//////////
|
||||
|
||||
extern uint8_t *basepaltable[BASEPALCOUNT];
|
||||
|
||||
extern int32_t g_firstFogPal;
|
||||
extern int32_t G_LoadLookups(void);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -115,15 +115,6 @@ double g_moveActorsTime = 0; // in ms, smoothed
|
|||
|
||||
char boardfilename[BMAX_PATH] = {0}, currentboardfilename[BMAX_PATH] = {0};
|
||||
|
||||
|
||||
static uint8_t water_pal[768], slime_pal[768], title_pal[768], dre_alms[768], ending_pal[768];
|
||||
|
||||
uint8_t *basepaltable[BASEPALCOUNT] = {
|
||||
palette, water_pal, slime_pal,
|
||||
dre_alms, title_pal, ending_pal,
|
||||
NULL /*anim_pal*/
|
||||
};
|
||||
|
||||
int8_t g_noFloorPal[MAXPALOOKUPS]; // 1 if sprite pal should not be taken over from floor pal
|
||||
|
||||
int32_t voting = -1;
|
||||
|
@ -7041,8 +7032,6 @@ SPAWN_END:
|
|||
return i;
|
||||
}
|
||||
|
||||
static int32_t g_firstFogPal;
|
||||
|
||||
static int32_t G_MaybeTakeOnFloorPal(spritetype *datspr, int32_t sect)
|
||||
{
|
||||
int32_t dapal = sector[sect].floorpal;
|
||||
|
@ -10680,27 +10669,12 @@ static inline void G_CheckGametype(void)
|
|||
|
||||
static void G_LoadExtraPalettes(void)
|
||||
{
|
||||
int32_t fp;
|
||||
|
||||
fp = kopen4loadfrommod("lookup.dat", 0);
|
||||
if (fp == -1)
|
||||
G_GameExit("\nERROR: File 'lookup.dat' not found.");
|
||||
|
||||
g_firstFogPal = loadlookups(fp, basepaltable);
|
||||
kclose(fp);
|
||||
|
||||
if (g_firstFogPal < 0)
|
||||
{
|
||||
if (g_firstFogPal == -1)
|
||||
G_GameExit("\nERROR loading 'lookup.dat': failed reading enough data.");
|
||||
else
|
||||
G_GameExit("\nERROR loading 'lookup.dat'.");
|
||||
}
|
||||
G_LoadLookups();
|
||||
|
||||
// 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);
|
||||
Bmemset(&basepaltable[BASEPAL][255*3], 0, 3);
|
||||
Bmemset(&basepaltable[WATERPAL][255*3], 0, 3);
|
||||
Bmemset(&basepaltable[SLIMEPAL][255*3], 0, 3);
|
||||
}
|
||||
|
||||
#define SETFLAG(Tilenum, Flag) g_tile[Tilenum].flags |= Flag
|
||||
|
|
|
@ -298,7 +298,6 @@ extern palette_t DefaultCrosshairColors;
|
|||
|
||||
extern uint32_t g_frameDelay;
|
||||
|
||||
extern uint8_t *basepaltable[BASEPALCOUNT];
|
||||
extern int8_t g_noFloorPal[MAXPALOOKUPS];
|
||||
|
||||
extern user_defs ud;
|
||||
|
|
|
@ -72,18 +72,6 @@ static void EditSpriteData(int16_t spritenum);
|
|||
static void EditWallData(int16_t wallnum);
|
||||
static void EditSectorData(int16_t sectnum);
|
||||
|
||||
#define BASEPALCOUNT 6
|
||||
|
||||
static uint8_t WATERpalette[768], SLIMEpalette[768], TITLEpalette[768];
|
||||
static uint8_t REALMSpalette[768], BOSS1palette[768];
|
||||
|
||||
uint8_t *basepaltable[BASEPALCOUNT] = {
|
||||
palette, WATERpalette, SLIMEpalette,
|
||||
REALMSpalette, TITLEpalette, BOSS1palette,
|
||||
};
|
||||
|
||||
|
||||
static int32_t g_firstFogPal;
|
||||
|
||||
static int32_t updownunits=1024;
|
||||
|
||||
|
|
|
@ -146,6 +146,7 @@ int32_t ExtPostStartupWindow(void)
|
|||
}
|
||||
|
||||
setbasepaltable(basepaltable, 1);
|
||||
fillemptylookups();
|
||||
|
||||
Ken_InitMultiPsky();
|
||||
|
||||
|
|
|
@ -528,6 +528,7 @@ int32_t app_main(int32_t argc, const char **argv)
|
|||
}
|
||||
|
||||
setbasepaltable(basepaltable, 1);
|
||||
fillemptylookups();
|
||||
|
||||
Ken_InitMultiPsky();
|
||||
|
||||
|
|
Loading…
Reference in a new issue