2007-12-26 16:06:03 +00:00
|
|
|
/*
|
|
|
|
** r_translate.cpp
|
|
|
|
** Translatioo table handling
|
|
|
|
**
|
|
|
|
**---------------------------------------------------------------------------
|
|
|
|
** Copyright 1998-2006 Randy Heit
|
|
|
|
** All rights reserved.
|
|
|
|
**
|
|
|
|
** Redistribution and use in source and binary forms, with or without
|
|
|
|
** modification, are permitted provided that the following conditions
|
|
|
|
** are met:
|
|
|
|
**
|
|
|
|
** 1. Redistributions of source code must retain the above copyright
|
|
|
|
** notice, this list of conditions and the following disclaimer.
|
|
|
|
** 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
** notice, this list of conditions and the following disclaimer in the
|
|
|
|
** documentation and/or other materials provided with the distribution.
|
|
|
|
** 3. The name of the author may not be used to endorse or promote products
|
|
|
|
** derived from this software without specific prior written permission.
|
|
|
|
**
|
|
|
|
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
**---------------------------------------------------------------------------
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stddef.h>
|
|
|
|
|
|
|
|
#include "templates.h"
|
|
|
|
#include "r_draw.h"
|
2008-09-15 14:11:05 +00:00
|
|
|
#include "r_main.h"
|
2007-12-26 16:06:03 +00:00
|
|
|
#include "r_translate.h"
|
|
|
|
#include "v_video.h"
|
|
|
|
#include "g_game.h"
|
2008-09-14 23:54:38 +00:00
|
|
|
#include "colormatcher.h"
|
2008-09-15 00:47:31 +00:00
|
|
|
#include "d_netinf.h"
|
2008-09-15 14:11:05 +00:00
|
|
|
#include "v_palette.h"
|
2008-09-21 18:02:38 +00:00
|
|
|
#include "sc_man.h"
|
|
|
|
#include "doomerrors.h"
|
|
|
|
#include "i_system.h"
|
2007-12-26 16:06:03 +00:00
|
|
|
|
|
|
|
#include "gi.h"
|
|
|
|
#include "stats.h"
|
|
|
|
|
2008-01-08 01:48:33 +00:00
|
|
|
TAutoGrowArray<FRemapTablePtr, FRemapTable *> translationtables[NUM_TRANSLATION_TABLES];
|
2007-12-26 16:06:03 +00:00
|
|
|
|
2008-04-15 22:17:30 +00:00
|
|
|
const BYTE IcePalette[16][3] =
|
|
|
|
{
|
|
|
|
{ 10, 8, 18 },
|
|
|
|
{ 15, 15, 26 },
|
|
|
|
{ 20, 16, 36 },
|
|
|
|
{ 30, 26, 46 },
|
|
|
|
{ 40, 36, 57 },
|
|
|
|
{ 50, 46, 67 },
|
|
|
|
{ 59, 57, 78 },
|
|
|
|
{ 69, 67, 88 },
|
|
|
|
{ 79, 77, 99 },
|
|
|
|
{ 89, 87,109 },
|
|
|
|
{ 99, 97,120 },
|
|
|
|
{ 109,107,130 },
|
|
|
|
{ 118,118,141 },
|
|
|
|
{ 128,128,151 },
|
|
|
|
{ 138,138,162 },
|
|
|
|
{ 148,148,172 }
|
|
|
|
};
|
|
|
|
|
2007-12-26 16:06:03 +00:00
|
|
|
/****************************************************/
|
|
|
|
/****************************************************/
|
|
|
|
|
|
|
|
FRemapTable::FRemapTable(int count)
|
|
|
|
{
|
|
|
|
assert(count <= 256);
|
|
|
|
|
|
|
|
Alloc(count);
|
|
|
|
|
|
|
|
// Note that the tables are left uninitialized. It is assumed that
|
|
|
|
// the caller will do that next, if only by calling MakeIdentity().
|
|
|
|
}
|
|
|
|
|
2008-09-21 18:02:38 +00:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
2007-12-26 16:06:03 +00:00
|
|
|
FRemapTable::~FRemapTable()
|
|
|
|
{
|
|
|
|
Free();
|
|
|
|
}
|
|
|
|
|
2008-09-21 18:02:38 +00:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
2007-12-26 16:06:03 +00:00
|
|
|
void FRemapTable::Alloc(int count)
|
|
|
|
{
|
|
|
|
Remap = (BYTE *)M_Malloc(count*sizeof(*Remap) + count*sizeof(*Palette));
|
|
|
|
assert (Remap != NULL);
|
|
|
|
Palette = (PalEntry *)(Remap + count*(sizeof(*Remap)));
|
|
|
|
Native = NULL;
|
|
|
|
NumEntries = count;
|
|
|
|
}
|
|
|
|
|
2008-09-21 18:02:38 +00:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
2007-12-26 16:06:03 +00:00
|
|
|
void FRemapTable::Free()
|
|
|
|
{
|
|
|
|
KillNative();
|
|
|
|
if (Remap != NULL)
|
|
|
|
{
|
2008-02-17 02:40:03 +00:00
|
|
|
M_Free(Remap);
|
2007-12-26 16:06:03 +00:00
|
|
|
Remap = NULL;
|
|
|
|
Palette = NULL;
|
|
|
|
NumEntries = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-09-21 18:02:38 +00:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
2007-12-26 16:06:03 +00:00
|
|
|
FRemapTable::FRemapTable(const FRemapTable &o)
|
|
|
|
{
|
|
|
|
Remap = NULL;
|
|
|
|
Native = NULL;
|
|
|
|
NumEntries = 0;
|
|
|
|
operator= (o);
|
|
|
|
}
|
|
|
|
|
2008-09-21 18:02:38 +00:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
2007-12-26 16:06:03 +00:00
|
|
|
FRemapTable &FRemapTable::operator=(const FRemapTable &o)
|
|
|
|
{
|
|
|
|
if (&o == this)
|
|
|
|
{
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
if (o.NumEntries != NumEntries)
|
|
|
|
{
|
|
|
|
Free();
|
|
|
|
}
|
|
|
|
if (Remap == NULL)
|
|
|
|
{
|
|
|
|
Alloc(o.NumEntries);
|
|
|
|
}
|
|
|
|
memcpy(Remap, o.Remap, NumEntries*sizeof(*Remap) + NumEntries*sizeof(*Palette));
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2008-09-21 18:02:38 +00:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
2007-12-26 16:06:03 +00:00
|
|
|
bool FRemapTable::operator==(const FRemapTable &o)
|
|
|
|
{
|
|
|
|
// Two translations are identical when they have the same amount of colors
|
|
|
|
// and the palette values for both are identical.
|
|
|
|
if (&o == this) return true;
|
|
|
|
if (o.NumEntries != NumEntries) return false;
|
|
|
|
return !memcmp(o.Palette, Palette, NumEntries * sizeof(*Palette));
|
|
|
|
}
|
|
|
|
|
2008-09-21 18:02:38 +00:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
2007-12-26 16:06:03 +00:00
|
|
|
void FRemapTable::Serialize(FArchive &arc)
|
|
|
|
{
|
|
|
|
int n = NumEntries;
|
|
|
|
|
|
|
|
arc << NumEntries;
|
|
|
|
if (arc.IsStoring())
|
|
|
|
{
|
|
|
|
arc.Write (Remap, NumEntries);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (n != NumEntries)
|
|
|
|
{
|
|
|
|
Free();
|
|
|
|
Alloc(NumEntries);
|
|
|
|
}
|
|
|
|
arc.Read (Remap, NumEntries);
|
|
|
|
}
|
|
|
|
for (int j = 0; j < NumEntries; ++j)
|
|
|
|
{
|
2008-04-22 18:48:30 +00:00
|
|
|
arc << Palette[j];
|
2007-12-26 16:06:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-09-21 18:02:38 +00:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//----------------------------------------------------------------------------
|
2007-12-26 16:06:03 +00:00
|
|
|
|
|
|
|
void FRemapTable::MakeIdentity()
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < NumEntries; ++i)
|
|
|
|
{
|
|
|
|
Remap[i] = i;
|
|
|
|
}
|
|
|
|
for (i = 0; i < NumEntries; ++i)
|
|
|
|
{
|
|
|
|
Palette[i] = GPalette.BaseColors[i];
|
|
|
|
}
|
2008-04-22 18:48:30 +00:00
|
|
|
for (i = 1; i < NumEntries; ++i)
|
|
|
|
{
|
|
|
|
Palette[i].a = 255;
|
|
|
|
}
|
2007-12-26 16:06:03 +00:00
|
|
|
}
|
|
|
|
|
2008-09-21 18:02:38 +00:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
2007-12-26 16:06:03 +00:00
|
|
|
bool FRemapTable::IsIdentity() const
|
|
|
|
{
|
|
|
|
for (int j = 0; j < 256; ++j)
|
|
|
|
{
|
|
|
|
if (Remap[j] != j)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2008-09-21 18:02:38 +00:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
2007-12-26 16:06:03 +00:00
|
|
|
void FRemapTable::KillNative()
|
|
|
|
{
|
|
|
|
if (Native != NULL)
|
|
|
|
{
|
|
|
|
delete Native;
|
|
|
|
Native = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-09-21 18:02:38 +00:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
2007-12-26 16:06:03 +00:00
|
|
|
void FRemapTable::UpdateNative()
|
|
|
|
{
|
|
|
|
if (Native != NULL)
|
|
|
|
{
|
|
|
|
Native->Update();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-09-21 18:02:38 +00:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
2008-01-10 04:11:38 +00:00
|
|
|
FNativePalette *FRemapTable::GetNative()
|
2007-12-26 16:06:03 +00:00
|
|
|
{
|
|
|
|
if (Native == NULL)
|
|
|
|
{
|
|
|
|
Native = screen->CreatePalette(this);
|
|
|
|
}
|
|
|
|
return Native;
|
|
|
|
}
|
|
|
|
|
2008-09-21 18:02:38 +00:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
2007-12-26 16:06:03 +00:00
|
|
|
void FRemapTable::AddIndexRange(int start, int end, int pal1, int pal2)
|
|
|
|
{
|
|
|
|
fixed_t palcol, palstep;
|
|
|
|
|
|
|
|
if (start > end)
|
|
|
|
{
|
|
|
|
swap (start, end);
|
|
|
|
swap (pal1, pal2);
|
|
|
|
}
|
|
|
|
else if (start == end)
|
|
|
|
{
|
2009-11-26 03:16:54 +00:00
|
|
|
start = GPalette.Remap[start];
|
|
|
|
pal1 = GPalette.Remap[pal1];
|
2007-12-26 16:06:03 +00:00
|
|
|
Remap[start] = pal1;
|
|
|
|
Palette[start] = GPalette.BaseColors[pal1];
|
2009-11-26 03:16:54 +00:00
|
|
|
Palette[start].a = start == 0 ? 0 : 255;
|
2007-12-26 16:06:03 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
palcol = pal1 << FRACBITS;
|
|
|
|
palstep = ((pal2 << FRACBITS) - palcol) / (end - start);
|
|
|
|
for (int i = start; i <= end; palcol += palstep, ++i)
|
|
|
|
{
|
2009-11-26 03:16:54 +00:00
|
|
|
int j = GPalette.Remap[i], k = GPalette.Remap[palcol >> FRACBITS];
|
|
|
|
Remap[j] = k;
|
|
|
|
Palette[j] = GPalette.BaseColors[k];
|
|
|
|
Palette[j].a = j == 0 ? 0 : 255;
|
2007-12-26 16:06:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-09-21 18:02:38 +00:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
2007-12-26 16:06:03 +00:00
|
|
|
void FRemapTable::AddColorRange(int start, int end, int _r1,int _g1, int _b1, int _r2, int _g2, int _b2)
|
|
|
|
{
|
|
|
|
fixed_t r1 = _r1 << FRACBITS;
|
|
|
|
fixed_t g1 = _g1 << FRACBITS;
|
|
|
|
fixed_t b1 = _b1 << FRACBITS;
|
|
|
|
fixed_t r2 = _r2 << FRACBITS;
|
|
|
|
fixed_t g2 = _g2 << FRACBITS;
|
|
|
|
fixed_t b2 = _b2 << FRACBITS;
|
|
|
|
fixed_t r, g, b;
|
|
|
|
fixed_t rs, gs, bs;
|
|
|
|
|
|
|
|
if (start > end)
|
|
|
|
{
|
|
|
|
swap (start, end);
|
|
|
|
r = r2;
|
|
|
|
g = g2;
|
|
|
|
b = b2;
|
|
|
|
rs = r1 - r2;
|
|
|
|
gs = g1 - g2;
|
|
|
|
bs = b1 - b2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
r = r1;
|
|
|
|
g = g1;
|
|
|
|
b = b1;
|
|
|
|
rs = r2 - r1;
|
|
|
|
gs = g2 - g1;
|
|
|
|
bs = b2 - b1;
|
|
|
|
}
|
|
|
|
if (start == end)
|
|
|
|
{
|
2009-11-26 03:16:54 +00:00
|
|
|
start = GPalette.Remap[start];
|
|
|
|
Remap[start] = ColorMatcher.Pick(r >> FRACBITS, g >> FRACBITS, b >> FRACBITS);
|
2007-12-26 16:06:03 +00:00
|
|
|
Palette[start] = PalEntry(r >> FRACBITS, g >> FRACBITS, b >> FRACBITS);
|
2009-11-26 03:16:54 +00:00
|
|
|
Palette[start].a = start == 0 ? 0 : 255;
|
2007-12-26 16:06:03 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
rs /= (end - start);
|
|
|
|
gs /= (end - start);
|
|
|
|
bs /= (end - start);
|
|
|
|
for (int i = start; i <= end; ++i)
|
|
|
|
{
|
2009-11-26 03:16:54 +00:00
|
|
|
int j = GPalette.Remap[i];
|
|
|
|
Remap[j] = ColorMatcher.Pick(r >> FRACBITS, g >> FRACBITS, b >> FRACBITS);
|
|
|
|
Palette[j] = PalEntry(j == 0 ? 0 : 255, r >> FRACBITS, g >> FRACBITS, b >> FRACBITS);
|
2007-12-26 16:06:03 +00:00
|
|
|
r += rs;
|
|
|
|
g += gs;
|
|
|
|
b += bs;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-09-21 18:02:38 +00:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
2009-10-16 16:04:19 +00:00
|
|
|
void FRemapTable::AddDesaturation(int start, int end, float r1,float g1, float b1, float r2, float g2, float b2)
|
|
|
|
{
|
|
|
|
r1 = clamp(r1, 0.0f, 2.0f);
|
|
|
|
g1 = clamp(g1, 0.0f, 2.0f);
|
|
|
|
b1 = clamp(b1, 0.0f, 2.0f);
|
|
|
|
r2 = clamp(r2, 0.0f, 2.0f);
|
|
|
|
g2 = clamp(g2, 0.0f, 2.0f);
|
|
|
|
b2 = clamp(b2, 0.0f, 2.0f);
|
|
|
|
|
|
|
|
r2 -= r1;
|
|
|
|
g2 -= g1;
|
|
|
|
b2 -= b1;
|
|
|
|
r1 *= 255;
|
|
|
|
g1 *= 255;
|
|
|
|
b1 *= 255;
|
|
|
|
|
2009-11-26 03:16:54 +00:00
|
|
|
for(int c = start; c < end; c++)
|
2009-10-16 16:04:19 +00:00
|
|
|
{
|
|
|
|
double intensity = (GPalette.BaseColors[c].r * 77 +
|
|
|
|
GPalette.BaseColors[c].g * 143 +
|
|
|
|
GPalette.BaseColors[c].b * 37) / 256.0;
|
|
|
|
|
|
|
|
PalEntry pe = PalEntry( MIN(255, int(r1 + intensity*r2)),
|
|
|
|
MIN(255, int(g1 + intensity*g2)),
|
|
|
|
MIN(255, int(b1 + intensity*b2)));
|
|
|
|
|
2009-11-26 03:16:54 +00:00
|
|
|
int cc = GPalette.Remap[c];
|
|
|
|
|
|
|
|
Remap[cc] = ColorMatcher.Pick(pe);
|
|
|
|
Palette[cc] = pe;
|
|
|
|
Palette[cc].a = cc == 0 ? 0:255;
|
2009-10-16 16:04:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
2008-09-21 18:02:38 +00:00
|
|
|
void FRemapTable::AddToTranslation(const char * range)
|
|
|
|
{
|
|
|
|
int start,end;
|
2009-10-16 16:04:19 +00:00
|
|
|
bool desaturated = false;
|
2008-09-21 18:02:38 +00:00
|
|
|
FScanner sc;
|
|
|
|
|
|
|
|
sc.OpenMem("translation", range, int(strlen(range)));
|
|
|
|
sc.SetCMode(true);
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
sc.MustGetToken(TK_IntConst);
|
|
|
|
start = sc.Number;
|
|
|
|
sc.MustGetToken(':');
|
|
|
|
sc.MustGetToken(TK_IntConst);
|
|
|
|
end = sc.Number;
|
|
|
|
sc.MustGetToken('=');
|
2009-10-16 16:04:19 +00:00
|
|
|
if (start < 0 || start > 255 || end < 0 || end > 255)
|
|
|
|
{
|
|
|
|
sc.ScriptError("Palette index out of range");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
sc.MustGetAnyToken();
|
|
|
|
|
|
|
|
if (sc.TokenType != '[' && sc.TokenType != '%')
|
2008-09-21 18:02:38 +00:00
|
|
|
{
|
|
|
|
int pal1,pal2;
|
|
|
|
|
2009-10-17 07:05:34 +00:00
|
|
|
sc.TokenMustBe(TK_IntConst);
|
2008-09-21 18:02:38 +00:00
|
|
|
pal1 = sc.Number;
|
|
|
|
sc.MustGetToken(':');
|
|
|
|
sc.MustGetToken(TK_IntConst);
|
|
|
|
pal2 = sc.Number;
|
|
|
|
AddIndexRange(start, end, pal1, pal2);
|
|
|
|
}
|
2009-10-16 16:04:19 +00:00
|
|
|
else if (sc.TokenType == '[')
|
2008-09-21 18:02:38 +00:00
|
|
|
{
|
|
|
|
// translation using RGB values
|
|
|
|
int r1,g1,b1,r2,g2,b2;
|
|
|
|
|
|
|
|
sc.MustGetToken(TK_IntConst);
|
|
|
|
r1 = sc.Number;
|
|
|
|
sc.MustGetToken(',');
|
|
|
|
|
|
|
|
sc.MustGetToken(TK_IntConst);
|
|
|
|
g1 = sc.Number;
|
|
|
|
sc.MustGetToken(',');
|
|
|
|
|
|
|
|
sc.MustGetToken(TK_IntConst);
|
|
|
|
b1 = sc.Number;
|
|
|
|
sc.MustGetToken(']');
|
|
|
|
sc.MustGetToken(':');
|
|
|
|
sc.MustGetToken('[');
|
|
|
|
|
|
|
|
sc.MustGetToken(TK_IntConst);
|
|
|
|
r2 = sc.Number;
|
|
|
|
sc.MustGetToken(',');
|
|
|
|
|
|
|
|
sc.MustGetToken(TK_IntConst);
|
|
|
|
g2 = sc.Number;
|
|
|
|
sc.MustGetToken(',');
|
|
|
|
|
|
|
|
sc.MustGetToken(TK_IntConst);
|
|
|
|
b2 = sc.Number;
|
|
|
|
sc.MustGetToken(']');
|
|
|
|
|
|
|
|
AddColorRange(start, end, r1, g1, b1, r2, g2, b2);
|
|
|
|
}
|
2009-10-16 16:04:19 +00:00
|
|
|
else if (sc.TokenType == '%')
|
|
|
|
{
|
|
|
|
// translation using RGB values
|
|
|
|
float r1,g1,b1,r2,g2,b2;
|
|
|
|
|
|
|
|
sc.MustGetToken('[');
|
|
|
|
sc.MustGetAnyToken();
|
|
|
|
if (sc.TokenType != TK_IntConst) sc.TokenMustBe(TK_FloatConst);
|
|
|
|
r1 = float(sc.Float);
|
|
|
|
sc.MustGetToken(',');
|
|
|
|
|
|
|
|
sc.MustGetAnyToken();
|
|
|
|
if (sc.TokenType != TK_IntConst) sc.TokenMustBe(TK_FloatConst);
|
|
|
|
g1 = float(sc.Float);
|
|
|
|
sc.MustGetToken(',');
|
|
|
|
|
|
|
|
sc.MustGetAnyToken();
|
|
|
|
if (sc.TokenType != TK_IntConst) sc.TokenMustBe(TK_FloatConst);
|
|
|
|
b1 = float(sc.Float);
|
|
|
|
sc.MustGetToken(']');
|
|
|
|
sc.MustGetToken(':');
|
|
|
|
sc.MustGetToken('[');
|
|
|
|
|
|
|
|
sc.MustGetAnyToken();
|
|
|
|
if (sc.TokenType != TK_IntConst) sc.TokenMustBe(TK_FloatConst);
|
|
|
|
r2 = float(sc.Float);
|
|
|
|
sc.MustGetToken(',');
|
|
|
|
|
|
|
|
sc.MustGetAnyToken();
|
|
|
|
if (sc.TokenType != TK_IntConst) sc.TokenMustBe(TK_FloatConst);
|
|
|
|
g2 = float(sc.Float);
|
|
|
|
sc.MustGetToken(',');
|
|
|
|
|
|
|
|
sc.MustGetAnyToken();
|
|
|
|
if (sc.TokenType != TK_IntConst) sc.TokenMustBe(TK_FloatConst);
|
|
|
|
b2 = float(sc.Float);
|
|
|
|
sc.MustGetToken(']');
|
|
|
|
|
|
|
|
AddDesaturation(start, end, r1, g1, b1, r2, g2, b2);
|
|
|
|
}
|
2008-09-21 18:02:38 +00:00
|
|
|
}
|
|
|
|
catch (CRecoverableError &err)
|
|
|
|
{
|
2008-09-27 07:11:38 +00:00
|
|
|
Printf("Error in translation '%s':\n%s\n", range, err.GetMessage());
|
2008-09-21 18:02:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Stores a copy of this translation in the DECORATE translation table
|
|
|
|
//
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
int FRemapTable::StoreTranslation()
|
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
for (i = 0; i < translationtables[TRANSLATION_Decorate].Size(); i++)
|
|
|
|
{
|
|
|
|
if (*this == *translationtables[TRANSLATION_Decorate][i])
|
|
|
|
{
|
|
|
|
// A duplicate of this translation already exists
|
|
|
|
return TRANSLATION(TRANSLATION_Decorate, i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (translationtables[TRANSLATION_Decorate].Size() >= MAX_DECORATE_TRANSLATIONS)
|
|
|
|
{
|
|
|
|
I_Error("Too many DECORATE translations");
|
|
|
|
}
|
|
|
|
FRemapTable *newtrans = new FRemapTable;
|
|
|
|
*newtrans = *this;
|
|
|
|
i = translationtables[TRANSLATION_Decorate].Push(newtrans);
|
|
|
|
return TRANSLATION(TRANSLATION_Decorate, i);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
TArray<PalEntry> BloodTranslationColors;
|
|
|
|
|
|
|
|
int CreateBloodTranslation(PalEntry color)
|
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
if (BloodTranslationColors.Size() == 0)
|
|
|
|
{
|
|
|
|
// Don't use the first slot.
|
|
|
|
translationtables[TRANSLATION_Blood].Push(NULL);
|
|
|
|
BloodTranslationColors.Push(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 1; i < BloodTranslationColors.Size(); i++)
|
|
|
|
{
|
|
|
|
if (color.r == BloodTranslationColors[i].r &&
|
|
|
|
color.g == BloodTranslationColors[i].g &&
|
|
|
|
color.b == BloodTranslationColors[i].b)
|
|
|
|
{
|
|
|
|
// A duplicate of this translation already exists
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (BloodTranslationColors.Size() >= MAX_DECORATE_TRANSLATIONS)
|
|
|
|
{
|
|
|
|
I_Error("Too many blood colors");
|
|
|
|
}
|
|
|
|
FRemapTable *trans = new FRemapTable;
|
|
|
|
for (i = 0; i < 256; i++)
|
|
|
|
{
|
|
|
|
int bright = MAX(MAX(GPalette.BaseColors[i].r, GPalette.BaseColors[i].g), GPalette.BaseColors[i].b);
|
|
|
|
PalEntry pe = PalEntry(color.r*bright/255, color.g*bright/255, color.b*bright/255);
|
|
|
|
int entry = ColorMatcher.Pick(pe.r, pe.g, pe.b);
|
|
|
|
|
|
|
|
trans->Palette[i] = pe;
|
|
|
|
trans->Remap[i] = entry;
|
|
|
|
}
|
|
|
|
translationtables[TRANSLATION_Blood].Push(trans);
|
|
|
|
return BloodTranslationColors.Push(color);
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//----------------------------------------------------------------------------
|
2007-12-26 16:06:03 +00:00
|
|
|
|
|
|
|
FRemapTable *TranslationToTable(int translation)
|
|
|
|
{
|
|
|
|
unsigned int type = GetTranslationType(translation);
|
|
|
|
unsigned int index = GetTranslationIndex(translation);
|
2008-01-08 01:48:33 +00:00
|
|
|
TAutoGrowArray<FRemapTablePtr, FRemapTable *> *slots;
|
2007-12-26 16:06:03 +00:00
|
|
|
|
|
|
|
if (type <= 0 || type >= NUM_TRANSLATION_TABLES)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
slots = &translationtables[type];
|
|
|
|
if (index >= slots->Size())
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return slots->operator[](index);
|
|
|
|
}
|
|
|
|
|
2008-09-21 18:02:38 +00:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
2007-12-26 16:06:03 +00:00
|
|
|
static void PushIdentityTable(int slot)
|
|
|
|
{
|
|
|
|
FRemapTable *table = new FRemapTable;
|
|
|
|
table->MakeIdentity();
|
|
|
|
translationtables[slot].Push(table);
|
|
|
|
}
|
|
|
|
|
2008-09-21 18:02:38 +00:00
|
|
|
//----------------------------------------------------------------------------
|
2007-12-26 16:06:03 +00:00
|
|
|
//
|
|
|
|
// R_InitTranslationTables
|
|
|
|
// Creates the translation tables to map the green color ramp to gray,
|
|
|
|
// brown, red. Assumes a given structure of the PLAYPAL.
|
|
|
|
//
|
2008-09-21 18:02:38 +00:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
2007-12-26 16:06:03 +00:00
|
|
|
void R_InitTranslationTables ()
|
|
|
|
{
|
|
|
|
int i, j;
|
|
|
|
|
|
|
|
// Each player gets two translations. Doom and Strife don't use the
|
|
|
|
// extra ones, but Heretic and Hexen do. These are set up during
|
|
|
|
// netgame arbitration and as-needed, so they just get to be identity
|
|
|
|
// maps until then so they won't be invalid.
|
|
|
|
for (i = 0; i < MAXPLAYERS; ++i)
|
|
|
|
{
|
|
|
|
PushIdentityTable(TRANSLATION_Players);
|
|
|
|
PushIdentityTable(TRANSLATION_PlayersExtra);
|
|
|
|
}
|
|
|
|
// The menu player also gets a separate translation table
|
|
|
|
PushIdentityTable(TRANSLATION_Players);
|
|
|
|
|
|
|
|
// The three standard translations from Doom or Heretic (seven for Strife),
|
|
|
|
// plus the generic ice translation.
|
|
|
|
for (i = 0; i < 8; ++i)
|
|
|
|
{
|
|
|
|
PushIdentityTable(TRANSLATION_Standard);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Each player corpse has its own translation so they won't change
|
|
|
|
// color if the player who created them changes theirs.
|
|
|
|
for (i = 0; i < BODYQUESIZE; ++i)
|
|
|
|
{
|
|
|
|
PushIdentityTable(TRANSLATION_PlayerCorpses);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create the standard translation tables
|
2008-08-30 19:44:19 +00:00
|
|
|
if (gameinfo.gametype & GAME_DoomChex)
|
2007-12-26 16:06:03 +00:00
|
|
|
{
|
|
|
|
for (i = 0x70; i < 0x80; i++)
|
|
|
|
{ // map green ramp to gray, brown, red
|
|
|
|
translationtables[TRANSLATION_Standard][0]->Remap[i] = 0x60 + (i&0xf);
|
|
|
|
translationtables[TRANSLATION_Standard][1]->Remap[i] = 0x40 + (i&0xf);
|
|
|
|
translationtables[TRANSLATION_Standard][2]->Remap[i] = 0x20 + (i&0xf);
|
|
|
|
|
2008-05-20 04:02:49 +00:00
|
|
|
translationtables[TRANSLATION_Standard][0]->Palette[i] = GPalette.BaseColors[0x60 + (i&0xf)] | MAKEARGB(255,0,0,0);
|
|
|
|
translationtables[TRANSLATION_Standard][1]->Palette[i] = GPalette.BaseColors[0x40 + (i&0xf)] | MAKEARGB(255,0,0,0);
|
|
|
|
translationtables[TRANSLATION_Standard][2]->Palette[i] = GPalette.BaseColors[0x20 + (i&0xf)] | MAKEARGB(255,0,0,0);
|
2007-12-26 16:06:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (gameinfo.gametype == GAME_Heretic)
|
|
|
|
{
|
|
|
|
for (i = 225; i <= 240; i++)
|
|
|
|
{
|
|
|
|
translationtables[TRANSLATION_Standard][0]->Remap[i] = 114+(i-225); // yellow
|
|
|
|
translationtables[TRANSLATION_Standard][1]->Remap[i] = 145+(i-225); // red
|
|
|
|
translationtables[TRANSLATION_Standard][2]->Remap[i] = 190+(i-225); // blue
|
|
|
|
|
2008-05-20 04:02:49 +00:00
|
|
|
translationtables[TRANSLATION_Standard][0]->Palette[i] = GPalette.BaseColors[114+(i-225)] | MAKEARGB(255,0,0,0);
|
|
|
|
translationtables[TRANSLATION_Standard][1]->Palette[i] = GPalette.BaseColors[145+(i-225)] | MAKEARGB(255,0,0,0);
|
|
|
|
translationtables[TRANSLATION_Standard][2]->Palette[i] = GPalette.BaseColors[190+(i-225)] | MAKEARGB(255,0,0,0);
|
2007-12-26 16:06:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (gameinfo.gametype == GAME_Strife)
|
|
|
|
{
|
|
|
|
for (i = 0x20; i <= 0x3F; ++i)
|
|
|
|
{
|
|
|
|
translationtables[TRANSLATION_Standard][0]->Remap[i] = i - 0x20;
|
|
|
|
translationtables[TRANSLATION_Standard][1]->Remap[i] = i - 0x20;
|
|
|
|
translationtables[TRANSLATION_Standard][2]->Remap[i] = 0xD0 + (i&0xf);
|
|
|
|
translationtables[TRANSLATION_Standard][3]->Remap[i] = 0xD0 + (i&0xf);
|
|
|
|
translationtables[TRANSLATION_Standard][4]->Remap[i] = i - 0x20;
|
|
|
|
translationtables[TRANSLATION_Standard][5]->Remap[i] = i - 0x20;
|
|
|
|
translationtables[TRANSLATION_Standard][6]->Remap[i] = i - 0x20;
|
|
|
|
}
|
|
|
|
for (i = 0x50; i <= 0x5F; ++i)
|
|
|
|
{
|
|
|
|
// Merchant hair
|
|
|
|
translationtables[TRANSLATION_Standard][4]->Remap[i] = 0x80 + (i&0xf);
|
|
|
|
translationtables[TRANSLATION_Standard][5]->Remap[i] = 0x10 + (i&0xf);
|
|
|
|
translationtables[TRANSLATION_Standard][6]->Remap[i] = 0x40 + (i&0xf);
|
|
|
|
}
|
|
|
|
for (i = 0x80; i <= 0x8F; ++i)
|
|
|
|
{
|
|
|
|
translationtables[TRANSLATION_Standard][0]->Remap[i] = 0x40 + (i&0xf); // red
|
|
|
|
translationtables[TRANSLATION_Standard][1]->Remap[i] = 0xB0 + (i&0xf); // rust
|
|
|
|
translationtables[TRANSLATION_Standard][2]->Remap[i] = 0x10 + (i&0xf); // gray
|
|
|
|
translationtables[TRANSLATION_Standard][3]->Remap[i] = 0x30 + (i&0xf); // dark green
|
|
|
|
translationtables[TRANSLATION_Standard][4]->Remap[i] = 0x50 + (i&0xf); // gold
|
|
|
|
translationtables[TRANSLATION_Standard][5]->Remap[i] = 0x60 + (i&0xf); // bright green
|
|
|
|
translationtables[TRANSLATION_Standard][6]->Remap[i] = 0x90 + (i&0xf); // blue
|
|
|
|
}
|
|
|
|
for (i = 0xC0; i <= 0xCF; ++i)
|
|
|
|
{
|
|
|
|
translationtables[TRANSLATION_Standard][4]->Remap[i] = 0xA0 + (i&0xf);
|
|
|
|
translationtables[TRANSLATION_Standard][5]->Remap[i] = 0x20 + (i&0xf);
|
|
|
|
translationtables[TRANSLATION_Standard][6]->Remap[i] = (i&0xf);
|
|
|
|
}
|
|
|
|
translationtables[TRANSLATION_Standard][6]->Remap[0xC0] = 1;
|
|
|
|
for (i = 0xD0; i <= 0xDF; ++i)
|
|
|
|
{
|
|
|
|
translationtables[TRANSLATION_Standard][4]->Remap[i] = 0xB0 + (i&0xf);
|
|
|
|
translationtables[TRANSLATION_Standard][5]->Remap[i] = 0x30 + (i&0xf);
|
|
|
|
translationtables[TRANSLATION_Standard][6]->Remap[i] = 0x10 + (i&0xf);
|
|
|
|
}
|
|
|
|
for (i = 0xF1; i <= 0xF6; ++i)
|
|
|
|
{
|
|
|
|
translationtables[TRANSLATION_Standard][0]->Remap[i] = 0xDF + (i&0xf);
|
|
|
|
}
|
|
|
|
for (i = 0xF7; i <= 0xFB; ++i)
|
|
|
|
{
|
|
|
|
translationtables[TRANSLATION_Standard][0]->Remap[i] = i - 6;
|
|
|
|
}
|
|
|
|
for (i = 0; i < 7; ++i)
|
|
|
|
{
|
|
|
|
for (int j = 0x20; j <= 0xFB; ++j)
|
|
|
|
{
|
|
|
|
translationtables[TRANSLATION_Standard][i]->Palette[j] =
|
2008-05-20 04:02:49 +00:00
|
|
|
GPalette.BaseColors[translationtables[TRANSLATION_Standard][i]->Remap[j]] | MAKEARGB(255,0,0,0);
|
2007-12-26 16:06:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create the ice translation table, based on Hexen's. Alas, the standard
|
|
|
|
// Doom palette has no good substitutes for these bluish-tinted grays, so
|
|
|
|
// they will just look gray unless you use a different PLAYPAL with Doom.
|
|
|
|
|
|
|
|
BYTE IcePaletteRemap[16];
|
|
|
|
for (i = 0; i < 16; ++i)
|
|
|
|
{
|
|
|
|
IcePaletteRemap[i] = ColorMatcher.Pick (IcePalette[i][0], IcePalette[i][1], IcePalette[i][2]);
|
|
|
|
}
|
|
|
|
FRemapTable *remap = translationtables[TRANSLATION_Standard][7];
|
|
|
|
for (i = 0; i < 256; ++i)
|
|
|
|
{
|
|
|
|
int r = GPalette.BaseColors[i].r;
|
|
|
|
int g = GPalette.BaseColors[i].g;
|
|
|
|
int b = GPalette.BaseColors[i].b;
|
|
|
|
int v = (r*77 + g*143 + b*37) >> 12;
|
|
|
|
remap->Remap[i] = IcePaletteRemap[v];
|
2008-05-20 04:02:49 +00:00
|
|
|
remap->Palette[i] = PalEntry(255, IcePalette[v][0], IcePalette[v][1], IcePalette[v][2]);
|
2007-12-26 16:06:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// set up shading tables for shaded columns
|
|
|
|
// 16 colormap sets, progressing from full alpha to minimum visible alpha
|
|
|
|
|
|
|
|
BYTE *table = shadetables;
|
|
|
|
|
|
|
|
// Full alpha
|
|
|
|
for (i = 0; i < 16; ++i)
|
|
|
|
{
|
2009-09-01 02:08:53 +00:00
|
|
|
ShadeFakeColormap[i].Color = ~0u;
|
|
|
|
ShadeFakeColormap[i].Desaturate = ~0u;
|
- Updated lempar.c to v1.31.
- Added .txt files to the list of types (wad, zip, and pk3) that can be
loaded without listing them after -file.
- Fonts that are created by the ACS setfont command to wrap a texture now
support animated textures.
- FON2 fonts can now use their full palette for CR_UNTRANSLATED when drawn
with the hardware 2D path instead of being restricted to the game palette.
- Fixed: Toggling vid_vsync would reset the displayed fullscreen gamma to 1
on a Radeon 9000.
- Added back the off-by-one palette handling, but in a much more limited
scope than before. The skipped entry is assumed to always be at 248, and
it is assumed that all Shader Model 1.4 cards suffer from this. That's
because all SM1.4 cards are based on variants of the ATI R200 core, and the
RV250 in a Radeon 9000 craps up like this. I see no reason to assume that
other flavors of the R200 are any different. (Interesting note: With the
Radeon 9000, D3DTADDRESS_CLAMP is an invalid address mode when using the
debug Direct3D 9 runtime, but it works perfectly fine with the retail
Direct3D 9 runtime.) (Insight: The R200 probably uses bytes for all its
math inside pixel shaders. That would explain perfectly why I can't use
constants greater than 1 with PS1.4 and why it can't do an exact mapping to
every entry in the color palette.
- Fixed: The software shaded drawer did not work for 2D, because its selected
"color"map was replaced with the identitymap before being used.
- Fixed: I cannot use Printf to output messages before the framebuffer was
completely setup, meaning that Shader Model 1.4 cards could not change
resolution.
- I have decided to let remap palettes specify variable alpha values for
their colors. D3DFB no longer forces them to 255.
- Updated re2c to version 0.12.3.
- Fixed: A_Wander used threshold as a timer, when it should have used
reactiontime.
- Fixed: A_CustomRailgun would not fire at all for actors without a target
when the aim parameter was disabled.
- Made the warp command work in multiplayer, again courtesy of Karate Chris.
- Fixed: Trying to spawn a bot while not in a game made for a crashing time.
(Patch courtesy of Karate Chris.)
- Removed some floating point math from hu_scores.cpp that somebody's GCC
gave warnings for (not mine, though).
- Fixed: The SBarInfo drawbar command crashed if the sprite image was
unavailable.
- Fixed: FString::operator=(const char *) did not release its old buffer when
being assigned to the null string.
- The scanner no longer has an upper limit on the length of strings it
accepts, though short strings will be faster than long ones.
- Moved all the text scanning functions into a class. Mainly, this means that
multiple script scanner states can be stored without being forced to do so
recursively. I think I might be taking advantage of that in the near
future. Possibly. Maybe.
- Removed some potential buffer overflows from the decal parser.
- Applied Blzut3's SBARINFO update #9:
* Fixed: When using even length values in drawnumber it would cap to a 98
value instead of a 99 as intended.
* The SBarInfo parser can now accept negatives for coordinates. This
doesn't allow much right now, but later I plan to add better fullscreen
hud support in which the negatives will be more useful. This also cleans
up the source a bit since all calls for (x, y) coordinates are with the
function getCoordinates().
- Added support for stencilling actors.
- Added support for non-black colors specified with DTA_ColorOverlay to the
software renderer.
- Fixed: The inverse, gold, red, and green fixed colormaps each allocated
space for 32 different colormaps, even though each only used the first one.
- Added two new blending flags to make reverse subtract blending more useful:
STYLEF_InvertSource and STYLEF_InvertOverlay. These invert the color that
gets blended with the background, since that seems like a good idea for
reverse subtraction. They also work with the other two blending operations.
- Added subtract and reverse subtract blending operations to the renderer.
Since the ERenderStyle enumeration was getting rather unwieldy, I converted
it into a new FRenderStyle structure that lets each parameter of the
blending equation be set separately. This simplified the set up for the
blend quite a bit, and it means a number of new combinations are available
by setting the parameters properly.
SVN r710 (trunk)
2008-01-25 23:57:44 +00:00
|
|
|
ShadeFakeColormap[i].Next = NULL;
|
|
|
|
ShadeFakeColormap[i].Maps = table;
|
|
|
|
|
2007-12-26 16:06:03 +00:00
|
|
|
for (j = 0; j < NUMCOLORMAPS; ++j)
|
|
|
|
{
|
|
|
|
int a = (NUMCOLORMAPS - j) * 256 / NUMCOLORMAPS * (16-i);
|
|
|
|
for (int k = 0; k < 256; ++k)
|
|
|
|
{
|
|
|
|
BYTE v = (((k+2) * a) + 256) >> 14;
|
|
|
|
table[k] = MIN<BYTE> (v, 64);
|
|
|
|
}
|
|
|
|
table += 256;
|
|
|
|
}
|
|
|
|
}
|
- Updated lempar.c to v1.31.
- Added .txt files to the list of types (wad, zip, and pk3) that can be
loaded without listing them after -file.
- Fonts that are created by the ACS setfont command to wrap a texture now
support animated textures.
- FON2 fonts can now use their full palette for CR_UNTRANSLATED when drawn
with the hardware 2D path instead of being restricted to the game palette.
- Fixed: Toggling vid_vsync would reset the displayed fullscreen gamma to 1
on a Radeon 9000.
- Added back the off-by-one palette handling, but in a much more limited
scope than before. The skipped entry is assumed to always be at 248, and
it is assumed that all Shader Model 1.4 cards suffer from this. That's
because all SM1.4 cards are based on variants of the ATI R200 core, and the
RV250 in a Radeon 9000 craps up like this. I see no reason to assume that
other flavors of the R200 are any different. (Interesting note: With the
Radeon 9000, D3DTADDRESS_CLAMP is an invalid address mode when using the
debug Direct3D 9 runtime, but it works perfectly fine with the retail
Direct3D 9 runtime.) (Insight: The R200 probably uses bytes for all its
math inside pixel shaders. That would explain perfectly why I can't use
constants greater than 1 with PS1.4 and why it can't do an exact mapping to
every entry in the color palette.
- Fixed: The software shaded drawer did not work for 2D, because its selected
"color"map was replaced with the identitymap before being used.
- Fixed: I cannot use Printf to output messages before the framebuffer was
completely setup, meaning that Shader Model 1.4 cards could not change
resolution.
- I have decided to let remap palettes specify variable alpha values for
their colors. D3DFB no longer forces them to 255.
- Updated re2c to version 0.12.3.
- Fixed: A_Wander used threshold as a timer, when it should have used
reactiontime.
- Fixed: A_CustomRailgun would not fire at all for actors without a target
when the aim parameter was disabled.
- Made the warp command work in multiplayer, again courtesy of Karate Chris.
- Fixed: Trying to spawn a bot while not in a game made for a crashing time.
(Patch courtesy of Karate Chris.)
- Removed some floating point math from hu_scores.cpp that somebody's GCC
gave warnings for (not mine, though).
- Fixed: The SBarInfo drawbar command crashed if the sprite image was
unavailable.
- Fixed: FString::operator=(const char *) did not release its old buffer when
being assigned to the null string.
- The scanner no longer has an upper limit on the length of strings it
accepts, though short strings will be faster than long ones.
- Moved all the text scanning functions into a class. Mainly, this means that
multiple script scanner states can be stored without being forced to do so
recursively. I think I might be taking advantage of that in the near
future. Possibly. Maybe.
- Removed some potential buffer overflows from the decal parser.
- Applied Blzut3's SBARINFO update #9:
* Fixed: When using even length values in drawnumber it would cap to a 98
value instead of a 99 as intended.
* The SBarInfo parser can now accept negatives for coordinates. This
doesn't allow much right now, but later I plan to add better fullscreen
hud support in which the negatives will be more useful. This also cleans
up the source a bit since all calls for (x, y) coordinates are with the
function getCoordinates().
- Added support for stencilling actors.
- Added support for non-black colors specified with DTA_ColorOverlay to the
software renderer.
- Fixed: The inverse, gold, red, and green fixed colormaps each allocated
space for 32 different colormaps, even though each only used the first one.
- Added two new blending flags to make reverse subtract blending more useful:
STYLEF_InvertSource and STYLEF_InvertOverlay. These invert the color that
gets blended with the background, since that seems like a good idea for
reverse subtraction. They also work with the other two blending operations.
- Added subtract and reverse subtract blending operations to the renderer.
Since the ERenderStyle enumeration was getting rather unwieldy, I converted
it into a new FRenderStyle structure that lets each parameter of the
blending equation be set separately. This simplified the set up for the
blend quite a bit, and it means a number of new combinations are available
by setting the parameters properly.
SVN r710 (trunk)
2008-01-25 23:57:44 +00:00
|
|
|
for (i = 0; i < NUMCOLORMAPS*16*256; ++i)
|
|
|
|
{
|
|
|
|
assert(shadetables[i] <= 64);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set up a guaranteed identity map
|
|
|
|
for (i = 0; i < 256; ++i)
|
|
|
|
{
|
|
|
|
identitymap[i] = i;
|
|
|
|
}
|
2007-12-26 16:06:03 +00:00
|
|
|
}
|
|
|
|
|
2008-09-21 18:02:38 +00:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
2007-12-26 16:06:03 +00:00
|
|
|
void R_DeinitTranslationTables()
|
|
|
|
{
|
|
|
|
for (int i = 0; i < NUM_TRANSLATION_TABLES; ++i)
|
|
|
|
{
|
|
|
|
for (unsigned int j = 0; j < translationtables[i].Size(); ++j)
|
|
|
|
{
|
|
|
|
if (translationtables[i][j] != NULL)
|
|
|
|
{
|
|
|
|
delete translationtables[i][j];
|
|
|
|
translationtables[i][j] = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-09-21 18:02:38 +00:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
//
|
2007-12-26 16:06:03 +00:00
|
|
|
// [RH] Create a player's translation table based on a given mid-range color.
|
|
|
|
// [GRB] Split to 2 functions (because of player setup menu)
|
2008-09-21 18:02:38 +00:00
|
|
|
//
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
2007-12-26 16:06:03 +00:00
|
|
|
static void SetRemap(FRemapTable *table, int i, float r, float g, float b)
|
|
|
|
{
|
|
|
|
int ir = clamp (int(r * 255.f), 0, 255);
|
|
|
|
int ig = clamp (int(g * 255.f), 0, 255);
|
|
|
|
int ib = clamp (int(b * 255.f), 0, 255);
|
|
|
|
table->Remap[i] = ColorMatcher.Pick (ir, ig, ib);
|
2008-05-20 04:02:49 +00:00
|
|
|
table->Palette[i] = PalEntry(255, ir, ig, ib);
|
2007-12-26 16:06:03 +00:00
|
|
|
}
|
|
|
|
|
2008-09-21 18:02:38 +00:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
2007-12-26 16:06:03 +00:00
|
|
|
static void R_CreatePlayerTranslation (float h, float s, float v, FPlayerSkin *skin, FRemapTable *table, FRemapTable *alttable)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
BYTE start = skin->range0start;
|
|
|
|
BYTE end = skin->range0end;
|
|
|
|
float r, g, b;
|
|
|
|
float bases, basev;
|
|
|
|
float sdelta, vdelta;
|
|
|
|
float range;
|
|
|
|
|
|
|
|
// Set up the base translation for this skin. If the skin was created
|
|
|
|
// for the current game, then this is just an identity translation.
|
|
|
|
// Otherwise, it remaps the colors from the skin's original palette to
|
|
|
|
// the current one.
|
|
|
|
if (skin->othergame)
|
|
|
|
{
|
2009-09-05 03:55:29 +00:00
|
|
|
memcpy (table->Remap, OtherGameSkinRemap, table->NumEntries);
|
|
|
|
memcpy (table->Palette, OtherGameSkinPalette, sizeof(*table->Palette) * table->NumEntries);
|
2007-12-26 16:06:03 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-09-05 03:55:29 +00:00
|
|
|
for (i = 0; i < table->NumEntries; ++i)
|
2007-12-26 16:06:03 +00:00
|
|
|
{
|
|
|
|
table->Remap[i] = i;
|
|
|
|
}
|
2009-09-05 03:55:29 +00:00
|
|
|
memcpy(table->Palette, GPalette.BaseColors, sizeof(*table->Palette) * table->NumEntries);
|
2007-12-26 16:06:03 +00:00
|
|
|
}
|
2009-09-05 03:55:29 +00:00
|
|
|
for (i = 1; i < table->NumEntries; ++i)
|
2008-05-20 04:02:49 +00:00
|
|
|
{
|
|
|
|
table->Palette[i].a = 255;
|
|
|
|
}
|
2007-12-26 16:06:03 +00:00
|
|
|
|
|
|
|
// [GRB] Don't translate skins with color range 0-0 (APlayerPawn default)
|
|
|
|
if (start == 0 && end == 0)
|
|
|
|
{
|
|
|
|
table->UpdateNative();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
range = (float)(end-start+1);
|
|
|
|
|
|
|
|
bases = s;
|
|
|
|
basev = v;
|
|
|
|
|
2008-08-30 19:44:19 +00:00
|
|
|
if (gameinfo.gametype & GAME_DoomStrifeChex)
|
2007-12-26 16:06:03 +00:00
|
|
|
{
|
|
|
|
// Build player sprite translation
|
|
|
|
s -= 0.23f;
|
|
|
|
v += 0.1f;
|
|
|
|
sdelta = 0.23f / range;
|
|
|
|
vdelta = -0.94112f / range;
|
|
|
|
|
|
|
|
for (i = start; i <= end; i++)
|
|
|
|
{
|
|
|
|
float uses, usev;
|
|
|
|
uses = clamp (s, 0.f, 1.f);
|
|
|
|
usev = clamp (v, 0.f, 1.f);
|
|
|
|
HSVtoRGB (&r, &g, &b, h, uses, usev);
|
|
|
|
SetRemap(table, i, r, g, b);
|
|
|
|
s += sdelta;
|
|
|
|
v += vdelta;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (gameinfo.gametype == GAME_Heretic)
|
|
|
|
{
|
|
|
|
float vdelta = 0.418916f / range;
|
|
|
|
|
|
|
|
// Build player sprite translation
|
|
|
|
for (i = start; i <= end; i++)
|
|
|
|
{
|
|
|
|
v = vdelta * (float)(i - start) + basev - 0.2352937f;
|
|
|
|
v = clamp (v, 0.f, 1.f);
|
|
|
|
HSVtoRGB (&r, &g, &b, h, s, v);
|
|
|
|
SetRemap(table, i, r, g, b);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Build rain/lifegem translation
|
|
|
|
if (alttable)
|
|
|
|
{
|
|
|
|
bases = MIN (bases*1.3f, 1.f);
|
|
|
|
basev = MIN (basev*1.3f, 1.f);
|
|
|
|
for (i = 145; i <= 168; i++)
|
|
|
|
{
|
|
|
|
s = MIN (bases, 0.8965f - 0.0962f*(float)(i - 161));
|
|
|
|
v = MIN (1.f, (0.2102f + 0.0489f*(float)(i - 144)) * basev);
|
|
|
|
HSVtoRGB (&r, &g, &b, h, s, v);
|
|
|
|
SetRemap(alttable, i, r, g, b);
|
|
|
|
}
|
|
|
|
alttable->UpdateNative();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (gameinfo.gametype == GAME_Hexen)
|
|
|
|
{
|
|
|
|
if (memcmp (sprites[skin->sprite].name, "PLAY", 4) == 0)
|
|
|
|
{ // The fighter is different! He gets a brown hairy loincloth, but the other
|
|
|
|
// two have blue capes.
|
|
|
|
float vs[9] = { .28f, .32f, .38f, .42f, .47f, .5f, .58f, .71f, .83f };
|
|
|
|
|
|
|
|
// Build player sprite translation
|
|
|
|
//h = 45.f;
|
|
|
|
v = MAX (0.1f, v);
|
|
|
|
|
|
|
|
for (i = start; i <= end; i++)
|
|
|
|
{
|
|
|
|
HSVtoRGB (&r, &g, &b, h, s, vs[(i-start)*9/(int)range]*basev);
|
|
|
|
SetRemap(table, i, r, g, b);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
float ms[18] = { .95f, .96f, .89f, .97f, .97f, 1.f, 1.f, 1.f, .97f, .99f, .87f, .77f, .69f, .62f, .57f, .47f, .43f };
|
|
|
|
float mv[18] = { .16f, .19f, .22f, .25f, .31f, .35f, .38f, .41f, .47f, .54f, .60f, .65f, .71f, .77f, .83f, .89f, .94f, 1.f };
|
|
|
|
|
|
|
|
// Build player sprite translation
|
|
|
|
v = MAX (0.1f, v);
|
|
|
|
|
|
|
|
for (i = start; i <= end; i++)
|
|
|
|
{
|
|
|
|
HSVtoRGB (&r, &g, &b, h, ms[(i-start)*18/(int)range]*bases, mv[(i-start)*18/(int)range]*basev);
|
|
|
|
SetRemap(table, i, r, g, b);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Build lifegem translation
|
|
|
|
if (alttable)
|
|
|
|
{
|
|
|
|
for (i = 164; i <= 185; ++i)
|
|
|
|
{
|
|
|
|
const PalEntry *base = &GPalette.BaseColors[i];
|
|
|
|
float dummy;
|
|
|
|
|
|
|
|
RGBtoHSV (base->r/255.f, base->g/255.f, base->b/255.f, &dummy, &s, &v);
|
|
|
|
HSVtoRGB (&r, &g, &b, h, s*bases, v*basev);
|
|
|
|
SetRemap(alttable, i, r, g, b);
|
|
|
|
}
|
|
|
|
alttable->UpdateNative();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
table->UpdateNative();
|
|
|
|
}
|
|
|
|
|
2008-09-21 18:02:38 +00:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
2007-12-26 16:06:03 +00:00
|
|
|
void R_BuildPlayerTranslation (int player)
|
|
|
|
{
|
|
|
|
float h, s, v;
|
|
|
|
|
|
|
|
D_GetPlayerColor (player, &h, &s, &v);
|
|
|
|
|
|
|
|
R_CreatePlayerTranslation (h, s, v,
|
|
|
|
&skins[players[player].userinfo.skin],
|
|
|
|
translationtables[TRANSLATION_Players][player],
|
|
|
|
translationtables[TRANSLATION_PlayersExtra][player]);
|
|
|
|
}
|
|
|
|
|
2008-09-21 18:02:38 +00:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
2007-12-26 16:06:03 +00:00
|
|
|
void R_GetPlayerTranslation (int color, FPlayerSkin *skin, FRemapTable *table)
|
|
|
|
{
|
|
|
|
float h, s, v;
|
|
|
|
|
|
|
|
RGBtoHSV (RPART(color)/255.f, GPART(color)/255.f, BPART(color)/255.f,
|
|
|
|
&h, &s, &v);
|
|
|
|
|
|
|
|
R_CreatePlayerTranslation (h, s, v, skin, table, NULL);
|
|
|
|
}
|
2008-09-21 18:02:38 +00:00
|
|
|
|