mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-11-11 07:11:39 +00:00
Rework green palette and torch effects to not modify palookup array
In other words make these effects polymost friendly
This commit is contained in:
parent
e0255789da
commit
ff6820aa92
7 changed files with 117 additions and 29 deletions
|
@ -14,6 +14,7 @@
|
|||
#include "snake.h"
|
||||
#include "grenade.h"
|
||||
#include "lighting.h"
|
||||
#include "light.h"
|
||||
#include "input.h"
|
||||
#include "util.h"
|
||||
#include "anims.h"
|
||||
|
@ -931,17 +932,19 @@ void DrawWeapons()
|
|||
int8_t nShade = sector[initsect].ceilingshade;
|
||||
|
||||
int nDouble = nPlayerDouble[nLocalPlayer];
|
||||
int nPal = 0;
|
||||
int nPal = kPalNormal;
|
||||
|
||||
if (nDouble)
|
||||
{
|
||||
if (word_96E26) {
|
||||
nPal = 5;
|
||||
nPal = kPalRedBrite;
|
||||
}
|
||||
|
||||
word_96E26 = word_96E26 == 0;
|
||||
}
|
||||
|
||||
nPal = RemapPLU(nPal);
|
||||
|
||||
int nVal = totalvel[nLocalPlayer] >> 1;
|
||||
|
||||
// CHECKME - not & 0x7FF?
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include "exhumed.h"
|
||||
#include "view.h"
|
||||
#include "cd.h"
|
||||
#include "lighting.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
@ -28,7 +29,7 @@ const char *GradList[kMaxGrads] = {
|
|||
int rtint = 0;
|
||||
int gtint = 0;
|
||||
int btint = 0;
|
||||
char *origpalookup[kMaxPalookups];
|
||||
//char *origpalookup[kMaxPalookups];
|
||||
//unsigned char curpal[768];
|
||||
//unsigned char kenpal[768];
|
||||
palette_t *fadedestpal;
|
||||
|
@ -36,6 +37,7 @@ palette_t *fadecurpal;
|
|||
short nPalDelay;
|
||||
short nPalDiff;
|
||||
short overscanindex;
|
||||
int bGreenPal = 0;
|
||||
|
||||
// keep a local copy of the palette that would have been sent to the VGA display adapter
|
||||
uint8_t vgaPalette[768];
|
||||
|
@ -77,7 +79,8 @@ int LoadPaletteLookups()
|
|||
paletteSetLookupTable(i, buffer);
|
||||
kclose(hFile);
|
||||
|
||||
origpalookup[i] = palookup[i];
|
||||
// origpalookup[i] = palookup[i];
|
||||
bGreenPal = 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
@ -85,20 +88,56 @@ int LoadPaletteLookups()
|
|||
|
||||
void SetGreenPal()
|
||||
{
|
||||
for (int i = 0; i < 12; i++)
|
||||
{
|
||||
palookup[i] = palookup[6];
|
||||
}
|
||||
|
||||
palookup[5] = origpalookup[5];
|
||||
bGreenPal = 1;
|
||||
// for (int i = 0; i < kMaxGrads; i++)
|
||||
// {
|
||||
// palookup[i] = palookup[6];
|
||||
// }
|
||||
//
|
||||
// palookup[5] = origpalookup[5];
|
||||
}
|
||||
|
||||
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()
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
#ifndef __light_h__
|
||||
#define __light_h__
|
||||
|
||||
#include "compat.h"
|
||||
|
||||
void MyLoadPalette();
|
||||
int LoadPaletteLookups();
|
||||
void WaitVBL();
|
||||
|
@ -9,6 +11,8 @@ void SetGreenPal();
|
|||
void RestoreGreenPal();
|
||||
void FixPalette();
|
||||
void FadeToWhite();
|
||||
int HavePLURemap();
|
||||
uint8_t RemapPLU(uint8_t pal);
|
||||
|
||||
extern void DoOverscanSet(short someval);
|
||||
void SetOverscan(int id);
|
||||
|
|
|
@ -712,24 +712,24 @@ void SetTorch(int nPlayer, int bTorchOnOff)
|
|||
return;
|
||||
}
|
||||
|
||||
char *pTempPal = origpalookup[kPalTorch];
|
||||
palookup[kPalTorch] = palookup[kPalNoTorch];
|
||||
palookup[kPalNoTorch] = pTempPal;
|
||||
|
||||
pTempPal = origpalookup[kPalTorch];
|
||||
origpalookup[kPalTorch] = origpalookup[kPalNoTorch];
|
||||
origpalookup[kPalNoTorch] = pTempPal;
|
||||
|
||||
pTempPal = origpalookup[kPalTorch2];
|
||||
origpalookup[kPalTorch2] = origpalookup[kPalNoTorch2];
|
||||
origpalookup[kPalNoTorch2] = pTempPal;
|
||||
|
||||
pTempPal = palookup[kPalTorch2];
|
||||
palookup[kPalNoTorch2] = palookup[kPalTorch2];
|
||||
palookup[kPalTorch2] = pTempPal;
|
||||
// char *pTempPal = origpalookup[kPalTorch];
|
||||
// palookup[kPalTorch] = palookup[kPalNoTorch];
|
||||
// palookup[kPalNoTorch] = pTempPal;
|
||||
//
|
||||
// pTempPal = origpalookup[kPalTorch];
|
||||
// origpalookup[kPalTorch] = origpalookup[kPalNoTorch];
|
||||
// origpalookup[kPalNoTorch] = pTempPal;
|
||||
//
|
||||
// pTempPal = origpalookup[kPalTorch2];
|
||||
// origpalookup[kPalTorch2] = origpalookup[kPalNoTorch2];
|
||||
// origpalookup[kPalNoTorch2] = pTempPal;
|
||||
//
|
||||
// pTempPal = palookup[kPalTorch2];
|
||||
// palookup[kPalNoTorch2] = palookup[kPalTorch2];
|
||||
// palookup[kPalTorch2] = pTempPal;
|
||||
|
||||
if (bTorchOnOff == 2) {
|
||||
bTorch = bTorch == 0;
|
||||
bTorch = !bTorch;
|
||||
}
|
||||
else {
|
||||
bTorch = bTorchOnOff;
|
||||
|
|
|
@ -14,4 +14,6 @@ void BuildFlash(short nPlayer, short nSector, int nVal);
|
|||
void AddGlow(short nSector, int nVal);
|
||||
void AddFlicker(short nSector, int nVal);
|
||||
|
||||
extern short bTorch;
|
||||
|
||||
#endif
|
|
@ -9,6 +9,7 @@
|
|||
#include "move.h"
|
||||
#include "view.h"
|
||||
#include "init.h"
|
||||
#include "light.h"
|
||||
#ifndef __WATCOMC__
|
||||
#include <cstring>
|
||||
#include <cstdio> // for printf
|
||||
|
@ -333,6 +334,8 @@ void seq_DrawStatusSequence(short nSequence, uint16_t edx, short ebx)
|
|||
short nFrameBase = FrameBase[edx];
|
||||
int16_t nFrameSize = FrameSize[edx];
|
||||
|
||||
int const nPal = RemapPLU(kPalNormal);
|
||||
|
||||
while (1)
|
||||
{
|
||||
nFrameSize--;
|
||||
|
@ -360,7 +363,7 @@ void seq_DrawStatusSequence(short nSequence, uint16_t edx, short ebx)
|
|||
nStat |= 0x2; // scale and clip to viewing window
|
||||
}
|
||||
|
||||
overwritesprite(laststatusx, laststatusy, laststatustile, 0, nStat, kPalNormal);
|
||||
overwritesprite(laststatusx, laststatusy, laststatustile, 0, nStat, nPal);
|
||||
nFrameBase++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -104,6 +104,8 @@ static void analyzesprites()
|
|||
pTSprite->shade = clamp(nShade, -128, 127);
|
||||
}
|
||||
|
||||
pTSprite->pal = RemapPLU(pTSprite->pal);
|
||||
|
||||
if (pSprite->statnum > 0)
|
||||
{
|
||||
runlist_SignalRun(pSprite->lotag - 1, nTSprite | 0x90000);
|
||||
|
@ -371,6 +373,9 @@ void DrawView()
|
|||
|
||||
if (nFreeze != 3)
|
||||
{
|
||||
static uint8_t sectorFloorPal[MAXSECTORS];
|
||||
static uint8_t sectorCeilingPal[MAXSECTORS];
|
||||
static uint8_t wallPal[MAXWALLS];
|
||||
int const viewingRange = viewingrange;
|
||||
|
||||
if (r_usenewaspect)
|
||||
|
@ -379,10 +384,42 @@ void DrawView()
|
|||
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);
|
||||
analyzesprites();
|
||||
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)
|
||||
{
|
||||
newaspect_enable = 0;
|
||||
|
|
Loading…
Reference in a new issue