Rework green palette and torch effects to not modify palookup array

In other words make these effects polymost friendly
This commit is contained in:
nukeykt 2019-10-27 22:53:20 +09:00 committed by Christoph Oelckers
parent e0255789da
commit ff6820aa92
7 changed files with 117 additions and 29 deletions

View file

@ -14,6 +14,7 @@
#include "snake.h" #include "snake.h"
#include "grenade.h" #include "grenade.h"
#include "lighting.h" #include "lighting.h"
#include "light.h"
#include "input.h" #include "input.h"
#include "util.h" #include "util.h"
#include "anims.h" #include "anims.h"
@ -931,17 +932,19 @@ void DrawWeapons()
int8_t nShade = sector[initsect].ceilingshade; int8_t nShade = sector[initsect].ceilingshade;
int nDouble = nPlayerDouble[nLocalPlayer]; int nDouble = nPlayerDouble[nLocalPlayer];
int nPal = 0; int nPal = kPalNormal;
if (nDouble) if (nDouble)
{ {
if (word_96E26) { if (word_96E26) {
nPal = 5; nPal = kPalRedBrite;
} }
word_96E26 = word_96E26 == 0; word_96E26 = word_96E26 == 0;
} }
nPal = RemapPLU(nPal);
int nVal = totalvel[nLocalPlayer] >> 1; int nVal = totalvel[nLocalPlayer] >> 1;
// CHECKME - not & 0x7FF? // CHECKME - not & 0x7FF?

View file

@ -4,6 +4,7 @@
#include "exhumed.h" #include "exhumed.h"
#include "view.h" #include "view.h"
#include "cd.h" #include "cd.h"
#include "lighting.h"
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@ -28,7 +29,7 @@ const char *GradList[kMaxGrads] = {
int rtint = 0; int rtint = 0;
int gtint = 0; int gtint = 0;
int btint = 0; int btint = 0;
char *origpalookup[kMaxPalookups]; //char *origpalookup[kMaxPalookups];
//unsigned char curpal[768]; //unsigned char curpal[768];
//unsigned char kenpal[768]; //unsigned char kenpal[768];
palette_t *fadedestpal; palette_t *fadedestpal;
@ -36,6 +37,7 @@ palette_t *fadecurpal;
short nPalDelay; short nPalDelay;
short nPalDiff; short nPalDiff;
short overscanindex; short overscanindex;
int bGreenPal = 0;
// keep a local copy of the palette that would have been sent to the VGA display adapter // keep a local copy of the palette that would have been sent to the VGA display adapter
uint8_t vgaPalette[768]; uint8_t vgaPalette[768];
@ -77,7 +79,8 @@ int LoadPaletteLookups()
paletteSetLookupTable(i, buffer); paletteSetLookupTable(i, buffer);
kclose(hFile); kclose(hFile);
origpalookup[i] = palookup[i]; // origpalookup[i] = palookup[i];
bGreenPal = 0;
} }
return 1; return 1;
@ -85,20 +88,56 @@ int LoadPaletteLookups()
void SetGreenPal() void SetGreenPal()
{ {
for (int i = 0; i < 12; i++) bGreenPal = 1;
{ // for (int i = 0; i < kMaxGrads; i++)
palookup[i] = palookup[6]; // {
} // palookup[i] = palookup[6];
// }
palookup[5] = origpalookup[5]; //
// palookup[5] = origpalookup[5];
} }
void RestoreGreenPal() void RestoreGreenPal()
{ {
for (int i = 0; i < 12; i++) bGreenPal = 0;
// for (int i = 0; i < kMaxGrads; i++)
// {
// palookup[i] = origpalookup[i];
// }
}
int HavePLURemap()
{
return bGreenPal || bTorch;
}
uint8_t RemapPLU(uint8_t pal)
{
if (bGreenPal)
{ {
palookup[i] = origpalookup[i]; if (pal != kPalRedBrite)
pal = kPalGreenBrite;
return pal;
} }
else if (bTorch)
{
switch (pal)
{
case kPalTorch:
pal = kPalNoTorch;
break;
case kPalNoTorch:
pal = kPalTorch;
break;
case kPalTorch2:
pal = kPalNoTorch2;
break;
case kPalNoTorch2:
pal = kPalTorch2;
break;
}
}
return pal;
} }
void WaitVBL() void WaitVBL()

View file

@ -2,6 +2,8 @@
#ifndef __light_h__ #ifndef __light_h__
#define __light_h__ #define __light_h__
#include "compat.h"
void MyLoadPalette(); void MyLoadPalette();
int LoadPaletteLookups(); int LoadPaletteLookups();
void WaitVBL(); void WaitVBL();
@ -9,6 +11,8 @@ void SetGreenPal();
void RestoreGreenPal(); void RestoreGreenPal();
void FixPalette(); void FixPalette();
void FadeToWhite(); void FadeToWhite();
int HavePLURemap();
uint8_t RemapPLU(uint8_t pal);
extern void DoOverscanSet(short someval); extern void DoOverscanSet(short someval);
void SetOverscan(int id); void SetOverscan(int id);

View file

