- replaced another large batch of homegrown type use.

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

View file

@ -1218,7 +1218,7 @@ void FParser::SF_ObjFlag(void)
if(mo && flagnum<26) // nullptr check if(mo && flagnum<26) // nullptr check
{ {
DWORD tempflags = mo->flags; uint32_t tempflags = mo->flags;
// remove old bit // remove old bit
tempflags &= ~(1 << flagnum); tempflags &= ~(1 << flagnum);
@ -1953,7 +1953,7 @@ void FParser::SF_SectorColormap(void)
if (t_argv[1].type==svt_string) if (t_argv[1].type==svt_string)
{ {
DWORD cm = R_ColormapNumForName(t_argv[1].value.s); uint32_t cm = R_ColormapNumForName(t_argv[1].value.s);
FSSectorTagIterator itr(tagnum); FSSectorTagIterator itr(tagnum);
while ((i = itr.Next()) >= 0) while ((i = itr.Next()) >= 0)

View file

@ -1487,7 +1487,7 @@ static int ntoh_cmp(const void *a, const void *b)
// //
//=========================================================================== //===========================================================================
void P_WriteDemoWeaponsChunk(BYTE **demo) void P_WriteDemoWeaponsChunk(uint8_t **demo)
{ {
WriteWord(Weapons_ntoh.Size(), demo); WriteWord(Weapons_ntoh.Size(), demo);
for (unsigned int i = 1; i < Weapons_ntoh.Size(); ++i) for (unsigned int i = 1; i < Weapons_ntoh.Size(); ++i)
@ -1505,7 +1505,7 @@ void P_WriteDemoWeaponsChunk(BYTE **demo)
// //
//=========================================================================== //===========================================================================
void P_ReadDemoWeaponsChunk(BYTE **demo) void P_ReadDemoWeaponsChunk(uint8_t **demo)
{ {
int count, i; int count, i;
PClassActor *type; PClassActor *type;
@ -1570,7 +1570,7 @@ void Net_WriteWeapon(PClassActor *type)
// //
//=========================================================================== //===========================================================================
PClassActor *Net_ReadWeapon(BYTE **stream) PClassActor *Net_ReadWeapon(uint8_t **stream)
{ {
int index; int index;

View file

@ -79,11 +79,11 @@ struct FWeaponSlots
void P_PlaybackKeyConfWeapons(FWeaponSlots *slots); void P_PlaybackKeyConfWeapons(FWeaponSlots *slots);
void Net_WriteWeapon(PClassActor *type); void Net_WriteWeapon(PClassActor *type);
PClassActor *Net_ReadWeapon(BYTE **stream); PClassActor *Net_ReadWeapon(uint8_t **stream);
void P_SetupWeapons_ntohton(); void P_SetupWeapons_ntohton();
void P_WriteDemoWeaponsChunk(BYTE **demo); void P_WriteDemoWeaponsChunk(uint8_t **demo);
void P_ReadDemoWeaponsChunk(BYTE **demo); void P_ReadDemoWeaponsChunk(uint8_t **demo);
class AWeapon : public AStateProvider class AWeapon : public AStateProvider
@ -91,7 +91,7 @@ class AWeapon : public AStateProvider
DECLARE_CLASS(AWeapon, AStateProvider) DECLARE_CLASS(AWeapon, AStateProvider)
HAS_OBJECT_POINTERS HAS_OBJECT_POINTERS
public: public:
DWORD WeaponFlags; uint32_t WeaponFlags;
PClassActor *AmmoType1, *AmmoType2; // Types of ammo used by this weapon PClassActor *AmmoType1, *AmmoType2; // Types of ammo used by this weapon
int AmmoGive1, AmmoGive2; // Amount of each ammo to get when picking up weapon int AmmoGive1, AmmoGive2; // Amount of each ammo to get when picking up weapon
int MinAmmo1, MinAmmo2; // Minimum ammo needed to switch to this weapon int MinAmmo1, MinAmmo2; // Minimum ammo needed to switch to this weapon

View file

@ -87,7 +87,7 @@ public:
void OnDestroy() override; void OnDestroy() override;
void Serialize(FSerializer &arc); void Serialize(FSerializer &arc);
TObjPtr<AActor*> Corpse; TObjPtr<AActor*> Corpse;
DWORD Count; // Only the first corpse pointer's count is valid. uint32_t Count; // Only the first corpse pointer's count is valid.
private: private:
DCorpsePointer () {} DCorpsePointer () {}
}; };
@ -104,7 +104,7 @@ CUSTOM_CVAR(Int, sv_corpsequeuesize, 64, CVAR_ARCHIVE|CVAR_SERVERINFO)
{ {
TThinkerIterator<DCorpsePointer> iterator (STAT_CORPSEPOINTER); TThinkerIterator<DCorpsePointer> iterator (STAT_CORPSEPOINTER);
DCorpsePointer *first = iterator.Next (); DCorpsePointer *first = iterator.Next ();
while (first != NULL && first->Count > (DWORD)self) while (first != NULL && first->Count > (uint32_t)self)
{ {
DCorpsePointer *next = iterator.Next (); DCorpsePointer *next = iterator.Next ();
first->Destroy (); first->Destroy ();
@ -126,7 +126,7 @@ DCorpsePointer::DCorpsePointer (AActor *ptr)
if (first != this) if (first != this)
{ {
if (first->Count >= (DWORD)sv_corpsequeuesize) if (first->Count >= (uint32_t)sv_corpsequeuesize)
{ {
DCorpsePointer *next = iterator.Next (); DCorpsePointer *next = iterator.Next ();
first->Destroy (); first->Destroy ();

View file

@ -173,7 +173,7 @@ void DBaseDecal::GetXY (side_t *wall, double &ox, double &oy) const
oy = v1->fY() + LeftDistance * dy; oy = v1->fY() + LeftDistance * dy;
} }
void DBaseDecal::SetShade (DWORD rgb) void DBaseDecal::SetShade (uint32_t rgb)
{ {
PalEntry *entry = (PalEntry *)&rgb; PalEntry *entry = (PalEntry *)&rgb;
AlphaColor = rgb | (ColorMatcher.Pick (entry->r, entry->g, entry->b) << 24); AlphaColor = rgb | (ColorMatcher.Pick (entry->r, entry->g, entry->b) << 24);

View file

@ -58,7 +58,7 @@ void DLightningThinker::LightningFlash ()
{ {
int i, j; int i, j;
sector_t *tempSec; sector_t *tempSec;
BYTE flashLight; uint8_t flashLight;
if (LightningFlashCount) if (LightningFlashCount)
{ {

View file

@ -28,7 +28,7 @@ public:
void OnDestroy() override; void OnDestroy() override;
FTextureID StickToWall(side_t *wall, double x, double y, F3DFloor * ffloor); FTextureID StickToWall(side_t *wall, double x, double y, F3DFloor * ffloor);
double GetRealZ (const side_t *wall) const; double GetRealZ (const side_t *wall) const;
void SetShade (DWORD rgb); void SetShade (uint32_t rgb);
void SetShade (int r, int g, int b); void SetShade (int r, int g, int b);
void Spread (const FDecalTemplate *tpl, side_t *wall, double x, double y, double z, F3DFloor * ffloor); void Spread (const FDecalTemplate *tpl, side_t *wall, double x, double y, double z, F3DFloor * ffloor);
void GetXY (side_t *side, double &x, double &y) const; void GetXY (side_t *side, double &x, double &y) const;
@ -39,10 +39,10 @@ public:
double Z; double Z;
double ScaleX, ScaleY; double ScaleX, ScaleY;
double Alpha; double Alpha;
DWORD AlphaColor; uint32_t AlphaColor;
int Translation; int Translation;
FTextureID PicNum; FTextureID PicNum;
DWORD RenderFlags; uint32_t RenderFlags;
FRenderStyle RenderStyle; FRenderStyle RenderStyle;
side_t *Side; side_t *Side;
sector_t *Sector; sector_t *Sector;

View file

@ -281,7 +281,7 @@ void DHUDMessage::ResetText (const char *text)
V_FreeBrokenLines (Lines); V_FreeBrokenLines (Lines);
} }
Lines = V_BreakLines (Font, NoWrap ? INT_MAX : width, (BYTE *)text); Lines = V_BreakLines (Font, NoWrap ? INT_MAX : width, (uint8_t *)text);
NumLines = 0; NumLines = 0;
Width = 0; Width = 0;

View file

@ -670,7 +670,7 @@ static int DrawAmmo(player_t *CPlayer, int x, int y)
// Weapons List // Weapons List
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
FTextureID GetInventoryIcon(AInventory *item, DWORD flags, bool *applyscale=NULL) // This function is also used by SBARINFO FTextureID GetInventoryIcon(AInventory *item, uint32_t flags, bool *applyscale=NULL) // This function is also used by SBARINFO
{ {
FTextureID picnum, AltIcon = item->AltHUDIcon; FTextureID picnum, AltIcon = item->AltHUDIcon;
FState * state=NULL, *ReadyState; FState * state=NULL, *ReadyState;

View file

@ -134,7 +134,7 @@ protected:
private: private:
TObjPtr<DHUDMessage*> Next; TObjPtr<DHUDMessage*> Next;
DWORD SBarID; uint32_t SBarID;
char *SourceText; char *SourceText;
friend class DBaseStatusBar; friend class DBaseStatusBar;
@ -225,11 +225,11 @@ struct FMugShotFrame
struct FMugShotState struct FMugShotState
{ {
BYTE bUsesLevels:1; uint8_t bUsesLevels:1;
BYTE bHealth2:1; // Health level is the 2nd character from the end. uint8_t bHealth2:1; // Health level is the 2nd character from the end.
BYTE bHealthSpecial:1; // Like health2 only the 2nd frame gets the normal health type. uint8_t bHealthSpecial:1; // Like health2 only the 2nd frame gets the normal health type.
BYTE bDirectional:1; // Faces direction of damage. uint8_t bDirectional:1; // Faces direction of damage.
BYTE bFinished:1; uint8_t bFinished:1;
unsigned int Position; unsigned int Position;
int Time; int Time;
@ -433,7 +433,7 @@ void ST_LoadCrosshair(bool alwaysload=false);
void ST_Clear(); void ST_Clear();
extern FTexture *CrosshairImage; extern FTexture *CrosshairImage;
FTextureID GetInventoryIcon(AInventory *item, DWORD flags, bool *applyscale); FTextureID GetInventoryIcon(AInventory *item, uint32_t flags, bool *applyscale);
enum DI_Flags enum DI_Flags
{ {

View file

@ -189,9 +189,9 @@ class SBarInfoCommand
if (!sc.CheckToken(TK_Null)) sc.MustGetToken(TK_Identifier); if (!sc.CheckToken(TK_Null)) sc.MustGetToken(TK_Identifier);
EColorRange returnVal = CR_UNTRANSLATED; EColorRange returnVal = CR_UNTRANSLATED;
FString namedTranslation; //we must send in "[translation]" FString namedTranslation; //we must send in "[translation]"
const BYTE *trans_ptr; const uint8_t *trans_ptr;
namedTranslation.Format("[%s]", sc.String); namedTranslation.Format("[%s]", sc.String);
trans_ptr = (const BYTE *)(&namedTranslation[0]); trans_ptr = (const uint8_t *)(&namedTranslation[0]);
if((returnVal = V_ParseFontColor(trans_ptr, CR_UNTRANSLATED, CR_UNTRANSLATED)) == CR_UNDEFINED) if((returnVal = V_ParseFontColor(trans_ptr, CR_UNTRANSLATED, CR_UNTRANSLATED)) == CR_UNDEFINED)
{ {
sc.ScriptError("Missing definition for color %s.", sc.String); sc.ScriptError("Missing definition for color %s.", sc.String);
@ -1379,7 +1379,7 @@ public:
double xScale = 1.0; double xScale = 1.0;
double yScale = 1.0; double yScale = 1.0;
const BYTE* str = (const BYTE*) cstring; const uint8_t* str = (const uint8_t*) cstring;
const EColorRange boldTranslation = EColorRange(translation ? translation - 1 : NumTextColors - 1); const EColorRange boldTranslation = EColorRange(translation ? translation - 1 : NumTextColors - 1);
int fontcolor = translation; int fontcolor = translation;

View file

@ -344,7 +344,7 @@ class CommandDrawImage : public SBarInfoCommandFlowControl
int maxheight; int maxheight;
double spawnScaleX; double spawnScaleX;
double spawnScaleY; double spawnScaleY;
DWORD flags; uint32_t flags;
bool applyscale; //Set remotely from from GetInventoryIcon when selected sprite comes from Spawn state bool applyscale; //Set remotely from from GetInventoryIcon when selected sprite comes from Spawn state
// I'm using imgx/imgy here so that I can inherit drawimage with drawnumber for some commands. // I'm using imgx/imgy here so that I can inherit drawimage with drawnumber for some commands.
SBarInfoCoordinate imgx; SBarInfoCoordinate imgx;
@ -2132,7 +2132,7 @@ class CommandDrawShader : public SBarInfoCommand
DummySpan[1].TopOffset = 0; DummySpan[1].TopOffset = 0;
DummySpan[1].Length = 0; DummySpan[1].Length = 0;
} }
const BYTE *GetColumn(unsigned int column, const Span **spans_out) const uint8_t *GetColumn(unsigned int column, const Span **spans_out)
{ {
if (spans_out != NULL) if (spans_out != NULL)
{ {
@ -2140,10 +2140,10 @@ class CommandDrawShader : public SBarInfoCommand
} }
return Pixels + ((column & WidthMask) << HeightBits); return Pixels + ((column & WidthMask) << HeightBits);
} }
const BYTE *GetPixels() { return Pixels; } const uint8_t *GetPixels() { return Pixels; }
void Unload() {} void Unload() {}
private: private:
BYTE Pixels[512]; uint8_t Pixels[512];
Span DummySpan[2]; Span DummySpan[2];
}; };

View file

@ -403,7 +403,7 @@ void DBaseStatusBar::Tick ()
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void DBaseStatusBar::AttachMessage (DHUDMessage *msg, DWORD id, int layer) void DBaseStatusBar::AttachMessage (DHUDMessage *msg, uint32_t id, int layer)
{ {
DHUDMessage *old = NULL; DHUDMessage *old = NULL;
DHUDMessage **prev; DHUDMessage **prev;
@ -471,7 +471,7 @@ DHUDMessage *DBaseStatusBar::DetachMessage (DHUDMessage *msg)
return NULL; return NULL;
} }
DHUDMessage *DBaseStatusBar::DetachMessage (DWORD id) DHUDMessage *DBaseStatusBar::DetachMessage (uint32_t id)
{ {
for (size_t i = 0; i < countof(Messages); ++i) for (size_t i = 0; i < countof(Messages); ++i)
{ {
@ -597,10 +597,10 @@ void DBaseStatusBar::RefreshBackground () const
void DBaseStatusBar::DrawCrosshair () void DBaseStatusBar::DrawCrosshair ()
{ {
static DWORD prevcolor = 0xffffffff; static uint32_t prevcolor = 0xffffffff;
static int palettecolor = 0; static int palettecolor = 0;
DWORD color; uint32_t color;
double size; double size;
int w, h; int w, h;

View file

@ -124,12 +124,12 @@ void DIntermissionScreen::Init(FIntermissionAction *desc, bool first)
if (desc->mPalette.IsNotEmpty() && (lumpnum = Wads.CheckNumForFullName(desc->mPalette, true)) > 0) if (desc->mPalette.IsNotEmpty() && (lumpnum = Wads.CheckNumForFullName(desc->mPalette, true)) > 0)
{ {
PalEntry *palette; PalEntry *palette;
const BYTE *orgpal; const uint8_t *orgpal;
FMemLump lump; FMemLump lump;
int i; int i;
lump = Wads.ReadLump (lumpnum); lump = Wads.ReadLump (lumpnum);
orgpal = (BYTE *)lump.GetMem(); orgpal = (uint8_t *)lump.GetMem();
palette = screen->GetPalette (); palette = screen->GetPalette ();
for (i = 256; i > 0; i--, orgpal += 3) for (i = 256; i > 0; i--, orgpal += 3)
{ {
@ -721,7 +721,7 @@ void DIntermissionScreenScroller::Drawer ()
DIntermissionController *DIntermissionController::CurrentIntermission; DIntermissionController *DIntermissionController::CurrentIntermission;
DIntermissionController::DIntermissionController(FIntermissionDescriptor *Desc, bool DeleteDesc, BYTE state) DIntermissionController::DIntermissionController(FIntermissionDescriptor *Desc, bool DeleteDesc, uint8_t state)
{ {
mDesc = Desc; mDesc = Desc;
mDeleteDesc = DeleteDesc; mDeleteDesc = DeleteDesc;
@ -883,7 +883,7 @@ void DIntermissionController::OnDestroy ()
// //
//========================================================================== //==========================================================================
void F_StartIntermission(FIntermissionDescriptor *desc, bool deleteme, BYTE state) void F_StartIntermission(FIntermissionDescriptor *desc, bool deleteme, uint8_t state)
{ {
if (DIntermissionController::CurrentIntermission != NULL) if (DIntermissionController::CurrentIntermission != NULL)
{ {
@ -907,7 +907,7 @@ void F_StartIntermission(FIntermissionDescriptor *desc, bool deleteme, BYTE stat
// //
//========================================================================== //==========================================================================
void F_StartIntermission(FName seq, BYTE state) void F_StartIntermission(FName seq, uint8_t state)
{ {
FIntermissionDescriptor **pdesc = IntermissionDescriptors.CheckKey(seq); FIntermissionDescriptor **pdesc = IntermissionDescriptors.CheckKey(seq);
if (pdesc != NULL) if (pdesc != NULL)

View file

@ -31,15 +31,15 @@ struct FIIntermissionPatch
struct FCastSound struct FCastSound
{ {
BYTE mSequence; uint8_t mSequence;
BYTE mIndex; uint8_t mIndex;
FString mSound; FString mSound;
}; };
struct FICastSound struct FICastSound
{ {
BYTE mSequence; uint8_t mSequence;
BYTE mIndex; uint8_t mIndex;
FSoundID mSound; FSoundID mSound;
}; };
@ -289,7 +289,7 @@ class DIntermissionController : public DObject
bool mDeleteDesc; bool mDeleteDesc;
bool mFirst; bool mFirst;
bool mAdvance, mSentAdvance; bool mAdvance, mSentAdvance;
BYTE mGameState; uint8_t mGameState;
int mIndex; int mIndex;
bool NextPage(); bool NextPage();
@ -297,7 +297,7 @@ class DIntermissionController : public DObject
public: public:
static DIntermissionController *CurrentIntermission; static DIntermissionController *CurrentIntermission;
DIntermissionController(FIntermissionDescriptor *mDesc = NULL, bool mDeleteDesc = false, BYTE state = FSTATE_ChangingLevel); DIntermissionController(FIntermissionDescriptor *mDesc = NULL, bool mDeleteDesc = false, uint8_t state = FSTATE_ChangingLevel);
bool Responder (event_t *ev); bool Responder (event_t *ev);
void Ticker (); void Ticker ();
void Drawer (); void Drawer ();
@ -311,8 +311,8 @@ public:
bool F_Responder (event_t* ev); bool F_Responder (event_t* ev);
void F_Ticker (); void F_Ticker ();
void F_Drawer (); void F_Drawer ();
void F_StartIntermission(FIntermissionDescriptor *desc, bool deleteme, BYTE state); void F_StartIntermission(FIntermissionDescriptor *desc, bool deleteme, uint8_t state);
void F_StartIntermission(FName desc, BYTE state); void F_StartIntermission(FName desc, uint8_t state);
void F_EndFinale (); void F_EndFinale ();
void F_AdvanceIntermission(); void F_AdvanceIntermission();

View file

@ -382,10 +382,10 @@ bool FIntermissionActionCast::ParseKey(FScanner &sc)
FCastSound *cs = &mCastSounds[mCastSounds.Reserve(1)]; FCastSound *cs = &mCastSounds[mCastSounds.Reserve(1)];
sc.MustGetToken('='); sc.MustGetToken('=');
sc.MustGetToken(TK_StringConst); sc.MustGetToken(TK_StringConst);
cs->mSequence = (BYTE)sc.MatchString(seqs); cs->mSequence = (uint8_t)sc.MatchString(seqs);
sc.MustGetToken(','); sc.MustGetToken(',');
sc.MustGetToken(TK_IntConst); sc.MustGetToken(TK_IntConst);
cs->mIndex = (BYTE)sc.Number; cs->mIndex = (uint8_t)sc.Number;
sc.MustGetToken(','); sc.MustGetToken(',');
sc.MustGetToken(TK_StringConst); sc.MustGetToken(TK_StringConst);
cs->mSound = sc.String; cs->mSound = sc.String;
@ -573,7 +573,7 @@ void FMapInfoParser::ParseIntermission()
struct EndSequence struct EndSequence
{ {
SBYTE EndType; int8_t EndType;
bool MusicLooping; bool MusicLooping;
bool PlayTheEnd; bool PlayTheEnd;
FString PicName; FString PicName;

View file

@ -771,7 +771,7 @@ void M_Drawer (void)
{ {
player = camera->player; player = camera->player;
} }
fade = PalEntry (BYTE(player->BlendA*255), BYTE(player->BlendR*255), BYTE(player->BlendG*255), BYTE(player->BlendB*255)); fade = PalEntry (uint8_t(player->BlendA*255), uint8_t(player->BlendR*255), uint8_t(player->BlendG*255), uint8_t(player->BlendB*255));
} }

View file

@ -77,7 +77,7 @@ EXTERN_CVAR (Bool, vid_tft) // Defined below
int testingmode; // Holds time to revert to old mode int testingmode; // Holds time to revert to old mode
int OldWidth, OldHeight, OldBits; int OldWidth, OldHeight, OldBits;
static FIntCVar DummyDepthCvar (NULL, 0, 0); static FIntCVar DummyDepthCvar (NULL, 0, 0);
static BYTE BitTranslate[32]; static uint8_t BitTranslate[32];
CUSTOM_CVAR (Int, menu_screenratios, -1, CVAR_ARCHIVE) CUSTOM_CVAR (Int, menu_screenratios, -1, CVAR_ARCHIVE)
{ {

View file

@ -262,7 +262,7 @@ bool F7ZFile::Open(bool quiet)
TArray<UInt16> nameUTF16; TArray<UInt16> nameUTF16;
TArray<char> nameASCII; TArray<char> nameASCII;
for (DWORD i = 0; i < NumLumps; ++i) for (uint32_t i = 0; i < NumLumps; ++i)
{ {
// skip Directories // skip Directories
if (SzArEx_IsDir(archPtr, i)) if (SzArEx_IsDir(archPtr, i))

View file

@ -46,8 +46,8 @@
struct GrpInfo struct GrpInfo
{ {
DWORD Magic[3]; uint32_t Magic[3];
DWORD NumLumps; uint32_t NumLumps;
}; };
struct GrpLump struct GrpLump
@ -57,7 +57,7 @@ struct GrpLump
struct struct
{ {
char Name[12]; char Name[12];
DWORD Size; uint32_t Size;
}; };
char NameWithZero[13]; char NameWithZero[13];
}; };
@ -110,7 +110,7 @@ bool FGrpFile::Open(bool quiet)
int Position = sizeof(GrpInfo) + NumLumps * sizeof(GrpLump); int Position = sizeof(GrpInfo) + NumLumps * sizeof(GrpLump);
for(DWORD i = 0; i < NumLumps; i++) for(uint32_t i = 0; i < NumLumps; i++)
{ {
Lumps[i].Owner = this; Lumps[i].Owner = this;
Lumps[i].Position = Position; Lumps[i].Position = Position;

View file

@ -106,7 +106,7 @@ bool FPakFile::Open(bool quiet)
if (!quiet && !batchrun) Printf(", %d lumps\n", NumLumps); if (!quiet && !batchrun) Printf(", %d lumps\n", NumLumps);
for(DWORD i = 0; i < NumLumps; i++) for(uint32_t i = 0; i < NumLumps; i++)
{ {
Lumps[i].LumpNameSetup(fileinfo[i].name); Lumps[i].LumpNameSetup(fileinfo[i].name);
Lumps[i].Owner = this; Lumps[i].Owner = this;

View file

@ -48,23 +48,23 @@
struct RFFInfo struct RFFInfo
{ {
// Should be "RFF\x18" // Should be "RFF\x18"
DWORD Magic; uint32_t Magic;
DWORD Version; uint32_t Version;
DWORD DirOfs; uint32_t DirOfs;
DWORD NumLumps; uint32_t NumLumps;
}; };
struct RFFLump struct RFFLump
{ {
DWORD DontKnow1[4]; uint32_t DontKnow1[4];
DWORD FilePos; uint32_t FilePos;
DWORD Size; uint32_t Size;
DWORD DontKnow2; uint32_t DontKnow2;
DWORD Time; uint32_t Time;
BYTE Flags; uint8_t Flags;
char Extension[3]; char Extension[3];
char Name[8]; char Name[8];
DWORD IndexNum; // Used by .sfx, possibly others uint32_t IndexNum; // Used by .sfx, possibly others
}; };
//========================================================================== //==========================================================================
@ -78,7 +78,7 @@ struct FRFFLump : public FUncompressedLump
virtual FileReader *GetReader(); virtual FileReader *GetReader();
virtual int FillCache(); virtual int FillCache();
DWORD IndexNum; uint32_t IndexNum;
int GetIndexNum() const { return IndexNum; } int GetIndexNum() const { return IndexNum; }
}; };
@ -91,11 +91,11 @@ struct FRFFLump : public FUncompressedLump
void BloodCrypt (void *data, int key, int len) void BloodCrypt (void *data, int key, int len)
{ {
int p = (BYTE)key, i; int p = (uint8_t)key, i;
for (i = 0; i < len; ++i) for (i = 0; i < len; ++i)
{ {
((BYTE *)data)[i] ^= (unsigned char)(p+(i>>1)); ((uint8_t *)data)[i] ^= (unsigned char)(p+(i>>1));
} }
} }
@ -153,7 +153,7 @@ bool FRFFFile::Open(bool quiet)
Lumps = new FRFFLump[NumLumps]; Lumps = new FRFFLump[NumLumps];
if (!quiet && !batchrun) Printf(", %d lumps\n", NumLumps); if (!quiet && !batchrun) Printf(", %d lumps\n", NumLumps);
for (DWORD i = 0; i < NumLumps; ++i) for (uint32_t i = 0; i < NumLumps; ++i)
{ {
Lumps[i].Position = LittleLong(lumps[i].FilePos); Lumps[i].Position = LittleLong(lumps[i].FilePos);
Lumps[i].LumpSize = LittleLong(lumps[i].Size); Lumps[i].LumpSize = LittleLong(lumps[i].Size);
@ -230,7 +230,7 @@ int FRFFLump::FillCache()
if (Flags & LUMPF_BLOODCRYPT) if (Flags & LUMPF_BLOODCRYPT)
{ {
int cryptlen = MIN<int> (LumpSize, 256); int cryptlen = MIN<int> (LumpSize, 256);
BYTE *data = (BYTE *)Cache; uint8_t *data = (uint8_t *)Cache;
for (int i = 0; i < cryptlen; ++i) for (int i = 0; i < cryptlen; ++i)
{ {

View file

@ -49,7 +49,7 @@ private:
FileReader &File; FileReader &File;
bool SawEOF; bool SawEOF;
BYTE InBuff[BUFF_SIZE]; uint8_t InBuff[BUFF_SIZE];
enum StreamState enum StreamState
{ {
@ -62,15 +62,15 @@ private:
{ {
StreamState State; StreamState State;
BYTE *In; uint8_t *In;
unsigned int AvailIn; unsigned int AvailIn;
unsigned int InternalOut; unsigned int InternalOut;
BYTE CFlags, Bits; uint8_t CFlags, Bits;
BYTE Window[WINDOW_SIZE+INTERNAL_BUFFER_SIZE]; uint8_t Window[WINDOW_SIZE+INTERNAL_BUFFER_SIZE];
const BYTE *WindowData; const uint8_t *WindowData;
BYTE *InternalBuffer; uint8_t *InternalBuffer;
} Stream; } Stream;
void FillBuffer() void FillBuffer()
@ -109,8 +109,8 @@ private:
return false; return false;
Stream.AvailIn -= 2; Stream.AvailIn -= 2;
WORD pos = BigShort(*(WORD*)Stream.In); uint16_t pos = BigShort(*(uint16_t*)Stream.In);
BYTE len = (pos & 0xF)+1; uint8_t len = (pos & 0xF)+1;
pos >>= 4; pos >>= 4;
Stream.In += 2; Stream.In += 2;
if(len == 1) if(len == 1)
@ -120,7 +120,7 @@ private:
return true; return true;
} }
const BYTE* copyStart = Stream.InternalBuffer-pos-1; const uint8_t* copyStart = Stream.InternalBuffer-pos-1;
// Complete overlap: Single byte repeated // Complete overlap: Single byte repeated
if(pos == 0) if(pos == 0)
@ -182,7 +182,7 @@ public:
long Read(void *buffer, long len) long Read(void *buffer, long len)
{ {
BYTE *Out = (BYTE*)buffer; uint8_t *Out = (uint8_t*)buffer;
long AvailOut = len; long AvailOut = len;
do do
@ -222,7 +222,7 @@ public:
while(AvailOut && Stream.State != STREAM_FINAL); while(AvailOut && Stream.State != STREAM_FINAL);
assert(AvailOut == 0); assert(AvailOut == 0);
return (long)(Out - (BYTE*)buffer); return (long)(Out - (uint8_t*)buffer);
} }
}; };
@ -329,7 +329,7 @@ FWadFile::~FWadFile()
bool FWadFile::Open(bool quiet) bool FWadFile::Open(bool quiet)
{ {
wadinfo_t header; wadinfo_t header;
DWORD InfoTableOfs; uint32_t InfoTableOfs;
bool isBigEndian = false; // Little endian is assumed until proven otherwise bool isBigEndian = false; // Little endian is assumed until proven otherwise
const long wadSize = Reader->GetLength(); const long wadSize = Reader->GetLength();
@ -358,7 +358,7 @@ bool FWadFile::Open(bool quiet)
Lumps = new FWadFileLump[NumLumps]; Lumps = new FWadFileLump[NumLumps];
for(DWORD i = 0; i < NumLumps; i++) for(uint32_t i = 0; i < NumLumps; i++)
{ {
uppercopy (Lumps[i].Name, fileinfo[i].Name); uppercopy (Lumps[i].Name, fileinfo[i].Name);
Lumps[i].Name[8] = 0; Lumps[i].Name[8] = 0;
@ -563,7 +563,7 @@ void FWadFile::SkinHack ()
static int namespc = ns_firstskin; static int namespc = ns_firstskin;
bool skinned = false; bool skinned = false;
bool hasmap = false; bool hasmap = false;
DWORD i; uint32_t i;
for (i = 0; i < NumLumps; i++) for (i = 0; i < NumLumps; i++)
{ {
@ -580,7 +580,7 @@ void FWadFile::SkinHack ()
if (!skinned) if (!skinned)
{ {
skinned = true; skinned = true;
DWORD j; uint32_t j;
for (j = 0; j < NumLumps; j++) for (j = 0; j < NumLumps; j++)
{ {
@ -627,7 +627,7 @@ void FWadFile::SkinHack ()
void FWadFile::FindStrifeTeaserVoices () void FWadFile::FindStrifeTeaserVoices ()
{ {
for (DWORD i = 0; i <= NumLumps; ++i) for (uint32_t i = 0; i <= NumLumps; ++i)
{ {
if (Lumps[i].Name[0] == 'V' && if (Lumps[i].Name[0] == 'V' &&
Lumps[i].Name[1] == 'O' && Lumps[i].Name[1] == 'O' &&

View file

@ -123,23 +123,23 @@ bool FCompressedBuffer::Decompress(char *destbuffer)
// //
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
static DWORD Zip_FindCentralDir(FileReader * fin) static uint32_t Zip_FindCentralDir(FileReader * fin)
{ {
unsigned char buf[BUFREADCOMMENT + 4]; unsigned char buf[BUFREADCOMMENT + 4];
DWORD FileSize; uint32_t FileSize;
DWORD uBackRead; uint32_t uBackRead;
DWORD uMaxBack; // maximum size of global comment uint32_t uMaxBack; // maximum size of global comment
DWORD uPosFound=0; uint32_t uPosFound=0;
fin->Seek(0, SEEK_END); fin->Seek(0, SEEK_END);
FileSize = fin->Tell(); FileSize = fin->Tell();
uMaxBack = MIN<DWORD>(0xffff, FileSize); uMaxBack = MIN<uint32_t>(0xffff, FileSize);
uBackRead = 4; uBackRead = 4;
while (uBackRead < uMaxBack) while (uBackRead < uMaxBack)
{ {
DWORD uReadSize, uReadPos; uint32_t uReadSize, uReadPos;
int i; int i;
if (uBackRead + BUFREADCOMMENT > uMaxBack) if (uBackRead + BUFREADCOMMENT > uMaxBack)
uBackRead = uMaxBack; uBackRead = uMaxBack;
@ -147,7 +147,7 @@ static DWORD Zip_FindCentralDir(FileReader * fin)
uBackRead += BUFREADCOMMENT; uBackRead += BUFREADCOMMENT;
uReadPos = FileSize - uBackRead; uReadPos = FileSize - uBackRead;
uReadSize = MIN<DWORD>((BUFREADCOMMENT + 4), (FileSize - uReadPos)); uReadSize = MIN<uint32_t>((BUFREADCOMMENT + 4), (FileSize - uReadPos));
if (fin->Seek(uReadPos, SEEK_SET) != 0) break; if (fin->Seek(uReadPos, SEEK_SET) != 0) break;
@ -182,7 +182,7 @@ FZipFile::FZipFile(const char * filename, FileReader *file)
bool FZipFile::Open(bool quiet) bool FZipFile::Open(bool quiet)
{ {
DWORD centraldir = Zip_FindCentralDir(Reader); uint32_t centraldir = Zip_FindCentralDir(Reader);
FZipEndOfCentralDirectory info; FZipEndOfCentralDirectory info;
int skipped = 0; int skipped = 0;
@ -223,7 +223,7 @@ bool FZipFile::Open(bool quiet)
// Check if all files have the same prefix so that this can be stripped out. // Check if all files have the same prefix so that this can be stripped out.
// This will only be done if there is either a MAPINFO, ZMAPINFO or GAMEINFO lump in the subdirectory, denoting a ZDoom mod. // This will only be done if there is either a MAPINFO, ZMAPINFO or GAMEINFO lump in the subdirectory, denoting a ZDoom mod.
if (NumLumps > 1) for (DWORD i = 0; i < NumLumps; i++) if (NumLumps > 1) for (uint32_t i = 0; i < NumLumps; i++)
{ {
FZipCentralDirectoryInfo *zip_fh = (FZipCentralDirectoryInfo *)dirptr; FZipCentralDirectoryInfo *zip_fh = (FZipCentralDirectoryInfo *)dirptr;
@ -292,7 +292,7 @@ bool FZipFile::Open(bool quiet)
dirptr = (char*)directory; dirptr = (char*)directory;
lump_p = Lumps; lump_p = Lumps;
for (DWORD i = 0; i < NumLumps; i++) for (uint32_t i = 0; i < NumLumps; i++)
{ {
FZipCentralDirectoryInfo *zip_fh = (FZipCentralDirectoryInfo *)dirptr; FZipCentralDirectoryInfo *zip_fh = (FZipCentralDirectoryInfo *)dirptr;
@ -348,7 +348,7 @@ bool FZipFile::Open(bool quiet)
lump_p->Owner = this; lump_p->Owner = this;
// The start of the Reader will be determined the first time it is accessed. // The start of the Reader will be determined the first time it is accessed.
lump_p->Flags = LUMPF_ZIPFILE | LUMPFZIP_NEEDFILESTART; lump_p->Flags = LUMPF_ZIPFILE | LUMPFZIP_NEEDFILESTART;
lump_p->Method = BYTE(zip_fh->Method); lump_p->Method = uint8_t(zip_fh->Method);
lump_p->GPFlags = zip_fh->Flags; lump_p->GPFlags = zip_fh->Flags;
lump_p->CRC32 = zip_fh->CRC32; lump_p->CRC32 = zip_fh->CRC32;
lump_p->CompressedSize = LittleLong(zip_fh->CompressedSize); lump_p->CompressedSize = LittleLong(zip_fh->CompressedSize);

View file

@ -16,8 +16,8 @@ enum
struct FZipLump : public FResourceLump struct FZipLump : public FResourceLump
{ {
WORD GPFlags; uint16_t GPFlags;
BYTE Method; uint8_t Method;
int CompressedSize; int CompressedSize;
int Position; int Position;
unsigned CRC32; unsigned CRC32;

View file

@ -204,7 +204,7 @@ FCompressedBuffer FResourceLump::GetRawData()
{ {
FCompressedBuffer cbuf = { (unsigned)LumpSize, (unsigned)LumpSize, METHOD_STORED, 0, 0, new char[LumpSize] }; FCompressedBuffer cbuf = { (unsigned)LumpSize, (unsigned)LumpSize, METHOD_STORED, 0, 0, new char[LumpSize] };
memcpy(cbuf.mBuffer, CacheLump(), LumpSize); memcpy(cbuf.mBuffer, CacheLump(), LumpSize);
cbuf.mCRC32 = crc32(0, (BYTE*)cbuf.mBuffer, LumpSize); cbuf.mCRC32 = crc32(0, (uint8_t*)cbuf.mBuffer, LumpSize);
ReleaseCache(); ReleaseCache();
return cbuf; return cbuf;
} }
@ -365,7 +365,7 @@ void FResourceFile::PostProcessArchive(void *lumps, size_t lumpsize)
// Filter out lumps using the same names as the Autoload.* sections // Filter out lumps using the same names as the Autoload.* sections
// in the ini file use. We reduce the maximum lump concidered after // in the ini file use. We reduce the maximum lump concidered after
// each one so that we don't risk refiltering already filtered lumps. // each one so that we don't risk refiltering already filtered lumps.
DWORD max = NumLumps; uint32_t max = NumLumps;
max -= FilterLumpsByGameType(gameinfo.gametype, lumps, lumpsize, max); max -= FilterLumpsByGameType(gameinfo.gametype, lumps, lumpsize, max);
long len; long len;
@ -390,10 +390,10 @@ void FResourceFile::PostProcessArchive(void *lumps, size_t lumpsize)
// //
//========================================================================== //==========================================================================
int FResourceFile::FilterLumps(FString filtername, void *lumps, size_t lumpsize, DWORD max) int FResourceFile::FilterLumps(FString filtername, void *lumps, size_t lumpsize, uint32_t max)
{ {
FString filter; FString filter;
DWORD start, end; uint32_t start, end;
if (filtername.IsEmpty()) if (filtername.IsEmpty())
{ {
@ -402,11 +402,11 @@ int FResourceFile::FilterLumps(FString filtername, void *lumps, size_t lumpsize,
filter << "filter/" << filtername << '/'; filter << "filter/" << filtername << '/';
if (FindPrefixRange(filter, lumps, lumpsize, max, start, end)) if (FindPrefixRange(filter, lumps, lumpsize, max, start, end))
{ {
void *from = (BYTE *)lumps + start * lumpsize; void *from = (uint8_t *)lumps + start * lumpsize;
// Remove filter prefix from every name // Remove filter prefix from every name
void *lump_p = from; void *lump_p = from;
for (DWORD i = start; i < end; ++i, lump_p = (BYTE *)lump_p + lumpsize) for (uint32_t i = start; i < end; ++i, lump_p = (uint8_t *)lump_p + lumpsize)
{ {
FResourceLump *lump = (FResourceLump *)lump_p; FResourceLump *lump = (FResourceLump *)lump_p;
assert(lump->FullName.CompareNoCase(filter, (int)filter.Len()) == 0); assert(lump->FullName.CompareNoCase(filter, (int)filter.Len()) == 0);
@ -415,17 +415,17 @@ int FResourceFile::FilterLumps(FString filtername, void *lumps, size_t lumpsize,
// Move filtered lumps to the end of the lump list. // Move filtered lumps to the end of the lump list.
size_t count = (end - start) * lumpsize; size_t count = (end - start) * lumpsize;
void *to = (BYTE *)lumps + NumLumps * lumpsize - count; void *to = (uint8_t *)lumps + NumLumps * lumpsize - count;
assert (to >= from); assert (to >= from);
if (from != to) if (from != to)
{ {
// Copy filtered lumps to a temporary buffer. // Copy filtered lumps to a temporary buffer.
BYTE *filteredlumps = new BYTE[count]; uint8_t *filteredlumps = new uint8_t[count];
memcpy(filteredlumps, from, count); memcpy(filteredlumps, from, count);
// Shift lumps left to make room for the filtered ones at the end. // Shift lumps left to make room for the filtered ones at the end.
memmove(from, (BYTE *)from + count, (NumLumps - end) * lumpsize); memmove(from, (uint8_t *)from + count, (NumLumps - end) * lumpsize);
// Copy temporary buffer to newly freed space. // Copy temporary buffer to newly freed space.
memcpy(to, filteredlumps, count); memcpy(to, filteredlumps, count);
@ -445,7 +445,7 @@ int FResourceFile::FilterLumps(FString filtername, void *lumps, size_t lumpsize,
// //
//========================================================================== //==========================================================================
int FResourceFile::FilterLumpsByGameType(int type, void *lumps, size_t lumpsize, DWORD max) int FResourceFile::FilterLumpsByGameType(int type, void *lumps, size_t lumpsize, uint32_t max)
{ {
static const struct { int match; const char *name; } blanket[] = static const struct { int match; const char *name; } blanket[] =
{ {
@ -479,16 +479,16 @@ int FResourceFile::FilterLumpsByGameType(int type, void *lumps, size_t lumpsize,
// //
//========================================================================== //==========================================================================
void FResourceFile::JunkLeftoverFilters(void *lumps, size_t lumpsize, DWORD max) void FResourceFile::JunkLeftoverFilters(void *lumps, size_t lumpsize, uint32_t max)
{ {
DWORD start, end; uint32_t start, end;
if (FindPrefixRange("filter/", lumps, lumpsize, max, start, end)) if (FindPrefixRange("filter/", lumps, lumpsize, max, start, end))
{ {
// Since the resource lumps may contain non-POD data besides the // Since the resource lumps may contain non-POD data besides the
// full name, we "delete" them by erasing their names so they // full name, we "delete" them by erasing their names so they
// can't be found. // can't be found.
void *stop = (BYTE *)lumps + end * lumpsize; void *stop = (uint8_t *)lumps + end * lumpsize;
for (void *p = (BYTE *)lumps + start * lumpsize; p < stop; p = (BYTE *)p + lumpsize) for (void *p = (uint8_t *)lumps + start * lumpsize; p < stop; p = (uint8_t *)p + lumpsize)
{ {
FResourceLump *lump = (FResourceLump *)p; FResourceLump *lump = (FResourceLump *)p;
lump->FullName = 0; lump->FullName = 0;
@ -508,9 +508,9 @@ void FResourceFile::JunkLeftoverFilters(void *lumps, size_t lumpsize, DWORD max)
// //
//========================================================================== //==========================================================================
bool FResourceFile::FindPrefixRange(FString filter, void *lumps, size_t lumpsize, DWORD maxlump, DWORD &start, DWORD &end) bool FResourceFile::FindPrefixRange(FString filter, void *lumps, size_t lumpsize, uint32_t maxlump, uint32_t &start, uint32_t &end)
{ {
DWORD min, max, mid, inside; uint32_t min, max, mid, inside;
FResourceLump *lump; FResourceLump *lump;
int cmp; int cmp;
@ -518,14 +518,14 @@ bool FResourceFile::FindPrefixRange(FString filter, void *lumps, size_t lumpsize
// Pretend that our range starts at 1 instead of 0 so that we can avoid // Pretend that our range starts at 1 instead of 0 so that we can avoid
// unsigned overflow if the range starts at the first lump. // unsigned overflow if the range starts at the first lump.
lumps = (BYTE *)lumps - lumpsize; lumps = (uint8_t *)lumps - lumpsize;
// Binary search to find any match at all. // Binary search to find any match at all.
min = 1, max = maxlump; min = 1, max = maxlump;
while (min <= max) while (min <= max)
{ {
mid = min + (max - min) / 2; mid = min + (max - min) / 2;
lump = (FResourceLump *)((BYTE *)lumps + mid * lumpsize); lump = (FResourceLump *)((uint8_t *)lumps + mid * lumpsize);
cmp = lump->FullName.CompareNoCase(filter, (int)filter.Len()); cmp = lump->FullName.CompareNoCase(filter, (int)filter.Len());
if (cmp == 0) if (cmp == 0)
break; break;
@ -545,7 +545,7 @@ bool FResourceFile::FindPrefixRange(FString filter, void *lumps, size_t lumpsize
while (min <= max) while (min <= max)
{ {
mid = min + (max - min) / 2; mid = min + (max - min) / 2;
lump = (FResourceLump *)((BYTE *)lumps + mid * lumpsize); lump = (FResourceLump *)((uint8_t *)lumps + mid * lumpsize);
cmp = lump->FullName.CompareNoCase(filter, (int)filter.Len()); cmp = lump->FullName.CompareNoCase(filter, (int)filter.Len());
// Go left on matches and right on misses. // Go left on matches and right on misses.
if (cmp == 0) if (cmp == 0)
@ -560,7 +560,7 @@ bool FResourceFile::FindPrefixRange(FString filter, void *lumps, size_t lumpsize
while (min <= max) while (min <= max)
{ {
mid = min + (max - min) / 2; mid = min + (max - min) / 2;
lump = (FResourceLump *)((BYTE *)lumps + mid * lumpsize); lump = (FResourceLump *)((uint8_t *)lumps + mid * lumpsize);
cmp = lump->FullName.CompareNoCase(filter, (int)filter.Len()); cmp = lump->FullName.CompareNoCase(filter, (int)filter.Len());
// Go right on matches and left on misses. // Go right on matches and left on misses.
if (cmp == 0) if (cmp == 0)

View file

@ -40,11 +40,11 @@ struct FResourceLump
{ {
char Name[9]; char Name[9];
DWORD dwName; // These are for accessing the first 4 or 8 chars of uint32_t dwName; // These are for accessing the first 4 or 8 chars of
QWORD qwName; // Name as a unit without breaking strict aliasing rules QWORD qwName; // Name as a unit without breaking strict aliasing rules
}; };
BYTE Flags; uint8_t Flags;
SBYTE RefCount; int8_t RefCount;
char * Cache; char * Cache;
FResourceFile * Owner; FResourceFile * Owner;
FTexture * LinkedTexture; FTexture * LinkedTexture;
@ -84,7 +84,7 @@ public:
FileReader *Reader; FileReader *Reader;
const char *Filename; const char *Filename;
protected: protected:
DWORD NumLumps; uint32_t NumLumps;
FResourceFile(const char *filename, FileReader *r); FResourceFile(const char *filename, FileReader *r);
@ -92,21 +92,21 @@ protected:
void PostProcessArchive(void *lumps, size_t lumpsize); void PostProcessArchive(void *lumps, size_t lumpsize);
private: private:
DWORD FirstLump; uint32_t FirstLump;
int FilterLumps(FString filtername, void *lumps, size_t lumpsize, DWORD max); int FilterLumps(FString filtername, void *lumps, size_t lumpsize, uint32_t max);
int FilterLumpsByGameType(int gametype, void *lumps, size_t lumpsize, DWORD max); int FilterLumpsByGameType(int gametype, void *lumps, size_t lumpsize, uint32_t max);
bool FindPrefixRange(FString filter, void *lumps, size_t lumpsize, DWORD max, DWORD &start, DWORD &end); bool FindPrefixRange(FString filter, void *lumps, size_t lumpsize, uint32_t max, uint32_t &start, uint32_t &end);
void JunkLeftoverFilters(void *lumps, size_t lumpsize, DWORD max); void JunkLeftoverFilters(void *lumps, size_t lumpsize, uint32_t max);
public: public:
static FResourceFile *OpenResourceFile(const char *filename, FileReader *file, bool quiet = false, bool containeronly = false); static FResourceFile *OpenResourceFile(const char *filename, FileReader *file, bool quiet = false, bool containeronly = false);
static FResourceFile *OpenDirectory(const char *filename, bool quiet = false); static FResourceFile *OpenDirectory(const char *filename, bool quiet = false);
virtual ~FResourceFile(); virtual ~FResourceFile();
FileReader *GetReader() const { return Reader; } FileReader *GetReader() const { return Reader; }
DWORD LumpCount() const { return NumLumps; } uint32_t LumpCount() const { return NumLumps; }
DWORD GetFirstLump() const { return FirstLump; } uint32_t GetFirstLump() const { return FirstLump; }
void SetFirstLump(DWORD f) { FirstLump = f; } void SetFirstLump(uint32_t f) { FirstLump = f; }
virtual void FindStrifeTeaserVoices (); virtual void FindStrifeTeaserVoices ();
virtual bool Open(bool quiet) = 0; virtual bool Open(bool quiet) = 0;

View file

@ -2466,7 +2466,7 @@ FxExpression *FxAssign::Resolve(FCompileContext &ctx)
ExpEmit FxAssign::Emit(VMFunctionBuilder *build) ExpEmit FxAssign::Emit(VMFunctionBuilder *build)
{ {
static const BYTE loadops[] = { OP_LK, OP_LKF, OP_LKS, OP_LKP }; static const uint8_t loadops[] = { OP_LK, OP_LKF, OP_LKS, OP_LKP };
assert(Base->ValueType->GetRegType() == Right->ValueType->GetRegType()); assert(Base->ValueType->GetRegType() == Right->ValueType->GetRegType());
ExpEmit pointer = Base->Emit(build); ExpEmit pointer = Base->Emit(build);

View file

@ -40,7 +40,7 @@
struct VMRemap struct VMRemap
{ {
BYTE altOp, kReg, kType; uint8_t altOp, kReg, kType;
}; };
@ -563,7 +563,7 @@ size_t VMFunctionBuilder::GetAddress()
size_t VMFunctionBuilder::Emit(int opcode, int opa, int opb, int opc) size_t VMFunctionBuilder::Emit(int opcode, int opa, int opb, int opc)
{ {
static BYTE opcodes[] = { OP_LK, OP_LKF, OP_LKS, OP_LKP }; static uint8_t opcodes[] = { OP_LK, OP_LKF, OP_LKS, OP_LKP };
assert(opcode >= 0 && opcode < NUM_OPS); assert(opcode >= 0 && opcode < NUM_OPS);
assert(opa >= 0); assert(opa >= 0);

View file

@ -331,7 +331,7 @@ static void ParseInsideDecoration (Baggage &bag, AActor *defaults,
{ {
sc.ScriptError ("DoomEdNum must be in the range [-1,32767]"); sc.ScriptError ("DoomEdNum must be in the range [-1,32767]");
} }
bag.Info->DoomEdNum = (SWORD)sc.Number; bag.Info->DoomEdNum = (int16_t)sc.Number;
} }
else if (sc.Compare ("SpawnNum")) else if (sc.Compare ("SpawnNum"))
{ {
@ -340,7 +340,7 @@ static void ParseInsideDecoration (Baggage &bag, AActor *defaults,
{ {
sc.ScriptError ("SpawnNum must be in the range [0,255]"); sc.ScriptError ("SpawnNum must be in the range [0,255]");
} }
bag.Info->SpawnID = (BYTE)sc.Number; bag.Info->SpawnID = (uint8_t)sc.Number;
} }
else if (sc.Compare ("Sprite") || ( else if (sc.Compare ("Sprite") || (
(def == DEF_BreakableDecoration || def == DEF_Projectile) && (def == DEF_BreakableDecoration || def == DEF_Projectile) &&

View file

@ -610,7 +610,7 @@ void ParseFunctionParameters(FScanner &sc, PClassActor *cls, TArray<FxExpression
PFunction *afd, FString statestring, FStateDefinitions *statedef) PFunction *afd, FString statestring, FStateDefinitions *statedef)
{ {
const TArray<PType *> &params = afd->Variants[0].Proto->ArgumentTypes; const TArray<PType *> &params = afd->Variants[0].Proto->ArgumentTypes;
const TArray<DWORD> &paramflags = afd->Variants[0].ArgFlags; const TArray<uint32_t> &paramflags = afd->Variants[0].ArgFlags;
int numparams = (int)params.Size(); int numparams = (int)params.Size();
int pnum = 0; int pnum = 0;
bool zeroparm; bool zeroparm;

View file

@ -79,7 +79,7 @@ PSymbolConstString::PSymbolConstString(FName name, const FString &str)
// //
//========================================================================== //==========================================================================
unsigned PFunction::AddVariant(PPrototype *proto, TArray<DWORD> &argflags, TArray<FName> &argnames, VMFunction *impl, int flags, int useflags) unsigned PFunction::AddVariant(PPrototype *proto, TArray<uint32_t> &argflags, TArray<FName> &argnames, VMFunction *impl, int flags, int useflags)
{ {
Variant variant; Variant variant;

View file

@ -101,7 +101,7 @@ FScriptPosition & GetStateSource(FState *state)
// //
//========================================================================== //==========================================================================
void SetImplicitArgs(TArray<PType *> *args, TArray<DWORD> *argflags, TArray<FName> *argnames, PStruct *cls, DWORD funcflags, int useflags) void SetImplicitArgs(TArray<PType *> *args, TArray<uint32_t> *argflags, TArray<FName> *argnames, PStruct *cls, uint32_t funcflags, int useflags)
{ {
// Must be called before adding any other arguments. // Must be called before adding any other arguments.
assert(args == nullptr || args->Size() == 0); assert(args == nullptr || args->Size() == 0);

View file

@ -52,7 +52,7 @@ struct FStateDefine
FName Label; FName Label;
TArray<FStateDefine> Children; TArray<FStateDefine> Children;
FState *State; FState *State;
BYTE DefineFlags; uint8_t DefineFlags;
}; };
class FStateDefinitions class FStateDefinitions
@ -83,7 +83,7 @@ public:
lastlabel = -1; lastlabel = -1;
} }
void SetStateLabel(const char *statename, FState *state, BYTE defflags = SDF_STATE); void SetStateLabel(const char *statename, FState *state, uint8_t defflags = SDF_STATE);
void AddStateLabel(const char *statename); void AddStateLabel(const char *statename);
int GetStateLabelIndex (FName statename); int GetStateLabelIndex (FName statename);
void InstallStates(PClassActor *info, AActor *defaults); void InstallStates(PClassActor *info, AActor *defaults);
@ -159,7 +159,7 @@ void ParseFunctionParameters(FScanner &sc, PClassActor *cls, TArray<FxExpression
FxExpression *ParseActions(FScanner &sc, FState state, FString statestring, Baggage &bag, bool &endswithret); FxExpression *ParseActions(FScanner &sc, FState state, FString statestring, Baggage &bag, bool &endswithret);
class FxVMFunctionCall *ParseAction(FScanner &sc, FState state, FString statestring, Baggage &bag); class FxVMFunctionCall *ParseAction(FScanner &sc, FState state, FString statestring, Baggage &bag);
FName CheckCastKludges(FName in); FName CheckCastKludges(FName in);
void SetImplicitArgs(TArray<PType *> *args, TArray<DWORD> *argflags, TArray<FName> *argnames, PStruct *cls, DWORD funcflags, int useflags); void SetImplicitArgs(TArray<PType *> *args, TArray<uint32_t> *argflags, TArray<FName> *argnames, PStruct *cls, uint32_t funcflags, int useflags);
PFunction *CreateAnonymousFunction(PClass *containingclass, PType *returntype, int flags); PFunction *CreateAnonymousFunction(PClass *containingclass, PType *returntype, int flags);
PFunction *FindClassMemberFunction(PStruct *cls, PStruct *funccls, FName name, FScriptPosition &sc, bool *error); PFunction *FindClassMemberFunction(PStruct *cls, PStruct *funccls, FName name, FScriptPosition &sc, bool *error);
void CreateDamageFunction(PNamespace *ns, const VersionInfo &ver, PClassActor *info, AActor *defaults, FxExpression *id, bool fromDecorate, int lumpnum); void CreateDamageFunction(PNamespace *ns, const VersionInfo &ver, PClassActor *info, AActor *defaults, FxExpression *id, bool fromDecorate, int lumpnum);

View file

@ -123,7 +123,7 @@ void ModActorFlag(AActor *actor, FFlagDef *fd, bool set)
if (fd->fieldsize == 4) if (fd->fieldsize == 4)
#endif #endif
{ {
DWORD *flagvar = (DWORD *)((char *)actor + fd->structoffset); uint32_t *flagvar = (uint32_t *)((char *)actor + fd->structoffset);
if (set) if (set)
{ {
*flagvar |= fd->flagbit; *flagvar |= fd->flagbit;
@ -136,7 +136,7 @@ void ModActorFlag(AActor *actor, FFlagDef *fd, bool set)
#ifdef __BIG_ENDIAN__ #ifdef __BIG_ENDIAN__
else if (fd->fieldsize == 2) else if (fd->fieldsize == 2)
{ {
WORD *flagvar = (WORD *)((char *)actor + fd->structoffset); uint16_t *flagvar = (uint16_t *)((char *)actor + fd->structoffset);
if (set) if (set)
{ {
*flagvar |= fd->flagbit; *flagvar |= fd->flagbit;
@ -149,7 +149,7 @@ void ModActorFlag(AActor *actor, FFlagDef *fd, bool set)
else else
{ {
assert(fd->fieldsize == 1); assert(fd->fieldsize == 1);
BYTE *flagvar = (BYTE *)((char *)actor + fd->structoffset); uint8_t *flagvar = (uint8_t *)((char *)actor + fd->structoffset);
if (set) if (set)
{ {
*flagvar |= fd->flagbit; *flagvar |= fd->flagbit;
@ -245,17 +245,17 @@ INTBOOL CheckActorFlag(const AActor *owner, FFlagDef *fd)
if (fd->fieldsize == 4) if (fd->fieldsize == 4)
#endif #endif
{ {
return fd->flagbit & *(DWORD *)(((char*)owner) + fd->structoffset); return fd->flagbit & *(uint32_t *)(((char*)owner) + fd->structoffset);
} }
#ifdef __BIG_ENDIAN__ #ifdef __BIG_ENDIAN__
else if (fd->fieldsize == 2) else if (fd->fieldsize == 2)
{ {
return fd->flagbit & *(WORD *)(((char*)owner) + fd->structoffset); return fd->flagbit & *(uint16_t *)(((char*)owner) + fd->structoffset);
} }
else else
{ {
assert(fd->fieldsize == 1); assert(fd->fieldsize == 1);
return fd->flagbit & *(BYTE *)(((char*)owner) + fd->structoffset); return fd->flagbit & *(uint8_t *)(((char*)owner) + fd->structoffset);
} }
#endif #endif
} }
@ -520,7 +520,7 @@ DEFINE_INFO_PROPERTY(spawnid, I, Actor)
{ {
I_Error ("SpawnID must be in the range [0,65535]"); I_Error ("SpawnID must be in the range [0,65535]");
} }
else info->SpawnID=(WORD)id; else info->SpawnID=(uint16_t)id;
} }
//========================================================================== //==========================================================================
@ -533,7 +533,7 @@ DEFINE_INFO_PROPERTY(conversationid, IiI, Actor)
PROP_INT_PARM(id2, 2); PROP_INT_PARM(id2, 2);
if (convid <= 0 || convid > 65535) return; // 0 is not usable because the dialogue scripts use it as 'no object'. if (convid <= 0 || convid > 65535) return; // 0 is not usable because the dialogue scripts use it as 'no object'.
else info->ConversationID=(WORD)convid; else info->ConversationID=(uint16_t)convid;
} }
//========================================================================== //==========================================================================
@ -2507,7 +2507,7 @@ DEFINE_CLASS_PROPERTY_PREFIX(player, damagescreencolor, Cfs, PlayerPawn)
{ {
PROP_DOUBLE_PARM(a, 2); PROP_DOUBLE_PARM(a, 2);
color.a = BYTE(255 * clamp<double>(a, 0.f, 1.f)); color.a = uint8_t(255 * clamp<double>(a, 0.f, 1.f));
defaults->DamageFade = color; defaults->DamageFade = color;
} }
else else
@ -2515,7 +2515,7 @@ DEFINE_CLASS_PROPERTY_PREFIX(player, damagescreencolor, Cfs, PlayerPawn)
PROP_DOUBLE_PARM(a, 2); PROP_DOUBLE_PARM(a, 2);
PROP_STRING_PARM(type, 3); PROP_STRING_PARM(type, 3);
color.a = BYTE(255 * clamp<double>(a, 0.f, 1.f)); color.a = uint8_t(255 * clamp<double>(a, 0.f, 1.f));
PainFlashes.Push(std::make_tuple(info, type, color)); PainFlashes.Push(std::make_tuple(info, type, color));
} }
} }

View file

@ -704,7 +704,7 @@ class VMFunction
public: public:
bool Unsafe = false; bool Unsafe = false;
int VarFlags = 0; // [ZZ] this replaces 5+ bool fields int VarFlags = 0; // [ZZ] this replaces 5+ bool fields
BYTE ImplicitArgs = 0; // either 0 for static, 1 for method or 3 for action uint8_t ImplicitArgs = 0; // either 0 for static, 1 for method or 3 for action
unsigned VirtualIndex = ~0u; unsigned VirtualIndex = ~0u;
FName Name; FName Name;
TArray<VMValue> DefaultArgs; TArray<VMValue> DefaultArgs;

View file

@ -2292,7 +2292,7 @@ void ZCCCompiler::CompileFunction(ZCC_StructWork *c, ZCC_FuncDeclarator *f, bool
} }
else else
{ {
(*afd->VMPointer)->ImplicitArgs = BYTE(implicitargs); (*afd->VMPointer)->ImplicitArgs = uint8_t(implicitargs);
} }
} }
SetImplicitArgs(&args, &argflags, &argnames, c->Type(), varflags, useflags); SetImplicitArgs(&args, &argflags, &argnames, c->Type(), varflags, useflags);

View file

@ -64,14 +64,14 @@ void AddInclude(ZCC_ExprConstant *node)
struct TokenMapEntry struct TokenMapEntry
{ {
SWORD TokenType; int16_t TokenType;
WORD TokenName; uint16_t TokenName;
TokenMapEntry(SWORD a, WORD b) TokenMapEntry(int16_t a, uint16_t b)
: TokenType(a), TokenName(b) : TokenType(a), TokenName(b)
{ } { }
}; };
static TMap<SWORD, TokenMapEntry> TokenMap; static TMap<int16_t, TokenMapEntry> TokenMap;
static SWORD BackTokenMap[YYERRORSYMBOL]; // YYERRORSYMBOL immediately follows the terminals described by the grammar static int16_t BackTokenMap[YYERRORSYMBOL]; // YYERRORSYMBOL immediately follows the terminals described by the grammar
#define TOKENDEF2(sc, zcc, name) { TokenMapEntry tme(zcc, name); TokenMap.Insert(sc, tme); } BackTokenMap[zcc] = sc #define TOKENDEF2(sc, zcc, name) { TokenMapEntry tme(zcc, name); TokenMap.Insert(sc, tme); } BackTokenMap[zcc] = sc
#define TOKENDEF(sc, zcc) TOKENDEF2(sc, zcc, NAME_None) #define TOKENDEF(sc, zcc) TOKENDEF2(sc, zcc, NAME_None)

View file

@ -29,7 +29,7 @@
#endif #endif
/** a parity check vector which certificate the period of 2^{MEXP} */ /** a parity check vector which certificate the period of 2^{MEXP} */
static const DWORD parity[4] = { PARITY1, PARITY2, PARITY3, PARITY4 }; static const uint32_t parity[4] = { PARITY1, PARITY2, PARITY3, PARITY4 };
/*---------------- /*----------------
STATIC FUNCTIONS STATIC FUNCTIONS
@ -37,8 +37,8 @@ STATIC FUNCTIONS
inline static int idxof(int i); inline static int idxof(int i);
inline static void rshift128(w128_t *out, w128_t const *in, int shift); inline static void rshift128(w128_t *out, w128_t const *in, int shift);
inline static void lshift128(w128_t *out, w128_t const *in, int shift); inline static void lshift128(w128_t *out, w128_t const *in, int shift);
inline static DWORD func1(DWORD x); inline static uint32_t func1(uint32_t x);
inline static DWORD func2(DWORD x); inline static uint32_t func2(uint32_t x);
#if defined(BIG_ENDIAN64) && !defined(ONLY64) #if defined(BIG_ENDIAN64) && !defined(ONLY64)
inline static void swap(w128_t *array, int size); inline static void swap(w128_t *array, int size);
#endif #endif
@ -89,10 +89,10 @@ inline static void rshift128(w128_t *out, w128_t const *in, int shift) {
oh = th >> (shift * 8); oh = th >> (shift * 8);
ol = tl >> (shift * 8); ol = tl >> (shift * 8);
ol |= th << (64 - shift * 8); ol |= th << (64 - shift * 8);
out->u[0] = (DWORD)(ol >> 32); out->u[0] = (uint32_t)(ol >> 32);
out->u[1] = (DWORD)ol; out->u[1] = (uint32_t)ol;
out->u[2] = (DWORD)(oh >> 32); out->u[2] = (uint32_t)(oh >> 32);
out->u[3] = (DWORD)oh; out->u[3] = (uint32_t)oh;
} }
#else #else
inline static void rshift128(w128_t *out, w128_t const *in, int shift) { inline static void rshift128(w128_t *out, w128_t const *in, int shift) {
@ -104,10 +104,10 @@ inline static void rshift128(w128_t *out, w128_t const *in, int shift) {
oh = th >> (shift * 8); oh = th >> (shift * 8);
ol = tl >> (shift * 8); ol = tl >> (shift * 8);
ol |= th << (64 - shift * 8); ol |= th << (64 - shift * 8);
out->u[1] = (DWORD)(ol >> 32); out->u[1] = (uint32_t)(ol >> 32);
out->u[0] = (DWORD)ol; out->u[0] = (uint32_t)ol;
out->u[3] = (DWORD)(oh >> 32); out->u[3] = (uint32_t)(oh >> 32);
out->u[2] = (DWORD)oh; out->u[2] = (uint32_t)oh;
} }
#endif #endif
/** /**
@ -128,10 +128,10 @@ inline static void lshift128(w128_t *out, w128_t const *in, int shift) {
oh = th << (shift * 8); oh = th << (shift * 8);
ol = tl << (shift * 8); ol = tl << (shift * 8);
oh |= tl >> (64 - shift * 8); oh |= tl >> (64 - shift * 8);
out->u[0] = (DWORD)(ol >> 32); out->u[0] = (uint32_t)(ol >> 32);
out->u[1] = (DWORD)ol; out->u[1] = (uint32_t)ol;
out->u[2] = (DWORD)(oh >> 32); out->u[2] = (uint32_t)(oh >> 32);
out->u[3] = (DWORD)oh; out->u[3] = (uint32_t)oh;
} }
#else #else
inline static void lshift128(w128_t *out, w128_t const *in, int shift) { inline static void lshift128(w128_t *out, w128_t const *in, int shift) {
@ -143,10 +143,10 @@ inline static void lshift128(w128_t *out, w128_t const *in, int shift) {
oh = th << (shift * 8); oh = th << (shift * 8);
ol = tl << (shift * 8); ol = tl << (shift * 8);
oh |= tl >> (64 - shift * 8); oh |= tl >> (64 - shift * 8);
out->u[1] = (DWORD)(ol >> 32); out->u[1] = (uint32_t)(ol >> 32);
out->u[0] = (DWORD)ol; out->u[0] = (uint32_t)ol;
out->u[3] = (DWORD)(oh >> 32); out->u[3] = (uint32_t)(oh >> 32);
out->u[2] = (DWORD)oh; out->u[2] = (uint32_t)oh;
} }
#endif #endif
@ -264,7 +264,7 @@ void FRandom::GenRandArray(w128_t *array, int size)
#if defined(BIG_ENDIAN64) && !defined(ONLY64) && !defined(HAVE_ALTIVEC) #if defined(BIG_ENDIAN64) && !defined(ONLY64) && !defined(HAVE_ALTIVEC)
inline static void swap(w128_t *array, int size) { inline static void swap(w128_t *array, int size) {
int i; int i;
DWORD x, y; uint32_t x, y;
for (i = 0; i < size; i++) { for (i = 0; i < size; i++) {
x = array[i].u[0]; x = array[i].u[0];
@ -282,9 +282,9 @@ inline static void swap(w128_t *array, int size) {
* @param x 32-bit integer * @param x 32-bit integer
* @return 32-bit integer * @return 32-bit integer
*/ */
static DWORD func1(DWORD x) static uint32_t func1(uint32_t x)
{ {
return (x ^ (x >> 27)) * (DWORD)1664525UL; return (x ^ (x >> 27)) * (uint32_t)1664525UL;
} }
/** /**
@ -293,9 +293,9 @@ static DWORD func1(DWORD x)
* @param x 32-bit integer * @param x 32-bit integer
* @return 32-bit integer * @return 32-bit integer
*/ */
static DWORD func2(DWORD x) static uint32_t func2(uint32_t x)
{ {
return (x ^ (x >> 27)) * (DWORD)1566083941UL; return (x ^ (x >> 27)) * (uint32_t)1566083941UL;
} }
/** /**
@ -305,7 +305,7 @@ void FRandom::PeriodCertification()
{ {
int inner = 0; int inner = 0;
int i, j; int i, j;
DWORD work; uint32_t work;
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
inner ^= sfmt.u[idxof(i)] & parity[i]; inner ^= sfmt.u[idxof(i)] & parity[i];
@ -360,7 +360,7 @@ int FRandom::GetMinArraySize64()
*/ */
unsigned int FRandom::GenRand32() unsigned int FRandom::GenRand32()
{ {
DWORD r; uint32_t r;
assert(initialized); assert(initialized);
if (idx >= SFMT::N32) if (idx >= SFMT::N32)
@ -382,7 +382,7 @@ unsigned int FRandom::GenRand32()
QWORD FRandom::GenRand64() QWORD FRandom::GenRand64()
{ {
#if defined(BIG_ENDIAN64) && !defined(ONLY64) #if defined(BIG_ENDIAN64) && !defined(ONLY64)
DWORD r1, r2; uint32_t r1, r2;
#else #else
QWORD r; QWORD r;
#endif #endif
@ -433,7 +433,7 @@ QWORD FRandom::GenRand64()
* memory. Mac OSX doesn't have these functions, but \b malloc of OSX * memory. Mac OSX doesn't have these functions, but \b malloc of OSX
* returns the pointer to the aligned memory block. * returns the pointer to the aligned memory block.
*/ */
void FRandom::FillArray32(DWORD *array, int size) void FRandom::FillArray32(uint32_t *array, int size)
{ {
assert(initialized); assert(initialized);
assert(idx == SFMT::N32); assert(idx == SFMT::N32);
@ -491,7 +491,7 @@ void FRandom::FillArray64(QWORD *array, int size)
* *
* @param seed a 32-bit integer used as the seed. * @param seed a 32-bit integer used as the seed.
*/ */
void FRandom::InitGenRand(DWORD seed) void FRandom::InitGenRand(uint32_t seed)
{ {
int i; int i;
@ -515,10 +515,10 @@ void FRandom::InitGenRand(DWORD seed)
* @param init_key the array of 32-bit integers, used as a seed. * @param init_key the array of 32-bit integers, used as a seed.
* @param key_length the length of init_key. * @param key_length the length of init_key.
*/ */
void FRandom::InitByArray(DWORD *init_key, int key_length) void FRandom::InitByArray(uint32_t *init_key, int key_length)
{ {
int i, j, count; int i, j, count;
DWORD r; uint32_t r;
int lag; int lag;
int mid; int mid;
int size = SFMT::N * 4; int size = SFMT::N * 4;

View file

@ -67,7 +67,7 @@
/** 128-bit data structure */ /** 128-bit data structure */
union w128_t { union w128_t {
vector unsigned int s; vector unsigned int s;
DWORD u[4]; uint32_t u[4];
QWORD u64[2]; QWORD u64[2];
}; };
@ -77,7 +77,7 @@ union w128_t {
/** 128-bit data structure */ /** 128-bit data structure */
union w128_t { union w128_t {
__m128i si; __m128i si;
DWORD u[4]; uint32_t u[4];
QWORD u64[2]; QWORD u64[2];
}; };
@ -85,7 +85,7 @@ union w128_t {
/** 128-bit data structure */ /** 128-bit data structure */
union w128_t { union w128_t {
DWORD u[4]; uint32_t u[4];
QWORD u64[2]; QWORD u64[2];
}; };

View file

@ -95,7 +95,7 @@ FAnimDef *FTextureManager::AddAnim (FAnimDef *anim)
// //
//========================================================================== //==========================================================================
FAnimDef *FTextureManager::AddSimpleAnim (FTextureID picnum, int animcount, DWORD speedmin, DWORD speedrange) FAnimDef *FTextureManager::AddSimpleAnim (FTextureID picnum, int animcount, uint32_t speedmin, uint32_t speedrange)
{ {
if (AreTexturesCompatible(picnum, picnum + (animcount - 1))) if (AreTexturesCompatible(picnum, picnum + (animcount - 1)))
{ {
@ -187,11 +187,11 @@ void FTextureManager::InitAnimated (void)
{ {
FMemLump animatedlump = Wads.ReadLump (lumpnum); FMemLump animatedlump = Wads.ReadLump (lumpnum);
int animatedlen = Wads.LumpLength(lumpnum); int animatedlen = Wads.LumpLength(lumpnum);
const BYTE *animdefs = (const BYTE *)animatedlump.GetMem(); const uint8_t *animdefs = (const uint8_t *)animatedlump.GetMem();
const BYTE *anim_p; const uint8_t *anim_p;
FTextureID pic1, pic2; FTextureID pic1, pic2;
int animtype; int animtype;
DWORD animspeed; uint32_t animspeed;
// Init animation // Init animation
animtype = FAnimDef::ANIM_Forward; animtype = FAnimDef::ANIM_Forward;
@ -349,7 +349,7 @@ void FTextureManager::ParseAnim (FScanner &sc, int usetype)
int defined = 0; int defined = 0;
bool optional = false, missing = false; bool optional = false, missing = false;
FAnimDef *ani = NULL; FAnimDef *ani = NULL;
BYTE type = FAnimDef::ANIM_Forward; uint8_t type = FAnimDef::ANIM_Forward;
sc.MustGetString (); sc.MustGetString ();
if (sc.Compare ("optional")) if (sc.Compare ("optional"))
@ -467,7 +467,7 @@ FAnimDef *FTextureManager::ParseRangeAnim (FScanner &sc, FTextureID picnum, int
{ {
int type; int type;
FTextureID framenum; FTextureID framenum;
DWORD min, max; uint32_t min, max;
type = FAnimDef::ANIM_Forward; type = FAnimDef::ANIM_Forward;
framenum = ParseFramenum (sc, picnum, usetype, missing); framenum = ParseFramenum (sc, picnum, usetype, missing);
@ -507,7 +507,7 @@ FAnimDef *FTextureManager::ParseRangeAnim (FScanner &sc, FTextureID picnum, int
void FTextureManager::ParsePicAnim (FScanner &sc, FTextureID picnum, int usetype, bool missing, TArray<FAnimDef::FAnimFrame> &frames) void FTextureManager::ParsePicAnim (FScanner &sc, FTextureID picnum, int usetype, bool missing, TArray<FAnimDef::FAnimFrame> &frames)
{ {
FTextureID framenum; FTextureID framenum;
DWORD min = 1, max = 1; uint32_t min = 1, max = 1;
framenum = ParseFramenum (sc, picnum, usetype, missing); framenum = ParseFramenum (sc, picnum, usetype, missing);
ParseTime (sc, min, max); ParseTime (sc, min, max);
@ -561,20 +561,20 @@ FTextureID FTextureManager::ParseFramenum (FScanner &sc, FTextureID basepicnum,
// //
//========================================================================== //==========================================================================
void FTextureManager::ParseTime (FScanner &sc, DWORD &min, DWORD &max) void FTextureManager::ParseTime (FScanner &sc, uint32_t &min, uint32_t &max)
{ {
sc.MustGetString (); sc.MustGetString ();
if (sc.Compare ("tics")) if (sc.Compare ("tics"))
{ {
sc.MustGetFloat (); sc.MustGetFloat ();
min = max = DWORD(sc.Float * 1000 / 35); min = max = uint32_t(sc.Float * 1000 / 35);
} }
else if (sc.Compare ("rand")) else if (sc.Compare ("rand"))
{ {
sc.MustGetFloat (); sc.MustGetFloat ();
min = DWORD(sc.Float * 1000 / 35); min = uint32_t(sc.Float * 1000 / 35);
sc.MustGetFloat (); sc.MustGetFloat ();
max = DWORD(sc.Float * 1000 / 35); max = uint32_t(sc.Float * 1000 / 35);
} }
else else
{ {
@ -876,7 +876,7 @@ FDoorAnimation *FTextureManager::FindAnimatedDoor (FTextureID picnum)
// //
//========================================================================== //==========================================================================
void FAnimDef::SetSwitchTime (DWORD mstime) void FAnimDef::SetSwitchTime (uint32_t mstime)
{ {
int speedframe = bDiscrete ? CurFrame : 0; int speedframe = bDiscrete ? CurFrame : 0;
@ -917,7 +917,7 @@ void FTextureManager::SetTranslation (FTextureID fromtexnum, FTextureID totexnum
// //
//========================================================================== //==========================================================================
void FTextureManager::UpdateAnimations (DWORD mstime) void FTextureManager::UpdateAnimations (uint32_t mstime)
{ {
for (unsigned int j = 0; j < mAnimations.Size(); ++j) for (unsigned int j = 0; j < mAnimations.Size(); ++j)
{ {
@ -955,7 +955,7 @@ void FTextureManager::UpdateAnimations (DWORD mstime)
// select a random frame other than the current one // select a random frame other than the current one
if (anim->NumFrames > 1) if (anim->NumFrames > 1)
{ {
WORD rndFrame = (WORD)pr_animatepictures(anim->NumFrames - 1); uint16_t rndFrame = (uint16_t)pr_animatepictures(anim->NumFrames - 1);
if (rndFrame >= anim->CurFrame) rndFrame++; if (rndFrame >= anim->CurFrame) rndFrame++;
anim->CurFrame = rndFrame; anim->CurFrame = rndFrame;
} }

View file

@ -51,15 +51,15 @@ class FAutomapTexture : public FTexture
public: public:
~FAutomapTexture (); ~FAutomapTexture ();
const BYTE *GetColumn (unsigned int column, const Span **spans_out); const uint8_t *GetColumn (unsigned int column, const Span **spans_out);
const BYTE *GetPixels (); const uint8_t *GetPixels ();
void Unload (); void Unload ();
void MakeTexture (); void MakeTexture ();
FAutomapTexture (int lumpnum); FAutomapTexture (int lumpnum);
private: private:
BYTE *Pixels; uint8_t *Pixels;
Span DummySpan[2]; Span DummySpan[2];
}; };
@ -89,7 +89,7 @@ FAutomapTexture::FAutomapTexture (int lumpnum)
: FTexture(NULL, lumpnum), Pixels(NULL) : FTexture(NULL, lumpnum), Pixels(NULL)
{ {
Width = 320; Width = 320;
Height = WORD(Wads.LumpLength(lumpnum) / 320); Height = uint16_t(Wads.LumpLength(lumpnum) / 320);
CalcBitSize (); CalcBitSize ();
DummySpan[0].TopOffset = 0; DummySpan[0].TopOffset = 0;
@ -134,9 +134,9 @@ void FAutomapTexture::MakeTexture ()
{ {
int x, y; int x, y;
FMemLump data = Wads.ReadLump (SourceLump); FMemLump data = Wads.ReadLump (SourceLump);
const BYTE *indata = (const BYTE *)data.GetMem(); const uint8_t *indata = (const uint8_t *)data.GetMem();
Pixels = new BYTE[Width * Height]; Pixels = new uint8_t[Width * Height];
for (x = 0; x < Width; ++x) for (x = 0; x < Width; ++x)
{ {
@ -153,7 +153,7 @@ void FAutomapTexture::MakeTexture ()
// //
//========================================================================== //==========================================================================
const BYTE *FAutomapTexture::GetPixels () const uint8_t *FAutomapTexture::GetPixels ()
{ {
if (Pixels == NULL) if (Pixels == NULL)
{ {
@ -168,7 +168,7 @@ const BYTE *FAutomapTexture::GetPixels ()
// //
//========================================================================== //==========================================================================
const BYTE *FAutomapTexture::GetColumn (unsigned int column, const Span **spans_out) const uint8_t *FAutomapTexture::GetColumn (unsigned int column, const Span **spans_out)
{ {
if (Pixels == NULL) if (Pixels == NULL)
{ {

View file

@ -273,26 +273,26 @@ void FBackdropTexture::Render()
int x, y; int x, y;
const DWORD a1add = DEGREES(0.5); const uint32_t a1add = DEGREES(0.5);
const DWORD a2add = DEGREES(359); const uint32_t a2add = DEGREES(359);
const DWORD a3add = DEGREES(5 / 7.f); const uint32_t a3add = DEGREES(5 / 7.f);
const DWORD a4add = DEGREES(358.66666); const uint32_t a4add = DEGREES(358.66666);
const DWORD t1add = DEGREES(358); const uint32_t t1add = DEGREES(358);
const DWORD t2add = DEGREES(357.16666); const uint32_t t2add = DEGREES(357.16666);
const DWORD t3add = DEGREES(2.285); const uint32_t t3add = DEGREES(2.285);
const DWORD t4add = DEGREES(359.33333); const uint32_t t4add = DEGREES(359.33333);
const DWORD x1add = 5 * 524288; const uint32_t x1add = 5 * 524288;
const DWORD x2add = 0u - 13 * 524288; const uint32_t x2add = 0u - 13 * 524288;
const DWORD z1add = 3 * 524288; const uint32_t z1add = 3 * 524288;
const DWORD z2add = 4 * 524288; const uint32_t z2add = 4 * 524288;
DWORD a1, a2, a3, a4; uint32_t a1, a2, a3, a4;
int32_t c1, c2, c3, c4; int32_t c1, c2, c3, c4;
DWORD tx, ty, tc, ts; uint32_t tx, ty, tc, ts;
DWORD ux, uy, uc, us; uint32_t ux, uy, uc, us;
DWORD ltx, lty, lux, luy; uint32_t ltx, lty, lux, luy;
from = Pixels; from = Pixels;

View file

@ -46,12 +46,12 @@
// //
//=========================================================================== //===========================================================================
template<class TSrc, class TDest, class TBlend> template<class TSrc, class TDest, class TBlend>
void iCopyColors(BYTE *pout, const BYTE *pin, int count, int step, FCopyInfo *inf, void iCopyColors(uint8_t *pout, const uint8_t *pin, int count, int step, FCopyInfo *inf,
BYTE tr, BYTE tg, BYTE tb) uint8_t tr, uint8_t tg, uint8_t tb)
{ {
int i; int i;
int fac; int fac;
BYTE r,g,b; uint8_t r,g,b;
int gray; int gray;
int a; int a;
@ -184,7 +184,7 @@ void iCopyColors(BYTE *pout, const BYTE *pin, int count, int step, FCopyInfo *in
} }
} }
typedef void (*CopyFunc)(BYTE *pout, const BYTE *pin, int count, int step, FCopyInfo *inf, BYTE r, BYTE g, BYTE b); typedef void (*CopyFunc)(uint8_t *pout, const uint8_t *pin, int count, int step, FCopyInfo *inf, uint8_t r, uint8_t g, uint8_t b);
#define COPY_FUNCS(op) \ #define COPY_FUNCS(op) \
{ \ { \
@ -219,7 +219,7 @@ static const CopyFunc copyfuncs[][10]={
// //
//=========================================================================== //===========================================================================
bool ClipCopyPixelRect(const FClipRect *cr, int &originx, int &originy, bool ClipCopyPixelRect(const FClipRect *cr, int &originx, int &originy,
const BYTE *&patch, int &srcwidth, int &srcheight, const uint8_t *&patch, int &srcwidth, int &srcheight,
int &pstep_x, int &pstep_y, int rotate) int &pstep_x, int &pstep_y, int rotate)
{ {
int pixxoffset; int pixxoffset;
@ -371,13 +371,13 @@ bool FClipRect::Intersect(int ix, int iy, int iw, int ih)
// True Color texture copy function // True Color texture copy function
// //
//=========================================================================== //===========================================================================
void FBitmap::CopyPixelDataRGB(int originx, int originy, const BYTE *patch, int srcwidth, void FBitmap::CopyPixelDataRGB(int originx, int originy, const uint8_t *patch, int srcwidth,
int srcheight, int step_x, int step_y, int rotate, int ct, FCopyInfo *inf, int srcheight, int step_x, int step_y, int rotate, int ct, FCopyInfo *inf,
int r, int g, int b) int r, int g, int b)
{ {
if (ClipCopyPixelRect(&ClipRect, originx, originy, patch, srcwidth, srcheight, step_x, step_y, rotate)) if (ClipCopyPixelRect(&ClipRect, originx, originy, patch, srcwidth, srcheight, step_x, step_y, rotate))
{ {
BYTE *buffer = data + 4 * originx + Pitch * originy; uint8_t *buffer = data + 4 * originx + Pitch * originy;
int op = inf==NULL? OP_COPY : inf->op; int op = inf==NULL? OP_COPY : inf->op;
for (int y=0;y<srcheight;y++) for (int y=0;y<srcheight;y++)
{ {
@ -388,7 +388,7 @@ void FBitmap::CopyPixelDataRGB(int originx, int originy, const BYTE *patch, int
template<class TDest, class TBlend> template<class TDest, class TBlend>
void iCopyPaletted(BYTE *buffer, const BYTE * patch, int srcwidth, int srcheight, int Pitch, void iCopyPaletted(uint8_t *buffer, const uint8_t * patch, int srcwidth, int srcheight, int Pitch,
int step_x, int step_y, int rotate, PalEntry * palette, FCopyInfo *inf) int step_x, int step_y, int rotate, PalEntry * palette, FCopyInfo *inf)
{ {
int x,y,pos; int x,y,pos;
@ -412,7 +412,7 @@ void iCopyPaletted(BYTE *buffer, const BYTE * patch, int srcwidth, int srcheight
} }
} }
typedef void (*CopyPalettedFunc)(BYTE *buffer, const BYTE * patch, int srcwidth, int srcheight, int Pitch, typedef void (*CopyPalettedFunc)(uint8_t *buffer, const uint8_t * patch, int srcwidth, int srcheight, int Pitch,
int step_x, int step_y, int rotate, PalEntry * palette, FCopyInfo *inf); int step_x, int step_y, int rotate, PalEntry * palette, FCopyInfo *inf);
@ -435,18 +435,18 @@ static const CopyPalettedFunc copypalettedfuncs[]=
// Paletted to True Color texture copy function // Paletted to True Color texture copy function
// //
//=========================================================================== //===========================================================================
void FBitmap::CopyPixelData(int originx, int originy, const BYTE * patch, int srcwidth, int srcheight, void FBitmap::CopyPixelData(int originx, int originy, const uint8_t * patch, int srcwidth, int srcheight,
int step_x, int step_y, int rotate, PalEntry * palette, FCopyInfo *inf) int step_x, int step_y, int rotate, PalEntry * palette, FCopyInfo *inf)
{ {
if (ClipCopyPixelRect(&ClipRect, originx, originy, patch, srcwidth, srcheight, step_x, step_y, rotate)) if (ClipCopyPixelRect(&ClipRect, originx, originy, patch, srcwidth, srcheight, step_x, step_y, rotate))
{ {
BYTE *buffer = data + 4*originx + Pitch*originy; uint8_t *buffer = data + 4*originx + Pitch*originy;
PalEntry penew[256]; PalEntry penew[256];
memset(penew, 0, sizeof(penew)); memset(penew, 0, sizeof(penew));
if (inf && inf->blend) if (inf && inf->blend)
{ {
iCopyColors<cPalEntry, cBGRA, bCopy>((BYTE*)penew, (const BYTE*)palette, 256, 4, inf, 0, 0, 0); iCopyColors<cPalEntry, cBGRA, bCopy>((uint8_t*)penew, (const uint8_t*)palette, 256, 4, inf, 0, 0, 0);
palette = penew; palette = penew;
} }
@ -462,7 +462,7 @@ void FBitmap::CopyPixelData(int originx, int originy, const BYTE * patch, int sr
//=========================================================================== //===========================================================================
void FBitmap::Zero() void FBitmap::Zero()
{ {
BYTE *buffer = data; uint8_t *buffer = data;
for (int y = ClipRect.y; y < ClipRect.height; ++y) for (int y = ClipRect.y; y < ClipRect.height; ++y)
{ {
memset(buffer + ClipRect.x, 0, ClipRect.width*4); memset(buffer + ClipRect.x, 0, ClipRect.width*4);

View file

@ -59,7 +59,7 @@ enum
class FBitmap class FBitmap
{ {
protected: protected:
BYTE *data; uint8_t *data;
int Width; int Width;
int Height; int Height;
int Pitch; int Pitch;
@ -77,7 +77,7 @@ public:
ClipRect.x = ClipRect.y = ClipRect.width = ClipRect.height = 0; ClipRect.x = ClipRect.y = ClipRect.width = ClipRect.height = 0;
} }
FBitmap(BYTE *buffer, int pitch, int width, int height) FBitmap(uint8_t *buffer, int pitch, int width, int height)
{ {
data = buffer; data = buffer;
@ -107,7 +107,7 @@ public:
Pitch = w*4; Pitch = w*4;
Width = w; Width = w;
Height = h; Height = h;
data = new BYTE[4*w*h]; data = new uint8_t[4*w*h];
memset(data, 0, 4*w*h); memset(data, 0, 4*w*h);
FreeBuffer = true; FreeBuffer = true;
ClipRect.x = ClipRect.y = 0; ClipRect.x = ClipRect.y = 0;
@ -131,12 +131,12 @@ public:
return Pitch; return Pitch;
} }
const BYTE *GetPixels() const const uint8_t *GetPixels() const
{ {
return data; return data;
} }
BYTE *GetPixels() uint8_t *GetPixels()
{ {
return data; return data;
} }
@ -164,17 +164,17 @@ public:
void Zero(); void Zero();
virtual void CopyPixelDataRGB(int originx, int originy, const BYTE *patch, int srcwidth, virtual void CopyPixelDataRGB(int originx, int originy, const uint8_t *patch, int srcwidth,
int srcheight, int step_x, int step_y, int rotate, int ct, FCopyInfo *inf = NULL, int srcheight, int step_x, int step_y, int rotate, int ct, FCopyInfo *inf = NULL,
/* for PNG tRNS */ int r=0, int g=0, int b=0); /* for PNG tRNS */ int r=0, int g=0, int b=0);
virtual void CopyPixelData(int originx, int originy, const BYTE * patch, int srcwidth, int srcheight, virtual void CopyPixelData(int originx, int originy, const uint8_t * patch, int srcwidth, int srcheight,
int step_x, int step_y, int rotate, PalEntry * palette, FCopyInfo *inf = NULL); int step_x, int step_y, int rotate, PalEntry * palette, FCopyInfo *inf = NULL);
}; };
bool ClipCopyPixelRect(const FClipRect *cr, int &originx, int &originy, bool ClipCopyPixelRect(const FClipRect *cr, int &originx, int &originy,
const BYTE *&patch, int &srcwidth, int &srcheight, const uint8_t *&patch, int &srcwidth, int &srcheight,
int &step_x, int &step_y, int rotate); int &step_x, int &step_y, int rotate);
//=========================================================================== //===========================================================================
@ -188,7 +188,7 @@ struct cRGB
static __forceinline unsigned char R(const unsigned char * p) { return p[0]; } static __forceinline unsigned char R(const unsigned char * p) { return p[0]; }
static __forceinline unsigned char G(const unsigned char * p) { return p[1]; } static __forceinline unsigned char G(const unsigned char * p) { return p[1]; }
static __forceinline unsigned char B(const unsigned char * p) { return p[2]; } static __forceinline unsigned char B(const unsigned char * p) { return p[2]; }
static __forceinline unsigned char A(const unsigned char * p, BYTE x, BYTE y, BYTE z) { return 255; } static __forceinline unsigned char A(const unsigned char * p, uint8_t x, uint8_t y, uint8_t z) { return 255; }
static __forceinline int Gray(const unsigned char * p) { return (p[0]*77 + p[1]*143 + p[2]*36)>>8; } static __forceinline int Gray(const unsigned char * p) { return (p[0]*77 + p[1]*143 + p[2]*36)>>8; }
}; };
@ -197,7 +197,7 @@ struct cRGBT
static __forceinline unsigned char R(const unsigned char * p) { return p[0]; } static __forceinline unsigned char R(const unsigned char * p) { return p[0]; }
static __forceinline unsigned char G(const unsigned char * p) { return p[1]; } static __forceinline unsigned char G(const unsigned char * p) { return p[1]; }
static __forceinline unsigned char B(const unsigned char * p) { return p[2]; } static __forceinline unsigned char B(const unsigned char * p) { return p[2]; }
static __forceinline unsigned char A(const unsigned char * p, BYTE r, BYTE g, BYTE b) { return (p[0] != r || p[1] != g || p[2] != b) ? 255 : 0; } static __forceinline unsigned char A(const unsigned char * p, uint8_t r, uint8_t g, uint8_t b) { return (p[0] != r || p[1] != g || p[2] != b) ? 255 : 0; }
static __forceinline int Gray(const unsigned char * p) { return (p[0]*77 + p[1]*143 + p[2]*36)>>8; } static __forceinline int Gray(const unsigned char * p) { return (p[0]*77 + p[1]*143 + p[2]*36)>>8; }
}; };
@ -213,7 +213,7 @@ struct cRGBA
static __forceinline unsigned char R(const unsigned char * p) { return p[0]; } static __forceinline unsigned char R(const unsigned char * p) { return p[0]; }
static __forceinline unsigned char G(const unsigned char * p) { return p[1]; } static __forceinline unsigned char G(const unsigned char * p) { return p[1]; }
static __forceinline unsigned char B(const unsigned char * p) { return p[2]; } static __forceinline unsigned char B(const unsigned char * p) { return p[2]; }
static __forceinline unsigned char A(const unsigned char * p, BYTE x, BYTE y, BYTE z) { return p[3]; } static __forceinline unsigned char A(const unsigned char * p, uint8_t x, uint8_t y, uint8_t z) { return p[3]; }
static __forceinline int Gray(const unsigned char * p) { return (p[0]*77 + p[1]*143 + p[2]*36)>>8; } static __forceinline int Gray(const unsigned char * p) { return (p[0]*77 + p[1]*143 + p[2]*36)>>8; }
}; };
@ -222,7 +222,7 @@ struct cIA
static __forceinline unsigned char R(const unsigned char * p) { return p[0]; } static __forceinline unsigned char R(const unsigned char * p) { return p[0]; }
static __forceinline unsigned char G(const unsigned char * p) { return p[0]; } static __forceinline unsigned char G(const unsigned char * p) { return p[0]; }
static __forceinline unsigned char B(const unsigned char * p) { return p[0]; } static __forceinline unsigned char B(const unsigned char * p) { return p[0]; }
static __forceinline unsigned char A(const unsigned char * p, BYTE x, BYTE y, BYTE z) { return p[1]; } static __forceinline unsigned char A(const unsigned char * p, uint8_t x, uint8_t y, uint8_t z) { return p[1]; }
static __forceinline int Gray(const unsigned char * p) { return p[0]; } static __forceinline int Gray(const unsigned char * p) { return p[0]; }
}; };
@ -231,7 +231,7 @@ struct cCMYK
static __forceinline unsigned char R(const unsigned char * p) { return p[3] - (((256-p[0])*p[3]) >> 8); } static __forceinline unsigned char R(const unsigned char * p) { return p[3] - (((256-p[0])*p[3]) >> 8); }
static __forceinline unsigned char G(const unsigned char * p) { return p[3] - (((256-p[1])*p[3]) >> 8); } static __forceinline unsigned char G(const unsigned char * p) { return p[3] - (((256-p[1])*p[3]) >> 8); }
static __forceinline unsigned char B(const unsigned char * p) { return p[3] - (((256-p[2])*p[3]) >> 8); } static __forceinline unsigned char B(const unsigned char * p) { return p[3] - (((256-p[2])*p[3]) >> 8); }
static __forceinline unsigned char A(const unsigned char * p, BYTE x, BYTE y, BYTE z) { return 255; } static __forceinline unsigned char A(const unsigned char * p, uint8_t x, uint8_t y, uint8_t z) { return 255; }
static __forceinline int Gray(const unsigned char * p) { return (R(p)*77 + G(p)*143 + B(p)*36)>>8; } static __forceinline int Gray(const unsigned char * p) { return (R(p)*77 + G(p)*143 + B(p)*36)>>8; }
}; };
@ -240,7 +240,7 @@ struct cBGR
static __forceinline unsigned char R(const unsigned char * p) { return p[2]; } static __forceinline unsigned char R(const unsigned char * p) { return p[2]; }
static __forceinline unsigned char G(const unsigned char * p) { return p[1]; } static __forceinline unsigned char G(const unsigned char * p) { return p[1]; }
static __forceinline unsigned char B(const unsigned char * p) { return p[0]; } static __forceinline unsigned char B(const unsigned char * p) { return p[0]; }
static __forceinline unsigned char A(const unsigned char * p, BYTE x, BYTE y, BYTE z) { return 255; } static __forceinline unsigned char A(const unsigned char * p, uint8_t x, uint8_t y, uint8_t z) { return 255; }
static __forceinline int Gray(const unsigned char * p) { return (p[2]*77 + p[1]*143 + p[0]*36)>>8; } static __forceinline int Gray(const unsigned char * p) { return (p[2]*77 + p[1]*143 + p[0]*36)>>8; }
}; };
@ -256,7 +256,7 @@ struct cBGRA
static __forceinline unsigned char R(const unsigned char * p) { return p[2]; } static __forceinline unsigned char R(const unsigned char * p) { return p[2]; }
static __forceinline unsigned char G(const unsigned char * p) { return p[1]; } static __forceinline unsigned char G(const unsigned char * p) { return p[1]; }
static __forceinline unsigned char B(const unsigned char * p) { return p[0]; } static __forceinline unsigned char B(const unsigned char * p) { return p[0]; }
static __forceinline unsigned char A(const unsigned char * p, BYTE x, BYTE y, BYTE z) { return p[3]; } static __forceinline unsigned char A(const unsigned char * p, uint8_t x, uint8_t y, uint8_t z) { return p[3]; }
static __forceinline int Gray(const unsigned char * p) { return (p[2]*77 + p[1]*143 + p[0]*36)>>8; } static __forceinline int Gray(const unsigned char * p) { return (p[2]*77 + p[1]*143 + p[0]*36)>>8; }
}; };
@ -272,7 +272,7 @@ struct cARGB
static __forceinline unsigned char R(const unsigned char * p) { return p[1]; } static __forceinline unsigned char R(const unsigned char * p) { return p[1]; }
static __forceinline unsigned char G(const unsigned char * p) { return p[2]; } static __forceinline unsigned char G(const unsigned char * p) { return p[2]; }
static __forceinline unsigned char B(const unsigned char * p) { return p[3]; } static __forceinline unsigned char B(const unsigned char * p) { return p[3]; }
static __forceinline unsigned char A(const unsigned char * p, BYTE x, BYTE y, BYTE z) { return p[0]; } static __forceinline unsigned char A(const unsigned char * p, uint8_t x, uint8_t y, uint8_t z) { return p[0]; }
static __forceinline int Gray(const unsigned char * p) { return (p[1]*77 + p[2]*143 + p[3]*36)>>8; } static __forceinline int Gray(const unsigned char * p) { return (p[1]*77 + p[2]*143 + p[3]*36)>>8; }
}; };
@ -281,16 +281,16 @@ struct cI16
static __forceinline unsigned char R(const unsigned char * p) { return p[1]; } static __forceinline unsigned char R(const unsigned char * p) { return p[1]; }
static __forceinline unsigned char G(const unsigned char * p) { return p[1]; } static __forceinline unsigned char G(const unsigned char * p) { return p[1]; }
static __forceinline unsigned char B(const unsigned char * p) { return p[1]; } static __forceinline unsigned char B(const unsigned char * p) { return p[1]; }
static __forceinline unsigned char A(const unsigned char * p, BYTE x, BYTE y, BYTE z) { return 255; } static __forceinline unsigned char A(const unsigned char * p, uint8_t x, uint8_t y, uint8_t z) { return 255; }
static __forceinline int Gray(const unsigned char * p) { return p[1]; } static __forceinline int Gray(const unsigned char * p) { return p[1]; }
}; };
struct cRGB555 struct cRGB555
{ {
static __forceinline unsigned char R(const unsigned char * p) { return (((*(WORD*)p)&0x1f)<<3); } static __forceinline unsigned char R(const unsigned char * p) { return (((*(uint16_t*)p)&0x1f)<<3); }
static __forceinline unsigned char G(const unsigned char * p) { return (((*(WORD*)p)&0x3e0)>>2); } static __forceinline unsigned char G(const unsigned char * p) { return (((*(uint16_t*)p)&0x3e0)>>2); }
static __forceinline unsigned char B(const unsigned char * p) { return (((*(WORD*)p)&0x7c00)>>7); } static __forceinline unsigned char B(const unsigned char * p) { return (((*(uint16_t*)p)&0x7c00)>>7); }
static __forceinline unsigned char A(const unsigned char * p, BYTE x, BYTE y, BYTE z) { return 255; } static __forceinline unsigned char A(const unsigned char * p, uint8_t x, uint8_t y, uint8_t z) { return 255; }
static __forceinline int Gray(const unsigned char * p) { return (R(p)*77 + G(p)*143 + B(p)*36)>>8; } static __forceinline int Gray(const unsigned char * p) { return (R(p)*77 + G(p)*143 + B(p)*36)>>8; }
}; };
@ -299,7 +299,7 @@ struct cPalEntry
static __forceinline unsigned char R(const unsigned char * p) { return ((PalEntry*)p)->r; } static __forceinline unsigned char R(const unsigned char * p) { return ((PalEntry*)p)->r; }
static __forceinline unsigned char G(const unsigned char * p) { return ((PalEntry*)p)->g; } static __forceinline unsigned char G(const unsigned char * p) { return ((PalEntry*)p)->g; }
static __forceinline unsigned char B(const unsigned char * p) { return ((PalEntry*)p)->b; } static __forceinline unsigned char B(const unsigned char * p) { return ((PalEntry*)p)->b; }
static __forceinline unsigned char A(const unsigned char * p, BYTE x, BYTE y, BYTE z) { return ((PalEntry*)p)->a; } static __forceinline unsigned char A(const unsigned char * p, uint8_t x, uint8_t y, uint8_t z) { return ((PalEntry*)p)->a; }
static __forceinline int Gray(const unsigned char * p) { return (R(p)*77 + G(p)*143 + B(p)*36)>>8; } static __forceinline int Gray(const unsigned char * p) { return (R(p)*77 + G(p)*143 + B(p)*36)>>8; }
}; };
@ -353,71 +353,71 @@ struct FCopyInfo
struct bOverwrite struct bOverwrite
{ {
static __forceinline void OpC(BYTE &d, BYTE s, BYTE a, FCopyInfo *i) { d = s; } static __forceinline void OpC(uint8_t &d, uint8_t s, uint8_t a, FCopyInfo *i) { d = s; }
static __forceinline void OpA(BYTE &d, BYTE s, FCopyInfo *i) { d = s; } static __forceinline void OpA(uint8_t &d, uint8_t s, FCopyInfo *i) { d = s; }
static __forceinline bool ProcessAlpha0() { return true; } static __forceinline bool ProcessAlpha0() { return true; }
}; };
struct bCopy struct bCopy
{ {
static __forceinline void OpC(BYTE &d, BYTE s, BYTE a, FCopyInfo *i) { d = s; } static __forceinline void OpC(uint8_t &d, uint8_t s, uint8_t a, FCopyInfo *i) { d = s; }
static __forceinline void OpA(BYTE &d, BYTE s, FCopyInfo *i) { d = s; } static __forceinline void OpA(uint8_t &d, uint8_t s, FCopyInfo *i) { d = s; }
static __forceinline bool ProcessAlpha0() { return false; } static __forceinline bool ProcessAlpha0() { return false; }
}; };
struct bCopyNewAlpha struct bCopyNewAlpha
{ {
static __forceinline void OpC(BYTE &d, BYTE s, BYTE a, FCopyInfo *i) { d = s; } static __forceinline void OpC(uint8_t &d, uint8_t s, uint8_t a, FCopyInfo *i) { d = s; }
static __forceinline void OpA(BYTE &d, BYTE s, FCopyInfo *i) { d = (s*i->alpha) >> BLENDBITS; } static __forceinline void OpA(uint8_t &d, uint8_t s, FCopyInfo *i) { d = (s*i->alpha) >> BLENDBITS; }
static __forceinline bool ProcessAlpha0() { return false; } static __forceinline bool ProcessAlpha0() { return false; }
}; };
struct bCopyAlpha struct bCopyAlpha
{ {
static __forceinline void OpC(BYTE &d, BYTE s, BYTE a, FCopyInfo *i) { d = (s*a + d*(255-a))/255; } static __forceinline void OpC(uint8_t &d, uint8_t s, uint8_t a, FCopyInfo *i) { d = (s*a + d*(255-a))/255; }
static __forceinline void OpA(BYTE &d, BYTE s, FCopyInfo *i) { d = s; } static __forceinline void OpA(uint8_t &d, uint8_t s, FCopyInfo *i) { d = s; }
static __forceinline bool ProcessAlpha0() { return false; } static __forceinline bool ProcessAlpha0() { return false; }
}; };
struct bOverlay struct bOverlay
{ {
static __forceinline void OpC(BYTE &d, BYTE s, BYTE a, FCopyInfo *i) { d = (s*a + d*(255-a))/255; } static __forceinline void OpC(uint8_t &d, uint8_t s, uint8_t a, FCopyInfo *i) { d = (s*a + d*(255-a))/255; }
static __forceinline void OpA(BYTE &d, BYTE s, FCopyInfo *i) { d = MAX(s,d); } static __forceinline void OpA(uint8_t &d, uint8_t s, FCopyInfo *i) { d = MAX(s,d); }
static __forceinline bool ProcessAlpha0() { return false; } static __forceinline bool ProcessAlpha0() { return false; }
}; };
struct bBlend struct bBlend
{ {
static __forceinline void OpC(BYTE &d, BYTE s, BYTE a, FCopyInfo *i) { d = (d*i->invalpha + s*i->alpha) >> BLENDBITS; } static __forceinline void OpC(uint8_t &d, uint8_t s, uint8_t a, FCopyInfo *i) { d = (d*i->invalpha + s*i->alpha) >> BLENDBITS; }
static __forceinline void OpA(BYTE &d, BYTE s, FCopyInfo *i) { d = s; } static __forceinline void OpA(uint8_t &d, uint8_t s, FCopyInfo *i) { d = s; }
static __forceinline bool ProcessAlpha0() { return false; } static __forceinline bool ProcessAlpha0() { return false; }
}; };
struct bAdd struct bAdd
{ {
static __forceinline void OpC(BYTE &d, BYTE s, BYTE a, FCopyInfo *i) { d = MIN<int>((d*BLENDUNIT + s*i->alpha) >> BLENDBITS, 255); } static __forceinline void OpC(uint8_t &d, uint8_t s, uint8_t a, FCopyInfo *i) { d = MIN<int>((d*BLENDUNIT + s*i->alpha) >> BLENDBITS, 255); }
static __forceinline void OpA(BYTE &d, BYTE s, FCopyInfo *i) { d = s; } static __forceinline void OpA(uint8_t &d, uint8_t s, FCopyInfo *i) { d = s; }
static __forceinline bool ProcessAlpha0() { return false; } static __forceinline bool ProcessAlpha0() { return false; }
}; };
struct bSubtract struct bSubtract
{ {
static __forceinline void OpC(BYTE &d, BYTE s, BYTE a, FCopyInfo *i) { d = MAX<int>((d*BLENDUNIT - s*i->alpha) >> BLENDBITS, 0); } static __forceinline void OpC(uint8_t &d, uint8_t s, uint8_t a, FCopyInfo *i) { d = MAX<int>((d*BLENDUNIT - s*i->alpha) >> BLENDBITS, 0); }
static __forceinline void OpA(BYTE &d, BYTE s, FCopyInfo *i) { d = s; } static __forceinline void OpA(uint8_t &d, uint8_t s, FCopyInfo *i) { d = s; }
static __forceinline bool ProcessAlpha0() { return false; } static __forceinline bool ProcessAlpha0() { return false; }
}; };
struct bReverseSubtract struct bReverseSubtract
{ {
static __forceinline void OpC(BYTE &d, BYTE s, BYTE a, FCopyInfo *i) { d = MAX<int>((-d*BLENDUNIT + s*i->alpha) >> BLENDBITS, 0); } static __forceinline void OpC(uint8_t &d, uint8_t s, uint8_t a, FCopyInfo *i) { d = MAX<int>((-d*BLENDUNIT + s*i->alpha) >> BLENDBITS, 0); }
static __forceinline void OpA(BYTE &d, BYTE s, FCopyInfo *i) { d = s; } static __forceinline void OpA(uint8_t &d, uint8_t s, FCopyInfo *i) { d = s; }
static __forceinline bool ProcessAlpha0() { return false; } static __forceinline bool ProcessAlpha0() { return false; }
}; };
struct bModulate struct bModulate
{ {
static __forceinline void OpC(BYTE &d, BYTE s, BYTE a, FCopyInfo *i) { d = (s*d)/255; } static __forceinline void OpC(uint8_t &d, uint8_t s, uint8_t a, FCopyInfo *i) { d = (s*d)/255; }
static __forceinline void OpA(BYTE &d, BYTE s, FCopyInfo *i) { d = s; } static __forceinline void OpA(uint8_t &d, uint8_t s, FCopyInfo *i) { d = s; }
static __forceinline bool ProcessAlpha0() { return false; } static __forceinline bool ProcessAlpha0() { return false; }
}; };

View file

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

View file

@ -50,12 +50,12 @@ class FEmptyTexture : public FTexture
public: public:
FEmptyTexture (int lumpnum); FEmptyTexture (int lumpnum);
const BYTE *GetColumn (unsigned int column, const Span **spans_out); const uint8_t *GetColumn (unsigned int column, const Span **spans_out);
const BYTE *GetPixels (); const uint8_t *GetPixels ();
void Unload() {} void Unload() {}
protected: protected:
BYTE Pixels[1]; uint8_t Pixels[1];
Span DummySpans[1]; Span DummySpans[1];
}; };
@ -103,7 +103,7 @@ FEmptyTexture::FEmptyTexture (int lumpnum)
// //
//========================================================================== //==========================================================================
const BYTE *FEmptyTexture::GetColumn (unsigned int column, const Span **spans_out) const uint8_t *FEmptyTexture::GetColumn (unsigned int column, const Span **spans_out)
{ {
if (spans_out != NULL) if (spans_out != NULL)
{ {
@ -118,7 +118,7 @@ const BYTE *FEmptyTexture::GetColumn (unsigned int column, const Span **spans_ou
// //
//========================================================================== //==========================================================================
const BYTE *FEmptyTexture::GetPixels () const uint8_t *FEmptyTexture::GetPixels ()
{ {
return Pixels; return Pixels;
} }

View file

@ -51,12 +51,12 @@ public:
FFlatTexture (int lumpnum); FFlatTexture (int lumpnum);
~FFlatTexture (); ~FFlatTexture ();
const BYTE *GetColumn (unsigned int column, const Span **spans_out); const uint8_t *GetColumn (unsigned int column, const Span **spans_out);
const BYTE *GetPixels (); const uint8_t *GetPixels ();
void Unload (); void Unload ();
protected: protected:
BYTE *Pixels; uint8_t *Pixels;
Span DummySpans[2]; Span DummySpans[2];
@ -146,7 +146,7 @@ void FFlatTexture::Unload ()
// //
//========================================================================== //==========================================================================
const BYTE *FFlatTexture::GetColumn (unsigned int column, const Span **spans_out) const uint8_t *FFlatTexture::GetColumn (unsigned int column, const Span **spans_out)
{ {
if (Pixels == NULL) if (Pixels == NULL)
{ {
@ -176,7 +176,7 @@ const BYTE *FFlatTexture::GetColumn (unsigned int column, const Span **spans_out
// //
//========================================================================== //==========================================================================
const BYTE *FFlatTexture::GetPixels () const uint8_t *FFlatTexture::GetPixels ()
{ {
if (Pixels == NULL) if (Pixels == NULL)
{ {
@ -194,7 +194,7 @@ const BYTE *FFlatTexture::GetPixels ()
void FFlatTexture::MakeTexture () void FFlatTexture::MakeTexture ()
{ {
FWadLump lump = Wads.OpenLumpNum (SourceLump); FWadLump lump = Wads.OpenLumpNum (SourceLump);
Pixels = new BYTE[Width*Height]; Pixels = new uint8_t[Width*Height];
long numread = lump.Read (Pixels, Width*Height); long numread = lump.Read (Pixels, Width*Height);
if (numread < Width*Height) if (numread < Width*Height)
{ {

View file

@ -51,26 +51,26 @@ class FIMGZTexture : public FTexture
{ {
struct ImageHeader struct ImageHeader
{ {
BYTE Magic[4]; uint8_t Magic[4];
WORD Width; uint16_t Width;
WORD Height; uint16_t Height;
SWORD LeftOffset; int16_t LeftOffset;
SWORD TopOffset; int16_t TopOffset;
BYTE Compression; uint8_t Compression;
BYTE Reserved[11]; uint8_t Reserved[11];
}; };
public: public:
FIMGZTexture (int lumpnum, WORD w, WORD h, SWORD l, SWORD t); FIMGZTexture (int lumpnum, uint16_t w, uint16_t h, int16_t l, int16_t t);
~FIMGZTexture (); ~FIMGZTexture ();
const BYTE *GetColumn (unsigned int column, const Span **spans_out); const uint8_t *GetColumn (unsigned int column, const Span **spans_out);
const BYTE *GetPixels (); const uint8_t *GetPixels ();
void Unload (); void Unload ();
protected: protected:
BYTE *Pixels; uint8_t *Pixels;
Span **Spans; Span **Spans;
void MakeTexture (); void MakeTexture ();
@ -85,9 +85,9 @@ protected:
FTexture *IMGZTexture_TryCreate(FileReader & file, int lumpnum) FTexture *IMGZTexture_TryCreate(FileReader & file, int lumpnum)
{ {
DWORD magic = 0; uint32_t magic = 0;
WORD w, h; uint16_t w, h;
SWORD l, t; int16_t l, t;
file.Seek(0, SEEK_SET); file.Seek(0, SEEK_SET);
if (file.Read(&magic, 4) != 4) return NULL; if (file.Read(&magic, 4) != 4) return NULL;
@ -102,7 +102,7 @@ FTexture *IMGZTexture_TryCreate(FileReader & file, int lumpnum)
// //
//========================================================================== //==========================================================================
FIMGZTexture::FIMGZTexture (int lumpnum, WORD w, WORD h, SWORD l, SWORD t) FIMGZTexture::FIMGZTexture (int lumpnum, uint16_t w, uint16_t h, int16_t l, int16_t t)
: FTexture(NULL, lumpnum), Pixels(0), Spans(0) : FTexture(NULL, lumpnum), Pixels(0), Spans(0)
{ {
Wads.GetLumpName (Name, lumpnum); Wads.GetLumpName (Name, lumpnum);
@ -150,7 +150,7 @@ void FIMGZTexture::Unload ()
// //
//========================================================================== //==========================================================================
const BYTE *FIMGZTexture::GetColumn (unsigned int column, const Span **spans_out) const uint8_t *FIMGZTexture::GetColumn (unsigned int column, const Span **spans_out)
{ {
if (Pixels == NULL) if (Pixels == NULL)
{ {
@ -184,7 +184,7 @@ const BYTE *FIMGZTexture::GetColumn (unsigned int column, const Span **spans_out
// //
//========================================================================== //==========================================================================
const BYTE *FIMGZTexture::GetPixels () const uint8_t *FIMGZTexture::GetPixels ()
{ {
if (Pixels == NULL) if (Pixels == NULL)
{ {
@ -203,7 +203,7 @@ void FIMGZTexture::MakeTexture ()
{ {
FMemLump lump = Wads.ReadLump (SourceLump); FMemLump lump = Wads.ReadLump (SourceLump);
const ImageHeader *imgz = (const ImageHeader *)lump.GetMem(); const ImageHeader *imgz = (const ImageHeader *)lump.GetMem();
const BYTE *data = (const BYTE *)&imgz[1]; const uint8_t *data = (const uint8_t *)&imgz[1];
if (Width != 0xFFFF) if (Width != 0xFFFF)
{ {
@ -213,12 +213,12 @@ void FIMGZTexture::MakeTexture ()
TopOffset = LittleShort(imgz->TopOffset); TopOffset = LittleShort(imgz->TopOffset);
} }
BYTE *dest_p; uint8_t *dest_p;
int dest_adv = Height; int dest_adv = Height;
int dest_rew = Width * Height - 1; int dest_rew = Width * Height - 1;
CalcBitSize (); CalcBitSize ();
Pixels = new BYTE[Width*Height]; Pixels = new uint8_t[Width*Height];
dest_p = Pixels; dest_p = Pixels;
// Convert the source image from row-major to column-major format // Convert the source image from row-major to column-major format
@ -239,7 +239,7 @@ void FIMGZTexture::MakeTexture ()
{ {
// IMGZ compression is the same RLE used by IFF ILBM files // IMGZ compression is the same RLE used by IFF ILBM files
int runlen = 0, setlen = 0; int runlen = 0, setlen = 0;
BYTE setval = 0; // Shut up, GCC uint8_t setval = 0; // Shut up, GCC
for (int y = Height; y != 0; --y) for (int y = Height; y != 0; --y)
{ {
@ -247,7 +247,7 @@ void FIMGZTexture::MakeTexture ()
{ {
if (runlen != 0) if (runlen != 0)
{ {
BYTE color = *data; uint8_t color = *data;
*dest_p = color; *dest_p = color;
dest_p += dest_adv; dest_p += dest_adv;
data++; data++;
@ -263,7 +263,7 @@ void FIMGZTexture::MakeTexture ()
} }
else else
{ {
SBYTE code = *data++; int8_t code = *data++;
if (code >= 0) if (code >= 0)
{ {
runlen = code + 1; runlen = code + 1;

View file

@ -185,8 +185,8 @@ public:
FJPEGTexture (int lumpnum, int width, int height); FJPEGTexture (int lumpnum, int width, int height);
~FJPEGTexture (); ~FJPEGTexture ();
const BYTE *GetColumn (unsigned int column, const Span **spans_out); const uint8_t *GetColumn (unsigned int column, const Span **spans_out);
const BYTE *GetPixels (); const uint8_t *GetPixels ();
void Unload (); void Unload ();
FTextureFormat GetFormat (); FTextureFormat GetFormat ();
int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf = NULL); int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf = NULL);
@ -194,7 +194,7 @@ public:
protected: protected:
BYTE *Pixels; uint8_t *Pixels;
Span DummySpans[2]; Span DummySpans[2];
void MakeTexture (); void MakeTexture ();
@ -212,9 +212,9 @@ FTexture *JPEGTexture_TryCreate(FileReader & data, int lumpnum)
{ {
union union
{ {
DWORD dw; uint32_t dw;
WORD w[2]; uint16_t w[2];
BYTE b[4]; uint8_t b[4];
} first4bytes; } first4bytes;
data.Seek(0, SEEK_SET); data.Seek(0, SEEK_SET);
@ -319,7 +319,7 @@ FTextureFormat FJPEGTexture::GetFormat()
// //
//========================================================================== //==========================================================================
const BYTE *FJPEGTexture::GetColumn (unsigned int column, const Span **spans_out) const uint8_t *FJPEGTexture::GetColumn (unsigned int column, const Span **spans_out)
{ {
if (Pixels == NULL) if (Pixels == NULL)
{ {
@ -349,7 +349,7 @@ const BYTE *FJPEGTexture::GetColumn (unsigned int column, const Span **spans_out
// //
//========================================================================== //==========================================================================
const BYTE *FJPEGTexture::GetPixels () const uint8_t *FJPEGTexture::GetPixels ()
{ {
if (Pixels == NULL) if (Pixels == NULL)
{ {
@ -372,7 +372,7 @@ void FJPEGTexture::MakeTexture ()
jpeg_decompress_struct cinfo; jpeg_decompress_struct cinfo;
jpeg_error_mgr jerr; jpeg_error_mgr jerr;
Pixels = new BYTE[Width * Height]; Pixels = new uint8_t[Width * Height];
memset (Pixels, 0xBA, Width * Height); memset (Pixels, 0xBA, Width * Height);
cinfo.err = jpeg_std_error(&jerr); cinfo.err = jpeg_std_error(&jerr);
@ -394,13 +394,13 @@ void FJPEGTexture::MakeTexture ()
jpeg_start_decompress(&cinfo); jpeg_start_decompress(&cinfo);
int y = 0; int y = 0;
buff = new BYTE[cinfo.output_width * cinfo.output_components]; buff = new uint8_t[cinfo.output_width * cinfo.output_components];
while (cinfo.output_scanline < cinfo.output_height) while (cinfo.output_scanline < cinfo.output_height)
{ {
int num_scanlines = jpeg_read_scanlines(&cinfo, &buff, 1); int num_scanlines = jpeg_read_scanlines(&cinfo, &buff, 1);
BYTE *in = buff; uint8_t *in = buff;
BYTE *out = Pixels + y; uint8_t *out = Pixels + y;
switch (cinfo.out_color_space) switch (cinfo.out_color_space)
{ {
case JCS_RGB: case JCS_RGB:
@ -496,12 +496,12 @@ int FJPEGTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FC
jpeg_start_decompress(&cinfo); jpeg_start_decompress(&cinfo);
int yc = 0; int yc = 0;
buff = new BYTE[cinfo.output_height * cinfo.output_width * cinfo.output_components]; buff = new uint8_t[cinfo.output_height * cinfo.output_width * cinfo.output_components];
while (cinfo.output_scanline < cinfo.output_height) while (cinfo.output_scanline < cinfo.output_height)
{ {
BYTE * ptr = buff + cinfo.output_width * cinfo.output_components * yc; uint8_t * ptr = buff + cinfo.output_width * cinfo.output_components * yc;
jpeg_read_scanlines(&cinfo, &ptr, 1); jpeg_read_scanlines(&cinfo, &ptr, 1);
yc++; yc++;
} }

View file

@ -58,7 +58,7 @@
// all and only while initing the textures is beyond me. // all and only while initing the textures is beyond me.
#ifdef ALPHA #ifdef ALPHA
#define SAFESHORT(s) ((short)(((BYTE *)&(s))[0] + ((BYTE *)&(s))[1] * 256)) #define SAFESHORT(s) ((short)(((uint8_t *)&(s))[0] + ((uint8_t *)&(s))[1] * 256))
#else #else
#define SAFESHORT(s) LittleShort(s) #define SAFESHORT(s) LittleShort(s)
#endif #endif
@ -78,11 +78,11 @@
// //
struct mappatch_t struct mappatch_t
{ {
SWORD originx; int16_t originx;
SWORD originy; int16_t originy;
SWORD patch; int16_t patch;
SWORD stepdir; int16_t stepdir;
SWORD colormap; int16_t colormap;
}; };
// //
@ -91,14 +91,14 @@ struct mappatch_t
// //
struct maptexture_t struct maptexture_t
{ {
BYTE name[8]; uint8_t name[8];
WORD Flags; // [RH] Was unused uint16_t Flags; // [RH] Was unused
BYTE ScaleX; // [RH] Scaling (8 is normal) uint8_t ScaleX; // [RH] Scaling (8 is normal)
BYTE ScaleY; // [RH] Same as above uint8_t ScaleY; // [RH] Same as above
SWORD width; int16_t width;
SWORD height; int16_t height;
BYTE columndirectory[4]; // OBSOLETE uint8_t columndirectory[4]; // OBSOLETE
SWORD patchcount; int16_t patchcount;
mappatch_t patches[1]; mappatch_t patches[1];
}; };
@ -108,9 +108,9 @@ struct maptexture_t
struct strifemappatch_t struct strifemappatch_t
{ {
SWORD originx; int16_t originx;
SWORD originy; int16_t originy;
SWORD patch; int16_t patch;
}; };
// //
@ -119,13 +119,13 @@ struct strifemappatch_t
// //
struct strifemaptexture_t struct strifemaptexture_t
{ {
BYTE name[8]; uint8_t name[8];
WORD Flags; // [RH] Was unused uint16_t Flags; // [RH] Was unused
BYTE ScaleX; // [RH] Scaling (8 is normal) uint8_t ScaleX; // [RH] Scaling (8 is normal)
BYTE ScaleY; // [RH] Same as above uint8_t ScaleY; // [RH] Same as above
SWORD width; int16_t width;
SWORD height; int16_t height;
SWORD patchcount; int16_t patchcount;
strifemappatch_t patches[1]; strifemappatch_t patches[1];
}; };
@ -155,8 +155,8 @@ public:
FMultiPatchTexture (FScanner &sc, int usetype); FMultiPatchTexture (FScanner &sc, int usetype);
~FMultiPatchTexture (); ~FMultiPatchTexture ();
const BYTE *GetColumn (unsigned int column, const Span **spans_out); const uint8_t *GetColumn (unsigned int column, const Span **spans_out);
const BYTE *GetPixels (); const uint8_t *GetPixels ();
FTextureFormat GetFormat(); FTextureFormat GetFormat();
bool UseBasePalette() ; bool UseBasePalette() ;
void Unload (); void Unload ();
@ -169,15 +169,15 @@ public:
void ResolvePatches(); void ResolvePatches();
protected: protected:
BYTE *Pixels; uint8_t *Pixels;
Span **Spans; Span **Spans;
int DefinitionLump; int DefinitionLump;
struct TexPart struct TexPart
{ {
SWORD OriginX, OriginY; int16_t OriginX, OriginY;
BYTE Rotate; uint8_t Rotate;
BYTE op; uint8_t op;
FRemapTable *Translation; FRemapTable *Translation;
PalEntry Blend; PalEntry Blend;
FTexture *Texture; FTexture *Texture;
@ -367,7 +367,7 @@ void FMultiPatchTexture::Unload ()
// //
//========================================================================== //==========================================================================
const BYTE *FMultiPatchTexture::GetPixels () const uint8_t *FMultiPatchTexture::GetPixels ()
{ {
if (bRedirect) if (bRedirect)
{ {
@ -386,7 +386,7 @@ const BYTE *FMultiPatchTexture::GetPixels ()
// //
//========================================================================== //==========================================================================
const BYTE *FMultiPatchTexture::GetColumn (unsigned int column, const Span **spans_out) const uint8_t *FMultiPatchTexture::GetColumn (unsigned int column, const Span **spans_out)
{ {
if (bRedirect) if (bRedirect)
{ {
@ -425,7 +425,7 @@ const BYTE *FMultiPatchTexture::GetColumn (unsigned int column, const Span **spa
// //
//========================================================================== //==========================================================================
BYTE *GetBlendMap(PalEntry blend, BYTE *blendwork) uint8_t *GetBlendMap(PalEntry blend, uint8_t *blendwork)
{ {
switch (blend.a==0 ? int(blend) : -1) switch (blend.a==0 ? int(blend) : -1)
@ -485,10 +485,10 @@ void FMultiPatchTexture::MakeTexture ()
// Add a little extra space at the end if the texture's height is not // Add a little extra space at the end if the texture's height is not
// a power of 2, in case somebody accidentally makes it repeat vertically. // a power of 2, in case somebody accidentally makes it repeat vertically.
int numpix = Width * Height + (1 << HeightBits) - Height; int numpix = Width * Height + (1 << HeightBits) - Height;
BYTE blendwork[256]; uint8_t blendwork[256];
bool hasTranslucent = false; bool hasTranslucent = false;
Pixels = new BYTE[numpix]; Pixels = new uint8_t[numpix];
memset (Pixels, 0, numpix); memset (Pixels, 0, numpix);
for (int i = 0; i < NumParts; ++i) for (int i = 0; i < NumParts; ++i)
@ -505,7 +505,7 @@ void FMultiPatchTexture::MakeTexture ()
{ {
if (Parts[i].Texture->bHasCanvas) continue; // cannot use camera textures as patch. if (Parts[i].Texture->bHasCanvas) continue; // cannot use camera textures as patch.
BYTE *trans = Parts[i].Translation ? Parts[i].Translation->Remap : NULL; uint8_t *trans = Parts[i].Translation ? Parts[i].Translation->Remap : NULL;
{ {
if (Parts[i].Blend != 0) if (Parts[i].Blend != 0)
{ {
@ -520,13 +520,13 @@ void FMultiPatchTexture::MakeTexture ()
{ {
// In case there are translucent patches let's do the composition in // In case there are translucent patches let's do the composition in
// True color to keep as much precision as possible before downconverting to the palette. // True color to keep as much precision as possible before downconverting to the palette.
BYTE *buffer = new BYTE[Width * Height * 4]; uint8_t *buffer = new uint8_t[Width * Height * 4];
memset(buffer, 0, Width * Height * 4); memset(buffer, 0, Width * Height * 4);
FillBuffer(buffer, Width * 4, Height, TEX_RGB); FillBuffer(buffer, Width * 4, Height, TEX_RGB);
for(int y = 0; y < Height; y++) for(int y = 0; y < Height; y++)
{ {
BYTE *in = buffer + Width * y * 4; uint8_t *in = buffer + Width * y * 4;
BYTE *out = Pixels + y; uint8_t *out = Pixels + y;
for (int x = 0; x < Width; x++) for (int x = 0; x < Width; x++)
{ {
if (*out == 0 && in[3] != 0) if (*out == 0 && in[3] != 0)
@ -823,7 +823,7 @@ void FTextureManager::AddTexturesLump (const void *lumpdata, int lumpsize, int d
{ {
FPatchLookup *patchlookup = NULL; FPatchLookup *patchlookup = NULL;
int i; int i;
DWORD numpatches; uint32_t numpatches;
if (firstdup == 0) if (firstdup == 0)
{ {
@ -844,7 +844,7 @@ void FTextureManager::AddTexturesLump (const void *lumpdata, int lumpsize, int d
// Check whether the amount of names reported is correct. // Check whether the amount of names reported is correct.
int lumplength = Wads.LumpLength(patcheslump); int lumplength = Wads.LumpLength(patcheslump);
if (numpatches > DWORD((lumplength-4)/8)) if (numpatches > uint32_t((lumplength-4)/8))
{ {
Printf("PNAMES lump is shorter than required (%u entries reported but only %d bytes (%d entries) long\n", Printf("PNAMES lump is shorter than required (%u entries reported but only %d bytes (%d entries) long\n",
numpatches, lumplength, (lumplength-4)/8); numpatches, lumplength, (lumplength-4)/8);
@ -855,7 +855,7 @@ void FTextureManager::AddTexturesLump (const void *lumpdata, int lumpsize, int d
// Catalog the patches these textures use so we know which // Catalog the patches these textures use so we know which
// textures they represent. // textures they represent.
patchlookup = new FPatchLookup[numpatches]; patchlookup = new FPatchLookup[numpatches];
for (DWORD i = 0; i < numpatches; ++i) for (uint32_t i = 0; i < numpatches; ++i)
{ {
char pname[9]; char pname[9];
pnames.Read(pname, 8); pnames.Read(pname, 8);
@ -865,16 +865,16 @@ void FTextureManager::AddTexturesLump (const void *lumpdata, int lumpsize, int d
} }
bool isStrife = false; bool isStrife = false;
const DWORD *maptex, *directory; const uint32_t *maptex, *directory;
DWORD maxoff; uint32_t maxoff;
int numtextures; int numtextures;
DWORD offset = 0; // Shut up, GCC! uint32_t offset = 0; // Shut up, GCC!
maptex = (const DWORD *)lumpdata; maptex = (const uint32_t *)lumpdata;
numtextures = LittleLong(*maptex); numtextures = LittleLong(*maptex);
maxoff = lumpsize; maxoff = lumpsize;
if (maxoff < DWORD(numtextures+1)*4) if (maxoff < uint32_t(numtextures+1)*4)
{ {
Printf ("Texture directory is too short"); Printf ("Texture directory is too short");
delete[] patchlookup; delete[] patchlookup;
@ -892,7 +892,7 @@ void FTextureManager::AddTexturesLump (const void *lumpdata, int lumpsize, int d
return; return;
} }
maptexture_t *tex = (maptexture_t *)((BYTE *)maptex + offset); maptexture_t *tex = (maptexture_t *)((uint8_t *)maptex + offset);
// There is bizzarely a Doom editing tool that writes to the // There is bizzarely a Doom editing tool that writes to the
// first two elements of columndirectory, so I can't check those. // first two elements of columndirectory, so I can't check those.
@ -915,7 +915,7 @@ void FTextureManager::AddTexturesLump (const void *lumpdata, int lumpsize, int d
// The very first texture is just a dummy. Copy its dimensions to texture 0. // The very first texture is just a dummy. Copy its dimensions to texture 0.
// It still needs to be created in case someone uses it by name. // It still needs to be created in case someone uses it by name.
offset = LittleLong(directory[1]); offset = LittleLong(directory[1]);
const maptexture_t *tex = (const maptexture_t *)((const BYTE *)maptex + offset); const maptexture_t *tex = (const maptexture_t *)((const uint8_t *)maptex + offset);
FDummyTexture *tex0 = static_cast<FDummyTexture *>(Textures[0].Texture); FDummyTexture *tex0 = static_cast<FDummyTexture *>(Textures[0].Texture);
tex0->SetSize (SAFESHORT(tex->width), SAFESHORT(tex->height)); tex0->SetSize (SAFESHORT(tex->width), SAFESHORT(tex->height));
} }
@ -939,7 +939,7 @@ void FTextureManager::AddTexturesLump (const void *lumpdata, int lumpsize, int d
} }
if (j + 1 == firstdup) if (j + 1 == firstdup)
{ {
FMultiPatchTexture *tex = new FMultiPatchTexture ((const BYTE *)maptex + offset, patchlookup, numpatches, isStrife, deflumpnum); FMultiPatchTexture *tex = new FMultiPatchTexture ((const uint8_t *)maptex + offset, patchlookup, numpatches, isStrife, deflumpnum);
if (i == 1 && texture1) if (i == 1 && texture1)
{ {
tex->UseType = FTexture::TEX_FirstDefined; tex->UseType = FTexture::TEX_FirstDefined;

View file

@ -44,8 +44,8 @@
// posts are runs of non masked source pixels // posts are runs of non masked source pixels
struct column_t struct column_t
{ {
BYTE topdelta; // -1 is the last post in a column uint8_t topdelta; // -1 is the last post in a column
BYTE length; // length data bytes follows uint8_t length; // length data bytes follows
}; };
@ -61,12 +61,12 @@ public:
FPatchTexture (int lumpnum, patch_t *header); FPatchTexture (int lumpnum, patch_t *header);
~FPatchTexture (); ~FPatchTexture ();
const BYTE *GetColumn (unsigned int column, const Span **spans_out); const uint8_t *GetColumn (unsigned int column, const Span **spans_out);
const BYTE *GetPixels (); const uint8_t *GetPixels ();
void Unload (); void Unload ();
protected: protected:
BYTE *Pixels; uint8_t *Pixels;
Span **Spans; Span **Spans;
bool hackflag; bool hackflag;
@ -85,7 +85,7 @@ static bool CheckIfPatch(FileReader & file)
{ {
if (file.GetLength() < 13) return false; // minimum length of a valid Doom patch if (file.GetLength() < 13) return false; // minimum length of a valid Doom patch
BYTE *data = new BYTE[file.GetLength()]; uint8_t *data = new uint8_t[file.GetLength()];
file.Seek(0, SEEK_SET); file.Seek(0, SEEK_SET);
file.Read(data, file.GetLength()); file.Read(data, file.GetLength());
@ -105,12 +105,12 @@ static bool CheckIfPatch(FileReader & file)
for (x = 0; x < width; ++x) for (x = 0; x < width; ++x)
{ {
DWORD ofs = LittleLong(foo->columnofs[x]); uint32_t ofs = LittleLong(foo->columnofs[x]);
if (ofs == (DWORD)width * 4 + 8) if (ofs == (uint32_t)width * 4 + 8)
{ {
gapAtStart = false; gapAtStart = false;
} }
else if (ofs >= (DWORD)(file.GetLength())) // Need one byte for an empty column (but there's patches that don't know that!) else if (ofs >= (uint32_t)(file.GetLength())) // Need one byte for an empty column (but there's patches that don't know that!)
{ {
delete [] data; delete [] data;
return false; return false;
@ -192,7 +192,7 @@ void FPatchTexture::Unload ()
// //
//========================================================================== //==========================================================================
const BYTE *FPatchTexture::GetPixels () const uint8_t *FPatchTexture::GetPixels ()
{ {
if (Pixels == NULL) if (Pixels == NULL)
{ {
@ -207,7 +207,7 @@ const BYTE *FPatchTexture::GetPixels ()
// //
//========================================================================== //==========================================================================
const BYTE *FPatchTexture::GetColumn (unsigned int column, const Span **spans_out) const uint8_t *FPatchTexture::GetColumn (unsigned int column, const Span **spans_out)
{ {
if (Pixels == NULL) if (Pixels == NULL)
{ {
@ -244,7 +244,7 @@ const BYTE *FPatchTexture::GetColumn (unsigned int column, const Span **spans_ou
void FPatchTexture::MakeTexture () void FPatchTexture::MakeTexture ()
{ {
BYTE *remap, remaptable[256]; uint8_t *remap, remaptable[256];
int numspans; int numspans;
const column_t *maxcol; const column_t *maxcol;
int x; int x;
@ -252,7 +252,7 @@ void FPatchTexture::MakeTexture ()
FMemLump lump = Wads.ReadLump (SourceLump); FMemLump lump = Wads.ReadLump (SourceLump);
const patch_t *patch = (const patch_t *)lump.GetMem(); const patch_t *patch = (const patch_t *)lump.GetMem();
maxcol = (const column_t *)((const BYTE *)patch + Wads.LumpLength (SourceLump) - 3); maxcol = (const column_t *)((const uint8_t *)patch + Wads.LumpLength (SourceLump) - 3);
// Check for badly-sized patches // Check for badly-sized patches
#if 0 // Such textures won't be created so there's no need to check here #if 0 // Such textures won't be created so there's no need to check here
@ -284,13 +284,13 @@ void FPatchTexture::MakeTexture ()
if (hackflag) if (hackflag)
{ {
Pixels = new BYTE[Width * Height]; Pixels = new uint8_t[Width * Height];
BYTE *out; uint8_t *out;
// Draw the image to the buffer // Draw the image to the buffer
for (x = 0, out = Pixels; x < Width; ++x) for (x = 0, out = Pixels; x < Width; ++x)
{ {
const BYTE *in = (const BYTE *)patch + LittleLong(patch->columnofs[x]) + 3; const uint8_t *in = (const uint8_t *)patch + LittleLong(patch->columnofs[x]) + 3;
for (int y = Height; y > 0; --y) for (int y = Height; y > 0; --y)
{ {
@ -307,14 +307,14 @@ void FPatchTexture::MakeTexture ()
numspans = Width; numspans = Width;
Pixels = new BYTE[numpix]; Pixels = new uint8_t[numpix];
memset (Pixels, 0, numpix); memset (Pixels, 0, numpix);
// Draw the image to the buffer // Draw the image to the buffer
for (x = 0; x < Width; ++x) for (x = 0; x < Width; ++x)
{ {
BYTE *outtop = Pixels + x*Height; uint8_t *outtop = Pixels + x*Height;
const column_t *column = (const column_t *)((const BYTE *)patch + LittleLong(patch->columnofs[x])); const column_t *column = (const column_t *)((const uint8_t *)patch + LittleLong(patch->columnofs[x]));
int top = -1; int top = -1;
while (column < maxcol && column->topdelta != 0xFF) while (column < maxcol && column->topdelta != 0xFF)
@ -329,7 +329,7 @@ void FPatchTexture::MakeTexture ()
} }
int len = column->length; int len = column->length;
BYTE *out = outtop + top; uint8_t *out = outtop + top;
if (len != 0) if (len != 0)
{ {
@ -341,14 +341,14 @@ void FPatchTexture::MakeTexture ()
{ {
numspans++; numspans++;
const BYTE *in = (const BYTE *)column + 3; const uint8_t *in = (const uint8_t *)column + 3;
for (int i = 0; i < len; ++i) for (int i = 0; i < len; ++i)
{ {
out[i] = remap[in[i]]; out[i] = remap[in[i]];
} }
} }
} }
column = (const column_t *)((const BYTE *)column + column->length + 4); column = (const column_t *)((const uint8_t *)column + column->length + 4);
} }
} }
} }
@ -367,19 +367,19 @@ void FPatchTexture::HackHack (int newheight)
// one post, where each post has a supposed length of 0. // one post, where each post has a supposed length of 0.
FMemLump lump = Wads.ReadLump (SourceLump); FMemLump lump = Wads.ReadLump (SourceLump);
const patch_t *realpatch = (patch_t *)lump.GetMem(); const patch_t *realpatch = (patch_t *)lump.GetMem();
const DWORD *cofs = realpatch->columnofs; const uint32_t *cofs = realpatch->columnofs;
int x, x2 = LittleShort(realpatch->width); int x, x2 = LittleShort(realpatch->width);
if (LittleShort(realpatch->height) == 256) if (LittleShort(realpatch->height) == 256)
{ {
for (x = 0; x < x2; ++x) for (x = 0; x < x2; ++x)
{ {
const column_t *col = (column_t*)((BYTE*)realpatch+LittleLong(cofs[x])); const column_t *col = (column_t*)((uint8_t*)realpatch+LittleLong(cofs[x]));
if (col->topdelta != 0 || col->length != 0) if (col->topdelta != 0 || col->length != 0)
{ {
break; // It's not bad! break; // It's not bad!
} }
col = (column_t *)((BYTE *)col + 256 + 4); col = (column_t *)((uint8_t *)col + 256 + 4);
if (col->topdelta != 0xFF) if (col->topdelta != 0xFF)
{ {
break; // More than one post in a column! break; // More than one post in a column!

View file

@ -53,24 +53,24 @@
struct PCXHeader struct PCXHeader
{ {
BYTE manufacturer; uint8_t manufacturer;
BYTE version; uint8_t version;
BYTE encoding; uint8_t encoding;
BYTE bitsPerPixel; uint8_t bitsPerPixel;
WORD xmin, ymin; uint16_t xmin, ymin;
WORD xmax, ymax; uint16_t xmax, ymax;
WORD horzRes, vertRes; uint16_t horzRes, vertRes;
BYTE palette[48]; uint8_t palette[48];
BYTE reserved; uint8_t reserved;
BYTE numColorPlanes; uint8_t numColorPlanes;
WORD bytesPerScanLine; uint16_t bytesPerScanLine;
WORD paletteType; uint16_t paletteType;
WORD horzSize, vertSize; uint16_t horzSize, vertSize;
BYTE padding[54]; uint8_t padding[54];
} FORCE_PACKED; } FORCE_PACKED;
#pragma pack() #pragma pack()
@ -87,8 +87,8 @@ public:
FPCXTexture (int lumpnum, PCXHeader &); FPCXTexture (int lumpnum, PCXHeader &);
~FPCXTexture (); ~FPCXTexture ();
const BYTE *GetColumn (unsigned int column, const Span **spans_out); const uint8_t *GetColumn (unsigned int column, const Span **spans_out);
const BYTE *GetPixels (); const uint8_t *GetPixels ();
void Unload (); void Unload ();
FTextureFormat GetFormat (); FTextureFormat GetFormat ();
@ -96,13 +96,13 @@ public:
bool UseBasePalette(); bool UseBasePalette();
protected: protected:
BYTE *Pixels; uint8_t *Pixels;
Span DummySpans[2]; Span DummySpans[2];
void ReadPCX1bit (BYTE *dst, FileReader & lump, PCXHeader *hdr); void ReadPCX1bit (uint8_t *dst, FileReader & lump, PCXHeader *hdr);
void ReadPCX4bits (BYTE *dst, FileReader & lump, PCXHeader *hdr); void ReadPCX4bits (uint8_t *dst, FileReader & lump, PCXHeader *hdr);
void ReadPCX8bits (BYTE *dst, FileReader & lump, PCXHeader *hdr); void ReadPCX8bits (uint8_t *dst, FileReader & lump, PCXHeader *hdr);
void ReadPCX24bits (BYTE *dst, FileReader & lump, PCXHeader *hdr, int planes); void ReadPCX24bits (uint8_t *dst, FileReader & lump, PCXHeader *hdr, int planes);
virtual void MakeTexture (); virtual void MakeTexture ();
@ -210,7 +210,7 @@ FTextureFormat FPCXTexture::GetFormat()
// //
//========================================================================== //==========================================================================
const BYTE *FPCXTexture::GetColumn (unsigned int column, const Span **spans_out) const uint8_t *FPCXTexture::GetColumn (unsigned int column, const Span **spans_out)
{ {
if (Pixels == NULL) if (Pixels == NULL)
{ {
@ -240,7 +240,7 @@ const BYTE *FPCXTexture::GetColumn (unsigned int column, const Span **spans_out)
// //
//========================================================================== //==========================================================================
const BYTE *FPCXTexture::GetPixels () const uint8_t *FPCXTexture::GetPixels ()
{ {
if (Pixels == NULL) if (Pixels == NULL)
{ {
@ -255,19 +255,19 @@ const BYTE *FPCXTexture::GetPixels ()
// //
//========================================================================== //==========================================================================
void FPCXTexture::ReadPCX1bit (BYTE *dst, FileReader & lump, PCXHeader *hdr) void FPCXTexture::ReadPCX1bit (uint8_t *dst, FileReader & lump, PCXHeader *hdr)
{ {
int y, i, bytes; int y, i, bytes;
int rle_count = 0; int rle_count = 0;
BYTE rle_value = 0; uint8_t rle_value = 0;
BYTE * srcp = new BYTE[lump.GetLength() - sizeof(PCXHeader)]; uint8_t * srcp = new uint8_t[lump.GetLength() - sizeof(PCXHeader)];
lump.Read(srcp, lump.GetLength() - sizeof(PCXHeader)); lump.Read(srcp, lump.GetLength() - sizeof(PCXHeader));
BYTE * src = srcp; uint8_t * src = srcp;
for (y = 0; y < Height; ++y) for (y = 0; y < Height; ++y)
{ {
BYTE * ptr = &dst[y * Width]; uint8_t * ptr = &dst[y * Width];
bytes = hdr->bytesPerScanLine; bytes = hdr->bytesPerScanLine;
@ -303,26 +303,26 @@ void FPCXTexture::ReadPCX1bit (BYTE *dst, FileReader & lump, PCXHeader *hdr)
// //
//========================================================================== //==========================================================================
void FPCXTexture::ReadPCX4bits (BYTE *dst, FileReader & lump, PCXHeader *hdr) void FPCXTexture::ReadPCX4bits (uint8_t *dst, FileReader & lump, PCXHeader *hdr)
{ {
int rle_count = 0, rle_value = 0; int rle_count = 0, rle_value = 0;
int x, y, c; int x, y, c;
int bytes; int bytes;
BYTE * line = new BYTE[hdr->bytesPerScanLine]; uint8_t * line = new uint8_t[hdr->bytesPerScanLine];
BYTE * colorIndex = new BYTE[Width]; uint8_t * colorIndex = new uint8_t[Width];
BYTE * srcp = new BYTE[lump.GetLength() - sizeof(PCXHeader)]; uint8_t * srcp = new uint8_t[lump.GetLength() - sizeof(PCXHeader)];
lump.Read(srcp, lump.GetLength() - sizeof(PCXHeader)); lump.Read(srcp, lump.GetLength() - sizeof(PCXHeader));
BYTE * src = srcp; uint8_t * src = srcp;
for (y = 0; y < Height; ++y) for (y = 0; y < Height; ++y)
{ {
BYTE * ptr = &dst[y * Width]; uint8_t * ptr = &dst[y * Width];
memset (ptr, 0, Width * sizeof (BYTE)); memset (ptr, 0, Width * sizeof (uint8_t));
for (c = 0; c < 4; ++c) for (c = 0; c < 4; ++c)
{ {
BYTE * pLine = line; uint8_t * pLine = line;
bytes = hdr->bytesPerScanLine; bytes = hdr->bytesPerScanLine;
@ -366,18 +366,18 @@ void FPCXTexture::ReadPCX4bits (BYTE *dst, FileReader & lump, PCXHeader *hdr)
// //
//========================================================================== //==========================================================================
void FPCXTexture::ReadPCX8bits (BYTE *dst, FileReader & lump, PCXHeader *hdr) void FPCXTexture::ReadPCX8bits (uint8_t *dst, FileReader & lump, PCXHeader *hdr)
{ {
int rle_count = 0, rle_value = 0; int rle_count = 0, rle_value = 0;
int y, bytes; int y, bytes;
BYTE * srcp = new BYTE[lump.GetLength() - sizeof(PCXHeader)]; uint8_t * srcp = new uint8_t[lump.GetLength() - sizeof(PCXHeader)];
lump.Read(srcp, lump.GetLength() - sizeof(PCXHeader)); lump.Read(srcp, lump.GetLength() - sizeof(PCXHeader));
BYTE * src = srcp; uint8_t * src = srcp;
for (y = 0; y < Height; ++y) for (y = 0; y < Height; ++y)
{ {
BYTE * ptr = &dst[y * Width]; uint8_t * ptr = &dst[y * Width];
bytes = hdr->bytesPerScanLine; bytes = hdr->bytesPerScanLine;
while (bytes--) while (bytes--)
@ -408,22 +408,22 @@ void FPCXTexture::ReadPCX8bits (BYTE *dst, FileReader & lump, PCXHeader *hdr)
// //
//========================================================================== //==========================================================================
void FPCXTexture::ReadPCX24bits (BYTE *dst, FileReader & lump, PCXHeader *hdr, int planes) void FPCXTexture::ReadPCX24bits (uint8_t *dst, FileReader & lump, PCXHeader *hdr, int planes)
{ {
int rle_count = 0, rle_value = 0; int rle_count = 0, rle_value = 0;
int y, c; int y, c;
int bytes; int bytes;
BYTE * srcp = new BYTE[lump.GetLength() - sizeof(PCXHeader)]; uint8_t * srcp = new uint8_t[lump.GetLength() - sizeof(PCXHeader)];
lump.Read(srcp, lump.GetLength() - sizeof(PCXHeader)); lump.Read(srcp, lump.GetLength() - sizeof(PCXHeader));
BYTE * src = srcp; uint8_t * src = srcp;
for (y = 0; y < Height; ++y) for (y = 0; y < Height; ++y)
{ {
/* for each color plane */ /* for each color plane */
for (c = 0; c < planes; ++c) for (c = 0; c < planes; ++c)
{ {
BYTE * ptr = &dst[y * Width * planes]; uint8_t * ptr = &dst[y * Width * planes];
bytes = hdr->bytesPerScanLine; bytes = hdr->bytesPerScanLine;
while (bytes--) while (bytes--)
@ -442,7 +442,7 @@ void FPCXTexture::ReadPCX24bits (BYTE *dst, FileReader & lump, PCXHeader *hdr, i
} }
rle_count--; rle_count--;
ptr[c] = (BYTE)rle_value; ptr[c] = (uint8_t)rle_value;
ptr += planes; ptr += planes;
} }
} }
@ -458,7 +458,7 @@ void FPCXTexture::ReadPCX24bits (BYTE *dst, FileReader & lump, PCXHeader *hdr, i
void FPCXTexture::MakeTexture() void FPCXTexture::MakeTexture()
{ {
BYTE PaletteMap[256]; uint8_t PaletteMap[256];
PCXHeader header; PCXHeader header;
int bitcount; int bitcount;
@ -467,7 +467,7 @@ void FPCXTexture::MakeTexture()
lump.Read(&header, sizeof(header)); lump.Read(&header, sizeof(header));
bitcount = header.bitsPerPixel * header.numColorPlanes; bitcount = header.bitsPerPixel * header.numColorPlanes;
Pixels = new BYTE[Width*Height]; Pixels = new uint8_t[Width*Height];
if (bitcount < 24) if (bitcount < 24)
{ {
@ -492,14 +492,14 @@ void FPCXTexture::MakeTexture()
} }
else if (bitcount == 8) else if (bitcount == 8)
{ {
BYTE c; uint8_t c;
lump.Seek(-769, SEEK_END); lump.Seek(-769, SEEK_END);
lump >> c; lump >> c;
//if (c !=0x0c) memcpy(PaletteMap, GrayMap, 256); // Fallback for files without palette //if (c !=0x0c) memcpy(PaletteMap, GrayMap, 256); // Fallback for files without palette
//else //else
for(int i=0;i<256;i++) for(int i=0;i<256;i++)
{ {
BYTE r,g,b; uint8_t r,g,b;
lump >> r >> g >> b; lump >> r >> g >> b;
PaletteMap[i] = ColorMatcher.Pick(r,g,b); PaletteMap[i] = ColorMatcher.Pick(r,g,b);
} }
@ -512,17 +512,17 @@ void FPCXTexture::MakeTexture()
} }
else else
{ {
BYTE *newpix = new BYTE[Width*Height]; uint8_t *newpix = new uint8_t[Width*Height];
FlipNonSquareBlockRemap (newpix, Pixels, Width, Height, Width, PaletteMap); FlipNonSquareBlockRemap (newpix, Pixels, Width, Height, Width, PaletteMap);
BYTE *oldpix = Pixels; uint8_t *oldpix = Pixels;
Pixels = newpix; Pixels = newpix;
delete[] oldpix; delete[] oldpix;
} }
} }
else else
{ {
BYTE * buffer = new BYTE[Width*Height * 3]; uint8_t * buffer = new uint8_t[Width*Height * 3];
BYTE * row = buffer; uint8_t * row = buffer;
ReadPCX24bits (buffer, lump, &header, 3); ReadPCX24bits (buffer, lump, &header, 3);
for(int y=0; y<Height; y++) for(int y=0; y<Height; y++)
{ {
@ -549,7 +549,7 @@ int FPCXTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCo
PalEntry pe[256]; PalEntry pe[256];
PCXHeader header; PCXHeader header;
int bitcount; int bitcount;
BYTE * Pixels; uint8_t * Pixels;
FWadLump lump = Wads.OpenLumpNum(SourceLump); FWadLump lump = Wads.OpenLumpNum(SourceLump);
@ -559,7 +559,7 @@ int FPCXTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCo
if (bitcount < 24) if (bitcount < 24)
{ {
Pixels = new BYTE[Width*Height]; Pixels = new uint8_t[Width*Height];
if (bitcount < 8) if (bitcount < 8)
{ {
for (int i=0;i<16;i++) for (int i=0;i<16;i++)
@ -581,7 +581,7 @@ int FPCXTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCo
} }
else if (bitcount == 8) else if (bitcount == 8)
{ {
BYTE c; uint8_t c;
lump.Seek(-769, SEEK_END); lump.Seek(-769, SEEK_END);
lump >> c; lump >> c;
c=0x0c; // Apparently there's many non-compliant PCXs out there... c=0x0c; // Apparently there's many non-compliant PCXs out there...
@ -591,7 +591,7 @@ int FPCXTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCo
} }
else for(int i=0;i<256;i++) else for(int i=0;i<256;i++)
{ {
BYTE r,g,b; uint8_t r,g,b;
lump >> r >> g >> b; lump >> r >> g >> b;
pe[i] = PalEntry(255, r,g,b); pe[i] = PalEntry(255, r,g,b);
} }
@ -602,7 +602,7 @@ int FPCXTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCo
} }
else else
{ {
Pixels = new BYTE[Width*Height * 3]; Pixels = new uint8_t[Width*Height * 3];
ReadPCX24bits (Pixels, lump, &header, 3); ReadPCX24bits (Pixels, lump, &header, 3);
bmp->CopyPixelDataRGB(x, y, Pixels, Width, Height, 3, Width*3, rotate, CF_RGB, inf); bmp->CopyPixelDataRGB(x, y, Pixels, Width, Height, 3, Width*3, rotate, CF_RGB, inf);
} }

View file

@ -51,11 +51,11 @@
class FPNGTexture : public FTexture class FPNGTexture : public FTexture
{ {
public: public:
FPNGTexture (FileReader &lump, int lumpnum, const FString &filename, int width, int height, BYTE bitdepth, BYTE colortype, BYTE interlace); FPNGTexture (FileReader &lump, int lumpnum, const FString &filename, int width, int height, uint8_t bitdepth, uint8_t colortype, uint8_t interlace);
~FPNGTexture (); ~FPNGTexture ();
const BYTE *GetColumn (unsigned int column, const Span **spans_out); const uint8_t *GetColumn (unsigned int column, const Span **spans_out);
const BYTE *GetPixels (); const uint8_t *GetPixels ();
void Unload (); void Unload ();
FTextureFormat GetFormat (); FTextureFormat GetFormat ();
int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf = NULL); int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf = NULL);
@ -64,19 +64,19 @@ public:
protected: protected:
FString SourceFile; FString SourceFile;
BYTE *Pixels; uint8_t *Pixels;
Span **Spans; Span **Spans;
FileReader *fr; FileReader *fr;
BYTE BitDepth; uint8_t BitDepth;
BYTE ColorType; uint8_t ColorType;
BYTE Interlace; uint8_t Interlace;
bool HaveTrans; bool HaveTrans;
WORD NonPaletteTrans[3]; uint16_t NonPaletteTrans[3];
BYTE *PaletteMap; uint8_t *PaletteMap;
int PaletteSize; int PaletteSize;
DWORD StartOfIDAT; uint32_t StartOfIDAT;
void MakeTexture (); void MakeTexture ();
@ -94,13 +94,13 @@ FTexture *PNGTexture_TryCreate(FileReader & data, int lumpnum)
{ {
union union
{ {
DWORD dw; uint32_t dw;
WORD w[2]; uint16_t w[2];
BYTE b[4]; uint8_t b[4];
} first4bytes; } first4bytes;
DWORD width, height; uint32_t width, height;
BYTE bitdepth, colortype, compression, filter, interlace; uint8_t bitdepth, colortype, compression, filter, interlace;
// This is most likely a PNG, but make sure. (Note that if the // This is most likely a PNG, but make sure. (Note that if the
// first 4 bytes match, but later bytes don't, we assume it's // first 4 bytes match, but later bytes don't, we assume it's
@ -159,8 +159,8 @@ FTexture *PNGTexture_TryCreate(FileReader & data, int lumpnum)
FTexture *PNGTexture_CreateFromFile(PNGHandle *png, const FString &filename) FTexture *PNGTexture_CreateFromFile(PNGHandle *png, const FString &filename)
{ {
DWORD width, height; uint32_t width, height;
BYTE bitdepth, colortype, compression, filter, interlace; uint8_t bitdepth, colortype, compression, filter, interlace;
if (M_FindPNGChunk(png, MAKE_ID('I','H','D','R')) == 0) if (M_FindPNGChunk(png, MAKE_ID('I','H','D','R')) == 0)
{ {
@ -196,18 +196,18 @@ FTexture *PNGTexture_CreateFromFile(PNGHandle *png, const FString &filename)
//========================================================================== //==========================================================================
FPNGTexture::FPNGTexture (FileReader &lump, int lumpnum, const FString &filename, int width, int height, FPNGTexture::FPNGTexture (FileReader &lump, int lumpnum, const FString &filename, int width, int height,
BYTE depth, BYTE colortype, BYTE interlace) uint8_t depth, uint8_t colortype, uint8_t interlace)
: FTexture(NULL, lumpnum), SourceFile(filename), Pixels(0), Spans(0), : FTexture(NULL, lumpnum), SourceFile(filename), Pixels(0), Spans(0),
BitDepth(depth), ColorType(colortype), Interlace(interlace), HaveTrans(false), BitDepth(depth), ColorType(colortype), Interlace(interlace), HaveTrans(false),
PaletteMap(0), PaletteSize(0), StartOfIDAT(0) PaletteMap(0), PaletteSize(0), StartOfIDAT(0)
{ {
union union
{ {
DWORD palette[256]; uint32_t palette[256];
BYTE pngpal[256][3]; uint8_t pngpal[256][3];
} p; } p;
BYTE trans[256]; uint8_t trans[256];
DWORD len, id; uint32_t len, id;
int i; int i;
if (lumpnum == -1) fr = &lump; if (lumpnum == -1) fr = &lump;
@ -241,7 +241,7 @@ FPNGTexture::FPNGTexture (FileReader &lump, int lumpnum, const FString &filename
case MAKE_ID('g','r','A','b'): case MAKE_ID('g','r','A','b'):
// This is like GRAB found in an ILBM, except coordinates use 4 bytes // This is like GRAB found in an ILBM, except coordinates use 4 bytes
{ {
DWORD hotx, hoty; uint32_t hotx, hoty;
int ihotx, ihoty; int ihotx, ihoty;
lump.Read(&hotx, 4); lump.Read(&hotx, 4);
@ -280,9 +280,9 @@ FPNGTexture::FPNGTexture (FileReader &lump, int lumpnum, const FString &filename
lump.Read (trans, len); lump.Read (trans, len);
HaveTrans = true; HaveTrans = true;
// Save for colortype 2 // Save for colortype 2
NonPaletteTrans[0] = WORD(trans[0] * 256 + trans[1]); NonPaletteTrans[0] = uint16_t(trans[0] * 256 + trans[1]);
NonPaletteTrans[1] = WORD(trans[2] * 256 + trans[3]); NonPaletteTrans[1] = uint16_t(trans[2] * 256 + trans[3]);
NonPaletteTrans[2] = WORD(trans[4] * 256 + trans[5]); NonPaletteTrans[2] = uint16_t(trans[4] * 256 + trans[5]);
break; break;
case MAKE_ID('a','l','P','h'): case MAKE_ID('a','l','P','h'):
@ -310,7 +310,7 @@ FPNGTexture::FPNGTexture (FileReader &lump, int lumpnum, const FString &filename
{ {
bMasked = true; bMasked = true;
PaletteSize = 256; PaletteSize = 256;
PaletteMap = new BYTE[256]; PaletteMap = new uint8_t[256];
memcpy (PaletteMap, GrayMap, 256); memcpy (PaletteMap, GrayMap, 256);
PaletteMap[NonPaletteTrans[0]] = 0; PaletteMap[NonPaletteTrans[0]] = 0;
} }
@ -322,7 +322,7 @@ FPNGTexture::FPNGTexture (FileReader &lump, int lumpnum, const FString &filename
break; break;
case 3: // Paletted case 3: // Paletted
PaletteMap = new BYTE[PaletteSize]; PaletteMap = new uint8_t[PaletteSize];
GPalette.MakeRemap (p.palette, PaletteMap, trans, PaletteSize); GPalette.MakeRemap (p.palette, PaletteMap, trans, PaletteSize);
for (i = 0; i < PaletteSize; ++i) for (i = 0; i < PaletteSize; ++i)
{ {
@ -407,7 +407,7 @@ FTextureFormat FPNGTexture::GetFormat()
// //
//========================================================================== //==========================================================================
const BYTE *FPNGTexture::GetColumn (unsigned int column, const Span **spans_out) const uint8_t *FPNGTexture::GetColumn (unsigned int column, const Span **spans_out)
{ {
if (Pixels == NULL) if (Pixels == NULL)
{ {
@ -441,7 +441,7 @@ const BYTE *FPNGTexture::GetColumn (unsigned int column, const Span **spans_out)
// //
//========================================================================== //==========================================================================
const BYTE *FPNGTexture::GetPixels () const uint8_t *FPNGTexture::GetPixels ()
{ {
if (Pixels == NULL) if (Pixels == NULL)
{ {
@ -469,14 +469,14 @@ void FPNGTexture::MakeTexture ()
lump = fr;// new FileReader(SourceFile.GetChars()); lump = fr;// new FileReader(SourceFile.GetChars());
} }
Pixels = new BYTE[Width*Height]; Pixels = new uint8_t[Width*Height];
if (StartOfIDAT == 0) if (StartOfIDAT == 0)
{ {
memset (Pixels, 0x99, Width*Height); memset (Pixels, 0x99, Width*Height);
} }
else else
{ {
DWORD len, id; uint32_t len, id;
lump->Seek (StartOfIDAT, SEEK_SET); lump->Seek (StartOfIDAT, SEEK_SET);
lump->Read(&len, 4); lump->Read(&len, 4);
lump->Read(&id, 4); lump->Read(&id, 4);
@ -498,7 +498,7 @@ void FPNGTexture::MakeTexture ()
} }
else else
{ {
BYTE *newpix = new BYTE[Width*Height]; uint8_t *newpix = new uint8_t[Width*Height];
if (PaletteMap != NULL) if (PaletteMap != NULL)
{ {
FlipNonSquareBlockRemap (newpix, Pixels, Width, Height, Width, PaletteMap); FlipNonSquareBlockRemap (newpix, Pixels, Width, Height, Width, PaletteMap);
@ -507,7 +507,7 @@ void FPNGTexture::MakeTexture ()
{ {
FlipNonSquareBlock (newpix, Pixels, Width, Height, Width); FlipNonSquareBlock (newpix, Pixels, Width, Height, Width);
} }
BYTE *oldpix = Pixels; uint8_t *oldpix = Pixels;
Pixels = newpix; Pixels = newpix;
delete[] oldpix; delete[] oldpix;
} }
@ -515,8 +515,8 @@ void FPNGTexture::MakeTexture ()
else /* RGB and/or Alpha present */ else /* RGB and/or Alpha present */
{ {
int bytesPerPixel = ColorType == 2 ? 3 : ColorType == 4 ? 2 : 4; int bytesPerPixel = ColorType == 2 ? 3 : ColorType == 4 ? 2 : 4;
BYTE *tempix = new BYTE[Width * Height * bytesPerPixel]; uint8_t *tempix = new uint8_t[Width * Height * bytesPerPixel];
BYTE *in, *out; uint8_t *in, *out;
int x, y, pitch, backstep; int x, y, pitch, backstep;
M_ReadIDAT (lump, tempix, Width, Height, Width*bytesPerPixel, BitDepth, ColorType, Interlace, BigLong((unsigned int)len)); M_ReadIDAT (lump, tempix, Width, Height, Width*bytesPerPixel, BitDepth, ColorType, Interlace, BigLong((unsigned int)len));
@ -616,7 +616,7 @@ int FPNGTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCo
{ {
// Parse pre-IDAT chunks. I skip the CRCs. Is that bad? // Parse pre-IDAT chunks. I skip the CRCs. Is that bad?
PalEntry pe[256]; PalEntry pe[256];
DWORD len, id; uint32_t len, id;
FileReader *lump; FileReader *lump;
static char bpp[] = {1, 0, 3, 1, 2, 0, 4}; static char bpp[] = {1, 0, 3, 1, 2, 0, 4};
int pixwidth = Width * bpp[ColorType]; int pixwidth = Width * bpp[ColorType];
@ -656,7 +656,7 @@ int FPNGTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCo
case MAKE_ID('t','R','N','S'): case MAKE_ID('t','R','N','S'):
if (ColorType == 3) if (ColorType == 3)
{ {
for(DWORD i = 0; i < len; i++) for(uint32_t i = 0; i < len; i++)
{ {
(*lump) >> pe[i].a; (*lump) >> pe[i].a;
if (pe[i].a != 0 && pe[i].a != 255) if (pe[i].a != 0 && pe[i].a != 255)
@ -681,7 +681,7 @@ int FPNGTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCo
transpal = true; transpal = true;
} }
BYTE * Pixels = new BYTE[pixwidth * Height]; uint8_t * Pixels = new uint8_t[pixwidth * Height];
lump->Seek (StartOfIDAT, SEEK_SET); lump->Seek (StartOfIDAT, SEEK_SET);
lump->Read(&len, 4); lump->Read(&len, 4);

View file

@ -52,12 +52,12 @@ public:
FRawPageTexture (int lumpnum); FRawPageTexture (int lumpnum);
~FRawPageTexture (); ~FRawPageTexture ();
const BYTE *GetColumn (unsigned int column, const Span **spans_out); const uint8_t *GetColumn (unsigned int column, const Span **spans_out);
const BYTE *GetPixels (); const uint8_t *GetPixels ();
void Unload (); void Unload ();
protected: protected:
BYTE *Pixels; uint8_t *Pixels;
static const Span DummySpans[2]; static const Span DummySpans[2];
void MakeTexture (); void MakeTexture ();
@ -97,8 +97,8 @@ static bool CheckIfRaw(FileReader & data)
for (x = 0; x < width; ++x) for (x = 0; x < width; ++x)
{ {
DWORD ofs = LittleLong(foo->columnofs[x]); uint32_t ofs = LittleLong(foo->columnofs[x]);
if (ofs == (DWORD)width * 4 + 8) if (ofs == (uint32_t)width * 4 + 8)
{ {
gapAtStart = false; gapAtStart = false;
} }
@ -110,7 +110,7 @@ static bool CheckIfRaw(FileReader & data)
else else
{ {
// Ensure this column does not extend beyond the end of the patch // Ensure this column does not extend beyond the end of the patch
const BYTE *foo2 = (const BYTE *)foo; const uint8_t *foo2 = (const uint8_t *)foo;
while (ofs < 64000) while (ofs < 64000)
{ {
if (foo2[ofs] == 255) if (foo2[ofs] == 255)
@ -214,7 +214,7 @@ void FRawPageTexture::Unload ()
// //
//========================================================================== //==========================================================================
const BYTE *FRawPageTexture::GetColumn (unsigned int column, const Span **spans_out) const uint8_t *FRawPageTexture::GetColumn (unsigned int column, const Span **spans_out)
{ {
if (Pixels == NULL) if (Pixels == NULL)
{ {
@ -237,7 +237,7 @@ const BYTE *FRawPageTexture::GetColumn (unsigned int column, const Span **spans_
// //
//========================================================================== //==========================================================================
const BYTE *FRawPageTexture::GetPixels () const uint8_t *FRawPageTexture::GetPixels ()
{ {
if (Pixels == NULL) if (Pixels == NULL)
{ {
@ -255,11 +255,11 @@ const BYTE *FRawPageTexture::GetPixels ()
void FRawPageTexture::MakeTexture () void FRawPageTexture::MakeTexture ()
{ {
FMemLump lump = Wads.ReadLump (SourceLump); FMemLump lump = Wads.ReadLump (SourceLump);
const BYTE *source = (const BYTE *)lump.GetMem(); const uint8_t *source = (const uint8_t *)lump.GetMem();
const BYTE *source_p = source; const uint8_t *source_p = source;
BYTE *dest_p; uint8_t *dest_p;
Pixels = new BYTE[Width*Height]; Pixels = new uint8_t[Width*Height];
dest_p = Pixels; dest_p = Pixels;
// Convert the source image from row-major to column-major format // Convert the source image from row-major to column-major format

View file

@ -764,7 +764,7 @@ void FTextureManager::LoadTextureDefs(int wadnum, const char *lumpname)
void FTextureManager::AddPatches (int lumpnum) void FTextureManager::AddPatches (int lumpnum)
{ {
FWadLump *file = Wads.ReopenLumpNum (lumpnum); FWadLump *file = Wads.ReopenLumpNum (lumpnum);
DWORD numpatches, i; uint32_t numpatches, i;
char name[9]; char name[9];
*file >> numpatches; *file >> numpatches;
@ -1181,7 +1181,7 @@ int FTextureManager::CountLumpTextures (int lumpnum)
if (lumpnum >= 0) if (lumpnum >= 0)
{ {
FWadLump file = Wads.OpenLumpNum (lumpnum); FWadLump file = Wads.OpenLumpNum (lumpnum);
DWORD numtex; uint32_t numtex;
file >> numtex; file >> numtex;
return int(numtex) >= 0 ? numtex : 0; return int(numtex) >= 0 ? numtex : 0;

View file

@ -53,19 +53,19 @@
struct TGAHeader struct TGAHeader
{ {
BYTE id_len; uint8_t id_len;
BYTE has_cm; uint8_t has_cm;
BYTE img_type; uint8_t img_type;
SWORD cm_first; int16_t cm_first;
SWORD cm_length; int16_t cm_length;
BYTE cm_size; uint8_t cm_size;
SWORD x_origin; int16_t x_origin;
SWORD y_origin; int16_t y_origin;
SWORD width; int16_t width;
SWORD height; int16_t height;
BYTE bpp; uint8_t bpp;
BYTE img_desc; uint8_t img_desc;
}; };
#pragma pack() #pragma pack()
@ -82,8 +82,8 @@ public:
FTGATexture (int lumpnum, TGAHeader *); FTGATexture (int lumpnum, TGAHeader *);
~FTGATexture (); ~FTGATexture ();
const BYTE *GetColumn (unsigned int column, const Span **spans_out); const uint8_t *GetColumn (unsigned int column, const Span **spans_out);
const BYTE *GetPixels (); const uint8_t *GetPixels ();
void Unload (); void Unload ();
FTextureFormat GetFormat (); FTextureFormat GetFormat ();
@ -91,10 +91,10 @@ public:
bool UseBasePalette(); bool UseBasePalette();
protected: protected:
BYTE *Pixels; uint8_t *Pixels;
Span **Spans; Span **Spans;
void ReadCompressed(FileReader &lump, BYTE * buffer, int bytesperpixel); void ReadCompressed(FileReader &lump, uint8_t * buffer, int bytesperpixel);
virtual void MakeTexture (); virtual void MakeTexture ();
@ -200,7 +200,7 @@ FTextureFormat FTGATexture::GetFormat()
// //
//========================================================================== //==========================================================================
const BYTE *FTGATexture::GetColumn (unsigned int column, const Span **spans_out) const uint8_t *FTGATexture::GetColumn (unsigned int column, const Span **spans_out)
{ {
if (Pixels == NULL) if (Pixels == NULL)
{ {
@ -234,7 +234,7 @@ const BYTE *FTGATexture::GetColumn (unsigned int column, const Span **spans_out)
// //
//========================================================================== //==========================================================================
const BYTE *FTGATexture::GetPixels () const uint8_t *FTGATexture::GetPixels ()
{ {
if (Pixels == NULL) if (Pixels == NULL)
{ {
@ -249,10 +249,10 @@ const BYTE *FTGATexture::GetPixels ()
// //
//========================================================================== //==========================================================================
void FTGATexture::ReadCompressed(FileReader &lump, BYTE * buffer, int bytesperpixel) void FTGATexture::ReadCompressed(FileReader &lump, uint8_t * buffer, int bytesperpixel)
{ {
BYTE b; uint8_t b;
BYTE data[4]; uint8_t data[4];
int Size = Width * Height; int Size = Width * Height;
while (Size > 0) while (Size > 0)
@ -288,14 +288,14 @@ void FTGATexture::ReadCompressed(FileReader &lump, BYTE * buffer, int bytesperpi
void FTGATexture::MakeTexture () void FTGATexture::MakeTexture ()
{ {
BYTE PaletteMap[256]; uint8_t PaletteMap[256];
FWadLump lump = Wads.OpenLumpNum (SourceLump); FWadLump lump = Wads.OpenLumpNum (SourceLump);
TGAHeader hdr; TGAHeader hdr;
WORD w; uint16_t w;
BYTE r,g,b,a; uint8_t r,g,b,a;
BYTE * buffer; uint8_t * buffer;
Pixels = new BYTE[Width*Height]; Pixels = new uint8_t[Width*Height];
lump.Read(&hdr, sizeof(hdr)); lump.Read(&hdr, sizeof(hdr));
lump.Seek(hdr.id_len, SEEK_CUR); lump.Seek(hdr.id_len, SEEK_CUR);
@ -339,7 +339,7 @@ void FTGATexture::MakeTexture ()
} }
int Size = Width * Height * (hdr.bpp>>3); int Size = Width * Height * (hdr.bpp>>3);
buffer = new BYTE[Size]; buffer = new uint8_t[Size];
if (hdr.img_type < 4) // uncompressed if (hdr.img_type < 4) // uncompressed
{ {
@ -350,7 +350,7 @@ void FTGATexture::MakeTexture ()
ReadCompressed(lump, buffer, hdr.bpp>>3); ReadCompressed(lump, buffer, hdr.bpp>>3);
} }
BYTE * ptr = buffer; uint8_t * ptr = buffer;
int step_x = (hdr.bpp>>3); int step_x = (hdr.bpp>>3);
int Pitch = Width * step_x; int Pitch = Width * step_x;
@ -372,7 +372,7 @@ void FTGATexture::MakeTexture ()
case 1: // paletted case 1: // paletted
for(int y=0;y<Height;y++) for(int y=0;y<Height;y++)
{ {
BYTE * p = ptr + y * Pitch; uint8_t * p = ptr + y * Pitch;
for(int x=0;x<Width;x++) for(int x=0;x<Width;x++)
{ {
Pixels[x*Height+y] = PaletteMap[*p]; Pixels[x*Height+y] = PaletteMap[*p];
@ -389,7 +389,7 @@ void FTGATexture::MakeTexture ()
step_x>>=1; step_x>>=1;
for(int y=0;y<Height;y++) for(int y=0;y<Height;y++)
{ {
WORD * p = (WORD*)(ptr + y * Pitch); uint16_t * p = (uint16_t*)(ptr + y * Pitch);
for(int x=0;x<Width;x++) for(int x=0;x<Width;x++)
{ {
int v = LittleLong(*p); int v = LittleLong(*p);
@ -402,7 +402,7 @@ void FTGATexture::MakeTexture ()
case 24: case 24:
for(int y=0;y<Height;y++) for(int y=0;y<Height;y++)
{ {
BYTE * p = ptr + y * Pitch; uint8_t * p = ptr + y * Pitch;
for(int x=0;x<Width;x++) for(int x=0;x<Width;x++)
{ {
Pixels[x*Height+y] = RGB256k.RGB[p[2]>>2][p[1]>>2][p[0]>>2]; Pixels[x*Height+y] = RGB256k.RGB[p[2]>>2][p[1]>>2][p[0]>>2];
@ -416,7 +416,7 @@ void FTGATexture::MakeTexture ()
{ {
for(int y=0;y<Height;y++) for(int y=0;y<Height;y++)
{ {
BYTE * p = ptr + y * Pitch; uint8_t * p = ptr + y * Pitch;
for(int x=0;x<Width;x++) for(int x=0;x<Width;x++)
{ {
Pixels[x*Height+y] = RGB256k.RGB[p[2]>>2][p[1]>>2][p[0]>>2]; Pixels[x*Height+y] = RGB256k.RGB[p[2]>>2][p[1]>>2][p[0]>>2];
@ -428,7 +428,7 @@ void FTGATexture::MakeTexture ()
{ {
for(int y=0;y<Height;y++) for(int y=0;y<Height;y++)
{ {
BYTE * p = ptr + y * Pitch; uint8_t * p = ptr + y * Pitch;
for(int x=0;x<Width;x++) for(int x=0;x<Width;x++)
{ {
Pixels[x*Height+y] = p[3] >= 128? RGB256k.RGB[p[2]>>2][p[1]>>2][p[0]>>2] : 0; Pixels[x*Height+y] = p[3] >= 128? RGB256k.RGB[p[2]>>2][p[1]>>2][p[0]>>2] : 0;
@ -449,7 +449,7 @@ void FTGATexture::MakeTexture ()
case 8: case 8:
for(int y=0;y<Height;y++) for(int y=0;y<Height;y++)
{ {
BYTE * p = ptr + y * Pitch; uint8_t * p = ptr + y * Pitch;
for(int x=0;x<Width;x++) for(int x=0;x<Width;x++)
{ {
Pixels[x*Height+y] = GrayMap[*p]; Pixels[x*Height+y] = GrayMap[*p];
@ -461,7 +461,7 @@ void FTGATexture::MakeTexture ()
case 16: case 16:
for(int y=0;y<Height;y++) for(int y=0;y<Height;y++)
{ {
BYTE * p = ptr + y * Pitch; uint8_t * p = ptr + y * Pitch;
for(int x=0;x<Width;x++) for(int x=0;x<Width;x++)
{ {
Pixels[x*Height+y] = GrayMap[p[1]]; // only use the high byte Pixels[x*Height+y] = GrayMap[p[1]]; // only use the high byte
@ -492,9 +492,9 @@ int FTGATexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCo
PalEntry pe[256]; PalEntry pe[256];
FWadLump lump = Wads.OpenLumpNum (SourceLump); FWadLump lump = Wads.OpenLumpNum (SourceLump);
TGAHeader hdr; TGAHeader hdr;
WORD w; uint16_t w;
BYTE r,g,b,a; uint8_t r,g,b,a;
BYTE * sbuffer; uint8_t * sbuffer;
int transval = 0; int transval = 0;
lump.Read(&hdr, sizeof(hdr)); lump.Read(&hdr, sizeof(hdr));
@ -541,7 +541,7 @@ int FTGATexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCo
} }
int Size = Width * Height * (hdr.bpp>>3); int Size = Width * Height * (hdr.bpp>>3);
sbuffer = new BYTE[Size]; sbuffer = new uint8_t[Size];
if (hdr.img_type < 4) // uncompressed if (hdr.img_type < 4) // uncompressed
{ {
@ -552,7 +552,7 @@ int FTGATexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCo
ReadCompressed(lump, sbuffer, hdr.bpp>>3); ReadCompressed(lump, sbuffer, hdr.bpp>>3);
} }
BYTE * ptr = sbuffer; uint8_t * ptr = sbuffer;
int step_x = (hdr.bpp>>3); int step_x = (hdr.bpp>>3);
int Pitch = Width * step_x; int Pitch = Width * step_x;