From b971bc2717cb2175bec91e3beffb56d46a6f6b30 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 23 May 2020 14:36:35 +0200 Subject: [PATCH] - avoid using global palette settings when drawing 2D content with a custom palette. Instead pass the palette info with the render call to avoid stale global state. --- source/build/include/build.h | 10 +-- source/build/include/palette.h | 12 +++- source/build/src/engine.cpp | 4 +- source/build/src/palette.cpp | 11 ---- source/core/2d/renderstyle.h | 20 +++--- source/core/2d/v_2ddrawer.cpp | 4 +- source/core/2d/v_2ddrawer.h | 2 +- .../rendering/gl/system/gl_framebuffer.cpp | 3 - source/core/serializer.h | 2 +- source/duke3d/src/network.cpp | 10 ++- source/duke3d/src/screens.cpp | 66 ++++++++----------- source/exhumed/src/engine.h | 2 +- source/exhumed/src/enginesubs.cpp | 4 +- source/exhumed/src/exhumed.cpp | 13 ++-- source/exhumed/src/exhumed.h | 2 +- source/exhumed/src/init.cpp | 3 +- source/exhumed/src/light.cpp | 3 - source/exhumed/src/menu.cpp | 53 +++++---------- source/exhumed/src/view.cpp | 2 - source/glbackend/gl_palmanager.cpp | 4 +- source/glbackend/gl_texture.cpp | 4 +- source/glbackend/hw_draw2d.cpp | 9 ++- source/rr/src/net.cpp | 10 ++- source/rr/src/screens.cpp | 63 +++++++++--------- source/rr/src/sector.cpp | 4 +- source/sw/src/game.cpp | 3 +- 26 files changed, 139 insertions(+), 184 deletions(-) diff --git a/source/build/include/build.h b/source/build/include/build.h index 76db19d28..31899566b 100644 --- a/source/build/include/build.h +++ b/source/build/include/build.h @@ -856,7 +856,7 @@ void videoClearScreen(int32_t dacol); void renderDrawMapView(int32_t dax, int32_t day, int32_t zoome, int16_t ang); void rotatesprite_(int32_t sx, int32_t sy, int32_t z, int16_t a, int16_t picnum, int8_t dashade, uint8_t dapalnum, int32_t dastat, uint8_t daalpha, uint8_t dablend, - int32_t cx1, int32_t cy1, int32_t cx2, int32_t cy2, FTexture *pic = nullptr); + int32_t cx1, int32_t cy1, int32_t cx2, int32_t cy2, FTexture *pic = nullptr, int basepal = 0); void renderDrawLine(int32_t x1, int32_t y1, int32_t x2, int32_t y2, uint8_t col); void drawlinergb(int32_t x1, int32_t y1, int32_t x2, int32_t y2, palette_t p); void drawlinergb(int32_t x1, int32_t y1, int32_t x2, int32_t y2, PalEntry p); @@ -864,15 +864,15 @@ void drawlinergb(int32_t x1, int32_t y1, int32_t x2, int32_t y2, PalEntry p); ////////// specialized rotatesprite wrappers for (very) often used cases ////////// static FORCE_INLINE void rotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16_t picnum, int8_t dashade, uint8_t dapalnum, int32_t dastat, - int32_t cx1, int32_t cy1, int32_t cx2, int32_t cy2, FTexture* pic = nullptr) + int32_t cx1, int32_t cy1, int32_t cx2, int32_t cy2, FTexture* pic = nullptr, int basepal = 0) { - rotatesprite_(sx, sy, z, a, picnum, dashade, dapalnum, dastat, 0, 0, cx1, cy1, cx2, cy2, pic); + rotatesprite_(sx, sy, z, a, picnum, dashade, dapalnum, dastat, 0, 0, cx1, cy1, cx2, cy2, pic, basepal); } // Don't clip at all, i.e. the whole screen real estate is available: static FORCE_INLINE void rotatesprite_fs(int32_t sx, int32_t sy, int32_t z, int16_t a, int16_t picnum, - int8_t dashade, uint8_t dapalnum, int32_t dastat, FTexture* pic = nullptr) + int8_t dashade, uint8_t dapalnum, int32_t dastat, FTexture* pic = nullptr, int basepal = 0) { - rotatesprite_(sx, sy, z, a, picnum, dashade, dapalnum, dastat, 0, 0, 0,0,xdim-1,ydim-1, pic); + rotatesprite_(sx, sy, z, a, picnum, dashade, dapalnum, dastat, 0, 0, 0,0,xdim-1,ydim-1, pic, basepal); } static FORCE_INLINE void rotatesprite_fs_alpha(int32_t sx, int32_t sy, int32_t z, int16_t a, int16_t picnum, diff --git a/source/build/include/palette.h b/source/build/include/palette.h index 94c4e56ac..b2e1c84cf 100644 --- a/source/build/include/palette.h +++ b/source/build/include/palette.h @@ -13,6 +13,9 @@ #include "renderstyle.h" #include "filesystem.h" +#include "zstring.h" +#include "palentry.h" +#include "templates.h" #define MAXBASEPALS 256 #define MAXPALOOKUPS 256 @@ -32,6 +35,7 @@ enum }; extern uint8_t curbasepal; +extern int32_t r_scenebrightness; extern uint8_t PaletteIndexFullbrights[32]; @@ -65,11 +69,13 @@ void paletteFreeLookupTable(int32_t palnum); enum ESetPalFlag { Pal_DontResetFade = 1, - Pal_SceneBrightness = 2, - Pal_Fullscreen = 4, - Pal_2D = 8, }; +inline void videoSetBrightness(int brightness) +{ + r_scenebrightness = clamp(brightness, 0, 15); +} + typedef TFlags ESetPalFlags; DEFINE_TFLAGS_OPERATORS(ESetPalFlags) diff --git a/source/build/src/engine.cpp b/source/build/src/engine.cpp index 429451344..8915ee635 100644 --- a/source/build/src/engine.cpp +++ b/source/build/src/engine.cpp @@ -5002,7 +5002,7 @@ void renderSetAspect(int32_t daxrange, int32_t daaspect) // void rotatesprite_(int32_t sx, int32_t sy, int32_t z, int16_t a, int16_t picnum, int8_t dashade, uint8_t dapalnum, int32_t dastat, uint8_t daalpha, uint8_t dablend, - int32_t cx1, int32_t cy1, int32_t cx2, int32_t cy2, FTexture *tex) + int32_t cx1, int32_t cy1, int32_t cx2, int32_t cy2, FTexture *tex, int basepal) { if (!tex && (unsigned)picnum >= MAXTILES) return; @@ -5028,7 +5028,7 @@ void rotatesprite_(int32_t sx, int32_t sy, int32_t z, int16_t a, int16_t picnum, } // We must store all calls in the 2D drawer so that the backend can operate on a clean 3D view. - twod->rotatesprite(sx, sy, z, a, picnum, dashade, dapalnum, dastat, daalpha, dablend, cx1, cy1, cx2, cy2, tex); + twod->rotatesprite(sx, sy, z, a, picnum, dashade, dapalnum, dastat, daalpha, dablend, cx1, cy1, cx2, cy2, tex, basepal); // RS_PERM code was removed because the current backend supports only one page that needs to be redrawn each frame in which case the perm list was skipped anyway. } diff --git a/source/build/src/palette.cpp b/source/build/src/palette.cpp index d0ac4b251..9287ad006 100644 --- a/source/build/src/palette.cpp +++ b/source/build/src/palette.cpp @@ -569,23 +569,12 @@ void paletteMakeLookupTable(int32_t palnum, const char *remapbuf, uint8_t r, uin // 4: don't calc curbrightness from dabrightness, DON'T USE THIS FLAG! // 8: don't gltexinvalidate8() // 16: don't reset palfade* -// 32: apply brightness to scene in OpenGL void videoSetPalette(int dabrightness, int dapalid, ESetPalFlags flags) { if (GPalette.GetTranslation(Translation_BasePalettes, dapalid) == nullptr) dapalid = 0; curbasepal = dapalid; - // In-scene brightness mode for RR's thunderstorm. This shouldn't affect the global gamma ramp. - if ((videoGetRenderMode() >= REND_POLYMOST) && (flags & Pal_SceneBrightness)) - { - r_scenebrightness = clamp(dabrightness, 0, 15); - } - else - { - r_scenebrightness = 0; - } - if ((flags & Pal_DontResetFade) == 0) { palfadergb.r = palfadergb.g = palfadergb.b = 0; diff --git a/source/core/2d/renderstyle.h b/source/core/2d/renderstyle.h index 12ac15191..6579432ad 100644 --- a/source/core/2d/renderstyle.h +++ b/source/core/2d/renderstyle.h @@ -142,16 +142,21 @@ enum ERenderFlags STYLEF_FadeToBlack = 64, }; -union FRenderStyle +struct FRenderStyle { - struct + union { - uint8_t BlendOp; // Of ERenderOp type - uint8_t SrcAlpha; // Of ERenderAlpha type - uint8_t DestAlpha; // Of ERenderAlpha type - uint8_t Flags; + struct + { + uint8_t BlendOp; // Of ERenderOp type + uint8_t SrcAlpha; // Of ERenderAlpha type + uint8_t DestAlpha; // Of ERenderAlpha type + uint8_t Flags; + }; + uint32_t AsDWORD; }; - uint32_t AsDWORD; + + FRenderStyle() = default; inline FRenderStyle &operator= (ERenderStyle legacy); bool operator==(const FRenderStyle &o) const { return AsDWORD == o.AsDWORD; } @@ -181,4 +186,3 @@ inline FRenderStyle &FRenderStyle::operator= (ERenderStyle legacy) *this = LegacyRenderStyles[legacy]; return *this; } - diff --git a/source/core/2d/v_2ddrawer.cpp b/source/core/2d/v_2ddrawer.cpp index 8f66118dc..96589d6af 100644 --- a/source/core/2d/v_2ddrawer.cpp +++ b/source/core/2d/v_2ddrawer.cpp @@ -628,7 +628,7 @@ static int32_t dorotspr_handle_bit2(int32_t* sxptr, int32_t* syptr, int32_t* z, void F2DDrawer::rotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16_t picnum, int8_t dashade, uint8_t dapalnum, int32_t dastat, uint8_t daalpha, uint8_t dablend, - int32_t clipx1, int32_t clipy1, int32_t clipx2, int32_t clipy2, FTexture *pic) + int32_t clipx1, int32_t clipy1, int32_t clipx2, int32_t clipy2, FTexture *pic, int basepal) { RenderCommand dg = {}; int method = 0; @@ -659,7 +659,7 @@ void F2DDrawer::rotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16 PalEntry p = 0xffffffff; dg.mTexture = pic? pic : TileFiles.tiles[picnum]; - dg.mRemapIndex = dapalnum | (dashade << 16); + dg.mRemapIndex = dapalnum | (basepal << 8) | (dashade << 16); dg.mVertCount = 4; dg.mVertIndex = (int)mVertices.Reserve(4); auto ptr = &mVertices[dg.mVertIndex]; diff --git a/source/core/2d/v_2ddrawer.h b/source/core/2d/v_2ddrawer.h index f0368857b..e67d1366b 100644 --- a/source/core/2d/v_2ddrawer.h +++ b/source/core/2d/v_2ddrawer.h @@ -142,7 +142,7 @@ public: void rotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16_t picnum, int8_t dashade, uint8_t dapalnum, int32_t dastat, uint8_t daalpha, uint8_t dablend, - int32_t cx1, int32_t cy1, int32_t cx2, int32_t cy2, FTexture *pic); + int32_t cx1, int32_t cy1, int32_t cx2, int32_t cy2, FTexture *pic = nullptr, int basepal = 0); void Clear(); diff --git a/source/core/rendering/gl/system/gl_framebuffer.cpp b/source/core/rendering/gl/system/gl_framebuffer.cpp index 6cc90b407..91ebca2bb 100644 --- a/source/core/rendering/gl/system/gl_framebuffer.cpp +++ b/source/core/rendering/gl/system/gl_framebuffer.cpp @@ -432,10 +432,7 @@ void OpenGLFrameBuffer::Draw2D() GLRenderer->mBuffers->BindCurrentFB(); ::DrawFullscreenBlends(); DrawRateStuff(); - auto savepal = curbasepal; - if (!(curpaletteflags & (Pal_Fullscreen|Pal_2D))) curbasepal = 0; GLInterface.Draw2D(&twodgen); - curbasepal = savepal; } } diff --git a/source/core/serializer.h b/source/core/serializer.h index d1180a4c1..24bb18c38 100644 --- a/source/core/serializer.h +++ b/source/core/serializer.h @@ -16,7 +16,7 @@ struct FWriter; struct FReader; class FFont; class FSoundID; -union FRenderStyle; +struct FRenderStyle; inline bool nullcmp(const void *buffer, size_t length) { diff --git a/source/duke3d/src/network.cpp b/source/duke3d/src/network.cpp index 6d89ec66e..cc5ba2174 100644 --- a/source/duke3d/src/network.cpp +++ b/source/duke3d/src/network.cpp @@ -1624,12 +1624,12 @@ static void Net_SyncPlayer(ENetEvent *event) static void display_betascreen(void) { - rotatesprite_fs(160 << 16, 100 << 16, 65536, 0, BETASCREEN, 0, 0, 2 + 8 + 64 + BGSTRETCH); + rotatesprite_fs(160 << 16, 100 << 16, 65536, 0, BETASCREEN, 0, 0, 2 + 8 + 64 + BGSTRETCH, nullptr, TITLEPAL); - rotatesprite_fs(160 << 16, (104) << 16, 60 << 10, 0, DUKENUKEM, 0, 0, 2 + 8); - rotatesprite_fs(160 << 16, (129) << 16, 30 << 11, 0, THREEDEE, 0, 0, 2 + 8); + rotatesprite_fs(160 << 16, (104) << 16, 60 << 10, 0, DUKENUKEM, 0, 0, 2 + 8, nullptr, TITLEPAL); + rotatesprite_fs(160 << 16, (129) << 16, 30 << 11, 0, THREEDEE, 0, 0, 2 + 8, nullptr, TITLEPAL); if (PLUTOPAK) // JBF 20030804 - rotatesprite_fs(160 << 16, (151) << 16, 30 << 11, 0, PLUTOPAKSPRITE + 1, 0, 0, 2 + 8); + rotatesprite_fs(160 << 16, (151) << 16, 30 << 11, 0, PLUTOPAKSPRITE + 1, 0, 0, 2 + 8, nullptr, TITLEPAL); } @@ -4696,8 +4696,6 @@ void Net_WaitForServer(void) if (numplayers < 2 || g_netServer) return; - P_SetGamePalette(g_player[myconnectindex].ps, TITLEPAL, Pal_2D); - do { if (G_FPSLimit()) diff --git a/source/duke3d/src/screens.cpp b/source/duke3d/src/screens.cpp index f6fe594e6..df2227324 100644 --- a/source/duke3d/src/screens.cpp +++ b/source/duke3d/src/screens.cpp @@ -1045,7 +1045,7 @@ void fadepal(int32_t r, int32_t g, int32_t b, int32_t start, int32_t end, int32_ } // START and END limits are always inclusive! -static void fadepaltile(int32_t r, int32_t g, int32_t b, int32_t start, int32_t end, int32_t step, int32_t tile) +static void fadepaltile(int32_t r, int32_t g, int32_t b, int32_t start, int32_t end, int32_t step, int32_t tile, int basepal) { if (ud.screenfade == 0) return; @@ -1064,7 +1064,7 @@ static void fadepaltile(int32_t r, int32_t g, int32_t b, int32_t start, int32_t return; } - rotatesprite_fs(160<<16, 100<<16, 65536L, 0, tile, 0, 0, 2+8+64+BGSTRETCH); + rotatesprite_fs(160<<16, 100<<16, 65536L, 0, tile, 0, 0, 2+8+64+BGSTRETCH, nullptr, basepal); G_FadePalette(r, g, b, start); start += step; } while (start != end+step); @@ -1091,11 +1091,11 @@ void gameDisplayTENScreen() inputState.ClearAllInput(); totalclock = 0; rotatesprite_fs(160 << 16, 100 << 16, 65536L, 0, TENSCREEN, 0, 0, 2 + 8 + 64 + BGSTRETCH); - fadepaltile(0, 0, 0, 252, 0, -28, TENSCREEN); + fadepaltile(0, 0, 0, 252, 0, -28, TENSCREEN, BASEPAL); while (!inputState.CheckAllInput() && totalclock < 2400) gameHandleEvents(); - fadepaltile(0, 0, 0, 0, 252, 28, TENSCREEN); + fadepaltile(0, 0, 0, 0, 252, 28, TENSCREEN, BASEPAL); inputState.ClearAllInput(); #ifdef __ANDROID__ inExtraScreens = 0; @@ -1114,14 +1114,14 @@ void gameDisplaySharewareScreens() fadepal(0, 0, 0, 0, 252, 28); inputState.ClearAllInput(); rotatesprite_fs(160 << 16, 100 << 16, 65536L, 0, 3291, 0, 0, 2 + 8 + 64 + BGSTRETCH); - fadepaltile(0, 0, 0, 252, 0, -28, 3291); + fadepaltile(0, 0, 0, 252, 0, -28, 3291, BASEPAL); while (!inputState.CheckAllInput()) gameHandleEvents(); - fadepaltile(0, 0, 0, 0, 252, 28, 3291); + fadepaltile(0, 0, 0, 0, 252, 28, 3291, BASEPAL); inputState.ClearAllInput(); rotatesprite_fs(160 << 16, 100 << 16, 65536L, 0, 3290, 0, 0, 2 + 8 + 64 + BGSTRETCH); - fadepaltile(0, 0, 0, 252, 0, -28, 3290); + fadepaltile(0, 0, 0, 252, 0, -28, 3290, BASEPAL); while (!inputState.CheckAllInput()) gameHandleEvents(); @@ -1158,12 +1158,11 @@ void gameDisplay3DRScreen() { videoClearScreen(0); - P_SetGamePalette(g_player[myconnectindex].ps, DREALMSPAL, Pal_Fullscreen); // JBF 20040308 fadepal(0, 0, 0, 0, 252, 28); renderFlushPerms(); - rotatesprite_fs(160 << 16, 100 << 16, 65536L, 0, DREALMS, 0, 0, 2 + 8 + 64 + BGSTRETCH); + rotatesprite_fs(160 << 16, 100 << 16, 65536L, 0, DREALMS, 0, 0, 2 + 8 + 64 + BGSTRETCH, nullptr, DREALMSPAL); videoNextPage(); - fadepaltile(0, 0, 0, 252, 0, -28, DREALMS); + fadepaltile(0, 0, 0, 252, 0, -28, DREALMS, DREALMSPAL); totalclock = 0; while (totalclock < (120 * 7) && !inputState.CheckAllInput()) @@ -1171,13 +1170,13 @@ void gameDisplay3DRScreen() if (G_FPSLimit()) { videoClearScreen(0); - rotatesprite_fs(160 << 16, 100 << 16, 65536L, 0, DREALMS, 0, 0, 2 + 8 + 64 + BGSTRETCH); + rotatesprite_fs(160 << 16, 100 << 16, 65536L, 0, DREALMS, 0, 0, 2 + 8 + 64 + BGSTRETCH, nullptr, DREALMSPAL); gameHandleEvents(); videoNextPage(); } } - fadepaltile(0, 0, 0, 0, 252, 28, DREALMS); + fadepaltile(0, 0, 0, 0, 252, 28, DREALMS, DREALMSPAL); } } } @@ -1189,12 +1188,9 @@ void gameDisplayTitleScreen(void) videoClearScreen(0); - // g_player[myconnectindex].ps->palette = titlepal; - P_SetGamePalette(g_player[myconnectindex].ps, TITLEPAL, Pal_2D); // JBF 20040308 - renderFlushPerms(); - rotatesprite_fs(160 << 16, 100 << 16, 65536L, 0, BETASCREEN, 0, 0, 2 + 8 + 64 + BGSTRETCH); + rotatesprite_fs(160 << 16, 100 << 16, 65536L, 0, BETASCREEN, 0, 0, 2 + 8 + 64 + BGSTRETCH, nullptr, TITLEPAL); inputState.keyFlushChars(); - fadepaltile(0, 0, 0, 252, 0, -28, BETASCREEN); + fadepaltile(0, 0, 0, 252, 0, -28, BETASCREEN, TITLEPAL); totalclock = 0; while ( @@ -1206,7 +1202,7 @@ void gameDisplayTitleScreen(void) if (G_FPSLimit()) { videoClearScreen(0); - rotatesprite_fs(160 << 16, 100 << 16, 65536L, 0, BETASCREEN, 0, 0, 2 + 8 + 64 + BGSTRETCH); + rotatesprite_fs(160 << 16, 100 << 16, 65536L, 0, BETASCREEN, 0, 0, 2 + 8 + 64 + BGSTRETCH, nullptr, TITLEPAL); if (logoflags & LOGO_DUKENUKEM) { if (totalclock > 120 && totalclock < (120 + 60)) @@ -1216,10 +1212,10 @@ void gameDisplayTitleScreen(void) titlesound++; S_PlaySound(PIPEBOMB_EXPLODE, CHAN_AUTO, CHANF_UI); } - rotatesprite_fs(160 << 16, 104 << 16, ((int32_t) totalclock - 120) << 10, 0, DUKENUKEM, 0, 0, 2 + 8); + rotatesprite_fs(160 << 16, 104 << 16, ((int32_t) totalclock - 120) << 10, 0, DUKENUKEM, 0, 0, 2 + 8, nullptr, TITLEPAL); } else if (totalclock >= (120 + 60)) - rotatesprite_fs(160 << 16, (104) << 16, 60 << 10, 0, DUKENUKEM, 0, 0, 2 + 8); + rotatesprite_fs(160 << 16, (104) << 16, 60 << 10, 0, DUKENUKEM, 0, 0, 2 + 8, nullptr, TITLEPAL); } else titlesound++; @@ -1234,11 +1230,11 @@ void gameDisplayTitleScreen(void) S_PlaySound(PIPEBOMB_EXPLODE, CHAN_AUTO, CHANF_UI); } - rotatesprite_fs(160 << 16, (104) << 16, 60 << 10, 0, DUKENUKEM, 0, 0, 2 + 8); - rotatesprite_fs(160 << 16, (129) << 16, ((int32_t) totalclock - 220) << 11, 0, THREEDEE, 0, 0, 2 + 8); + rotatesprite_fs(160 << 16, (104) << 16, 60 << 10, 0, DUKENUKEM, 0, 0, 2 + 8, nullptr, TITLEPAL); + rotatesprite_fs(160 << 16, (129) << 16, ((int32_t) totalclock - 220) << 11, 0, THREEDEE, 0, 0, 2 + 8, nullptr, TITLEPAL); } else if (totalclock >= (220 + 30)) - rotatesprite_fs(160 << 16, (129) << 16, 30 << 11, 0, THREEDEE, 0, 0, 2 + 8); + rotatesprite_fs(160 << 16, (129) << 16, 30 << 11, 0, THREEDEE, 0, 0, 2 + 8, nullptr, TITLEPAL); } else titlesound++; @@ -1249,7 +1245,7 @@ void gameDisplayTitleScreen(void) if (totalclock >= 280 && totalclock < 395) { rotatesprite_fs(160 << 16, (151) << 16, (410 - (int32_t) totalclock) << 12, 0, PLUTOPAKSPRITE + 1, - (sintable[((int32_t) totalclock << 4) & 2047] >> 11), 0, 2 + 8); + (sintable[((int32_t) totalclock << 4) & 2047] >> 11), 0, 2 + 8, nullptr, TITLEPAL); if (titlesound == 2) { titlesound++; @@ -1264,21 +1260,12 @@ void gameDisplayTitleScreen(void) S_PlaySound(PIPEBOMB_EXPLODE, CHAN_AUTO, CHANF_UI); } rotatesprite_fs(160 << 16, (151) << 16, 30 << 11, 0, PLUTOPAKSPRITE + 1, (sintable[((int32_t) totalclock << 4) & 2047] >> 11), 0, - 2 + 8); + 2 + 8, nullptr, TITLEPAL); } } - -#ifdef LUNATIC - g_elEventError = 0; -#endif VM_OnEvent(EVENT_LOGO, -1, screenpeek); videoNextPage(); - -#ifdef LUNATIC - if (g_elEventError) - break; -#endif } gameHandleEvents(); @@ -1418,9 +1405,8 @@ static void G_BonusCutscenes(void) 350, 380, VICTORY1+8, 86, 59 // duplicate row to alleviate overflow in the for loop below "boss" }; - P_SetGamePalette(g_player[myconnectindex].ps, ENDINGPAL, Pal_Fullscreen); // JBF 20040308 videoClearScreen(0L); - rotatesprite_fs(0, 50<<16, 65536L, 0, VICTORY1, 0, 0, 2+8+16+64+128+BGSTRETCH); + rotatesprite_fs(0, 50 << 16, 65536L, 0, VICTORY1, 0, 0, 2 + 8 + 16 + 64 + 128 + BGSTRETCH, nullptr, ENDINGPAL); videoNextPage(); fadepal(0, 0, 0, 252, 0, -4); @@ -1432,7 +1418,7 @@ static void G_BonusCutscenes(void) if (G_FPSLimit()) { videoClearScreen(0L); - rotatesprite_fs(0, 50<<16, 65536L, 0, VICTORY1, 0, 0, 2+8+16+64+128+BGSTRETCH); + rotatesprite_fs(0, 50<<16, 65536L, 0, VICTORY1, 0, 0, 2+8+16+64+128+BGSTRETCH, nullptr, ENDINGPAL); // boss if (totalclock > 390 && totalclock < 780) @@ -1444,7 +1430,7 @@ static void G_BonusCutscenes(void) S_PlaySound(SQUISHED, CHAN_AUTO, CHANF_UI); bonuscnt++; } - rotatesprite_fs(bossmove[t+3]<<16, bossmove[t+4]<<16, 65536L, 0, bossmove[t+2], 0, 0, 2+8+16+64+128+BGSTRETCH); + rotatesprite_fs(bossmove[t+3]<<16, bossmove[t+4]<<16, 65536L, 0, bossmove[t+2], 0, 0, 2+8+16+64+128+BGSTRETCH, nullptr, ENDINGPAL); } // Breathe @@ -1460,7 +1446,7 @@ static void G_BonusCutscenes(void) if (totalclock >= 750) { - rotatesprite_fs(86<<16, 59<<16, 65536L, 0, VICTORY1+8, 0, 0, 2+8+16+64+128+BGSTRETCH); + rotatesprite_fs(86<<16, 59<<16, 65536L, 0, VICTORY1+8, 0, 0, 2+8+16+64+128+BGSTRETCH, nullptr, ENDINGPAL); if (totalclock >= 750 && bonuscnt == 2) { S_PlaySound(DUKETALKTOBOSS, CHAN_AUTO, CHANF_UI); @@ -1476,7 +1462,7 @@ static void G_BonusCutscenes(void) S_PlaySound(BOSSTALKTODUKE, CHAN_AUTO, CHANF_UI); bonuscnt++; } - rotatesprite_fs(breathe[t+3]<<16, breathe[t+4]<<16, 65536L, 0, breathe[t+2], 0, 0, 2+8+16+64+128+BGSTRETCH); + rotatesprite_fs(breathe[t+3]<<16, breathe[t+4]<<16, 65536L, 0, breathe[t+2], 0, 0, 2+8+16+64+128+BGSTRETCH, nullptr, ENDINGPAL); } } videoNextPage(); diff --git a/source/exhumed/src/engine.h b/source/exhumed/src/engine.h index 6d53ec6ae..b49858aef 100644 --- a/source/exhumed/src/engine.h +++ b/source/exhumed/src/engine.h @@ -56,7 +56,7 @@ inline int Cos(int angle) } int movesprite(short spritenum, int dx, int dy, int dz, int ceildist, int flordist, unsigned int clipmask); -void overwritesprite(int thex, int they, short tilenum, signed char shade, char stat, char dapalnum); +void overwritesprite(int thex, int they, short tilenum, signed char shade, char stat, char dapalnum, int basepal = 0); void precache(); void resettiming(); void printext(int x, int y, const char* buffer, short tilenum, char invisiblecol); diff --git a/source/exhumed/src/enginesubs.cpp b/source/exhumed/src/enginesubs.cpp index 479f5483d..5b610cb32 100644 --- a/source/exhumed/src/enginesubs.cpp +++ b/source/exhumed/src/enginesubs.cpp @@ -27,7 +27,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. BEGIN_PS_NS -void overwritesprite(int thex, int they, short tilenum, signed char shade, char stat, char dapalnum) +void overwritesprite(int thex, int they, short tilenum, signed char shade, char stat, char dapalnum, int basepal) { #if 0 rotatesprite(thex << 16, they << 16, 0x10000, (short)((flags & 8) << 7), tilenum, shade, dapalnum, @@ -55,7 +55,7 @@ void overwritesprite(int thex, int they, short tilenum, signed char shade, char they += offy; rotatesprite(thex << 16, they << 16, 65536L, (stat & 8) << 7, tilenum, shade, dapalnum, 16 + (stat & 2) + ((stat & 4) >> 2) + (((stat & 16) >> 2) ^ ((stat & 8) >> 1)), - windowxy1.x, windowxy1.y, windowxy2.x, windowxy2.y); + windowxy1.x, windowxy1.y, windowxy2.x, windowxy2.y, nullptr, basepal); picanm[tilenum].sf = animbak; } diff --git a/source/exhumed/src/exhumed.cpp b/source/exhumed/src/exhumed.cpp index 36189cb98..e8895195b 100644 --- a/source/exhumed/src/exhumed.cpp +++ b/source/exhumed/src/exhumed.cpp @@ -2507,25 +2507,20 @@ void KeyFn1() videoNextPage(); } +extern int currentCinemaPalette; void DoGameOverScene() { FadeOut(0); inputState.ClearAllInput(); - if (LoadCinemaPalette(16) < 0) { - return; - } - - SetOverscan(ANIMPAL); NoClip(); - overwritesprite(0, 0, kTile3591, 0, 2, kPalNormal); + overwritesprite(0, 0, kTile3591, 0, 2, kPalNormal, 16); Clip(); videoNextPage(); CinemaFadeIn(); PlayGameOverSound(); WaitAnyKey(3); FadeOut(0); - SetOverscan(BASEPAL); } void DoTitle() @@ -2739,7 +2734,7 @@ int CopyCharToBitmap(char nChar, int nTile, int xPos, int yPos) } // Note: strings passed should be uppercase -int myprintext(int x, int y, const char *str, int shade) +int myprintext(int x, int y, const char *str, int shade, int basepal) { if (y < -15 || y >= 200) return x; @@ -2749,7 +2744,7 @@ int myprintext(int x, int y, const char *str, int shade) while (*c != '\0') { int nTile = seq_GetSeqPicnum(kSeqFont2, 0, (*c) - 32); - overwritesprite(x, y, nTile, shade, 2, kPalNormal); + overwritesprite(x, y, nTile, shade, 2, kPalNormal, basepal); int tileWidth = tilesiz[nTile].x; diff --git a/source/exhumed/src/exhumed.h b/source/exhumed/src/exhumed.h index 9ca41fc25..e2372a660 100644 --- a/source/exhumed/src/exhumed.h +++ b/source/exhumed/src/exhumed.h @@ -192,7 +192,7 @@ void WaitTicks(int nTicks); void FadeIn(); void FadeOut(int bFadeMusic); -int myprintext(int x, int y, const char *str, int shade); +int myprintext(int x, int y, const char *str, int shade, int basepal = 0); int MyGetStringWidth(const char *str); void mychangespritesect(int nSprite, int nSector); diff --git a/source/exhumed/src/init.cpp b/source/exhumed/src/init.cpp index ce71028c3..5497a0c21 100644 --- a/source/exhumed/src/init.cpp +++ b/source/exhumed/src/init.cpp @@ -52,6 +52,7 @@ enum kTagRamses = 61, }; +void uploadCinemaPalettes(); ClockTicks ototalclock = 0; int initx, inity, initz; @@ -216,7 +217,7 @@ void InstallEngine() { G_FatalEngineError(); } - + uploadCinemaPalettes(); LoadPaletteLookups(); V_Init2(); diff --git a/source/exhumed/src/light.cpp b/source/exhumed/src/light.cpp index a3de41440..7a5034e3f 100644 --- a/source/exhumed/src/light.cpp +++ b/source/exhumed/src/light.cpp @@ -93,9 +93,6 @@ int LoadPaletteLookups() } hFile.Read(buffer, 256*64); - // TODO: dumb hack - if (lookuptables[i]) - ALIGNED_FREE_AND_NULL(lookuptables[i]); paletteSetLookupTable(i, buffer); bGreenPal = 0; diff --git a/source/exhumed/src/menu.cpp b/source/exhumed/src/menu.cpp index 981811f1e..8bfac39a6 100644 --- a/source/exhumed/src/menu.cpp +++ b/source/exhumed/src/menu.cpp @@ -64,7 +64,6 @@ uint8_t * PlasmaBuffer; uint8_t energytile[66 * 66] = {0}; -uint8_t cinemapal[768]; short nLeft[50] = {0}; int line; @@ -991,30 +990,21 @@ int nextclock; short nHeight; short nCrawlY; short cinematile; +int currentCinemaPalette; -// TODO - moveme -int LoadCinemaPalette(int nPal) +void uploadCinemaPalettes() { - nPal--; - - if (nPal < 0 || nPal >= kMaxCinemaPals) { - return -2; + for (int i = 0; i < countof(cinpalfname); i++) + { + uint8_t palette[768] = {}; + auto hFile = fileSystem.OpenFileReader(cinpalfname[i]); + if (hFile.isOpen()) + hFile.Read(palette, 768); + for (auto& c : palette) + c <<= 2; + paletteSetColorTable(ANIMPAL+i, palette); } - - // original code strcpy'd into a buffer first... - - auto hFile = fileSystem.OpenFileReader(cinpalfname[nPal]); - if (!hFile.isOpen()) { - return -2; - } - - hFile.Read(cinemapal, sizeof(cinemapal)); - - for (auto &c : cinemapal) - c <<= 2; - - return nPal; } //int IncrementCinemaFadeIn() @@ -1053,8 +1043,7 @@ void CinemaFadeIn() { BlackOut(); - paletteSetColorTable(ANIMPAL, cinemapal); - videoSetPalette(0, ANIMPAL, Pal_Fullscreen); + //videoSetPalette(0, ANIMPAL, Pal_Fullscreen); #ifdef USE_OPENGL if (videoGetRenderMode() >= REND_POLYMOST) @@ -1135,7 +1124,7 @@ bool AdvanceCinemaText() while (i < linecount && y <= 199) { if (y >= -10) { - myprintext(nLeft[i], y, gString[line + i], 0); + myprintext(nLeft[i], y, gString[line + i], 0, currentCinemaPalette); } i++; @@ -1171,7 +1160,7 @@ void DoCinemaText(short nVal) while (bContinue) { - overwritesprite(0, 0, cinematile, 0, 2, kPalNormal); + overwritesprite(0, 0, cinematile, 0, 2, kPalNormal, currentCinemaPalette); bContinue = AdvanceCinemaText(); @@ -1191,53 +1180,47 @@ void GoToTheCinema(int nVal) case 0: { - LoadCinemaPalette(1); cinematile = 3454; break; } case 1: { - LoadCinemaPalette(2); cinematile = 3452; break; } case 2: { - LoadCinemaPalette(3); cinematile = 3449; break; } case 3: { - LoadCinemaPalette(4); cinematile = 3445; break; } case 4: { - LoadCinemaPalette(5); cinematile = 3451; break; } case 5: { - LoadCinemaPalette(6); cinematile = 3448; break; } case 6: { - LoadCinemaPalette(7); cinematile = 3446; break; } } + currentCinemaPalette = nVal; #if 0 if (ISDEMOVER) { @@ -1251,12 +1234,12 @@ void GoToTheCinema(int nVal) StopAllSounds(); NoClip(); - overwritesprite(0, 0, kMovieTile, 100, 2, kPalNormal); + overwritesprite(0, 0, kMovieTile, 100, 2, kPalNormal, currentCinemaPalette); videoNextPage(); // int386(16, (const union REGS *)&val, (union REGS *)&val) - overwritesprite(0, 0, cinematile, 0, 2, kPalNormal); + overwritesprite(0, 0, cinematile, 0, 2, kPalNormal, currentCinemaPalette); videoNextPage(); CinemaFadeIn(); @@ -1321,7 +1304,7 @@ void GoToTheCinema(int nVal) FadeOut(kTrue); - overwritesprite(0, 0, kMovieTile, 100, 2, kPalNormal); + overwritesprite(0, 0, kMovieTile, 100, 2, kPalNormal, currentCinemaPalette); videoNextPage(); GrabPalette(); diff --git a/source/exhumed/src/view.cpp b/source/exhumed/src/view.cpp index 267a3e5e9..2d53fbce5 100644 --- a/source/exhumed/src/view.cpp +++ b/source/exhumed/src/view.cpp @@ -605,8 +605,6 @@ bool GameInterface::GenerateSavePic() return true; } - - void NoClip() { videoSetViewableArea(0, 0, xdim - 1, ydim - 1); diff --git a/source/glbackend/gl_palmanager.cpp b/source/glbackend/gl_palmanager.cpp index fa8026b84..bfba1a927 100644 --- a/source/glbackend/gl_palmanager.cpp +++ b/source/glbackend/gl_palmanager.cpp @@ -296,7 +296,7 @@ int PaletteManager::LookupPalette(int palette, int palswap, bool brightmap, bool PaletteData* paldata = &palettes[realpal]; PalswapData* swapdata = &palswaps[realswap]; PalEntry swappedpalette[256]; - int end = nontransparent255 ? 256 : 255; + int end = paldata->colors[255].a == 255 ? 256 : 255; if (!brightmap) { for (int i = 0; i < end; i++) @@ -331,7 +331,7 @@ int PaletteManager::LookupPalette(int palette, int palswap, bool brightmap, bool return -1; } } - if (!nontransparent255) swappedpalette[255] = 0; + if (end == 255) swappedpalette[255] = 0; int palid = FindPalette((uint8_t*)swappedpalette); swappedpalmap.Insert(combined, palid); return palid; diff --git a/source/glbackend/gl_texture.cpp b/source/glbackend/gl_texture.cpp index fea34c334..64edfaa2e 100644 --- a/source/glbackend/gl_texture.cpp +++ b/source/glbackend/gl_texture.cpp @@ -201,7 +201,7 @@ bool GLInstance::SetTextureInternal(int picnum, FTexture* tex, int palette, int applytint = true; if (!(h.f & HICTINT_APPLYOVERPALSWAP)) usepalswap = 0; } - lookuppal = palmanager.LookupPalette(usepalette, usepalswap, false,fixpalette < 0? !!(curpaletteflags & Pal_Fullscreen) : 0); + lookuppal = palmanager.LookupPalette(usepalette, usepalswap, false, 0); } } @@ -286,7 +286,7 @@ bool GLInstance::SetTextureInternal(int picnum, FTexture* tex, int palette, int } } #if 1 - if (!(tex->PicAnim.sf & PICANM_NOFULLBRIGHT_BIT) && !(globalflags & GLOBAL_NO_GL_FULLBRIGHT) && !tex->NoBrightmapFlag[usepalswap] && !(curpaletteflags & (Pal_Fullscreen|Pal_2D))) + if (!(tex->PicAnim.sf & PICANM_NOFULLBRIGHT_BIT) && !(globalflags & GLOBAL_NO_GL_FULLBRIGHT) && !tex->NoBrightmapFlag[usepalswap]) { if (TextureType == TT_HICREPLACE) { diff --git a/source/glbackend/hw_draw2d.cpp b/source/glbackend/hw_draw2d.cpp index 597e5d1e7..cd226b5c6 100644 --- a/source/glbackend/hw_draw2d.cpp +++ b/source/glbackend/hw_draw2d.cpp @@ -41,6 +41,7 @@ #include "v_draw.h" #include "palette.h" #include "flatvertices.h" +#include "build.h" extern int16_t numshades; extern TArray matrixArray; @@ -173,7 +174,13 @@ void GLInstance::Draw2D(F2DDrawer *drawer) // todo: Set up hictinting. (broken as the feature is...) SetShade(cmd.mRemapIndex >> 16, numshades); SetFadeDisable(false); - SetTexture(0, tex, cmd.mRemapIndex & 0xffff, 4/*DAMETH_CLAMPED*/, cmd.mFlags & F2DDrawer::DTF_Wrap ? SamplerRepeat : SamplerClampXY); + auto saved = curbasepal; // screw Build's dependencies on global state variables. We only need to change this for the following SetTexture call. + curbasepal = (cmd.mRemapIndex >> 8) & 0xff; + auto savedf = globalflags; + if (curbasepal > 0) globalflags |= GLOBAL_NO_GL_FULLBRIGHT; // temp. hack to disable brightmaps. + SetTexture(0, tex, cmd.mRemapIndex & 0xff, 4/*DAMETH_CLAMPED*/, cmd.mFlags & F2DDrawer::DTF_Wrap ? SamplerRepeat : SamplerClampXY); + curbasepal = saved; + globalflags = savedf; } else { diff --git a/source/rr/src/net.cpp b/source/rr/src/net.cpp index ba568bcb9..d3473ceb5 100644 --- a/source/rr/src/net.cpp +++ b/source/rr/src/net.cpp @@ -132,12 +132,12 @@ void Net_SyncPlayer(ENetEvent *event) static void display_betascreen(void) { - rotatesprite_fs(160<<16,100<<16,65536,0,BETASCREEN,0,0,2+8+64+BGSTRETCH); + rotatesprite_fs(160<<16,100<<16,65536,0,BETASCREEN,0,0,2+8+64+BGSTRETCH, nullptr, TITLEPAL); - rotatesprite_fs(160<<16,(104)<<16,60<<10,0,DUKENUKEM,0,0,2+8); - rotatesprite_fs(160<<16,(129)<<16,30<<11,0,THREEDEE,0,0,2+8); + rotatesprite_fs(160<<16,(104)<<16,60<<10,0,DUKENUKEM,0,0,2+8, nullptr, TITLEPAL); + rotatesprite_fs(160<<16,(129)<<16,30<<11,0,THREEDEE,0,0,2+8, nullptr, TITLEPAL); if (PLUTOPAK) // JBF 20030804 - rotatesprite_fs(160<<16,(151)<<16,30<<11,0,PLUTOPAKSPRITE+1,0,0,2+8); + rotatesprite_fs(160<<16,(151)<<16,30<<11,0,PLUTOPAKSPRITE+1,0,0,2+8, nullptr, TITLEPAL); } void faketimerhandler(void) @@ -166,8 +166,6 @@ void Net_WaitForEverybody(void) } - P_SetGamePalette(g_player[myconnectindex].ps, TITLEPAL, Pal_2D); - do { if (G_FPSLimit()) diff --git a/source/rr/src/screens.cpp b/source/rr/src/screens.cpp index e4be788b7..3dc9bf31f 100644 --- a/source/rr/src/screens.cpp +++ b/source/rr/src/screens.cpp @@ -1010,7 +1010,7 @@ void fadepal(int32_t r, int32_t g, int32_t b, int32_t start, int32_t end, int32_ } // START and END limits are always inclusive! -static void fadepaltile(int32_t r, int32_t g, int32_t b, int32_t start, int32_t end, int32_t step, int32_t tile) +static void fadepaltile(int32_t r, int32_t g, int32_t b, int32_t start, int32_t end, int32_t step, int32_t tile, int basepal) { if (ud.screenfade == 0) return; @@ -1028,7 +1028,7 @@ static void fadepaltile(int32_t r, int32_t g, int32_t b, int32_t start, int32_t videoFadePalette(r, g, b, end); // have to set to end fade value if we break! return; } - rotatesprite_fs(160<<16, 100<<16, 65536L, 0, tile, 0, 0, 2+8+64+BGSTRETCH); + rotatesprite_fs(160<<16, 100<<16, 65536L, 0, tile, 0, 0, 2+8+64+BGSTRETCH, nullptr, basepal); G_FadePalette(r, g, b, start); start += step; @@ -1051,13 +1051,13 @@ void G_DisplayExtraScreens(void) fadepal(0, 0, 0, 0, 252, 28); inputState.ClearAllInput(); rotatesprite_fs(160<<16, 100<<16, 65536L, 0, 3291, 0, 0, 2+8+64+BGSTRETCH); - fadepaltile(0, 0, 0, 252, 0, -28, 3291); + fadepaltile(0, 0, 0, 252, 0, -28, 3291, BASEPAL); while (!inputState.CheckAllInput()) G_HandleAsync(); - fadepaltile(0, 0, 0, 0, 252, 28, 3291); + fadepaltile(0, 0, 0, 0, 252, 28, 3291, BASEPAL); rotatesprite_fs(160<<16, 100<<16, 65536L, 0, 3290, 0, 0, 2+8+64+BGSTRETCH); - fadepaltile(0, 0, 0, 252, 0, -28, 3290); + fadepaltile(0, 0, 0, 252, 0, -28, 3290, BASEPAL); while (!inputState.CheckAllInput()) G_HandleAsync(); @@ -1073,11 +1073,11 @@ void G_DisplayExtraScreens(void) inputState.ClearAllInput(); totalclock = 0; rotatesprite_fs(160<<16, 100<<16, 65536L, 0, TENSCREEN, 0, 0, 2+8+64+BGSTRETCH); - fadepaltile(0, 0, 0, 252, 0, -28, TENSCREEN); + fadepaltile(0, 0, 0, 252, 0, -28, TENSCREEN, BASEPAL); while (!inputState.CheckAllInput() && totalclock < 2400) G_HandleAsync(); - fadepaltile(0, 0, 0, 0, 252, 28, TENSCREEN); + fadepaltile(0, 0, 0, 0, 252, 28, TENSCREEN, BASEPAL); inputState.ClearAllInput(); } } @@ -1113,7 +1113,7 @@ void G_DisplayLogo(void) renderFlushPerms(); rotatesprite_fs(160 << 16, 100 << 16, 65536L, 0, 7106, 0, 0, 2 + 8 + 64 + BGSTRETCH); videoNextPage(); - fadepaltile(0, 0, 0, 252, 0, -4, 7106); + fadepaltile(0, 0, 0, 252, 0, -4, 7106, BASEPAL); totalclock = 0; while (totalclock < (120 * 3) && !inputState.CheckAllInput()) @@ -1133,7 +1133,7 @@ void G_DisplayLogo(void) } } - fadepaltile(0, 0, 0, 0, 252, 4, 7106); + fadepaltile(0, 0, 0, 0, 252, 4, 7106, BASEPAL); } videoClearScreen(0L); @@ -1158,7 +1158,7 @@ void G_DisplayLogo(void) renderFlushPerms(); rotatesprite_fs(160 << 16, 100 << 16, 65536L, 0, 7107, 0, 0, 2 + 8 + 64 + BGSTRETCH); videoNextPage(); - fadepaltile(0, 0, 0, 252, 0, -4, 7107); + fadepaltile(0, 0, 0, 252, 0, -4, 7107, BASEPAL); totalclock = 0; while (totalclock < (120 * 3) && !inputState.CheckAllInput()) @@ -1178,7 +1178,7 @@ void G_DisplayLogo(void) } } - fadepaltile(0, 0, 0, 0, 252, 4, 7107); + fadepaltile(0, 0, 0, 0, 252, 4, 7107, BASEPAL); } inputState.ClearAllInput(); @@ -1285,12 +1285,11 @@ void G_DisplayLogo(void) { videoClearScreen(0); - P_SetGamePalette(g_player[myconnectindex].ps, DREALMSPAL, Pal_Fullscreen); // JBF 20040308 fadepal(0, 0, 0, 0, 252, 28); renderFlushPerms(); - rotatesprite_fs(160 << 16, 100 << 16, 65536L, 0, DREALMS, 0, 0, 2 + 8 + 64 + BGSTRETCH); + rotatesprite_fs(160 << 16, 100 << 16, 65536L, 0, DREALMS, 0, 0, 2 + 8 + 64 + BGSTRETCH, nullptr, DREALMSPAL); videoNextPage(); - fadepaltile(0, 0, 0, 252, 0, -28, DREALMS); + fadepaltile(0, 0, 0, 252, 0, -28, DREALMS, DREALMSPAL); totalclock = 0; while (totalclock < (120 * 7) && !inputState.CheckAllInput()) @@ -1298,13 +1297,13 @@ void G_DisplayLogo(void) if (G_FPSLimit()) { videoClearScreen(0); - rotatesprite_fs(160 << 16, 100 << 16, 65536L, 0, DREALMS, 0, 0, 2 + 8 + 64 + BGSTRETCH); + rotatesprite_fs(160 << 16, 100 << 16, 65536L, 0, DREALMS, 0, 0, 2 + 8 + 64 + BGSTRETCH, nullptr, DREALMSPAL); G_HandleAsync(); videoNextPage(); } } - fadepaltile(0, 0, 0, 0, 252, 28, DREALMS); + fadepaltile(0, 0, 0, 0, 252, 28, DREALMS, DREALMSPAL); } } @@ -1319,11 +1318,10 @@ void G_DisplayLogo(void) videoClearScreen(0); //g_player[myconnectindex].ps->palette = titlepal; - P_SetGamePalette(g_player[myconnectindex].ps, TITLEPAL, Pal_2D); // JBF 20040308 renderFlushPerms(); - rotatesprite_fs(160<<16, 100<<16, 65536L, 0, BETASCREEN, 0, 0, 2+8+64+BGSTRETCH); + rotatesprite_fs(160<<16, 100<<16, 65536L, 0, BETASCREEN, 0, 0, 2+8+64+BGSTRETCH, nullptr, TITLEPAL); inputState.keyFlushChars(); - fadepaltile(0, 0, 0, 252, 0, -28, BETASCREEN); + fadepaltile(0, 0, 0, 252, 0, -28, BETASCREEN, TITLEPAL); totalclock = 0; while ( @@ -1333,7 +1331,7 @@ void G_DisplayLogo(void) if (G_FPSLimit()) { videoClearScreen(0); - rotatesprite_fs(160<<16, 100<<16, 65536L, 0, BETASCREEN, 0, 0, 2+8+64+BGSTRETCH); + rotatesprite_fs(160<<16, 100<<16, 65536L, 0, BETASCREEN, 0, 0, 2+8+64+BGSTRETCH, nullptr, TITLEPAL); if (totalclock > 120 && totalclock < (120+60)) { @@ -1342,10 +1340,10 @@ void G_DisplayLogo(void) soundanm++; S_PlaySound(PIPEBOMB_EXPLODE, CHAN_AUTO, CHANF_UI); } - rotatesprite_fs(160<<16, 104<<16, ((int32_t) totalclock-120)<<10, 0, DUKENUKEM, 0, 0, 2+8); + rotatesprite_fs(160<<16, 104<<16, ((int32_t) totalclock-120)<<10, 0, DUKENUKEM, 0, 0, 2+8, nullptr, TITLEPAL); } else if (totalclock >= (120+60)) - rotatesprite_fs(160<<16, (104)<<16, 60<<10, 0, DUKENUKEM, 0, 0, 2+8); + rotatesprite_fs(160<<16, (104)<<16, 60<<10, 0, DUKENUKEM, 0, 0, 2+8, nullptr, TITLEPAL); if (totalclock > 220 && totalclock < (220+30)) { @@ -1355,18 +1353,18 @@ void G_DisplayLogo(void) S_PlaySound(PIPEBOMB_EXPLODE, CHAN_AUTO, CHANF_UI); } - rotatesprite_fs(160<<16, (104)<<16, 60<<10, 0, DUKENUKEM, 0, 0, 2+8); - rotatesprite_fs(160<<16, (129)<<16, ((int32_t) totalclock - 220)<<11, 0, THREEDEE, 0, 0, 2+8); + rotatesprite_fs(160<<16, (104)<<16, 60<<10, 0, DUKENUKEM, 0, 0, 2+8, nullptr, TITLEPAL); + rotatesprite_fs(160<<16, (129)<<16, ((int32_t) totalclock - 220)<<11, 0, THREEDEE, 0, 0, 2+8, nullptr, TITLEPAL); } else if (totalclock >= (220+30)) - rotatesprite_fs(160<<16, (129)<<16, 30<<11, 0, THREEDEE, 0, 0, 2+8); + rotatesprite_fs(160<<16, (129)<<16, 30<<11, 0, THREEDEE, 0, 0, 2+8, nullptr, TITLEPAL); if (PLUTOPAK) { // JBF 20030804 if (totalclock >= 280 && totalclock < 395) { - rotatesprite_fs(160<<16, (151)<<16, (410-(int32_t) totalclock)<<12, 0, PLUTOPAKSPRITE+1, (sintable[((int32_t) totalclock<<4)&2047]>>11), 0, 2+8); + rotatesprite_fs(160<<16, (151)<<16, (410-(int32_t) totalclock)<<12, 0, PLUTOPAKSPRITE+1, (sintable[((int32_t) totalclock<<4)&2047]>>11), 0, 2+8, nullptr, TITLEPAL); if (soundanm == 2) { soundanm++; @@ -1380,7 +1378,7 @@ void G_DisplayLogo(void) soundanm++; S_PlaySound(PIPEBOMB_EXPLODE, CHAN_AUTO, CHANF_UI); } - rotatesprite_fs(160<<16, (151)<<16, 30<<11, 0, PLUTOPAKSPRITE+1, (sintable[((int32_t) totalclock<<4)&2047]>>11), 0, 2+8); + rotatesprite_fs(160<<16, (151)<<16, 30<<11, 0, PLUTOPAKSPRITE+1, (sintable[((int32_t) totalclock<<4)&2047]>>11), 0, 2+8, nullptr, TITLEPAL); } } @@ -1509,9 +1507,8 @@ static void G_BonusCutscenes(void) 350, 380, VICTORY1+8, 86, 59 // duplicate row to alleviate overflow in the for loop below "boss" }; - P_SetGamePalette(g_player[myconnectindex].ps, ENDINGPAL, Pal_Fullscreen); // JBF 20040308 videoClearScreen(0L); - rotatesprite_fs(0, 50<<16, 65536L, 0, VICTORY1, 0, 0, 2+8+16+64+128+BGSTRETCH); + rotatesprite_fs(0, 50<<16, 65536L, 0, VICTORY1, 0, 0, 2+8+16+64+128+BGSTRETCH, nullptr, ENDINGPAL); videoNextPage(); fadepal(0, 0, 0, 252, 0, -4); @@ -1523,7 +1520,7 @@ static void G_BonusCutscenes(void) if (G_FPSLimit()) { videoClearScreen(0L); - rotatesprite_fs(0, 50<<16, 65536L, 0, VICTORY1, 0, 0, 2+8+16+64+128+BGSTRETCH); + rotatesprite_fs(0, 50 << 16, 65536L, 0, VICTORY1, 0, 0, 2 + 8 + 16 + 64 + 128 + BGSTRETCH, nullptr, ENDINGPAL); // boss if (totalclock > 390 && totalclock < 780) @@ -1535,7 +1532,7 @@ static void G_BonusCutscenes(void) S_PlaySound(SQUISHED, CHAN_AUTO, CHANF_UI); bonuscnt++; } - rotatesprite_fs(bossmove[t+3]<<16, bossmove[t+4]<<16, 65536L, 0, bossmove[t+2], 0, 0, 2+8+16+64+128+BGSTRETCH); + rotatesprite_fs(bossmove[t+3]<<16, bossmove[t+4]<<16, 65536L, 0, bossmove[t+2], 0, 0, 2+8+16+64+128+BGSTRETCH, nullptr, ENDINGPAL); } // Breathe @@ -1551,7 +1548,7 @@ static void G_BonusCutscenes(void) if (totalclock >= 750) { - rotatesprite_fs(86<<16, 59<<16, 65536L, 0, VICTORY1+8, 0, 0, 2+8+16+64+128+BGSTRETCH); + rotatesprite_fs(86<<16, 59<<16, 65536L, 0, VICTORY1+8, 0, 0, 2+8+16+64+128+BGSTRETCH, nullptr, ENDINGPAL); if (totalclock >= 750 && bonuscnt == 2) { S_PlaySound(DUKETALKTOBOSS, CHAN_AUTO, CHANF_UI); @@ -1567,7 +1564,7 @@ static void G_BonusCutscenes(void) S_PlaySound(BOSSTALKTODUKE, CHAN_AUTO, CHANF_UI); bonuscnt++; } - rotatesprite_fs(breathe[t+3]<<16, breathe[t+4]<<16, 65536L, 0, breathe[t+2], 0, 0, 2+8+16+64+128+BGSTRETCH); + rotatesprite_fs(breathe[t+3]<<16, breathe[t+4]<<16, 65536L, 0, breathe[t+2], 0, 0, 2+8+16+64+128+BGSTRETCH, nullptr, ENDINGPAL); } } diff --git a/source/rr/src/sector.cpp b/source/rr/src/sector.cpp index 4bb934b5c..806a080b3 100644 --- a/source/rr/src/sector.cpp +++ b/source/rr/src/sector.cpp @@ -5270,7 +5270,7 @@ void G_Thunder(void) { brightness = 0; g_thunderFlash = 0; - videoSetPalette(0,g_player[screenpeek].ps->palette,Pal_SceneBrightness); + videoSetBrightness(0); g_visibility = g_player[screenpeek].ps->visibility; } } @@ -5313,7 +5313,7 @@ void G_Thunder(void) g_visibility = 2048; if (brightness > 8) brightness = 0; - videoSetPalette(brightness,g_player[screenpeek].ps->palette,Pal_SceneBrightness); + videoSetBrightness(brightness); } if (g_winderFlash == 1) { diff --git a/source/sw/src/game.cpp b/source/sw/src/game.cpp index fb9c7ec87..9d70227b0 100644 --- a/source/sw/src/game.cpp +++ b/source/sw/src/game.cpp @@ -1417,7 +1417,6 @@ void LogoLevel(void) DSPRINTF(ds,"LogoLevel..."); MONO_PRINT(ds); - videoSetPalette(0, DREALMSPAL, Pal_Fullscreen); MONO_PRINT(ds); //FadeOut(0, 0); @@ -1434,7 +1433,7 @@ void LogoLevel(void) while (TRUE) { twod->ClearScreen(); - rotatesprite(0, 0, RS_SCALE, 0, THREED_REALMS_PIC, 0, 0, TITLE_ROT_FLAGS, 0, 0, xdim - 1, ydim - 1); + rotatesprite(0, 0, RS_SCALE, 0, THREED_REALMS_PIC, 0, 0, TITLE_ROT_FLAGS, 0, 0, xdim - 1, ydim - 1, nullptr, DREALMSPAL); videoNextPage(); handleevents();