mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-10 06:42:08 +00:00
- added support for reading JASC palette files. I hope it's correct, considering I have no such files to test. The format should be simple enough, though.
This commit is contained in:
parent
f70d0a6ced
commit
0ebe98d1e0
6 changed files with 47 additions and 13 deletions
|
@ -2210,7 +2210,7 @@ void Net_DoCommand (int type, uint8_t **stream, int player)
|
|||
case DEM_SETINV:
|
||||
s = ReadString(stream);
|
||||
i = ReadLong(stream);
|
||||
cht_SetInv(&players[player], s, i, ReadByte(stream));
|
||||
cht_SetInv(&players[player], s, i, !!ReadByte(stream));
|
||||
break;
|
||||
|
||||
case DEM_WARPCHEAT:
|
||||
|
|
|
@ -133,9 +133,11 @@ void gl_GenerateGlobalBrightmapFromColormap()
|
|||
if (lump == -1) lump = Wads.CheckNumForName("COLORMAP", ns_colormaps);
|
||||
if (lump == -1) return;
|
||||
FMemLump cmap = Wads.ReadLump(lump);
|
||||
FMemLump palette = Wads.ReadLump("PLAYPAL");
|
||||
uint8_t palbuffer[768];
|
||||
ReadPalette(Wads.CheckNumForName("PLAYPAL"), palbuffer);
|
||||
|
||||
const unsigned char *cmapdata = (const unsigned char *)cmap.GetMem();
|
||||
const unsigned char *paldata = (const unsigned char *)palette.GetMem();
|
||||
const uint8_t *paldata = palbuffer;
|
||||
|
||||
const int black = 0;
|
||||
const int white = ColorMatcher.Pick(255,255,255);
|
||||
|
|
|
@ -124,12 +124,13 @@ void DIntermissionScreen::Init(FIntermissionAction *desc, bool first)
|
|||
if (desc->mPalette.IsNotEmpty() && (lumpnum = Wads.CheckNumForFullName(desc->mPalette, true)) > 0)
|
||||
{
|
||||
PalEntry *palette;
|
||||
uint8_t palbuffer[768];
|
||||
const uint8_t *orgpal;
|
||||
FMemLump lump;
|
||||
int i;
|
||||
|
||||
lump = Wads.ReadLump (lumpnum);
|
||||
orgpal = (uint8_t *)lump.GetMem();
|
||||
ReadPalette(lumpnum, palbuffer);
|
||||
orgpal = (uint8_t *)palbuffer;
|
||||
palette = screen->GetPalette ();
|
||||
for (i = 256; i > 0; i--, orgpal += 3)
|
||||
{
|
||||
|
|
|
@ -306,6 +306,40 @@ static int sortforremap2 (const void *a, const void *b)
|
|||
}
|
||||
}
|
||||
|
||||
void ReadPalette(int lumpnum, uint8_t *buffer)
|
||||
{
|
||||
if (lumpnum < 0)
|
||||
{
|
||||
I_FatalError("Palette not found");
|
||||
}
|
||||
FMemLump lump = Wads.ReadLump(lumpnum);
|
||||
uint8_t *lumpmem = (uint8_t*)lump.GetMem();
|
||||
memset(buffer, 0, 768);
|
||||
if (memcmp(lumpmem, "JASC-PAL", 8))
|
||||
{
|
||||
memcpy(buffer, lumpmem, MIN<size_t>(768, lump.GetSize()));
|
||||
}
|
||||
else
|
||||
{
|
||||
FScanner sc;
|
||||
|
||||
sc.OpenMem(Wads.GetLumpFullName(lumpnum), (char*)lumpmem, lump.GetSize());
|
||||
sc.MustGetString();
|
||||
sc.MustGetNumber(); // version - ignore
|
||||
sc.MustGetNumber();
|
||||
int colors = MIN(256, sc.Number) * 3;
|
||||
for (int i = 0; i < colors; i++)
|
||||
{
|
||||
sc.MustGetNumber();
|
||||
if (sc.Number < 0 || sc.Number > 255)
|
||||
{
|
||||
sc.ScriptError("Color %d value out of range.", sc.Number);
|
||||
}
|
||||
buffer[i] = sc.Number;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static bool FixBuildPalette (uint8_t *opal, int lump, bool blood)
|
||||
{
|
||||
if (Wads.LumpLength (lump) < 768)
|
||||
|
@ -354,8 +388,7 @@ void InitPalette ()
|
|||
|
||||
if (!usingBuild)
|
||||
{
|
||||
FWadLump palump = Wads.OpenLumpName ("PLAYPAL");
|
||||
palump.Read (pal, 768);
|
||||
ReadPalette(Wads.CheckNumForName("PLAYPAL"), pal);
|
||||
}
|
||||
|
||||
GPalette.SetPalette (pal);
|
||||
|
|
|
@ -73,6 +73,7 @@ extern FPalette GPalette;
|
|||
int BestColor (const uint32_t *pal, int r, int g, int b, int first=1, int num=255);
|
||||
void DoBlending (const PalEntry *from, PalEntry *to, int count, int r, int g, int b, int a);
|
||||
|
||||
void ReadPalette(int lumpnum, uint8_t *buffer);
|
||||
void InitPalette ();
|
||||
|
||||
// V_SetBlend()
|
||||
|
|
|
@ -52,6 +52,7 @@
|
|||
#include "s_sound.h"
|
||||
#include "m_argv.h"
|
||||
#include "d_main.h"
|
||||
#include "v_palette.h"
|
||||
|
||||
// MACROS ------------------------------------------------------------------
|
||||
|
||||
|
@ -1452,13 +1453,9 @@ void ST_Util_FreeBitmap (BITMAPINFO *bitmap_info)
|
|||
void ST_Util_BitmapColorsFromPlaypal (BITMAPINFO *bitmap_info)
|
||||
{
|
||||
uint8_t playpal[768];
|
||||
int i;
|
||||
|
||||
{
|
||||
FWadLump lumpr = Wads.OpenLumpName ("PLAYPAL");
|
||||
lumpr.Read (playpal, 768);
|
||||
}
|
||||
for (i = 0; i < 256; ++i)
|
||||
ReadPalette(Wads.CheckNumForName("PLAYPAL"), playpal);
|
||||
for (int i = 0; i < 256; ++i)
|
||||
{
|
||||
bitmap_info->bmiColors[i].rgbBlue = playpal[i*3+2];
|
||||
bitmap_info->bmiColors[i].rgbGreen = playpal[i*3+1];
|
||||
|
|
Loading…
Reference in a new issue