mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-11-10 23:02:03 +00:00
Restructure the basepaltable subsystem to support up to 256 palettes and use dynamic allocation like palookup and blendtable.
git-svn-id: https://svn.eduke32.com/eduke32@5348 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
2a237a3d72
commit
c0e7dba4c1
16 changed files with 36 additions and 53 deletions
|
@ -77,7 +77,7 @@ enum rendmode_t {
|
|||
#define MAXVOXELS 4096
|
||||
#define MAXSTATUS 1024
|
||||
#define MAXPLAYERS 16
|
||||
#define MAXBASEPALS 8
|
||||
#define MAXBASEPALS 256
|
||||
#define MAXPALOOKUPS 256
|
||||
#define MAXBLENDTABS 256
|
||||
// Maximum number of component tiles in a multi-psky:
|
||||
|
@ -699,7 +699,7 @@ EXTERN int16_t sintable[2048];
|
|||
EXTERN uint8_t palette[768];
|
||||
EXTERN int16_t numshades;
|
||||
EXTERN char *palookup[MAXPALOOKUPS];
|
||||
EXTERN uint8_t **basepaltableptr;
|
||||
extern uint8_t *basepaltable[MAXBASEPALS];
|
||||
EXTERN uint8_t paletteloaded;
|
||||
|
||||
enum {
|
||||
|
@ -1045,7 +1045,7 @@ intptr_t allocatepermanenttile(int16_t tilenume, int32_t xsiz, int32_t ysiz);
|
|||
void copytilepiece(int32_t tilenume1, int32_t sx1, int32_t sy1, int32_t xsiz, int32_t ysiz, int32_t tilenume2, int32_t sx2, int32_t sy2);
|
||||
void makepalookup(int32_t palnum, const char *remapbuf, int8_t r, int8_t g, int8_t b, char noFloorPal);
|
||||
//void setvgapalette(void);
|
||||
void setbasepaltable(uint8_t **basepaltable, uint8_t basepalcount);
|
||||
void setbasepal(int32_t id, uint8_t const *table);
|
||||
void setbrightness(char dabrightness, uint8_t dapalid, uint8_t flags);
|
||||
void setpalettefade(char r, char g, char b, char offset);
|
||||
void squarerotatetile(int16_t tilenume);
|
||||
|
|
|
@ -1937,7 +1937,7 @@ static int32_t defsparser(scriptfile *script)
|
|||
scriptfile_getstring(script,&fn); break;
|
||||
}
|
||||
}
|
||||
if (EDUKE32_PREDICT_FALSE((unsigned)basepal >= ((unsigned)basepalcount)))
|
||||
if (EDUKE32_PREDICT_FALSE((unsigned)basepal >= MAXBASEPALS))
|
||||
{
|
||||
initprintf("Error: missing or invalid 'base palette number' for highpalookup definition "
|
||||
"near line %s:%d\n", script->filename, scriptfile_getlinum(script,highpaltokptr));
|
||||
|
|
|
@ -2414,8 +2414,8 @@ static int32_t baktile;
|
|||
|
||||
char apptitle[256] = "Build Engine";
|
||||
|
||||
uint8_t *basepaltable[MAXBASEPALS] = { palette };
|
||||
static uint8_t basepalreset=1;
|
||||
uint8_t basepalcount;
|
||||
uint8_t curbasepal;
|
||||
|
||||
static uint32_t g_lastpalettesum = 0;
|
||||
|
@ -9369,6 +9369,12 @@ void uninitengine(void)
|
|||
Bfree(blendtable[i]);
|
||||
Bmemset(blendtable, 0, sizeof(blendtable));
|
||||
|
||||
for (int i=1; i<MAXBASEPALS; i++)
|
||||
if (basepaltable[i] != NULL)
|
||||
Bfree(basepaltable[i]);
|
||||
Bmemset(basepaltable, 0, sizeof(basepaltable));
|
||||
basepaltable[0] = palette;
|
||||
|
||||
#ifdef DYNALLOC_ARRAYS
|
||||
DO_FREE_AND_NULL(blockptr);
|
||||
#endif
|
||||
|
@ -15638,15 +15644,14 @@ void makepalookup(int32_t palnum, const char *remapbuf, int8_t r, int8_t g, int8
|
|||
}
|
||||
|
||||
//
|
||||
// setbasepaltable
|
||||
// setbasepal
|
||||
//
|
||||
void setbasepaltable(uint8_t **thebasepaltable, uint8_t thebasepalcount)
|
||||
void setbasepal(int32_t id, uint8_t const * const table)
|
||||
{
|
||||
if (thebasepalcount >= MAXBASEPALS)
|
||||
thebasepalcount = MAXBASEPALS - 1;
|
||||
if (basepaltable[id] == NULL)
|
||||
basepaltable[id] = (uint8_t *)Xmalloc(768);
|
||||
|
||||
basepaltableptr = thebasepaltable;
|
||||
basepalcount = thebasepalcount;
|
||||
Bmemcpy(basepaltable[id], table, 768);
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -15671,7 +15676,7 @@ void setbrightness(char dabrightness, uint8_t dapalid, uint8_t flags)
|
|||
|
||||
Bassert((flags&4)==0);
|
||||
|
||||
if (dapalid >= basepalcount)
|
||||
if (/*(unsigned)dapalid >= MAXBASEPALS ||*/ basepaltable[dapalid] == NULL)
|
||||
dapalid = 0;
|
||||
#ifdef USE_OPENGL
|
||||
paldidchange = (curbasepal != dapalid || basepalreset);
|
||||
|
@ -15679,7 +15684,7 @@ void setbrightness(char dabrightness, uint8_t dapalid, uint8_t flags)
|
|||
curbasepal = dapalid;
|
||||
basepalreset = 0;
|
||||
|
||||
dapal = basepaltableptr[curbasepal];
|
||||
dapal = basepaltable[curbasepal];
|
||||
|
||||
if (!(flags&4))
|
||||
{
|
||||
|
|
|
@ -28,7 +28,6 @@ extern "C" {
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern uint8_t basepalcount;
|
||||
extern uint8_t curbasepal;
|
||||
|
||||
extern int16_t thesector[MAXWALLSB], thewall[MAXWALLSB];
|
||||
|
|
|
@ -4917,7 +4917,7 @@ static _prbucket* polymer_getbuildmaterial(_prmaterial* material, int16_t tile
|
|||
0,
|
||||
GL_RGB,
|
||||
GL_UNSIGNED_BYTE,
|
||||
basepaltableptr[curbasepal]);
|
||||
basepaltable[curbasepal]);
|
||||
bglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
bglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
bglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, glinfo.clamptoedge?GL_CLAMP_TO_EDGE:GL_CLAMP);
|
||||
|
|
|
@ -241,7 +241,7 @@ int32_t G_PlayAnim(const char *fn)
|
|||
goto end_anim;
|
||||
}
|
||||
|
||||
basepaltable[ANIMPAL] = ANIM_GetPalette();
|
||||
setbasepal(ANIMPAL, ANIM_GetPalette());
|
||||
|
||||
// setpalette(0L,256L,tempbuf);
|
||||
// setbrightness(ud.brightness>>2,tempbuf,2);
|
||||
|
|
|
@ -9864,11 +9864,6 @@ int32_t ExtInit(void)
|
|||
Bsprintf(apptitle, "Mapster32 %s %s", VERSION, s_buildRev);
|
||||
autosavetimer = totalclock+120*autosave;
|
||||
|
||||
// This must run before the following OSD_Exec() as the cfg may
|
||||
// e.g. contain a vid_gamma setting, resulting in a crash in
|
||||
// setbrightness() which expects basepaltableptr to be initialized.
|
||||
setbasepaltable(basepaltable, BASEPALCOUNT);
|
||||
|
||||
registerosdcommands();
|
||||
|
||||
{
|
||||
|
|
|
@ -1001,14 +1001,6 @@ void G_DoAutoload(const char *dirname)
|
|||
|
||||
uint32_t PaletteIndexFullbrights[8] = { 0, 0, 0, 0, 0, 0, 0, 2147418112 };
|
||||
|
||||
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*/
|
||||
};
|
||||
|
||||
void G_LoadLookups(void)
|
||||
{
|
||||
int32_t fp, j;
|
||||
|
@ -1027,13 +1019,17 @@ void G_LoadLookups(void)
|
|||
return kclose(fp);
|
||||
}
|
||||
|
||||
uint8_t paldata[768];
|
||||
|
||||
for (j=1; j<=5; j++)
|
||||
{
|
||||
// Account for TITLE and REALMS swap between basepal number and on-disk order.
|
||||
int32_t basepalnum = (j == 3 || j == 4) ? 4+3-j : j;
|
||||
|
||||
if (kread_and_test(fp, basepaltable[basepalnum], 768))
|
||||
if (kread_and_test(fp, paldata, 768))
|
||||
return kclose(fp);
|
||||
|
||||
setbasepal(basepalnum, paldata);
|
||||
}
|
||||
|
||||
kclose(fp);
|
||||
|
|
|
@ -124,8 +124,6 @@ void G_DoAutoload(const char *dirname);
|
|||
|
||||
//////////
|
||||
|
||||
extern uint8_t *basepaltable[BASEPALCOUNT];
|
||||
|
||||
extern void G_LoadLookups(void);
|
||||
|
||||
//////////
|
||||
|
|
|
@ -305,10 +305,10 @@ static void G_PatchStatusBar(int32_t x1, int32_t y1, int32_t x2, int32_t y2)
|
|||
rotatesprite(tx,ty,scl,0,BOTTOMSTATUSBAR,4,0,10+16+64,clx1+clofx,cly1+clofy,clx2+clofx-1,cly2+clofy-1);
|
||||
}
|
||||
|
||||
void P_SetGamePalette(DukePlayer_t *player, uint8_t palid, int32_t set)
|
||||
void P_SetGamePalette(DukePlayer_t *player, uint32_t palid, int32_t set)
|
||||
{
|
||||
if (palid >= BASEPALCOUNT)
|
||||
palid = BASEPAL;
|
||||
if (palid >= MAXBASEPALS)
|
||||
palid = 0;
|
||||
|
||||
player->palette = palid;
|
||||
|
||||
|
@ -10982,9 +10982,12 @@ static inline void G_CheckGametype(void)
|
|||
static void G_PostLoadPalette(void)
|
||||
{
|
||||
// Make color index 255 of default/water/slime palette black.
|
||||
Bmemset(&basepaltable[BASEPAL][255*3], 0, 3);
|
||||
Bmemset(&basepaltable[WATERPAL][255*3], 0, 3);
|
||||
Bmemset(&basepaltable[SLIMEPAL][255*3], 0, 3);
|
||||
if (basepaltable[BASEPAL] != NULL)
|
||||
Bmemset(&basepaltable[BASEPAL][255*3], 0, 3);
|
||||
if (basepaltable[WATERPAL] != NULL)
|
||||
Bmemset(&basepaltable[WATERPAL][255*3], 0, 3);
|
||||
if (basepaltable[SLIMEPAL] != NULL)
|
||||
Bmemset(&basepaltable[SLIMEPAL][255*3], 0, 3);
|
||||
|
||||
generatefogpals();
|
||||
|
||||
|
@ -11113,8 +11116,6 @@ static void G_Startup(void)
|
|||
if (initengine())
|
||||
G_FatalEngineError();
|
||||
|
||||
setbasepaltable(basepaltable, BASEPALCOUNT);
|
||||
|
||||
#ifdef LUNATIC
|
||||
El_CreateGameState();
|
||||
C_InitQuotes();
|
||||
|
|
|
@ -378,7 +378,7 @@ void G_UpdatePlayerFromMenu(void);
|
|||
void M32RunScript(const char *s);
|
||||
void P_DoQuote(int32_t q,DukePlayer_t *p);
|
||||
extern int32_t textsc(int32_t sc);
|
||||
void P_SetGamePalette(DukePlayer_t *player,uint8_t palid,int32_t set);
|
||||
void P_SetGamePalette(DukePlayer_t *player, uint32_t palid, int32_t set);
|
||||
|
||||
extern int32_t G_GetStringLineLength(const char *text, const char *end, const int32_t iter);
|
||||
extern int32_t G_GetStringNumLines(const char *text, const char *end, const int32_t iter);
|
||||
|
|
|
@ -681,7 +681,7 @@ int32_t G_CheckActivatorMotion(int32_t lotag);
|
|||
int32_t A_Dodge(spritetype *s);
|
||||
int32_t A_MoveSpriteClipdist(int32_t spritenum, const vec3_t *change, uint32_t cliptype, int32_t clipdist);
|
||||
void P_DoQuote(int32_t q, DukePlayer_t *p);
|
||||
void P_SetGamePalette(DukePlayer_t *player, uint8_t palid, int32_t set);
|
||||
void P_SetGamePalette(DukePlayer_t *player, uint32_t palid, int32_t set);
|
||||
void G_AddUserQuote(const char *daquote);
|
||||
void G_ClearCameraView(DukePlayer_t *ps);
|
||||
void G_DrawTileGeneric(int32_t x, int32_t y, int32_t zoom, int32_t tilenum,
|
||||
|
|
|
@ -145,8 +145,6 @@ int32_t ExtPostStartupWindow(void)
|
|||
return -1;
|
||||
}
|
||||
|
||||
setbasepaltable(basepaltable, 1);
|
||||
|
||||
Ken_InitMultiPsky();
|
||||
|
||||
tiletovox[PLAYER] = nextvoxid++;
|
||||
|
|
|
@ -26,11 +26,6 @@ const char *G_DefFile(void)
|
|||
return defaultdeffilename;
|
||||
}
|
||||
|
||||
uint8_t *basepaltable[1] =
|
||||
{
|
||||
palette
|
||||
};
|
||||
|
||||
uint32_t PaletteIndexFullbrights[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
void Ken_InitMultiPsky(void)
|
||||
|
|
|
@ -4,6 +4,4 @@
|
|||
extern const char *G_DefaultGrpFile(void);
|
||||
extern const char *G_GrpFile(void);
|
||||
|
||||
extern uint8_t *basepaltable[1];
|
||||
|
||||
extern void Ken_InitMultiPsky(void);
|
||||
|
|
|
@ -526,8 +526,6 @@ int32_t app_main(int32_t argc, const char **argv)
|
|||
return -1;
|
||||
}
|
||||
|
||||
setbasepaltable(basepaltable, 1);
|
||||
|
||||
Ken_InitMultiPsky();
|
||||
|
||||
initinput();
|
||||
|
|
Loading…
Reference in a new issue