- Backported GZDoom's true color font mappings for use with native textures

when the time comes.


SVN r626 (trunk)
This commit is contained in:
Christoph Oelckers 2007-12-23 16:53:39 +00:00
parent 1791acfb56
commit 154e21d9e7
4 changed files with 40 additions and 5 deletions

View file

@ -1,4 +1,6 @@
December 23, 2007 (Changes by Graf Zahl)
- Backported GZDoom's true color font mappings for use with native textures
when the time comes.
- Added Karate Chris's 'sv_doubleammo' submission.
- Added Karate Chris's 'Take' console command submission.
- Changed DTA_Translation parameter for DrawTexture to an integer to avoid

View file

@ -1254,7 +1254,7 @@ static void ConfirmIsAGo ()
//
// Set some stuff up for the video modes menu
//
static BYTE BitTranslate[16];
static BYTE BitTranslate[32];
void M_OptInit (void)
{

View file

@ -252,6 +252,7 @@ FFont::FFont (const char *name, const char *nametemplate, int first, int count,
charlumps = new int[count];
PatchRemap = new BYTE[256];
Ranges = NULL;
PalRanges = NULL;
FirstChar = first;
LastChar = first + count - 1;
FontHeight = 0;
@ -354,6 +355,11 @@ FFont::~FFont ()
delete[] Ranges;
Ranges = NULL;
}
if (PalRanges)
{
delete[] PalRanges;
PalRanges = NULL;
}
if (PatchRemap)
{
delete[] PatchRemap;
@ -539,8 +545,11 @@ void FFont::BuildTranslations (const double *luminosity, const BYTE *identity, c
int i, j;
const TranslationParm *parmstart = (const TranslationParm *)ranges;
BYTE *range;
PalEntry *prange;
range = Ranges = new BYTE[NumTextColors * ActiveColors];
// this is padded so that each palette can be treated as if it had 256 colors
prange = PalRanges = new PalEntry[NumTextColors * ActiveColors + 256];
// Create different translations for different color ranges
for (i = 0; i < NumTextColors; i++)
@ -555,6 +564,10 @@ void FFont::BuildTranslations (const double *luminosity, const BYTE *identity, c
{
memcpy (range, Ranges, ActiveColors);
}
for (j = 0; j < ActiveColors; j++)
{
*prange++ = GPalette.BaseColors[range[j]];
}
range += ActiveColors;
continue;
}
@ -562,6 +575,7 @@ void FFont::BuildTranslations (const double *luminosity, const BYTE *identity, c
assert(parmstart->RangeStart >= 0);
*range++ = 0;
*prange++ = PalEntry(0);
for (j = 1; j < ActiveColors; j++)
{
@ -586,6 +600,7 @@ void FFont::BuildTranslations (const double *luminosity, const BYTE *identity, c
g=clamp(g, 0, 255);
b=clamp(b, 0, 255);
*range++ = ColorMatcher.Pick (r, g, b);
*prange++ = PalEntry(r, g, b);
}
// Advance to the next color range.
@ -612,6 +627,16 @@ BYTE *FFont::GetColorTranslation (EColorRange range) const
return Ranges + ActiveColors * range;
}
PalEntry *FFont::GetTranslatedPalette (EColorRange range) const
{
if (ActiveColors == 0)
return NULL;
else if (range >= NumTextColors)
range = CR_UNTRANSLATED;
return PalRanges + ActiveColors * range;
}
//==========================================================================
//
// FFont :: GetChar
@ -1432,18 +1457,24 @@ FSpecialFont::FSpecialFont (const char *name, int first, int count, int *lumplis
{
int factor = 1;
BYTE *oldranges = Ranges;
Ranges = new BYTE[NumTextColors * TotalColors * factor];
PalEntry *oldpranges = PalRanges;
for (i = 0; i < CR_UNTRANSLATED; i++)
Ranges = new BYTE[NumTextColors * TotalColors]; // palette map + true color map + padding
PalRanges = new PalEntry[NumTextColors * TotalColors + 256]; // padded so that each palette can be treated as if it had 256 colors
for (i = 0; i < NumTextColors; i++)
{
memcpy (&Ranges[i * TotalColors * factor], &oldranges[i * ActiveColors * factor], ActiveColors * factor);
memcpy(&Ranges [i * TotalColors], &oldranges [i * ActiveColors], ActiveColors);
memcpy(&PalRanges[i * TotalColors], &oldpranges[i * ActiveColors], ActiveColors*sizeof(PalEntry));
for(j=ActiveColors;j<TotalColors;j++)
{
Ranges[TotalColors*i + j] = identity[j];
PalRanges[TotalColors*i + j] = GPalette.BaseColors[identity[j]];
}
}
delete[] oldranges;
delete[] oldpranges;
}
ActiveColors = TotalColors;

View file

@ -87,6 +87,7 @@ public:
FTexture *GetChar (int code, int *const width) const;
int GetCharWidth (int code) const;
BYTE *GetColorTranslation (EColorRange range) const;
PalEntry *GetTranslatedPalette (EColorRange range) const;
int GetSpaceWidth () const { return SpaceWidth; }
int GetHeight () const { return FontHeight; }
int GetDefaultKerning () const { return GlobalKerning; }
@ -114,6 +115,7 @@ protected:
} *Chars;
int ActiveColors;
BYTE *Ranges;
PalEntry *PalRanges;
BYTE *PatchRemap;
char *Name;