@ -712,24 +712,24 @@ void SetTorch(int nPlayer, int bTorchOnOff)
return; return;
} }
char *pTempPal = origpalookup[kPalTorch]; // char *pTempPal = origpalookup[kPalTorch];
palookup[kPalTorch] = palookup[kPalNoTorch]; // palookup[kPalTorch] = palookup[kPalNoTorch];
palookup[kPalNoTorch] = pTempPal; // palookup[kPalNoTorch] = pTempPal;
//
pTempPal = origpalookup[kPalTorch]; // pTempPal = origpalookup[kPalTorch];
origpalookup[kPalTorch] = origpalookup[kPalNoTorch]; // origpalookup[kPalTorch] = origpalookup[kPalNoTorch];
origpalookup[kPalNoTorch] = pTempPal; // origpalookup[kPalNoTorch] = pTempPal;
//
pTempPal = origpalookup[kPalTorch2]; // pTempPal = origpalookup[kPalTorch2];
origpalookup[kPalTorch2] = origpalookup[kPalNoTorch2]; // origpalookup[kPalTorch2] = origpalookup[kPalNoTorch2];
origpalookup[kPalNoTorch2] = pTempPal; // origpalookup[kPalNoTorch2] = pTempPal;
//
pTempPal = palookup[kPalTorch2]; // pTempPal = palookup[kPalTorch2];
palookup[kPalNoTorch2] = palookup[kPalTorch2]; // palookup[kPalNoTorch2] = palookup[kPalTorch2];
palookup[kPalTorch2] = pTempPal; // palookup[kPalTorch2] = pTempPal;
if (bTorchOnOff == 2) { if (bTorchOnOff == 2) {
bTorch = bTorch == 0; bTorch = !bTorch;
} }
else { else {
bTorch = bTorchOnOff; bTorch = bTorchOnOff;

View file

@ -14,4 +14,6 @@ void BuildFlash(short nPlayer, short nSector, int nVal);
void AddGlow(short nSector, int nVal); void AddGlow(short nSector, int nVal);
void AddFlicker(short nSector, int nVal); void AddFlicker(short nSector, int nVal);
extern short bTorch;
#endif #endif

View file

@ -9,6 +9,7 @@
#include "move.h" #include "move.h"
#include "view.h" #include "view.h"
#include "init.h" #include "init.h"
#include "light.h"
#ifndef __WATCOMC__ #ifndef __WATCOMC__
#include <cstring> #include <cstring>
#include <cstdio> // for printf #include <cstdio> // for printf
@ -333,6 +334,8 @@ void seq_DrawStatusSequence(short nSequence, uint16_t edx, short ebx)
short nFrameBase = FrameBase[edx]; short nFrameBase = FrameBase[edx];
int16_t nFrameSize = FrameSize[edx]; int16_t nFrameSize = FrameSize[edx];
int const nPal = RemapPLU(kPalNormal);
while (1) while (1)
{ {
nFrameSize--; nFrameSize--;
@ -360,7 +363,7 @@ void seq_DrawStatusSequence(short nSequence, uint16_t edx, short ebx)
nStat |= 0x2; // scale and clip to viewing window nStat |= 0x2; // scale and clip to viewing window
} }
overwritesprite(laststatusx, laststatusy, laststatustile, 0, nStat, kPalNormal); overwritesprite(laststatusx, laststatusy, laststatustile, 0, nStat, nPal);
nFrameBase++; nFrameBase++;
} }
} }

View file

@ -104,6 +104,8 @@ static void analyzesprites()
pTSprite->shade = clamp(nShade, -128, 127); pTSprite->shade = clamp(nShade, -128, 127);
} }
pTSprite->pal = RemapPLU(pTSprite->pal);
if (pSprite->statnum > 0) if (pSprite->statnum > 0)
{ {
runlist_SignalRun(pSprite->lotag - 1, nTSprite | 0x90000); runlist_SignalRun(pSprite->lotag - 1, nTSprite | 0x90000);
@ -371,6 +373,9 @@ void DrawView()
if (nFreeze != 3) if (nFreeze != 3)
{ {
static uint8_t sectorFloorPal[MAXSECTORS];
static uint8_t sectorCeilingPal[MAXSECTORS];
static uint8_t wallPal[MAXWALLS];
int const viewingRange = viewingrange; int const viewingRange = viewingrange;
if (r_usenewaspect) if (r_usenewaspect)
@ -379,10 +384,42 @@ void DrawView()
videoSetCorrectedAspect(); videoSetCorrectedAspect();
} }
if (HavePLURemap())
{
for (int i = 0; i < numsectors; i++)
{
sectorFloorPal[i] = sector[i].floorpal;
sectorCeilingPal[i] = sector[i].ceilingpal;
if (sector[i].floorpal != kPalRedBrite)
sector[i].floorpal = kPalGreenBrite;
if (sector[i].ceilingpal != kPalRedBrite)
sector[i].ceilingpal = kPalGreenBrite;
}
for (int i = 0; i < numwalls; i++)
{
wallPal[i] = wall[i].pal;
if (wall[i].pal != kPalRedBrite)
wall[i].pal = kPalGreenBrite;
}
}
drawrooms(nCamerax, nCameray, viewz, nCameraa, nCamerapan, nSector); drawrooms(nCamerax, nCameray, viewz, nCameraa, nCamerapan, nSector);
analyzesprites(); analyzesprites();
renderDrawMasks(); renderDrawMasks();
if (HavePLURemap())
{
for (int i = 0; i < numsectors; i++)
{
sector[i].floorpal = sectorFloorPal[i];
sector[i].ceilingpal = sectorCeilingPal[i];
}
for (int i = 0; i < numwalls; i++)
{
wall[i].pal = wallPal[i];
}
}
if (r_usenewaspect) if (r_usenewaspect)
{ {
newaspect_enable = 0; newaspect_enable = 0;