From b6dce8a559057ac64bddc99a6254074e5a7cefeb Mon Sep 17 00:00:00 2001 From: plagman Date: Thu, 27 Jan 2011 06:35:52 +0000 Subject: [PATCH] Move the new basepal table one step further so that the engine is now aware of it. git-svn-id: https://svn.eduke32.com/eduke32@1781 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/build/include/build.h | 3 ++- polymer/eduke32/build/src/baselayer.c | 2 +- polymer/eduke32/build/src/build.c | 12 ++++++------ polymer/eduke32/build/src/engine.c | 26 +++++++++++++++++++++++-- polymer/eduke32/build/src/engine_priv.h | 4 ++++ polymer/eduke32/source/astub.c | 12 +++++++----- polymer/eduke32/source/game.c | 6 ++++-- polymer/eduke32/source/mapster32.h | 5 +++++ polymer/eduke32/source/menus.c | 8 ++++---- polymer/eduke32/source/osdcmds.c | 8 ++++---- 10 files changed, 61 insertions(+), 25 deletions(-) diff --git a/polymer/eduke32/build/include/build.h b/polymer/eduke32/build/include/build.h index 9eeb4f381..b500b1c6a 100644 --- a/polymer/eduke32/build/include/build.h +++ b/polymer/eduke32/build/include/build.h @@ -447,7 +447,8 @@ int32_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, char *remapbuf, int8_t r, int8_t g, int8_t b, char dastat); void setvgapalette(void); -void setbrightness(char dabrightness, uint8_t *dapal, char noapply); +void setbasepaltable(uint8_t **basepaltable, uint8_t basepalcount); +void setbrightness(char dabrightness, uint8_t dapalid, char noapply); void setpalettefade(char r, char g, char b, char offset); void squarerotatetile(int16_t tilenume); diff --git a/polymer/eduke32/build/src/baselayer.c b/polymer/eduke32/build/src/baselayer.c index fa258c1c0..48b43ab0a 100644 --- a/polymer/eduke32/build/src/baselayer.c +++ b/polymer/eduke32/build/src/baselayer.c @@ -298,7 +298,7 @@ static int32_t osdcmd_cvar_set_baselayer(const osdfuncparm_t *parm) if (!Bstrcasecmp(parm->name, "vid_gamma") || !Bstrcasecmp(parm->name, "vid_brightness") || !Bstrcasecmp(parm->name, "vid_contrast")) { - setbrightness(GAMMA_CALC,palette,0); + setbrightness(GAMMA_CALC,0,0); return r; } diff --git a/polymer/eduke32/build/src/build.c b/polymer/eduke32/build/src/build.c index 95e23d7e4..28c41dcd9 100644 --- a/polymer/eduke32/build/src/build.c +++ b/polymer/eduke32/build/src/build.c @@ -490,7 +490,7 @@ int32_t app_main(int32_t argc, const char **argv) vid_gamma = vid_contrast = 1.0; vid_brightness = 0.0; - setbrightness(0,palette,0); + setbrightness(0,0,0); if (setgamemode(fullscreen, xdim2d, ydim2d, 8) < 0) { ExtUnInit(); @@ -511,7 +511,7 @@ int32_t app_main(int32_t argc, const char **argv) vid_gamma_3d = vid_contrast_3d = vid_brightness_3d = -1; - setbrightness(GAMMA_CALC,palette,0); + setbrightness(GAMMA_CALC,0,0); } else { @@ -526,7 +526,7 @@ int32_t app_main(int32_t argc, const char **argv) // executed once per init, but after setgamemode so that OSD has the right width OSD_Exec("m32_autoexec.cfg"); - setbrightness(GAMMA_CALC,palette,0); + setbrightness(GAMMA_CALC,0,0); } CANCEL: @@ -1209,7 +1209,7 @@ void editinput(void) vid_gamma = vid_contrast = 1.0; vid_brightness = 0.0; - setbrightness(0,palette,0); + setbrightness(0,0,0); keystatus[buildkeys[BK_MODE2D_3D]] = 0; overheadeditor(); @@ -1221,7 +1221,7 @@ void editinput(void) vid_gamma_3d = vid_contrast_3d = vid_brightness_3d = -1; - setbrightness(GAMMA_CALC,palette,0); + setbrightness(GAMMA_CALC,0,0); } } @@ -5049,7 +5049,7 @@ CANCEL: exit(0); } - setbrightness(GAMMA_CALC,palette,0); + setbrightness(GAMMA_CALC,0,0); pos.z = oposz; diff --git a/polymer/eduke32/build/src/engine.c b/polymer/eduke32/build/src/engine.c index deee5ba51..57343affa 100644 --- a/polymer/eduke32/build/src/engine.c +++ b/polymer/eduke32/build/src/engine.c @@ -1193,6 +1193,11 @@ static int32_t bakrendmode,baktile; int32_t totalclocklock; char apptitle[256] = "Build Engine"; + +uint8_t **basepaltableptr; +uint8_t basepalcount; +uint8_t curbasepal; + palette_t curpalette[256]; // the current palette, unadjusted for brightness or tint palette_t curpalettefaded[256]; // the current palette, adjusted for brightness and tint (ie. what gets sent to the card) palette_t palfadergb = { 0,0,0,0 }; @@ -8414,7 +8419,7 @@ int32_t setgamemode(char davidoption, int32_t daxdim, int32_t daydim, int32_t da setview(0L,0L,xdim-1,ydim-1); clearallviews(0L); - setbrightness(curbrightness,palette,0); + setbrightness(curbrightness,0,0); if (searchx < 0) { searchx = halfxdimen; searchy = (ydimen>>1); } @@ -11119,13 +11124,30 @@ void setvgapalette(void) setpalette(0,256); } +// +// setbasepaltable +// +void setbasepaltable(uint8_t **thebasepaltable, uint8_t thebasepalcount) +{ + basepaltableptr = thebasepaltable; + basepalcount = thebasepalcount; +} + // // setbrightness // -void setbrightness(char dabrightness, uint8_t *dapal, char noapply) +void setbrightness(char dabrightness, uint8_t dapalid, char noapply) { int32_t i, k, j; + uint8_t *dapal; // uint32_t lastbright = curbrightness; + + if (dapalid >= basepalcount) + dapalid = 0; + + curbasepal = dapalid; + + dapal = basepaltableptr[dapalid]; if (!(noapply&4)) { diff --git a/polymer/eduke32/build/src/engine_priv.h b/polymer/eduke32/build/src/engine_priv.h index 3b5ce887d..579150e5f 100644 --- a/polymer/eduke32/build/src/engine_priv.h +++ b/polymer/eduke32/build/src/engine_priv.h @@ -8,6 +8,10 @@ #define MAXNODESPERLINE 42 //Warning: This depends on MAXYSAVES & MAXYDIM! #define MAXCLIPDIST 1024 +extern uint8_t **basepaltableptr; +extern uint8_t basepalcount; +extern uint8_t curbasepal; + extern char pow2char[8]; extern int32_t pow2int[32]; diff --git a/polymer/eduke32/source/astub.c b/polymer/eduke32/source/astub.c index 316faa10e..40ff00d90 100644 --- a/polymer/eduke32/source/astub.c +++ b/polymer/eduke32/source/astub.c @@ -6196,7 +6196,7 @@ static void Keys3d(void) brightness &= 15; vid_gamma = 1.0 + ((float)brightness / 10.0); - setbrightness(brightness, palette, 0); + setbrightness(brightness, 0, 0); message("Brightness: %d/16", brightness+1); } @@ -9177,6 +9177,8 @@ int32_t ExtInit(void) initprintf("There was a problem initializing the engine.\n"); return -1; } + + setbasepaltable(basepaltable, BASEPALCOUNT); kensplayerheight = 40; //32 zmode = 2; @@ -10149,28 +10151,28 @@ void SetBOSS1Palette(void) { if (acurpalette==3) return; acurpalette=3; - setbrightness(GAMMA_CALC,BOSS1palette,0); + setbrightness(GAMMA_CALC,5,0); } void SetSLIMEPalette(void) { if (acurpalette==2) return; acurpalette=2; - setbrightness(GAMMA_CALC,SLIMEpalette,0); + setbrightness(GAMMA_CALC,2,0); } void SetWATERPalette(void) { if (acurpalette==1) return; acurpalette=1; - setbrightness(GAMMA_CALC,WATERpalette,0); + setbrightness(GAMMA_CALC,1,0); } void SetGAMEPalette(void) { if (acurpalette==0) return; acurpalette=0; - setbrightness(GAMMA_CALC,GAMEpalette,0); + setbrightness(GAMMA_CALC,6,0); } static void SearchSectors(int32_t dir) // <0: backwards, >=0: forwards diff --git a/polymer/eduke32/source/game.c b/polymer/eduke32/source/game.c index 38ce1b10f..7568e51c5 100644 --- a/polymer/eduke32/source/game.c +++ b/polymer/eduke32/source/game.c @@ -296,7 +296,7 @@ void P_SetGamePalette(DukePlayer_t *player, uint8_t palid, int32_t set) player->palette = palid; - setbrightness(ud.brightness>>2, basepaltable[palid], set); + setbrightness(ud.brightness>>2, palid, set); } int32_t G_PrintGameText(int32_t f, int32_t tile, int32_t x, int32_t y, const char *t, @@ -9048,6 +9048,8 @@ static void G_Startup(void) fprintf(stderr, "G_Startup: There was a problem initializing the Build engine: %s\n", engineerrstr); exit(6); } + + setbasepaltable(basepaltable, BASEPALCOUNT); G_InitDynamicTiles(); @@ -9910,7 +9912,7 @@ CLEAN_DIRECTORY: ud.config.ScreenBPP = bpp[i]; } - setbrightness(ud.brightness>>2,basepaltable[g_player[myconnectindex].ps->palette],0); + setbrightness(ud.brightness>>2,g_player[myconnectindex].ps->palette,0); S_MusicStartup(); S_SoundStartup(); diff --git a/polymer/eduke32/source/mapster32.h b/polymer/eduke32/source/mapster32.h index 2c3c5f4fe..8b42f50df 100644 --- a/polymer/eduke32/source/mapster32.h +++ b/polymer/eduke32/source/mapster32.h @@ -113,9 +113,14 @@ static void EditWallData(int16_t wallnum); static void EditSectorData(int16_t sectnum); static void FuncMenu(void); +#define BASEPALCOUNT 7 + static uint8_t GAMEpalette[768], WATERpalette[768], SLIMEpalette[768], TITLEpalette[768]; static uint8_t REALMSpalette[768], BOSS1palette[768]; +uint8_t *basepaltable[BASEPALCOUNT] = { palette, WATERpalette, SLIMEpalette, TITLEpalette, REALMSpalette, BOSS1palette, GAMEpalette }; + + static char num_tables; static int32_t updownunits=1024; diff --git a/polymer/eduke32/source/menus.c b/polymer/eduke32/source/menus.c index 2ce00b169..6ae70fd40 100644 --- a/polymer/eduke32/source/menus.c +++ b/polymer/eduke32/source/menus.c @@ -2613,7 +2613,7 @@ cheat_for_port_credits: vid_gamma = (double)b/40960.f; ud.brightness = (int32_t)(min(max((double)((vid_gamma-1.0)*10.0),0),15)); ud.brightness <<= 2; - setbrightness(ud.brightness>>2,basepaltable[g_player[myconnectindex].ps->palette],0); + setbrightness(ud.brightness>>2,g_player[myconnectindex].ps->palette,0); } b = (int32_t)(vid_contrast*40960.f); @@ -2622,7 +2622,7 @@ cheat_for_port_credits: if (b != (vid_contrast*40960.f)) { vid_contrast = (double)b/40960.f; - setbrightness(ud.brightness>>2,basepaltable[g_player[myconnectindex].ps->palette],0); + setbrightness(ud.brightness>>2,g_player[myconnectindex].ps->palette,0); } b = (int32_t)(vid_brightness*40960.f); @@ -2631,7 +2631,7 @@ cheat_for_port_credits: if (b != (vid_brightness*40960.f)) { vid_brightness = (double)b/40960.f; - setbrightness(ud.brightness>>2,basepaltable[g_player[myconnectindex].ps->palette],0); + setbrightness(ud.brightness>>2,g_player[myconnectindex].ps->palette,0); } if (x == 3) @@ -2640,7 +2640,7 @@ cheat_for_port_credits: vid_contrast = DEFAULT_CONTRAST; vid_brightness = DEFAULT_BRIGHTNESS; ud.brightness = 0; - setbrightness(ud.brightness>>2,basepaltable[g_player[myconnectindex].ps->palette],0); + setbrightness(ud.brightness>>2,g_player[myconnectindex].ps->palette,0); } } diff --git a/polymer/eduke32/source/osdcmds.c b/polymer/eduke32/source/osdcmds.c index 782930bff..fc060261d 100644 --- a/polymer/eduke32/source/osdcmds.c +++ b/polymer/eduke32/source/osdcmds.c @@ -731,7 +731,7 @@ void onvideomodechange(int32_t newmode) } #endif - setbrightness(ud.brightness>>2, basepaltable[palid], 0); + setbrightness(ud.brightness>>2, palid, 0); g_restorePalette = 1; g_crosshairSum = 0; } @@ -1304,19 +1304,19 @@ static int32_t osdcmd_cvar_set_game(const osdfuncparm_t *parm) { ud.brightness = GAMMA_CALC; ud.brightness <<= 2; - setbrightness(ud.brightness>>2,basepaltable[g_player[myconnectindex].ps->palette],0); + setbrightness(ud.brightness>>2,g_player[myconnectindex].ps->palette,0); return r; } else if (!Bstrcasecmp(parm->name, "vid_brightness")) { - setbrightness(ud.brightness>>2,basepaltable[g_player[myconnectindex].ps->palette],0); + setbrightness(ud.brightness>>2,g_player[myconnectindex].ps->palette,0); return r; } else if (!Bstrcasecmp(parm->name, "vid_contrast")) { - setbrightness(ud.brightness>>2,basepaltable[g_player[myconnectindex].ps->palette],0); + setbrightness(ud.brightness>>2,g_player[myconnectindex].ps->palette,0); return r; }