- disable palette transparency for color 255 when running an animation.

There's several intro cutscenes using the full palette and for these the color must not be nulled as it should for in-game textures.
This commit is contained in:
Christoph Oelckers 2019-12-25 14:13:15 +01:00
parent b0cefdedce
commit 120a985b98
7 changed files with 29 additions and 8 deletions

View File

@ -35,6 +35,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "screen.h"
#include "sound.h"
#include "view.h"
#include "../glbackend/glbackend.h"
#include "sound/s_soundinternal.h"
BEGIN_BLD_NS
@ -236,6 +237,7 @@ void credPlaySmk(const char *_pzSMK, const char *_pzWAV, int nWav)
Smacker_GetPalette(hSMK, palette);
paletteSetColorTable(kSMKPal, palette, true);
GLInterface.EnableNonTransparent255(true);
videoSetPalette(0, kSMKPal, 8+2);
int nScale;
@ -290,6 +292,7 @@ void credPlaySmk(const char *_pzSMK, const char *_pzWAV, int nWav)
Smacker_Close(hSMK);
inputState.ClearAllInput();
soundEngine->StopAllChannels();
GLInterface.EnableNonTransparent255(false);
videoSetPalette(0, 0, 8+2);
tileDelete(kSMKTile);
Bfree(pzSMK_);

View File

@ -28,6 +28,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "animlib.h"
#include "cmdlib.h"
#include "compat.h"
#include "../glbackend/glbackend.h"
#include "anim.h"
@ -300,6 +301,7 @@ int32_t Anim_Play(const char *fn)
// OSD_Printf("msecs per frame: %d\n", msecsperframe);
GLInterface.EnableNonTransparent255(true);
do
{
nextframetime += msecsperframe;
@ -391,6 +393,7 @@ int32_t Anim_Play(const char *fn)
}
} while (timerGetTicks() < nextframetime);
} while (running);
GLInterface.EnableNonTransparent255(false);
animvpx_print_stats(&codec);
@ -440,6 +443,7 @@ int32_t Anim_Play(const char *fn)
paletteSetColorTable(ANIMPAL, ANIM_GetPalette(), true);
// setpalette(0L,256L,tempbuf);
GLInterface.EnableNonTransparent255(true);
P_SetGamePalette(g_player[myconnectindex].ps, ANIMPAL, 8 + 2);
#ifdef USE_OPENGL
@ -529,6 +533,7 @@ int32_t Anim_Play(const char *fn)
}
++i;
} while (i < numframes);
GLInterface.EnableNonTransparent255(false);
end_anim_restore_gl:
#ifdef USE_OPENGL

View File

