diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index ee16bbe0ca..d50274473b 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -755,6 +755,8 @@ file( GLOB HEADER_FILES
 	scripting/decorate/*.h
 	scripting/zscript/*.h
 	scripting/vm/*.h
+	timidity/*.h
+	wildmidi/*.h
 	xlat/*.h
 	gl/*.h
 	gl/api/*.h
diff --git a/src/actor.h b/src/actor.h
index 080813bf5d..b5f4472b94 100644
--- a/src/actor.h
+++ b/src/actor.h
@@ -511,7 +511,7 @@ typedef TFlags<ActorFlag5> ActorFlags5;
 typedef TFlags<ActorFlag6> ActorFlags6;
 typedef TFlags<ActorFlag7> ActorFlags7;
 typedef TFlags<ActorRenderFlag> ActorRenderFlags;
-typedef TFlags<ActorBounceFlag, WORD> ActorBounceFlags;
+typedef TFlags<ActorBounceFlag, uint16_t> ActorBounceFlags;
 DEFINE_TFLAGS_OPERATORS (ActorFlags)
 DEFINE_TFLAGS_OPERATORS (ActorFlags2)
 DEFINE_TFLAGS_OPERATORS (ActorFlags3)
@@ -746,7 +746,7 @@ public:
 	void DestroyAllInventory ();
 
 	// Set the alphacolor field properly
-	void SetShade (DWORD rgb);
+	void SetShade (uint32_t rgb);
 	void SetShade (int r, int g, int b);
 
 	// Plays a conversation animation
@@ -991,8 +991,8 @@ public:
 	uint8_t			fountaincolor;		// Split out of 'effect' to have easier access.
 	FRenderStyle	RenderStyle;		// Style to draw this actor with
 	FTextureID		picnum;				// Draw this instead of sprite if valid
-	DWORD			fillcolor;			// Color to draw when STYLE_Shaded
-	DWORD			Translation;
+	uint32_t			fillcolor;			// Color to draw when STYLE_Shaded
+	uint32_t			Translation;
 
 	ActorRenderFlags	renderflags;		// Different rendering flags
 	ActorFlags		flags;
@@ -1045,7 +1045,7 @@ public:
 	int				projectileKickback;
 
 	// [BB] If 0, everybody can see the actor, if > 0, only members of team (VisibleToTeam-1) can see it.
-	DWORD			VisibleToTeam;
+	uint32_t			VisibleToTeam;
 
 	int				special1;		// Special info
 	int				special2;		// Special info
@@ -1055,9 +1055,9 @@ public:
 	int				weaponspecial;	// Special info for weapons.
 	int 			health;
 	uint8_t			movedir;		// 0-7
-	SBYTE			visdir;
-	SWORD			movecount;		// when 0, select a new dir
-	SWORD			strafecount;	// for MF3_AVOIDMELEE
+	int8_t			visdir;
+	int16_t			movecount;		// when 0, select a new dir
+	int16_t			strafecount;	// for MF3_AVOIDMELEE
 	TObjPtr<AActor*> target;			// thing being chased/attacked (or NULL)
 									// also the originator for missiles
 	TObjPtr<AActor*>	lastenemy;		// Last known enemy -- killough 2/15/98
@@ -1070,7 +1070,7 @@ public:
 	player_t		*player;		// only valid if type of APlayerPawn
 	TObjPtr<AActor*>	LastLookActor;	// Actor last looked for (if TIDtoHate != 0)
 	DVector3		SpawnPoint; 	// For nightmare respawn
-	WORD			SpawnAngle;
+	uint16_t			SpawnAngle;
 	int				StartHealth;
 	uint8_t			WeaveIndexXY;	// Separated from special2 because it's used by globally accessible functions.
 	uint8_t			WeaveIndexZ;
@@ -1092,9 +1092,9 @@ public:
 	int				waterlevel;		// 0=none, 1=feet, 2=waist, 3=eyes
 	uint8_t			boomwaterlevel;	// splash information for non-swimmable water sectors
 	uint8_t			MinMissileChance;// [RH] If a random # is > than this, then missile attack.
-	SBYTE			LastLookPlayerNumber;// Player number last looked for (if TIDtoHate == 0)
+	int8_t			LastLookPlayerNumber;// Player number last looked for (if TIDtoHate == 0)
 	ActorBounceFlags	BounceFlags;	// which bouncing type?
-	DWORD			SpawnFlags;		// Increased to DWORD because of Doom 64
+	uint32_t			SpawnFlags;		// Increased to uint32_t because of Doom 64
 	double			meleerange;		// specifies how far a melee attack reaches.
 	double			meleethreshold;	// Distance below which a monster doesn't try to shoot missiles anynore
 									// but instead tries to come closer for a melee attack.
@@ -1137,13 +1137,13 @@ public:
 
 
 	TObjPtr<AInventory*>	Inventory;		// [RH] This actor's inventory
-	DWORD			InventoryID;	// A unique ID to keep track of inventory items
+	uint32_t			InventoryID;	// A unique ID to keep track of inventory items
 
 	uint8_t smokecounter;
 	uint8_t FloatBobPhase;
 	uint8_t FriendPlayer;				// [RH] Player # + 1 this friendly monster works for (so 0 is no player, 1 is player 0, etc)
 	PalEntry BloodColor;
-	DWORD BloodTranslation;
+	uint32_t BloodTranslation;
 
 	// [RH] Stuff that used to be part of an Actor Info
 	FSoundIDNoInit SeeSound;
@@ -1160,7 +1160,7 @@ public:
 	double MaxStepHeight;
 
 	int32_t Mass;
-	SWORD PainChance;
+	int16_t PainChance;
 	int PainThreshold;
 	FNameNoInit DamageType;
 	FNameNoInit DamageTypeReceived;
@@ -1545,7 +1545,7 @@ template<class T> inline T *Spawn()	// for inventory items we do not need coordi
 }
 
 void PrintMiscActorInfo(AActor * query);
-AActor *P_LinePickActor(AActor *t1, DAngle angle, double distance, DAngle pitch, ActorFlags actorMask, DWORD wallMask);
+AActor *P_LinePickActor(AActor *t1, DAngle angle, double distance, DAngle pitch, ActorFlags actorMask, uint32_t wallMask);
 
 // If we want to make P_AimLineAttack capable of handling arbitrary portals, it needs to pass a lot more info than just the linetarget actor.
 struct FTranslatedLineTarget
diff --git a/src/am_map.cpp b/src/am_map.cpp
index 8df0741828..5c2a80e9d1 100644
--- a/src/am_map.cpp
+++ b/src/am_map.cpp
@@ -256,7 +256,7 @@ struct AMColorset
 			c[i].FromCVar(*values[i]);
 		}
 
-		DWORD ba = *(values[0]);
+		uint32_t ba = *(values[0]);
 
 		int r = RPART(ba) - 16;
 		int g = GPART(ba) - 16;
@@ -791,7 +791,7 @@ static bool stopped = true;
 static void AM_calcMinMaxMtoF();
 
 static void DrawMarker (FTexture *tex, double x, double y, int yadjust,
-	INTBOOL flip, double xscale, double yscale, int translation, double alpha, DWORD fillcolor, FRenderStyle renderstyle);
+	INTBOOL flip, double xscale, double yscale, int translation, double alpha, uint32_t fillcolor, FRenderStyle renderstyle);
 
 void AM_rotatePoint (double *x, double *y);
 void AM_rotate (double *x, double *y, DAngle an);
@@ -1920,7 +1920,7 @@ void AM_drawSubsectors()
 
 		// Fill the points array from the subsector.
 		points.Resize(subsectors[i].numlines);
-		for (DWORD j = 0; j < subsectors[i].numlines; ++j)
+		for (uint32_t j = 0; j < subsectors[i].numlines; ++j)
 		{
 			mpoint_t pt = { subsectors[i].firstline[j].v1->fX(),
 							subsectors[i].firstline[j].v1->fY() };
@@ -2911,7 +2911,7 @@ void AM_drawThings ()
 //=============================================================================
 
 static void DrawMarker (FTexture *tex, double x, double y, int yadjust,
-	INTBOOL flip, double xscale, double yscale, int translation, double alpha, DWORD fillcolor, FRenderStyle renderstyle)
+	INTBOOL flip, double xscale, double yscale, int translation, double alpha, uint32_t fillcolor, FRenderStyle renderstyle)
 {
 	if (tex == NULL || tex->UseType == FTexture::TEX_Null)
 	{
@@ -2932,7 +2932,7 @@ static void DrawMarker (FTexture *tex, double x, double y, int yadjust,
 		DTA_TranslationIndex, translation,
 		DTA_Alpha, alpha,
 		DTA_FillColor, fillcolor,
-		DTA_RenderStyle, DWORD(renderstyle),
+		DTA_RenderStyle, uint32_t(renderstyle),
 		TAG_DONE);
 }
 
@@ -2977,7 +2977,7 @@ void AM_drawAuthorMarkers ()
 
 		FTextureID picnum;
 		FTexture *tex;
-		WORD flip = 0;
+		uint16_t flip = 0;
 
 		if (mark->picnum.isValid())
 		{
diff --git a/src/basictypes.h b/src/basictypes.h
index aceb4752cb..3da363dd75 100644
--- a/src/basictypes.h
+++ b/src/basictypes.h
@@ -37,8 +37,8 @@ typedef int						INTBOOL;
 typedef struct _GUID
 {
     DWORD	Data1;
-    WORD	Data2;
-    WORD	Data3;
+    uint16_t Data2;
+	uint16_t Data3;
     uint8_t	Data4[8];
 } GUID;
 #endif
diff --git a/src/c_console.cpp b/src/c_console.cpp
index 83e61d3feb..f33b2ed370 100644
--- a/src/c_console.cpp
+++ b/src/c_console.cpp
@@ -94,7 +94,7 @@ CVAR(Bool, con_notablist, false, CVAR_ARCHIVE)
 
 
 static FTextureID conback;
-static DWORD conshade;
+static uint32_t conshade;
 static bool conline;
 
 extern int		gametic;
diff --git a/src/c_cvars.cpp b/src/c_cvars.cpp
index fecb156c3a..fa4b8d1484 100644
--- a/src/c_cvars.cpp
+++ b/src/c_cvars.cpp
@@ -74,7 +74,7 @@ FBaseCVar::FBaseCVar (const FBaseCVar &var)
 	I_FatalError ("Use of cvar copy constructor");
 }
 
-FBaseCVar::FBaseCVar (const char *var_name, DWORD flags, void (*callback)(FBaseCVar &))
+FBaseCVar::FBaseCVar (const char *var_name, uint32_t flags, void (*callback)(FBaseCVar &))
 {
 	FBaseCVar *var;
 
@@ -573,8 +573,8 @@ UCVarValue FBaseCVar::FromString (const char *value, ECVarType type)
 		if (i == 38 && value[i] == 0)
 		{
 			cGUID.Data1 = strtoul (value + 1, NULL, 16);
-			cGUID.Data2 = (WORD)strtoul (value + 10, NULL, 16);
-			cGUID.Data3 = (WORD)strtoul (value + 15, NULL, 16);
+			cGUID.Data2 = (uint16_t)strtoul (value + 10, NULL, 16);
+			cGUID.Data3 = (uint16_t)strtoul (value + 15, NULL, 16);
 			cGUID.Data4[0] = HexToByte (value + 20);
 			cGUID.Data4[1] = HexToByte (value + 22);
 			cGUID.Data4[2] = HexToByte (value + 25);
@@ -690,7 +690,7 @@ DEFINE_ACTION_FUNCTION(_CVar, GetRealType)
 // Boolean cvar implementation
 //
 
-FBoolCVar::FBoolCVar (const char *name, bool def, DWORD flags, void (*callback)(FBoolCVar &))
+FBoolCVar::FBoolCVar (const char *name, bool def, uint32_t flags, void (*callback)(FBoolCVar &))
 : FBaseCVar (name, flags, reinterpret_cast<void (*)(FBaseCVar &)>(callback))
 {
 	DefaultValue = def;
@@ -748,7 +748,7 @@ void FBoolCVar::DoSet (UCVarValue value, ECVarType type)
 // Integer cvar implementation
 //
 
-FIntCVar::FIntCVar (const char *name, int def, DWORD flags, void (*callback)(FIntCVar &))
+FIntCVar::FIntCVar (const char *name, int def, uint32_t flags, void (*callback)(FIntCVar &))
 : FBaseCVar (name, flags, reinterpret_cast<void (*)(FBaseCVar &)>(callback))
 {
 	DefaultValue = def;
@@ -806,7 +806,7 @@ void FIntCVar::DoSet (UCVarValue value, ECVarType type)
 // Floating point cvar implementation
 //
 
-FFloatCVar::FFloatCVar (const char *name, float def, DWORD flags, void (*callback)(FFloatCVar &))
+FFloatCVar::FFloatCVar (const char *name, float def, uint32_t flags, void (*callback)(FFloatCVar &))
 : FBaseCVar (name, flags, reinterpret_cast<void (*)(FBaseCVar &)>(callback))
 {
 	DefaultValue = def;
@@ -874,7 +874,7 @@ void FFloatCVar::DoSet (UCVarValue value, ECVarType type)
 // String cvar implementation
 //
 
-FStringCVar::FStringCVar (const char *name, const char *def, DWORD flags, void (*callback)(FStringCVar &))
+FStringCVar::FStringCVar (const char *name, const char *def, uint32_t flags, void (*callback)(FStringCVar &))
 : FBaseCVar (name, flags, reinterpret_cast<void (*)(FBaseCVar &)>(callback))
 {
 	DefaultValue = copystring (def);
@@ -943,7 +943,7 @@ void FStringCVar::DoSet (UCVarValue value, ECVarType type)
 // Color cvar implementation
 //
 
-FColorCVar::FColorCVar (const char *name, int def, DWORD flags, void (*callback)(FColorCVar &))
+FColorCVar::FColorCVar (const char *name, int def, uint32_t flags, void (*callback)(FColorCVar &))
 : FIntCVar (name, def, flags, reinterpret_cast<void (*)(FIntCVar &)>(callback))
 {
 }
@@ -1024,7 +1024,7 @@ int FColorCVar::ToInt2 (UCVarValue value, ECVarType type)
 // GUID cvar implementation
 //
 
-FGUIDCVar::FGUIDCVar (const char *name, const GUID *def, DWORD flags, void (*callback)(FGUIDCVar &))
+FGUIDCVar::FGUIDCVar (const char *name, const GUID *def, uint32_t flags, void (*callback)(FGUIDCVar &))
 : FBaseCVar (name, flags, reinterpret_cast<void (*)(FBaseCVar &)>(callback))
 {
 	if (def != NULL)
@@ -1141,7 +1141,7 @@ DEFINE_ACTION_FUNCTION(_CVar, ResetToDefault)
 // the network. The "host" cvar is responsible for that.
 //
 
-FFlagCVar::FFlagCVar (const char *name, FIntCVar &realvar, DWORD bitval)
+FFlagCVar::FFlagCVar (const char *name, FIntCVar &realvar, uint32_t bitval)
 : FBaseCVar (name, 0, NULL),
 ValueVar (realvar),
 BitVal (bitval)
@@ -1246,7 +1246,7 @@ void FFlagCVar::DoSet (UCVarValue value, ECVarType type)
 // Similar to FFlagCVar but can have multiple bits
 //
 
-FMaskCVar::FMaskCVar (const char *name, FIntCVar &realvar, DWORD bitval)
+FMaskCVar::FMaskCVar (const char *name, FIntCVar &realvar, uint32_t bitval)
 : FBaseCVar (name, 0, NULL),
 ValueVar (realvar),
 BitVal (bitval)
@@ -1354,7 +1354,7 @@ static int sortcvars (const void *a, const void *b)
 	return strcmp (((*(FBaseCVar **)a))->GetName(), ((*(FBaseCVar **)b))->GetName());
 }
 
-void FilterCompactCVars (TArray<FBaseCVar *> &cvars, DWORD filter)
+void FilterCompactCVars (TArray<FBaseCVar *> &cvars, uint32_t filter)
 {
 	// Accumulate all cvars that match the filter flags.
 	for (FBaseCVar *cvar = CVars; cvar != NULL; cvar = cvar->m_Next)
@@ -1370,7 +1370,7 @@ void FilterCompactCVars (TArray<FBaseCVar *> &cvars, DWORD filter)
 	}
 }
 
-void C_WriteCVars (uint8_t **demo_p, DWORD filter, bool compact)
+void C_WriteCVars (uint8_t **demo_p, uint32_t filter, bool compact)
 {
 	FString dump = C_GetMassCVarString(filter, compact);
 	size_t dumplen = dump.Len() + 1;	// include terminating \0
@@ -1378,7 +1378,7 @@ void C_WriteCVars (uint8_t **demo_p, DWORD filter, bool compact)
 	*demo_p += dumplen;
 }
 
-FString C_GetMassCVarString (DWORD filter, bool compact)
+FString C_GetMassCVarString (uint32_t filter, bool compact)
 {
 	FBaseCVar *cvar;
 	FString dump;
@@ -1420,7 +1420,7 @@ void C_ReadCVars (uint8_t **demo_p)
 	{       // compact mode
 		TArray<FBaseCVar *> cvars;
 		FBaseCVar *cvar;
-		DWORD filter;
+		uint32_t filter;
 
 		ptr++;
 		breakpt = strchr (ptr, '\\');
@@ -1613,7 +1613,7 @@ FBaseCVar *GetUserCVar(int playernum, const char *cvarname)
 //
 //===========================================================================
 
-FBaseCVar *C_CreateCVar(const char *var_name, ECVarType var_type, DWORD flags)
+FBaseCVar *C_CreateCVar(const char *var_name, ECVarType var_type, uint32_t flags)
 {
 	assert(FindCVar(var_name, NULL) == NULL);
 	flags |= CVAR_AUTO;
@@ -1634,7 +1634,7 @@ void UnlatchCVars (void)
 
 	while (LatchedValues.Pop (var))
 	{
-		DWORD oldflags = var.Variable->Flags;
+		uint32_t oldflags = var.Variable->Flags;
 		var.Variable->Flags &= ~(CVAR_LATCH | CVAR_SERVERINFO);
 		var.Variable->SetGenericRep (var.Value, var.Type);
 		if (var.Type == CVAR_String)
@@ -1643,7 +1643,7 @@ void UnlatchCVars (void)
 	}
 }
 
-void DestroyCVarsFlagged (DWORD flags)
+void DestroyCVarsFlagged (uint32_t flags)
 {
 	FBaseCVar *cvar = CVars;
 	FBaseCVar *next = cvar;
@@ -1808,7 +1808,7 @@ void FBaseCVar::ListVars (const char *filter, bool plain)
 	{
 		if (CheckWildcards (filter, var->GetName()))
 		{
-			DWORD flags = var->GetFlags();
+			uint32_t flags = var->GetFlags();
 			if (plain)
 			{ // plain formatting does not include user-defined cvars
 				if (!(flags & CVAR_UNSETTABLE))
diff --git a/src/c_cvars.h b/src/c_cvars.h
index 221097f347..5a918bc637 100644
--- a/src/c_cvars.h
+++ b/src/c_cvars.h
@@ -165,7 +165,7 @@ private:
 	friend FBaseCVar *FindCVar (const char *var_name, FBaseCVar **prev);
 	friend FBaseCVar *FindCVarSub (const char *var_name, int namelen);
 	friend void UnlatchCVars (void);
-	friend void DestroyCVarsFlagged (DWORD flags);
+	friend void DestroyCVarsFlagged (uint32_t flags);
 	friend void C_ArchiveCVars (FConfigFile *f, uint32 filter);
 	friend void C_SetCVarsToDefaults (void);
 	friend void FilterCompactCVars (TArray<FBaseCVar *> &cvars, uint32 filter);
@@ -196,13 +196,13 @@ FBaseCVar *GetCVar(AActor *activator, const char *cvarname);
 FBaseCVar *GetUserCVar(int playernum, const char *cvarname);
 
 // Create a new cvar with the specified name and type
-FBaseCVar *C_CreateCVar(const char *var_name, ECVarType var_type, DWORD flags);
+FBaseCVar *C_CreateCVar(const char *var_name, ECVarType var_type, uint32_t flags);
 
 // Called from G_InitNew()
 void UnlatchCVars (void);
 
 // Destroy CVars with the matching flags; called from CCMD(restart)
-void DestroyCVarsFlagged (DWORD flags);
+void DestroyCVarsFlagged (uint32_t flags);
 
 // archive cvars to FILE f
 void C_ArchiveCVars (FConfigFile *f, uint32 filter);
diff --git a/src/c_dispatch.cpp b/src/c_dispatch.cpp
index 198460b62f..ad32fcca97 100644
--- a/src/c_dispatch.cpp
+++ b/src/c_dispatch.cpp
@@ -297,13 +297,13 @@ static int ListActionCommands (const char *pattern)
 #endif
 
 #if !defined (get16bits)
-#define get16bits(d) ((((DWORD)(((const uint8_t *)(d))[1])) << 8)\
-                       +(DWORD)(((const uint8_t *)(d))[0]) )
+#define get16bits(d) ((((uint32_t)(((const uint8_t *)(d))[1])) << 8)\
+                       +(uint32_t)(((const uint8_t *)(d))[0]) )
 #endif
 
-DWORD SuperFastHash (const char *data, size_t len)
+uint32_t SuperFastHash (const char *data, size_t len)
 {
-	DWORD hash = 0, tmp;
+	uint32_t hash = 0, tmp;
 	size_t rem;
 
 	if (len == 0 || data == NULL) return 0;
@@ -352,12 +352,12 @@ DWORD SuperFastHash (const char *data, size_t len)
 /* A modified version to do a case-insensitive hash */
 
 #undef get16bits
-#define get16bits(d) ((((DWORD)tolower(((const uint8_t *)(d))[1])) << 8)\
-                       +(DWORD)tolower(((const uint8_t *)(d))[0]) )
+#define get16bits(d) ((((uint32_t)tolower(((const uint8_t *)(d))[1])) << 8)\
+                       +(uint32_t)tolower(((const uint8_t *)(d))[0]) )
 
