mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-10 23:02:08 +00:00
- Backported GZDoom's true color font mappings for use with native textures
when the time comes. SVN r626 (trunk)
This commit is contained in:
parent
1791acfb56
commit
154e21d9e7
4 changed files with 40 additions and 5 deletions
|
@ -1,4 +1,6 @@
|
||||||
December 23, 2007 (Changes by Graf Zahl)
|
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 'sv_doubleammo' submission.
|
||||||
- Added Karate Chris's 'Take' console command submission.
|
- Added Karate Chris's 'Take' console command submission.
|
||||||
- Changed DTA_Translation parameter for DrawTexture to an integer to avoid
|
- Changed DTA_Translation parameter for DrawTexture to an integer to avoid
|
||||||
|
|
|
@ -1254,7 +1254,7 @@ static void ConfirmIsAGo ()
|
||||||
//
|
//
|
||||||
// Set some stuff up for the video modes menu
|
// Set some stuff up for the video modes menu
|
||||||
//
|
//
|
||||||
static BYTE BitTranslate[16];
|
static BYTE BitTranslate[32];
|
||||||
|
|
||||||
void M_OptInit (void)
|
void M_OptInit (void)
|
||||||
{
|
{
|
||||||
|
|
|
@ -252,6 +252,7 @@ FFont::FFont (const char *name, const char *nametemplate, int first, int count,
|
||||||
charlumps = new int[count];
|
charlumps = new int[count];
|
||||||
PatchRemap = new BYTE[256];
|
PatchRemap = new BYTE[256];
|
||||||
Ranges = NULL;
|
Ranges = NULL;
|
||||||
|
PalRanges = NULL;
|
||||||
FirstChar = first;
|
FirstChar = first;
|
||||||
LastChar = first + count - 1;
|
LastChar = first + count - 1;
|
||||||
FontHeight = 0;
|
FontHeight = 0;
|
||||||
|
@ -354,6 +355,11 @@ FFont::~FFont ()
|
||||||
delete[] Ranges;
|
delete[] Ranges;
|
||||||
Ranges = NULL;
|
Ranges = NULL;
|
||||||
}
|
}
|
||||||
|
if (PalRanges)
|
||||||
|
{
|
||||||
|
delete[] PalRanges;
|
||||||
|
PalRanges = NULL;
|
||||||
|
}
|
||||||
if (PatchRemap)
|
if (PatchRemap)
|
||||||
{
|
{
|
||||||
delete[] PatchRemap;
|
delete[] PatchRemap;
|
||||||
|
@ -539,8 +545,11 @@ void FFont::BuildTranslations (const double *luminosity, const BYTE *identity, c
|
||||||
int i, j;
|
int i, j;
|
||||||
const TranslationParm *parmstart = (const TranslationParm *)ranges;
|
const TranslationParm *parmstart = (const TranslationParm *)ranges;
|
||||||
BYTE *range;
|
BYTE *range;
|
||||||
|
PalEntry *prange;
|
||||||
|
|
||||||
range = Ranges = new BYTE[NumTextColors * ActiveColors];
|
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
|
// Create different translations for different color ranges
|
||||||
for (i = 0; i < NumTextColors; i++)
|
for (i = 0; i < NumTextColors; i++)
|
||||||
|
@ -555,6 +564,10 @@ void FFont::BuildTranslations (const double *luminosity, const BYTE *identity, c
|
||||||
{
|
{
|
||||||
memcpy (range, Ranges, ActiveColors);
|
memcpy (range, Ranges, ActiveColors);
|
||||||
}
|
}
|
||||||
|
for (j = 0; j < ActiveColors; j++)
|
||||||
|
{
|
||||||
|
*prange++ = GPalette.BaseColors[range[j]];
|
||||||
|
}
|
||||||
range += ActiveColors;
|
range += ActiveColors;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -562,6 +575,7 @@ void FFont::BuildTranslations (const double *luminosity, const BYTE *identity, c
|
||||||
assert(parmstart->RangeStart >= 0);
|
assert(parmstart->RangeStart >= 0);
|
||||||
|
|
||||||
*range++ = 0;
|
*range++ = 0;
|
||||||
|
*prange++ = PalEntry(0);
|
||||||
|
|
||||||
for (j = 1; j < ActiveColors; j++)
|
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);
|
g=clamp(g, 0, 255);
|
||||||
b=clamp(b, 0, 255);
|
b=clamp(b, 0, 255);
|
||||||
*range++ = ColorMatcher.Pick (r, g, b);
|
*range++ = ColorMatcher.Pick (r, g, b);
|
||||||
|
*prange++ = PalEntry(r, g, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Advance to the next color range.
|
// Advance to the next color range.
|
||||||
|
@ -612,6 +627,16 @@ BYTE *FFont::GetColorTranslation (EColorRange range) const
|
||||||
return Ranges + ActiveColors * range;
|
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
|
// FFont :: GetChar
|
||||||
|
@ -1432,18 +1457,24 @@ FSpecialFont::FSpecialFont (const char *name, int first, int count, int *lumplis
|
||||||
{
|
{
|
||||||
int factor = 1;
|
int factor = 1;
|
||||||
BYTE *oldranges = Ranges;
|
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++)
|
for(j=ActiveColors;j<TotalColors;j++)
|
||||||
{
|
{
|
||||||
Ranges[TotalColors*i + j] = identity[j];
|
Ranges[TotalColors*i + j] = identity[j];
|
||||||
|
PalRanges[TotalColors*i + j] = GPalette.BaseColors[identity[j]];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
delete[] oldranges;
|
delete[] oldranges;
|
||||||
|
delete[] oldpranges;
|
||||||
}
|
}
|
||||||
ActiveColors = TotalColors;
|
ActiveColors = TotalColors;
|
||||||
|
|
||||||
|
|
|
@ -87,6 +87,7 @@ public:
|
||||||
FTexture *GetChar (int code, int *const width) const;
|
FTexture *GetChar (int code, int *const width) const;
|
||||||
int GetCharWidth (int code) const;
|
int GetCharWidth (int code) const;
|
||||||
BYTE *GetColorTranslation (EColorRange range) const;
|
BYTE *GetColorTranslation (EColorRange range) const;
|
||||||
|
PalEntry *GetTranslatedPalette (EColorRange range) const;
|
||||||
int GetSpaceWidth () const { return SpaceWidth; }
|
int GetSpaceWidth () const { return SpaceWidth; }
|
||||||
int GetHeight () const { return FontHeight; }
|
int GetHeight () const { return FontHeight; }
|
||||||
int GetDefaultKerning () const { return GlobalKerning; }
|
int GetDefaultKerning () const { return GlobalKerning; }
|
||||||
|
@ -114,6 +115,7 @@ protected:
|
||||||
} *Chars;
|
} *Chars;
|
||||||
int ActiveColors;
|
int ActiveColors;
|
||||||
BYTE *Ranges;
|
BYTE *Ranges;
|
||||||
|
PalEntry *PalRanges;
|
||||||
BYTE *PatchRemap;
|
BYTE *PatchRemap;
|
||||||
|
|
||||||
char *Name;
|
char *Name;
|
||||||
|
|
Loading…
Reference in a new issue