@ -285,20 +285,21 @@ void PaletteManager::BindPalswap(int index)
}
int PaletteManager::LookupPalette(int palette, int palswap, bool brightmap)
int PaletteManager::LookupPalette(int palette, int palswap, bool brightmap, bool nontransparent255)
{
int realpal = palettemap[palette];
int realswap = palswapmap[palswap];
int combined = (brightmap? 0x1000000 : 0) + realpal * 0x10000 + realswap;
int combined = (nontransparent255? 0x2000000 : 0) + (brightmap? 0x1000000 : 0) + realpal * 0x10000 + realswap;
int* combinedindex = swappedpalmap.CheckKey(combined);
if (combinedindex) return *combinedindex;
PaletteData* paldata = &palettes[realpal];
PalswapData* swapdata = &palswaps[realswap];
PalEntry swappedpalette[256];
int end = nontransparent255 ? 256 : 255;
if (!brightmap)
{
for (int i = 0; i < 255; i++)
for (int i = 0; i < end; i++)
{
int swapi = swapdata->lookup[i];
swappedpalette[i] = paldata->colors[swapi];
@ -330,7 +331,7 @@ int PaletteManager::LookupPalette(int palette, int palswap, bool brightmap)
return -1;
}
}
swappedpalette[255] = 0;
if (!nontransparent255) swappedpalette[255] = 0;
int palid = FindPalette((uint8_t*)swappedpalette);
swappedpalmap.Insert(combined, palid);
return palid;

View File

@ -46,7 +46,6 @@
CVAR(Int, fixpalette, 0, 0)
CVAR(Int, fixpalswap, 0, 0)
template<class T>
void FlipNonSquareBlock(T* dst, const T* src, int x, int y, int srcpitch)
{
@ -177,7 +176,7 @@ bool GLInstance::SetTextureInternal(int picnum, FTexture* tex, int palette, int
if (TextureType == TT_TRUECOLOR)
{
/*lookuppal = palmanager.LookupPalette(usepalette, usepalswap, true);
if (lookuppal< 0)*/ lookuppal = palmanager.LookupPalette(usepalette, usepalswap, false);
if (lookuppal< 0)*/ lookuppal = palmanager.LookupPalette(usepalette, usepalswap, false, g_nontransparent255);
}
}

View File

@ -83,7 +83,7 @@ public:
void BindPalette(int index);
void BindPalswap(int index);
int ActivePalswap() const { return lastsindex; }
int LookupPalette(int palette, int palswap, bool brightmap);
int LookupPalette(int palette, int palswap, bool brightmap, bool nontransparent255 = false);
const PalEntry *GetPaletteData(int palid) const { return palettes[palid].colors; }
unsigned FindPalette(const uint8_t* paldata);
@ -194,6 +194,7 @@ class GLInstance
int TextureType;
int MatrixChange = 0;
bool istrans = false;
bool g_nontransparent255 = false; // Ugh... This is for movie playback and needs to be maintained as global state.
IVertexBuffer* LastVertexBuffer = nullptr;
int LastVB_Offset[2] = {};
@ -240,6 +241,11 @@ public:
void EnableBlend(bool on);
void EnableDepthTest(bool on);
void EnableMultisampling(bool on);
void EnableNonTransparent255(bool on)
{
g_nontransparent255 = on;
}
void SetVertexBuffer(IVertexBuffer* vb, int offset1, int offset2)
{
renderState.VertexBuffer = vb;

View File

@ -28,6 +28,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "animlib.h"
#include "compat.h"
#include "cmdlib.h"
#include "../glbackend/glbackend.h"
#include "anim.h"
@ -39,7 +40,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
BEGIN_RR_NS
// animsound_t.sound
EDUKE32_STATIC_ASSERT(INT16_MAX >= MAXSOUNDS);
TArray<dukeanim_t> g_Animations;
dukeanim_t * g_animPtr;
@ -338,6 +338,7 @@ int32_t Anim_Play(const char *fn)
// OSD_Printf("msecs per frame: %d\n", msecsperframe);
GLInterface.EnableNonTransparent255(true);
do
{
nextframetime += msecsperframe;
@ -425,6 +426,7 @@ int32_t Anim_Play(const char *fn)
}
} while (timerGetTicks() < nextframetime);
} while (running);
GLInterface.EnableNonTransparent255(false);
animvpx_print_stats(&codec);
@ -482,6 +484,7 @@ int32_t Anim_Play(const char *fn)
paletteSetColorTable(ANIMPAL, ANIM_GetPalette(), true);
// setpalette(0L,256L,tempbuf);
GLInterface.EnableNonTransparent255(true);
P_SetGamePalette(g_player[myconnectindex].ps, ANIMPAL, 8 + 2);
ototalclock = totalclock;
@ -564,6 +567,7 @@ int32_t Anim_Play(const char *fn)
++i;
} while (i < numframes);
GLInterface.EnableNonTransparent255(false);
end_anim_restore_gl:
#ifdef USE_OPENGL

View File

@ -42,6 +42,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms
#include "animlib.h"
#include "anim.h"
#include "../glbackend/glbackend.h"
#include "common_game.h"
@ -273,6 +274,7 @@ playanm(short anim_num)
//ototalclock = totalclock + 120*2;
ototalclock = (int32_t) totalclock;
GLInterface.EnableNonTransparent255(true);
for (i = 1; i < numframes; i++)
{
while (totalclock < ototalclock)
@ -324,6 +326,7 @@ playanm(short anim_num)
ENDOFANIMLOOP:
GLInterface.EnableNonTransparent255(false);
videoClearViewableArea(0L);
videoNextPage();