-DWORD SuperFastHashI (const char *data, size_t len)
+uint32_t SuperFastHashI (const char *data, size_t len)
 {
-	DWORD hash = 0, tmp;
+	uint32_t hash = 0, tmp;
 	size_t rem;
 
 	if (len <= 0 || data == NULL) return 0;
diff --git a/src/c_dispatch.h b/src/c_dispatch.h
index d85b2a116c..68d6233514 100644
--- a/src/c_dispatch.h
+++ b/src/c_dispatch.h
@@ -152,7 +152,7 @@ struct FButtonStatus
 {
 	enum { MAX_KEYS = 6 };	// Maximum number of keys that can press this button
 
-	WORD Keys[MAX_KEYS];
+	uint16_t Keys[MAX_KEYS];
 	BYTE bDown;				// Button is down right now
 	BYTE bWentDown;			// Button went down this tic
 	BYTE bWentUp;			// Button went up this tic
diff --git a/src/colormatcher.cpp b/src/colormatcher.cpp
index 8957439439..bc0a921282 100644
--- a/src/colormatcher.cpp
+++ b/src/colormatcher.cpp
@@ -50,7 +50,7 @@ FColorMatcher::FColorMatcher ()
 	Pal = NULL;
 }
 
-FColorMatcher::FColorMatcher (const DWORD *palette)
+FColorMatcher::FColorMatcher (const uint32_t *palette)
 {
 	SetPalette (palette);
 }
@@ -66,7 +66,7 @@ FColorMatcher &FColorMatcher::operator= (const FColorMatcher &other)
 	return *this;
 }
 
-void FColorMatcher::SetPalette (const DWORD *palette)
+void FColorMatcher::SetPalette (const uint32_t *palette)
 {
 	Pal = (const PalEntry *)palette;
 }
