- replaced another large batch of homegrown type use.

This commit is contained in:
Christoph Oelckers 2017-03-08 18:44:37 +01:00
commit 6dee9ff566
57 changed files with 656 additions and 656 deletions

View file

@ -104,42 +104,42 @@
struct DDPIXELFORMAT
{
DWORD Size; // Must be 32
DWORD Flags;
DWORD FourCC;
DWORD RGBBitCount;
DWORD RBitMask, GBitMask, BBitMask;
DWORD RGBAlphaBitMask;
uint32_t Size; // Must be 32
uint32_t Flags;
uint32_t FourCC;
uint32_t RGBBitCount;
uint32_t RBitMask, GBitMask, BBitMask;
uint32_t RGBAlphaBitMask;
};
struct DDCAPS2
{
DWORD Caps1, Caps2;
DWORD Reserved[2];
uint32_t Caps1, Caps2;
uint32_t Reserved[2];
};
struct DDSURFACEDESC2
{
DWORD Size; // Must be 124. DevIL claims some writers set it to 'DDS ' instead.
DWORD Flags;
DWORD Height;
DWORD Width;
uint32_t Size; // Must be 124. DevIL claims some writers set it to 'DDS ' instead.
uint32_t Flags;
uint32_t Height;
uint32_t Width;
union
{
int32_t Pitch;
DWORD LinearSize;
uint32_t LinearSize;
};
DWORD Depth;
DWORD MipMapCount;
DWORD Reserved1[11];
uint32_t Depth;
uint32_t MipMapCount;
uint32_t Reserved1[11];
DDPIXELFORMAT PixelFormat;
DDCAPS2 Caps;
DWORD Reserved2;
uint32_t Reserved2;
};
struct DDSFileHeader
{
DWORD Magic;
uint32_t Magic;
DDSURFACEDESC2 Desc;
};
@ -156,32 +156,32 @@ public:
FDDSTexture (FileReader &lump, int lumpnum, void *surfdesc);
~FDDSTexture ();
const BYTE *GetColumn (unsigned int column, const Span **spans_out);
const BYTE *GetPixels ();
const uint8_t *GetColumn (unsigned int column, const Span **spans_out);
const uint8_t *GetPixels ();
void Unload ();
FTextureFormat GetFormat ();
protected:
BYTE *Pixels;
uint8_t *Pixels;
Span **Spans;
DWORD Format;
uint32_t Format;
DWORD RMask, GMask, BMask, AMask;
BYTE RShiftL, GShiftL, BShiftL, AShiftL;
BYTE RShiftR, GShiftR, BShiftR, AShiftR;
uint32_t RMask, GMask, BMask, AMask;
uint8_t RShiftL, GShiftL, BShiftL, AShiftL;
uint8_t RShiftR, GShiftR, BShiftR, AShiftR;
int32_t Pitch;
DWORD LinearSize;
uint32_t LinearSize;
static void CalcBitShift (DWORD mask, BYTE *lshift, BYTE *rshift);
static void CalcBitShift (uint32_t mask, uint8_t *lshift, uint8_t *rshift);
void MakeTexture ();
void ReadRGB (FWadLump &lump, BYTE *tcbuf = NULL);
void DecompressDXT1 (FWadLump &lump, BYTE *tcbuf = NULL);
void DecompressDXT3 (FWadLump &lump, bool premultiplied, BYTE *tcbuf = NULL);
void DecompressDXT5 (FWadLump &lump, bool premultiplied, BYTE *tcbuf = NULL);
void ReadRGB (FWadLump &lump, uint8_t *tcbuf = NULL);
void DecompressDXT1 (FWadLump &lump, uint8_t *tcbuf = NULL);
void DecompressDXT3 (FWadLump &lump, bool premultiplied, uint8_t *tcbuf = NULL);
void DecompressDXT5 (FWadLump &lump, bool premultiplied, uint8_t *tcbuf = NULL);
int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf = NULL);
bool UseBasePalette();
@ -224,7 +224,7 @@ FTexture *DDSTexture_TryCreate (FileReader &data, int lumpnum)
union
{
DDSURFACEDESC2 surfdesc;
DWORD byteswapping[sizeof(DDSURFACEDESC2) / 4];
uint32_t byteswapping[sizeof(DDSURFACEDESC2) / 4];
};
if (!CheckDDS(data)) return NULL;
@ -233,7 +233,7 @@ FTexture *DDSTexture_TryCreate (FileReader &data, int lumpnum)
data.Read (&surfdesc, sizeof(surfdesc));
#ifdef __BIG_ENDIAN__
// Every single element of the header is a DWORD
// Every single element of the header is a uint32_t
for (unsigned int i = 0; i < sizeof(DDSURFACEDESC2) / 4; ++i)
{
byteswapping[i] = LittleLong(byteswapping[i]);
@ -293,8 +293,8 @@ FDDSTexture::FDDSTexture (FileReader &lump, int lumpnum, void *vsurfdesc)
TopOffset = 0;
bMasked = false;
Width = WORD(surf->Width);
Height = WORD(surf->Height);
Width = uint16_t(surf->Width);
Height = uint16_t(surf->Height);
CalcBitSize ();
if (surf->PixelFormat.Flags & DDPF_FOURCC)
@ -345,9 +345,9 @@ FDDSTexture::FDDSTexture (FileReader &lump, int lumpnum, void *vsurfdesc)
//
//==========================================================================
void FDDSTexture::CalcBitShift (DWORD mask, BYTE *lshiftp, BYTE *rshiftp)
void FDDSTexture::CalcBitShift (uint32_t mask, uint8_t *lshiftp, uint8_t *rshiftp)
{
BYTE shift;
uint8_t shift;
if (mask == 0)
{
@ -433,7 +433,7 @@ FTextureFormat FDDSTexture::GetFormat()
//
//==========================================================================
const BYTE *FDDSTexture::GetColumn (unsigned int column, const Span **spans_out)
const uint8_t *FDDSTexture::GetColumn (unsigned int column, const Span **spans_out)
{
if (Pixels == NULL)
{
@ -467,7 +467,7 @@ const BYTE *FDDSTexture::GetColumn (unsigned int column, const Span **spans_out)
//
//==========================================================================
const BYTE *FDDSTexture::GetPixels ()
const uint8_t *FDDSTexture::GetPixels ()
{
if (Pixels == NULL)
{
@ -486,7 +486,7 @@ void FDDSTexture::MakeTexture ()
{
FWadLump lump = Wads.OpenLumpNum (SourceLump);
Pixels = new BYTE[Width*Height];
Pixels = new uint8_t[Width*Height];
lump.Seek (sizeof(DDSURFACEDESC2) + 4, SEEK_SET);
@ -514,27 +514,27 @@ void FDDSTexture::MakeTexture ()
//
//==========================================================================
void FDDSTexture::ReadRGB (FWadLump &lump, BYTE *tcbuf)
void FDDSTexture::ReadRGB (FWadLump &lump, uint8_t *tcbuf)
{
DWORD x, y;
DWORD amask = AMask == 0 ? 0 : 0x80000000 >> AShiftL;
BYTE *linebuff = new BYTE[Pitch];
uint32_t x, y;
uint32_t amask = AMask == 0 ? 0 : 0x80000000 >> AShiftL;
uint8_t *linebuff = new uint8_t[Pitch];
for (y = Height; y > 0; --y)
{
BYTE *buffp = linebuff;
BYTE *pixelp = tcbuf? tcbuf + 4*y*Height : Pixels + y;
uint8_t *buffp = linebuff;
uint8_t *pixelp = tcbuf? tcbuf + 4*y*Height : Pixels + y;
lump.Read (linebuff, Pitch);
for (x = Width; x > 0; --x)
{
DWORD c;
uint32_t c;
if (Format == 4)
{
c = LittleLong(*(DWORD *)buffp); buffp += 4;
c = LittleLong(*(uint32_t *)buffp); buffp += 4;
}
else if (Format == 2)
{
c = LittleShort(*(WORD *)buffp); buffp += 2;
c = LittleShort(*(uint16_t *)buffp); buffp += 2;
}
else if (Format == 3)
{
@ -548,9 +548,9 @@ void FDDSTexture::ReadRGB (FWadLump &lump, BYTE *tcbuf)
{
if (amask == 0 || (c & amask))
{
DWORD r = (c & RMask) << RShiftL; r |= r >> RShiftR;
DWORD g = (c & GMask) << GShiftL; g |= g >> GShiftR;
DWORD b = (c & BMask) << BShiftL; b |= b >> BShiftR;
uint32_t r = (c & RMask) << RShiftL; r |= r >> RShiftR;
uint32_t g = (c & GMask) << GShiftL; g |= g >> GShiftR;
uint32_t b = (c & BMask) << BShiftL; b |= b >> BShiftR;
*pixelp = RGB256k.RGB[r >> 26][g >> 26][b >> 26];
}
else
@ -562,14 +562,14 @@ void FDDSTexture::ReadRGB (FWadLump &lump, BYTE *tcbuf)
}
else
{
DWORD r = (c & RMask) << RShiftL; r |= r >> RShiftR;
DWORD g = (c & GMask) << GShiftL; g |= g >> GShiftR;
DWORD b = (c & BMask) << BShiftL; b |= b >> BShiftR;
DWORD a = (c & AMask) << AShiftL; a |= a >> AShiftR;
pixelp[0] = (BYTE)(r>>24);
pixelp[1] = (BYTE)(g>>24);
pixelp[2] = (BYTE)(b>>24);
pixelp[3] = (BYTE)(a>>24);
uint32_t r = (c & RMask) << RShiftL; r |= r >> RShiftR;
uint32_t g = (c & GMask) << GShiftL; g |= g >> GShiftR;
uint32_t b = (c & BMask) << BShiftL; b |= b >> BShiftR;
uint32_t a = (c & AMask) << AShiftL; a |= a >> AShiftR;
pixelp[0] = (uint8_t)(r>>24);
pixelp[1] = (uint8_t)(g>>24);
pixelp[2] = (uint8_t)(b>>24);
pixelp[3] = (uint8_t)(a>>24);
pixelp+=4;
}
}
@ -583,13 +583,13 @@ void FDDSTexture::ReadRGB (FWadLump &lump, BYTE *tcbuf)
//
//==========================================================================
void FDDSTexture::DecompressDXT1 (FWadLump &lump, BYTE *tcbuf)
void FDDSTexture::DecompressDXT1 (FWadLump &lump, uint8_t *tcbuf)
{
const long blocklinelen = ((Width + 3) >> 2) << 3;
BYTE *blockbuff = new BYTE[blocklinelen];
BYTE *block;
uint8_t *blockbuff = new uint8_t[blocklinelen];
uint8_t *block;
PalEntry color[4];
BYTE palcol[4];
uint8_t palcol[4];
int ox, oy, x, y, i;
color[0].a = 255;
@ -602,7 +602,7 @@ void FDDSTexture::DecompressDXT1 (FWadLump &lump, BYTE *tcbuf)
block = blockbuff;
for (ox = 0; ox < Width; ox += 4)
{
WORD color16[2] = { LittleShort(((WORD *)block)[0]), LittleShort(((WORD *)block)[1]) };
uint16_t color16[2] = { LittleShort(((uint16_t *)block)[0]), LittleShort(((uint16_t *)block)[1]) };
// Convert color from R5G6B5 to R8G8B8.
for (i = 1; i >= 0; --i)
@ -646,7 +646,7 @@ void FDDSTexture::DecompressDXT1 (FWadLump &lump, BYTE *tcbuf)
{
break;
}
BYTE yslice = block[4 + y];
uint8_t yslice = block[4 + y];
for (x = 0; x < 4; ++x)
{
if (ox + x >= Width)
@ -660,7 +660,7 @@ void FDDSTexture::DecompressDXT1 (FWadLump &lump, BYTE *tcbuf)
}
else
{
BYTE * tcp = &tcbuf[(ox + x)*4 + (oy + y) * Width*4];
uint8_t * tcp = &tcbuf[(ox + x)*4 + (oy + y) * Width*4];
tcp[0] = color[ci].r;
tcp[1] = color[ci].g;
tcp[2] = color[ci].b;
@ -681,13 +681,13 @@ void FDDSTexture::DecompressDXT1 (FWadLump &lump, BYTE *tcbuf)
//
//==========================================================================
void FDDSTexture::DecompressDXT3 (FWadLump &lump, bool premultiplied, BYTE *tcbuf)
void FDDSTexture::DecompressDXT3 (FWadLump &lump, bool premultiplied, uint8_t *tcbuf)
{
const long blocklinelen = ((Width + 3) >> 2) << 4;
BYTE *blockbuff = new BYTE[blocklinelen];
BYTE *block;
uint8_t *blockbuff = new uint8_t[blocklinelen];
uint8_t *block;
PalEntry color[4];
BYTE palcol[4];
uint8_t palcol[4];
int ox, oy, x, y, i;
for (oy = 0; oy < Height; oy += 4)
@ -696,7 +696,7 @@ void FDDSTexture::DecompressDXT3 (FWadLump &lump, bool premultiplied, BYTE *tcbu
block = blockbuff;
for (ox = 0; ox < Width; ox += 4)
{
WORD color16[2] = { LittleShort(((WORD *)block)[4]), LittleShort(((WORD *)block)[5]) };
uint16_t color16[2] = { LittleShort(((uint16_t *)block)[4]), LittleShort(((uint16_t *)block)[5]) };
// Convert color from R5G6B5 to R8G8B8.
for (i = 1; i >= 0; --i)
@ -726,8 +726,8 @@ void FDDSTexture::DecompressDXT3 (FWadLump &lump, bool premultiplied, BYTE *tcbu
{
break;
}
BYTE yslice = block[12 + y];
WORD yalphaslice = LittleShort(((WORD *)block)[y]);
uint8_t yslice = block[12 + y];
uint16_t yalphaslice = LittleShort(((uint16_t *)block)[y]);
for (x = 0; x < 4; ++x)
{
if (ox + x >= Width)
@ -741,7 +741,7 @@ void FDDSTexture::DecompressDXT3 (FWadLump &lump, bool premultiplied, BYTE *tcbu
}
else
{
BYTE * tcp = &tcbuf[(ox + x)*4 + (oy + y) * Width*4];
uint8_t * tcp = &tcbuf[(ox + x)*4 + (oy + y) * Width*4];
int c = (yslice >> (x + x)) & 3;
tcp[0] = color[c].r;
tcp[1] = color[c].g;
@ -763,14 +763,14 @@ void FDDSTexture::DecompressDXT3 (FWadLump &lump, bool premultiplied, BYTE *tcbu
//
//==========================================================================
void FDDSTexture::DecompressDXT5 (FWadLump &lump, bool premultiplied, BYTE *tcbuf)
void FDDSTexture::DecompressDXT5 (FWadLump &lump, bool premultiplied, uint8_t *tcbuf)
{
const long blocklinelen = ((Width + 3) >> 2) << 4;
BYTE *blockbuff = new BYTE[blocklinelen];
BYTE *block;
uint8_t *blockbuff = new uint8_t[blocklinelen];
uint8_t *block;
PalEntry color[4];
BYTE palcol[4];
DWORD yalphaslice = 0;
uint8_t palcol[4];
uint32_t yalphaslice = 0;
int ox, oy, x, y, i;
for (oy = 0; oy < Height; oy += 4)
@ -779,8 +779,8 @@ void FDDSTexture::DecompressDXT5 (FWadLump &lump, bool premultiplied, BYTE *tcbu
block = blockbuff;
for (ox = 0; ox < Width; ox += 4)
{
WORD color16[2] = { LittleShort(((WORD *)block)[4]), LittleShort(((WORD *)block)[5]) };
BYTE alpha[8];
uint16_t color16[2] = { LittleShort(((uint16_t *)block)[4]), LittleShort(((uint16_t *)block)[5]) };
uint8_t alpha[8];
// Calculate the eight alpha values.
alpha[0] = block[0];
@ -840,7 +840,7 @@ void FDDSTexture::DecompressDXT5 (FWadLump &lump, bool premultiplied, BYTE *tcbu
{
yalphaslice >>= 12;
}
BYTE yslice = block[12 + y];
uint8_t yslice = block[12 + y];
for (x = 0; x < 4; ++x)
{
if (ox + x >= Width)
@ -854,7 +854,7 @@ void FDDSTexture::DecompressDXT5 (FWadLump &lump, bool premultiplied, BYTE *tcbu
}
else
{
BYTE * tcp = &tcbuf[(ox + x)*4 + (oy + y) * Width*4];
uint8_t * tcp = &tcbuf[(ox + x)*4 + (oy + y) * Width*4];
int c = (yslice >> (x + x)) & 3;
tcp[0] = color[c].r;
tcp[1] = color[c].g;
@ -879,7 +879,7 @@ int FDDSTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCo
{
FWadLump lump = Wads.OpenLumpNum (SourceLump);
BYTE *TexBuffer = new BYTE[4*Width*Height];
uint8_t *TexBuffer = new uint8_t[4*Width*Height];
lump.Seek (sizeof(DDSURFACEDESC2) + 4, SEEK_SET);