diff --git a/src/colormatcher.h b/src/colormatcher.h
index edf456b510..e605fe0553 100644
--- a/src/colormatcher.h
+++ b/src/colormatcher.h
@@ -38,10 +38,10 @@ class FColorMatcher
 {
 public:
 	FColorMatcher ();
-	FColorMatcher (const DWORD *palette);
+	FColorMatcher (const uint32_t *palette);
 	FColorMatcher (const FColorMatcher &other);
 
-	void SetPalette (const DWORD *palette);
+	void SetPalette (const uint32_t *palette);
 	uint8_t Pick (int r, int g, int b);
 	uint8_t Pick (PalEntry pe)
 	{
diff --git a/src/compatibility.cpp b/src/compatibility.cpp
index 1737b237d4..7698a3f8b8 100644
--- a/src/compatibility.cpp
+++ b/src/compatibility.cpp
@@ -61,7 +61,7 @@
 struct FCompatOption
 {
 	const char *Name;
-	DWORD CompatFlags;
+	uint32_t CompatFlags;
 	int WhichSlot;
 };
 
diff --git a/src/compatibility.h b/src/compatibility.h
index b2fbec6818..2c33e962eb 100644
--- a/src/compatibility.h
+++ b/src/compatibility.h
@@ -8,7 +8,7 @@
 union FMD5Holder
 {
 	BYTE Bytes[16];
-	DWORD DWords[4];
+	uint32_t DWords[4];
 	hash_t Hash;
 };
 
diff --git a/src/configfile.cpp b/src/configfile.cpp
index 3adbd3761b..146fefdfce 100644
--- a/src/configfile.cpp
+++ b/src/configfile.cpp
@@ -871,7 +871,7 @@ const char *FConfigFile::GenerateEndTag(const char *value)
 
 		for (int i = 0; i < 5; ++i)
 		{
-			//DWORD three_bytes = (rand_bytes[i*3] << 16) | (rand_bytes[i*3+1] << 8) | (rand_bytes[i*3+2]); // ???
+			//uint32_t three_bytes = (rand_bytes[i*3] << 16) | (rand_bytes[i*3+1] << 8) | (rand_bytes[i*3+2]); // ???
 			EndTag[4+i*4  ] = Base64Table[rand_bytes[i*3] >> 2];
 			EndTag[4+i*4+1] = Base64Table[((rand_bytes[i*3] & 3) << 4) | (rand_bytes[i*3+1] >> 4)];
 			EndTag[4+i*4+2] = Base64Table[((rand_bytes[i*3+1] & 15) << 2) | (rand_bytes[i*3+2] >> 6)];
diff --git a/src/d_dehacked.cpp b/src/d_dehacked.cpp
index 139678400e..a4ff314a71 100644
--- a/src/d_dehacked.cpp
+++ b/src/d_dehacked.cpp
@@ -401,11 +401,11 @@ static bool HandleKey (const struct Key *keys, void *structure, const char *key,
 static int FindSprite (const char *sprname)
 {
 	int i;
-	DWORD nameint = *((DWORD *)sprname);
+	uint32_t nameint = *((uint32_t *)sprname);
 
 	for (i = 0; i < NumUnchangedSprites; ++i)
 	{
-		if (*((DWORD *)&UnchangedSpriteNames[i*4]) == nameint)
+		if (*((uint32_t *)&UnchangedSpriteNames[i*4]) == nameint)
 		{
 			return i;
 		}
@@ -850,7 +850,7 @@ static int PatchThing (int thingy)
 	bool patchedStates = false;
 	ActorFlags oldflags;
 	PClassActor *type;
-	SWORD *ednum, dummyed;
+	int16_t *ednum, dummyed;
 
 	type = NULL;
 	info = (AActor *)&dummy;
@@ -898,7 +898,7 @@ static int PatchThing (int thingy)
 		}
 		else if (linelen == 11 && stricmp (Line1, "Pain chance") == 0)
 		{
-			info->PainChance = (SWORD)val;
+			info->PainChance = (int16_t)val;
 		}
 		else if (linelen == 12 && stricmp (Line1, "Translucency") == 0)
 		{
@@ -1049,7 +1049,7 @@ static int PatchThing (int thingy)
 			}
 			else if (stricmp (Line1, "Bits") == 0)
 			{
-				DWORD value[4] = { 0, 0, 0 };
+				uint32_t value[4] = { 0, 0, 0 };
 				bool vchanged[4] = { false, false, false };
 				// ZDoom used to block the upper range of bits to force use of mnemonics for extra flags.
 				// MBF also defined extra flags in the same range, but without forcing mnemonics. For MBF
@@ -1244,7 +1244,7 @@ static int PatchThing (int thingy)
 			}
 			else if (stricmp (Line1, "ID #") == 0)
 			{
-				*ednum = (SWORD)val;
+				*ednum = (int16_t)val;
 			}
 		}
 		else Printf (unknown_str, Line1, "Thing", thingy);
@@ -2111,7 +2111,7 @@ static int PatchCodePtrs (int dummy)
 				}
 				else
 				{
-					TArray<DWORD> &args = sym->Variants[0].ArgFlags;
+					TArray<uint32_t> &args = sym->Variants[0].ArgFlags;
 					unsigned numargs = sym->GetImplicitArgs();
 					if ((sym->Variants[0].Flags & VARF_Virtual || (args.Size() > numargs && !(args[numargs] & VARF_Optional))))
 					{
@@ -2594,7 +2594,7 @@ static bool DoDehPatch()
 
 static inline bool CompareLabel (const char *want, const uint8_t *have)
 {
-	return *(DWORD *)want == *(DWORD *)have;
+	return *(uint32_t *)want == *(uint32_t *)have;
 }
 
 static int DehUseCount;
@@ -2724,7 +2724,7 @@ static bool LoadDehSupp ()
 						}
 						else
 						{
-							TArray<DWORD> &args = sym->Variants[0].ArgFlags;
+							TArray<uint32_t> &args = sym->Variants[0].ArgFlags;
 							unsigned numargs = sym->GetImplicitArgs();
 							if ((sym->Variants[0].Flags & VARF_Virtual || (args.Size() > numargs && !(args[numargs] & VARF_Optional))))
 							{
diff --git a/src/d_event.h b/src/d_event.h
index 2152ce0d9c..5b7d202a44 100644
--- a/src/d_event.h
+++ b/src/d_event.h
@@ -47,9 +47,9 @@ struct event_t
 {
 	uint8_t		type;
 	uint8_t		subtype;
-	SWORD 		data1;		// keys / mouse/joystick buttons
-	SWORD		data2;
-	SWORD		data3;
+	int16_t 		data1;		// keys / mouse/joystick buttons
+	int16_t		data2;
+	int16_t		data3;
 	int 		x;			// mouse/joystick x move
 	int 		y;			// mouse/joystick y move
 };
diff --git a/src/d_iwad.cpp b/src/d_iwad.cpp
index b80cbaf988..2a8504dc16 100644
--- a/src/d_iwad.cpp
+++ b/src/d_iwad.cpp
@@ -261,7 +261,7 @@ void FIWadManager::ParseIWadInfos(const char *fn)
 	FResourceFile *resfile = FResourceFile::OpenResourceFile(fn, NULL, true);
 	if (resfile != NULL)
 	{
-		DWORD cnt = resfile->LumpCount();
+		uint32_t cnt = resfile->LumpCount();
 		for(int i=cnt-1; i>=0; i--)
 		{
 			FResourceLump *lmp = resfile->GetLump(i);
@@ -296,7 +296,7 @@ int FIWadManager::ScanIWAD (const char *iwad)
 	if (iwadfile != NULL)
 	{
 		ClearChecks();
-		for(DWORD ii = 0; ii < iwadfile->LumpCount(); ii++)
+		for(uint32_t ii = 0; ii < iwadfile->LumpCount(); ii++)
 		{
 			FResourceLump *lump = iwadfile->GetLump(ii);
 
diff --git a/src/d_main.cpp b/src/d_main.cpp
index 63727c1786..0b14a8cb08 100644
--- a/src/d_main.cpp
+++ b/src/d_main.cpp
@@ -1939,7 +1939,7 @@ static FString CheckGameInfo(TArray<FString> & pwads)
 
 		if (resfile != NULL)
 		{
-			DWORD cnt = resfile->LumpCount();
+			uint32_t cnt = resfile->LumpCount();
 			for(int i=cnt-1; i>=0; i--)
 			{
 				FResourceLump *lmp = resfile->GetLump(i);
diff --git a/src/d_main.h b/src/d_main.h
index 0bcf73a209..034c263c7d 100644
--- a/src/d_main.h
+++ b/src/d_main.h
@@ -77,8 +77,8 @@ struct FIWADInfo
 	FString Autoname;		// Name of autoload ini section for this IWAD
 	FString Configname;		// Name of config section for this IWAD
 	FString Required;		// Requires another IWAD
-	DWORD FgColor;			// Foreground color for title banner
-	DWORD BkColor;			// Background color for title banner
+	uint32_t FgColor;			// Foreground color for title banner
+	uint32_t BkColor;			// Background color for title banner
 	EGameType gametype;		// which game are we playing?
 	FString MapInfo;		// Base mapinfo to load
 	TArray<FString> Load;	// Wads to be loaded with this one.
@@ -92,8 +92,8 @@ struct FIWADInfo
 struct FStartupInfo
 {
 	FString Name;
-	DWORD FgColor;			// Foreground color for title banner
-	DWORD BkColor;			// Background color for title banner
+	uint32_t FgColor;			// Foreground color for title banner
+	uint32_t BkColor;			// Background color for title banner
 	FString Song;
 	int Type;
 	enum
diff --git a/src/d_net.cpp b/src/d_net.cpp
index 221d67ba8f..f505285c26 100644
--- a/src/d_net.cpp
+++ b/src/d_net.cpp
@@ -127,7 +127,7 @@ void D_ProcessEvents (void);
 void G_BuildTiccmd (ticcmd_t *cmd); 
 void D_DoAdvanceDemo (void);
 
-static void SendSetup (DWORD playersdetected[MAXNETNODES], uint8_t gotsetup[MAXNETNODES], int len);
+static void SendSetup (uint32_t playersdetected[MAXNETNODES], uint8_t gotsetup[MAXNETNODES], int len);
 static void RunScript(uint8_t **stream, APlayerPawn *pawn, int snum, int argn, int always);
 
 int		reboundpacket;
@@ -1405,7 +1405,7 @@ void NetUpdate (void)
 
 struct ArbitrateData
 {
-	DWORD playersdetected[MAXNETNODES];
+	uint32_t playersdetected[MAXNETNODES];
 	uint8_t  gotsetup[MAXNETNODES];
 };
 
@@ -1490,7 +1490,7 @@ bool DoArbitrate (void *userdata)
 	if (consoleplayer == Net_Arbitrator)
 	{
 		for (i = 0; i < doomcom.numnodes; ++i)
-			if (data->playersdetected[i] != DWORD(1 << doomcom.numnodes) - 1 || !data->gotsetup[i])
+			if (data->playersdetected[i] != uint32_t(1 << doomcom.numnodes) - 1 || !data->gotsetup[i])
 				break;
 
 		if (i == doomcom.numnodes)
@@ -1631,7 +1631,7 @@ void D_ArbitrateNetStart (void)
 	StartScreen->NetDone();
 }
 
-static void SendSetup (DWORD playersdetected[MAXNETNODES], uint8_t gotsetup[MAXNETNODES], int len)
+static void SendSetup (uint32_t playersdetected[MAXNETNODES], uint8_t gotsetup[MAXNETNODES], int len)
 {
 	if (consoleplayer != Net_Arbitrator)
 	{
@@ -2270,7 +2270,7 @@ void Net_DoCommand (int type, uint8_t **stream, int player)
 	case DEM_INVUSE:
 	case DEM_INVDROP:
 		{
-			DWORD which = ReadLong (stream);
+			uint32_t which = ReadLong (stream);
 			int amt = -1;
 
 			if (type == DEM_INVDROP) amt = ReadLong(stream);
@@ -2308,7 +2308,7 @@ void Net_DoCommand (int type, uint8_t **stream, int player)
 		{
 			PClassActor *typeinfo;
 			int angle = 0;
-			SWORD tid = 0;
+			int16_t tid = 0;
 			uint8_t special = 0;
 			int args[5];
 
diff --git a/src/d_net.h b/src/d_net.h
index 45559b86aa..def8dee068 100644
--- a/src/d_net.h
+++ b/src/d_net.h
@@ -59,27 +59,27 @@
 //
 struct doomcom_t
 {
-	DWORD	id;				// should be DOOMCOM_ID
-	SWORD	intnum;			// DOOM executes an int to execute commands
+	uint32_t	id;				// should be DOOMCOM_ID
+	int16_t	intnum;			// DOOM executes an int to execute commands
 
 // communication between DOOM and the driver
-	SWORD	command;		// CMD_SEND or CMD_GET
-	SWORD	remotenode;		// dest for send, set by get (-1 = no packet).
-	SWORD	datalength;		// bytes in doomdata to be sent
+	int16_t	command;		// CMD_SEND or CMD_GET
+	int16_t	remotenode;		// dest for send, set by get (-1 = no packet).
+	int16_t	datalength;		// bytes in doomdata to be sent
 
 // info common to all nodes
-	SWORD	numnodes;		// console is always node 0.
-	SWORD	ticdup;			// 1 = no duplication, 2-5 = dup for slow nets
+	int16_t	numnodes;		// console is always node 0.
+	int16_t	ticdup;			// 1 = no duplication, 2-5 = dup for slow nets
 #ifdef DJGPP
-	SWORD	pad[5];			// keep things aligned for DOS drivers
+	int16_t	pad[5];			// keep things aligned for DOS drivers
 #endif
 
 // info specific to this node
-	SWORD	consoleplayer;
-	SWORD	numplayers;
+	int16_t	consoleplayer;
+	int16_t	numplayers;
 #ifdef DJGPP
-	SWORD	angleoffset;	// does not work, but needed to preserve
-	SWORD	drone;			// alignment for DOS drivers
+	int16_t	angleoffset;	// does not work, but needed to preserve
+	int16_t	drone;			// alignment for DOS drivers
 #endif
 
 // packet data to be sent
diff --git a/src/d_player.h b/src/d_player.h
index d94553454b..031083bbfe 100644
--- a/src/d_player.h
+++ b/src/d_player.h
@@ -256,7 +256,7 @@ public:
 	bool CheckSkin (int skin);
 
 	PClassActor *Type;
-	DWORD Flags;
+	uint32_t Flags;
 	TArray<int> Skins;
 };
 
@@ -386,7 +386,7 @@ public:
 	uint8_t		playerstate;
 	ticcmd_t	cmd;
 	usercmd_t	original_cmd;
-	DWORD		original_oldbuttons;
+	uint32_t		original_oldbuttons;
 
 	userinfo_t	userinfo;				// [RH] who is this?
 	
@@ -411,7 +411,7 @@ public:
 
 	bool		attackdown;
 	bool		usedown;
-	DWORD		oldbuttons;
+	uint32_t		oldbuttons;
 	int			health;					// only used between levels, mo->health
 										// is used during levels
 
@@ -423,7 +423,7 @@ public:
 	int			lastkilltime;			// [RH] For multikills
 	uint8_t		multicount;
 	uint8_t		spreecount;				// [RH] Keep track of killing sprees
-	WORD		WeaponState;
+	uint16_t		WeaponState;
 
 	AWeapon	   *ReadyWeapon;
 	AWeapon	   *PendingWeapon;			// WP_NOCHANGE if not changing
@@ -464,11 +464,11 @@ public:
 	FName		LastDamageType;			// [RH] For damage-specific pain and death sounds
 
 	TObjPtr<AActor*> MUSINFOactor;		// For MUSINFO purposes
-	SBYTE		MUSINFOtics;
+	int8_t		MUSINFOtics;
 
 	bool		settings_controller;	// Player can control game settings.
-	SBYTE		crouching;
-	SBYTE		crouchdir;
+	int8_t		crouching;
+	int8_t		crouchdir;
 
 	//Added by MC:
 	TObjPtr<DBot*> Bot;
diff --git a/src/d_protocol.cpp b/src/d_protocol.cpp
index 61a709630f..36ec2cab2b 100644
--- a/src/d_protocol.cpp
+++ b/src/d_protocol.cpp
@@ -159,7 +159,7 @@ int UnpackUserCmd (usercmd_t *ucmd, const usercmd_t *basis, uint8_t **stream)
 		// We can support up to 29 buttons, using from 0 to 4 bytes to store them.
 		if (flags & UCMDF_BUTTONS)
 		{
-			DWORD buttons = ucmd->buttons;
+			uint32_t buttons = ucmd->buttons;
 			uint8_t in = ReadByte(stream);
 
 			buttons = (buttons & ~0x7F) | (in & 0x7F);
@@ -204,7 +204,7 @@ int PackUserCmd (const usercmd_t *ucmd, const usercmd_t *basis, uint8_t **stream
 	uint8_t *temp = *stream;
 	uint8_t *start = *stream;
 	usercmd_t blank;
-	DWORD buttons_changed;
+	uint32_t buttons_changed;
 
 	if (basis == NULL)
 	{
diff --git a/src/d_protocol.h b/src/d_protocol.h
index f2e33463f9..7de26a179d 100644
--- a/src/d_protocol.h
+++ b/src/d_protocol.h
@@ -63,7 +63,7 @@ struct zdemoheader_s {
 
 struct usercmd_t
 {
-	DWORD	buttons;
+	uint32_t	buttons;
 	short	pitch;			// up/down
 	short	yaw;			// left/right
 	short	roll;			// "tilt"
@@ -141,7 +141,7 @@ enum EDemoCommand
 	DEM_DELCONTROLLER,	// 49 Player to remove from the controller list.
 	DEM_KILLCLASSCHEAT,	// 50 String: Class to kill.
 	DEM_UNDONE11,		// 51
-	DEM_SUMMON2,		// 52 String: Thing to fabricate, WORD: angle offset
+	DEM_SUMMON2,		// 52 String: Thing to fabricate, uint16_t: angle offset
 	DEM_SUMMONFRIEND2,	// 53
 	DEM_SUMMONFOE2,		// 54
 	DEM_ADDSLOTDEFAULT,	// 55
diff --git a/src/d_ticcmd.h b/src/d_ticcmd.h
index 7e819629c2..66a629e081 100644
--- a/src/d_ticcmd.h
+++ b/src/d_ticcmd.h
@@ -32,7 +32,7 @@
 struct ticcmd_t
 {
 	usercmd_t	ucmd;
-	SWORD		consistancy;	// checks for net game
+	int16_t		consistancy;	// checks for net game
 };
 
 #endif	// __D_TICCMD_H__
diff --git a/src/decallib.cpp b/src/decallib.cpp
index e352e90c24..d4ca5984bc 100644
--- a/src/decallib.cpp
+++ b/src/decallib.cpp
@@ -89,10 +89,10 @@ private:
 
 struct FDecalLib::FTranslation
 {
-	FTranslation (DWORD start, DWORD end);
-	FTranslation *LocateTranslation (DWORD start, DWORD end);
+	FTranslation (uint32_t start, uint32_t end);
+	FTranslation *LocateTranslation (uint32_t start, uint32_t end);
 
-	DWORD StartColor, EndColor;
+	uint32_t StartColor, EndColor;
 	FTranslation *Next;
 	uint16_t Index;
 };
@@ -546,7 +546,7 @@ void FDecalLib::ParseDecal (FScanner &sc)
 			break;
 
 		case DECAL_COLORS:
-			DWORD startcolor, endcolor;
+			uint32_t startcolor, endcolor;
 
 			sc.MustGetString (); startcolor = V_GetColor (NULL, sc);
 			sc.MustGetString (); endcolor   = V_GetColor (NULL, sc);
@@ -1009,7 +1009,7 @@ FDecalBase *FDecalLib::ScanTreeForName (const char *name, FDecalBase *root)
 	return root;
 }
 
-FDecalLib::FTranslation *FDecalLib::GenerateTranslation (DWORD start, DWORD end)
+FDecalLib::FTranslation *FDecalLib::GenerateTranslation (uint32_t start, uint32_t end)
 {
 	FTranslation *trans;
 
@@ -1069,9 +1069,9 @@ const FDecalTemplate *FDecalTemplate::GetDecal () const
 	return this;
 }
 
-FDecalLib::FTranslation::FTranslation (DWORD start, DWORD end)
+FDecalLib::FTranslation::FTranslation (uint32_t start, uint32_t end)
 {
-	DWORD ri, gi, bi, rs, gs, bs;
+	uint32_t ri, gi, bi, rs, gs, bs;
 	PalEntry *first, *last;
 	uint8_t *table;
 	unsigned int i, tablei;
@@ -1112,7 +1112,7 @@ FDecalLib::FTranslation::FTranslation (DWORD start, DWORD end)
 	Index = (uint16_t)TRANSLATION(TRANSLATION_Decals, tablei >> 8);
 }
 
-FDecalLib::FTranslation *FDecalLib::FTranslation::LocateTranslation (DWORD start, DWORD end)
+FDecalLib::FTranslation *FDecalLib::FTranslation::LocateTranslation (uint32_t start, uint32_t end)
 {
 	FTranslation *trans = this;
 
diff --git a/src/decallib.h b/src/decallib.h
index 5f08bdfd11..7c3369c4d0 100644
--- a/src/decallib.h
+++ b/src/decallib.h
@@ -60,7 +60,7 @@ protected:
 
 	FDecalBase *Left, *Right;
 	FName Name;
-	WORD SpawnID;
+	uint16_t SpawnID;
 	TArray<const PClass *> Users;	// Which actors generate this decal
 };
 
@@ -75,11 +75,11 @@ public:
 	void ReplaceDecalRef (FDecalBase *from, FDecalBase *to);
 
 	double ScaleX, ScaleY;
-	DWORD ShadeColor;
-	DWORD Translation;
+	uint32_t ShadeColor;
+	uint32_t Translation;
 	FRenderStyle RenderStyle;
 	FTextureID PicNum;
-	WORD RenderFlags;
+	uint16_t RenderFlags;
 	double Alpha;				// same as actor->alpha
 	const FDecalAnimator *Animator;
 	const FDecalBase *LowerDecal;
@@ -97,22 +97,22 @@ public:
 	void ReadDecals (FScanner &sc);
 	void ReadAllDecals ();
 
-	const FDecalTemplate *GetDecalByNum (WORD num) const;
+	const FDecalTemplate *GetDecalByNum (uint16_t num) const;
 	const FDecalTemplate *GetDecalByName (const char *name) const;
 
 private:
 	struct FTranslation;
 
 	static void DelTree (FDecalBase *root);
-	static FDecalBase *ScanTreeForNum (const WORD num, FDecalBase *root);
+	static FDecalBase *ScanTreeForNum (const uint16_t num, FDecalBase *root);
 	static FDecalBase *ScanTreeForName (const char *name, FDecalBase *root);
 	static void ReplaceDecalRef (FDecalBase *from, FDecalBase *to, FDecalBase *root);
-	FTranslation *GenerateTranslation (DWORD start, DWORD end);
-	void AddDecal (const char *name, WORD num, const FDecalTemplate &decal);
+	FTranslation *GenerateTranslation (uint32_t start, uint32_t end);
+	void AddDecal (const char *name, uint16_t num, const FDecalTemplate &decal);
 	void AddDecal (FDecalBase *decal);
 	FDecalAnimator *FindAnimator (const char *name);
 
-	WORD GetDecalID (FScanner &sc);
+	uint16_t GetDecalID (FScanner &sc);
 	void ParseDecal (FScanner &sc);
 	void ParseDecalGroup (FScanner &sc);
 	void ParseGenerator (FScanner &sc);
diff --git a/src/dobjgc.cpp b/src/dobjgc.cpp
index 4f0aa20db4..56e8c82d4d 100644
--- a/src/dobjgc.cpp
+++ b/src/dobjgc.cpp
@@ -150,7 +150,7 @@ DObject *Gray;
 DObject *Root;
 DObject *SoftRoots;
 DObject **SweepPos;
-DWORD CurrentWhite = OF_White0 | OF_Fixed;
+uint32_t CurrentWhite = OF_White0 | OF_Fixed;
 EGCState State = GCS_Pause;
 int Pause = DEFAULT_GCPAUSE;
 int StepMul = DEFAULT_GCMUL;
diff --git a/src/dobjtype.cpp b/src/dobjtype.cpp
index 8375742fcf..0812ac9d56 100644
--- a/src/dobjtype.cpp
+++ b/src/dobjtype.cpp
@@ -673,11 +673,11 @@ int PInt::GetValueInt(void *addr) const
 	}
 	else if (Size == 1)
 	{
-		return Unsigned ? *(uint8_t *)addr : *(SBYTE *)addr;
+		return Unsigned ? *(uint8_t *)addr : *(int8_t *)addr;
 	}
 	else if (Size == 2)
 	{
-		return Unsigned ? *(uint16_t *)addr : *(SWORD *)addr;
+		return Unsigned ? *(uint16_t *)addr : *(int16_t *)addr;
 	}
 	else if (Size == 8)
 	{ // truncated output
@@ -2372,7 +2372,7 @@ bool PStruct::ReadFields(FSerializer &ar, void *addr) const
 //
 //==========================================================================
 
-PField *PStruct::AddField(FName name, PType *type, DWORD flags)
+PField *PStruct::AddField(FName name, PType *type, uint32_t flags)
 {
 	PField *field = new PField(name, type, flags);
 
@@ -2405,7 +2405,7 @@ PField *PStruct::AddField(FName name, PType *type, DWORD flags)
 //
 //==========================================================================
 
-PField *PStruct::AddNativeField(FName name, PType *type, size_t address, DWORD flags, int bitvalue)
+PField *PStruct::AddNativeField(FName name, PType *type, size_t address, uint32_t flags, int bitvalue)
 {
 	PField *field = new PField(name, type, flags|VARF_Native|VARF_Transient, address, bitvalue);
 
@@ -2495,7 +2495,7 @@ PField::PField()
 }
 
 
-PField::PField(FName name, PType *type, DWORD flags, size_t offset, int bitvalue)
+PField::PField(FName name, PType *type, uint32_t flags, size_t offset, int bitvalue)
 	: PSymbol(name), Offset(offset), Type(type), Flags(flags)
 {
 	if (bitvalue != 0)
@@ -3330,7 +3330,7 @@ PClass *PClass::CreateDerivedClass(FName name, unsigned int size)
 //
 //==========================================================================
 
-PField *PClass::AddMetaField(FName name, PType *type, DWORD flags)
+PField *PClass::AddMetaField(FName name, PType *type, uint32_t flags)
 {
 	PField *field = new PField(name, type, flags);
 
@@ -3360,7 +3360,7 @@ PField *PClass::AddMetaField(FName name, PType *type, DWORD flags)
 //
 //==========================================================================
 
-PField *PClass::AddField(FName name, PType *type, DWORD flags)
+PField *PClass::AddField(FName name, PType *type, uint32_t flags)
 {
 	if (!(flags & VARF_Meta))
 	{
diff --git a/src/dobjtype.h b/src/dobjtype.h
index 16acfdcf93..6b24610f83 100644
--- a/src/dobjtype.h
+++ b/src/dobjtype.h
@@ -525,8 +525,8 @@ public:
 	VMFunction *mConstructor = nullptr;
 	VMFunction *mDestructor = nullptr;
 
-	virtual PField *AddField(FName name, PType *type, DWORD flags=0);
-	virtual PField *AddNativeField(FName name, PType *type, size_t address, DWORD flags = 0, int bitvalue = 0);
+	virtual PField *AddField(FName name, PType *type, uint32_t flags=0);
+	virtual PField *AddNativeField(FName name, PType *type, size_t address, uint32_t flags = 0, int bitvalue = 0);
 
 	void WriteValue(FSerializer &ar, const char *key,const void *addr) const override;
 	bool ReadValue(FSerializer &ar, const char *key,void *addr) const override;
@@ -581,7 +581,7 @@ protected:
 	void Derive(PClass *newclass, FName name);
 	void InitializeSpecials(void *addr, void *defaults, TArray<FTypeAndOffset> PClass::*Inits);
 	void SetSuper();
-	PField *AddMetaField(FName name, PType *type, DWORD flags);
+	PField *AddMetaField(FName name, PType *type, uint32_t flags);
 public:
 	void WriteValue(FSerializer &ar, const char *key,const void *addr) const override;
 	void WriteAllFields(FSerializer &ar, const void *addr) const;
@@ -617,7 +617,7 @@ public:
 	void InsertIntoHash();
 	DObject *CreateNew();
 	PClass *CreateDerivedClass(FName name, unsigned int size);
-	PField *AddField(FName name, PType *type, DWORD flags=0) override;
+	PField *AddField(FName name, PType *type, uint32_t flags=0) override;
 	void InitializeActorInfo();
 	void BuildFlatPointers();
 	void BuildArrayPointers();
diff --git a/src/doomdata.h b/src/doomdata.h
index 39df8d84d1..0ce01bf6a4 100644
--- a/src/doomdata.h
+++ b/src/doomdata.h
@@ -241,7 +241,7 @@ struct mapsubsector_t
 struct mapsubsector4_t
 {
 	uint16_t	numsegs;
-	DWORD	firstseg;	// index of first one, segs are stored sequentially
+	uint32_t	firstseg;	// index of first one, segs are stored sequentially
 };
 #pragma pack()
 
@@ -251,10 +251,10 @@ struct mapseg_t
 {
 	uint16_t	v1;
 	uint16_t	v2;
-	SWORD	angle;
+	int16_t	angle;
 	uint16_t	linedef;
-	SWORD	side;
-	SWORD	offset;
+	int16_t	side;
+	int16_t	offset;
 
 	int V1() { return LittleShort(v1); }
 	int V2() { return LittleShort(v2); }
@@ -264,10 +264,10 @@ struct mapseg4_t
 {
 	int32_t v1;
 	int32_t v2;
-	SWORD angle;
+	int16_t angle;
 	uint16_t linedef;
-	SWORD side;
-	SWORD offset;
+	int16_t side;
+	int16_t offset;
 
 	int V1() { return LittleLong(v1); }
 	int V2() { return LittleLong(v2); }
@@ -286,13 +286,13 @@ struct mapnode_t
 		NF_SUBSECTOR = 0x8000,
 		NF_LUMPOFFSET = 0
 	};
-	SWORD 	x,y,dx,dy;	// partition line
-	SWORD 	bbox[2][4];	// bounding box for each child
+	int16_t 	x,y,dx,dy;	// partition line
+	int16_t 	bbox[2][4];	// bounding box for each child
 	// If NF_SUBSECTOR is or'ed in, it's a subsector,
 	// else it's a node of another subtree.
 	uint16_t 	children[2];
 
-	DWORD Child(int num) { return LittleShort(children[num]); }
+	uint32_t Child(int num) { return LittleShort(children[num]); }
 };
 
 
@@ -303,13 +303,13 @@ struct mapnode4_t
 		NF_SUBSECTOR = 0x80000000,
 		NF_LUMPOFFSET = 8
 	};
-	SWORD 	x,y,dx,dy;	// partition line
-	SWORD 	bbox[2][4];	// bounding box for each child
+	int16_t 	x,y,dx,dy;	// partition line
+	int16_t 	bbox[2][4];	// bounding box for each child
 	// If NF_SUBSECTOR is or'ed in, it's a subsector,
 	// else it's a node of another subtree.
-	DWORD 	children[2];
+	uint32_t 	children[2];
 
-	DWORD Child(int num) { return LittleLong(children[num]); }
+	uint32_t Child(int num) { return LittleLong(children[num]); }
 };
 
 
@@ -318,22 +318,22 @@ struct mapnode4_t
 // plus skill/visibility flags and attributes.
 struct mapthing_t
 {
-	SWORD		x;
-	SWORD		y;
-	SWORD		angle;
-	SWORD		type;
-	SWORD		options;
+	int16_t		x;
+	int16_t		y;
+	int16_t		angle;
+	int16_t		type;
+	int16_t		options;
 };
 
 // [RH] Hexen-compatible MapThing.
 struct mapthinghexen_t
 {
-	SWORD 		thingid;
-	SWORD		x;
-	SWORD		y;
-	SWORD		z;
-	SWORD		angle;
-	SWORD		type;
+	int16_t 		thingid;
+	int16_t		x;
+	int16_t		y;
+	int16_t		z;
+	int16_t		angle;
+	int16_t		type;
 	uint16_t		flags;
 	uint8_t		special;
 	uint8_t		args[5];
@@ -351,19 +351,19 @@ struct FMapThing
 	uint16_t		ClassFilter;
 	int16_t		EdNum;
 	FDoomEdEntry *info;
-	DWORD		flags;
+	uint32_t		flags;
 	int			special;
 	int			args[5];
 	int			Conversation;
 	double		Gravity;
 	double		Alpha;
-	DWORD		fillcolor;
+	uint32_t		fillcolor;
 	DVector2	Scale;
 	double		Health;
 	int			score;
 	int16_t		pitch;
 	int16_t		roll;
-	DWORD		RenderStyle;
+	uint32_t		RenderStyle;
 	int			FloatbobPhase;
 };
 
diff --git a/src/doomdef.h b/src/doomdef.h
index a07985bb65..d78bef6a9f 100644
--- a/src/doomdef.h
+++ b/src/doomdef.h
@@ -377,9 +377,9 @@ enum
 #define BLINKTHRESHOLD (4*32)
 
 #ifndef __BIG_ENDIAN__
-#define MAKE_ID(a,b,c,d)	((DWORD)((a)|((b)<<8)|((c)<<16)|((d)<<24)))
+#define MAKE_ID(a,b,c,d)	((uint32_t)((a)|((b)<<8)|((c)<<16)|((d)<<24)))
 #else
-#define MAKE_ID(a,b,c,d)	((DWORD)((d)|((c)<<8)|((b)<<16)|((a)<<24)))
+#define MAKE_ID(a,b,c,d)	((uint32_t)((d)|((c)<<8)|((b)<<16)|((a)<<24)))
 #endif
 
 #endif	// __DOOMDEF_H__
diff --git a/src/edata.cpp b/src/edata.cpp
index 19583f7770..ee5f1fe840 100644
--- a/src/edata.cpp
+++ b/src/edata.cpp
@@ -95,8 +95,8 @@ struct EDMapthing
 	int type;
 	double height;
 	int args[5];
-	WORD skillfilter;
-	DWORD flags;
+	uint16_t skillfilter;
+	uint32_t flags;
 };
 
 struct EDLinedef
@@ -107,8 +107,8 @@ struct EDLinedef
 	int id;
 	int args[5];
 	double alpha;
-	DWORD flags;
-	DWORD activation;
+	uint32_t flags;
+	uint32_t activation;
 };
 
 
@@ -117,9 +117,9 @@ struct EDSector
 {
 	int recordnum;
 
-	DWORD flags;
-	DWORD flagsRemove;
-	DWORD flagsAdd;
+	uint32_t flags;
+	uint32_t flagsRemove;
+	uint32_t flagsAdd;
 
 	int damageamount;
 	int damageinterval;
@@ -130,11 +130,11 @@ struct EDSector
 	int floorterrain;
 	int ceilingterrain;
 
-	DWORD color;
+	uint32_t color;
 
-	DWORD damageflags;
-	DWORD damageflagsAdd;
-	DWORD damageflagsRemove;
+	uint32_t damageflags;
+	uint32_t damageflagsAdd;
+	uint32_t damageflagsRemove;
 
 	bool flagsSet;
 	bool damageflagsSet;
@@ -143,7 +143,7 @@ struct EDSector
 	// colormaptop//bottom cannot be used because ZDoom has no corresponding properties.
 	double xoffs[2], yoffs[2];
 	DAngle angle[2];
-	DWORD portalflags[2];
+	uint32_t portalflags[2];
 	double Overlayalpha[2];
 };
 
@@ -222,8 +222,8 @@ static void parseLinedef(FScanner &sc)
 		else if (sc.Compare("extflags"))
 		{
 			// these are needed to build the proper activation mask out of the possible flags which do not match ZDoom 1:1.
-			DWORD actmethod = 0;
-			DWORD acttype = 0;
+			uint32_t actmethod = 0;
+			uint32_t acttype = 0;
 			do
 			{
 				sc.CheckString("=");
@@ -291,7 +291,7 @@ static void parseSector(FScanner &sc)
 		}
 		else if (sc.Compare("flags"))
 		{
-			DWORD *flagvar = NULL;
+			uint32_t *flagvar = NULL;
 			if (sc.CheckString("."))
 			{
 				sc.MustGetString();
@@ -348,7 +348,7 @@ static void parseSector(FScanner &sc)
 		}
 		else if (sc.Compare("damageflags"))
 		{
-			DWORD *flagvar = NULL;
+			uint32_t *flagvar = NULL;
 			uint8_t *leakvar = NULL;
 			if (sc.CheckString("."))
 			{
@@ -449,7 +449,7 @@ static void parseSector(FScanner &sc)
 			sc.MustGetString();
 			// Eternity is based on SMMU and uses colormaps differently than all other ports.
 			// The only solution here is to convert the colormap to an RGB value and set it as the sector's color.
-			DWORD cmap = R_ColormapNumForName(sc.String);
+			uint32_t cmap = R_ColormapNumForName(sc.String);
 			if (cmap != 0)
 			{
 				sec.color = R_BlendForColormap(cmap) & 0xff000000;
@@ -700,7 +700,7 @@ void ProcessEDLinedef(line_t *ld, int recordnum)
 		ld->special = 0;
 		return;
 	}
-	const DWORD fmask = ML_REPEAT_SPECIAL | ML_FIRSTSIDEONLY | ML_ADDTRANS | ML_BLOCKEVERYTHING | ML_ZONEBOUNDARY | ML_CLIP_MIDTEX;
+	const uint32_t fmask = ML_REPEAT_SPECIAL | ML_FIRSTSIDEONLY | ML_ADDTRANS | ML_BLOCKEVERYTHING | ML_ZONEBOUNDARY | ML_CLIP_MIDTEX;
 	ld->special = eld->special;
 	ld->activation = eld->activation;
 	ld->flags = (ld->flags&~fmask) | eld->flags;
@@ -719,7 +719,7 @@ void ProcessEDSector(sector_t *sec, int recordnum)
 	}
 
 	// In ZDoom the regular and the damage flags are part of the same flag word so we need to do some masking.
-	const DWORD flagmask = SECF_SECRET | SECF_WASSECRET | SECF_FRICTION | SECF_PUSH | SECF_SILENT | SECF_SILENTMOVE;
+	const uint32_t flagmask = SECF_SECRET | SECF_WASSECRET | SECF_FRICTION | SECF_PUSH | SECF_SILENT | SECF_SILENTMOVE;
 	if (esec->flagsSet) sec->Flags = (sec->Flags & ~flagmask);
 	sec->Flags = (sec->Flags | esec->flags | esec->flagsAdd) & ~esec->flagsRemove;
 
@@ -740,7 +740,7 @@ void ProcessEDSector(sector_t *sec, int recordnum)
 
 	if (esec->colorSet) sec->SetColor(RPART(esec->color), GPART(esec->color), BPART(esec->color), 0);
 
-	const DWORD pflagmask = PLANEF_DISABLED | PLANEF_NORENDER | PLANEF_NOPASS | PLANEF_BLOCKSOUND | PLANEF_ADDITIVE;
+	const uint32_t pflagmask = PLANEF_DISABLED | PLANEF_NORENDER | PLANEF_NOPASS | PLANEF_BLOCKSOUND | PLANEF_ADDITIVE;
 	for (int i = 0; i < 2; i++)
 	{
 		sec->SetXOffset(i, esec->xoffs[i]);
diff --git a/src/files.h b/src/files.h
index 05afe9b459..e8099ada80 100644
--- a/src/files.h
+++ b/src/files.h
@@ -19,27 +19,27 @@ public:
 		return *this;
 	}
 
-	FileReaderBase &operator>> (SBYTE &v)
+	FileReaderBase &operator>> (int8_t &v)
 	{
 		Read (&v, 1);
 		return *this;
 	}
 
-	FileReaderBase &operator>> (WORD &v)
+	FileReaderBase &operator>> (uint16_t &v)
 	{
 		Read (&v, 2);
 		v = LittleShort(v);
 		return *this;
 	}
 
-	FileReaderBase &operator>> (SWORD &v)
+	FileReaderBase &operator>> (int16_t &v)
 	{
 		Read (&v, 2);
 		v = LittleShort(v);
 		return *this;
 	}
 
-	FileReaderBase &operator>> (DWORD &v)
+	FileReaderBase &operator>> (uint32_t &v)
 	{
 		Read (&v, 4);
 		v = LittleLong(v);
@@ -85,27 +85,27 @@ public:
 		return *this;
 	}
 
-	FileReader &operator>> (SBYTE &v)
+	FileReader &operator>> (int8_t &v)
 	{
 		Read (&v, 1);
 		return *this;
 	}
 
-	FileReader &operator>> (WORD &v)
+	FileReader &operator>> (uint16_t &v)
 	{
 		Read (&v, 2);
 		v = LittleShort(v);
 		return *this;
 	}
 
-	FileReader &operator>> (SWORD &v)
+	FileReader &operator>> (int16_t &v)
 	{
 		Read (&v, 2);
 		v = LittleShort(v);
 		return *this;
 	}
 
-	FileReader &operator>> (DWORD &v)
+	FileReader &operator>> (uint32_t &v)
 	{
 		Read (&v, 4);
 		v = LittleLong(v);
@@ -144,27 +144,27 @@ public:
 		return *this;
 	}
 
-	FileReaderZ &operator>> (SBYTE &v)
+	FileReaderZ &operator>> (int8_t &v)
 	{
 		Read (&v, 1);
 		return *this;
 	}
 
-	FileReaderZ &operator>> (WORD &v)
+	FileReaderZ &operator>> (uint16_t &v)
 	{
 		Read (&v, 2);
 		v = LittleShort(v);
 		return *this;
 	}
 
-	FileReaderZ &operator>> (SWORD &v)
+	FileReaderZ &operator>> (int16_t &v)
 	{
 		Read (&v, 2);
 		v = LittleShort(v);
 		return *this;
 	}
 
-	FileReaderZ &operator>> (DWORD &v)
+	FileReaderZ &operator>> (uint32_t &v)
 	{
 		Read (&v, 4);
 		v = LittleLong(v);
@@ -206,27 +206,27 @@ public:
 		return *this;
 	}
 
-	FileReaderBZ2 &operator>> (SBYTE &v)
+	FileReaderBZ2 &operator>> (int8_t &v)
 	{
 		Read (&v, 1);
 		return *this;
 	}
 
-	FileReaderBZ2 &operator>> (WORD &v)
+	FileReaderBZ2 &operator>> (uint16_t &v)
 	{
 		Read (&v, 2);
 		v = LittleShort(v);
 		return *this;
 	}
 
-	FileReaderBZ2 &operator>> (SWORD &v)
+	FileReaderBZ2 &operator>> (int16_t &v)
 	{
 		Read (&v, 2);
 		v = LittleShort(v);
 		return *this;
 	}
 
-	FileReaderBZ2 &operator>> (DWORD &v)
+	FileReaderBZ2 &operator>> (uint32_t &v)
 	{
 		Read (&v, 4);
 		v = LittleLong(v);
@@ -270,27 +270,27 @@ public:
 		return *this;
 	}
 
-	FileReaderLZMA &operator>> (SBYTE &v)
+	FileReaderLZMA &operator>> (int8_t &v)
 	{
 		Read (&v, 1);
 		return *this;
 	}
 
-	FileReaderLZMA &operator>> (WORD &v)
+	FileReaderLZMA &operator>> (uint16_t &v)
 	{
 		Read (&v, 2);
 		v = LittleShort(v);
 		return *this;
 	}
 
-	FileReaderLZMA &operator>> (SWORD &v)
+	FileReaderLZMA &operator>> (int16_t &v)
 	{
 		Read (&v, 2);
 		v = LittleShort(v);
 		return *this;
 	}
 
-	FileReaderLZMA &operator>> (DWORD &v)
+	FileReaderLZMA &operator>> (uint32_t &v)
 	{
 		Read (&v, 4);
 		v = LittleLong(v);
diff --git a/src/gl/system/gl_framebuffer.cpp b/src/gl/system/gl_framebuffer.cpp
index 864d796a81..19c062b095 100644
--- a/src/gl/system/gl_framebuffer.cpp
+++ b/src/gl/system/gl_framebuffer.cpp
@@ -265,7 +265,7 @@ void OpenGLFrameBuffer::DoSetGamma()
 	bool useHWGamma = m_supportsGamma && ((vid_hwgamma == 0) || (vid_hwgamma == 2 && IsFullscreen()));
 	if (useHWGamma)
 	{
-		WORD gammaTable[768];
+		uint16_t gammaTable[768];
 
 		// This formula is taken from Doomsday
 		float gamma = clamp<float>(Gamma, 0.1f, 4.f);
@@ -281,7 +281,7 @@ void OpenGLFrameBuffer::DoSetGamma()
 			val += bright * 128;
 			if(gamma != 1) val = pow(val, invgamma) / norm;
 
-			gammaTable[i] = gammaTable[i + 256] = gammaTable[i + 512] = (WORD)clamp<double>(val*256, 0, 0xffff);
+			gammaTable[i] = gammaTable[i + 256] = gammaTable[i + 512] = (uint16_t)clamp<double>(val*256, 0, 0xffff);
 		}
 		SetGammaTable(gammaTable);
 
diff --git a/src/i_net.cpp b/src/i_net.cpp
index a1ec6017cd..cc357e2c94 100644
--- a/src/i_net.cpp
+++ b/src/i_net.cpp
@@ -135,8 +135,8 @@ struct PreGamePacket
 	};
 	struct
 	{
-		DWORD	address;
-		WORD	port;
+		uint32_t address;
+		uint16_t port;
 		uint8_t	player;
 		uint8_t	pad;
 	} machines[MAXNETNODES];
diff --git a/src/oplsynth/dosbox/opl.cpp b/src/oplsynth/dosbox/opl.cpp
index f7c81ee4af..8f2fdd8592 100644
--- a/src/oplsynth/dosbox/opl.cpp
+++ b/src/oplsynth/dosbox/opl.cpp
@@ -36,8 +36,8 @@ typedef uintptr_t	Bitu;
 typedef intptr_t	Bits;
 typedef DWORD		Bit32u;
 typedef int32_t		Bit32s;
-typedef WORD		Bit16u;
-typedef SWORD		Bit16s;
+typedef uint16_t	Bit16u;
+typedef int16_t		Bit16s;
 typedef uint8_t		Bit8u;
 typedef SBYTE		Bit8s;
 
diff --git a/src/oplsynth/mlopl_io.cpp b/src/oplsynth/mlopl_io.cpp
index cd4b3dd559..ef89bfc271 100644
--- a/src/oplsynth/mlopl_io.cpp
+++ b/src/oplsynth/mlopl_io.cpp
@@ -102,7 +102,7 @@ void OPLio::OPLwriteValue(uint32_t regbase, uint32_t channel, uint8_t value)
 	OPLwriteReg (which, reg, value);
 }
 
-static WORD frequencies[] =
+static uint16_t frequencies[] =
 {
 	0x133, 0x133, 0x134, 0x134, 0x135, 0x136, 0x136, 0x137, 0x137, 0x138, 0x138, 0x139,
 	0x139, 0x13a, 0x13b, 0x13b, 0x13c, 0x13c, 0x13d, 0x13d, 0x13e, 0x13f, 0x13f, 0x140,
diff --git a/src/oplsynth/music_opldumper_mididevice.cpp b/src/oplsynth/music_opldumper_mididevice.cpp
index 6ea7ee63bf..9e9110285b 100644
--- a/src/oplsynth/music_opldumper_mididevice.cpp
+++ b/src/oplsynth/music_opldumper_mididevice.cpp
@@ -101,7 +101,7 @@ public:
 	{
 		if (File != NULL)
 		{
-			WORD endmark = 0xFFFF;
+			uint16_t endmark = 0xFFFF;
 			fwrite(&endmark, 2, 1, File);
 			fclose(File);
 		}
@@ -130,7 +130,7 @@ public:
 
 		double clock_rate;
 		int clock_mul;
-		WORD clock_word;
+		uint16_t clock_word;
 
 		clock_rate = samples_per_tick * ADLIB_CLOCK_MUL;
 		clock_mul = 1;
@@ -141,7 +141,7 @@ public:
 		{
 			clock_mul++;
 		}
-		clock_word = WORD(clock_rate / clock_mul + 0.5);
+		clock_word = uint16_t(clock_rate / clock_mul + 0.5);
 
 		if (NeedClockRate)
 		{ // Set the initial clock rate.
diff --git a/src/oplsynth/muslib.h b/src/oplsynth/muslib.h
index eb4682b32a..9d5bdfcbdc 100644
--- a/src/oplsynth/muslib.h
+++ b/src/oplsynth/muslib.h
@@ -107,7 +107,7 @@ struct OPL2instrument {
 
 /* OP2 instrument file entry */
 struct OP2instrEntry {
-/*00*/	WORD	flags;				// see FL_xxx below
+/*00*/	uint16_t flags;				// see FL_xxx below
 /*02*/	uint8_t	finetune;			// finetune value for 2-voice sounds
 /*03*/	uint8_t	note;				// note # for fixed instruments
 /*04*/	struct OPL2instrument instr[2];	// instruments
diff --git a/src/oplsynth/nukedopl3.h b/src/oplsynth/nukedopl3.h
index 9421814ac0..b5abf3b38b 100644
--- a/src/oplsynth/nukedopl3.h
+++ b/src/oplsynth/nukedopl3.h
@@ -36,8 +36,8 @@ typedef uintptr_t	Bitu;
 typedef intptr_t	Bits;
 typedef DWORD		Bit32u;
 typedef int32_t		Bit32s;
-typedef WORD		Bit16u;
-typedef SWORD		Bit16s;
+typedef uint16_t	Bit16u;
+typedef int16_t		Bit16s;
 typedef uint8_t		Bit8u;
 typedef SBYTE		Bit8s;
 
diff --git a/src/oplsynth/opl_mus_player.cpp b/src/oplsynth/opl_mus_player.cpp
index da28d9ce54..5c8d2d2a5b 100644
--- a/src/oplsynth/opl_mus_player.cpp
+++ b/src/oplsynth/opl_mus_player.cpp
@@ -79,17 +79,17 @@ fail:	delete[] scoredata;
 			 ((DWORD *)scoredata)[1] == MAKE_ID('D','A','T','A'))
 	{
 		RawPlayer = RDosPlay;
-		if (*(WORD *)(scoredata + 8) == 0)
+		if (*(uint16_t *)(scoredata + 8) == 0)
 		{ // A clock speed of 0 is bad
-			*(WORD *)(scoredata + 8) = 0xFFFF; 
+			*(uint16_t *)(scoredata + 8) = 0xFFFF; 
 		}
-		SamplesPerTick = LittleShort(*(WORD *)(scoredata + 8)) / ADLIB_CLOCK_MUL;
+		SamplesPerTick = LittleShort(*(uint16_t *)(scoredata + 8)) / ADLIB_CLOCK_MUL;
 	}
 	// Check for DosBox OPL dump
 	else if (((DWORD *)scoredata)[0] == MAKE_ID('D','B','R','A') &&
 		((DWORD *)scoredata)[1] == MAKE_ID('W','O','P','L'))
 	{
-		if (LittleShort(((WORD *)scoredata)[5]) == 1)
+		if (LittleShort(((uint16_t *)scoredata)[5]) == 1)
 		{
 			RawPlayer = DosBox1;
 			SamplesPerTick = OPL_SAMPLE_RATE / 1000;
@@ -117,7 +117,7 @@ fail:	delete[] scoredata;
 		}
 		else
 		{
-			Printf("Unsupported DOSBox Raw OPL version %d.%d\n", LittleShort(((WORD *)scoredata)[4]), LittleShort(((WORD *)scoredata)[5]));
+			Printf("Unsupported DOSBox Raw OPL version %d.%d\n", LittleShort(((uint16_t *)scoredata)[4]), LittleShort(((uint16_t *)scoredata)[5]));
 			goto fail;
 		}
 	}
@@ -185,7 +185,7 @@ void OPLmusicFile::Restart ()
 	{
 	case RDosPlay:
 		score = scoredata + 10;
-		SamplesPerTick = LittleShort(*(WORD *)(scoredata + 8)) / ADLIB_CLOCK_MUL;
+		SamplesPerTick = LittleShort(*(uint16_t *)(scoredata + 8)) / ADLIB_CLOCK_MUL;
 		break;
 
 	case DosBox1:
@@ -364,7 +364,7 @@ void OPLmusicBlock::OffsetSamples(float *buff, int count)
 int OPLmusicFile::PlayTick ()
 {
 	uint8_t reg, data;
-	WORD delay;
+	uint16_t delay;
 
 	switch (RawPlayer)
 	{
@@ -385,7 +385,7 @@ int OPLmusicFile::PlayTick ()
 			case 2:		// Speed change or OPL3 switch
 				if (data == 0)
 				{
-					SamplesPerTick = LittleShort(*(WORD *)(score)) / ADLIB_CLOCK_MUL;
+					SamplesPerTick = LittleShort(*(uint16_t *)(score)) / ADLIB_CLOCK_MUL;
 					io->SetClockRate(SamplesPerTick);
 					score += 2;
 				}
@@ -493,7 +493,7 @@ int OPLmusicFile::PlayTick ()
 			}
 			reg = score[0];
 			data = score[1];
-			delay = LittleShort(((WORD *)score)[1]);
+			delay = LittleShort(((uint16_t *)score)[1]);
 			score += 4;
 			io->OPLwriteReg (0, reg, data);
 		}
diff --git a/src/posix/cocoa/i_input.mm b/src/posix/cocoa/i_input.mm
index cb39c049a8..53afa85362 100644
--- a/src/posix/cocoa/i_input.mm
+++ b/src/posix/cocoa/i_input.mm
@@ -317,7 +317,7 @@ uint8_t ModifierToDIK(const uint32_t modifier)
 	return 0;
 }
 
-SWORD ModifierFlagsToGUIKeyModifiers(NSEvent* theEvent)
+int16_t ModifierFlagsToGUIKeyModifiers(NSEvent* theEvent)
 {
 	const NSUInteger modifiers([theEvent modifierFlags] & NSDeviceIndependentModifierFlagsMask);
 	return ((modifiers & NSShiftKeyMask    ) ? GKM_SHIFT : 0)
@@ -690,7 +690,7 @@ void ProcessMouseButtonEvent(NSEvent* theEvent)
 
 void ProcessMouseWheelEvent(NSEvent* theEvent)
 {
-	const SWORD modifiers = ModifierFlagsToGUIKeyModifiers(theEvent);
+	const int16_t modifiers = ModifierFlagsToGUIKeyModifiers(theEvent);
 	const CGFloat delta   = (modifiers & GKM_SHIFT)
 		? [theEvent deltaX]
 		: [theEvent deltaY];
diff --git a/src/posix/cocoa/i_video.mm b/src/posix/cocoa/i_video.mm
index 3017d0c9b1..7c6f71db7c 100644
--- a/src/posix/cocoa/i_video.mm
+++ b/src/posix/cocoa/i_video.mm
@@ -1138,7 +1138,7 @@ SDLGLFB::SDLGLFB(void*, const int width, const int height, int, int, const bool
 	{
 		for (uint32_t i = 0; i < GAMMA_TABLE_SIZE; ++i)
 		{
-			m_originalGamma[i] = static_cast<WORD>(gammaTable[i] * 65535.0f);
+			m_originalGamma[i] = static_cast<uint16_t>(gammaTable[i] * 65535.0f);
 		}
 	}
 }
@@ -1222,7 +1222,7 @@ void SDLGLFB::SwapBuffers()
 	[[NSOpenGLContext currentContext] flushBuffer];
 }
 
-void SDLGLFB::SetGammaTable(WORD* table)
+void SDLGLFB::SetGammaTable(uint16_t* table)
 {
 	if (m_supportsGamma)
 	{
diff --git a/src/posix/cocoa/sdlglvideo.h b/src/posix/cocoa/sdlglvideo.h
index fcbf23f2ad..180598692b 100644
--- a/src/posix/cocoa/sdlglvideo.h
+++ b/src/posix/cocoa/sdlglvideo.h
@@ -74,7 +74,7 @@ protected:
 	static const uint32_t GAMMA_TABLE_SIZE = GAMMA_CHANNEL_SIZE * GAMMA_CHANNEL_COUNT;
 
 	bool				m_supportsGamma;
-	WORD				m_originalGamma[GAMMA_TABLE_SIZE];
+	uint16_t			m_originalGamma[GAMMA_TABLE_SIZE];
 
 	SDLGLFB();
 
@@ -83,7 +83,7 @@ protected:
 	bool CanUpdate();
 	void SwapBuffers();
 
-	void SetGammaTable(WORD* table);
+	void SetGammaTable(uint16_t* table);
 	void ResetGammaTable();
 };
 
diff --git a/src/posix/sdl/sdlglvideo.cpp b/src/posix/sdl/sdlglvideo.cpp
index d88c2bc6ad..2cd07b2247 100644
--- a/src/posix/sdl/sdlglvideo.cpp
+++ b/src/posix/sdl/sdlglvideo.cpp
@@ -33,7 +33,7 @@ IMPLEMENT_CLASS(SDLGLFB, true, false)
 
 struct MiniModeInfo
 {
-	WORD Width, Height;
+	uint16_t Width, Height;
 };
 
 // PUBLIC FUNCTION PROTOTYPES ----------------------------------------------
@@ -377,7 +377,7 @@ bool SDLGLFB::CanUpdate ()
 	return true;
 }
 
-void SDLGLFB::SetGammaTable(WORD *tbl)
+void SDLGLFB::SetGammaTable(uint16_t *tbl)
 {
 	if (m_supportsGamma)
 	{
diff --git a/src/posix/sdl/sdlglvideo.h b/src/posix/sdl/sdlglvideo.h
index d8ce9005dc..d157a0c311 100644
--- a/src/posix/sdl/sdlglvideo.h
+++ b/src/posix/sdl/sdlglvideo.h
@@ -63,7 +63,7 @@ public:
 
 protected:
 	bool CanUpdate();
-	void SetGammaTable(WORD *tbl);
+	void SetGammaTable(uint16_t *tbl);
 	void ResetGammaTable();
 	void InitializeState();
 
diff --git a/src/posix/sdl/sdlvideo.cpp b/src/posix/sdl/sdlvideo.cpp
index 3404e415e7..5902fc03b8 100644
--- a/src/posix/sdl/sdlvideo.cpp
+++ b/src/posix/sdl/sdlvideo.cpp
@@ -83,7 +83,7 @@ IMPLEMENT_CLASS(SDLFB, false, false)
 
 struct MiniModeInfo
 {
-	WORD Width, Height;
+	uint16_t Width, Height;
 };
 
 // PUBLIC FUNCTION PROTOTYPES ----------------------------------------------
@@ -743,7 +743,7 @@ void SDLFB::SetVSync (bool vsync)
 #endif // __APPLE__
 }
 
-void SDLFB::ScaleCoordsFromWindow(SWORD &x, SWORD &y)
+void SDLFB::ScaleCoordsFromWindow(int16_t &x, int16_t &y)
 {
 	int w, h;
 	SDL_GetWindowSize (Screen, &w, &h);
@@ -773,8 +773,8 @@ void SDLFB::ScaleCoordsFromWindow(SWORD &x, SWORD &y)
 	}
 	else
 	{
-		x = (SWORD)(x*Width/w);
-		y = (SWORD)(y*Height/h);
+		x = (int16_t)(x*Width/w);
+		y = (int16_t)(y*Height/h);
 	}
 }
 
diff --git a/src/r_data/sprites.cpp b/src/r_data/sprites.cpp
index 1d7e051086..d4c0465125 100644
--- a/src/r_data/sprites.cpp
+++ b/src/r_data/sprites.cpp
@@ -211,7 +211,7 @@ static void R_InstallSprite (int num, spriteframewithrotate *sprtemp, int &maxfr
 	
 	// allocate space for the frames present and copy sprtemp to it
 	sprites[num].numframes = maxframe;
-	sprites[num].spriteframes = WORD(framestart = SpriteFrames.Reserve (maxframe));
+	sprites[num].spriteframes = uint16_t(framestart = SpriteFrames.Reserve (maxframe));
 	for (frame = 0; frame < maxframe; ++frame)
 	{
 		memcpy (SpriteFrames[framestart+frame].Texture, sprtemp[frame].Texture, sizeof(sprtemp[frame].Texture));
@@ -428,7 +428,7 @@ static void R_ExtendSpriteFrames(spritedef_t &spr, int frame)
 		newstart = SpriteFrames.Reserve(frame - spr.numframes);
 		if (spr.numframes == 0)
 		{
-			spr.spriteframes = WORD(newstart);
+			spr.spriteframes = uint16_t(newstart);
 		}
 	}
 	else
@@ -440,7 +440,7 @@ static void R_ExtendSpriteFrames(spritedef_t &spr, int frame)
 		{
 			SpriteFrames[newstart + i] = SpriteFrames[spr.spriteframes + i];
 		}
-		spr.spriteframes = WORD(newstart);
+		spr.spriteframes = uint16_t(newstart);
 		newstart += i;
 	}
 	// Initialize all new frames to 0.
diff --git a/src/r_data/sprites.h b/src/r_data/sprites.h
index beeff22f42..d40be370fb 100644
--- a/src/r_data/sprites.h
+++ b/src/r_data/sprites.h
@@ -19,7 +19,7 @@ struct spriteframe_t
 {
 	struct FVoxelDef *Voxel;// voxel to use for this frame
 	FTextureID Texture[16];	// texture to use for view angles 0-15
-	WORD Flip;				// flip (1 = flip) to use for view angles 0-15.
+	uint16_t Flip;		// flip (1 = flip) to use for view angles 0-15.
 };
 
 //
@@ -32,10 +32,10 @@ struct spritedef_t
 	union
 	{
 		char name[5];
-		DWORD dwName;
+		uint32_t dwName;
 	};
 	uint8_t numframes;
-	WORD spriteframes;
+	uint16_t spriteframes;
 };
 
 extern TArray<spriteframe_t> SpriteFrames;
diff --git a/src/sound/i_music.cpp b/src/sound/i_music.cpp
index a896aeee73..69a27a55c0 100644
--- a/src/sound/i_music.cpp
+++ b/src/sound/i_music.cpp
@@ -602,7 +602,7 @@ static bool ungzip(BYTE *data, int complen, TArray<BYTE> &newdata)
 	// Find start of compressed data stream
 	if (flags & GZIP_FEXTRA)
 	{
-		compstart += 2 + LittleShort(*(WORD *)(data + 10));
+		compstart += 2 + LittleShort(*(uint16_t *)(data + 10));
 	}
 	if (flags & GZIP_FNAME)
 	{
diff --git a/src/sound/i_musicinterns.h b/src/sound/i_musicinterns.h
index d073625b44..c6bf2c98ce 100644
--- a/src/sound/i_musicinterns.h
+++ b/src/sound/i_musicinterns.h
@@ -100,7 +100,7 @@ public:
 	virtual bool FakeVolume();
 	virtual bool Pause(bool paused) = 0;
 	virtual bool NeedThreadedCallback();
-	virtual void PrecacheInstruments(const WORD *instruments, int count);
+	virtual void PrecacheInstruments(const uint16_t *instruments, int count);
 	virtual void TimidityVolumeChanged();
 	virtual void FluidSettingInt(const char *setting, int value);
 	virtual void FluidSettingNum(const char *setting, double value);
@@ -133,7 +133,7 @@ public:
 	bool FakeVolume();
 	bool NeedThreadedCallback();
 	bool Pause(bool paused);
-	void PrecacheInstruments(const WORD *instruments, int count);
+	void PrecacheInstruments(const uint16_t *instruments, int count);
 
 protected:
 	static void CALLBACK CallbackFunc(HMIDIOUT, UINT, DWORD_PTR, DWORD, DWORD);
@@ -348,7 +348,7 @@ public:
 	~TimidityMIDIDevice();
 
 	int Open(void (*callback)(unsigned int, void *, DWORD, DWORD), void *userdata);
-	void PrecacheInstruments(const WORD *instruments, int count);
+	void PrecacheInstruments(const uint16_t *instruments, int count);
 	FString GetStats();
 
 protected:
@@ -382,7 +382,7 @@ public:
 	~WildMIDIDevice();
 
 	int Open(void (*callback)(unsigned int, void *, DWORD, DWORD), void *userdata);
-	void PrecacheInstruments(const WORD *instruments, int count);
+	void PrecacheInstruments(const uint16_t *instruments, int count);
 	FString GetStats();
 
 protected:
@@ -618,7 +618,7 @@ protected:
 	TrackInfo *TrackDue;
 	int NumTracks;
 	int Format;
-	WORD DesignationMask;
+	uint16_t DesignationMask;
 };
 
 // HMI file played with a MIDI stream ---------------------------------------
diff --git a/src/sound/i_soundinternal.h b/src/sound/i_soundinternal.h
index c86c6cdaae..786ff5dca5 100644
--- a/src/sound/i_soundinternal.h
+++ b/src/sound/i_soundinternal.h
@@ -60,7 +60,7 @@ struct ReverbContainer
 {
 	ReverbContainer *Next;
 	const char *Name;
-	WORD ID;
+	uint16_t ID;
 	bool Builtin;
 	bool Modified;
 	REVERB_PROPERTIES Properties;
diff --git a/src/sound/music_cd.cpp b/src/sound/music_cd.cpp
index 4aaf46e528..17b050f8b4 100644
--- a/src/sound/music_cd.cpp
+++ b/src/sound/music_cd.cpp
@@ -82,9 +82,9 @@ bool CDSong::IsPlaying ()
 CDDAFile::CDDAFile (FileReader &reader)
 	: CDSong ()
 {
-	DWORD chunk;
-	WORD track;
-	DWORD discid;
+	uint32_t chunk;
+	uint16_t track;
+	uint32_t discid;
 	long endpos = reader.Tell() + reader.GetLength() - 8;
 
 	// I_RegisterSong already identified this as a CDDA file, so we
diff --git a/src/sound/music_hmi_midiout.cpp b/src/sound/music_hmi_midiout.cpp
index 6919707653..5197cd3082 100644
--- a/src/sound/music_hmi_midiout.cpp
+++ b/src/sound/music_hmi_midiout.cpp
@@ -94,7 +94,7 @@ struct HMISong::TrackInfo
 	size_t MaxTrackP;
 	DWORD Delay;
 	DWORD PlayedTime;
-	WORD Designation[NUM_HMI_DESIGNATIONS];
+	uint16_t Designation[NUM_HMI_DESIGNATIONS];
 	bool Enabled;
 	bool Finished;
 	BYTE RunningStatus;
diff --git a/src/sound/music_midi_base.cpp b/src/sound/music_midi_base.cpp
index 8c44a2ac43..3ad8fafc20 100644
--- a/src/sound/music_midi_base.cpp
+++ b/src/sound/music_midi_base.cpp
@@ -130,7 +130,7 @@ void I_BuildMIDIMenuList (FOptionValues *opt)
 	}
 }
 
-static void PrintMidiDevice (int id, const char *name, WORD tech, DWORD support)
+static void PrintMidiDevice (int id, const char *name, uint16_t tech, DWORD support)
 {
 	if (id == snd_mididevice)
 	{
diff --git a/src/sound/music_midistream.cpp b/src/sound/music_midistream.cpp
index 6906aa4c57..0f7501f791 100644
--- a/src/sound/music_midistream.cpp
+++ b/src/sound/music_midistream.cpp
@@ -1131,13 +1131,13 @@ void MIDIStreamer::Precache()
 	DoRestart();
 
 	// Now pack everything into a contiguous region for the PrecacheInstruments call().
-	TArray<WORD> packed;
+	TArray<uint16_t> packed;
 
 	for (int i = 0; i < 256; ++i)
 	{
 		if (found_instruments[i])
 		{
-			WORD packnum = (i & 127) | ((i & 128) << 7);
+			uint16_t packnum = (i & 127) | ((i & 128) << 7);
 			if (!multiple_banks)
 			{
 				packed.Push(packnum);
@@ -1429,7 +1429,7 @@ MIDIDevice::~MIDIDevice()
 //
 //==========================================================================
 
-void MIDIDevice::PrecacheInstruments(const WORD *instruments, int count)
+void MIDIDevice::PrecacheInstruments(const uint16_t *instruments, int count)
 {
 }
 
diff --git a/src/sound/music_mus_midiout.cpp b/src/sound/music_mus_midiout.cpp
index 58b86201a4..420c1dfcdc 100644
--- a/src/sound/music_mus_midiout.cpp
+++ b/src/sound/music_mus_midiout.cpp
@@ -211,14 +211,14 @@ bool MUSSong2::CheckDone()
 
 void MUSSong2::Precache()
 {
-	TArray<WORD> work(LittleShort(MusHeader->NumInstruments));
+	TArray<uint16_t> work(LittleShort(MusHeader->NumInstruments));
 	const BYTE *used = (BYTE *)MusHeader + sizeof(MUSHeader) / sizeof(BYTE);
 	int i, k;
 
 	for (i = k = 0; i < LittleShort(MusHeader->NumInstruments); ++i)
 	{
 		BYTE instr = used[k++];
-		WORD val;
+		uint16_t val;
 		if (instr < 128)
 		{
 			val = instr;
diff --git a/src/sound/music_smf_midiout.cpp b/src/sound/music_smf_midiout.cpp
index ae0c47e808..623cef53ed 100644
--- a/src/sound/music_smf_midiout.cpp
+++ b/src/sound/music_smf_midiout.cpp
@@ -67,7 +67,7 @@ struct MIDISong2::TrackInfo
 	bool Designated;
 	bool EProgramChange;
 	bool EVolume;
-	WORD Designation;
+	uint16_t Designation;
 
 	size_t LoopBegin;
 	DWORD LoopDelay;
diff --git a/src/sound/music_wildmidi_mididevice.cpp b/src/sound/music_wildmidi_mididevice.cpp
index 03ededb460..c664dc6235 100644
--- a/src/sound/music_wildmidi_mididevice.cpp
+++ b/src/sound/music_wildmidi_mididevice.cpp
@@ -167,7 +167,7 @@ int WildMIDIDevice::Open(void (*callback)(unsigned int, void *, DWORD, DWORD), v
 //
 //==========================================================================
 
-void WildMIDIDevice::PrecacheInstruments(const WORD *instruments, int count)
+void WildMIDIDevice::PrecacheInstruments(const uint16_t *instruments, int count)
 {
 	for (int i = 0; i < count; ++i)
 	{
diff --git a/src/sound/music_win_mididevice.cpp b/src/sound/music_win_mididevice.cpp
index ed00b0c878..b025d70f06 100644
--- a/src/sound/music_win_mididevice.cpp
+++ b/src/sound/music_win_mididevice.cpp
@@ -239,7 +239,7 @@ void WinMIDIDevice::Stop()
 //
 //==========================================================================
 
-void WinMIDIDevice::PrecacheInstruments(const WORD *instruments, int count)
+void WinMIDIDevice::PrecacheInstruments(const uint16_t *instruments, int count)
 {
 	// Setting snd_midiprecache to false disables this precaching, since it
 	// does involve sleeping for more than a miniscule amount of time.
diff --git a/src/sound/oalsound.h b/src/sound/oalsound.h
index 951ae0fdca..3e110bde04 100644
--- a/src/sound/oalsound.h
+++ b/src/sound/oalsound.h
@@ -221,8 +221,8 @@ private:
 
 	const ReverbContainer *PrevEnvironment;
 
-    typedef TMap<WORD,ALuint> EffectMap;
-    typedef TMapIterator<WORD,ALuint> EffectMapIter;
+    typedef TMap<uint16_t,ALuint> EffectMap;
+    typedef TMapIterator<uint16_t,ALuint> EffectMapIter;
     ALuint EnvSlot;
     ALuint EnvFilters[2];
     EffectMap EnvEffects;
diff --git a/src/timidity/gf1patch.h b/src/timidity/gf1patch.h
index f652e1304f..b030bb6e09 100644
--- a/src/timidity/gf1patch.h
+++ b/src/timidity/gf1patch.h
@@ -29,15 +29,15 @@ struct GF1PatchHeader
 	BYTE Instruments;
 	BYTE Voices;
 	BYTE Channels;
-	WORD WaveForms;
-	WORD MasterVolume;
+	uint16_t WaveForms;
+	uint16_t MasterVolume;
 	DWORD DataSize;
 	BYTE Reserved[PATCH_HEADER_RESERVED_SIZE];
 } GCC_PACKED;
 
 struct GF1InstrumentData
 {
-	WORD Instrument;
+	uint16_t Instrument;
 	char InstrumentName[INST_NAME_SIZE];
 	int  InstrumentSize;
 	BYTE Layers;
@@ -60,11 +60,11 @@ struct GF1PatchData
 	int   WaveSize;
 	int   StartLoop;
 	int   EndLoop;
-	WORD  SampleRate;
+	uint16_t  SampleRate;
 	int   LowFrequency;
 	int   HighFrequency;
 	int   RootFrequency;
-	SWORD Tune;
+	int16_t Tune;
 	BYTE  Balance;
 	BYTE  EnvelopeRate[ENVELOPES];
 	BYTE  EnvelopeOffset[ENVELOPES];
@@ -75,8 +75,8 @@ struct GF1PatchData
 	BYTE  VibratoRate;
 	BYTE  VibratoDepth;
 	BYTE  Modes;
-	SWORD ScaleFrequency;
-	WORD  ScaleFactor;		/* From 0 to 2048 or 0 to 2 */
+	int16_t ScaleFrequency;
+	uint16_t  ScaleFactor;		/* From 0 to 2048 or 0 to 2 */
 	BYTE  Reserved[PATCH_DATA_RESERVED_SIZE];
 } GCC_PACKED;
 #ifdef _MSC_VER
diff --git a/src/timidity/instrum.cpp b/src/timidity/instrum.cpp
index 6cce239a84..e4d5918791 100644
--- a/src/timidity/instrum.cpp
+++ b/src/timidity/instrum.cpp
@@ -511,7 +511,7 @@ void convert_sample_data(Sample *sp, const void *data)
 
 	case PATCH_16:
 	  {					/* 16-bit, signed */
-		SWORD *cp = (SWORD *)data;
+		int16_t *cp = (int16_t *)data;
 		/* Convert these to samples */
 		sp->data_length >>= 1;
 		sp->loop_start >>= 1;
@@ -534,7 +534,7 @@ void convert_sample_data(Sample *sp, const void *data)
 
 	case PATCH_16 | PATCH_UNSIGNED:
 	  {					/* 16-bit, unsigned */
-		WORD *cp = (WORD *)data;
+		auto *cp = (uint16_t *)data;
 		/* Convert these to samples */
 		sp->data_length >>= 1;
 		sp->loop_start >>= 1;
diff --git a/src/timidity/instrum_dls.cpp b/src/timidity/instrum_dls.cpp
index c882cd84e2..06ce83df23 100644
--- a/src/timidity/instrum_dls.cpp
+++ b/src/timidity/instrum_dls.cpp
@@ -56,9 +56,9 @@ struct RIFF_Chunk
 		}
 	}
 
-	DWORD	magic;
-	DWORD	length;
-	DWORD	subtype;
+	uint32_t	magic;
+	uint32_t	length;
+	uint32_t	subtype;
 	BYTE	*data;
 	RIFF_Chunk *child;
 	RIFF_Chunk *next;
@@ -75,20 +75,20 @@ void PrintRIFF(RIFF_Chunk *chunk, int level);
 #define RIFF        MAKE_ID('R','I','F','F')
 #define LIST        MAKE_ID('L','I','S','T')
 
-static bool ChunkHasSubType(DWORD magic)
+static bool ChunkHasSubType(uint32_t magic)
 {
 	return (magic == RIFF || magic == LIST);
 }
 
-static int ChunkHasSubChunks(DWORD magic)
+static int ChunkHasSubChunks(uint32_t magic)
 {
 	return (magic == RIFF || magic == LIST);
 }
 
-static void LoadSubChunks(RIFF_Chunk *chunk, BYTE *data, DWORD left)
+static void LoadSubChunks(RIFF_Chunk *chunk, BYTE *data, uint32_t left)
 {
 	BYTE *subchunkData;
-	DWORD subchunkDataLen;
+	uint32_t subchunkDataLen;
 
 	while ( left > 8 ) {
 		RIFF_Chunk *child = new RIFF_Chunk;
@@ -102,10 +102,10 @@ static void LoadSubChunks(RIFF_Chunk *chunk, BYTE *data, DWORD left)
 			chunk->child = child;
 		}
 
-		child->magic = *(DWORD *)data;
+		child->magic = *(uint32_t *)data;
 		data += 4;
 		left -= 4;
-		child->length = LittleLong(*(DWORD *)data);
+		child->length = LittleLong(*(uint32_t *)data);
 		data += 4;
 		left -= 4;
 		child->data = data;
@@ -117,7 +117,7 @@ static void LoadSubChunks(RIFF_Chunk *chunk, BYTE *data, DWORD left)
 		subchunkData = child->data;
 		subchunkDataLen = child->length;
 		if ( ChunkHasSubType(child->magic) && subchunkDataLen >= 4 ) {
-			child->subtype = *(DWORD *)subchunkData;
+			child->subtype = *(uint32_t *)subchunkData;
 			subchunkData += 4;
 			subchunkDataLen -= 4;
 		}
@@ -134,7 +134,7 @@ RIFF_Chunk *LoadRIFF(FILE *src)
 {
 	RIFF_Chunk *chunk;
 	BYTE *subchunkData;
-	DWORD subchunkDataLen;
+	uint32_t subchunkDataLen;
 
 	/* Allocate the chunk structure */
 	chunk = new RIFF_Chunk;
@@ -162,7 +162,7 @@ RIFF_Chunk *LoadRIFF(FILE *src)
 	subchunkData = chunk->data;
 	subchunkDataLen = chunk->length;
 	if ( ChunkHasSubType(chunk->magic) && subchunkDataLen >= 4 ) {
-		chunk->subtype = *(DWORD *)subchunkData;
+		chunk->subtype = *(uint32_t *)subchunkData;
 		subchunkData += 4;
 		subchunkDataLen -= 4;
 	}
@@ -251,10 +251,10 @@ http://www.midi.org/about-midi/dls/dlsspec.shtml
 
 /* Some typedefs so the public dls headers don't need to be modified */
 #define FAR
-typedef SWORD	SHORT;
-typedef WORD	USHORT;
+typedef int16_t	SHORT;
+typedef uint16_t USHORT;
 typedef int32_t	LONG;
-typedef DWORD	ULONG;
+typedef uint32_t ULONG;
 #define mmioFOURCC	MAKE_ID
 #define DEFINE_GUID(A, B, C, E, F, G, H, I, J, K, L, M)
 
@@ -263,19 +263,19 @@ typedef DWORD	ULONG;
 
 struct WaveFMT
 {
-	WORD wFormatTag;
-	WORD wChannels;
-	DWORD dwSamplesPerSec;
-	DWORD dwAvgBytesPerSec;
-	WORD wBlockAlign;
-	WORD wBitsPerSample;
+	uint16_t wFormatTag;
+	uint16_t wChannels;
+	uint32_t dwSamplesPerSec;
+	uint32_t dwAvgBytesPerSec;
+	uint16_t wBlockAlign;
+	uint16_t wBitsPerSample;
 };
 
 struct DLS_Wave
 {
 	WaveFMT *format;
 	BYTE *data;
-	DWORD length;
+	uint32_t length;
 	WSMPL *wsmp;
 	WLOOP *wsmp_loop;
 };
@@ -303,7 +303,7 @@ struct DLS_Data
 {
 	RIFF_Chunk *chunk;
 
-	DWORD cInstruments;
+	uint32_t cInstruments;
 	DLS_Instrument *instruments;
 
 	POOLTABLE *ptbl;
@@ -367,7 +367,7 @@ static void AllocRegions(DLS_Instrument *instrument)
 static void FreeInstruments(DLS_Data *data)
 {
 	if ( data->instruments ) {
-		DWORD i;
+		uint32_t i;
 		for ( i = 0; i < data->cInstruments; ++i ) {
 			FreeRegions(&data->instruments[i]);
 		}
@@ -404,7 +404,7 @@ static void AllocWaveList(DLS_Data *data)
 
 static void Parse_colh(DLS_Data *data, RIFF_Chunk *chunk)
 {
-	data->cInstruments = LittleLong(*(DWORD *)chunk->data);
+	data->cInstruments = LittleLong(*(uint32_t *)chunk->data);
 	AllocInstruments(data);
 }
 
@@ -442,7 +442,7 @@ static void Parse_wlnk(DLS_Data *data, RIFF_Chunk *chunk, DLS_Region *region)
 
 static void Parse_wsmp(DLS_Data *data, RIFF_Chunk *chunk, WSMPL **wsmp_ptr, WLOOP **wsmp_loop_ptr)
 {
-	DWORD i;
+	uint32_t i;
 	WSMPL *wsmp = (WSMPL *)chunk->data;
 	WLOOP *loop;
 	wsmp->cbSize = LittleLong(wsmp->cbSize);
@@ -465,7 +465,7 @@ static void Parse_wsmp(DLS_Data *data, RIFF_Chunk *chunk, WSMPL **wsmp_ptr, WLOO
 
 static void Parse_art(DLS_Data *data, RIFF_Chunk *chunk, CONNECTIONLIST **art_ptr, CONNECTION **artList_ptr)
 {
-	DWORD i;
+	uint32_t i;
 	CONNECTIONLIST *art = (CONNECTIONLIST *)chunk->data;
 	CONNECTION *artList;
 	art->cbSize = LittleLong(art->cbSize);
@@ -487,7 +487,7 @@ static void Parse_lart(DLS_Data *data, RIFF_Chunk *chunk, CONNECTIONLIST **conn_
 {
 	/* FIXME: This only supports one set of connections */
 	for ( chunk = chunk->child; chunk; chunk = chunk->next ) {
-		DWORD magic = (chunk->magic == FOURCC_LIST) ? chunk->subtype : chunk->magic;
+		uint32_t magic = (chunk->magic == FOURCC_LIST) ? chunk->subtype : chunk->magic;
 		switch(magic) {
 			case FOURCC_ART1:
 			case FOURCC_ART2:
@@ -500,7 +500,7 @@ static void Parse_lart(DLS_Data *data, RIFF_Chunk *chunk, CONNECTIONLIST **conn_
 static void Parse_rgn(DLS_Data *data, RIFF_Chunk *chunk, DLS_Region *region)
 {
 	for ( chunk = chunk->child; chunk; chunk = chunk->next ) {
-		DWORD magic = (chunk->magic == FOURCC_LIST) ? chunk->subtype : chunk->magic;
+		uint32_t magic = (chunk->magic == FOURCC_LIST) ? chunk->subtype : chunk->magic;
 		switch(magic) {
 			case FOURCC_RGNH:
 				Parse_rgnh(data, chunk, region);
@@ -521,9 +521,9 @@ static void Parse_rgn(DLS_Data *data, RIFF_Chunk *chunk, DLS_Region *region)
 
 static void Parse_lrgn(DLS_Data *data, RIFF_Chunk *chunk, DLS_Instrument *instrument)
 {
-	DWORD region = 0;
+	uint32_t region = 0;
 	for ( chunk = chunk->child; chunk; chunk = chunk->next ) {
-		DWORD magic = (chunk->magic == FOURCC_LIST) ? chunk->subtype : chunk->magic;
+		uint32_t magic = (chunk->magic == FOURCC_LIST) ? chunk->subtype : chunk->magic;
 		switch(magic) {
 			case FOURCC_RGN:
 			case FOURCC_RGN2:
@@ -538,7 +538,7 @@ static void Parse_lrgn(DLS_Data *data, RIFF_Chunk *chunk, DLS_Instrument *instru
 static void Parse_INFO_INS(DLS_Data *data, RIFF_Chunk *chunk, DLS_Instrument *instrument)
 {
 	for ( chunk = chunk->child; chunk; chunk = chunk->next ) {
-		DWORD magic = (chunk->magic == FOURCC_LIST) ? chunk->subtype : chunk->magic;
+		uint32_t magic = (chunk->magic == FOURCC_LIST) ? chunk->subtype : chunk->magic;
 		switch(magic) {
 			case FOURCC_INAM: /* Name */
 				instrument->name = (const char *)chunk->data;
@@ -550,7 +550,7 @@ static void Parse_INFO_INS(DLS_Data *data, RIFF_Chunk *chunk, DLS_Instrument *in
 static void Parse_ins(DLS_Data *data, RIFF_Chunk *chunk, DLS_Instrument *instrument)
 {
 	for ( chunk = chunk->child; chunk; chunk = chunk->next ) {
-		DWORD magic = (chunk->magic == FOURCC_LIST) ? chunk->subtype : chunk->magic;
+		uint32_t magic = (chunk->magic == FOURCC_LIST) ? chunk->subtype : chunk->magic;
 		switch(magic) {
 			case FOURCC_INSH:
 				Parse_insh(data, chunk, instrument);
@@ -571,9 +571,9 @@ static void Parse_ins(DLS_Data *data, RIFF_Chunk *chunk, DLS_Instrument *instrum
 
 static void Parse_lins(DLS_Data *data, RIFF_Chunk *chunk)
 {
-	DWORD instrument = 0;
+	uint32_t instrument = 0;
 	for ( chunk = chunk->child; chunk; chunk = chunk->next ) {
-		DWORD magic = (chunk->magic == FOURCC_LIST) ? chunk->subtype : chunk->magic;
+		uint32_t magic = (chunk->magic == FOURCC_LIST) ? chunk->subtype : chunk->magic;
 		switch(magic) {
 			case FOURCC_INS:
 				if ( instrument < data->cInstruments ) {
@@ -586,7 +586,7 @@ static void Parse_lins(DLS_Data *data, RIFF_Chunk *chunk)
 
 static void Parse_ptbl(DLS_Data *data, RIFF_Chunk *chunk)
 {
-	DWORD i;
+	uint32_t i;
 	POOLTABLE *ptbl = (POOLTABLE *)chunk->data;
 	ptbl->cbSize = LittleLong(ptbl->cbSize);
 	ptbl->cCues = LittleLong(ptbl->cCues);
@@ -619,7 +619,7 @@ static void Parse_data(DLS_Data *data, RIFF_Chunk *chunk, DLS_Wave *wave)
 static void Parse_wave(DLS_Data *data, RIFF_Chunk *chunk, DLS_Wave *wave)
 {
 	for ( chunk = chunk->child; chunk; chunk = chunk->next ) {
-		DWORD magic = (chunk->magic == FOURCC_LIST) ? chunk->subtype : chunk->magic;
+		uint32_t magic = (chunk->magic == FOURCC_LIST) ? chunk->subtype : chunk->magic;
 		switch(magic) {
 			case FOURCC_FMT:
 				Parse_fmt(data, chunk, wave);
@@ -636,9 +636,9 @@ static void Parse_wave(DLS_Data *data, RIFF_Chunk *chunk, DLS_Wave *wave)
 
 static void Parse_wvpl(DLS_Data *data, RIFF_Chunk *chunk)
 {
-	DWORD wave = 0;
+	uint32_t wave = 0;
 	for ( chunk = chunk->child; chunk; chunk = chunk->next ) {
-		DWORD magic = (chunk->magic == FOURCC_LIST) ? chunk->subtype : chunk->magic;
+		uint32_t magic = (chunk->magic == FOURCC_LIST) ? chunk->subtype : chunk->magic;
 		switch(magic) {
 			case FOURCC_wave:
 				if ( wave < data->ptbl->cCues ) {
@@ -652,7 +652,7 @@ static void Parse_wvpl(DLS_Data *data, RIFF_Chunk *chunk)
 static void Parse_INFO_DLS(DLS_Data *data, RIFF_Chunk *chunk)
 {
 	for ( chunk = chunk->child; chunk; chunk = chunk->next ) {
-		DWORD magic = (chunk->magic == FOURCC_LIST) ? chunk->subtype : chunk->magic;
+		uint32_t magic = (chunk->magic == FOURCC_LIST) ? chunk->subtype : chunk->magic;
 		switch(magic) {
 			case FOURCC_IARL: /* Archival Location */
 				break;
@@ -713,7 +713,7 @@ DLS_Data *LoadDLS(FILE *src)
 	}
 
 	for ( chunk = data->chunk->child; chunk; chunk = chunk->next ) {
-		DWORD magic = (chunk->magic == FOURCC_LIST) ? chunk->subtype : chunk->magic;
+		uint32_t magic = (chunk->magic == FOURCC_LIST) ? chunk->subtype : chunk->magic;
 		switch(magic) {
 			case FOURCC_COLH:
 				Parse_colh(data, chunk);
@@ -883,7 +883,7 @@ static const char *DestinationToString(USHORT usDestination)
 
 static void PrintArt(const char *type, CONNECTIONLIST *art, CONNECTION *artList)
 {
-	DWORD i;
+	uint32_t i;
 	printf("%s Connections:\n", type);
 	for ( i = 0; i < art->cConnections; ++i ) {
 		printf("  Source: %s, Control: %s, Destination: %s, Transform: %s, Scale: %d\n",
@@ -895,14 +895,14 @@ static void PrintArt(const char *type, CONNECTIONLIST *art, CONNECTION *artList)
 	}
 }
 
-static void PrintWave(DLS_Wave *wave, DWORD index)
+static void PrintWave(DLS_Wave *wave, uint32_t index)
 {
 	WaveFMT *format = wave->format;
 	if ( format ) {
 		printf("  Wave %u: Format: %hu, %hu channels, %u Hz, %hu bits (length = %u)\n", index, format->wFormatTag, format->wChannels, format->dwSamplesPerSec, format->wBitsPerSample, wave->length);
 	}
 	if ( wave->wsmp ) {
-		DWORD i;
+		uint32_t i;
 		printf("    wsmp->usUnityNote = %hu\n", wave->wsmp->usUnityNote);
 		printf("    wsmp->sFineTune = %hd\n", wave->wsmp->sFineTune);
 		printf("    wsmp->lAttenuation = %d\n", wave->wsmp->lAttenuation);
@@ -917,7 +917,7 @@ static void PrintWave(DLS_Wave *wave, DWORD index)
 	}
 }
 
-static void PrintRegion(DLS_Region *region, DWORD index)
+static void PrintRegion(DLS_Region *region, uint32_t index)
 {
 	printf("  Region %u:\n", index);
 	if ( region->header ) {
@@ -933,7 +933,7 @@ static void PrintRegion(DLS_Region *region, DWORD index)
 		printf("    wlnk->ulTableIndex = %u\n", region->wlnk->ulTableIndex);
 	}
 	if ( region->wsmp ) {
-		DWORD i;
+		uint32_t i;
 		printf("    wsmp->usUnityNote = %hu\n", region->wsmp->usUnityNote);
 		printf("    wsmp->sFineTune = %hd\n", region->wsmp->sFineTune);
 		printf("    wsmp->lAttenuation = %d\n", region->wsmp->lAttenuation);
@@ -951,14 +951,14 @@ static void PrintRegion(DLS_Region *region, DWORD index)
 	}
 }
 
-static void PrintInstrument(DLS_Instrument *instrument, DWORD index)
+static void PrintInstrument(DLS_Instrument *instrument, uint32_t index)
 {
 	printf("Instrument %u:\n", index);
 	if ( instrument->name ) {
 		printf("  Name: %s\n", instrument->name);
 	}
 	if ( instrument->header ) {
-		DWORD i;
+		uint32_t i;
 		printf("  ulBank = 0x%8.8x\n", instrument->header->Locale.ulBank);
 		printf("  ulInstrument = %u\n", instrument->header->Locale.ulInstrument);
 		printf("  Regions: %u\n", instrument->header->cRegions);
@@ -976,13 +976,13 @@ void PrintDLS(DLS_Data *data)
 	printf("DLS Data:\n");
 	printf("cInstruments = %u\n", data->cInstruments); 
 	if ( data->instruments ) {
-		DWORD i;
+		uint32_t i;
 		for ( i = 0; i < data->cInstruments; ++i ) {
 			PrintInstrument(&data->instruments[i], i);
 		}
 	}
 	if ( data->ptbl && data->ptbl->cCues > 0 ) {
-		DWORD i;
+		uint32_t i;
 		printf("Cues: ");
 		for ( i = 0; i < data->ptbl->cCues; ++i ) {
 			if ( i > 0 ) {
@@ -993,7 +993,7 @@ void PrintDLS(DLS_Data *data)
 		printf("\n");
 	}
 	if ( data->waveList && data->ptbl ) {
-		DWORD i;
+		uint32_t i;
 		printf("Waves:\n");
 		for ( i = 0; i < data->ptbl->cCues; ++i ) {
 			PrintWave(&data->waveList[i], i);
@@ -1116,7 +1116,7 @@ static int load_connection(ULONG cConnections, CONNECTION *artList, USHORT desti
 	return value;
 }
 
-static void load_region_dls(Renderer *song, Sample *sample, DLS_Instrument *ins, DWORD index)
+static void load_region_dls(Renderer *song, Sample *sample, DLS_Instrument *ins, uint32_t index)
 {
 	DLS_Region *rgn = &ins->regions[index];
 	DLS_Wave *wave = &song->patches->waveList[rgn->wlnk->ulTableIndex];
@@ -1187,7 +1187,7 @@ static void load_region_dls(Renderer *song, Sample *sample, DLS_Instrument *ins,
 Instrument *load_instrument_dls(Renderer *song, int drum, int bank, int instrument)
 {
 	Instrument *inst;
-	DWORD i;
+	uint32_t i;
 	DLS_Instrument *dls_ins = NULL;
 
 	if (song->patches == NULL)
diff --git a/src/timidity/instrum_sf2.cpp b/src/timidity/instrum_sf2.cpp
index 2e9d7d0c00..fe839ce45e 100644
--- a/src/timidity/instrum_sf2.cpp
+++ b/src/timidity/instrum_sf2.cpp
@@ -192,7 +192,7 @@ ListHandler PdtaHandlers[] =
 	{ 0, 0 }
 };
 
-static double timecent_to_sec(SWORD timecent)
+static double timecent_to_sec(int16_t timecent)
 {
 	if (timecent == -32768)
 		return 0;
@@ -250,7 +250,7 @@ static inline int read_char(FileReader *f)
 
 static inline int read_uword(FileReader *f)
 {
-	WORD x;
+	uint16_t x;
 	if (f->Read(&x, 2) != 2)
 	{
 		throw CIOErr();
@@ -260,7 +260,7 @@ static inline int read_uword(FileReader *f)
 
 static inline int read_sword(FileReader *f)
 {
-	SWORD x;
+	int16_t x;
 	if (f->Read(&x, 2) != 2)
 	{
 		throw CIOErr();
@@ -317,7 +317,7 @@ static void check_list(FileReader *f, DWORD id, DWORD filelen, DWORD &chunklen)
 
 static void ParseIfil(SFFile *sf2, FileReader *f, DWORD chunkid, DWORD chunklen)
 {
-	WORD major, minor;
+	uint16_t major, minor;
 
 	if (chunklen != 4)
 	{
@@ -473,7 +473,7 @@ static void ParsePhdr(SFFile *sf2, FileReader *f, DWORD chunkid, DWORD chunklen)
 static void ParseBag(SFFile *sf2, FileReader *f, DWORD chunkid, DWORD chunklen)
 {
 	SFBag *bags, *bag;
-	WORD prev_mod = 0;
+	uint16_t prev_mod = 0;
 	int numbags;
 	int i;
 
@@ -513,7 +513,7 @@ static void ParseBag(SFFile *sf2, FileReader *f, DWORD chunkid, DWORD chunklen)
 	for (bag = bags, i = numbags; i != 0; --i, ++bag)
 	{
 		bag->GenIndex = read_uword(f);
-		WORD mod = read_uword(f);
+		uint16_t mod = read_uword(f);
 		// Section 7.3, page 22:
 		//		If the generator or modulator indices are non-monotonic or do not
 		//		match the size of the respective PGEN or PMOD sub-chunks, the file
@@ -1165,7 +1165,7 @@ void SFFile::SetInstrumentGenerators(SFGenComposite *composite, int start, int s
 			continue;
 		}
 		// Set the generator
-		((WORD *)composite)[GenDefs[gen->Oper].StructIndex] = gen->uAmount;
+		((uint16_t *)composite)[GenDefs[gen->Oper].StructIndex] = gen->uAmount;
 		if (gen->Oper == GEN_sampleID)
 		{ // Anything past sampleID is ignored.
 			break;
@@ -1209,7 +1209,7 @@ void SFFile::AddPresetGenerators(SFGenComposite *composite, int start, int stop,
 			continue;
 		}
 		// Add to instrument/default generator.
-		int added = ((SWORD *)composite)[def->StructIndex] + gen->Amount;
+		int added = ((int16_t *)composite)[def->StructIndex] + gen->Amount;
 		// Clamp to proper range.
 		if (added <= -32768 && def->Flags & GENF_32768_Ok)
 		{
@@ -1219,7 +1219,7 @@ void SFFile::AddPresetGenerators(SFGenComposite *composite, int start, int stop,
 		{
 			added = clamp<int>(added, def->Min, def->Max);
 		}
-		((SWORD *)composite)[def->StructIndex] = added;
+		((int16_t *)composite)[def->StructIndex] = added;
 		gen_set[gen->Oper] = true;
 		if (gen->Oper == GEN_instrument)
 		{ // Anything past the instrument generator is ignored.
@@ -1513,7 +1513,7 @@ void SFFile::LoadSample(SFSample *sample)
 	// Load 16-bit sample data.
 	for (i = 0; i < sample->End - sample->Start; ++i)
 	{
-		SWORD samp;
+		int16_t samp;
 		*fp >> samp;
 		sample->InMemoryData[i] = samp / 32768.f;
 	}
diff --git a/src/timidity/resample.cpp b/src/timidity/resample.cpp
index 649262a149..bd45271e12 100644
--- a/src/timidity/resample.cpp
+++ b/src/timidity/resample.cpp
@@ -485,7 +485,7 @@ static sample_t *rs_vib_bidir(sample_t *resample_buffer, float rate, Voice *vp,
 sample_t *resample_voice(Renderer *song, Voice *vp, int *countptr)
 {
 	int ofs;
-	WORD modes;
+	uint16_t modes;
 
 	if (vp->sample->sample_rate == 0)
 	{
diff --git a/src/timidity/sf2.h b/src/timidity/sf2.h
index 122aff99e5..45dec4ae02 100644
--- a/src/timidity/sf2.h
+++ b/src/timidity/sf2.h
@@ -1,4 +1,4 @@
-typedef WORD SFGenerator;
+typedef uint16_t SFGenerator;
 
 struct SFRange
 {
@@ -11,16 +11,16 @@ struct SFPreset
 	char Name[21];
 	BYTE LoadOrder:7;
 	BYTE bHasGlobalZone:1;
-	WORD Program;
-	WORD Bank;
-	WORD BagIndex;
+	uint16_t Program;
+	uint16_t Bank;
+	uint16_t BagIndex;
 	/* Don't care about library, genre, and morphology */
 };
 
 struct SFBag
 {
-	WORD GenIndex;
-//	WORD ModIndex;		// If I am feeling ambitious, I might add support for modulators some day.
+	uint16_t GenIndex;
+//	uint16_t ModIndex;		// If I am feeling ambitious, I might add support for modulators some day.
 	SFRange KeyRange;
 	SFRange VelRange;
 	int Target;			// Either an instrument or sample index
@@ -31,7 +31,7 @@ struct SFInst
 	char Name[21];
 	BYTE Pad:7;
 	BYTE bHasGlobalZone:1;
-	WORD BagIndex;
+	uint16_t BagIndex;
 };
 
 struct SFSample
@@ -44,8 +44,8 @@ struct SFSample
 	DWORD SampleRate;
 	BYTE  OriginalPitch;
 	SBYTE PitchCorrection;
-	WORD  SampleLink;
-	WORD  SampleType;
+	uint16_t  SampleLink;
+	uint16_t  SampleType;
 	char  Name[21];
 };
 
@@ -68,8 +68,8 @@ struct SFGenList
 	union
 	{
 		SFRange Range;
-		SWORD Amount;
-		WORD uAmount;
+		int16_t Amount;
+		uint16_t uAmount;
 	};
 };
 
@@ -142,20 +142,20 @@ enum
 
 struct SFModulator
 {
-	WORD Index:7;
-	WORD CC:1;
-	WORD Dir:1;			/* 0 = min->max, 1 = max->min */
-	WORD Polarity:1;	/* 0 = unipolar, 1 = bipolar */
-	WORD Type:6;
+	uint16_t Index:7;
+	uint16_t CC:1;
+	uint16_t Dir:1;			/* 0 = min->max, 1 = max->min */
+	uint16_t Polarity:1;	/* 0 = unipolar, 1 = bipolar */
+	uint16_t Type:6;
 };
 
 struct SFModList
 {
 	SFModulator SrcOper;
 	SFGenerator DestOper;
-	SWORD		Amount;
+	int16_t		Amount;
 	SFModulator AmtSrcOper;
-	WORD		Transform;
+	uint16_t		Transform;
 };
 
 // Modulator sources when CC is 0
@@ -206,55 +206,55 @@ struct SFGenComposite
 	SFRange velRange;
 	union
 	{
-		WORD instrument;	// At preset level
-		WORD sampleID;		// At instrument level
+		uint16_t instrument;	// At preset level
+		uint16_t sampleID;		// At instrument level
 	};
-	SWORD modLfoToPitch;
-	SWORD vibLfoToPitch;
-	SWORD modEnvToPitch;
-	SWORD initialFilterFc;
-	SWORD initialFilterQ;
-	SWORD modLfoToFilterFc;
-	SWORD modEnvToFilterFc;
-	SWORD modLfoToVolume;
-	SWORD chorusEffectsSend;
-	SWORD reverbEffectsSend;
-	SWORD pan;
-	SWORD delayModLFO;
-	SWORD freqModLFO;
-	SWORD delayVibLFO;
-	SWORD freqVibLFO;
-	SWORD delayModEnv;
-	SWORD attackModEnv;
-	SWORD holdModEnv;
-	SWORD decayModEnv;
-	SWORD sustainModEnv;
-	SWORD releaseModEnv;
-	SWORD keynumToModEnvHold;
-	SWORD keynumToModEnvDecay;
-	SWORD delayVolEnv;
-	SWORD attackVolEnv;
-	SWORD holdVolEnv;
-	SWORD decayVolEnv;
-	SWORD sustainVolEnv;
-	SWORD releaseVolEnv;
-	SWORD keynumToVolEnvHold;
-	SWORD keynumToVolEnvDecay;
-	SWORD initialAttenuation;
-	SWORD coarseTune;
-	SWORD fineTune;
-	SWORD scaleTuning;
+	int16_t modLfoToPitch;
+	int16_t vibLfoToPitch;
+	int16_t modEnvToPitch;
+	int16_t initialFilterFc;
+	int16_t initialFilterQ;
+	int16_t modLfoToFilterFc;
+	int16_t modEnvToFilterFc;
+	int16_t modLfoToVolume;
+	int16_t chorusEffectsSend;
+	int16_t reverbEffectsSend;
+	int16_t pan;
+	int16_t delayModLFO;
+	int16_t freqModLFO;
+	int16_t delayVibLFO;
+	int16_t freqVibLFO;
+	int16_t delayModEnv;
+	int16_t attackModEnv;
+	int16_t holdModEnv;
+	int16_t decayModEnv;
+	int16_t sustainModEnv;
+	int16_t releaseModEnv;
+	int16_t keynumToModEnvHold;
+	int16_t keynumToModEnvDecay;
+	int16_t delayVolEnv;
+	int16_t attackVolEnv;
+	int16_t holdVolEnv;
+	int16_t decayVolEnv;
+	int16_t sustainVolEnv;
+	int16_t releaseVolEnv;
+	int16_t keynumToVolEnvHold;
+	int16_t keynumToVolEnvDecay;
+	int16_t initialAttenuation;
+	int16_t coarseTune;
+	int16_t fineTune;
+	int16_t scaleTuning;
 
 	// The following are only for instruments:
-	SWORD startAddrsOffset,		startAddrsCoarseOffset;
-	SWORD endAddrsOffset,		endAddrsCoarseOffset;
-	SWORD startLoopAddrsOffset,	startLoopAddrsCoarseOffset;
-	SWORD endLoopAddrsOffset,	endLoopAddrsCoarseOffset;
-	SWORD keynum;
-	SWORD velocity;
-	WORD  sampleModes;
-	SWORD exclusiveClass;
-	SWORD overridingRootKey;
+	int16_t startAddrsOffset,		startAddrsCoarseOffset;
+	int16_t endAddrsOffset,		endAddrsCoarseOffset;
+	int16_t startLoopAddrsOffset,	startLoopAddrsCoarseOffset;
+	int16_t endLoopAddrsOffset,	endLoopAddrsCoarseOffset;
+	int16_t keynum;
+	int16_t velocity;
+	uint16_t  sampleModes;
+	int16_t exclusiveClass;
+	int16_t overridingRootKey;
 };
 
 // Intermediate percussion representation
diff --git a/src/timidity/timidity.h b/src/timidity/timidity.h
index b3a1e2c809..28f4908afe 100644
--- a/src/timidity/timidity.h
+++ b/src/timidity/timidity.h
@@ -240,13 +240,13 @@ struct Sample
 		tremolo_depth, vibrato_depth,
 		low_vel, high_vel,
 		 type;
-	WORD
+	uint16_t
 		modes;
-	SWORD
+	int16_t
 		panning;
-	WORD
+	uint16_t
 		scale_factor, key_group;
-	SWORD
+	int16_t
 		scale_note;
 	bool
 		self_nonexclusive;
@@ -254,7 +254,7 @@ struct Sample
 		left_offset, right_offset;
 
 	// SF2 stuff
-	SWORD tune;
+	int16_t tune;
 	SBYTE velocity;
 
 	float initial_attenuation;
@@ -432,7 +432,7 @@ struct Channel
 		volume, expression;
 	SBYTE
 		panning;
-	WORD
+	uint16_t
 		rpn, nrpn;
 	bool
 		nrpn_mode;
diff --git a/src/weightedlist.h b/src/weightedlist.h
index e171f6e353..55bcc95a88 100644
--- a/src/weightedlist.h
+++ b/src/weightedlist.h
@@ -44,10 +44,10 @@ class TWeightedList
 	template<class U>
 	struct Choice
 	{
-		Choice(WORD w, U v) : Next(NULL), Weight(w), RandomVal(0), Value(v) {}
+		Choice(uint16_t w, U v) : Next(NULL), Weight(w), RandomVal(0), Value(v) {}
 
 		Choice<U> *Next;
-		WORD Weight;
+		uint16_t Weight;
 		BYTE RandomVal;	// 0 (never) - 255 (always)
 		T Value;
 	};
@@ -65,7 +65,7 @@ class TWeightedList
 			}
 		}
 
-		void AddEntry (T value, WORD weight);
+		void AddEntry (T value, uint16_t weight);
 		T PickEntry () const;
 		void ReplaceValues (T oldval, T newval);
 
@@ -79,7 +79,7 @@ class TWeightedList
 };
 
 template<class T> 
-void TWeightedList<T>::AddEntry (T value, WORD weight)
+void TWeightedList<T>::AddEntry (T value, uint16_t weight)
 {
 	if (weight == 0)
 	{ // If the weight is 0, don't bother adding it,
diff --git a/src/win32/eaxedit.cpp b/src/win32/eaxedit.cpp
index ec3a2ac29d..c28603aa61 100644
--- a/src/win32/eaxedit.cpp
+++ b/src/win32/eaxedit.cpp
@@ -56,8 +56,8 @@ typedef struct w32apiFixedOFNA {
 	LPCSTR lpstrInitialDir;
 	LPCSTR lpstrTitle;
 	DWORD Flags;
-	WORD nFileOffset;
-	WORD nFileExtension;
+	uint16_t nFileOffset;
+	uint16_t nFileExtension;
 	LPCSTR lpstrDefExt;
 	LPARAM lCustData;
 	LPOFNHOOKPROC lpfnHook;
@@ -255,7 +255,7 @@ void PopulateEnvDropDown (HWND hCtl, bool showIDs, const ReverbContainer *defEnv
 	}
 }
 
-void SetIDEdits (HWND hDlg, WORD id)
+void SetIDEdits (HWND hDlg, uint16_t id)
 {
 	char text[4];
 
@@ -292,7 +292,7 @@ void PopulateEnvList (HWND hCtl, bool show, const ReverbContainer *defEnv)
 	SendMessage (hCtl, WM_SETREDRAW, TRUE, 0);
 }
 
-WORD FirstFreeID (WORD base, bool builtin)
+uint16_t FirstFreeID (uint16_t base, bool builtin)
 {
 	int tryCount = 0;
 	int priID = HIBYTE(base);
@@ -316,7 +316,7 @@ WORD FirstFreeID (WORD base, bool builtin)
 
 	for (;;)
 	{
-		WORD lastID = Environments->ID;
+		uint16_t lastID = Environments->ID;
 		const ReverbContainer *env = Environments->Next;
 
 		// Find the lowest-numbered free ID with the same primary ID as base
diff --git a/src/win32/fb_d3d9.cpp b/src/win32/fb_d3d9.cpp
index 789eacd98d..8d088e9dc9 100644
--- a/src/win32/fb_d3d9.cpp
+++ b/src/win32/fb_d3d9.cpp
@@ -877,7 +877,7 @@ bool D3DFB::CreateVertexes ()
 	{
 		return false;
 	}
-	if (FAILED(D3DDevice->CreateIndexBuffer(sizeof(WORD)*NUM_INDEXES,
+	if (FAILED(D3DDevice->CreateIndexBuffer(sizeof(uint16_t)*NUM_INDEXES,
 		D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, D3DFMT_INDEX16, D3DPOOL_DEFAULT, &IndexBuffer, NULL)))
 	{
 		return false;
diff --git a/src/win32/fb_d3d9_wipe.cpp b/src/win32/fb_d3d9_wipe.cpp
index fb46cc2151..34cd30e74e 100644
--- a/src/win32/fb_d3d9_wipe.cpp
+++ b/src/win32/fb_d3d9_wipe.cpp
@@ -468,7 +468,7 @@ bool D3DFB::Wiper_Melt::Run(int ticks, D3DFB *fb)
 
 					BufferedTris *quad = &fb->QuadExtra[fb->QuadBatchPos];
 					FBVERTEX *vert = &fb->VertexData[fb->VertexPos];
-					WORD *index = &fb->IndexData[fb->IndexPos];
+					uint16_t *index = &fb->IndexData[fb->IndexPos];
 
 					quad->Group1 = 0;
 					quad->Flags = BQF_DisableAlphaTest;
diff --git a/src/win32/i_crash.cpp b/src/win32/i_crash.cpp
index 5c1678c5c2..c7b4376f1e 100644
--- a/src/win32/i_crash.cpp
+++ b/src/win32/i_crash.cpp
@@ -169,15 +169,15 @@ namespace zip
 	{
 		DWORD	Magic;						// 0
 		BYTE	VersionToExtract[2];		// 4
-		WORD	Flags;						// 6
-		WORD	Method;						// 8
-		WORD	ModTime;					// 10
-		WORD	ModDate;					// 12
+		uint16_t	Flags;						// 6
+		uint16_t	Method;						// 8
+		uint16_t	ModTime;					// 10
+		uint16_t	ModDate;					// 12
 		DWORD	CRC32;						// 14
 		DWORD	CompressedSize;				// 18
 		DWORD	UncompressedSize;			// 22
-		WORD	NameLength;					// 26
-		WORD	ExtraLength;				// 28
+		uint16_t	NameLength;					// 26
+		uint16_t	ExtraLength;				// 28
 	};
 
 	struct CentralDirectoryEntry
@@ -185,18 +185,18 @@ namespace zip
 		DWORD	Magic;
 		BYTE	VersionMadeBy[2];
 		BYTE	VersionToExtract[2];
-		WORD	Flags;
-		WORD	Method;
-		WORD	ModTime;
-		WORD	ModDate;
+		uint16_t	Flags;
+		uint16_t	Method;
+		uint16_t	ModTime;
+		uint16_t	ModDate;
 		DWORD	CRC32;
 		DWORD	CompressedSize;
 		DWORD	UncompressedSize;
-		WORD	NameLength;
-		WORD	ExtraLength;
-		WORD	CommentLength;
-		WORD	StartingDiskNumber;
-		WORD	InternalAttributes;
+		uint16_t	NameLength;
+		uint16_t	ExtraLength;
+		uint16_t	CommentLength;
+		uint16_t	StartingDiskNumber;
+		uint16_t	InternalAttributes;
 		DWORD	ExternalAttributes;
 		DWORD	LocalHeaderOffset;
 	};
@@ -204,13 +204,13 @@ namespace zip
 	struct EndOfCentralDirectory
 	{
 		DWORD	Magic;
-		WORD	DiskNumber;
-		WORD	FirstDisk;
-		WORD	NumEntries;
-		WORD	NumEntriesOnAllDisks;
+		uint16_t	DiskNumber;
+		uint16_t	FirstDisk;
+		uint16_t	NumEntries;
+		uint16_t	NumEntriesOnAllDisks;
 		DWORD	DirectorySize;
 		DWORD	DirectoryOffset;
-		WORD	ZipCommentLength;
+		uint16_t	ZipCommentLength;
 	};
 #pragma pack(pop)
 }
@@ -803,7 +803,7 @@ HANDLE WriteTextReport ()
 			//" Cr0NpxState=%08x\r\n"
 			"\r\n"
 			,
-			(WORD)ctxt->FloatSave.ControlWord, (WORD)ctxt->FloatSave.StatusWord, (WORD)ctxt->FloatSave.TagWord,
+			(uint16_t)ctxt->FloatSave.ControlWord, (uint16_t)ctxt->FloatSave.StatusWord, (uint16_t)ctxt->FloatSave.TagWord,
 			ctxt->FloatSave.ErrorOffset, ctxt->FloatSave.ErrorSelector, ctxt->FloatSave.DataOffset,
 			ctxt->FloatSave.DataSelector
 			//, ctxt->FloatSave.Cr0NpxState
@@ -1583,7 +1583,7 @@ static HANDLE MakeZip ()
 		central.CRC32 = LittleLong(TarFiles[i].CRC32);
 		central.CompressedSize = LittleLong(TarFiles[i].CompressedSize);
 		central.UncompressedSize = LittleLong(TarFiles[i].UncompressedSize);
-		central.NameLength = LittleShort((WORD)namelen);
+		central.NameLength = LittleShort((uint16_t)namelen);
 		central.LocalHeaderOffset = LittleLong(TarFiles[i].ZipOffset);
 		WriteFile (file, &central, sizeof(central), &len, NULL);
 		WriteFile (file, TarFiles[i].Filename, (DWORD)namelen, &len, NULL);
@@ -1648,7 +1648,7 @@ static void AddZipFile (HANDLE ziphandle, TarFile *whichfile, short dosdate, sho
 	local.ModTime = dostime;
 	local.ModDate = dosdate;
 	local.UncompressedSize = LittleLong(whichfile->UncompressedSize);
-	local.NameLength = LittleShort((WORD)strlen(whichfile->Filename));
+	local.NameLength = LittleShort((uint16_t)strlen(whichfile->Filename));
 	
 	whichfile->ZipOffset = SetFilePointer (ziphandle, 0, NULL, FILE_CURRENT);
 	WriteFile (ziphandle, &local, sizeof(local), &wrote, NULL);
diff --git a/src/win32/i_input.h b/src/win32/i_input.h
index a9d165fcac..f941d9e8e0 100644
--- a/src/win32/i_input.h
+++ b/src/win32/i_input.h
@@ -89,7 +89,7 @@ protected:
 
 	int WheelMove[2];
 	int LastX, LastY;	// for m_filter
-	WORD ButtonState;	// bit mask of current button states (1=down, 0=up)
+	int ButtonState;	// bit mask of current button states (1=down, 0=up)
 };
 
 class FKeyboard : public FInputDevice
diff --git a/src/win32/i_mouse.cpp b/src/win32/i_mouse.cpp
index d13ef2445e..0af52cb1ad 100644
--- a/src/win32/i_mouse.cpp
+++ b/src/win32/i_mouse.cpp
@@ -1059,7 +1059,7 @@ bool FWin32Mouse::WndProcHook(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
 		// a single message. Winuser.h describes the button field as being filled with
 		// flags, which suggests that it could merge them. My testing
 		// indicates it does not, but I will assume it might in the future.
-		WORD xbuttons = GET_XBUTTON_WPARAM(wParam);
+		auto xbuttons = GET_XBUTTON_WPARAM(wParam);
 		event_t ev = { 0 };
 
 		ev.type = (message == WM_XBUTTONDOWN) ? EV_KeyDown : EV_KeyUp;
diff --git a/src/win32/i_rawps2.cpp b/src/win32/i_rawps2.cpp
index 940ef4bb1a..29f477a14b 100644
--- a/src/win32/i_rawps2.cpp
+++ b/src/win32/i_rawps2.cpp
@@ -126,7 +126,7 @@ protected:
 	float Multiplier;
 	AxisInfo Axes[NUM_AXES];
 	static DefaultAxisConfig DefaultAxes[NUM_AXES];
-	WORD LastButtons;
+	int LastButtons;
 	bool Connected;
 	bool Marked;
 	bool Active;
@@ -481,7 +481,7 @@ bool FRawPS2Controller::ProcessInput(RAWHID *raw, int code)
 	}
 
 	// Generate events for buttons that have changed.
-	WORD buttons = 0;
+	int buttons = 0;
 	
 	// If we know we are digital, ignore the D-Pad.
 	if (!digital)
diff --git a/src/win32/i_xinput.cpp b/src/win32/i_xinput.cpp
index 22c2dd7142..7286a9d8f2 100644
--- a/src/win32/i_xinput.cpp
+++ b/src/win32/i_xinput.cpp
@@ -115,7 +115,7 @@ protected:
 	AxisInfo Axes[NUM_AXES];
 	static DefaultAxisConfig DefaultAxes[NUM_AXES];
 	DWORD LastPacketNumber;
-	WORD LastButtons;
+	int LastButtons;
 	bool Connected;
 
 	void Attached();
diff --git a/src/win32/st_start.cpp b/src/win32/st_start.cpp
index 1fc47754a0..4c322b90e9 100644
--- a/src/win32/st_start.cpp
+++ b/src/win32/st_start.cpp
@@ -1342,7 +1342,7 @@ void ST_Util_DrawBlock (BITMAPINFO *bitmap_info, const BYTE *src, int x, int y,
 	{ // net progress notches
 		for (; height > 0; --height)
 		{
-			*((WORD *)dest) = *((const WORD *)src);
+			*((uint16_t *)dest) = *((const uint16_t *)src);
 			dest += destpitch;
 			src += 2;
 		}
diff --git a/src/win32/win32gliface.cpp b/src/win32/win32gliface.cpp
index c4b5b7b433..b54406870f 100644
--- a/src/win32/win32gliface.cpp
+++ b/src/win32/win32gliface.cpp
@@ -1031,7 +1031,7 @@ void Win32GLFrameBuffer::ResetGammaTable()
 	}
 }
 
-void Win32GLFrameBuffer::SetGammaTable(WORD *tbl)
+void Win32GLFrameBuffer::SetGammaTable(uint16_t *tbl)
 {
 	if (m_supportsGamma)
 	{
diff --git a/src/win32/win32gliface.h b/src/win32/win32gliface.h
index e767073c4e..b5855668c1 100644
--- a/src/win32/win32gliface.h
+++ b/src/win32/win32gliface.h
@@ -138,7 +138,7 @@ protected:
 
 	bool CanUpdate();
 	void ResetGammaTable();
-	void SetGammaTable(WORD * tbl);
+	void SetGammaTable(uint16_t * tbl);
 
 	float m_Gamma, m_Brightness, m_Contrast;
 	WORD m_origGamma[768];
diff --git a/src/win32/win32iface.h b/src/win32/win32iface.h
index 13cf603fae..63f8270276 100644
--- a/src/win32/win32iface.h
+++ b/src/win32/win32iface.h
@@ -127,7 +127,7 @@ public:
 	virtual void Blank () = 0;
 	virtual bool PaintToWindow () = 0;
 	virtual HRESULT GetHR () = 0;
-	virtual void ScaleCoordsFromWindow(SWORD &x, SWORD &y);
+	virtual void ScaleCoordsFromWindow(int16_t &x, int16_t &y);
 
 protected:
 	virtual bool CreateResources () = 0;
@@ -304,8 +304,8 @@ private:
 		BYTE Desat;
 		D3DPal *Palette;
 		IDirect3DTexture9 *Texture;
-		WORD NumVerts;		// Number of _unique_ vertices used by this set.
-		WORD NumTris;		// Number of triangles used by this set.
+		int NumVerts;		// Number of _unique_ vertices used by this set.
+		int NumTris;		// Number of triangles used by this set.
 	};
 
 	enum
@@ -447,7 +447,7 @@ private:
 	IDirect3DVertexBuffer9 *VertexBuffer;
 	FBVERTEX *VertexData;
 	IDirect3DIndexBuffer9 *IndexBuffer;
-	WORD *IndexData;
+	uint16_t *IndexData;
 	BufferedTris *QuadExtra;
 	int VertexPos;
 	int IndexPos;
diff --git a/src/win32/win32video.cpp b/src/win32/win32video.cpp
index 0a32edc02c..7deb09d0f0 100644
--- a/src/win32/win32video.cpp
+++ b/src/win32/win32video.cpp
@@ -756,15 +756,15 @@ void Win32Video::SetWindowedScale (float scale)
 //
 //==========================================================================
 
-void BaseWinFB::ScaleCoordsFromWindow(SWORD &x, SWORD &y)
+void BaseWinFB::ScaleCoordsFromWindow(int16_t &x, int16_t &y)
 {
 	RECT rect;
 
 	int TrueHeight = GetTrueHeight();
 	if (GetClientRect(Window, &rect))
 	{
-		x = SWORD(x * Width / (rect.right - rect.left));
-		y = SWORD(y * TrueHeight / (rect.bottom - rect.top));
+		x = int16_t(x * Width / (rect.right - rect.left));
+		y = int16_t(y * TrueHeight / (rect.bottom - rect.top));
 	}
 	// Subtract letterboxing borders
 	y -= (TrueHeight - Height) / 2;
diff --git a/src/xlat/xlat.h b/src/xlat/xlat.h
index 494ac79928..770f69bcae 100644
--- a/src/xlat/xlat.h
+++ b/src/xlat/xlat.h
@@ -69,15 +69,15 @@ struct FBoomArg
 	BYTE ListSize;
 	BYTE ArgNum;
 	BYTE ConstantValue;
-	WORD AndValue;
-	WORD ResultFilter[15];
+	uint16_t AndValue;
+	uint16_t ResultFilter[15];
 	BYTE ResultValue[15];
 };
 
 struct FBoomTranslator
 {
-	WORD FirstLinetype;
-	WORD LastLinetype;
+	uint16_t FirstLinetype;
+	uint16_t LastLinetype;
 	BYTE NewSpecial;
 	TArray<FBoomArg> Args;
 } ;