From 490fd8f3a017bf1ecf19c001f4dfffce1295c601 Mon Sep 17 00:00:00 2001
From: "alexey.lysiuk" <alexey.lysiuk@gmail.com>
Date: Sat, 15 Apr 2017 12:33:26 +0300
Subject: [PATCH 01/29] Fixed applying of multiple damage factors

https://mantis.zdoom.org/view.php?id=586
---
 src/info.cpp | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/info.cpp b/src/info.cpp
index 4619b75856..94a4c4fb5a 100644
--- a/src/info.cpp
+++ b/src/info.cpp
@@ -513,8 +513,11 @@ void PClassActor::SetDamageFactor(FName type, double factor)
 {
 	for (auto & p : ActorInfo()->DamageFactors)
 	{
-		if (p.first == type) p.second = factor;
-		return;
+		if (p.first == type)
+		{
+			p.second = factor;
+			return;
+		}
 	}
 	ActorInfo()->DamageFactors.Push({ type, factor });
 }

From e333e314100eba432f1208403406daea8aec408b Mon Sep 17 00:00:00 2001
From: Christoph Oelckers <coelckers@users.noreply.github.com>
Date: Sat, 15 Apr 2017 12:01:44 +0200
Subject: [PATCH 02/29] - fixed: Vector array elements failed to allocate the
 proper amount of registers.

---
 src/scripting/backend/codegen.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/scripting/backend/codegen.cpp b/src/scripting/backend/codegen.cpp
index 737bb3c310..35582aa429 100644
--- a/src/scripting/backend/codegen.cpp
+++ b/src/scripting/backend/codegen.cpp
@@ -7445,7 +7445,7 @@ ExpEmit FxArrayElement::Emit(VMFunctionBuilder *build)
 			else
 			{
 				start.Free(build);
-				ExpEmit dest(build, ValueType->GetRegType());
+				ExpEmit dest(build, ValueType->GetRegType(), ValueType->GetRegCount());
 				// added 1 to use the *_R version that takes the offset from a register
 				build->Emit(arraytype->ElementType->GetLoadOp() + 1, dest.RegNum, start.RegNum, indexwork.RegNum);
 				return dest;

From 069e4e9b0b4d160f8eba2f934b6e3803f9db4202 Mon Sep 17 00:00:00 2001
From: Christoph Oelckers <coelckers@users.noreply.github.com>
Date: Sat, 15 Apr 2017 12:02:33 +0200
Subject: [PATCH 03/29] - allow tag == 0 for backside activation on a few more
 actions.

---
 src/p_ceiling.cpp | 4 ++--
 src/p_floor.cpp   | 8 ++++----
 src/p_lnspec.cpp  | 6 +++---
 src/p_spec.h      | 7 +++----
 4 files changed, 12 insertions(+), 13 deletions(-)

diff --git a/src/p_ceiling.cpp b/src/p_ceiling.cpp
index 40b0094ab4..b45ded588d 100644
--- a/src/p_ceiling.cpp
+++ b/src/p_ceiling.cpp
@@ -585,9 +585,9 @@ bool EV_CeilingCrushStop (int tag, bool remove)
 	return rtn;
 }
 
-bool EV_StopCeiling(int tag)
+bool EV_StopCeiling(int tag, line_t *line)
 {
-	FSectorTagIterator it(tag);
+	FSectorTagIterator it(tag, line);
 	while (int sec = it.Next())
 	{
 		if (level.sectors[sec].ceilingdata)
diff --git a/src/p_floor.cpp b/src/p_floor.cpp
index 580726155b..d370cdccf2 100644
--- a/src/p_floor.cpp
+++ b/src/p_floor.cpp
@@ -543,10 +543,10 @@ bool EV_DoFloor (DFloor::EFloor floortype, line_t *line, int tag,
 //
 //==========================================================================
 
-bool EV_FloorCrushStop (int tag)
+bool EV_FloorCrushStop (int tag, line_t *line)
 {
 	int secnum;
-	FSectorTagIterator it(tag);
+	FSectorTagIterator it(tag, line);
 	while ((secnum = it.Next()) >= 0)
 	{
 		sector_t *sec = &level.sectors[secnum];
@@ -563,9 +563,9 @@ bool EV_FloorCrushStop (int tag)
 }
 
 // same as above but stops any floor mover that was active on the given sector.
-bool EV_StopFloor(int tag)
+bool EV_StopFloor(int tag, line_t *line)
 {
-	FSectorTagIterator it(tag);
+	FSectorTagIterator it(tag, line);
 	while (int sec = it.Next())
 	{
 		if (level.sectors[sec].floordata)
diff --git a/src/p_lnspec.cpp b/src/p_lnspec.cpp
index 12a29dd3b0..01f4f85ffd 100644
--- a/src/p_lnspec.cpp
+++ b/src/p_lnspec.cpp
@@ -417,7 +417,7 @@ FUNC(LS_Floor_LowerByValueTimes8)
 FUNC(LS_Floor_CrushStop)
 // Floor_CrushStop (tag)
 {
-	return EV_FloorCrushStop (arg0);
+	return EV_FloorCrushStop (arg0, ln);
 }
 
 FUNC(LS_Floor_LowerInstant)
@@ -571,7 +571,7 @@ FUNC(LS_Generic_Floor)
 FUNC(LS_Floor_Stop)
 // Floor_Stop (tag)
 {
-	return EV_StopFloor(arg0);
+	return EV_StopFloor(arg0, ln);
 }
 
 
@@ -882,7 +882,7 @@ FUNC(LS_Ceiling_LowerByTexture)
 FUNC(LS_Ceiling_Stop)
 // Ceiling_Stop (tag)
 {
-	return EV_StopCeiling(arg0);
+	return EV_StopCeiling(arg0, ln);
 }
 
 
diff --git a/src/p_spec.h b/src/p_spec.h
index 5c8130a532..cd3107c4f2 100644
--- a/src/p_spec.h
+++ b/src/p_spec.h
@@ -452,7 +452,7 @@ bool P_CreateCeiling(sector_t *sec, DCeiling::ECeiling type, line_t *line, int t
 bool EV_DoCeiling (DCeiling::ECeiling type, line_t *line, int tag, double speed, double speed2, double height, int crush, int silent, int change, DCeiling::ECrushMode hexencrush = DCeiling::ECrushMode::crushDoom);
 
 bool EV_CeilingCrushStop (int tag, bool remove);
-bool EV_StopCeiling(int tag);
+bool EV_StopCeiling(int tag, line_t *line);
 void P_ActivateInStasisCeiling (int tag);
 
 
@@ -550,7 +550,6 @@ public:
 		int usespecials);
 	friend bool EV_DoFloor (DFloor::EFloor floortype, line_t *line, int tag,
 		double speed, double height, int crush, int change, bool hexencrush, bool hereticlower);
-	friend bool EV_FloorCrushStop (int tag);
 	friend bool EV_DoDonut (int tag, line_t *line, double pillarspeed, double slimespeed);
 private:
 	DFloor ();
@@ -565,8 +564,8 @@ bool EV_BuildStairs (int tag, DFloor::EStair type, line_t *line,
 bool EV_DoFloor(DFloor::EFloor floortype, line_t *line, int tag,
 	double speed, double height, int crush, int change, bool hexencrush, bool hereticlower = false);
 
-bool EV_FloorCrushStop (int tag);
-bool EV_StopFloor(int tag);
+bool EV_FloorCrushStop (int tag, line_t *line);
+bool EV_StopFloor(int tag, line_t *line);
 bool EV_DoDonut (int tag, line_t *line, double pillarspeed, double slimespeed);
 
 class DElevator : public DMover

From 2d0da4fcfa4aafe80140818c0e90071c41eb5e9b Mon Sep 17 00:00:00 2001
From: Christoph Oelckers <coelckers@users.noreply.github.com>
Date: Sat, 15 Apr 2017 13:20:58 +0200
Subject: [PATCH 04/29] - fixed: Dynamic arrays of objects in structs were not
 registered for garbage collection.

---
 src/scripting/types.cpp | 24 ++++++++++++++++++++++--
 src/scripting/types.h   |  5 +++--
 2 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/src/scripting/types.cpp b/src/scripting/types.cpp
index 5a8581812f..82263dfcd4 100644
--- a/src/scripting/types.cpp
+++ b/src/scripting/types.cpp
@@ -183,7 +183,7 @@ void PType::SetPointer(void *base, unsigned offset, TArray<size_t> *stroffs)
 {
 }
 
-void PType::SetPointerArray(void *base, unsigned offset, TArray<size_t> *stroffs) const
+void PType::SetPointerArray(void *base, unsigned offset, TArray<size_t> *stroffs)
 {
 }
 
@@ -1951,7 +1951,7 @@ void PDynArray::SetDefaultValue(void *base, unsigned offset, TArray<FTypeAndOffs
 //
 //==========================================================================
 
-void PDynArray::SetPointerArray(void *base, unsigned offset, TArray<size_t> *special) const
+void PDynArray::SetPointerArray(void *base, unsigned offset, TArray<size_t> *special)
 {
 	if (ElementType->isObjectPointer())
 	{
@@ -2185,6 +2185,26 @@ void PStruct::SetPointer(void *base, unsigned offset, TArray<size_t> *special)
 	}
 }
 
+//==========================================================================
+//
+// PStruct :: SetPointerArray
+//
+//==========================================================================
+
+void PStruct::SetPointerArray(void *base, unsigned offset, TArray<size_t> *special)
+{
+	auto it = Symbols.GetIterator();
+	PSymbolTable::MapType::Pair *pair;
+	while (it.NextPair(pair))
+	{
+		auto field = dyn_cast<PField>(pair->Value);
+		if (field && !(field->Flags & VARF_Transient))
+		{
+			field->Type->SetPointerArray(base, unsigned(offset + field->Offset), special);
+		}
+	}
+}
+
 //==========================================================================
 //
 // PStruct :: WriteValue
diff --git a/src/scripting/types.h b/src/scripting/types.h
index d4dc196f7a..5c55db6c1a 100644
--- a/src/scripting/types.h
+++ b/src/scripting/types.h
@@ -125,7 +125,7 @@ public:
 	// object is destroyed.
 	virtual void SetDefaultValue(void *base, unsigned offset, TArray<FTypeAndOffset> *special=NULL);
 	virtual void SetPointer(void *base, unsigned offset, TArray<size_t> *ptrofs = NULL);
-	virtual void SetPointerArray(void *base, unsigned offset, TArray<size_t> *ptrofs = NULL) const;
+	virtual void SetPointerArray(void *base, unsigned offset, TArray<size_t> *ptrofs = NULL);
 
 	// Initialize the value, if needed (e.g. strings)
 	virtual void InitializeValue(void *addr, const void *def) const;
@@ -512,7 +512,7 @@ public:
 	void SetDefaultValue(void *base, unsigned offset, TArray<FTypeAndOffset> *specials) override;
 	void InitializeValue(void *addr, const void *def) const override;
 	void DestroyValue(void *addr) const override;
-	void SetPointerArray(void *base, unsigned offset, TArray<size_t> *ptrofs = NULL) const override;
+	void SetPointerArray(void *base, unsigned offset, TArray<size_t> *ptrofs = NULL) override;
 };
 
 class PMap : public PCompoundType
@@ -544,6 +544,7 @@ public:
 	bool ReadValue(FSerializer &ar, const char *key,void *addr) const override;
 	void SetDefaultValue(void *base, unsigned offset, TArray<FTypeAndOffset> *specials) override;
 	void SetPointer(void *base, unsigned offset, TArray<size_t> *specials) override;
+	void SetPointerArray(void *base, unsigned offset, TArray<size_t> *special) override;
 };
 
 class PPrototype : public PCompoundType

From 046e250f2e32399450ec74d43518384a455d65e1 Mon Sep 17 00:00:00 2001
From: Christoph Oelckers <coelckers@users.noreply.github.com>
Date: Sat, 15 Apr 2017 14:54:43 +0200
Subject: [PATCH 05/29] - fixed: Ceiling_CrushStop checked the wrong argument
 for the remove parameter.

---
 src/p_lnspec.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/p_lnspec.cpp b/src/p_lnspec.cpp
index 01f4f85ffd..3a5d0d94b4 100644
--- a/src/p_lnspec.cpp
+++ b/src/p_lnspec.cpp
@@ -717,7 +717,7 @@ FUNC(LS_Ceiling_CrushStop)
 // Ceiling_CrushStop (tag, remove)
 {
 	bool remove;
-	switch (arg3)
+	switch (arg1)
 	{
 	case 1:
 		remove = false;

From 1ee925684226663dda43fa6d1a3b9bf9cacee676 Mon Sep 17 00:00:00 2001
From: Christoph Oelckers <coelckers@users.noreply.github.com>
Date: Sat, 15 Apr 2017 16:41:00 +0200
Subject: [PATCH 06/29] - did a complete workover of the weapon sprite
 translucency code that got inherited from QZDoom.

This was very poorly done without ever addressing the issues a composite render style can bring, it merely dealt with the known legacy render styles.
The same, identical code was also present in two different places.
The oversight that AlterWeaponSprite overrode even forced styles was also fixed.

OpenGL is not implemented yet but with the problems eliminated should be doable now.
---
 src/p_pspr.cpp                               |  80 ++++++++++++-
 src/p_pspr.h                                 |   5 +-
 src/polyrenderer/scene/poly_playersprite.cpp | 115 ++-----------------
 src/r_data/renderstyle.h                     |   3 -
 src/swrenderer/things/r_playersprite.cpp     | 114 ++----------------
 src/swrenderer/viewport/r_spritedrawer.cpp   |   6 +-
 wadsrc/static/zscript/shared/player.txt      |   2 +-
 7 files changed, 96 insertions(+), 229 deletions(-)

diff --git a/src/p_pspr.cpp b/src/p_pspr.cpp
index cb89305d87..73afa00673 100644
--- a/src/p_pspr.cpp
+++ b/src/p_pspr.cpp
@@ -122,7 +122,6 @@ DEFINE_FIELD(DPSprite, oldy)
 DEFINE_FIELD(DPSprite, firstTic)
 DEFINE_FIELD(DPSprite, Tics)
 DEFINE_FIELD(DPSprite, alpha)
-DEFINE_FIELD(DPSprite, RenderStyle)
 DEFINE_FIELD_BIT(DPSprite, Flags, bAddWeapon, PSPF_ADDWEAPON)
 DEFINE_FIELD_BIT(DPSprite, Flags, bAddBob, PSPF_ADDBOB)
 DEFINE_FIELD_BIT(DPSprite, Flags, bPowDouble, PSPF_POWDOUBLE)
@@ -147,7 +146,7 @@ DPSprite::DPSprite(player_t *owner, AActor *caller, int id)
   processPending(true)
 {
 	alpha = 1;
-	RenderStyle = STYLE_Normal;
+	Renderstyle = STYLE_Normal;
 
 	DPSprite *prev = nullptr;
 	DPSprite *next = Owner->psprites;
@@ -298,6 +297,79 @@ DEFINE_ACTION_FUNCTION(_PlayerInfo, GetPSprite)	// the underscore is needed to g
 }
 
 
+
+std::pair<FRenderStyle, float> DPSprite::GetRenderStyle(FRenderStyle ownerstyle, double owneralpha)
+{
+	FRenderStyle returnstyle, mystyle;
+	double returnalpha;
+
+	ownerstyle.CheckFuzz();
+	mystyle = Renderstyle;
+	mystyle.CheckFuzz();
+	if (Flags & PSPF_RENDERSTYLE)
+	{
+		ownerstyle.CheckFuzz();
+		if (Flags & PSPF_FORCESTYLE)
+		{
+			returnstyle = mystyle;
+		}
+		else if (ownerstyle.BlendOp != STYLEOP_Add)
+		{
+			// all styles that do more than simple blending need to be fully preserved.
+			returnstyle = ownerstyle;
+		}
+		else
+		{
+			returnstyle = mystyle;
+			if (ownerstyle.DestAlpha == STYLEALPHA_One)
+			{
+				// If the owner is additive and the overlay translucent, force additive result.
+				returnstyle.DestAlpha = STYLEALPHA_One;
+			}
+			if (ownerstyle.Flags & (STYLEF_ColorIsFixed|STYLEF_RedIsAlpha))
+			{
+				// If the owner's style is a stencil type, this must be preserved.
+				returnstyle.Flags = ownerstyle.Flags;
+			}
+		}
+	}
+	else
+	{
+		returnstyle = ownerstyle;
+	}
+
+	if ((Flags & PSPF_FORCEALPHA) && returnstyle.BlendOp != STYLEOP_Fuzz && returnstyle.BlendOp != STYLEOP_Shadow)
+	{
+		// ALWAYS take priority if asked for, except fuzz. Fuzz does absolutely nothing
+		// no matter what way it's changed.
+		returnalpha = alpha;
+		returnstyle.Flags &= ~(STYLEF_Alpha1 | STYLEF_TransSoulsAlpha);
+	}
+	else if (Flags & PSPF_ALPHA)
+	{
+		// Set the alpha based on if using the overlay's own or not. Also adjust
+		// and override the alpha if not forced.
+		if (returnstyle.BlendOp != STYLEOP_Add)
+		{
+			returnalpha = owneralpha;
+		}
+		else
+		{
+			returnalpha = owneralpha * alpha;
+		}
+	}
+
+	// Should normal renderstyle come out on top at the end and we desire alpha,
+	// switch it to translucent. Normal never applies any sort of alpha.
+	if (returnstyle.BlendOp == STYLEOP_Add && returnstyle.SrcAlpha == STYLEALPHA_One && returnstyle.DestAlpha == STYLEALPHA_Zero && returnalpha < 1.)
+	{
+		returnstyle = LegacyRenderStyles[STYLE_Translucent];
+		returnalpha = owneralpha * alpha;
+	}
+
+	return{ returnstyle, clamp<float>(float(alpha), 0.f, 1.f) };
+}
+
 //---------------------------------------------------------------------------
 //
 // PROC P_NewPspriteTick
@@ -1237,7 +1309,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_OverlayRenderStyle)
 		if (pspr == nullptr || style >= STYLE_Count || style < 0)
 			return 0;
 
-		pspr->RenderStyle = style;
+		pspr->Renderstyle = ERenderStyle(style);
 	}
 	return 0;
 }
@@ -1472,7 +1544,7 @@ void DPSprite::Serialize(FSerializer &arc)
 		("oldx", oldx)
 		("oldy", oldy)
 		("alpha", alpha)
-		("renderstyle", RenderStyle);
+		("renderstyle_", Renderstyle);	// The underscore is intentional to avoid problems with old savegames which had this as an ERenderStyle (which is not future proof.)
 }
 
 //------------------------------------------------------------------------
diff --git a/src/p_pspr.h b/src/p_pspr.h
index 08d78429a5..f91c4b30fc 100644
--- a/src/p_pspr.h
+++ b/src/p_pspr.h
@@ -23,6 +23,8 @@
 #ifndef __P_PSPR_H__
 #define __P_PSPR_H__
 
+#include "r_data/renderstyle.h"
+
 // Basic data types.
 // Needs fixed point, and BAM angles.
 
@@ -81,13 +83,14 @@ public:
 	void		SetCaller(AActor *newcaller) { Caller = newcaller; }
 	void		ResetInterpolation() { oldx = x; oldy = y; }
 	void OnDestroy() override;
+	std::pair<FRenderStyle, float> GetRenderStyle(FRenderStyle ownerstyle, double owneralpha);
 
 	double x, y, alpha;
 	double oldx, oldy;
 	bool firstTic;
 	int Tics;
 	int Flags;
-	int RenderStyle;
+	FRenderStyle Renderstyle;
 
 private:
 	DPSprite () {}
diff --git a/src/polyrenderer/scene/poly_playersprite.cpp b/src/polyrenderer/scene/poly_playersprite.cpp
index eb1ff323ed..ac8af89cea 100644
--- a/src/polyrenderer/scene/poly_playersprite.cpp
+++ b/src/polyrenderer/scene/poly_playersprite.cpp
@@ -217,7 +217,7 @@ void RenderPolyPlayerSprites::RenderSprite(DPSprite *pspr, AActor *owner, float
 	flip = sprframe->Flip & 1;
 	tex = TexMan(picnum);
 
-	if (tex->UseType == FTexture::TEX_Null || pspr->RenderStyle == STYLE_None)
+	if (tex->UseType == FTexture::TEX_Null)
 		return;
 
 	if (pspr->firstTic)
@@ -319,112 +319,11 @@ void RenderPolyPlayerSprites::RenderSprite(DPSprite *pspr, AActor *owner, float
 	FDynamicColormap *colormap_to_use = nullptr;
 	if (pspr->GetID() < PSP_TARGETCENTER)
 	{
-		// [MC] Set the render style 
+		auto rs = pspr->GetRenderStyle(owner->RenderStyle, owner->Alpha);
+		vis.RenderStyle = rs.first;
+		vis.Alpha = rs.second;
 
-		if (pspr->Flags & PSPF_RENDERSTYLE)
-		{
-			const int rs = clamp<int>(pspr->RenderStyle, 0, STYLE_Count);
-
-			if (pspr->Flags & PSPF_FORCESTYLE)
-			{
-				vis.RenderStyle = LegacyRenderStyles[rs];
-			}
-			else if (owner->RenderStyle == LegacyRenderStyles[STYLE_Fuzzy])
-			{
-				vis.RenderStyle = LegacyRenderStyles[STYLE_Fuzzy];
-			}
-			else if (owner->RenderStyle == LegacyRenderStyles[STYLE_OptFuzzy])
-			{
-				vis.RenderStyle = LegacyRenderStyles[STYLE_OptFuzzy];
-				vis.RenderStyle.CheckFuzz();
-			}
-			else if (owner->RenderStyle == LegacyRenderStyles[STYLE_Subtract])
-			{
-				vis.RenderStyle = LegacyRenderStyles[STYLE_Subtract];
-			}
-			else
-			{
-				vis.RenderStyle = LegacyRenderStyles[rs];
-			}
-		}
-		else
-		{
-			vis.RenderStyle = owner->RenderStyle;
-		}
-
-		// Set the alpha based on if using the overlay's own or not. Also adjust
-		// and override the alpha if not forced.
-		if (pspr->Flags & PSPF_ALPHA)
-		{
-			if (vis.RenderStyle == LegacyRenderStyles[STYLE_Fuzzy])
-			{
-				alpha = owner->Alpha;
-			}
-			else if (vis.RenderStyle == LegacyRenderStyles[STYLE_OptFuzzy])
-			{
-				FRenderStyle style = vis.RenderStyle;
-				style.CheckFuzz();
-				switch (style.BlendOp)
-				{
-				default:
-					alpha = pspr->alpha * owner->Alpha;
-					break;
-				case STYLEOP_Fuzz:
-				case STYLEOP_Sub:
-					alpha = owner->Alpha;
-					break;
-				}
-
-			}
-			else if (vis.RenderStyle == LegacyRenderStyles[STYLE_Subtract])
-			{
-				alpha = owner->Alpha;
-			}
-			else if (vis.RenderStyle == LegacyRenderStyles[STYLE_Add] ||
-				vis.RenderStyle == LegacyRenderStyles[STYLE_Translucent] ||
-				vis.RenderStyle == LegacyRenderStyles[STYLE_TranslucentStencil] ||
-				vis.RenderStyle == LegacyRenderStyles[STYLE_AddStencil] ||
-				vis.RenderStyle == LegacyRenderStyles[STYLE_AddShaded])
-			{
-				alpha = owner->Alpha * pspr->alpha;
-			}
-			else
-			{
-				alpha = owner->Alpha;
-			}
-		}
-
-		// Should normal renderstyle come out on top at the end and we desire alpha,
-		// switch it to translucent. Normal never applies any sort of alpha.
-		if ((pspr->Flags & PSPF_ALPHA) &&
-			vis.RenderStyle == LegacyRenderStyles[STYLE_Normal] &&
-			vis.Alpha < 1.0)
-		{
-			vis.RenderStyle = LegacyRenderStyles[STYLE_Translucent];
-			alpha = owner->Alpha * pspr->alpha;
-		}
-
-		// ALWAYS take priority if asked for, except fuzz. Fuzz does absolutely nothing
-		// no matter what way it's changed.
-		if (pspr->Flags & PSPF_FORCEALPHA)
-		{
-			//Due to lack of != operators...
-			if (vis.RenderStyle == LegacyRenderStyles[STYLE_Fuzzy] ||
-				vis.RenderStyle == LegacyRenderStyles[STYLE_SoulTrans] ||
-				vis.RenderStyle == LegacyRenderStyles[STYLE_Stencil])
-			{
-			}
-			else
-			{
-				alpha = pspr->alpha;
-				vis.RenderStyle.Flags |= STYLEF_ForceAlpha;
-			}
-		}
-		vis.Alpha = clamp<float>(float(alpha), 0.f, 1.f);
-
-		// Due to how some of the effects are handled, going to 0 or less causes some
-		// weirdness to display. There's no point rendering it anyway if it's 0.
-		if (vis.Alpha <= 0.)
+		if (!vis.RenderStyle.IsVisible(vis.Alpha))
 			return;
 
 		//-----------------------------------------------------------------------------
@@ -455,9 +354,9 @@ void RenderPolyPlayerSprites::RenderSprite(DPSprite *pspr, AActor *owner, float
 
 			viewpoint.camera->Inventory->AlterWeaponSprite(&visstyle);
 
-			vis.Alpha = visstyle.Alpha;
+			if (!(pspr->Flags & PSPF_FORCEALPHA)) vis.Alpha = visstyle.Alpha;
 
-			if (visstyle.RenderStyle != STYLE_Count)
+			if (visstyle.RenderStyle != STYLE_Count && !(pspr->Flags & PSPF_FORCESTYLE))
 			{
 				vis.RenderStyle = visstyle.RenderStyle;
 			}
diff --git a/src/r_data/renderstyle.h b/src/r_data/renderstyle.h
index ebc1bd53fb..b1fd98a5ce 100644
--- a/src/r_data/renderstyle.h
+++ b/src/r_data/renderstyle.h
@@ -119,9 +119,6 @@ enum ERenderFlags
 	// Actors only: Ignore sector fade and fade to black. To fade to white,
 	// combine this with STYLEF_InvertOverlay.
 	STYLEF_FadeToBlack = 64,
-
-	// Force alpha.
-	STYLEF_ForceAlpha = 128,
 };
 
 union FRenderStyle
diff --git a/src/swrenderer/things/r_playersprite.cpp b/src/swrenderer/things/r_playersprite.cpp
index c56b95980b..cd8fc62d37 100644
--- a/src/swrenderer/things/r_playersprite.cpp
+++ b/src/swrenderer/things/r_playersprite.cpp
@@ -217,7 +217,7 @@ namespace swrenderer
 		flip = sprframe->Flip & 1;
 		tex = TexMan(picnum);
 
-		if (tex->UseType == FTexture::TEX_Null || pspr->RenderStyle == STYLE_None)
+		if (tex->UseType == FTexture::TEX_Null)
 			return;
 
 		if (pspr->firstTic)
@@ -320,111 +320,11 @@ namespace swrenderer
 		if (pspr->GetID() < PSP_TARGETCENTER)
 		{
 			// [MC] Set the render style 
+			auto rs = pspr->GetRenderStyle(owner->RenderStyle, owner->Alpha);
+			vis.RenderStyle = rs.first;
+			vis.Alpha = rs.second;
 
-			if (pspr->Flags & PSPF_RENDERSTYLE)
-			{
-				const int rs = clamp<int>(pspr->RenderStyle, 0, STYLE_Count);
-
-				if (pspr->Flags & PSPF_FORCESTYLE)
-				{
-					vis.RenderStyle = LegacyRenderStyles[rs];
-				}
-				else if (owner->RenderStyle == LegacyRenderStyles[STYLE_Fuzzy])
-				{
-					vis.RenderStyle = LegacyRenderStyles[STYLE_Fuzzy];
-				}
-				else if (owner->RenderStyle == LegacyRenderStyles[STYLE_OptFuzzy])
-				{
-					vis.RenderStyle = LegacyRenderStyles[STYLE_OptFuzzy];
-					vis.RenderStyle.CheckFuzz();
-				}
-				else if (owner->RenderStyle == LegacyRenderStyles[STYLE_Subtract])
-				{
-					vis.RenderStyle = LegacyRenderStyles[STYLE_Subtract];
-				}
-				else
-				{
-					vis.RenderStyle = LegacyRenderStyles[rs];
-				}
-			}
-			else
-			{
-				vis.RenderStyle = owner->RenderStyle;
-			}
-
-			// Set the alpha based on if using the overlay's own or not. Also adjust
-			// and override the alpha if not forced.
-			if (pspr->Flags & PSPF_ALPHA)
-			{
-				if (vis.RenderStyle == LegacyRenderStyles[STYLE_Fuzzy])
-				{
-					alpha = owner->Alpha;
-				}
-				else if (vis.RenderStyle == LegacyRenderStyles[STYLE_OptFuzzy])
-				{
-					FRenderStyle style = vis.RenderStyle;
-					style.CheckFuzz();
-					switch (style.BlendOp)
-					{
-					default:
-						alpha = pspr->alpha * owner->Alpha;
-						break;
-					case STYLEOP_Fuzz:
-					case STYLEOP_Sub:
-						alpha = owner->Alpha;
-						break;
-					}
-
-				}
-				else if (vis.RenderStyle == LegacyRenderStyles[STYLE_Subtract])
-				{
-					alpha = owner->Alpha;
-				}
-				else if (vis.RenderStyle == LegacyRenderStyles[STYLE_Add] ||
-					vis.RenderStyle == LegacyRenderStyles[STYLE_Translucent] ||
-					vis.RenderStyle == LegacyRenderStyles[STYLE_TranslucentStencil] ||
-					vis.RenderStyle == LegacyRenderStyles[STYLE_AddStencil] ||
-					vis.RenderStyle == LegacyRenderStyles[STYLE_AddShaded])
-				{
-					alpha = owner->Alpha * pspr->alpha;
-				}
-				else
-				{
-					alpha = owner->Alpha;
-				}
-			}
-
-			// Should normal renderstyle come out on top at the end and we desire alpha,
-			// switch it to translucent. Normal never applies any sort of alpha.
-			if ((pspr->Flags & PSPF_ALPHA) &&
-				vis.RenderStyle == LegacyRenderStyles[STYLE_Normal] &&
-				vis.Alpha < 1.0)
-			{
-				vis.RenderStyle = LegacyRenderStyles[STYLE_Translucent];
-				alpha = owner->Alpha * pspr->alpha;
-			}
-
-			// ALWAYS take priority if asked for, except fuzz. Fuzz does absolutely nothing
-			// no matter what way it's changed.
-			if (pspr->Flags & PSPF_FORCEALPHA)
-			{
-				//Due to lack of != operators...
-				if (vis.RenderStyle == LegacyRenderStyles[STYLE_Fuzzy] ||
-					vis.RenderStyle == LegacyRenderStyles[STYLE_SoulTrans] ||
-					vis.RenderStyle == LegacyRenderStyles[STYLE_Stencil])
-				{
-				}
-				else
-				{
-					alpha = pspr->alpha;
-					vis.RenderStyle.Flags |= STYLEF_ForceAlpha;
-				}
-			}
-			vis.Alpha = clamp<float>(float(alpha), 0.f, 1.f);
-
-			// Due to how some of the effects are handled, going to 0 or less causes some
-			// weirdness to display. There's no point rendering it anyway if it's 0.
-			if (vis.Alpha <= 0.)
+			if (!vis.RenderStyle.IsVisible(vis.Alpha))
 				return;
 
 			//-----------------------------------------------------------------------------
@@ -455,9 +355,9 @@ namespace swrenderer
 				
 				Thread->Viewport->viewpoint.camera->Inventory->AlterWeaponSprite(&visstyle);
 				
-				vis.Alpha = visstyle.Alpha;
+				if (!(pspr->Flags & PSPF_FORCEALPHA)) vis.Alpha = visstyle.Alpha;
 
-				if (visstyle.RenderStyle != STYLE_Count)
+				if (visstyle.RenderStyle != STYLE_Count && !(pspr->Flags & PSPF_FORCESTYLE))
 				{
 					vis.RenderStyle = visstyle.RenderStyle;
 				}
diff --git a/src/swrenderer/viewport/r_spritedrawer.cpp b/src/swrenderer/viewport/r_spritedrawer.cpp
index 116a5037bb..006af41b13 100644
--- a/src/swrenderer/viewport/r_spritedrawer.cpp
+++ b/src/swrenderer/viewport/r_spritedrawer.cpp
@@ -393,11 +393,7 @@ namespace swrenderer
 			color = 0;
 		}
 
-		if (style.Flags & STYLEF_ForceAlpha)
-		{
-			alpha = clamp<fixed_t>(alpha, 0, OPAQUE);
-		}
-		else if (style.Flags & STYLEF_TransSoulsAlpha)
+		if (style.Flags & STYLEF_TransSoulsAlpha)
 		{
 			alpha = fixed_t(transsouls * OPAQUE);
 		}
diff --git a/wadsrc/static/zscript/shared/player.txt b/wadsrc/static/zscript/shared/player.txt
index 20b2b320aa..43c01044f5 100644
--- a/wadsrc/static/zscript/shared/player.txt
+++ b/wadsrc/static/zscript/shared/player.txt
@@ -223,7 +223,7 @@ class PSprite : Object native play
 	native readonly PlayerInfo Owner;
 	native SpriteID Sprite;
 	native int Frame;
-	native readonly int RenderStyle;
+	//native readonly int RenderStyle;	had to be blocked because the internal representation was not ok. Renderstyle is still pending a proper solution.
 	native readonly int ID;
 	native Bool processPending;
 	native double x;

From 259e3127feef079e75d7eb14eff6ceb3dc9b619c Mon Sep 17 00:00:00 2001
From: Major Cooke <paul.growney22@gmail.com>
Date: Sat, 15 Apr 2017 09:33:04 -0500
Subject: [PATCH 07/29] - Fixed crash with corpse queueing.

---
 src/g_shared/a_action.cpp | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/src/g_shared/a_action.cpp b/src/g_shared/a_action.cpp
index 627c7323de..a15628cb40 100644
--- a/src/g_shared/a_action.cpp
+++ b/src/g_shared/a_action.cpp
@@ -125,16 +125,19 @@ DCorpsePointer::DCorpsePointer (AActor *ptr)
 	TThinkerIterator<DCorpsePointer> iterator (STAT_CORPSEPOINTER);
 	DCorpsePointer *first = iterator.Next ();
 
-	if (first != this)
+	if (first != nullptr)
 	{
-		if (first->Count >= (uint32_t)sv_corpsequeuesize)
+		if (first != this)
 		{
-			DCorpsePointer *next = iterator.Next ();
-			first->Destroy ();
-			first = next;
+			if (first->Count >= (uint32_t)sv_corpsequeuesize)
+			{
+				DCorpsePointer *next = iterator.Next();
+				first->Destroy();
+				first = next;
+			}
 		}
+		++first->Count;
 	}
-	++first->Count;
 }
 
 void DCorpsePointer::OnDestroy ()

From 47bcd8aaa2f8f54bb9d148611da33256c57ea5a3 Mon Sep 17 00:00:00 2001
From: Christoph Oelckers <coelckers@users.noreply.github.com>
Date: Sat, 15 Apr 2017 17:25:46 +0200
Subject: [PATCH 08/29] - added per-layer translucency support to the OpenGL
 PSprite drawer.

---
 src/gl/scene/gl_weapon.cpp | 114 +++++++++++++++++++------------------
 1 file changed, 59 insertions(+), 55 deletions(-)

diff --git a/src/gl/scene/gl_weapon.cpp b/src/gl/scene/gl_weapon.cpp
index c0dc250f71..2d2d827c63 100644
--- a/src/gl/scene/gl_weapon.cpp
+++ b/src/gl/scene/gl_weapon.cpp
@@ -307,38 +307,47 @@ void GLSceneDrawer::DrawPlayerSprites(sector_t * viewsector, bool hudModelStep)
 		lightlevel = 255;
 	}
 
-	PalEntry ThingColor = (playermo->RenderStyle.Flags & STYLEF_ColorIsFixed) ? playermo->fillcolor : 0xffffff;
-	ThingColor.a = 255;
+	gl_RenderState.AlphaFunc(GL_GEQUAL, gl_mask_sprite_threshold);
 
-	visstyle_t vis;
+	// hack alert! Rather than changing everything in the underlying lighting code let's just temporarily change
+	// light mode here to draw the weapon sprite.
+	int oldlightmode = glset.lightmode;
+	if (glset.lightmode == 8) glset.lightmode = 2;
 
-	vis.RenderStyle = STYLE_Count;
-	vis.Alpha = playermo->Alpha;
-	vis.Invert = false;
-	playermo->AlterWeaponSprite(&vis);
-	
-	FRenderStyle RenderStyle;
-	if (vis.RenderStyle == STYLE_Count) RenderStyle = playermo->RenderStyle;
-	else RenderStyle = vis.RenderStyle;
-
-	if (vis.Invert)
+	for(DPSprite *psp = player->psprites; psp != nullptr && psp->GetID() < PSP_TARGETCENTER; psp = psp->GetNext())
 	{
-		// this only happens for Strife's inverted weapon sprite
-		RenderStyle.Flags |= STYLEF_InvertSource;
-	}
-	if (RenderStyle.AsDWORD == 0)
-	{
-		// This is RenderStyle None.
-		return;
-	}
+		auto rs = psp->GetRenderStyle(playermo->RenderStyle, playermo->Alpha);
 
-	// Set the render parameters
+		visstyle_t vis;
+		float trans = 0.f;
 
-	int OverrideShader = -1;
-	float trans = 0.f;
-	if (RenderStyle.BlendOp >= STYLEOP_Fuzz && RenderStyle.BlendOp <= STYLEOP_FuzzOrRevSub)
-	{
-		RenderStyle.CheckFuzz();
+		vis.RenderStyle = STYLE_Count;
+		vis.Alpha = rs.second;
+		vis.Invert = false;
+		playermo->AlterWeaponSprite(&vis);
+
+		FRenderStyle RenderStyle;
+
+		if (!(psp->Flags & PSPF_FORCEALPHA)) trans = vis.Alpha;
+
+		if (vis.RenderStyle != STYLE_Count && !(psp->Flags & PSPF_FORCESTYLE))
+		{
+			RenderStyle = vis.RenderStyle;
+		}
+		else
+		{
+			RenderStyle = rs.first;
+		}
+
+		if (vis.Invert)
+		{
+			// this only happens for Strife's inverted weapon sprite
+			RenderStyle.Flags |= STYLEF_InvertSource;
+		}
+
+		// Set the render parameters
+
+		int OverrideShader = -1;
 		if (RenderStyle.BlendOp == STYLEOP_Fuzz)
 		{
 			if (gl_fuzztype != 0)
@@ -353,40 +362,35 @@ void GLSceneDrawer::DrawPlayerSprites(sector_t * viewsector, bool hudModelStep)
 				RenderStyle.BlendOp = STYLEOP_Shadow;
 			}
 		}
-	}
 
-	gl_SetRenderStyle(RenderStyle, false, false);
+		gl_SetRenderStyle(RenderStyle, false, false);
 
-	if (RenderStyle.Flags & STYLEF_TransSoulsAlpha)
-	{
-		trans = transsouls;
-	}
-	else if (RenderStyle.Flags & STYLEF_Alpha1)
-	{
-		trans = 1.f;
-	}
-	else if (trans == 0.f)
-	{
-		trans = vis.Alpha;
-	}
+		if (RenderStyle.Flags & STYLEF_TransSoulsAlpha)
+		{
+			trans = transsouls;
+		}
+		else if (RenderStyle.Flags & STYLEF_Alpha1)
+		{
+			trans = 1.f;
+		}
+		else if (trans == 0.f)
+		{
+			trans = vis.Alpha;
+		}
 
-	// now draw the different layers of the weapon
-	gl_RenderState.EnableBrightmap(true);
-	PalEntry finalcol(ThingColor.a,
-		ThingColor.r * viewsector->SpecialColors[sector_t::sprites].r / 255,
-		ThingColor.g * viewsector->SpecialColors[sector_t::sprites].g / 255,
-		ThingColor.b * viewsector->SpecialColors[sector_t::sprites].b / 255);
+		PalEntry ThingColor = (playermo->RenderStyle.Flags & STYLEF_ColorIsFixed) ? playermo->fillcolor : 0xffffff;
+		ThingColor.a = 255;
 
-	gl_RenderState.SetObjectColor(finalcol);
-	gl_RenderState.AlphaFunc(GL_GEQUAL, gl_mask_sprite_threshold);
+		// now draw the different layers of the weapon.
+		// For stencil render styles brightmaps need to be disabled.
+		gl_RenderState.EnableBrightmap(!(RenderStyle.Flags & STYLEF_ColorIsFixed));
+		PalEntry finalcol(ThingColor.a,
+			ThingColor.r * viewsector->SpecialColors[sector_t::sprites].r / 255,
+			ThingColor.g * viewsector->SpecialColors[sector_t::sprites].g / 255,
+			ThingColor.b * viewsector->SpecialColors[sector_t::sprites].b / 255);
 
-	// hack alert! Rather than changing everything in the underlying lighting code let's just temporarily change
-	// light mode here to draw the weapon sprite.
-	int oldlightmode = glset.lightmode;
-	if (glset.lightmode == 8) glset.lightmode = 2;
+		gl_RenderState.SetObjectColor(finalcol);
 
-	for(DPSprite *psp = player->psprites; psp != nullptr && psp->GetID() < PSP_TARGETCENTER; psp = psp->GetNext())
-	{
 		if (psp->GetState() != nullptr) 
 		{
 			FColormap cmc = cm;

From 4f67dc4f016c3e62fec838130def42e7affca297 Mon Sep 17 00:00:00 2001
From: Christoph Oelckers <coelckers@users.noreply.github.com>
Date: Sat, 15 Apr 2017 19:07:13 +0200
Subject: [PATCH 09/29] - fixed: DCorpsePointer's constructor was doing nasty
 stuff while the object wasn't fully set up yet.

---
 src/g_shared/a_action.cpp | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/g_shared/a_action.cpp b/src/g_shared/a_action.cpp
index a15628cb40..fe4ab9d4b0 100644
--- a/src/g_shared/a_action.cpp
+++ b/src/g_shared/a_action.cpp
@@ -85,6 +85,7 @@ class DCorpsePointer : public DThinker
 	HAS_OBJECT_POINTERS
 public:
 	DCorpsePointer (AActor *ptr);
+	void Queue();
 	void OnDestroy() override;
 	void Serialize(FSerializer &arc);
 	TObjPtr<AActor*> Corpse;
@@ -115,11 +116,14 @@ CUSTOM_CVAR(Int, sv_corpsequeuesize, 64, CVAR_ARCHIVE|CVAR_SERVERINFO)
 }
 
 
-DCorpsePointer::DCorpsePointer (AActor *ptr)
-: DThinker (STAT_CORPSEPOINTER), Corpse (ptr)
+DCorpsePointer::DCorpsePointer(AActor *ptr)
+	: DThinker(STAT_CORPSEPOINTER), Corpse(ptr)
 {
 	Count = 0;
+}
 
+void DCorpsePointer::Queue()
+{
 	// Thinkers are added to the end of their respective lists, so
 	// the first thinker in the list is the oldest one.
 	TThinkerIterator<DCorpsePointer> iterator (STAT_CORPSEPOINTER);
@@ -184,7 +188,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_QueueCorpse)
 
 	if (sv_corpsequeuesize > 0)
 	{
-		Create<DCorpsePointer> (self);
+		auto p = Create<DCorpsePointer> (self);
+		p->Queue();
 	}
 	return 0;
 }

From ba5721f98a0efce8310d89f18ad10cf45d98bd90 Mon Sep 17 00:00:00 2001
From: Christoph Oelckers <coelckers@users.noreply.github.com>
Date: Sun, 16 Apr 2017 01:36:53 +0200
Subject: [PATCH 10/29] - rewrote the OPL middle layer to remove the MusLib
 code.

The new version keeps the non-MusLib code of both files and replaces most of the rest with code from Chocolate Doom.
---
 src/CMakeLists.txt                            |   4 +-
 .../mididevices/music_opl_mididevice.cpp      |  73 +--
 .../music_opldumper_mididevice.cpp            |  10 +-
 src/sound/musicformats/music_opl.cpp          |   2 +-
 src/sound/oplsynth/dosbox/opl.cpp             |   2 +-
 src/sound/oplsynth/fmopl.cpp                  |  14 +-
 src/sound/oplsynth/genmidi.h                  |  47 ++
 src/sound/oplsynth/mlopl.cpp                  | 485 -----------------
 src/sound/oplsynth/mlopl_io.cpp               | 380 --------------
 src/sound/oplsynth/musicblock.cpp             | 454 ++++++++++++++++
 src/sound/oplsynth/musicblock.h               |  58 +++
 src/sound/oplsynth/muslib.h                   | 267 ----------
 src/sound/oplsynth/nukedopl3.h                |   2 +-
 src/sound/oplsynth/opl.h                      |   2 +
 src/sound/oplsynth/opl_mus_player.cpp         |  24 +-
 src/sound/oplsynth/opl_mus_player.h           |   2 +
 src/sound/oplsynth/oplio.cpp                  | 493 ++++++++++++++++++
 src/sound/oplsynth/oplio.h                    | 110 ++++
 18 files changed, 1233 insertions(+), 1196 deletions(-)
 create mode 100644 src/sound/oplsynth/genmidi.h
 delete mode 100644 src/sound/oplsynth/mlopl.cpp
 delete mode 100644 src/sound/oplsynth/mlopl_io.cpp
 create mode 100644 src/sound/oplsynth/musicblock.cpp
 create mode 100644 src/sound/oplsynth/musicblock.h
 delete mode 100644 src/sound/oplsynth/muslib.h
 create mode 100644 src/sound/oplsynth/oplio.cpp
 create mode 100644 src/sound/oplsynth/oplio.h

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index da79cd4086..54dce36caf 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1256,8 +1256,8 @@ set (PCH_SOURCES
 	sound/musicformats/music_opl.cpp
 	sound/musicformats/music_stream.cpp
 	sound/oplsynth/fmopl.cpp
-	sound/oplsynth/mlopl.cpp
-	sound/oplsynth/mlopl_io.cpp
+	sound/oplsynth/musicblock.cpp
+	sound/oplsynth/oplio.cpp
 	sound/oplsynth/dosbox/opl.cpp
 	sound/oplsynth/OPL3.cpp
 	sound/oplsynth/nukedopl3.cpp
diff --git a/src/sound/mididevices/music_opl_mididevice.cpp b/src/sound/mididevices/music_opl_mididevice.cpp
index e61a5c10d0..fe09e0448f 100644
--- a/src/sound/mididevices/music_opl_mididevice.cpp
+++ b/src/sound/mididevices/music_opl_mididevice.cpp
@@ -83,7 +83,11 @@ OPLMIDIDevice::OPLMIDIDevice(const char *args)
 	OPL_SetCore(args);
 	FullPan = opl_fullpan;
 	FWadLump data = Wads.OpenLumpName("GENMIDI");
-	OPLloadBank(data);
+
+	uint8_t filehdr[8];
+	data.Read(filehdr, 8);
+	if (memcmp(filehdr, "#OPL_II#", 8)) I_Error("Corrupt GENMIDI lump");
+	data.Read(OPLinstruments, sizeof(genmidi_instr_t) * GENMIDI_NUM_TOTAL);
 	SampleRate = (int)OPL_SAMPLE_RATE;
 }
 
@@ -97,15 +101,15 @@ OPLMIDIDevice::OPLMIDIDevice(const char *args)
 
 int OPLMIDIDevice::Open(MidiCallback callback, void *userdata)
 {
-	if (io == NULL || 0 == (NumChips = io->OPLinit(opl_numchips, FullPan, true)))
+	if (io == NULL || 0 == (NumChips = io->Init(opl_numchips, FullPan, true)))
 	{
 		return 1;
 	}
 	int ret = OpenStream(14, (FullPan || io->IsOPL3) ? 0 : SoundStream::Mono, callback, userdata);
 	if (ret == 0)
 	{
-		OPLstopMusic();
-		OPLplayMusic(100);
+		stopAllVoices();
+		resetAllControllers(100);
 		DEBUGOUT("========= New song started ==========\n", 0, 0, 0);
 	}
 	return ret;
@@ -120,7 +124,7 @@ int OPLMIDIDevice::Open(MidiCallback callback, void *userdata)
 void OPLMIDIDevice::Close()
 {
 	SoftSynthMIDIDevice::Close();
-	io->OPLdeinit();
+	io->Reset();
 }
 
 //==========================================================================
@@ -176,7 +180,7 @@ void OPLMIDIDevice::HandleEvent(int status, int parm1, int parm2)
 	int command = status & 0xF0;
 	int channel = status & 0x0F;
 
-	// Swap channels 9 and 15, because their roles are reversed
+	// Swap voices 9 and 15, because their roles are reversed
 	// in MUS and MIDI formats.
 	if (channel == 9)
 	{
@@ -191,12 +195,12 @@ void OPLMIDIDevice::HandleEvent(int status, int parm1, int parm2)
 	{
 	case MIDI_NOTEOFF:
 		playingcount--;
-		OPLreleaseNote(channel, parm1);
+		noteOff(channel, parm1);
 		break;
 
 	case MIDI_NOTEON:
 		playingcount++;
-		OPLplayNote(channel, parm1, parm2);
+		noteOn(channel, parm1, parm2);
 		break;
 
 	case MIDI_POLYPRESS:
@@ -206,26 +210,27 @@ void OPLMIDIDevice::HandleEvent(int status, int parm1, int parm2)
 	case MIDI_CTRLCHANGE:
 		switch (parm1)
 		{
-		case 0:		OPLchangeControl(channel, ctrlBank, parm2);			break;
-		case 1:		OPLchangeControl(channel, ctrlModulation, parm2);	break;
-		case 6:		OPLchangeControl(channel, ctrlDataEntryHi, parm2);	break;
-		case 7:		OPLchangeControl(channel, ctrlVolume, parm2);		break;
-		case 10:	OPLchangeControl(channel, ctrlPan, parm2);			break;
-		case 11:	OPLchangeControl(channel, ctrlExpression, parm2);	break;
-		case 38:	OPLchangeControl(channel, ctrlDataEntryLo, parm2);	break;
-		case 64:	OPLchangeControl(channel, ctrlSustainPedal, parm2);	break;
-		case 67:	OPLchangeControl(channel, ctrlSoftPedal, parm2);	break;
-		case 91:	OPLchangeControl(channel, ctrlReverb, parm2);		break;
-		case 93:	OPLchangeControl(channel, ctrlChorus, parm2);		break;
-		case 98:	OPLchangeControl(channel, ctrlNRPNLo, parm2);		break;
-		case 99:	OPLchangeControl(channel, ctrlNRPNHi, parm2);		break;
-		case 100:	OPLchangeControl(channel, ctrlRPNLo, parm2);		break;
-		case 101:	OPLchangeControl(channel, ctrlRPNHi, parm2);		break;
-		case 120:	OPLchangeControl(channel, ctrlSoundsOff, parm2);	break;
-		case 121:	OPLresetControllers(channel, 100);					break;
-		case 123:	OPLchangeControl(channel, ctrlNotesOff, parm2);		break;
-		case 126:	OPLchangeControl(channel, ctrlMono, parm2);			break;
-		case 127:	OPLchangeControl(channel, ctrlPoly, parm2);			break;
+		// some controllers here get passed on but are not handled by the player.
+		//case 0:	changeBank(channel, parm2);							break;
+		case 1:		changeModulation(channel, parm2);					break;
+		case 6:		changeExtended(channel, ctrlDataEntryHi, parm2);	break;
+		case 7:		changeVolume(channel, parm2, false);				break;
+		case 10:	changePanning(channel, parm2);						break;
+		case 11:	changeVolume(channel, parm2, true);					break;
+		case 38:	changeExtended(channel, ctrlDataEntryLo, parm2);	break;
+		case 64:	changeSustain(channel, parm2);						break;
+		//case 67:	changeSoftPedal(channel, parm2);					break;
+		//case 91:	changeReverb(channel, parm2);						break;
+		//case 93:	changeChorus(channel, parm2);						break;
+		case 98:	changeExtended(channel, ctrlNRPNLo, parm2);			break;
+		case 99:	changeExtended(channel, ctrlNRPNHi, parm2);			break;
+		case 100:	changeExtended(channel, ctrlRPNLo, parm2);			break;
+		case 101:	changeExtended(channel, ctrlRPNHi, parm2);			break;
+		case 120:	allNotesOff(channel, parm2);						break;
+		case 121:	resetControllers(channel, 100);						break;
+		case 123:	notesOff(channel, parm2);							break;
+		//case 126:	changeMono(channel, parm2);							break;
+		//case 127:	changePoly(channel, parm2);							break;
 		default:
 			DEBUGOUT("Unhandled controller: Channel %d, controller %d, value %d\n", channel, parm1, parm2);
 			break;
@@ -233,7 +238,7 @@ void OPLMIDIDevice::HandleEvent(int status, int parm1, int parm2)
 		break;
 
 	case MIDI_PRGMCHANGE:
-		OPLprogramChange(channel, parm1);
+		programChange(channel, parm1);
 		break;
 
 	case MIDI_CHANPRESS:
@@ -241,7 +246,7 @@ void OPLMIDIDevice::HandleEvent(int status, int parm1, int parm2)
 		break;
 
 	case MIDI_PITCHBEND:
-		OPLpitchWheel(channel, parm1 | (parm2 << 7));
+		changePitch(channel, parm1, parm2);
 		break;
 	}
 }
@@ -289,17 +294,17 @@ FString OPLMIDIDevice::GetStats()
 {
 	FString out;
 	char star[3] = { TEXTCOLOR_ESCAPE, 'A', '*' };
-	for (uint32_t i = 0; i < io->OPLchannels; ++i)
+	for (uint32_t i = 0; i < io->NumChannels; ++i)
 	{
-		if (channels[i].flags & CH_FREE)
+		if (voices[i].index == -1)
 		{
 			star[1] = CR_BRICK + 'A';
 		}
-		else if (channels[i].flags & CH_SUSTAIN)
+		else if (voices[i].sustained)
 		{
 			star[1] = CR_ORANGE + 'A';
 		}
-		else if (channels[i].flags & CH_SECONDARY)
+		else if (voices[i].current_instr_voice == &voices[i].current_instr->voices[1])
 		{
 			star[1] = CR_BLUE + 'A';
 		}
diff --git a/src/sound/mididevices/music_opldumper_mididevice.cpp b/src/sound/mididevices/music_opldumper_mididevice.cpp
index cf7000d4c6..e301a30548 100644
--- a/src/sound/mididevices/music_opldumper_mididevice.cpp
+++ b/src/sound/mididevices/music_opldumper_mididevice.cpp
@@ -327,16 +327,16 @@ DiskWriterIO::DiskWriterIO(const char *filename)
 
 DiskWriterIO::~DiskWriterIO()
 {
-	OPLdeinit();
+	Reset();
 }
 
 //==========================================================================
 //
-// DiskWriterIO :: OPLinit
+// DiskWriterIO :: Init
 //
 //==========================================================================
 
-int DiskWriterIO::OPLinit(uint32_t numchips, bool, bool initopl3)
+int DiskWriterIO::Init(uint32_t numchips, bool, bool initopl3)
 {
 	FILE *file = fopen(Filename, "wb");
 	if (file == NULL)
@@ -357,10 +357,10 @@ int DiskWriterIO::OPLinit(uint32_t numchips, bool, bool initopl3)
 	{
 		chips[0] = new OPL_DOSBOXdump(file, numchips > 1);
 	}
-	OPLchannels = OPL2CHANNELS * numchips;
+	NumChannels = OPL_NUM_VOICES * numchips;
 	NumChips = numchips;
 	IsOPL3 = numchips > 1;
-	OPLwriteInitState(initopl3);
+	WriteInitState(initopl3);
 	return numchips;
 }
 
diff --git a/src/sound/musicformats/music_opl.cpp b/src/sound/musicformats/music_opl.cpp
index 85f4b815b9..0f949fae00 100644
--- a/src/sound/musicformats/music_opl.cpp
+++ b/src/sound/musicformats/music_opl.cpp
@@ -32,7 +32,7 @@
 */
 
 #include "i_musicinterns.h"
-#include "oplsynth/muslib.h"
+#include "oplsynth/musicblock.h"
 #include "oplsynth/opl.h"
 
 static bool OPL_Active;
diff --git a/src/sound/oplsynth/dosbox/opl.cpp b/src/sound/oplsynth/dosbox/opl.cpp
index 25b4462109..67fcefc0be 100644
--- a/src/sound/oplsynth/dosbox/opl.cpp
+++ b/src/sound/oplsynth/dosbox/opl.cpp
@@ -26,7 +26,7 @@
 
 #include "doomtype.h"
 #include "../opl.h"
-#include "../muslib.h"
+#include "../musicblock.h"
 #include <math.h>
 #include "m_random.h"
 
diff --git a/src/sound/oplsynth/fmopl.cpp b/src/sound/oplsynth/fmopl.cpp
index 0e270e6f5f..1bbd74dc48 100644
--- a/src/sound/oplsynth/fmopl.cpp
+++ b/src/sound/oplsynth/fmopl.cpp
@@ -1311,7 +1311,7 @@ static inline void set_sl_rr(FM_OPL *OPL,int slot,int v)
 
 
 /* write a value v to register r on OPL chip */
-static void OPLWriteReg(FM_OPL *OPL, int r, int v)
+static void WriteRegister(FM_OPL *OPL, int r, int v)
 {
 	OPL_CH *CH;
 	int slot;
@@ -1523,11 +1523,11 @@ static void OPLResetChip(FM_OPL *OPL)
 	OPL_STATUS_RESET(OPL,0x7f);
 
 	/* reset with register write */
-	OPLWriteReg(OPL,0x01,0); /* wavesel disable */
-	OPLWriteReg(OPL,0x02,0); /* Timer1 */
-	OPLWriteReg(OPL,0x03,0); /* Timer2 */
-	OPLWriteReg(OPL,0x04,0); /* IRQ mask clear */
-	for(i = 0xff ; i >= 0x20 ; i-- ) OPLWriteReg(OPL,i,0);
+	WriteRegister(OPL,0x01,0); /* wavesel disable */
+	WriteRegister(OPL,0x02,0); /* Timer1 */
+	WriteRegister(OPL,0x03,0); /* Timer2 */
+	WriteRegister(OPL,0x04,0); /* IRQ mask clear */
+	for(i = 0xff ; i >= 0x20 ; i-- ) WriteRegister(OPL,i,0);
 
 	/* reset operator parameters */
 	for( c = 0 ; c < 9 ; c++ )
@@ -1569,7 +1569,7 @@ public:
 	/* YM3812 I/O interface */
 	void WriteReg(int reg, int v)
 	{
-		OPLWriteReg(&Chip, reg & 0xff, v);
+		WriteRegister(&Chip, reg & 0xff, v);
 	}
 
 	void Reset()
diff --git a/src/sound/oplsynth/genmidi.h b/src/sound/oplsynth/genmidi.h
new file mode 100644
index 0000000000..76ac26a96d
--- /dev/null
+++ b/src/sound/oplsynth/genmidi.h
@@ -0,0 +1,47 @@
+#include "doomtype.h"
+
+#pragma pack(push, 1)
+struct genmidi_op_t
+{
+	uint8_t tremolo;
+	uint8_t attack;
+	uint8_t sustain;
+	uint8_t waveform;
+	uint8_t scale;
+	uint8_t level;
+} FORCE_PACKED;
+
+struct genmidi_voice_t
+{
+	genmidi_op_t modulator;
+	uint8_t feedback;
+	genmidi_op_t carrier;
+	uint8_t unused;
+	int16_t base_note_offset;
+} FORCE_PACKED;
+
+
+struct genmidi_instr_t
+{
+	uint16_t flags;
+	uint8_t fine_tuning;
+	uint8_t fixed_note;
+	genmidi_voice_t voices[2];
+} FORCE_PACKED;
+
+#pragma pack(pop)
+
+enum
+{
+	GENMIDI_FLAG_FIXED = 0x0001,         /* fixed pitch */
+	GENMIDI_FLAG_2VOICE = 0x0004         /* double voice (OPL3) */
+};
+
+enum
+{
+	GENMIDI_NUM_INSTRS = 128,
+	GENMIDI_FIST_PERCUSSION = 35,
+	GENMIDI_NUM_PERCUSSION = 47,
+	GENMIDI_NUM_TOTAL = GENMIDI_NUM_INSTRS + GENMIDI_NUM_PERCUSSION
+};
+
diff --git a/src/sound/oplsynth/mlopl.cpp b/src/sound/oplsynth/mlopl.cpp
deleted file mode 100644
index 87cd7f450f..0000000000
--- a/src/sound/oplsynth/mlopl.cpp
+++ /dev/null
@@ -1,485 +0,0 @@
-/*
-*	Name:		OPL2/OPL3 Music driver
-*	Project:	MUS File Player Library
-*	Version:	1.67
-*	Author:		Vladimir Arnost (QA-Software)
-*	Last revision:	May-2-1996
-*	Compiler:	Borland C++ 3.1, Watcom C/C++ 10.0
-*
-*/
-
-/*
-* Revision History:
-*
-*	Aug-8-1994	V1.00	V.Arnost
-*		Written from scratch
-*	Aug-9-1994	V1.10	V.Arnost
-*		Some minor changes to improve sound quality. Tried to add
-*		stereo sound capabilities, but failed to -- my SB Pro refuses
-*		to switch to stereo mode.
-*	Aug-13-1994	V1.20	V.Arnost
-*		Stereo sound fixed. Now works also with Sound Blaster Pro II
-*		(chip OPL3 -- gives 18 "stereo" (ahem) channels).
-*		Changed code to handle properly notes without volume.
-*		(Uses previous volume on given channel.)
-*		Added cyclic channel usage to avoid annoying clicking noise.
-*	Aug-28-1994	V1.40	V.Arnost
-*		Added Adlib and SB Pro II detection.
-*	Apr-16-1995	V1.60	V.Arnost
-*		Moved into separate source file MUSLIB.C
-*	Jul-12-1995	V1.62	V.Arnost
-*		Module created and source code copied from MUSLIB.C
-*	Aug-08-1995	V1.63	V.Arnost
-*		Modified to follow changes in MLOPL_IO.C
-*	Aug-13-1995	V1.64	V.Arnost
-*		Added OPLsendMIDI() function
-*	Sep-8-1995	V1.65	V.Arnost
-*		Added sustain pedal support.
-*		Improved pause/unpause functions. Now all notes are made
-*		silent (even released notes, which haven't sounded off yet).
-*	Mar-1-1996	V1.66	V.Arnost
-*		Cleaned up the source
-*	May-2-1996	V1.67	V.Arnost
-*		Added modulation wheel (vibrato) support
-*/
-
-#include <stdlib.h>
-#include <string.h>
-#ifdef _WIN32
-#include <io.h>
-#endif
-#include "muslib.h"
-#include "files.h"
-
-#include "c_cvars.h"
-
-#define MOD_MIN		40		/* vibrato threshold */
-
-
-//#define HIGHEST_NOTE 102
-#define HIGHEST_NOTE 127
-
-musicBlock::musicBlock ()
-{
-	memset (this, 0, sizeof(*this));
-}
-
-musicBlock::~musicBlock ()
-{
-	if (OPLinstruments != NULL) free(OPLinstruments);
-}
-
-void musicBlock::writeFrequency(uint32_t slot, uint32_t note, int pitch, uint32_t keyOn)
-{
-	io->OPLwriteFreq (slot, note, pitch, keyOn);
-}
-
-void musicBlock::writeModulation(uint32_t slot, struct OPL2instrument *instr, int state)
-{
-	if (state)
-		state = 0x40;	/* enable Frequency Vibrato */
-	io->OPLwriteChannel(0x20, slot,
-		(instr->feedback & 1) ? (instr->trem_vibr_1 | state) : instr->trem_vibr_1,
-		instr->trem_vibr_2 | state);
-}
-
-uint32_t musicBlock::calcVolume(uint32_t channelVolume, uint32_t channelExpression, uint32_t noteVolume)
-{
-	noteVolume = ((uint64_t)channelVolume * channelExpression * noteVolume) / (127*127);
-	if (noteVolume > 127)
-		return 127;
-	else
-		return noteVolume;
-}
-
-int musicBlock::occupyChannel(uint32_t slot, uint32_t channel,
-						 int note, int volume, struct OP2instrEntry *instrument, uint8_t secondary)
-{
-	struct OPL2instrument *instr;
-	struct channelEntry *ch = &channels[slot];
-
-	ch->channel = channel;
-	ch->note = note;
-	ch->flags = secondary ? CH_SECONDARY : 0;
-	if (driverdata.channelModulation[channel] >= MOD_MIN)
-		ch->flags |= CH_VIBRATO;
-	ch->time = MLtime;
-	if (volume == -1)
-		volume = driverdata.channelLastVolume[channel];
-	else
-		driverdata.channelLastVolume[channel] = volume;
-	ch->realvolume = calcVolume(driverdata.channelVolume[channel],
-		driverdata.channelExpression[channel], ch->volume = volume);
-	if (instrument->flags & FL_FIXED_PITCH)
-		note = instrument->note;
-	else if (channel == PERCUSSION)
-		note = 60;			// C-5
-	if (secondary && (instrument->flags & FL_DOUBLE_VOICE))
-		ch->finetune = (instrument->finetune - 0x80) >> 1;
-	else
-		ch->finetune = 0;
-	ch->pitch = ch->finetune + driverdata.channelPitch[channel];
-	if (secondary)
-		instr = &instrument->instr[1];
-	else
-		instr = &instrument->instr[0];
-	ch->instr = instr;
-	if (channel != PERCUSSION && !(instrument->flags & FL_FIXED_PITCH))
-	{
-		if ( (note += instr->basenote) < 0)
-			while ((note += 12) < 0) {}
-		else if (note > HIGHEST_NOTE)
-			while ((note -= 12) > HIGHEST_NOTE) {}
-	}
-	ch->realnote = note;
-
-	io->OPLwriteInstrument(slot, instr);
-	if (ch->flags & CH_VIBRATO)
-		writeModulation(slot, instr, 1);
-	io->OPLwritePan(slot, instr, driverdata.channelPan[channel]);
-	io->OPLwriteVolume(slot, instr, ch->realvolume);
-	writeFrequency(slot, note, ch->pitch, 1);
-	return slot;
-}
-
-int musicBlock::releaseChannel(uint32_t slot, uint32_t killed)
-{
-	struct channelEntry *ch = &channels[slot];
-	writeFrequency(slot, ch->realnote, ch->pitch, 0);
-	ch->channel |= CH_FREE;
-	ch->time = MLtime;
-	ch->flags = CH_FREE;
-	if (killed)
-	{
-		io->OPLwriteChannel(0x80, slot, 0x0F, 0x0F);  // release rate - fastest
-		io->OPLwriteChannel(0x40, slot, 0x3F, 0x3F);  // no volume
-	}
-	return slot;
-}
-
-int musicBlock::releaseSustain(uint32_t channel)
-{
-	uint32_t i;
-	uint32_t id = channel;
-
-	for(i = 0; i < io->OPLchannels; i++)
-	{
-		if (channels[i].channel == id && channels[i].flags & CH_SUSTAIN)
-			releaseChannel(i, 0);
-	}
-	return 0;
-}
-
-int musicBlock::findFreeChannel(uint32_t flag, uint32_t channel, uint8_t note)
-{
-	uint32_t i;
-
-	uint32_t bestfit = 0;
-	uint32_t bestvoice = 0;
-
-	for (i = 0; i < io->OPLchannels; ++i)
-	{
-		uint32_t magic;
-
-		magic = ((channels[i].flags & CH_FREE) << 24) |
-				((channels[i].note == note &&
-					channels[i].channel == channel) << 30) |
-				((channels[i].flags & CH_SUSTAIN) << 28) |
-				((MLtime - channels[i].time) & 0x1fffffff);
-		if (magic > bestfit)
-		{
-			bestfit = magic;
-			bestvoice = i;
-		}
-	}
-	if ((flag & 1) && !(bestfit & 0x80000000))
-	{ // No free channels good enough
-		return -1;
-	}
-	releaseChannel (bestvoice, 1);
-	return bestvoice;
-}
-
-struct OP2instrEntry *musicBlock::getInstrument(uint32_t channel, uint8_t note)
-{
-	uint32_t instrnumber;
-
-	if (channel == PERCUSSION)
-	{
-		if (note < 35 || note > 81)
-			return NULL;		/* wrong percussion number */
-		instrnumber = note + (128-35);
-	}
-	else
-	{
-		instrnumber = driverdata.channelInstr[channel];
-	}
-
-	if (OPLinstruments)
-		return &OPLinstruments[instrnumber];
-	else
-		return NULL;
-}
-
-
-// code 1: play note
-CVAR (Bool, opl_singlevoice, 0, 0)
-
-void musicBlock::OPLplayNote(uint32_t channel, uint8_t note, int volume)
-{
-	int i;
-	struct OP2instrEntry *instr;
-
-	if (volume == 0)
-	{
-		OPLreleaseNote (channel, note);
-		return;
-	}
-
-	if ( (instr = getInstrument(channel, note)) == NULL )
-		return;
-
-	if ( (i = findFreeChannel((channel == PERCUSSION) ? 2 : 0, channel, note)) != -1)
-	{
-		occupyChannel(i, channel, note, volume, instr, 0);
-		if ((instr->flags & FL_DOUBLE_VOICE) && !opl_singlevoice)
-		{
-			if ( (i = findFreeChannel((channel == PERCUSSION) ? 3 : 1, channel, note)) != -1)
-				occupyChannel(i, channel, note, volume, instr, 1);
-		}
-	}
-}
-
-// code 0: release note
-void musicBlock::OPLreleaseNote(uint32_t channel, uint8_t note)
-{
-	uint32_t i;
-	uint32_t id = channel;
-	uint32_t sustain = driverdata.channelSustain[channel];
-
-	for(i = 0; i < io->OPLchannels; i++)
-	{
-		if (channels[i].channel == id && channels[i].note == note)
-		{
-			if (sustain < 0x40)
-				releaseChannel(i, 0);
-			else
-				channels[i].flags |= CH_SUSTAIN;
-		}
-	}
-}
-
-// code 2: change pitch wheel (bender)
-void musicBlock::OPLpitchWheel(uint32_t channel, int pitch)
-{
-	uint32_t i;
-	uint32_t id = channel;
-
-	// Convert pitch from 14-bit to 7-bit, then scale it, since the player
-	// code only understands sensitivities of 2 semitones.
-	pitch = (pitch - 8192) * driverdata.channelPitchSens[channel] / (200 * 128) + 64;
-	driverdata.channelPitch[channel] = pitch;
-	for(i = 0; i < io->OPLchannels; i++)
-	{
-		struct channelEntry *ch = &channels[i];
-		if (ch->channel == id)
-		{
-			ch->time = MLtime;
-			ch->pitch = ch->finetune + pitch;
-			writeFrequency(i, ch->realnote, ch->pitch, 1);
-		}
-	}
-}
-
-// code 4: change control
-void musicBlock::OPLchangeControl(uint32_t channel, uint8_t controller, int value)
-{
-	uint32_t i;
-	uint32_t id = channel;
-
-	switch (controller)
-	{
-	case ctrlPatch:			/* change instrument */
-		OPLprogramChange(channel, value);
-		break;
-
-	case ctrlModulation:
-		driverdata.channelModulation[channel] = value;
-		for(i = 0; i < io->OPLchannels; i++)
-		{
-			struct channelEntry *ch = &channels[i];
-			if (ch->channel == id)
-			{
-				uint8_t flags = ch->flags;
-				ch->time = MLtime;
-				if (value >= MOD_MIN)
-				{
-					ch->flags |= CH_VIBRATO;
-					if (ch->flags != flags)
-						writeModulation(i, ch->instr, 1);
-				} else {
-					ch->flags &= ~CH_VIBRATO;
-					if (ch->flags != flags)
-						writeModulation(i, ch->instr, 0);
-				}
-			}
-		}
-		break;
-
-	case ctrlVolume:		/* change volume */
-		driverdata.channelVolume[channel] = value;
-		/* fall-through */
-	case ctrlExpression:	/* change expression */
-		if (controller == ctrlExpression)
-		{
-			driverdata.channelExpression[channel] = value;
-		}
-		for(i = 0; i < io->OPLchannels; i++)
-		{
-			struct channelEntry *ch = &channels[i];
-			if (ch->channel == id)
-			{
-				ch->time = MLtime;
-				ch->realvolume = calcVolume(driverdata.channelVolume[channel],
-					driverdata.channelExpression[channel], ch->volume);
-				io->OPLwriteVolume(i, ch->instr, ch->realvolume);
-			}
-		}
-		break;
-
-	case ctrlPan:			/* change pan (balance) */
-		driverdata.channelPan[channel] = value -= 64;
-		for(i = 0; i < io->OPLchannels; i++)
-		{
-			struct channelEntry *ch = &channels[i];
-			if (ch->channel == id)
-			{
-				ch->time = MLtime;
-				io->OPLwritePan(i, ch->instr, value);
-			}
-		}
-		break;
-
-	case ctrlSustainPedal:		/* change sustain pedal (hold) */
-		driverdata.channelSustain[channel] = value;
-		if (value < 0x40)
-			releaseSustain(channel);
-		break;
-
-	case ctrlNotesOff:			/* turn off all notes that are not sustained */
-		for (i = 0; i < io->OPLchannels; ++i)
-		{
-			if (channels[i].channel == id)
-			{
-				if (driverdata.channelSustain[id] < 0x40)
-					releaseChannel(i, 0);
-				else
-					channels[i].flags |= CH_SUSTAIN;
-			}
-		}
-		break;
-
-	case ctrlSoundsOff:			/* release all notes for this channel */
-		for (i = 0; i < io->OPLchannels; ++i)
-		{
-			if (channels[i].channel == id)
-			{
-				releaseChannel(i, 0);
-			}
-		}
-		break;
-
-	case ctrlRPNHi:
-		driverdata.channelRPN[id] = (driverdata.channelRPN[id] & 0x007F) | (value << 7);
-		break;
-
-	case ctrlRPNLo:
-		driverdata.channelRPN[id] = (driverdata.channelRPN[id] & 0x3F80) | value;
-		break;
-
-	case ctrlNRPNLo:
-	case ctrlNRPNHi:
-		driverdata.channelRPN[id] = 0x3FFF;
-		break;
-
-	case ctrlDataEntryHi:
-		if (driverdata.channelRPN[id] == 0)
-		{
-			driverdata.channelPitchSens[id] = value * 100 + (driverdata.channelPitchSens[id] % 100);
-		}
-		break;
-
-	case ctrlDataEntryLo:
-		if (driverdata.channelRPN[id] == 0)
-		{
-			driverdata.channelPitchSens[id] = value + (driverdata.channelPitchSens[id] / 100) * 100;
-		}
-		break;
-	}
-}
-
-void musicBlock::OPLresetControllers(uint32_t chan, int vol)
-{
-	driverdata.channelVolume[chan] = vol;
-	driverdata.channelExpression[chan] = 127;
-	driverdata.channelSustain[chan] = 0;
-	driverdata.channelLastVolume[chan] = 64;
-	driverdata.channelPitch[chan] = 64;
-	driverdata.channelRPN[chan] = 0x3fff;
-	driverdata.channelPitchSens[chan] = 200;
-}
-
-void musicBlock::OPLprogramChange(uint32_t channel, int value)
-{
-	driverdata.channelInstr[channel] = value;
-}
-
-void musicBlock::OPLplayMusic(int vol)
-{
-	uint32_t i;
-
-	for (i = 0; i < CHANNELS; i++)
-	{
-		OPLresetControllers(i, vol);
-	}
-}
-
-void musicBlock::OPLstopMusic()
-{
-	uint32_t i;
-	for(i = 0; i < io->OPLchannels; i++)
-		if (!(channels[i].flags & CH_FREE))
-			releaseChannel(i, 1);
-}
-
-int musicBlock::OPLloadBank (FileReader &data)
-{
-	static const uint8_t masterhdr[8] = { '#','O','P','L','_','I','I','#' };
-	struct OP2instrEntry *instruments;
-
-	uint8_t filehdr[8];
-
-	data.Read (filehdr, 8);
-	if (memcmp(filehdr, masterhdr, 8))
-		return -2;			/* bad instrument file */
-	if ( (instruments = (struct OP2instrEntry *)calloc(OP2INSTRCOUNT, OP2INSTRSIZE)) == NULL)
-		return -3;			/* not enough memory */
-	data.Read (instruments, OP2INSTRSIZE * OP2INSTRCOUNT);
-	if (OPLinstruments != NULL)
-	{
-		free(OPLinstruments);
-	}
-	OPLinstruments = instruments;
-#if 0
-	for (int i = 0; i < 175; ++i)
-	{
-		Printf ("%3d.%-33s%3d %3d %3d %d\n", i,
-			(uint8_t *)data+6308+i*32,
-			OPLinstruments[i].instr[0].basenote,
-			OPLinstruments[i].instr[1].basenote,
-			OPLinstruments[i].note,
-			OPLinstruments[i].flags);
-	}
-#endif
-	return 0;
-}
diff --git a/src/sound/oplsynth/mlopl_io.cpp b/src/sound/oplsynth/mlopl_io.cpp
deleted file mode 100644
index ef89bfc271..0000000000
--- a/src/sound/oplsynth/mlopl_io.cpp
+++ /dev/null
@@ -1,380 +0,0 @@
-/*
-*	Name:		Low-level OPL2/OPL3 I/O interface
-*	Project:	MUS File Player Library
-*	Version:	1.64
-*	Author:		Vladimir Arnost (QA-Software)
-*	Last revision:	Mar-1-1996
-*	Compiler:	Borland C++ 3.1, Watcom C/C++ 10.0
-*
-*/
-
-/*
-* Revision History:
-*
-*	Aug-8-1994	V1.00	V.Arnost
-*		Written from scratch
-*	Aug-9-1994	V1.10	V.Arnost
-*		Added stereo capabilities
-*	Aug-13-1994	V1.20	V.Arnost
-*		Stereo capabilities made functional
-*	Aug-24-1994	V1.30	V.Arnost
-*		Added Adlib and SB Pro II detection
-*	Oct-30-1994	V1.40	V.Arnost
-*		Added BLASTER variable parsing
-*	Apr-14-1995	V1.50	V.Arnost
-*              Some declarations moved from adlib.h to doomtype.h
-*	Jul-22-1995	V1.60	V.Arnost
-*		Ported to Watcom C
-*		Simplified WriteChannel() and WriteValue()
-*	Jul-24-1995	V1.61	V.Arnost
-*		DetectBlaster() moved to MLMISC.C
-*	Aug-8-1995	V1.62	V.Arnost
-*		Module renamed to MLOPL_IO.C and functions renamed to OPLxxx
-*		Mixer-related functions moved to module MLSBMIX.C
-*	Sep-8-1995	V1.63	V.Arnost
-*		OPLwriteReg() routine sped up on OPL3 cards
-*	Mar-1-1996	V1.64	V.Arnost
-*		Cleaned up the source
-*/
-
-#include <math.h>
-#ifdef _WIN32
-#include <dos.h>
-#include <conio.h>
-#endif
-#include "muslib.h"
-#include "opl.h"
-#include "c_cvars.h"
-
-const double HALF_PI = (M_PI*0.5);
-
-EXTERN_CVAR(Int, opl_core)
-extern int current_opl_core;
-
-OPLio::~OPLio()
-{
-}
-
-void OPLio::SetClockRate(double samples_per_tick)
-{
-}
-
-void OPLio::WriteDelay(int ticks)
-{
-}
-
-void OPLio::OPLwriteReg(int which, uint32_t reg, uint8_t data)
-{
-	if (IsOPL3)
-	{
-		reg |= (which & 1) << 8;
-		which >>= 1;
-	}
-	if (chips[which] != NULL)
-	{
-		chips[which]->WriteReg(reg, data);
-	}
-}
-
-/*
-* Write to an operator pair. To be used for register bases of 0x20, 0x40,
-* 0x60, 0x80 and 0xE0.
-*/
-void OPLio::OPLwriteChannel(uint32_t regbase, uint32_t channel, uint8_t data1, uint8_t data2)
-{
-	static const uint32_t op_num[OPL2CHANNELS] = {
-		0x00, 0x01, 0x02, 0x08, 0x09, 0x0A, 0x10, 0x11, 0x12};
-
-	uint32_t which = channel / OPL2CHANNELS;
-	uint32_t reg = regbase + op_num[channel % OPL2CHANNELS];
-	OPLwriteReg (which, reg, data1);
-	OPLwriteReg (which, reg+3, data2);
-}
-
-/*
-* Write to channel a single value. To be used for register bases of
-* 0xA0, 0xB0 and 0xC0.
-*/
-void OPLio::OPLwriteValue(uint32_t regbase, uint32_t channel, uint8_t value)
-{
-	uint32_t which = channel / OPL2CHANNELS;
-	uint32_t reg = regbase + (channel % OPL2CHANNELS);
-	OPLwriteReg (which, reg, value);
-}
-
-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,
-	0x140, 0x141, 0x142, 0x142, 0x143, 0x143, 0x144, 0x144, 0x145, 0x146, 0x146, 0x147,
-	0x147, 0x148, 0x149, 0x149, 0x14a, 0x14a, 0x14b, 0x14c, 0x14c, 0x14d, 0x14d, 0x14e,
-	0x14f, 0x14f, 0x150, 0x150, 0x151, 0x152, 0x152, 0x153, 0x153, 0x154, 0x155, 0x155,
-	0x156, 0x157, 0x157, 0x158, 0x158, 0x159, 0x15a, 0x15a, 0x15b, 0x15b, 0x15c, 0x15d,
-	0x15d, 0x15e, 0x15f, 0x15f, 0x160, 0x161, 0x161, 0x162, 0x162, 0x163, 0x164, 0x164,
-	0x165, 0x166, 0x166, 0x167, 0x168, 0x168, 0x169, 0x16a, 0x16a, 0x16b, 0x16c, 0x16c,
-	0x16d, 0x16e, 0x16e, 0x16f, 0x170, 0x170, 0x171, 0x172, 0x172, 0x173, 0x174, 0x174,
-	0x175, 0x176, 0x176, 0x177, 0x178, 0x178, 0x179, 0x17a, 0x17a, 0x17b, 0x17c, 0x17c,
-	0x17d, 0x17e, 0x17e, 0x17f, 0x180, 0x181, 0x181, 0x182, 0x183, 0x183, 0x184, 0x185,
-	0x185, 0x186, 0x187, 0x188, 0x188, 0x189, 0x18a, 0x18a, 0x18b, 0x18c, 0x18d, 0x18d,
-	0x18e, 0x18f, 0x18f, 0x190, 0x191, 0x192, 0x192, 0x193, 0x194, 0x194, 0x195, 0x196,
-	0x197, 0x197, 0x198, 0x199, 0x19a, 0x19a, 0x19b, 0x19c, 0x19d, 0x19d, 0x19e, 0x19f,
-	0x1a0, 0x1a0, 0x1a1, 0x1a2, 0x1a3, 0x1a3, 0x1a4, 0x1a5, 0x1a6, 0x1a6, 0x1a7, 0x1a8,
-	0x1a9, 0x1a9, 0x1aa, 0x1ab, 0x1ac, 0x1ad, 0x1ad, 0x1ae, 0x1af, 0x1b0, 0x1b0, 0x1b1,
-	0x1b2, 0x1b3, 0x1b4, 0x1b4, 0x1b5, 0x1b6, 0x1b7, 0x1b8, 0x1b8, 0x1b9, 0x1ba, 0x1bb,
-	0x1bc, 0x1bc, 0x1bd, 0x1be, 0x1bf, 0x1c0, 0x1c0, 0x1c1, 0x1c2, 0x1c3, 0x1c4, 0x1c4,
-	0x1c5, 0x1c6, 0x1c7, 0x1c8, 0x1c9, 0x1c9, 0x1ca, 0x1cb, 0x1cc, 0x1cd, 0x1ce, 0x1ce,
-	0x1cf, 0x1d0, 0x1d1, 0x1d2, 0x1d3, 0x1d3, 0x1d4, 0x1d5, 0x1d6, 0x1d7, 0x1d8, 0x1d8,
-	0x1d9, 0x1da, 0x1db, 0x1dc, 0x1dd, 0x1de, 0x1de, 0x1df, 0x1e0, 0x1e1, 0x1e2, 0x1e3,
-	0x1e4, 0x1e5, 0x1e5, 0x1e6, 0x1e7, 0x1e8, 0x1e9, 0x1ea, 0x1eb, 0x1ec, 0x1ed, 0x1ed,
-	0x1ee, 0x1ef, 0x1f0, 0x1f1, 0x1f2, 0x1f3, 0x1f4, 0x1f5, 0x1f6, 0x1f6, 0x1f7, 0x1f8,
-	0x1f9, 0x1fa, 0x1fb, 0x1fc, 0x1fd, 0x1fe, 0x1ff, 0x200,
-	
-	0x201, 0x201, 0x202, 0x203, 0x204, 0x205, 0x206, 0x207, 0x208, 0x209, 0x20a, 0x20b, 0x20c, 0x20d, 0x20e, 0x20f,
-	0x210, 0x210, 0x211, 0x212, 0x213, 0x214, 0x215, 0x216, 0x217, 0x218, 0x219, 0x21a, 0x21b, 0x21c, 0x21d, 0x21e,
-	
-	0x21f, 0x220, 0x221, 0x222, 0x223, 0x224, 0x225, 0x226, 0x227, 0x228, 0x229, 0x22a, 0x22b, 0x22c, 0x22d, 0x22e,
-	0x22f, 0x230, 0x231, 0x232, 0x233, 0x234, 0x235, 0x236, 0x237, 0x238, 0x239, 0x23a, 0x23b, 0x23c, 0x23d, 0x23e,
-	
-	0x23f, 0x240, 0x241, 0x242, 0x244, 0x245, 0x246, 0x247, 0x248, 0x249, 0x24a, 0x24b, 0x24c, 0x24d, 0x24e, 0x24f,
-	0x250, 0x251, 0x252, 0x253, 0x254, 0x256, 0x257, 0x258, 0x259, 0x25a, 0x25b, 0x25c, 0x25d, 0x25e, 0x25f, 0x260,
-
-	0x262, 0x263, 0x264, 0x265, 0x266, 0x267, 0x268, 0x269, 0x26a, 0x26c, 0x26d, 0x26e, 0x26f, 0x270, 0x271, 0x272,
-	0x273, 0x275, 0x276, 0x277, 0x278, 0x279, 0x27a, 0x27b, 0x27d, 0x27e, 0x27f, 0x280, 0x281, 0x282, 0x284, 0x285,
-	
-	0x286, 0x287, 0x288, 0x289, 0x28b, 0x28c, 0x28d, 0x28e, 0x28f, 0x290, 0x292, 0x293, 0x294, 0x295, 0x296, 0x298,
-	0x299, 0x29a, 0x29b, 0x29c, 0x29e, 0x29f, 0x2a0, 0x2a1, 0x2a2, 0x2a4, 0x2a5, 0x2a6, 0x2a7, 0x2a9, 0x2aa, 0x2ab,
-	
-	0x2ac, 0x2ae, 0x2af, 0x2b0, 0x2b1, 0x2b2, 0x2b4, 0x2b5, 0x2b6, 0x2b7, 0x2b9, 0x2ba, 0x2bb, 0x2bd, 0x2be, 0x2bf,
-	0x2c0, 0x2c2, 0x2c3, 0x2c4, 0x2c5, 0x2c7, 0x2c8, 0x2c9, 0x2cb, 0x2cc, 0x2cd, 0x2ce, 0x2d0, 0x2d1, 0x2d2, 0x2d4,
-
-	0x2d5, 0x2d6, 0x2d8, 0x2d9, 0x2da, 0x2dc, 0x2dd, 0x2de, 0x2e0, 0x2e1, 0x2e2, 0x2e4, 0x2e5, 0x2e6, 0x2e8, 0x2e9,
-	0x2ea, 0x2ec, 0x2ed, 0x2ee, 0x2f0, 0x2f1, 0x2f2, 0x2f4, 0x2f5, 0x2f6, 0x2f8, 0x2f9, 0x2fb, 0x2fc, 0x2fd, 0x2ff,
-	
-	0x300, 0x302, 0x303, 0x304, 0x306, 0x307, 0x309, 0x30a, 0x30b, 0x30d, 0x30e, 0x310, 0x311, 0x312, 0x314, 0x315,
-	0x317, 0x318, 0x31a, 0x31b, 0x31c, 0x31e, 0x31f, 0x321, 0x322, 0x324, 0x325, 0x327, 0x328, 0x329, 0x32b, 0x32c,
-	
-	0x32e, 0x32f, 0x331, 0x332, 0x334, 0x335, 0x337, 0x338, 0x33a, 0x33b, 0x33d, 0x33e, 0x340, 0x341, 0x343, 0x344,
-	0x346, 0x347, 0x349, 0x34a, 0x34c, 0x34d, 0x34f, 0x350, 0x352, 0x353, 0x355, 0x357, 0x358, 0x35a, 0x35b, 0x35d,
-
-	0x35e, 0x360, 0x361, 0x363, 0x365, 0x366, 0x368, 0x369, 0x36b, 0x36c, 0x36e, 0x370, 0x371, 0x373, 0x374, 0x376,
-	0x378, 0x379, 0x37b, 0x37c, 0x37e, 0x380, 0x381, 0x383, 0x384, 0x386, 0x388, 0x389, 0x38b, 0x38d, 0x38e, 0x390,
-	
-	0x392, 0x393, 0x395, 0x397, 0x398, 0x39a, 0x39c, 0x39d, 0x39f, 0x3a1, 0x3a2, 0x3a4, 0x3a6, 0x3a7, 0x3a9, 0x3ab,
-	0x3ac, 0x3ae, 0x3b0, 0x3b1, 0x3b3, 0x3b5, 0x3b7, 0x3b8, 0x3ba, 0x3bc, 0x3bd, 0x3bf, 0x3c1, 0x3c3, 0x3c4, 0x3c6,
-	
-	0x3c8, 0x3ca, 0x3cb, 0x3cd, 0x3cf, 0x3d1, 0x3d2, 0x3d4, 0x3d6, 0x3d8, 0x3da, 0x3db, 0x3dd, 0x3df, 0x3e1, 0x3e3,
-	0x3e4, 0x3e6, 0x3e8, 0x3ea, 0x3ec, 0x3ed, 0x3ef, 0x3f1, 0x3f3, 0x3f5, 0x3f6, 0x3f8, 0x3fa, 0x3fc, 0x3fe, 0x36c
-};
-
-/*
-* Write frequency/octave/keyon data to a channel
-* [RH] This is totally different from the original MUS library code
-* but matches exactly what DMX does. I haven't a clue why there are 284
-* special bytes at the beginning of the table for the first few notes.
-* That last byte in the table doesn't look right, either, but that's what
-* it really is.
-*/
-void OPLio::OPLwriteFreq(uint32_t channel, uint32_t note, uint32_t pitch, uint32_t keyon)
-{
-	int octave = 0;
-	int j = (note << 5) + pitch;
-
-	if (j < 0)
-	{
-		j = 0;
-	}
-	else if (j >= 284)
-	{
-		j -= 284;
-		octave = j / (32*12);
-		if (octave > 7)
-		{
-			octave = 7;
-		}
-		j = (j % (32*12)) + 284;
-	}
-	int i = frequencies[j] | (octave << 10);
-
-	OPLwriteValue (0xA0, channel, (uint8_t)i);
-	OPLwriteValue (0xB0, channel, (uint8_t)(i>>8)|(keyon<<5));
-}
-
-/*
-* Adjust volume value (register 0x40)
-*/
-inline uint32_t OPLio::OPLconvertVolume(uint32_t data, uint32_t volume)
-{
-	static uint8_t volumetable[128] = {
-		0,   1,   3,   5,   6,   8,  10,  11,
-		13,  14,  16,  17,  19,  20,  22,  23,
-		25,  26,  27,  29,  30,  32,  33,  34,
-		36,  37,  39,  41,  43,  45,  47,  49,
-		50,  52,  54,  55,  57,  59,  60,  61,
-		63,  64,  66,  67,  68,  69,  71,  72,
-		73,  74,  75,  76,  77,  79,  80,  81,
-		82,  83,  84,  84,  85,  86,  87,  88,
-		89,  90,  91,  92,  92,  93,  94,  95,
-		96,  96,  97,  98,  99,  99, 100, 101,
-		101, 102, 103, 103, 104, 105, 105, 106,
-		107, 107, 108, 109, 109, 110, 110, 111,
-		112, 112, 113, 113, 114, 114, 115, 115,
-		116, 117, 117, 118, 118, 119, 119, 120,
-		120, 121, 121, 122, 122, 123, 123, 123,
-		124, 124, 125, 125, 126, 126, 127, 127};
-
-	return 0x3F - (((0x3F - data) *
-		(uint32_t)volumetable[volume <= 127 ? volume : 127]) >> 7);
-
-}
-
-uint32_t OPLio::OPLpanVolume(uint32_t volume, int pan)
-{
-	if (pan >= 0)
-		return volume;
-	else
-		return (volume * (pan + 64)) / 64;
-}
-
-/*
-* Write volume data to a channel
-*/
-void OPLio::OPLwriteVolume(uint32_t channel, struct OPL2instrument *instr, uint32_t volume)
-{
-	if (instr != 0)
-	{
-		OPLwriteChannel(0x40, channel, ((instr->feedback & 1) ?
-			OPLconvertVolume(instr->level_1, volume) : instr->level_1) | instr->scale_1,
-			OPLconvertVolume(instr->level_2, volume) | instr->scale_2);
-	}
-}
-
-/*
-* Write pan (balance) data to a channel
-*/
-void OPLio::OPLwritePan(uint32_t channel, struct OPL2instrument *instr, int pan)
-{
-	if (instr != 0)
-	{
-		uint8_t bits;
-		if (pan < -36) bits = 0x10;		// left
-		else if (pan > 36) bits = 0x20;	// right
-		else bits = 0x30;			// both
-
-		OPLwriteValue(0xC0, channel, instr->feedback | bits);
-
-		// Set real panning if we're using emulated chips.
-		int chanper = IsOPL3 ? OPL3CHANNELS : OPL2CHANNELS;
-		int which = channel / chanper;
-		if (chips[which] != NULL)
-		{
-			// This is the MIDI-recommended pan formula. 0 and 1 are
-			// both hard left so that 64 can be perfectly center.
-			// (Note that the 'pan' passed to this function is the
-			// MIDI pan position, subtracted by 64.)
-			double level = (pan <= -63) ? 0 : (pan + 64 - 1) / 126.0;
-			chips[which]->SetPanning(channel % chanper,
-				(float)cos(HALF_PI * level), (float)sin(HALF_PI * level));
-		}
-	}
-}
-
-/*
-* Write an instrument to a channel
-*
-* Instrument layout:
-*
-*   Operator1  Operator2  Descr.
-*    data[0]    data[7]   reg. 0x20 - tremolo/vibrato/sustain/KSR/multi
-*    data[1]    data[8]   reg. 0x60 - attack rate/decay rate
-*    data[2]    data[9]   reg. 0x80 - sustain level/release rate
-*    data[3]    data[10]  reg. 0xE0 - waveform select
-*    data[4]    data[11]  reg. 0x40 - key scale level
-*    data[5]    data[12]  reg. 0x40 - output level (bottom 6 bits only)
-*          data[6]        reg. 0xC0 - feedback/AM-FM (both operators)
-*/
-void OPLio::OPLwriteInstrument(uint32_t channel, struct OPL2instrument *instr)
-{
-	OPLwriteChannel(0x40, channel, 0x3F, 0x3F);		// no volume
-	OPLwriteChannel(0x20, channel, instr->trem_vibr_1, instr->trem_vibr_2);
-	OPLwriteChannel(0x60, channel, instr->att_dec_1,   instr->att_dec_2);
-	OPLwriteChannel(0x80, channel, instr->sust_rel_1,  instr->sust_rel_2);
-	OPLwriteChannel(0xE0, channel, instr->wave_1,      instr->wave_2);
-	OPLwriteValue  (0xC0, channel, instr->feedback | 0x30);
-}
-
-/*
-* Stop all sounds
-*/
-void OPLio::OPLshutup(void)
-{
-	uint32_t i;
-
-	for(i = 0; i < OPLchannels; i++)
-	{
-		OPLwriteChannel(0x40, i, 0x3F, 0x3F);	// turn off volume
-		OPLwriteChannel(0x60, i, 0xFF, 0xFF);	// the fastest attack, decay
-		OPLwriteChannel(0x80, i, 0x0F, 0x0F);	// ... and release
-		OPLwriteValue(0xB0, i, 0);		// KEY-OFF
-	}
-}
-
-/*
-* Initialize hardware upon startup
-*/
-int OPLio::OPLinit(uint32_t numchips, bool stereo, bool initopl3)
-{
-	assert(numchips >= 1 && numchips <= countof(chips));
-	uint32_t i;
-	IsOPL3 = (current_opl_core == 1 || current_opl_core == 2 || current_opl_core == 3);
-
-	memset(chips, 0, sizeof(chips));
-	if (IsOPL3)
-	{
-		numchips = (numchips + 1) >> 1;
-	}
-	for (i = 0; i < numchips; ++i)
-	{
-		OPLEmul *chip = IsOPL3 ? (current_opl_core == 1 ? DBOPLCreate(stereo) : (current_opl_core == 2 ? JavaOPLCreate(stereo) : NukedOPL3Create(stereo))) : YM3812Create(stereo);
-		if (chip == NULL)
-		{
-			break;
-		}
-		chips[i] = chip;
-	}
-	NumChips = i;
-	OPLchannels = i * (IsOPL3 ? OPL3CHANNELS : OPL2CHANNELS);
-	OPLwriteInitState(initopl3);
-	return i;
-}
-
-void OPLio::OPLwriteInitState(bool initopl3)
-{
-	for (uint32_t i = 0; i < NumChips; ++i)
-	{
-		int chip = i << (int)IsOPL3;
-		if (IsOPL3 && initopl3)
-		{
-			OPLwriteReg(chip, 0x105, 0x01);	// enable YMF262/OPL3 mode
-			OPLwriteReg(chip, 0x104, 0x00);	// disable 4-operator mode
-		}
-		OPLwriteReg(chip, 0x01, 0x20);	// enable Waveform Select
-		OPLwriteReg(chip, 0x0B, 0x40);	// turn off CSW mode
-		OPLwriteReg(chip, 0xBD, 0x00);	// set vibrato/tremolo depth to low, set melodic mode
-	}
-	OPLshutup();
-}
-
-/*
-* Deinitialize hardware before shutdown
-*/
-void OPLio::OPLdeinit(void)
-{
-	for (size_t i = 0; i < countof(chips); ++i)
-	{
-		if (chips[i] != NULL)
-		{
-			delete chips[i];
-			chips[i] = NULL;
-		}
-	}
-}
diff --git a/src/sound/oplsynth/musicblock.cpp b/src/sound/oplsynth/musicblock.cpp
new file mode 100644
index 0000000000..e0a2314762
--- /dev/null
+++ b/src/sound/oplsynth/musicblock.cpp
@@ -0,0 +1,454 @@
+#include <stdlib.h>
+#include <string.h>
+#include "muslib.h"
+#include "files.h"
+#include "templates.h"
+
+#include "c_cvars.h"
+
+musicBlock::musicBlock ()
+{
+	memset (this, 0, sizeof(*this));
+	for(auto &voice : voices) voice.index = -1;	// mark all free.
+}
+
+musicBlock::~musicBlock ()
+{
+}
+
+//----------------------------------------------------------------------------
+//
+// 
+//
+//----------------------------------------------------------------------------
+
+int musicBlock::releaseVoice(uint32_t slot, uint32_t killed)
+{
+	struct OPLVoice *ch = &voices[slot];
+	io->WriteFrequency(slot, ch->note, ch->pitch, 0);
+	ch->index = -1;
+	if (killed) io->MuteChannel(slot);
+	return slot;
+}
+
+//----------------------------------------------------------------------------
+//
+// 
+//
+//----------------------------------------------------------------------------
+
+int musicBlock::findFreeVoice()
+{
+	for (uint32_t i = 0; i < io->NumChannels; ++i)
+	{
+		if (voices[i].index == -1)
+		{
+			releaseVoice(i, 1);
+			return i;
+		}
+	}
+	return -1;
+}
+
+//----------------------------------------------------------------------------
+//
+// When all voices are in use, we must discard an existing voice to
+// play a new note.  Find and free an existing voice.  The channel
+// passed to the function is the channel for the new note to be
+// played.
+//
+//----------------------------------------------------------------------------
+
+int musicBlock::replaceExistingVoice()
+{
+	// Check the allocated voices, if we find an instrument that is
+	// of a lower priority to the new instrument, discard it.
+	// If a voice is being used to play the second voice of an instrument,
+	// use that, as second voices are non-essential.
+	// Lower numbered MIDI channels implicitly have a higher priority
+	// than higher-numbered channels, eg. MIDI channel 1 is never
+	// discarded for MIDI channel 2.
+
+	int result = 0;
+
+	for (uint32_t i = 0; i < io->NumChannels; ++i)
+	{
+		if (voices[i].current_instr_voice == &voices[i].current_instr->voices[1] ||
+			voices[i].index >= voices[result].index)
+		{
+			result = i;
+		}
+	}
+
+	releaseVoice(result, 1);
+	return result;
+}
+
+//----------------------------------------------------------------------------
+//
+// 
+//
+//----------------------------------------------------------------------------
+
+void musicBlock::voiceKeyOn(uint32_t slot, uint32_t channo, genmidi_instr_t *instrument, uint32_t instrument_voice, uint32_t key, uint32_t volume)
+{
+	struct OPLVoice *voice = &voices[slot];
+	auto &channel = oplchannels[channo];
+	genmidi_voice_t *gmvoice;
+
+	voice->index = channo;
+	voice->key = key;
+
+	// Program the voice with the instrument data:
+	voice->current_instr = instrument;
+	gmvoice = voice->current_instr_voice = &instrument->voices[instrument_voice];
+	io->WriteInstrument(slot,gmvoice, channel.Vibrato);
+	io->WritePan(slot, gmvoice, channel.Panning);
+
+	// Set the volume level.
+	voice->note_volume = volume;
+	io->WriteVolume(slot, gmvoice, channel.Volume, channel.Expression, volume);
+
+	// Write the frequency value to turn the note on.
+
+	// Work out the note to use.  This is normally the same as
+	// the key, unless it is a fixed pitch instrument.
+	uint32_t note;
+	if (instrument->flags & GENMIDI_FLAG_FIXED)	note = instrument->fixed_note;
+	else if (channo == CHAN_PERCUSSION) note = 60;	
+	else note = key;
+
+	// If this is the second voice of a double voice instrument, the
+	// frequency index can be adjusted by the fine tuning field.
+	voice->fine_tuning = (instrument_voice != 0) ? (voice->current_instr->fine_tuning / 2) - 64 : 0;
+	voice->pitch = voice->fine_tuning + channel.Pitch;
+
+	if (!(instrument->flags & GENMIDI_FLAG_FIXED) && channo != CHAN_PERCUSSION)
+	{
+		note += gmvoice->base_note_offset;
+	}
+
+	// Avoid possible overflow due to base note offset:
+
+	while (note < 0)
+	{
+		note += 12;
+	}
+
+	while (note > HIGHEST_NOTE)
+	{
+		note -= 12;
+	}
+	voice->note = note;
+	io->WriteFrequency(slot, note, voice->pitch, 1);
+}
+
+//----------------------------------------------------------------------------
+//
+// 
+//
+//----------------------------------------------------------------------------
+
+CVAR(Bool, opl_singlevoice, 0, 0)
+
+void musicBlock::noteOn(uint32_t channel, uint8_t key, int volume)
+{
+	if (volume <= 0)
+	{
+		noteOff(channel, key);
+		return;
+	}
+	uint32_t note;
+	genmidi_instr_t *instrument;
+
+	// Percussion channel is treated differently.
+	if (channel == CHAN_PERCUSSION)
+	{
+		if (key < GENMIDI_FIST_PERCUSSION || key >= GENMIDI_FIST_PERCUSSION + GENMIDI_NUM_PERCUSSION)
+		{
+			return;
+		}
+
+		instrument = &OPLinstruments[key + (GENMIDI_NUM_INSTRS - GENMIDI_FIST_PERCUSSION)];
+	}
+	else
+	{
+		auto inst = oplchannels[channel].Instrument;
+		if (inst >= GENMIDI_NUM_TOTAL) return;	// better safe than sorry.
+		instrument = &OPLinstruments[inst];
+	}
+
+	bool double_voice = ((instrument->flags) & GENMIDI_FLAG_2VOICE) && !opl_singlevoice;
+
+	int i = findFreeVoice();
+	if (i < 0) i = replaceExistingVoice();
+
+	if (i >= 0)
+	{
+		voiceKeyOn(i, channel, instrument, 0, key, volume);
+		if (double_voice)
+		{
+			i = findFreeVoice();
+			if (i > 0)
+			{
+				voiceKeyOn(i, channel, instrument, 1, key, volume);
+			}
+		}
+	}
+}
+
+//----------------------------------------------------------------------------
+//
+// 
+//
+//----------------------------------------------------------------------------
+
+void musicBlock::noteOff(uint32_t id, uint8_t note)
+{
+	uint32_t sustain = oplchannels[id].Sustain;
+
+	for(uint32_t i = 0; i < io->NumChannels; i++)
+	{
+		if (voices[i].index == id && voices[i].key == note)
+		{
+			if (sustain >= MIN_SUSTAIN) voices[i].sustained = true;
+			else releaseVoice(i, 0);
+		}
+	}
+}
+
+//----------------------------------------------------------------------------
+//
+// 
+//
+//----------------------------------------------------------------------------
+
+void musicBlock::changePitch(uint32_t id, int val1, int val2)
+{
+	// Convert pitch from 14-bit to 7-bit, then scale it, since the player
+	// code only understands sensitivities of 2 semitones.
+	int pitch = ((val1 | (val2 << 7)) - 8192) * oplchannels[id].PitchSensitivity / (200 * 128) + 64;
+	oplchannels[id].Pitch = pitch;
+	for(uint32_t i = 0; i < io->NumChannels; i++)
+	{
+		auto &ch = voices[i];
+		if (ch.index == id)
+		{
+			ch.pitch = ch.fine_tuning + pitch;
+			io->WriteFrequency(i, ch.note, ch.pitch, 1);
+		}
+	}
+}
+
+//----------------------------------------------------------------------------
+//
+// 
+//
+//----------------------------------------------------------------------------
+
+void musicBlock::changeModulation(uint32_t id, int value)
+{
+	bool vibrato = (value >= VIBRATO_THRESHOLD);
+	oplchannels[id].Vibrato = vibrato;
+	for (uint32_t i = 0; i < io->NumChannels; i++)
+	{
+		auto &ch = voices[i];
+		if (ch.index == id)
+		{
+			io->WriteTremolo(i, ch.current_instr_voice, vibrato);
+		}
+	}
+}
+
+//----------------------------------------------------------------------------
+//
+// 
+//
+//----------------------------------------------------------------------------
+
+void musicBlock::changeSustain(uint32_t id, int value)
+{
+	oplchannels[id].Sustain = value;
+	if (value < MIN_SUSTAIN)
+	{
+		for (uint32_t i = 0; i < io->NumChannels; i++)
+		{
+			if (voices[i].index == id && voices[i].sustained)
+				releaseVoice(i, 0);
+		}
+	}
+}
+
+//----------------------------------------------------------------------------
+//
+// Change volume or expression.
+// Since both go to the same register, one function can handle both.
+//
+//----------------------------------------------------------------------------
+
+void musicBlock::changeVolume(uint32_t id, int value, bool expression)
+{
+	auto &chan = oplchannels[id];
+	if (!expression) chan.Volume = value;
+	else chan.Expression = value;
+	for (uint32_t i = 0; i < io->NumChannels; i++)
+	{
+		auto &ch = voices[i];
+		if (ch.index == id)
+		{
+			io->WriteVolume(i, ch.current_instr_voice, chan.Volume, chan.Expression, ch.note_volume);
+		}
+	}
+}
+
+//----------------------------------------------------------------------------
+//
+// 
+//
+//----------------------------------------------------------------------------
+
+void musicBlock::changePanning(uint32_t id, int value)
+{
+	oplchannels[id].Panning = value;
+	for(uint32_t i = 0; i < io->NumChannels; i++)
+	{
+		auto &ch = voices[i];
+		if (ch.index == id)
+		{
+			io->WritePan(i, ch.current_instr_voice, value);
+		}
+	}
+}
+
+//----------------------------------------------------------------------------
+//
+// 
+//
+//----------------------------------------------------------------------------
+
+void musicBlock::notesOff(uint32_t id, int value)
+{
+	for (uint32_t i = 0; i < io->NumChannels; ++i)
+	{
+		if (voices[i].index == id)
+		{
+			if (oplchannels[id].Sustain >= MIN_SUSTAIN) voices[i].sustained = true;
+			else releaseVoice(i, 0);
+		}
+	}
+}
+
+//----------------------------------------------------------------------------
+//
+// release all notes for this channel
+//
+//----------------------------------------------------------------------------
+
+void musicBlock::allNotesOff(uint32_t id, int value)
+{
+	for (uint32_t i = 0; i < io->NumChannels; ++i)
+	{
+		if (voices[i].index == id)
+		{
+			releaseVoice(i, 0);
+		}
+	}
+}
+
+//----------------------------------------------------------------------------
+//
+// 
+//
+//----------------------------------------------------------------------------
+
+void musicBlock::changeExtended(uint32_t id, uint8_t controller, int value)
+{
+	switch (controller)
+	{
+	case ctrlRPNHi:
+		oplchannels[id].RPN = (oplchannels[id].RPN & 0x007F) | (value << 7);
+		break;
+
+	case ctrlRPNLo:
+		oplchannels[id].RPN = (oplchannels[id].RPN & 0x3F80) | value;
+		break;
+
+	case ctrlNRPNLo:
+	case ctrlNRPNHi:
+		oplchannels[id].RPN = 0x3FFF;
+		break;
+
+	case ctrlDataEntryHi:
+		if (oplchannels[id].RPN == 0)
+		{
+			oplchannels[id].PitchSensitivity = value * 100 + (oplchannels[id].PitchSensitivity % 100);
+		}
+		break;
+
+	case ctrlDataEntryLo:
+		if (oplchannels[id].RPN == 0)
+		{
+			oplchannels[id].PitchSensitivity = value + (oplchannels[id].PitchSensitivity / 100) * 100;
+		}
+		break;
+	}
+}
+
+//----------------------------------------------------------------------------
+//
+// 
+//
+//----------------------------------------------------------------------------
+
+void musicBlock::resetControllers(uint32_t chan, int vol)
+{
+	auto &channel = oplchannels[chan];
+
+	channel.Volume = vol;
+	channel.Expression = 127;
+	channel.Sustain = 0;
+	channel.Pitch = 64;
+	channel.RPN = 0x3fff;
+	channel.PitchSensitivity = 200;
+}
+
+//----------------------------------------------------------------------------
+//
+// 
+//
+//----------------------------------------------------------------------------
+
+void musicBlock::programChange(uint32_t channel, int value)
+{
+	oplchannels[channel].Instrument = value;
+}
+
+//----------------------------------------------------------------------------
+//
+// 
+//
+//----------------------------------------------------------------------------
+
+void musicBlock::resetAllControllers(int vol)
+{
+	uint32_t i;
+
+	for (i = 0; i < NUM_CHANNELS; i++)
+	{
+		resetControllers(i, vol);
+	}
+}
+
+//----------------------------------------------------------------------------
+//
+// 
+//
+//----------------------------------------------------------------------------
+
+void musicBlock::stopAllVoices()
+{
+	for (uint32_t i = 0; i < io->NumChannels; i++)
+	{
+		if (voices[i].index >= 0) releaseVoice(i, 1);
+	}
+}
diff --git a/src/sound/oplsynth/musicblock.h b/src/sound/oplsynth/musicblock.h
new file mode 100644
index 0000000000..1f13aa01f3
--- /dev/null
+++ b/src/sound/oplsynth/musicblock.h
@@ -0,0 +1,58 @@
+#pragma once
+#include "doomtype.h"
+#include "genmidi.h"
+#include "oplio.h"
+
+
+struct OPLVoice 
+{
+	int index;					// Index of this voice, or -1 if not in use.
+	unsigned int key;			// The midi key that this voice is playing.
+	unsigned int note;			// The note being played.  This is normally the same as the key, but if the instrument is a fixed pitch instrument, it is different.
+	unsigned int note_volume;	// The volume of the note being played on this channel.
+	genmidi_instr_t *current_instr;	// Currently-loaded instrument data
+	genmidi_voice_t *current_instr_voice;// The voice number in the instrument to use. This is normally set to the instrument's first voice; if this is a double voice instrument, it may be the second one
+	bool sustained;
+	int8_t	fine_tuning;
+	int	pitch;
+};
+
+struct musicBlock {
+	musicBlock();
+	~musicBlock();
+
+	uint8_t *score;
+	uint8_t *scoredata;
+	int playingcount;
+	OPLChannel oplchannels[NUM_CHANNELS];
+	OPLio *io;
+
+	struct genmidi_instr_t OPLinstruments[GENMIDI_NUM_TOTAL];
+
+	void changeModulation(uint32_t id, int value);
+	void changeSustain(uint32_t id, int value);
+	void changeVolume(uint32_t id, int value, bool expression);
+	void changePanning(uint32_t id, int value);
+	void notesOff(uint32_t id, int value);
+	void allNotesOff(uint32_t id, int value);
+	void changeExtended(uint32_t channel, uint8_t controller, int value);
+	void resetControllers(uint32_t channel, int vol);
+	void programChange(uint32_t channel, int value);
+	void resetAllControllers(int vol);
+	void changePitch(uint32_t channel, int val1, int val2);
+
+	void noteOn(uint32_t channel, uint8_t note, int volume);
+	void noteOff(uint32_t channel, uint8_t note);
+	void stopAllVoices();
+
+protected:
+	OPLVoice voices[NUM_VOICES];
+
+	int findFreeVoice();
+	int replaceExistingVoice();
+	void voiceKeyOn(uint32_t slot, uint32_t channo, genmidi_instr_t *instrument, uint32_t instrument_voice, uint32_t, uint32_t volume);
+	int releaseVoice(uint32_t slot, uint32_t killed);
+
+	friend class Stat_opl;
+
+};
diff --git a/src/sound/oplsynth/muslib.h b/src/sound/oplsynth/muslib.h
deleted file mode 100644
index 9d5bdfcbdc..0000000000
--- a/src/sound/oplsynth/muslib.h
+++ /dev/null
@@ -1,267 +0,0 @@
-/*
- *	Name:		Main header include file
- *	Project:	MUS File Player Library
- *	Version:	1.75
- *	Author:		Vladimir Arnost (QA-Software)
- *	Last revision:	Mar-9-1996
- *	Compiler:	Borland C++ 3.1, Watcom C/C++ 10.0
- *
- */
-
-/* From muslib175.zip/README.1ST:
-
-1.1 - Disclaimer of Warranties
-------------------------------
-
-#ifdef LAWYER
-
-THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
-FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGE.
-
-#else
-
-Use this software at your own risk.
-
-#endif
-
-
-1.2 - Terms of Use
-------------------
-
-This library may be used in any freeware or shareware product free of
-charge. The product may not be sold for profit (except for shareware) and
-should be freely available to the public. It would be nice of you if you
-credited me in your product and notified me if you use this library.
-
-If you want to use this library in a commercial product, contact me
-and we will make an agreement. It is a violation of the law to make money
-of this product without prior signing an agreement and paying a license fee.
-This licence will allow its holder to sell any products based on MUSLib,
-royalty-free. There is no need to buy separate licences for different
-products once the licence fee is paid.
-
-
-1.3 - Contacting the Author
----------------------------
-
-Internet (address valid probably until the end of year 1998):
-  xarnos00@dcse.fee.vutbr.cz
-
-FIDO:
-  2:423/36.2
-
-Snail-mail:
-
-  Vladimir Arnost
-  Ceska 921
-  Chrudim 4
-  537 01
-  CZECH REPUBLIC
-
-Voice-mail (Czech language only, not recommended; weekends only):
-
-  +42-455-2154
-*/
-
-#ifndef __MUSLIB_H_
-#define __MUSLIB_H_
-
-#ifndef __DEFTYPES_H_
-  #include "doomtype.h"
-#endif
-
-class FileReader;
-
-/* Global Definitions */
-
-#define CHANNELS	16		// total channels 0..CHANNELS-1
-#define PERCUSSION	15		// percussion channel
-
-/* OPL2 instrument */
-struct OPL2instrument {
-/*00*/	uint8_t    trem_vibr_1;	/* OP 1: tremolo/vibrato/sustain/KSR/multi */
-/*01*/	uint8_t	att_dec_1;		/* OP 1: attack rate/decay rate */
-/*02*/	uint8_t	sust_rel_1;		/* OP 1: sustain level/release rate */
-/*03*/	uint8_t	wave_1;			/* OP 1: waveform select */
-/*04*/	uint8_t	scale_1;		/* OP 1: key scale level */
-/*05*/	uint8_t	level_1;		/* OP 1: output level */
-/*06*/	uint8_t	feedback;		/* feedback/AM-FM (both operators) */
-/*07*/	uint8_t    trem_vibr_2;	/* OP 2: tremolo/vibrato/sustain/KSR/multi */
-/*08*/	uint8_t	att_dec_2;		/* OP 2: attack rate/decay rate */
-/*09*/	uint8_t	sust_rel_2;		/* OP 2: sustain level/release rate */
-/*0A*/	uint8_t	wave_2;			/* OP 2: waveform select */
-/*0B*/	uint8_t	scale_2;		/* OP 2: key scale level */
-/*0C*/	uint8_t	level_2;		/* OP 2: output level */
-/*0D*/	uint8_t	unused;
-/*0E*/	int16_t	basenote;		/* base note offset */
-};
-
-/* OP2 instrument file entry */
-struct OP2instrEntry {
-/*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
-};
-
-#define FL_FIXED_PITCH	0x0001		// note has fixed pitch (see below)
-#define FL_DOUBLE_VOICE	0x0004		// use two voices instead of one
-
-
-#define OP2INSTRSIZE	sizeof(struct OP2instrEntry) // instrument size (36 bytes)
-#define OP2INSTRCOUNT	(128 + 81-35+1)	// instrument count
-
-/* From MLOPL_IO.CPP */
-#define OPL2CHANNELS	9
-#define OPL3CHANNELS	18
-#define MAXOPL2CHIPS	8
-#define MAXCHANNELS		(OPL2CHANNELS * MAXOPL2CHIPS)
-
-
-/* Channel Flags: */
-#define CH_SECONDARY	0x01
-#define CH_SUSTAIN		0x02
-#define CH_VIBRATO		0x04		/* set if modulation >= MOD_MIN */
-#define CH_FREE			0x80
-
-struct OPLdata {
-	uint32_t	channelInstr[CHANNELS];			// instrument #
-	uint8_t	channelVolume[CHANNELS];		// volume
-	uint8_t	channelLastVolume[CHANNELS];	// last volume
-	int8_t	channelPan[CHANNELS];			// pan, 0=normal
-	int8_t	channelPitch[CHANNELS];			// pitch wheel, 64=normal
-	uint8_t	channelSustain[CHANNELS];		// sustain pedal value
-	uint8_t	channelModulation[CHANNELS];	// modulation pot value
-	uint16_t	channelPitchSens[CHANNELS];		// pitch sensitivity, 2=default
-	uint16_t	channelRPN[CHANNELS];			// RPN number for data entry
-	uint8_t	channelExpression[CHANNELS];	// expression
-};
-
-struct OPLio {
-	virtual ~OPLio();
-
-	void	OPLwriteChannel(uint32_t regbase, uint32_t channel, uint8_t data1, uint8_t data2);
-	void	OPLwriteValue(uint32_t regbase, uint32_t channel, uint8_t value);
-	void	OPLwriteFreq(uint32_t channel, uint32_t freq, uint32_t octave, uint32_t keyon);
-	uint32_t	OPLconvertVolume(uint32_t data, uint32_t volume);
-	uint32_t	OPLpanVolume(uint32_t volume, int pan);
-	void	OPLwriteVolume(uint32_t channel, struct OPL2instrument *instr, uint32_t volume);
-	void	OPLwritePan(uint32_t channel, struct OPL2instrument *instr, int pan);
-	void	OPLwriteInstrument(uint32_t channel, struct OPL2instrument *instr);
-	void	OPLshutup(void);
-	void	OPLwriteInitState(bool initopl3);
-
-	virtual int		OPLinit(uint32_t numchips, bool stereo=false, bool initopl3=false);
-	virtual void	OPLdeinit(void);
-	virtual void	OPLwriteReg(int which, uint32_t reg, uint8_t data);
-	virtual void	SetClockRate(double samples_per_tick);
-	virtual void	WriteDelay(int ticks);
-
-	class OPLEmul *chips[MAXOPL2CHIPS];
-	uint32_t OPLchannels;
-	uint32_t NumChips;
-	bool IsOPL3;
-};
-
-struct DiskWriterIO : public OPLio
-{
-	DiskWriterIO(const char *filename);
-	~DiskWriterIO();
-
-	int OPLinit(uint32_t numchips, bool notused, bool initopl3);
-	void SetClockRate(double samples_per_tick);
-	void WriteDelay(int ticks);
-
-	FString Filename;
-};
-
-struct musicBlock {
-	musicBlock();
-	~musicBlock();
-
-	uint8_t *score;
-	uint8_t *scoredata;
-	int playingcount;
-	OPLdata driverdata;
-	OPLio *io;
-
-	struct OP2instrEntry *OPLinstruments;
-
-	uint32_t MLtime;
-
-	void OPLplayNote(uint32_t channel, uint8_t note, int volume);
-	void OPLreleaseNote(uint32_t channel, uint8_t note);
-	void OPLpitchWheel(uint32_t channel, int pitch);
-	void OPLchangeControl(uint32_t channel, uint8_t controller, int value);
-	void OPLprogramChange(uint32_t channel, int value);
-	void OPLresetControllers(uint32_t channel, int vol);
-	void OPLplayMusic(int vol);
-	void OPLstopMusic();
-
-	int OPLloadBank (FileReader &data);
-
-protected:
-	/* OPL channel (voice) data */
-	struct channelEntry {
-		uint8_t	channel;		/* MUS channel number */
-		uint8_t	note;			/* note number */
-		uint8_t	flags;			/* see CH_xxx below */
-		uint8_t	realnote;		/* adjusted note number */
-		int8_t	finetune;		/* frequency fine-tune */
-		int	pitch;				/* pitch-wheel value */
-		uint32_t	volume;			/* note volume */
-		uint32_t	realvolume;		/* adjusted note volume */
-		struct OPL2instrument *instr;	/* current instrument */
-		uint32_t	time;			/* note start time */
-	} channels[MAXCHANNELS];
-
-	void writeFrequency(uint32_t slot, uint32_t note, int pitch, uint32_t keyOn);
-	void writeModulation(uint32_t slot, struct OPL2instrument *instr, int state);
-	uint32_t calcVolume(uint32_t channelVolume, uint32_t channelExpression, uint32_t noteVolume);
-	int occupyChannel(uint32_t slot, uint32_t channel,
-						 int note, int volume, struct OP2instrEntry *instrument, uint8_t secondary);
-	int releaseChannel(uint32_t slot, uint32_t killed);
-	int releaseSustain(uint32_t channel);
-	int findFreeChannel(uint32_t flag, uint32_t channel, uint8_t note);
-	struct OP2instrEntry *getInstrument(uint32_t channel, uint8_t note);
-
-	friend class Stat_opl;
-
-};
-
-enum MUSctrl {
-    ctrlPatch = 0,
-    ctrlBank,
-    ctrlModulation,
-    ctrlVolume,
-    ctrlPan,
-    ctrlExpression,
-    ctrlReverb,
-    ctrlChorus,
-    ctrlSustainPedal,
-    ctrlSoftPedal,
-	ctrlRPNHi,
-	ctrlRPNLo,
-	ctrlNRPNHi,
-	ctrlNRPNLo,
-	ctrlDataEntryHi,
-	ctrlDataEntryLo,
-
-	ctrlSoundsOff,
-    ctrlNotesOff,
-    ctrlMono,
-    ctrlPoly,
-};
-
-#define ADLIB_CLOCK_MUL			24.0
-
-#endif // __MUSLIB_H_
diff --git a/src/sound/oplsynth/nukedopl3.h b/src/sound/oplsynth/nukedopl3.h
index 17ebbe4d2c..3c3c65895a 100644
--- a/src/sound/oplsynth/nukedopl3.h
+++ b/src/sound/oplsynth/nukedopl3.h
@@ -30,7 +30,7 @@
 //version 1.6
 
 #include "opl.h"
-#include "muslib.h"
+#include "musicblock.h"
 
 typedef uintptr_t	Bitu;
 typedef intptr_t	Bits;
diff --git a/src/sound/oplsynth/opl.h b/src/sound/oplsynth/opl.h
index 1a3842fd3b..d5faa136c3 100644
--- a/src/sound/oplsynth/opl.h
+++ b/src/sound/oplsynth/opl.h
@@ -24,6 +24,8 @@ OPLEmul *NukedOPL3Create(bool stereo);
 
 #define OPL_SAMPLE_RATE			49716.0
 #define CENTER_PANNING_POWER	0.70710678118	/* [RH] volume at center for EQP */
+#define ADLIB_CLOCK_MUL			24.0
+
 
 
 #endif
\ No newline at end of file
diff --git a/src/sound/oplsynth/opl_mus_player.cpp b/src/sound/oplsynth/opl_mus_player.cpp
index 55dd132cef..4829f9cfae 100644
--- a/src/sound/oplsynth/opl_mus_player.cpp
+++ b/src/sound/oplsynth/opl_mus_player.cpp
@@ -38,16 +38,15 @@ OPLmusicBlock::~OPLmusicBlock()
 void OPLmusicBlock::ResetChips ()
 {
 	ChipAccess.Enter();
-	io->OPLdeinit ();
-	NumChips = io->OPLinit(MIN(*opl_numchips, 2), FullPan);
+	io->Reset ();
+	NumChips = io->Init(MIN(*opl_numchips, 2), FullPan);
 	ChipAccess.Leave();
 }
 
 void OPLmusicBlock::Restart()
 {
-	OPLstopMusic ();
-	OPLplayMusic (127);
-	MLtime = 0;
+	stopAllVoices ();
+	resetAllControllers (127);
 	playingcount = 0;
 	LastOffset = 0;
 }
@@ -69,7 +68,7 @@ fail:	delete[] scoredata;
         return;
     }
 
-	if (0 == (NumChips = io->OPLinit(NumChips)))
+	if (0 == (NumChips = io->Init(NumChips)))
 	{
 		goto fail;
 	}
@@ -161,7 +160,7 @@ OPLmusicFile::~OPLmusicFile ()
 {
 	if (scoredata != NULL)
 	{
-		io->OPLdeinit ();
+		io->Reset ();
 		delete[] scoredata;
 		scoredata = NULL;
 	}
@@ -280,7 +279,6 @@ bool OPLmusicBlock::ServiceStream (void *buff, int numbytes)
 				io->WriteDelay(next);
 				NextTickIn += SamplesPerTick * next;
 				assert (NextTickIn >= 0);
-				MLtime += next;
 			}
 		}
 	}
@@ -407,7 +405,7 @@ int OPLmusicFile::PlayTick ()
 				break;
 
 			default:	// It's something to stuff into the OPL chip
-				io->OPLwriteReg(WhichChip, reg, data);
+				io->WriteRegister(WhichChip, reg, data);
 				break;
 			}
 		}
@@ -447,7 +445,7 @@ int OPLmusicFile::PlayTick ()
 			{
 				data = *score++;
 			}
-			io->OPLwriteReg(WhichChip, reg, data);
+			io->WriteRegister(WhichChip, reg, data);
 		}
 		break;
 
@@ -477,7 +475,7 @@ int OPLmusicFile::PlayTick ()
 				}
 				else if (code < to_reg_size)
 				{
-					io->OPLwriteReg(which, to_reg[code], data);
+					io->WriteRegister(which, to_reg[code], data);
 				}
 			}
 		}
@@ -495,7 +493,7 @@ int OPLmusicFile::PlayTick ()
 			data = score[1];
 			delay = LittleShort(((uint16_t *)score)[1]);
 			score += 4;
-			io->OPLwriteReg (0, reg, data);
+			io->WriteRegister (0, reg, data);
 		}
 		return delay;
 	}
@@ -524,7 +522,7 @@ OPLmusicFile::OPLmusicFile(const OPLmusicFile *source, const char *filename)
 		delete io;
 	}
 	io = new DiskWriterIO(filename);
-	NumChips = io->OPLinit(NumChips);
+	NumChips = io->Init(NumChips);
 	Restart();
 }
 
diff --git a/src/sound/oplsynth/opl_mus_player.h b/src/sound/oplsynth/opl_mus_player.h
index bc76e06823..a8ace69d2b 100644
--- a/src/sound/oplsynth/opl_mus_player.h
+++ b/src/sound/oplsynth/opl_mus_player.h
@@ -1,6 +1,8 @@
 #include "critsec.h"
 #include "muslib.h"
 
+class FileReader;
+
 class OPLmusicBlock : public musicBlock
 {
 public:
diff --git a/src/sound/oplsynth/oplio.cpp b/src/sound/oplsynth/oplio.cpp
new file mode 100644
index 0000000000..68b769db48
--- /dev/null
+++ b/src/sound/oplsynth/oplio.cpp
@@ -0,0 +1,493 @@
+/*
+** oplio.cpp
+** low level OPL code
+**
+**---------------------------------------------------------------------------
+** Copyright 1998-2008 Randy Heit
+** All rights reserved.
+**
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions
+** are met:
+**
+** 1. Redistributions of source code must retain the above copyright
+**    notice, this list of conditions and the following disclaimer.
+** 2. Redistributions in binary form must reproduce the above copyright
+**    notice, this list of conditions and the following disclaimer in the
+**    documentation and/or other materials provided with the distribution.
+** 3. The name of the author may not be used to endorse or promote products
+**    derived from this software without specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+**---------------------------------------------------------------------------
+*/
+
+#include "genmidi.h"
+#include "oplio.h"
+#include "opl.h"
+#include "c_cvars.h"
+#include "templates.h"
+
+const double HALF_PI = (M_PI*0.5);
+
+EXTERN_CVAR(Int, opl_core)
+extern int current_opl_core;
+
+OPLio::~OPLio()
+{
+}
+
+void OPLio::SetClockRate(double samples_per_tick)
+{
+}
+
+void OPLio::WriteDelay(int ticks)
+{
+}
+
+//----------------------------------------------------------------------------
+//
+// Initialize OPL emulator
+//
+//----------------------------------------------------------------------------
+
+int OPLio::Init(uint32_t numchips, bool stereo, bool initopl3)
+{
+	assert(numchips >= 1 && numchips <= countof(chips));
+	uint32_t i;
+	IsOPL3 = (current_opl_core == 1 || current_opl_core == 2 || current_opl_core == 3);
+
+	memset(chips, 0, sizeof(chips));
+	if (IsOPL3)
+	{
+		numchips = (numchips + 1) >> 1;
+	}
+	for (i = 0; i < numchips; ++i)
+	{
+		OPLEmul *chip = IsOPL3 ? (current_opl_core == 1 ? DBOPLCreate(stereo) : (current_opl_core == 2 ? JavaOPLCreate(stereo) : NukedOPL3Create(stereo))) : YM3812Create(stereo);
+		if (chip == NULL)
+		{
+			break;
+		}
+		chips[i] = chip;
+	}
+	NumChips = i;
+	NumChannels = i * (IsOPL3 ? OPL3_NUM_VOICES : OPL_NUM_VOICES);
+	WriteInitState(initopl3);
+	return i;
+}
+
+//----------------------------------------------------------------------------
+//
+// 
+//
+//----------------------------------------------------------------------------
+
+void OPLio::WriteInitState(bool initopl3)
+{
+	for (uint32_t k = 0; k < NumChips; ++k)
+	{
+		int chip = k << (int)IsOPL3;
+		if (IsOPL3 && initopl3)
+		{
+			WriteRegister(chip, OPL_REG_OPL3_ENABLE, 1);
+			WriteRegister(chip, OPL_REG_4OPMODE_ENABLE, 0);
+		}
+		WriteRegister(chip, OPL_REG_WAVEFORM_ENABLE, WAVEFORM_ENABLED);
+		WriteRegister(chip, OPL_REG_PERCUSSION_MODE, 0);	// should be the default, but cannot verify for some of the cores.
+	}
+
+	// Reset all channels.
+	for (uint32_t k = 0; k < NumChannels; k++)
+	{
+		MuteChannel(k);
+		WriteValue(OPL_REGS_FREQ_2, k, 0);
+	}
+}
+
+
+//----------------------------------------------------------------------------
+//
+// Deinitialize emulator before shutdown
+//
+//----------------------------------------------------------------------------
+
+void OPLio::Reset(void)
+{
+	for (size_t i = 0; i < countof(chips); ++i)
+	{
+		if (chips[i] != NULL)
+		{
+			delete chips[i];
+			chips[i] = NULL;
+		}
+	}
+}
+
+//----------------------------------------------------------------------------
+//
+// 
+//
+//----------------------------------------------------------------------------
+
+void OPLio::WriteRegister(int chipnum, uint32_t reg, uint8_t data)
+{
+	if (IsOPL3)
+	{
+		reg |= (chipnum & 1) << 8;
+		chipnum >>= 1;
+	}
+	if (chips[chipnum] != nullptr)
+	{
+		chips[chipnum]->WriteReg(reg, data);
+	}
+}
+
+//----------------------------------------------------------------------------
+//
+// 
+//
+//----------------------------------------------------------------------------
+
+void OPLio::WriteValue(uint32_t regbase, uint32_t channel, uint8_t value)
+{
+	WriteRegister (channel / OPL_NUM_VOICES, regbase + (channel % OPL_NUM_VOICES), value);
+}
+
+//----------------------------------------------------------------------------
+//
+// 
+//
+//----------------------------------------------------------------------------
+
+static const int voice_operators[OPL_NUM_VOICES] = { 0x00, 0x01, 0x02, 0x08, 0x09, 0x0a, 0x10, 0x11, 0x12 };
+
+void OPLio::WriteOperator(uint32_t regbase, uint32_t channel, int index, uint8_t data2)
+{
+	WriteRegister(channel / OPL_NUM_VOICES, regbase + voice_operators[channel % OPL_NUM_VOICES] + 3*index, data2);
+}
+
+//----------------------------------------------------------------------------
+//
+// Write frequency/octave/keyon data to a channel
+//
+// [RH] This is totally different from the original MUS library code
+// but matches exactly what DMX does. I haven't a clue why there are 284
+// special bytes at the beginning of the table for the first few notes.
+// That last byte in the table doesn't look right, either, but that's what
+// it really is.
+//
+//----------------------------------------------------------------------------
+
+static const uint16_t frequencies[] = {	// (this is the table from Chocolate Doom, which contains the same values as ZDoom's original one but is better formatted.
+
+    0x133, 0x133, 0x134, 0x134, 0x135, 0x136, 0x136, 0x137,   // -1
+    0x137, 0x138, 0x138, 0x139, 0x139, 0x13a, 0x13b, 0x13b,
+    0x13c, 0x13c, 0x13d, 0x13d, 0x13e, 0x13f, 0x13f, 0x140,
+    0x140, 0x141, 0x142, 0x142, 0x143, 0x143, 0x144, 0x144,
+
+    0x145, 0x146, 0x146, 0x147, 0x147, 0x148, 0x149, 0x149,   // -2
+    0x14a, 0x14a, 0x14b, 0x14c, 0x14c, 0x14d, 0x14d, 0x14e,
+    0x14f, 0x14f, 0x150, 0x150, 0x151, 0x152, 0x152, 0x153,
+    0x153, 0x154, 0x155, 0x155, 0x156, 0x157, 0x157, 0x158,
+
+    // These are used for the first seven MIDI note values:
+
+    0x158, 0x159, 0x15a, 0x15a, 0x15b, 0x15b, 0x15c, 0x15d,   // 0
+    0x15d, 0x15e, 0x15f, 0x15f, 0x160, 0x161, 0x161, 0x162,
+    0x162, 0x163, 0x164, 0x164, 0x165, 0x166, 0x166, 0x167,
+    0x168, 0x168, 0x169, 0x16a, 0x16a, 0x16b, 0x16c, 0x16c,
+
+    0x16d, 0x16e, 0x16e, 0x16f, 0x170, 0x170, 0x171, 0x172,   // 1
+    0x172, 0x173, 0x174, 0x174, 0x175, 0x176, 0x176, 0x177,
+    0x178, 0x178, 0x179, 0x17a, 0x17a, 0x17b, 0x17c, 0x17c,
+    0x17d, 0x17e, 0x17e, 0x17f, 0x180, 0x181, 0x181, 0x182,
+
+    0x183, 0x183, 0x184, 0x185, 0x185, 0x186, 0x187, 0x188,   // 2
+    0x188, 0x189, 0x18a, 0x18a, 0x18b, 0x18c, 0x18d, 0x18d,
+    0x18e, 0x18f, 0x18f, 0x190, 0x191, 0x192, 0x192, 0x193,
+    0x194, 0x194, 0x195, 0x196, 0x197, 0x197, 0x198, 0x199,
+
+    0x19a, 0x19a, 0x19b, 0x19c, 0x19d, 0x19d, 0x19e, 0x19f,   // 3
+    0x1a0, 0x1a0, 0x1a1, 0x1a2, 0x1a3, 0x1a3, 0x1a4, 0x1a5,
+    0x1a6, 0x1a6, 0x1a7, 0x1a8, 0x1a9, 0x1a9, 0x1aa, 0x1ab,
+    0x1ac, 0x1ad, 0x1ad, 0x1ae, 0x1af, 0x1b0, 0x1b0, 0x1b1,
+
+    0x1b2, 0x1b3, 0x1b4, 0x1b4, 0x1b5, 0x1b6, 0x1b7, 0x1b8,   // 4
+    0x1b8, 0x1b9, 0x1ba, 0x1bb, 0x1bc, 0x1bc, 0x1bd, 0x1be,
+    0x1bf, 0x1c0, 0x1c0, 0x1c1, 0x1c2, 0x1c3, 0x1c4, 0x1c4,
+    0x1c5, 0x1c6, 0x1c7, 0x1c8, 0x1c9, 0x1c9, 0x1ca, 0x1cb,
+
+    0x1cc, 0x1cd, 0x1ce, 0x1ce, 0x1cf, 0x1d0, 0x1d1, 0x1d2,   // 5
+    0x1d3, 0x1d3, 0x1d4, 0x1d5, 0x1d6, 0x1d7, 0x1d8, 0x1d8,
+    0x1d9, 0x1da, 0x1db, 0x1dc, 0x1dd, 0x1de, 0x1de, 0x1df,
+    0x1e0, 0x1e1, 0x1e2, 0x1e3, 0x1e4, 0x1e5, 0x1e5, 0x1e6,
+
+    0x1e7, 0x1e8, 0x1e9, 0x1ea, 0x1eb, 0x1ec, 0x1ed, 0x1ed,   // 6
+    0x1ee, 0x1ef, 0x1f0, 0x1f1, 0x1f2, 0x1f3, 0x1f4, 0x1f5,
+    0x1f6, 0x1f6, 0x1f7, 0x1f8, 0x1f9, 0x1fa, 0x1fb, 0x1fc,
+    0x1fd, 0x1fe, 0x1ff, 0x200, 0x201, 0x201, 0x202, 0x203,
+
+    // First note of looped range used for all octaves:
+
+    0x204, 0x205, 0x206, 0x207, 0x208, 0x209, 0x20a, 0x20b,   // 7
+    0x20c, 0x20d, 0x20e, 0x20f, 0x210, 0x210, 0x211, 0x212,
+    0x213, 0x214, 0x215, 0x216, 0x217, 0x218, 0x219, 0x21a,
+    0x21b, 0x21c, 0x21d, 0x21e, 0x21f, 0x220, 0x221, 0x222,
+
+    0x223, 0x224, 0x225, 0x226, 0x227, 0x228, 0x229, 0x22a,   // 8
+    0x22b, 0x22c, 0x22d, 0x22e, 0x22f, 0x230, 0x231, 0x232,
+    0x233, 0x234, 0x235, 0x236, 0x237, 0x238, 0x239, 0x23a,
+    0x23b, 0x23c, 0x23d, 0x23e, 0x23f, 0x240, 0x241, 0x242,
+
+    0x244, 0x245, 0x246, 0x247, 0x248, 0x249, 0x24a, 0x24b,   // 9
+    0x24c, 0x24d, 0x24e, 0x24f, 0x250, 0x251, 0x252, 0x253,
+    0x254, 0x256, 0x257, 0x258, 0x259, 0x25a, 0x25b, 0x25c,
+    0x25d, 0x25e, 0x25f, 0x260, 0x262, 0x263, 0x264, 0x265,
+
+    0x266, 0x267, 0x268, 0x269, 0x26a, 0x26c, 0x26d, 0x26e,   // 10
+    0x26f, 0x270, 0x271, 0x272, 0x273, 0x275, 0x276, 0x277,
+    0x278, 0x279, 0x27a, 0x27b, 0x27d, 0x27e, 0x27f, 0x280,
+    0x281, 0x282, 0x284, 0x285, 0x286, 0x287, 0x288, 0x289,
+
+    0x28b, 0x28c, 0x28d, 0x28e, 0x28f, 0x290, 0x292, 0x293,   // 11
+    0x294, 0x295, 0x296, 0x298, 0x299, 0x29a, 0x29b, 0x29c,
+    0x29e, 0x29f, 0x2a0, 0x2a1, 0x2a2, 0x2a4, 0x2a5, 0x2a6,
+    0x2a7, 0x2a9, 0x2aa, 0x2ab, 0x2ac, 0x2ae, 0x2af, 0x2b0,
+
+    0x2b1, 0x2b2, 0x2b4, 0x2b5, 0x2b6, 0x2b7, 0x2b9, 0x2ba,   // 12
+    0x2bb, 0x2bd, 0x2be, 0x2bf, 0x2c0, 0x2c2, 0x2c3, 0x2c4,
+    0x2c5, 0x2c7, 0x2c8, 0x2c9, 0x2cb, 0x2cc, 0x2cd, 0x2ce,
+    0x2d0, 0x2d1, 0x2d2, 0x2d4, 0x2d5, 0x2d6, 0x2d8, 0x2d9,
+
+    0x2da, 0x2dc, 0x2dd, 0x2de, 0x2e0, 0x2e1, 0x2e2, 0x2e4,   // 13
+    0x2e5, 0x2e6, 0x2e8, 0x2e9, 0x2ea, 0x2ec, 0x2ed, 0x2ee,
+    0x2f0, 0x2f1, 0x2f2, 0x2f4, 0x2f5, 0x2f6, 0x2f8, 0x2f9,
+    0x2fb, 0x2fc, 0x2fd, 0x2ff, 0x300, 0x302, 0x303, 0x304,
+
+    0x306, 0x307, 0x309, 0x30a, 0x30b, 0x30d, 0x30e, 0x310,   // 14
+    0x311, 0x312, 0x314, 0x315, 0x317, 0x318, 0x31a, 0x31b,
+    0x31c, 0x31e, 0x31f, 0x321, 0x322, 0x324, 0x325, 0x327,
+    0x328, 0x329, 0x32b, 0x32c, 0x32e, 0x32f, 0x331, 0x332,
+
+    0x334, 0x335, 0x337, 0x338, 0x33a, 0x33b, 0x33d, 0x33e,   // 15
+    0x340, 0x341, 0x343, 0x344, 0x346, 0x347, 0x349, 0x34a,
+    0x34c, 0x34d, 0x34f, 0x350, 0x352, 0x353, 0x355, 0x357,
+    0x358, 0x35a, 0x35b, 0x35d, 0x35e, 0x360, 0x361, 0x363,
+
+    0x365, 0x366, 0x368, 0x369, 0x36b, 0x36c, 0x36e, 0x370,   // 16
+    0x371, 0x373, 0x374, 0x376, 0x378, 0x379, 0x37b, 0x37c,
+    0x37e, 0x380, 0x381, 0x383, 0x384, 0x386, 0x388, 0x389,
+    0x38b, 0x38d, 0x38e, 0x390, 0x392, 0x393, 0x395, 0x397,
+
+    0x398, 0x39a, 0x39c, 0x39d, 0x39f, 0x3a1, 0x3a2, 0x3a4,   // 17
+    0x3a6, 0x3a7, 0x3a9, 0x3ab, 0x3ac, 0x3ae, 0x3b0, 0x3b1,
+    0x3b3, 0x3b5, 0x3b7, 0x3b8, 0x3ba, 0x3bc, 0x3bd, 0x3bf,
+    0x3c1, 0x3c3, 0x3c4, 0x3c6, 0x3c8, 0x3ca, 0x3cb, 0x3cd,
+
+    // The last note has an incomplete range, and loops round back to
+    // the start.  Note that the last value is actually a buffer overrun
+    // and does not fit with the other values.
+
+    0x3cf, 0x3d1, 0x3d2, 0x3d4, 0x3d6, 0x3d8, 0x3da, 0x3db,   // 18
+    0x3dd, 0x3df, 0x3e1, 0x3e3, 0x3e4, 0x3e6, 0x3e8, 0x3ea,
+    0x3ec, 0x3ed, 0x3ef, 0x3f1, 0x3f3, 0x3f5, 0x3f6, 0x3f8,
+    0x3fa, 0x3fc, 0x3fe, 0x36c,
+};
+
+void OPLio::WriteFrequency(uint32_t channel, uint32_t note, uint32_t pitch, uint32_t keyon)
+{
+	int octave = 0;
+	int j = (note << 5) + pitch;
+
+	if (j < 0)
+	{
+		j = 0;
+	}
+	else if (j >= 284)
+	{
+		j -= 284;
+		octave = j / (32*12);
+		if (octave > 7)
+		{
+			octave = 7;
+		}
+		j = (j % (32*12)) + 284;
+	}
+	int i = frequencies[j] | (octave << 10);
+
+	WriteValue (OPL_REGS_FREQ_1, channel, (uint8_t)i);
+	WriteValue (OPL_REGS_FREQ_2, channel, (uint8_t)(i>>8)|(keyon<<5));
+}
+
+//----------------------------------------------------------------------------
+//
+// 
+//
+//----------------------------------------------------------------------------
+
+static uint8_t volumetable[128] = {
+	  0,   1,   3,   5,   6,   8,  10,  11,
+	 13,  14,  16,  17,  19,  20,  22,  23,
+	 25,  26,  27,  29,  30,  32,  33,  34,
+	 36,  37,  39,  41,  43,  45,  47,  49,
+	 50,  52,  54,  55,  57,  59,  60,  61,
+	 63,  64,  66,  67,  68,  69,  71,  72,
+	 73,  74,  75,  76,  77,  79,  80,  81,
+	 82,  83,  84,  84,  85,  86,  87,  88,
+	 89,  90,  91,  92,  92,  93,  94,  95,
+	 96,  96,  97,  98,  99,  99, 100, 101,
+	101, 102, 103, 103, 104, 105, 105, 106,
+	107, 107, 108, 109, 109, 110, 110, 111,
+	112, 112, 113, 113, 114, 114, 115, 115,
+	116, 117, 117, 118, 118, 119, 119, 120,
+	120, 121, 121, 122, 122, 123, 123, 123,
+	124, 124, 125, 125, 126, 126, 127, 127};
+
+void OPLio::WriteVolume(uint32_t channel, struct genmidi_voice_t *voice, uint32_t vol1, uint32_t vol2, uint32_t vol3)
+{
+	if (voice != nullptr)
+	{
+		uint32_t full_volume = volumetable[MIN<uint32_t>(127, (uint32_t)((uint64_t)vol1*vol2*vol3) / (127 * 127))];
+		int reg_volume2 = ((0x3f - voice->carrier.level) * full_volume) / 128;
+		reg_volume2 = (0x3f - reg_volume2) | voice->carrier.scale;
+		WriteOperator(OPL_REGS_LEVEL, channel, 1, reg_volume2);
+
+		int reg_volume1;
+		if (voice->feedback & 0x01)
+		{
+			// Chocolate Doom says:
+			// If we are using non-modulated feedback mode, we must set the
+			// volume for both voices.
+			// Note that the same register volume value is written for
+			// both voices, always calculated from the carrier's level
+			// value.
+
+			// But Muslib does it differently than the comment above states. Which one is correct?
+			
+			reg_volume1 = ((0x3f - voice->modulator.level) * full_volume) / 128;
+			reg_volume1 = (0x3f - reg_volume1) | voice->modulator.scale;
+		}
+		else
+		{
+			reg_volume1 = voice->modulator.level | voice->modulator.scale;
+		}
+		WriteOperator(OPL_REGS_LEVEL, channel, 0,reg_volume1);
+	}
+}
+
+
+//----------------------------------------------------------------------------
+//
+// 
+//
+//----------------------------------------------------------------------------
+
+void OPLio::WritePan(uint32_t channel, struct genmidi_voice_t *voice, int pan)
+{
+	if (voice != 0)
+	{
+		WriteValue(OPL_REGS_FEEDBACK, channel, voice->feedback | (pan >= 28 ? 0x20 : 0) | (pan <= 100 ? 0x10 : 0));
+
+		// Set real panning if we're using emulated chips.
+		int chanper = IsOPL3 ? OPL3_NUM_VOICES : OPL_NUM_VOICES;
+		int which = channel / chanper;
+		if (chips[which] != NULL)
+		{
+			// This is the MIDI-recommended pan formula. 0 and 1 are
+			// both hard left so that 64 can be perfectly center.
+			double level = (pan <= 1) ? 0 : (pan - 1) / 126.0;
+			chips[which]->SetPanning(channel % chanper,
+				(float)cos(HALF_PI * level), (float)sin(HALF_PI * level));
+		}
+	}
+}
+
+//----------------------------------------------------------------------------
+//
+// 
+//
+//----------------------------------------------------------------------------
+
+void OPLio::WriteTremolo(uint32_t channel, struct genmidi_voice_t *voice, bool vibrato)
+{
+	int val1 = voice->modulator.tremolo, val2 = voice->carrier.tremolo;
+	if (vibrato)
+	{
+		if (voice->feedback & 1) val1 |= 0x40;
+		val2 |= 0x40;
+	}
+	WriteOperator(OPL_REGS_TREMOLO, channel, 1, val2);
+	WriteOperator(OPL_REGS_TREMOLO, channel, 0, val2);
+}
+
+//----------------------------------------------------------------------------
+//
+// 
+//
+//----------------------------------------------------------------------------
+
+void OPLio::MuteChannel(uint32_t channel)
+{
+	WriteOperator(OPL_REGS_LEVEL, channel, 1, NO_VOLUME);
+	WriteOperator(OPL_REGS_ATTACK, channel, 1, MAX_ATTACK_DECAY);
+	WriteOperator(OPL_REGS_SUSTAIN, channel, 1, NO_SUSTAIN_MAX_RELEASE);
+
+	WriteOperator(OPL_REGS_LEVEL, channel, 0, NO_VOLUME);
+	WriteOperator(OPL_REGS_ATTACK, channel, 0, MAX_ATTACK_DECAY);
+	WriteOperator(OPL_REGS_SUSTAIN, channel, 0, NO_SUSTAIN_MAX_RELEASE);
+}
+
+//----------------------------------------------------------------------------
+//
+// 
+//
+//----------------------------------------------------------------------------
+
+void OPLio::LoadOperatorData(uint32_t channel, int op_index, genmidi_op_t *data, bool max_level, bool vibrato)
+{
+	// The scale and level fields must be combined for the level register.
+	// For the carrier wave we always set the maximum level.
+
+	int level = data->scale;
+	if (max_level) level |= 0x3f;
+	else level |= data->level;
+
+	int tremolo = data->tremolo;
+	if (vibrato) tremolo |= 0x40;
+
+	WriteOperator(OPL_REGS_LEVEL, channel, op_index, level);
+	WriteOperator(OPL_REGS_TREMOLO, channel, op_index, tremolo);
+	WriteOperator(OPL_REGS_ATTACK, channel, op_index, data->attack);
+	WriteOperator(OPL_REGS_SUSTAIN, channel, op_index, data->sustain);
+	WriteOperator(OPL_REGS_WAVEFORM, channel, op_index, data->waveform);
+}
+
+//----------------------------------------------------------------------------
+//
+// 
+//
+//----------------------------------------------------------------------------
+
+void OPLio::WriteInstrument(uint32_t channel, struct genmidi_voice_t *voice, bool vibrato)
+{
+	bool modulating = (voice->feedback & 0x01) == 0;
+
+	// Doom loads the second operator first, then the first.
+	// The carrier is set to minimum volume until the voice volume
+	// is set later.  If we are not using modulating mode, we must set both to minimum volume.
+
+	LoadOperatorData(channel, 1, &voice->carrier, true, vibrato);
+	LoadOperatorData(channel, 0, &voice->modulator, !modulating, vibrato && modulating);
+
+	// The feedback register is written by the calling code.
+}
diff --git a/src/sound/oplsynth/oplio.h b/src/sound/oplsynth/oplio.h
new file mode 100644
index 0000000000..94ad8b2f0d
--- /dev/null
+++ b/src/sound/oplsynth/oplio.h
@@ -0,0 +1,110 @@
+#pragma once
+
+
+enum
+{
+	// Operator registers (21 of each):
+	OPL_REGS_TREMOLO          = 0x20,
+	OPL_REGS_LEVEL            = 0x40,
+	OPL_REGS_ATTACK           = 0x60,
+	OPL_REGS_SUSTAIN          = 0x80,
+	OPL_REGS_WAVEFORM         = 0xE0,
+
+	// Voice registers (9 of each):
+	OPL_REGS_FREQ_1           = 0xA0,
+	OPL_REGS_FREQ_2           = 0xB0,
+	OPL_REGS_FEEDBACK         = 0xC0,
+};
+
+enum
+{
+	OPL_REG_WAVEFORM_ENABLE   = 0x01,
+	OPL_REG_TIMER1            = 0x02,
+	OPL_REG_TIMER2            = 0x03,
+	OPL_REG_TIMER_CTRL        = 0x04,
+	OPL_REG_FM_MODE           = 0x08,
+	OPL_REG_PERCUSSION_MODE   = 0xBD,
+	
+	OPL_REG_OPL3_ENABLE       = 0x105,
+	OPL_REG_4OPMODE_ENABLE    = 0x104,
+	
+};
+
+enum
+{
+	NO_VOLUME = 0x3f,
+	MAX_ATTACK_DECAY = 0xff,
+	NO_SUSTAIN_MAX_RELEASE = 0xf,
+	WAVEFORM_ENABLED = 0x20
+};
+
+enum
+{
+	OPL_NUM_VOICES	= 9,
+	OPL3_NUM_VOICES	= 18,
+	MAXOPL2CHIPS	= 8,
+	NUM_VOICES		= (OPL_NUM_VOICES * MAXOPL2CHIPS),
+
+	NUM_CHANNELS	= 16,
+	CHAN_PERCUSSION	= 15,
+
+	VIBRATO_THRESHOLD = 40,
+	MIN_SUSTAIN = 0x40,
+	HIGHEST_NOTE = 127,
+
+};
+
+struct genmidi_voice_t;
+
+struct OPLio 
+{
+	virtual ~OPLio();
+
+	void WriteOperator(uint32_t regbase, uint32_t channel, int index, uint8_t data2);
+	void LoadOperatorData(uint32_t channel, int op_index, genmidi_op_t *op_data, bool maxlevel, bool vibrato);
+	void WriteValue(uint32_t regbase, uint32_t channel, uint8_t value);
+	void WriteFrequency(uint32_t channel, uint32_t freq, uint32_t octave, uint32_t keyon);
+	void WriteVolume(uint32_t channel, genmidi_voice_t *voice, uint32_t v1, uint32_t v2, uint32_t v3);
+	void WritePan(uint32_t channel, genmidi_voice_t *voice, int pan);
+	void WriteTremolo(uint32_t channel, genmidi_voice_t *voice, bool vibrato);
+	void WriteInstrument(uint32_t channel, genmidi_voice_t *voice, bool vibrato);
+	void WriteInitState(bool opl3);
+	void MuteChannel(uint32_t chan);
+	void StopPlayback();
+
+	virtual int	 Init(uint32_t numchips, bool stereo = false, bool initopl3 = false);
+	virtual void Reset();
+	virtual void WriteRegister(int which, uint32_t reg, uint8_t data);
+	virtual void SetClockRate(double samples_per_tick);
+	virtual void WriteDelay(int ticks);
+
+	class OPLEmul *chips[OPL_NUM_VOICES];
+	uint32_t NumChannels;
+	uint32_t NumChips;
+	bool IsOPL3;
+};
+
+struct DiskWriterIO : public OPLio
+{
+	DiskWriterIO(const char *filename);
+	~DiskWriterIO();
+
+	int Init(uint32_t numchips, bool notused, bool initopl3);
+	void SetClockRate(double samples_per_tick);
+	void WriteDelay(int ticks);
+
+	FString Filename;
+};
+
+struct OPLChannel
+{
+	uint32_t Instrument;
+	uint8_t Volume;
+	uint8_t Panning;
+	int8_t Pitch;
+	uint8_t Sustain;
+	bool Vibrato;
+	uint8_t Expression;
+	uint16_t PitchSensitivity;
+	uint16_t RPN;
+};

From 79ed1f73e742db966a2d31b8d1164b27a764471b Mon Sep 17 00:00:00 2001
From: Christoph Oelckers <coelckers@users.noreply.github.com>
Date: Mon, 17 Apr 2017 00:46:27 +0200
Subject: [PATCH 11/29] - some minor cleanup, including renaming some data
 structutrd in the OPL code.

---
 .../mididevices/music_opl_mididevice.cpp      |  2 +-
 src/sound/oplsynth/genmidi.h                  |  6 +++---
 src/sound/oplsynth/musicblock.cpp             |  6 +++---
 src/sound/oplsynth/musicblock.h               | 20 ++++++++++++-------
 src/sound/oplsynth/opl_mus_player.h           |  5 ++++-
 src/sound/oplsynth/oplio.cpp                  |  8 ++++----
 src/sound/oplsynth/oplio.h                    | 10 +++++-----
 7 files changed, 33 insertions(+), 24 deletions(-)

diff --git a/src/sound/mididevices/music_opl_mididevice.cpp b/src/sound/mididevices/music_opl_mididevice.cpp
index fe09e0448f..d584d3ebd4 100644
--- a/src/sound/mididevices/music_opl_mididevice.cpp
+++ b/src/sound/mididevices/music_opl_mididevice.cpp
@@ -87,7 +87,7 @@ OPLMIDIDevice::OPLMIDIDevice(const char *args)
 	uint8_t filehdr[8];
 	data.Read(filehdr, 8);
 	if (memcmp(filehdr, "#OPL_II#", 8)) I_Error("Corrupt GENMIDI lump");
-	data.Read(OPLinstruments, sizeof(genmidi_instr_t) * GENMIDI_NUM_TOTAL);
+	data.Read(OPLinstruments, sizeof(GenMidiInstrument) * GENMIDI_NUM_TOTAL);
 	SampleRate = (int)OPL_SAMPLE_RATE;
 }
 
diff --git a/src/sound/oplsynth/genmidi.h b/src/sound/oplsynth/genmidi.h
index 76ac26a96d..f315f8245a 100644
--- a/src/sound/oplsynth/genmidi.h
+++ b/src/sound/oplsynth/genmidi.h
@@ -11,7 +11,7 @@ struct genmidi_op_t
 	uint8_t level;
 } FORCE_PACKED;
 
-struct genmidi_voice_t
+struct GenMidiVoice
 {
 	genmidi_op_t modulator;
 	uint8_t feedback;
@@ -21,12 +21,12 @@ struct genmidi_voice_t
 } FORCE_PACKED;
 
 
-struct genmidi_instr_t
+struct GenMidiInstrument
 {
 	uint16_t flags;
 	uint8_t fine_tuning;
 	uint8_t fixed_note;
-	genmidi_voice_t voices[2];
+	GenMidiVoice voices[2];
 } FORCE_PACKED;
 
 #pragma pack(pop)
diff --git a/src/sound/oplsynth/musicblock.cpp b/src/sound/oplsynth/musicblock.cpp
index e0a2314762..9a2c0d93ff 100644
--- a/src/sound/oplsynth/musicblock.cpp
+++ b/src/sound/oplsynth/musicblock.cpp
@@ -90,11 +90,11 @@ int musicBlock::replaceExistingVoice()
 //
 //----------------------------------------------------------------------------
 
-void musicBlock::voiceKeyOn(uint32_t slot, uint32_t channo, genmidi_instr_t *instrument, uint32_t instrument_voice, uint32_t key, uint32_t volume)
+void musicBlock::voiceKeyOn(uint32_t slot, uint32_t channo, GenMidiInstrument *instrument, uint32_t instrument_voice, uint32_t key, uint32_t volume)
 {
 	struct OPLVoice *voice = &voices[slot];
 	auto &channel = oplchannels[channo];
-	genmidi_voice_t *gmvoice;
+	GenMidiVoice *gmvoice;
 
 	voice->index = channo;
 	voice->key = key;
@@ -159,7 +159,7 @@ void musicBlock::noteOn(uint32_t channel, uint8_t key, int volume)
 		return;
 	}
 	uint32_t note;
-	genmidi_instr_t *instrument;
+	GenMidiInstrument *instrument;
 
 	// Percussion channel is treated differently.
 	if (channel == CHAN_PERCUSSION)
diff --git a/src/sound/oplsynth/musicblock.h b/src/sound/oplsynth/musicblock.h
index 1f13aa01f3..e806a45e6f 100644
--- a/src/sound/oplsynth/musicblock.h
+++ b/src/sound/oplsynth/musicblock.h
@@ -10,8 +10,8 @@ struct OPLVoice
 	unsigned int key;			// The midi key that this voice is playing.
 	unsigned int note;			// The note being played.  This is normally the same as the key, but if the instrument is a fixed pitch instrument, it is different.
 	unsigned int note_volume;	// The volume of the note being played on this channel.
-	genmidi_instr_t *current_instr;	// Currently-loaded instrument data
-	genmidi_voice_t *current_instr_voice;// The voice number in the instrument to use. This is normally set to the instrument's first voice; if this is a double voice instrument, it may be the second one
+	GenMidiInstrument *current_instr;	// Currently-loaded instrument data
+	GenMidiVoice *current_instr_voice;// The voice number in the instrument to use. This is normally set to the instrument's first voice; if this is a double voice instrument, it may be the second one
 	bool sustained;
 	int8_t	fine_tuning;
 	int	pitch;
@@ -21,13 +21,10 @@ struct musicBlock {
 	musicBlock();
 	~musicBlock();
 
-	uint8_t *score;
-	uint8_t *scoredata;
-	int playingcount;
 	OPLChannel oplchannels[NUM_CHANNELS];
 	OPLio *io;
 
-	struct genmidi_instr_t OPLinstruments[GENMIDI_NUM_TOTAL];
+	struct GenMidiInstrument OPLinstruments[GENMIDI_NUM_TOTAL];
 
 	void changeModulation(uint32_t id, int value);
 	void changeSustain(uint32_t id, int value);
@@ -50,9 +47,18 @@ protected:
 
 	int findFreeVoice();
 	int replaceExistingVoice();
-	void voiceKeyOn(uint32_t slot, uint32_t channo, genmidi_instr_t *instrument, uint32_t instrument_voice, uint32_t, uint32_t volume);
+	void voiceKeyOn(uint32_t slot, uint32_t channo, GenMidiInstrument *instrument, uint32_t instrument_voice, uint32_t, uint32_t volume);
 	int releaseVoice(uint32_t slot, uint32_t killed);
 
 	friend class Stat_opl;
 
 };
+
+enum ExtCtrl {
+	ctrlRPNHi,
+	ctrlRPNLo,
+	ctrlNRPNHi,
+	ctrlNRPNLo,
+	ctrlDataEntryHi,
+	ctrlDataEntryLo,
+};
diff --git a/src/sound/oplsynth/opl_mus_player.h b/src/sound/oplsynth/opl_mus_player.h
index a8ace69d2b..52ef4be764 100644
--- a/src/sound/oplsynth/opl_mus_player.h
+++ b/src/sound/oplsynth/opl_mus_player.h
@@ -1,5 +1,5 @@
 #include "critsec.h"
-#include "muslib.h"
+#include "musicblock.h"
 
 class FileReader;
 
@@ -18,6 +18,9 @@ protected:
 	virtual int PlayTick() = 0;
 	void OffsetSamples(float *buff, int count);
 
+	uint8_t *score;
+	uint8_t *scoredata;
+	int playingcount;
 	double NextTickIn;
 	double SamplesPerTick;
 	int NumChips;
diff --git a/src/sound/oplsynth/oplio.cpp b/src/sound/oplsynth/oplio.cpp
index 68b769db48..1229a5bbf3 100644
--- a/src/sound/oplsynth/oplio.cpp
+++ b/src/sound/oplsynth/oplio.cpp
@@ -353,7 +353,7 @@ static uint8_t volumetable[128] = {
 	120, 121, 121, 122, 122, 123, 123, 123,
 	124, 124, 125, 125, 126, 126, 127, 127};
 
-void OPLio::WriteVolume(uint32_t channel, struct genmidi_voice_t *voice, uint32_t vol1, uint32_t vol2, uint32_t vol3)
+void OPLio::WriteVolume(uint32_t channel, struct GenMidiVoice *voice, uint32_t vol1, uint32_t vol2, uint32_t vol3)
 {
 	if (voice != nullptr)
 	{
@@ -392,7 +392,7 @@ void OPLio::WriteVolume(uint32_t channel, struct genmidi_voice_t *voice, uint32_
 //
 //----------------------------------------------------------------------------
 
-void OPLio::WritePan(uint32_t channel, struct genmidi_voice_t *voice, int pan)
+void OPLio::WritePan(uint32_t channel, struct GenMidiVoice *voice, int pan)
 {
 	if (voice != 0)
 	{
@@ -418,7 +418,7 @@ void OPLio::WritePan(uint32_t channel, struct genmidi_voice_t *voice, int pan)
 //
 //----------------------------------------------------------------------------
 
-void OPLio::WriteTremolo(uint32_t channel, struct genmidi_voice_t *voice, bool vibrato)
+void OPLio::WriteTremolo(uint32_t channel, struct GenMidiVoice *voice, bool vibrato)
 {
 	int val1 = voice->modulator.tremolo, val2 = voice->carrier.tremolo;
 	if (vibrato)
@@ -478,7 +478,7 @@ void OPLio::LoadOperatorData(uint32_t channel, int op_index, genmidi_op_t *data,
 //
 //----------------------------------------------------------------------------
 
-void OPLio::WriteInstrument(uint32_t channel, struct genmidi_voice_t *voice, bool vibrato)
+void OPLio::WriteInstrument(uint32_t channel, struct GenMidiVoice *voice, bool vibrato)
 {
 	bool modulating = (voice->feedback & 0x01) == 0;
 
diff --git a/src/sound/oplsynth/oplio.h b/src/sound/oplsynth/oplio.h
index 94ad8b2f0d..93b7e281c2 100644
--- a/src/sound/oplsynth/oplio.h
+++ b/src/sound/oplsynth/oplio.h
@@ -54,7 +54,7 @@ enum
 
 };
 
-struct genmidi_voice_t;
+struct GenMidiVoice;
 
 struct OPLio 
 {
@@ -64,10 +64,10 @@ struct OPLio
 	void LoadOperatorData(uint32_t channel, int op_index, genmidi_op_t *op_data, bool maxlevel, bool vibrato);
 	void WriteValue(uint32_t regbase, uint32_t channel, uint8_t value);
 	void WriteFrequency(uint32_t channel, uint32_t freq, uint32_t octave, uint32_t keyon);
-	void WriteVolume(uint32_t channel, genmidi_voice_t *voice, uint32_t v1, uint32_t v2, uint32_t v3);
-	void WritePan(uint32_t channel, genmidi_voice_t *voice, int pan);
-	void WriteTremolo(uint32_t channel, genmidi_voice_t *voice, bool vibrato);
-	void WriteInstrument(uint32_t channel, genmidi_voice_t *voice, bool vibrato);
+	void WriteVolume(uint32_t channel, GenMidiVoice *voice, uint32_t v1, uint32_t v2, uint32_t v3);
+	void WritePan(uint32_t channel, GenMidiVoice *voice, int pan);
+	void WriteTremolo(uint32_t channel, GenMidiVoice *voice, bool vibrato);
+	void WriteInstrument(uint32_t channel, GenMidiVoice *voice, bool vibrato);
 	void WriteInitState(bool opl3);
 	void MuteChannel(uint32_t chan);
 	void StopPlayback();

From c219811a542e0d6aae38b920ae9e257c5c2286c1 Mon Sep 17 00:00:00 2001
From: Christoph Oelckers <coelckers@users.noreply.github.com>
Date: Mon, 17 Apr 2017 01:06:54 +0200
Subject: [PATCH 12/29] - removed FMod as the last remaining piece of code that
 is not GPL compatible.

Please consider GZDoom as licensed under the GPL starting with this commit, even though the license headers have not been changed yet.
---
 CMakeLists.txt                |    1 -
 src/CMakeLists.txt            |  180 +-
 src/menu/menudef.cpp          |    4 -
 src/s_sound.cpp               |    1 +
 src/sound/fmod_wrap.h         |  624 ------
 src/sound/fmodsound.cpp       | 3527 ---------------------------------
 src/sound/fmodsound.h         |  141 --
 src/sound/i_music.cpp         |    3 -
 src/sound/i_musicinterns.h    |    1 -
 src/sound/i_sound.cpp         |   33 +-
 src/sound/i_sound.h           |    1 -
 src/sound/music_midi_base.cpp |   17 -
 src/sound/oalsound.cpp        |    2 +-
 wadsrc/static/language.enu    |   13 -
 wadsrc/static/menudef.txt     |   63 +-
 15 files changed, 6 insertions(+), 4605 deletions(-)
 delete mode 100644 src/sound/fmod_wrap.h
 delete mode 100644 src/sound/fmodsound.cpp
 delete mode 100644 src/sound/fmodsound.h

diff --git a/CMakeLists.txt b/CMakeLists.txt
index e96249ff31..f426119c23 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -150,7 +150,6 @@ endif()
 
 set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}")
 
-option( NO_FMOD "Disable FMODEx sound support" OFF )
 option( NO_OPENAL "Disable OpenAL sound support" OFF )
 
 find_package( BZip2 )
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 54dce36caf..d303102b00 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -34,56 +34,6 @@ if( CMAKE_SIZEOF_VOID_P MATCHES "8" )
 	set( X64 64 )
 endif()
 
-# You can either use "make install" on the FMOD distribution to put it
-# in standard system locations, or you can unpack the FMOD distribution
-# in the root of the zdoom tree. e.g.:
-# zdoom
-#   docs
-#   fmodapi<version>linux[64] -or simply- fmod
-#   jpeg-6b
-#   ...
-# The recommended method is to put it in the zdoom tree, since its
-# headers are unversioned. Especially now that we can't work properly
-# with anything newer than 4.26.xx, you probably don't want to use
-# a system-wide version.
-
-# Construct version numbers for searching for the FMOD library on Linux.
-set( MINOR_VERSIONS "61" "50" "49" "48" "47" "46" "45" "44" "43" "42" "41"
-	"40" "39" "38" "37" "36" "35" "34" "33" "32" "31" "30" "29" "28"
-	"27" "26" "25" "24" "23" "22" "21" "20" "21" "19" "18" "17" "16"
-	"15" "14" "13" "12" "11" "10" "09" "08" "07" "06" "05" "04" "03"
-	"02" "01" "00" )
-set( MAJOR_VERSIONS "44" "34" "28" "26" "24" "22" "20" )
-
-if( NOT FMOD_DIR_VERSIONS )
-	set( FMOD_DIR_VERSIONS "" )
-endif()
-if( NOT FMOD_VERSIONS )
-	set( FMOD_VERSIONS "" )
-endif()
-if( NOT FMOD_LOCAL_INC_DIRS )
-	set( FMOD_LOCAL_INC_DIRS "" )
-endif()
-if( NOT FMOD_LOCAL_LIB_DIRS )
-	set( FMOD_LOCAL_LIB_DIRS "" )
-endif()
-
-set( FMOD_DIR_VERSIONS ${FMOD_DIR_VERSIONS} "../fmod" )
-foreach( majver ${MAJOR_VERSIONS} )
-	foreach( minver ${MINOR_VERSIONS} )
-		set( FMOD_VERSIONS ${FMOD_VERSIONS} "fmodex${X64}-4.${majver}.${minver}" )
-		# FMOD Ex version 4.44 unified 32-bit and 64-bit linux packages into one.
-		if( NOT majver EQUAL "44" )
-			set( FMOD_DIR_VERSIONS ${FMOD_DIR_VERSIONS} "${CMAKE_HOME_DIRECTORY}/fmodapi4${majver}${minver}linux${X64}" )
-		else()
-			set( FMOD_DIR_VERSIONS ${FMOD_DIR_VERSIONS} "${CMAKE_HOME_DIRECTORY}/fmodapi4${majver}${minver}linux" )
-		endif()
-	endforeach()
-	foreach( dir ${FMOD_DIR_VERSIONS} )
-		set( FMOD_LOCAL_INC_DIRS ${FMOD_LOCAL_INC_DIRS} "${dir}/api/inc" )
-		set( FMOD_LOCAL_LIB_DIRS ${FMOD_LOCAL_LIB_DIRS} "${dir}/api/lib" )
-	endforeach()
-endforeach()
 
 if( NOT ZDOOM_LIBS )
 	set( ZDOOM_LIBS "" )
@@ -100,15 +50,9 @@ if( WIN32 )
 	
 	add_definitions( -D_WIN32 )
 	
-	set( FMOD_SEARCH_PATHS
-		"C:/Program Files/FMOD SoundSystem/FMOD Programmers API ${WIN_TYPE}/api"
-		"C:/Program Files (x86)/FMOD SoundSystem/FMOD Programmers API ${WIN_TYPE}/api"
-		)
-	set( FMOD_INC_PATH_SUFFIXES PATH_SUFFIXES inc )
-	set( FMOD_LIB_PATH_SUFFIXES PATH_SUFFIXES lib )
 	
 	if( ( MSVC14 AND NOT CMAKE_GENERATOR_TOOLSET STREQUAL "v140_xp" ) OR	# For VS 2015.
-		( MSVC15 AND NOT CMAKE_GENERATOR_TOOLSET STREQUAL "v150_xp" ) )		# For VS 2017.
+		( MSVC15 AND NOT CMAKE_GENERATOR_TOOLSET STREQUAL "v141_xp" ) )		# For VS 2017.
 		# for modern Windows SDKs the DirectX headers should be available by default.
 		set( DX_dinput8_LIBRARY dinput8 )
 		set( DX_dxguid_LIBRARY dxguid )
@@ -189,9 +133,6 @@ if( WIN32 )
 	endif()
 else()
 	if( APPLE )
-		set( FMOD_SEARCH_PATHS "/Developer/FMOD Programmers API Mac/api" )
-		set( FMOD_INC_PATH_SUFFIXES PATH_SUFFIXES inc )
-		set( FMOD_LIB_PATH_SUFFIXES PATH_SUFFIXES lib )
 		set( NO_GTK ON )
 		set( DYN_GTK OFF )
 
@@ -204,17 +145,6 @@ else()
 		option( NO_GTK "Disable GTK+ dialogs (Not applicable to Windows)" )
 		option( DYN_GTK "Load GTK+ at runtime instead of compile time" ON )
 
-		set( FMOD_SEARCH_PATHS
-			/usr/local/include
-			/usr/local/include/fmodex
-			/usr/include
-			/usr/include/fmodex
-			/opt/local/include
-			/opt/local/include/fmodex
-			/opt/include
-			/opt/include/fmodex )
-		set( FMOD_INC_PATH_SUFFIXES PATH_SUFFIXES fmodex )
-
 		# Use GTK+ for the IWAD picker, if available.
 		if( NOT NO_GTK )
 			pkg_check_modules( GTK3 gtk+-3.0 )
@@ -281,82 +211,6 @@ if( NOT NO_OPENAL )
 	endif()
 endif()
 
-if( NOT NO_FMOD )
-	# Search for FMOD include files
-	if( NOT WIN32 )
-		find_path( FMOD_INCLUDE_DIR fmod.hpp
-			PATHS ${FMOD_LOCAL_INC_DIRS} )
-	endif()
-
-	if( NOT FMOD_INCLUDE_DIR )
-		find_path( FMOD_INCLUDE_DIR fmod.hpp
-			PATHS ${FMOD_SEARCH_PATHS}
-			${FMOD_INC_PATH_SUFFIXES} )
-	endif()
-
-	if( FMOD_INCLUDE_DIR )
-		message( STATUS "FMOD include files found at ${FMOD_INCLUDE_DIR}" )
-		include_directories( "${FMOD_INCLUDE_DIR}" )
-		
-		if( EXISTS "${FMOD_INCLUDE_DIR}/fmod_common.h" )
-			set( FMOD_STUDIO YES )
-			set( FMOD_VERSION_FILE "fmod_common.h" )
-		else()
-			set( FMOD_STUDIO NO )
-			set( FMOD_VERSION_FILE "fmod.h" )
-		endif()
-
-		file( STRINGS "${FMOD_INCLUDE_DIR}/${FMOD_VERSION_FILE}" FMOD_VERSION_LINE REGEX "^#define[ \t]+FMOD_VERSION[ \t]+0x[0-9]+$" )
-		string( REGEX REPLACE "^#define[ \t]+FMOD_VERSION[ \t]+0x([0-9][0-9][0-9][0-9])([0-9][0-9])([0-9][0-9])$" "\\1.\\2.\\3" FMOD_VERSION "${FMOD_VERSION_LINE}" )
-		message( STATUS "FMOD version: ${FMOD_VERSION}" )
-
-		# FMOD Ex didn't hide xiph symbols in the past (not applicable to Win32 since symbols are hidden by default there).
-		if( NOT WIN32 AND NOT FMOD_STUDIO AND NOT NO_OPENAL AND "${FMOD_VERSION}" VERSION_LESS "4.36.00")
-			message( SEND_ERROR "Use of FMOD Ex ${FMOD_VERSION} with OpenAL will result in crashes. Either update FMOD to 4.36 or later or set NO_OPENAL." )
-		endif()
-	else()
-		message( STATUS "Could not find FMOD include files" )
-		set( NO_FMOD ON )
-	endif()
-endif()
-
-if( NOT NO_FMOD )
-	# Decide on the name of the FMOD library we want to use.
-	if( NOT FMOD_LIB_NAME AND MSVC )
-		set( FMOD_LIB_NAME fmodex${X64}_vc )
-	endif()
-
-	if( NOT FMOD_LIB_NAME AND BORLAND )
-		set( FMOD_LIB_NAME fmodex${X64}_bc )
-	endif()
-
-	if( NOT FMOD_LIB_NAME )
-		set( FMOD_LIB_NAME fmodex${X64} )
-	endif()
-
-	# Search for FMOD library
-	if( WIN32 OR APPLE )
-		find_library( FMOD_LIBRARY ${FMOD_LIB_NAME}
-			PATHS ${FMOD_SEARCH_PATHS}
-			${FMOD_LIB_PATH_SUFFIXES} )
-	else()
-		find_library( FMOD_LIBRARY
-			NAMES ${FMOD_VERSIONS}
-			PATHS ${FMOD_LOCAL_LIB_DIRS} )
-	endif()
-
-	if( FMOD_LIBRARY )
-		message( STATUS "FMOD library found at ${FMOD_LIBRARY}" )
-		set( ZDOOM_LIBS ${ZDOOM_LIBS} "${FMOD_LIBRARY}" )
-	else()
-		message( STATUS "Could not find FMOD library" )
-		set( NO_FMOD ON )
-	endif()
-endif()
-
-if( NO_FMOD )
-	add_definitions( -DNO_FMOD=1 )
-endif()
 if( NO_OPENAL )
 	add_definitions( -DNO_OPENAL=1 )
 
@@ -683,10 +537,9 @@ elseif( APPLE )
 		set( OTHER_SYSTEM_SOURCES ${PLAT_WIN32_SOURCES} ${PLAT_COCOA_SOURCES} ${PLAT_UNIX_SOURCES} )
 	endif()
 
-	set( SYSTEM_SOURCES ${SYSTEM_SOURCES} ${PLAT_POSIX_SOURCES} ${PLAT_OSX_SOURCES} "${FMOD_LIBRARY}" )
+	set( SYSTEM_SOURCES ${SYSTEM_SOURCES} ${PLAT_POSIX_SOURCES} ${PLAT_OSX_SOURCES} )
 
 	set_source_files_properties( posix/osx/zdoom.icns PROPERTIES MACOSX_PACKAGE_LOCATION Resources )
-	set_source_files_properties( "${FMOD_LIBRARY}" PROPERTIES MACOSX_PACKAGE_LOCATION Frameworks )
 	set_source_files_properties( posix/osx/iwadpicker_cocoa.mm PROPERTIES COMPILE_FLAGS -fobjc-exceptions )
 else()
 	set( SYSTEM_SOURCES_DIR posix posix/sdl )
@@ -901,7 +754,6 @@ set( FASTMATH_SOURCES
 	swrenderer/r_all.cpp
 	polyrenderer/poly_all.cpp
 	sound/oplsynth/opl_mus_player.cpp
-	sound/fmodsound.cpp
 	sound/mpg123_decoder.cpp
 	sound/music_midi_base.cpp
 	sound/oalsound.cpp
@@ -1372,14 +1224,6 @@ if( MSVC )
 	option( ZDOOM_GENERATE_MAPFILE "Generate .map file for debugging." OFF )
 	set( LINKERSTUFF "/MANIFEST:NO" )
 
-	if( NOT NO_FMOD )
-		if( FMOD_STUDIO )
-			set( LINKERSTUFF "${LINKERSTUFF} /DELAYLOAD:\"fmod${X64}.dll\"" )
-		else()
-			set( LINKERSTUFF "${LINKERSTUFF} /DELAYLOAD:\"fmodex${X64}.dll\"" )
-		endif()
-	endif()
-
 	if( ZDOOM_GENERATE_MAPFILE )
 		set( LINKERSTUFF "${LINKERSTUFF} /MAP" )
 	endif()
@@ -1418,26 +1262,6 @@ if( APPLE )
 		LINK_FLAGS "-framework AudioToolbox -framework AudioUnit -framework Carbon -framework Cocoa -framework IOKit -framework OpenGL"
 		MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/posix/osx/zdoom-info.plist" )
 
-	if( NOT NO_FMOD )
-		if( FMOD_STUDIO )
-			set( FMOD_DYLIB libfmod.dylib )
-		else()
-			set( FMOD_DYLIB libfmodex.dylib )
-		endif()
-
-		# Fix fmod link so that it can be found in the app bundle.
-		find_program( OTOOL otool HINTS "/usr/bin" "${OSX_DEVELOPER_ROOT}/usr/bin" )
-		find_program( INSTALL_NAME_TOOL install_name_tool HINTS "/usr/bin" "${OSX_DEVELOPER_ROOT}/usr/bin" )
-		execute_process( COMMAND "${OTOOL}" -L "${FMOD_LIBRARY}"
-			COMMAND grep "${FMOD_DYLIB} (compat"
-			COMMAND head -n1
-			COMMAND awk "{print $1}"
-			OUTPUT_VARIABLE FMOD_LINK
-			OUTPUT_STRIP_TRAILING_WHITESPACE )
-		add_custom_command( TARGET zdoom POST_BUILD
-			COMMAND "${INSTALL_NAME_TOOL}" -change "${FMOD_LINK}" @executable_path/../Frameworks/${FMOD_DYLIB} "$<TARGET_FILE:zdoom>"
-			COMMENT "Relinking FMOD Ex" )
-	endif()
 endif()
 
 if( WIN32 )
diff --git a/src/menu/menudef.cpp b/src/menu/menudef.cpp
index a14ac25b32..d3a2ee49fe 100644
--- a/src/menu/menudef.cpp
+++ b/src/menu/menudef.cpp
@@ -247,10 +247,6 @@ static bool CheckSkipOptionBlock(FScanner &sc)
 		{
 			filter |= IsOpenALPresent();
 		}
-		else if (sc.Compare("FModEx"))
-		{
-			filter |= IsFModExPresent();
-		}
 	}
 	while (sc.CheckString(","));
 	sc.MustGetStringName(")");
diff --git a/src/s_sound.cpp b/src/s_sound.cpp
index 75f6a68a86..f5fc2ed13e 100644
--- a/src/s_sound.cpp
+++ b/src/s_sound.cpp
@@ -140,6 +140,7 @@ CUSTOM_CVAR (Int, snd_channels, 128, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)	// number o
 	if (self < 64) self = 64;
 }
 CVAR (Bool, snd_flipstereo, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
+CVAR(Bool, snd_waterreverb, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
 
 // CODE --------------------------------------------------------------------
 
diff --git a/src/sound/fmod_wrap.h b/src/sound/fmod_wrap.h
deleted file mode 100644
index 02d6a56ae3..0000000000
--- a/src/sound/fmod_wrap.h
+++ /dev/null
@@ -1,624 +0,0 @@
-
-#ifndef FMOD_WRAP_H
-#define FMOD_WRAP_H
-
-#ifndef NO_FMOD
-
-#if !defined(_WIN32) || defined(_MSC_VER)
-// Use the real C++ interface if it's supported on this platform.
-#include "fmod.hpp"
-#else
-// Use a wrapper C++ interface for non-Microsoft compilers on Windows.
-
-#include "fmod.h"
-
-// Create fake definitions for these structs so they can be subclassed.
-struct FMOD_SYSTEM {};
-struct FMOD_SOUND {};
-struct FMOD_CHANNEL {};
-struct FMOD_CHANNELGROUP {};
-struct FMOD_SOUNDGROUP {};
-struct FMOD_REVERB {};
-struct FMOD_DSP {};
-struct FMOD_DSPCONNECTION {};
-struct FMOD_POLYGON {};
-struct FMOD_GEOMETRY {};
-struct FMOD_SYNCPOINT {};
-/*
-	Constant and defines
-*/
-
-/*
-	FMOD Namespace
-*/
-
-namespace FMOD
-{
-
-	class System;
-	class Sound;
-	class Channel;
-	class ChannelGroup;
-	class SoundGroup;
-	class Reverb;
-	class DSP;
-	class DSPConnection;
-	class Geometry;
-
-	/*
-		FMOD global system functions (optional).
-	*/
-	inline FMOD_RESULT Memory_Initialize(void *poolmem, int poollen, FMOD_MEMORY_ALLOCCALLBACK useralloc, FMOD_MEMORY_REALLOCCALLBACK userrealloc, FMOD_MEMORY_FREECALLBACK userfree, FMOD_MEMORY_TYPE memtypeflags = (FMOD_MEMORY_NORMAL | FMOD_MEMORY_XBOX360_PHYSICAL)) { return FMOD_Memory_Initialize(poolmem, poollen, useralloc, userrealloc, userfree, memtypeflags); }
-	//inline FMOD_RESULT Memory_GetStats  (int *currentalloced, int *maxalloced) { return FMOD_Memory_GetStats(currentalloced, maxalloced); }
-	inline FMOD_RESULT Debug_SetLevel(FMOD_DEBUGLEVEL level)  { return FMOD_Debug_SetLevel(level); }
-	inline FMOD_RESULT Debug_GetLevel(FMOD_DEBUGLEVEL *level) { return FMOD_Debug_GetLevel(level); }
-	inline FMOD_RESULT File_SetDiskBusy(int busy) { return FMOD_File_SetDiskBusy(busy); }
-	inline FMOD_RESULT File_GetDiskBusy(int *busy) { return FMOD_File_GetDiskBusy(busy); }
-
-	/*
-		FMOD System factory functions.
-	*/
-	inline FMOD_RESULT System_Create(System **system) { return FMOD_System_Create((FMOD_SYSTEM **)system); }
-
-	/*
-	   'System' API
-	*/
-
-	class System : FMOD_SYSTEM
-	{
-	  private:
-
-		System();   /* Constructor made private so user cannot statically instance a System class.  
-					   System_Create must be used. */
-	  public:
-
-		  FMOD_RESULT release                () { return FMOD_System_Release(this); }
-
-		// Pre-init functions.
-		  FMOD_RESULT setOutput              (FMOD_OUTPUTTYPE output) { return FMOD_System_SetOutput(this, output); }
-		  FMOD_RESULT getOutput              (FMOD_OUTPUTTYPE *output) { return FMOD_System_GetOutput(this, output); }
-		  FMOD_RESULT getNumDrivers          (int *numdrivers) { return FMOD_System_GetNumDrivers(this, numdrivers); }
-		  FMOD_RESULT getDriverInfo          (int id, char *name, int namelen, FMOD_GUID *guid) { return FMOD_System_GetDriverInfo(this, id, name, namelen, guid); }
-		  FMOD_RESULT getDriverCaps          (int id, FMOD_CAPS *caps, int *minfrequency, int *maxfrequency, FMOD_SPEAKERMODE *controlpanelspeakermode) { return FMOD_System_GetDriverCaps(this, id, caps, minfrequency, maxfrequency, controlpanelspeakermode); }
-		  FMOD_RESULT setDriver              (int driver) { return FMOD_System_SetDriver(this, driver); }
-		  FMOD_RESULT getDriver              (int *driver) { return FMOD_System_GetDriver(this, driver); }
-		  FMOD_RESULT setHardwareChannels    (int min2d, int max2d, int min3d, int max3d) { return FMOD_System_SetHardwareChannels(this, min2d, max2d, min3d, max3d); }
-		  FMOD_RESULT setSoftwareChannels    (int numsoftwarechannels) { return FMOD_System_SetSoftwareChannels(this, numsoftwarechannels); }
-		  FMOD_RESULT getSoftwareChannels    (int *numsoftwarechannels) { return FMOD_System_GetSoftwareChannels(this, numsoftwarechannels); }
-		  FMOD_RESULT setSoftwareFormat      (int samplerate, FMOD_SOUND_FORMAT format, int numoutputchannels, int maxinputchannels, FMOD_DSP_RESAMPLER resamplemethod) { return FMOD_System_SetSoftwareFormat(this, samplerate, format, numoutputchannels, maxinputchannels, resamplemethod); }
-		  FMOD_RESULT getSoftwareFormat      (int *samplerate, FMOD_SOUND_FORMAT *format, int *numoutputchannels, int *maxinputchannels, FMOD_DSP_RESAMPLER *resamplemethod, int *bits) { return FMOD_System_GetSoftwareFormat(this, samplerate, format, numoutputchannels, maxinputchannels, resamplemethod, bits); }
-		  FMOD_RESULT setDSPBufferSize       (unsigned int bufferlength, int numbuffers) { return FMOD_System_SetDSPBufferSize(this, bufferlength, numbuffers); }
-		  FMOD_RESULT getDSPBufferSize       (unsigned int *bufferlength, int *numbuffers) { return FMOD_System_GetDSPBufferSize(this, bufferlength, numbuffers); }
-		  FMOD_RESULT setFileSystem          (FMOD_FILE_OPENCALLBACK useropen, FMOD_FILE_CLOSECALLBACK userclose, FMOD_FILE_READCALLBACK userread, FMOD_FILE_SEEKCALLBACK userseek, int blockalign) { return FMOD_System_SetFileSystem(this, useropen, userclose, userread, userseek, blockalign); }
-		  FMOD_RESULT attachFileSystem       (FMOD_FILE_OPENCALLBACK useropen, FMOD_FILE_CLOSECALLBACK userclose, FMOD_FILE_READCALLBACK userread, FMOD_FILE_SEEKCALLBACK userseek) { return FMOD_System_AttachFileSystem(this, useropen, userclose, userread, userseek); }
-		  FMOD_RESULT setAdvancedSettings    (FMOD_ADVANCEDSETTINGS *settings) { return FMOD_System_SetAdvancedSettings(this, settings); }
-		  FMOD_RESULT getAdvancedSettings    (FMOD_ADVANCEDSETTINGS *settings) { return FMOD_System_GetAdvancedSettings(this, settings); }
-		  FMOD_RESULT setSpeakerMode         (FMOD_SPEAKERMODE speakermode) { return FMOD_System_SetSpeakerMode(this, speakermode); }
-		  FMOD_RESULT getSpeakerMode         (FMOD_SPEAKERMODE *speakermode) { return FMOD_System_GetSpeakerMode(this, speakermode); }
-		  FMOD_RESULT setCallback            (FMOD_SYSTEM_CALLBACK callback) { return FMOD_System_SetCallback(this, callback); }
-
-		// Plug-in support
-		  FMOD_RESULT setPluginPath          (const char *path) { return FMOD_System_SetPluginPath(this, path); }
-		  FMOD_RESULT loadPlugin             (const char *filename, unsigned int *handle, unsigned int priority = 0) { return FMOD_System_LoadPlugin(this, filename, handle, priority); }
-		  FMOD_RESULT unloadPlugin           (unsigned int handle) { return FMOD_System_UnloadPlugin(this, handle); }
-		  FMOD_RESULT getNumPlugins          (FMOD_PLUGINTYPE plugintype, int *numplugins) { return FMOD_System_GetNumPlugins(this, plugintype, numplugins); }
-		  FMOD_RESULT getPluginHandle        (FMOD_PLUGINTYPE plugintype, int index, unsigned int *handle) { return FMOD_System_GetPluginHandle(this, plugintype, index, handle); }
-		  FMOD_RESULT getPluginInfo          (unsigned int handle, FMOD_PLUGINTYPE *plugintype, char *name, int namelen, unsigned int *version) { return FMOD_System_GetPluginInfo(this, handle, plugintype, name, namelen, version); }
-		  FMOD_RESULT setOutputByPlugin      (unsigned int handle) { return FMOD_System_SetOutputByPlugin(this, handle); }
-		  FMOD_RESULT getOutputByPlugin      (unsigned int *handle) { return FMOD_System_GetOutputByPlugin(this, handle); }
-		  FMOD_RESULT createCodec            (FMOD_CODEC_DESCRIPTION *description, unsigned int priority = 0) { return FMOD_System_CreateCodec(this, description, priority); }
-
-		// Init/Close
-		  FMOD_RESULT init                   (int maxchannels, FMOD_INITFLAGS flags, void *extradriverdata) { return FMOD_System_Init(this, maxchannels, flags, extradriverdata); }
-		  FMOD_RESULT close                  () { return FMOD_System_Close(this); }
-
-		// General post-init system functions
-		  FMOD_RESULT update                 ()        /* IMPORTANT! CALL THIS ONCE PER FRAME! */ { return FMOD_System_Update(this); }
-
-		  FMOD_RESULT set3DSettings          (float dopplerscale, float distancefactor, float rolloffscale) { return FMOD_System_Set3DSettings(this, dopplerscale, distancefactor, rolloffscale); }
-		  FMOD_RESULT get3DSettings          (float *dopplerscale, float *distancefactor, float *rolloffscale) { return FMOD_System_Get3DSettings(this, dopplerscale, distancefactor, rolloffscale); }
-		  FMOD_RESULT set3DNumListeners      (int numlisteners) { return FMOD_System_Set3DNumListeners(this, numlisteners); }
-		  FMOD_RESULT get3DNumListeners      (int *numlisteners) { return FMOD_System_Get3DNumListeners(this, numlisteners); }
-		  FMOD_RESULT set3DListenerAttributes(int listener, const FMOD_VECTOR *pos, const FMOD_VECTOR *vel, const FMOD_VECTOR *forward, const FMOD_VECTOR *up) { return FMOD_System_Set3DListenerAttributes(this, listener, pos, vel, forward, up); }
-		  FMOD_RESULT get3DListenerAttributes(int listener, FMOD_VECTOR *pos, FMOD_VECTOR *vel, FMOD_VECTOR *forward, FMOD_VECTOR *up) { return FMOD_System_Get3DListenerAttributes(this, listener, pos, vel, forward, up); }
-		  FMOD_RESULT set3DRolloffCallback   (FMOD_3D_ROLLOFFCALLBACK callback) { return FMOD_System_Set3DRolloffCallback(this, callback); }
-		  FMOD_RESULT set3DSpeakerPosition   (FMOD_SPEAKER speaker, float x, float y, bool active) { return FMOD_System_Set3DSpeakerPosition(this, speaker, x, y, active); }
-		  FMOD_RESULT get3DSpeakerPosition   (FMOD_SPEAKER speaker, float *x, float *y, bool *active) { FMOD_BOOL b; FMOD_RESULT res = FMOD_System_Get3DSpeakerPosition(this, speaker, x, y, &b); *active = b; return res; }
-
-		  FMOD_RESULT setStreamBufferSize    (unsigned int filebuffersize, FMOD_TIMEUNIT filebuffersizetype) { return FMOD_System_SetStreamBufferSize(this, filebuffersize, filebuffersizetype); }
-		  FMOD_RESULT getStreamBufferSize    (unsigned int *filebuffersize, FMOD_TIMEUNIT *filebuffersizetype) { return FMOD_System_GetStreamBufferSize(this, filebuffersize, filebuffersizetype); }
-
-		// System information functions.
-		  FMOD_RESULT getVersion             (unsigned int *version) { return FMOD_System_GetVersion(this, version); }
-		  FMOD_RESULT getOutputHandle        (void **handle) { return FMOD_System_GetOutputHandle(this, handle); }
-		  FMOD_RESULT getChannelsPlaying     (int *channels) { return FMOD_System_GetChannelsPlaying(this, channels); }
-		  FMOD_RESULT getHardwareChannels    (int *num2d, int *num3d, int *total) { return FMOD_System_GetHardwareChannels(this, num2d, num3d, total); }
-#if FMOD_VERSION < 0x42501
-		  FMOD_RESULT getCPUUsage            (float *dsp, float *stream, float *update, float *total) { return FMOD_System_GetCPUUsage(this, dsp, stream, update, total); }
-#else
-		  FMOD_RESULT getCPUUsage            (float *dsp, float *stream, float *geometry, float *update, float *total) { return FMOD_System_GetCPUUsage(this, dsp, stream, geometry, update, total); }
-#endif
-		  FMOD_RESULT getSoundRAM            (int *currentalloced, int *maxalloced, int *total) { return FMOD_System_GetSoundRAM(this, currentalloced, maxalloced, total); }
-		  FMOD_RESULT getNumCDROMDrives      (int *numdrives) { return FMOD_System_GetNumCDROMDrives(this, numdrives); }
-		  FMOD_RESULT getCDROMDriveName      (int drive, char *drivename, int drivenamelen, char *scsiname, int scsinamelen, char *devicename, int devicenamelen) { return FMOD_System_GetCDROMDriveName(this, drive, drivename, drivenamelen, scsiname, scsinamelen, devicename, devicenamelen); }
-		  FMOD_RESULT getSpectrum            (float *spectrumarray, int numvalues, int channeloffset, FMOD_DSP_FFT_WINDOW windowtype) { return FMOD_System_GetSpectrum(this, spectrumarray, numvalues, channeloffset, windowtype); }
-		  FMOD_RESULT getWaveData            (float *wavearray, int numvalues, int channeloffset) { return FMOD_System_GetWaveData(this, wavearray, numvalues, channeloffset); }
-
-		// Sound/DSP/Channel/FX creation and retrieval.
-		  FMOD_RESULT createSound            (const char *name_or_data, FMOD_MODE mode, FMOD_CREATESOUNDEXINFO *exinfo, Sound **sound) { return FMOD_System_CreateSound(this, name_or_data, mode, exinfo, (FMOD_SOUND **)sound); }
-		  FMOD_RESULT createStream           (const char *name_or_data, FMOD_MODE mode, FMOD_CREATESOUNDEXINFO *exinfo, Sound **sound) { return FMOD_System_CreateStream(this, name_or_data, mode, exinfo, (FMOD_SOUND **)sound); }
-		  FMOD_RESULT createDSP              (FMOD_DSP_DESCRIPTION *description, DSP **dsp) { return FMOD_System_CreateDSP(this, description, (FMOD_DSP **)dsp); }
-		  FMOD_RESULT createDSPByType        (FMOD_DSP_TYPE type, DSP **dsp) { return FMOD_System_CreateDSPByType(this, type, (FMOD_DSP **)dsp); }
-		  FMOD_RESULT createChannelGroup     (const char *name, ChannelGroup **channelgroup) { return FMOD_System_CreateChannelGroup(this, name, (FMOD_CHANNELGROUP **)channelgroup); }
-		  FMOD_RESULT createSoundGroup       (const char *name, SoundGroup **soundgroup) { return FMOD_System_CreateSoundGroup(this, name, (FMOD_SOUNDGROUP **)soundgroup); }
-		  FMOD_RESULT createReverb           (Reverb **reverb) { return FMOD_System_CreateReverb(this, (FMOD_REVERB **)reverb); }
-
-		  FMOD_RESULT playSound              (FMOD_CHANNELINDEX channelid, Sound *sound, bool paused, Channel **channel) { return FMOD_System_PlaySound(this, channelid, (FMOD_SOUND *)sound, paused, (FMOD_CHANNEL **)channel); }
-		  FMOD_RESULT playDSP                (FMOD_CHANNELINDEX channelid, DSP *dsp, bool paused, Channel **channel) { return FMOD_System_PlayDSP(this, channelid, (FMOD_DSP *)dsp, paused, (FMOD_CHANNEL **)channel); }
-		  FMOD_RESULT getChannel             (int channelid, Channel **channel) { return FMOD_System_GetChannel(this, channelid, (FMOD_CHANNEL **)channel); }
-		  FMOD_RESULT getMasterChannelGroup  (ChannelGroup **channelgroup) { return FMOD_System_GetMasterChannelGroup(this, (FMOD_CHANNELGROUP **)channelgroup); }
-		  FMOD_RESULT getMasterSoundGroup    (SoundGroup **soundgroup) { return FMOD_System_GetMasterSoundGroup(this, (FMOD_SOUNDGROUP **)soundgroup); }
-
-		// Reverb API
-		  FMOD_RESULT setReverbProperties    (const FMOD_REVERB_PROPERTIES *prop) { return FMOD_System_SetReverbProperties(this, prop); }
-		  FMOD_RESULT getReverbProperties    (FMOD_REVERB_PROPERTIES *prop) { return FMOD_System_GetReverbProperties(this, prop); }
-		  FMOD_RESULT setReverbAmbientProperties(FMOD_REVERB_PROPERTIES *prop) { return FMOD_System_SetReverbAmbientProperties(this, prop); }
-		  FMOD_RESULT getReverbAmbientProperties(FMOD_REVERB_PROPERTIES *prop) { return FMOD_System_GetReverbAmbientProperties(this, prop); }
-
-		// System level DSP access.
-		  FMOD_RESULT getDSPHead             (DSP **dsp) { return FMOD_System_GetDSPHead(this, (FMOD_DSP **)dsp); }
-		  FMOD_RESULT addDSP                 (DSP *dsp, DSPConnection **connection) { return FMOD_System_AddDSP(this, (FMOD_DSP *)dsp, (FMOD_DSPCONNECTION**)dsp); }
-		  FMOD_RESULT lockDSP                () { return FMOD_System_LockDSP(this); }
-		  FMOD_RESULT unlockDSP              () { return FMOD_System_UnlockDSP(this); }
-		  FMOD_RESULT getDSPClock            (unsigned int *hi, unsigned int *lo) { return FMOD_System_GetDSPClock(this, hi, lo); }
-
-		// Recording API.
-		  FMOD_RESULT getRecordNumDrivers    (int *numdrivers) { return FMOD_System_GetRecordNumDrivers(this, numdrivers); }
-		  FMOD_RESULT getRecordDriverInfo    (int id, char *name, int namelen, FMOD_GUID *guid) { return FMOD_System_GetRecordDriverInfo(this, id, name, namelen, guid); }
-		  FMOD_RESULT getRecordDriverCaps    (int id, FMOD_CAPS *caps, int *minfrequency, int *maxfrequency) { return FMOD_System_GetRecordDriverCaps(this, id, caps, minfrequency, maxfrequency); }
-		  FMOD_RESULT getRecordPosition      (int id, unsigned int *position) { return FMOD_System_GetRecordPosition(this, id, position); }
-
-		  FMOD_RESULT recordStart            (int id, Sound *sound, bool loop) { return FMOD_System_RecordStart(this, id, (FMOD_SOUND *)sound, loop); }
-		  FMOD_RESULT recordStop             (int id) { return FMOD_System_RecordStop(this, id); }
-		  FMOD_RESULT isRecording            (int id, bool *recording) { FMOD_BOOL b; FMOD_RESULT res = FMOD_System_IsRecording(this, id, &b); *recording = b; return res; }
-
-		// Geometry API.
-		  FMOD_RESULT createGeometry         (int maxpolygons, int maxvertices, Geometry **geometry) { return FMOD_System_CreateGeometry(this, maxpolygons, maxvertices, (FMOD_GEOMETRY **)geometry); }
-		  FMOD_RESULT setGeometrySettings    (float maxworldsize) { return FMOD_System_SetGeometrySettings(this, maxworldsize); }
-		  FMOD_RESULT getGeometrySettings    (float *maxworldsize) { return FMOD_System_GetGeometrySettings(this, maxworldsize); }
-		  FMOD_RESULT loadGeometry           (const void *data, int datasize, Geometry **geometry) { return FMOD_System_LoadGeometry(this, data, datasize, (FMOD_GEOMETRY **)geometry); }
-
-		// Network functions.
-		  FMOD_RESULT setNetworkProxy        (const char *proxy) { return FMOD_System_SetNetworkProxy(this, proxy); }
-		  FMOD_RESULT getNetworkProxy        (char *proxy, int proxylen) { return FMOD_System_GetNetworkProxy(this, proxy, proxylen); }
-		  FMOD_RESULT setNetworkTimeout      (int timeout) { return FMOD_System_SetNetworkTimeout(this, timeout); }
-		  FMOD_RESULT getNetworkTimeout      (int *timeout) { return FMOD_System_GetNetworkTimeout(this, timeout); }
-
-		// Userdata set/get.
-		  FMOD_RESULT setUserData            (void *userdata) { return FMOD_System_SetUserData(this, userdata); }
-		  FMOD_RESULT getUserData            (void **userdata) { return FMOD_System_GetUserData(this, userdata); }
-
-		  FMOD_RESULT getMemoryInfo          (unsigned int memorybits, unsigned int event_memorybits, unsigned int *memoryused, unsigned int *memoryused_array) { return FMOD_System_GetMemoryInfo(this, memorybits, event_memorybits, memoryused, memoryused_array); }
-	};
-
-	/*
-		'Sound' API
-	*/
-	class Sound : FMOD_SOUND
-	{
-	  private:
-
-		Sound();   /* Constructor made private so user cannot statically instance a Sound class.
-					  Appropriate Sound creation or retrieval function must be used. */
-	  public:
-
-		  FMOD_RESULT release                () { return FMOD_Sound_Release(this); }
-		  FMOD_RESULT getSystemObject        (System **system) { return FMOD_Sound_GetSystemObject(this, (FMOD_SYSTEM **)system); }
-
-		// Standard sound manipulation functions.
-		  FMOD_RESULT lock                   (unsigned int offset, unsigned int length, void **ptr1, void **ptr2, unsigned int *len1, unsigned int *len2) { return FMOD_Sound_Lock(this, offset, length, ptr1, ptr2, len1, len2); }
-		  FMOD_RESULT unlock                 (void *ptr1, void *ptr2, unsigned int len1, unsigned int len2) { return FMOD_Sound_Unlock(this, ptr1, ptr2, len1, len2); }
-		  FMOD_RESULT setDefaults            (float frequency, float volume, float pan, int priority) { return FMOD_Sound_SetDefaults(this, frequency, volume, pan, priority); }
-		  FMOD_RESULT getDefaults            (float *frequency, float *volume, float *pan, int *priority) { return FMOD_Sound_GetDefaults(this, frequency, volume, pan, priority); }
-		  FMOD_RESULT setVariations          (float frequencyvar, float volumevar, float panvar) { return FMOD_Sound_SetVariations(this, frequencyvar, volumevar, panvar); }
-		  FMOD_RESULT getVariations          (float *frequencyvar, float *volumevar, float *panvar) { return FMOD_Sound_GetVariations(this, frequencyvar, volumevar, panvar); }
-		  FMOD_RESULT set3DMinMaxDistance    (float min, float max) { return FMOD_Sound_Set3DMinMaxDistance(this, min, max); }
-		  FMOD_RESULT get3DMinMaxDistance    (float *min, float *max) { return FMOD_Sound_Get3DMinMaxDistance(this, min, max); }
-		  FMOD_RESULT set3DConeSettings      (float insideconeangle, float outsideconeangle, float outsidevolume) { return FMOD_Sound_Set3DConeSettings(this, insideconeangle, outsideconeangle, outsidevolume); }
-		  FMOD_RESULT get3DConeSettings      (float *insideconeangle, float *outsideconeangle, float *outsidevolume) { return FMOD_Sound_Get3DConeSettings(this, insideconeangle, outsideconeangle, outsidevolume); }
-		  FMOD_RESULT set3DCustomRolloff     (FMOD_VECTOR *points, int numpoints) { return FMOD_Sound_Set3DCustomRolloff(this, points, numpoints); }
-		  FMOD_RESULT get3DCustomRolloff     (FMOD_VECTOR **points, int *numpoints) { return FMOD_Sound_Get3DCustomRolloff(this, points, numpoints); }
-		  FMOD_RESULT setSubSound            (int index, Sound *subsound) { return FMOD_Sound_SetSubSound(this, index, subsound); }
-		  FMOD_RESULT getSubSound            (int index, Sound **subsound) { return FMOD_Sound_GetSubSound(this, index, (FMOD_SOUND **)subsound); }
-		  FMOD_RESULT setSubSoundSentence    (int *subsoundlist, int numsubsounds) { return FMOD_Sound_SetSubSoundSentence(this, subsoundlist, numsubsounds); }
-		  FMOD_RESULT getName                (char *name, int namelen) { return FMOD_Sound_GetName(this, name, namelen); }
-		  FMOD_RESULT getLength              (unsigned int *length, FMOD_TIMEUNIT lengthtype) { return FMOD_Sound_GetLength(this, length, lengthtype); }
-		  FMOD_RESULT getFormat              (FMOD_SOUND_TYPE *type, FMOD_SOUND_FORMAT *format, int *channels, int *bits) { return FMOD_Sound_GetFormat(this, type, format, channels, bits); }
-		  FMOD_RESULT getNumSubSounds        (int *numsubsounds) { return FMOD_Sound_GetNumSubSounds(this, numsubsounds); }
-		  FMOD_RESULT getNumTags             (int *numtags, int *numtagsupdated) { return FMOD_Sound_GetNumTags(this, numtags, numtagsupdated); }
-		  FMOD_RESULT getTag                 (const char *name, int index, FMOD_TAG *tag) { return FMOD_Sound_GetTag(this, name, index, tag); }
-		  FMOD_RESULT getOpenState           (FMOD_OPENSTATE *openstate, unsigned int *percentbuffered, bool *starving) { FMOD_BOOL b; FMOD_RESULT res = FMOD_Sound_GetOpenState(this, openstate, percentbuffered, &b); *starving = b; return res; }
-		  FMOD_RESULT readData               (void *buffer, unsigned int lenbytes, unsigned int *read) { return FMOD_Sound_ReadData(this, buffer, lenbytes, read); }
-		  FMOD_RESULT seekData               (unsigned int pcm) { return FMOD_Sound_SeekData(this, pcm); }
-
-		  FMOD_RESULT setSoundGroup          (SoundGroup *soundgroup) { return FMOD_Sound_SetSoundGroup(this, (FMOD_SOUNDGROUP *)soundgroup); }
-		  FMOD_RESULT getSoundGroup          (SoundGroup **soundgroup) { return FMOD_Sound_GetSoundGroup(this, (FMOD_SOUNDGROUP **)soundgroup); }
-
-		// Synchronization point API.  These points can come from markers embedded in wav files, and can also generate channel callbacks.        
-		  FMOD_RESULT getNumSyncPoints       (int *numsyncpoints) { return FMOD_Sound_GetNumSyncPoints(this, numsyncpoints); }
-		  FMOD_RESULT getSyncPoint           (int index, FMOD_SYNCPOINT **point) { return FMOD_Sound_GetSyncPoint(this, index, point); }
-		  FMOD_RESULT getSyncPointInfo       (FMOD_SYNCPOINT *point, char *name, int namelen, unsigned int *offset, FMOD_TIMEUNIT offsettype) { return FMOD_Sound_GetSyncPointInfo(this, point, name, namelen, offset, offsettype); }
-		  FMOD_RESULT addSyncPoint           (unsigned int offset, FMOD_TIMEUNIT offsettype, const char *name, FMOD_SYNCPOINT **point) { return FMOD_Sound_AddSyncPoint(this, offset, offsettype, name, point); }
-		  FMOD_RESULT deleteSyncPoint        (FMOD_SYNCPOINT *point) { return FMOD_Sound_DeleteSyncPoint(this, point); }
-
-		// Functions also in Channel class but here they are the 'default' to save having to change it in Channel all the time.
-		  FMOD_RESULT setMode                (FMOD_MODE mode) { return FMOD_Sound_SetMode(this, mode); }
-		  FMOD_RESULT getMode                (FMOD_MODE *mode) { return FMOD_Sound_GetMode(this, mode); }
-		  FMOD_RESULT setLoopCount           (int loopcount) { return FMOD_Sound_SetLoopCount(this, loopcount); }
-		  FMOD_RESULT getLoopCount           (int *loopcount) { return FMOD_Sound_GetLoopCount(this, loopcount); }
-		  FMOD_RESULT setLoopPoints          (unsigned int loopstart, FMOD_TIMEUNIT loopstarttype, unsigned int loopend, FMOD_TIMEUNIT loopendtype) { return FMOD_Sound_SetLoopPoints(this, loopstart, loopstarttype, loopend, loopendtype); }
-		  FMOD_RESULT getLoopPoints          (unsigned int *loopstart, FMOD_TIMEUNIT loopstarttype, unsigned int *loopend, FMOD_TIMEUNIT loopendtype) { return FMOD_Sound_GetLoopPoints(this, loopstart, loopstarttype, loopend, loopendtype); }
-
-		// Userdata set/get.
-		  FMOD_RESULT setUserData            (void *userdata) { return FMOD_Sound_SetUserData(this, userdata); }
-		  FMOD_RESULT getUserData            (void **userdata) { return FMOD_Sound_GetUserData(this, userdata); }
-
-		  FMOD_RESULT getMemoryInfo          (unsigned int memorybits, unsigned int event_memorybits, unsigned int *memoryused, unsigned int *memoryused_array) { return FMOD_Sound_GetMemoryInfo(this, memorybits, event_memorybits, memoryused, memoryused_array); }
-	};
-
-	/*
-		'Channel' API.
-	*/ 
-	class Channel : FMOD_CHANNEL
-	{
-	  private:
-
-		Channel();   /* Constructor made private so user cannot statically instance a Channel class.
-						Appropriate Channel creation or retrieval function must be used. */
-	  public:
-
-		  FMOD_RESULT getSystemObject        (System **system) { return FMOD_Channel_GetSystemObject(this, (FMOD_SYSTEM **)system); }
-
-		  FMOD_RESULT stop                   () { return FMOD_Channel_Stop(this); }
-		  FMOD_RESULT setPaused              (bool paused) { return FMOD_Channel_SetPaused(this, paused); }
-		  FMOD_RESULT getPaused              (bool *paused) { FMOD_BOOL b; FMOD_RESULT res = FMOD_Channel_GetPaused(this, &b); *paused = b; return res; }
-		  FMOD_RESULT setVolume              (float volume) { return FMOD_Channel_SetVolume(this, volume); }
-		  FMOD_RESULT getVolume              (float *volume) { return FMOD_Channel_GetVolume(this, volume); }
-		  FMOD_RESULT setFrequency           (float frequency) { return FMOD_Channel_SetFrequency(this, frequency); }
-		  FMOD_RESULT getFrequency           (float *frequency) { return FMOD_Channel_GetFrequency(this, frequency); }
-		  FMOD_RESULT setPan                 (float pan) { return FMOD_Channel_SetPan(this, pan); }
-		  FMOD_RESULT getPan                 (float *pan) { return FMOD_Channel_GetPan(this, pan); }
-		  FMOD_RESULT setDelay               (FMOD_DELAYTYPE delaytype, unsigned int delayhi, unsigned int delaylo) { return FMOD_Channel_SetDelay(this, delaytype, delayhi, delaylo); }
-		  FMOD_RESULT getDelay               (FMOD_DELAYTYPE delaytype, unsigned int *delayhi, unsigned int *delaylo) { return FMOD_Channel_GetDelay(this, delaytype, delayhi, delaylo); }
-		  FMOD_RESULT setSpeakerMix          (float frontleft, float frontright, float center, float lfe, float backleft, float backright, float sideleft, float sideright) { return FMOD_Channel_SetSpeakerMix(this, frontleft, frontright, center, lfe, backleft, backright, sideleft, sideright); }
-		  FMOD_RESULT getSpeakerMix          (float *frontleft, float *frontright, float *center, float *lfe, float *backleft, float *backright, float *sideleft, float *sideright) { return FMOD_Channel_GetSpeakerMix(this, frontleft, frontright, center, lfe, backleft, backright, sideleft, sideright); }
-		  FMOD_RESULT setSpeakerLevels       (FMOD_SPEAKER speaker, float *levels, int numlevels) { return FMOD_Channel_SetSpeakerLevels(this, speaker, levels, numlevels); }
-		  FMOD_RESULT getSpeakerLevels       (FMOD_SPEAKER speaker, float *levels, int numlevels) { return FMOD_Channel_GetSpeakerLevels(this, speaker, levels, numlevels); }
-		  FMOD_RESULT setInputChannelMix     (float *levels, int numlevels) { return FMOD_Channel_SetInputChannelMix(this, levels, numlevels); }
-		  FMOD_RESULT getInputChannelMix     (float *levels, int numlevels) { return FMOD_Channel_GetInputChannelMix(this, levels, numlevels); }
-		  FMOD_RESULT setMute                (bool mute) { return FMOD_Channel_SetMute(this, mute); }
-		  FMOD_RESULT getMute                (bool *mute) { FMOD_BOOL b; FMOD_RESULT res = FMOD_Channel_GetMute(this, &b); *mute = b; return res; }
-		  FMOD_RESULT setPriority            (int priority) { return FMOD_Channel_SetPriority(this, priority); }
-		  FMOD_RESULT getPriority            (int *priority) { return FMOD_Channel_GetPriority(this, priority); }
-		  FMOD_RESULT setPosition            (unsigned int position, FMOD_TIMEUNIT postype) { return FMOD_Channel_SetPosition(this, position, postype); }
-		  FMOD_RESULT getPosition            (unsigned int *position, FMOD_TIMEUNIT postype) { return FMOD_Channel_GetPosition(this, position, postype); }
-		  FMOD_RESULT setReverbProperties    (const FMOD_REVERB_CHANNELPROPERTIES *prop) { return FMOD_Channel_SetReverbProperties(this, prop); }
-		  FMOD_RESULT getReverbProperties    (FMOD_REVERB_CHANNELPROPERTIES *prop) { return FMOD_Channel_GetReverbProperties(this, prop); }
-
-		  FMOD_RESULT setChannelGroup        (ChannelGroup *channelgroup) { return FMOD_Channel_SetChannelGroup(this, (FMOD_CHANNELGROUP *)channelgroup); }
-		  FMOD_RESULT getChannelGroup        (ChannelGroup **channelgroup) { return FMOD_Channel_GetChannelGroup(this, (FMOD_CHANNELGROUP **)channelgroup); }
-		  FMOD_RESULT setCallback            (FMOD_CHANNEL_CALLBACK callback) { return FMOD_Channel_SetCallback(this, callback); }
-		  FMOD_RESULT setLowPassGain         (float gain) { return FMOD_Channel_SetLowPassGain(this, gain); }
-		  FMOD_RESULT getLowPassGain         (float *gain) { return FMOD_Channel_GetLowPassGain(this, gain); }
-
-		// 3D functionality.
-		  FMOD_RESULT set3DAttributes        (const FMOD_VECTOR *pos, const FMOD_VECTOR *vel) { return FMOD_Channel_Set3DAttributes(this, pos, vel); }
-		  FMOD_RESULT get3DAttributes        (FMOD_VECTOR *pos, FMOD_VECTOR *vel) { return FMOD_Channel_Get3DAttributes(this, pos, vel); }
-		  FMOD_RESULT set3DMinMaxDistance    (float mindistance, float maxdistance) { return FMOD_Channel_Set3DMinMaxDistance(this, mindistance, maxdistance); }
-		  FMOD_RESULT get3DMinMaxDistance    (float *mindistance, float *maxdistance) { return FMOD_Channel_Get3DMinMaxDistance(this, mindistance, maxdistance); }
-		  FMOD_RESULT set3DConeSettings      (float insideconeangle, float outsideconeangle, float outsidevolume) { return FMOD_Channel_Set3DConeSettings(this, insideconeangle, outsideconeangle, outsidevolume); }
-		  FMOD_RESULT get3DConeSettings      (float *insideconeangle, float *outsideconeangle, float *outsidevolume) { return FMOD_Channel_Get3DConeSettings(this, insideconeangle, outsideconeangle, outsidevolume); }
-		  FMOD_RESULT set3DConeOrientation   (FMOD_VECTOR *orientation) { return FMOD_Channel_Set3DConeOrientation(this, orientation); }
-		  FMOD_RESULT get3DConeOrientation   (FMOD_VECTOR *orientation) { return FMOD_Channel_Get3DConeOrientation(this, orientation); }
-		  FMOD_RESULT set3DCustomRolloff     (FMOD_VECTOR *points, int numpoints) { return FMOD_Channel_Set3DCustomRolloff(this, points, numpoints); }
-		  FMOD_RESULT get3DCustomRolloff     (FMOD_VECTOR **points, int *numpoints) { return FMOD_Channel_Get3DCustomRolloff(this, points, numpoints); }
-		  FMOD_RESULT set3DOcclusion         (float directocclusion, float reverbocclusion) { return FMOD_Channel_Set3DOcclusion(this, directocclusion, reverbocclusion); }
-		  FMOD_RESULT get3DOcclusion         (float *directocclusion, float *reverbocclusion) { return FMOD_Channel_Get3DOcclusion(this, directocclusion, reverbocclusion); }
-		  FMOD_RESULT set3DSpread            (float angle) { return FMOD_Channel_Set3DSpread(this, angle); }
-		  FMOD_RESULT get3DSpread            (float *angle) { return FMOD_Channel_Get3DSpread(this, angle); }
-		  FMOD_RESULT set3DPanLevel          (float level) { return FMOD_Channel_Set3DPanLevel(this, level); }
-		  FMOD_RESULT get3DPanLevel          (float *level) { return FMOD_Channel_Get3DPanLevel(this, level); }
-		  FMOD_RESULT set3DDopplerLevel      (float level) { return FMOD_Channel_Set3DDopplerLevel(this, level); }
-		  FMOD_RESULT get3DDopplerLevel      (float *level) { return FMOD_Channel_Get3DDopplerLevel(this, level); }
-
-		// DSP functionality only for channels playing sounds created with FMOD_SOFTWARE.
-		  FMOD_RESULT getDSPHead             (DSP **dsp) { return FMOD_Channel_GetDSPHead(this, (FMOD_DSP **)dsp); }
-		  FMOD_RESULT addDSP                 (DSP *dsp, DSPConnection **connection) { return FMOD_Channel_AddDSP(this, (FMOD_DSP *)dsp, (FMOD_DSPCONNECTION **)connection); }
-
-		// Information only functions.
-		  FMOD_RESULT isPlaying              (bool *isplaying) { FMOD_BOOL b; FMOD_RESULT res = FMOD_Channel_IsPlaying(this, &b); *isplaying = b; return res; }
-		  FMOD_RESULT isVirtual              (bool *isvirtual) { FMOD_BOOL b; FMOD_RESULT res = FMOD_Channel_IsVirtual(this, &b); *isvirtual = b; return res; }
-		  FMOD_RESULT getAudibility          (float *audibility) { return FMOD_Channel_GetAudibility(this, audibility); }
-		  FMOD_RESULT getCurrentSound        (Sound **sound) { return FMOD_Channel_GetCurrentSound(this, (FMOD_SOUND **)sound); }
-		  FMOD_RESULT getSpectrum            (float *spectrumarray, int numvalues, int channeloffset, FMOD_DSP_FFT_WINDOW windowtype) { return FMOD_Channel_GetSpectrum(this, spectrumarray, numvalues, channeloffset, windowtype); }
-		  FMOD_RESULT getWaveData            (float *wavearray, int numvalues, int channeloffset) { return FMOD_Channel_GetWaveData(this, wavearray, numvalues, channeloffset); }
-		  FMOD_RESULT getIndex               (int *index) { return FMOD_Channel_GetIndex(this, index); }
-
-		// Functions also found in Sound class but here they can be set per channel.
-		  FMOD_RESULT setMode                (FMOD_MODE mode) { return FMOD_Channel_SetMode(this, mode); }
-		  FMOD_RESULT getMode                (FMOD_MODE *mode) { return FMOD_Channel_GetMode(this, mode); }
-		  FMOD_RESULT setLoopCount           (int loopcount) { return FMOD_Channel_SetLoopCount(this, loopcount); }
-		  FMOD_RESULT getLoopCount           (int *loopcount) { return FMOD_Channel_GetLoopCount(this, loopcount); }
-		  FMOD_RESULT setLoopPoints          (unsigned int loopstart, FMOD_TIMEUNIT loopstarttype, unsigned int loopend, FMOD_TIMEUNIT loopendtype) { return FMOD_Channel_SetLoopPoints(this, loopstart, loopstarttype, loopend, loopendtype); }
-		  FMOD_RESULT getLoopPoints          (unsigned int *loopstart, FMOD_TIMEUNIT loopstarttype, unsigned int *loopend, FMOD_TIMEUNIT loopendtype) { return FMOD_Channel_GetLoopPoints(this, loopstart, loopstarttype, loopend, loopendtype); }
-
-		// Userdata set/get.
-		  FMOD_RESULT setUserData            (void *userdata) { return FMOD_Channel_SetUserData(this, userdata); }
-		  FMOD_RESULT getUserData            (void **userdata) { return FMOD_Channel_GetUserData(this, userdata); }
-
-		  FMOD_RESULT getMemoryInfo          (unsigned int memorybits, unsigned int event_memorybits, unsigned int *memoryused, unsigned int *memoryused_array) { return FMOD_Channel_GetMemoryInfo(this, memorybits, event_memorybits, memoryused, memoryused_array); }
-	};
-
-	/*
-		'ChannelGroup' API
-	*/
-	class ChannelGroup : FMOD_CHANNELGROUP
-	{
-	  private:
-
-		ChannelGroup();   /* Constructor made private so user cannot statically instance a ChannelGroup class.  
-							 Appropriate ChannelGroup creation or retrieval function must be used. */
-	  public:
-
-		  FMOD_RESULT release                 () { return FMOD_ChannelGroup_Release(this); }
-		  FMOD_RESULT getSystemObject         (System **system) { return FMOD_ChannelGroup_GetSystemObject(this, (FMOD_SYSTEM **)system); }
-
-		// Channelgroup scale values.  (changes attributes relative to the channels, doesn't overwrite them)
-		  FMOD_RESULT setVolume               (float volume) { return FMOD_ChannelGroup_SetVolume(this, volume); }
-		  FMOD_RESULT getVolume               (float *volume) { return FMOD_ChannelGroup_GetVolume(this, volume); }
-		  FMOD_RESULT setPitch                (float pitch) { return FMOD_ChannelGroup_SetPitch(this, pitch); }
-		  FMOD_RESULT getPitch                (float *pitch) { return FMOD_ChannelGroup_GetPitch(this, pitch); }
-		  FMOD_RESULT set3DOcclusion          (float directocclusion, float reverbocclusion) { return FMOD_ChannelGroup_Set3DOcclusion(this, directocclusion, reverbocclusion); }
-		  FMOD_RESULT get3DOcclusion          (float *directocclusion, float *reverbocclusion) { return FMOD_ChannelGroup_Get3DOcclusion(this, directocclusion, reverbocclusion); }
-		  FMOD_RESULT setPaused               (bool paused) { return FMOD_ChannelGroup_SetPaused(this, paused); }
-		  FMOD_RESULT getPaused               (bool *paused) { FMOD_BOOL b; FMOD_RESULT res = FMOD_ChannelGroup_GetPaused(this, &b); *paused = b; return res; }
-		  FMOD_RESULT setMute                 (bool mute) { return FMOD_ChannelGroup_SetMute(this, mute); }
-		  FMOD_RESULT getMute                 (bool *mute) { FMOD_BOOL b; FMOD_RESULT res = FMOD_ChannelGroup_GetMute(this, &b); *mute = b; return res; }
-
-		// Channelgroup override values.  (recursively overwrites whatever settings the channels had)
-		  FMOD_RESULT stop                    () { return FMOD_ChannelGroup_Stop(this); }
-		  FMOD_RESULT overrideVolume          (float volume) { return FMOD_ChannelGroup_OverrideVolume(this, volume); }
-		  FMOD_RESULT overrideFrequency       (float frequency) { return FMOD_ChannelGroup_OverrideFrequency(this, frequency); }
-		  FMOD_RESULT overridePan             (float pan) { return FMOD_ChannelGroup_OverridePan(this, pan); }
-		  FMOD_RESULT overrideReverbProperties(const FMOD_REVERB_CHANNELPROPERTIES *prop) { return FMOD_ChannelGroup_OverrideReverbProperties(this, prop); }
-		  FMOD_RESULT override3DAttributes    (const FMOD_VECTOR *pos, const FMOD_VECTOR *vel) { return FMOD_ChannelGroup_Override3DAttributes(this, pos, vel); }
-		  FMOD_RESULT overrideSpeakerMix      (float frontleft, float frontright, float center, float lfe, float backleft, float backright, float sideleft, float sideright) { return FMOD_ChannelGroup_OverrideSpeakerMix(this, frontleft, frontright, center, lfe, backleft, backright, sideleft, sideright); }
-
-		// Nested channel groups.
-		  FMOD_RESULT addGroup                (ChannelGroup *group) { return FMOD_ChannelGroup_AddGroup(this, group); }
-		  FMOD_RESULT getNumGroups            (int *numgroups) { return FMOD_ChannelGroup_GetNumGroups(this, numgroups); }
-		  FMOD_RESULT getGroup                (int index, ChannelGroup **group) { return FMOD_ChannelGroup_GetGroup(this, index, (FMOD_CHANNELGROUP **)group); }
-		  FMOD_RESULT getParentGroup          (ChannelGroup **group) { return FMOD_ChannelGroup_GetParentGroup(this, (FMOD_CHANNELGROUP **)group); }
-
-		// DSP functionality only for channel groups playing sounds created with FMOD_SOFTWARE.
-		  FMOD_RESULT getDSPHead              (DSP **dsp) { return FMOD_ChannelGroup_GetDSPHead(this, (FMOD_DSP **)dsp); }
-		  FMOD_RESULT addDSP                  (DSP *dsp, DSPConnection **connection) { return FMOD_ChannelGroup_AddDSP(this, (FMOD_DSP *)dsp, (FMOD_DSPCONNECTION **)connection); }
-
-		// Information only functions.
-		  FMOD_RESULT getName                 (char *name, int namelen) { return FMOD_ChannelGroup_GetName(this, name, namelen); }
-		  FMOD_RESULT getNumChannels          (int *numchannels) { return FMOD_ChannelGroup_GetNumChannels(this, numchannels); }
-		  FMOD_RESULT getChannel              (int index, Channel **channel) { return FMOD_ChannelGroup_GetChannel(this, index, (FMOD_CHANNEL **)channel); }
-		  FMOD_RESULT getSpectrum             (float *spectrumarray, int numvalues, int channeloffset, FMOD_DSP_FFT_WINDOW windowtype) { return FMOD_ChannelGroup_GetSpectrum(this, spectrumarray, numvalues, channeloffset, windowtype); }
-		  FMOD_RESULT getWaveData             (float *wavearray, int numvalues, int channeloffset) { return FMOD_ChannelGroup_GetWaveData(this, wavearray, numvalues, channeloffset) ;}
-
-		// Userdata set/get.
-		  FMOD_RESULT setUserData             (void *userdata) { return FMOD_ChannelGroup_SetUserData(this, userdata); }
-		  FMOD_RESULT getUserData             (void **userdata) { return FMOD_ChannelGroup_GetUserData(this, userdata); }
-
-		  FMOD_RESULT getMemoryInfo           (unsigned int memorybits, unsigned int event_memorybits, unsigned int *memoryused, unsigned int *memoryused_array) { return FMOD_ChannelGroup_GetMemoryInfo(this, memorybits, event_memorybits, memoryused, memoryused_array); }
-	};
-
-	/*
-		'SoundGroup' API
-	*/
-	class SoundGroup : FMOD_SOUNDGROUP
-	{
-	  private:
-
-		SoundGroup();       /* Constructor made private so user cannot statically instance a SoundGroup class.  
-							   Appropriate SoundGroup creation or retrieval function must be used. */
-	  public:
-
-		  FMOD_RESULT release                () { return FMOD_SoundGroup_Release(this); }
-		  FMOD_RESULT getSystemObject        (System **system) { return FMOD_SoundGroup_GetSystemObject(this, (FMOD_SYSTEM **)system); }
-
-		// SoundGroup control functions.
-		  FMOD_RESULT setMaxAudible          (int maxaudible) { return FMOD_SoundGroup_SetMaxAudible(this, maxaudible); }
-		  FMOD_RESULT getMaxAudible          (int *maxaudible) { return FMOD_SoundGroup_GetMaxAudible(this, maxaudible); }
-		  FMOD_RESULT setMaxAudibleBehavior  (FMOD_SOUNDGROUP_BEHAVIOR behavior) { return FMOD_SoundGroup_SetMaxAudibleBehavior(this, behavior); }
-		  FMOD_RESULT getMaxAudibleBehavior  (FMOD_SOUNDGROUP_BEHAVIOR *behavior) { return FMOD_SoundGroup_GetMaxAudibleBehavior(this, behavior); }
-		  FMOD_RESULT setMuteFadeSpeed       (float speed) { return FMOD_SoundGroup_SetMuteFadeSpeed(this, speed); }
-		  FMOD_RESULT getMuteFadeSpeed       (float *speed) { return FMOD_SoundGroup_GetMuteFadeSpeed(this, speed); }
-		  FMOD_RESULT setVolume              (float volume) { return FMOD_SoundGroup_SetVolume(this, volume); }
-		  FMOD_RESULT getVolume              (float *volume) { return FMOD_SoundGroup_GetVolume(this, volume); }
-		  FMOD_RESULT stop                   () { return FMOD_SoundGroup_Stop(this); }
-
-		// Information only functions.
-		  FMOD_RESULT getName                (char *name, int namelen) { return FMOD_SoundGroup_GetName(this, name, namelen); }
-		  FMOD_RESULT getNumSounds           (int *numsounds) { return FMOD_SoundGroup_GetNumSounds(this, numsounds); }
-		  FMOD_RESULT getSound               (int index, Sound **sound) { return FMOD_SoundGroup_GetSound(this, index, (FMOD_SOUND **)sound); }
-		  FMOD_RESULT getNumPlaying          (int *numplaying) { return FMOD_SoundGroup_GetNumPlaying(this, numplaying); }
-
-		// Userdata set/get.
-		  FMOD_RESULT setUserData            (void *userdata) { return FMOD_SoundGroup_SetUserData(this, userdata); }
-		  FMOD_RESULT getUserData            (void **userdata) { return FMOD_SoundGroup_GetUserData(this, userdata); }
-
-		  FMOD_RESULT getMemoryInfo          (unsigned int memorybits, unsigned int event_memorybits, unsigned int *memoryused, unsigned int *memoryused_array) { return FMOD_SoundGroup_GetMemoryInfo(this, memorybits, event_memorybits, memoryused, memoryused_array); }
-	};
-
-	/*
-		'DSP' API
-	*/
-	class DSP : FMOD_DSP
-	{
-	  private:
-
-		DSP();   /* Constructor made private so user cannot statically instance a DSP class.  
-					Appropriate DSP creation or retrieval function must be used. */
-	  public:
-
-		  FMOD_RESULT release                () { return FMOD_DSP_Release(this); }
-		  FMOD_RESULT getSystemObject        (System **system) { return FMOD_DSP_GetSystemObject(this, (FMOD_SYSTEM **)system); }
-
-		// Connection / disconnection / input and output enumeration.
-		  FMOD_RESULT addInput               (DSP *target, DSPConnection **connection) { return FMOD_DSP_AddInput(this, target, (FMOD_DSPCONNECTION **)connection); }
-		  FMOD_RESULT disconnectFrom         (DSP *target) { return FMOD_DSP_DisconnectFrom(this, target); }
-		  FMOD_RESULT disconnectAll          (bool inputs, bool outputs) { return FMOD_DSP_DisconnectAll(this, inputs, outputs); }
-		  FMOD_RESULT remove                 () { return FMOD_DSP_Remove(this); }
-		  FMOD_RESULT getNumInputs           (int *numinputs) { return FMOD_DSP_GetNumInputs(this, numinputs); }
-		  FMOD_RESULT getNumOutputs          (int *numoutputs) { return FMOD_DSP_GetNumOutputs(this, numoutputs); }
-		  FMOD_RESULT getInput               (int index, DSP **input, DSPConnection **inputconnection) { return FMOD_DSP_GetInput(this, index, (FMOD_DSP **)input, (FMOD_DSPCONNECTION **)inputconnection); }
-		  FMOD_RESULT getOutput              (int index, DSP **output, DSPConnection **outputconnection) { return FMOD_DSP_GetOutput(this, index, (FMOD_DSP **)output, (FMOD_DSPCONNECTION **)outputconnection); }
-
-		// DSP unit control.
-		  FMOD_RESULT setActive              (bool active) { return FMOD_DSP_SetActive(this, active); }
-		  FMOD_RESULT getActive              (bool *active) { FMOD_BOOL b; FMOD_RESULT res = FMOD_DSP_GetActive(this, &b); *active = b; return res; }
-		  FMOD_RESULT setBypass              (bool bypass) { return FMOD_DSP_SetBypass(this, bypass); }
-		  FMOD_RESULT getBypass              (bool *bypass) { FMOD_BOOL b; FMOD_RESULT res = FMOD_DSP_GetBypass(this, &b); *bypass = b; return res; }
-		  FMOD_RESULT setSpeakerActive       (FMOD_SPEAKER speaker, bool active) { return FMOD_DSP_SetSpeakerActive(this, speaker, active); }
-		  FMOD_RESULT getSpeakerActive       (FMOD_SPEAKER speaker, bool *active) { FMOD_BOOL b; FMOD_RESULT res = FMOD_DSP_GetSpeakerActive(this, speaker, &b); *active = b; return res; }
-		  FMOD_RESULT reset                  ()  { return FMOD_DSP_Reset(this); }
-
-		// DSP parameter control.
-		  FMOD_RESULT setParameter           (int index, float value) { return FMOD_DSP_SetParameter(this, index, value); }
-		  FMOD_RESULT getParameter           (int index, float *value, char *valuestr, int valuestrlen) { return FMOD_DSP_GetParameter(this, index, value, valuestr, valuestrlen); }
-		  FMOD_RESULT getNumParameters       (int *numparams) { return FMOD_DSP_GetNumParameters(this, numparams); }
-		  FMOD_RESULT getParameterInfo       (int index, char *name, char *label, char *description, int descriptionlen, float *min, float *max) { return FMOD_DSP_GetParameterInfo(this, index, name, label, description, descriptionlen, min, max); }
-		  FMOD_RESULT showConfigDialog       (void *hwnd, bool show) { return FMOD_DSP_ShowConfigDialog(this, hwnd, show); }
-		
-		// DSP attributes.        
-		  FMOD_RESULT getInfo                (char *name, unsigned int *version, int *channels, int *configwidth, int *configheight) { return FMOD_DSP_GetInfo(this, name, version, channels, configwidth, configheight); }
-		  FMOD_RESULT getType                (FMOD_DSP_TYPE *type) { return FMOD_DSP_GetType(this, type); }
-		  FMOD_RESULT setDefaults            (float frequency, float volume, float pan, int priority) { return FMOD_DSP_SetDefaults(this, frequency, volume, pan, priority); }
-		  FMOD_RESULT getDefaults            (float *frequency, float *volume, float *pan, int *priority) { return FMOD_DSP_GetDefaults(this, frequency, volume, pan, priority) ;}
-
-		// Userdata set/get.
-		  FMOD_RESULT setUserData            (void *userdata) { return FMOD_DSP_SetUserData(this, userdata); }
-		  FMOD_RESULT getUserData            (void **userdata) { return FMOD_DSP_GetUserData(this, userdata); }
-
-		  FMOD_RESULT getMemoryInfo          (unsigned int memorybits, unsigned int event_memorybits, unsigned int *memoryused, unsigned int *memoryused_array) { return FMOD_DSP_GetMemoryInfo(this, memorybits, event_memorybits, memoryused, memoryused_array); }
-	};
-
-
-	/*
-		'DSPConnection' API
-	*/
-	class DSPConnection : FMOD_DSPCONNECTION
-	{
-	  private:
-
-		DSPConnection();    /* Constructor made private so user cannot statically instance a DSPConnection class.  
-							   Appropriate DSPConnection creation or retrieval function must be used. */
-
-	  public:
-
-		  FMOD_RESULT getInput              (DSP **input) { return FMOD_DSPConnection_GetInput(this, (FMOD_DSP **)input); }
-		  FMOD_RESULT getOutput             (DSP **output) { return FMOD_DSPConnection_GetOutput(this, (FMOD_DSP **)output); }
-		  FMOD_RESULT setMix                (float volume) { return FMOD_DSPConnection_SetMix(this, volume); }
-		  FMOD_RESULT getMix                (float *volume) { return FMOD_DSPConnection_GetMix(this, volume); }
-		  FMOD_RESULT setLevels             (FMOD_SPEAKER speaker, float *levels, int numlevels) { return FMOD_DSPConnection_SetLevels(this, speaker, levels, numlevels); }
-		  FMOD_RESULT getLevels             (FMOD_SPEAKER speaker, float *levels, int numlevels) { return FMOD_DSPConnection_GetLevels(this, speaker, levels, numlevels); }
-
-		// Userdata set/get.
-		  FMOD_RESULT setUserData           (void *userdata) { return FMOD_DSPConnection_SetUserData(this, userdata); }
-		  FMOD_RESULT getUserData           (void **userdata) { return FMOD_DSPConnection_GetUserData(this, userdata); }
-
-		  FMOD_RESULT getMemoryInfo         (unsigned int memorybits, unsigned int event_memorybits, unsigned int *memoryused, unsigned int *memoryused_array) { return FMOD_DSPConnection_GetMemoryInfo(this, memorybits, event_memorybits, memoryused, memoryused_array); }
-	};
-
-
-	/*
-		'Geometry' API
-	*/
-	class Geometry : FMOD_GEOMETRY
-	{
-	  private:
-
-		Geometry();   /* Constructor made private so user cannot statically instance a Geometry class.  
-						 Appropriate Geometry creation or retrieval function must be used. */
-
-	  public:
-
-		  FMOD_RESULT release                () { return FMOD_Geometry_Release(this); }
-
-		// Polygon manipulation.
-		  FMOD_RESULT addPolygon             (float directocclusion, float reverbocclusion, bool doublesided, int numvertices, const FMOD_VECTOR *vertices, int *polygonindex) { return FMOD_Geometry_AddPolygon(this, directocclusion, reverbocclusion, doublesided, numvertices, vertices, polygonindex); }
-		  FMOD_RESULT getNumPolygons         (int *numpolygons) { return FMOD_Geometry_GetNumPolygons(this, numpolygons); }
-		  FMOD_RESULT getMaxPolygons         (int *maxpolygons, int *maxvertices) { return FMOD_Geometry_GetMaxPolygons(this, maxpolygons, maxvertices); }
-		  FMOD_RESULT getPolygonNumVertices  (int index, int *numvertices) { return FMOD_Geometry_GetPolygonNumVertices(this, index, numvertices); }
-		  FMOD_RESULT setPolygonVertex       (int index, int vertexindex, const FMOD_VECTOR *vertex) { return FMOD_Geometry_SetPolygonVertex(this, index, vertexindex, vertex); }
-		  FMOD_RESULT getPolygonVertex       (int index, int vertexindex, FMOD_VECTOR *vertex) { return FMOD_Geometry_GetPolygonVertex(this, index, vertexindex, vertex); }
-		  FMOD_RESULT setPolygonAttributes   (int index, float directocclusion, float reverbocclusion, bool doublesided) { return FMOD_Geometry_SetPolygonAttributes(this, index, directocclusion, reverbocclusion, doublesided); }
-		  FMOD_RESULT getPolygonAttributes   (int index, float *directocclusion, float *reverbocclusion, bool *doublesided) { FMOD_BOOL b; FMOD_RESULT res = FMOD_Geometry_GetPolygonAttributes(this, index, directocclusion, reverbocclusion, &b); *doublesided = b; return res; }
-
-		// Object manipulation.
-		  FMOD_RESULT setActive              (bool active) { return FMOD_Geometry_SetActive(this, active); }
-		  FMOD_RESULT getActive              (bool *active) { FMOD_BOOL b; FMOD_RESULT res = FMOD_Geometry_GetActive(this, &b); *active = b; return res; }
-		  FMOD_RESULT setRotation            (const FMOD_VECTOR *forward, const FMOD_VECTOR *up) { return FMOD_Geometry_SetRotation(this, forward, up); }
-		  FMOD_RESULT getRotation            (FMOD_VECTOR *forward, FMOD_VECTOR *up) { return FMOD_Geometry_GetRotation(this, forward, up); }
-		  FMOD_RESULT setPosition            (const FMOD_VECTOR *position) { return FMOD_Geometry_SetPosition(this, position); }
-		  FMOD_RESULT getPosition            (FMOD_VECTOR *position) { return FMOD_Geometry_GetPosition(this, position); }
-		  FMOD_RESULT setScale               (const FMOD_VECTOR *scale) { return FMOD_Geometry_SetScale(this, scale); }
-		  FMOD_RESULT getScale               (FMOD_VECTOR *scale) { return FMOD_Geometry_GetScale(this, scale); }
-		  FMOD_RESULT save                   (void *data, int *datasize) { return FMOD_Geometry_Save(this, data, datasize); }
-
-		// Userdata set/get.
-		  FMOD_RESULT setUserData            (void *userdata) { return FMOD_Geometry_SetUserData(this, userdata); }
-		  FMOD_RESULT getUserData            (void **userdata) { return FMOD_Geometry_GetUserData(this, userdata); }
-
-		  FMOD_RESULT getMemoryInfo          (unsigned int memorybits, unsigned int event_memorybits, unsigned int *memoryused, unsigned int *memoryused_array) { return FMOD_Geometry_GetMemoryInfo(this, memorybits, event_memorybits, memoryused, memoryused_array); }
-	};
-
-
-	/*
-		'Reverb' API
-	*/
-	class Reverb : FMOD_REVERB
-	{
-	  private:
-
-		Reverb();    /*  Constructor made private so user cannot statically instance a Reverb class.  
-						 Appropriate Reverb creation or retrieval function must be used. */
-
-	  public:    
-
-		  FMOD_RESULT release                () { return FMOD_Reverb_Release(this); }
-
-		// Reverb manipulation.
-		  FMOD_RESULT set3DAttributes        (const FMOD_VECTOR *position, float mindistance, float maxdistance) { return FMOD_Reverb_Set3DAttributes(this, position, mindistance, maxdistance); }
-		  FMOD_RESULT get3DAttributes        (FMOD_VECTOR *position, float *mindistance, float *maxdistance) { return FMOD_Reverb_Get3DAttributes(this, position, mindistance, maxdistance); }
-		  FMOD_RESULT setProperties          (const FMOD_REVERB_PROPERTIES *properties) { return FMOD_Reverb_SetProperties(this, properties); }
-		  FMOD_RESULT getProperties          (FMOD_REVERB_PROPERTIES *properties) { return FMOD_Reverb_GetProperties(this, properties); }
-		  FMOD_RESULT setActive              (bool active) { return FMOD_Reverb_SetActive(this, active); }
-		  FMOD_RESULT getActive              (bool *active) { FMOD_BOOL b; FMOD_RESULT res = FMOD_Reverb_GetActive(this, &b); *active = b; return res; }
-
-		// Userdata set/get.
-		  FMOD_RESULT setUserData            (void *userdata) { return FMOD_Reverb_SetUserData(this, userdata); }
-		  FMOD_RESULT getUserData            (void **userdata) { return FMOD_Reverb_GetUserData(this, userdata); }
-
-		  FMOD_RESULT getMemoryInfo          (unsigned int memorybits, unsigned int event_memorybits, unsigned int *memoryused, unsigned int *memoryused_array) { return FMOD_Reverb_GetMemoryInfo(this, memorybits, event_memorybits, memoryused, memoryused_array); }
-	};
-}
-
-#endif
-
-// FMOD Ex vs FMOD Studio
-#if FMOD_VERSION >= 0x00040000 && FMOD_VERSION <= 0x0004FFFF
-#define FMOD_STUDIO 0
-#else
-#define FMOD_STUDIO 1
-#define FMOD_SOFTWARE 0
-#endif
-
-#endif
-#endif
diff --git a/src/sound/fmodsound.cpp b/src/sound/fmodsound.cpp
deleted file mode 100644
index a5972dceb6..0000000000
--- a/src/sound/fmodsound.cpp
+++ /dev/null
@@ -1,3527 +0,0 @@
-/*
-** fmodsound.cpp
-** System interface for sound; uses FMOD Ex.
-**
-**---------------------------------------------------------------------------
-** Copyright 1998-2009 Randy Heit
-** All rights reserved.
-**
-** Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions
-** are met:
-**
-** 1. Redistributions of source code must retain the above copyright
-**    notice, this list of conditions and the following disclaimer.
-** 2. Redistributions in binary form must reproduce the above copyright
-**    notice, this list of conditions and the following disclaimer in the
-**    documentation and/or other materials provided with the distribution.
-** 3. The name of the author may not be used to endorse or promote products
-**    derived from this software without specific prior written permission.
-**
-** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
-** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-**---------------------------------------------------------------------------
-**
-*/
-
-// HEADER FILES ------------------------------------------------------------
-
-#ifdef _WIN32
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
-#include <mmsystem.h>
-extern HWND Window;
-#else
-#define FALSE 0
-#define TRUE 1
-#endif
-#if defined(__FreeBSD__) || defined(__APPLE__)
-#include <stdlib.h>
-#elif __sun
-#include <alloca.h>
-#else
-#include <malloc.h>
-#endif
-
-#include "except.h"
-#include "templates.h"
-#include "fmodsound.h"
-#include "c_cvars.h"
-#include "i_system.h"
-#include "i_music.h"
-#include "v_text.h"
-#include "v_video.h"
-#include "v_palette.h"
-#include "cmdlib.h"
-#include "s_sound.h"
-#include "files.h"
-#include "i_musicinterns.h"
-
-#if FMOD_VERSION > 0x42899 && FMOD_VERSION < 0x43400
-#error You are trying to compile with an unsupported version of FMOD.
-#endif
-
-// MACROS ------------------------------------------------------------------
-
-// killough 2/21/98: optionally use varying pitched sounds
-#define PITCH(freq,pitch) (snd_pitched ? ((freq)*(pitch))/128.f : float(freq))
-
-// Just some extra for music and whatever
-#define NUM_EXTRA_SOFTWARE_CHANNELS		1
-
-#define MAX_CHANNELS				256
-
-#define SPECTRUM_SIZE				256
-
-// PUBLIC DATA DEFINITIONS -------------------------------------------------
-
-ReverbContainer *ForcedEnvironment;
-
-CVAR (Int, snd_driver, 0, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
-CVAR (Int, snd_buffercount, 0, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
-CVAR (Bool, snd_hrtf, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
-CVAR (Bool, snd_waterreverb, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
-CVAR (String, snd_resampler, "Linear", CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
-CVAR (String, snd_speakermode, "Auto", CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
-CVAR (String, snd_output_format, "PCM-16", CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
-CVAR (String, snd_midipatchset, "", CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
-CVAR (Bool, snd_profile, false, 0)
-
-// Underwater low-pass filter cutoff frequency. Set to 0 to disable the filter.
-CUSTOM_CVAR (Float, snd_waterlp, 250, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
-{
-	// Clamp to the DSP unit's limits.
-	if (*self < 10 && *self != 0)
-	{
-		self = 10;
-	}
-	else if (*self > 22000)
-	{
-		self = 22000;
-	}
-}
-
-CUSTOM_CVAR (Int, snd_streambuffersize, 64, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
-{
-	if (self < 16)
-	{
-		self = 16;
-	}
-	else if (self > 1024)
-	{
-		self = 1024;
-	}
-}
-
-#ifndef NO_FMOD
-#if !FMOD_STUDIO && FMOD_VERSION < 0x43400
-#define FMOD_OPENSTATE_PLAYING FMOD_OPENSTATE_STREAMING
-#endif
-
-#if !FMOD_STUDIO
-#define setParameterFloat setParameter
-#endif
-
-// TYPES -------------------------------------------------------------------
-
-struct FEnumList
-{
-	const char *Name;
-	int Value;
-};
-
-// EXTERNAL FUNCTION PROTOTYPES --------------------------------------------
-
-// PUBLIC FUNCTION PROTOTYPES ----------------------------------------------
-
-// PRIVATE FUNCTION PROTOTYPES ---------------------------------------------
-
-static int Enum_NumForName(const FEnumList *list, const char *name);
-static const char *Enum_NameForNum(const FEnumList *list, int num);
-
-// EXTERNAL DATA DECLARATIONS ----------------------------------------------
-
-EXTERN_CVAR (String, snd_output)
-EXTERN_CVAR (Float, snd_sfxvolume)
-EXTERN_CVAR (Float, snd_musicvolume)
-EXTERN_CVAR (Int, snd_buffersize)
-EXTERN_CVAR (Int, snd_samplerate)
-EXTERN_CVAR (Bool, snd_pitched)
-EXTERN_CVAR (Int, snd_channels)
-
-extern int sfx_empty;
-
-// PRIVATE DATA DEFINITIONS ------------------------------------------------
-
-static const ReverbContainer *PrevEnvironment;
-static bool ShowedBanner;
-
-// The rolloff callback is called during FMOD::Sound::play, so we need this
-// global variable to contain the sound info during that time for the
-// callback.
-static FRolloffInfo *GRolloff;
-static float GDistScale;
-
-// In the below lists, duplicate entries are for user selection. When
-// queried, only the first one for the particular value is shown.
-static const FEnumList OutputNames[] =
-{
-	{ "Auto",					FMOD_OUTPUTTYPE_AUTODETECT },
-	{ "Default",				FMOD_OUTPUTTYPE_AUTODETECT },
-	{ "No sound",				FMOD_OUTPUTTYPE_NOSOUND },
-
-	// Windows
-	{ "DirectSound",			FMOD_OUTPUTTYPE_DSOUND },
-	{ "DSound",					FMOD_OUTPUTTYPE_DSOUND },
-	{ "Windows Multimedia",		FMOD_OUTPUTTYPE_WINMM },
-	{ "WinMM",					FMOD_OUTPUTTYPE_WINMM },
-	{ "WaveOut",				FMOD_OUTPUTTYPE_WINMM },
-	{ "WASAPI",					FMOD_OUTPUTTYPE_WASAPI },
-	{ "ASIO",					FMOD_OUTPUTTYPE_ASIO },
-
-#if FMOD_STUDIO
-	//Android
-
-	{ "OPENSL",					FMOD_OUTPUTTYPE_OPENSL },
-	{ "Android Audio Track",	FMOD_OUTPUTTYPE_AUDIOTRACK },
-#endif
-
-	// Linux
-#if !FMOD_STUDIO
-	{ "OSS",					FMOD_OUTPUTTYPE_OSS },
-#endif
-	{ "ALSA",					FMOD_OUTPUTTYPE_ALSA },
-#if !FMOD_STUDIO
-	{ "ESD",					FMOD_OUTPUTTYPE_ESD },
-#endif
-#if FMOD_STUDIO || FMOD_VERSION >= 0x43400
-	{ "PulseAudio",				FMOD_OUTPUTTYPE_PULSEAUDIO },
-	{ "Pulse",					FMOD_OUTPUTTYPE_PULSEAUDIO },
-#endif
-#if !FMOD_STUDIO
-	{ "SDL",					666 },
-#endif
-
-	// Mac
-	{ "Core Audio",				FMOD_OUTPUTTYPE_COREAUDIO },
-
-	{ NULL, 0 }
-};
-
-static const FEnumList SpeakerModeNames[] =
-{
-	{ "Mono",					FMOD_SPEAKERMODE_MONO },
-	{ "Stereo",					FMOD_SPEAKERMODE_STEREO },
-	{ "Quad",					FMOD_SPEAKERMODE_QUAD },
-	{ "Surround",				FMOD_SPEAKERMODE_SURROUND },
-	{ "5.1",					FMOD_SPEAKERMODE_5POINT1 },
-	{ "7.1",					FMOD_SPEAKERMODE_7POINT1 },
-#if !FMOD_STUDIO && FMOD_VERSION < 0x44000
-	{ "Prologic",				FMOD_SPEAKERMODE_PROLOGIC },
-#endif
-	{ "1",						FMOD_SPEAKERMODE_MONO },
-	{ "2",						FMOD_SPEAKERMODE_STEREO },
-	{ "4",						FMOD_SPEAKERMODE_QUAD },
-	{ NULL, 0 }
-};
-
-static const FEnumList ResamplerNames[] =
-{
-	{ "No Interpolation",		FMOD_DSP_RESAMPLER_NOINTERP },
-	{ "NoInterp",				FMOD_DSP_RESAMPLER_NOINTERP },
-	{ "Linear",					FMOD_DSP_RESAMPLER_LINEAR },
-	// [BL] 64-bit versions of FMOD Ex between 4.24 and 4.26 crash with these resamplers.
-#if FMOD_STUDIO || !(defined(_M_X64) || defined(__amd64__)) || !(FMOD_VERSION >= 0x42400 && FMOD_VERSION <= 0x426FF)
-	{ "Cubic",					FMOD_DSP_RESAMPLER_CUBIC },
-	{ "Spline",					FMOD_DSP_RESAMPLER_SPLINE },
-#endif
-	{ NULL, 0 }
-};
-
-static const FEnumList SoundFormatNames[] =
-{
-	{ "None",					FMOD_SOUND_FORMAT_NONE },
-	{ "PCM-8",					FMOD_SOUND_FORMAT_PCM8 },
-	{ "PCM-16",					FMOD_SOUND_FORMAT_PCM16 },
-	{ "PCM-24",					FMOD_SOUND_FORMAT_PCM24 },
-	{ "PCM-32",					FMOD_SOUND_FORMAT_PCM32 },
-	{ "PCM-Float",				FMOD_SOUND_FORMAT_PCMFLOAT },
-#if FMOD_STUDIO && FMOD_VERSION < 0x10700
-	{ "GCADPCM",				FMOD_SOUND_FORMAT_GCADPCM },
-	{ "IMAADPCM",				FMOD_SOUND_FORMAT_IMAADPCM },
-	{ "VAG",					FMOD_SOUND_FORMAT_VAG },
-	{ "XMA",					FMOD_SOUND_FORMAT_XMA },
-	{ "MPEG",					FMOD_SOUND_FORMAT_MPEG },
-#endif
-	{ NULL, 0 }
-};
-
-static const char *OpenStateNames[] =
-{
-	"Ready",
-	"Loading",
-	"Error",
-	"Connecting",
-	"Buffering",
-	"Seeking",
-	"Streaming"
-};
-
-const FMODSoundRenderer::spk FMODSoundRenderer::SpeakerNames4[4] = { "L", "R", "BL", "BR" };
-const FMODSoundRenderer::spk FMODSoundRenderer::SpeakerNamesMore[8] = { "L", "R", "C", "LFE", "BL", "BR", "SL", "SR" };
-
-// CODE --------------------------------------------------------------------
-
-//==========================================================================
-//
-// Enum_NumForName
-//
-// Returns the value of an enum name, or -1 if not found.
-//
-//==========================================================================
-
-static int Enum_NumForName(const FEnumList *list, const char *name)
-{
-	while (list->Name != NULL)
-	{
-		if (stricmp(list->Name, name) == 0)
-		{
-			return list->Value;
-		}
-		list++;
-	}
-	return -1;
-}
-
-//==========================================================================
-//
-// Enum_NameForNum
-//
-// Returns the name of an enum value. If there is more than one name for a
-// value, on the first one in the list is returned. Returns NULL if there
-// was no match.
-//
-//==========================================================================
-
-static const char *Enum_NameForNum(const FEnumList *list, int num)
-{
-	while (list->Name != NULL)
-	{
-		if (list->Value == num)
-		{
-			return list->Name;
-		}
-		list++;
-	}
-	return NULL;
-}
-
-//==========================================================================
-//
-// The container for a streaming FMOD::Sound, for playing music.
-//
-//==========================================================================
-
-class FMODStreamCapsule : public SoundStream
-{
-public:
-	FMODStreamCapsule(FMOD::Sound *stream, FMODSoundRenderer *owner, const char *url)
-		: Owner(owner), Stream(NULL), Channel(NULL),
-		  UserData(NULL), Callback(NULL), Reader(NULL), URL(url), Ended(false)
-	{
-		SetStream(stream);
-	}
-
-    FMODStreamCapsule(FMOD::Sound *stream, FMODSoundRenderer *owner, FileReader *reader)
-        : Owner(owner), Stream(NULL), Channel(NULL),
-          UserData(NULL), Callback(NULL), Reader(reader), Ended(false)
-    {
-        SetStream(stream);
-    }
-
-	FMODStreamCapsule(void *udata, SoundStreamCallback callback, FMODSoundRenderer *owner)
-		: Owner(owner), Stream(NULL), Channel(NULL),
-		  UserData(udata), Callback(callback), Reader(NULL), Ended(false)
-	{}
-
-	~FMODStreamCapsule()
-	{
-		if (Channel != NULL)
-		{
-			Channel->stop();
-		}
-		if (Stream != NULL)
-		{
-			Stream->release();
-		}
-		if (Reader != NULL)
-		{
-			delete Reader;
-		}
-	}
-
-	void SetStream(FMOD::Sound *stream)
-	{
-		float frequency;
-
-		Stream = stream;
-
-		// As this interface is for music, make it super-high priority.
-#if FMOD_STUDIO
-		if (FMOD_OK == stream->getDefaults(&frequency, NULL))
-			stream->setDefaults(frequency, 1);
-#else
-		if (FMOD_OK == stream->getDefaults(&frequency, NULL, NULL, NULL))
-			stream->setDefaults(frequency, 1, 0, 0);
-#endif
-	}
-
-	bool Play(bool looping, float volume)
-	{
-		FMOD_RESULT result;
-
-		if (URL.IsNotEmpty())
-		{ // Net streams cannot be looped, because they cannot be seeked.
-			looping = false;
-		}
-		Stream->setMode((looping ? FMOD_LOOP_NORMAL : FMOD_LOOP_OFF) | FMOD_SOFTWARE | FMOD_2D);
-#if FMOD_STUDIO
-		result = Owner->Sys->playSound(Stream,0, true, &Channel);
-#else
-		result = Owner->Sys->playSound(FMOD_CHANNEL_FREE, Stream, true, &Channel);
-#endif
-		if (result != FMOD_OK)
-		{
-			return false;
-		}
-		Channel->setChannelGroup(Owner->MusicGroup);
-#if FMOD_STUDIO
-		Channel->setMixLevelsOutput(1, 1, 1, 1, 1, 1, 1, 1);
-#else
-		Channel->setSpeakerMix(1, 1, 1, 1, 1, 1, 1, 1);
-#endif
-		Channel->setVolume(volume);
-		// Ensure reverb is disabled.
-#if FMOD_STUDIO
-		Channel->setReverbProperties(0,0.f);
-#else
-		FMOD_REVERB_CHANNELPROPERTIES reverb = { 0, };
-		if (FMOD_OK == Channel->getReverbProperties(&reverb))
-		{
-			reverb.Room = -10000;
-			Channel->setReverbProperties(&reverb);
-		}
-#endif
-		Channel->setPaused(false);
-		Ended = false;
-		JustStarted = true;
-		Starved = false;
-		Loop = looping;
-		Volume = volume;
-		return true;
-	}
-
-	void Stop()
-	{
-		if (Channel != NULL)
-		{
-			Channel->stop();
-			Channel = NULL;
-		}
-	}
-
-	bool SetPaused(bool paused)
-	{
-		if (Channel != NULL)
-		{
-			return FMOD_OK == Channel->setPaused(paused);
-		}
-		return false;
-	}
-
-	unsigned int GetPosition()
-	{
-		unsigned int pos;
-
-		if (Channel != NULL && FMOD_OK == Channel->getPosition(&pos, FMOD_TIMEUNIT_MS))
-		{
-			return pos;
-		}
-		return 0;
-	}
-
-	bool IsEnded()
-	{
-		bool is;
-		FMOD_OPENSTATE openstate = FMOD_OPENSTATE_MAX;
-		bool starving;
-#if FMOD_STUDIO || FMOD_VERSION >= 0x43400
-		bool diskbusy;
-#endif
-
-		if (Stream == NULL)
-		{
-			return true;
-		}
-#if !FMOD_STUDIO && FMOD_VERSION < 0x43400
-		if (FMOD_OK != Stream->getOpenState(&openstate, NULL, &starving))
-#else
-		if (FMOD_OK != Stream->getOpenState(&openstate, NULL, &starving, &diskbusy))
-#endif
-		{
-			openstate = FMOD_OPENSTATE_ERROR;
-		}
-		if (openstate == FMOD_OPENSTATE_ERROR)
-		{
-			if (Channel != NULL)
-			{
-				Channel->stop();
-				Channel = NULL;
-			}
-			return true;
-		}
-		if (Channel != NULL && (FMOD_OK != Channel->isPlaying(&is) || is == false))
-		{
-			return true;
-		}
-		if (Ended)
-		{
-			Channel->stop();
-			Channel = NULL;
-			return true;
-		}
-		if (URL.IsNotEmpty() && !JustStarted && openstate == FMOD_OPENSTATE_READY)
-		{
-			// Reconnect the stream, since it seems to have stalled.
-			// The only way to do this appears to be to completely recreate it.
-			FMOD_RESULT result;
-
-			Channel->stop();
-			Stream->release();
-			Channel = NULL;
-			Stream = NULL;
-			// Open the stream asynchronously, so we don't hang the game while trying to reconnect.
-			// (It would be nice to do the initial open asynchronously as well, but I'd need to rethink
-			// the music system design to pull that off.)
-			result = Owner->Sys->createSound(URL, (Loop ? FMOD_LOOP_NORMAL : FMOD_LOOP_OFF) | FMOD_SOFTWARE | FMOD_2D |
-				FMOD_CREATESTREAM | FMOD_NONBLOCKING, NULL, &Stream);
-			JustStarted = true;
-			return result != FMOD_OK;
-		}
-		if (JustStarted && openstate == FMOD_OPENSTATE_PLAYING)
-		{
-			JustStarted = false;
-		}
-		if (JustStarted && Channel == NULL && openstate == FMOD_OPENSTATE_READY)
-		{
-			return !Play(Loop, Volume);
-		}
-		if (starving != Starved)
-		{ // Mute the sound if it's starving.
-			Channel->setVolume(starving ? 0 : Volume);
-			Starved = starving;
-		}
-		return false;
-	}
-
-	void SetVolume(float volume)
-	{
-		if (Channel != NULL && !Starved)
-		{
-			Channel->setVolume(volume);
-		}
-		Volume = volume;
-	}
-
-	// Sets the position in ms.
-	bool SetPosition(unsigned int ms_pos)
-	{
-		return FMOD_OK == Channel->setPosition(ms_pos, FMOD_TIMEUNIT_MS);
-	}
-
-	// Sets the order number for MOD formats.
-	bool SetOrder(int order_pos)
-	{
-		return FMOD_OK == Channel->setPosition(order_pos, FMOD_TIMEUNIT_MODORDER);
-	}
-
-	FString GetStats()
-	{
-		FString stats;
-		FMOD_OPENSTATE openstate;
-		unsigned int percentbuffered;
-		unsigned int position;
-		bool starving;
-#if FMOD_STUDIO || FMOD_VERSION >= 0x43400
-		bool diskbusy;
-#endif
-		float volume;
-		float frequency;
-		bool paused;
-		bool isplaying;
-
-#if !FMOD_STUDIO && FMOD_VERSION < 0x43400
-		if (FMOD_OK == Stream->getOpenState(&openstate, &percentbuffered, &starving))
-#else
-		if (FMOD_OK == Stream->getOpenState(&openstate, &percentbuffered, &starving, &diskbusy))
-#endif
-		{
-			stats = (openstate <= FMOD_OPENSTATE_PLAYING ? OpenStateNames[openstate] : "Unknown state");
-			stats.AppendFormat(",%3d%% buffered, %s", percentbuffered, starving ? "Starving" : "Well-fed");
-		}
-		if (Channel == NULL)
-		{
-			stats += ", not playing";
-		}
-		if (Channel != NULL && FMOD_OK == Channel->getPosition(&position, FMOD_TIMEUNIT_MS))
-		{
-			stats.AppendFormat(", %d", position);
-			if (FMOD_OK == Stream->getLength(&position, FMOD_TIMEUNIT_MS))
-			{
-				stats.AppendFormat("/%d", position);
-			}
-			stats += " ms";
-		}
-		if (Channel != NULL && FMOD_OK == Channel->getVolume(&volume))
-		{
-			stats.AppendFormat(", %d%%", int(volume * 100));
-		}
-		if (Channel != NULL && FMOD_OK == Channel->getPaused(&paused) && paused)
-		{
-			stats += ", paused";
-		}
-		if (Channel != NULL && FMOD_OK == Channel->isPlaying(&isplaying) && isplaying)
-		{
-			stats += ", playing";
-		}
-		if (Channel != NULL && FMOD_OK == Channel->getFrequency(&frequency))
-		{
-			stats.AppendFormat(", %g Hz", frequency);
-		}
-		if (JustStarted)
-		{
-			stats += " JS";
-		}
-		if (Ended)
-		{
-			stats += " XX";
-		}
-		return stats;
-	}
-
-	static FMOD_RESULT F_CALLBACK PCMReadCallback(FMOD_SOUND *sound, void *data, unsigned int datalen)
-	{
-		FMOD_RESULT result;
-		FMODStreamCapsule *self;
-		
-		result = ((FMOD::Sound *)sound)->getUserData((void **)&self);
-		if (result != FMOD_OK || self == NULL || self->Callback == NULL || self->Ended)
-		{
-			// Contrary to the docs, this return value is completely ignored.
-			return FMOD_OK;
-		}
-		if (!self->Callback(self, data, datalen, self->UserData))
-		{
-			self->Ended = true;
-		}
-		return FMOD_OK;
-	}
-
-	static FMOD_RESULT F_CALLBACK PCMSetPosCallback(FMOD_SOUND *sound, int subsound, unsigned int position, FMOD_TIMEUNIT postype)
-	{
-		// This is useful if the user calls Channel::setPosition and you want
-		// to seek your data accordingly.
-		return FMOD_OK;
-	}
-
-private:
-	FMODSoundRenderer *Owner;
-	FMOD::Sound *Stream;
-	FMOD::Channel *Channel;
-	void *UserData;
-	SoundStreamCallback Callback;
-    FileReader *Reader;
-	FString URL;
-	bool Ended;
-	bool JustStarted;
-	bool Starved;
-	bool Loop;
-	float Volume;
-};
-
-//==========================================================================
-//
-// The interface the game uses to talk to FMOD.
-//
-//==========================================================================
-
-FMODSoundRenderer::FMODSoundRenderer()
-{
-	InitSuccess = Init();
-}
-
-FMODSoundRenderer::~FMODSoundRenderer()
-{
-	Shutdown();
-}
-
-bool FMODSoundRenderer::IsValid()
-{
-	return InitSuccess;
-}
-
-//==========================================================================
-//
-// FMODSoundRenderer :: Init
-//
-//==========================================================================
-
-bool FMODSoundRenderer::Init()
-{
-	FMOD_RESULT result;
-	unsigned int version;
-	FMOD_SPEAKERMODE speakermode;
-	FMOD_SOUND_FORMAT format;
-	FMOD_DSP_RESAMPLER resampler;
-	FMOD_INITFLAGS initflags;
-	int samplerate;
-	int driver;
-
-	int eval;
-
-	SFXPaused = 0;
-	DSPLocked = false;
-	MusicGroup = NULL;
-	SfxGroup = NULL;
-	PausableSfx = NULL;
-	SfxConnection = NULL;
-	WaterLP = NULL;
-	WaterReverb = NULL;
-	PrevEnvironment = DefaultEnvironments[0];
-	DSPClock.AsOne = 0;
-	ChannelGroupTargetUnit = NULL;
-	ChannelGroupTargetUnitOutput = NULL;
-	SfxReverbHooked = false;
-	SfxReverbPlaceholder = NULL;
-	OutputPlugin = 0;
-
-	Printf("I_InitSound: Initializing FMOD\n");
-
-	// This is just for safety. Normally this should never be called if FMod Ex cannot be found.
-	if (!IsFModExPresent())
-	{
-		Sys = NULL;
-		Printf(TEXTCOLOR_ORANGE"Failed to load fmodex"
-#ifdef _WIN64
-			"64"
-#endif
-			".dll\n");
-		return false;
-	}
-
-	// Create a System object and initialize.
-	result = FMOD::System_Create(&Sys);
-	if (result != FMOD_OK)
-	{
-		Sys = NULL;
-		Printf(TEXTCOLOR_ORANGE"Failed to create FMOD system object: Error %d\n", result);
-		return false;
-	}
-
-	result = Sys->getVersion(&version);
-	if (result != FMOD_OK)
-	{
-		Printf(TEXTCOLOR_ORANGE"Could not validate FMOD version: Error %d\n", result);
-		return false;
-	}
-
-	const char *wrongver = NULL;
-#if FMOD_STUDIO
-	if (version < (FMOD_VERSION & 0xFFFF00))
-#elif FMOD_VERSION >= 0x43600
-	if (version < 0x43600)
-#else
-	if (version < 0x42000)
-#endif
-	{
-		wrongver = "an old";
-	}
-#if !FMOD_STUDIO && FMOD_VERSION < 0x42700
-	else if ((version & 0xFFFF00) > 0x42600)
-#else
-	else if ((version & 0xFFFF00) > (FMOD_VERSION & 0xFFFF00))
-#endif
-	{
-		wrongver = "a new";
-	}
-	if (wrongver != NULL)
-	{
-		Printf (" " TEXTCOLOR_ORANGE "Error! You are using %s version of FMOD (%x.%02x.%02x).\n"
-				" " TEXTCOLOR_ORANGE "This program was built for version %x.%02x.%02x\n",
-				wrongver,
-				version >> 16, (version >> 8) & 255, version & 255,
-				FMOD_VERSION >> 16, (FMOD_VERSION >> 8) & 255, FMOD_VERSION & 255);
-		return false;
-	}
-	ActiveFMODVersion = version;
-
-	if (!ShowedBanner)
-	{
-		// '\xa9' is the copyright symbol in the Windows-1252 code page.
-		Printf("FMOD Sound System, copyright \xa9 Firelight Technologies Pty, Ltd., 1994-2009.\n");
-		Printf("Loaded FMOD version %x.%02x.%02x\n", version >> 16, (version >> 8) & 255, version & 255);
-		ShowedBanner = true;
-	}
-#if defined(_WIN32) && !FMOD_STUDIO
-	if (OSPlatform == os_WinNT4)
-	{
-		// The following was true as of FMOD 3. I don't know if it still
-		// applies to FMOD Ex, nor do I have an NT 4 install anymore, but
-		// there's no reason to get rid of it yet.
-		//
-		// If running Windows NT 4, we need to initialize DirectSound before
-		// using WinMM. If we don't, then FSOUND_Close will corrupt a
-		// heap. This might just be the Audigy's drivers--I don't know why
-		// it happens. At least the fix is simple enough. I only need to
-		// initialize DirectSound once, and then I can initialize/close
-		// WinMM as many times as I want.
-		//
-		// Yes, using WinMM under NT 4 is a good idea. I can get latencies as
-		// low as 20 ms with WinMM, but with DirectSound I need to have the
-		// latency as high as 120 ms to avoid crackling--quite the opposite
-		// from the other Windows versions with real DirectSound support.
-
-		static bool inited_dsound = false;
-
-		if (!inited_dsound)
-		{
-			if (Sys->setOutput(FMOD_OUTPUTTYPE_DSOUND) == FMOD_OK)
-			{
-				if (Sys->init(1, FMOD_INIT_NORMAL, 0) == FMOD_OK)
-				{
-					inited_dsound = true;
-					Sleep(50);
-					Sys->close();
-				}
-				Sys->setOutput(FMOD_OUTPUTTYPE_WINMM);
-			}
-		}
-	}
-#endif
-
-#if !defined _WIN32 && !defined __APPLE__ && !FMOD_STUDIO
-	// Try to load SDL output plugin
-	result = Sys->setPluginPath(progdir);	// Should we really look for it in the program directory?
-	result = Sys->loadPlugin("liboutput_sdl.so", &OutputPlugin);
-	if (result != FMOD_OK)
-	{
-		OutputPlugin = 0;
-	}
-#endif
-
-	// Set the user specified output mode.
-	eval = Enum_NumForName(OutputNames, snd_output);
-	if (eval >= 0)
-	{
-		if (eval == 666 && OutputPlugin != 0)
-		{
-			result = Sys->setOutputByPlugin(OutputPlugin);
-		}
-		else
-		{
-			result = Sys->setOutput(FMOD_OUTPUTTYPE(eval));
-		}
-		if (result != FMOD_OK)
-		{
-			Printf(TEXTCOLOR_BLUE"Setting output type '%s' failed. Using default instead. (Error %d)\n", *snd_output, result);
-			eval = FMOD_OUTPUTTYPE_AUTODETECT;
-			Sys->setOutput(FMOD_OUTPUTTYPE_AUTODETECT);
-		}
-	}
-	
-	result = Sys->getNumDrivers(&driver);
-#if defined(__unix__) && !FMOD_STUDIO
-	if (result == FMOD_OK)
-	{
-		// On Linux, FMOD defaults to OSS. If OSS is not present, it doesn't
-		// try ALSA; it just fails. We'll try for it, but only if OSS wasn't
-		// explicitly specified for snd_output.
-		if (driver == 0 && eval == FMOD_OUTPUTTYPE_AUTODETECT)
-		{
-			FMOD_OUTPUTTYPE output;
-			if (FMOD_OK == Sys->getOutput(&output))
-			{
-				if (output == FMOD_OUTPUTTYPE_OSS)
-				{
-					Printf(TEXTCOLOR_BLUE"OSS could not be initialized. Trying ALSA.\n");
-					Sys->setOutput(FMOD_OUTPUTTYPE_ALSA);
-					result = Sys->getNumDrivers(&driver);
-				}
-			}
-		}
-	}
-#endif
-	if (result == FMOD_OK)
-	{
-		if (driver == 0)
-		{
-			Printf(TEXTCOLOR_ORANGE"No working sound devices found. Try a different snd_output?\n");
-			return false;
-		}
-		if (snd_driver >= driver)
-		{
-			Printf(TEXTCOLOR_BLUE"Driver %d does not exist. Using 0.\n", *snd_driver);
-			driver = 0;
-		}
-		else
-		{
-			driver = snd_driver;
-		}
-		result = Sys->setDriver(driver);
-	}
-	result = Sys->getDriver(&driver);
-#if FMOD_STUDIO
-	// We were built with an FMOD Studio that only returns the control panel frequency
-	result = Sys->getDriverInfo(driver, nullptr, 0, nullptr, &Driver_MinFrequency, &speakermode, nullptr);
-	Driver_MaxFrequency = Driver_MinFrequency;
-#elif FMOD_VERSION >= 0x43600
-	// We were built with an FMOD that only returns the control panel frequency
-	result = Sys->getDriverCaps(driver, &Driver_Caps, &Driver_MinFrequency, &speakermode);
-	Driver_MaxFrequency = Driver_MinFrequency;
-#else
-	// We were built with an FMOD that returns a frequency range
-	result = Sys->getDriverCaps(driver, &Driver_Caps, &Driver_MinFrequency, &Driver_MaxFrequency, &speakermode);
-#endif
-	if (result != FMOD_OK)
-	{
-		Printf(TEXTCOLOR_BLUE"Could not ascertain driver capabilities. Some things may be weird. (Error %d)\n", result);
-		// Fill in some default to pretend it worked. (But as long as we specify a valid driver,
-		// can this call actually fail?)
-#if !FMOD_STUDIO
-		Driver_Caps = 0;
-#endif
-		Driver_MinFrequency = 4000;
-		Driver_MaxFrequency = 48000;
-		speakermode = FMOD_SPEAKERMODE_STEREO;
-	}
-
-	// Set the user selected speaker mode.
-	eval = Enum_NumForName(SpeakerModeNames, snd_speakermode);
-	if (eval >= 0)
-	{
-		speakermode = FMOD_SPEAKERMODE(eval);
-	}
-#if !FMOD_STUDIO
-	result = Sys->setSpeakerMode(speakermode);
-	if (result != FMOD_OK)
-	{
-		Printf(TEXTCOLOR_BLUE"Could not set speaker mode to '%s'. (Error %d)\n", *snd_speakermode, result);
-	}
-#endif
-
-	// Set software format
-	eval = Enum_NumForName(SoundFormatNames, snd_output_format);
-	format = eval >= 0 ? FMOD_SOUND_FORMAT(eval) : FMOD_SOUND_FORMAT_PCM16;
-	if (format == FMOD_SOUND_FORMAT_PCM8)
-	{
-		// PCM-8 sounds like garbage with anything but DirectSound.
-		FMOD_OUTPUTTYPE output;
-		if (FMOD_OK != Sys->getOutput(&output) || output != FMOD_OUTPUTTYPE_DSOUND)
-		{
-			format = FMOD_SOUND_FORMAT_PCM16;
-		}
-	}
-	eval = Enum_NumForName(ResamplerNames, snd_resampler);
-	resampler = eval >= 0 ? FMOD_DSP_RESAMPLER(eval) : FMOD_DSP_RESAMPLER_LINEAR;
-	// These represented the frequency limits for hardware channels, which we never used anyway.
-//	samplerate = clamp<int>(snd_samplerate, Driver_MinFrequency, Driver_MaxFrequency);
-	samplerate = snd_samplerate;
-	if (samplerate == 0 || snd_samplerate == 0)
-	{ // Creative's ASIO drivers report the only supported frequency as 0!
-#if FMOD_STUDIO
-		if (FMOD_OK != Sys->getSoftwareFormat(&samplerate, NULL, NULL))
-#else
-		if (FMOD_OK != Sys->getSoftwareFormat(&samplerate, NULL, NULL, NULL, NULL, NULL))
-#endif
-		{
-			samplerate = 48000;
-		}
-	}
-	if (samplerate != snd_samplerate && snd_samplerate != 0)
-	{
-		Printf(TEXTCOLOR_BLUE"Sample rate %d is unsupported. Trying %d.\n", *snd_samplerate, samplerate);
-	}
-#if FMOD_STUDIO
-	result = Sys->setSoftwareFormat(samplerate, speakermode, 0);
-#else
-	result = Sys->setSoftwareFormat(samplerate, format, 0, 0, resampler);
-#endif
-	if (result != FMOD_OK)
-	{
-		Printf(TEXTCOLOR_BLUE"Could not set mixing format. Defaults will be used. (Error %d)\n", result);
-	}
-
-#if FMOD_STUDIO
-	FMOD_ADVANCEDSETTINGS advSettings = {};
-	advSettings.cbSize = sizeof advSettings;
-	advSettings.resamplerMethod = resampler;
-	result = Sys->setAdvancedSettings(&advSettings);
-	if (result != FMOD_OK)
-	{
-		Printf(TEXTCOLOR_BLUE"Could not set resampler method. Defaults will be used. (Error %d)\n", result);
-	}
-#endif
-
-	// Set software channels according to snd_channels
-	result = Sys->setSoftwareChannels(snd_channels + NUM_EXTRA_SOFTWARE_CHANNELS);
-	if (result != FMOD_OK)
-	{
-		Printf(TEXTCOLOR_BLUE"Failed to set the preferred number of channels. (Error %d)\n", result);
-	}
-
-#if !FMOD_STUDIO
-	if (Driver_Caps & FMOD_CAPS_HARDWARE_EMULATED)
-	{ // The user has the 'Acceleration' slider set to off!
-	  // This is really bad for latency!
-		Printf (TEXTCOLOR_BLUE"Warning: The sound acceleration slider has been set to off.\n");
-		Printf (TEXTCOLOR_BLUE"Please turn it back on if you want decent sound.\n");
-		result = Sys->setDSPBufferSize(1024, 10);	// At 48khz, the latency between issuing an fmod command and hearing it will now be about 213ms.
-	}
-	else
-#endif
-	if (snd_buffersize != 0 || snd_buffercount != 0)
-	{
-		int buffersize = snd_buffersize ? snd_buffersize : 1024;
-		int buffercount = snd_buffercount ? snd_buffercount : 4;
-		result = Sys->setDSPBufferSize(buffersize, buffercount);
-	}
-	else
-	{
-		result = FMOD_OK;
-	}
-	if (result != FMOD_OK)
-	{
-		Printf(TEXTCOLOR_BLUE"Setting DSP buffer size failed. (Error %d)\n", result);
-	}
-
-	// Try to init
-	initflags = FMOD_INIT_NORMAL;
-	if (snd_hrtf)
-	{
-		// These flags are the same thing, just with different names.
-#ifdef FMOD_INIT_CHANNEL_LOWPASS
-		initflags |= FMOD_INIT_CHANNEL_LOWPASS;
-#elif defined(FMOD_INIT_SOFTWARE_HRTF)
-		initflags |= FMOD_INIT_SOFTWARE_HRTF;
-#else
-		initflags |= FMOD_INIT_HRTF_LOWPASS;
-#endif
-	}
-	if (snd_profile)
-	{
-#ifdef FMOD_INIT_PROFILE_ENABLE
-		initflags |= FMOD_INIT_PROFILE_ENABLE;
-#else
-		initflags |= FMOD_INIT_ENABLE_PROFILE;
-#endif
-	}
-	for (;;)
-	{
-		result = Sys->init(MAX(*snd_channels, MAX_CHANNELS), initflags, 0);
-		if (result == FMOD_ERR_OUTPUT_CREATEBUFFER)
-		{ 
-			// Possible causes of a buffer creation failure:
-			// 1. The speaker mode selected isn't supported by this soundcard. Force it to stereo.
-			// 2. The output format is unsupported. Force it to 16-bit PCM.
-			// 3. ???
-#if FMOD_STUDIO
-			result = Sys->getSoftwareFormat(nullptr, &speakermode, nullptr);
-#else
-			result = Sys->getSpeakerMode(&speakermode);
-#endif
-			if (result == FMOD_OK &&
-				speakermode != FMOD_SPEAKERMODE_STEREO &&
-#if FMOD_STUDIO
-				FMOD_OK == Sys->setSoftwareFormat(samplerate, FMOD_SPEAKERMODE_STEREO, 0))
-#else
-				FMOD_OK == Sys->setSpeakerMode(FMOD_SPEAKERMODE_STEREO))
-#endif
-			{
-				Printf(TEXTCOLOR_RED"  Buffer creation failed. Retrying with stereo output.\n");
-				continue;
-			}
-#if !FMOD_STUDIO
-			result = Sys->getSoftwareFormat(&samplerate, &format, NULL, NULL, &resampler, NULL);
-			if (result == FMOD_OK &&
-				format != FMOD_SOUND_FORMAT_PCM16 &&
-				FMOD_OK == Sys->setSoftwareFormat(samplerate, FMOD_SOUND_FORMAT_PCM16, 0, 0, resampler))
-			{
-				Printf(TEXTCOLOR_RED"  Buffer creation failed. Retrying with PCM-16 output.\n");
-				continue;
-			}
-#endif
-		}
-		else if (result == FMOD_ERR_NET_SOCKET_ERROR &&
-#ifdef FMOD_INIT_PROFILE_ENABLE
-				 (initflags & FMOD_INIT_PROFILE_ENABLE))
-#else
-				 (initflags & FMOD_INIT_ENABLE_PROFILE))
-#endif
-		{
-			Printf(TEXTCOLOR_RED"  Could not create socket. Retrying without profiling.\n");
-#ifdef FMOD_INIT_PROFILE_ENABLE
-			initflags &= ~FMOD_INIT_PROFILE_ENABLE;
-#else
-			initflags &= ~FMOD_INIT_ENABLE_PROFILE;
-#endif
-			continue;
-		}
-#ifdef _WIN32
-		else if (result == FMOD_ERR_OUTPUT_INIT)
-		{
-			FMOD_OUTPUTTYPE output;
-			result = Sys->getOutput(&output);
-			if (result == FMOD_OK && output != FMOD_OUTPUTTYPE_DSOUND)
-			{
-				Printf(TEXTCOLOR_BLUE"  Init failed for output type %s. Retrying with DirectSound.\n",
-					Enum_NameForNum(OutputNames, output));
-				if (FMOD_OK == Sys->setOutput(FMOD_OUTPUTTYPE_DSOUND))
-				{
-					continue;
-				}
-			}
-		}
-#endif
-		break;
-	}
-	if (result != FMOD_OK)
-	{ // Initializing FMOD failed. Cry cry.
-		Printf(TEXTCOLOR_ORANGE"  System::init returned error code %d\n", result);
-		return false;
-	}
-
-	// Create channel groups
-	result = Sys->createChannelGroup("Music", &MusicGroup);
-	if (result != FMOD_OK)
-	{
-		Printf(TEXTCOLOR_ORANGE"  Could not create music channel group. (Error %d)\n", result);
-		return false;
-	}
-
-	result = Sys->createChannelGroup("SFX", &SfxGroup);
-	if (result != FMOD_OK)
-	{
-		Printf(TEXTCOLOR_ORANGE"  Could not create sfx channel group. (Error %d)\n", result);
-		return false;
-	}
-
-	result = Sys->createChannelGroup("Pausable SFX", &PausableSfx);
-	if (result != FMOD_OK)
-	{
-		Printf(TEXTCOLOR_ORANGE"  Could not create pausable sfx channel group. (Error %d)\n", result);
-		return false;
-	}
-
-	result = SfxGroup->addGroup(PausableSfx);
-	if (result != FMOD_OK)
-	{
-		Printf(TEXTCOLOR_BLUE"  Could not attach pausable sfx to sfx channel group. (Error %d)\n", result);
-	}
-
-	// Create DSP units for underwater effect
-	result = Sys->createDSPByType(FMOD_DSP_TYPE_LOWPASS, &WaterLP);
-	if (result != FMOD_OK)
-	{
-		Printf(TEXTCOLOR_BLUE"  Could not create underwater lowpass unit. (Error %d)\n", result);
-	}
-	else
-	{
-		result = Sys->createDSPByType(FMOD_DSP_TYPE_SFXREVERB, &WaterReverb);
-		if (result != FMOD_OK)
-		{
-			Printf(TEXTCOLOR_BLUE"  Could not create underwater reverb unit. (Error %d)\n", result);
-		}
-	}
-
-	// Connect underwater DSP unit between PausableSFX and SFX groups, while
-	// retaining the connection established by SfxGroup->addGroup().
-	if (WaterLP != NULL)
-	{
-		FMOD::DSP *sfx_head, *pausable_head;
-
-#if FMOD_STUDIO
-		result = SfxGroup->getDSP(FMOD_CHANNELCONTROL_DSP_HEAD, &sfx_head);
-#else
-		result = SfxGroup->getDSPHead(&sfx_head);
-#endif
-		if (result == FMOD_OK)
-		{
-			result = sfx_head->getInput(0, &pausable_head, &SfxConnection);
-			if (result == FMOD_OK)
-			{
-				// The placeholder mixer is for reference to where to connect the SFX
-				// reverb unit once it gets created.
-				result = Sys->createDSPByType(FMOD_DSP_TYPE_MIXER, &SfxReverbPlaceholder);
-				if (result == FMOD_OK)
-				{
-					// Replace the PausableSFX->SFX connection with
-					// PausableSFX->ReverbPlaceholder->SFX.
-					result = SfxReverbPlaceholder->addInput(pausable_head, NULL);
-					if (result == FMOD_OK)
-					{
-						FMOD::DSPConnection *connection;
-						result = sfx_head->addInput(SfxReverbPlaceholder, &connection);
-						if (result == FMOD_OK)
-						{
-							sfx_head->disconnectFrom(pausable_head);
-							SfxReverbPlaceholder->setActive(true);
-							SfxReverbPlaceholder->setBypass(true);
-							// The placeholder now takes the place of the pausable_head
-							// for the following connections.
-							pausable_head = SfxReverbPlaceholder;
-							SfxConnection = connection;
-						}
-					}
-					else
-					{
-						SfxReverbPlaceholder->release();
-						SfxReverbPlaceholder = NULL;
-					}
-				}
-				result = WaterLP->addInput(pausable_head, NULL);
-				WaterLP->setActive(false);
-				WaterLP->setParameterFloat(FMOD_DSP_LOWPASS_CUTOFF, snd_waterlp);
-				WaterLP->setParameterFloat(FMOD_DSP_LOWPASS_RESONANCE, 2);
-
-				if (WaterReverb != NULL)
-				{
-					result = WaterReverb->addInput(WaterLP, NULL);
-					if (result == FMOD_OK)
-					{
-						result = sfx_head->addInput(WaterReverb, NULL);
-						if (result == FMOD_OK)
-						{
-//							WaterReverb->setParameter(FMOD_DSP_REVERB_ROOMSIZE, 0.001f);
-//							WaterReverb->setParameter(FMOD_DSP_REVERB_DAMP, 0.2f);
-
-							// These parameters are entirely empirical and can probably
-							// stand some improvement, but it sounds remarkably close
-							// to the old reverb unit's output.
-#if FMOD_STUDIO
-							WaterReverb->setParameterFloat(FMOD_DSP_SFXREVERB_LOWSHELFFREQUENCY, 150);
-#else
-							WaterReverb->setParameterFloat(FMOD_DSP_SFXREVERB_LFREFERENCE, 150);
-#endif
-							WaterReverb->setParameterFloat(FMOD_DSP_SFXREVERB_HFREFERENCE, 10000);
-#if !FMOD_STUDIO
-							WaterReverb->setParameterFloat(FMOD_DSP_SFXREVERB_ROOM, 0);
-							WaterReverb->setParameterFloat(FMOD_DSP_SFXREVERB_ROOMHF, -5000);
-#endif
-							WaterReverb->setParameterFloat(FMOD_DSP_SFXREVERB_DRYLEVEL, 0);
-#if FMOD_STUDIO
-							WaterReverb->setParameterFloat(FMOD_DSP_SFXREVERB_HFDECAYRATIO, 100);
-#else
-							WaterReverb->setParameterFloat(FMOD_DSP_SFXREVERB_DECAYHFRATIO, 1);
-#endif
-							WaterReverb->setParameterFloat(FMOD_DSP_SFXREVERB_DECAYTIME, 0.25f);
-							WaterReverb->setParameterFloat(FMOD_DSP_SFXREVERB_DENSITY, 100);
-							WaterReverb->setParameterFloat(FMOD_DSP_SFXREVERB_DIFFUSION, 100);
-							WaterReverb->setActive(false);
-						}
-					}
-				}
-				else
-				{
-					result = sfx_head->addInput(WaterLP, NULL);
-				}
-			}
-		}
-	}
-	LastWaterLP = snd_waterlp;
-
-	// Find the FMOD Channel Group Target Unit. To completely eliminate sound
-	// while the program is deactivated, we can deactivate this DSP unit, and
-	// all audio processing will cease. This is not directly exposed by the
-	// API but can be easily located by getting the master channel group and
-	// tracing its single output, since it is known to hook up directly to the
-	// Channel Group Target Unit. (See FMOD Profiler for proof.)
-	FMOD::ChannelGroup *master_group;
-	result = Sys->getMasterChannelGroup(&master_group);
-	if (result == FMOD_OK)
-	{
-		FMOD::DSP *master_head;
-
-#if FMOD_STUDIO
-		result = master_group->getDSP(FMOD_CHANNELCONTROL_DSP_HEAD, &master_head);
-#else
-		result = master_group->getDSPHead(&master_head);
-#endif
-		if (result == FMOD_OK)
-		{
-			result = master_head->getOutput(0, &ChannelGroupTargetUnit, NULL);
-			if (result != FMOD_OK)
-			{
-				ChannelGroupTargetUnit = NULL;
-			}
-			else
-			{
-				FMOD::DSP *dontcare;
-				result = ChannelGroupTargetUnit->getOutput(0, &dontcare, &ChannelGroupTargetUnitOutput);
-				if (result != FMOD_OK)
-				{
-					ChannelGroupTargetUnitOutput = NULL;
-				}
-			}
-		}
-	}
-
-#if FMOD_STUDIO
-	if (FMOD_OK != Sys->getSoftwareFormat(&OutputRate, NULL, NULL))
-#else
-	if (FMOD_OK != Sys->getSoftwareFormat(&OutputRate, NULL, NULL, NULL, NULL, NULL))
-#endif
-	{
-		OutputRate = 48000;		// Guess, but this should never happen.
-	}
-	Sys->set3DSettings(0.5f, 96.f, 1.f);
-	Sys->set3DRolloffCallback(RolloffCallback);
-	Sys->setStreamBufferSize(snd_streambuffersize * 1024, FMOD_TIMEUNIT_RAWBYTES);
-	snd_sfxvolume.Callback ();
-	return true;
-}
-
-//==========================================================================
-//
-// FMODSoundRenderer :: Shutdown
-//
-//==========================================================================
-
-void FMODSoundRenderer::Shutdown()
-{
-	if (Sys != NULL)
-	{
-		if (MusicGroup != NULL)
-		{
-			MusicGroup->release();
-			MusicGroup = NULL;
-		}
-		if (PausableSfx != NULL)
-		{
-			PausableSfx->release();
-			PausableSfx = NULL;
-		}
-		if (SfxGroup != NULL)
-		{
-			SfxGroup->release();
-			SfxGroup = NULL;
-		}
-		if (WaterLP != NULL)
-		{
-			WaterLP->release();
-			WaterLP = NULL;
-		}
-		if (WaterReverb != NULL)
-		{
-			WaterReverb->release();
-			WaterReverb = NULL;
-		}
-		if (SfxReverbPlaceholder != NULL)
-		{
-			SfxReverbPlaceholder->release();
-			SfxReverbPlaceholder = NULL;
-		}
-
-		Sys->close();
-		if (OutputPlugin != 0)
-		{
-			Sys->unloadPlugin(OutputPlugin);
-			OutputPlugin = 0;
-		}
-		Sys->release();
-		Sys = NULL;
-	}
-}
-
-//==========================================================================
-//
-// FMODSoundRenderer :: GetOutputRate
-//
-//==========================================================================
-
-float FMODSoundRenderer::GetOutputRate()
-{
-	return (float)OutputRate;
-}
-
-//==========================================================================
-//
-// FMODSoundRenderer :: PrintStatus
-//
-//==========================================================================
-
-void FMODSoundRenderer::PrintStatus()
-{
-	FMOD_OUTPUTTYPE output;
-	FMOD_SPEAKERMODE speakermode;
-	int driver;
-	int samplerate;
-	unsigned int bufferlength;
-	int numbuffers;
-
-	Printf ("Loaded FMOD version: " TEXTCOLOR_GREEN "%x.%02x.%02x\n", ActiveFMODVersion >> 16,
-		(ActiveFMODVersion >> 8) & 255, ActiveFMODVersion & 255);
-	if (FMOD_OK == Sys->getOutput(&output))
-	{
-		Printf ("Output type: " TEXTCOLOR_GREEN "%s\n", Enum_NameForNum(OutputNames, output));
-	}
-#if FMOD_STUDIO
-	if (FMOD_OK == Sys->getSoftwareFormat(&samplerate, &speakermode, nullptr))
-	{
-		Printf ("Speaker mode: " TEXTCOLOR_GREEN "%s\n", Enum_NameForNum(SpeakerModeNames, speakermode));
-		Printf (TEXTCOLOR_LIGHTBLUE "Software mixer sample rate: " TEXTCOLOR_GREEN "%d\n", samplerate);
-	}
-#else
-	if (FMOD_OK == Sys->getSpeakerMode(&speakermode))
-	{
-		Printf ("Speaker mode: " TEXTCOLOR_GREEN "%s\n", Enum_NameForNum(SpeakerModeNames, speakermode));
-	}
-#endif
-	if (FMOD_OK == Sys->getDriver(&driver))
-	{
-		char name[256];
-#if FMOD_STUDIO
-		if (FMOD_OK != Sys->getDriverInfo(driver, name, sizeof(name), nullptr, nullptr, nullptr, nullptr))
-#else
-		if (FMOD_OK != Sys->getDriverInfo(driver, name, sizeof(name), NULL))
-#endif
-		{
-			strcpy(name, "Unknown");
-		}
-		Printf ("Driver: " TEXTCOLOR_GREEN "%d" TEXTCOLOR_NORMAL " (" TEXTCOLOR_ORANGE "%s" TEXTCOLOR_NORMAL ")\n", driver, name);
-#if !FMOD_STUDIO
-		DumpDriverCaps(Driver_Caps, Driver_MinFrequency, Driver_MaxFrequency);
-#endif
-	}
-#if !FMOD_STUDIO
-	FMOD_SOUND_FORMAT format;
-	FMOD_DSP_RESAMPLER resampler;
-	int numoutputchannels;
-	if (FMOD_OK == Sys->getSoftwareFormat(&samplerate, &format, &numoutputchannels, NULL, &resampler, NULL))
-	{
-		Printf (TEXTCOLOR_LIGHTBLUE "Software mixer sample rate: " TEXTCOLOR_GREEN "%d\n", samplerate);
-		Printf (TEXTCOLOR_LIGHTBLUE "Software mixer format: " TEXTCOLOR_GREEN "%s\n", Enum_NameForNum(SoundFormatNames, format));
-		Printf (TEXTCOLOR_LIGHTBLUE "Software mixer channels: " TEXTCOLOR_GREEN "%d\n", numoutputchannels);
-		Printf (TEXTCOLOR_LIGHTBLUE "Software mixer resampler: " TEXTCOLOR_GREEN "%s\n", Enum_NameForNum(ResamplerNames, resampler));
-	}
-#endif
-	if (FMOD_OK == Sys->getDSPBufferSize(&bufferlength, &numbuffers))
-	{
-		Printf (TEXTCOLOR_LIGHTBLUE "DSP buffers: " TEXTCOLOR_GREEN "%u samples x %d\n", bufferlength, numbuffers);
-	}
-}
-
-//==========================================================================
-//
-// FMODSoundRenderer :: DumpDriverCaps
-//
-//==========================================================================
-
-#if !FMOD_STUDIO
-void FMODSoundRenderer::DumpDriverCaps(FMOD_CAPS caps, int minfrequency, int maxfrequency)
-{
-	Printf (TEXTCOLOR_OLIVE "   Min. frequency: " TEXTCOLOR_GREEN "%d\n", minfrequency);
-	Printf (TEXTCOLOR_OLIVE "   Max. frequency: " TEXTCOLOR_GREEN "%d\n", maxfrequency);
-	Printf ("  Features:\n");
-	if (caps == 0)									Printf(TEXTCOLOR_OLIVE "   None\n");
-	if (caps & FMOD_CAPS_HARDWARE)					Printf(TEXTCOLOR_OLIVE "   Hardware mixing\n");
-	if (caps & FMOD_CAPS_HARDWARE_EMULATED)			Printf(TEXTCOLOR_OLIVE "   Hardware acceleration is turned off!\n");
-	if (caps & FMOD_CAPS_OUTPUT_MULTICHANNEL)		Printf(TEXTCOLOR_OLIVE "   Multichannel\n");
-	if (caps & FMOD_CAPS_OUTPUT_FORMAT_PCM8)		Printf(TEXTCOLOR_OLIVE "   PCM-8");
-	if (caps & FMOD_CAPS_OUTPUT_FORMAT_PCM16)		Printf(TEXTCOLOR_OLIVE "   PCM-16");
-	if (caps & FMOD_CAPS_OUTPUT_FORMAT_PCM24)		Printf(TEXTCOLOR_OLIVE "   PCM-24");
-	if (caps & FMOD_CAPS_OUTPUT_FORMAT_PCM32)		Printf(TEXTCOLOR_OLIVE "   PCM-32");
-	if (caps & FMOD_CAPS_OUTPUT_FORMAT_PCMFLOAT)	Printf(TEXTCOLOR_OLIVE "   PCM-Float");
-	if (caps & (FMOD_CAPS_OUTPUT_FORMAT_PCM8 | FMOD_CAPS_OUTPUT_FORMAT_PCM16 | FMOD_CAPS_OUTPUT_FORMAT_PCM24 | FMOD_CAPS_OUTPUT_FORMAT_PCM32 | FMOD_CAPS_OUTPUT_FORMAT_PCMFLOAT))
-	{
-		Printf("\n");
-	}
-	if (caps & FMOD_CAPS_REVERB_LIMITED)			Printf(TEXTCOLOR_OLIVE "   Limited reverb\n");
-}
-#endif
-
-//==========================================================================
-//
-// FMODSoundRenderer :: PrintDriversList
-//
-//==========================================================================
-
-void FMODSoundRenderer::PrintDriversList()
-{
-	int numdrivers;
-	int i;
-	char name[256];
-	
-	if (FMOD_OK == Sys->getNumDrivers(&numdrivers))
-	{
-		for (i = 0; i < numdrivers; ++i)
-		{
-#if FMOD_STUDIO
-			if (FMOD_OK == Sys->getDriverInfo(i, name, sizeof(name), nullptr, nullptr, nullptr, nullptr))
-#else
-			if (FMOD_OK == Sys->getDriverInfo(i, name, sizeof(name), NULL))
-#endif
-			{
-				Printf("%d. %s\n", i, name);
-			}
-		}
-	}
-}
-
-//==========================================================================
-//
-// FMODSoundRenderer :: GatherStats
-//
-//==========================================================================
-
-FString FMODSoundRenderer::GatherStats()
-{
-	int channels;
-	float dsp, stream, update, geometry, total;
-	FString out;
-
-	channels = 0;
-	total = update = geometry = stream = dsp = 0;
-	Sys->getChannelsPlaying(&channels);
-#if FMOD_STUDIO || FMOD_VERSION >= 0x42501
-	// We were built with an FMOD with the geometry parameter.
-	if (ActiveFMODVersion >= 0x42501)
-	{ // And we are running with an FMOD that includes it.
-		FMOD_System_GetCPUUsage((FMOD_SYSTEM *)Sys, &dsp, &stream, &geometry, &update, &total);
-	}
-	else
-	{ // And we are running with an FMOD that does not include it.
-	  // Cast the function to the appropriate type and call through the cast,
-	  // since the headers are for the newer version.
-		((FMOD_RESULT (F_API *)(FMOD_SYSTEM *, float *, float *, float *, float *))
-			FMOD_System_GetCPUUsage)((FMOD_SYSTEM *)Sys, &dsp, &stream, &update, &total);
-	}
-#else
-	// Same as above, except the headers we used do not include the geometry parameter.
-	if (ActiveFMODVersion >= 0x42501)
-	{
-		((FMOD_RESULT (F_API *)(FMOD_SYSTEM *, float *, float *, float *, float *, float *))
-			FMOD_System_GetCPUUsage)((FMOD_SYSTEM *)Sys, &dsp, &stream, &geometry, &update, &total);
-	}
-	else
-	{
-		FMOD_System_GetCPUUsage((FMOD_SYSTEM *)Sys, &dsp, &stream, &update, &total);
-	}
-#endif
-
-	out.Format ("%d channels," TEXTCOLOR_YELLOW "%5.2f" TEXTCOLOR_NORMAL "%% CPU "
-		"(DSP:" TEXTCOLOR_YELLOW "%5.2f" TEXTCOLOR_NORMAL "%% "
-		"Stream:" TEXTCOLOR_YELLOW "%5.2f" TEXTCOLOR_NORMAL "%% "
-		"Geometry:" TEXTCOLOR_YELLOW "%5.2f" TEXTCOLOR_NORMAL "%% "
-		"Update:" TEXTCOLOR_YELLOW "%5.2f" TEXTCOLOR_NORMAL "%%)",
-		channels, total, dsp, stream, geometry, update);
-	return out;
-}
-
-//==========================================================================
-//
-// FMODSoundRenderer :: SetSfxVolume
-//
-//==========================================================================
-
-void FMODSoundRenderer::SetSfxVolume(float volume)
-{
-	SfxGroup->setVolume(volume);
-}
-
-//==========================================================================
-//
-// FMODSoundRenderer :: SetMusicVolume
-//
-//==========================================================================
-
-void FMODSoundRenderer::SetMusicVolume(float volume)
-{
-	MusicGroup->setVolume(volume);
-}
-
-//==========================================================================
-//
-// FMODSoundRenderer :: CreateStream
-//
-// Creates a streaming sound that receives PCM data through a callback.
-//
-//==========================================================================
-
-SoundStream *FMODSoundRenderer::CreateStream (SoundStreamCallback callback, int buffbytes, int flags, int samplerate, void *userdata)
-{
-	FMODStreamCapsule *capsule;
-	FMOD::Sound *sound;
-	FMOD_RESULT result;
-	FMOD_CREATESOUNDEXINFO exinfo;
-	FMOD_MODE mode;
-	int sample_shift;
-	int channel_shift;
-
-	InitCreateSoundExInfo(&exinfo);
-	capsule = new FMODStreamCapsule (userdata, callback, this);
-
-	mode = FMOD_2D | FMOD_OPENUSER | FMOD_LOOP_NORMAL | FMOD_SOFTWARE | FMOD_CREATESTREAM | FMOD_OPENONLY;
-	sample_shift = (flags & (SoundStream::Bits32 | SoundStream::Float)) ? 2 : (flags & SoundStream::Bits8) ? 0 : 1;
-	channel_shift = (flags & SoundStream::Mono) ? 0 : 1;
-
-	// Chunk size of stream update in samples. This will be the amount of data
-	// passed to the user callback.
-	exinfo.decodebuffersize	 = buffbytes >> (sample_shift + channel_shift);
-
-	// Number of channels in the sound.
-	exinfo.numchannels		 = 1 << channel_shift;
-
-	// Length of PCM data in bytes of whole song (for Sound::getLength).
-	// This pretends it's extremely long.
-	exinfo.length			 = ~0u;
-
-	// Default playback rate of sound. */
-	exinfo.defaultfrequency	 = samplerate;
-
-	// Data format of sound.
-	if (flags & SoundStream::Float)
-	{
-		exinfo.format = FMOD_SOUND_FORMAT_PCMFLOAT;
-	}
-	else if (flags & SoundStream::Bits32)
-	{
-		exinfo.format = FMOD_SOUND_FORMAT_PCM32;
-	}
-	else if (flags & SoundStream::Bits8)
-	{
-		exinfo.format = FMOD_SOUND_FORMAT_PCM8;
-	}
-	else
-	{
-		exinfo.format = FMOD_SOUND_FORMAT_PCM16;
-	}
-
-	// User callback for reading.
-	exinfo.pcmreadcallback	 = FMODStreamCapsule::PCMReadCallback;
-
-	// User callback for seeking.
-	exinfo.pcmsetposcallback = FMODStreamCapsule::PCMSetPosCallback;
-
-	// User data to be attached to the sound during creation.  Access via Sound::getUserData.
-	exinfo.userdata = capsule;
-
-	result = Sys->createSound(NULL, mode, &exinfo, &sound);
-	if (result != FMOD_OK)
-	{
-		delete capsule;
-		return NULL;
-	}
-	capsule->SetStream(sound);
-	return capsule;
-}
-
-//==========================================================================
-//
-// GetTagData
-//
-// Checks for a string-type tag, and returns its data.
-//
-//==========================================================================
-
-const char *GetTagData(FMOD::Sound *sound, const char *tag_name)
-{
-	FMOD_TAG tag;
-
-	if (FMOD_OK == sound->getTag(tag_name, 0, &tag) &&
-		(tag.datatype == FMOD_TAGDATATYPE_STRING || tag.datatype == FMOD_TAGDATATYPE_STRING_UTF8))
-	{
-		return (const char *)tag.data;
-	}
-	return NULL;
-}
-
-//==========================================================================
-//
-// SetCustomLoopPts
-//
-// Sets up custom sound loops by checking for these tags:
-//    LOOP_START
-//    LOOP_END
-//    LOOP_BIDI
-//
-//==========================================================================
-
-static void SetCustomLoopPts(FMOD::Sound *sound)
-{
-#if 0
-	FMOD_TAG tag;
-	int numtags;
-	if (FMOD_OK == stream->getNumTags(&numtags, NULL))
-	{
-		for (int i = 0; i < numtags; ++i)
-		{
-			if (FMOD_OK == sound->getTag(NULL, i, &tag))
-			{
-				Printf("Tag %2d. %d %s = %s\n", i, tag.datatype, tag.name, tag.data);
-			}
-		}
-	}
-#endif
-	const char *tag_data;
-	unsigned int looppt[2];
-	bool looppt_as_samples[2], have_looppt[2] = { false };
-	static const char *const loop_tags[2] = { "LOOP_START", "LOOP_END" };
-
-	for (int i = 0; i < 2; ++i)
-	{
-		if (NULL != (tag_data = GetTagData(sound, loop_tags[i])))
-		{
-			if (S_ParseTimeTag(tag_data, &looppt_as_samples[i], &looppt[i]))
-			{
-				have_looppt[i] = true;
-			}
-			else
-			{
-				Printf("Invalid %s tag: '%s'\n", loop_tags[i], tag_data);
-			}
-		}
-	}
-	if (have_looppt[0] && !have_looppt[1])
-	{ // Have a start tag, but not an end tag: End at the end of the song.
-		have_looppt[1] = (FMOD_OK == sound->getLength(&looppt[1], FMOD_TIMEUNIT_PCM));
-		looppt_as_samples[1] = true;
-	}
-	else if (!have_looppt[0] && have_looppt[1])
-	{ // Have an end tag, but no start tag: Start at beginning of the song.
-		looppt[0] = 0;
-		looppt_as_samples[0] = true;
-		have_looppt[0] = true;
-	}
-	if (have_looppt[0] && have_looppt[1])
-	{ // Have both loop points: Try to set the loop.
-		FMOD_RESULT res = sound->setLoopPoints(
-			looppt[0], looppt_as_samples[0] ? FMOD_TIMEUNIT_PCM : FMOD_TIMEUNIT_MS,
-			looppt[1] - 1, looppt_as_samples[1] ? FMOD_TIMEUNIT_PCM : FMOD_TIMEUNIT_MS);
-		if (res != FMOD_OK)
-		{
-			Printf("Setting custom loop points failed. Error %d\n", res);
-		}
-	}
-	// Check for a bi-directional loop.
-	if (NULL != (tag_data = GetTagData(sound, "LOOP_BIDI")) &&
-		(stricmp(tag_data, "on") == 0 ||
-		 stricmp(tag_data, "true") == 0 ||
-		 stricmp(tag_data, "yes") == 0 ||
-		 stricmp(tag_data, "1") == 0))
-	{
-		FMOD_MODE mode;
-		if (FMOD_OK == (sound->getMode(&mode)))
-		{
-			sound->setMode((mode & ~(FMOD_LOOP_OFF | FMOD_LOOP_NORMAL)) | FMOD_LOOP_BIDI);
-		}
-	}
-}
-
-//==========================================================================
-//
-// open_reader_callback
-// close_reader_callback
-// read_reader_callback
-// seek_reader_callback
-//
-// FMOD_CREATESOUNDEXINFO callbacks to handle reading resource data from a
-// FileReader.
-//
-//==========================================================================
-
-#if FMOD_STUDIO
-static FMOD_RESULT F_CALLBACK open_reader_callback(const char *name, unsigned int *filesize, void **handle, void *userdata)
-#else
-static FMOD_RESULT F_CALLBACK open_reader_callback(const char *name, int unicode, unsigned int *filesize, void **handle, void **userdata)
-#endif
-{
-    FileReader *reader = NULL;
-    if(sscanf(name, "_FileReader_%p", &reader) != 1)
-    {
-        Printf("Invalid name in callback: %s\n", name);
-        return FMOD_ERR_FILE_NOTFOUND;
-    }
-
-    *filesize = reader->GetLength();
-    *handle = reader;
-#if !FMOD_STUDIO
-    *userdata = reader;
-#endif
-    return FMOD_OK;
-}
-
-static FMOD_RESULT F_CALLBACK close_reader_callback(void *handle, void *userdata)
-{
-    return FMOD_OK;
-}
-
-static FMOD_RESULT F_CALLBACK read_reader_callback(void *handle, void *buffer, unsigned int sizebytes, unsigned int *bytesread, void *userdata)
-{
-    FileReader *reader = reinterpret_cast<FileReader*>(handle);
-    *bytesread = reader->Read(buffer, sizebytes);
-    if(*bytesread > 0) return FMOD_OK;
-    return FMOD_ERR_FILE_EOF;
-}
-
-static FMOD_RESULT F_CALLBACK seek_reader_callback(void *handle, unsigned int pos, void *userdata)
-{
-    FileReader *reader = reinterpret_cast<FileReader*>(handle);
-    if(reader->Seek(pos, SEEK_SET) == 0)
-        return FMOD_OK;
-    return FMOD_ERR_FILE_COULDNOTSEEK;
-}
-
-
-//==========================================================================
-//
-// FMODSoundRenderer :: OpenStream
-//
-// Creates a streaming sound from a FileReader.
-//
-//==========================================================================
-
-SoundStream *FMODSoundRenderer::OpenStream(FileReader *reader, int flags)
-{
-    FMOD_MODE mode;
-    FMOD_CREATESOUNDEXINFO exinfo;
-    FMOD::Sound *stream;
-    FMOD_RESULT result;
-    FString patches;
-    FString name;
-
-    InitCreateSoundExInfo(&exinfo);
-#if FMOD_STUDIO
-    exinfo.fileuseropen  = open_reader_callback;
-    exinfo.fileuserclose = close_reader_callback;
-    exinfo.fileuserread  = read_reader_callback;
-    exinfo.fileuserseek  = seek_reader_callback;
-#else
-    exinfo.useropen  = open_reader_callback;
-    exinfo.userclose = close_reader_callback;
-    exinfo.userread  = read_reader_callback;
-    exinfo.userseek  = seek_reader_callback;
-#endif
-
-    mode = FMOD_SOFTWARE | FMOD_2D | FMOD_CREATESTREAM;
-    if(flags & SoundStream::Loop)
-        mode |= FMOD_LOOP_NORMAL;
-    if((*snd_midipatchset)[0] != '\0')
-    {
-#ifdef _WIN32
-        // If the path does not contain any path separators, automatically
-        // prepend $PROGDIR to the path.
-        if (strcspn(snd_midipatchset, ":/\\") == strlen(snd_midipatchset))
-        {
-            patches << "$PROGDIR/" << snd_midipatchset;
-            patches = NicePath(patches);
-        }
-        else
-#endif
-        {
-            patches = NicePath(snd_midipatchset);
-        }
-        exinfo.dlsname = patches;
-    }
-
-    name.Format("_FileReader_%p", reader);
-    result = Sys->createSound(name, mode, &exinfo, &stream);
-    if(result == FMOD_ERR_FORMAT && exinfo.dlsname != NULL)
-    {
-        // FMOD_ERR_FORMAT could refer to either the main sound file or
-        // to the DLS instrument set. Try again without special DLS
-        // instruments to see if that lets it succeed.
-        exinfo.dlsname = NULL;
-        result = Sys->createSound(name, mode, &exinfo, &stream);
-        if (result == FMOD_OK)
-        {
-            Printf("%s is an unsupported format.\n", *snd_midipatchset);
-        }
-    }
-    if(result != FMOD_OK)
-        return NULL;
-
-    SetCustomLoopPts(stream);
-    return new FMODStreamCapsule(stream, this, reader);
-}
-
-SoundStream *FMODSoundRenderer::OpenStream(const char *url, int flags)
-{
-    FMOD_MODE mode;
-    FMOD_CREATESOUNDEXINFO exinfo;
-    FMOD::Sound *stream;
-    FMOD_RESULT result;
-    FString patches;
-
-    InitCreateSoundExInfo(&exinfo);
-    mode = FMOD_SOFTWARE | FMOD_2D | FMOD_CREATESTREAM;
-    if(flags & SoundStream::Loop)
-        mode |= FMOD_LOOP_NORMAL;
-    if((*snd_midipatchset)[0] != '\0')
-    {
-#ifdef _WIN32
-        // If the path does not contain any path separators, automatically
-        // prepend $PROGDIR to the path.
-        if (strcspn(snd_midipatchset, ":/\\") == strlen(snd_midipatchset))
-        {
-            patches << "$PROGDIR/" << snd_midipatchset;
-            patches = NicePath(patches);
-        }
-        else
-#endif
-        {
-            patches = NicePath(snd_midipatchset);
-        }
-        exinfo.dlsname = patches;
-    }
-
-    result = Sys->createSound(url, mode, &exinfo, &stream);
-    if(result == FMOD_ERR_FORMAT && exinfo.dlsname != NULL)
-    {
-        exinfo.dlsname = NULL;
-        result = Sys->createSound(url, mode, &exinfo, &stream);
-        if(result == FMOD_OK)
-        {
-            Printf("%s is an unsupported format.\n", *snd_midipatchset);
-        }
-    }
-
-    if(result != FMOD_OK)
-        return NULL;
-
-    SetCustomLoopPts(stream);
-    return new FMODStreamCapsule(stream, this, url);
-}
-
-//==========================================================================
-//
-// FMODSoundRenderer :: StartSound
-//
-//==========================================================================
-
-FISoundChannel *FMODSoundRenderer::StartSound(SoundHandle sfx, float vol, int pitch, int flags, FISoundChannel *reuse_chan)
-{
-	FMOD_RESULT result;
-	FMOD_MODE mode;
-	FMOD::Channel *chan;
-	float freq;
-
-#if FMOD_STUDIO
-	if (FMOD_OK == ((FMOD::Sound *)sfx.data)->getDefaults(&freq, NULL))
-#else
-	if (FMOD_OK == ((FMOD::Sound *)sfx.data)->getDefaults(&freq, NULL, NULL, NULL))
-#endif
-	{
-		freq = PITCH(freq, pitch);
-	}
-	else
-	{
-		freq = 0;
-	}
-
-	GRolloff = NULL;	// Do 2D sounds need rolloff?
-#if FMOD_STUDIO
-	result = Sys->playSound((FMOD::Sound *)sfx.data, (flags & SNDF_NOPAUSE) ? SfxGroup : PausableSfx, true, &chan);
-#else
-	result = Sys->playSound(FMOD_CHANNEL_FREE, (FMOD::Sound *)sfx.data, true, &chan);
-#endif
-	if (FMOD_OK == result)
-	{
-		result = chan->getMode(&mode);
-
-		if (result != FMOD_OK)
-		{
-			assert(0);
-			mode = FMOD_SOFTWARE;
-		}
-		mode = (mode & ~FMOD_3D) | FMOD_2D;
-		if (flags & SNDF_LOOP)
-		{
-			mode &= ~FMOD_LOOP_OFF;
-			if (!(mode & (FMOD_LOOP_NORMAL | FMOD_LOOP_BIDI)))
-			{
-				mode |= FMOD_LOOP_NORMAL;
-			}
-		}
-		else
-		{
-			mode |= FMOD_LOOP_OFF;
-		}
-		chan->setMode(mode);
-#if !FMOD_STUDIO
-		chan->setChannelGroup((flags & SNDF_NOPAUSE) ? SfxGroup : PausableSfx);
-#endif
-		if (freq != 0)
-		{
-			chan->setFrequency(freq);
-		}
-		chan->setVolume(vol);
-		if (!HandleChannelDelay(chan, reuse_chan, flags & (SNDF_ABSTIME | SNDF_LOOP), freq))
-		{
-			chan->stop();
-			return NULL;
-		}
-		if (flags & SNDF_NOREVERB)
-		{
-#if FMOD_STUDIO
-			chan->setReverbProperties(0,0.f);
-#else
-			FMOD_REVERB_CHANNELPROPERTIES reverb = { 0, };
-			if (FMOD_OK == chan->getReverbProperties(&reverb))
-			{
-				reverb.Room = -10000;
-				chan->setReverbProperties(&reverb);
-			}
-#endif
-		}
-		chan->setPaused(false);
-		return CommonChannelSetup(chan, reuse_chan);
-	}
-
-	//DPrintf (DMSG_WARNING, "Sound %s failed to play: %d\n", sfx->name.GetChars(), result);
-	return NULL;
-}
-
-//==========================================================================
-//
-// FMODSoundRenderer :: StartSound3D
-//
-//==========================================================================
-
-FISoundChannel *FMODSoundRenderer::StartSound3D(SoundHandle sfx, SoundListener *listener, float vol, 
-	FRolloffInfo *rolloff, float distscale,
-	int pitch, int priority, const FVector3 &pos, const FVector3 &vel,
-	int channum, int flags, FISoundChannel *reuse_chan)
-{
-	FMOD_RESULT result;
-	FMOD_MODE mode;
-	FMOD::Channel *chan;
-	float freq;
-	float def_freq;
-#if !FMOD_STUDIO
-	float def_vol, def_pan;
-#endif
-	int numchans;
-	int def_priority;
-
-#if FMOD_STUDIO
-	if (FMOD_OK == ((FMOD::Sound *)sfx.data)->getDefaults(&def_freq, &def_priority))
-#else
-	if (FMOD_OK == ((FMOD::Sound *)sfx.data)->getDefaults(&def_freq, &def_vol, &def_pan, &def_priority))
-#endif
-	{
-		freq = PITCH(def_freq, pitch);
-		// Change the sound's default priority before playing it.
-#if FMOD_STUDIO
-		((FMOD::Sound *)sfx.data)->setDefaults(def_freq, clamp(def_priority - priority, 1, 256));
-#else
-		((FMOD::Sound *)sfx.data)->setDefaults(def_freq, def_vol, def_pan, clamp(def_priority - priority, 1, 256));
-#endif
-	}
-	else
-	{
-		freq = 0;
-		def_priority = -1;
-	}
-
-	// Play it.
-	GRolloff = rolloff;
-	GDistScale = distscale;
-
-	// Experiments indicate that playSound will ignore priorities and always succeed
-	// as long as the parameters are set properly. It will first try to kick out sounds
-	// with the same priority level but has no problem with kicking out sounds at
-	// higher priority levels if it needs to.
-#if FMOD_STUDIO
-	result = Sys->playSound((FMOD::Sound *)sfx.data, (flags & SNDF_NOPAUSE) ? SfxGroup : PausableSfx, true, &chan);
-#else
-	result = Sys->playSound(FMOD_CHANNEL_FREE, (FMOD::Sound *)sfx.data, true, &chan);
-#endif
-
-	// Then set the priority back.
-	if (def_priority >= 0)
-	{
-#if FMOD_STUDIO
-		((FMOD::Sound *)sfx.data)->setDefaults(def_freq,  def_priority);
-#else
-		((FMOD::Sound *)sfx.data)->setDefaults(def_freq, def_vol, def_pan, def_priority);
-#endif
-	}
-
-	if (FMOD_OK == result)
-	{
-		result = chan->getMode(&mode);
-		if (result != FMOD_OK)
-		{
-			mode = FMOD_3D | FMOD_SOFTWARE;
-		}
-		if (flags & SNDF_LOOP)
-		{
-			mode &= ~FMOD_LOOP_OFF;
-			if (!(mode & (FMOD_LOOP_NORMAL | FMOD_LOOP_BIDI)))
-			{
-				mode |= FMOD_LOOP_NORMAL;
-			}
-		}
-		else
-		{
-			// FMOD_LOOP_OFF overrides FMOD_LOOP_NORMAL and FMOD_LOOP_BIDI
-			mode |= FMOD_LOOP_OFF;
-		}
-		mode = SetChanHeadSettings(listener, chan, pos, !!(flags & SNDF_AREA), mode);
-		chan->setMode(mode);
-#if !FMOD_STUDIO
-		chan->setChannelGroup((flags & SNDF_NOPAUSE) ? SfxGroup : PausableSfx);
-#endif
-
-		if (mode & FMOD_3D)
-		{
-			// Reduce volume of stereo sounds, because each channel will be summed together
-			// and is likely to be very similar, resulting in an amplitude twice what it
-			// would have been had it been mixed to mono.
-			if (FMOD_OK == ((FMOD::Sound *)sfx.data)->getFormat(NULL, NULL, &numchans, NULL))
-			{
-				if (numchans > 1)
-				{
-					vol *= 0.5f;
-				}
-			}
-		}
-		if (freq != 0)
-		{
-			chan->setFrequency(freq);
-		}
-		chan->setVolume(vol);
-		if (mode & FMOD_3D)
-		{
-			chan->set3DAttributes((FMOD_VECTOR *)&pos[0], (FMOD_VECTOR *)&vel[0]);
-		}
-		if (!HandleChannelDelay(chan, reuse_chan, flags & (SNDF_ABSTIME | SNDF_LOOP), freq))
-		{
-			// FMOD seems to get confused if you stop a channel right after
-			// starting it, so hopefully this function will never fail.
-			// (Presumably you need an update between them, but I haven't
-			// tested this hypothesis.)
-			chan->stop();
-			return NULL;
-		}
-		if (flags & SNDF_NOREVERB)
-		{
-#if FMOD_STUDIO
-			chan->setReverbProperties(0,0.f);
-#else
-			FMOD_REVERB_CHANNELPROPERTIES reverb = { 0, };
-			if (FMOD_OK == chan->getReverbProperties(&reverb))
-			{
-				reverb.Room = -10000;
-				chan->setReverbProperties(&reverb);
-			}
-#endif
-		}
-		chan->setPaused(false);
-		chan->getPriority(&def_priority);
-		FISoundChannel *schan = CommonChannelSetup(chan, reuse_chan);
-		schan->Rolloff = *rolloff;
-		return schan;
-	}
-
-	GRolloff = NULL;
-	//DPrintf (DMSG_WARNING, "Sound %s failed to play: %d\n", sfx->name.GetChars(), result);
-	return 0;
-}
-
-//==========================================================================
-//
-// FMODSoundRenderer :: MarkStartTime
-//
-// Marks a channel's start time without actually playing it.
-//
-//==========================================================================
-
-void FMODSoundRenderer::MarkStartTime(FISoundChannel *chan)
-{
-#if FMOD_STUDIO
-	uint64_t dsp_time;
-	((FMOD::Channel *)chan->SysChannel)->getDSPClock(&dsp_time,NULL);
-	chan->StartTime.Lo = dsp_time & 0xFFFFFFFF;
-	chan->StartTime.Hi = dsp_time >> 32;
-#else
-	Sys->getDSPClock(&chan->StartTime.Hi, &chan->StartTime.Lo);
-#endif
-}
-
-//==========================================================================
-//
-// FMODSoundRenderer :: HandleChannelDelay
-//
-// If the sound is restarting, seek it to its proper place. Returns false
-// if the sound would have ended.
-//
-// Otherwise, record its starting time, and return true.
-//
-//==========================================================================
-
-bool FMODSoundRenderer::HandleChannelDelay(FMOD::Channel *chan, FISoundChannel *reuse_chan, int flags, float freq) const
-{
-	if (reuse_chan != NULL)
-	{ // Sound is being restarted, so seek it to the position
-	  // it would be in now if it had never been evicted.
-		QWORD_UNION nowtime;
-#if FMOD_STUDIO
-		uint64_t delay;
-		chan->getDelay(&delay,NULL,NULL);
-		nowtime.Lo = delay & 0xFFFFFFFF;
-		nowtime.Hi = delay >> 32;
-#else
-		chan->getDelay(FMOD_DELAYTYPE_DSPCLOCK_START, &nowtime.Hi, &nowtime.Lo);
-#endif
-
-		// If abstime is set, the sound is being restored, and
-		// the channel's start time is actually its seek position.
-		if (flags & SNDF_ABSTIME)
-		{
-			unsigned int seekpos = reuse_chan->StartTime.Lo;
-			if (seekpos > 0)
-			{
-				chan->setPosition(seekpos, FMOD_TIMEUNIT_PCM);
-			}
-			reuse_chan->StartTime.AsOne = uint64_t(nowtime.AsOne - seekpos * OutputRate / freq);
-		}
-		else if (reuse_chan->StartTime.AsOne != 0)
-		{
-			uint64_t difftime = nowtime.AsOne - reuse_chan->StartTime.AsOne;
-			if (difftime > 0)
-			{
-				// Clamp the position of looping sounds to be within the sound.
-				// If we try to start it several minutes past its normal end,
-				// FMOD doesn't like that.
-				// FIXME: Clamp this right for loops that don't cover the whole sound.
-				if (flags & SNDF_LOOP)
-				{
-					FMOD::Sound *sound;
-					if (FMOD_OK == chan->getCurrentSound(&sound))
-					{
-						unsigned int len;
-						if (FMOD_OK == sound->getLength(&len, FMOD_TIMEUNIT_MS) && len != 0)
-						{
-							difftime %= len;
-						}
-					}
-				}
-				return chan->setPosition((unsigned int)(difftime / OutputRate), FMOD_TIMEUNIT_MS) == FMOD_OK;
-			}
-		}
-	}
-	else
-	{
-//		chan->setDelay(FMOD_DELAYTYPE_DSPCLOCK_START, DSPClock.Hi, DSPClock.Lo);
-	}
-	return true;
-}
-
-//==========================================================================
-//
-// FMODSoundRenderer :: SetChanHeadSettings
-//
-// If this sound is played at the same coordinates as the listener, make
-// it head relative. Also, area sounds should use no 3D panning if close
-// enough to the listener.
-//
-//==========================================================================
-
-FMOD_MODE FMODSoundRenderer::SetChanHeadSettings(SoundListener *listener, FMOD::Channel *chan,
-												 const FVector3 &pos, bool areasound, 
-												 FMOD_MODE oldmode) const
-{
-	if (!listener->valid)
-	{
-		return oldmode;
-	}
-	FVector3 cpos, mpos;
-
-	cpos = listener->position;
-
-	if (areasound)
-	{
-		float level, old_level;
-
-		// How far are we from the perceived sound origin? Within a certain
-		// short distance, we interpolate between 2D panning and full 3D panning.
-		const double interp_range = 32.0;
-		double dist_sqr = (cpos - pos).LengthSquared();
-
-		if (dist_sqr == 0)
-		{
-			level = 0;
-		}
-		else if (dist_sqr <= interp_range * interp_range)
-		{ // Within interp_range: Interpolate between none and full 3D panning.
-			level = float(1 - (interp_range - sqrt(dist_sqr)) / interp_range);
-		}
-		else
-		{ // Beyond interp_range: Normal 3D panning.
-			level = 1;
-		}
-#if FMOD_STUDIO
-		if (chan->get3DLevel(&old_level) == FMOD_OK && old_level != level)
-		{ // Only set it if it's different.
-			chan->set3DLevel(level);
-#else
-		if (chan->get3DPanLevel(&old_level) == FMOD_OK && old_level != level)
-		{ // Only set it if it's different.
-			chan->set3DPanLevel(level);
-#endif
-			if (level < 1)
-			{ // Let the noise come from all speakers, not just the front ones.
-			  // A centered 3D sound does not play at full volume, so neither should the 2D-panned one.
-			  // This is sqrt(0.5), which is the result for a centered equal power panning.
-#if FMOD_STUDIO
-				chan->setMixLevelsOutput(0.70711f,0.70711f,0.70711f,0.70711f,0.70711f,0.70711f,0.70711f,0.70711f);
-#else
-				chan->setSpeakerMix(0.70711f,0.70711f,0.70711f,0.70711f,0.70711f,0.70711f,0.70711f,0.70711f);
-#endif
-			}
-		}
-		return oldmode;
-	}
-	else if ((cpos - pos).LengthSquared() < (0.0004 * 0.0004))
-	{ // Head relative
-		return (oldmode & ~FMOD_3D) | FMOD_2D;
-	}
-	// World relative
-	return (oldmode & ~FMOD_2D) | FMOD_3D;
-}
-
-//==========================================================================
-//
-// FMODSoundRenderer :: CommonChannelSetup
-//
-// Assign an end callback to the channel and allocates a game channel for
-// it.
-//
-//==========================================================================
-
-FISoundChannel *FMODSoundRenderer::CommonChannelSetup(FMOD::Channel *chan, FISoundChannel *reuse_chan) const
-{
-	FISoundChannel *schan;
-	
-	if (reuse_chan != NULL)
-	{
-		schan = reuse_chan;
-		schan->SysChannel = chan;
-	}
-	else
-	{
-		schan = S_GetChannel(chan);
-#if FMOD_STUDIO
-		uint64_t time;
-		chan->getDelay(&time,NULL,NULL);
-		schan->StartTime.Lo = time & 0xFFFFFFFF;
-		schan->StartTime.Hi = time >> 32;
-#else
-		chan->getDelay(FMOD_DELAYTYPE_DSPCLOCK_START, &schan->StartTime.Hi, &schan->StartTime.Lo);
-#endif
-	}
-	chan->setUserData(schan);
-	chan->setCallback(ChannelCallback);
-	GRolloff = NULL;
-	return schan;
-}
-
-//==========================================================================
-//
-// FMODSoundRenderer :: StopChannel
-//
-//==========================================================================
-
-void FMODSoundRenderer::StopChannel(FISoundChannel *chan)
-{
-	if (chan != NULL && chan->SysChannel != NULL)
-	{
-		if (((FMOD::Channel *)chan->SysChannel)->stop() == FMOD_ERR_INVALID_HANDLE)
-		{ // The channel handle was invalid; pretend it ended.
-			S_ChannelEnded(chan);
-		}
-	}
-}
-
-//==========================================================================
-//
-// FMODSoundRenderer :: ChannelVolume
-//
-//==========================================================================
-
-void FMODSoundRenderer::ChannelVolume(FISoundChannel *chan, float volume)
-{
-	if (chan != NULL && chan->SysChannel != NULL)
-	{
-		((FMOD::Channel *)chan->SysChannel)->setVolume(volume);
-	}
-}
-
-//==========================================================================
-//
-// FMODSoundRenderer :: GetPosition
-//
-// Returns position of sound on this channel, in samples.
-//
-//==========================================================================
-
-unsigned int FMODSoundRenderer::GetPosition(FISoundChannel *chan)
-{
-	unsigned int pos;
-
-	if (chan == NULL || chan->SysChannel == NULL)
-	{
-		return 0;
-	}
-	((FMOD::Channel *)chan->SysChannel)->getPosition(&pos, FMOD_TIMEUNIT_PCM);
-	return pos;
-}
-
-//==========================================================================
-//
-// FMODSoundRenderer :: GetAudibility
-//
-// Returns the audible volume of the channel, after rollof and any other
-// factors are applied.
-//
-//==========================================================================
-
-float FMODSoundRenderer::GetAudibility(FISoundChannel *chan)
-{
-	float aud;
-
-	if (chan == NULL || chan->SysChannel == NULL)
-	{
-		return 0;
-	}
-	((FMOD::Channel *)chan->SysChannel)->getAudibility(&aud);
-	return aud;
-}
-
-//==========================================================================
-//
-// FMODSoundRenderer :: SetSfxPaused
-//
-//==========================================================================
-
-void FMODSoundRenderer::SetSfxPaused(bool paused, int slot)
-{
-	int oldslots = SFXPaused;
-
-	if (paused)
-	{
-		SFXPaused |= 1 << slot;
-	}
-	else
-	{
-		SFXPaused &= ~(1 << slot);
-	}
-	//Printf("%d\n", SFXPaused);
-	if (oldslots != 0 && SFXPaused == 0)
-	{
-		PausableSfx->setPaused(false);
-	}
-	else if (oldslots == 0 && SFXPaused != 0)
-	{
-		PausableSfx->setPaused(true);
-	}
-}
-
-//==========================================================================
-//
-// FMODSoundRenderer :: SetInactive
-//
-// This is similar to SetSfxPaused but will *pause* everything, including
-// the global reverb effect. This is meant to be used only when the
-// game is deactivated, not for general sound pausing.
-//
-//==========================================================================
-
-void FMODSoundRenderer::SetInactive(SoundRenderer::EInactiveState inactive)
-{
-	float mix;
-	bool active;
-
-	if (inactive == INACTIVE_Active)
-	{
-		mix = 1;
-		active = true;
-	}
-	else if (inactive == INACTIVE_Complete)
-	{
-		mix = 1;
-		active = false;
-	}
-	else // inactive == INACTIVE_Mute
-	{
-		mix = 0;
-		active = true;
-	}
-	if (ChannelGroupTargetUnitOutput != NULL)
-	{
-		ChannelGroupTargetUnitOutput->setMix(mix);
-	}
-	if (ChannelGroupTargetUnit != NULL)
-	{
-		ChannelGroupTargetUnit->setActive(active);
-	}
-}
-
-//==========================================================================
-//
-// FMODSoundRenderer :: UpdateSoundParams3D
-//
-//==========================================================================
-
-void FMODSoundRenderer::UpdateSoundParams3D(SoundListener *listener, FISoundChannel *chan, bool areasound, const FVector3 &pos, const FVector3 &vel)
-{
-	if (chan == NULL || chan->SysChannel == NULL)
-		return;
-
-	FMOD::Channel *fchan = (FMOD::Channel *)chan->SysChannel;
-	FMOD_MODE oldmode, mode;
-
-	if (fchan->getMode(&oldmode) != FMOD_OK)
-	{
-		oldmode = FMOD_3D | FMOD_SOFTWARE;
-	}
-	mode = SetChanHeadSettings(listener, fchan, pos, areasound, oldmode);
-	if (mode != oldmode)
-	{ // Only set the mode if it changed.
-		fchan->setMode(mode);
-	}
-	fchan->set3DAttributes((FMOD_VECTOR *)&pos[0], (FMOD_VECTOR *)&vel[0]);
-}
-
-//==========================================================================
-//
-// FMODSoundRenderer :: UpdateListener
-//
-//==========================================================================
-
-void FMODSoundRenderer::UpdateListener(SoundListener *listener)
-{
-	FMOD_VECTOR pos, vel;
-	FMOD_VECTOR forward;
-	FMOD_VECTOR up;
-
-	if (!listener->valid)
-	{
-		return;
-	}
-
-	// Set velocity to 0 to prevent crazy doppler shifts just from running.
-
-	vel.x = listener->velocity.X;
-	vel.y = listener->velocity.Y;
-	vel.z = listener->velocity.Z;
-	pos.x = listener->position.X;
-	pos.y = listener->position.Y;
-	pos.z = listener->position.Z;
-
-	float angle = listener->angle;
-	forward.x = cosf(angle);
-	forward.y = 0;
-	forward.z = sinf(angle);
-
-	up.x = 0;
-	up.y = 1;
-	up.z = 0;
-
-	Sys->set3DListenerAttributes(0, &pos, &vel, &forward, &up);
-
-	bool underwater = false;
-	const ReverbContainer *env;
-
-	underwater = (listener->underwater && snd_waterlp);
-	if (ForcedEnvironment)
-	{
-		env = ForcedEnvironment;
-	}
-	else
-	{
-		env = listener->Environment;
-		if (env == NULL)
-		{
-			env = DefaultEnvironments[0];
-		}
-	}
-	if (env != PrevEnvironment || env->Modified)
-	{
-		DPrintf (DMSG_NOTIFY, "Reverb Environment %s\n", env->Name);
-		const_cast<ReverbContainer*>(env)->Modified = false;
-		SetSystemReverbProperties(&env->Properties);
-		PrevEnvironment = env;
-
-		if (!SfxReverbHooked)
-		{
-			SfxReverbHooked = ReconnectSFXReverbUnit();
-		}
-	}
-
-	if (underwater || env->SoftwareWater)
-	{
-		//PausableSfx->setPitch(0.64171f);		// This appears to be what Duke 3D uses
-		PausableSfx->setPitch(0.7937005f);		// Approx. 4 semitones lower; what Nash suggested
-		if (WaterLP != NULL)
-		{
-			if (LastWaterLP != snd_waterlp)
-			{
-				LastWaterLP = snd_waterlp;
-				WaterLP->setParameterFloat(FMOD_DSP_LOWPASS_CUTOFF, snd_waterlp);
-			}
-			WaterLP->setActive(true);
-			if (WaterReverb != NULL && snd_waterreverb)
-			{
-				WaterReverb->setActive(true);
-				WaterReverb->setBypass(false);
-				SfxConnection->setMix(0);
-			}
-			else
-			{
-				// Let some of the original mix through so that high frequencies are
-				// not completely lost. The reverb unit has its own connection and
-				// preserves dry sounds itself if used.
-				SfxConnection->setMix(0.1f);
-				if (WaterReverb != NULL)
-				{
-					WaterReverb->setActive(true);
-					WaterReverb->setBypass(true);
-				}
-			}
-		}
-	}
-	else
-	{
-		PausableSfx->setPitch(1);
-		if (WaterLP != NULL)
-		{
-			SfxConnection->setMix(1);
-			WaterLP->setActive(false);
-			if (WaterReverb != NULL)
-			{
-				WaterReverb->setActive(false);
-			}
-		}
-	}
-}
-
-//==========================================================================
-//
-// FMODSoundRenderer :: ReconnectSFXReverbUnit
-//
-// Locates the DSP unit responsible for software 3D reverb. There is only
-// one, and it by default is connected directly to the ChannelGroup Target
-// Unit. Older versions of FMOD created this at startup; newer versions
-// delay creating it until the first call to setReverbProperties, at which
-// point it persists until the system is closed.
-//
-// Upon locating the proper DSP unit, reconnects it to serve as an input to
-// our water DSP chain after the Pausable SFX ChannelGroup.
-//
-//==========================================================================
-
-bool FMODSoundRenderer::ReconnectSFXReverbUnit()
-{
-	FMOD::DSP *unit;
-	FMOD_DSP_TYPE type;
-	int numinputs, i;
-
-	if (ChannelGroupTargetUnit == NULL || SfxReverbPlaceholder == NULL)
-	{
-		return false;
-	}
-	// Look for SFX Reverb unit
-	if (FMOD_OK != ChannelGroupTargetUnit->getNumInputs(&numinputs))
-	{
-		return false;
-	}
-	for (i = numinputs - 1; i >= 0; --i)
-	{
-		if (FMOD_OK == ChannelGroupTargetUnit->getInput(i, &unit, NULL) &&
-			FMOD_OK == unit->getType(&type))
-		{
-			if (type == FMOD_DSP_TYPE_SFXREVERB)
-			{
-				break;
-			}
-		}
-	}
-	if (i < 0)
-	{
-		return false;
-	}
-
-	// Found it! Now move it in the DSP graph to be done before the water
-	// effect.
-	if (FMOD_OK != ChannelGroupTargetUnit->disconnectFrom(unit))
-	{
-		return false;
-	}
-	if (FMOD_OK != SfxReverbPlaceholder->addInput(unit, NULL))
-	{
-		return false;
-	}
-	return true;
-}
-
-//==========================================================================
-//
-// FMODSoundRenderer :: Sync
-//
-// Used by the save/load code to restart sounds at the same position they
-// were in at the time of saving. Must not be nested.
-//
-//==========================================================================
-
-void FMODSoundRenderer::Sync(bool sync)
-{
-	DSPLocked = sync;
-	if (sync)
-	{
-		Sys->lockDSP();
-#if FMOD_STUDIO
-		uint64_t clock;
-		SfxGroup->getDSPClock(&clock,NULL);
-		DSPClock.Lo = clock & 0xFFFFFFFF;
-		DSPClock.Hi = clock >> 32;
-#else
-		Sys->getDSPClock(&DSPClock.Hi, &DSPClock.Lo);
-#endif
-	}
-	else
-	{
-		Sys->unlockDSP();
-	}
-}
-
-//==========================================================================
-//
-// FMODSoundRenderer :: UpdateSounds
-//
-//==========================================================================
-
-void FMODSoundRenderer::UpdateSounds()
-{
-	// Any sounds played between now and the next call to this function
-	// will start exactly one tic from now.
-#if FMOD_STUDIO
-	uint64_t clock;
-	SfxGroup->getDSPClock(&clock,NULL);
-	DSPClock.Lo = clock & 0xFFFFFFFF;
-	DSPClock.Hi = clock >> 32;
-#else
-	Sys->getDSPClock(&DSPClock.Hi, &DSPClock.Lo);
-#endif
-	DSPClock.AsOne += OutputRate / TICRATE;
-	Sys->update();
-}
-
-//==========================================================================
-//
-// FMODSoundRenderer :: LoadSoundRaw
-//
-//==========================================================================
-
-std::pair<SoundHandle,bool> FMODSoundRenderer::LoadSoundRaw(uint8_t *sfxdata, int length, int frequency, int channels, int bits, int loopstart, int loopend, bool monoize)
-{
-	FMOD_CREATESOUNDEXINFO exinfo;
-	SoundHandle retval = { NULL };
-	int numsamples;
-
-	if (length <= 0)
-	{
-		return std::make_pair(retval, true);
-	}
-
-	InitCreateSoundExInfo(&exinfo);
-	exinfo.length = length;
-	exinfo.numchannels = channels;
-	exinfo.defaultfrequency = frequency;
-	switch (bits)
-	{
-#if FMOD_STUDIO
-	case -8:
-		// Need to convert sample data from signed to unsigned.
-		for (int i = 0; i < length; i++)
-		{
-			sfxdata[i] ^= 0x80;
-		}
-
-	case 8:
-#else // !FMOD_STUDIO
-	case 8:
-		// Need to convert sample data from unsigned to signed.
-		for (int i = 0; i < length; ++i)
-		{
-			sfxdata[i] = sfxdata[i] - 128;
-		}
-
-	case -8:
-#endif // FMOD_STUDIO
-		exinfo.format = FMOD_SOUND_FORMAT_PCM8;
-		numsamples = length;
-		break;
-
-	case 16:
-		exinfo.format = FMOD_SOUND_FORMAT_PCM16;
-		numsamples = length >> 1;
-		break;
-
-	case 32:
-		exinfo.format = FMOD_SOUND_FORMAT_PCM32;
-		numsamples = length >> 2;
-		break;
-
-	default:
-		return std::make_pair(retval, true);
-	}
-
-	const FMOD_MODE samplemode = FMOD_3D | FMOD_OPENMEMORY | FMOD_SOFTWARE | FMOD_OPENRAW;
-	FMOD::Sound *sample;
-	FMOD_RESULT result;
-
-	result = Sys->createSound((char *)sfxdata, samplemode, &exinfo, &sample);
-	if (result != FMOD_OK)
-	{
-		DPrintf(DMSG_ERROR, "Failed to allocate sample: Error %d\n", result);
-		return std::make_pair(retval, true);
-	}
-
-	if (loopstart >= 0)
-	{
-		if (loopend == -1)
-			loopend = numsamples - 1;
-		sample->setLoopPoints(loopstart, FMOD_TIMEUNIT_PCM, loopend, FMOD_TIMEUNIT_PCM);
-	}
-
-	retval.data = sample;
-	return std::make_pair(retval, true);
-}
-
-//==========================================================================
-//
-// FMODSoundRenderer :: LoadSound
-//
-//==========================================================================
-
-std::pair<SoundHandle,bool> FMODSoundRenderer::LoadSound(uint8_t *sfxdata, int length, bool monoize)
-{
-	FMOD_CREATESOUNDEXINFO exinfo;
-	SoundHandle retval = { NULL };
-
-	if (length == 0) return std::make_pair(retval, true);
-
-	InitCreateSoundExInfo(&exinfo);
-	exinfo.length = length;
-
-	const FMOD_MODE samplemode = FMOD_3D | FMOD_OPENMEMORY | FMOD_SOFTWARE;
-	FMOD::Sound *sample;
-	FMOD_RESULT result;
-
-	result = Sys->createSound((char *)sfxdata, samplemode, &exinfo, &sample);
-	if (result != FMOD_OK)
-	{
-		DPrintf(DMSG_ERROR, "Failed to allocate sample: Error %d\n", result);
-		return std::make_pair(retval, true);
-	}
-	SetCustomLoopPts(sample);
-	retval.data = sample;
-	return std::make_pair(retval, true);
-}
-
-//==========================================================================
-//
-// FMODSoundRenderer :: UnloadSound
-//
-//==========================================================================
-
-void FMODSoundRenderer::UnloadSound(SoundHandle sfx)
-{
-	if (sfx.data != NULL)
-	{
-		((FMOD::Sound *)sfx.data)->release();
-	}
-}
-
-//==========================================================================
-//
-// FMODSoundRenderer :: GetMSLength
-//
-//==========================================================================
-
-unsigned int FMODSoundRenderer::GetMSLength(SoundHandle sfx)
-{
-	if (sfx.data != NULL)
-	{
-		unsigned int length;
-
-		if (((FMOD::Sound *)sfx.data)->getLength(&length, FMOD_TIMEUNIT_MS) == FMOD_OK)
-		{
-			return length;
-		}
-	}
-	return 0;	// Don't know.
-}
-
-
-//==========================================================================
-//
-// FMODSoundRenderer :: GetMSLength
-//
-//==========================================================================
-
-unsigned int FMODSoundRenderer::GetSampleLength(SoundHandle sfx)
-{
-	if (sfx.data != NULL)
-	{
-		unsigned int length;
-
-		if (((FMOD::Sound *)sfx.data)->getLength(&length, FMOD_TIMEUNIT_PCM) == FMOD_OK)
-		{
-			return length;
-		}
-	}
-	return 0;	// Don't know.
-}
-
-
-//==========================================================================
-//
-// FMODSoundRenderer :: ChannelCallback								static
-//
-// Handles when a channel finishes playing. This is only called when
-// System::update is called and is therefore asynchronous with the actual
-// end of the channel.
-//
-//==========================================================================
-
-FMOD_RESULT F_CALLBACK FMODSoundRenderer::ChannelCallback
-#if FMOD_STUDIO
-	(FMOD_CHANNELCONTROL *channel, FMOD_CHANNELCONTROL_TYPE controltype, FMOD_CHANNELCONTROL_CALLBACK_TYPE type, void *data1, void *data2)
-#else
-	(FMOD_CHANNEL *channel, FMOD_CHANNEL_CALLBACKTYPE type, void *data1, void *data2)
-#endif
-{
-#if FMOD_STUDIO
-	FMOD::ChannelControl *chan = (FMOD::ChannelControl *)channel;
-#else
-	FMOD::Channel *chan = (FMOD::Channel *)channel;
-#endif
-	FISoundChannel *schan;
-
-	if (chan->getUserData((void **)&schan) == FMOD_OK && schan != NULL)
-	{
-#if FMOD_STUDIO
-		if (type == FMOD_CHANNELCONTROL_CALLBACK_END)
-#else
-		if (type == FMOD_CHANNEL_CALLBACKTYPE_END)
-#endif
-		{
-			S_ChannelEnded(schan);
-		}
-#if FMOD_STUDIO
-		else if (type == FMOD_CHANNELCONTROL_CALLBACK_VIRTUALVOICE)
-#else
-		else if (type == FMOD_CHANNEL_CALLBACKTYPE_VIRTUALVOICE)
-#endif
-		{
-			S_ChannelVirtualChanged(schan, data1 != 0);
-		}
-	}
-	return FMOD_OK;
-}
-
-
-//==========================================================================
-//
-// FMODSoundRenderer :: RolloffCallback								static
-//
-// Calculates a volume for the sound based on distance.
-//
-//==========================================================================
-
-#if FMOD_STUDIO
-float F_CALLBACK FMODSoundRenderer::RolloffCallback(FMOD_CHANNELCONTROL *channel, float distance)
-#else
-float F_CALLBACK FMODSoundRenderer::RolloffCallback(FMOD_CHANNEL *channel, float distance)
-#endif
-{
-#if FMOD_STUDIO
-	FMOD::ChannelControl *chan = (FMOD::ChannelControl *)channel;
-#else
-	FMOD::Channel *chan = (FMOD::Channel *)channel;
-#endif
-	FISoundChannel *schan;
-
-	if (GRolloff != NULL)
-	{
-		return S_GetRolloff(GRolloff, distance * GDistScale, true);
-	}
-	else if (chan->getUserData((void **)&schan) == FMOD_OK && schan != NULL)
-	{
-		return S_GetRolloff(&schan->Rolloff, distance * schan->DistanceScale, true);
-	}
-	else
-	{
-		return 0;
-	}
-}
-
-//==========================================================================
-//
-// FMODSoundRenderer :: DrawWaveDebug
-//
-// Bit 0: ( 1) Show oscilloscope for sfx.
-// Bit 1: ( 2) Show spectrum for sfx.
-// Bit 2: ( 4) Show oscilloscope for music.
-// Bit 3: ( 8) Show spectrum for music.
-// Bit 4: (16) Show oscilloscope for all sounds.
-// Bit 5: (32) Show spectrum for all sounds.
-//
-//==========================================================================
-
-void FMODSoundRenderer::DrawWaveDebug(int mode)
-{
-	const int window_height = 100;
-	int window_size;
-	int numoutchans;
-	int y, yy;
-	const spk *labels;
-	int labelcount;
-
-#if FMOD_STUDIO
-	if (FMOD_OK != Sys->getSoftwareFormat(NULL, NULL, &numoutchans))
-#else
-	if (FMOD_OK != Sys->getSoftwareFormat(NULL, NULL, &numoutchans, NULL, NULL, NULL))
-#endif
-	{
-		return;
-	}
-
-	// Decide on which set of labels to use.
-	labels = (numoutchans == 4) ? SpeakerNames4 : SpeakerNamesMore;
-	labelcount = MIN<int>(numoutchans, countof(SpeakerNamesMore));
-
-	// Scale all the channel windows so one group fits completely on one row, with
-	// 16 pixels of padding between each window.
-	window_size = (screen->GetWidth() - 16) / numoutchans - 16;
-
-	float *wavearray = (float*)alloca(MAX(SPECTRUM_SIZE,window_size)*sizeof(float));
-	y = 16;
-
-	yy = DrawChannelGroupOutput(SfxGroup, wavearray, window_size, window_height, y, mode);
-	if (y != yy)
-	{
-		DrawSpeakerLabels(labels, yy-14, window_size, labelcount);
-	}
-	y = DrawChannelGroupOutput(MusicGroup, wavearray, window_size, window_height, yy, mode >> 2);
-	if (y != yy)
-	{
-		DrawSpeakerLabels(labels, y-14, window_size, labelcount);
-	}
-	yy = DrawSystemOutput(wavearray, window_size, window_height, y, mode >> 4);
-	if (y != yy)
-	{
-		DrawSpeakerLabels(labels, yy-14, window_size, labelcount);
-	}
-}
-
-//==========================================================================
-//
-// FMODSoundRenderer :: DrawSpeakerLabels
-//
-//==========================================================================
-
-void FMODSoundRenderer::DrawSpeakerLabels(const spk *labels, int y, int width, int count)
-{
-	if (labels == NULL)
-	{
-		return;
-	}
-	for (int i = 0, x = 16; i < count; ++i)
-	{
-		screen->DrawText(SmallFont, CR_LIGHTBLUE, x, y, labels[i], TAG_DONE);
-		x += width + 16;
-	}
-}
-
-//==========================================================================
-//
-// FMODSoundRenderer :: DrawChannelGroupOutput
-//
-// Draws an oscilloscope and/or a spectrum for a channel group.
-//
-//==========================================================================
-
-int FMODSoundRenderer::DrawChannelGroupOutput(FMOD::ChannelGroup *group, float *wavearray, int width, int height, int y, int mode)
-{
-	int y1, y2;
-
-	switch (mode & 0x03)
-	{
-	case 0x01:		// Oscilloscope only
-		return DrawChannelGroupWaveData(group, wavearray, width, height, y, false);
-
-	case 0x02:		// Spectrum only
-		return DrawChannelGroupSpectrum(group, wavearray, width, height, y, false);
-
-	case 0x03:		// Oscilloscope + Spectrum
-		width = (width + 16) / 2 - 16;
-		y1 = DrawChannelGroupSpectrum(group, wavearray, width, height, y, true);
-		y2 = DrawChannelGroupWaveData(group, wavearray, width, height, y, true);
-		return MAX(y1, y2);
-	}
-	return y;
-}
-
-//==========================================================================
-//
-// FMODSoundRenderer :: DrawSystemOutput
-//
-// Like DrawChannelGroupOutput(), but uses the system object.
-//
-//==========================================================================
-
-int FMODSoundRenderer::DrawSystemOutput(float *wavearray, int width, int height, int y, int mode)
-{
-	int y1, y2;
-
-	switch (mode & 0x03)
-	{
-	case 0x01:		// Oscilloscope only
-		return DrawSystemWaveData(wavearray, width, height, y, false);
-
-	case 0x02:		// Spectrum only
-		return DrawSystemSpectrum(wavearray, width, height, y, false);
-
-	case 0x03:		// Oscilloscope + Spectrum
-		width = (width + 16) / 2 - 16;
-		y1 = DrawSystemSpectrum(wavearray, width, height, y, true);
-		y2 = DrawSystemWaveData(wavearray, width, height, y, true);
-		return MAX(y1, y2);
-	}
-	return y;
-}
-
-//==========================================================================
-//
-// FMODSoundRenderer :: DrawChannelGroupWaveData
-//
-// Draws all the output channels for a specified channel group.
-// Setting skip to true causes it to skip every other window.
-//
-//==========================================================================
-
-int FMODSoundRenderer::DrawChannelGroupWaveData(FMOD::ChannelGroup *group, float *wavearray, int width, int height, int y, bool skip)
-{
-	int drawn = 0;
-	int x = 16;
-
-#if !FMOD_STUDIO
-	while (FMOD_OK == group->getWaveData(wavearray, width, drawn))
-	{
-		drawn++;
-		DrawWave(wavearray, x, y, width, height);
-		x += (width + 16) << int(skip);
-	}
-#endif
-	if (drawn)
-	{
-		y += height + 16;
-	}
-	return y;
-}
-
-//==========================================================================
-//
-// FMODSoundRenderer::DrawSystemWaveData
-//
-// Like DrawChannelGroupWaveData, but it uses the system object to get the
-// complete output.
-//
-//==========================================================================
-
-int FMODSoundRenderer::DrawSystemWaveData(float *wavearray, int width, int height, int y, bool skip)
-{
-	int drawn = 0;
-	int x = 16;
-
-#if !FMOD_STUDIO
-	while (FMOD_OK == Sys->getWaveData(wavearray, width, drawn))
-	{
-		drawn++;
-		DrawWave(wavearray, x, y, width, height);
-		x += (width + 16) << int(skip);
-	}
-#endif
-	if (drawn)
-	{
-		y += height + 16;
-	}
-	return y;
-}
-
-//==========================================================================
-//
-// FMODSoundRenderer :: DrawWave
-//
-// Draws an oscilloscope at the specified coordinates on the screen. Each
-// entry in the wavearray buffer has its own column. IOW, there are <width>
-// entries in wavearray.
-//
-//==========================================================================
-
-void FMODSoundRenderer::DrawWave(float *wavearray, int x, int y, int width, int height)
-{
-	float scale = height / 2.f;
-	float mid = y + scale;
-	int i;
-
-	// Draw a box around the oscilloscope.
-	screen->DrawLine(x - 1, y - 1, x + width, y - 1, -1, MAKEARGB(160, 0, 40, 200));
-	screen->DrawLine(x + width, y - 1, x + width, y + height, -1, MAKEARGB(160, 0, 40, 200));
-	screen->DrawLine(x + width, y + height, x - 1, y + height, -1, MAKEARGB(160, 0, 40, 200));
-	screen->DrawLine(x - 1, y + height, x - 1, y - 1, -1, MAKEARGB(160, 0, 40, 200));
-
-	// Draw the actual oscilloscope.
-	if (screen->Accel2D)
-	{ // Drawing this with lines is super-slow without hardware acceleration, at least with
-	  // the debug build.
-		float lasty = mid - wavearray[0] * scale;
-		float newy;
-		for (i = 1; i < width; ++i)
-		{
-			newy = mid - wavearray[i] * scale;
-			screen->DrawLine(x + i - 1, int(lasty), x + i, int(newy), -1, MAKEARGB(255,255,248,248));
-			lasty = newy;
-		}
-	}
-	else
-	{
-		for (i = 0; i < width; ++i)
-		{
-			float y = wavearray[i] * scale + mid;
-			screen->DrawPixel(x + i, int(y), -1, MAKEARGB(255,255,255,255));
-		}
-	}
-}
-
-//==========================================================================
-//
-// FMODSoundRenderer :: DrawChannelGroupSpectrum
-//
-// Draws all the spectrum for a specified channel group.
-// Setting skip to true causes it to skip every other window, starting at
-// the second one.
-//
-//==========================================================================
-
-int FMODSoundRenderer::DrawChannelGroupSpectrum(FMOD::ChannelGroup *group, float *spectrumarray, int width, int height, int y, bool skip)
-{
-	int drawn = 0;
-	int x = 16;
-
-	if (skip)
-	{
-		x += width + 16;
-	}
-	// TODO: FMOD Studio: Grab from DSP
-#if !FMOD_STUDIO
-	while (FMOD_OK == group->getSpectrum(spectrumarray, SPECTRUM_SIZE, drawn, FMOD_DSP_FFT_WINDOW_TRIANGLE))
-	{
-		drawn++;
-		DrawSpectrum(spectrumarray, x, y, width, height);
-		x += (width + 16) << int(skip);
-	}
-#endif
-	if (drawn)
-	{
-		y += height + 16;
-	}
-	return y;
-}
-
-//==========================================================================
-//
-// FMODSoundRenderer::DrawSystemSpectrum
-//
-// Like DrawChannelGroupSpectrum, but it uses the system object to get the
-// complete output.
-//
-//==========================================================================
-
-int FMODSoundRenderer::DrawSystemSpectrum(float *spectrumarray, int width, int height, int y, bool skip)
-{
-	int drawn = 0;
-	int x = 16;
-
-	if (skip)
-	{
-		x += width + 16;
-	}
-	// TODO: FMOD Studio: Grab from DSP
-#if !FMOD_STUDIO
-	while (FMOD_OK == Sys->getSpectrum(spectrumarray, SPECTRUM_SIZE, drawn, FMOD_DSP_FFT_WINDOW_TRIANGLE))
-	{
-		drawn++;
-		DrawSpectrum(spectrumarray, x, y, width, height);
-		x += (width + 16) << int(skip);
-	}
-#endif
-	if (drawn)
-	{
-		y += height + 16;
-	}
-	return y;
-}
-
-//==========================================================================
-//
-// FMODSoundRenderer :: DrawSpectrum
-//
-// Draws a spectrum at the specified coordinates on the screen.
-//
-//==========================================================================
-
-void FMODSoundRenderer::DrawSpectrum(float *spectrumarray, int x, int y, int width, int height)
-{
-	float scale = height / 2.f;
-	float mid = y + scale;
-	float db;
-	int top;
-
-	// Draw a border and dark background for the spectrum.
-	screen->DrawLine(x - 1, y - 1, x + width, y - 1, -1, MAKEARGB(160, 0, 40, 200));
-	screen->DrawLine(x + width, y - 1, x + width, y + height, -1, MAKEARGB(160, 0, 40, 200));
-	screen->DrawLine(x + width, y + height, x - 1, y + height, -1, MAKEARGB(160, 0, 40, 200));
-	screen->DrawLine(x - 1, y + height, x - 1, y - 1, -1, MAKEARGB(160, 0, 40, 200));
-	screen->Dim(MAKERGB(0,0,0), 0.3f, x, y, width, height);
-
-	// Draw the actual spectrum.
-	for (int i = 0; i < width; ++i)
-	{
-		db = spectrumarray[i * (SPECTRUM_SIZE - 2) / width + 1];
-		db = MAX(-150.f, 10 * log10f(db) * 2);		// Convert to decibels and clamp
-		db = 1.f - (db / -150.f);
-		db *= height;
-		top = (int)db;
-		if (top >= height)
-		{
-			top = height - 1;
-		}
-//		screen->Clear(x + i, int(y + height - db), x + i + 1, y + height, -1, MAKEARGB(255, 255, 255, 40));
-		screen->Dim(MAKERGB(255,255,40), 0.65f, x + i, y + height - top, 1, top);
-	}
-}
-
-//==========================================================================
-//
-// FMODSoundRenderer :: DecodeSample
-//
-// Uses FMOD to decode a compressed sample to a 16-bit buffer. This is used
-// by the DUMB XM reader to handle FMOD's OggMods.
-//
-//==========================================================================
-
-short *FMODSoundRenderer::DecodeSample(int outlen, const void *coded, int sizebytes, ECodecType type)
-{
-	FMOD_CREATESOUNDEXINFO exinfo;
-	FMOD::Sound *sound;
-	FMOD_SOUND_FORMAT format;
-	int channels;
-	unsigned int len, amt_read;
-	FMOD_RESULT result;
-	short *outbuf;
-
-	InitCreateSoundExInfo(&exinfo);
-	if (type == CODEC_Vorbis)
-	{
-		exinfo.suggestedsoundtype = FMOD_SOUND_TYPE_OGGVORBIS;
-	}
-	exinfo.length = sizebytes;
-	result = Sys->createSound((const char *)coded,
-		FMOD_2D | FMOD_SOFTWARE | FMOD_CREATESTREAM |
-		FMOD_OPENMEMORY_POINT | FMOD_OPENONLY | FMOD_LOWMEM,
-		&exinfo, &sound);
-	if (result != FMOD_OK)
-	{
-		return NULL;
-	}
-	result = sound->getFormat(NULL, &format, &channels, NULL);
-	// TODO: Handle more formats if it proves necessary.
-	if (result != FMOD_OK || format != FMOD_SOUND_FORMAT_PCM16 || channels != 1)
-	{
-		sound->release();
-		return NULL;
-	}
-	len = outlen;
-	// Must be malloc'ed for DUMB, which is C.
-	outbuf = (short *)malloc(len);
-	result = sound->readData(outbuf, len, &amt_read);
-	sound->release();
-	if (result == FMOD_ERR_FILE_EOF)
-	{
-		memset((uint8_t *)outbuf + amt_read, 0, len - amt_read);
-	}
-	else if (result != FMOD_OK || amt_read != len)
-	{
-		free(outbuf);
-		return NULL;
-	}
-	return outbuf;
-}
-
-//==========================================================================
-//
-// FMODSoundRenderer :: InitCreateSoundExInfo
-//
-// Allow for compiling with 4.26 APIs while still running with older DLLs.
-//
-//==========================================================================
-
-void FMODSoundRenderer::InitCreateSoundExInfo(FMOD_CREATESOUNDEXINFO *exinfo) const
-{
-	memset(exinfo, 0, sizeof(*exinfo));
-#if !FMOD_STUDIO && FMOD_VERSION >= 0x42600 && FMOD_VERSION < 0x43800
-    if (ActiveFMODVersion < 0x42600)
-    {
-        // This parameter was added for 4.26.00, and trying to pass it to older
-        // DLLs will fail.
-        exinfo->cbsize = myoffsetof(FMOD_CREATESOUNDEXINFO, ignoresetfilesystem);
-    }
-    else
-#endif
-    {
-        exinfo->cbsize = sizeof(*exinfo);
-    }
-}
-
-//==========================================================================
-//
-// FMODSoundRenderer :: SetSystemReverbProperties
-//
-// Set the global reverb properties.
-//
-//==========================================================================
-
-FMOD_RESULT FMODSoundRenderer::SetSystemReverbProperties(const REVERB_PROPERTIES *props)
-{
-#if !FMOD_STUDIO && FMOD_VERSION < 0x43600
-	return Sys->setReverbProperties((const FMOD_REVERB_PROPERTIES *)props);
-#else
-	// The reverb format changed when hardware mixing support was dropped, because
-	// all EAX-only properties were removed from the structure.
-	FMOD_REVERB_PROPERTIES fr;
-
-#if FMOD_STUDIO
-	const float LateEarlyRatio = powf(10.f, (props->Reverb - props->Reflections)/2000.f);
-	const float EarlyAndLatePower = powf(10.f, props->Reflections/1000.f) + powf(10, props->Reverb/1000.f);
-	const float HFGain = powf(10.f, props->RoomHF/2000.f);
-	fr.DecayTime = props->DecayTime*1000.f;
-	fr.EarlyDelay = props->ReflectionsDelay*1000.f;
-	fr.LateDelay = props->ReverbDelay*1000.f;
-	fr.HFReference = props->HFReference;
-	fr.HFDecayRatio = clamp<float>(props->DecayHFRatio*100.f, 0.f, 100.f);
-	fr.Diffusion = props->Diffusion;
-	fr.Density = props->Density;
-	fr.LowShelfFrequency = props->DecayLFRatio;
-	fr.LowShelfGain = clamp<float>(props->RoomLF/100.f, -48.f, 12.f);
-	fr.HighCut = clamp<float>(props->RoomLF < 0 ? props->HFReference/sqrtf((1.f-HFGain)/HFGain) : 20000.f, 20.f, 20000.f);
-	fr.EarlyLateMix = props->Reflections > -10000.f ? LateEarlyRatio/(LateEarlyRatio + 1)*100.f : 100.f;
-	fr.WetLevel = clamp<float>(10*log10f(EarlyAndLatePower)+props->Room/100.f, -80.f, 20.f);
-
-	return Sys->setReverbProperties(0, &fr);
-#else
-	fr.Instance = props->Instance;
-	fr.Environment = props->Environment;
-	fr.EnvDiffusion = props->EnvDiffusion;
-	fr.Room = props->Room;
-	fr.RoomHF = props->RoomHF;
-	fr.RoomLF = props->RoomLF;
-	fr.DecayTime = props->DecayTime;
-	fr.DecayHFRatio = props->DecayHFRatio;
-	fr.DecayLFRatio = props->DecayLFRatio;
-	fr.Reflections = props->Reflections;
-	fr.ReflectionsDelay = props->ReflectionsDelay;
-	fr.Reverb = props->Reverb;
-	fr.ReverbDelay = props->ReverbDelay;
-	fr.ModulationTime = props->ModulationTime;
-	fr.ModulationDepth = props->ModulationDepth;
-	fr.HFReference = props->HFReference;
-	fr.LFReference = props->LFReference;
-	fr.Diffusion = props->Diffusion;
-	fr.Density = props->Density;
-	fr.Flags = props->Flags;
-
-	return Sys->setReverbProperties(&fr);
-#endif
-#endif
-}
-
-MIDIDevice* FMODSoundRenderer::CreateMIDIDevice() const
-{
-	return new SndSysMIDIDevice;
-}
-
-#endif // NO_FMOD
-
-
-//==========================================================================
-//
-// IsFModExPresent
-//
-// Check if FMod can be used
-//
-//==========================================================================
-
-bool IsFModExPresent()
-{
-#ifdef NO_FMOD
-	return false;
-#elif !defined _MSC_VER
-	return true;	// on non-MSVC we cannot delay load the library so it has to be present.
-#else
-	static bool cached_result;
-	static bool done = false;
-
-	if (!done)
-	{
-		done = true;
-
-		FMOD::System *Sys;
-		FMOD_RESULT result;
-		__try
-		{
-			result = FMOD::System_Create(&Sys);
-		}
-		__except (CheckException(GetExceptionCode()))
-		{
-			// FMod could not be delay loaded
-			return false;
-		}
-		if (result == FMOD_OK) Sys->release();
-		cached_result = true;
-	}
-	return cached_result;
-#endif
-}
diff --git a/src/sound/fmodsound.h b/src/sound/fmodsound.h
deleted file mode 100644
index d80423ebda..0000000000
--- a/src/sound/fmodsound.h
+++ /dev/null
@@ -1,141 +0,0 @@
-#ifndef FMODSOUND_H
-#define FMODSOUND_H
-
-#include "i_sound.h"
-
-#ifndef NO_FMOD
-#include "fmod_wrap.h"
-
-class FMODSoundRenderer : public SoundRenderer
-{
-public:
-	FMODSoundRenderer ();
-	~FMODSoundRenderer ();
-	bool IsValid ();
-
-	void SetSfxVolume (float volume);
-	void SetMusicVolume (float volume);
-	std::pair<SoundHandle,bool> LoadSound(uint8_t *sfxdata, int length, bool monoize);
-	std::pair<SoundHandle,bool> LoadSoundRaw(uint8_t *sfxdata, int length, int frequency, int channels, int bits, int loopstart, int loopend = -1, bool monoize = false);
-	void UnloadSound (SoundHandle sfx);
-	unsigned int GetMSLength(SoundHandle sfx);
-	unsigned int GetSampleLength(SoundHandle sfx);
-	float GetOutputRate();
-
-	// Streaming sounds.
-	SoundStream *CreateStream (SoundStreamCallback callback, int buffsamples, int flags, int samplerate, void *userdata);
-    SoundStream *OpenStream (FileReader *reader, int flags);
-	SoundStream *OpenStream (const char *url, int flags);
-
-	// Starts a sound.
-	FISoundChannel *StartSound (SoundHandle sfx, float vol, int pitch, int chanflags, FISoundChannel *reuse_chan);
-	FISoundChannel *StartSound3D (SoundHandle sfx, SoundListener *listener, float vol, FRolloffInfo *rolloff, float distscale, int pitch, int priority, const FVector3 &pos, const FVector3 &vel, int channum, int chanflags, FISoundChannel *reuse_chan);
-
-	// Stops a sound channel.
-	void StopChannel (FISoundChannel *chan);
-
-	// Changes a channel's volume.
-	void ChannelVolume (FISoundChannel *chan, float volume);
-
-	// Marks a channel's start time without actually playing it.
-	void MarkStartTime (FISoundChannel *chan);
-
-	// Returns position of sound on this channel, in samples.
-	unsigned int GetPosition(FISoundChannel *chan);
-
-	// Gets a channel's audibility (real volume).
-	float GetAudibility(FISoundChannel *chan);
-
-	// Synchronizes following sound startups.
-	void Sync (bool sync);
-
-	// Pauses or resumes all sound effect channels.
-	void SetSfxPaused (bool paused, int slot);
-
-	// Pauses or resumes *every* channel, including environmental reverb.
-	void SetInactive (EInactiveState inactive);
-
-	// Updates the position of a sound channel.
-	void UpdateSoundParams3D (SoundListener *listener, FISoundChannel *chan, bool areasound, const FVector3 &pos, const FVector3 &vel);
-
-	void UpdateListener (SoundListener *listener);
-	void UpdateSounds ();
-
-	void PrintStatus ();
-	void PrintDriversList ();
-	FString GatherStats ();
-	short *DecodeSample(int outlen, const void *coded, int sizebytes, ECodecType type);
-
-	void DrawWaveDebug(int mode);
-
-	virtual MIDIDevice* CreateMIDIDevice() const override;
-
-private:
-	uint32_t ActiveFMODVersion;
-	int SFXPaused;
-	bool InitSuccess;
-	bool DSPLocked;
-	QWORD_UNION DSPClock;
-	int OutputRate;
-
-#if FMOD_STUDIO
-	static FMOD_RESULT F_CALLBACK ChannelCallback(FMOD_CHANNELCONTROL *channel, FMOD_CHANNELCONTROL_TYPE controltype, FMOD_CHANNELCONTROL_CALLBACK_TYPE type, void *data1, void *data2);
-	static float F_CALLBACK RolloffCallback(FMOD_CHANNELCONTROL *channel, float distance);
-#else
-	static FMOD_RESULT F_CALLBACK ChannelCallback(FMOD_CHANNEL *channel, FMOD_CHANNEL_CALLBACKTYPE type, void *data1, void *data2);
-	static float F_CALLBACK RolloffCallback(FMOD_CHANNEL *channel, float distance);
-#endif
-
-	bool HandleChannelDelay(FMOD::Channel *chan, FISoundChannel *reuse_chan, int flags, float freq) const;
-	FISoundChannel *CommonChannelSetup(FMOD::Channel *chan, FISoundChannel *reuse_chan) const;
-	FMOD_MODE SetChanHeadSettings(SoundListener *listener, FMOD::Channel *chan, const FVector3 &pos, bool areasound, FMOD_MODE oldmode) const;
-
-	bool ReconnectSFXReverbUnit();
-	void InitCreateSoundExInfo(FMOD_CREATESOUNDEXINFO *exinfo) const;
-	FMOD_RESULT SetSystemReverbProperties(const REVERB_PROPERTIES *props);
-
-	bool Init ();
-	void Shutdown ();
-#if !FMOD_STUDIO
-	void DumpDriverCaps(FMOD_CAPS caps, int minfrequency, int maxfrequency);
-#endif
-
-	int DrawChannelGroupOutput(FMOD::ChannelGroup *group, float *wavearray, int width, int height, int y, int mode);
-	int DrawSystemOutput(float *wavearray, int width, int height, int y, int mode);
-
-	int DrawChannelGroupWaveData(FMOD::ChannelGroup *group, float *wavearray, int width, int height, int y, bool skip);
-	int DrawSystemWaveData(float *wavearray, int width, int height, int y, bool skip);
-	void DrawWave(float *wavearray, int x, int y, int width, int height);
-
-	int DrawChannelGroupSpectrum(FMOD::ChannelGroup *group, float *wavearray, int width, int height, int y, bool skip);
-	int DrawSystemSpectrum(float *wavearray, int width, int height, int y, bool skip);
-	void DrawSpectrum(float *spectrumarray, int x, int y, int width, int height);
-
-	typedef char spk[4];
-	static const spk SpeakerNames4[4], SpeakerNamesMore[8];
-	void DrawSpeakerLabels(const spk *labels, int y, int width, int count);
-
-	FMOD::System *Sys;
-	FMOD::ChannelGroup *SfxGroup, *PausableSfx;
-	FMOD::ChannelGroup *MusicGroup;
-	FMOD::DSP *WaterLP, *WaterReverb;
-	FMOD::DSPConnection *SfxConnection;
-	FMOD::DSPConnection *ChannelGroupTargetUnitOutput;
-	FMOD::DSP *ChannelGroupTargetUnit;
-	FMOD::DSP *SfxReverbPlaceholder;
-	bool SfxReverbHooked;
-	float LastWaterLP;
-	unsigned int OutputPlugin;
-
-	// Just for snd_status display
-	int Driver_MinFrequency;
-	int Driver_MaxFrequency;
-#if !FMOD_STUDIO
-	FMOD_CAPS Driver_Caps;
-#endif
-
-	friend class FMODStreamCapsule;
-};
-
-#endif
-#endif
diff --git a/src/sound/i_music.cpp b/src/sound/i_music.cpp
index af848cbeb6..a31c4de749 100644
--- a/src/sound/i_music.cpp
+++ b/src/sound/i_music.cpp
@@ -184,9 +184,6 @@ void I_ShutdownMusic(bool onexit)
 	}
 	Timidity::FreeAll();
 	if (onexit) WildMidi_Shutdown();
-#ifdef _WIN32
-	I_ShutdownMusicWin32();
-#endif // _WIN32
 }
 
 void I_ShutdownMusicExit()
diff --git a/src/sound/i_musicinterns.h b/src/sound/i_musicinterns.h
index 227464c11b..6cb2e05a2d 100644
--- a/src/sound/i_musicinterns.h
+++ b/src/sound/i_musicinterns.h
@@ -10,7 +10,6 @@
 #include "wildmidi/wildmidi_lib.h"
 
 void I_InitMusicWin32 ();
-void I_ShutdownMusicWin32 ();
 
 extern float relative_volume;
 
diff --git a/src/sound/i_sound.cpp b/src/sound/i_sound.cpp
index 42e5a8d7dc..74445a98ce 100644
--- a/src/sound/i_sound.cpp
+++ b/src/sound/i_sound.cpp
@@ -39,7 +39,6 @@
 #include "doomtype.h"
 #include <math.h>
 
-#include "fmodsound.h"
 #include "oalsound.h"
 
 #include "mpg123_decoder.h"
@@ -68,9 +67,7 @@ CVAR (Int, snd_samplerate, 0, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
 CVAR (Int, snd_buffersize, 0, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
 CVAR (String, snd_output, "default", CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
 
-#ifndef NO_FMOD
-#define DEF_BACKEND "fmod"
-#elif !defined(NO_OPENAL)
+#if !defined(NO_OPENAL)
 #define DEF_BACKEND "openal"
 #else
 #define DEF_BACKEND "null"
@@ -259,29 +256,10 @@ void I_InitSound ()
 		return;
 	}
 
-	// This has been extended to allow falling back from FMod to OpenAL and vice versa if the currently active sound system cannot be found.
 	if (stricmp(snd_backend, "null") == 0)
 	{
 		GSnd = new NullSoundRenderer;
 	}
-	else if(stricmp(snd_backend, "fmod") == 0)
-	{
-		#ifndef NO_FMOD
-			if (IsFModExPresent())
-			{
-				GSnd = new FMODSoundRenderer;
-			}
-		#endif
-		#ifndef NO_OPENAL
-			if ((!GSnd || !GSnd->IsValid()) && IsOpenALPresent())
-			{
-				Printf (TEXTCOLOR_RED"FMod Ex Sound init failed. Trying OpenAL.\n");
-				I_CloseSound();
-				GSnd = new OpenALSoundRenderer;
-				snd_backend = "openal";
-			}
-		#endif
-	}
 	else if(stricmp(snd_backend, "openal") == 0)
 	{
 		#ifndef NO_OPENAL
@@ -290,15 +268,6 @@ void I_InitSound ()
 				GSnd = new OpenALSoundRenderer;
 			}
 		#endif
-		#ifndef NO_FMOD
-			if ((!GSnd || !GSnd->IsValid()) && IsFModExPresent())
-			{
-				Printf (TEXTCOLOR_RED"OpenAL Sound init failed. Trying FMod Ex.\n");
-				I_CloseSound();
-				GSnd = new FMODSoundRenderer;
-				snd_backend = "fmod";
-			}
-		#endif
 	}
 	else
 	{
diff --git a/src/sound/i_sound.h b/src/sound/i_sound.h
index 5f1917d689..97d81d9dca 100644
--- a/src/sound/i_sound.h
+++ b/src/sound/i_sound.h
@@ -177,7 +177,6 @@ FISoundChannel *S_GetChannel(void *syschan);
 
 extern ReverbContainer *DefaultEnvironments[26];
 
-bool IsFModExPresent();
 bool IsOpenALPresent();
 
 #endif
diff --git a/src/sound/music_midi_base.cpp b/src/sound/music_midi_base.cpp
index 4e3708eb48..42e8ab863f 100644
--- a/src/sound/music_midi_base.cpp
+++ b/src/sound/music_midi_base.cpp
@@ -96,23 +96,6 @@ void I_InitMusicWin32 ()
 	snd_mididevice.Callback ();
 }
 
-void I_ShutdownMusicWin32 ()
-{
-	// Ancient bug a saw on NT 4.0 and an old version of FMOD 3: If waveout
-	// is used for sound and a MIDI is also played, then when I quit, the OS
-	// tells me a free block was modified after being freed. This is
-	// apparently a synchronization issue between two threads, because if I
-	// put this Sleep here after stopping the music but before shutting down
-	// the entire sound system, the error does not happen. Observed with a
-	// Vortex 2 (may Aureal rest in peace) and an Audigy (damn you, Creative!).
-	// I no longer have a system with NT4 drivers, so I don't know if this
-	// workaround is still needed or not.
-	if (OSPlatform == os_WinNT4)
-	{
-		Sleep(50);
-	}
-}
-
 void I_BuildMIDIMenuList (FOptionValues *opt)
 {
 	AddDefaultMidiDevices(opt);
diff --git a/src/sound/oalsound.cpp b/src/sound/oalsound.cpp
index d38435be1d..f173903ec0 100644
--- a/src/sound/oalsound.cpp
+++ b/src/sound/oalsound.cpp
@@ -630,7 +630,7 @@ public:
 };
 
 
-extern ReverbContainer *ForcedEnvironment;
+ReverbContainer *ForcedEnvironment;
 
 #define AREA_SOUND_RADIUS  (32.f)
 
diff --git a/wadsrc/static/language.enu b/wadsrc/static/language.enu
index 550a94634a..8e8572b2fe 100644
--- a/wadsrc/static/language.enu
+++ b/wadsrc/static/language.enu
@@ -2128,23 +2128,11 @@ SNDMNU_UNDERWATERREVERB	= "Underwater reverb";
 SNDMNU_RANDOMIZEPITCHES	= "Randomize pitches";
 SNDMNU_CHANNELS			= "Sound channels";
 SNDMNU_BACKEND			= "Sound backend";
-SNDMNU_FMOD				= "FMOD options";
 SNDMNU_OPENAL			= "OpenAL options";
 SNDMNU_RESTART			= "Restart sound";
 SNDMNU_ADVANCED			= "Advanced options";
 SNDMNU_MODREPLAYER		= "Module replayer options";
 
-// Fmod Options
-FMODMNU_TITLE			= "FMOD OPTIONS";
-FMODMNU_WATERCUTOFF		= "Underwater cutoff";
-FMODMNU_OUTPUTSYSTEM	= "Output system";
-FMODMNU_OUTPUTFORMAT	= "Output format";
-FMODMNU_SPEAKERMODE		= "Speaker mode";
-FMODMNU_RESAMPLER		= "Resampler";
-FMODMNU_HRTFFILTER		= "HRTF filter";
-FMODMNU_BUFFERSIZE		= "Buffer size";
-FMODMNU_BUFFERCOUNT		= "Buffer count";
-
 // OpenAL Options
 OPENALMNU_TITLE				= "OPENAL OPTIONS";
 OPENALMNU_PLAYBACKDEVICE	= "Playback device";
@@ -2428,7 +2416,6 @@ OPTSTR_5POINT1				= "5.1 speakers";
 OPTSTR_7POINT1				= "7.1 speakers";
 OPTSTR_NOINTERPOLATION		= "No interpolation";
 OPTSTR_SPLINE				= "Spline";
-OPTSTR_FMOD					= "FMOD Ex";
 OPTSTR_OPENAL				= "OpenAL";
 
 
diff --git a/wadsrc/static/menudef.txt b/wadsrc/static/menudef.txt
index 3c9c88759c..c5e3820af9 100644
--- a/wadsrc/static/menudef.txt
+++ b/wadsrc/static/menudef.txt
@@ -1557,51 +1557,12 @@ OptionString Resamplers
 }
 
 
-OptionString SoundBackends
-{
-	"fmod",		"$OPTSTR_FMOD"
-	"openal",	"$OPTSTR_OPENAL"
-	"null",		"$OPTSTR_NOSOUND"
-}
-
-OptionString SoundBackendsFModOnly
-{
-	"fmod",		"$OPTSTR_FMOD"
-	"null",		"$OPTSTR_NOSOUND"
-}
-
 OptionString SoundBackendsOpenALOnly
 {
 	"openal",	"$OPTSTR_OPENAL"
 	"null",		"$OPTSTR_NOSOUND"
 }
 
-OptionMenu FMODSoundItems
-{
-	Title "$FMODMNU_TITLE"
-	Slider	"$FMODMNU_WATERCUTOFF",			"snd_waterlp", 0.0, 2000.0, 50.0, 0
-	IfOption(Windows)
-	{
-		Option "$FMODMNU_OUTPUTSYSTEM",		"snd_output", "SoundOutputsWindows"
-	}
-	IfOption(Unix)
-	{
-		Option "$FMODMNU_OUTPUTSYSTEM",		"snd_output", "SoundOutputsUnix"
-	}
-	IfOption(Mac)
-	{
-		Option "$FMODMNU_OUTPUTSYSTEM",		"snd_output", "SoundOutputsMac"
-	}
-	Option "$FMODMNU_OUTPUTFORMAT",			"snd_output_format", "OutputFormats"
-	Option "$FMODMNU_SPEAKERMODE",			"snd_speakermode", "SpeakerModes"
-	Option "$FMODMNU_RESAMPLER",			"snd_resampler", "Resamplers"
-	Option "$FMODMNU_HRTFFILTER",			"snd_hrtf", "OnOff"
-	StaticText " "
-	Option "$FMODMNU_BUFFERSIZE",			"snd_buffersize", "BufferSizes"
-	Option "$FMODMNU_BUFFERCOUNT",			"snd_buffercount", "BufferCounts"
-}
-
-
 OptionMenu OpenALSoundItems
 {
 	Title "$OPENALMNU_TITLE"
@@ -1628,31 +1589,9 @@ OptionMenu SoundOptions
 	Slider "$SNDMNU_CHANNELS",			"snd_channels", 64, 256, 8, 0
 	StaticText " "
 
-	ifoption(fmodex)
-	{
-		ifoption(openal)
-		{
-			Option "$SNDMNU_BACKEND",		"snd_backend", "SoundBackends"
-		}
-		else
-		{
-			Option "$SNDMNU_BACKEND",		"snd_backend", "SoundBackendsFModOnly"
-		}
-	}
-	else
-	{
-		ifoption(openal)
-		{
-			Option "$SNDMNU_BACKEND",		"snd_backend", "SoundBackendsOpenALOnly"
-		}
-	}
-	
-	ifoption(fmodex)
-	{
-		Submenu "$SNDMNU_FMOD",			"FMODSoundItems"
-	}
 	ifoption(openal)
 	{
+		Option "$SNDMNU_BACKEND",		"snd_backend", "SoundBackendsOpenALOnly"
 		Submenu "$SNDMNU_OPENAL",		"OpenALSoundItems"
 	}
 	StaticText " "

From 4519ab12e970829373316437be5fcdb171092b24 Mon Sep 17 00:00:00 2001
From: "alexey.lysiuk" <alexey.lysiuk@gmail.com>
Date: Mon, 17 Apr 2017 10:27:11 +0300
Subject: [PATCH 13/29] Fixed compilation errors

src/sound/oplsynth/musicblock.cpp:3:10: fatal error: 'muslib.h' file not found
src/sound/oplsynth/oplio.cpp:410:12: error: use of undeclared identifier 'cos'
src/sound/oplsynth/oplio.cpp:410:41: error: use of undeclared identifier 'sin'
---
 src/sound/oplsynth/musicblock.cpp | 2 +-
 src/sound/oplsynth/oplio.cpp      | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/sound/oplsynth/musicblock.cpp b/src/sound/oplsynth/musicblock.cpp
index 9a2c0d93ff..9e26b47323 100644
--- a/src/sound/oplsynth/musicblock.cpp
+++ b/src/sound/oplsynth/musicblock.cpp
@@ -1,6 +1,6 @@
 #include <stdlib.h>
 #include <string.h>
-#include "muslib.h"
+#include "musicblock.h"
 #include "files.h"
 #include "templates.h"
 
diff --git a/src/sound/oplsynth/oplio.cpp b/src/sound/oplsynth/oplio.cpp
index 1229a5bbf3..140521231c 100644
--- a/src/sound/oplsynth/oplio.cpp
+++ b/src/sound/oplsynth/oplio.cpp
@@ -31,6 +31,7 @@
 **---------------------------------------------------------------------------
 */
 
+#include <math.h>
 #include "genmidi.h"
 #include "oplio.h"
 #include "opl.h"

From cdade41ca908acb8cde2abc702879818b2866ccf Mon Sep 17 00:00:00 2001
From: "alexey.lysiuk" <alexey.lysiuk@gmail.com>
Date: Mon, 17 Apr 2017 10:38:21 +0300
Subject: [PATCH 14/29] Removed obsolete file

---
 specs/fmod_version.txt | 3 ---
 1 file changed, 3 deletions(-)
 delete mode 100644 specs/fmod_version.txt

diff --git a/specs/fmod_version.txt b/specs/fmod_version.txt
deleted file mode 100644
index e0e03262df..0000000000
--- a/specs/fmod_version.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-This version of ZDoom must be compiled with any version between 4.22 and 4.28 inclusive or 4.34.
-Use of the latest 4.26 is recommended though due to technical issues with 4.28.
-

From 59626cf843dffa7876ff33e6f723106fd53cc67f Mon Sep 17 00:00:00 2001
From: "alexey.lysiuk" <alexey.lysiuk@gmail.com>
Date: Mon, 17 Apr 2017 10:46:38 +0300
Subject: [PATCH 15/29] Simplified transition to OpenAL sound backend

---
 src/sound/i_sound.cpp | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/src/sound/i_sound.cpp b/src/sound/i_sound.cpp
index 74445a98ce..b51cc298b1 100644
--- a/src/sound/i_sound.cpp
+++ b/src/sound/i_sound.cpp
@@ -256,6 +256,15 @@ void I_InitSound ()
 		return;
 	}
 
+#ifndef NO_OPENAL
+	// Simplify transition to OpenAL backend
+	if (stricmp(snd_backend, "fmod") == 0)
+	{
+		Printf (TEXTCOLOR_ORANGE "FMOD Ex sound system was removed, switching to OpenAL\n");
+		snd_backend = "openal";
+	}
+#endif // NO_OPENAL
+
 	if (stricmp(snd_backend, "null") == 0)
 	{
 		GSnd = new NullSoundRenderer;

From 33ee761b3749716d8491b8dddf1a599c1380c149 Mon Sep 17 00:00:00 2001
From: Christoph Oelckers <coelckers@users.noreply.github.com>
Date: Mon, 17 Apr 2017 10:10:09 +0200
Subject: [PATCH 16/29] - fixed: The timing of Heretic's lava damage was not
 correct.

---
 src/p_spec.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/p_spec.cpp b/src/p_spec.cpp
index 7c128eb1d2..0ce113a25f 100644
--- a/src/p_spec.cpp
+++ b/src/p_spec.cpp
@@ -1155,15 +1155,15 @@ void P_InitSectorSpecial(sector_t *sector, int special)
 		break;
 
 	case dDamage_LavaWimpy:
-		P_SetupSectorDamage(sector, 5, 32, 256, NAME_Fire, SECF_DMGTERRAINFX);
+		P_SetupSectorDamage(sector, 5, 16, 256, NAME_Fire, SECF_DMGTERRAINFX);
 		break;
 
 	case dDamage_LavaHefty:
-		P_SetupSectorDamage(sector, 8, 32, 256, NAME_Fire, SECF_DMGTERRAINFX);
+		P_SetupSectorDamage(sector, 8, 16, 256, NAME_Fire, SECF_DMGTERRAINFX);
 		break;
 
 	case dScroll_EastLavaDamage:
-		P_SetupSectorDamage(sector, 5, 32, 256, NAME_Fire, SECF_DMGTERRAINFX);
+		P_SetupSectorDamage(sector, 5, 16, 256, NAME_Fire, SECF_DMGTERRAINFX);
 		P_CreateScroller(EScroll::sc_floor, -4., 0, -1, sector->Index(), 0);
 		keepspecial = true;
 		break;

From f0d741241dfb95fd4139b5fd33569025dd24edd1 Mon Sep 17 00:00:00 2001
From: Christoph Oelckers <coelckers@users.noreply.github.com>
Date: Mon, 17 Apr 2017 10:24:24 +0200
Subject: [PATCH 17/29] - cleaned out most of the cruft from the docs directory
 and added a copy of the GPL v3.

---
 CMakeLists.txt             |    4 -
 docs/BUILDLIC.TXT          |   71 --
 docs/README.asm            |  283 ------
 docs/README.gl             |  149 ---
 docs/commands.txt          | 1742 ------------------------------------
 docs/doomlic.txt           |  112 ---
 docs/history.txt           |  534 -----------
 docs/licenses/README.TXT   |   13 +-
 docs/licenses/buildlic.txt |   71 --
 docs/licenses/bzip2.txt    |   42 +
 docs/licenses/doomlic.txt  |  112 ---
 docs/licenses/gpl.txt      |  674 ++++++++++++++
 docs/licenses/xBRZ.jpg     |  Bin 60099 -> 0 bytes
 docs/zdoom.txt             | 1134 -----------------------
 output_sdl/CMakeLists.txt  |   17 -
 output_sdl/output_sdl.c    |  215 -----
 16 files changed, 723 insertions(+), 4450 deletions(-)
 delete mode 100644 docs/BUILDLIC.TXT
 delete mode 100644 docs/README.asm
 delete mode 100644 docs/README.gl
 delete mode 100644 docs/commands.txt
 delete mode 100644 docs/doomlic.txt
 delete mode 100644 docs/history.txt
 delete mode 100644 docs/licenses/buildlic.txt
 create mode 100644 docs/licenses/bzip2.txt
 delete mode 100644 docs/licenses/doomlic.txt
 create mode 100644 docs/licenses/gpl.txt
 delete mode 100644 docs/licenses/xBRZ.jpg
 delete mode 100644 docs/zdoom.txt
 delete mode 100644 output_sdl/CMakeLists.txt
 delete mode 100644 output_sdl/output_sdl.c

diff --git a/CMakeLists.txt b/CMakeLists.txt
index f426119c23..4de1d047f2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -327,10 +327,6 @@ add_subdirectory( wadsrc_bm )
 add_subdirectory( wadsrc_lights )
 add_subdirectory( src )
 
-if( NOT WIN32 AND NOT APPLE )
-	add_subdirectory( output_sdl )
-endif()
-
 if( NOT CMAKE_CROSSCOMPILING )
 	export(TARGETS ${CROSS_EXPORTS} FILE "${CMAKE_BINARY_DIR}/ImportExecutables.cmake" )
 endif()
diff --git a/docs/BUILDLIC.TXT b/docs/BUILDLIC.TXT
deleted file mode 100644
index a0cec1251f..0000000000
--- a/docs/BUILDLIC.TXT
+++ /dev/null
@@ -1,71 +0,0 @@
-BUILD SOURCE CODE LICENSE TERMS:                             06/20/2000
-
-[1] I give you permission to make modifications to my Build source and
-       distribute it, BUT:
-
-[2] Any derivative works based on my Build source may be distributed ONLY
-       through the INTERNET.
-
-[3] Distribution of any derivative works MUST be done completely FREE of
-       charge - no commercial exploitation whatsoever.
-
-[4] Anything you distribute which uses a part of my Build Engine source
-       code MUST include:
-
-   [A] The following message somewhere in the archive:
-
-       // "Build Engine & Tools" Copyright (c) 1993-1997 Ken Silverman
-       // Ken Silverman's official web site: "http://www.advsys.net/ken"
-       // See the included license file "BUILDLIC.TXT" for license info.
-
-   [B] This text file "BUILDLIC.TXT" along with it.
-
-   [C] Any source files that you modify must include this message as well:
-
-       // This file has been modified from Ken Silverman's original release
-
-[5] The use of the Build Engine for commercial purposes will require an
-       appropriate license arrangement with me. Contact information is
-       on my web site.
-
-[6] I take no responsibility for damage to your system.
-
-[7] Technical support: Before contacting me with questions, please read
-       and do ALL of the following!
-
-   [A] Look though ALL of my text files. There are 7 of them (including this
-          one). I like to think that I wrote them for a reason. You will find
-          many of your answers in the history section of BUILD.TXT and
-          BUILD2.TXT (they're located inside SRC.ZIP).
-
-   [B] If that doesn't satisfy you, then try going to:
-
-             "http://www.advsys.net/ken/buildsrc"
-
-          where I will maintain a Build Source Code FAQ (or perhaps I might
-          just provide a link to a good FAQ).
-
-   [C] I am willing to respond to questions, but ONLY if they come at a rate
-          that I can handle.
-
-             PLEASE TRY TO AVOID ASKING DUPLICATE QUESTIONS!
-
-          As my line of defense, I will post my current policy about
-          answering Build source questions (right below the E-mail address
-          on my web site.) You can check there to see if I'm getting
-          overloaded with questions or not.
-
-          If I'm too busy, it might say something like this:
-
-               I'm too busy to answer Build source questions right now.
-               Sorry, but don't expect a reply from me any time soon.
-
-          If I'm open for Build source questions, please state your question
-             clearly and don't include any unsolicited attachments unless
-             they're really small (like less than 50k). Assume that I have
-             a 28.8k modem. Also, don't leave out important details just
-             to make your question appear shorter - making me guess what
-             you're asking doesn't save me time!
-
-----------------------------------------------------------------------------
--Ken S. (official web site: http://www.advsys.net/ken)
diff --git a/docs/README.asm b/docs/README.asm
deleted file mode 100644
index 89629769ac..0000000000
--- a/docs/README.asm
+++ /dev/null
@@ -1,283 +0,0 @@
-
-README - DOOM assembly code
-
-Okay, I add the DOS assembly module for the historically
-inclined here (may rec.games.programmer suffer). If anyone
-feels the urge to port these to GNU GCC; either inline or
-as separate modules including Makefile support, be my guest.
-
-Module tmap.S includes the inner loops for texture mapping,
-the interesting one being the floor/ceiling span rendering.
-
-There was another module in the source dump, fpfunc.S, that
-had both texture mapping and fixed point functions. It
-contained implementations both for i386 and M68k. For
-brevity, I include only the i386 fixed point stuff below.
-
-//====================================================
-// tmap.S  as of January 10th, 1997
-
-//================
-//
-// R_DrawColumn
-//
-//================
-
-	.data
-loopcount	.long	0
-pixelcount	.long	0
-
-	.text
-
-	.align 16
-.globl _R_DrawColumn
-_R_DrawColumn:
-
-	pushad
-
-	movl		ebp,[_dc_yl]
-	movl		ebx,ebp
-	movl     edi,[_ylookup+ebx*4]
-	movl		ebx,[_dc_x]
-	addl     edi,[_columnofs + ebx*4]
-
-	movl		eax,[_dc_yh]
-	incl		eax
-	subl     eax,ebp                   	// pixel count
-	movl		[pixelcount],eax			// save for final pixel
-	js		done						// nothing to scale
-	shrl		eax,1						// double pixel count
-	movl		[loopcount],eax
-	
-	movl     ecx,[_dc_iscale]
-
-	movl		eax,[_centery]
-	subl		eax,ebp
-	imull	ecx
-	movl		ebp,[_dc_texturemid]
-	subl		ebp,eax
-	shll		ebp,9							// 7 significant bits, 25 frac
-
-	movl     esi,[_dc_source]
-	
-
-	movl		ebx,[_dc_iscale]
-	shll		ebx,9
-	movl		eax,OFFSET patch1+2		// convice tasm to modify code...
-	movl		[eax],ebx
-	movl		eax,OFFSET patch2+2		// convice tasm to modify code...
-	movl		[eax],ebx
-	
-// eax		aligned colormap
-// ebx		aligned colormap
-// ecx,edx	scratch
-// esi		virtual source
-// edi		moving destination pointer
-// ebp		frac
-	
-	movl	ecx,ebp					// begin calculating first pixel
-	addl	ebp,ebx					// advance frac pointer
-	shrl ecx,25					// finish calculation for first pixel
-	movl	edx,ebp					// begin calculating second pixel
-	addl	ebp,ebx					// advance frac pointer
-	shrl edx,25					// finish calculation for second pixel
-	movl eax,[_dc_colormap]
-	movl ebx,eax
-	movb	al,[esi+ecx]			// get first pixel
-	movb	bl,[esi+edx]			// get second pixel
-	movb	al,[eax]				// color translate first pixel
-	movb	bl,[ebx]				// color translate second pixel
-	
-	testl	[pixelcount],0fffffffeh
-	jnz	doubleloop				// at least two pixels to map
-	jmp	checklast
-	
-	.align	16
-doubleloop:
-	movl	ecx,ebp					// begin calculating third pixel
-patch1:
-	addl	ebp,12345678h			// advance frac pointer
-	movb	[edi],al				// write first pixel
-	shrl ecx,25					// finish calculation for third pixel
-	movl	edx,ebp					// begin calculating fourth pixel
-patch2:
-	addl	ebp,12345678h			// advance frac pointer
-	movl	[edi+SCREENWIDTH],bl	// write second pixel
-	shrl edx,25					// finish calculation for fourth pixel
-	movb	al,[esi+ecx]			// get third pixel
-	addl	edi,SCREENWIDTH*2		// advance to third pixel destination
-	movb	bl,[esi+edx]			// get fourth pixel
-	decl	[loopcount]				// done with loop?
-	movb	al,[eax]				// color translate third pixel
-	movb	bl,[ebx]				// color translate fourth pixel
-	jnz	doubleloop
-	
-// check for final pixel
-checklast:
-	testl	[pixelcount],1
-	jz	done
-	movb	[edi],al				// write final pixel
-	
-done:
-	popad
-	ret
-	
-
-
-//================
-//
-// R_DrawSpan
-//
-// Horizontal texture mapping
-//
-//================
-
-
-	.align	16
-.globl _R_DrawSpan
-_R_DrawSpan:
-	pushad
-
-//
-// find loop count
-//	
-	movl		eax,[_ds_x2]
-	incl		eax
-	subl     eax,[_ds_x1]               	// pixel count
-	movl		[pixelcount],eax			// save for final pixel
-	js		hdone						// nothing to scale
-	shrl		eax,1						// double pixel count
-	movl		[loopcount],eax
-
-//
-// build composite position
-//
-	movl	ebp,[_ds_xfrac]
-	shll	ebp,10
-	andl	ebp,0ffff0000h
-	movl	eax,[_ds_yfrac]
-	shrl	eax,6
-	andl	eax,0ffffh
-	orl	ebp,eax
-
-	movl	esi,[_ds_source]
-
-//
-// calculate screen dest
-//
-	movl	edi,[_ds_y]
-	movl	edi,[_ylookup+edi*4]
-	movl	eax,[_ds_x1]
-	addl edi,[_columnofs+eax*4]
-
-//
-// build composite step
-//
-	movl	ebx,[_ds_xstep]
-	shll	ebx,10
-	andl	ebx,0ffff0000h
-	movl	eax,[_ds_ystep]
-	shrl	eax,6
-	andl	eax,0ffffh
-	orl	ebx,eax
-
-	movl		eax,OFFSET hpatch1+2		// convice tasm to modify code...
-	movl		[eax],ebx
-	movl		eax,OFFSET hpatch2+2		// convice tasm to modify code...
-	movl		[eax],ebx
-	
-// eax		aligned colormap
-// ebx		aligned colormap
-// ecx,edx	scratch
-// esi		virtual source
-// edi		moving destination pointer
-// ebp		frac
-	
-	shldl ecx,ebp,22				// begin calculating third pixel (y units)
-	shldl ecx,ebp,6				// begin calculating third pixel (x units)
-	addl	ebp,ebx					// advance frac pointer
-	andl ecx,4095				// finish calculation for third pixel
-	shldl edx,ebp,22				// begin calculating fourth pixel (y units)
-	shldl edx,ebp,6				// begin calculating fourth pixel (x units)
-	addl	ebp,ebx					// advance frac pointer
-	andl edx,4095				// finish calculation for fourth pixel
-	movl eax,[_ds_colormap]
-	movl ebx,eax
-	movb	al,[esi+ecx]			// get first pixel
-	movb	bl,[esi+edx]			// get second pixel
-	movb	al,[eax]				// color translate first pixel
-	movb	bl,[ebx]				// color translate second pixel
-	
-	testl	[pixelcount],0fffffffeh
-	jnz	hdoubleloop				// at least two pixels to map
-	jmp	hchecklast
-	
-
-	.align	16
-hdoubleloop:
-	shldl ecx,ebp,22				// begin calculating third pixel (y units)
-	shldl ecx,ebp,6				// begin calculating third pixel (x units)
-hpatch1:
-	addl	ebp,12345678h			// advance frac pointer
-	movb	[edi],al				// write first pixel
-	andl ecx,4095				// finish calculation for third pixel
-	shldl edx,ebp,22				// begin calculating fourth pixel (y units)
-	shldl edx,ebp,6				// begin calculating fourth pixel (x units)
-hpatch2:
-	addl	ebp,12345678h			// advance frac pointer
-	movb	[edi+1],bl				// write second pixel
-	andl edx,4095				// finish calculation for fourth pixel
-	movb	al,[esi+ecx]			// get third pixel
-	addl	edi,2					// advance to third pixel destination
-	movb	bl,[esi+edx]			// get fourth pixel
-	decl	[loopcount]				// done with loop?
-	movb	al,[eax]				// color translate third pixel
-	movb	bl,[ebx]				// color translate fourth pixel
-	jnz	hdoubleloop
-
-// check for final pixel
-hchecklast:
-	testl	[pixelcount],1
-	jz	hdone
-	movb	[edi],al				// write final pixel
-	
-hdone:
-	popad
-	ret
-
-
-
-
-//====================================================
-// fpfunc.S  as of January 10th, 1997 (parts)
-
-#ifdef i386
-
-.text
-	.align 4
-.globl _FixedMul
-_FixedMul:	
-	pushl %ebp
-	movl %esp,%ebp
-	movl 8(%ebp),%eax
-	imull 12(%ebp)
-	shrdl $16,%edx,%eax
-	popl %ebp
-	ret
-
-
-	.align 4
-.globl _FixedDiv2
-_FixedDiv2:
-	pushl %ebp
-	movl %esp,%ebp
-	movl 8(%ebp),%eax
-	cdq
-	shldl $16,%eax,%edx
-	sall	$16,%eax
-	idivl	12(%ebp)
-	popl %ebp
-	ret
-
-#endif
-
diff --git a/docs/README.gl b/docs/README.gl
deleted file mode 100644
index df443a9fb1..0000000000
--- a/docs/README.gl
+++ /dev/null
@@ -1,149 +0,0 @@
-
-README: glDOOM
-
-I never got around to do anything with respect to
-a Linux glDOOM port except for assembling a Linux3Dfx
-HOWTO (which, at that time, was a prerequisite
-to get permission to publicly distribute the
-already finished LinuxGlide port by Daryll Strauss).
-
-Linux q2test (and soon LinuxQuake2) demonstrate that
-Mesa with the MesaVoodoo driver is quite up to the
-requirements for a glDOOM port. If anybody wants to
-get into Linux glDOOM, please drop me a line.
-
-There is a Win32 GLDOOM port in the works, by Jim Dose.
-Quoting a recent posting by him:
-
-"I haven't had as much time lately to really work on
-the conversion. I currently have the renderer drawing
-the walls and floors as texture spans as the are in
-the software renderer. There's lighting on the walls,
-but not the floors, and sprites are being drawn, but
-not with the right texture. I figure that this is one
-nights work to get the game looking "normal". I haven't
-tested the game on less than a p200, so I'm not sure
-how it will perform under the average machine, but I
-don't expect it to be blindingly fast because of the
-number of spans that have to be drawn each frame.
-Rendering as polys is definitely the way to go.
-
-The reason I chose to do spans first was because it
-left the base renderer intact and I could concentrate
-on ironing out any Windows compatibility problems.
-Actually, the first version I had running was simply
-a blit of the 320x200 game screen through Open GL.
-Surprisingly, this actually was very playable, but
-certainly wasn't taking any advantage of 3D acceleration.
-Once the game was running, I started converting all
-the span routines over."
-
-Comment: for merging Linuxdoom with Win32, this is
-probably the best source for getting the Win32
-environment done - before more significant changes
-occur.
-
-"One problem with drawing spans is that the engine
-doesn't calculate the texture coordinates with
-fractional accuracy, so the bilinear filtering works
-vertically, but not horizontally on the walls. I may
-try to fix this, but since I plan to use polys for
-the final version, it's not really high priority.
-Also, spans don't really allow for looking up and
-down."
-
-Comment: true looking up/down vs. Heretic-style
-y-shearing seems to require either a strange kind
-of transofrmation matrix (he probably does not use
-the OpenGL transformation at all), or rendering
-all the spans as textured rectangular slices
-instead of using glDrawBitmap. No, polys are the
-way to go.
-   
-"When I tackle the conversion to polys, one big problem
-I'll encounter is drawing floors. Since the world is
-stored in a 2D bsp tree, there is no information on
-the shape of the floors. In fact the floors can be
-concave and may include holes (typically, most renderers
-break concave polys down into a collection of convex
-polys or triangles). In software, the floors are actually
-drawn using an algorithm that's similar to a flood fill
-(except that a list of open spans is kept instead of a
-buffer of pixels).  This makes drawing the floors as
-polys fairly difficult."
-
-A polygon based approach will require significant changes
-to the data structures used in the refresh module. I
-recommend either separating a libref_soft.so first (a
-Quake2 like approach), and creating libref_gl afterwards,
-or abandoning the software rendering entirely.
-
-John Carmack wrote once upon a time:
-"... the U64 DOOM engine is much more what I would consider
-The Right Thing now -- it turns the subsector boundaries
-into polygons for the floors and ceilings ahead of time,
-then for rendering it walks the BSP front to back, doing
-visibility determination of subsectors by the one dimensional
-occlusion buffer and clipping sprites into subsectors, then
-it goes backwards through the visible subsectors, drawing
-floors, ceilings, walls, then sorted internal sprite fragments.
-It's a ton simpler and a ton faster, although it does suffer
-some overdraw when a high subsector overlooks a low one (but
-that is more than made up for by the simplicity of everything
-else)."
-
-Well, IMO compiling a separate list of floor/ceiling polygons
-after having read the WAD file, and thus introducing this as
-a completely separate data structure to the current code base
-might be the easiest thing to do. Jim Dose writes:
-
-"One method I may use to draw the floors as polys was suggested
-by Billy Zelsnack of Rebel Boat Rocker when we were working
-at 3D Realms together a few years ago. Basically, Billy was
-designing an engine that dealt with the world in a 2D portal
-format similar to the one that Build used, except that it had
-true looking up and down (no shearing). Since floors were
-basically implicit and could be concave, Billy drew them as
-if the walls extended downwards to infinity, but fixed the
-texture coordinates to appear that they were on the plane of
-the floor. The effect was that you could look up and down and
-there were no gaps or overdraw. It's a fairly clever method
-and allows you to store the world in a simpler data format.
-Had perspective texture mapping been fast enough back then,
-both Build and Doom could have done this in software."
-
-Perhaps the above is sufficient to get you started.
-Other Issues:
-
-1. Occlusion
-DOOM uses a per-column lookup (top/bottom index) to do HLHSR.
-This works fine with span based rendering (well, getting
-horizontal spans of floors/ceilings into the picture is a
-separate story). It isn't really mindboggling with polygon
-based rendering. GLDOOM should abandon that.
-
-2. Precalculated Visibility
-DOOM has the data used by Quake's PVS - in REJECT.
-During Quake development, lots of replacements for the
-occlusion buffer were tried, and PVS turned out to be best.
-I suggest usind the REJECT as PVS.
-
-There have been special effects using a utility named RMB.
-REJECT is a lump meant for enemy AI LoS calculation - a
-nonstandard REJECT will not work as a PVS, and introduce
-rendering errors. I suggest looking for a PVS lump in the
-WAD, and using REJECT if none is found. That way, it might
-be feasible to eat the cake and keep it.
-
-3. Mipmaps
-DOOM does not have mipmapping. As we have 8bit palettized
-textures, OpenGL mipmapping might not give the desired
-results. Plus, composing textures from patches at runtime
-would require runtime mipmapping. Precalculated mipmaps
-in the WAD?
-
-4. Sprites
-Partly transparent textures and sprites impose another
-problem related to mipmapping. Without alpha channel,
-this could give strange results. Precalculated, valid
-sprite mipmaps (w/o alpha)?
diff --git a/docs/commands.txt b/docs/commands.txt
deleted file mode 100644
index 4dfd483f33..0000000000
--- a/docs/commands.txt
+++ /dev/null
@@ -1,1742 +0,0 @@
-This document lists all commands and cvars supported by the current version
-of ZDoom (1.22) and a short description of each. There are a total of 130
-commands and 141 cvars.
-===========================================================================
-
-There are five types of cvars:
-
-boolean:  This is a number that can be either "0" or "1". "0" indicates no/
-          false, and "1" indicates yes/true.
-
-  color:  This is a series of three hexadecimal numbers representing the
-          amounts of red, green, and blue (in that order) in a color. For
-          example, pure redwould be represented as "ffff 0000 0000". The
-          setcolor command can be used to set one of these cvars using a
-          color name instead of numbers. (See the description of the
-          setcolor command below.)
-
- number:  This is an ordinary number.
-
- integer: This is an ordinary that doesn't take fractional values.
-
- string:  This is a series of text characters enclosed in quotes.
-
-
-Some commands also take parameters. Any parameters that are required are 
-enclosed in < >, and those that are optional are enclosed in [ ].
-
-
-ACTION COMMANDS
-===============
-NOTE: As in Quake, all action commands come in pairs. When prefixed by a
-'+', they activate the corresponding action, and when prefixed by a '-',
-they deactivate that action.
-
-
-+attack, -attack
- While active, causes the player to fire his active weapon.
-
-+back, -back
- While active, causes the player to move backward.
-See also: +forward
-
-+forward, -forward
- While active, causes the player to move forward.
-See also: +back
-
-+jump, -jump
- Causes the player to jump. When underwater, the player will swim upward
- instead.
-See also: +moveup
-
-+klook, -klook
- While active, causes +forward and +back to act like +lookup and +lookdown 
- instead.
-See also: +mlook, +lookup, +lookdown, +forward, +back
-
-+left, -left
- While active, normally causes the player to turn to the left. However, as
- long as +strafe is active, this will cause the player to move to the left
- instead.
-See also: +right, +strafe, +moveleft
-
-+lookdown, -lookdown
- While active, causes the player to look down.
-See also: +lookup, +klook
-
-+lookup, -lookup
- While active, causes the player to look up.
-See also: +lookdown, +klook
-
-+mlook, -mlook
- While active, causes movement along the mouse's vertical axis to tilt the 
- player's view up or down instead of moving the player forward or backward.
-See also: +klook, freelook, invertmouse, lookspring
-
-+movedown, -movedown
- Moves the player down if swimming or flying.
-See also: +moveup
-
-+moveleft, -moveleft
- While active, causes the player to move to the left.
-See also: +moveright, +left, +strafe
-
-+moveright, -moveright
- While active, causes the player to move to the right.
-See also: +moveleft, +right, +strafe
-
-+moveup, -moveup
- Moves the player up if swimming or flying.
-See also: +movedown
-
-+right, -right
- While active, normally causes the player to turn to the right. However, as
- long as +strafe is active, this will cause the player to move to the right
- instead.
-See alse: +left, +strafe, +moveright
-
-+showscores, -showscores
- While this action is active and you are playing a deathmatch game, a list
- of the frags made by all players will be displayed on the screen. In
- deathmatch games, this list will also automatically be display when you
- are dead.
-
-+speed, -speed
- While active, all player movements occur at a rate faster than normal.
-See also: cl_run
-
-+strafe, -strafe
- While active, causes all +left and +right commands to act like +moveleft
- and +moveright instead.
-See also: +left, +right, +moveleft, +moveright
-
-+use, -use
- While active, causes the player to attempt to use any usable items in
- front of him/her (such as a door).
-
-
-OTHER COMMANDS AND CVARS
-========================
-addbot [name]
-(command)
- Spawns a bot. If a name is given, the corresponding bot in bots.cfg will be
- spawned. Otherwise, a bot will be picked at random from bots.cfg.
-See also: listbots, removebots
-
-alias <new command> <command string>
-(command)
- If specified with no parameters, will display a list of all current
- aliases. If only <new command> is specified, it will be removed from the
- list of aliases. If <command string> is also specified, it will be added
- to the list of aliases as <new command>. For example, to create a new
- command to kill the monsters on the level, you can use the command:
-
-     alias massacre kill monsters
-
- Then, you can use the newly created massacre command to kill all the
- monsters on the level.
-
-alwaysapplydmflags
-(cvar: boolean)
-default: 0
- Normally, some dmflags are only used in deathmatch. If alwaysapplydmflags
- is 1, then they will also be used in single-player and co-op games.
-See also: dmflags
-
-am_backcolor
-(cvar: color)
-default: "6c 54 40" (a light tan)
- The color of the automap background. Changes to this cvar take effect the
- next time the automap is activated.
-See also: all the am_* cvars
-
-am_cdwallcolor
-(cvar: color)
-default: "4c 38 20" (a dark tan)
- The color of two-sided lines that have a different ceiling height on each
- side. Changes to this cvar take effect the next time the automap is
- activated.
-See also: all the am_* cvars
-
-am_fdwallcolor
-(cvar: color)
-default: "88 70 58" (a lighter tan)
- The color of two-sided lines that have a different floor height on each
- side. Changes to this cvar take effect the next time the automap is
- activated.
-See also: all the am_* cvars
-
-am_gridcolor
-(cvar: color)
-default: "8b 5a 2b" (tan4)
- The color of the automap grid. Changes to this cvar take effect the next
- time the automap is activated.
-See also: all the am_* cvars
-
-am_interlevelcolor
-(cvar: color)
-default: "ff 00 00" (red)
- The color of inter-level teleporters. These are teleporters that teleport
- you to a different map. Changes to this cvar take effect the next time the
- automap is activated.
-See also: all the am_* cvars
-
-am_intralevelcolor
-(cvar: color)
-default: "00 00 ff" (blue)
- The color of intra-level teleporters. These are teleporters that teleport
- you to a different location on the same map. Changes to this cvar take
- effect the next time the automap is activated.
-See also: all the am_* cvars
-
-am_lockedcolor
-(cvar: color)
-default: "00 00 98" (a blue)
- The color of lines that open locked doors. Changes to this cvar take
- effetc the next time the automap is activated.
-See also: all the am_* cvars
-
-am_notseencolor
-(cvar: color)
-default: "6c 6c 6c" (somewhat dark gray)
- The color of lines on the automap that haven't yet been seen. Visible with
- a computer area map. Changes to this cvar take effect the next time the
- automap is activated.
-See also: all the am_* cvars
-
-am_overlay
-(cvar: boolean)
-default: 0
- Normally, the togglemap command switches the automap between fully off and
- fully on. Setting this cvar to "1" will cause togglemap to draw the
- automap on top of the player's view before it draws the automap
- fullscreen. (Bad description, I know. Just try it)
-See also: am_rotate, togglemap
-
-am_ovotherwallscolor
-(cvar: color)
-default: "00 88 44" (a dark blueish-green)
- The color of passable lines on the automap when the map is overlayed.
- Changes to this cvar take effect the next time the automap is activated.
-See also: all the am_* cvars
-
-ov_telecolor
-(cvar: color)
-default: "ff ff 00" (a bright green)
- The color of teleports on the overlayed automap. Changes to this cvar take
- effect the next time the automap is activated.
-See also: all the am_* cvars
-
-am_ovthingcolor
-(cvar: color)
-default: "e8 88 00" (an orange)
- The color of things visible with the automap cheat when the map is
- overlayed. Changes to this cvar take effect the next time the automap is
- activated.
-See also: all the am_* cvars
-
-am_ovunseencolor
-(cvar: color)
-default: "00 22 6e" (a dark greenish-blue)
- The color of unseen lines on the automap when the map is overlayed.
- Changes to this cvar take effect the next time the automap is activated.
-See also: all the am_* cvars
-
-am_ovwallcolor
-(cvar: color)
-default: "00 ff 00" (a bright green)
- The color of impassable walls when the automap is overlayed. Changes to
- this cvar take effect the next time the automap is activated.
-See also: all the am_* cvars
-
-am_ovyourcolor
-(cvar: color)
-default: "fc e8 d8" (a very light orange--almost white)
- The color of the arrow representing the player in single player games when
- the map is overlayed. Changes to this cvar take effect the next time the
- automap is activated.
-See also: all the am_* cvars
-
-am_rotate
-(cvar: boolean)
-default: 0
- Normally, the automap is always drawn such that north is at the top of the
- screen. Setting this cvar to "1" causes the automap to be drawn so that
- lines toward the top of the screen are always directly in front of the
- player's view. Changes to this cvar take effect immediately, unlike most
- of the other am_* cvars. This can be particularly useful when the automap
- is overlayed.
-See also: am_overlay
-
-am_showmonsters
-(cvar: boolean)
-default: 1
- When true, the fullscreen automap will display a count of the number of
- monsters that have been killed in the current level and the total number
- of monsters in the level.
-See also: am_showtime, am_showsecrets
-
-am_showsecrets
-(cvar: boolean)
-default: 1
- When true, the fullscreen automap will display a count of the number of
- secrets that have been found in the current level and the total number of
- secrets in the level.
-See also: am_showmonsters, am_showtime
-
-am_showtime
-(cvar: boolean)
-default: 1
- When true, the fullscreen automap will display the total amount of time
- you have been in a level (excluding time that has been paused).
-See also: am_showmonsters, am_showsecrets
-
-am_thingcolor
-(cvar: color)
-default: "fcfc fcfc fcfc" (almost white)
- The color of things revealed with the map cheat. Changes to this cvar take
- effect the next time the automap is activated.
-See also: all the am_* cvars
-
-am_tswallcolor
-(cvar: color)
-default: "8888 8888 8888" (gray)
- The color of two-sided lines that don't have any difference in floor or
- ceiling heights on either side. Only seen using map cheat. Changes to this
- cvar take effect the next time the automap is activated.
-See also: all the am_* cvars
-
-am_usecustomcolors
-(cvar: boolean)
-default: 1
- When true, the automap uses the colors specified by the am_* cvars,
- otherwise it uses the standard DOOM automap colors. Changes to this cvar
- take effect the next time the automap is activated.
-See also: all the am_* cvars
-
-am_wallcolor
-(cvar: color)
-default: "2c2c 1818 0808" (a dark brown)
- The color of one-sided and secret walls in the automap. Changes to this
- cvar take effect the next time the automap is activated.
-See also: all the am_* cvars
-
-am_xhaircolor
-(cvar: color)
-default: "8080 8080 8080" (gray)
- The color of the "crosshair" dot in the center of the automap. Changes to
- this cvar take effect the next time the automap is activated.
-See also: all the am_* cvars
-
-am_yourcolor
-(cvar: color)
-default: "fcfc e8e8 d8d8" (a very light orange--almost white)
- The color of the arrow representing the player in single player games.
- Changes to this cvar take effect the next time the automap is activated.
-See also: all the am_* cvars
-
-autoaim
-(cvar: number)
-default: 5000
- This represents the vertical distance from an object that the player's
- sight must be before that object is aimed at. Setting this cvar to "0"
- disables autoaiming, while large values such as "5000" will reproduce the
- original DOOM behavior of always autoaiming.
-See also: color, name
-
-autoexec
-(cvar: string)
-default: "<PROGDIR>/autoexec.cfg"
- This is a file that will be automatically executed by ZDoom each time it
- starts. This file is executed immediately after the config file is loaded.
- It should contain a series of console commands. C++ style comments are
- also supported. Comments begin with // and anything after them until the
- end of the line will be ignored.
-
- <PROGDIR> represents the directory that ZDoom is in and will naturally
- vary depending on where you put it.
-
-bind [key [command string]]
-(command)
- If no parameters are specified, the entire list of bound keys will be
- printed to the console. If only [key] is specified, the binding for that
- specific key will be printed. If both [key] and [command string] are
- specified, [command string] will be bound to [key].
-See also: doublebind, unbind, unbindall, undoublebind
-
-binddefaults
-(command)
- Binds all keys to their default commands. This will not unbind any keys
- that do not have any default bindings, so if you want to properly restore
- the default controls, you need to use unbindall first.
-See also: unbindall, bind
-
-bot_allowspy
-(cvar: boolean)
-default: 0
- Allows you to see through the eyes of bots during botmatch games.
-
-bot_next_color
-(cvar: number)
-default: 11
- Theoretically, a number representing the color of the next bot to be
- spawned. In practice, it doesn't do anything.
-
-bot_observer
-(cvar: boolean)
-default: 0
- When set to 1, the player will experience minimal interaction with the
- world, and bots will ignore him.
-
-bumpgamma
-(command)
- Increases the current gamma level by 0.1. If the new gamma level would be
- greater than 3.0, it wraps the gamma around to 1.0
-See also: gamma
-
-centerview
-(command)
- Causes the player to look straight ahead.
-See also: +lookup, +lookdown
-
-changemap <map>
-(command)
- Exits the current level and continues the game on the specified map.
- Unlike the map and idclev commands, this command *will* work properly
- during network games and is recorded in demos. Unfortunately, it has
- occasionally resulted in some problems. It should, however, be safe
- enough to use most of the time.
-See also: idclev, map
-
-changemus <music>
-(command)
- Changes the currently playing music. <music> should be the name of a music
- lump or file on disk (which need not have been specified with the -file
- parameter).
-See also: dir, idmus
-
-chase
-(command)
- Turns the chasecom on and off. This command also works while watching
- demos, so you can bind it to a key and watch demos in the third person.
-See also: chase_dist, chase_height, chasedemo
-
-chase_dist
-(cvar: number)
-default: 90
- This is how far away from the player the chasecam likes to be, but it will
- get closer as necessary to avoid going inside walls.
-See also: chase, chase_height
-
-chase_height
-(cvar: number)
-default: -8
- This is the base height above the top of the player's head that the
- chasecam will be positioned at. Looking up and down will move the camera
- in the opposite direction so that the player stays at approximately the
- same height on the screen. Large values of this cvar (either positive or
- negative) will produce strange output.
-See also: chase, chase_dist
-
-chasedemo
-(cvar: boolean)
-default: 0
- If this cvar is true, then demos will automatically start with the
- chasecam active.
-See also: chase
-
-chatmacro0
-chatmacro1
-chatmacro2
-chatmacro3
-chatmacro4
-chatmacro5
-chatmacro6
-chatmacro7
-chatmacro8
-chatmacro9
-(cvar: string)
- These are all strings programmable to the function keys during a netgame.
- To use these, enter chat mode with the messagemode command, and then hold
- down Alt and press one of the number keys. The string stored in the
- corresponding chatmacro cvar will be sent as if you had typed it yourself.
-
-cl_bloodtype
-(cvar: number)
-default: 0
- Controls how blood is drawn. Supported values are:
-    0: Blood is drawn as sprites
-    1: Blood is drawn as both sprites and particles
-    2: Blood is drawn as particles
-
-cl_pufftype
-(cvar: number)
-default: 0
- Controls how bullet puffs are drawn. Supported values are:
-    0: Puffs are drawn as sprites.
-    1: Puffs are drawn as particles.
-
-cl_rockettrails
-(cvar: boolean)
-default: 1
- Controls whether or not rockets leave trails of smoke behind them.
-
-cl_run
-(cvar: boolean)
-default: 0
- When non-zero, the game will always treat movement commands as if +speed
- is active.
-See also: +speed
-
-clear
-(command)
- Clears the console of all text.
-
-cmdlist
-(command)
- Lists all commands currently supported by ZDoom.
-See also: cvarlist
-
-color
-(cvar: color)
-default: "4040 cfcf 0000" (Mostly green)
- This is the color of your player's suit.
-See also: gender, name, skin, team
-
-con_midtime
-(cvar: number)
-default: 3
- This is the number of seconds that messages in the middle of the screen
- will be displayed before they dispapper.
-See also: con_notifytime
-
-con_notifytime
-(cvar: number)
-default: 3
- This is the number of seconds that new messages will stay at the top of
- the screen before they start scrolling away.
-See also: con_midtime
-
-con_scaletext
-(cvar: boolean)
-default: 0
- If this cvar is true, then message text will be scaled to larger sizes
- depending on the screen resolution so that it will stay approximately the
- same size it would be on a 320x200 screen.
-
-configver
-(cvar: number)
-default: "116"
- This cvar is used to keep track of which version of ZDoom was used to write
- the current config file and adjust for differences that may have been
- introduced between versions. Changing it has no effect, since it will
- always be changed to reflect the current game version before the config
- file is saved.
-
-crosshair
-(cvar: number)
-default: 0
- If this cvar is non-zero, it draws a crosshair. If this cvar is negative,
- the crosshair is translucent, otherwise it is opaque. The specific
- crosshair drawn depends on the value of this cvar.
-
-cvarlist
-(command)
- Lists the values of all currently defined cvars. Each cvar can also be
- prefaced by multiple flags. These are:
-
-    A Cvar gets saved in the config file.
-    U Cvar contains user info.
-    S Cvar contains server info.
-    - Cvar can only be changed from the command line.
-    L Changes to cvar's contents don't take effect until the next game.
-    C Cvar has an internal callback.
-    * Cvar was created by the user and is meaningless to the game.
-
-See also: cmdlist, get, set
-
-deathmatch
-(cvar: boolean)
-default: 0
- When true, deathmatch rules are used for the game.
-
-def_patch
-(cvar: string)
-default: ""
- This is the name of a DeHackEd patch file to automatically apply each time
- the game is run. It will only be used if the following conditions are met:
-
-    a) def_patch is not "", and the file exists.
-    b) No loaded WAD files contain a DEHACKED lump.
-    c) No patch is specified with the -deh command line parameter.
-
-developer
-(cvar: boolean)
-default: 0
- When true, prints various debugging messages to the console.
-
-dimamount
-(cvar: number)
-default: 1
- This is the amount of dimcolor to mix with the background when a menu is 
- displayed. The available values are:
-    0: Do not dim the background.
-    1: Mix 25% of dimcolor with the background.
-    2: Mix 50% of dimcolor with the background.
-    3: Mix 75% of dimcolor with the background.
-See also: dimcolor
-
-dimcolor
-(cvar: color)
-default: "ffff d7d7 0000" (gold)
- This is the color to mix with the background when a menu is displayed.
-See also: dimamount, setcolor
-
-dir [[path/][pattern]]
-(command)
- This command lists the contents of a directory. It supports wildcards (but
- will not recurse into multiple directories). If [path] is not specified,
- it will display the contents of the directory the game was run from.
-
-deathmatch
-(cvar: boolean)
-default: 0
- When set to true, the game is treated as a deathmatch. When the game is
- started with -altdeath or -deathmatch, this cvar is automatically set to 1.
-
-dmflags
-(cvar: number)
-default: 0
- This cvar controls the behavior of several aspects of gameplay. To
- determine what value to store in this cvar, select the desired features
- from the table below and add their values together. If a feature is
- marked with (DM), then that feature will only be active during a
- deathmatch game.
-
-  Value  Description
- ------  -----------------------------------------------------------------   
-      1  Do not spawn health items (DM)
-      2  Do not spawn powerups (DM)
-      4  Leave weapons around after pickup (DM)
-      8  Falling too far hurts
-     16  Players cannot hurt teammates (friendly fire avoidance)
-     64  Stay on the same map when someone exits (DM)
-    128  Spawn players as far as possible from other players (DM)
-    256  Automatically respawn dead players (DM)
-    512  Do not spawn armor (DM)
-   1024  Kill anyone who tries to exit the level (DM)
-   2048  Don't use any ammo when firing
-   4096  Don't spawn monsters
-   8192  Monsters respawn sometime after their death
-  16384  Powerups other than invulnerability and invisibilty respawn
-  32768  Monsters are fast
-  65536  Don't allow jumping
- 131072  Don't allow freelook
- 262144  Invulnerability and invisibility respawn
-
-See also: menu_gameplay, teamplay
-
-doublebind [key [command string]]
-(command)
- If no parameters are specified, the entire list of doublebound keys will be
- printed to the console. If only [key] is specified, the doublebinding for
- that specific key will be printed. If both [key] and [command string] are
- specified, [command string] will be doublebound to [key]. (Doublebindings
- are commands that are executed when a key is pressed twice quickly--such as
- double cliking a mouse button.)
-See also: bind, unbind, unbindall, undoublebind
-
-dumpheap
-(command)
- Prints detailed information about the heap. Probably not very useful to
- the average user.
-See also: mem
-
-echo <string>
-(command)
- Prints <string> to the console.
-
-endgame
-(command)
- Ends the current single player game and drops the console down to cover the
- screen.
-See also: menu_endgame
-
-error <error message>
-(command)
- Simulates an error by killing the current game and falling back to the
- fullscreen console with the specified message.
-
-exec <script file>
-(command)
- Executes a series of commands stored in the <script file> as if they were
- typed in at the console.
-
-fly
-(command)
- Toggles fly mode on and off.
-
-forcewater
-(cvar: boolean)
-default: 0
- When set to 1, all BOOM-style deep water will be swimmable. This is not
- the default, because the effect can be used for more than just deep water
- (although water is probably its most common use).
-
-fov [viewfield]
-(command)
- When used without a parameter, returns the current field of vision. When
- viewfield is specified, sets the field of vision. This can be between 1
- and 179 degrees. The default is 90.
-
-fraglimit
-(cvar: number)
-default: 0
- If this cvar is non-zero, the game will automatically advance to the next
- level once anyone gets this many frags. (deathmatch only)
-See also: timelimit
-
-freelook
-(cvar: boolean)
-default: 0
- When true, mouse aiming will always be on, regardless of the state of
- +mlook.
-See also: +mlook, invertmouse
-
-freeze
-(command)
- Use this command once to freeze gameplay (while still allowing you to move
- around). Use it again to unfreeze gameplay.
-
-fullscreen
-(cvar: boolean)
-default: 1
- If this cvar is true, the game will be displayed fullscreen. Otherwise, it
- will be drawn in a window.
-
-gameversion
-(command)
- Prints the version number and compile date of ZDoom.
-
-gamma
-(cvar: number)
-default: 1.0
- If <level> is not specified, displays the current gamma correction level. 
- Otherwise, sets the gamma correction level to <level>. 1.0 is equivalent
- to no correction, while larger numbers translate into a brighter display,
- and smaller numbers translate into a darker display. 0.0 is invalid and
- will be rejected. Negative numbers are technically invalid as well but
- will be accepted solely for the novelty value doing so provides.
-See also: bumpgamma
-
-gender
-(cvar: string)
-default: "male"
- This is the gender of your player. Valid values are "male", "female", and
- "neuter". Anything else will be treated as male. When you die, certain
- messages will be altered to reflect the gender selected here.
- Unfortunately, I don't provide any non-male player sounds, so you'll still
- sound like a man no matter what this cvar is set to unless you provide your
- own sounds.
-See also: color, name, skin, team
-
-get <cvar>
- Displays the value of <cvar>. This is probably redundant since typing the
- name of the cvar alone will accomplish the same thing.
-See also: cvarlist, set
-
-give <item>
-(command)
- Gives an item to the player. This is a cheat. Give understands the
- following items:
-
-    all - gives you everything
-    health - gives you full health
-    weapons - gives you every weapon
-    ammo - gives you full ammo
-    armor - gives you full armor
-    keys - gives you every key
-
- Single items:
-    Basic Armor
-    Mega Armor
-    Armor Bonus
-    Chainsaw
-    Shotgun
-    Super Shotgun
-    Chaingun
-    Rocket Launcher
-    Plasma Gun
-    BFG9000
-    Bullets
-    Shells
-    Cells
-    Rockets
-    Invulnerability
-    Berserk
-    Partial Invisibility
-    Iron Feet
-    Computer Map
-    Light Amplification Visor
-    Blue Keycard
-    Yellow Keycard
-    Red Keycard
-    Blue Skull Key
-    Yellow Skull Key
-    Red Skull Key
-See also: sv_cheats
-
-god
-(command)
- Toggles God (Degreelessness) mode on/off. While active, you cannot be hurt
- by normal attacks (although telefragging will still kill you). Also known
- as iddqd. This is (of course) a cheat.
-See also: sv_cheats
-
-history
-(command)
- Prints the console command history.
-
-hud_scale
-(cvar: boolean)
-default: 0
- Controls scaling of the fullscreen hud. At resolutions of 640x400 or above,
- setting this cvar to 1 will cause the icons to be scaled to approximately
- the same size they would be at 320x200. If this cvar is 0, the icons will
- always be drawn without any scaling.
-
-idclev <level code>
-(command)
- Changes to the level specified by <level code>.
-
-iddqd
- See god.
-
-idmus <level code>
-(command)
- Changes the music to that associated with the specified level.
-See also: changemus
-
-idmypos
-(cvar: boolean)
-default: 0
- When non-zero, constantly displays the player's current position and view
- angle.
-See also: idmypos (command)
-
-impulse <number>
-(command)
- This is currently a hack to get weapon selection to work with keybindings
- until I finalize the inventory system (at which time, I plan to handle
- weapon selections as they are in Quake2). <number> can be a value ranging
- between 1 and 7 inclusive and will select the corresponding weapon. Values
- between 50 and 57 inclusive can be used to specify specific weapons instead
- of rolling between the fist/chainsaw and shotgun/ssg with impulses 1 and 3.
-See also: weapnext, weapprev
-
-i_remapkeypad
-(cvar: boolean)
-default: 1
- When non-zero, most keypad keys will act like the keys in the cursor
- island between the main keyboard and the numeric keypad. For instance,
- when this cvar is true, pressing "4" on the keypad is the same as pressing
- the left arrow on the cursor island. If you need to map different commands
- specifically to keys on the numeric keypad, set i_remapkeypad to "0".
-See also: bind
-
-in_mouse
-(cvar: number)
-default: 0
- This cvar select which method ZDoom will use to read the mouse. Valid
- values are:
-    0: Automatically select a method based on the operating system.
-    1: Use normal Win32 API calls (default for Windows NT).
-    2: Use DirectInput (default for Windows 95/98).
-
-invertmouse
-(cvar: boolean)
-default: 0
- When true, reverses the way mouse movement up and down is interpreted with
- +mlook. Normally, moving the mouse forward will make you look up, and
- moving it back will make you look down. Setting this cvar to true changes
- this behavior so that moving the mouse forward makes you look down, and
- moving it back makes you lookup.
-See also: +mlook, freelook
-
-joy_speedmultipiler
-(cvar: number)
-default: 1.0
- This cvar controls the overall sensitivity/movement speed possible with a
- joystick. Values above 1.0 will allow you to reach full speed with less
- movement of the joystick, but they will not let you go any faster than
- normal (use the turbo cvar for that). Values less than 1.0 will prevent
- you from reaching full speed with the joystick. One potentially useful
- trick is to create these two aliases:
-    alias +creep "joy_speedmultiplier 0.25"
-    alias -creep "joy_speedmultiplier 1.0"
- If you bind +creep to a button, then whenever that button is held down, you
- will walk with the joystick instead of run.
-See also: joy_xsensitivity, joy_ysensitivity
-
-joy_xsensitivity
-(cvar: number)
-default: 1.0
- This cvar controls how far the joystick needs to be moved horizontally to
- reach full speed for turning or strafing.
-See also: joy_speedmultipiler, joy_ysensitivity
-
-joy_xthreshold
-(cvar: number)
-default: 0.15
- This cvar is used to set the size of the joystick's horizontal "dead zone."
- Larger numbers correspond to a larger dead zone. The joystick needs to be
- outside this zone before its movement will register with the game.
-See also: joy_xsensitivity, joy_ythreshold
-
-joy_ysensitivity
-(cvar: number)
-default: -1.0
- This cvar controls how far the joystick needs to be moved vertically to
- reach full speed for moving forward and backward or looking up and down.
-See also: joy_speedmultipiler, joy_xsenstivity
-
-joy_ythreshold
-(cvar: number)
-default: 0.15
- This cvar is used to set the size of the joystick's vertical "dead zone."
- Larger numbers correspond to a larger dead zone. The joystick needs to be
- outside this zone before its movement will register with the game.
-See also: joy_xthreshold, joy_ysensitivity
-
-key <value1> [[value2]...]
-(command)
- Translates all parameters to the command into their corresponding key
- values which are used internally for command and alias lookup. Probably
- not very useful for the average user.
-
-kill [monsters]
-(command)
- If used as "kill monsters", will kill all monsters on the level.
- Otherwise, it will kill you instead. This command is broken in netgames,
- so don't use it unless you are playing a single player game.
-
-limits
-(command)
- Prints the current state of all dynamic limits in ZDoom. These are only
- limits in the sense that they were limits in the original Doom. In ZDoom,
- these limits have been removed, and this command will give you a rough
- idea of how many of them your level uses.
-
-listbots
-(command)
- Lists the bots available in bots.cfg, and indicates which are currently playing.
-See also: addbot
-
-logfile [log file]
-(command)
- If [log file] is not specified, will stop console logging (if active). 
- Otherwise, all file named [log file] will be created on disk, and all
- console output will be recorded in it as well as on the screen.
-
-lookspring
-(cvar: boolean)
-default: 1
- When true, all -mlook commands will also generate centerview commands.
-See also: +mlook
-
-lookstrafe
-(cvar: boolean)
-default: 0
- When true, moving the mouse left and right will always cause the player
- to strafe left and right regardless of the state of +strafe.
-See also: +strafe
-
-m_forward
-(cvar: number)
-default: 1.0
- This is the sensitivity of moving forward and backward with the mouse.
-See also: mouse_sensitivity
-
-m_pitch
-(cvar: number)
-default: 1.0
- This is the sensitivity of looking up and down with the mouse.
-See also: mouse_sensitivity, +mlook, freelook
-
-m_side
-(cvar: number)
-default: 2.0
- This is the sensitivity of strafing left and right with the mouse.
-See also: mouse_sensitivity, +strafe, lookstrafe
-
-m_yaw
-(cvar: number)
-default: 1.0
-This is the sensitivity of looking left and right with the mouse.
-See also: mouse_sensitivity
-
-map <map>
-(command)
- Starts a new game on the specified map.
-See also: changemap, idclev
-
-mem
-(command)
- Prints statistics about the memory usage of the zone heap.
-See also: dumpheap
-
-menu_display
-(command)
- Displays the display options menu,
-
-menu_endgame
-(command)
- Asks the user if they want to end the current game, and returns to the
- title screen if they do.
-
-menu_game
-(command)
- Displays the new game menu.
-
-menu_gameplay
-(command)
- Displays the gameplay options (dmflags) menu.
-See also: dmflags
-
-menu_help
-(command)
- Displays the help screen.
-
-menu_keys
-(command)
- Displays the customize controls menu.
-
-menu_load
-(command)
- Displays the load game menu.
-
-menu_main
-(command)
- Displays the main menu.
-
-menu_options
-(command)
- Displays the options menu.
-
-menu_player
-(command)
- Displays the player setup menu.
-
-menu_quit
-(command)
- Asks the user if they want to quit, and quits if they do.
-
-menu_save
-(command)
- Displays the save game menu.
-
-menu_video
-(command)
- Displays the video mode menu.
-
-messagemode
-(command)
- Enters message entry mode. Anything typed while in this mode will be
- sent to everyone else as if you had used the say command.
-See also: say, say_team, messagemode2
-
-messagemode2
-(command)
- Just like messagemode except that the message is only sent to other
- members of your team. If teamplay is zero or you don't have a team, then
- this command will work just like messagemode and send the message to
- everyone.
-See also: messagemode, say, say_team, teamplay
-
-mouse_sensitivity
-(cvar: number)
-default: 1.0
- The larger this cvar, the more sensitive the game is to all mouse
- movements.
-See also: m_forward, m_pitch, m_side, m_yaw
-
-msg
-(cvar: number)
-default: 0
- This is the minimum message level that the player will see. Message levels
- are:
-    0. Item pickup
-    1. Obituaries
-    2. Critical messages
-    3. Chat messages
-    4. Chat messages from a teammate
-
-msg0color
-(cvar: number)
-default: 6
- This cvar controls the color used to display level 0 messages. Available
- colors are:
-    0. Brick
-    1. Tan
-    2. Gray
-    3. Green
-    4. Brown
-    5. Gold
-    6. Red
-    7. Blue
-See also: msg1color, msg2color, msg3color, msg4color, msgmidcolor
-
-msg1color
-(cvar: number)
-default: 5
- This cvar controls the color used to display level 1 messages. Available
- colors are the same as for msg0color.
-See also: msg0color, msg2color, msg3color, msg4color, msgmidcolor
-
-msg2color
-(cvar: number)
-default: 2
- This cvar controls the color used to display level 2 messages. Available
- colors are the same as for msg0color.
-See also: msg0color, msg1color, msg3color, msg4color, msgmidcolor
-
-msg3color
-(cvar: number)
-default: 3
- This cvar controls the color used to display level 3 messages. Available
- colors are the same as for msg0color.
-See also: msg0color, msg1color, msg2color, msg4color, msgmidcolor
-
-msg4color
-(cvar: number)
-default: 3
- This cvar controls the color used to display level 4 messages. Available
- colors are the same as for msg0color.
-See also: msg0color, msg1color, msg2color, msg3color, msgmidcolor
-
-msgmidcolor
-(cvar: number)
-default: 5
- This cvar controls the color used to display messages in the middle of
- the screen. Available colors are the same as for msg0color.
-See also: msg0color, msg1color, msg2color, msg3color, msg4color
-
-name
-(cvar: string)
-default: "Player"
- This is your player's name. This is only really useful in a
- multiplayer game, but it can also be set for single player.
-See also: color, gender, skin, team
-
-neverswitchonpickup
-(cvar: boolean)
-default: 0
- When this cvar is true, you won't automatically switch to a new weapon
- when you pick one up.
-
-nobfgaim
-(cvar: boolean)
-default: 0
- When set to 1, prevents manual aiming of the BFG. It will still aim up or
- down if you shoot it at something, but you won't be able to, for instance,
- shoot it at the ground to quickly generate tracer damage by looking down.
-
-noclip
-(command)
- Toggles noclipping mode on/off. This is a cheat.
-See also: sv_cheats
-
-nofilecompression
-(cvar: boolean)
-default: 0
- This is a debugging cvar used to disable file compression. You should leave
- it set to 0.
-
-noise
-(cvar: boolean)
-default: 0
- When set to 1, the current status of all sound channels is displayed on
- the screen.
-See also: snd_channels
-
-notarget
-(command)
- Toggles notarget mode on/off. While active, monsters will not target you
- unless you hurt them first. This is a cheat.
-See also: sv_cheats
-
-pause
-(command)
- Pauses or unpauses the game depending on whether or not it is currently
- paused.
-
-pings
-(command)
- This lists a very rough estimate of the speed of the connection between
- your machine and any others in the game. In reality, the values printed by
- this command aren't even pings; they're just the number of milliseconds
- that have passed since the last time you received a network packet from the
- other machines.
-
-playdemo <demo>
-(command)
- Plays a demo. The demo can be a file on disk or a lump in a wad.
-See also: timedemo
-
-puke <script> [arguments]
-(command)
- Executes an ACS script on the current map, optionally passing it up to
- three numerical arguments.
-
-quickload
-(command)
- Loads the last quicksaved game.
-See also: quicksave
-
-quicksave
-(command)
- Quick saves the game.
-See also: quickload
-
-quit
-(command)
- Exits ZDoom and saves all configuration information to disk.
-
-r_columnmethod
-(cvar: number)
-default: 1
- Selects which of two algorithms to use to draw vertical columns on the
- screen. Method 0 is the original algorithm used by DOOM and is best for
- a 486. Method 1 is a new algorithm optimized for modern processors, and
- can as much as double the framerate on post-Pentium processors. (On 486s,
- it can drop the framerate by at least half.)
-
-r_detail
-(cvar: number)
-default: 0
- This cvar selects the detail level of the view window. Valid values are:
-    0. Normal detail level. Equivalent to Doom's high detail mode.
-    1. Double pixels horizontally. Equivalent to Doom's low detail mode.
-    2. Double pixels vertically.
-    3. Double pixels horizontally and vertically.
- Doubling pixels horizontally offers more of a speed-up than doubling them
- vertically does.
-
-r_drawflat
-(cvar: boolean)
-default: 0
- When set to 0, segs will be drawn as solid colors instead of textures.
- This is useful if you want to see how a node builder split a level's
- linedefs. Otherwise, it just looks ugly.
-
-r_drawfuzz
-(cvar: boolean)
-default: 1
- When set to false, the "fuzz" effect on spectres and partially invisible
- players will be replaced with translucency.
-
-r_drawplayersprites
-(cvar: boolean)
-default: 1
- When zero, the game will not draw the player's weapon or muzzle flash.
-
-r_particles
-(cvar: boolean)
-default: 1
- If set to true, particles are drawn. Otherwise, they aren't.
-
-r_stretchsky
-(cvar: boolean)
-default: 1
- Controls whether or not short sky textures are stretched so that you don't
- see them wrap when you look up.
-
-r_viewsize
-(cvar: string)
- String containing the width and height of the current view window. This
- cvar is read only.
-See also: sizeup, sizedown, screenblocks
-
-removebots
-(command)
- Removes any bots from the game. Bots will also be automatically removed from
- network games when the arbitrator quits.
-See also: addbot
-
-say <message>
-(command)
- Sends a <message> to everyone playing.
-See also: messagemode, messagemode2, say_team
-
-say_team <message>
-(command)
- Sends a <message> only to other members of your team. If teamplay is zero
- or you aren't on a team, then this command will act just like say and send
- the message to everyone.
-See also: messagemode, messagemode2, say, team, teamplay
-
-screenblocks
-(cvar: integer)
-default: 10
- This cvar determines the size of the view window. Valid values are in the
- range 3-12 inclusive. Attempts to set this cvar to values outside this
- range will be truncated. 3 is the smallest view window, and 12 is full
- screen. 11 is also full screen, but includes a small heads-up display.
-See also: sizeup, sizedown, r_viewsize
-
-screenshot [file]
-(command)
- Dumps a copy of the screen to disk as a .pcx file. If [file] is not
- specified, the screenshot will be saved to the directory the game was run
- from with a name of the form doom????.pcx.
-
-set <cvar> <value>
-(command)
- Sets <cvar> to <value>. If <cvar> does not exist, it will be created.
-See also: get
-
-setcolor <cvar> <color name>
-(command)
- Sets <cvar> to a color value specified in the X11R6RGB lump. (This is the 
- X11R6.rgb file from a standard X-Windows system.) If <color name> cannot
- be found, the contents of <cvar> are left unchanged. The file colors.txt
- included with the ZDoom archive contains a list of all the color names
- listed in zdoom.wad.
-See also: all the am_* cvars, dimcolor
-
-show_messages
-(cvar: boolean)
-Default: 1
- When this variable is non-zero, game messages will be displayed at the top
- of the screen. Regardless of the state of this cvar, console messages will
- always be displayed in the console and also written to disk if logging is
- enabled.
-
-sizedown
-(command)
- Decreases the size of the view window.
-See also: screenblocks, sizeup
-
-sizeup
-(command)
- Increases the size of the view window.
-See also: screenblocks, sizedown
-
-skill
-(cvar: integer)
-default: 2
- This variable contains the game skill, ranging from 0 to 4 inclusive.
- Changes to this cvar only take effect when a new level is loaded.
-
-skin
-(cvar: string)
-default: "base"
- This is your player's skin. Any skins you want to use or see need to be
- loaded at the command line with the -file parameter. "Base" is the name of
- the regular Doom marine and is always available. When (if?) I get
- client/server working, I will use a better mechanism where you can just
- throw the skins in a directory and use them without having to worry about
- specifying them at the command line.
-See also: color, gender, name, skins, team
-
-skins
-(command)
- Lists the names of the skins that were loaded when the game was started.
-See also: skin
-
-snd_channels
-(cvar: integer)
-default: 8
- This cvar determines the number of channels used for mixing sound effects.
- Larger values generally sound better but also require a faster processor.
- In general, anything between 8-16 should be plenty.
-
-snd_listmididevices
-(command)
- This command lists the MIDI devices available in the system. Devices in
- this list can be used in the snd_mididevice cvar to select which device
- plays music.
-See also: snd_mididevice, snd_midivolume
-
-snd_mididevice
-(cvar: integer)
-default: -1
- This cvar determines which MIDI device ZDoom uses for MIDI and MUS music.
- A value of -1 indicates to use the Windows MIDI Mapper, while other
- values select specific MIDI devices. A complete list of MIDI devices
- available can be obtained with the snd_listmididevices command.
-See also: snd_listmididevices, snd_midivolume
-
-snd_midivolume
-(cvar: number)
-default: 0.5
- This is the volume at which MIDI and MUS music is played and can range
- from 0.0-1.0. 
-See also: snd_musicvolume, snd_sfxvolume
-
-snd_musicvolume
-(cvar: integer)
-default: 9
- This is the volume at which MOD music is played and can range from 0-64
- inclusive. Note that setting this near its maximum will probably result in
- nasty distortions of the music.
-See also: snd_midivolume, snd_sfxvolume
-
-snd_pitched
-(cvar: boolean)
-default: 0
- When set to true, the random pitch effect found in early version of Doom
- will be simulated.
-
-snd_samplerate
-(cvar: integer)
-default: 44100
- This is the sampling rate at which sounds are mixed in the game. The value
- in this cvar will only take effect when MIDAS is restarted (usually when
- the game first starts). If you do not play MOD music from within the game,
- you can set this as low as 11025 without experiencing much perceptable
- loss of sound quality.
-
-snd_sfxvolume
-(cvar: integer)
-default: 8
- This is the volume at which sound effects are played and can range from
- 0-15 inclusive.
-See also: snd_midivolume, snd_musicvolume
-
-snd_surround
-(cvar: boolean)
-default: 1
- When true, selected sounds will be played on the surround channel. The
- effect is even noticable if (like me) you don't have special hardware
- to decode it. If you think it's annoying or you have a buggy soundcard
- that mixes in stereo but outputs in mono, you can turn this off.
-
-splashfactor
-(cvar: number)
-default: 1.0
- This controls the amount of damage players receive when they fire a rocket
- and it explodes right next to them. It applies only to the player who fires
- the rocket; all others receive normal damage. A value of 0.5 would apply
- only half damage to the player. A value of 2.0 would apply double damage.
- Other values are similar. Useful mostly for people who like to rocket
- jump and don't like dying if they don't have 100% health and a lot of
- armor.
-
-soundlinks
-(command)
- Lists the links between different sounds that use the same sound lump.
- Links are generated dynamically while you play, so it is possible for this
- command to give different results in different games and even at different
- times during the same game.
-See also: soundlist
-
-soundlist
-(command)
- Lists all the sounds defined and the lumps that they alias to. Unlike
- regular Doom, ZDoom refers to sounds using a long name and uses a SNDINFO
- lump to map those to the lumps in a WAD file that contain the actual
- sounds. Long names that refer to the same sound lump will have links
- generated as necessary to avoid actually loading multiple copies of the
- same sound into memory.
-See also: soundlinks
-
-spynext
-(command)
- During a cooperative game or while watching a multiplayer demo, this
- command will switch the view to the next player.
-See also: spyprev
-
-spyprev
-(command)
- During a cooperative game or while watching a multiplayer demo, this
- command will switch the view to the previous player.
-See also: spynext
-
-st_scale
-(cvar: boolean)
-default: 0
- When this cvar is true, the status bar will be scaled so that it covers
- the entire width of the screen in higher resolutions. This may look
- somewhat ugly, but it should be easier to read on high resolutions with
- smaller monitors.
-
-stat [page]
-(command)
- Displays profiling information. When used alone, displays a list of
- available displays. Use one of those as the page parameter to toggle
- the display on and off.
-    stat fps : Time spent rendering the scene (not the same as vid_fps 1)
-    stat bots : Time spent doing bot-related activities
-    stat think : Time spent running all thinkers
-
-stop
-(command)
- Stops demo recording and exits the game.
-
-sv_cheats
-(cvar: boolean)
-default: 0
- When non-zero, cheats will be allowed in Nightmare difficulty and network
- games. For purposes of fairness, this cvar can only be set from the
- command line when you run ZDoom. This is to avoid situations where the key
- player in a multiplayer game (player 1) could go to the console and type
- something like this:
-    sv_cheats 1
-    god
-    sv_cheats 0
- whereby rendering himself immune to the attacks of others.
-See also: give, god, noclip, notarget, idclev
-
-sv_friction
-(cvar: number)
-default: 0.90625
- This is a dummy cvar that is still waiting to be implemented.
-See also: sv_gravity
-
-sv_gravity
-(cvar: number)
-default: 800
- This is the overall gravity of the entire level. 800 is normal gravity.
-
-team
-(cvar: string)
-default: ""
- This is the team that your player belongs to.
-See also: teamplay, say_team, messagemode2
-
-teamplay
-(cvar: boolean)
-default: 0
- When set to "1", players will be recognized by team. Otherwise, everyone
- is treated as if they aren't on a team regardless of the settings of their
- team cvars. Useful primarily for the friendy fire avoidance dmflag and
- say_team command.
-See also: dmflags, say_team team
-
-testblend <color> <amount>
-(command)
- Sets the palette blend to a specified color and amount. <color> can be
- either a color name defined in the X11R6RGB lump or a color string.
- <amount> can be a number between 0.0 and 1.0 inclusive and specifies how
- much of <color> should be mixed with the palette, with 0.0 being no mixing
- and 1.0 being full mixing.
-See also: testcolor, testfade
-
-testcolor <color>
- Sets the light color of any sectors using the default light to <color>.
- <color> can be either a color defined in the X11R6RGB lump or a color
- string.
-See also: testblend, testfade
-
-testfade <color>
-(command)
- Temporarily sets the fade color of the current level to <color>. Most
- levels fade to black by default, but this can be changed with the MAPINFO
- lump. <color> can be either a color defined in the X11R6RGB lump or a
- color string.
-See also: testblend, testcolor
-
-testgibs
-(cvar: boolean)
-default: 0
- Does nothing.
-
-ticker
-(cvar: boolean)
-default: 0
- When true, draws a series of dots at the bottom of the screen representing
- the number of tics it took to display the current frame. (One tic is
- 1/35th of a second.) When -devparm is specified on the command line, this
- cvar is automatically set to "1". You can get a rough idea of your fps by
- counting the number of lit dots and dividing that from 35. A better way
- would be to use vid_fps.
-See also: vid_fps
-
-timedemo <demo>
-(command)
- Plays a demo as fast as the refresh rate will allow and displays the
- average framerate attained during playback. For stability reasons, this
- command will also exit the game when the demo finishes.
-See also: playdemo
-
-timelimit
-(cvar: number)
-default: 0
- When this cvar is non-zero, the game will automatically advance to the
- next level after this many minutes have elapsed. (deathmatch only)
-See also: fraglimit
-
-toggle <cvar>
-(command)
- Toggles the value of <cvar> between zero and non-zero.
-
-toggleconsole
-(command)
- Toggles display of the console on/off.
-
-togglemap
-(command)
- Toggles the automap on/off. 
-See also: am_overlay
-
-togglemessages
-(command)
- Toggles display of game messages on/off. The only difference between doing
- this and "toggle show_messages" is that this command always displays a
- message describing the current state of messages.
-See also: show_messages, toggle
-
-turn180
-(command)
- Quickly turns your player around 180 degrees.
-
-transsouls
-(cvar: number)
-default: 0.75
- This is the amount of translucency exhibitted by lost souls. Valid values
- are in the interval (0.0,1.0]. Large values mean less translucency.
-
-turbo
-(cvar: number)
-default: 100
- This cvar effects how quickly the player moves. A value of 100 will cause
- the player to move at normal speed, 200 will cause the player to move at
- 200% of normal speed, 50 will cause the player to move at 50% of normal
- speed, etc. Valid values range from 10 to 256.
-
-unbind <key>
-(command)
- Removes a binding from the specified key.
-See also: bind, doublebind, unbindall, undoublebind
-
-unbindall
-(command)
- Removes all bindings and doublebindings from every key. To restore the
- default bindings, you can use the binddefaults command. There is no way to
- restore any custom bindings after issuing this command except by retyping
- each bind command or using the controls setup menu.
-See also: bind, binddefaults, doublebind, unbind, undoublebind
-
-undoublebind <key>
-(command)
- Removes a doublebinding from the specified key.
-See also: bind, doublebind, unbind, unbindall
-
-use_joystick
-(cvar: boolean)
-default: 0
- Set this cvar to 1 if you want to use a joystick with ZDoom.
-See also: use_mouse
-
-use_mouse
-(cvar: boolean)
-default: 1
- Set this cvar is 0, ZDoom will ignore the mouse.
-See also: use_joystick
-
-var_friction
-(cvar: boolean)
-default: 1
- When set to "0", normal friction is applied to the player in all cases.
- Otherwise, the amount of friction applied is determined by the sector
- the player is in.
-
-var_pushers
-(cvar: boolean)
-default: 0
- When set to "0", disables the BOOM push/pull wind effects.
-
-vid_currentmode
-(command)
- Displays the resolution of the currently active video mode.
-See also: vid_defwidth, vid_defheight, vid_listmodes
-
-vid_defbits
-(cvar: integer)
-default: 8
- Specifies the default screen depth. Currently, only 8 bits are supported.
-See also: vid_defheight, vid_defwidth
-
-vid_defheight
-(cvar: integer)
-default: 200
- Specifies the default screen height to use if not overridden at the
- command line.
-See also: vid_defbits, vid_defwidth
-
-vid_defwidth
-(cvar: integer)
-default: 320
- Specifies the default screen width to use if not overridden at the command
- line.
-See also: vid_defbits, vid_defheight
-
-vid_listmodes
-(command)
- Lists all resolutions supported by the current display driver.
-See also: vid_currentmode
-
-vid_fps
-(cvar: boolean)
-default: 0
- When true, will display a frame-per-second meter at the bottom of the
- screen.
-
-vid_noptc
-(cvar: boolean)
-default: 0
- When this cvar is true, ZDoom will use DirectDraw directly instead of
- using PTC to access it. Changes to this cvar take effect the next time
- the game starts.
-
-vid_palettehack      (Win32 only)
-(cvar: boolean)
-default: 0
- When this cvar is true, the game will refresh the palette every time
- the screen is redrawn. This can be useful with some buggy video drivers.
-
-vid_winscale         (Linux only)
-(cvar: number)
-default: 1.0
- Controls how large the display is scaled when playing in an X window.
- Values of 1.0 and 2.0 are fast, other values use slower, generic scaling.
-
-vid_setmode <width> <height> <modeid>
-(command)
- Sets the screen mode to <width> x <height> with <modeid> (if your video
- hardware supports it).
-See also vid_describecurrentmode, vid_describemodes
-
-weapnext
-(command)
- Selects the next weapon (in order) that you own and have ammo for.
-See also: impulse, weapprev
-
-weapondrop
-(cvar: boolean)
-default: 0
- When true, dead players will drop their current weapon (or ammo if the
- pistol).
-
-weapprev
-(command)
- Selects the previous weapon (in order) that you own and have ammo for.
-See also: impulse, weapnext
-
-wi_percents
-(cvar: boolean)
-default: 1
- When false, intermission stats are printed as absolute values such as "3
- of 6". When true, intermission stats are printed as percentages such as
- "50%".
-
-wipetype
-(cvar: number)
-default: 1
- Selects the type of screen wipe to use. There are currently four possible
- settings for this cvar:
-    1. No wipe
-    2. Melt
-    3. Burn
-    4. Crossfade
diff --git a/docs/doomlic.txt b/docs/doomlic.txt
deleted file mode 100644
index 2b2252ee2f..0000000000
--- a/docs/doomlic.txt
+++ /dev/null
@@ -1,112 +0,0 @@
-
-
-      LIMITED USE SOFTWARE LICENSE AGREEMENT
-
-        This Limited Use Software License Agreement (the "Agreement")
-is a legal agreement between you, the end-user, and Id Software, Inc.
-("ID").  By downloading or purchasing the software material, which
-includes source code (the "Source Code"), artwork data, music and
-software tools (collectively, the "Software"), you are agreeing to
-be bound by the terms of this Agreement.  If you do not agree to the
-terms of this Agreement, promptly destroy the Software you may have
-downloaded or copied.
-
-ID SOFTWARE LICENSE
-
-1.      Grant of License.  ID grants to you the right to use the
-Software.  You have no ownership or proprietary rights in or to the 
-Software, or the Trademark. For purposes of this section, "use" means 
-loading the Software into RAM, as well as installation on a hard disk
-or other storage device. The Software, together with any archive copy
-thereof, shall be destroyed when no longer used in accordance with 
-this Agreement, or when the right to use the Software is terminated.  
-You agree that the Software will not be shipped, transferred or 
-exported into any country in violation of the U.S. Export 
-Administration Act (or any other law governing such matters) and that 
-you will not utilize, in any other manner, the Software in violation 
-of any applicable law.
-
-2.      Permitted Uses.  For educational purposes only, you, the
-end-user, may use portions of the Source Code, such as particular
-routines, to develop your own software, but may not duplicate the
-Source Code, except as noted in paragraph 4.  The limited right
-referenced in the preceding sentence is hereinafter referred to as
-"Educational Use."  By so exercising the Educational Use right you
-shall not obtain any ownership, copyright, proprietary or other
-interest in or to the Source Code, or any portion of the Source
-Code.  You may dispose of your own software in your sole discretion.
-With the exception of the Educational Use right, you may not
-otherwise use the Software, or an portion of the Software, which
-includes the Source Code, for commercial gain.
-
-3.      Prohibited Uses:  Under no circumstances shall you, the
-end-user, be permitted, allowed or authorized to commercially exploit
-the Software. Neither you nor anyone at your direction shall do any
-of the following acts with regard to the Software, or any portion
-thereof:
-
-        Rent;
-
-        Sell;
-
-        Lease;
-
-        Offer on a pay-per-play basis;
-
-        Distribute for money or any other consideration; or
-
-        In any other manner and through any medium whatsoever
-commercially exploit or use for any commercial purpose.
-
-Notwithstanding the foregoing prohibitions, you may commercially
-exploit the software you develop by exercising the Educational Use 
-right, referenced in paragraph 2. hereinabove.
-
-4.      Copyright.  The Software and all copyrights related thereto 
-(including all characters and other images generated by the Software
-or depicted in the Software) are owned by ID and is protected by
-United States  copyright laws and international treaty provisions.  
-Id shall retain exclusive ownership and copyright in and to the
-Software and all portions of the Software and you shall have no 
-ownership or other proprietary interest in such materials. You must
-treat the Software like any other copyrighted material. You may not
-otherwise reproduce, copy or disclose to others, in whole or in any
-part, the Software.  You may not copy the written materials
-accompanying the Software.  You agree to use your best efforts to
-see that any user of the Software licensed hereunder complies with
-this Agreement.
-
-5.      NO WARRANTIES.  ID DISCLAIMS ALL WARRANTIES, BOTH EXPRESS
-IMPLIED, INCLUDING BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE WITH RESPECT
-TO THE SOFTWARE.  THIS LIMITED WARRANTY GIVES YOU SPECIFIC LEGAL
-RIGHTS.  YOU MAY HAVE OTHER RIGHTS WHICH VARY FROM JURISDICTION TO
-JURISDICTION.  ID DOES NOT WARRANT THAT THE OPERATION OF THE SOFTWARE
-WILL BE UNINTERRUPTED, ERROR FREE OR MEET YOUR SPECIFIC REQUIREMENTS.
-THE WARRANTY SET FORTH ABOVE IS IN LIEU OF ALL OTHER EXPRESS
-WARRANTIES WHETHER ORAL OR WRITTEN.  THE AGENTS, EMPLOYEES, 
-DISTRIBUTORS, AND DEALERS OF ID ARE NOT AUTHORIZED TO MAKE 
-MODIFICATIONS TO THIS WARRANTY, OR ADDITIONAL WARRANTIES ON BEHALF
-OF ID. 
-
-        Exclusive Remedies.  The Software is being offered to you
-free of any charge.  You agree that you have no remedy against ID, its
-affiliates, contractors, suppliers, and agents for loss or damage 
-caused by any defect or failure in the Software regardless of the form
-of action, whether in contract, tort, includinegligence, strict
-liability or otherwise, with regard to the Software.  This Agreement
-shall be construed in accordance with and governed by the laws of the
-State of Texas.  Copyright and other proprietary matters will be
-governed by United States laws and international treaties.  IN ANY 
-CASE, ID SHALL NOT BE LIABLE FOR LOSS OF DATA, LOSS OF PROFITS, LOST
-SAVINGS, SPECIAL, INCIDENTAL, CONSEQUENTIAL, INDIRECT OR OTHER
-SIMILAR DAMAGES ARISING FROM BREACH OF WARRANTY, BREACH OF CONTRACT,
-NEGLIGENCE, OR OTHER LEGAL THEORY EVEN IF ID OR ITS AGENT HAS BEEN
-ADVISED OF THE POSSIBILITY OF SUCH DAMAGES, OR FOR ANY CLAIM BY ANY
-OTHER PARTY. Some jurisdictions do not allow the exclusion or
-limitation of incidental or consequential damages, so the above
-limitation or exclusion may not apply to you.
-
-
-
-
diff --git a/docs/history.txt b/docs/history.txt
deleted file mode 100644
index dd17985e00..0000000000
--- a/docs/history.txt
+++ /dev/null
@@ -1,534 +0,0 @@
-ZDoom Release History
-
-More detailed info can be found in the file docs/rh-log.txt included with
-the source code.
-
-
-1.22 (12 December 1999)
-=======================
-* Scroll_Texture_Both and TranslucentLine specials can now be used from ACS.
-* Fixed compiler-dependent cvar ordering during netgame arbitration.
-* Fixed certain polyobject movement combinations that would not stop even
-  though they were supposed to.
-* Did some cleanup for Alpha processors.
-
-
-1.21 (26 November 1999)
-=======================
-* Fixed problems with thinkers removing themselves and causing other thinkers
-  to not get a chance to think.
-* Added hud_scale cvar.
-
-
-1.20 (25 November 1999)
-=======================
-* Fixed saving, reloading, and then resaving games when travelling between
-  levels in a hub.
-* Fixed saving of ACS scripts scheduled to occur on a future level.
-
-
-1.19 (24 November 1999)
-=======================
-* DeHackEd patches that set an actor's death sound to 0 without removing
-  the A_Scream call no longer crash.
-* Fixed sync problems when playing with bullet puffs as particles vs as
-  sprites.
-* Fixed friction when walking on the bottom of swimmable water.
-* Added Jeffrey Cuenco's fixes to get -host and -join to work properly.
-* Fixed BOOM generalized locked doors so that the open/close type will
-  actually close.
-* Added pointer tracking and cleanup. This should fix the occasional
-  crashes when saving games and various other anomalies.
-
-
-1.18b (15 September 1999)
-=========================
-* Fixed crash when saving games with more than 1024 objects.
-* Fixed crash when loading a game without starting a new one first.
-* Reduced the size and frequency of pregame network packets, under the
-  assumption that problems people were having using 1.18 on the Internet
-  are a result of limited modem bandwidth. 
-
-
-1.18a (12 September 1999)
-=========================
-* Fixed liquid warping temporarily stopping when changing levels.
-* +/-mlook commands do not generate unknown command messages.
-* Fixed support for maps with >10 deathmatch starts. Thanks to Roman
-  Hatsiev.
-* Fixed support for the special "maps" EndGame? in MAPINFO lumps.
-* Teleport destination (no gravity) now works as intended.
-* Hopefully fixed savegame problems.
-* Bots are restored from savegames.
-* Fixed keyboard turning speed when -dup is used.
-* Network commands get executed only once when -dup is used.
-* In sectors with damaging floors and swimmable deep water, the damage
-  will also be applied while the player is swimming and not just when
-  the player is on the ground.
-
-
-1.18 (5 September 1999)
-=======================
-* Replaced the older Cajun 0.71 with Cajun 0.97.
-* Fixed handling of status bar faces with skins that provide them.
-* Added swimmable water.
-* Messages printed to the middle of the screen also print to the console.
-* Skill and other server cvars get saved in savegames again.
-* Added liquid texture warping.
-* Bad MAPINFO lumps generate error messages instead of hanging.
-* Realized that it's impossible to guarantee that all object pointers will
-  be valid without some effort, so FArchive saves DObject objects as NULL
-  objects now instead of aborting with an error.
-* Added the ACS built-in functions localambientsound, activatorsound, and
-  setlinemonsterblocking.
-* Added a thing that does nothing but count toward the number of secrets.
-* Added a fly mode.
-* Finally implemented the +moveup and +movedown commands.
-
-
-118test10-source only (14 August 1999)
-======================================
-* Reimplemented hub travel.
-* Optimized R_MapPlane slightly.
-* Added fov command.
-* Added vertical sub-pixel accuracy to the renderer.
-* Added searches for an IWAD in the current directory, $DOOMWADDIR, and
-  $HOME.
-
-
-118test9 (9 August 1999)
-========================
-* Fixed the "wild" bot spinning problem.
-* Commands like changemap that could make network games go out of sync
-  should work properly now. The reason they would do that is closely related
-  to the reason that the bots would start spinning.
-* Finished the serializer. Now savegames work. Hubs don't, because I haven't
-  written the player travelling code yet.
-* Various other code cleanup.
-
-
-118test8 (20 July 1999)
-=======================
-* Fixed a crash problem with the "burn" screen wipe.
-* Fixed a crash problem with playing non-assigned sound sequences.
-* Fixed a crash problem related to trying to shutdown the music subsystem
-  twice.
-* If you try to add more coop bots than there are coop starts, the extra
-  bot leaves quietly instead of ending the game.
-* Weapondrop is now a "server" cvar, which it should have been in the
-  first place.
-* Changed the nodetable file format to be more compact.
-* Bots can now be recorded in demos.
-* Bots work in multiplayer games. Still buggy. Spawning bots can cause
-  consistancy failures, and they can start spinning wildly.
-
-
-118test7 (12 July 1999)
-=======================
-* Fixed handling of maps with scrolling walls.
-* Single player works again. In test6, all games were considered either coop
-  or deathmatch.
-* Disabled the bot thinking code in single player games, so you don't suffer
-  a performance hitwhen not using bots.
-* Added some performance counters accessible through the stat command.
-
-
-118test6 (10 July 1999)
-=======================
-* Rewrote the wu line drawer to look better (especially in overlay mode).
-* Stretched skies now get stretched horizontally as well as vertically.
-* Did an initial integration of the Cajun Bot 0.71 code.
-
-
-118test5 (6 July 1999)
-======================
-* Fixed a potential infinite loop that was introduced in 118test1.
-* Delayed the initial execution of cvar callbacks.
-* Added Heretic's anti-aliased Wu line drawer to the automap.
-
-
-118test4 (3 July 1999)
-======================
-* Fixed the "Bad DCanvas::CopyRect" problem introduced in test3.
-* Fixed sound sequences that should not be cut off when stopped (such as
-  the standard doors).
-
-
-118test3 (2 July 1999)
-======================
-* Removed unnecessary display mode switches.
-* Created a DCanvas class to encapsulate most 2D rendering.
-
-
-118test2 (1 July 1999)
-======================
-* Fixed vertical aim clipping (BFG works again).
-* Fixed monster wandering.
-* Maps with mapthings of type 0 no longer generate warning messages.
-* Crushers that do no damage no longer act as if they inflict pain to
-  actors.
-* The alias command lists aliases again.
-* Aliases are saved to the config file again.
-
-
-118test1 (30 June 1999)
-=======================
-* Tweaked the optimized renderer for fifth-generation processors.
-* Added the following specials:
-    - Line_AlignFloor
-    - Line_AlignCeiling
-    - Sector_SetRotation
-    - Sector_SetCeilingPanning
-    - Sector_SetFloorPanning
-    - Secter_SetCeilingScale
-    - Sector_SetFloorScale
-* Added an additional parameter to the Transfer_Heights special.
-* Switched to the OpenPTC library for display.
-* Converted lots of code to an object-oriented C++ architecture.
-
-
-1.17c (5 May 1999)
-==================
-* Fixed game saving crashes on maps with wind/current effects.
-* In deep water sectors, the underwater light and fog colors can now be
-  set independently of the area above water.
-* Added nojump, allowjump, nofreelook, and allowfreelook keywords for
-  use in MAPINFO lumps.
-* The random number seed now changes each time you run the program.
-
-
-1.17b (15 March 1999)
-=====================
-1.17b contains some minor bug fixes over 1.17 and 1.17a. It also loads
-faster because the sprite dimensions are not cached until they are
-actually needed. There are also some other internal changes in
-preparation for supporting Heretic and Hexen, but those don't affect
-the user yet.
-
-
-1.17a (21 February 1999)
-========================
-1.17a is mostly minor bug fixes and was released because Herian 2 needed
-some of those fixes. There are a few new features, however:
-
-* If you have a skins directory in the same directory as zdoom.exe,
-  every wad file in it will be automatically loaded when the game starts.
-  This way, you don't have to load your skins by hand to use them.
-* New formatting options for text printed using ACS.
-* A code pointer to make monsters fire a railgun.
-
-
-1.17 (17 February 1999)
-=======================
-* I'm releasing both DOS and Win32 versions simultaneously. (The DOS version
-  does not support MIDI/MUS music or a joystick.)
-
-Bug fixes:
-* Multiplayer games with monsters do not crash.
-* Player corpses do not levitate and then fall down when a player respawns
-  in multiplayer games.
-* Using togglemap outside of a game will not crash.
-* Monsters stop attacking their target once it's dead.
-* EV_StopPlat() does not get stuck in an infinite loop if there are moving
-  platforms.
-* Partially invisible players are drawn the proper colors (instead of
-  green) if r_drawfuzz is 0.
-* If you are invisible, so are your muzzle flashes.
-* Trying to execute a non-existant script will not crash.
-* Using a ChangeCamera special from an open script will not crash.
-* The FloorAndCeiling_RaiseByValue and FloorAndCeiling_LowerByValues now
-  behave like Hexen's.
-* Using -loadgame from the command line works.
-* Fixed a memory leak during generation of the translucency tables.
-* In high resolutions, weapon sprites meet the bottom of the screen.
-* Sounds will not cut out mysteriously when there is no reason for them to
-  do so.
-* Sounds will also not be stopped immediately when a thing is removed, so
-  explosion sounds will play to their full length.
-* Things can make more than one sound at once.
-* The deathmatch scoreboard is aligned properly at high resolutions.
-* Spynext and spyprev work properly instead of leaving the status bar
-  "lagging behind" the player being viewed.
-* The light-amp does not disable colored lighting.
-* The sky gets inverted when using the invulnerability powerup.
-* Implemented better z-checking code (from Heretic/Hexen).
-* Pain elementals will spawn one lost soul at a time instead of two inside
-  of each other.
-* Bex patches that use thing mnemonics really do work now, and unknown bit
-  messages aren't generated for regular DeHackEd patches.
-* Linedef type 134 for regular DOOM/BOOM maps requires a red key for
-  activation (it was being improperly translated to require a blue one).
-* Monsters can activate secret lines when they cross them. (See DOOM2/MAP08).
-* The player extreme death sound is used.
-* When a player leaves a network game, their body is removed instead of
-  being left empty.
-* 0-length sounds are treated as empty sounds instead of sounds 4 gigs long.
-* Skins that replaced player sounds with sounds in the IWAD work.
-* Muzzle flashes do not light up foggy areas, and fullbright sprites stay
-  shrouded in fog.
-* Alphanumeric keys no longer automatically repeat on the console.
-* Wads such as gothicdm2 that used new flats in addition to the ones in the
-  IWAD with the regular doom.exe work.
-
-New features:
-* Significant speed improvements on modern processors.
-* Armor and keys are shown on the fullscreen HUD.
-* Colored text.
-* A playdemo console command.
-* A chasecam.
-* A particle sytsem.
-* An optional railgun to show off the particle system. (Start the game with
-  -deh railgun.bex if you want to use it.)
-
-New features interesting for wad authors:
-* Polyobjects.
-* Sound sequences.
-* WAVE files can be used as sound lumps without converting them to DMX's
-  format first.
-* A sky can be specified to not be stretched even if it is shorter than 200
-  pixels.
-* Sparks.
-* Particle fountains.
-* Parallax skies.
-* Some new DeHackEd thing flags from Hexen (bobbing, reflective, etc.).
-
-
-1.16 (22 December 1998)
-=======================
-Bug fixes:
-* No more limit on size of savegames or demos.
-* Screen resolutions above 320x200 are now the proper brightness (they were
-  too bright before.)
-* Improved the brightness of the console font.
-* Bullet puffs can show up on the floor and ceiling and not just walls.
-* Missile weapons can trigger gun activation lines.
-* Barrels now bounce around as much as they did in original DOOM. (They were
-  too "inert" in 1.14.)
-* If a demo is being recorded, quitting the game normally will save the demo
-  to disk. (Previously, you had to use the stop command to do this.)
-
-New features for players:
-* Proper support for BOOM maps.
-* Mouse wheel support and weapnext/weapprev commands.
-* Doublebindings.
-* Better analog joystick support.
-* 180 degree turn command for keyboarders.
-* Damage done by a rocket to its shooter is configurable and defaults to the
-  original Doom behavior.
-* User-configurable gender. (Even though I don't have any new player sounds,
-  at least the obituaries are gender-aware. :-)
-* Teamplay mode.
-* New cvar to disable manual aiming of the BFG to prevent someone from
-  shooting it at the floor and quickly triggering tracer damage before.
-* Maps no longer need to have as many deathmatch starts as there are players
-  in a deathmatch game.
-* Support for Doom Legacy skins.
-* Rewrote the MIDI/MUS code so that it has a working volume control.
-* Many more console commands and cvars.
-
-New features for editors:
-* Proper support for BOOM maps.
-* Obituaries are configurable with a .bex patch.
-* Moster paths
-* Colored lighting
-* Fog can be applied to only part of a level instead of all of it.
-* Per-sector gravity settings.
-* Support for up to 256 ambient sounds (as opposed to the limit of 64 in
-  earlier versions).
-* Sector damage adjustable from between 0-255 points of damage.
-* Changable camera views.
-* The following editing features that were introduced in Hexen are also
-  available in ZDoom:
-  - Most line specials take arguments that modify their behavior.
-  - ACS scripting.
-  - Hubs.
-  - Earthquakes.
-  - Dormant monsters.
-  - Trigger events to happen on monster deaths.
-  - "Waggling" floors.
-  - Pillar builders.
-  - Push activation lines (walking into a wall can trigger an event).
-  - Thing spawning (e.g. for traps/gifts).
-
-
-1.14a (27 July 1998)
-====================
-Bugs fixed are:
-
-* No more crashing about freeing a pointer without ZONEID when changing
-  levels.
-* Skies wider than 256 pixels are drawn correctly.
-* Monsters' heights are once again the same as they were in id's original
-  DOOM, so certain areas work properly again.
-* Monsters shouldn't teleport into each other anymore.
-* Improved support for international keyboards.
-* The skill level chosen for a new game is no longer ignored if the new
-  game is started while a demo is playing.
-
-Cosmetic changes:
-
-* No more "sv_gravity changed to...", "skill changed to...", etc. messages
-  in single player games.
-* Activating the player setup menu automatically stops any playing demos,
-  since it doesn't work properly while they play.
-* Barrels don't go flying away when exploding anymore.
-* Added def_patch cvar to automatically load a DeHackEd patch each time the
-  game is started.
-* ZDoom save games now use the name zdoomsv?.dsg instead of doomsav?.dsg.
-
-This version also includes some preliminary BOOM support as I started
-integrating some of the BOOM source code with ZDoom:
-
-* Medusa fix.
-* Openings limit removed.
-* Removed limit on switches and animations.
-* Added support for BOOM-like ANIMATED and SWITCHES lumps in PWADs.
-* Added support for BOOM-style scrollers (including conveyors).
-* Added partial deep-water support.
-
-
-1.14 (14 July 1998)
-===================
-Bugs fixed:
-* The bunny scroller at the end of E3M8 no longer crashes the game.
-* The IDKFA cheat gives the proper amount of armor again.
-* Demo recording works again.
-* Telefragging works again.
-* Picking up the invulnerability sphere displays the correct colors now.
-* DeHackEd patches containing text replacements no longer crash the game.
-* Printing a string containing "%s" to the console and then changing the
-  video mode will no longer crash the game.
-* Chat mode finally works again.
-* If MIDAS can't initialize, you can still play the game but without sound.
-* Pistol and chaingun sounds no longer cut out when there are lots of
-  zombie men shooting their pistols at you.
-* Mouse input should no longer be so jerky under Windows NT.
-* The crosshair is finally accurate for aiming.
-* Autoaim is properly remembered each time you start ZDoom.
-* Switches in the Ultimate Doom that aren't also in the shareware Doom
-  properly change their appearance when switched.
-
-New features:
-* Players can choose their own colors and names.
-  (Player setup menu is included).
-* 8-player support (untested but should work).
-* Miscellaneous internal code changes have been borrowed from the BOOM
-  source. (This does *not* mean that ZDoom supports BOOM levels yet.)
-* Cheats, chat messages, and gamestate changes are now recorded in demos.
-* Single-player demos recorded with ZDoom are generally smaller than
-  before.
-* Quake 2-style deathmatch flags.
-* Cheats (optionally) work in multiplayer games.
-* Mode X is now supported under Win95, so all the machines that couldn't
-  run ZDoom in 320x200 before should be able to now.
-* Fewer conditions result in error messages that quit the game. (If you
-  have Heretic, try this: Start ZDoom with -file heretic and go to the
-  console and type "MAP E1M1".)
-* Keys can repeat in the console.
-* The console and chat mode now use the localized keymap set with the
-  Keyboard control panel.
-* Messages at the top of the screen now break along between words instead
-  of in the middle of them.
-* Added -config command line parameter.
-* Added -fastdemo command line parameter.
-* Added new screen shot command. (bound to "Print Screen" key by default)
-* Added Quake-like +showscores command. (bound to "\" key by default)
-* Aliases are now saved in the config file.
-* Added support for multiple pitched sounds like in very old version of
-  Doom. (Use the snd_pitched cvar to turn it on and off.)
-
-
-1.13 (26 May 1998)
-==================
-* Fixed some major bugs (that crashed the game) and other lesser bugs that were
-  just annoying.
-* 3-D collisions for walking under and standing on other things.
-* The status bar can be scaled to the full width of the screen.
-* The screen mode can be selected from a menu inside the game.
-* ZDoom can run in a window on the desktop.
-* Better DeHackEd support. Only a few text replacements are not supported.
-  Everything else works (including monster infighting which I haven't seen
-  in any other port).
-* New features for level designers (see editing.txt for details):
-    Specification of next and secret maps on a per-map basis.
-    Specify sky texture on a per-map basis.
-    Use any lump in a wad as music for a map.
-    Give maps a custom name without using a DeHackEd patch.
-    Maps can be named anything (not just E?M? or MAP??).
-    Place any messages of any length between any two maps.
-    Hexen-style fog (of any color).
-    Ambient sounds--either point like Quake or global like Heretic and Hexen.
-    Automatic use of DeHackEd patches in PWADs.
-    No more tutti-frutti for short textures of certain heights.
-    zdoom.wcf file for use with WadAuthor.
-* Rocket jumping. (One very important note about this: You need to be *in the
-  air* when your rocket explodes for rocket jumping to work. This is different
-  from Quake, and I will probably rewrite it for the next release.)
-* Dynamic palette flashes.
-* Supports stretching skies for freelook.
-* Larger freelook range.
-* Added tab-completion to the console.
-* zdoom.cfg is now the name of the default configuration file since Doom
-  Legacy decided to start using config.cfg.
-* French language support. (Set language cvar to "french".)
-* Player obituaries.
-* Unlimited ammo cheat (use g_unlimitedammo cvar).
-
-
-1.12 (7 April 1998)
-===================
-* Some visual enhancements were made such as centering the menus and 
-  drawing borders around the status bar in higher resolutions.
-* Console commands can now be specified on the command line.
-* Removed some of DOOM's limits such as VisPlanes, VisSprites, and 2S 
-  HOM.
-* Rewrote some of the inner loops in assembly. (There was some assembly 
-  in 1.11, but it never got used.)
-* New cvars relating to mouse movement. (invertmouse, m_pitch, m_yaw, 
-  etc.)
-* Mouse movement doesn't get sluggish in high resolutions.
-* Automap colors are customizable.
-* Automap overlay and rotation are available.
-* Eight crosshairs.
-* Shoot up/down.
-* Alt-Tab and Pause work properly on all machines now.
-* The +jump command now works.
-* 25% and 75% translucency levels in addition to 50%. The translucency 
-  tables now get saved to disk, too, so they only need to be calculated 
-  once instead of every time the game is run.
-* The console font is now editable.
-* Near complete support for DeHackEd patches. (Only monster infighting 
-  and changing a few minor text strings are not supported.)
-* Sky height and position is now fixed for high resolutions. (It still 
-  wraps if you look up, but at least now if you look straight ahead, it 
-  never will.)
-* Weapon sprite is always drawn at the correct location. (It was being 
-  drawn too low in some resolutions like 400x300.)
-* New options menu, which includes a key configuration screen.
-* "Stealth" monsters.
-* New full-screen HUD.
-* And a few other things not worth mentioning separately.
-
-
-1.11 (6 March 1998) Initial Release
-===================================
-* Works under both Windows 95 and NT 4.0, although it works best under 
-  Win95.
-* Limited support for the Pause key. It works with some keyboards on 
-  some machines.
-* Supports any resolution compatible with your DirectDraw drivers.
-* Look up/down ala Heretic.
-* Translucency for selected objects.
-* Has a console with most of the functionality of Quake's. The only 
-  significant missing feature is Tab-completion.
-* Notarget cheat.
-* Command to kill all monsters in a level or yourself.
-* Can play MUS, MIDI, and MOD music.
-* Selected sounds are played in surround sound.
-* Doors that need keys to open are highlighted on the automap.
-* Automap now shows various statistics in addition to the level name.
-* True keybindings. Bind any key to any command or sequence of 
-  commands.
-* Intermission screen can now display your stats using absolute values 
-  rather than percentages.
-* A new more general demo format.
diff --git a/docs/licenses/README.TXT b/docs/licenses/README.TXT
index cef723395d..3463a5ed7e 100644
--- a/docs/licenses/README.TXT
+++ b/docs/licenses/README.TXT
@@ -1,8 +1,10 @@
 The original Doom source code was released by id Software under the
-Doom Source Code License. See doomlic.txt.
+GPL v2, but has been relicensed under the GPL v3 for GZDoom.
+See gpl.txt
 
 Parts of the voxel code in the software renderer use code from the 
-BUILD engine by Ken Silverman. See buildlic.txt.
+BUILD engine by Ken Silverman and are used under the terms of the
+GPL v3 with permission.
 
 The majority of original code uses a BSD-like lincese. See bsd.txt.
 
@@ -16,7 +18,7 @@ Jean-loup Gailly and Mark Adler.
 
 This software uses the gdtoa package, see gdtoa.txt.
 
-This software uses the snes_spc library, which is covered by the GNU Lesser
+This software uses the game_music_emu library, which is covered by the GNU Lesser
 General Public License. See lgpl.txt.
 
 This software uses the "Dynamic Universal Music Bibliotheque" library for
@@ -25,6 +27,5 @@ however, has been heavily modified from its original form and is the same
 version used by the foobar2000 component foo_dumb as of mid-2008, found at
 http://kode54.foobar2000.org/.
 
-This software uses the OPL emulator from MAME 0.95. Playback of MUS files
-on the OPL emulation is accomplished with some help from Vladimir Arnost's
-MUS File Player Library, with fixes to make it more accurate.
+All script code in gzdoom.pk3 is licensed under the GPL v3 unless noted 
+otherwise.
\ No newline at end of file
diff --git a/docs/licenses/buildlic.txt b/docs/licenses/buildlic.txt
deleted file mode 100644
index a0cec1251f..0000000000
--- a/docs/licenses/buildlic.txt
+++ /dev/null
@@ -1,71 +0,0 @@
-BUILD SOURCE CODE LICENSE TERMS:                             06/20/2000
-
-[1] I give you permission to make modifications to my Build source and
-       distribute it, BUT:
-
-[2] Any derivative works based on my Build source may be distributed ONLY
-       through the INTERNET.
-
-[3] Distribution of any derivative works MUST be done completely FREE of
-       charge - no commercial exploitation whatsoever.
-
-[4] Anything you distribute which uses a part of my Build Engine source
-       code MUST include:
-
-   [A] The following message somewhere in the archive:
-
-       // "Build Engine & Tools" Copyright (c) 1993-1997 Ken Silverman
-       // Ken Silverman's official web site: "http://www.advsys.net/ken"
-       // See the included license file "BUILDLIC.TXT" for license info.
-
-   [B] This text file "BUILDLIC.TXT" along with it.
-
-   [C] Any source files that you modify must include this message as well:
-
-       // This file has been modified from Ken Silverman's original release
-
-[5] The use of the Build Engine for commercial purposes will require an
-       appropriate license arrangement with me. Contact information is
-       on my web site.
-
-[6] I take no responsibility for damage to your system.
-
-[7] Technical support: Before contacting me with questions, please read
-       and do ALL of the following!
-
-   [A] Look though ALL of my text files. There are 7 of them (including this
-          one). I like to think that I wrote them for a reason. You will find
-          many of your answers in the history section of BUILD.TXT and
-          BUILD2.TXT (they're located inside SRC.ZIP).
-
-   [B] If that doesn't satisfy you, then try going to:
-
-             "http://www.advsys.net/ken/buildsrc"
-
-          where I will maintain a Build Source Code FAQ (or perhaps I might
-          just provide a link to a good FAQ).
-
-   [C] I am willing to respond to questions, but ONLY if they come at a rate
-          that I can handle.
-
-             PLEASE TRY TO AVOID ASKING DUPLICATE QUESTIONS!
-
-          As my line of defense, I will post my current policy about
-          answering Build source questions (right below the E-mail address
-          on my web site.) You can check there to see if I'm getting
-          overloaded with questions or not.
-
-          If I'm too busy, it might say something like this:
-
-               I'm too busy to answer Build source questions right now.
-               Sorry, but don't expect a reply from me any time soon.
-
-          If I'm open for Build source questions, please state your question
-             clearly and don't include any unsolicited attachments unless
-             they're really small (like less than 50k). Assume that I have
-             a 28.8k modem. Also, don't leave out important details just
-             to make your question appear shorter - making me guess what
-             you're asking doesn't save me time!
-
-----------------------------------------------------------------------------
--Ken S. (official web site: http://www.advsys.net/ken)
diff --git a/docs/licenses/bzip2.txt b/docs/licenses/bzip2.txt
new file mode 100644
index 0000000000..cc614178cf
--- /dev/null
+++ b/docs/licenses/bzip2.txt
@@ -0,0 +1,42 @@
+
+--------------------------------------------------------------------------
+
+This program, "bzip2", the associated library "libbzip2", and all
+documentation, are copyright (C) 1996-2010 Julian R Seward.  All
+rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+
+2. The origin of this software must not be misrepresented; you must 
+   not claim that you wrote the original software.  If you use this 
+   software in a product, an acknowledgment in the product 
+   documentation would be appreciated but is not required.
+
+3. Altered source versions must be plainly marked as such, and must
+   not be misrepresented as being the original software.
+
+4. The name of the author may not be used to endorse or promote 
+   products derived from this software without specific prior written 
+   permission.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Julian Seward, jseward@bzip.org
+bzip2/libbzip2 version 1.0.6 of 6 September 2010
+
+--------------------------------------------------------------------------
diff --git a/docs/licenses/doomlic.txt b/docs/licenses/doomlic.txt
deleted file mode 100644
index 2b2252ee2f..0000000000
--- a/docs/licenses/doomlic.txt
+++ /dev/null
@@ -1,112 +0,0 @@
-
-
-      LIMITED USE SOFTWARE LICENSE AGREEMENT
-
-        This Limited Use Software License Agreement (the "Agreement")
-is a legal agreement between you, the end-user, and Id Software, Inc.
-("ID").  By downloading or purchasing the software material, which
-includes source code (the "Source Code"), artwork data, music and
-software tools (collectively, the "Software"), you are agreeing to
-be bound by the terms of this Agreement.  If you do not agree to the
-terms of this Agreement, promptly destroy the Software you may have
-downloaded or copied.
-
-ID SOFTWARE LICENSE
-
-1.      Grant of License.  ID grants to you the right to use the
-Software.  You have no ownership or proprietary rights in or to the 
-Software, or the Trademark. For purposes of this section, "use" means 
-loading the Software into RAM, as well as installation on a hard disk
-or other storage device. The Software, together with any archive copy
-thereof, shall be destroyed when no longer used in accordance with 
-this Agreement, or when the right to use the Software is terminated.  
-You agree that the Software will not be shipped, transferred or 
-exported into any country in violation of the U.S. Export 
-Administration Act (or any other law governing such matters) and that 
-you will not utilize, in any other manner, the Software in violation 
-of any applicable law.
-
-2.      Permitted Uses.  For educational purposes only, you, the
-end-user, may use portions of the Source Code, such as particular
-routines, to develop your own software, but may not duplicate the
-Source Code, except as noted in paragraph 4.  The limited right
-referenced in the preceding sentence is hereinafter referred to as
-"Educational Use."  By so exercising the Educational Use right you
-shall not obtain any ownership, copyright, proprietary or other
-interest in or to the Source Code, or any portion of the Source
-Code.  You may dispose of your own software in your sole discretion.
-With the exception of the Educational Use right, you may not
-otherwise use the Software, or an portion of the Software, which
-includes the Source Code, for commercial gain.
-
-3.      Prohibited Uses:  Under no circumstances shall you, the
-end-user, be permitted, allowed or authorized to commercially exploit
-the Software. Neither you nor anyone at your direction shall do any
-of the following acts with regard to the Software, or any portion
-thereof:
-
-        Rent;
-
-        Sell;
-
-        Lease;
-
-        Offer on a pay-per-play basis;
-
-        Distribute for money or any other consideration; or
-
-        In any other manner and through any medium whatsoever
-commercially exploit or use for any commercial purpose.
-
-Notwithstanding the foregoing prohibitions, you may commercially
-exploit the software you develop by exercising the Educational Use 
-right, referenced in paragraph 2. hereinabove.
-
-4.      Copyright.  The Software and all copyrights related thereto 
-(including all characters and other images generated by the Software
-or depicted in the Software) are owned by ID and is protected by
-United States  copyright laws and international treaty provisions.  
-Id shall retain exclusive ownership and copyright in and to the
-Software and all portions of the Software and you shall have no 
-ownership or other proprietary interest in such materials. You must
-treat the Software like any other copyrighted material. You may not
-otherwise reproduce, copy or disclose to others, in whole or in any
-part, the Software.  You may not copy the written materials
-accompanying the Software.  You agree to use your best efforts to
-see that any user of the Software licensed hereunder complies with
-this Agreement.
-
-5.      NO WARRANTIES.  ID DISCLAIMS ALL WARRANTIES, BOTH EXPRESS
-IMPLIED, INCLUDING BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE WITH RESPECT
-TO THE SOFTWARE.  THIS LIMITED WARRANTY GIVES YOU SPECIFIC LEGAL
-RIGHTS.  YOU MAY HAVE OTHER RIGHTS WHICH VARY FROM JURISDICTION TO
-JURISDICTION.  ID DOES NOT WARRANT THAT THE OPERATION OF THE SOFTWARE
-WILL BE UNINTERRUPTED, ERROR FREE OR MEET YOUR SPECIFIC REQUIREMENTS.
-THE WARRANTY SET FORTH ABOVE IS IN LIEU OF ALL OTHER EXPRESS
-WARRANTIES WHETHER ORAL OR WRITTEN.  THE AGENTS, EMPLOYEES, 
-DISTRIBUTORS, AND DEALERS OF ID ARE NOT AUTHORIZED TO MAKE 
-MODIFICATIONS TO THIS WARRANTY, OR ADDITIONAL WARRANTIES ON BEHALF
-OF ID. 
-
-        Exclusive Remedies.  The Software is being offered to you
-free of any charge.  You agree that you have no remedy against ID, its
-affiliates, contractors, suppliers, and agents for loss or damage 
-caused by any defect or failure in the Software regardless of the form
-of action, whether in contract, tort, includinegligence, strict
-liability or otherwise, with regard to the Software.  This Agreement
-shall be construed in accordance with and governed by the laws of the
-State of Texas.  Copyright and other proprietary matters will be
-governed by United States laws and international treaties.  IN ANY 
-CASE, ID SHALL NOT BE LIABLE FOR LOSS OF DATA, LOSS OF PROFITS, LOST
-SAVINGS, SPECIAL, INCIDENTAL, CONSEQUENTIAL, INDIRECT OR OTHER
-SIMILAR DAMAGES ARISING FROM BREACH OF WARRANTY, BREACH OF CONTRACT,
-NEGLIGENCE, OR OTHER LEGAL THEORY EVEN IF ID OR ITS AGENT HAS BEEN
-ADVISED OF THE POSSIBILITY OF SUCH DAMAGES, OR FOR ANY CLAIM BY ANY
-OTHER PARTY. Some jurisdictions do not allow the exclusion or
-limitation of incidental or consequential damages, so the above
-limitation or exclusion may not apply to you.
-
-
-
-
diff --git a/docs/licenses/gpl.txt b/docs/licenses/gpl.txt
new file mode 100644
index 0000000000..94a9ed024d
--- /dev/null
+++ b/docs/licenses/gpl.txt
@@ -0,0 +1,674 @@
+                    GNU GENERAL PUBLIC LICENSE
+                       Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+                            Preamble
+
+  The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+  The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works.  By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users.  We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors.  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+  To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights.  Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received.  You must make sure that they, too, receive
+or can get the source code.  And you must show them these terms so they
+know their rights.
+
+  Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+  For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software.  For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+  Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so.  This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software.  The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable.  Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products.  If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+  Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary.  To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+                       TERMS AND CONDITIONS
+
+  0. Definitions.
+
+  "This License" refers to version 3 of the GNU General Public License.
+
+  "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+  "The Program" refers to any copyrightable work licensed under this
+License.  Each licensee is addressed as "you".  "Licensees" and
+"recipients" may be individuals or organizations.
+
+  To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy.  The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+  A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+  To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy.  Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+  To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies.  Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+  An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License.  If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+  1. Source Code.
+
+  The "source code" for a work means the preferred form of the work
+for making modifications to it.  "Object code" means any non-source
+form of a work.
+
+  A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+  The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form.  A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+  The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities.  However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work.  For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+  The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+  The Corresponding Source for a work in source code form is that
+same work.
+
+  2. Basic Permissions.
+
+  All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met.  This License explicitly affirms your unlimited
+permission to run the unmodified Program.  The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work.  This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+  You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force.  You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright.  Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+  Conveying under any other circumstances is permitted solely under
+the conditions stated below.  Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+  3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+  No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+  When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+  4. Conveying Verbatim Copies.
+
+  You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+  You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+  5. Conveying Modified Source Versions.
+
+  You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+    a) The work must carry prominent notices stating that you modified
+    it, and giving a relevant date.
+
+    b) The work must carry prominent notices stating that it is
+    released under this License and any conditions added under section
+    7.  This requirement modifies the requirement in section 4 to
+    "keep intact all notices".
+
+    c) You must license the entire work, as a whole, under this
+    License to anyone who comes into possession of a copy.  This
+    License will therefore apply, along with any applicable section 7
+    additional terms, to the whole of the work, and all its parts,
+    regardless of how they are packaged.  This License gives no
+    permission to license the work in any other way, but it does not
+    invalidate such permission if you have separately received it.
+
+    d) If the work has interactive user interfaces, each must display
+    Appropriate Legal Notices; however, if the Program has interactive
+    interfaces that do not display Appropriate Legal Notices, your
+    work need not make them do so.
+
+  A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit.  Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+  6. Conveying Non-Source Forms.
+
+  You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+    a) Convey the object code in, or embodied in, a physical product
+    (including a physical distribution medium), accompanied by the
+    Corresponding Source fixed on a durable physical medium
+    customarily used for software interchange.
+
+    b) Convey the object code in, or embodied in, a physical product
+    (including a physical distribution medium), accompanied by a
+    written offer, valid for at least three years and valid for as
+    long as you offer spare parts or customer support for that product
+    model, to give anyone who possesses the object code either (1) a
+    copy of the Corresponding Source for all the software in the
+    product that is covered by this License, on a durable physical
+    medium customarily used for software interchange, for a price no
+    more than your reasonable cost of physically performing this
+    conveying of source, or (2) access to copy the
+    Corresponding Source from a network server at no charge.
+
+    c) Convey individual copies of the object code with a copy of the
+    written offer to provide the Corresponding Source.  This
+    alternative is allowed only occasionally and noncommercially, and
+    only if you received the object code with such an offer, in accord
+    with subsection 6b.
+
+    d) Convey the object code by offering access from a designated
+    place (gratis or for a charge), and offer equivalent access to the
+    Corresponding Source in the same way through the same place at no
+    further charge.  You need not require recipients to copy the
+    Corresponding Source along with the object code.  If the place to
+    copy the object code is a network server, the Corresponding Source
+    may be on a different server (operated by you or a third party)
+    that supports equivalent copying facilities, provided you maintain
+    clear directions next to the object code saying where to find the
+    Corresponding Source.  Regardless of what server hosts the
+    Corresponding Source, you remain obligated to ensure that it is
+    available for as long as needed to satisfy these requirements.
+
+    e) Convey the object code using peer-to-peer transmission, provided
+    you inform other peers where the object code and Corresponding
+    Source of the work are being offered to the general public at no
+    charge under subsection 6d.
+
+  A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+  A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling.  In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage.  For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product.  A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+  "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source.  The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+  If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information.  But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+  The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed.  Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+  Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+  7. Additional Terms.
+
+  "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law.  If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+  When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it.  (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.)  You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+  Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+    a) Disclaiming warranty or limiting liability differently from the
+    terms of sections 15 and 16 of this License; or
+
+    b) Requiring preservation of specified reasonable legal notices or
+    author attributions in that material or in the Appropriate Legal
+    Notices displayed by works containing it; or
+
+    c) Prohibiting misrepresentation of the origin of that material, or
+    requiring that modified versions of such material be marked in
+    reasonable ways as different from the original version; or
+
+    d) Limiting the use for publicity purposes of names of licensors or
+    authors of the material; or
+
+    e) Declining to grant rights under trademark law for use of some
+    trade names, trademarks, or service marks; or
+
+    f) Requiring indemnification of licensors and authors of that
+    material by anyone who conveys the material (or modified versions of
+    it) with contractual assumptions of liability to the recipient, for
+    any liability that these contractual assumptions directly impose on
+    those licensors and authors.
+
+  All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10.  If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term.  If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+  If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+  Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+  8. Termination.
+
+  You may not propagate or modify a covered work except as expressly
+provided under this License.  Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+  However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+  Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+  Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License.  If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+  9. Acceptance Not Required for Having Copies.
+
+  You are not required to accept this License in order to receive or
+run a copy of the Program.  Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance.  However,
+nothing other than this License grants you permission to propagate or
+modify any covered work.  These actions infringe copyright if you do
+not accept this License.  Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+  10. Automatic Licensing of Downstream Recipients.
+
+  Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License.  You are not responsible
+for enforcing compliance by third parties with this License.
+
+  An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations.  If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+  You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License.  For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+  11. Patents.
+
+  A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based.  The
+work thus licensed is called the contributor's "contributor version".
+
+  A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version.  For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+  Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+  In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement).  To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+  If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients.  "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+  If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+  A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License.  You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+  Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+  12. No Surrender of Others' Freedom.
+
+  If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all.  For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+  13. Use with the GNU Affero General Public License.
+
+  Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work.  The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+  14. Revised Versions of this License.
+
+  The Free Software Foundation may publish revised and/or new versions of
+the GNU General Public License from time to time.  Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+  Each version is given a distinguishing version number.  If the
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation.  If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+  If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+  Later license versions may give you additional or different
+permissions.  However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+  15. Disclaimer of Warranty.
+
+  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+  16. Limitation of Liability.
+
+  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+  17. Interpretation of Sections 15 and 16.
+
+  If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+                     END OF TERMS AND CONDITIONS
+
+            How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the program's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+Also add information on how to contact you by electronic and paper mail.
+
+  If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+    <program>  Copyright (C) <year>  <name of author>
+    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License.  Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+  You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+<http://www.gnu.org/licenses/>.
+
+  The GNU General Public License does not permit incorporating your program
+into proprietary programs.  If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library.  If this is what you want to do, use the GNU Lesser General
+Public License instead of this License.  But first, please read
+<http://www.gnu.org/philosophy/why-not-lgpl.html>.
diff --git a/docs/licenses/xBRZ.jpg b/docs/licenses/xBRZ.jpg
deleted file mode 100644
index ab8335391b0e35541662e9664ad53c31aaed0c51..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001

literal 60099
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
VZ-P$?YO$&>=SYI<c0xY%{1??#e?kBN

diff --git a/docs/zdoom.txt b/docs/zdoom.txt
deleted file mode 100644
index 2ac555f59a..0000000000
--- a/docs/zdoom.txt
+++ /dev/null
@@ -1,1134 +0,0 @@
-ZDOOM v1.22
-December 12, 1999
-
-A port of id Software's original Linux Doom source code to Win32 and Linux
-with additional enhancements by Randy Heit (rheit@iastate.edu).
-
-ZDoom's homepage is at: http://zdoom.notgod.com/
-
-
-Contents
-
-  1. Introduction
-1-1. Significant differences between ZDoom and regular Doom
-1-2. Installing ZDoom
-
-  2. Command line arguments
-2-1. Configuration options
-2-2. Play options
-2-3. Loading options
-2-4. Debug options
-2-5. Multiplayer options
-2-6. Other options
-
-  3. Configuring ZDoom
-3-1. The Player Setup menu
-3-2. The new Options menu
-3-3. The Configure Controls menu
-3-4. The Gameplay Options menu
-3-5. The Display Options menu
-3-6. The Messages menu
-3-7. The Video Modes menu
-3-8. Changing settings not found in a menu
-
-  4. The Console
-4-1. Activating the console
-4-2. Using the console
-
-  5. Key bindings
-
-  6. Playing a network game
-6-1. Playing a network game with the DOS version
-6-2. Playing a network game the nice way
-6-3. Playing a network game the old way
-6-4. Configuring ICQ to launch an Internet game
-6-5. Playing with a modem/serial/parallel cable connection
-
-  7. Known bugs
-
-  8. Acknowledgments
-
-
-1. Introduction
-===============
-
-ZDoom is an enhanced port of the official DOOM source code. Originally for
-Win32 (Windows 95/98/NT), it is now available for Linux as well.
-
-ZDoom may be used and distributed free of charge. It must not be sold for
-profit. These are terms set forth by the Doom Source Code license, the
-MIDAS Digital Audio System license, and the Prometheus Truecolor license.
-
-
-1-1. Significant differences between ZDoom and regular Doom
------------------------------------------------------------
-
-- Will work under Windows NT with sound.
-- Free look (look up/down).
-- High resoulutions.
-- Translucency.
-- A console.
-- MOD and MIDI support.
-- Better mouse support.
-- Limited TCP/IP (actually UDP) networking.
-- Quake-style key bindings.
-- Jumping.
-- Crosshairs.
-- Walk over/under other things.
-- Hexen-style map editing.
-- Almost full BOOM support.
-
-
-1-2. Installing ZDoom
----------------------
-
-To use ZDoom, unzip both zdoom.exe and zdoom.wad into your existing Doom 
-directory. (You must already have an existing copy of Doom to use this
-program.) If nothing else, you need to download the shareware Doom, which
-is available in several places on the Internet. To truly take advantage of
-ZDoom, though you need the full game. The Depths of Doom Trilogy can be had
-fairly cheaply and includes Ultimate Doom, Doom II, and The Master Levels
-for Doom II.
-
-ZDOOM REQUIRES an IWAD from a 1.9 version of Doom. If you have a lesser
-version, you can find patches to upgrade your version at
-ftp.idsoftware.com.
-
-ZDoom on Windows systems also requires Microsoft's DirectX 3 or later. If
-you are using Windows 95, you can download the latest version from Microsoft's
-website at http://www.microsoft.com/directx. Windows NT 4.0 users can get it
-as part of Service Packs 3 and 4 (which are available at
-http://www.microsoft.com/NTServer/all/downloads.asp).
-
-ZDoom for Linux requires Hermes. You can get it from http://hermes.terminal.at
-
-
-2. Command line parameters
-==========================
-
-ZDoom supports many command line parameters. They are described below:
-
-2-1. Configuration options
---------------------------
-
--bits <numbits>
-    Specifies the display depth. Currently, only 8 is supported.
-
--width <x>
--height <y>
-    Specifies the desired resolution of the screen. If only one of -width
-    or -height is specified, ZDoom will try to guess the other one based on
-    a standard aspect ratio. If the specified resolution is not supported
-    by your DirectDraw drivers, ZDoom will try various resolutions until it
-    either finds one that works or gives up. To determine which resolutions
-    ZDoom can use, use the vid_describemodes command from the console once
-    you have started the game.
-
--cdrom
-    Causes ZDoom to look for savegames and zdoom.cfg in a directory called
-    C:\ZDOOMDAT. Screenshots will also be saved in this directory.
-
--config <configfile>
-    Causes ZDoom to use an alternative configuration file. If configfile
-    doesn't exist, it will be created.
-
--heapsize <x>
-    This is the size in megabytes of the zone memory manager�s heap. If set
-    too low, problems will almost certainly arise. 6 megabytes is probably
-    a reasonable minimum to use for this parameter, although ZDoom won�t
-    stop you from using something smaller like 0.5 megabytes (which will
-    almost certainly give you a Z_Malloc error if you try it). Values too
-	high will also cause problems, because the game will use the system
-	heap to obtain memory too. If the zone heap is too large, it will have
-	to use virtual memory, and everything will be slower. By default, the
-    heap size is 8 megabytes.
-
--iwad <iwadfile[.wad]>
-    The IWAD file specified after this parameter will be used as the game
-    IWAD file instead of the default one. Normally, ZDoom looks for IWADs
-    in the following order and uses the first one it finds:
-
-        doom2f.wad
-        doom2.wad
-        plutonia.wad
-        tnt.wad
-        doom.wad
-        doom1.wad
-
-	ZDoom will look for the IWAD in the current directory, in the same
-	directory as zdoom.exe, in the directory set in the DOOMWADDIR
-	environment variable, and in the directory set in the HOME environment
-	variable.
-
--m (DOS only)
-	Displays the MIDAS configuration screen when the game starts so you
-	can pick your soundcard if it isn't detected properly. Sorry, but there
-	isn't any way to save this configuration.
-
--noflathack
-	Some wads were able to use new flats with the original Doom.exe. ZDoom
-	will normally try and detect them. Use this switch to prevent that.
-
--noidle (Win32 only)
-    When the user presses Alt-Tab to switch from ZDoom to another window,
-    ZDoom will normally reduce its priority class so that it doesn't slow
-    the rest of the system down. By specifying this parameter, ZDoom will
-    try to run at full speed even when it isn't the active window.
-
--nommx
-    Causes ZDoom not to use any MMX code. Normally, ZDoom should be able to
-    figure out on its own whether the processor supports MMX or not and
-    will act accordingly. Currently, MMX isn't actually used, so this switch
-	doesn't do anything.
-
--nomusic
-    Prevents the playback of music.
-
--noptc (Win32 only)
-	This forces ZDoom to use DirectDraw directly instead of using PTC as
-	an abstraction layer on top of it. Setting the cvar vid_noptc to 1
-	has the same effect as this command line option, and is also
-	remembered so that you don't need to type it in each type you run
-	the game. Unless you have problems with video, it is recommended that
-	you let ZDoom use PTC.
-
--nosfx
-    Prevents the playback of sound effects. Because of the nature of MOD
-    music, this also disables playback of MODs.
-
--nosound
-    Disables both music and sound effects.
-
--notrans
-    Disables translucency.
-
--primarysound (Win32 only)
-    If DirectSound is available, this parameter will cause ZDoom to try to
-    use the primary buffer for mixing. This can potentially lower sound
-    latency but also introduces the possibilty for more sound problems.
-
--wavonly (Win32 only)
-    Forces ZDoom to use the standard Windows wave device for sound output
-    instead of DirectSound. If you experience problems with sound, it may
-    be worthwhile trying this parameter, although it will generally
-    introduce a large amount of latency, causing sounds to be heard later
-    than expected.
-
--transfile <transfile[.tch]>
-    Causes ZDoom to use an alternative translucency cache file. This file
-    is automatically generated if it doesn't already exist and is used to
-    speed up startup by eliminating the need to recalculate the
-    translucency tables every time the game is started. By default, ZDoom
-    will look for a file called transtab.tch in the same directory that it
-    resides in. If the .tch extension is omitted, it will automatically be
-    added.
-
-2-2. Play options
------------------
-
--avg
-    Stands for "Austin Virtual Gaming." Automatically advances to the next
-    level after 20 minutes. This is equivalent to +set timelimit 20 or
-	-timer 20.
-
--fast
-    Sets the dmflags cvar to make the monsters as fast as in nightmare mode
-    even if you aren't playing nightmare.
-
--nomonsters
-    Sets the dmflags cvar so that monsters are not spawned on levels.
-
--respawn
-    Sets the dmflags cvar so that monsters respawn even if you aren't
-    playing at nightmare difficulty.
-
--timer <x>
-    Causes ZDoom to automatically advance to the next level after x
-    minutes. This is equivalent to +set timelimit <x>.
-
--turbo <x>
-    Causes player movement to be x% as fast as normal. Valid values are
-    10-256, with 100 being normal. Values larger than 100 are considered
-    cheating. This is equivalent to +set turbo <x>.
-
-2-3. Loading options
---------------------
-
--deh <dehfile[.deh]>
-    Causes ZDoom to apply a DeHackEd or .bex patch to the game. This must be
-    a text patch; binary patches are not supported. (As far as I know, most
-    patches are text patches so this shouldn�t be too much of a problem.)
-    Also, only patch format 6 is known to be supported. Other formats may
-    or may not work properly. If the .deh extension is omitted, ZDoom will
-    automatically add it. If this is a .bex patch, however, the extension
-    does need to be included.
-
--bex <bexfile[.bex]>
-	This is the same as -deh, except the default file extension is .bex.
-
--file <file1[.wad]> [file2[.wad] [file3[.wad] ...
-    Used to load one or more PWAD files which generally contain user-
-    created levels. Files listed further right take precedence to files
-    listed before them, so as an example, if both file1.wad and file2.wad
-    contain have a MAP01, the MAP01 in file2.wad would be used instead of
-    the one in file1.wad If the .wad extension is omitted, ZDoom will
-    automatically add it.
-
--loadgame <x>
-    Automatically loads savegame x, where x is 0-7 corresponding to one of
-    the savegame slots.
-
--maxdemo <x>
-    Specifies the initial size of the recording buffer used with the -record
-    parameter. This buffer will grow as needed, but you might want to use
-    this parameter to avoid any potential pauses when the buffer grows. The
-    default size of 128k is large enough for about 10 minutes of a
-    deathmatch, although the actual amount of space used by a demo depends
-    on what happens in the demo (due to the rudimentary delta compression
-    ZDoom applies to demos): If you did nothing but stand still, this should
-    be large enough for about 5.5 days.
-
--playdemo <demofile[.lmp]>
-    ZDoom will automatically play the specified demo when it starts. If the
-	.lmp extension is omitted, it will automatically be added.
-
--record <demofile[.lmp]>
-    Records a demo. The -warp parameter or +map command should also be used
-    if you don't want to record the demo on MAP01 or E1M1. To stop the demo
-    recording, use the "stop" console command. If the .lmp extension is
-    omitted, it will automatically be added. Unlike regular DOOM, only one
-    person in a multiplayer game needs to specify the -record parameter if
-    they want to record a demo. However, if someone quits before the person
-    recording the demo does, the person recording will automatically quit,
-    too, because I didn't bother to give demos a way to record when a player
-    leaves the game.
-
--skill <x>
-    Sets the initial skill level. This is overridden if you start a new
-    game from the New Game menu.
-
--timedemo <demofile[.lmp]>
-    Plays back a demo faster than -playdemo and displays a framerate when
-    the demo is over. If the .lmp extension is omitted, it will
-    automatically be added.
-
--warp <m>
--warp <e> <m>
-    For Doom II, starts the game on map m. For other versions of doom,
-    starts the game on episode e, map m. The +map command can also be used
-    to perform this action, but it expects the actual name of the map.
-    (i.e. MAP01, E1M1, ...)
-
-2-4. Debug options
-------------------
-
--noblit
-    Causes ZDoom not to update the display on the screen, but it stills
-    draws everything to an internal buffer. Only useful with -timedemo.
-
--nodraw
-    Causes ZDoom not to draw anything at all. Only useful with -timedemo.
-
--debugfile
-    Causes ZDoom to write network debugging information to a file called
-    debugN.txt where N is your player number.
-
--devparm
-    Prints a message telling you that you can take screenshots with the
-    Print Screen key. With the original Doom, using -devparm was the only
-    way to take screenshots. With ZDoom, screenshot is just another command.
-
-+set developer 1
-    Prints a bunch of debugging messages to the console.
-
-2-5. Multiplayer options
-------------------------
-
--altdeath
-    Informs ZDoom that you will be playing a deathmatch game and sets the
-    dmflags cvar so that items other than invulnerability and invisibilty
-    respawn after being picked up. Only player 1 needs to specify this.
-
--deathmatch
-    Informs ZDoom that you will be playing a deathmatch game and sets the
-    dmflags cvar so that weapons stay behind when a player picks them up.
-    Only player 1 needs to specify this.
-
--dup <x>
-    Causes ZDoom to transmit fewer player movement commands across the
-    network. Valid values range from 1-9. For example, -dup 2 would cause
-    ZDoom to send half as many movements as normal.
-
--extratic
-    Causes ZDoom to send a backup copy of every movement command across the
-    network.
-
--host <x>
-    This machine will function as a host for a multiplayer game with <x>
-    players (including this machine). It will wait for other machines to
-    connect using the -join parameter and then start the game when
-    everyone is connected. See section 6 for more details.
-
--join <host>
-    Connect to a host for a multiplayer game. See section 6 for more
-    details.
-
--net <console> [hosts] ...
-    Informs ZDoom that you will be playing a network game. See section 6
-    about network games below for more details.
-
--port <x>
-    Specifies an alternate IP port for this machine during a network game.
-    By default, the port 5029 is used.
-
-2-6. Other options
-------------------
-
-In addition to the above parameters, console commands can be included on
-the command line by preceding them with a '+'. Some, however, will cause
-the game to crash if you use them (such as cheats). If you wish to
-change a cvar in this manner, it is a good idea to use the set command. This
-is because any set commands will be executed just after the config file is
-loaded, and all other commands are executed after every game subsystem has
-been initialized. For example, to turn on developer messages when you start
-ZDoom, use the command line:
-
-    zdoom +set developer 1
-
-instead of
-
-    zdoom +developer 1
-
-If you use the second line, you'll miss out on all the developer messages
-that get generated during the startup process.
-
-For a complete list of console commands and cvars, refer to the
-commands.txt file. If you want to get the most from ZDoom, I highly
-recommend at least glancing at it.
-
-
-3. Configuring ZDoom
-====================
-
-Zdoom now includes a new options menu which can be used to set some of the
-game's new options. A new control configuration menu is also included that
-can be used to easily assign some commands to different keys without a
-separate setup program.
-
-3-1. The Player Setup menu
---------------------------
-
-This menu is found on the main menu and is used to select your player's
-name, team, suit color, gender, skin, and autoaim setting.
-
-Your player's name will be displayed on the scoreboard in deathmatch games
-and in the obituaries that are printed when you die. In teamplay games, your
-team name is used to identify which team you are on and also appears in the
-deathmatch scoreboard.
-
-The suit color is controlled with three sliders; one for each of red,
-green, and blue color components. Because the Doom palette only has 256
-colors, not all possible combinations will look good. The current color
-is displayed on an animated player character to the right of the sliders.
-
-Your player's gender can be male, female, or cyborg. However, unless you
-have a soundpack or a skin with non-male sounds, your player will still
-sound like the male DOOM marine. Some obituaries (such as "Zathras checks
-his glasses") will adjust themselves to fit the gender you select.
-
-You also have the option of looking like something other than the DOOM
-marine by picking a skin. ZDoom doesn't come with any, but it is compatible
-with skins developed for Doom Legacy. You can find skins to download from
-their site at http://frag.com/doomlegacy/dl_skins.htm. To automatically
-load skins at game startup, create a skins directory (in the same directory
-as zdoom.exe), and place your skins in it. You can also load skins from
-the command line with -file.
-
-The autoaim settings controls how close your vertical aim should be from a
-monster before ZDoom will adjust your aim to shoot it. By default, this
-value is set to always which means that it behaves just like the original
-Doom. Never indicates that ZDoom will never adjust your aim for you, and
-you will shoot where you aim. There are also intermediate values which
-adjust how much leeway you can have in your aim.
-
-3-2. The Options menu
-----------------------
-
-ZDoom's Options menu is different from the options menu in the original
-Doom and contains the following items:
-
-Customize Controls
-    Displays the customize controls menu.
-
-Go to console
-    Opens the console.
-
-Gameplay Options
-    Displays the gameplay options menu.
-
-Display Options
-    Displays the display options menu.
-
-Set video mode
-    Displays the video modes menu.
-
-Mouse speed
-    Adjusts how sensitive ZDoom is to mouse movements.
-
-MIDI Music Volume
-    Adjusts the volume of MIDI and MUS music. This is the type of music
-    found in the levels that come with DOOM and does not affect the volume
-    of MOD music.
-
-MOD Music volume
-    Adjusts the volume of MOD music. Setting this to a high setting will
-    usually result in nasty-sounding aliasing. Note that this only effects
-    the volume of MOD music and not MUS or MIDI music.
-
-Sound volume
-    Adjusts the volume of sound effects.
-
-Always Run
-    When on, you will always run whether or not you are holding down the
-    +speed key. By default, you can also change this setting by pressing
-    the caps lock key while playing a game.
-
-Always Mouselook
-    When on, moving the mouse up and down will always cause you to look up
-    and down instead of only when the +mouselook key is pressed.
-
-Invert Mouse
-    When on, mouselooking is reversed so that pushing the mouse forward
-    causes you to look down, and pulling the mouse back causes you to look
-    up.
-
-Lookspring
-    When on, releasing the +mouselook key will automatically center your
-    view.
-
-Lookstrafe
-    When on, moving the mouse left and right will always cause the player
-    to move in the corresponding direction.
-
-Reset to defaults
-    Select this item to set all options to their default values.
-
-Reset to last saved
-    Select this item to set all options to the values contained in the
-    configuration file.
-
-3-3. The Configure Controls menu
---------------------------------
-
-This menu is found on the options menu and lists several controls and up to
-two keys assigned to that control. There may be more than two keys assigned
-to a control, but only two of them will be shown at a time. If there are no
-keys assigned to the given control, this will be indicated with ???.
-
-To change the keys assigned to a control, use the up and down arrow keys to
-select the control you wish to change. To assign a new key to the control,
-press Enter and then the key you want to activate this control. If you
-decide you don�t want to assign a new key to the control, press Escape. To
-remove all keys for the selected control, press Backspace instead of Enter.
-
-This menu only lists a select few commands, but they are the ones that are
-most likely to be used during gameplay. To assign other commands to keys,
-you can use the bind command from the console.
-
-3-4. The Gameplay Options menu
-------------------------------
-
-This menu is found in the options menu and controls several options
-related to game play and map directly to different dmflags values. The
-dmflags value corresponding to the current settings can be found at the
-bottom of the menu. Many of these settings apply only to deathmatch games
-and are indicated by a (DM) after their names. During a multiplayer game,
-only player 1 can change these settings. Currently, there are 18 dmflags
-that can be set from this menu:
-
-Falling damage
-    When set to yes, falling long distances will cause players damage.
-
-Weapons stay (DM)
-    When set to yes, weapons won't disappear when they're picked up. This
-    is the default when started with -deathmatch.
-
-Allow powerups (DM)
-    When set to yes, powerups (such as light amplification goggles) will
-    be spawned on levels.
-
-Allow health (DM)
-    When set to yes, any items that give you health (such as stimpacks)
-    will be spawned on levels.
-
-Allow armor (DM)
-    When set to yes, armor will be spawned on levels.
-
-Spawn farthest (DM)
-    When set to yes, dead players will respawn as far as possible from
-    other players.
-
-Same map (DM)
-    When set to yes, exiting a level will restart the current one instead
-    of advancing to another.
-
-Force respawn (DM)
-    When set to yes, dead players will respawn immediately.
-
-Allow exit (DM)
-    When set to no, anyone who tries to leave the level will be instantly
-    killed.
-
-Infinite ammo
-    When set to yes, weapons do not deplete their ammo.
-
-No monsters
-    When set to yes, monsters will not be spawned on levels.
-
-Monsters respawn
-    When set to yes, monsters respawn (just like nightmare difficulty).
-
-Powerups respawn
-    When set to yes, powerups other than invulnerability and invisibility
-    will respawn. This is the default for -altdeath.
-
-Fast monsters
-    When set to yes, monsters will be faster than normal (just like
-    nightmare difficulty).
-
-Allow jump
-    When set to yes, players can jump.
-
-Allow freelook
-    When set to yes, players can look up and down.
-
-Friendly fire
-    When set to yes, players on the same team can hurt each other. If you
-    kill a teammate, you also lose a frag. If this is set to no, players on
-    the same team will still be able to push each other around with their
-    weapons, but they won't be able to hurt each other. This flag only has
-    an effect when teamplay is on. Otherwise, all players can always hurt
-    each other.
-
-The final option on this menu, "Teamplay," is not a dmflag. When it is on,
-the deathmatch scoreboard will also show the name's of players' teams, and
-the game will also use the setting of the friendly fire dmflag.
-
-Some of the DM-only flags (such as item respawning) can also be enabled
-for singe player and co-op can be enabled by opening the console and setting
-the alwaysapplydmflags cvar to 1.
-
-3-5. The Display Options menu
------------------------------
-
-This menu is found in the options menu and controls various aspects of the
-display. Options currently available are:
-
-Messages
-    Displays the messages menu.
-
-Screen size
-    Controls the size of the screen used to draw the players view. Larger
-    sizes require more processing power to draw but also look better.
-
-Brightness
-    Controls how bright the display is.
-
-Crosshair
-    Selects one of eight crosshairs or no crosshair at all. Some of these
-    crosshairs are probably of dubious value but are available anyway.
-
-Column render mode
-    Selects a column renderer. Original is the one used by DOOM. And
-    optimized is a new one that can as much as double the framerate on
-    modern processors. If you're using a 486, you should definitely
-    be using the original renderer, because the optimized one will cut
-    your framerate by at least half.
-
-Detail mode
-    Controls vertical and horizontal pixel doubling. This is similar to the
-    low detail mode of the original Doom which would double the size of
-    pixels horizontally except that it can also do the same vertically.
-    Doubling horizontally will almost always result in a speedup
-    significantly larger than doubling them vertically.
-
-Stretch short skies
-    When turned on, short sky textures (such as the ones included with
-    Doom) are stretched vertically so that they don't wrap when you look up
-    or down.
-
-Stretch status bar
-    When turned on, the status bar will always be as wide as the screen.
-
-Screen wipe style
-    Selects the style of screen wipe to use between levels. "None" means to
-    just switch directly to the new screen. "Melt" is the style used by
-    Doom. "Burn" makes the old screen burn into the new one. "Crossfade"
-    fades out the old screen while fading the new one in at the same time.
-
-DirectDraw palette hack (Win32 only)
-    If you have trouble with the palette, your video card probably has buggy
-    drivers. Turn this on, and ZDoom will reset the palette every frame
-    and not just when it changes.
-
-Use fuzz effect
-    Controls whether the fuzz effect will be used for partially invisible
-    things. If turned off, then translucency will be used instead.
-
-Rocket trails
-    Controls whether rockets leave a trail of particles behind them.
-
-Blood type
-    Determines the way blood is draw: as sprites only, particles only,
-    or both.
-
-Bullet puff type
-    Determines the way bullet puffs are drawn: either as sprites or as
-    particles.
-
-Rotate automap
-    When turned on, the automap will rotate to keep the area that you are
-    facing toward the top of the map.
-
-Overlay automap
-    When turned on, the automap will first be overlayed on top of the
-    player view before being drawn fullscreen.
-
-Standard map colors
-    When turned on, ZDoom will use the automap colors from the original
-    Doom instead of the colors specified with the am_*color cvars.
-
-3-6. The Messages Menu
-----------------------
-
-This menu lets you adjust how messages are displayed on the screen.
-Possible items you can select from this menu are:
-
-Scale text in high res
-    When turned on, message text is enlarged on higher resolutions so that
-    it takes up about as much space as it would on a 320x200 screen.
-
-Minimum message level
-    This is the minimum message level (see below) that will be shown.
-
-The remaining items control the colors used to display messages each level
-of message:
-
-Item pickup
-    Messages that appear when you pick up an item.
-
-Obituaries
-    Messages that appear when a player dies.
-
-Critical messages
-    Anything that doesn't fit into one of the other categories.
-
-Chat messages
-    Messages from another player.
-
-Team messages
-    Messages from a teammate who is only speaking to his team.
-
-Centered messages
-    Messages in the middle of the screen
-
-3-7. The Video Modes menu
--------------------------
-
-The video modes menu can be used to select the current display mode and
-switch between windowed mode and full screen. This menu can be found as a
-selection inside the Options menu.
-
-3-8. Changing settings not found in a menu
-------------------------------------------
-
-There are many settings (cvars) that aren't listed in any menu. To change
-these you need to use the console (see section 4). For a complete list of
-these, refer to the commands.txt file.
-
-
-4. The Console
-==============
-
-ZDoom has a console very similar to Quake's. Almost all game settings and
-controls can be accessed from it. For a complete list of console commands
-and cvars, see the commands.txt file.
-
-4-1. Activating the console
----------------------------
-
-There are two ways to activate the console: From the Options menu, and with
-the toggleconsole command. The console can always be activated by selecting
-"Go to console" from the Options menu. While playing a game, pressing a key
-bound to the toggleconsole command can also activate the console. By
-default, this is the ` key, but it can be changed to any key with the bind
-command.
-
-
-4-2. Using the console
-----------------------
-
-Using the console is fairly simple. Just type in commands and press Enter
-to execute them. To scroll around in the console�s text buffer, you can use
-the Page Up and Page Down keys. Pressing Shift-Page Up scrolls to the top
-of the buffer, while pressing Shift-Page Down scrolls to the bottom.
-Without pressing Shift, these keys will scroll one line at a time in the
-corresponding direction.
-
-A handy feature of the console that was added in 1.13 is tab-completion. To
-use it, begin typing a command, and then press tab repeatedy to cycle
-through all the commands that begin with whatever you typed.
-
-To deactivate the console, you can press either ` or Escape. This will also
-erase any text you might have been typing on the command line.
-
-
-5. Key bindings
-===============
-
-ZDoom supports Quake-style controls as opposed to those of the original 
-Doom. To bind a command to a key, use the bind command followed by the key
-to bind and the command(s) to bind to it. Multiple commands should be
-separated by semicolons (;) and if there are any spaces in the commands,
-they need to all be enclosed in quotation marks (").
-
-For example, to make the Page Up key cause the player to look up, use the 
-command:
-
-bind pgup +lookup
-
-From now on, pressing Page Up will cause you to look up. Since this is also
-an action command (it begins with a '+'), releasing Page Up will also
-execute the -lookup command, which will cause you to stop looking up.
-
-You can also refer to keys by scancodes instead of names. For instance,
-
-bind #3 "echo I don't like my pistol."
-
-and
-
-bind 2 "echo I don't like my pistol."
-
-will both do the same thing, because 3 is the scancode for the "2" key.
-
-If you use key names, the keys are assumed to be arranged in a Qwerty
-layout. This may be somewhat confusing because the console uses the layout
-selected in the Keyboard control panel (which might not be Qwerty), but I
-decided to do it this way for consistancy. Thus, if you wanted to assign the
-key directly to the right of the tab key to a command, you would use
-"bind q <command>" even if that key isn't labeled Q on your keyboard.
-
-All key bindings are automatically saved in the config.cfg file when the
-game quits.
-
-The following special keys as well as the alphanumeric keys are named and
-can be bound. These are the same keys displayed in the Configure Controls
-menu:
-
-backspace
-tab
-enter
-ctrl
-shift
-kp*             * on the numeric keypad
-alt             Either the left or right Alt key
-space
-capslock
-numlock
-scroll          Scroll Lock
-kp7             7 on the numeric keypad
-kp8             8 on the numeric keypad
-kp9             9 on the numeric keypad
-kp-             - on the numeric keypad
-kp4             4 on the numeric keypad
-kp5             5 on the numeric keypad
-kp6             6 on the numeric keypad
-kp+             + on the numeric keypad
-kp1             1 on the numeric keypad
-kp2             2 on the numeric keypad
-kp3             3 on the numeric keypad
-kp0             0 on the numeric keypad
-kp.             . on the numeric keypad
-kana
-convert
-noconvert
-yen
-kp=             = on some numeric keypads
-circumflex
-kanji
-stop
-ax
-unlabeled
-kp,             , on some numeric keypads
-kp/             / on the numeric keypad
-sysrq
-home
-uparrow
-pgup
-leftarrow
-rightarrow
-end
-downarrow
-pgdn
-ins
-del
-lwin            The left Windows key
-rwin            The right Windows key
-apps            The application menu key
-pause           The pause key
-mouse1          The left mouse button
-mouse2          The right mouse button
-mouse3          The middle mouse button
-mouse4          The fourth mouse button if yours has one
-joy1 - joy32    All 32 joystick buttons supported by Windows
-mwheelup        The mouse wheel was rolled up
-mwheeldown      The mouse wheel was rolled down
-
-Note that i_remapkeypad must be "0" for kp0, kp., kp1, kp2, kp3, kp4, kp6,
-kp7, kp8, and kp9 to be treated as distinct keys.
-
-
-6. Playing a network game
-=========================
-
-Due to changes ZDoom has made to the message format of network games, you
-will definitely not be able to play a network game between ZDoom and
-another version of Doom. Since ZDoom uses the UDP protocol for networking,
-it is possible to play a game on the Internet as well as a LAN. If you want
-to try it, a good frontend to try is ZM (http://www.doomworld.com/zm).
-
-6-1. Playing a network game with the DOS version
-------------------------------------------------
-
-The information in the following sections about network games does *not*
-apply to the DOS version of ZDoom. While networking with the DOS version is
-untested, it should work just like the original DOOM: through sersetup
-or ipxsetup. If you want to try it, rename zdoomdos.exe to whatever sersetup
-or ipxsetup expects (it varies depending on which game they came with). BE
-SURE TO RENAME THE ORIGINAL DOOM.EXE, DOOM2.EXE, HERETIC.EXE, OR HEXEN.EXE
-TO SOMETHING ELSE BEFORE YOU DO THIS. Then launch a game using DM or some
-similar program. Please note that due to the size of the network packets
-used during game startup, you may experience access violations with the DOS
-version.
-
-6-2. Playing a network game the nice way
-----------------------------------------
-
-As of version 1.19, starting network games has been vastly simplified. The
-old method is retained for compatibility (see the next section), but you
-are encouraged to use this new method. Not only is the new method easier,
-but it should work with IP masquerading, providing that only the machines
-connect to the host use IP masquerading. What follows are Jeffrey Cuenco's
-instructions for using them:
-
-The syntax for these command-line parameters are as follows:
-
-To start (host) a game you simply type:
-
-    zdoom -host <x> 
-
-where x is the number of players that are going to be in the game
-(including yourself).
-
-To join a game you simply type:
-
-    zdoom -join <host ip> 
-
-where host ip is the ip address of the "host" computer.
-
-These functions simplify the netgame process by having one computer, the
-"host," accept connection requests from other computers running ZDoom.
-The host then sends back a response packet to the client, which contains
-the client's console number. When the total number of hosts connected to
-the host + the host itself equals the number of players specified in
-"-host," then the host sends a packet to all the clients connected to the
-host, containing the ip addresses of all the other computers connected to
-the host excluding the ip of the host itself and your ip (which you already
-have). When each client receives this "all here" packet, then it stores
-each address under a different index in the array that holds all the
-addresses of the client computers you're playing against. After each
-client successfully receives the "all here" packet and has already sent
-ACKs (acknowledgement packets) to the host, then the host sends a "Go"
-packet to all clients stating that it's ok to start the netgame. What
-follows this is the normal activity that you've already seen after you
-execute "-net ..."
-
-6-3. Playing a network game the old way
----------------------------------------
-
-To begin a network game, start ZDoom with the "-net" command-line
-parameter. This is *different* from the DOS version of Doom (but the same
-as the Linux version). The -net parameter takes the form:
-
-    -net <console> [machine1] [machine2] ...
-
-<console> is the player number that your machine is playing as (1 to 8)
-and is followed by the addresses of the other machines in the network game.
-These addresses can be either IP addresses like 192.168.0.1 or hostnames
-like some.machine.com. To specify an alternate port to connect to on the
-other machines, append a colon to the address and follow it with the port
-number you wish to use (i.e. some.machine.com:26000).
-
-The number of players in a netgame is determined by the number of machines
-after <console> in the -net parameter. For a two-player game, you would
-only list one other machine. For a four-player game, you would list three.
-
-Each player must choose a different console number. One person *must* be
-console 1, and there can be no gaps between console numbers. For instance,
-in a two-player game it's okay for one player to be console 1 and the other
-to be console 2, but it's not okay if one player is console 1 and the other
-is console 4.
-
-An example for a two-player game:
-
-    One machine named joe runs:         zdoom -net 1 bob -deathmatch
-    The other machine named bob runs:   zdoom -net 2 joe -deathmatch
-
-It's also possible to start a network game on your own machine if you run
-ZDoom in a window with the -nomusic and -noidle parameters:
-
-    Start the first copy of zdoom:
-        zdoom -net 1 localhost:26000 -port 26001 -noidle -nomusic
-
-    Then start the second copy:
-        zdoom -net 2 localhost:26001 -port 26000 -noidle -nomusic
-
-This works much nicer under Windows NT than it does under 95/98.
-
-6-4. Configuring ICQ to launch an Internet game
------------------------------------------------
-
-I don't personally recommend using ZDoom on the Internet (and have never
-tried it), but if you want to give it a try, it's just like setting it up
-for a LAN game. You might also want to try specifying the -extratic and
--dup 2 parameters to help compensate for the latency the Internet
-introduces. Doomworld's Linguica has also provided instructions for setting
-up ICQ to launch a game of ZDoom:
-
-    With a little tweaking I was able to successfully configure the nearly
-    ubiquitous program ICQ to launch ZDoom games with literally the click of
-    a button. Here's how: Go into the "Preferences" menu in ICQ and then
-    "Internet Phone/Games/Chat." Then click on "New External." You'll be
-    given a box with three empty lines to fill in. In the first line, type
-    in the title of the application, i.e. "ZDoom." In the second line, type
-    in the path to your zdoom.exe -- "C:\DOOM2\zdoom.exe" or whatever. In
-    the third line, type in the following: "-net 2 %i -extratic -dup 2
-    -deathmatch -nomonsters -skill 5 -warp 01 -nomusic" which will configure
-    ZDoom to DM on Map01 with the optimum TCP/IP deathmatch settings. Then
-    click on the "Client/Server Application" button. This will bring up two
-    additional lines to fill in. In the fourth line, type the same thing as
-    in line 2: "C:\DOOM2\zdoom.exe" or whatever. In the fifth line, type
-    "-net 1 %i -extratic -dup 2 -deathmatch -nomonsters -skill 5 -warp 01
-    -nomusic" which once again configures ZDoom for optimum Internet play.
-    It's exactly the same as line 3 except it has "-net 1" instead of
-    "-net 2." Once all this is typed in, press OK. Then, if you want to DM a
-    friend who has similarly enabled his ICQ, simply click on their name,
-    click on "Internet Phone/Games," and then on "ZDoom." And away you go!
-
-6-5. Playing with a modem/serial/parallel cable connection
-----------------------------------------------------------
-
-ZDoom only supports UDP games. However, using Microsoft's Dial-Up Networking
-(included with Windows 95/98/NT), it should be possible to also play a game
-on two computers connected with modems or null-modem serial or parallel
-cables. My only network connection is my Ethernet card, so I haven't
-actually tried this, but I can't see any reason why it shouldn't work.
-
-If you're running Windows 95, go download Dial-Up Networking 1.3 from
-http://www.microsoft.com/windows95/downloads/contents/wurecommended/s_wunetworking/dun13win95/default.asp
-and install it.
-
-If you're running Windows 98, open the "Add/Remove Programs" control panel
-and click the Windows Setup tab. Choose "Communications" from the components
-list and click "Details..." If there isn't a check by "Dial-Up Networking"
-and "Dial-Up Server," check them and click OK. Click OK again to close the
-control panel.
-
-Now go visit http://www.geocities.com/TimesSquare/Fortress/4004/guide.html
-and start reading the section entitled "Configuring the Dial-Up-Server." Once
-you have everything set up, start a game using the instructions for starting
-a LAN game above.
-
-If you want to use two computers connected directly using a parallel or
-serial cable, you also have to use Microsoft's Direct Cable Connection.
-
-
-7. Known Bugs
-=============
-
-* When played in a window on Windows NT, the mouse can sometimes go crazy.
-  You can get around this by pausing and unpausing the game several times
-  or Alt-Tabbing out of ZDoom and back into it. Alternatively, you can also
-  set the in_mouse cvar to "2" to force ZDoom to use DirectInput to read
-  the mouse, but this may make the mouse very jerky while using the keyboard
-  at the same time.
-* Some machines were incapable of running version 1.13 and died inside of
-  I_StartGraphics. I have been unable to reproduce this on my machine and
-  could find nothing wrong with the code, so my best guess is that it's a
-  driver problem (if it still happens).
-* I've had reports that ZDoom will rearrange the icons on the desktop after
-  quitting the game in fullscreen. I have not had this happen to me, but it
-  appears to be a DirectDraw problem.
-
-If you find another bug with ZDoom, first try and duplicate it. If you
-can't duplicate it, it's probably either a problem with your system or 
-omething that I won't be able to fix unless I stumble on it. (I actually
-did find an obscure bug this way!) If you can duplicate the problem, run
-the game in a window, and send me the contents of the dialog box that pops
-up when it dies. If you have Drwatson (found in the \windows\system
-directory of Windows 95B and 98), also run that beforehand and send me a
-copy of the log file it generates (provided that it's not too large). Also
-describe what you were doing when the problem occured and list any PWADs or
-DeHackEd patches you were using at the time.
-
-
-8. Acknowledgments
-==================
-(in no particular order)
-
-id Software /  These are the people who developed Doom and later released
-John           the source code for the Linux port. Without them, there
-Carmack        would be no ZDoom. I have also used some of the functions
-               from their Quake2 game DLL source.
-
-Bernd          Packaged up id's Linux code for the initial source release.
-Kreimeier
-
-Raven          Portions of Heretic and Hexen were used in ZDoom.
-Software
-
-Chi Hoang      Responsible in one way or another for BOOM. It provided a
-Team TNT       significant codebase for ZDoom. Information about BOOM can
-               be found at the Team TNT website:
-               http://www.teamtnt.com/boompubl/ixboom.htm
-
-Lee Killough   For all his brilliant work on both BOOM and later MBF.
-               Portions of MBF were used in ZDoom, primarily to fix BOOM
-               bugs.
-
-Yoghurt        Creator of the Cajun Bot. http://www.doomworld.com/doombot/
-
-Sebastien      Created qmus2mid which I used to determine the structure of
-Bacquet        DOOM's MUS lumps so that the game would have music.
-
-Andy Bay       Original input code is from his (discontinued) ATB Doom port.
-
-Peterri        Original sound code and some assembly is from his
-Kangaslampi    (discontineud) NTDOOM port. He was also the person primarily
-               responsible for writing the MIDAS Digital Audio System
-               1.1.2, which is used for all sound effects and MOD music.
-               It is copyright 1996,1997 Housemarque Inc. It can be found
-               at http://www.s2.org/midas/.
-
-Glenn "Gaffer" Developed the Prometheus Truecolor library. OpenPTC was used
-Fiedler        for the latest version of ZDoom, and older versions of PTC
-               were used for older versions of ZDoom. Its homepage is at
-               http://www.gaffer.org/ptc/.
-
-Markus         Wrote the miniLZO library, which ZDoom uses for data
-F.X.J.         compression. Its webpage is at
-Oberhummer     http://wildsau.idv.uni-linz.ac.at/mfx/lzo.html
-
-Greg Lewis     Released his DeHackEd source, without which adding
-               DeHackEd support would have been much harder.
-
diff --git a/output_sdl/CMakeLists.txt b/output_sdl/CMakeLists.txt
deleted file mode 100644
index 323d941494..0000000000
--- a/output_sdl/CMakeLists.txt
+++ /dev/null
@@ -1,17 +0,0 @@
-cmake_minimum_required( VERSION 2.8.7 )
-if( NOT NO_FMOD AND FMOD_INCLUDE_DIR )
-	include_directories( ${FMOD_INCLUDE_DIR} ${SDL2_INCLUDE_DIR} )
-	check_library_exists(${FMOD_LIBRARY} "FMOD_System_GetDriverCaps" "fmod.h" FMOD_IS_EX)
-
-	# Only usable with FMOD Ex
-	if( FMOD_IS_EX )
-		include_directories( ${FMOD_INCLUDE_DIR} ${SDL2_INCLUDE_DIR} )
-		add_library( output_sdl MODULE output_sdl.c )
-		target_link_libraries( output_sdl ${SDL2_LIBRARY} )
-
-		FILE( WRITE ${CMAKE_CURRENT_BINARY_DIR}/link-make "if [ ! -e ${ZDOOM_OUTPUT_DIR}/liboutput_sdl.so ]; then ln -sf output_sdl/liboutput_sdl.so ${ZDOOM_OUTPUT_DIR}/liboutput_sdl.so; fi" )
-		add_custom_command( TARGET output_sdl POST_BUILD
-			COMMAND chmod +x ${CMAKE_CURRENT_BINARY_DIR}/link-make
-			COMMAND /bin/sh -c ${CMAKE_CURRENT_BINARY_DIR}/link-make )
-	endif()
-endif()
diff --git a/output_sdl/output_sdl.c b/output_sdl/output_sdl.c
deleted file mode 100644
index e56143128d..0000000000
--- a/output_sdl/output_sdl.c
+++ /dev/null
@@ -1,215 +0,0 @@
-#include <stdio.h>
-#include "fmod.h"
-#include "fmod_output.h"
-#include "SDL.h"
-
-#define CONVERTBUFFER_SIZE 	4096	// in bytes
-
-#define D(x)
-
-#define FALSE 	0
-#define TRUE 	1
-
-typedef int BOOL;
-
-struct AudioData
-{
-	FMOD_OUTPUT_STATE *Output;
-	BOOL ConvertU8toS8;
-	BOOL ConvertU16toS16;
-	int BytesPerSample;
-};
-
-FMOD_SOUND_FORMAT Format_SDLtoFMOD(Uint16 format)
-{
-	if ((format & (AUDIO_U8 | AUDIO_U16LSB)) == AUDIO_U8)
-	{
-		return FMOD_SOUND_FORMAT_PCM8;
-	}
-	return FMOD_SOUND_FORMAT_PCM16;
-}
-
-Uint16 Format_FMODtoSDL(FMOD_SOUND_FORMAT format)
-{
-	switch (format)
-	{
-	case FMOD_SOUND_FORMAT_PCM8:	return AUDIO_S8;
-	case FMOD_SOUND_FORMAT_PCM16:	return AUDIO_S16SYS;
-	default: 						return AUDIO_S16SYS;
-	}
-}
-
-static void SDLCALL AudioCallback(void *userdata, Uint8 *stream, int len)
-{
-	struct AudioData *data = (struct AudioData *)userdata;
-	int i;
-
-	data->Output->readfrommixer(data->Output, stream, len / data->BytesPerSample);
-	
-	if (data->ConvertU8toS8)
-	{
-		for (i = 0; i < len; ++i)
-		{
-			stream[i] -= 0x80;
-		}
-	}
-	else if (data->ConvertU16toS16)
-	{
-		len /= 2;
-		for (i = 0; i < len; ++i)
-		{
-			((short *)stream)[i] -= 0x8000;
-		}
-	}
-}
-
-static FMOD_RESULT F_CALLBACK GetNumDrivers(FMOD_OUTPUT_STATE *output_state, int *numdrivers)
-{
-	if (numdrivers == NULL)
-	{
-		return FMOD_ERR_INVALID_PARAM;
-	}
-	*numdrivers = 1;
-	return FMOD_OK;
-}
-
-static FMOD_RESULT F_CALLBACK GetDriverName(FMOD_OUTPUT_STATE *output_state, int id, char *name, int namelen)
-{
-	if (id != 0 || name == NULL)
-	{
-		return FMOD_ERR_INVALID_PARAM;
-	}
-	strncpy(name, "SDL default", namelen);
-	return FMOD_OK;
-}
-
-static FMOD_RESULT F_CALLBACK GetDriverCaps(FMOD_OUTPUT_STATE *output_state, int id, FMOD_CAPS *caps)
-{
-	if (id != 0 || caps == NULL)
-	{
-		return FMOD_ERR_INVALID_PARAM;
-	}
-	*caps = FMOD_CAPS_OUTPUT_FORMAT_PCM8 | FMOD_CAPS_OUTPUT_FORMAT_PCM16 | FMOD_CAPS_OUTPUT_MULTICHANNEL;
-	return FMOD_OK;
-}
-
-static FMOD_RESULT F_CALLBACK Init(FMOD_OUTPUT_STATE *output_state, int selecteddriver,
-	FMOD_INITFLAGS flags, int *outputrate, int outputchannels,
-	FMOD_SOUND_FORMAT *outputformat, int dspbufferlength, int dspnumbuffers,
-	void *extradriverdata)
-{
-	SDL_AudioSpec desired, obtained;
-	struct AudioData *data;
-	
-	if (selecteddriver != 0 || outputrate == NULL || outputformat == NULL)
-	{
-		D(printf("invalid param\n"));
-		return FMOD_ERR_INVALID_PARAM;
-	}
-	if (SDL_InitSubSystem(SDL_INIT_AUDIO) < 0)
-	{
-		D(printf("init subsystem failed\n"));
-		return FMOD_ERR_OUTPUT_INIT;
-	}
-	data = malloc(sizeof(*data));
-	if (data == NULL)
-	{
-		D(printf("nomem\n"));
-		SDL_QuitSubSystem(SDL_INIT_AUDIO);
-		return FMOD_ERR_MEMORY;
-	}
-	desired.freq = *outputrate;
-	desired.format = Format_FMODtoSDL(*outputformat);
-	desired.channels = outputchannels;
-	desired.samples = dspbufferlength;
-	desired.callback = AudioCallback;
-	desired.userdata = data;
-	if (SDL_OpenAudio(&desired, &obtained) < 0)
-	{
-		D(printf("openaudio failed\n"));
-		free(data);
-		SDL_QuitSubSystem(SDL_INIT_AUDIO);
-		return FMOD_ERR_OUTPUT_INIT;
-	}
-	if (obtained.channels != outputchannels)
-	{ // Obtained channels don't match what we wanted.
-		SDL_CloseAudio();
-		SDL_QuitSubSystem(SDL_INIT_AUDIO);
-		free(data);
-		return FMOD_ERR_OUTPUT_CREATEBUFFER;
-	}
-	data->Output = output_state;
-	data->ConvertU8toS8 = FALSE;
-	data->ConvertU16toS16 = FALSE;
-	if (obtained.format == AUDIO_U8)
-	{
-		data->ConvertU8toS8 = TRUE;
-		D(printf("convert u8 to s8\n"));
-	}
-	else if (obtained.format == AUDIO_U16SYS)
-	{
-		data->ConvertU16toS16 = TRUE;
-		D(printf("convert u16 to s16\n"));
-	}
-	output_state->plugindata = data;
-	*outputrate = obtained.freq;
-	*outputformat = Format_SDLtoFMOD(obtained.format);
-	data->BytesPerSample = *outputformat == FMOD_SOUND_FORMAT_PCM16 ? 2 : 1;
-	data->BytesPerSample *= desired.channels;
-	D(printf("init ok\n"));
-	SDL_PauseAudio(0);
-	return FMOD_OK;
-}
-
-static FMOD_RESULT F_CALLBACK Close(FMOD_OUTPUT_STATE *output_state)
-{
-	struct AudioData *data = (struct AudioData *)output_state->plugindata;
-	
-	D(printf("Close\n"));
-	if (data != NULL)
-	{
-		SDL_CloseAudio();
-		SDL_QuitSubSystem(SDL_INIT_AUDIO);
-		free(data);
-	}
-	return FMOD_OK;
-}
-
-static FMOD_RESULT F_CALLBACK Update(FMOD_OUTPUT_STATE *update)
-{
-	return FMOD_OK;
-}
-
-static FMOD_RESULT F_CALLBACK GetHandle(FMOD_OUTPUT_STATE *output_state, void **handle)
-{
-	D(printf("Gethandle\n"));
-	// SDL's audio isn't multi-instanced, so this is pretty meaningless
-	if (handle == NULL)
-	{
-		return FMOD_ERR_INVALID_PARAM;
-	}
-	*handle = output_state->plugindata;
-	return FMOD_OK;
-}
-
-static FMOD_OUTPUT_DESCRIPTION Desc =
-{
-	"SDL Output",		// name
-	1,					// version
-	0,					// polling
-	GetNumDrivers,
-	GetDriverName,
-	GetDriverCaps,
-	Init,
-	Close,
-	Update,
-	GetHandle,
-	NULL,				// getposition
-	NULL,				// lock
-	NULL				// unlock
-};
-
-F_DECLSPEC F_DLLEXPORT FMOD_OUTPUT_DESCRIPTION * F_API FMODGetOutputDescription()
-{
-	return &Desc;
-}

From b68741b17f4a8ae304550dc3facf21a560108674 Mon Sep 17 00:00:00 2001
From: Christoph Oelckers <coelckers@users.noreply.github.com>
Date: Mon, 17 Apr 2017 10:31:25 +0200
Subject: [PATCH 18/29] - removed the special conditions of the FraggleScript
 license, now that they are no longer needed. Also relicensed the two original
 files under the GPL for consistency.

---
 src/fragglescript/t_cmd.cpp      | 64 +++++++++++++-------------------
 src/fragglescript/t_func.cpp     | 13 -------
 src/fragglescript/t_load.cpp     | 57 ++++++++++++----------------
 src/fragglescript/t_oper.cpp     | 13 -------
 src/fragglescript/t_parse.cpp    | 13 -------
 src/fragglescript/t_prepro.cpp   | 13 -------
 src/fragglescript/t_script.cpp   | 13 -------
 src/fragglescript/t_script.h     | 13 -------
 src/fragglescript/t_spec.cpp     | 13 -------
 src/fragglescript/t_variable.cpp | 13 -------
 10 files changed, 50 insertions(+), 175 deletions(-)

diff --git a/src/fragglescript/t_cmd.cpp b/src/fragglescript/t_cmd.cpp
index db3fcd0338..0fbb5a146f 100644
--- a/src/fragglescript/t_cmd.cpp
+++ b/src/fragglescript/t_cmd.cpp
@@ -1,41 +1,29 @@
-/*
-** t_cmd.cpp
-** Emulation for selected Legacy console commands
-** Unfortunately Legacy allows full access of FS to the console
-** so everything that gets used by some map has to be emulated...
-**
-**---------------------------------------------------------------------------
-** Copyright 2005 Christoph Oelckers
-** All rights reserved.
-**
-** Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions
-** are met:
-**
-** 1. Redistributions of source code must retain the above copyright
-**    notice, this list of conditions and the following disclaimer.
-** 2. Redistributions in binary form must reproduce the above copyright
-**    notice, this list of conditions and the following disclaimer in the
-**    documentation and/or other materials provided with the distribution.
-** 3. The name of the author may not be used to endorse or promote products
-**    derived from this software without specific prior written permission.
-**
-** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
-** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-**---------------------------------------------------------------------------
-**
-*/
-
-
-
+//---------------------------------------------------------------------------
+//
+// Copyright(C) 2005-2017 Christoph Oelckers
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 3 of the License, or
+// (at your option) any later version.
+// 
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+// 
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+//
+//--------------------------------------------------------------------------
+//
+// Emulation for selected Legacy console commands
+// Unfortunately Legacy allows full access of FS to the console
+// so everything that gets used by some map has to be emulated...
+//
+//---------------------------------------------------------------------------
+//
 
 
 #include <string.h>
diff --git a/src/fragglescript/t_func.cpp b/src/fragglescript/t_func.cpp
index 181d20d30d..90c8fbe5a5 100644
--- a/src/fragglescript/t_func.cpp
+++ b/src/fragglescript/t_func.cpp
@@ -33,19 +33,6 @@
 //
 //---------------------------------------------------------------------------
 //
-// FraggleScript is from SMMU which is under the GPL. Technically, 
-// therefore, combining the FraggleScript code with the non-free 
-// ZDoom code is a violation of the GPL.
-//
-// As this may be a problem for you, I hereby grant an exception to my 
-// copyright on the SMMU source (including FraggleScript). You may use 
-// any code from SMMU in (G)ZDoom, provided that:
-//
-//    * For any binary release of the port, the source code is also made 
-//      available.
-//    * The copyright notice is kept on any file containing my code.
-//
-//
 
 #include "templates.h"
 #include "p_local.h"
diff --git a/src/fragglescript/t_load.cpp b/src/fragglescript/t_load.cpp
index e277354251..3fca69aadc 100644
--- a/src/fragglescript/t_load.cpp
+++ b/src/fragglescript/t_load.cpp
@@ -1,36 +1,27 @@
-/*
-** t_load.cpp
-** FraggleScript loader
-**
-**---------------------------------------------------------------------------
-** Copyright 2002-2005 Christoph Oelckers
-** All rights reserved.
-**
-** Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions
-** are met:
-**
-** 1. Redistributions of source code must retain the above copyright
-**    notice, this list of conditions and the following disclaimer.
-** 2. Redistributions in binary form must reproduce the above copyright
-**    notice, this list of conditions and the following disclaimer in the
-**    documentation and/or other materials provided with the distribution.
-** 3. The name of the author may not be used to endorse or promote products
-**    derived from this software without specific prior written permission.
-**
-** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
-** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-**---------------------------------------------------------------------------
-**
-*/
+//---------------------------------------------------------------------------
+//
+// Copyright(C) 2002-2017 Christoph Oelckers
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 3 of the License, or
+// (at your option) any later version.
+// 
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+// 
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+//
+//--------------------------------------------------------------------------
+//
+// FraggleScript loader
+//
+//---------------------------------------------------------------------------
+//
 
 
 #include "w_wad.h"
diff --git a/src/fragglescript/t_oper.cpp b/src/fragglescript/t_oper.cpp
index f25f719e79..761a0d22e5 100644
--- a/src/fragglescript/t_oper.cpp
+++ b/src/fragglescript/t_oper.cpp
@@ -28,19 +28,6 @@
 //
 //---------------------------------------------------------------------------
 //
-// FraggleScript is from SMMU which is under the GPL. Technically, 
-// therefore, combining the FraggleScript code with the non-free 
-// ZDoom code is a violation of the GPL.
-//
-// As this may be a problem for you, I hereby grant an exception to my 
-// copyright on the SMMU source (including FraggleScript). You may use 
-// any code from SMMU in (G)ZDoom, provided that:
-//
-//    * For any binary release of the port, the source code is also made 
-//      available.
-//    * The copyright notice is kept on any file containing my code.
-//
-//
 
 /* includes ************************/
 #include "t_script.h"
diff --git a/src/fragglescript/t_parse.cpp b/src/fragglescript/t_parse.cpp
index 28330e9e98..6b9af07732 100644
--- a/src/fragglescript/t_parse.cpp
+++ b/src/fragglescript/t_parse.cpp
@@ -29,19 +29,6 @@
 //
 //---------------------------------------------------------------------------
 //
-// FraggleScript is from SMMU which is under the GPL. Technically, 
-// therefore, combining the FraggleScript code with the non-free 
-// ZDoom code is a violation of the GPL.
-//
-// As this may be a problem for you, I hereby grant an exception to my 
-// copyright on the SMMU source (including FraggleScript). You may use 
-// any code from SMMU in (G)ZDoom, provided that:
-//
-//    * For any binary release of the port, the source code is also made 
-//      available.
-//    * The copyright notice is kept on any file containing my code.
-//
-//
 
 /* includes ************************/
 #include <stdarg.h>
diff --git a/src/fragglescript/t_prepro.cpp b/src/fragglescript/t_prepro.cpp
index c770e94af6..4b00a3177d 100644
--- a/src/fragglescript/t_prepro.cpp
+++ b/src/fragglescript/t_prepro.cpp
@@ -37,19 +37,6 @@
 //
 //---------------------------------------------------------------------------
 //
-// FraggleScript is from SMMU which is under the GPL. Technically, 
-// therefore, combining the FraggleScript code with the non-free 
-// ZDoom code is a violation of the GPL.
-//
-// As this may be a problem for you, I hereby grant an exception to my 
-// copyright on the SMMU source (including FraggleScript). You may use 
-// any code from SMMU in (G)ZDoom, provided that:
-//
-//    * For any binary release of the port, the source code is also made 
-//      available.
-//    * The copyright notice is kept on any file containing my code.
-//
-//
 
 /* includes ************************/
 
diff --git a/src/fragglescript/t_script.cpp b/src/fragglescript/t_script.cpp
index 47447d9888..3c62d4d3a8 100644
--- a/src/fragglescript/t_script.cpp
+++ b/src/fragglescript/t_script.cpp
@@ -31,19 +31,6 @@
 //
 //---------------------------------------------------------------------------
 //
-// FraggleScript is from SMMU which is under the GPL. Technically, 
-// therefore, combining the FraggleScript code with the non-free 
-// ZDoom code is a violation of the GPL.
-//
-// As this may be a problem for you, I hereby grant an exception to my 
-// copyright on the SMMU source (including FraggleScript). You may use 
-// any code from SMMU in (G)ZDoom, provided that:
-//
-//    * For any binary release of the port, the source code is also made 
-//      available.
-//    * The copyright notice is kept on any file containing my code.
-//
-//
 
 #include "t_script.h"
 #include "p_lnspec.h"
diff --git a/src/fragglescript/t_script.h b/src/fragglescript/t_script.h
index 11977f9d2f..80751003cb 100644
--- a/src/fragglescript/t_script.h
+++ b/src/fragglescript/t_script.h
@@ -20,19 +20,6 @@
 //
 //---------------------------------------------------------------------------
 //
-// FraggleScript is from SMMU which is under the GPL. Technically, 
-// therefore, combining the FraggleScript code with the non-free 
-// ZDoom code is a violation of the GPL.
-//
-// As this may be a problem for you, I hereby grant an exception to my 
-// copyright on the SMMU source (including FraggleScript). You may use 
-// any code from SMMU in (G)ZDoom, provided that:
-//
-//    * For any binary release of the port, the source code is also made 
-//      available.
-//    * The copyright notice is kept on any file containing my code.
-//
-//
 
 #ifndef __T_SCRIPT_H__
 #define __T_SCRIPT_H__
diff --git a/src/fragglescript/t_spec.cpp b/src/fragglescript/t_spec.cpp
index 7703398ed9..61cab3cb6e 100644
--- a/src/fragglescript/t_spec.cpp
+++ b/src/fragglescript/t_spec.cpp
@@ -27,19 +27,6 @@
 //
 //---------------------------------------------------------------------------
 //
-// FraggleScript is from SMMU which is under the GPL. Technically, 
-// therefore, combining the FraggleScript code with the non-free 
-// ZDoom code is a violation of the GPL.
-//
-// As this may be a problem for you, I hereby grant an exception to my 
-// copyright on the SMMU source (including FraggleScript). You may use 
-// any code from SMMU in (G)ZDoom, provided that:
-//
-//    * For any binary release of the port, the source code is also made 
-//      available.
-//    * The copyright notice is kept on any file containing my code.
-//
-//
 
 #include "t_script.h"
 
diff --git a/src/fragglescript/t_variable.cpp b/src/fragglescript/t_variable.cpp
index d0a0c8b9fc..47735d26f0 100644
--- a/src/fragglescript/t_variable.cpp
+++ b/src/fragglescript/t_variable.cpp
@@ -38,19 +38,6 @@
 //
 //---------------------------------------------------------------------------
 //
-// FraggleScript is from SMMU which is under the GPL. Technically, 
-// therefore, combining the FraggleScript code with the non-free 
-// ZDoom code is a violation of the GPL.
-//
-// As this may be a problem for you, I hereby grant an exception to my 
-// copyright on the SMMU source (including FraggleScript). You may use 
-// any code from SMMU in (G)ZDoom, provided that:
-//
-//    * For any binary release of the port, the source code is also made 
-//      available.
-//    * The copyright notice is kept on any file containing my code.
-//
-//
 
 #include "t_script.h"
 #include "a_pickups.h"

From 57d703236bf19f1a6d8e7e6aa005ef0c393f7d6a Mon Sep 17 00:00:00 2001
From: Christoph Oelckers <coelckers@users.noreply.github.com>
Date: Mon, 17 Apr 2017 12:27:19 +0200
Subject: [PATCH 19/29] - changed Doom source license to GPL in all
 subdirectories and fixed missing licenses in a few other files.

---
 src/g_inventory/a_pickups.cpp                 | 35 ++++++++++++
 src/g_shared/a_action.cpp                     | 23 ++++++++
 src/g_shared/a_flashfader.cpp                 | 34 +++++++++++
 src/g_shared/a_lightning.cpp                  | 24 ++++++++
 src/g_shared/a_morph.cpp                      | 23 ++++++++
 src/g_shared/a_quake.cpp                      | 24 ++++++++
 src/p_enemy.cpp                               | 27 +++++----
 src/posix/cocoa/i_main_except.cpp             | 32 +++++++++++
 src/posix/i_system.h                          | 24 ++++----
 src/posix/sdl/critsec.cpp                     | 38 ++++++++++++-
 src/posix/sdl/i_gui.cpp                       | 34 ++++++++++-
 src/posix/sdl/i_input.cpp                     | 32 +++++++++++
 src/posix/sdl/i_joystick.cpp                  | 32 +++++++++++
 src/posix/sdl/i_system.cpp                    | 25 ++++----
 src/posix/sdl/i_timer.cpp                     | 32 +++++++++++
 src/posix/sdl/sdlglvideo.cpp                  | 32 +++++++++++
 src/posix/sdl/sdlvideo.cpp                    | 32 +++++++++++
 src/posix/unix/iwadpicker_gtk.cpp             | 33 +++++++++++
 src/r_data/sprites.cpp                        | 22 +++++++
 src/resourcefiles/ancientzip.cpp              | 32 +++++++++++
 src/scripting/backend/scopebarrier.cpp        | 33 +++++++++++
 src/scripting/backend/vmbuilder.cpp           |  1 +
 src/scripting/thingdef.h                      | 41 +++++++++++++
 src/scripting/vm/vm.h                         | 35 ++++++++++++
 src/scripting/vm/vmexec.h                     | 35 ++++++++++++
 src/scripting/zscript/zcc-parse.lemon         | 37 ++++++++++++
 src/sound/mpg123_decoder.cpp                  | 32 +++++++++++
 src/sound/music_midi_base.cpp                 | 33 +++++++++++
 src/sound/musicformats/music_cd.cpp           | 33 +++++++++++
 src/sound/oplsynth/musicblock.cpp             | 27 +++++++++
 src/sound/oplsynth/opl_mus_player.cpp         | 33 +++++++++++
 src/sound/oplsynth/oplio.cpp                  | 56 ++++++++----------
 src/sound/sndfile_decoder.cpp                 | 32 +++++++++++
 src/swrenderer/drawers/r_draw_rgba.cpp        | 57 +++++++++++--------
 src/swrenderer/line/r_fogboundary.cpp         | 23 +++++---
 src/swrenderer/line/r_fogboundary.h           | 23 +++++---
 src/swrenderer/line/r_line.cpp                | 23 +++++---
 src/swrenderer/line/r_line.h                  | 23 +++++---
 src/swrenderer/line/r_renderdrawsegment.cpp   | 23 +++++---
 src/swrenderer/line/r_renderdrawsegment.h     | 23 +++++---
 src/swrenderer/line/r_walldraw.cpp            | 23 +++++---
 src/swrenderer/line/r_walldraw.h              | 23 +++++---
 src/swrenderer/line/r_wallsetup.cpp           | 21 +++++++
 src/swrenderer/line/r_wallsetup.h             | 22 +++++++
 src/swrenderer/plane/r_flatplane.cpp          | 23 +++++---
 src/swrenderer/plane/r_flatplane.h            | 23 +++++---
 src/swrenderer/plane/r_planerenderer.cpp      | 23 +++++---
 src/swrenderer/plane/r_planerenderer.h        | 23 +++++---
 src/swrenderer/plane/r_skyplane.cpp           | 23 +++++---
 src/swrenderer/plane/r_skyplane.h             | 23 +++++---
 src/swrenderer/plane/r_slopeplane.cpp         | 23 +++++---
 src/swrenderer/plane/r_slopeplane.h           | 23 +++++---
 src/swrenderer/plane/r_visibleplane.cpp       | 23 +++++---
 src/swrenderer/plane/r_visibleplane.h         | 23 +++++---
 src/swrenderer/plane/r_visibleplanelist.cpp   | 23 +++++---
 src/swrenderer/plane/r_visibleplanelist.h     | 23 +++++---
 src/swrenderer/r_memory.cpp                   | 21 ++++---
 src/swrenderer/r_memory.h                     | 13 -----
 src/swrenderer/scene/r_3dfloors.cpp           | 29 +++++++++-
 src/swrenderer/scene/r_light.cpp              | 23 +++++---
 src/swrenderer/scene/r_light.h                | 22 ++++---
 src/swrenderer/scene/r_opaque_pass.cpp        | 26 +++++----
 src/swrenderer/scene/r_opaque_pass.h          | 22 ++++---
 src/swrenderer/scene/r_portal.cpp             | 24 +++++---
 src/swrenderer/scene/r_portal.h               | 22 ++++---
 src/swrenderer/scene/r_scene.cpp              | 22 ++++---
 src/swrenderer/scene/r_scene.h                | 22 ++++---
 src/swrenderer/scene/r_translucent_pass.cpp   | 22 ++++---
 src/swrenderer/scene/r_translucent_pass.h     | 22 ++++---
 src/swrenderer/segments/r_clipsegment.cpp     | 22 ++++---
 src/swrenderer/segments/r_clipsegment.h       | 22 ++++---
 src/swrenderer/segments/r_drawsegment.cpp     | 22 ++++---
 src/swrenderer/segments/r_drawsegment.h       | 22 ++++---
 src/swrenderer/segments/r_portalsegment.cpp   | 22 ++++---
 src/swrenderer/segments/r_portalsegment.h     | 22 ++++---
 src/swrenderer/things/r_decal.cpp             | 22 ++++---
 src/swrenderer/things/r_decal.h               | 13 -----
 src/swrenderer/things/r_particle.cpp          | 22 ++++---
 src/swrenderer/things/r_particle.h            | 13 -----
 src/swrenderer/things/r_playersprite.cpp      | 22 ++++---
 src/swrenderer/things/r_playersprite.h        | 22 ++++---
 src/swrenderer/things/r_sprite.cpp            | 22 ++++---
 src/swrenderer/things/r_sprite.h              | 13 -----
 src/swrenderer/things/r_visiblesprite.cpp     | 22 ++++---
 src/swrenderer/things/r_visiblesprite.h       | 22 ++++---
 src/swrenderer/things/r_visiblespritelist.cpp | 22 ++++---
 src/swrenderer/things/r_visiblespritelist.h   | 13 -----
 src/swrenderer/things/r_voxel.cpp             | 23 +++++++-
 src/swrenderer/things/r_voxel.h               |  1 -
 src/swrenderer/things/r_wallsprite.cpp        | 22 ++++---
 src/swrenderer/things/r_wallsprite.h          | 13 -----
 src/swrenderer/viewport/r_drawerargs.cpp      | 22 ++++---
 src/swrenderer/viewport/r_skydrawer.cpp       | 22 ++++---
 src/swrenderer/viewport/r_spandrawer.cpp      | 22 ++++---
 src/swrenderer/viewport/r_viewport.cpp        | 22 ++++---
 src/swrenderer/viewport/r_walldrawer.cpp      | 22 ++++---
 src/textures/textures.h                       | 34 +++++++++++
 src/textures/warpbuffer.h                     | 34 +++++++++++
 src/win32/critsec.cpp                         | 32 +++++++++++
 src/win32/eaxedit.cpp                         | 33 +++++++++++
 src/win32/i_dijoy.cpp                         | 33 +++++++++++
 src/win32/i_keyboard.cpp                      | 33 +++++++++++
 src/win32/i_mouse.cpp                         | 32 +++++++++++
 src/win32/i_rawps2.cpp                        | 33 +++++++++++
 src/win32/i_system.h                          | 25 ++++----
 src/win32/i_xinput.cpp                        | 33 +++++++++++
 src/win32/win32gliface.cpp                    | 34 +++++++++++
 src/xlat/xlat_parser.y                        | 33 +++++++++++
 108 files changed, 2239 insertions(+), 547 deletions(-)

diff --git a/src/g_inventory/a_pickups.cpp b/src/g_inventory/a_pickups.cpp
index 5d2617881f..ff98ea4219 100644
--- a/src/g_inventory/a_pickups.cpp
+++ b/src/g_inventory/a_pickups.cpp
@@ -1,3 +1,38 @@
+/*
+** a_pickups.cpp
+** Inventory base class implementation
+**
+**---------------------------------------------------------------------------
+** Copyright 2005-2016 Randy Heit
+** Copyright 2005-2016 Cheistoph Oelckers
+** All rights reserved.
+**
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions
+** are met:
+**
+** 1. Redistributions of source code must retain the above copyright
+**    notice, this list of conditions and the following disclaimer.
+** 2. Redistributions in binary form must reproduce the above copyright
+**    notice, this list of conditions and the following disclaimer in the
+**    documentation and/or other materials provided with the distribution.
+** 3. The name of the author may not be used to endorse or promote products
+**    derived from this software without specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+**---------------------------------------------------------------------------
+**
+*/
+
 #include <assert.h>
 
 #include "info.h"
diff --git a/src/g_shared/a_action.cpp b/src/g_shared/a_action.cpp
index fe4ab9d4b0..d85792b169 100644
--- a/src/g_shared/a_action.cpp
+++ b/src/g_shared/a_action.cpp
@@ -1,3 +1,26 @@
+//-----------------------------------------------------------------------------
+//
+// Copyright 1993-1996 id Software
+// Copyright 1994-1996 Raven Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2002-2016 Christoph Oelckers
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
+
+
 #include "actor.h"
 #include "p_conversation.h"
 #include "p_lnspec.h"
diff --git a/src/g_shared/a_flashfader.cpp b/src/g_shared/a_flashfader.cpp
index 504eb73084..64c4ff2184 100644
--- a/src/g_shared/a_flashfader.cpp
+++ b/src/g_shared/a_flashfader.cpp
@@ -1,3 +1,37 @@
+/*
+** a_flashfader.cpp
+** User settable screen blends
+**
+**---------------------------------------------------------------------------
+** Copyright 1998-2006 Randy Heit
+** All rights reserved.
+**
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions
+** are met:
+**
+** 1. Redistributions of source code must retain the above copyright
+**    notice, this list of conditions and the following disclaimer.
+** 2. Redistributions in binary form must reproduce the above copyright
+**    notice, this list of conditions and the following disclaimer in the
+**    documentation and/or other materials provided with the distribution.
+** 3. The name of the author may not be used to endorse or promote products
+**    derived from this software without specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+**---------------------------------------------------------------------------
+**
+*/
+
 #include "a_sharedglobal.h"
 #include "g_level.h"
 #include "d_player.h"
diff --git a/src/g_shared/a_lightning.cpp b/src/g_shared/a_lightning.cpp
index 28cdeceea9..aedcd7e6df 100644
--- a/src/g_shared/a_lightning.cpp
+++ b/src/g_shared/a_lightning.cpp
@@ -1,3 +1,27 @@
+//-----------------------------------------------------------------------------
+//
+// Copyright 1994-1996 Raven Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2002-2016 Christoph Oelckers
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
+//
+// Hexen's lightning system
+//
+
 #include "a_lightning.h"
 #include "doomstat.h"
 #include "p_lnspec.h"
diff --git a/src/g_shared/a_morph.cpp b/src/g_shared/a_morph.cpp
index 3b68e8c2ba..41c2e174d5 100644
--- a/src/g_shared/a_morph.cpp
+++ b/src/g_shared/a_morph.cpp
@@ -1,3 +1,26 @@
+//-----------------------------------------------------------------------------
+//
+// Copyright 1994-1996 Raven Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2002-2016 Christoph Oelckers
+// Copyright 2005-2008 Martin Howe
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
+//
+
 #include "info.h"
 #include "a_pickups.h"
 #include "gstrings.h"
diff --git a/src/g_shared/a_quake.cpp b/src/g_shared/a_quake.cpp
index 6c8e0f2da2..10010c3f9b 100644
--- a/src/g_shared/a_quake.cpp
+++ b/src/g_shared/a_quake.cpp
@@ -1,3 +1,27 @@
+//-----------------------------------------------------------------------------
+//
+// Copyright 1994-1996 Raven Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2002-2016 Christoph Oelckers
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
+//
+// Hexen's earthquake system, significantly enhanced
+//
+
 #include "templates.h"
 #include "doomtype.h"
 #include "doomstat.h"
diff --git a/src/p_enemy.cpp b/src/p_enemy.cpp
index 6c25bd46d7..3aefe7b9fd 100644
--- a/src/p_enemy.cpp
+++ b/src/p_enemy.cpp
@@ -1,20 +1,25 @@
-// Emacs style mode select	 -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id:$
+// Copyright 1993-1996 id Software
+// Copyright 1994-1996 Raven Software
+// Copyright 1998-1998 Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
+// Copyright 1999-2016 Randy Heit
+// Copyright 2002-2016 Christoph Oelckers
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
-//
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
 //
-// $Log:$
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 //
 // DESCRIPTION:
 //		Enemy thinking, AI.
diff --git a/src/posix/cocoa/i_main_except.cpp b/src/posix/cocoa/i_main_except.cpp
index 8a095f2a0e..5c3785588b 100644
--- a/src/posix/cocoa/i_main_except.cpp
+++ b/src/posix/cocoa/i_main_except.cpp
@@ -1,3 +1,35 @@
+/*
+ ** i_main_except.cpp
+ **
+ **---------------------------------------------------------------------------
+ ** Copyright 2012-2015 Alexey Lysiuk
+ ** All rights reserved.
+ **
+ ** Redistribution and use in source and binary forms, with or without
+ ** modification, are permitted provided that the following conditions
+ ** are met:
+ **
+ ** 1. Redistributions of source code must retain the above copyright
+ **    notice, this list of conditions and the following disclaimer.
+ ** 2. Redistributions in binary form must reproduce the above copyright
+ **    notice, this list of conditions and the following disclaimer in the
+ **    documentation and/or other materials provided with the distribution.
+ ** 3. The name of the author may not be used to endorse or promote products
+ **    derived from this software without specific prior written permission.
+ **
+ ** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ ** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ ** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ ** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ ** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ ** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ ** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ **---------------------------------------------------------------------------
+ **
+ */
 // Workaround for GCC Objective-C++ with C++ exceptions bug.
 
 #include "doomerrors.h"
diff --git a/src/posix/i_system.h b/src/posix/i_system.h
index 2110007cfd..c9b90fcb54 100644
--- a/src/posix/i_system.h
+++ b/src/posix/i_system.h
@@ -1,18 +1,22 @@
-// Emacs style mode select	 -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id:$
+// Copyright 1993-1996 id Software
+// Copyright 1999-2016 Randy Heit
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
-//
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 //
 // DESCRIPTION:
 //		System specific interface stuff.
diff --git a/src/posix/sdl/critsec.cpp b/src/posix/sdl/critsec.cpp
index 8de14c8df5..ca9a225c00 100644
--- a/src/posix/sdl/critsec.cpp
+++ b/src/posix/sdl/critsec.cpp
@@ -1,6 +1,38 @@
-// Wraps an SDL mutex object. (A critical section is a Windows synchronization
-// object similar to a mutex but optimized for access by threads belonging to
-// only one process, hence the class name.)
+/*
+** critsec.cpp
+**
+**---------------------------------------------------------------------------
+** Copyright 2006-2016 Randy Heit
+** All rights reserved.
+**
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions
+** are met:
+**
+** 1. Redistributions of source code must retain the above copyright
+**    notice, this list of conditions and the following disclaimer.
+** 2. Redistributions in binary form must reproduce the above copyright
+**    notice, this list of conditions and the following disclaimer in the
+**    documentation and/or other materials provided with the distribution.
+** 3. The name of the author may not be used to endorse or promote products
+**    derived from this software without specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+**---------------------------------------------------------------------------
+**
+** Wraps an SDL mutex object. (A critical section is a Windows synchronization
+** object similar to a mutex but optimized for access by threads belonging to
+** only one process, hence the class name.)
+*/
 
 #include "SDL.h"
 #include "SDL_thread.h"
diff --git a/src/posix/sdl/i_gui.cpp b/src/posix/sdl/i_gui.cpp
index b757ef2538..a2d89c067c 100644
--- a/src/posix/sdl/i_gui.cpp
+++ b/src/posix/sdl/i_gui.cpp
@@ -1,5 +1,35 @@
-
-// Moved from sdl/i_system.cpp
+/*
+** i_gui.cpp
+**
+**---------------------------------------------------------------------------
+** Copyright 2008 Randy Heit
+** All rights reserved.
+**
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions
+** are met:
+**
+** 1. Redistributions of source code must retain the above copyright
+**    notice, this list of conditions and the following disclaimer.
+** 2. Redistributions in binary form must reproduce the above copyright
+**    notice, this list of conditions and the following disclaimer in the
+**    documentation and/or other materials provided with the distribution.
+** 3. The name of the author may not be used to endorse or promote products
+**    derived from this software without specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+**---------------------------------------------------------------------------
+**
+*/
 
 #include <string.h>
 
diff --git a/src/posix/sdl/i_input.cpp b/src/posix/sdl/i_input.cpp
index fc705e8554..ecf93ed5d7 100644
--- a/src/posix/sdl/i_input.cpp
+++ b/src/posix/sdl/i_input.cpp
@@ -1,3 +1,35 @@
+/*
+** i_input.cpp
+**
+**---------------------------------------------------------------------------
+** Copyright 2005-2016 Randy Heit
+** All rights reserved.
+**
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions
+** are met:
+**
+** 1. Redistributions of source code must retain the above copyright
+**    notice, this list of conditions and the following disclaimer.
+** 2. Redistributions in binary form must reproduce the above copyright
+**    notice, this list of conditions and the following disclaimer in the
+**    documentation and/or other materials provided with the distribution.
+** 3. The name of the author may not be used to endorse or promote products
+**    derived from this software without specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+**---------------------------------------------------------------------------
+**
+*/
 #include <SDL.h>
 #include <ctype.h>
 #include "doomtype.h"
diff --git a/src/posix/sdl/i_joystick.cpp b/src/posix/sdl/i_joystick.cpp
index 0f1b62ac49..98e4cf7c10 100644
--- a/src/posix/sdl/i_joystick.cpp
+++ b/src/posix/sdl/i_joystick.cpp
@@ -1,3 +1,35 @@
+/*
+** i_joystick.cpp
+**
+**---------------------------------------------------------------------------
+** Copyright 2005-2016 Randy Heit
+** All rights reserved.
+**
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions
+** are met:
+**
+** 1. Redistributions of source code must retain the above copyright
+**    notice, this list of conditions and the following disclaimer.
+** 2. Redistributions in binary form must reproduce the above copyright
+**    notice, this list of conditions and the following disclaimer in the
+**    documentation and/or other materials provided with the distribution.
+** 3. The name of the author may not be used to endorse or promote products
+**    derived from this software without specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+**---------------------------------------------------------------------------
+**
+*/
 #include <SDL.h>
 
 #include "doomdef.h"
diff --git a/src/posix/sdl/i_system.cpp b/src/posix/sdl/i_system.cpp
index 01457c012f..753589819b 100644
--- a/src/posix/sdl/i_system.cpp
+++ b/src/posix/sdl/i_system.cpp
@@ -1,24 +1,23 @@
-// Emacs style mode select	 -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id:$
+// Copyright 1993-1996 id Software
+// Copyright 1999-2016 Randy Heit
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
-//
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
 //
-// $Log:$
-//
-// DESCRIPTION:
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
 //
 //-----------------------------------------------------------------------------
+//
 
 
 #include <stdlib.h>
diff --git a/src/posix/sdl/i_timer.cpp b/src/posix/sdl/i_timer.cpp
index aad0192828..04f0ed3dc6 100644
--- a/src/posix/sdl/i_timer.cpp
+++ b/src/posix/sdl/i_timer.cpp
@@ -1,3 +1,35 @@
+/*
+** i_timer.cpp
+**
+**---------------------------------------------------------------------------
+** Copyright 2005-2016 Randy Heit
+** All rights reserved.
+**
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions
+** are met:
+**
+** 1. Redistributions of source code must retain the above copyright
+**    notice, this list of conditions and the following disclaimer.
+** 2. Redistributions in binary form must reproduce the above copyright
+**    notice, this list of conditions and the following disclaimer in the
+**    documentation and/or other materials provided with the distribution.
+** 3. The name of the author may not be used to endorse or promote products
+**    derived from this software without specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+**---------------------------------------------------------------------------
+**
+*/
 
 // Moved from sdl/i_system.cpp
 
diff --git a/src/posix/sdl/sdlglvideo.cpp b/src/posix/sdl/sdlglvideo.cpp
index 196f2034b0..0aacb84541 100644
--- a/src/posix/sdl/sdlglvideo.cpp
+++ b/src/posix/sdl/sdlglvideo.cpp
@@ -1,3 +1,35 @@
+/*
+** sdlglvideo.cpp
+**
+**---------------------------------------------------------------------------
+** Copyright 2005-2016 Christoph Oelckers et.al.
+** All rights reserved.
+**
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions
+** are met:
+**
+** 1. Redistributions of source code must retain the above copyright
+**    notice, this list of conditions and the following disclaimer.
+** 2. Redistributions in binary form must reproduce the above copyright
+**    notice, this list of conditions and the following disclaimer in the
+**    documentation and/or other materials provided with the distribution.
+** 3. The name of the author may not be used to endorse or promote products
+**    derived from this software without specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+**---------------------------------------------------------------------------
+**
+*/
 
 // HEADER FILES ------------------------------------------------------------
 
diff --git a/src/posix/sdl/sdlvideo.cpp b/src/posix/sdl/sdlvideo.cpp
index 4c830fe6cf..5186b25537 100644
--- a/src/posix/sdl/sdlvideo.cpp
+++ b/src/posix/sdl/sdlvideo.cpp
@@ -1,3 +1,35 @@
+/*
+** sdlvideo.cpp
+**
+**---------------------------------------------------------------------------
+** Copyright 2005-2016 Randy Heit
+** All rights reserved.
+**
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions
+** are met:
+**
+** 1. Redistributions of source code must retain the above copyright
+**    notice, this list of conditions and the following disclaimer.
+** 2. Redistributions in binary form must reproduce the above copyright
+**    notice, this list of conditions and the following disclaimer in the
+**    documentation and/or other materials provided with the distribution.
+** 3. The name of the author may not be used to endorse or promote products
+**    derived from this software without specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+**---------------------------------------------------------------------------
+**
+*/
 
 // HEADER FILES ------------------------------------------------------------
 
diff --git a/src/posix/unix/iwadpicker_gtk.cpp b/src/posix/unix/iwadpicker_gtk.cpp
index 56228c4e8c..ebaab609f8 100644
--- a/src/posix/unix/iwadpicker_gtk.cpp
+++ b/src/posix/unix/iwadpicker_gtk.cpp
@@ -1,3 +1,36 @@
+/*
+** iwadpicker_gtk.cpp
+**
+**---------------------------------------------------------------------------
+** Copyright 2008-2016 Braden Obrzut
+** All rights reserved.
+**
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions
+** are met:
+**
+** 1. Redistributions of source code must retain the above copyright
+**    notice, this list of conditions and the following disclaimer.
+** 2. Redistributions in binary form must reproduce the above copyright
+**    notice, this list of conditions and the following disclaimer in the
+**    documentation and/or other materials provided with the distribution.
+** 3. The name of the author may not be used to endorse or promote products
+**    derived from this software without specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+**---------------------------------------------------------------------------
+**
+*/
+
 #ifndef NO_GTK
 
 #if !DYN_GTK
diff --git a/src/r_data/sprites.cpp b/src/r_data/sprites.cpp
index 17abea01e5..aab36109aa 100644
--- a/src/r_data/sprites.cpp
+++ b/src/r_data/sprites.cpp
@@ -1,3 +1,25 @@
+//-----------------------------------------------------------------------------
+//
+// Copyright 1993-1996 id Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2005-2016 Christoph Oelckers
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
+//
+
 
 #include "doomtype.h"
 #include "w_wad.h"
diff --git a/src/resourcefiles/ancientzip.cpp b/src/resourcefiles/ancientzip.cpp
index 89ae043f8a..a56d9adeb3 100644
--- a/src/resourcefiles/ancientzip.cpp
+++ b/src/resourcefiles/ancientzip.cpp
@@ -1,4 +1,36 @@
 /*
+** ancientzip.cpp
+**
+**---------------------------------------------------------------------------
+** Copyright 2010-2011 Randy Heit
+** All rights reserved.
+**
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions
+** are met:
+**
+** 1. Redistributions of source code must retain the above copyright
+**    notice, this list of conditions and the following disclaimer.
+** 2. Redistributions in binary form must reproduce the above copyright
+**    notice, this list of conditions and the following disclaimer in the
+**    documentation and/or other materials provided with the distribution.
+** 3. The name of the author may not be used to endorse or promote products
+**    derived from this software without specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+**---------------------------------------------------------------------------
+**
+** Based in information from
+**
     gunzip.c by Pasi Ojala,	a1bert@iki.fi
 				http://www.iki.fi/a1bert/
 
diff --git a/src/scripting/backend/scopebarrier.cpp b/src/scripting/backend/scopebarrier.cpp
index 4fe0f646d5..f4d584c7ba 100644
--- a/src/scripting/backend/scopebarrier.cpp
+++ b/src/scripting/backend/scopebarrier.cpp
@@ -1,3 +1,36 @@
+/*
+** scopebarrier.cpp
+**
+**---------------------------------------------------------------------------
+** Copyright 2017 ZZYZX
+** All rights reserved.
+**
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions
+** are met:
+**
+** 1. Redistributions of source code must retain the above copyright
+**    notice, this list of conditions and the following disclaimer.
+** 2. Redistributions in binary form must reproduce the above copyright
+**    notice, this list of conditions and the following disclaimer in the
+**    documentation and/or other materials provided with the distribution.
+** 3. The name of the author may not be used to endorse or promote products
+**    derived from this software without specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+**---------------------------------------------------------------------------
+**
+*/
+
 #include "dobject.h"
 #include "scopebarrier.h"
 #include "types.h"
diff --git a/src/scripting/backend/vmbuilder.cpp b/src/scripting/backend/vmbuilder.cpp
index 13f9ecb27d..131a2094bc 100644
--- a/src/scripting/backend/vmbuilder.cpp
+++ b/src/scripting/backend/vmbuilder.cpp
@@ -3,6 +3,7 @@
 **
 **---------------------------------------------------------------------------
 ** Copyright -2016 Randy Heit
+** Copyright 2016-2017 Christoph Oelckers
 ** All rights reserved.
 **
 ** Redistribution and use in source and binary forms, with or without
diff --git a/src/scripting/thingdef.h b/src/scripting/thingdef.h
index 8019a5a411..29e6487978 100644
--- a/src/scripting/thingdef.h
+++ b/src/scripting/thingdef.h
@@ -1,3 +1,44 @@
+/*
+** thingdef.h
+**
+** Actor definitions
+**
+**---------------------------------------------------------------------------
+** Copyright 2002-2008 Christoph Oelckers
+** Copyright 2004-2008 Randy Heit
+** All rights reserved.
+**
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions
+** are met:
+**
+** 1. Redistributions of source code must retain the above copyright
+**    notice, this list of conditions and the following disclaimer.
+** 2. Redistributions in binary form must reproduce the above copyright
+**    notice, this list of conditions and the following disclaimer in the
+**    documentation and/or other materials provided with the distribution.
+** 3. The name of the author may not be used to endorse or promote products
+**    derived from this software without specific prior written permission.
+** 4. When not used as part of ZDoom or a ZDoom derivative, this code will be
+**    covered by the terms of the GNU General Public License as published by
+**    the Free Software Foundation; either version 2 of the License, or (at
+**    your option) any later version.
+**
+** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+**---------------------------------------------------------------------------
+**
+*/
+
+
 #ifndef __THINGDEF_H
 #define __THINGDEF_H
 
diff --git a/src/scripting/vm/vm.h b/src/scripting/vm/vm.h
index b7b7aa1c5a..9ebc86f003 100644
--- a/src/scripting/vm/vm.h
+++ b/src/scripting/vm/vm.h
@@ -1,3 +1,38 @@
+/*
+** vm.h
+** VM <-> native interface
+**
+**---------------------------------------------------------------------------
+** Copyright -2016 Randy Heit
+** Copyright 2016 Christoph Oelckers
+** All rights reserved.
+**
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions
+** are met:
+**
+** 1. Redistributions of source code must retain the above copyright
+**    notice, this list of conditions and the following disclaimer.
+** 2. Redistributions in binary form must reproduce the above copyright
+**    notice, this list of conditions and the following disclaimer in the
+**    documentation and/or other materials provided with the distribution.
+** 3. The name of the author may not be used to endorse or promote products
+**    derived from this software without specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+**---------------------------------------------------------------------------
+**
+*/
+
 #ifndef VM_H
 #define VM_H
 
diff --git a/src/scripting/vm/vmexec.h b/src/scripting/vm/vmexec.h
index b573c06704..452414c99f 100644
--- a/src/scripting/vm/vmexec.h
+++ b/src/scripting/vm/vmexec.h
@@ -1,3 +1,38 @@
+/*
+** vmexec.h
+** VM bytecode interpreter
+**
+**---------------------------------------------------------------------------
+** Copyright -2016 Randy Heit
+** Copyright 2016-2017 Christoph Oelckers
+** All rights reserved.
+**
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions
+** are met:
+**
+** 1. Redistributions of source code must retain the above copyright
+**    notice, this list of conditions and the following disclaimer.
+** 2. Redistributions in binary form must reproduce the above copyright
+**    notice, this list of conditions and the following disclaimer in the
+**    documentation and/or other materials provided with the distribution.
+** 3. The name of the author may not be used to endorse or promote products
+**    derived from this software without specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+**---------------------------------------------------------------------------
+**
+*/
+
 #ifndef IMPLEMENT_VMEXEC
 #error vmexec.h must not be #included outside vmexec.cpp. Use vm.h instead.
 #endif
diff --git a/src/scripting/zscript/zcc-parse.lemon b/src/scripting/zscript/zcc-parse.lemon
index 923c40eef4..cd630298b5 100644
--- a/src/scripting/zscript/zcc-parse.lemon
+++ b/src/scripting/zscript/zcc-parse.lemon
@@ -1,3 +1,40 @@
+/*
+** zcc-parse.lemon
+** ZScript parser grammar
+**
+**---------------------------------------------------------------------------
+** Copyright -2016 Randy Heit
+** Copyright 2016-2017 Christoph Oelckers
+** All rights reserved.
+**
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions
+** are met:
+**
+** 1. Redistributions of source code must retain the above copyright
+**    notice, this list of conditions and the following disclaimer.
+** 2. Redistributions in binary form must reproduce the above copyright
+**    notice, this list of conditions and the following disclaimer in the
+**    documentation and/or other materials provided with the distribution.
+** 3. The name of the author may not be used to endorse or promote products
+**    derived from this software without specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+**---------------------------------------------------------------------------
+**
+*/
+
+
+
 %include
 {
 // Allocates a new AST node off the parse state's arena.
diff --git a/src/sound/mpg123_decoder.cpp b/src/sound/mpg123_decoder.cpp
index 1aa5a0e2f8..f5c9a86af1 100644
--- a/src/sound/mpg123_decoder.cpp
+++ b/src/sound/mpg123_decoder.cpp
@@ -1,3 +1,35 @@
+/*
+** mpg123_decoder.cpp
+**
+**---------------------------------------------------------------------------
+** Copyright 2008-2010 Chris Robinson
+** All rights reserved.
+**
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions
+** are met:
+**
+** 1. Redistributions of source code must retain the above copyright
+**    notice, this list of conditions and the following disclaimer.
+** 2. Redistributions in binary form must reproduce the above copyright
+**    notice, this list of conditions and the following disclaimer in the
+**    documentation and/or other materials provided with the distribution.
+** 3. The name of the author may not be used to endorse or promote products
+**    derived from this software without specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+**---------------------------------------------------------------------------
+**
+*/
 #ifdef _WIN32
 #define WIN32_LEAN_AND_MEAN
 #include <windows.h>
diff --git a/src/sound/music_midi_base.cpp b/src/sound/music_midi_base.cpp
index 42e8ab863f..20711d2a04 100644
--- a/src/sound/music_midi_base.cpp
+++ b/src/sound/music_midi_base.cpp
@@ -1,3 +1,36 @@
+/*
+** music_midi_base.cpp
+**
+**---------------------------------------------------------------------------
+** Copyright 1998-2010 Randy Heit
+** All rights reserved.
+**
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions
+** are met:
+**
+** 1. Redistributions of source code must retain the above copyright
+**    notice, this list of conditions and the following disclaimer.
+** 2. Redistributions in binary form must reproduce the above copyright
+**    notice, this list of conditions and the following disclaimer in the
+**    documentation and/or other materials provided with the distribution.
+** 3. The name of the author may not be used to endorse or promote products
+**    derived from this software without specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+**---------------------------------------------------------------------------
+**
+*/
+
 #include "i_midi_win32.h"
 
 
diff --git a/src/sound/musicformats/music_cd.cpp b/src/sound/musicformats/music_cd.cpp
index 17b050f8b4..7d5a8e4a3e 100644
--- a/src/sound/musicformats/music_cd.cpp
+++ b/src/sound/musicformats/music_cd.cpp
@@ -1,3 +1,36 @@
+/*
+** music_cd.cpp
+**
+**---------------------------------------------------------------------------
+** Copyright 1999-2003 Randy Heit
+** All rights reserved.
+**
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions
+** are met:
+**
+** 1. Redistributions of source code must retain the above copyright
+**    notice, this list of conditions and the following disclaimer.
+** 2. Redistributions in binary form must reproduce the above copyright
+**    notice, this list of conditions and the following disclaimer in the
+**    documentation and/or other materials provided with the distribution.
+** 3. The name of the author may not be used to endorse or promote products
+**    derived from this software without specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+**---------------------------------------------------------------------------
+**
+*/
+
 #include "i_musicinterns.h"
 #include "i_cd.h"
 #include "files.h"
diff --git a/src/sound/oplsynth/musicblock.cpp b/src/sound/oplsynth/musicblock.cpp
index 9e26b47323..5de26f76fe 100644
--- a/src/sound/oplsynth/musicblock.cpp
+++ b/src/sound/oplsynth/musicblock.cpp
@@ -1,3 +1,30 @@
+//-----------------------------------------------------------------------------
+//
+// Copyright 2002-2016 Randy Heit
+// Copyright 2005-2014 Simon Howard 
+// Copyright 2017 Christoph Oelckers
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
+//
+// This is mostly a reimplementation of the interface provided by
+// MusLib based on Chocolate-Doom's OPL player, although the
+// interface has been cleaned up a bit to be more consistent and readable.
+//
+//
+
 #include <stdlib.h>
 #include <string.h>
 #include "musicblock.h"
diff --git a/src/sound/oplsynth/opl_mus_player.cpp b/src/sound/oplsynth/opl_mus_player.cpp
index 4829f9cfae..6b70be34fc 100644
--- a/src/sound/oplsynth/opl_mus_player.cpp
+++ b/src/sound/oplsynth/opl_mus_player.cpp
@@ -1,3 +1,36 @@
+/*
+** opl_mus_player.cpp
+**
+**---------------------------------------------------------------------------
+** Copyright 1999-2016 Randy Heit
+** All rights reserved.
+**
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions
+** are met:
+**
+** 1. Redistributions of source code must retain the above copyright
+**    notice, this list of conditions and the following disclaimer.
+** 2. Redistributions in binary form must reproduce the above copyright
+**    notice, this list of conditions and the following disclaimer in the
+**    documentation and/or other materials provided with the distribution.
+** 3. The name of the author may not be used to endorse or promote products
+**    derived from this software without specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+**---------------------------------------------------------------------------
+**
+*/
+
 #ifdef _WIN32
 #include <io.h>
 #endif
diff --git a/src/sound/oplsynth/oplio.cpp b/src/sound/oplsynth/oplio.cpp
index 140521231c..e810a58c18 100644
--- a/src/sound/oplsynth/oplio.cpp
+++ b/src/sound/oplsynth/oplio.cpp
@@ -1,35 +1,27 @@
-/*
-** oplio.cpp
-** low level OPL code
-**
-**---------------------------------------------------------------------------
-** Copyright 1998-2008 Randy Heit
-** All rights reserved.
-**
-** Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions
-** are met:
-**
-** 1. Redistributions of source code must retain the above copyright
-**    notice, this list of conditions and the following disclaimer.
-** 2. Redistributions in binary form must reproduce the above copyright
-**    notice, this list of conditions and the following disclaimer in the
-**    documentation and/or other materials provided with the distribution.
-** 3. The name of the author may not be used to endorse or promote products
-**    derived from this software without specific prior written permission.
-**
-** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
-** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-**---------------------------------------------------------------------------
-*/
+//-----------------------------------------------------------------------------
+//
+// Copyright 2002-2016 Randy Heit
+// Copyright 2005-2014 Simon Howard 
+// Copyright 2017 Christoph Oelckers
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
+//
+// OPL IO interface. Partly built from the non-MusLib code in the old version
+// plus some additions from Chocolate Doom.
+//
 
 #include <math.h>
 #include "genmidi.h"
diff --git a/src/sound/sndfile_decoder.cpp b/src/sound/sndfile_decoder.cpp
index 9d0d2331bc..101c39d4a2 100644
--- a/src/sound/sndfile_decoder.cpp
+++ b/src/sound/sndfile_decoder.cpp
@@ -1,3 +1,35 @@
+/*
+** sndfile_decoder.cpp
+**
+**---------------------------------------------------------------------------
+** Copyright 2008-2010 Chris Robinson
+** All rights reserved.
+**
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions
+** are met:
+**
+** 1. Redistributions of source code must retain the above copyright
+**    notice, this list of conditions and the following disclaimer.
+** 2. Redistributions in binary form must reproduce the above copyright
+**    notice, this list of conditions and the following disclaimer in the
+**    documentation and/or other materials provided with the distribution.
+** 3. The name of the author may not be used to endorse or promote products
+**    derived from this software without specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+**---------------------------------------------------------------------------
+**
+*/
 #ifdef _WIN32
 #define WIN32_LEAN_AND_MEAN
 #include <windows.h>
diff --git a/src/swrenderer/drawers/r_draw_rgba.cpp b/src/swrenderer/drawers/r_draw_rgba.cpp
index 3592744d9a..f94190fa3e 100644
--- a/src/swrenderer/drawers/r_draw_rgba.cpp
+++ b/src/swrenderer/drawers/r_draw_rgba.cpp
@@ -1,26 +1,37 @@
-// Emacs style mode select	 -*- C++ -*- 
-//-----------------------------------------------------------------------------
-//
-// $Id:$
-//
-// Copyright (C) 1993-1996 by id Software, Inc.
-//
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
-//
-// The source is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
-//
-// $Log:$
-//
-// DESCRIPTION:
-//		True color span/column drawing functions.
-//
-//-----------------------------------------------------------------------------
-
+/*
+** r_draw_rgba.cpp
+**
+**---------------------------------------------------------------------------
+** Copyright 1998-2016 Randy Heit
+** Copyright 2016 Magnus Norddahl
+** Copyright 2016 Rachael Alexanderson
+** All rights reserved.
+**
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions
+** are met:
+**
+** 1. Redistributions of source code must retain the above copyright
+**    notice, this list of conditions and the following disclaimer.
+** 2. Redistributions in binary form must reproduce the above copyright
+**    notice, this list of conditions and the following disclaimer in the
+**    documentation and/or other materials provided with the distribution.
+** 3. The name of the author may not be used to endorse or promote products
+**    derived from this software without specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+**---------------------------------------------------------------------------
+**
+*/
 #include <stddef.h>
 
 #include "templates.h"
diff --git a/src/swrenderer/line/r_fogboundary.cpp b/src/swrenderer/line/r_fogboundary.cpp
index 7f3ef3529b..bd6ba50aa5 100644
--- a/src/swrenderer/line/r_fogboundary.cpp
+++ b/src/swrenderer/line/r_fogboundary.cpp
@@ -1,14 +1,23 @@
+//-----------------------------------------------------------------------------
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// Copyright 1993-1996 id Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2016 Magnus Norddahl
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 //
 
 #include <stdlib.h>
diff --git a/src/swrenderer/line/r_fogboundary.h b/src/swrenderer/line/r_fogboundary.h
index c7df265a4b..39005c0396 100644
--- a/src/swrenderer/line/r_fogboundary.h
+++ b/src/swrenderer/line/r_fogboundary.h
@@ -1,14 +1,23 @@
+//-----------------------------------------------------------------------------
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// Copyright 1993-1996 id Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2016 Magnus Norddahl
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 //
 
 #pragma once
diff --git a/src/swrenderer/line/r_line.cpp b/src/swrenderer/line/r_line.cpp
index 4e20e15470..d0c8f08b2d 100644
--- a/src/swrenderer/line/r_line.cpp
+++ b/src/swrenderer/line/r_line.cpp
@@ -1,14 +1,23 @@
+//-----------------------------------------------------------------------------
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// Copyright 1993-1996 id Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2016 Magnus Norddahl
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 //
 
 #include <stdlib.h>
diff --git a/src/swrenderer/line/r_line.h b/src/swrenderer/line/r_line.h
index b0e3c416d9..1462410e58 100644
--- a/src/swrenderer/line/r_line.h
+++ b/src/swrenderer/line/r_line.h
@@ -1,14 +1,23 @@
+//-----------------------------------------------------------------------------
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// Copyright 1993-1996 id Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2016 Magnus Norddahl
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 //
 
 #pragma once
diff --git a/src/swrenderer/line/r_renderdrawsegment.cpp b/src/swrenderer/line/r_renderdrawsegment.cpp
index 9ccf388b43..5831fa0586 100644
--- a/src/swrenderer/line/r_renderdrawsegment.cpp
+++ b/src/swrenderer/line/r_renderdrawsegment.cpp
@@ -1,14 +1,23 @@
+//-----------------------------------------------------------------------------
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// Copyright 1993-1996 id Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2016 Magnus Norddahl
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 //
 
 #include <stdlib.h>
diff --git a/src/swrenderer/line/r_renderdrawsegment.h b/src/swrenderer/line/r_renderdrawsegment.h
index a13d1341df..6587dd1c51 100644
--- a/src/swrenderer/line/r_renderdrawsegment.h
+++ b/src/swrenderer/line/r_renderdrawsegment.h
@@ -1,14 +1,23 @@
+//-----------------------------------------------------------------------------
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// Copyright 1993-1996 id Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2016 Magnus Norddahl
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 //
 
 #pragma once
diff --git a/src/swrenderer/line/r_walldraw.cpp b/src/swrenderer/line/r_walldraw.cpp
index f07a63bb8e..b5b69f3054 100644
--- a/src/swrenderer/line/r_walldraw.cpp
+++ b/src/swrenderer/line/r_walldraw.cpp
@@ -1,14 +1,23 @@
+//-----------------------------------------------------------------------------
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// Copyright 1993-1996 id Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2016 Magnus Norddahl
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 //
 
 #include <stdlib.h>
diff --git a/src/swrenderer/line/r_walldraw.h b/src/swrenderer/line/r_walldraw.h
index d662092d23..d3cd026a21 100644
--- a/src/swrenderer/line/r_walldraw.h
+++ b/src/swrenderer/line/r_walldraw.h
@@ -1,14 +1,23 @@
+//-----------------------------------------------------------------------------
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// Copyright 1993-1996 id Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2016 Magnus Norddahl
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 //
 
 #pragma once
diff --git a/src/swrenderer/line/r_wallsetup.cpp b/src/swrenderer/line/r_wallsetup.cpp
index dbae303d5f..b910bfec86 100644
--- a/src/swrenderer/line/r_wallsetup.cpp
+++ b/src/swrenderer/line/r_wallsetup.cpp
@@ -1,3 +1,24 @@
+//-----------------------------------------------------------------------------
+//
+// Copyright 1993-1996 id Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2016 Magnus Norddahl
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
+//
 
 #include <stdlib.h>
 #include <stddef.h>
diff --git a/src/swrenderer/line/r_wallsetup.h b/src/swrenderer/line/r_wallsetup.h
index d7d32dd5b8..f0035fa433 100644
--- a/src/swrenderer/line/r_wallsetup.h
+++ b/src/swrenderer/line/r_wallsetup.h
@@ -1,3 +1,25 @@
+//-----------------------------------------------------------------------------
+//
+// Copyright 1993-1996 id Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2016 Magnus Norddahl
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
+//
+
 
 #pragma once
 
diff --git a/src/swrenderer/plane/r_flatplane.cpp b/src/swrenderer/plane/r_flatplane.cpp
index 17b9a26301..394bf9a46a 100644
--- a/src/swrenderer/plane/r_flatplane.cpp
+++ b/src/swrenderer/plane/r_flatplane.cpp
@@ -1,14 +1,23 @@
+//-----------------------------------------------------------------------------
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// Copyright 1993-1996 id Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2016 Magnus Norddahl
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 //
 
 #include <stdlib.h>
diff --git a/src/swrenderer/plane/r_flatplane.h b/src/swrenderer/plane/r_flatplane.h
index 1d62c09f78..56b70a40c0 100644
--- a/src/swrenderer/plane/r_flatplane.h
+++ b/src/swrenderer/plane/r_flatplane.h
@@ -1,14 +1,23 @@
+//-----------------------------------------------------------------------------
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// Copyright 1993-1996 id Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2016 Magnus Norddahl
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 //
 
 #pragma once
diff --git a/src/swrenderer/plane/r_planerenderer.cpp b/src/swrenderer/plane/r_planerenderer.cpp
index 772c13df4d..bc1eb22f91 100644
--- a/src/swrenderer/plane/r_planerenderer.cpp
+++ b/src/swrenderer/plane/r_planerenderer.cpp
@@ -1,14 +1,23 @@
+//-----------------------------------------------------------------------------
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// Copyright 1993-1996 id Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2016 Magnus Norddahl
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 //
 
 #include <stdlib.h>
diff --git a/src/swrenderer/plane/r_planerenderer.h b/src/swrenderer/plane/r_planerenderer.h
index f7992cd66b..93859b53ab 100644
--- a/src/swrenderer/plane/r_planerenderer.h
+++ b/src/swrenderer/plane/r_planerenderer.h
@@ -1,14 +1,23 @@
+//-----------------------------------------------------------------------------
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// Copyright 1993-1996 id Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2016 Magnus Norddahl
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 //
 
 #pragma once
diff --git a/src/swrenderer/plane/r_skyplane.cpp b/src/swrenderer/plane/r_skyplane.cpp
index e76016a3eb..b8175b3ea8 100644
--- a/src/swrenderer/plane/r_skyplane.cpp
+++ b/src/swrenderer/plane/r_skyplane.cpp
@@ -1,14 +1,23 @@
+//-----------------------------------------------------------------------------
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// Copyright 1993-1996 id Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2016 Magnus Norddahl
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 //
 
 #include <stdlib.h>
diff --git a/src/swrenderer/plane/r_skyplane.h b/src/swrenderer/plane/r_skyplane.h
index 9a79b1e96b..79a27c987a 100644
--- a/src/swrenderer/plane/r_skyplane.h
+++ b/src/swrenderer/plane/r_skyplane.h
@@ -1,14 +1,23 @@
+//-----------------------------------------------------------------------------
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// Copyright 1993-1996 id Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2016 Magnus Norddahl
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 //
 
 #pragma once
diff --git a/src/swrenderer/plane/r_slopeplane.cpp b/src/swrenderer/plane/r_slopeplane.cpp
index d8897aa6c1..b4fcb51854 100644
--- a/src/swrenderer/plane/r_slopeplane.cpp
+++ b/src/swrenderer/plane/r_slopeplane.cpp
@@ -1,14 +1,23 @@
+//-----------------------------------------------------------------------------
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// Copyright 1993-1996 id Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2016 Magnus Norddahl
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 //
 
 #include <stdlib.h>
diff --git a/src/swrenderer/plane/r_slopeplane.h b/src/swrenderer/plane/r_slopeplane.h
index b707a3f7c4..ae46102544 100644
--- a/src/swrenderer/plane/r_slopeplane.h
+++ b/src/swrenderer/plane/r_slopeplane.h
@@ -1,14 +1,23 @@
+//-----------------------------------------------------------------------------
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// Copyright 1993-1996 id Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2016 Magnus Norddahl
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 //
 
 #pragma once
diff --git a/src/swrenderer/plane/r_visibleplane.cpp b/src/swrenderer/plane/r_visibleplane.cpp
index 88c2e6d349..b877a6ff10 100644
--- a/src/swrenderer/plane/r_visibleplane.cpp
+++ b/src/swrenderer/plane/r_visibleplane.cpp
@@ -1,14 +1,23 @@
+//-----------------------------------------------------------------------------
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// Copyright 1993-1996 id Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2016 Magnus Norddahl
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 //
 
 #include <stdlib.h>
diff --git a/src/swrenderer/plane/r_visibleplane.h b/src/swrenderer/plane/r_visibleplane.h
index 970eee6326..b77c37215e 100644
--- a/src/swrenderer/plane/r_visibleplane.h
+++ b/src/swrenderer/plane/r_visibleplane.h
@@ -1,14 +1,23 @@
+//-----------------------------------------------------------------------------
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// Copyright 1993-1996 id Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2016 Magnus Norddahl
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 //
 
 #pragma once
diff --git a/src/swrenderer/plane/r_visibleplanelist.cpp b/src/swrenderer/plane/r_visibleplanelist.cpp
index 16f9925621..c97c6a6dc4 100644
--- a/src/swrenderer/plane/r_visibleplanelist.cpp
+++ b/src/swrenderer/plane/r_visibleplanelist.cpp
@@ -1,14 +1,23 @@
+//-----------------------------------------------------------------------------
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// Copyright 1993-1996 id Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2016 Magnus Norddahl
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 //
 
 #include <stdlib.h>
diff --git a/src/swrenderer/plane/r_visibleplanelist.h b/src/swrenderer/plane/r_visibleplanelist.h
index e07a086fd9..c44c860eb7 100644
--- a/src/swrenderer/plane/r_visibleplanelist.h
+++ b/src/swrenderer/plane/r_visibleplanelist.h
@@ -1,14 +1,23 @@
+//-----------------------------------------------------------------------------
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// Copyright 1993-1996 id Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2016 Magnus Norddahl
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 //
 
 #pragma once
diff --git a/src/swrenderer/r_memory.cpp b/src/swrenderer/r_memory.cpp
index 4cbfb91ef7..38fc7d8688 100644
--- a/src/swrenderer/r_memory.cpp
+++ b/src/swrenderer/r_memory.cpp
@@ -1,15 +1,22 @@
+//-----------------------------------------------------------------------------
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// Copyright 1999-2016 Randy Heit
+// Copyright 2016 Magnus Norddahl
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
 //
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 
 #include <stdlib.h>
 #include "templates.h"
diff --git a/src/swrenderer/r_memory.h b/src/swrenderer/r_memory.h
index 1b93ff1dfc..67ade026ed 100644
--- a/src/swrenderer/r_memory.h
+++ b/src/swrenderer/r_memory.h
@@ -1,16 +1,3 @@
-//
-// Copyright (C) 1993-1996 by id Software, Inc.
-//
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
-//
-// The source is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
-//
-
 #pragma once
 
 #include <memory>
diff --git a/src/swrenderer/scene/r_3dfloors.cpp b/src/swrenderer/scene/r_3dfloors.cpp
index f1496cd9e7..567660e9a8 100644
--- a/src/swrenderer/scene/r_3dfloors.cpp
+++ b/src/swrenderer/scene/r_3dfloors.cpp
@@ -2,7 +2,34 @@
 **	r_3dfloors.cpp
 **	software 3D floors addon
 **
-**	by kgsws
+**---------------------------------------------------------------------------
+** Copyright 2010 kgsws
+** All rights reserved.
+**
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions
+** are met:
+**
+** 1. Redistributions of source code must retain the above copyright
+**    notice, this list of conditions and the following disclaimer.
+** 2. Redistributions in binary form must reproduce the above copyright
+**    notice, this list of conditions and the following disclaimer in the
+**    documentation and/or other materials provided with the distribution.
+** 3. The name of the author may not be used to endorse or promote products
+**    derived from this software without specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+**---------------------------------------------------------------------------
+**
 */
 
 #include "templates.h"
diff --git a/src/swrenderer/scene/r_light.cpp b/src/swrenderer/scene/r_light.cpp
index 56afb81a31..685ce369c2 100644
--- a/src/swrenderer/scene/r_light.cpp
+++ b/src/swrenderer/scene/r_light.cpp
@@ -1,14 +1,23 @@
+//-----------------------------------------------------------------------------
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// Copyright 1993-1996 id Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2016 Magnus Norddahl
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 //
 
 #include <stdlib.h>
diff --git a/src/swrenderer/scene/r_light.h b/src/swrenderer/scene/r_light.h
index 79c2fd49d5..ae2a2e671f 100644
--- a/src/swrenderer/scene/r_light.h
+++ b/src/swrenderer/scene/r_light.h
@@ -1,15 +1,23 @@
+//-----------------------------------------------------------------------------
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// Copyright 1993-1996 id Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2016 Magnus Norddahl
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
 //
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 
 #pragma once
 
diff --git a/src/swrenderer/scene/r_opaque_pass.cpp b/src/swrenderer/scene/r_opaque_pass.cpp
index 12bb95513c..2ce071f2b4 100644
--- a/src/swrenderer/scene/r_opaque_pass.cpp
+++ b/src/swrenderer/scene/r_opaque_pass.cpp
@@ -1,18 +1,24 @@
-// Emacs style mode select	 -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id:$
+// Copyright 1993-1996 id Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2006-2016 Christoph Oelckers
+// Copyright 2016 Magnus Norddahl
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
-//
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 //
 // DESCRIPTION:
 //		BSP traversal, handling of LineSegs for rendering.
diff --git a/src/swrenderer/scene/r_opaque_pass.h b/src/swrenderer/scene/r_opaque_pass.h
index 123e08e0a1..c71dd3985f 100644
--- a/src/swrenderer/scene/r_opaque_pass.h
+++ b/src/swrenderer/scene/r_opaque_pass.h
@@ -1,15 +1,23 @@
+//-----------------------------------------------------------------------------
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// Copyright 1993-1996 id Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2016 Magnus Norddahl
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
 //
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 
 #pragma once
 
diff --git a/src/swrenderer/scene/r_portal.cpp b/src/swrenderer/scene/r_portal.cpp
index 6c5d7a5521..06812f0ba7 100644
--- a/src/swrenderer/scene/r_portal.cpp
+++ b/src/swrenderer/scene/r_portal.cpp
@@ -1,15 +1,25 @@
+//-----------------------------------------------------------------------------
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// Copyright 1993-1996 id Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2006-2016 Christoph Oelckers
+// Copyright 2015-2016 ZZYZX
+// Copyright 2016 Magnus Norddahl
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
 //
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 
 #include <stdlib.h>
 #include <math.h>
diff --git a/src/swrenderer/scene/r_portal.h b/src/swrenderer/scene/r_portal.h
index b4382c68a1..34a49a4ffa 100644
--- a/src/swrenderer/scene/r_portal.h
+++ b/src/swrenderer/scene/r_portal.h
@@ -1,15 +1,23 @@
+//-----------------------------------------------------------------------------
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// Copyright 1993-1996 id Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2016 Magnus Norddahl
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
 //
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 
 #pragma once
 
diff --git a/src/swrenderer/scene/r_scene.cpp b/src/swrenderer/scene/r_scene.cpp
index 401517cf6c..5109cb82c7 100644
--- a/src/swrenderer/scene/r_scene.cpp
+++ b/src/swrenderer/scene/r_scene.cpp
@@ -1,15 +1,23 @@
+//-----------------------------------------------------------------------------
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// Copyright 1993-1996 id Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2016 Magnus Norddahl
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
 //
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 
 #include <stdlib.h>
 #include <float.h>
diff --git a/src/swrenderer/scene/r_scene.h b/src/swrenderer/scene/r_scene.h
index 02c12ec2cc..b4124812b1 100644
--- a/src/swrenderer/scene/r_scene.h
+++ b/src/swrenderer/scene/r_scene.h
@@ -1,15 +1,23 @@
+//-----------------------------------------------------------------------------
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// Copyright 1993-1996 id Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2016 Magnus Norddahl
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
 //
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 
 #pragma once
 
diff --git a/src/swrenderer/scene/r_translucent_pass.cpp b/src/swrenderer/scene/r_translucent_pass.cpp
index 442643332b..6afa2fcc9b 100644
--- a/src/swrenderer/scene/r_translucent_pass.cpp
+++ b/src/swrenderer/scene/r_translucent_pass.cpp
@@ -1,15 +1,23 @@
+//-----------------------------------------------------------------------------
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// Copyright 1993-1996 id Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2016 Magnus Norddahl
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
 //
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/src/swrenderer/scene/r_translucent_pass.h b/src/swrenderer/scene/r_translucent_pass.h
index 44551b2867..47da285b54 100644
--- a/src/swrenderer/scene/r_translucent_pass.h
+++ b/src/swrenderer/scene/r_translucent_pass.h
@@ -1,15 +1,23 @@
+//-----------------------------------------------------------------------------
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// Copyright 1993-1996 id Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2016 Magnus Norddahl
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
 //
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 
 #pragma once
 
diff --git a/src/swrenderer/segments/r_clipsegment.cpp b/src/swrenderer/segments/r_clipsegment.cpp
index 4e25daa350..5201bc38e7 100644
--- a/src/swrenderer/segments/r_clipsegment.cpp
+++ b/src/swrenderer/segments/r_clipsegment.cpp
@@ -1,15 +1,23 @@
+//-----------------------------------------------------------------------------
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// Copyright 1993-1996 id Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2016 Magnus Norddahl
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
 //
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 
 #include <stdlib.h>
 #include "templates.h"
diff --git a/src/swrenderer/segments/r_clipsegment.h b/src/swrenderer/segments/r_clipsegment.h
index 48a083ba6e..0634464641 100644
--- a/src/swrenderer/segments/r_clipsegment.h
+++ b/src/swrenderer/segments/r_clipsegment.h
@@ -1,15 +1,23 @@
+//-----------------------------------------------------------------------------
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// Copyright 1993-1996 id Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2016 Magnus Norddahl
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
 //
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 
 #pragma once
 
diff --git a/src/swrenderer/segments/r_drawsegment.cpp b/src/swrenderer/segments/r_drawsegment.cpp
index e4bc3d26b4..6d8d507077 100644
--- a/src/swrenderer/segments/r_drawsegment.cpp
+++ b/src/swrenderer/segments/r_drawsegment.cpp
@@ -1,15 +1,23 @@
+//-----------------------------------------------------------------------------
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// Copyright 1993-1996 id Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2016 Magnus Norddahl
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
 //
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 
 #include <stdlib.h>
 #include "templates.h"
diff --git a/src/swrenderer/segments/r_drawsegment.h b/src/swrenderer/segments/r_drawsegment.h
index 9bfd5dc65f..5480ac4f24 100644
--- a/src/swrenderer/segments/r_drawsegment.h
+++ b/src/swrenderer/segments/r_drawsegment.h
@@ -1,15 +1,23 @@
+//-----------------------------------------------------------------------------
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// Copyright 1993-1996 id Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2016 Magnus Norddahl
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
 //
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 
 #pragma once
 
diff --git a/src/swrenderer/segments/r_portalsegment.cpp b/src/swrenderer/segments/r_portalsegment.cpp
index f1591b6667..a5dcfe7c3e 100644
--- a/src/swrenderer/segments/r_portalsegment.cpp
+++ b/src/swrenderer/segments/r_portalsegment.cpp
@@ -1,15 +1,23 @@
+//-----------------------------------------------------------------------------
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// Copyright 1993-1996 id Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2016 Magnus Norddahl
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
 //
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 
 #include <stdlib.h>
 #include "templates.h"
diff --git a/src/swrenderer/segments/r_portalsegment.h b/src/swrenderer/segments/r_portalsegment.h
index 74596bb4de..d27b213ee0 100644
--- a/src/swrenderer/segments/r_portalsegment.h
+++ b/src/swrenderer/segments/r_portalsegment.h
@@ -1,15 +1,23 @@
+//-----------------------------------------------------------------------------
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// Copyright 1993-1996 id Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2016 Magnus Norddahl
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
 //
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 
 #pragma once
 
diff --git a/src/swrenderer/things/r_decal.cpp b/src/swrenderer/things/r_decal.cpp
index 50ef96f096..676b561a6d 100644
--- a/src/swrenderer/things/r_decal.cpp
+++ b/src/swrenderer/things/r_decal.cpp
@@ -1,15 +1,23 @@
+//-----------------------------------------------------------------------------
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// Copyright 1993-1996 id Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2016 Magnus Norddahl
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
 //
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 
 #include <stdlib.h>
 #include <stddef.h>
diff --git a/src/swrenderer/things/r_decal.h b/src/swrenderer/things/r_decal.h
index 4694014b75..98e1f4ed5d 100644
--- a/src/swrenderer/things/r_decal.h
+++ b/src/swrenderer/things/r_decal.h
@@ -1,16 +1,3 @@
-//
-// Copyright (C) 1993-1996 by id Software, Inc.
-//
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
-//
-// The source is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
-//
-
 #pragma once
 
 struct side_t;
diff --git a/src/swrenderer/things/r_particle.cpp b/src/swrenderer/things/r_particle.cpp
index 5eb31274e4..fee9a39c0c 100644
--- a/src/swrenderer/things/r_particle.cpp
+++ b/src/swrenderer/things/r_particle.cpp
@@ -1,15 +1,23 @@
+//-----------------------------------------------------------------------------
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// Copyright 1993-1996 id Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2016 Magnus Norddahl
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
 //
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/src/swrenderer/things/r_particle.h b/src/swrenderer/things/r_particle.h
index af2f59e6cc..84bd10aae3 100644
--- a/src/swrenderer/things/r_particle.h
+++ b/src/swrenderer/things/r_particle.h
@@ -1,16 +1,3 @@
-//
-// Copyright (C) 1993-1996 by id Software, Inc.
-//
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
-//
-// The source is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
-//
-
 #pragma once
 
 #include "r_visiblesprite.h"
diff --git a/src/swrenderer/things/r_playersprite.cpp b/src/swrenderer/things/r_playersprite.cpp
index cd8fc62d37..9fd4a44e29 100644
--- a/src/swrenderer/things/r_playersprite.cpp
+++ b/src/swrenderer/things/r_playersprite.cpp
@@ -1,15 +1,23 @@
+//-----------------------------------------------------------------------------
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// Copyright 1993-1996 id Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2016 Magnus Norddahl
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
 //
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/src/swrenderer/things/r_playersprite.h b/src/swrenderer/things/r_playersprite.h
index 588f9f8dc6..755997a2a4 100644
--- a/src/swrenderer/things/r_playersprite.h
+++ b/src/swrenderer/things/r_playersprite.h
@@ -1,15 +1,23 @@
+//-----------------------------------------------------------------------------
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// Copyright 1993-1996 id Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2016 Magnus Norddahl
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
 //
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 
 #pragma once
 
diff --git a/src/swrenderer/things/r_sprite.cpp b/src/swrenderer/things/r_sprite.cpp
index c98e9dcc65..a349025607 100644
--- a/src/swrenderer/things/r_sprite.cpp
+++ b/src/swrenderer/things/r_sprite.cpp
@@ -1,15 +1,23 @@
+//-----------------------------------------------------------------------------
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// Copyright 1993-1996 id Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2016 Magnus Norddahl
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
 //
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/src/swrenderer/things/r_sprite.h b/src/swrenderer/things/r_sprite.h
index 678c909090..55d504fc9a 100644
--- a/src/swrenderer/things/r_sprite.h
+++ b/src/swrenderer/things/r_sprite.h
@@ -1,16 +1,3 @@
-//
-// Copyright (C) 1993-1996 by id Software, Inc.
-//
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
-//
-// The source is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
-//
-
 #pragma once
 
 #include "r_visiblesprite.h"
diff --git a/src/swrenderer/things/r_visiblesprite.cpp b/src/swrenderer/things/r_visiblesprite.cpp
index bd03feb2d3..26a5d76bee 100644
--- a/src/swrenderer/things/r_visiblesprite.cpp
+++ b/src/swrenderer/things/r_visiblesprite.cpp
@@ -1,15 +1,23 @@
+//-----------------------------------------------------------------------------
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// Copyright 1993-1996 id Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2016 Magnus Norddahl
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
 //
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/src/swrenderer/things/r_visiblesprite.h b/src/swrenderer/things/r_visiblesprite.h
index 7bd5b9de2e..f9490472c7 100644
--- a/src/swrenderer/things/r_visiblesprite.h
+++ b/src/swrenderer/things/r_visiblesprite.h
@@ -1,15 +1,23 @@
+//-----------------------------------------------------------------------------
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// Copyright 1993-1996 id Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2016 Magnus Norddahl
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
 //
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 
 #pragma once
 
diff --git a/src/swrenderer/things/r_visiblespritelist.cpp b/src/swrenderer/things/r_visiblespritelist.cpp
index eac6c91f30..7161507dde 100644
--- a/src/swrenderer/things/r_visiblespritelist.cpp
+++ b/src/swrenderer/things/r_visiblespritelist.cpp
@@ -1,15 +1,23 @@
+//-----------------------------------------------------------------------------
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// Copyright 1993-1996 id Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2016 Magnus Norddahl
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
 //
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/src/swrenderer/things/r_visiblespritelist.h b/src/swrenderer/things/r_visiblespritelist.h
index 2f53514fa3..30d27cc677 100644
--- a/src/swrenderer/things/r_visiblespritelist.h
+++ b/src/swrenderer/things/r_visiblespritelist.h
@@ -1,16 +1,3 @@
-//
-// Copyright (C) 1993-1996 by id Software, Inc.
-//
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
-//
-// The source is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
-//
-
 #pragma once
 
 namespace swrenderer
diff --git a/src/swrenderer/things/r_voxel.cpp b/src/swrenderer/things/r_voxel.cpp
index 0d639381b2..18ab8850b4 100644
--- a/src/swrenderer/things/r_voxel.cpp
+++ b/src/swrenderer/things/r_voxel.cpp
@@ -1,10 +1,27 @@
+//-----------------------------------------------------------------------------
+//
+// Copyright(c) 1993 - 1997 Ken Silverman
+// Copyright(c) 1998 - 2016 Randy Heit
+// All rights reserved.
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 // 
 //---------------------------------------------------------------------------
 //
 // Voxel rendering
-// Copyright(c) 1993 - 1997 Ken Silverman
-// Copyright(c) 1998 - 2016 Randy Heit
-// All rights reserved.
 //
 // Draw a voxel slab. This function is taken from the Build Engine.
 //
diff --git a/src/swrenderer/things/r_voxel.h b/src/swrenderer/things/r_voxel.h
index e8bbe64cd3..a97ee5196a 100644
--- a/src/swrenderer/things/r_voxel.h
+++ b/src/swrenderer/things/r_voxel.h
@@ -2,7 +2,6 @@
 //---------------------------------------------------------------------------
 //
 // Voxel rendering
-// Copyright(c) 1993 - 1997 Ken Silverman
 // Copyright(c) 1998 - 2016 Randy Heit
 // All rights reserved.
 //
diff --git a/src/swrenderer/things/r_wallsprite.cpp b/src/swrenderer/things/r_wallsprite.cpp
index 67c66ede99..6b1ccdcaad 100644
--- a/src/swrenderer/things/r_wallsprite.cpp
+++ b/src/swrenderer/things/r_wallsprite.cpp
@@ -1,15 +1,23 @@
+//-----------------------------------------------------------------------------
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// Copyright 1993-1996 id Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2016 Magnus Norddahl
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
 //
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/src/swrenderer/things/r_wallsprite.h b/src/swrenderer/things/r_wallsprite.h
index 76bbdc6c03..163fe12fb2 100644
--- a/src/swrenderer/things/r_wallsprite.h
+++ b/src/swrenderer/things/r_wallsprite.h
@@ -1,16 +1,3 @@
-//
-// Copyright (C) 1993-1996 by id Software, Inc.
-//
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
-//
-// The source is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
-//
-
 #pragma once
 
 #include "r_visiblesprite.h"
diff --git a/src/swrenderer/viewport/r_drawerargs.cpp b/src/swrenderer/viewport/r_drawerargs.cpp
index f74565c4d9..19e9d66825 100644
--- a/src/swrenderer/viewport/r_drawerargs.cpp
+++ b/src/swrenderer/viewport/r_drawerargs.cpp
@@ -1,15 +1,23 @@
+//-----------------------------------------------------------------------------
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// Copyright 1993-1996 id Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2016 Magnus Norddahl
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
 //
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 
 #include <stddef.h>
 #include "r_drawerargs.h"
diff --git a/src/swrenderer/viewport/r_skydrawer.cpp b/src/swrenderer/viewport/r_skydrawer.cpp
index 3fd6bb3ff2..47409bf086 100644
--- a/src/swrenderer/viewport/r_skydrawer.cpp
+++ b/src/swrenderer/viewport/r_skydrawer.cpp
@@ -1,15 +1,23 @@
+//-----------------------------------------------------------------------------
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// Copyright 1993-1996 id Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2016 Magnus Norddahl
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
 //
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 
 #include <stddef.h>
 #include "r_skydrawer.h"
diff --git a/src/swrenderer/viewport/r_spandrawer.cpp b/src/swrenderer/viewport/r_spandrawer.cpp
index 8900dfe25b..fd81d60fd0 100644
--- a/src/swrenderer/viewport/r_spandrawer.cpp
+++ b/src/swrenderer/viewport/r_spandrawer.cpp
@@ -1,15 +1,23 @@
+//-----------------------------------------------------------------------------
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// Copyright 1993-1996 id Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2016 Magnus Norddahl
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
 //
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 
 #include <stddef.h>
 #include "r_spandrawer.h"
diff --git a/src/swrenderer/viewport/r_viewport.cpp b/src/swrenderer/viewport/r_viewport.cpp
index c0caa6599e..9cfac43736 100644
--- a/src/swrenderer/viewport/r_viewport.cpp
+++ b/src/swrenderer/viewport/r_viewport.cpp
@@ -1,15 +1,23 @@
+//-----------------------------------------------------------------------------
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// Copyright 1993-1996 id Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2016 Magnus Norddahl
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
 //
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 
 #include <stdlib.h>
 #include <float.h>
diff --git a/src/swrenderer/viewport/r_walldrawer.cpp b/src/swrenderer/viewport/r_walldrawer.cpp
index 2ec85e675b..c61ed33032 100644
--- a/src/swrenderer/viewport/r_walldrawer.cpp
+++ b/src/swrenderer/viewport/r_walldrawer.cpp
@@ -1,15 +1,23 @@
+//-----------------------------------------------------------------------------
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// Copyright 1993-1996 id Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2016 Magnus Norddahl
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
 //
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 
 #include <stddef.h>
 #include "r_walldrawer.h"
diff --git a/src/textures/textures.h b/src/textures/textures.h
index cc3f2b588e..3c93b35df3 100644
--- a/src/textures/textures.h
+++ b/src/textures/textures.h
@@ -1,3 +1,37 @@
+/*
+** textures.h
+**
+**---------------------------------------------------------------------------
+** Copyright 2005-2016 Randy Heit
+** Copyright 2005-2016 Christoph Oelckers
+** All rights reserved.
+**
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions
+** are met:
+**
+** 1. Redistributions of source code must retain the above copyright
+**    notice, this list of conditions and the following disclaimer.
+** 2. Redistributions in binary form must reproduce the above copyright
+**    notice, this list of conditions and the following disclaimer in the
+**    documentation and/or other materials provided with the distribution.
+** 3. The name of the author may not be used to endorse or promote products
+**    derived from this software without specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+**---------------------------------------------------------------------------
+**
+*/
+
 #ifndef __TEXTURES_H
 #define __TEXTURES_H
 
diff --git a/src/textures/warpbuffer.h b/src/textures/warpbuffer.h
index 673ba09467..668c40aeb8 100644
--- a/src/textures/warpbuffer.h
+++ b/src/textures/warpbuffer.h
@@ -1,3 +1,37 @@
+/*
+**
+**
+**---------------------------------------------------------------------------
+** Copyright 2005-2016 Randy Heit
+** Copyright 2005-2016 Christoph Oelckers et.al.
+** All rights reserved.
+**
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions
+** are met:
+**
+** 1. Redistributions of source code must retain the above copyright
+**    notice, this list of conditions and the following disclaimer.
+** 2. Redistributions in binary form must reproduce the above copyright
+**    notice, this list of conditions and the following disclaimer in the
+**    documentation and/or other materials provided with the distribution.
+** 3. The name of the author may not be used to endorse or promote products
+**    derived from this software without specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+**---------------------------------------------------------------------------
+**
+*/
+
 #include "textures/textures.h"
 
 template<class TYPE> 
diff --git a/src/win32/critsec.cpp b/src/win32/critsec.cpp
index 4fcd085a9a..471b19b9f1 100644
--- a/src/win32/critsec.cpp
+++ b/src/win32/critsec.cpp
@@ -1,3 +1,35 @@
+/*
+**
+**
+**---------------------------------------------------------------------------
+** Copyright 2005-2016 Randy Heit
+** All rights reserved.
+**
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions
+** are met:
+**
+** 1. Redistributions of source code must retain the above copyright
+**    notice, this list of conditions and the following disclaimer.
+** 2. Redistributions in binary form must reproduce the above copyright
+**    notice, this list of conditions and the following disclaimer in the
+**    documentation and/or other materials provided with the distribution.
+** 3. The name of the author may not be used to endorse or promote products
+**    derived from this software without specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+**---------------------------------------------------------------------------
+**
+*/
 // Wraps a Windows critical section object.
 
 #ifndef _WINNT_
diff --git a/src/win32/eaxedit.cpp b/src/win32/eaxedit.cpp
index 09344a46b4..509f95322b 100644
--- a/src/win32/eaxedit.cpp
+++ b/src/win32/eaxedit.cpp
@@ -1,3 +1,36 @@
+/*
+**
+**
+**---------------------------------------------------------------------------
+** Copyright 2005-2016 Randy Heit
+** All rights reserved.
+**
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions
+** are met:
+**
+** 1. Redistributions of source code must retain the above copyright
+**    notice, this list of conditions and the following disclaimer.
+** 2. Redistributions in binary form must reproduce the above copyright
+**    notice, this list of conditions and the following disclaimer in the
+**    documentation and/or other materials provided with the distribution.
+** 3. The name of the author may not be used to endorse or promote products
+**    derived from this software without specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+**---------------------------------------------------------------------------
+**
+*/
+
 #define WIN32_LEAN_AND_MEAN
 #define _WIN32_WINNT 0x0500
 #define _WIN32_IE 0x0500
diff --git a/src/win32/i_dijoy.cpp b/src/win32/i_dijoy.cpp
index b48efa983f..199a4fa568 100644
--- a/src/win32/i_dijoy.cpp
+++ b/src/win32/i_dijoy.cpp
@@ -1,3 +1,36 @@
+/*
+**
+**
+**---------------------------------------------------------------------------
+** Copyright 2005-2016 Randy Heit
+** All rights reserved.
+**
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions
+** are met:
+**
+** 1. Redistributions of source code must retain the above copyright
+**    notice, this list of conditions and the following disclaimer.
+** 2. Redistributions in binary form must reproduce the above copyright
+**    notice, this list of conditions and the following disclaimer in the
+**    documentation and/or other materials provided with the distribution.
+** 3. The name of the author may not be used to endorse or promote products
+**    derived from this software without specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+**---------------------------------------------------------------------------
+**
+*/
+
 // HEADER FILES ------------------------------------------------------------
 
 #define WIN32_LEAN_AND_MEAN
diff --git a/src/win32/i_keyboard.cpp b/src/win32/i_keyboard.cpp
index 9443b0a869..04dd5a1cc7 100644
--- a/src/win32/i_keyboard.cpp
+++ b/src/win32/i_keyboard.cpp
@@ -1,3 +1,36 @@
+/*
+**
+**
+**---------------------------------------------------------------------------
+** Copyright 2005-2016 Randy Heit
+** All rights reserved.
+**
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions
+** are met:
+**
+** 1. Redistributions of source code must retain the above copyright
+**    notice, this list of conditions and the following disclaimer.
+** 2. Redistributions in binary form must reproduce the above copyright
+**    notice, this list of conditions and the following disclaimer in the
+**    documentation and/or other materials provided with the distribution.
+** 3. The name of the author may not be used to endorse or promote products
+**    derived from this software without specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+**---------------------------------------------------------------------------
+**
+*/
+
 // HEADER FILES ------------------------------------------------------------
 
 #define WIN32_LEAN_AND_MEAN
diff --git a/src/win32/i_mouse.cpp b/src/win32/i_mouse.cpp
index ff3b638ebd..47faa6dc93 100644
--- a/src/win32/i_mouse.cpp
+++ b/src/win32/i_mouse.cpp
@@ -1,3 +1,35 @@
+/*
+**
+**
+**---------------------------------------------------------------------------
+** Copyright 2005-2016 Randy Heit
+** All rights reserved.
+**
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions
+** are met:
+**
+** 1. Redistributions of source code must retain the above copyright
+**    notice, this list of conditions and the following disclaimer.
+** 2. Redistributions in binary form must reproduce the above copyright
+**    notice, this list of conditions and the following disclaimer in the
+**    documentation and/or other materials provided with the distribution.
+** 3. The name of the author may not be used to endorse or promote products
+**    derived from this software without specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+**---------------------------------------------------------------------------
+**
+*/
 
 // HEADER FILES ------------------------------------------------------------
 
diff --git a/src/win32/i_rawps2.cpp b/src/win32/i_rawps2.cpp
index fc43ff6026..9ae44161e8 100644
--- a/src/win32/i_rawps2.cpp
+++ b/src/win32/i_rawps2.cpp
@@ -1,3 +1,36 @@
+/*
+**
+**
+**---------------------------------------------------------------------------
+** Copyright 2005-2016 Randy Heit
+** All rights reserved.
+**
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions
+** are met:
+**
+** 1. Redistributions of source code must retain the above copyright
+**    notice, this list of conditions and the following disclaimer.
+** 2. Redistributions in binary form must reproduce the above copyright
+**    notice, this list of conditions and the following disclaimer in the
+**    documentation and/or other materials provided with the distribution.
+** 3. The name of the author may not be used to endorse or promote products
+**    derived from this software without specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+**---------------------------------------------------------------------------
+**
+*/
+
 // HEADER FILES ------------------------------------------------------------
 
 #define WIN32_LEAN_AND_MEAN
diff --git a/src/win32/i_system.h b/src/win32/i_system.h
index 5959b61120..bf09f25abf 100644
--- a/src/win32/i_system.h
+++ b/src/win32/i_system.h
@@ -1,18 +1,23 @@
-// Emacs style mode select	 -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id:$
+// Copyright 1993-1996 id Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2002-2016 Christoph Oelckers
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
-//
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 //
 // DESCRIPTION:
 //		System specific interface stuff.
diff --git a/src/win32/i_xinput.cpp b/src/win32/i_xinput.cpp
index 6756cd6386..c6cd535a71 100644
--- a/src/win32/i_xinput.cpp
+++ b/src/win32/i_xinput.cpp
@@ -1,3 +1,36 @@
+/*
+**
+**
+**---------------------------------------------------------------------------
+** Copyright 2005-2016 Randy Heit
+** All rights reserved.
+**
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions
+** are met:
+**
+** 1. Redistributions of source code must retain the above copyright
+**    notice, this list of conditions and the following disclaimer.
+** 2. Redistributions in binary form must reproduce the above copyright
+**    notice, this list of conditions and the following disclaimer in the
+**    documentation and/or other materials provided with the distribution.
+** 3. The name of the author may not be used to endorse or promote products
+**    derived from this software without specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+**---------------------------------------------------------------------------
+**
+*/
+
 #ifndef NO_XINPUT
 
 // HEADER FILES ------------------------------------------------------------
diff --git a/src/win32/win32gliface.cpp b/src/win32/win32gliface.cpp
index 96c1510df4..3d4bca30a8 100644
--- a/src/win32/win32gliface.cpp
+++ b/src/win32/win32gliface.cpp
@@ -1,3 +1,37 @@
+/*
+**
+**
+**---------------------------------------------------------------------------
+** Copyright 2003-2005 Tim Stump
+** Copyright 2005-2016 Christoph Oelckers
+** All rights reserved.
+**
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions
+** are met:
+**
+** 1. Redistributions of source code must retain the above copyright
+**    notice, this list of conditions and the following disclaimer.
+** 2. Redistributions in binary form must reproduce the above copyright
+**    notice, this list of conditions and the following disclaimer in the
+**    documentation and/or other materials provided with the distribution.
+** 3. The name of the author may not be used to endorse or promote products
+**    derived from this software without specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+**---------------------------------------------------------------------------
+**
+*/
+
 //#include "gl/system/gl_system.h"
 
 #define WIN32_LEAN_AND_MEAN
diff --git a/src/xlat/xlat_parser.y b/src/xlat/xlat_parser.y
index e6afc1307e..76567a500b 100644
--- a/src/xlat/xlat_parser.y
+++ b/src/xlat/xlat_parser.y
@@ -1,3 +1,36 @@
+/*
+** XLAT grammar
+**
+**---------------------------------------------------------------------------
+** Copyright 1999-2016 Randy Heit
+** Copyright 2005-2016 Christoph Oelckers
+** All rights reserved.
+**
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions
+** are met:
+**
+** 1. Redistributions of source code must retain the above copyright
+**    notice, this list of conditions and the following disclaimer.
+** 2. Redistributions in binary form must reproduce the above copyright
+**    notice, this list of conditions and the following disclaimer in the
+**    documentation and/or other materials provided with the distribution.
+** 3. The name of the author may not be used to endorse or promote products
+**    derived from this software without specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+**---------------------------------------------------------------------------
+**
+*/
 
 %token_prefix XLAT_
 %token_type {FParseToken}

From 96d328de9baaf4c9ed3244846a394b60e912ab6c Mon Sep 17 00:00:00 2001
From: Christoph Oelckers <coelckers@users.noreply.github.com>
Date: Mon, 17 Apr 2017 13:33:19 +0200
Subject: [PATCH 20/29] - removed all Doom Source license and all default Raven
 copyright headers and replaced them with GPLv3. Also fixed the license in a
 few other files.

For some files that had the Doom Source license attached but saw heavy external contributions over the years I added a special note to license all original ZDoom code under BSD.
---
 src/CMakeLists.txt                        |  2 -
 src/actor.h                               | 26 +++++----
 src/actorptrselect.cpp                    | 33 ++++++++++++
 src/am_map.cpp                            | 26 +++++----
 src/am_map.h                              | 26 ++++-----
 src/b_bot.cpp                             | 34 ++++++++++++
 src/b_func.cpp                            | 34 ++++++++++++
 src/b_game.cpp                            | 34 ++++++++++++
 src/b_move.cpp                            | 34 ++++++++++++
 src/b_think.cpp                           | 34 ++++++++++++
 src/cmdlib.cpp                            | 22 ++++++++
 src/ct_chat.cpp                           | 31 +++++++----
 src/d_event.h                             | 24 ++++-----
 src/d_main.cpp                            | 24 +++++----
 src/d_main.h                              | 25 +++++----
 src/d_net.cpp                             | 25 +++++----
 src/d_net.h                               | 25 +++++----
 src/d_player.h                            | 27 +++++-----
 src/dobjtype.cpp                          |  3 +-
 src/doomdata.h                            | 26 +++++----
 src/doomdef.cpp                           | 29 ----------
 src/doomdef.h                             | 25 +++++----
 src/doomstat.cpp                          | 25 +++++----
 src/doomstat.h                            | 25 +++++----
 src/doomtype.h                            | 14 -----
 src/dsectoreffect.cpp                     | 25 +++++----
 src/events.cpp                            | 32 +++++++++++
 src/f_wipe.cpp                            | 24 +++++----
 src/f_wipe.h                              | 28 +++++-----
 src/files.h                               | 35 ++++++++++++
 src/g_game.cpp                            | 26 ++++-----
 src/g_game.h                              | 25 +++++----
 src/g_levellocals.h                       | 35 ++++++++++++
 src/hu_stuff.h                            | 26 +++++----
 src/i_net.cpp                             | 24 +++++----
 src/i_net.h                               | 22 --------
 src/i_video.h                             | 22 --------
 src/m_bbox.cpp                            | 30 +++++------
 src/m_bbox.h                              | 25 +++++----
 src/m_cheat.cpp                           | 52 +++++++++++-------
 src/m_cheat.h                             | 22 --------
 src/m_joy.cpp                             | 32 +++++++++++
 src/m_misc.cpp                            | 24 +++++----
 src/m_misc.h                              | 25 ++++-----
 src/m_swap.h                              | 15 ------
 src/nodebuild.h                           | 37 +++++++++++++
 src/p_ceiling.cpp                         | 28 ++++++----
 src/p_doors.cpp                           | 25 +++++----
 src/p_floor.cpp                           | 27 ++++++----
 src/p_interaction.cpp                     | 26 +++++----
 src/p_lights.cpp                          | 26 +++++----
 src/p_local.h                             | 28 ++++++----
 src/p_map.cpp                             | 57 ++++++++++++++++----
 src/p_maputl.cpp                          | 56 +++++++++++++++----
 src/p_mobj.cpp                            | 59 +++++++++++++++-----
 src/p_plats.cpp                           | 27 ++++++----
 src/p_portals.cpp                         | 35 ------------
 src/p_pspr.cpp                            | 35 ++++++++----
 src/p_pspr.h                              | 27 ++++++----
 src/p_pusher.cpp                          | 25 +++++----
 src/p_scroll.cpp                          | 54 +++++++++++++++----
 src/p_secnodes.cpp                        | 25 +++++----
 src/p_sectors.cpp                         | 56 +++++++++++++++----
 src/p_setup.cpp                           | 57 ++++++++++++++++----
 src/p_setup.h                             | 25 +++++----
 src/p_sight.cpp                           | 33 ++++++++----
 src/p_spec.cpp                            | 56 +++++++++++++++----
 src/p_spec.h                              | 27 ++++++----
 src/p_teleport.cpp                        | 27 ++++++----
 src/p_tick.cpp                            | 25 +++++----
 src/p_tick.h                              | 25 ---------
 src/p_user.cpp                            | 57 ++++++++++++++++----
 src/po_man.cpp                            | 32 +++++++----
 src/r_defs.h                              | 27 ++++++----
 src/r_sky.cpp                             | 26 +++++----
 src/r_sky.h                               | 26 +++++----
 src/r_state.h                             | 25 +++++----
 src/r_utility.cpp                         | 26 +++++----
 src/s_environment.cpp                     | 34 ++++++++++++
 src/s_sndseq.cpp                          | 31 +++++++----
 src/s_sound.cpp                           | 53 ++++++++++++++----
 src/s_sound.h                             | 23 +++++---
 src/sc_man.cpp                            | 66 +++++++++++++++++++----
 src/sc_man_scanner.re                     | 35 ++++++++++++
 src/st_stuff.cpp                          | 26 +++++----
 src/st_stuff.h                            | 23 --------
 src/swrenderer/line/r_line.cpp            |  2 +-
 src/swrenderer/plane/r_flatplane.cpp      |  2 +-
 src/swrenderer/viewport/r_viewport.h      | 12 -----
 src/v_video.cpp                           | 49 +++++++++++------
 src/w_wad.h                               | 14 -----
 src/wi_stuff.h                            | 25 +++++----
 src/x86.cpp                               | 34 ++++++++++++
 wadsrc/static/zscript/zscript_license.txt | 21 ++++++++
 94 files changed, 1843 insertions(+), 936 deletions(-)
 delete mode 100644 src/doomdef.cpp
 delete mode 100644 src/p_portals.cpp
 create mode 100644 wadsrc/static/zscript/zscript_license.txt

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index d303102b00..541dc01501 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -823,7 +823,6 @@ set (PCH_SOURCES
 	dobject.cpp
 	dobjgc.cpp
 	dobjtype.cpp
-	doomdef.cpp
 	doomstat.cpp
 	dsectoreffect.cpp
 	dthinker.cpp
@@ -884,7 +883,6 @@ set (PCH_SOURCES
 	p_mobj.cpp
 	p_pillar.cpp
 	p_plats.cpp
-	p_portals.cpp
 	p_pspr.cpp
 	p_pusher.cpp
 	p_saveg.cpp
diff --git a/src/actor.h b/src/actor.h
index bc65144da6..ff9e27af96 100644
--- a/src/actor.h
+++ b/src/actor.h
@@ -1,18 +1,24 @@
-// Emacs style mode select	 -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id:$
+// Copyright 1993-1996 id Software
+// Copyright 1994-1996 Raven Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2002-2016 Christoph Oelckers
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
-//
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 //
 // DESCRIPTION:
 //		Map Objects, MObj, definition and handling.
diff --git a/src/actorptrselect.cpp b/src/actorptrselect.cpp
index c902f9f143..4be3330c94 100644
--- a/src/actorptrselect.cpp
+++ b/src/actorptrselect.cpp
@@ -1,3 +1,36 @@
+/*
+**
+**
+**---------------------------------------------------------------------------
+** Copyright 2011 FDARI
+** All rights reserved.
+**
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions
+** are met:
+**
+** 1. Redistributions of source code must retain the above copyright
+**    notice, this list of conditions and the following disclaimer.
+** 2. Redistributions in binary form must reproduce the above copyright
+**    notice, this list of conditions and the following disclaimer in the
+**    documentation and/or other materials provided with the distribution.
+** 3. The name of the author may not be used to endorse or promote products
+**    derived from this software without specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+**---------------------------------------------------------------------------
+**
+*/
+
 #include "actorptrselect.h"
 #include "actor.h"
 #include "d_player.h"
diff --git a/src/am_map.cpp b/src/am_map.cpp
index 5c39857dc8..b9b583ed3f 100644
--- a/src/am_map.cpp
+++ b/src/am_map.cpp
@@ -1,21 +1,25 @@
-// Emacs style mode select   -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id:$
+// Copyright 1993-1996 id Software
+// Copyright 1994-1996 Raven Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2002-2016 Christoph Oelckers
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
-//
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
 //
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 //
-// $Log:$
 //
 // DESCRIPTION:  the automap code
 //
diff --git a/src/am_map.h b/src/am_map.h
index 8bf9b08c22..22bb34670c 100644
--- a/src/am_map.h
+++ b/src/am_map.h
@@ -1,24 +1,24 @@
-// Emacs style mode select	 -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id:$
+// Copyright 1993-1996 id Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2002-2016 Christoph Oelckers
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
-//
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
 //
-// DESCRIPTION:
-//	AutoMap module.
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
 //
 //-----------------------------------------------------------------------------
-
+//
 #ifndef __AMMAP_H__
 #define __AMMAP_H__
 
diff --git a/src/b_bot.cpp b/src/b_bot.cpp
index 5fc891fb42..d1848fc6a0 100644
--- a/src/b_bot.cpp
+++ b/src/b_bot.cpp
@@ -1,3 +1,37 @@
+/*
+**
+**
+**---------------------------------------------------------------------------
+** Copyright 1999 Martin Colberg
+** Copyright 1999-2016 Randy Heit
+** Copyright 2005-2016 Christoph Oelckers
+** All rights reserved.
+**
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions
+** are met:
+**
+** 1. Redistributions of source code must retain the above copyright
+**    notice, this list of conditions and the following disclaimer.
+** 2. Redistributions in binary form must reproduce the above copyright
+**    notice, this list of conditions and the following disclaimer in the
+**    documentation and/or other materials provided with the distribution.
+** 3. The name of the author may not be used to endorse or promote products
+**    derived from this software without specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+**---------------------------------------------------------------------------
+**
+*/
 // Cajun bot
 //
 // [RH] Moved console commands out of d_netcmd.c (in Cajun source), because
diff --git a/src/b_func.cpp b/src/b_func.cpp
index cc79deea75..3014e1bdd4 100644
--- a/src/b_func.cpp
+++ b/src/b_func.cpp
@@ -1,3 +1,37 @@
+/*
+**
+**
+**---------------------------------------------------------------------------
+** Copyright 1999 Martin Colberg
+** Copyright 1999-2016 Randy Heit
+** Copyright 2005-2016 Christoph Oelckers
+** All rights reserved.
+**
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions
+** are met:
+**
+** 1. Redistributions of source code must retain the above copyright
+**    notice, this list of conditions and the following disclaimer.
+** 2. Redistributions in binary form must reproduce the above copyright
+**    notice, this list of conditions and the following disclaimer in the
+**    documentation and/or other materials provided with the distribution.
+** 3. The name of the author may not be used to endorse or promote products
+**    derived from this software without specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+**---------------------------------------------------------------------------
+**
+*/
 /*******************************
 * B_spawn.c                    *
 * Description:                 *
diff --git a/src/b_game.cpp b/src/b_game.cpp
index 9a78110953..1cb91ddf49 100644
--- a/src/b_game.cpp
+++ b/src/b_game.cpp
@@ -1,3 +1,37 @@
+/*
+**
+**
+**---------------------------------------------------------------------------
+** Copyright 1999 Martin Colberg
+** Copyright 1999-2016 Randy Heit
+** Copyright 2005-2016 Christoph Oelckers
+** All rights reserved.
+**
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions
+** are met:
+**
+** 1. Redistributions of source code must retain the above copyright
+**    notice, this list of conditions and the following disclaimer.
+** 2. Redistributions in binary form must reproduce the above copyright
+**    notice, this list of conditions and the following disclaimer in the
+**    documentation and/or other materials provided with the distribution.
+** 3. The name of the author may not be used to endorse or promote products
+**    derived from this software without specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+**---------------------------------------------------------------------------
+**
+*/
 /*******************************************
 * B_game.h                                 *
 * Description:                             *
diff --git a/src/b_move.cpp b/src/b_move.cpp
index 9361d55615..730c628b72 100644
--- a/src/b_move.cpp
+++ b/src/b_move.cpp
@@ -1,3 +1,37 @@
+/*
+**
+**
+**---------------------------------------------------------------------------
+** Copyright 1999 Martin Colberg
+** Copyright 1999-2016 Randy Heit
+** Copyright 2005-2016 Christoph Oelckers
+** All rights reserved.
+**
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions
+** are met:
+**
+** 1. Redistributions of source code must retain the above copyright
+**    notice, this list of conditions and the following disclaimer.
+** 2. Redistributions in binary form must reproduce the above copyright
+**    notice, this list of conditions and the following disclaimer in the
+**    documentation and/or other materials provided with the distribution.
+** 3. The name of the author may not be used to endorse or promote products
+**    derived from this software without specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+**---------------------------------------------------------------------------
+**
+*/
 /********************************
 * B_Think.c                     *
 * Description:                  *
diff --git a/src/b_think.cpp b/src/b_think.cpp
index 116e70c4f4..f0b4380c00 100644
--- a/src/b_think.cpp
+++ b/src/b_think.cpp
@@ -1,3 +1,37 @@
+/*
+**
+**
+**---------------------------------------------------------------------------
+** Copyright 1999 Martin Colberg
+** Copyright 1999-2016 Randy Heit
+** Copyright 2005-2016 Christoph Oelckers
+** All rights reserved.
+**
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions
+** are met:
+**
+** 1. Redistributions of source code must retain the above copyright
+**    notice, this list of conditions and the following disclaimer.
+** 2. Redistributions in binary form must reproduce the above copyright
+**    notice, this list of conditions and the following disclaimer in the
+**    documentation and/or other materials provided with the distribution.
+** 3. The name of the author may not be used to endorse or promote products
+**    derived from this software without specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+**---------------------------------------------------------------------------
+**
+*/
 /********************************
 * B_Think.c                     *
 * Description:                  *
diff --git a/src/cmdlib.cpp b/src/cmdlib.cpp
index 342ce05aa3..7013c6a60b 100644
--- a/src/cmdlib.cpp
+++ b/src/cmdlib.cpp
@@ -1,3 +1,25 @@
+//-----------------------------------------------------------------------------
+//
+// Copyright 1996 id Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2002-2016 Christoph Oelckers
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
+//
+
 // cmdlib.c (mostly borrowed from the Q2 source)
 
 #ifdef _WIN32
diff --git a/src/ct_chat.cpp b/src/ct_chat.cpp
index c632df2038..34a5ee9703 100644
--- a/src/ct_chat.cpp
+++ b/src/ct_chat.cpp
@@ -1,14 +1,25 @@
+//-----------------------------------------------------------------------------
+//
+// Copyright 1993-1996 id Software
+// Copyright 1994-1996 Raven Software
+// Copyright 1999-2016 Randy Heit
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
+//
 
-//**************************************************************************
-//**
-//** ct_chat.c : Heretic 2 : Raven Software, Corp.
-//**
-//** $RCSfile: ct_chat.c,v $
-//** $Revision: 1.12 $
-//** $Date: 96/01/16 10:35:26 $
-//** $Author: bgokey $
-//**
-//**************************************************************************
 
 #include <string.h>
 #include <ctype.h>
diff --git a/src/d_event.h b/src/d_event.h
index 5b7d202a44..22988cda54 100644
--- a/src/d_event.h
+++ b/src/d_event.h
@@ -1,22 +1,22 @@
-// Emacs style mode select	 -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id:$
+// Copyright 1993-1996 id Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2002-2016 Christoph Oelckers
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
-//
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
 //
-// DESCRIPTION:
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
 //
-//	  
 //-----------------------------------------------------------------------------
 
 
diff --git a/src/d_main.cpp b/src/d_main.cpp
index b6a67c06b0..86e0fbb51a 100644
--- a/src/d_main.cpp
+++ b/src/d_main.cpp
@@ -1,20 +1,22 @@
-// Emacs style mode select	 -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id:$
+// Copyright 1993-1996 id Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2002-2016 Christoph Oelckers
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
-//
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
 //
-// $Log:$
 //
 // DESCRIPTION:
 //		DOOM main program (D_DoomMain) and game loop (D_DoomLoop),
diff --git a/src/d_main.h b/src/d_main.h
index 034c263c7d..ca8d40322b 100644
--- a/src/d_main.h
+++ b/src/d_main.h
@@ -1,20 +1,23 @@
-// Emacs style mode select	 -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id:$
+// Copyright 1993-1996 id Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2002-2016 Christoph Oelckers
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
-//
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
 //
-// $Log:$
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 //
 // DESCRIPTION:
 //		System specific interface stuff.
diff --git a/src/d_net.cpp b/src/d_net.cpp
index 12449111a1..0e5e82c079 100644
--- a/src/d_net.cpp
+++ b/src/d_net.cpp
@@ -1,20 +1,23 @@
-// Emacs style mode select	 -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id:$
+// Copyright 1993-1996 id Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2002-2016 Christoph Oelckers
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
-//
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
 //
-// $Log:$
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 //
 // DESCRIPTION:
 //		DOOM Network game communication and protocol,
diff --git a/src/d_net.h b/src/d_net.h
index 282f73e152..352a01eb28 100644
--- a/src/d_net.h
+++ b/src/d_net.h
@@ -1,18 +1,23 @@
-// Emacs style mode select	 -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id:$
+// Copyright 1993-1996 id Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2002-2016 Christoph Oelckers
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
-//
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 //
 // DESCRIPTION:
 //		Networking stuff.
diff --git a/src/d_player.h b/src/d_player.h
index 79a0cb5284..edc611a69e 100644
--- a/src/d_player.h
+++ b/src/d_player.h
@@ -1,23 +1,26 @@
-// Emacs style mode select	 -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id:$
+// Copyright 1993-1996 id Software
+// Copyright 1994-1996 Raven Software
+// Copyright 1998-1998 Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
+// Copyright 1999-2016 Randy Heit
+// Copyright 2002-2016 Christoph Oelckers
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
-//
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
-//
-// DESCRIPTION:
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
 //
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
 //
 //-----------------------------------------------------------------------------
+//
 
 
 #ifndef __D_PLAYER_H__
diff --git a/src/dobjtype.cpp b/src/dobjtype.cpp
index bf41d3cdea..ad745843e3 100644
--- a/src/dobjtype.cpp
+++ b/src/dobjtype.cpp
@@ -3,7 +3,8 @@
 ** Implements the type information class
 **
 **---------------------------------------------------------------------------
-** Copyright 1998-2010 Randy Heit
+** Copyright 1998-2016 Randy Heit
+** Copyright 2005-2016 Christoph Oelckers
 ** All rights reserved.
 **
 ** Redistribution and use in source and binary forms, with or without
diff --git a/src/doomdata.h b/src/doomdata.h
index 2bcd271bdc..e6cb728ec2 100644
--- a/src/doomdata.h
+++ b/src/doomdata.h
@@ -1,18 +1,24 @@
-// Emacs style mode select	 -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id:$
+// Copyright 1993-1996 id Software
+// Copyright 1994-1996 Raven Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2002-2016 Christoph Oelckers
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
-//
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 //
 // DESCRIPTION:
 //	all external data is defined here
diff --git a/src/doomdef.cpp b/src/doomdef.cpp
deleted file mode 100644
index e80c5791da..0000000000
--- a/src/doomdef.cpp
+++ /dev/null
@@ -1,29 +0,0 @@
-// Emacs style mode select   -*- C++ -*- 
-//-----------------------------------------------------------------------------
-//
-// $Id:$
-//
-// Copyright (C) 1993-1996 by id Software, Inc.
-//
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
-//
-// The source is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
-//
-// $Log:$
-//
-// DESCRIPTION:
-//  DoomDef - basic defines for DOOM, e.g. Version, game mode
-//   and skill level, and display parameters.
-//
-//-----------------------------------------------------------------------------
-
-
-
-#include "doomdef.h"
-
-// Location for any defines turned variables.
diff --git a/src/doomdef.h b/src/doomdef.h
index 0b639db30b..e64e5e2153 100644
--- a/src/doomdef.h
+++ b/src/doomdef.h
@@ -1,18 +1,23 @@
-// Emacs style mode select	 -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id:$
+// Copyright 1993-1996 id Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2002-2016 Christoph Oelckers
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
-//
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 //
 // DESCRIPTION:
 //	Internally used data structures for virtually everything,
diff --git a/src/doomstat.cpp b/src/doomstat.cpp
index 3093983318..e02dc44579 100644
--- a/src/doomstat.cpp
+++ b/src/doomstat.cpp
@@ -1,20 +1,23 @@
-// Emacs style mode select   -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id:$
+// Copyright 1993-1996 id Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2002-2016 Christoph Oelckers
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
-//
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
 //
-// $Log:$
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 //
 // DESCRIPTION:
 //      Put all global state variables here.
diff --git a/src/doomstat.h b/src/doomstat.h
index 3ebf07f92d..3e76d7f2f7 100644
--- a/src/doomstat.h
+++ b/src/doomstat.h
@@ -1,18 +1,23 @@
-// Emacs style mode select	 -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id:$
+// Copyright 1993-1996 id Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2002-2016 Christoph Oelckers
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
-//
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 //
 // DESCRIPTION:
 //	 All the global variables that store the internal state.
diff --git a/src/doomtype.h b/src/doomtype.h
index 6c8e1a33b0..bd6c2112b5 100644
--- a/src/doomtype.h
+++ b/src/doomtype.h
@@ -1,19 +1,5 @@
-// Emacs style mode select       -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id: doomtype.h,v 1.2 1997/12/29 19:50:48 pekangas Exp $
-//
-// Copyright (C) 1993-1996 by id Software, Inc.
-//
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
-//
-// The source is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
-//
 // DESCRIPTION:
 //              Simple basic typedefs, isolated here to make it easier
 //               separating modules.
diff --git a/src/dsectoreffect.cpp b/src/dsectoreffect.cpp
index 719fbf2d76..b1d517fe77 100644
--- a/src/dsectoreffect.cpp
+++ b/src/dsectoreffect.cpp
@@ -1,20 +1,23 @@
-// Emacs style mode select	 -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id:$
+// Copyright 1993-1996 id Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2002-2016 Christoph Oelckers
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
-//
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
 //
-// $Log:$
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 //
 // DESCRIPTION:
 //		Base class for effects on sectors.
diff --git a/src/events.cpp b/src/events.cpp
index c2ae5f0b40..b07211777e 100755
--- a/src/events.cpp
+++ b/src/events.cpp
@@ -1,3 +1,35 @@
+/*
+**
+**
+**---------------------------------------------------------------------------
+** Copyright 2017 ZZYZX
+** All rights reserved.
+**
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions
+** are met:
+**
+** 1. Redistributions of source code must retain the above copyright
+**    notice, this list of conditions and the following disclaimer.
+** 2. Redistributions in binary form must reproduce the above copyright
+**    notice, this list of conditions and the following disclaimer in the
+**    documentation and/or other materials provided with the distribution.
+** 3. The name of the author may not be used to endorse or promote products
+**    derived from this software without specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+**---------------------------------------------------------------------------
+**
+*/
 #include "events.h"
 #include "vm.h"
 #include "r_utility.h"
diff --git a/src/f_wipe.cpp b/src/f_wipe.cpp
index 5515cd96c3..02a9268e7d 100644
--- a/src/f_wipe.cpp
+++ b/src/f_wipe.cpp
@@ -1,20 +1,22 @@
-// Emacs style mode select	 -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id:$
+// Copyright 1993-1996 id Software
+// Copyright 1999-2016 Randy Heit
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
-//
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
 //
-// $Log:$
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 //
 // DESCRIPTION:
 //		Mission begin melt/wipe screen special effect.
diff --git a/src/f_wipe.h b/src/f_wipe.h
index 0f94e6a065..a9296745d2 100644
--- a/src/f_wipe.h
+++ b/src/f_wipe.h
@@ -1,18 +1,21 @@
-// Emacs style mode select	 -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id:$
+// Copyright 1993-1996 id Software
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
-//
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 //
 // DESCRIPTION:
 //		Mission start screen wipe/melt, special effects.
@@ -46,8 +49,3 @@ enum
 };
 
 #endif
-//-----------------------------------------------------------------------------
-//
-// $Log:$
-//
-//-----------------------------------------------------------------------------
diff --git a/src/files.h b/src/files.h
index e8099ada80..4c73273a12 100644
--- a/src/files.h
+++ b/src/files.h
@@ -1,3 +1,38 @@
+/*
+** files.h
+** Implements classes for reading from files or memory blocks
+**
+**---------------------------------------------------------------------------
+** Copyright 1998-2008 Randy Heit
+** Copyright 2005-2008 Christoph Oelckers
+** All rights reserved.
+**
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions
+** are met:
+**
+** 1. Redistributions of source code must retain the above copyright
+**    notice, this list of conditions and the following disclaimer.
+** 2. Redistributions in binary form must reproduce the above copyright
+**    notice, this list of conditions and the following disclaimer in the
+**    documentation and/or other materials provided with the distribution.
+** 3. The name of the author may not be used to endorse or promote products
+**    derived from this software without specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+**---------------------------------------------------------------------------
+**
+*/
+
 #ifndef FILES_H
 #define FILES_H
 
diff --git a/src/g_game.cpp b/src/g_game.cpp
index a32672de74..0a0a4c438e 100644
--- a/src/g_game.cpp
+++ b/src/g_game.cpp
@@ -1,24 +1,24 @@
-// Emacs style mode select	 -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id:$
+// Copyright 1993-1996 id Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2002-2016 Christoph Oelckers
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
-//
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
 //
-// $Log:$
-//
-// DESCRIPTION:  none
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
 //
 //-----------------------------------------------------------------------------
+//
 
 
 
diff --git a/src/g_game.h b/src/g_game.h
index 0bfc498dda..3a11e31f21 100644
--- a/src/g_game.h
+++ b/src/g_game.h
@@ -1,18 +1,23 @@
-// Emacs style mode select	 -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id:$
+// Copyright 1993-1996 id Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2002-2016 Christoph Oelckers
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
-//
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 //
 // DESCRIPTION:
 //	 Duh.
diff --git a/src/g_levellocals.h b/src/g_levellocals.h
index 4ca0a0e7e9..b7f4f9aa33 100644
--- a/src/g_levellocals.h
+++ b/src/g_levellocals.h
@@ -1,3 +1,38 @@
+/*
+** g_levellocals.h
+** The static data for a level
+**
+**---------------------------------------------------------------------------
+** Copyright 1998-2016 Randy Heit
+** Copyright 2005-2017 Christoph Oelckers
+** All rights reserved.
+**
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions
+** are met:
+**
+** 1. Redistributions of source code must retain the above copyright
+**    notice, this list of conditions and the following disclaimer.
+** 2. Redistributions in binary form must reproduce the above copyright
+**    notice, this list of conditions and the following disclaimer in the
+**    documentation and/or other materials provided with the distribution.
+** 3. The name of the author may not be used to endorse or promote products
+**    derived from this software without specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+**---------------------------------------------------------------------------
+**
+*/
+
 #pragma once
 
 #include "doomdata.h"
diff --git a/src/hu_stuff.h b/src/hu_stuff.h
index 0f42d73d88..9003b53e31 100644
--- a/src/hu_stuff.h
+++ b/src/hu_stuff.h
@@ -1,18 +1,24 @@
-// Emacs style mode select	 -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id:$
+// Copyright 1993-1996 id Software
+// Copyright 1994-1996 Raven Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2002-2016 Christoph Oelckers
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
-//
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 //
 // DESCRIPTION:  Head up display
 //
diff --git a/src/i_net.cpp b/src/i_net.cpp
index 7bf1f29aae..48160373cf 100644
--- a/src/i_net.cpp
+++ b/src/i_net.cpp
@@ -1,18 +1,22 @@
-// Emacs style mode select	 -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id: i_net.c,v 1.2 1997/12/29 19:50:54 pekangas Exp $
+// Copyright 1993-1996 id Software
+// Copyright 1999-2016 Randy Heit
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
-//
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 //
 // DESCRIPTION:
 //		Low-level networking code. Uses BSD sockets for UDP networking.
diff --git a/src/i_net.h b/src/i_net.h
index 290ec858a2..124116cf5c 100644
--- a/src/i_net.h
+++ b/src/i_net.h
@@ -1,25 +1,3 @@
-// Emacs style mode select	 -*- C++ -*- 
-//-----------------------------------------------------------------------------
-//
-// $Id: i_net.h,v 1.1.1.1 1997/12/28 12:59:02 pekangas Exp $
-//
-// Copyright (C) 1993-1996 by id Software, Inc.
-//
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
-//
-// The source is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
-//
-// DESCRIPTION:
-//		System specific network interface stuff.
-//
-//-----------------------------------------------------------------------------
-
-
 #ifndef __I_NET_H__
 #define __I_NET_H__
 
diff --git a/src/i_video.h b/src/i_video.h
index 234c33bbfe..b1c56c9a6c 100644
--- a/src/i_video.h
+++ b/src/i_video.h
@@ -1,25 +1,3 @@
-// Emacs style mode select   -*- C++ -*- 
-//-----------------------------------------------------------------------------
-//
-// $Id:$
-//
-// Copyright (C) 1993-1996 by id Software, Inc.
-//
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
-//
-// The source is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
-//
-// DESCRIPTION:
-//		System specific interface stuff.
-//
-//-----------------------------------------------------------------------------
-
-
 #ifndef __I_VIDEO_H__
 #define __I_VIDEO_H__
 
diff --git a/src/m_bbox.cpp b/src/m_bbox.cpp
index 143f54d47a..1fb6ca1423 100644
--- a/src/m_bbox.cpp
+++ b/src/m_bbox.cpp
@@ -1,26 +1,26 @@
-// Emacs style mode select	 -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id:$
+// Copyright 1993-1996 id Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2002-2016 Christoph Oelckers
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
-//
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
 //
-// $Log:$
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 //
 // DESCRIPTION:
-//		Main loop menu stuff.
-//		Random number LUT.
-//		Default Config File.
-//		PCX Screenshots.
+//		bounding box class
 //
 //-----------------------------------------------------------------------------
 
diff --git a/src/m_bbox.h b/src/m_bbox.h
index 71728b8510..e19f179d75 100644
--- a/src/m_bbox.h
+++ b/src/m_bbox.h
@@ -1,18 +1,23 @@
-// Emacs style mode select	 -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id:$
+// Copyright 1993-1996 id Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2002-2016 Christoph Oelckers
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
-//
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 //
 // DESCRIPTION:
 //	  Nil.
diff --git a/src/m_cheat.cpp b/src/m_cheat.cpp
index cba490a0c7..d1dd91e65c 100644
--- a/src/m_cheat.cpp
+++ b/src/m_cheat.cpp
@@ -1,25 +1,39 @@
-// Emacs style mode select	 -*- C++ -*- 
-//-----------------------------------------------------------------------------
-//
-// $Id:$
-//
-// Copyright (C) 1993-1996 by id Software, Inc.
-//
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
-//
-// The source is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
-//
-// $Log:$
-//
+/*
+**
+**
+**---------------------------------------------------------------------------
+** Copyright 1999-2016 Randy Heit
+** Copyright 2005-2016 Christoph Oelckers
+** All rights reserved.
+**
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions
+** are met:
+**
+** 1. Redistributions of source code must retain the above copyright
+**    notice, this list of conditions and the following disclaimer.
+** 2. Redistributions in binary form must reproduce the above copyright
+**    notice, this list of conditions and the following disclaimer in the
+**    documentation and/or other materials provided with the distribution.
+** 3. The name of the author may not be used to endorse or promote products
+**    derived from this software without specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+**---------------------------------------------------------------------------
+**
+*/
 // DESCRIPTION:
 //		Cheat sequence checking.
 //
-//-----------------------------------------------------------------------------
 
 
 #include <stdlib.h>
diff --git a/src/m_cheat.h b/src/m_cheat.h
index c7417b2eb0..c6ebcb1a16 100644
--- a/src/m_cheat.h
+++ b/src/m_cheat.h
@@ -1,25 +1,3 @@
-// Emacs style mode select	 -*- C++ -*- 
-//-----------------------------------------------------------------------------
-//
-// $Id:$
-//
-// Copyright (C) 1993-1996 by id Software, Inc.
-//
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
-//
-// The source is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
-//
-// DESCRIPTION:
-//		Cheat code checking.
-//
-//-----------------------------------------------------------------------------
-
-
 #ifndef __M_CHEAT_H__
 #define __M_CHEAT_H__
 
diff --git a/src/m_joy.cpp b/src/m_joy.cpp
index dd5d8f58fd..bd51a77df8 100644
--- a/src/m_joy.cpp
+++ b/src/m_joy.cpp
@@ -1,3 +1,35 @@
+/*
+**
+**
+**---------------------------------------------------------------------------
+** Copyright 2005-2016 Randy Heit
+** All rights reserved.
+**
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions
+** are met:
+**
+** 1. Redistributions of source code must retain the above copyright
+**    notice, this list of conditions and the following disclaimer.
+** 2. Redistributions in binary form must reproduce the above copyright
+**    notice, this list of conditions and the following disclaimer in the
+**    documentation and/or other materials provided with the distribution.
+** 3. The name of the author may not be used to endorse or promote products
+**    derived from this software without specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+**---------------------------------------------------------------------------
+**
+*/
 // HEADER FILES ------------------------------------------------------------
 
 #include <math.h>
diff --git a/src/m_misc.cpp b/src/m_misc.cpp
index a118638aa9..8673102a28 100644
--- a/src/m_misc.cpp
+++ b/src/m_misc.cpp
@@ -1,21 +1,23 @@
-// Emacs style mode select	 -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id:$
+// Copyright 1993-1996 id Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2002-2016 Christoph Oelckers
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
-//
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
 //
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
 //
-// $Log:$
+//-----------------------------------------------------------------------------
 //
 // DESCRIPTION:
 //		Default Config File.
diff --git a/src/m_misc.h b/src/m_misc.h
index cd2b09f2f2..660eb7a587 100644
--- a/src/m_misc.h
+++ b/src/m_misc.h
@@ -1,23 +1,24 @@
-// Emacs style mode select	 -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id:$
+// Copyright 1993-1996 id Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2002-2016 Christoph Oelckers
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
-//
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
 //
-// DESCRIPTION:
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
 //
-//	  
 //-----------------------------------------------------------------------------
+//
 
 
 #ifndef __M_MISC__
diff --git a/src/m_swap.h b/src/m_swap.h
index ddcf8eaf90..982aa5ca1b 100644
--- a/src/m_swap.h
+++ b/src/m_swap.h
@@ -1,18 +1,3 @@
-// Emacs style mode select	 -*- C++ -*- 
-//-----------------------------------------------------------------------------
-//
-// $Id:$
-//
-// Copyright (C) 1993-1996 by id Software, Inc.
-//
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
-//
-// The source is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
 //
 // DESCRIPTION:
 //		Endianess handling, swapping 16bit and 32bit.
diff --git a/src/nodebuild.h b/src/nodebuild.h
index 5e22032f71..f66e64aa4d 100644
--- a/src/nodebuild.h
+++ b/src/nodebuild.h
@@ -1,3 +1,40 @@
+/*
+** nodebuild.cpp
+**
+**---------------------------------------------------------------------------
+** Copyright 2002-2016 Randy Heit
+** All rights reserved.
+**
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions
+** are met:
+**
+** 1. Redistributions of source code must retain the above copyright
+**    notice, this list of conditions and the following disclaimer.
+** 2. Redistributions in binary form must reproduce the above copyright
+**    notice, this list of conditions and the following disclaimer in the
+**    documentation and/or other materials provided with the distribution.
+** 3. The name of the author may not be used to endorse or promote products
+**    derived from this software without specific prior written permission.
+** 4. When not used as part of ZDoom or a ZDoom derivative, this code will be
+**    covered by the terms of the GNU General Public License as published by
+**    the Free Software Foundation; either version 2 of the License, or (at
+**    your option) any later version.
+**
+** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+**---------------------------------------------------------------------------
+**
+*/
+
 #include "doomdata.h"
 #include "tarray.h"
 #include "r_defs.h"
diff --git a/src/p_ceiling.cpp b/src/p_ceiling.cpp
index b45ded588d..fcd2a54876 100644
--- a/src/p_ceiling.cpp
+++ b/src/p_ceiling.cpp
@@ -1,20 +1,26 @@
-// Emacs style mode select	 -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id:$
+// Copyright 1993-1996 id Software
+// Copyright 1994-1996 Raven Software
+// Copyright 1998-1998 Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
+// Copyright 1999-2016 Randy Heit
+// Copyright 2002-2016 Christoph Oelckers
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
-//
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 //
-// $Log:$
 //
 // DESCRIPTION:  Ceiling animation (lowering, crushing, raising)
 //
diff --git a/src/p_doors.cpp b/src/p_doors.cpp
index 13c5447f13..43deaeaf87 100644
--- a/src/p_doors.cpp
+++ b/src/p_doors.cpp
@@ -1,20 +1,23 @@
-// Emacs style mode select	 -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id:$
+// Copyright 1993-1996 id Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2002-2016 Christoph Oelckers
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
-//
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
 //
-// $Log:$
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 //
 // DESCRIPTION: Door animation code (opening/closing)
 //		[RH] Removed sliding door code and simplified for Hexen-ish specials
diff --git a/src/p_floor.cpp b/src/p_floor.cpp
index d370cdccf2..63ebdc4af6 100644
--- a/src/p_floor.cpp
+++ b/src/p_floor.cpp
@@ -1,20 +1,25 @@
-// Emacs style mode select	 -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id:$
+// Copyright 1993-1996 id Software
+// Copyright 1994-1996 Raven Software
+// Copyright 1998-1998 Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
+// Copyright 1999-2016 Randy Heit
+// Copyright 2002-2016 Christoph Oelckers
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
-//
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
 //
-// $Log:$
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 //
 // DESCRIPTION:
 //		Floor animation: raising stairs.
diff --git a/src/p_interaction.cpp b/src/p_interaction.cpp
index 59a22fa762..35e2bf7bc9 100644
--- a/src/p_interaction.cpp
+++ b/src/p_interaction.cpp
@@ -1,20 +1,24 @@
-// Emacs style mode select	 -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id:$
+// Copyright 1993-1996 id Software
+// Copyright 1994-1996 Raven Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2002-2016 Christoph Oelckers
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
-//
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
 //
-// $Log:$
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 //
 // DESCRIPTION:
 //		Handling interactions (i.e., collisions).
diff --git a/src/p_lights.cpp b/src/p_lights.cpp
index c3a69f0527..2a52692b50 100644
--- a/src/p_lights.cpp
+++ b/src/p_lights.cpp
@@ -1,20 +1,24 @@
-// Emacs style mode select	 -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id:$
+// Copyright 1993-1996 id Software
+// Copyright 1994-1996 Raven Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2002-2016 Christoph Oelckers
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
-//
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
 //
-// $Log:$
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 //
 // DESCRIPTION:
 //		Handle Sector base lighting effects.
diff --git a/src/p_local.h b/src/p_local.h
index eb921ae96d..301b36ad7a 100644
--- a/src/p_local.h
+++ b/src/p_local.h
@@ -1,19 +1,27 @@
-// Emacs style mode select	 -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id:$
+// Copyright 1993-1996 id Software
+// Copyright 1994-1996 Raven Software
+// Copyright 1998-1998 Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
+// Copyright 1999-2016 Randy Heit
+// Copyright 2002-2016 Christoph Oelckers
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
-//
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
 //
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
+//
+
 // DESCRIPTION:
 //		Play functions, animation, global header.
 //
diff --git a/src/p_map.cpp b/src/p_map.cpp
index dd00519e27..d997cffe60 100644
--- a/src/p_map.cpp
+++ b/src/p_map.cpp
@@ -1,20 +1,25 @@
-// Emacs style mode select	 -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id:$
+// Copyright 1993-1996 id Software
+// Copyright 1994-1996 Raven Software
+// Copyright 1998-1998 Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
+// Copyright 1999-2016 Randy Heit
+// Copyright 2002-2017 Christoph Oelckers
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
-//
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
 //
-// $Log:$
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 //
 // DESCRIPTION:
 //		Movement, collision handling.
@@ -22,6 +27,36 @@
 //
 //-----------------------------------------------------------------------------
 
+/* For code that originates from ZDoom the following applies:
+**
+**---------------------------------------------------------------------------
+**
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions
+** are met:
+**
+** 1. Redistributions of source code must retain the above copyright
+**    notice, this list of conditions and the following disclaimer.
+** 2. Redistributions in binary form must reproduce the above copyright
+**    notice, this list of conditions and the following disclaimer in the
+**    documentation and/or other materials provided with the distribution.
+** 3. The name of the author may not be used to endorse or promote products
+**    derived from this software without specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+**---------------------------------------------------------------------------
+**
+*/
+
 #include <stdlib.h>
 #include <math.h>
 #include <algorithm>
diff --git a/src/p_maputl.cpp b/src/p_maputl.cpp
index 5e7dfa2187..e6b39e5866 100644
--- a/src/p_maputl.cpp
+++ b/src/p_maputl.cpp
@@ -1,20 +1,25 @@
-// Emacs style mode select	 -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id:$
+// Copyright 1993-1996 id Software
+// Copyright 1994-1996 Raven Software
+// Copyright 1998-1998 Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
+// Copyright 1999-2016 Randy Heit
+// Copyright 2002-2017 Christoph Oelckers
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
-//
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
 //
-// $Log:$
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 //
 // DESCRIPTION:
 //		Movement/collision utility functions,
@@ -24,6 +29,35 @@
 //
 //-----------------------------------------------------------------------------
 
+/* For code that originates from ZDoom the following applies:
+**
+**---------------------------------------------------------------------------
+**
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions
+** are met:
+**
+** 1. Redistributions of source code must retain the above copyright
+**    notice, this list of conditions and the following disclaimer.
+** 2. Redistributions in binary form must reproduce the above copyright
+**    notice, this list of conditions and the following disclaimer in the
+**    documentation and/or other materials provided with the distribution.
+** 3. The name of the author may not be used to endorse or promote products
+**    derived from this software without specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+**---------------------------------------------------------------------------
+**
+*/
 
 
 #include <stdlib.h>
diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp
index e0a10946a3..9a6ef3642a 100644
--- a/src/p_mobj.cpp
+++ b/src/p_mobj.cpp
@@ -1,26 +1,61 @@
-// Emacs style mode select	 -*- C++ -*- 
-//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
 //
-// $Id:$
+// Copyright 1993-1996 id Software
+// Copyright 1994-1996 Raven Software
+// Copyright 1998-1998 Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
+// Copyright 1999-2016 Randy Heit
+// Copyright 2002-2017 Christoph Oelckers
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
-//
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
 //
-// $Log:$
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 //
 // DESCRIPTION:
 //		Moving object handling. Spawn functions.
 //
 //-----------------------------------------------------------------------------
 
+/* For code that originates from ZDoom the following applies:
+**
+**---------------------------------------------------------------------------
+**
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions
+** are met:
+**
+** 1. Redistributions of source code must retain the above copyright
+**    notice, this list of conditions and the following disclaimer.
+** 2. Redistributions in binary form must reproduce the above copyright
+**    notice, this list of conditions and the following disclaimer in the
+**    documentation and/or other materials provided with the distribution.
+** 3. The name of the author may not be used to endorse or promote products
+**    derived from this software without specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+**---------------------------------------------------------------------------
+**
+*/
+
 // HEADER FILES ------------------------------------------------------------
 #include <float.h>
 #include "templates.h"
diff --git a/src/p_plats.cpp b/src/p_plats.cpp
index 320597ddcc..c43a74b1ec 100644
--- a/src/p_plats.cpp
+++ b/src/p_plats.cpp
@@ -1,20 +1,25 @@
-// Emacs style mode select	 -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id:$
+// Copyright 1993-1996 id Software
+// Copyright 1994-1996 Raven Software
+// Copyright 1998-1998 Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
+// Copyright 1999-2016 Randy Heit
+// Copyright 2002-2016 Christoph Oelckers
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
-//
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
 //
-// $Log:$
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 //
 // DESCRIPTION:
 //		Plats (i.e. elevator platforms) code, raising/lowering.
diff --git a/src/p_portals.cpp b/src/p_portals.cpp
deleted file mode 100644
index 92ecfd075f..0000000000
--- a/src/p_portals.cpp
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
-** p_portals.cpp
-**
-** portal stuff
-**
-**---------------------------------------------------------------------------
-** Copyright 2015 Christoph Oelckers
-** All rights reserved.
-**
-** Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions
-** are met:
-**
-** 1. Redistributions of source code must retain the above copyright
-**    notice, this list of conditions and the following disclaimer.
-** 2. Redistributions in binary form must reproduce the above copyright
-**    notice, this list of conditions and the following disclaimer in the
-**    documentation and/or other materials provided with the distribution.
-** 3. The name of the author may not be used to endorse or promote products
-**    derived from this software without specific prior written permission.
-**
-** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
-** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-**---------------------------------------------------------------------------
-**
-*/
-
diff --git a/src/p_pspr.cpp b/src/p_pspr.cpp
index 73afa00673..72920f8944 100644
--- a/src/p_pspr.cpp
+++ b/src/p_pspr.cpp
@@ -1,14 +1,27 @@
-
-//**************************************************************************
-//**
-//** p_pspr.c : Heretic 2 : Raven Software, Corp.
-//**
-//** $RCSfile: p_pspr.c,v $
-//** $Revision: 1.105 $
-//** $Date: 96/01/06 03:23:35 $
-//** $Author: bgokey $
-//**
-//**************************************************************************
+//-----------------------------------------------------------------------------
+//
+// Copyright 1993-1996 id Software
+// Copyright 1994-1996 Raven Software
+// Copyright 1998-1998 Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
+// Copyright 1999-2016 Randy Heit
+// Copyright 2002-2016 Christoph Oelckers
+// Copyright 2016 Leonard2
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
+//
 
 // HEADER FILES ------------------------------------------------------------
 
diff --git a/src/p_pspr.h b/src/p_pspr.h
index f91c4b30fc..615af3c3c9 100644
--- a/src/p_pspr.h
+++ b/src/p_pspr.h
@@ -1,19 +1,26 @@
-// Emacs style mode select	 -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id:$
+// Copyright 1993-1996 id Software
+// Copyright 1994-1996 Raven Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2002-2016 Christoph Oelckers
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
-//
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
 //
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
+//
+
 // DESCRIPTION:
 //	Sprite animation.
 //
diff --git a/src/p_pusher.cpp b/src/p_pusher.cpp
index c4b38c582b..c3bfe62af2 100644
--- a/src/p_pusher.cpp
+++ b/src/p_pusher.cpp
@@ -1,20 +1,23 @@
-// Emacs style mode select	 -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id:$
+// Copyright 1998-1998 Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
+// Copyright 1999-2016 Randy Heit
+// Copyright 2002-2016 Christoph Oelckers
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
-//
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
 //
-// $Log:$
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 //
 // DESCRIPTION:
 //		Initializes and implements BOOM linedef triggers for
diff --git a/src/p_scroll.cpp b/src/p_scroll.cpp
index 59b18f1cee..f2661a2a1d 100644
--- a/src/p_scroll.cpp
+++ b/src/p_scroll.cpp
@@ -1,20 +1,23 @@
-// Emacs style mode select	 -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id:$
+// Copyright 1998-1998 Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
+// Copyright 1999-2016 Randy Heit
+// Copyright 2002-2016 Christoph Oelckers
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
-//
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
 //
-// $Log:$
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 //
 // DESCRIPTION:
 //		Initializes and implements BOOM linedef triggers for
@@ -22,6 +25,35 @@
 //
 //-----------------------------------------------------------------------------
 
+/* For code that originates from ZDoom the following applies:
+**
+**---------------------------------------------------------------------------
+**
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions
+** are met:
+**
+** 1. Redistributions of source code must retain the above copyright
+**    notice, this list of conditions and the following disclaimer.
+** 2. Redistributions in binary form must reproduce the above copyright
+**    notice, this list of conditions and the following disclaimer in the
+**    documentation and/or other materials provided with the distribution.
+** 3. The name of the author may not be used to endorse or promote products
+**    derived from this software without specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+**---------------------------------------------------------------------------
+**
+*/
 
 #include <stdlib.h>
 #include "actor.h"
diff --git a/src/p_secnodes.cpp b/src/p_secnodes.cpp
index f0c7eb32f5..f95c28b39c 100644
--- a/src/p_secnodes.cpp
+++ b/src/p_secnodes.cpp
@@ -1,20 +1,23 @@
-// Emacs style mode select	 -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id:$
+// Copyright 1998-1998 Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
+// Copyright 1999-2016 Randy Heit
+// Copyright 2002-2016 Christoph Oelckers
 //
-// Copyright (C) 1998-1996 by id Software, Inc.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
-//
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
 //
-// $Log:$
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 //
 // DESCRIPTION:
 //		Boom secnodes
diff --git a/src/p_sectors.cpp b/src/p_sectors.cpp
index f84afb1ff8..369c5de61b 100644
--- a/src/p_sectors.cpp
+++ b/src/p_sectors.cpp
@@ -1,26 +1,60 @@
-// Emacs style mode select	 -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id:$
+// Copyright 1993-1996 id Software
+// Copyright 1998-1998 Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
+// Copyright 1999-2016 Randy Heit
+// Copyright 2002-2017 Christoph Oelckers
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
-//
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
 //
-// $Log:$
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 //
 // DESCRIPTION:
 //		Sector utility functions.
 //
 //-----------------------------------------------------------------------------
 
+/* For code that originates from ZDoom the following applies:
+**
+**---------------------------------------------------------------------------
+**
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions
+** are met:
+**
+** 1. Redistributions of source code must retain the above copyright
+**    notice, this list of conditions and the following disclaimer.
+** 2. Redistributions in binary form must reproduce the above copyright
+**    notice, this list of conditions and the following disclaimer in the
+**    documentation and/or other materials provided with the distribution.
+** 3. The name of the author may not be used to endorse or promote products
+**    derived from this software without specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+**---------------------------------------------------------------------------
+**
+*/
+
 #include "p_spec.h"
 #include "p_lnspec.h"
 #include "c_cvars.h"
diff --git a/src/p_setup.cpp b/src/p_setup.cpp
index 341caab7b2..d19e65295d 100644
--- a/src/p_setup.cpp
+++ b/src/p_setup.cpp
@@ -1,20 +1,25 @@
-// Emacs style mode select	 -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id:$
+// Copyright 1993-1996 id Software
+// Copyright 1994-1996 Raven Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2002-2016 Christoph Oelckers
+// Copyright 2010 James Haley
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
-//
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
 //
-// $Log:$
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 //
 // DESCRIPTION:
 //		Do all the WAD I/O, get map description,
@@ -22,6 +27,36 @@
 //
 //-----------------------------------------------------------------------------
 
+/* For code that originates from ZDoom the following applies:
+**
+**---------------------------------------------------------------------------
+**
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions
+** are met:
+**
+** 1. Redistributions of source code must retain the above copyright
+**    notice, this list of conditions and the following disclaimer.
+** 2. Redistributions in binary form must reproduce the above copyright
+**    notice, this list of conditions and the following disclaimer in the
+**    documentation and/or other materials provided with the distribution.
+** 3. The name of the author may not be used to endorse or promote products
+**    derived from this software without specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+**---------------------------------------------------------------------------
+**
+*/
+
 
 #include <math.h>
 #include <float.h>
diff --git a/src/p_setup.h b/src/p_setup.h
index 1b6c1d5153..dae64160b7 100644
--- a/src/p_setup.h
+++ b/src/p_setup.h
@@ -1,18 +1,23 @@
-// Emacs style mode select	 -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id:$
+// Copyright 1993-1996 id Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2002-2016 Christoph Oelckers
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
-//
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 //
 // DESCRIPTION:
 //	 Setup a game, startup stuff.
diff --git a/src/p_sight.cpp b/src/p_sight.cpp
index b4c69d3fe1..f86ae4c22e 100644
--- a/src/p_sight.cpp
+++ b/src/p_sight.cpp
@@ -1,14 +1,25 @@
-//**************************************************************************
-//**
-//** p_sight.cpp : Heretic 2 : Raven Software, Corp.
-//**
-//** $RCSfile: p_sight.c,v $
-//** $Revision: 1.1 $
-//** $Date: 95/05/11 00:22:50 $
-//** $Author: bgokey $
-//**
-//**************************************************************************
-
+//-----------------------------------------------------------------------------
+//
+// Copyright 1993-1994 id Software
+// Copyright 1994-1996 Raven Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2002-2016 Christoph Oelckers
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
+//
 #include <assert.h>
 
 #include "doomdef.h"
diff --git a/src/p_spec.cpp b/src/p_spec.cpp
index 0ce113a25f..9299c5dca7 100644
--- a/src/p_spec.cpp
+++ b/src/p_spec.cpp
@@ -1,20 +1,25 @@
-// Emacs style mode select	 -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id:$
+// Copyright 1993-1996 id Software
+// Copyright 1994-1996 Raven Software
+// Copyright 1998-1998 Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
+// Copyright 1999-2016 Randy Heit
+// Copyright 2002-2016 Christoph Oelckers
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
-//
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
 //
-// $Log:$
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 //
 // DESCRIPTION:
 //		Implements special effects:
@@ -30,6 +35,35 @@
 //
 //-----------------------------------------------------------------------------
 
+/* For code that originates from ZDoom the following applies:
+**
+**---------------------------------------------------------------------------
+**
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions
+** are met:
+**
+** 1. Redistributions of source code must retain the above copyright
+**    notice, this list of conditions and the following disclaimer.
+** 2. Redistributions in binary form must reproduce the above copyright
+**    notice, this list of conditions and the following disclaimer in the
+**    documentation and/or other materials provided with the distribution.
+** 3. The name of the author may not be used to endorse or promote products
+**    derived from this software without specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+**---------------------------------------------------------------------------
+**
+*/
 
 #include <stdlib.h>
 
diff --git a/src/p_spec.h b/src/p_spec.h
index cd3107c4f2..6dc1186586 100644
--- a/src/p_spec.h
+++ b/src/p_spec.h
@@ -1,18 +1,25 @@
-// Emacs style mode select	 -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id:$
+// Copyright 1993-1996 id Software
+// Copyright 1994-1996 Raven Software
+// Copyright 1998-1998 Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
+// Copyright 1999-2016 Randy Heit
+// Copyright 2002-2016 Christoph Oelckers
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
-//
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 //
 // DESCRIPTION:  none
 //		Implements special effects:
diff --git a/src/p_teleport.cpp b/src/p_teleport.cpp
index a56e4e790a..55b93a423b 100644
--- a/src/p_teleport.cpp
+++ b/src/p_teleport.cpp
@@ -1,20 +1,25 @@
-// Emacs style mode select	 -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id:$
+// Copyright 1993-1996 id Software
+// Copyright 1994-1996 Raven Software
+// Copyright 1998-1998 Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
+// Copyright 1999-2016 Randy Heit
+// Copyright 2002-2016 Christoph Oelckers
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
-//
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
 //
-// $Log:$
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 //
 // DESCRIPTION:
 //		Teleportation.
diff --git a/src/p_tick.cpp b/src/p_tick.cpp
index 3ef1775f5f..78dfa9abb7 100644
--- a/src/p_tick.cpp
+++ b/src/p_tick.cpp
@@ -1,20 +1,23 @@
-// Emacs style mode select	 -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id:$
+// Copyright 1993-1996 id Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2002-2016 Christoph Oelckers
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
-//
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
 //
-// $Log:$
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 //
 // DESCRIPTION:
 //		Ticker.
diff --git a/src/p_tick.h b/src/p_tick.h
index d336cc27bb..36de13b270 100644
--- a/src/p_tick.h
+++ b/src/p_tick.h
@@ -1,35 +1,10 @@
-// Emacs style mode select	 -*- C++ -*- 
-//-----------------------------------------------------------------------------
-//
-// $Id:$
-//
-// Copyright (C) 1993-1996 by id Software, Inc.
-//
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
-//
-// The source is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
-//
-// DESCRIPTION:
-//		?
-//
-//-----------------------------------------------------------------------------
-
-
 #ifndef __P_TICK__
 #define __P_TICK__
 
-
-
 // Called by C_Ticker,
 // can call G_PlayerExited.
 // Carries out all thinking of monsters and players.
 void P_Ticker (void);
-
 bool P_CheckTickerPaused ();
 
 
diff --git a/src/p_user.cpp b/src/p_user.cpp
index b0cce58ab9..9494ae3c36 100644
--- a/src/p_user.cpp
+++ b/src/p_user.cpp
@@ -1,20 +1,25 @@
-// Emacs style mode select	 -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id:$
+// Copyright 1993-1996 id Software
+// Copyright 1994-1996 Raven Software
+// Copyright 1998-1998 Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
+// Copyright 1999-2016 Randy Heit
+// Copyright 2002-2016 Christoph Oelckers
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
-//
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
 //
-// $Log:$
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 //
 // DESCRIPTION:
 //		Player related stuff.
@@ -23,6 +28,36 @@
 //
 //-----------------------------------------------------------------------------
 
+/* For code that originates from ZDoom the following applies:
+**
+**---------------------------------------------------------------------------
+**
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions
+** are met:
+**
+** 1. Redistributions of source code must retain the above copyright
+**    notice, this list of conditions and the following disclaimer.
+** 2. Redistributions in binary form must reproduce the above copyright
+**    notice, this list of conditions and the following disclaimer in the
+**    documentation and/or other materials provided with the distribution.
+** 3. The name of the author may not be used to endorse or promote products
+**    derived from this software without specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+**---------------------------------------------------------------------------
+**
+*/
+
 #include "templates.h"
 #include "doomdef.h"
 #include "d_event.h"
diff --git a/src/po_man.cpp b/src/po_man.cpp
index 09c42211cf..1fa323c5e7 100644
--- a/src/po_man.cpp
+++ b/src/po_man.cpp
@@ -1,14 +1,24 @@
-
-//**************************************************************************
-//**
-//** PO_MAN.C : Heretic 2 : Raven Software, Corp.
-//**
-//** $RCSfile: po_man.c,v $
-//** $Revision: 1.22 $
-//** $Date: 95/09/28 18:20:56 $
-//** $Author: cjr $
-//**
-//**************************************************************************
+//-----------------------------------------------------------------------------
+//
+// Copyright 1994-1996 Raven Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2002-2016 Christoph Oelckers
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
+//
 
 // HEADER FILES ------------------------------------------------------------
 
diff --git a/src/r_defs.h b/src/r_defs.h
index 08fa4c29f5..411a3c078d 100644
--- a/src/r_defs.h
+++ b/src/r_defs.h
@@ -1,18 +1,25 @@
-// Emacs style mode select	 -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id:$
+// Copyright 1993-1996 id Software
+// Copyright 1994-1996 Raven Software
+// Copyright 1998-1998 Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
+// Copyright 1999-2016 Randy Heit
+// Copyright 2002-2016 Christoph Oelckers
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
-//
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 //
 // DESCRIPTION:
 //		Refresh/rendering module, shared data struct definitions.
diff --git a/src/r_sky.cpp b/src/r_sky.cpp
index c3d8de1a07..eb31e20648 100644
--- a/src/r_sky.cpp
+++ b/src/r_sky.cpp
@@ -1,20 +1,24 @@
-// Emacs style mode select	 -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id:$
+// Copyright 1993-1996 id Software
+// Copyright 1994-1996 Raven Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2002-2016 Christoph Oelckers
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
-//
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
 //
-// $Log:$
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 //
 // DESCRIPTION:
 //	Sky rendering. The DOOM sky is a texture map like any
diff --git a/src/r_sky.h b/src/r_sky.h
index b30acbd7e3..39ac77f27f 100644
--- a/src/r_sky.h
+++ b/src/r_sky.h
@@ -1,19 +1,25 @@
-// Emacs style mode select	 -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id:$
+// Copyright 1993-1996 id Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2002-2016 Christoph Oelckers
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
-//
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
 //
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
+//
+
 // DESCRIPTION:
 //		Sky rendering.
 //
diff --git a/src/r_state.h b/src/r_state.h
index 309f70607e..5619a15301 100644
--- a/src/r_state.h
+++ b/src/r_state.h
@@ -1,18 +1,23 @@
-// Emacs style mode select	 -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id:$
+// Copyright 1993-1996 id Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2002-2016 Christoph Oelckers
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
-//
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 //
 // DESCRIPTION:
 //		Refresh/render internal state variables (global).
diff --git a/src/r_utility.cpp b/src/r_utility.cpp
index 6af399bfbd..f700afe79e 100644
--- a/src/r_utility.cpp
+++ b/src/r_utility.cpp
@@ -1,20 +1,24 @@
-// Emacs style mode select	 -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id:$
+// Copyright 1993-1996 id Software
+// Copyright 1994-1996 Raven Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2002-2016 Christoph Oelckers
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
-//
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
 //
-// $Log:$
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 //
 // DESCRIPTION:
 //		Rendering main loop and setup functions,
diff --git a/src/s_environment.cpp b/src/s_environment.cpp
index 4dafa706e6..0e3bd12e81 100644
--- a/src/s_environment.cpp
+++ b/src/s_environment.cpp
@@ -1,3 +1,37 @@
+/*
+**
+**
+**---------------------------------------------------------------------------
+** Copyright 2005-2016 Randy Heit
+** Copyright 2005-2016 Christoph Oelckers
+** All rights reserved.
+**
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions
+** are met:
+**
+** 1. Redistributions of source code must retain the above copyright
+**    notice, this list of conditions and the following disclaimer.
+** 2. Redistributions in binary form must reproduce the above copyright
+**    notice, this list of conditions and the following disclaimer in the
+**    documentation and/or other materials provided with the distribution.
+** 3. The name of the author may not be used to endorse or promote products
+**    derived from this software without specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+**---------------------------------------------------------------------------
+**
+*/
+
 #include "doomtype.h"
 #include "tarray.h"
 #include "s_sound.h"
diff --git a/src/s_sndseq.cpp b/src/s_sndseq.cpp
index 589dcc0530..dea68cf020 100644
--- a/src/s_sndseq.cpp
+++ b/src/s_sndseq.cpp
@@ -1,13 +1,24 @@
-//**************************************************************************
-//**
-//** sn_sonix.c : Heretic 2 : Raven Software, Corp.
-//**
-//** $RCSfile: sn_sonix.c,v $
-//** $Revision: 1.17 $
-//** $Date: 95/10/05 18:25:44 $
-//** $Author: paul $
-//**
-//**************************************************************************
+//-----------------------------------------------------------------------------
+//
+// Copyright 1994-1996 Raven Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2002-2016 Christoph Oelckers
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
+//
 
 #include <string.h>
 #include <stdio.h>
diff --git a/src/s_sound.cpp b/src/s_sound.cpp
index f5fc2ed13e..3d678b7d26 100644
--- a/src/s_sound.cpp
+++ b/src/s_sound.cpp
@@ -1,24 +1,57 @@
-// Emacs style mode select	 -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id: s_sound.c,v 1.3 1998/01/05 16:26:08 pekangas Exp $
+// Copyright 1993-1996 id Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2002-2016 Christoph Oelckers
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
-//
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
 //
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 //
 // DESCRIPTION:  none
 //
 //-----------------------------------------------------------------------------
 
+/* For code that originates from ZDoom the following applies:
+**
+**---------------------------------------------------------------------------
+**
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions
+** are met:
+**
+** 1. Redistributions of source code must retain the above copyright
+**    notice, this list of conditions and the following disclaimer.
+** 2. Redistributions in binary form must reproduce the above copyright
+**    notice, this list of conditions and the following disclaimer in the
+**    documentation and/or other materials provided with the distribution.
+** 3. The name of the author may not be used to endorse or promote products
+**    derived from this software without specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+**---------------------------------------------------------------------------
+**
+*/
 
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/src/s_sound.h b/src/s_sound.h
index 5bfc790db6..779bae295d 100644
--- a/src/s_sound.h
+++ b/src/s_sound.h
@@ -1,16 +1,23 @@
-// Emacs style mode select	 -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// Copyright 1993-1996 id Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2002-2016 Christoph Oelckers
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 //
 // DESCRIPTION:
 //		The not so system specific sound interface.
diff --git a/src/sc_man.cpp b/src/sc_man.cpp
index ee31e0f6de..590cba58c7 100644
--- a/src/sc_man.cpp
+++ b/src/sc_man.cpp
@@ -1,14 +1,60 @@
+/* For code that originates from ZDoom the following applies:
+**
+**---------------------------------------------------------------------------
+** Copyright 2005-2016 Randy Heit
+** Copyright 2005-2016 Christoph Oelckers
+** All rights reserved.
+**
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions
+** are met:
+**
+** 1. Redistributions of source code must retain the above copyright
+**    notice, this list of conditions and the following disclaimer.
+** 2. Redistributions in binary form must reproduce the above copyright
+**    notice, this list of conditions and the following disclaimer in the
+**    documentation and/or other materials provided with the distribution.
+** 3. The name of the author may not be used to endorse or promote products
+**    derived from this software without specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+**---------------------------------------------------------------------------
+**
+*/
+
+// This file contains some code by Raven Software, licensed under:
+
+//-----------------------------------------------------------------------------
+//
+// Copyright 1994-1996 Raven Software
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
+//
+
+
 
-//**************************************************************************
-//**
-//** sc_man.c : Heretic 2 : Raven Software, Corp.
-//**
-//** $RCSfile: sc_man.c,v $
-//** $Revision: 1.3 $
-//** $Date: 96/01/06 03:23:43 $
-//** $Author: bgokey $
-//**
-//**************************************************************************
 
 // HEADER FILES ------------------------------------------------------------
 
diff --git a/src/sc_man_scanner.re b/src/sc_man_scanner.re
index 0c3da78bf4..0dd74009aa 100644
--- a/src/sc_man_scanner.re
+++ b/src/sc_man_scanner.re
@@ -1,3 +1,38 @@
+/*
+**
+**
+**---------------------------------------------------------------------------
+** Copyright 2005-2016 Randy Heit
+** Copyright 2005-2016 Christoph Oelckers
+** All rights reserved.
+**
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions
+** are met:
+**
+** 1. Redistributions of source code must retain the above copyright
+**    notice, this list of conditions and the following disclaimer.
+** 2. Redistributions in binary form must reproduce the above copyright
+**    notice, this list of conditions and the following disclaimer in the
+**    documentation and/or other materials provided with the distribution.
+** 3. The name of the author may not be used to endorse or promote products
+**    derived from this software without specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+**---------------------------------------------------------------------------
+**
+*/
+
+
 #define	YYCTYPE		unsigned char
 #define	YYCURSOR	cursor
 #define	YYLIMIT		limit
diff --git a/src/st_stuff.cpp b/src/st_stuff.cpp
index ea3de557bb..fe96d62655 100644
--- a/src/st_stuff.cpp
+++ b/src/st_stuff.cpp
@@ -1,20 +1,24 @@
-// Emacs style mode select	 -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id:$
+// Copyright 1993-1996 id Software
+// Copyright 1994-1996 Raven Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2002-2016 Christoph Oelckers
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
-//
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
 //
-// $Log:$
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 //
 // DESCRIPTION:
 //		Cheat code. See *_sbar.cpp for status bars.
diff --git a/src/st_stuff.h b/src/st_stuff.h
index 19e17a1114..cb40988048 100644
--- a/src/st_stuff.h
+++ b/src/st_stuff.h
@@ -1,26 +1,3 @@
-// Emacs style mode select	 -*- C++ -*- 
-//-----------------------------------------------------------------------------
-//
-// $Id:$
-//
-// Copyright (C) 1993-1996 by id Software, Inc.
-//
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
-//
-// The source is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
-//
-// DESCRIPTION:
-//		Status bar code.
-//		Does the face/direction indicator animatin.
-//		Does palette indicators as well (red pain/berserk, bright pickup)
-//
-//-----------------------------------------------------------------------------
-
 #ifndef __STSTUFF_H__
 #define __STSTUFF_H__
 
diff --git a/src/swrenderer/line/r_line.cpp b/src/swrenderer/line/r_line.cpp
index d0c8f08b2d..95b0b1d8c0 100644
--- a/src/swrenderer/line/r_line.cpp
+++ b/src/swrenderer/line/r_line.cpp
@@ -307,7 +307,7 @@ namespace swrenderer
 
 #ifdef RANGECHECK
 		if (start >= viewwidth || start >= stop)
-			I_FatalError("Bad R_StoreWallRange: %i to %i", start, stop);
+			I_Error("Bad R_StoreWallRange: %i to %i", start, stop);
 #endif
 
 		if (!rw_prepped)
diff --git a/src/swrenderer/plane/r_flatplane.cpp b/src/swrenderer/plane/r_flatplane.cpp
index 394bf9a46a..28be2aa25a 100644
--- a/src/swrenderer/plane/r_flatplane.cpp
+++ b/src/swrenderer/plane/r_flatplane.cpp
@@ -160,7 +160,7 @@ namespace swrenderer
 #ifdef RANGECHECK
 		if (x2 < x1 || x1<0 || x2 >= viewwidth || (unsigned)y >= (unsigned)viewheight)
 		{
-			I_FatalError("R_MapPlane: %i, %i at %i", x1, x2, y);
+			I_Error("R_MapPlane: %i, %i at %i", x1, x2, y);
 		}
 #endif
 
diff --git a/src/swrenderer/viewport/r_viewport.h b/src/swrenderer/viewport/r_viewport.h
index 6a58cebd32..1263425ac2 100644
--- a/src/swrenderer/viewport/r_viewport.h
+++ b/src/swrenderer/viewport/r_viewport.h
@@ -1,15 +1,3 @@
-//
-// Copyright (C) 1993-1996 by id Software, Inc.
-//
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
-//
-// The source is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
-//
 
 #pragma once
 
diff --git a/src/v_video.cpp b/src/v_video.cpp
index 49cf088ea8..651d3d7de8 100644
--- a/src/v_video.cpp
+++ b/src/v_video.cpp
@@ -1,21 +1,38 @@
-// Emacs style mode select	 -*- C++ -*- 
+/*
+**
+**
+**---------------------------------------------------------------------------
+** Copyright 1999-2016 Randy Heit
+** Copyright 2005-2016 Christoph Oelckers
+** All rights reserved.
+**
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions
+** are met:
+**
+** 1. Redistributions of source code must retain the above copyright
+**    notice, this list of conditions and the following disclaimer.
+** 2. Redistributions in binary form must reproduce the above copyright
+**    notice, this list of conditions and the following disclaimer in the
+**    documentation and/or other materials provided with the distribution.
+** 3. The name of the author may not be used to endorse or promote products
+**    derived from this software without specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+**---------------------------------------------------------------------------
+**
+*/
 //-----------------------------------------------------------------------------
 //
-// $Id:$
-//
-// Copyright (C) 1993-1996 by id Software, Inc.
-//
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
-//
-// The source is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
-//
-// $Log:$
-//
 // DESCRIPTION:
 //		Functions to draw patches (by post) directly to screen->
 //		Functions to blit a block to the screen->
diff --git a/src/w_wad.h b/src/w_wad.h
index 5eaea8fab1..52be4e79f2 100644
--- a/src/w_wad.h
+++ b/src/w_wad.h
@@ -1,19 +1,5 @@
-// Emacs style mode select   -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id:$
-//
-// Copyright (C) 1993-1996 by id Software, Inc.
-//
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
-//
-// The source is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
-//
 // DESCRIPTION:
 //	WAD I/O functions.
 //
diff --git a/src/wi_stuff.h b/src/wi_stuff.h
index 16e566f8db..4b12820f00 100644
--- a/src/wi_stuff.h
+++ b/src/wi_stuff.h
@@ -1,18 +1,23 @@
-// Emacs style mode select	 -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id:$
+// Copyright 1993-1996 id Software
+// Copyright 1999-2016 Randy Heit
+// Copyright 2002-2016 Christoph Oelckers
 //
-// Copyright (C) 1993-1996 by id Software, Inc.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
 //
-// This source is available for distribution and/or modification
-// only under the terms of the DOOM Source Code License as
-// published by id Software. All rights reserved.
-//
-// The source is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
-// for more details.
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
 //
 // DESCRIPTION:
 //	Intermission.
diff --git a/src/x86.cpp b/src/x86.cpp
index dff76c9576..20df06aa18 100644
--- a/src/x86.cpp
+++ b/src/x86.cpp
@@ -1,3 +1,37 @@
+/*
+**
+**
+**---------------------------------------------------------------------------
+** Copyright 2005-2016 Randy Heit
+** Copyright 2005-2016 Christoph Oelckers
+** All rights reserved.
+**
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions
+** are met:
+**
+** 1. Redistributions of source code must retain the above copyright
+**    notice, this list of conditions and the following disclaimer.
+** 2. Redistributions in binary form must reproduce the above copyright
+**    notice, this list of conditions and the following disclaimer in the
+**    documentation and/or other materials provided with the distribution.
+** 3. The name of the author may not be used to endorse or promote products
+**    derived from this software without specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+**---------------------------------------------------------------------------
+**
+*/
+
 #include "doomtype.h"
 #include "doomdef.h"
 #include "x86.h"
diff --git a/wadsrc/static/zscript/zscript_license.txt b/wadsrc/static/zscript/zscript_license.txt
new file mode 100644
index 0000000000..50a89061ca
--- /dev/null
+++ b/wadsrc/static/zscript/zscript_license.txt
@@ -0,0 +1,21 @@
+Unless noted differently in the file, the following license applies to all ZScript sources:
+
+//-----------------------------------------------------------------------------
+//
+// Copyright 1993-2017 id Software, Randy Heit, Christoph Oelckers et.al.
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see http://www.gnu.org/licenses/
+//
+//-----------------------------------------------------------------------------
+//
\ No newline at end of file

From a48a3d0abf4914d0f6d745722461e7b77e0f22af Mon Sep 17 00:00:00 2001
From: Christoph Oelckers <coelckers@users.noreply.github.com>
Date: Mon, 17 Apr 2017 15:37:45 +0200
Subject: [PATCH 21/29] - fixed some signedness warnings in OPL code.

---
 src/sound/oplsynth/musicblock.cpp | 7 +++----
 src/sound/oplsynth/musicblock.h   | 2 +-
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/src/sound/oplsynth/musicblock.cpp b/src/sound/oplsynth/musicblock.cpp
index 5de26f76fe..d905744d44 100644
--- a/src/sound/oplsynth/musicblock.cpp
+++ b/src/sound/oplsynth/musicblock.cpp
@@ -36,7 +36,7 @@
 musicBlock::musicBlock ()
 {
 	memset (this, 0, sizeof(*this));
-	for(auto &voice : voices) voice.index = -1;	// mark all free.
+	for(auto &voice : voices) voice.index = ~0u;	// mark all free.
 }
 
 musicBlock::~musicBlock ()
@@ -53,7 +53,7 @@ int musicBlock::releaseVoice(uint32_t slot, uint32_t killed)
 {
 	struct OPLVoice *ch = &voices[slot];
 	io->WriteFrequency(slot, ch->note, ch->pitch, 0);
-	ch->index = -1;
+	ch->index = ~0u;
 	if (killed) io->MuteChannel(slot);
 	return slot;
 }
@@ -68,7 +68,7 @@ int musicBlock::findFreeVoice()
 {
 	for (uint32_t i = 0; i < io->NumChannels; ++i)
 	{
-		if (voices[i].index == -1)
+		if (voices[i].index == ~0u)
 		{
 			releaseVoice(i, 1);
 			return i;
@@ -185,7 +185,6 @@ void musicBlock::noteOn(uint32_t channel, uint8_t key, int volume)
 		noteOff(channel, key);
 		return;
 	}
-	uint32_t note;
 	GenMidiInstrument *instrument;
 
 	// Percussion channel is treated differently.
diff --git a/src/sound/oplsynth/musicblock.h b/src/sound/oplsynth/musicblock.h
index e806a45e6f..815e3d2679 100644
--- a/src/sound/oplsynth/musicblock.h
+++ b/src/sound/oplsynth/musicblock.h
@@ -6,7 +6,7 @@
 
 struct OPLVoice 
 {
-	int index;					// Index of this voice, or -1 if not in use.
+	unsigned int index;			// Index of this voice, or -1 if not in use.
 	unsigned int key;			// The midi key that this voice is playing.
 	unsigned int note;			// The note being played.  This is normally the same as the key, but if the instrument is a fixed pitch instrument, it is different.
 	unsigned int note_volume;	// The volume of the note being played on this channel.

From 7405f541e84cf3451bc936811f620ae688fc3910 Mon Sep 17 00:00:00 2001
From: Christoph Oelckers <coelckers@users.noreply.github.com>
Date: Mon, 17 Apr 2017 17:05:09 +0200
Subject: [PATCH 22/29] - allow dynamic loading of all sound related libraries
 without providing any SDK at all.

The needed headers are now included in the repo, which for these libraries is possible thanks to a stable ABI (at least on Windows, the other platforms still need to be checked but the headers only add, never remove or change existing content.)
The big advantage of this setup is that it allows building the project on Windows without any necessary setup - all that needs to be provided is the DLLs from the binary package.
This still requires some fixes for macOS and Linux. On MacOS the proper library names are missing and the ones for Linux are not verified. Both platforms should work, though, if the dynamic loading is disabled.
---
 src/CMakeLists.txt             |   43 +-
 src/sound/mpg123_decoder.cpp   |   49 +-
 src/sound/mpg123_decoder.h     |    5 +
 src/sound/mpgload.h            |   40 ++
 src/sound/oaldef.h             |   93 ---
 src/sound/oalload.h            |   94 ++-
 src/sound/oalsound.h           |    9 +-
 src/sound/sndfile_decoder.cpp  |   63 +-
 src/sound/sndfile_decoder.h    |    4 +
 src/sound/sndload.h            |   23 +
 src/sound/thirdparty/al.h      |  656 +++++++++++++++++
 src/sound/thirdparty/alc.h     |  237 +++++++
 src/sound/thirdparty/alext.h   |  400 +++++++++++
 src/sound/thirdparty/efx.h     |  761 ++++++++++++++++++++
 src/sound/thirdparty/mpg123.h  | 1202 ++++++++++++++++++++++++++++++++
 src/sound/thirdparty/sndfile.h |  666 ++++++++++++++++++
 16 files changed, 4201 insertions(+), 144 deletions(-)
 create mode 100644 src/sound/mpgload.h
 delete mode 100644 src/sound/oaldef.h
 create mode 100644 src/sound/sndload.h
 create mode 100644 src/sound/thirdparty/al.h
 create mode 100644 src/sound/thirdparty/alc.h
 create mode 100644 src/sound/thirdparty/alext.h
 create mode 100644 src/sound/thirdparty/efx.h
 create mode 100644 src/sound/thirdparty/mpg123.h
 create mode 100644 src/sound/thirdparty/sndfile.h

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 541dc01501..9d7582e9fa 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -25,6 +25,8 @@ endif()
 
 option( DYN_FLUIDSYNTH "Dynamically load fluidsynth" ON )
 option( DYN_OPENAL "Dynamically load OpenAL" ON )
+option( DYN_SNDFILE "Dynamically load libsndfile" ON )
+option( DYN_MPG123 "Dynamically load libmpg123" ON )
 
 if( APPLE )
     option( OSX_COCOA_BACKEND "Use native Cocoa backend instead of SDL" ON )
@@ -192,22 +194,22 @@ else()
 endif()
 
 if( NOT NO_OPENAL )
-	find_package( OpenAL )
-	mark_as_advanced(CLEAR OPENAL_INCLUDE_DIR)
-	if( OPENAL_INCLUDE_DIR )
-		include_directories( ${OPENAL_INCLUDE_DIR} )
-		if( DYN_OPENAL )
-			add_definitions( -DDYN_OPENAL )
-		else()
+	if ( NOT DYN_OPENAL )	# DYN_OPENAL uses local copies of the headers.
+		find_package( OpenAL )
+		mark_as_advanced(CLEAR OPENAL_INCLUDE_DIR)
+		if( OPENAL_INCLUDE_DIR )
+			include_directories( ${OPENAL_INCLUDE_DIR} )
 			mark_as_advanced(CLEAR OPENAL_LIBRARY)
 			if( OPENAL_LIBRARY )
 				set( ZDOOM_LIBS ${OPENAL_LIBRARY} ${ZDOOM_LIBS} )
 			else()
 				set( NO_OPENAL ON )
 			endif()
+		else()
+			set( NO_OPENAL ON )
 		endif()
 	else()
-		set( NO_OPENAL ON )
+		add_definitions( -DDYN_OPENAL )
 	endif()
 endif()
 
@@ -219,11 +221,15 @@ if( NO_OPENAL )
 else()
 	# Search for libSndFile
 
-	find_package( SndFile )
+	if ( NOT DYN_SNDFILE )
+		find_package( SndFile )
+	endif()
 
 	# Search for libmpg123
 
-	find_package( MPG123 )
+	if ( NOT DYN_MPG123 )
+		find_package( MPG123 )
+	endif()
 endif()
 
 # Search for FluidSynth
@@ -580,12 +586,18 @@ add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/sc_man_scanner.h
 
 include_directories( ${CMAKE_CURRENT_BINARY_DIR} )
 
-if( SNDFILE_FOUND )
-    add_definitions( -DHAVE_SNDFILE )
+if( DYN_SNDFILE)
+	add_definitions( -DHAVE_SNDFILE -DDYN_SNDFILE )
+elseif( SNDFILE_FOUND )
+	add_definitions( -DHAVE_SNDFILE )
 endif()
-if( MPG123_FOUND )
-    add_definitions( -DHAVE_MPG123 )
+
+if( DYN_MPG123)
+	add_definitions( -DHAVE_MPG123 -DDYN_MPG123 )
+elseif( MPG123_FOUND )
+	add_definitions( -DHAVE_MPG123 )
 endif()
+
 if( DYN_FLUIDSYNTH )
 	add_definitions( -DHAVE_FLUIDSYNTH -DDYN_FLUIDSYNTH )
 elseif( FLUIDSYNTH_FOUND )
@@ -1225,9 +1237,6 @@ if( MSVC )
 	if( ZDOOM_GENERATE_MAPFILE )
 		set( LINKERSTUFF "${LINKERSTUFF} /MAP" )
 	endif()
-	if( NOT NO_OPENAL )
-		set( LINKERSTUFF "${LINKERSTUFF} /DELAYLOAD:\"libmpg123-0.dll\" /DELAYLOAD:\"libsndfile-1.dll\"" )
-	endif()
 	set_target_properties(zdoom PROPERTIES LINK_FLAGS ${LINKERSTUFF})
 
 	add_custom_command(TARGET zdoom POST_BUILD
diff --git a/src/sound/mpg123_decoder.cpp b/src/sound/mpg123_decoder.cpp
index f5c9a86af1..4aaac0025a 100644
--- a/src/sound/mpg123_decoder.cpp
+++ b/src/sound/mpg123_decoder.cpp
@@ -38,8 +38,42 @@
 #include "mpg123_decoder.h"
 #include "files.h"
 #include "except.h"
+#include "i_module.h"
+#include "cmdlib.h"
 
 #ifdef HAVE_MPG123
+
+
+FModule MPG123Module{"MPG123"};
+
+#include "mpgload.h"
+
+#ifdef _WIN32
+#define MPG123LIB "libmpg123-0.dll"
+#elif defined(__APPLE__)
+#define MPG123LIB ""
+#else
+#define MPG123LIB "libmpg123.so.1"
+#endif
+
+bool IsMPG123Present()
+{
+#if !defined DYN_MPG123
+	return true;
+#else
+	static bool cached_result = false;
+	static bool done = false;
+
+	if (!done)
+	{
+		done = true;
+		cached_result = MPG123Module.Load({NicePath("$PROGDIR/" MPG123LIB), MPG123LIB});
+	}
+	return cached_result;
+#endif
+}
+
+
 static bool inited = false;
 
 
@@ -84,18 +118,9 @@ bool MPG123Decoder::open(FileReader *reader)
 {
     if(!inited)
     {
-#ifdef _MSC_VER
-		__try {
-#endif
-			if(mpg123_init() != MPG123_OK)
-				return false;
-			inited = true;
-#ifdef _MSC_VER
-        } __except (CheckException(GetExceptionCode())) {
-			// this means that the delay loaded decoder DLL was not found.
-			return false;
-		}
-#endif
+		if (!IsMPG123Present()) return false;
+		if(mpg123_init() != MPG123_OK) return false;
+		inited = true;
     }
 
     Reader = reader;
diff --git a/src/sound/mpg123_decoder.h b/src/sound/mpg123_decoder.h
index e1c786888d..fa20f0b3ce 100644
--- a/src/sound/mpg123_decoder.h
+++ b/src/sound/mpg123_decoder.h
@@ -9,7 +9,12 @@
 #include <stddef.h>
 typedef ptrdiff_t ssize_t;
 #endif
+
+#ifndef DYN_MPG123
 #include "mpg123.h"
+#else
+#include "thirdparty/mpg123.h"
+#endif
 
 struct MPG123Decoder : public SoundDecoder
 {
diff --git a/src/sound/mpgload.h b/src/sound/mpgload.h
new file mode 100644
index 0000000000..f93f08c472
--- /dev/null
+++ b/src/sound/mpgload.h
@@ -0,0 +1,40 @@
+#ifndef MPGDEF_H
+#define MPGDEF_H
+
+#if defined HAVE_MPG123 && defined DYN_MPG123
+
+#define DEFINE_ENTRY(type, name) static TReqProc<MPG123Module, type> p_##name{#name};
+DEFINE_ENTRY(int (*)(mpg123_handle *mh), mpg123_close)
+DEFINE_ENTRY(void (*)(mpg123_handle *mh), mpg123_delete)
+DEFINE_ENTRY(int (*)(void), mpg123_init)
+DEFINE_ENTRY(mpg123_handle* (*)(const char* decoder, int *error), mpg123_new)
+DEFINE_ENTRY(int (*)(mpg123_handle *mh, ssize_t (*r_read) (void *, void *, size_t), off_t (*r_lseek)(void *, off_t, int), void (*cleanup)(void*)), mpg123_replace_reader_handle)
+DEFINE_ENTRY(int (*)(mpg123_handle *mh, void *iohandle), mpg123_open_handle)
+DEFINE_ENTRY(int (*)(mpg123_handle *mh, long *rate, int *channels, int *encoding), mpg123_getformat)
+DEFINE_ENTRY(int (*)(mpg123_handle *mh), mpg123_format_none)
+DEFINE_ENTRY(int (*)(mpg123_handle *mh, unsigned char *outmemory, size_t outmemsize, size_t *done), mpg123_read)
+DEFINE_ENTRY(off_t (*)(mpg123_handle *mh, off_t sampleoff, int whence), mpg123_seek)
+DEFINE_ENTRY(int (*)(mpg123_handle *mh, long rate, int channels, int encodings), mpg123_format)
+DEFINE_ENTRY(off_t (*)(mpg123_handle *mh), mpg123_tell)
+DEFINE_ENTRY(off_t (*)(mpg123_handle *mh), mpg123_length)
+
+#undef DEFINE_ENTRY
+
+#ifndef IN_IDE_PARSER
+#define mpg123_close p_mpg123_close
+#define mpg123_delete p_mpg123_delete
+#define mpg123_init p_mpg123_init
+#define mpg123_new p_mpg123_new
+#define mpg123_replace_reader_handle p_mpg123_replace_reader_handle
+#define mpg123_open_handle p_mpg123_open_handle
+#define mpg123_getformat p_mpg123_getformat
+#define mpg123_format_none p_mpg123_format_none
+#define mpg123_read p_mpg123_read
+#define mpg123_seek p_mpg123_seek
+#define mpg123_tell p_mpg123_tell
+#define mpg123_format p_mpg123_format
+#define mpg123_length p_mpg123_length
+#endif
+
+#endif
+#endif
diff --git a/src/sound/oaldef.h b/src/sound/oaldef.h
deleted file mode 100644
index f51c27b3f0..0000000000
--- a/src/sound/oaldef.h
+++ /dev/null
@@ -1,93 +0,0 @@
-DEFINE_ENTRY(LPALENABLE,alEnable)
-DEFINE_ENTRY(LPALDISABLE, alDisable)
-DEFINE_ENTRY(LPALISENABLED, alIsEnabled)
-DEFINE_ENTRY(LPALGETSTRING, alGetString)
-DEFINE_ENTRY(LPALGETBOOLEANV, alGetBooleanv)
-DEFINE_ENTRY(LPALGETINTEGERV, alGetIntegerv)
-DEFINE_ENTRY(LPALGETFLOATV, alGetFloatv)
-DEFINE_ENTRY(LPALGETDOUBLEV, alGetDoublev)
-DEFINE_ENTRY(LPALGETBOOLEAN, alGetBoolean)
-DEFINE_ENTRY(LPALGETINTEGER, alGetInteger)
-DEFINE_ENTRY(LPALGETFLOAT, alGetFloat)
-DEFINE_ENTRY(LPALGETDOUBLE, alGetDouble)
-DEFINE_ENTRY(LPALGETERROR, alGetError)
-DEFINE_ENTRY(LPALISEXTENSIONPRESENT, alIsExtensionPresent)
-DEFINE_ENTRY(LPALGETPROCADDRESS, alGetProcAddress)
-DEFINE_ENTRY(LPALGETENUMVALUE, alGetEnumValue)
-DEFINE_ENTRY(LPALLISTENERF, alListenerf)
-DEFINE_ENTRY(LPALLISTENER3F, alListener3f)
-DEFINE_ENTRY(LPALLISTENERFV, alListenerfv)
-DEFINE_ENTRY(LPALLISTENERI, alListeneri)
-DEFINE_ENTRY(LPALLISTENER3I, alListener3i)
-DEFINE_ENTRY(LPALLISTENERIV, alListeneriv)
-DEFINE_ENTRY(LPALGETLISTENERF, alGetListenerf)
-DEFINE_ENTRY(LPALGETLISTENER3F, alGetListener3f)
-DEFINE_ENTRY(LPALGETLISTENERFV, alGetListenerfv)
-DEFINE_ENTRY(LPALGETLISTENERI, alGetListeneri)
-DEFINE_ENTRY(LPALGETLISTENER3I, alGetListener3i)
-DEFINE_ENTRY(LPALGETLISTENERIV, alGetListeneriv)
-DEFINE_ENTRY(LPALGENSOURCES, alGenSources)
-DEFINE_ENTRY(LPALDELETESOURCES, alDeleteSources)
-DEFINE_ENTRY(LPALISSOURCE, alIsSource)
-DEFINE_ENTRY(LPALSOURCEF, alSourcef)
-DEFINE_ENTRY(LPALSOURCE3F, alSource3f)
-DEFINE_ENTRY(LPALSOURCEFV, alSourcefv)
-DEFINE_ENTRY(LPALSOURCEI, alSourcei)
-DEFINE_ENTRY(LPALSOURCE3I, alSource3i)
-DEFINE_ENTRY(LPALSOURCEIV, alSourceiv)
-DEFINE_ENTRY(LPALGETSOURCEF, alGetSourcef)
-DEFINE_ENTRY(LPALGETSOURCE3F, alGetSource3f)
-DEFINE_ENTRY(LPALGETSOURCEFV, alGetSourcefv)
-DEFINE_ENTRY(LPALGETSOURCEI, alGetSourcei)
-DEFINE_ENTRY(LPALGETSOURCE3I, alGetSource3i)
-DEFINE_ENTRY(LPALGETSOURCEIV, alGetSourceiv)
-DEFINE_ENTRY(LPALSOURCEPLAYV, alSourcePlayv)
-DEFINE_ENTRY(LPALSOURCESTOPV, alSourceStopv)
-DEFINE_ENTRY(LPALSOURCEREWINDV, alSourceRewindv)
-DEFINE_ENTRY(LPALSOURCEPAUSEV, alSourcePausev)
-DEFINE_ENTRY(LPALSOURCEPLAY, alSourcePlay)
-DEFINE_ENTRY(LPALSOURCESTOP, alSourceStop)
-DEFINE_ENTRY(LPALSOURCEREWIND, alSourceRewind)
-DEFINE_ENTRY(LPALSOURCEPAUSE, alSourcePause)
-DEFINE_ENTRY(LPALSOURCEQUEUEBUFFERS, alSourceQueueBuffers)
-DEFINE_ENTRY(LPALSOURCEUNQUEUEBUFFERS, alSourceUnqueueBuffers)
-DEFINE_ENTRY(LPALGENBUFFERS, alGenBuffers)
-DEFINE_ENTRY(LPALDELETEBUFFERS, alDeleteBuffers)
-DEFINE_ENTRY(LPALISBUFFER, alIsBuffer)
-DEFINE_ENTRY(LPALBUFFERDATA, alBufferData)
-DEFINE_ENTRY(LPALBUFFERF, alBufferf)
-DEFINE_ENTRY(LPALBUFFER3F, alBuffer3f)
-DEFINE_ENTRY(LPALBUFFERFV, alBufferfv)
-DEFINE_ENTRY(LPALBUFFERI, alBufferi)
-DEFINE_ENTRY(LPALBUFFER3I, alBuffer3i)
-DEFINE_ENTRY(LPALBUFFERIV, alBufferiv)
-DEFINE_ENTRY(LPALGETBUFFERF, alGetBufferf)
-DEFINE_ENTRY(LPALGETBUFFER3F, alGetBuffer3f)
-DEFINE_ENTRY(LPALGETBUFFERFV, alGetBufferfv)
-DEFINE_ENTRY(LPALGETBUFFERI, alGetBufferi)
-DEFINE_ENTRY(LPALGETBUFFER3I, alGetBuffer3i)
-DEFINE_ENTRY(LPALGETBUFFERIV, alGetBufferiv)
-DEFINE_ENTRY(LPALDOPPLERFACTOR, alDopplerFactor)
-DEFINE_ENTRY(LPALDOPPLERVELOCITY, alDopplerVelocity)
-DEFINE_ENTRY(LPALSPEEDOFSOUND, alSpeedOfSound)
-DEFINE_ENTRY(LPALDISTANCEMODEL, alDistanceModel)
-DEFINE_ENTRY(LPALCCREATECONTEXT, alcCreateContext)
-DEFINE_ENTRY(LPALCMAKECONTEXTCURRENT, alcMakeContextCurrent)
-DEFINE_ENTRY(LPALCPROCESSCONTEXT, alcProcessContext)
-DEFINE_ENTRY(LPALCSUSPENDCONTEXT, alcSuspendContext)
-DEFINE_ENTRY(LPALCDESTROYCONTEXT, alcDestroyContext)
-DEFINE_ENTRY(LPALCGETCURRENTCONTEXT, alcGetCurrentContext)
-DEFINE_ENTRY(LPALCGETCONTEXTSDEVICE, alcGetContextsDevice)
-DEFINE_ENTRY(LPALCOPENDEVICE, alcOpenDevice)
-DEFINE_ENTRY(LPALCCLOSEDEVICE, alcCloseDevice)
-DEFINE_ENTRY(LPALCGETERROR, alcGetError)
-DEFINE_ENTRY(LPALCISEXTENSIONPRESENT, alcIsExtensionPresent)
-DEFINE_ENTRY(LPALCGETPROCADDRESS, alcGetProcAddress)
-DEFINE_ENTRY(LPALCGETENUMVALUE, alcGetEnumValue)
-DEFINE_ENTRY(LPALCGETSTRING, alcGetString)
-DEFINE_ENTRY(LPALCGETINTEGERV, alcGetIntegerv)
-DEFINE_ENTRY(LPALCCAPTUREOPENDEVICE, alcCaptureOpenDevice)
-DEFINE_ENTRY(LPALCCAPTURECLOSEDEVICE, alcCaptureCloseDevice)
-DEFINE_ENTRY(LPALCCAPTURESTART, alcCaptureStart)
-DEFINE_ENTRY(LPALCCAPTURESTOP, alcCaptureStop)
-DEFINE_ENTRY(LPALCCAPTURESAMPLES, alcCaptureSamples)
diff --git a/src/sound/oalload.h b/src/sound/oalload.h
index 1fcf537732..3c7c96b80b 100644
--- a/src/sound/oalload.h
+++ b/src/sound/oalload.h
@@ -4,7 +4,99 @@
 #if !defined NO_OPENAL && defined DYN_OPENAL
 
 #define DEFINE_ENTRY(type, name) static TReqProc<OpenALModule, type> p_##name{#name};
-#include "oaldef.h"
+DEFINE_ENTRY(LPALENABLE,alEnable)
+DEFINE_ENTRY(LPALDISABLE, alDisable)
+DEFINE_ENTRY(LPALISENABLED, alIsEnabled)
+DEFINE_ENTRY(LPALGETSTRING, alGetString)
+DEFINE_ENTRY(LPALGETBOOLEANV, alGetBooleanv)
+DEFINE_ENTRY(LPALGETINTEGERV, alGetIntegerv)
+DEFINE_ENTRY(LPALGETFLOATV, alGetFloatv)
+DEFINE_ENTRY(LPALGETDOUBLEV, alGetDoublev)
+DEFINE_ENTRY(LPALGETBOOLEAN, alGetBoolean)
+DEFINE_ENTRY(LPALGETINTEGER, alGetInteger)
+DEFINE_ENTRY(LPALGETFLOAT, alGetFloat)
+DEFINE_ENTRY(LPALGETDOUBLE, alGetDouble)
+DEFINE_ENTRY(LPALGETERROR, alGetError)
+DEFINE_ENTRY(LPALISEXTENSIONPRESENT, alIsExtensionPresent)
+DEFINE_ENTRY(LPALGETPROCADDRESS, alGetProcAddress)
+DEFINE_ENTRY(LPALGETENUMVALUE, alGetEnumValue)
+DEFINE_ENTRY(LPALLISTENERF, alListenerf)
+DEFINE_ENTRY(LPALLISTENER3F, alListener3f)
+DEFINE_ENTRY(LPALLISTENERFV, alListenerfv)
+DEFINE_ENTRY(LPALLISTENERI, alListeneri)
+DEFINE_ENTRY(LPALLISTENER3I, alListener3i)
+DEFINE_ENTRY(LPALLISTENERIV, alListeneriv)
+DEFINE_ENTRY(LPALGETLISTENERF, alGetListenerf)
+DEFINE_ENTRY(LPALGETLISTENER3F, alGetListener3f)
+DEFINE_ENTRY(LPALGETLISTENERFV, alGetListenerfv)
+DEFINE_ENTRY(LPALGETLISTENERI, alGetListeneri)
+DEFINE_ENTRY(LPALGETLISTENER3I, alGetListener3i)
+DEFINE_ENTRY(LPALGETLISTENERIV, alGetListeneriv)
+DEFINE_ENTRY(LPALGENSOURCES, alGenSources)
+DEFINE_ENTRY(LPALDELETESOURCES, alDeleteSources)
+DEFINE_ENTRY(LPALISSOURCE, alIsSource)
+DEFINE_ENTRY(LPALSOURCEF, alSourcef)
+DEFINE_ENTRY(LPALSOURCE3F, alSource3f)
+DEFINE_ENTRY(LPALSOURCEFV, alSourcefv)
+DEFINE_ENTRY(LPALSOURCEI, alSourcei)
+DEFINE_ENTRY(LPALSOURCE3I, alSource3i)
+DEFINE_ENTRY(LPALSOURCEIV, alSourceiv)
+DEFINE_ENTRY(LPALGETSOURCEF, alGetSourcef)
+DEFINE_ENTRY(LPALGETSOURCE3F, alGetSource3f)
+DEFINE_ENTRY(LPALGETSOURCEFV, alGetSourcefv)
+DEFINE_ENTRY(LPALGETSOURCEI, alGetSourcei)
+DEFINE_ENTRY(LPALGETSOURCE3I, alGetSource3i)
+DEFINE_ENTRY(LPALGETSOURCEIV, alGetSourceiv)
+DEFINE_ENTRY(LPALSOURCEPLAYV, alSourcePlayv)
+DEFINE_ENTRY(LPALSOURCESTOPV, alSourceStopv)
+DEFINE_ENTRY(LPALSOURCEREWINDV, alSourceRewindv)
+DEFINE_ENTRY(LPALSOURCEPAUSEV, alSourcePausev)
+DEFINE_ENTRY(LPALSOURCEPLAY, alSourcePlay)
+DEFINE_ENTRY(LPALSOURCESTOP, alSourceStop)
+DEFINE_ENTRY(LPALSOURCEREWIND, alSourceRewind)
+DEFINE_ENTRY(LPALSOURCEPAUSE, alSourcePause)
+DEFINE_ENTRY(LPALSOURCEQUEUEBUFFERS, alSourceQueueBuffers)
+DEFINE_ENTRY(LPALSOURCEUNQUEUEBUFFERS, alSourceUnqueueBuffers)
+DEFINE_ENTRY(LPALGENBUFFERS, alGenBuffers)
+DEFINE_ENTRY(LPALDELETEBUFFERS, alDeleteBuffers)
+DEFINE_ENTRY(LPALISBUFFER, alIsBuffer)
+DEFINE_ENTRY(LPALBUFFERDATA, alBufferData)
+DEFINE_ENTRY(LPALBUFFERF, alBufferf)
+DEFINE_ENTRY(LPALBUFFER3F, alBuffer3f)
+DEFINE_ENTRY(LPALBUFFERFV, alBufferfv)
+DEFINE_ENTRY(LPALBUFFERI, alBufferi)
+DEFINE_ENTRY(LPALBUFFER3I, alBuffer3i)
+DEFINE_ENTRY(LPALBUFFERIV, alBufferiv)
+DEFINE_ENTRY(LPALGETBUFFERF, alGetBufferf)
+DEFINE_ENTRY(LPALGETBUFFER3F, alGetBuffer3f)
+DEFINE_ENTRY(LPALGETBUFFERFV, alGetBufferfv)
+DEFINE_ENTRY(LPALGETBUFFERI, alGetBufferi)
+DEFINE_ENTRY(LPALGETBUFFER3I, alGetBuffer3i)
+DEFINE_ENTRY(LPALGETBUFFERIV, alGetBufferiv)
+DEFINE_ENTRY(LPALDOPPLERFACTOR, alDopplerFactor)
+DEFINE_ENTRY(LPALDOPPLERVELOCITY, alDopplerVelocity)
+DEFINE_ENTRY(LPALSPEEDOFSOUND, alSpeedOfSound)
+DEFINE_ENTRY(LPALDISTANCEMODEL, alDistanceModel)
+DEFINE_ENTRY(LPALCCREATECONTEXT, alcCreateContext)
+DEFINE_ENTRY(LPALCMAKECONTEXTCURRENT, alcMakeContextCurrent)
+DEFINE_ENTRY(LPALCPROCESSCONTEXT, alcProcessContext)
+DEFINE_ENTRY(LPALCSUSPENDCONTEXT, alcSuspendContext)
+DEFINE_ENTRY(LPALCDESTROYCONTEXT, alcDestroyContext)
+DEFINE_ENTRY(LPALCGETCURRENTCONTEXT, alcGetCurrentContext)
+DEFINE_ENTRY(LPALCGETCONTEXTSDEVICE, alcGetContextsDevice)
+DEFINE_ENTRY(LPALCOPENDEVICE, alcOpenDevice)
+DEFINE_ENTRY(LPALCCLOSEDEVICE, alcCloseDevice)
+DEFINE_ENTRY(LPALCGETERROR, alcGetError)
+DEFINE_ENTRY(LPALCISEXTENSIONPRESENT, alcIsExtensionPresent)
+DEFINE_ENTRY(LPALCGETPROCADDRESS, alcGetProcAddress)
+DEFINE_ENTRY(LPALCGETENUMVALUE, alcGetEnumValue)
+DEFINE_ENTRY(LPALCGETSTRING, alcGetString)
+DEFINE_ENTRY(LPALCGETINTEGERV, alcGetIntegerv)
+DEFINE_ENTRY(LPALCCAPTUREOPENDEVICE, alcCaptureOpenDevice)
+DEFINE_ENTRY(LPALCCAPTURECLOSEDEVICE, alcCaptureCloseDevice)
+DEFINE_ENTRY(LPALCCAPTURESTART, alcCaptureStart)
+DEFINE_ENTRY(LPALCCAPTURESTOP, alcCaptureStop)
+DEFINE_ENTRY(LPALCCAPTURESAMPLES, alcCaptureSamples)
 #undef DEFINE_ENTRY
 
 #ifndef IN_IDE_PARSER
diff --git a/src/sound/oalsound.h b/src/sound/oalsound.h
index 0c54f5ab3c..5e6fe5597f 100644
--- a/src/sound/oalsound.h
+++ b/src/sound/oalsound.h
@@ -14,10 +14,14 @@
 
 #ifdef DYN_OPENAL
 #define AL_NO_PROTOTYPES
-#endif // DYN_OPENAL
-
+#include "thirdparty/al.h"
+#include "thirdparty/alc.h"
+#include "thirdparty/efx.h"
+#else
 #include "al.h"
 #include "alc.h"
+#include "efx.h"
+#endif
 
 #ifndef ALC_ENUMERATE_ALL_EXT
 #define ALC_ENUMERATE_ALL_EXT 1
@@ -70,7 +74,6 @@
 #define AL_SOURCE_RADIUS                         0x1031
 #endif
 
-#include "efx.h"
 
 
 class OpenALSoundStream;
diff --git a/src/sound/sndfile_decoder.cpp b/src/sound/sndfile_decoder.cpp
index 101c39d4a2..f905a980d7 100644
--- a/src/sound/sndfile_decoder.cpp
+++ b/src/sound/sndfile_decoder.cpp
@@ -40,9 +40,42 @@
 #include "files.h"
 #include "xs_Float.h"
 #include "except.h"
+#include "i_module.h"
+#include "cmdlib.h"
 
 #ifdef HAVE_SNDFILE
 
+FModule SndFileModule{"SndFile"};
+
+#include "sndload.h"
+
+
+#ifdef _WIN32
+#define SNDFILELIB "libsndfile-1.dll"
+#elif defined(__APPLE__)
+#define SNDFILELIB ""
+#else
+#define SNDFILELIB "libsndfile.so.1"
+#endif
+
+bool IsSndFilePresent()
+{
+#if !defined DYN_SNDFILE
+	return true;
+#else
+	static bool cached_result = false;
+	static bool done = false;
+
+	if (!done)
+	{
+		done = true;
+		cached_result = SndFileModule.Load({NicePath("$PROGDIR/" SNDFILELIB), SNDFILELIB});
+	}
+	return cached_result;
+#endif
+}
+
+
 sf_count_t SndFileDecoder::file_get_filelen(void *user_data)
 {
     FileReader *reader = reinterpret_cast<SndFileDecoder*>(user_data)->Reader;
@@ -85,27 +118,21 @@ SndFileDecoder::~SndFileDecoder()
 
 bool SndFileDecoder::open(FileReader *reader)
 {
-#ifdef _MSC_VER
-	__try {
-#endif
-		SF_VIRTUAL_IO sfio = { file_get_filelen, file_seek, file_read, file_write, file_tell };
+	if (!IsSndFilePresent()) return false;
+	
+	SF_VIRTUAL_IO sfio = { file_get_filelen, file_seek, file_read, file_write, file_tell };
 
-		Reader = reader;
-		SndInfo.format = 0;
-		SndFile = sf_open_virtual(&sfio, SFM_READ, &SndInfo, this);
-		if (SndFile)
-		{
-			if (SndInfo.channels == 1 || SndInfo.channels == 2)
-				return true;
+	Reader = reader;
+	SndInfo.format = 0;
+	SndFile = sf_open_virtual(&sfio, SFM_READ, &SndInfo, this);
+	if (SndFile)
+	{
+		if (SndInfo.channels == 1 || SndInfo.channels == 2)
+			return true;
 
-			sf_close(SndFile);
-			SndFile = 0;
-		}
-#ifdef _MSC_VER
-	} __except (CheckException(GetExceptionCode())) {
-		// this means that the delay loaded decoder DLL was not found.
+		sf_close(SndFile);
+		SndFile = 0;
 	}
-#endif
     return false;
 }
 
diff --git a/src/sound/sndfile_decoder.h b/src/sound/sndfile_decoder.h
index 0c4cfe9350..e5473dcb22 100644
--- a/src/sound/sndfile_decoder.h
+++ b/src/sound/sndfile_decoder.h
@@ -5,7 +5,11 @@
 
 #ifdef HAVE_SNDFILE
 
+#ifndef DYN_SNDFILE
 #include "sndfile.h"
+#else
+#include "thirdparty/sndfile.h"
+#endif
 
 struct SndFileDecoder : public SoundDecoder
 {
diff --git a/src/sound/sndload.h b/src/sound/sndload.h
new file mode 100644
index 0000000000..633cc19b08
--- /dev/null
+++ b/src/sound/sndload.h
@@ -0,0 +1,23 @@
+#ifndef SNDDEF_H
+#define SNDDEF_H
+
+#if defined HAVE_SNDFILE && defined DYN_SNDFILE
+
+#define DEFINE_ENTRY(type, name) static TReqProc<SndFileModule, type> p_##name{#name};
+DEFINE_ENTRY(int (*)(SNDFILE *sndfile), sf_close)
+DEFINE_ENTRY(SNDFILE* (*)(SF_VIRTUAL_IO *sfvirtual, int mode, SF_INFO *sfinfo, void *user_data), sf_open_virtual)
+DEFINE_ENTRY(sf_count_t (*)(SNDFILE *sndfile, float *ptr, sf_count_t frames), sf_readf_float)
+DEFINE_ENTRY(sf_count_t (*)(SNDFILE *sndfile, sf_count_t frames, int whence), sf_seek)
+#undef DEFINE_ENTRY
+
+#ifndef IN_IDE_PARSER
+#define sf_close p_sf_close
+#define sf_open_virtual p_sf_open_virtual
+#define sf_readf_float p_sf_readf_float
+#define sf_seek p_sf_seek
+#endif
+
+#endif
+#endif
+
+
diff --git a/src/sound/thirdparty/al.h b/src/sound/thirdparty/al.h
new file mode 100644
index 0000000000..413b38331e
--- /dev/null
+++ b/src/sound/thirdparty/al.h
@@ -0,0 +1,656 @@
+#ifndef AL_AL_H
+#define AL_AL_H
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+#ifndef AL_API
+ #if defined(AL_LIBTYPE_STATIC)
+  #define AL_API
+ #elif defined(_WIN32)
+  #define AL_API __declspec(dllimport)
+ #else
+  #define AL_API extern
+ #endif
+#endif
+
+#if defined(_WIN32)
+ #define AL_APIENTRY __cdecl
+#else
+ #define AL_APIENTRY
+#endif
+
+
+/** Deprecated macro. */
+#define OPENAL
+#define ALAPI                                    AL_API
+#define ALAPIENTRY                               AL_APIENTRY
+#define AL_INVALID                               (-1)
+#define AL_ILLEGAL_ENUM                          AL_INVALID_ENUM
+#define AL_ILLEGAL_COMMAND                       AL_INVALID_OPERATION
+
+/** Supported AL version. */
+#define AL_VERSION_1_0
+#define AL_VERSION_1_1
+
+/** 8-bit boolean */
+typedef char ALboolean;
+
+/** character */
+typedef char ALchar;
+
+/** signed 8-bit 2's complement integer */
+typedef signed char ALbyte;
+
+/** unsigned 8-bit integer */
+typedef unsigned char ALubyte;
+
+/** signed 16-bit 2's complement integer */
+typedef short ALshort;
+
+/** unsigned 16-bit integer */
+typedef unsigned short ALushort;
+
+/** signed 32-bit 2's complement integer */
+typedef int ALint;
+
+/** unsigned 32-bit integer */
+typedef unsigned int ALuint;
+
+/** non-negative 32-bit binary integer size */
+typedef int ALsizei;
+
+/** enumerated 32-bit value */
+typedef int ALenum;
+
+/** 32-bit IEEE754 floating-point */
+typedef float ALfloat;
+
+/** 64-bit IEEE754 floating-point */
+typedef double ALdouble;
+
+/** void type (for opaque pointers only) */
+typedef void ALvoid;
+
+
+/* Enumerant values begin at column 50. No tabs. */
+
+/** "no distance model" or "no buffer" */
+#define AL_NONE                                  0
+
+/** Boolean False. */
+#define AL_FALSE                                 0
+
+/** Boolean True. */
+#define AL_TRUE                                  1
+
+
+/**
+ * Relative source.
+ * Type:    ALboolean
+ * Range:   [AL_TRUE, AL_FALSE]
+ * Default: AL_FALSE
+ *
+ * Specifies if the Source has relative coordinates.
+ */
+#define AL_SOURCE_RELATIVE                       0x202
+
+
+/**
+ * Inner cone angle, in degrees.
+ * Type:    ALint, ALfloat
+ * Range:   [0 - 360]
+ * Default: 360
+ *
+ * The angle covered by the inner cone, where the source will not attenuate.
+ */
+#define AL_CONE_INNER_ANGLE                      0x1001
+
+/**
+ * Outer cone angle, in degrees.
+ * Range:   [0 - 360]
+ * Default: 360
+ *
+ * The angle covered by the outer cone, where the source will be fully
+ * attenuated.
+ */
+#define AL_CONE_OUTER_ANGLE                      0x1002
+
+/**
+ * Source pitch.
+ * Type:    ALfloat
+ * Range:   [0.5 - 2.0]
+ * Default: 1.0
+ *
+ * A multiplier for the frequency (sample rate) of the source's buffer.
+ */
+#define AL_PITCH                                 0x1003
+
+/**
+ * Source or listener position.
+ * Type:    ALfloat[3], ALint[3]
+ * Default: {0, 0, 0}
+ *
+ * The source or listener location in three dimensional space.
+ *
+ * OpenAL, like OpenGL, uses a right handed coordinate system, where in a
+ * frontal default view X (thumb) points right, Y points up (index finger), and
+ * Z points towards the viewer/camera (middle finger).
+ *
+ * To switch from a left handed coordinate system, flip the sign on the Z
+ * coordinate.
+ */
+#define AL_POSITION                              0x1004
+
+/**
+ * Source direction.
+ * Type:    ALfloat[3], ALint[3]
+ * Default: {0, 0, 0}
+ *
+ * Specifies the current direction in local space.
+ * A zero-length vector specifies an omni-directional source (cone is ignored).
+ */
+#define AL_DIRECTION                             0x1005
+
+/**
+ * Source or listener velocity.
+ * Type:    ALfloat[3], ALint[3]
+ * Default: {0, 0, 0}
+ *
+ * Specifies the current velocity in local space.
+ */
+#define AL_VELOCITY                              0x1006
+
+/**
+ * Source looping.
+ * Type:    ALboolean
+ * Range:   [AL_TRUE, AL_FALSE]
+ * Default: AL_FALSE
+ *
+ * Specifies whether source is looping.
+ */
+#define AL_LOOPING                               0x1007
+
+/**
+ * Source buffer.
+ * Type:  ALuint
+ * Range: any valid Buffer.
+ *
+ * Specifies the buffer to provide sound samples.
+ */
+#define AL_BUFFER                                0x1009
+
+/**
+ * Source or listener gain.
+ * Type:  ALfloat
+ * Range: [0.0 - ]
+ *
+ * A value of 1.0 means unattenuated. Each division by 2 equals an attenuation
+ * of about -6dB. Each multiplicaton by 2 equals an amplification of about
+ * +6dB.
+ *
+ * A value of 0.0 is meaningless with respect to a logarithmic scale; it is
+ * silent.
+ */
+#define AL_GAIN                                  0x100A
+
+/**
+ * Minimum source gain.
+ * Type:  ALfloat
+ * Range: [0.0 - 1.0]
+ *
+ * The minimum gain allowed for a source, after distance and cone attenation is
+ * applied (if applicable).
+ */
+#define AL_MIN_GAIN                              0x100D
+
+/**
+ * Maximum source gain.
+ * Type:  ALfloat
+ * Range: [0.0 - 1.0]
+ *
+ * The maximum gain allowed for a source, after distance and cone attenation is
+ * applied (if applicable).
+ */
+#define AL_MAX_GAIN                              0x100E
+
+/**
+ * Listener orientation.
+ * Type: ALfloat[6]
+ * Default: {0.0, 0.0, -1.0, 0.0, 1.0, 0.0}
+ *
+ * Effectively two three dimensional vectors. The first vector is the front (or
+ * "at") and the second is the top (or "up").
+ *
+ * Both vectors are in local space.
+ */
+#define AL_ORIENTATION                           0x100F
+
+/**
+ * Source state (query only).
+ * Type:  ALint
+ * Range: [AL_INITIAL, AL_PLAYING, AL_PAUSED, AL_STOPPED]
+ */
+#define AL_SOURCE_STATE                          0x1010
+
+/** Source state value. */
+#define AL_INITIAL                               0x1011
+#define AL_PLAYING                               0x1012
+#define AL_PAUSED                                0x1013
+#define AL_STOPPED                               0x1014
+
+/**
+ * Source Buffer Queue size (query only).
+ * Type: ALint
+ *
+ * The number of buffers queued using alSourceQueueBuffers, minus the buffers
+ * removed with alSourceUnqueueBuffers.
+ */
+#define AL_BUFFERS_QUEUED                        0x1015
+
+/**
+ * Source Buffer Queue processed count (query only).
+ * Type: ALint
+ *
+ * The number of queued buffers that have been fully processed, and can be
+ * removed with alSourceUnqueueBuffers.
+ *
+ * Looping sources will never fully process buffers because they will be set to
+ * play again for when the source loops.
+ */
+#define AL_BUFFERS_PROCESSED                     0x1016
+
+/**
+ * Source reference distance.
+ * Type:    ALfloat
+ * Range:   [0.0 - ]
+ * Default: 1.0
+ *
+ * The distance in units that no attenuation occurs.
+ *
+ * At 0.0, no distance attenuation ever occurs on non-linear attenuation models.
+ */
+#define AL_REFERENCE_DISTANCE                    0x1020
+
+/**
+ * Source rolloff factor.
+ * Type:    ALfloat
+ * Range:   [0.0 - ]
+ * Default: 1.0
+ *
+ * Multiplier to exaggerate or diminish distance attenuation.
+ *
+ * At 0.0, no distance attenuation ever occurs.
+ */
+#define AL_ROLLOFF_FACTOR                        0x1021
+
+/**
+ * Outer cone gain.
+ * Type:    ALfloat
+ * Range:   [0.0 - 1.0]
+ * Default: 0.0
+ *
+ * The gain attenuation applied when the listener is outside of the source's
+ * outer cone.
+ */
+#define AL_CONE_OUTER_GAIN                       0x1022
+
+/**
+ * Source maximum distance.
+ * Type:    ALfloat
+ * Range:   [0.0 - ]
+ * Default: +inf
+ *
+ * The distance above which the source is not attenuated any further with a
+ * clamped distance model, or where attenuation reaches 0.0 gain for linear
+ * distance models with a default rolloff factor.
+ */
+#define AL_MAX_DISTANCE                          0x1023
+
+/** Source buffer position, in seconds */
+#define AL_SEC_OFFSET                            0x1024
+/** Source buffer position, in sample frames */
+#define AL_SAMPLE_OFFSET                         0x1025
+/** Source buffer position, in bytes */
+#define AL_BYTE_OFFSET                           0x1026
+
+/**
+ * Source type (query only).
+ * Type:  ALint
+ * Range: [AL_STATIC, AL_STREAMING, AL_UNDETERMINED]
+ *
+ * A Source is Static if a Buffer has been attached using AL_BUFFER.
+ *
+ * A Source is Streaming if one or more Buffers have been attached using
+ * alSourceQueueBuffers.
+ *
+ * A Source is Undetermined when it has the NULL buffer attached using
+ * AL_BUFFER.
+ */
+#define AL_SOURCE_TYPE                           0x1027
+
+/** Source type value. */
+#define AL_STATIC                                0x1028
+#define AL_STREAMING                             0x1029
+#define AL_UNDETERMINED                          0x1030
+
+/** Buffer format specifier. */
+#define AL_FORMAT_MONO8                          0x1100
+#define AL_FORMAT_MONO16                         0x1101
+#define AL_FORMAT_STEREO8                        0x1102
+#define AL_FORMAT_STEREO16                       0x1103
+
+/** Buffer frequency (query only). */
+#define AL_FREQUENCY                             0x2001
+/** Buffer bits per sample (query only). */
+#define AL_BITS                                  0x2002
+/** Buffer channel count (query only). */
+#define AL_CHANNELS                              0x2003
+/** Buffer data size (query only). */
+#define AL_SIZE                                  0x2004
+
+/**
+ * Buffer state.
+ *
+ * Not for public use.
+ */
+#define AL_UNUSED                                0x2010
+#define AL_PENDING                               0x2011
+#define AL_PROCESSED                             0x2012
+
+
+/** No error. */
+#define AL_NO_ERROR                              0
+
+/** Invalid name paramater passed to AL call. */
+#define AL_INVALID_NAME                          0xA001
+
+/** Invalid enum parameter passed to AL call. */
+#define AL_INVALID_ENUM                          0xA002
+
+/** Invalid value parameter passed to AL call. */
+#define AL_INVALID_VALUE                         0xA003
+
+/** Illegal AL call. */
+#define AL_INVALID_OPERATION                     0xA004
+
+/** Not enough memory. */
+#define AL_OUT_OF_MEMORY                         0xA005
+
+
+/** Context string: Vendor ID. */
+#define AL_VENDOR                                0xB001
+/** Context string: Version. */
+#define AL_VERSION                               0xB002
+/** Context string: Renderer ID. */
+#define AL_RENDERER                              0xB003
+/** Context string: Space-separated extension list. */
+#define AL_EXTENSIONS                            0xB004
+
+
+/**
+ * Doppler scale.
+ * Type:    ALfloat
+ * Range:   [0.0 - ]
+ * Default: 1.0
+ *
+ * Scale for source and listener velocities.
+ */
+#define AL_DOPPLER_FACTOR                        0xC000
+AL_API void AL_APIENTRY alDopplerFactor(ALfloat value);
+
+/**
+ * Doppler velocity (deprecated).
+ *
+ * A multiplier applied to the Speed of Sound.
+ */
+#define AL_DOPPLER_VELOCITY                      0xC001
+AL_API void AL_APIENTRY alDopplerVelocity(ALfloat value);
+
+/**
+ * Speed of Sound, in units per second.
+ * Type:    ALfloat
+ * Range:   [0.0001 - ]
+ * Default: 343.3
+ *
+ * The speed at which sound waves are assumed to travel, when calculating the
+ * doppler effect.
+ */
+#define AL_SPEED_OF_SOUND                        0xC003
+AL_API void AL_APIENTRY alSpeedOfSound(ALfloat value);
+
+/**
+ * Distance attenuation model.
+ * Type:    ALint
+ * Range:   [AL_NONE, AL_INVERSE_DISTANCE, AL_INVERSE_DISTANCE_CLAMPED,
+ *           AL_LINEAR_DISTANCE, AL_LINEAR_DISTANCE_CLAMPED,
+ *           AL_EXPONENT_DISTANCE, AL_EXPONENT_DISTANCE_CLAMPED]
+ * Default: AL_INVERSE_DISTANCE_CLAMPED
+ *
+ * The model by which sources attenuate with distance.
+ *
+ * None     - No distance attenuation.
+ * Inverse  - Doubling the distance halves the source gain.
+ * Linear   - Linear gain scaling between the reference and max distances.
+ * Exponent - Exponential gain dropoff.
+ *
+ * Clamped variations work like the non-clamped counterparts, except the
+ * distance calculated is clamped between the reference and max distances.
+ */
+#define AL_DISTANCE_MODEL                        0xD000
+AL_API void AL_APIENTRY alDistanceModel(ALenum distanceModel);
+
+/** Distance model value. */
+#define AL_INVERSE_DISTANCE                      0xD001
+#define AL_INVERSE_DISTANCE_CLAMPED              0xD002
+#define AL_LINEAR_DISTANCE                       0xD003
+#define AL_LINEAR_DISTANCE_CLAMPED               0xD004
+#define AL_EXPONENT_DISTANCE                     0xD005
+#define AL_EXPONENT_DISTANCE_CLAMPED             0xD006
+
+/** Renderer State management. */
+AL_API void AL_APIENTRY alEnable(ALenum capability);
+AL_API void AL_APIENTRY alDisable(ALenum capability);
+AL_API ALboolean AL_APIENTRY alIsEnabled(ALenum capability);
+
+/** State retrieval. */
+AL_API const ALchar* AL_APIENTRY alGetString(ALenum param);
+AL_API void AL_APIENTRY alGetBooleanv(ALenum param, ALboolean *values);
+AL_API void AL_APIENTRY alGetIntegerv(ALenum param, ALint *values);
+AL_API void AL_APIENTRY alGetFloatv(ALenum param, ALfloat *values);
+AL_API void AL_APIENTRY alGetDoublev(ALenum param, ALdouble *values);
+AL_API ALboolean AL_APIENTRY alGetBoolean(ALenum param);
+AL_API ALint AL_APIENTRY alGetInteger(ALenum param);
+AL_API ALfloat AL_APIENTRY alGetFloat(ALenum param);
+AL_API ALdouble AL_APIENTRY alGetDouble(ALenum param);
+
+/**
+ * Error retrieval.
+ *
+ * Obtain the first error generated in the AL context since the last check.
+ */
+AL_API ALenum AL_APIENTRY alGetError(void);
+
+/**
+ * Extension support.
+ *
+ * Query for the presence of an extension, and obtain any appropriate function
+ * pointers and enum values.
+ */
+AL_API ALboolean AL_APIENTRY alIsExtensionPresent(const ALchar *extname);
+AL_API void* AL_APIENTRY alGetProcAddress(const ALchar *fname);
+AL_API ALenum AL_APIENTRY alGetEnumValue(const ALchar *ename);
+
+
+/** Set Listener parameters */
+AL_API void AL_APIENTRY alListenerf(ALenum param, ALfloat value);
+AL_API void AL_APIENTRY alListener3f(ALenum param, ALfloat value1, ALfloat value2, ALfloat value3);
+AL_API void AL_APIENTRY alListenerfv(ALenum param, const ALfloat *values);
+AL_API void AL_APIENTRY alListeneri(ALenum param, ALint value);
+AL_API void AL_APIENTRY alListener3i(ALenum param, ALint value1, ALint value2, ALint value3);
+AL_API void AL_APIENTRY alListeneriv(ALenum param, const ALint *values);
+
+/** Get Listener parameters */
+AL_API void AL_APIENTRY alGetListenerf(ALenum param, ALfloat *value);
+AL_API void AL_APIENTRY alGetListener3f(ALenum param, ALfloat *value1, ALfloat *value2, ALfloat *value3);
+AL_API void AL_APIENTRY alGetListenerfv(ALenum param, ALfloat *values);
+AL_API void AL_APIENTRY alGetListeneri(ALenum param, ALint *value);
+AL_API void AL_APIENTRY alGetListener3i(ALenum param, ALint *value1, ALint *value2, ALint *value3);
+AL_API void AL_APIENTRY alGetListeneriv(ALenum param, ALint *values);
+
+
+/** Create Source objects. */
+AL_API void AL_APIENTRY alGenSources(ALsizei n, ALuint *sources);
+/** Delete Source objects. */
+AL_API void AL_APIENTRY alDeleteSources(ALsizei n, const ALuint *sources);
+/** Verify a handle is a valid Source. */
+AL_API ALboolean AL_APIENTRY alIsSource(ALuint source);
+
+/** Set Source parameters. */
+AL_API void AL_APIENTRY alSourcef(ALuint source, ALenum param, ALfloat value);
+AL_API void AL_APIENTRY alSource3f(ALuint source, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3);
+AL_API void AL_APIENTRY alSourcefv(ALuint source, ALenum param, const ALfloat *values);
+AL_API void AL_APIENTRY alSourcei(ALuint source, ALenum param, ALint value);
+AL_API void AL_APIENTRY alSource3i(ALuint source, ALenum param, ALint value1, ALint value2, ALint value3);
+AL_API void AL_APIENTRY alSourceiv(ALuint source, ALenum param, const ALint *values);
+
+/** Get Source parameters. */
+AL_API void AL_APIENTRY alGetSourcef(ALuint source, ALenum param, ALfloat *value);
+AL_API void AL_APIENTRY alGetSource3f(ALuint source, ALenum param, ALfloat *value1, ALfloat *value2, ALfloat *value3);
+AL_API void AL_APIENTRY alGetSourcefv(ALuint source, ALenum param, ALfloat *values);
+AL_API void AL_APIENTRY alGetSourcei(ALuint source,  ALenum param, ALint *value);
+AL_API void AL_APIENTRY alGetSource3i(ALuint source, ALenum param, ALint *value1, ALint *value2, ALint *value3);
+AL_API void AL_APIENTRY alGetSourceiv(ALuint source,  ALenum param, ALint *values);
+
+
+/** Play, replay, or resume (if paused) a list of Sources */
+AL_API void AL_APIENTRY alSourcePlayv(ALsizei n, const ALuint *sources);
+/** Stop a list of Sources */
+AL_API void AL_APIENTRY alSourceStopv(ALsizei n, const ALuint *sources);
+/** Rewind a list of Sources */
+AL_API void AL_APIENTRY alSourceRewindv(ALsizei n, const ALuint *sources);
+/** Pause a list of Sources */
+AL_API void AL_APIENTRY alSourcePausev(ALsizei n, const ALuint *sources);
+
+/** Play, replay, or resume a Source */
+AL_API void AL_APIENTRY alSourcePlay(ALuint source);
+/** Stop a Source */
+AL_API void AL_APIENTRY alSourceStop(ALuint source);
+/** Rewind a Source (set playback postiton to beginning) */
+AL_API void AL_APIENTRY alSourceRewind(ALuint source);
+/** Pause a Source */
+AL_API void AL_APIENTRY alSourcePause(ALuint source);
+
+/** Queue buffers onto a source */
+AL_API void AL_APIENTRY alSourceQueueBuffers(ALuint source, ALsizei nb, const ALuint *buffers);
+/** Unqueue processed buffers from a source */
+AL_API void AL_APIENTRY alSourceUnqueueBuffers(ALuint source, ALsizei nb, ALuint *buffers);
+
+
+/** Create Buffer objects */
+AL_API void AL_APIENTRY alGenBuffers(ALsizei n, ALuint *buffers);
+/** Delete Buffer objects */
+AL_API void AL_APIENTRY alDeleteBuffers(ALsizei n, const ALuint *buffers);
+/** Verify a handle is a valid Buffer */
+AL_API ALboolean AL_APIENTRY alIsBuffer(ALuint buffer);
+
+/** Specifies the data to be copied into a buffer */
+AL_API void AL_APIENTRY alBufferData(ALuint buffer, ALenum format, const ALvoid *data, ALsizei size, ALsizei freq);
+
+/** Set Buffer parameters, */
+AL_API void AL_APIENTRY alBufferf(ALuint buffer, ALenum param, ALfloat value);
+AL_API void AL_APIENTRY alBuffer3f(ALuint buffer, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3);
+AL_API void AL_APIENTRY alBufferfv(ALuint buffer, ALenum param, const ALfloat *values);
+AL_API void AL_APIENTRY alBufferi(ALuint buffer, ALenum param, ALint value);
+AL_API void AL_APIENTRY alBuffer3i(ALuint buffer, ALenum param, ALint value1, ALint value2, ALint value3);
+AL_API void AL_APIENTRY alBufferiv(ALuint buffer, ALenum param, const ALint *values);
+
+/** Get Buffer parameters. */
+AL_API void AL_APIENTRY alGetBufferf(ALuint buffer, ALenum param, ALfloat *value);
+AL_API void AL_APIENTRY alGetBuffer3f(ALuint buffer, ALenum param, ALfloat *value1, ALfloat *value2, ALfloat *value3);
+AL_API void AL_APIENTRY alGetBufferfv(ALuint buffer, ALenum param, ALfloat *values);
+AL_API void AL_APIENTRY alGetBufferi(ALuint buffer, ALenum param, ALint *value);
+AL_API void AL_APIENTRY alGetBuffer3i(ALuint buffer, ALenum param, ALint *value1, ALint *value2, ALint *value3);
+AL_API void AL_APIENTRY alGetBufferiv(ALuint buffer, ALenum param, ALint *values);
+
+/** Pointer-to-function type, useful for dynamically getting AL entry points. */
+typedef void          (AL_APIENTRY *LPALENABLE)(ALenum capability);
+typedef void          (AL_APIENTRY *LPALDISABLE)(ALenum capability);
+typedef ALboolean     (AL_APIENTRY *LPALISENABLED)(ALenum capability);
+typedef const ALchar* (AL_APIENTRY *LPALGETSTRING)(ALenum param);
+typedef void          (AL_APIENTRY *LPALGETBOOLEANV)(ALenum param, ALboolean *values);
+typedef void          (AL_APIENTRY *LPALGETINTEGERV)(ALenum param, ALint *values);
+typedef void          (AL_APIENTRY *LPALGETFLOATV)(ALenum param, ALfloat *values);
+typedef void          (AL_APIENTRY *LPALGETDOUBLEV)(ALenum param, ALdouble *values);
+typedef ALboolean     (AL_APIENTRY *LPALGETBOOLEAN)(ALenum param);
+typedef ALint         (AL_APIENTRY *LPALGETINTEGER)(ALenum param);
+typedef ALfloat       (AL_APIENTRY *LPALGETFLOAT)(ALenum param);
+typedef ALdouble      (AL_APIENTRY *LPALGETDOUBLE)(ALenum param);
+typedef ALenum        (AL_APIENTRY *LPALGETERROR)(void);
+typedef ALboolean     (AL_APIENTRY *LPALISEXTENSIONPRESENT)(const ALchar *extname);
+typedef void*         (AL_APIENTRY *LPALGETPROCADDRESS)(const ALchar *fname);
+typedef ALenum        (AL_APIENTRY *LPALGETENUMVALUE)(const ALchar *ename);
+typedef void          (AL_APIENTRY *LPALLISTENERF)(ALenum param, ALfloat value);
+typedef void          (AL_APIENTRY *LPALLISTENER3F)(ALenum param, ALfloat value1, ALfloat value2, ALfloat value3);
+typedef void          (AL_APIENTRY *LPALLISTENERFV)(ALenum param, const ALfloat *values);
+typedef void          (AL_APIENTRY *LPALLISTENERI)(ALenum param, ALint value);
+typedef void          (AL_APIENTRY *LPALLISTENER3I)(ALenum param, ALint value1, ALint value2, ALint value3);
+typedef void          (AL_APIENTRY *LPALLISTENERIV)(ALenum param, const ALint *values);
+typedef void          (AL_APIENTRY *LPALGETLISTENERF)(ALenum param, ALfloat *value);
+typedef void          (AL_APIENTRY *LPALGETLISTENER3F)(ALenum param, ALfloat *value1, ALfloat *value2, ALfloat *value3);
+typedef void          (AL_APIENTRY *LPALGETLISTENERFV)(ALenum param, ALfloat *values);
+typedef void          (AL_APIENTRY *LPALGETLISTENERI)(ALenum param, ALint *value);
+typedef void          (AL_APIENTRY *LPALGETLISTENER3I)(ALenum param, ALint *value1, ALint *value2, ALint *value3);
+typedef void          (AL_APIENTRY *LPALGETLISTENERIV)(ALenum param, ALint *values);
+typedef void          (AL_APIENTRY *LPALGENSOURCES)(ALsizei n, ALuint *sources);
+typedef void          (AL_APIENTRY *LPALDELETESOURCES)(ALsizei n, const ALuint *sources);
+typedef ALboolean     (AL_APIENTRY *LPALISSOURCE)(ALuint source);
+typedef void          (AL_APIENTRY *LPALSOURCEF)(ALuint source, ALenum param, ALfloat value);
+typedef void          (AL_APIENTRY *LPALSOURCE3F)(ALuint source, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3);
+typedef void          (AL_APIENTRY *LPALSOURCEFV)(ALuint source, ALenum param, const ALfloat *values);
+typedef void          (AL_APIENTRY *LPALSOURCEI)(ALuint source, ALenum param, ALint value);
+typedef void          (AL_APIENTRY *LPALSOURCE3I)(ALuint source, ALenum param, ALint value1, ALint value2, ALint value3);
+typedef void          (AL_APIENTRY *LPALSOURCEIV)(ALuint source, ALenum param, const ALint *values);
+typedef void          (AL_APIENTRY *LPALGETSOURCEF)(ALuint source, ALenum param, ALfloat *value);
+typedef void          (AL_APIENTRY *LPALGETSOURCE3F)(ALuint source, ALenum param, ALfloat *value1, ALfloat *value2, ALfloat *value3);
+typedef void          (AL_APIENTRY *LPALGETSOURCEFV)(ALuint source, ALenum param, ALfloat *values);
+typedef void          (AL_APIENTRY *LPALGETSOURCEI)(ALuint source, ALenum param, ALint *value);
+typedef void          (AL_APIENTRY *LPALGETSOURCE3I)(ALuint source, ALenum param, ALint *value1, ALint *value2, ALint *value3);
+typedef void          (AL_APIENTRY *LPALGETSOURCEIV)(ALuint source, ALenum param, ALint *values);
+typedef void          (AL_APIENTRY *LPALSOURCEPLAYV)(ALsizei n, const ALuint *sources);
+typedef void          (AL_APIENTRY *LPALSOURCESTOPV)(ALsizei n, const ALuint *sources);
+typedef void          (AL_APIENTRY *LPALSOURCEREWINDV)(ALsizei n, const ALuint *sources);
+typedef void          (AL_APIENTRY *LPALSOURCEPAUSEV)(ALsizei n, const ALuint *sources);
+typedef void          (AL_APIENTRY *LPALSOURCEPLAY)(ALuint source);
+typedef void          (AL_APIENTRY *LPALSOURCESTOP)(ALuint source);
+typedef void          (AL_APIENTRY *LPALSOURCEREWIND)(ALuint source);
+typedef void          (AL_APIENTRY *LPALSOURCEPAUSE)(ALuint source);
+typedef void          (AL_APIENTRY *LPALSOURCEQUEUEBUFFERS)(ALuint source, ALsizei nb, const ALuint *buffers);
+typedef void          (AL_APIENTRY *LPALSOURCEUNQUEUEBUFFERS)(ALuint source, ALsizei nb, ALuint *buffers);
+typedef void          (AL_APIENTRY *LPALGENBUFFERS)(ALsizei n, ALuint *buffers);
+typedef void          (AL_APIENTRY *LPALDELETEBUFFERS)(ALsizei n, const ALuint *buffers);
+typedef ALboolean     (AL_APIENTRY *LPALISBUFFER)(ALuint buffer);
+typedef void          (AL_APIENTRY *LPALBUFFERDATA)(ALuint buffer, ALenum format, const ALvoid *data, ALsizei size, ALsizei freq);
+typedef void          (AL_APIENTRY *LPALBUFFERF)(ALuint buffer, ALenum param, ALfloat value);
+typedef void          (AL_APIENTRY *LPALBUFFER3F)(ALuint buffer, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3);
+typedef void          (AL_APIENTRY *LPALBUFFERFV)(ALuint buffer, ALenum param, const ALfloat *values);
+typedef void          (AL_APIENTRY *LPALBUFFERI)(ALuint buffer, ALenum param, ALint value);
+typedef void          (AL_APIENTRY *LPALBUFFER3I)(ALuint buffer, ALenum param, ALint value1, ALint value2, ALint value3);
+typedef void          (AL_APIENTRY *LPALBUFFERIV)(ALuint buffer, ALenum param, const ALint *values);
+typedef void          (AL_APIENTRY *LPALGETBUFFERF)(ALuint buffer, ALenum param, ALfloat *value);
+typedef void          (AL_APIENTRY *LPALGETBUFFER3F)(ALuint buffer, ALenum param, ALfloat *value1, ALfloat *value2, ALfloat *value3);
+typedef void          (AL_APIENTRY *LPALGETBUFFERFV)(ALuint buffer, ALenum param, ALfloat *values);
+typedef void          (AL_APIENTRY *LPALGETBUFFERI)(ALuint buffer, ALenum param, ALint *value);
+typedef void          (AL_APIENTRY *LPALGETBUFFER3I)(ALuint buffer, ALenum param, ALint *value1, ALint *value2, ALint *value3);
+typedef void          (AL_APIENTRY *LPALGETBUFFERIV)(ALuint buffer, ALenum param, ALint *values);
+typedef void          (AL_APIENTRY *LPALDOPPLERFACTOR)(ALfloat value);
+typedef void          (AL_APIENTRY *LPALDOPPLERVELOCITY)(ALfloat value);
+typedef void          (AL_APIENTRY *LPALSPEEDOFSOUND)(ALfloat value);
+typedef void          (AL_APIENTRY *LPALDISTANCEMODEL)(ALenum distanceModel);
+
+#if defined(__cplusplus)
+}  /* extern "C" */
+#endif
+
+#endif /* AL_AL_H */
diff --git a/src/sound/thirdparty/alc.h b/src/sound/thirdparty/alc.h
new file mode 100644
index 0000000000..294e8b33c6
--- /dev/null
+++ b/src/sound/thirdparty/alc.h
@@ -0,0 +1,237 @@
+#ifndef AL_ALC_H
+#define AL_ALC_H
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+#ifndef ALC_API
+ #if defined(AL_LIBTYPE_STATIC)
+  #define ALC_API
+ #elif defined(_WIN32)
+  #define ALC_API __declspec(dllimport)
+ #else
+  #define ALC_API extern
+ #endif
+#endif
+
+#if defined(_WIN32)
+ #define ALC_APIENTRY __cdecl
+#else
+ #define ALC_APIENTRY
+#endif
+
+
+/** Deprecated macro. */
+#define ALCAPI                                   ALC_API
+#define ALCAPIENTRY                              ALC_APIENTRY
+#define ALC_INVALID                              0
+
+/** Supported ALC version? */
+#define ALC_VERSION_0_1                          1
+
+/** Opaque device handle */
+typedef struct ALCdevice_struct ALCdevice;
+/** Opaque context handle */
+typedef struct ALCcontext_struct ALCcontext;
+
+/** 8-bit boolean */
+typedef char ALCboolean;
+
+/** character */
+typedef char ALCchar;
+
+/** signed 8-bit 2's complement integer */
+typedef signed char ALCbyte;
+
+/** unsigned 8-bit integer */
+typedef unsigned char ALCubyte;
+
+/** signed 16-bit 2's complement integer */
+typedef short ALCshort;
+
+/** unsigned 16-bit integer */
+typedef unsigned short ALCushort;
+
+/** signed 32-bit 2's complement integer */
+typedef int ALCint;
+
+/** unsigned 32-bit integer */
+typedef unsigned int ALCuint;
+
+/** non-negative 32-bit binary integer size */
+typedef int ALCsizei;
+
+/** enumerated 32-bit value */
+typedef int ALCenum;
+
+/** 32-bit IEEE754 floating-point */
+typedef float ALCfloat;
+
+/** 64-bit IEEE754 floating-point */
+typedef double ALCdouble;
+
+/** void type (for opaque pointers only) */
+typedef void ALCvoid;
+
+
+/* Enumerant values begin at column 50. No tabs. */
+
+/** Boolean False. */
+#define ALC_FALSE                                0
+
+/** Boolean True. */
+#define ALC_TRUE                                 1
+
+/** Context attribute: <int> Hz. */
+#define ALC_FREQUENCY                            0x1007
+
+/** Context attribute: <int> Hz. */
+#define ALC_REFRESH                              0x1008
+
+/** Context attribute: AL_TRUE or AL_FALSE. */
+#define ALC_SYNC                                 0x1009
+
+/** Context attribute: <int> requested Mono (3D) Sources. */
+#define ALC_MONO_SOURCES                         0x1010
+
+/** Context attribute: <int> requested Stereo Sources. */
+#define ALC_STEREO_SOURCES                       0x1011
+
+/** No error. */
+#define ALC_NO_ERROR                             0
+
+/** Invalid device handle. */
+#define ALC_INVALID_DEVICE                       0xA001
+
+/** Invalid context handle. */
+#define ALC_INVALID_CONTEXT                      0xA002
+
+/** Invalid enum parameter passed to an ALC call. */
+#define ALC_INVALID_ENUM                         0xA003
+
+/** Invalid value parameter passed to an ALC call. */
+#define ALC_INVALID_VALUE                        0xA004
+
+/** Out of memory. */
+#define ALC_OUT_OF_MEMORY                        0xA005
+
+
+/** Runtime ALC version. */
+#define ALC_MAJOR_VERSION                        0x1000
+#define ALC_MINOR_VERSION                        0x1001
+
+/** Context attribute list properties. */
+#define ALC_ATTRIBUTES_SIZE                      0x1002
+#define ALC_ALL_ATTRIBUTES                       0x1003
+
+/** String for the default device specifier. */
+#define ALC_DEFAULT_DEVICE_SPECIFIER             0x1004
+/**
+ * String for the given device's specifier.
+ *
+ * If device handle is NULL, it is instead a null-char separated list of
+ * strings of known device specifiers (list ends with an empty string).
+ */
+#define ALC_DEVICE_SPECIFIER                     0x1005
+/** String for space-separated list of ALC extensions. */
+#define ALC_EXTENSIONS                           0x1006
+
+
+/** Capture extension */
+#define ALC_EXT_CAPTURE 1
+/**
+ * String for the given capture device's specifier.
+ *
+ * If device handle is NULL, it is instead a null-char separated list of
+ * strings of known capture device specifiers (list ends with an empty string).
+ */
+#define ALC_CAPTURE_DEVICE_SPECIFIER             0x310
+/** String for the default capture device specifier. */
+#define ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER     0x311
+/** Number of sample frames available for capture. */
+#define ALC_CAPTURE_SAMPLES                      0x312
+
+
+/** Enumerate All extension */
+#define ALC_ENUMERATE_ALL_EXT 1
+/** String for the default extended device specifier. */
+#define ALC_DEFAULT_ALL_DEVICES_SPECIFIER        0x1012
+/**
+ * String for the given extended device's specifier.
+ *
+ * If device handle is NULL, it is instead a null-char separated list of
+ * strings of known extended device specifiers (list ends with an empty string).
+ */
+#define ALC_ALL_DEVICES_SPECIFIER                0x1013
+
+
+/** Context management. */
+ALC_API ALCcontext* ALC_APIENTRY alcCreateContext(ALCdevice *device, const ALCint* attrlist);
+ALC_API ALCboolean  ALC_APIENTRY alcMakeContextCurrent(ALCcontext *context);
+ALC_API void        ALC_APIENTRY alcProcessContext(ALCcontext *context);
+ALC_API void        ALC_APIENTRY alcSuspendContext(ALCcontext *context);
+ALC_API void        ALC_APIENTRY alcDestroyContext(ALCcontext *context);
+ALC_API ALCcontext* ALC_APIENTRY alcGetCurrentContext(void);
+ALC_API ALCdevice*  ALC_APIENTRY alcGetContextsDevice(ALCcontext *context);
+
+/** Device management. */
+ALC_API ALCdevice* ALC_APIENTRY alcOpenDevice(const ALCchar *devicename);
+ALC_API ALCboolean ALC_APIENTRY alcCloseDevice(ALCdevice *device);
+
+
+/**
+ * Error support.
+ *
+ * Obtain the most recent Device error.
+ */
+ALC_API ALCenum ALC_APIENTRY alcGetError(ALCdevice *device);
+
+/**
+ * Extension support.
+ *
+ * Query for the presence of an extension, and obtain any appropriate
+ * function pointers and enum values.
+ */
+ALC_API ALCboolean ALC_APIENTRY alcIsExtensionPresent(ALCdevice *device, const ALCchar *extname);
+ALC_API void*      ALC_APIENTRY alcGetProcAddress(ALCdevice *device, const ALCchar *funcname);
+ALC_API ALCenum    ALC_APIENTRY alcGetEnumValue(ALCdevice *device, const ALCchar *enumname);
+
+/** Query function. */
+ALC_API const ALCchar* ALC_APIENTRY alcGetString(ALCdevice *device, ALCenum param);
+ALC_API void           ALC_APIENTRY alcGetIntegerv(ALCdevice *device, ALCenum param, ALCsizei size, ALCint *values);
+
+/** Capture function. */
+ALC_API ALCdevice* ALC_APIENTRY alcCaptureOpenDevice(const ALCchar *devicename, ALCuint frequency, ALCenum format, ALCsizei buffersize);
+ALC_API ALCboolean ALC_APIENTRY alcCaptureCloseDevice(ALCdevice *device);
+ALC_API void       ALC_APIENTRY alcCaptureStart(ALCdevice *device);
+ALC_API void       ALC_APIENTRY alcCaptureStop(ALCdevice *device);
+ALC_API void       ALC_APIENTRY alcCaptureSamples(ALCdevice *device, ALCvoid *buffer, ALCsizei samples);
+
+/** Pointer-to-function type, useful for dynamically getting ALC entry points. */
+typedef ALCcontext*    (ALC_APIENTRY *LPALCCREATECONTEXT)(ALCdevice *device, const ALCint *attrlist);
+typedef ALCboolean     (ALC_APIENTRY *LPALCMAKECONTEXTCURRENT)(ALCcontext *context);
+typedef void           (ALC_APIENTRY *LPALCPROCESSCONTEXT)(ALCcontext *context);
+typedef void           (ALC_APIENTRY *LPALCSUSPENDCONTEXT)(ALCcontext *context);
+typedef void           (ALC_APIENTRY *LPALCDESTROYCONTEXT)(ALCcontext *context);
+typedef ALCcontext*    (ALC_APIENTRY *LPALCGETCURRENTCONTEXT)(void);
+typedef ALCdevice*     (ALC_APIENTRY *LPALCGETCONTEXTSDEVICE)(ALCcontext *context);
+typedef ALCdevice*     (ALC_APIENTRY *LPALCOPENDEVICE)(const ALCchar *devicename);
+typedef ALCboolean     (ALC_APIENTRY *LPALCCLOSEDEVICE)(ALCdevice *device);
+typedef ALCenum        (ALC_APIENTRY *LPALCGETERROR)(ALCdevice *device);
+typedef ALCboolean     (ALC_APIENTRY *LPALCISEXTENSIONPRESENT)(ALCdevice *device, const ALCchar *extname);
+typedef void*          (ALC_APIENTRY *LPALCGETPROCADDRESS)(ALCdevice *device, const ALCchar *funcname);
+typedef ALCenum        (ALC_APIENTRY *LPALCGETENUMVALUE)(ALCdevice *device, const ALCchar *enumname);
+typedef const ALCchar* (ALC_APIENTRY *LPALCGETSTRING)(ALCdevice *device, ALCenum param);
+typedef void           (ALC_APIENTRY *LPALCGETINTEGERV)(ALCdevice *device, ALCenum param, ALCsizei size, ALCint *values);
+typedef ALCdevice*     (ALC_APIENTRY *LPALCCAPTUREOPENDEVICE)(const ALCchar *devicename, ALCuint frequency, ALCenum format, ALCsizei buffersize);
+typedef ALCboolean     (ALC_APIENTRY *LPALCCAPTURECLOSEDEVICE)(ALCdevice *device);
+typedef void           (ALC_APIENTRY *LPALCCAPTURESTART)(ALCdevice *device);
+typedef void           (ALC_APIENTRY *LPALCCAPTURESTOP)(ALCdevice *device);
+typedef void           (ALC_APIENTRY *LPALCCAPTURESAMPLES)(ALCdevice *device, ALCvoid *buffer, ALCsizei samples);
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif /* AL_ALC_H */
diff --git a/src/sound/thirdparty/alext.h b/src/sound/thirdparty/alext.h
new file mode 100644
index 0000000000..7d2a95274a
--- /dev/null
+++ b/src/sound/thirdparty/alext.h
@@ -0,0 +1,400 @@
+/**
+ * OpenAL cross platform audio library
+ * Copyright (C) 2008 by authors.
+ * This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Library General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ *  License along with this library; if not, write to the
+ *  Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ *  Boston, MA  02111-1307, USA.
+ * Or go to http://www.gnu.org/copyleft/lgpl.html
+ */
+
+#ifndef AL_ALEXT_H
+#define AL_ALEXT_H
+
+#include <stddef.h>
+/* Define int64_t and uint64_t types */
+#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
+#include <inttypes.h>
+#elif defined(_WIN32) && defined(__GNUC__)
+#include <stdint.h>
+#elif defined(_WIN32)
+typedef __int64 int64_t;
+typedef unsigned __int64 uint64_t;
+#else
+/* Fallback if nothing above works */
+#include <inttypes.h>
+#endif
+
+#include "alc.h"
+#include "al.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef AL_LOKI_IMA_ADPCM_format
+#define AL_LOKI_IMA_ADPCM_format 1
+#define AL_FORMAT_IMA_ADPCM_MONO16_EXT           0x10000
+#define AL_FORMAT_IMA_ADPCM_STEREO16_EXT         0x10001
+#endif
+
+#ifndef AL_LOKI_WAVE_format
+#define AL_LOKI_WAVE_format 1
+#define AL_FORMAT_WAVE_EXT                       0x10002
+#endif
+
+#ifndef AL_EXT_vorbis
+#define AL_EXT_vorbis 1
+#define AL_FORMAT_VORBIS_EXT                     0x10003
+#endif
+
+#ifndef AL_LOKI_quadriphonic
+#define AL_LOKI_quadriphonic 1
+#define AL_FORMAT_QUAD8_LOKI                     0x10004
+#define AL_FORMAT_QUAD16_LOKI                    0x10005
+#endif
+
+#ifndef AL_EXT_float32
+#define AL_EXT_float32 1
+#define AL_FORMAT_MONO_FLOAT32                   0x10010
+#define AL_FORMAT_STEREO_FLOAT32                 0x10011
+#endif
+
+#ifndef AL_EXT_double
+#define AL_EXT_double 1
+#define AL_FORMAT_MONO_DOUBLE_EXT                0x10012
+#define AL_FORMAT_STEREO_DOUBLE_EXT              0x10013
+#endif
+
+#ifndef AL_EXT_MULAW
+#define AL_EXT_MULAW 1
+#define AL_FORMAT_MONO_MULAW_EXT                 0x10014
+#define AL_FORMAT_STEREO_MULAW_EXT               0x10015
+#endif
+
+#ifndef AL_EXT_ALAW
+#define AL_EXT_ALAW 1
+#define AL_FORMAT_MONO_ALAW_EXT                  0x10016
+#define AL_FORMAT_STEREO_ALAW_EXT                0x10017
+#endif
+
+#ifndef ALC_LOKI_audio_channel
+#define ALC_LOKI_audio_channel 1
+#define ALC_CHAN_MAIN_LOKI                       0x500001
+#define ALC_CHAN_PCM_LOKI                        0x500002
+#define ALC_CHAN_CD_LOKI                         0x500003
+#endif
+
+#ifndef AL_EXT_MCFORMATS
+#define AL_EXT_MCFORMATS 1
+#define AL_FORMAT_QUAD8                          0x1204
+#define AL_FORMAT_QUAD16                         0x1205
+#define AL_FORMAT_QUAD32                         0x1206
+#define AL_FORMAT_REAR8                          0x1207
+#define AL_FORMAT_REAR16                         0x1208
+#define AL_FORMAT_REAR32                         0x1209
+#define AL_FORMAT_51CHN8                         0x120A
+#define AL_FORMAT_51CHN16                        0x120B
+#define AL_FORMAT_51CHN32                        0x120C
+#define AL_FORMAT_61CHN8                         0x120D
+#define AL_FORMAT_61CHN16                        0x120E
+#define AL_FORMAT_61CHN32                        0x120F
+#define AL_FORMAT_71CHN8                         0x1210
+#define AL_FORMAT_71CHN16                        0x1211
+#define AL_FORMAT_71CHN32                        0x1212
+#endif
+
+#ifndef AL_EXT_MULAW_MCFORMATS
+#define AL_EXT_MULAW_MCFORMATS 1
+#define AL_FORMAT_MONO_MULAW                     0x10014
+#define AL_FORMAT_STEREO_MULAW                   0x10015
+#define AL_FORMAT_QUAD_MULAW                     0x10021
+#define AL_FORMAT_REAR_MULAW                     0x10022
+#define AL_FORMAT_51CHN_MULAW                    0x10023
+#define AL_FORMAT_61CHN_MULAW                    0x10024
+#define AL_FORMAT_71CHN_MULAW                    0x10025
+#endif
+
+#ifndef AL_EXT_IMA4
+#define AL_EXT_IMA4 1
+#define AL_FORMAT_MONO_IMA4                      0x1300
+#define AL_FORMAT_STEREO_IMA4                    0x1301
+#endif
+
+#ifndef AL_EXT_STATIC_BUFFER
+#define AL_EXT_STATIC_BUFFER 1
+typedef ALvoid (AL_APIENTRY*PFNALBUFFERDATASTATICPROC)(const ALint,ALenum,ALvoid*,ALsizei,ALsizei);
+#ifdef AL_ALEXT_PROTOTYPES
+AL_API ALvoid AL_APIENTRY alBufferDataStatic(const ALint buffer, ALenum format, ALvoid *data, ALsizei len, ALsizei freq);
+#endif
+#endif
+
+#ifndef ALC_EXT_EFX
+#define ALC_EXT_EFX 1
+#include "efx.h"
+#endif
+
+#ifndef ALC_EXT_disconnect
+#define ALC_EXT_disconnect 1
+#define ALC_CONNECTED                            0x313
+#endif
+
+#ifndef ALC_EXT_thread_local_context
+#define ALC_EXT_thread_local_context 1
+typedef ALCboolean  (ALC_APIENTRY*PFNALCSETTHREADCONTEXTPROC)(ALCcontext *context);
+typedef ALCcontext* (ALC_APIENTRY*PFNALCGETTHREADCONTEXTPROC)(void);
+#ifdef AL_ALEXT_PROTOTYPES
+ALC_API ALCboolean  ALC_APIENTRY alcSetThreadContext(ALCcontext *context);
+ALC_API ALCcontext* ALC_APIENTRY alcGetThreadContext(void);
+#endif
+#endif
+
+#ifndef AL_EXT_source_distance_model
+#define AL_EXT_source_distance_model 1
+#define AL_SOURCE_DISTANCE_MODEL                 0x200
+#endif
+
+#ifndef AL_SOFT_buffer_sub_data
+#define AL_SOFT_buffer_sub_data 1
+#define AL_BYTE_RW_OFFSETS_SOFT                  0x1031
+#define AL_SAMPLE_RW_OFFSETS_SOFT                0x1032
+typedef ALvoid (AL_APIENTRY*PFNALBUFFERSUBDATASOFTPROC)(ALuint,ALenum,const ALvoid*,ALsizei,ALsizei);
+#ifdef AL_ALEXT_PROTOTYPES
+AL_API ALvoid AL_APIENTRY alBufferSubDataSOFT(ALuint buffer,ALenum format,const ALvoid *data,ALsizei offset,ALsizei length);
+#endif
+#endif
+
+#ifndef AL_SOFT_loop_points
+#define AL_SOFT_loop_points 1
+#define AL_LOOP_POINTS_SOFT                      0x2015
+#endif
+
+#ifndef AL_EXT_FOLDBACK
+#define AL_EXT_FOLDBACK 1
+#define AL_EXT_FOLDBACK_NAME                     "AL_EXT_FOLDBACK"
+#define AL_FOLDBACK_EVENT_BLOCK                  0x4112
+#define AL_FOLDBACK_EVENT_START                  0x4111
+#define AL_FOLDBACK_EVENT_STOP                   0x4113
+#define AL_FOLDBACK_MODE_MONO                    0x4101
+#define AL_FOLDBACK_MODE_STEREO                  0x4102
+typedef void (AL_APIENTRY*LPALFOLDBACKCALLBACK)(ALenum,ALsizei);
+typedef void (AL_APIENTRY*LPALREQUESTFOLDBACKSTART)(ALenum,ALsizei,ALsizei,ALfloat*,LPALFOLDBACKCALLBACK);
+typedef void (AL_APIENTRY*LPALREQUESTFOLDBACKSTOP)(void);
+#ifdef AL_ALEXT_PROTOTYPES
+AL_API void AL_APIENTRY alRequestFoldbackStart(ALenum mode,ALsizei count,ALsizei length,ALfloat *mem,LPALFOLDBACKCALLBACK callback);
+AL_API void AL_APIENTRY alRequestFoldbackStop(void);
+#endif
+#endif
+
+#ifndef ALC_EXT_DEDICATED
+#define ALC_EXT_DEDICATED 1
+#define AL_DEDICATED_GAIN                        0x0001
+#define AL_EFFECT_DEDICATED_DIALOGUE             0x9001
+#define AL_EFFECT_DEDICATED_LOW_FREQUENCY_EFFECT 0x9000
+#endif
+
+#ifndef AL_SOFT_buffer_samples
+#define AL_SOFT_buffer_samples 1
+/* Channel configurations */
+#define AL_MONO_SOFT                             0x1500
+#define AL_STEREO_SOFT                           0x1501
+#define AL_REAR_SOFT                             0x1502
+#define AL_QUAD_SOFT                             0x1503
+#define AL_5POINT1_SOFT                          0x1504
+#define AL_6POINT1_SOFT                          0x1505
+#define AL_7POINT1_SOFT                          0x1506
+
+/* Sample types */
+#define AL_BYTE_SOFT                             0x1400
+#define AL_UNSIGNED_BYTE_SOFT                    0x1401
+#define AL_SHORT_SOFT                            0x1402
+#define AL_UNSIGNED_SHORT_SOFT                   0x1403
+#define AL_INT_SOFT                              0x1404
+#define AL_UNSIGNED_INT_SOFT                     0x1405
+#define AL_FLOAT_SOFT                            0x1406
+#define AL_DOUBLE_SOFT                           0x1407
+#define AL_BYTE3_SOFT                            0x1408
+#define AL_UNSIGNED_BYTE3_SOFT                   0x1409
+
+/* Storage formats */
+#define AL_MONO8_SOFT                            0x1100
+#define AL_MONO16_SOFT                           0x1101
+#define AL_MONO32F_SOFT                          0x10010
+#define AL_STEREO8_SOFT                          0x1102
+#define AL_STEREO16_SOFT                         0x1103
+#define AL_STEREO32F_SOFT                        0x10011
+#define AL_QUAD8_SOFT                            0x1204
+#define AL_QUAD16_SOFT                           0x1205
+#define AL_QUAD32F_SOFT                          0x1206
+#define AL_REAR8_SOFT                            0x1207
+#define AL_REAR16_SOFT                           0x1208
+#define AL_REAR32F_SOFT                          0x1209
+#define AL_5POINT1_8_SOFT                        0x120A
+#define AL_5POINT1_16_SOFT                       0x120B
+#define AL_5POINT1_32F_SOFT                      0x120C
+#define AL_6POINT1_8_SOFT                        0x120D
+#define AL_6POINT1_16_SOFT                       0x120E
+#define AL_6POINT1_32F_SOFT                      0x120F
+#define AL_7POINT1_8_SOFT                        0x1210
+#define AL_7POINT1_16_SOFT                       0x1211
+#define AL_7POINT1_32F_SOFT                      0x1212
+
+/* Buffer attributes */
+#define AL_INTERNAL_FORMAT_SOFT                  0x2008
+#define AL_BYTE_LENGTH_SOFT                      0x2009
+#define AL_SAMPLE_LENGTH_SOFT                    0x200A
+#define AL_SEC_LENGTH_SOFT                       0x200B
+
+typedef void (AL_APIENTRY*LPALBUFFERSAMPLESSOFT)(ALuint,ALuint,ALenum,ALsizei,ALenum,ALenum,const ALvoid*);
+typedef void (AL_APIENTRY*LPALBUFFERSUBSAMPLESSOFT)(ALuint,ALsizei,ALsizei,ALenum,ALenum,const ALvoid*);
+typedef void (AL_APIENTRY*LPALGETBUFFERSAMPLESSOFT)(ALuint,ALsizei,ALsizei,ALenum,ALenum,ALvoid*);
+typedef ALboolean (AL_APIENTRY*LPALISBUFFERFORMATSUPPORTEDSOFT)(ALenum);
+#ifdef AL_ALEXT_PROTOTYPES
+AL_API void AL_APIENTRY alBufferSamplesSOFT(ALuint buffer, ALuint samplerate, ALenum internalformat, ALsizei samples, ALenum channels, ALenum type, const ALvoid *data);
+AL_API void AL_APIENTRY alBufferSubSamplesSOFT(ALuint buffer, ALsizei offset, ALsizei samples, ALenum channels, ALenum type, const ALvoid *data);
+AL_API void AL_APIENTRY alGetBufferSamplesSOFT(ALuint buffer, ALsizei offset, ALsizei samples, ALenum channels, ALenum type, ALvoid *data);
+AL_API ALboolean AL_APIENTRY alIsBufferFormatSupportedSOFT(ALenum format);
+#endif
+#endif
+
+#ifndef AL_SOFT_direct_channels
+#define AL_SOFT_direct_channels 1
+#define AL_DIRECT_CHANNELS_SOFT                  0x1033
+#endif
+
+#ifndef ALC_SOFT_loopback
+#define ALC_SOFT_loopback 1
+#define ALC_FORMAT_CHANNELS_SOFT                 0x1990
+#define ALC_FORMAT_TYPE_SOFT                     0x1991
+
+/* Sample types */
+#define ALC_BYTE_SOFT                            0x1400
+#define ALC_UNSIGNED_BYTE_SOFT                   0x1401
+#define ALC_SHORT_SOFT                           0x1402
+#define ALC_UNSIGNED_SHORT_SOFT                  0x1403
+#define ALC_INT_SOFT                             0x1404
+#define ALC_UNSIGNED_INT_SOFT                    0x1405
+#define ALC_FLOAT_SOFT                           0x1406
+
+/* Channel configurations */
+#define ALC_MONO_SOFT                            0x1500
+#define ALC_STEREO_SOFT                          0x1501
+#define ALC_QUAD_SOFT                            0x1503
+#define ALC_5POINT1_SOFT                         0x1504
+#define ALC_6POINT1_SOFT                         0x1505
+#define ALC_7POINT1_SOFT                         0x1506
+
+typedef ALCdevice* (ALC_APIENTRY*LPALCLOOPBACKOPENDEVICESOFT)(const ALCchar*);
+typedef ALCboolean (ALC_APIENTRY*LPALCISRENDERFORMATSUPPORTEDSOFT)(ALCdevice*,ALCsizei,ALCenum,ALCenum);
+typedef void (ALC_APIENTRY*LPALCRENDERSAMPLESSOFT)(ALCdevice*,ALCvoid*,ALCsizei);
+#ifdef AL_ALEXT_PROTOTYPES
+ALC_API ALCdevice* ALC_APIENTRY alcLoopbackOpenDeviceSOFT(const ALCchar *deviceName);
+ALC_API ALCboolean ALC_APIENTRY alcIsRenderFormatSupportedSOFT(ALCdevice *device, ALCsizei freq, ALCenum channels, ALCenum type);
+ALC_API void ALC_APIENTRY alcRenderSamplesSOFT(ALCdevice *device, ALCvoid *buffer, ALCsizei samples);
+#endif
+#endif
+
+#ifndef AL_EXT_STEREO_ANGLES
+#define AL_EXT_STEREO_ANGLES 1
+#define AL_STEREO_ANGLES                         0x1030
+#endif
+
+#ifndef AL_EXT_SOURCE_RADIUS
+#define AL_EXT_SOURCE_RADIUS 1
+#define AL_SOURCE_RADIUS                         0x1031
+#endif
+
+#ifndef AL_SOFT_source_latency
+#define AL_SOFT_source_latency 1
+#define AL_SAMPLE_OFFSET_LATENCY_SOFT            0x1200
+#define AL_SEC_OFFSET_LATENCY_SOFT               0x1201
+typedef int64_t ALint64SOFT;
+typedef uint64_t ALuint64SOFT;
+typedef void (AL_APIENTRY*LPALSOURCEDSOFT)(ALuint,ALenum,ALdouble);
+typedef void (AL_APIENTRY*LPALSOURCE3DSOFT)(ALuint,ALenum,ALdouble,ALdouble,ALdouble);
+typedef void (AL_APIENTRY*LPALSOURCEDVSOFT)(ALuint,ALenum,const ALdouble*);
+typedef void (AL_APIENTRY*LPALGETSOURCEDSOFT)(ALuint,ALenum,ALdouble*);
+typedef void (AL_APIENTRY*LPALGETSOURCE3DSOFT)(ALuint,ALenum,ALdouble*,ALdouble*,ALdouble*);
+typedef void (AL_APIENTRY*LPALGETSOURCEDVSOFT)(ALuint,ALenum,ALdouble*);
+typedef void (AL_APIENTRY*LPALSOURCEI64SOFT)(ALuint,ALenum,ALint64SOFT);
+typedef void (AL_APIENTRY*LPALSOURCE3I64SOFT)(ALuint,ALenum,ALint64SOFT,ALint64SOFT,ALint64SOFT);
+typedef void (AL_APIENTRY*LPALSOURCEI64VSOFT)(ALuint,ALenum,const ALint64SOFT*);
+typedef void (AL_APIENTRY*LPALGETSOURCEI64SOFT)(ALuint,ALenum,ALint64SOFT*);
+typedef void (AL_APIENTRY*LPALGETSOURCE3I64SOFT)(ALuint,ALenum,ALint64SOFT*,ALint64SOFT*,ALint64SOFT*);
+typedef void (AL_APIENTRY*LPALGETSOURCEI64VSOFT)(ALuint,ALenum,ALint64SOFT*);
+#ifdef AL_ALEXT_PROTOTYPES
+AL_API void AL_APIENTRY alSourcedSOFT(ALuint source, ALenum param, ALdouble value);
+AL_API void AL_APIENTRY alSource3dSOFT(ALuint source, ALenum param, ALdouble value1, ALdouble value2, ALdouble value3);
+AL_API void AL_APIENTRY alSourcedvSOFT(ALuint source, ALenum param, const ALdouble *values);
+AL_API void AL_APIENTRY alGetSourcedSOFT(ALuint source, ALenum param, ALdouble *value);
+AL_API void AL_APIENTRY alGetSource3dSOFT(ALuint source, ALenum param, ALdouble *value1, ALdouble *value2, ALdouble *value3);
+AL_API void AL_APIENTRY alGetSourcedvSOFT(ALuint source, ALenum param, ALdouble *values);
+AL_API void AL_APIENTRY alSourcei64SOFT(ALuint source, ALenum param, ALint64SOFT value);
+AL_API void AL_APIENTRY alSource3i64SOFT(ALuint source, ALenum param, ALint64SOFT value1, ALint64SOFT value2, ALint64SOFT value3);
+AL_API void AL_APIENTRY alSourcei64vSOFT(ALuint source, ALenum param, const ALint64SOFT *values);
+AL_API void AL_APIENTRY alGetSourcei64SOFT(ALuint source, ALenum param, ALint64SOFT *value);
+AL_API void AL_APIENTRY alGetSource3i64SOFT(ALuint source, ALenum param, ALint64SOFT *value1, ALint64SOFT *value2, ALint64SOFT *value3);
+AL_API void AL_APIENTRY alGetSourcei64vSOFT(ALuint source, ALenum param, ALint64SOFT *values);
+#endif
+#endif
+
+#ifndef ALC_EXT_DEFAULT_FILTER_ORDER
+#define ALC_EXT_DEFAULT_FILTER_ORDER 1
+#define ALC_DEFAULT_FILTER_ORDER                 0x1100
+#endif
+
+#ifndef AL_SOFT_deferred_updates
+#define AL_SOFT_deferred_updates 1
+#define AL_DEFERRED_UPDATES_SOFT                 0xC002
+typedef ALvoid (AL_APIENTRY*LPALDEFERUPDATESSOFT)(void);
+typedef ALvoid (AL_APIENTRY*LPALPROCESSUPDATESSOFT)(void);
+#ifdef AL_ALEXT_PROTOTYPES
+AL_API ALvoid AL_APIENTRY alDeferUpdatesSOFT(void);
+AL_API ALvoid AL_APIENTRY alProcessUpdatesSOFT(void);
+#endif
+#endif
+
+#ifndef AL_SOFT_block_alignment
+#define AL_SOFT_block_alignment 1
+#define AL_UNPACK_BLOCK_ALIGNMENT_SOFT           0x200C
+#define AL_PACK_BLOCK_ALIGNMENT_SOFT             0x200D
+#endif
+
+#ifndef AL_SOFT_MSADPCM
+#define AL_SOFT_MSADPCM 1
+#define AL_FORMAT_MONO_MSADPCM_SOFT              0x1302
+#define AL_FORMAT_STEREO_MSADPCM_SOFT            0x1303
+#endif
+
+#ifndef AL_SOFT_source_length
+#define AL_SOFT_source_length 1
+/*#define AL_BYTE_LENGTH_SOFT                      0x2009*/
+/*#define AL_SAMPLE_LENGTH_SOFT                    0x200A*/
+/*#define AL_SEC_LENGTH_SOFT                       0x200B*/
+#endif
+
+#ifndef ALC_SOFT_pause_device
+#define ALC_SOFT_pause_device 1
+typedef void (ALC_APIENTRY*LPALCDEVICEPAUSESOFT)(ALCdevice *device);
+typedef void (ALC_APIENTRY*LPALCDEVICERESUMESOFT)(ALCdevice *device);
+#ifdef AL_ALEXT_PROTOTYPES
+ALC_API void ALC_APIENTRY alcDevicePauseSOFT(ALCdevice *device);
+ALC_API void ALC_APIENTRY alcDeviceResumeSOFT(ALCdevice *device);
+#endif
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/src/sound/thirdparty/efx.h b/src/sound/thirdparty/efx.h
new file mode 100644
index 0000000000..57766983f6
--- /dev/null
+++ b/src/sound/thirdparty/efx.h
@@ -0,0 +1,761 @@
+#ifndef AL_EFX_H
+#define AL_EFX_H
+
+
+#include "alc.h"
+#include "al.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define ALC_EXT_EFX_NAME                         "ALC_EXT_EFX"
+
+#define ALC_EFX_MAJOR_VERSION                    0x20001
+#define ALC_EFX_MINOR_VERSION                    0x20002
+#define ALC_MAX_AUXILIARY_SENDS                  0x20003
+
+
+/* Listener properties. */
+#define AL_METERS_PER_UNIT                       0x20004
+
+/* Source properties. */
+#define AL_DIRECT_FILTER                         0x20005
+#define AL_AUXILIARY_SEND_FILTER                 0x20006
+#define AL_AIR_ABSORPTION_FACTOR                 0x20007
+#define AL_ROOM_ROLLOFF_FACTOR                   0x20008
+#define AL_CONE_OUTER_GAINHF                     0x20009
+#define AL_DIRECT_FILTER_GAINHF_AUTO             0x2000A
+#define AL_AUXILIARY_SEND_FILTER_GAIN_AUTO       0x2000B
+#define AL_AUXILIARY_SEND_FILTER_GAINHF_AUTO     0x2000C
+
+
+/* Effect properties. */
+
+/* Reverb effect parameters */
+#define AL_REVERB_DENSITY                        0x0001
+#define AL_REVERB_DIFFUSION                      0x0002
+#define AL_REVERB_GAIN                           0x0003
+#define AL_REVERB_GAINHF                         0x0004
+#define AL_REVERB_DECAY_TIME                     0x0005
+#define AL_REVERB_DECAY_HFRATIO                  0x0006
+#define AL_REVERB_REFLECTIONS_GAIN               0x0007
+#define AL_REVERB_REFLECTIONS_DELAY              0x0008
+#define AL_REVERB_LATE_REVERB_GAIN               0x0009
+#define AL_REVERB_LATE_REVERB_DELAY              0x000A
+#define AL_REVERB_AIR_ABSORPTION_GAINHF          0x000B
+#define AL_REVERB_ROOM_ROLLOFF_FACTOR            0x000C
+#define AL_REVERB_DECAY_HFLIMIT                  0x000D
+
+/* EAX Reverb effect parameters */
+#define AL_EAXREVERB_DENSITY                     0x0001
+#define AL_EAXREVERB_DIFFUSION                   0x0002
+#define AL_EAXREVERB_GAIN                        0x0003
+#define AL_EAXREVERB_GAINHF                      0x0004
+#define AL_EAXREVERB_GAINLF                      0x0005
+#define AL_EAXREVERB_DECAY_TIME                  0x0006
+#define AL_EAXREVERB_DECAY_HFRATIO               0x0007
+#define AL_EAXREVERB_DECAY_LFRATIO               0x0008
+#define AL_EAXREVERB_REFLECTIONS_GAIN            0x0009
+#define AL_EAXREVERB_REFLECTIONS_DELAY           0x000A
+#define AL_EAXREVERB_REFLECTIONS_PAN             0x000B
+#define AL_EAXREVERB_LATE_REVERB_GAIN            0x000C
+#define AL_EAXREVERB_LATE_REVERB_DELAY           0x000D
+#define AL_EAXREVERB_LATE_REVERB_PAN             0x000E
+#define AL_EAXREVERB_ECHO_TIME                   0x000F
+#define AL_EAXREVERB_ECHO_DEPTH                  0x0010
+#define AL_EAXREVERB_MODULATION_TIME             0x0011
+#define AL_EAXREVERB_MODULATION_DEPTH            0x0012
+#define AL_EAXREVERB_AIR_ABSORPTION_GAINHF       0x0013
+#define AL_EAXREVERB_HFREFERENCE                 0x0014
+#define AL_EAXREVERB_LFREFERENCE                 0x0015
+#define AL_EAXREVERB_ROOM_ROLLOFF_FACTOR         0x0016
+#define AL_EAXREVERB_DECAY_HFLIMIT               0x0017
+
+/* Chorus effect parameters */
+#define AL_CHORUS_WAVEFORM                       0x0001
+#define AL_CHORUS_PHASE                          0x0002
+#define AL_CHORUS_RATE                           0x0003
+#define AL_CHORUS_DEPTH                          0x0004
+#define AL_CHORUS_FEEDBACK                       0x0005
+#define AL_CHORUS_DELAY                          0x0006
+
+/* Distortion effect parameters */
+#define AL_DISTORTION_EDGE                       0x0001
+#define AL_DISTORTION_GAIN                       0x0002
+#define AL_DISTORTION_LOWPASS_CUTOFF             0x0003
+#define AL_DISTORTION_EQCENTER                   0x0004
+#define AL_DISTORTION_EQBANDWIDTH                0x0005
+
+/* Echo effect parameters */
+#define AL_ECHO_DELAY                            0x0001
+#define AL_ECHO_LRDELAY                          0x0002
+#define AL_ECHO_DAMPING                          0x0003
+#define AL_ECHO_FEEDBACK                         0x0004
+#define AL_ECHO_SPREAD                           0x0005
+
+/* Flanger effect parameters */
+#define AL_FLANGER_WAVEFORM                      0x0001
+#define AL_FLANGER_PHASE                         0x0002
+#define AL_FLANGER_RATE                          0x0003
+#define AL_FLANGER_DEPTH                         0x0004
+#define AL_FLANGER_FEEDBACK                      0x0005
+#define AL_FLANGER_DELAY                         0x0006
+
+/* Frequency shifter effect parameters */
+#define AL_FREQUENCY_SHIFTER_FREQUENCY           0x0001
+#define AL_FREQUENCY_SHIFTER_LEFT_DIRECTION      0x0002
+#define AL_FREQUENCY_SHIFTER_RIGHT_DIRECTION     0x0003
+
+/* Vocal morpher effect parameters */
+#define AL_VOCAL_MORPHER_PHONEMEA                0x0001
+#define AL_VOCAL_MORPHER_PHONEMEA_COARSE_TUNING  0x0002
+#define AL_VOCAL_MORPHER_PHONEMEB                0x0003
+#define AL_VOCAL_MORPHER_PHONEMEB_COARSE_TUNING  0x0004
+#define AL_VOCAL_MORPHER_WAVEFORM                0x0005
+#define AL_VOCAL_MORPHER_RATE                    0x0006
+
+/* Pitchshifter effect parameters */
+#define AL_PITCH_SHIFTER_COARSE_TUNE             0x0001
+#define AL_PITCH_SHIFTER_FINE_TUNE               0x0002
+
+/* Ringmodulator effect parameters */
+#define AL_RING_MODULATOR_FREQUENCY              0x0001
+#define AL_RING_MODULATOR_HIGHPASS_CUTOFF        0x0002
+#define AL_RING_MODULATOR_WAVEFORM               0x0003
+
+/* Autowah effect parameters */
+#define AL_AUTOWAH_ATTACK_TIME                   0x0001
+#define AL_AUTOWAH_RELEASE_TIME                  0x0002
+#define AL_AUTOWAH_RESONANCE                     0x0003
+#define AL_AUTOWAH_PEAK_GAIN                     0x0004
+
+/* Compressor effect parameters */
+#define AL_COMPRESSOR_ONOFF                      0x0001
+
+/* Equalizer effect parameters */
+#define AL_EQUALIZER_LOW_GAIN                    0x0001
+#define AL_EQUALIZER_LOW_CUTOFF                  0x0002
+#define AL_EQUALIZER_MID1_GAIN                   0x0003
+#define AL_EQUALIZER_MID1_CENTER                 0x0004
+#define AL_EQUALIZER_MID1_WIDTH                  0x0005
+#define AL_EQUALIZER_MID2_GAIN                   0x0006
+#define AL_EQUALIZER_MID2_CENTER                 0x0007
+#define AL_EQUALIZER_MID2_WIDTH                  0x0008
+#define AL_EQUALIZER_HIGH_GAIN                   0x0009
+#define AL_EQUALIZER_HIGH_CUTOFF                 0x000A
+
+/* Effect type */
+#define AL_EFFECT_FIRST_PARAMETER                0x0000
+#define AL_EFFECT_LAST_PARAMETER                 0x8000
+#define AL_EFFECT_TYPE                           0x8001
+
+/* Effect types, used with the AL_EFFECT_TYPE property */
+#define AL_EFFECT_NULL                           0x0000
+#define AL_EFFECT_REVERB                         0x0001
+#define AL_EFFECT_CHORUS                         0x0002
+#define AL_EFFECT_DISTORTION                     0x0003
+#define AL_EFFECT_ECHO                           0x0004
+#define AL_EFFECT_FLANGER                        0x0005
+#define AL_EFFECT_FREQUENCY_SHIFTER              0x0006
+#define AL_EFFECT_VOCAL_MORPHER                  0x0007
+#define AL_EFFECT_PITCH_SHIFTER                  0x0008
+#define AL_EFFECT_RING_MODULATOR                 0x0009
+#define AL_EFFECT_AUTOWAH                        0x000A
+#define AL_EFFECT_COMPRESSOR                     0x000B
+#define AL_EFFECT_EQUALIZER                      0x000C
+#define AL_EFFECT_EAXREVERB                      0x8000
+
+/* Auxiliary Effect Slot properties. */
+#define AL_EFFECTSLOT_EFFECT                     0x0001
+#define AL_EFFECTSLOT_GAIN                       0x0002
+#define AL_EFFECTSLOT_AUXILIARY_SEND_AUTO        0x0003
+
+/* NULL Auxiliary Slot ID to disable a source send. */
+#define AL_EFFECTSLOT_NULL                       0x0000
+
+
+/* Filter properties. */
+
+/* Lowpass filter parameters */
+#define AL_LOWPASS_GAIN                          0x0001
+#define AL_LOWPASS_GAINHF                        0x0002
+
+/* Highpass filter parameters */
+#define AL_HIGHPASS_GAIN                         0x0001
+#define AL_HIGHPASS_GAINLF                       0x0002
+
+/* Bandpass filter parameters */
+#define AL_BANDPASS_GAIN                         0x0001
+#define AL_BANDPASS_GAINLF                       0x0002
+#define AL_BANDPASS_GAINHF                       0x0003
+
+/* Filter type */
+#define AL_FILTER_FIRST_PARAMETER                0x0000
+#define AL_FILTER_LAST_PARAMETER                 0x8000
+#define AL_FILTER_TYPE                           0x8001
+
+/* Filter types, used with the AL_FILTER_TYPE property */
+#define AL_FILTER_NULL                           0x0000
+#define AL_FILTER_LOWPASS                        0x0001
+#define AL_FILTER_HIGHPASS                       0x0002
+#define AL_FILTER_BANDPASS                       0x0003
+
+
+/* Effect object function types. */
+typedef void (AL_APIENTRY *LPALGENEFFECTS)(ALsizei, ALuint*);
+typedef void (AL_APIENTRY *LPALDELETEEFFECTS)(ALsizei, const ALuint*);
+typedef ALboolean (AL_APIENTRY *LPALISEFFECT)(ALuint);
+typedef void (AL_APIENTRY *LPALEFFECTI)(ALuint, ALenum, ALint);
+typedef void (AL_APIENTRY *LPALEFFECTIV)(ALuint, ALenum, const ALint*);
+typedef void (AL_APIENTRY *LPALEFFECTF)(ALuint, ALenum, ALfloat);
+typedef void (AL_APIENTRY *LPALEFFECTFV)(ALuint, ALenum, const ALfloat*);
+typedef void (AL_APIENTRY *LPALGETEFFECTI)(ALuint, ALenum, ALint*);
+typedef void (AL_APIENTRY *LPALGETEFFECTIV)(ALuint, ALenum, ALint*);
+typedef void (AL_APIENTRY *LPALGETEFFECTF)(ALuint, ALenum, ALfloat*);
+typedef void (AL_APIENTRY *LPALGETEFFECTFV)(ALuint, ALenum, ALfloat*);
+
+/* Filter object function types. */
+typedef void (AL_APIENTRY *LPALGENFILTERS)(ALsizei, ALuint*);
+typedef void (AL_APIENTRY *LPALDELETEFILTERS)(ALsizei, const ALuint*);
+typedef ALboolean (AL_APIENTRY *LPALISFILTER)(ALuint);
+typedef void (AL_APIENTRY *LPALFILTERI)(ALuint, ALenum, ALint);
+typedef void (AL_APIENTRY *LPALFILTERIV)(ALuint, ALenum, const ALint*);
+typedef void (AL_APIENTRY *LPALFILTERF)(ALuint, ALenum, ALfloat);
+typedef void (AL_APIENTRY *LPALFILTERFV)(ALuint, ALenum, const ALfloat*);
+typedef void (AL_APIENTRY *LPALGETFILTERI)(ALuint, ALenum, ALint*);
+typedef void (AL_APIENTRY *LPALGETFILTERIV)(ALuint, ALenum, ALint*);
+typedef void (AL_APIENTRY *LPALGETFILTERF)(ALuint, ALenum, ALfloat*);
+typedef void (AL_APIENTRY *LPALGETFILTERFV)(ALuint, ALenum, ALfloat*);
+
+/* Auxiliary Effect Slot object function types. */
+typedef void (AL_APIENTRY *LPALGENAUXILIARYEFFECTSLOTS)(ALsizei, ALuint*);
+typedef void (AL_APIENTRY *LPALDELETEAUXILIARYEFFECTSLOTS)(ALsizei, const ALuint*);
+typedef ALboolean (AL_APIENTRY *LPALISAUXILIARYEFFECTSLOT)(ALuint);
+typedef void (AL_APIENTRY *LPALAUXILIARYEFFECTSLOTI)(ALuint, ALenum, ALint);
+typedef void (AL_APIENTRY *LPALAUXILIARYEFFECTSLOTIV)(ALuint, ALenum, const ALint*);
+typedef void (AL_APIENTRY *LPALAUXILIARYEFFECTSLOTF)(ALuint, ALenum, ALfloat);
+typedef void (AL_APIENTRY *LPALAUXILIARYEFFECTSLOTFV)(ALuint, ALenum, const ALfloat*);
+typedef void (AL_APIENTRY *LPALGETAUXILIARYEFFECTSLOTI)(ALuint, ALenum, ALint*);
+typedef void (AL_APIENTRY *LPALGETAUXILIARYEFFECTSLOTIV)(ALuint, ALenum, ALint*);
+typedef void (AL_APIENTRY *LPALGETAUXILIARYEFFECTSLOTF)(ALuint, ALenum, ALfloat*);
+typedef void (AL_APIENTRY *LPALGETAUXILIARYEFFECTSLOTFV)(ALuint, ALenum, ALfloat*);
+
+#ifdef AL_ALEXT_PROTOTYPES
+AL_API ALvoid AL_APIENTRY alGenEffects(ALsizei n, ALuint *effects);
+AL_API ALvoid AL_APIENTRY alDeleteEffects(ALsizei n, const ALuint *effects);
+AL_API ALboolean AL_APIENTRY alIsEffect(ALuint effect);
+AL_API ALvoid AL_APIENTRY alEffecti(ALuint effect, ALenum param, ALint iValue);
+AL_API ALvoid AL_APIENTRY alEffectiv(ALuint effect, ALenum param, const ALint *piValues);
+AL_API ALvoid AL_APIENTRY alEffectf(ALuint effect, ALenum param, ALfloat flValue);
+AL_API ALvoid AL_APIENTRY alEffectfv(ALuint effect, ALenum param, const ALfloat *pflValues);
+AL_API ALvoid AL_APIENTRY alGetEffecti(ALuint effect, ALenum param, ALint *piValue);
+AL_API ALvoid AL_APIENTRY alGetEffectiv(ALuint effect, ALenum param, ALint *piValues);
+AL_API ALvoid AL_APIENTRY alGetEffectf(ALuint effect, ALenum param, ALfloat *pflValue);
+AL_API ALvoid AL_APIENTRY alGetEffectfv(ALuint effect, ALenum param, ALfloat *pflValues);
+
+AL_API ALvoid AL_APIENTRY alGenFilters(ALsizei n, ALuint *filters);
+AL_API ALvoid AL_APIENTRY alDeleteFilters(ALsizei n, const ALuint *filters);
+AL_API ALboolean AL_APIENTRY alIsFilter(ALuint filter);
+AL_API ALvoid AL_APIENTRY alFilteri(ALuint filter, ALenum param, ALint iValue);
+AL_API ALvoid AL_APIENTRY alFilteriv(ALuint filter, ALenum param, const ALint *piValues);
+AL_API ALvoid AL_APIENTRY alFilterf(ALuint filter, ALenum param, ALfloat flValue);
+AL_API ALvoid AL_APIENTRY alFilterfv(ALuint filter, ALenum param, const ALfloat *pflValues);
+AL_API ALvoid AL_APIENTRY alGetFilteri(ALuint filter, ALenum param, ALint *piValue);
+AL_API ALvoid AL_APIENTRY alGetFilteriv(ALuint filter, ALenum param, ALint *piValues);
+AL_API ALvoid AL_APIENTRY alGetFilterf(ALuint filter, ALenum param, ALfloat *pflValue);
+AL_API ALvoid AL_APIENTRY alGetFilterfv(ALuint filter, ALenum param, ALfloat *pflValues);
+
+AL_API ALvoid AL_APIENTRY alGenAuxiliaryEffectSlots(ALsizei n, ALuint *effectslots);
+AL_API ALvoid AL_APIENTRY alDeleteAuxiliaryEffectSlots(ALsizei n, const ALuint *effectslots);
+AL_API ALboolean AL_APIENTRY alIsAuxiliaryEffectSlot(ALuint effectslot);
+AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSloti(ALuint effectslot, ALenum param, ALint iValue);
+AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSlotiv(ALuint effectslot, ALenum param, const ALint *piValues);
+AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSlotf(ALuint effectslot, ALenum param, ALfloat flValue);
+AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSlotfv(ALuint effectslot, ALenum param, const ALfloat *pflValues);
+AL_API ALvoid AL_APIENTRY alGetAuxiliaryEffectSloti(ALuint effectslot, ALenum param, ALint *piValue);
+AL_API ALvoid AL_APIENTRY alGetAuxiliaryEffectSlotiv(ALuint effectslot, ALenum param, ALint *piValues);
+AL_API ALvoid AL_APIENTRY alGetAuxiliaryEffectSlotf(ALuint effectslot, ALenum param, ALfloat *pflValue);
+AL_API ALvoid AL_APIENTRY alGetAuxiliaryEffectSlotfv(ALuint effectslot, ALenum param, ALfloat *pflValues);
+#endif
+
+/* Filter ranges and defaults. */
+
+/* Lowpass filter */
+#define AL_LOWPASS_MIN_GAIN                      (0.0f)
+#define AL_LOWPASS_MAX_GAIN                      (1.0f)
+#define AL_LOWPASS_DEFAULT_GAIN                  (1.0f)
+
+#define AL_LOWPASS_MIN_GAINHF                    (0.0f)
+#define AL_LOWPASS_MAX_GAINHF                    (1.0f)
+#define AL_LOWPASS_DEFAULT_GAINHF                (1.0f)
+
+/* Highpass filter */
+#define AL_HIGHPASS_MIN_GAIN                     (0.0f)
+#define AL_HIGHPASS_MAX_GAIN                     (1.0f)
+#define AL_HIGHPASS_DEFAULT_GAIN                 (1.0f)
+
+#define AL_HIGHPASS_MIN_GAINLF                   (0.0f)
+#define AL_HIGHPASS_MAX_GAINLF                   (1.0f)
+#define AL_HIGHPASS_DEFAULT_GAINLF               (1.0f)
+
+/* Bandpass filter */
+#define AL_BANDPASS_MIN_GAIN                     (0.0f)
+#define AL_BANDPASS_MAX_GAIN                     (1.0f)
+#define AL_BANDPASS_DEFAULT_GAIN                 (1.0f)
+
+#define AL_BANDPASS_MIN_GAINHF                   (0.0f)
+#define AL_BANDPASS_MAX_GAINHF                   (1.0f)
+#define AL_BANDPASS_DEFAULT_GAINHF               (1.0f)
+
+#define AL_BANDPASS_MIN_GAINLF                   (0.0f)
+#define AL_BANDPASS_MAX_GAINLF                   (1.0f)
+#define AL_BANDPASS_DEFAULT_GAINLF               (1.0f)
+
+
+/* Effect parameter ranges and defaults. */
+
+/* Standard reverb effect */
+#define AL_REVERB_MIN_DENSITY                    (0.0f)
+#define AL_REVERB_MAX_DENSITY                    (1.0f)
+#define AL_REVERB_DEFAULT_DENSITY                (1.0f)
+
+#define AL_REVERB_MIN_DIFFUSION                  (0.0f)
+#define AL_REVERB_MAX_DIFFUSION                  (1.0f)
+#define AL_REVERB_DEFAULT_DIFFUSION              (1.0f)
+
+#define AL_REVERB_MIN_GAIN                       (0.0f)
+#define AL_REVERB_MAX_GAIN                       (1.0f)
+#define AL_REVERB_DEFAULT_GAIN                   (0.32f)
+
+#define AL_REVERB_MIN_GAINHF                     (0.0f)
+#define AL_REVERB_MAX_GAINHF                     (1.0f)
+#define AL_REVERB_DEFAULT_GAINHF                 (0.89f)
+
+#define AL_REVERB_MIN_DECAY_TIME                 (0.1f)
+#define AL_REVERB_MAX_DECAY_TIME                 (20.0f)
+#define AL_REVERB_DEFAULT_DECAY_TIME             (1.49f)
+
+#define AL_REVERB_MIN_DECAY_HFRATIO              (0.1f)
+#define AL_REVERB_MAX_DECAY_HFRATIO              (2.0f)
+#define AL_REVERB_DEFAULT_DECAY_HFRATIO          (0.83f)
+
+#define AL_REVERB_MIN_REFLECTIONS_GAIN           (0.0f)
+#define AL_REVERB_MAX_REFLECTIONS_GAIN           (3.16f)
+#define AL_REVERB_DEFAULT_REFLECTIONS_GAIN       (0.05f)
+
+#define AL_REVERB_MIN_REFLECTIONS_DELAY          (0.0f)
+#define AL_REVERB_MAX_REFLECTIONS_DELAY          (0.3f)
+#define AL_REVERB_DEFAULT_REFLECTIONS_DELAY      (0.007f)
+
+#define AL_REVERB_MIN_LATE_REVERB_GAIN           (0.0f)
+#define AL_REVERB_MAX_LATE_REVERB_GAIN           (10.0f)
+#define AL_REVERB_DEFAULT_LATE_REVERB_GAIN       (1.26f)
+
+#define AL_REVERB_MIN_LATE_REVERB_DELAY          (0.0f)
+#define AL_REVERB_MAX_LATE_REVERB_DELAY          (0.1f)
+#define AL_REVERB_DEFAULT_LATE_REVERB_DELAY      (0.011f)
+
+#define AL_REVERB_MIN_AIR_ABSORPTION_GAINHF      (0.892f)
+#define AL_REVERB_MAX_AIR_ABSORPTION_GAINHF      (1.0f)
+#define AL_REVERB_DEFAULT_AIR_ABSORPTION_GAINHF  (0.994f)
+
+#define AL_REVERB_MIN_ROOM_ROLLOFF_FACTOR        (0.0f)
+#define AL_REVERB_MAX_ROOM_ROLLOFF_FACTOR        (10.0f)
+#define AL_REVERB_DEFAULT_ROOM_ROLLOFF_FACTOR    (0.0f)
+
+#define AL_REVERB_MIN_DECAY_HFLIMIT              AL_FALSE
+#define AL_REVERB_MAX_DECAY_HFLIMIT              AL_TRUE
+#define AL_REVERB_DEFAULT_DECAY_HFLIMIT          AL_TRUE
+
+/* EAX reverb effect */
+#define AL_EAXREVERB_MIN_DENSITY                 (0.0f)
+#define AL_EAXREVERB_MAX_DENSITY                 (1.0f)
+#define AL_EAXREVERB_DEFAULT_DENSITY             (1.0f)
+
+#define AL_EAXREVERB_MIN_DIFFUSION               (0.0f)
+#define AL_EAXREVERB_MAX_DIFFUSION               (1.0f)
+#define AL_EAXREVERB_DEFAULT_DIFFUSION           (1.0f)
+
+#define AL_EAXREVERB_MIN_GAIN                    (0.0f)
+#define AL_EAXREVERB_MAX_GAIN                    (1.0f)
+#define AL_EAXREVERB_DEFAULT_GAIN                (0.32f)
+
+#define AL_EAXREVERB_MIN_GAINHF                  (0.0f)
+#define AL_EAXREVERB_MAX_GAINHF                  (1.0f)
+#define AL_EAXREVERB_DEFAULT_GAINHF              (0.89f)
+
+#define AL_EAXREVERB_MIN_GAINLF                  (0.0f)
+#define AL_EAXREVERB_MAX_GAINLF                  (1.0f)
+#define AL_EAXREVERB_DEFAULT_GAINLF              (1.0f)
+
+#define AL_EAXREVERB_MIN_DECAY_TIME              (0.1f)
+#define AL_EAXREVERB_MAX_DECAY_TIME              (20.0f)
+#define AL_EAXREVERB_DEFAULT_DECAY_TIME          (1.49f)
+
+#define AL_EAXREVERB_MIN_DECAY_HFRATIO           (0.1f)
+#define AL_EAXREVERB_MAX_DECAY_HFRATIO           (2.0f)
+#define AL_EAXREVERB_DEFAULT_DECAY_HFRATIO       (0.83f)
+
+#define AL_EAXREVERB_MIN_DECAY_LFRATIO           (0.1f)
+#define AL_EAXREVERB_MAX_DECAY_LFRATIO           (2.0f)
+#define AL_EAXREVERB_DEFAULT_DECAY_LFRATIO       (1.0f)
+
+#define AL_EAXREVERB_MIN_REFLECTIONS_GAIN        (0.0f)
+#define AL_EAXREVERB_MAX_REFLECTIONS_GAIN        (3.16f)
+#define AL_EAXREVERB_DEFAULT_REFLECTIONS_GAIN    (0.05f)
+
+#define AL_EAXREVERB_MIN_REFLECTIONS_DELAY       (0.0f)
+#define AL_EAXREVERB_MAX_REFLECTIONS_DELAY       (0.3f)
+#define AL_EAXREVERB_DEFAULT_REFLECTIONS_DELAY   (0.007f)
+
+#define AL_EAXREVERB_DEFAULT_REFLECTIONS_PAN_XYZ (0.0f)
+
+#define AL_EAXREVERB_MIN_LATE_REVERB_GAIN        (0.0f)
+#define AL_EAXREVERB_MAX_LATE_REVERB_GAIN        (10.0f)
+#define AL_EAXREVERB_DEFAULT_LATE_REVERB_GAIN    (1.26f)
+
+#define AL_EAXREVERB_MIN_LATE_REVERB_DELAY       (0.0f)
+#define AL_EAXREVERB_MAX_LATE_REVERB_DELAY       (0.1f)
+#define AL_EAXREVERB_DEFAULT_LATE_REVERB_DELAY   (0.011f)
+
+#define AL_EAXREVERB_DEFAULT_LATE_REVERB_PAN_XYZ (0.0f)
+
+#define AL_EAXREVERB_MIN_ECHO_TIME               (0.075f)
+#define AL_EAXREVERB_MAX_ECHO_TIME               (0.25f)
+#define AL_EAXREVERB_DEFAULT_ECHO_TIME           (0.25f)
+
+#define AL_EAXREVERB_MIN_ECHO_DEPTH              (0.0f)
+#define AL_EAXREVERB_MAX_ECHO_DEPTH              (1.0f)
+#define AL_EAXREVERB_DEFAULT_ECHO_DEPTH          (0.0f)
+
+#define AL_EAXREVERB_MIN_MODULATION_TIME         (0.04f)
+#define AL_EAXREVERB_MAX_MODULATION_TIME         (4.0f)
+#define AL_EAXREVERB_DEFAULT_MODULATION_TIME     (0.25f)
+
+#define AL_EAXREVERB_MIN_MODULATION_DEPTH        (0.0f)
+#define AL_EAXREVERB_MAX_MODULATION_DEPTH        (1.0f)
+#define AL_EAXREVERB_DEFAULT_MODULATION_DEPTH    (0.0f)
+
+#define AL_EAXREVERB_MIN_AIR_ABSORPTION_GAINHF   (0.892f)
+#define AL_EAXREVERB_MAX_AIR_ABSORPTION_GAINHF   (1.0f)
+#define AL_EAXREVERB_DEFAULT_AIR_ABSORPTION_GAINHF (0.994f)
+
+#define AL_EAXREVERB_MIN_HFREFERENCE             (1000.0f)
+#define AL_EAXREVERB_MAX_HFREFERENCE             (20000.0f)
+#define AL_EAXREVERB_DEFAULT_HFREFERENCE         (5000.0f)
+
+#define AL_EAXREVERB_MIN_LFREFERENCE             (20.0f)
+#define AL_EAXREVERB_MAX_LFREFERENCE             (1000.0f)
+#define AL_EAXREVERB_DEFAULT_LFREFERENCE         (250.0f)
+
+#define AL_EAXREVERB_MIN_ROOM_ROLLOFF_FACTOR     (0.0f)
+#define AL_EAXREVERB_MAX_ROOM_ROLLOFF_FACTOR     (10.0f)
+#define AL_EAXREVERB_DEFAULT_ROOM_ROLLOFF_FACTOR (0.0f)
+
+#define AL_EAXREVERB_MIN_DECAY_HFLIMIT           AL_FALSE
+#define AL_EAXREVERB_MAX_DECAY_HFLIMIT           AL_TRUE
+#define AL_EAXREVERB_DEFAULT_DECAY_HFLIMIT       AL_TRUE
+
+/* Chorus effect */
+#define AL_CHORUS_WAVEFORM_SINUSOID              (0)
+#define AL_CHORUS_WAVEFORM_TRIANGLE              (1)
+
+#define AL_CHORUS_MIN_WAVEFORM                   (0)
+#define AL_CHORUS_MAX_WAVEFORM                   (1)
+#define AL_CHORUS_DEFAULT_WAVEFORM               (1)
+
+#define AL_CHORUS_MIN_PHASE                      (-180)
+#define AL_CHORUS_MAX_PHASE                      (180)
+#define AL_CHORUS_DEFAULT_PHASE                  (90)
+
+#define AL_CHORUS_MIN_RATE                       (0.0f)
+#define AL_CHORUS_MAX_RATE                       (10.0f)
+#define AL_CHORUS_DEFAULT_RATE                   (1.1f)
+
+#define AL_CHORUS_MIN_DEPTH                      (0.0f)
+#define AL_CHORUS_MAX_DEPTH                      (1.0f)
+#define AL_CHORUS_DEFAULT_DEPTH                  (0.1f)
+
+#define AL_CHORUS_MIN_FEEDBACK                   (-1.0f)
+#define AL_CHORUS_MAX_FEEDBACK                   (1.0f)
+#define AL_CHORUS_DEFAULT_FEEDBACK               (0.25f)
+
+#define AL_CHORUS_MIN_DELAY                      (0.0f)
+#define AL_CHORUS_MAX_DELAY                      (0.016f)
+#define AL_CHORUS_DEFAULT_DELAY                  (0.016f)
+
+/* Distortion effect */
+#define AL_DISTORTION_MIN_EDGE                   (0.0f)
+#define AL_DISTORTION_MAX_EDGE                   (1.0f)
+#define AL_DISTORTION_DEFAULT_EDGE               (0.2f)
+
+#define AL_DISTORTION_MIN_GAIN                   (0.01f)
+#define AL_DISTORTION_MAX_GAIN                   (1.0f)
+#define AL_DISTORTION_DEFAULT_GAIN               (0.05f)
+
+#define AL_DISTORTION_MIN_LOWPASS_CUTOFF         (80.0f)
+#define AL_DISTORTION_MAX_LOWPASS_CUTOFF         (24000.0f)
+#define AL_DISTORTION_DEFAULT_LOWPASS_CUTOFF     (8000.0f)
+
+#define AL_DISTORTION_MIN_EQCENTER               (80.0f)
+#define AL_DISTORTION_MAX_EQCENTER               (24000.0f)
+#define AL_DISTORTION_DEFAULT_EQCENTER           (3600.0f)
+
+#define AL_DISTORTION_MIN_EQBANDWIDTH            (80.0f)
+#define AL_DISTORTION_MAX_EQBANDWIDTH            (24000.0f)
+#define AL_DISTORTION_DEFAULT_EQBANDWIDTH        (3600.0f)
+
+/* Echo effect */
+#define AL_ECHO_MIN_DELAY                        (0.0f)
+#define AL_ECHO_MAX_DELAY                        (0.207f)
+#define AL_ECHO_DEFAULT_DELAY                    (0.1f)
+
+#define AL_ECHO_MIN_LRDELAY                      (0.0f)
+#define AL_ECHO_MAX_LRDELAY                      (0.404f)
+#define AL_ECHO_DEFAULT_LRDELAY                  (0.1f)
+
+#define AL_ECHO_MIN_DAMPING                      (0.0f)
+#define AL_ECHO_MAX_DAMPING                      (0.99f)
+#define AL_ECHO_DEFAULT_DAMPING                  (0.5f)
+
+#define AL_ECHO_MIN_FEEDBACK                     (0.0f)
+#define AL_ECHO_MAX_FEEDBACK                     (1.0f)
+#define AL_ECHO_DEFAULT_FEEDBACK                 (0.5f)
+
+#define AL_ECHO_MIN_SPREAD                       (-1.0f)
+#define AL_ECHO_MAX_SPREAD                       (1.0f)
+#define AL_ECHO_DEFAULT_SPREAD                   (-1.0f)
+
+/* Flanger effect */
+#define AL_FLANGER_WAVEFORM_SINUSOID             (0)
+#define AL_FLANGER_WAVEFORM_TRIANGLE             (1)
+
+#define AL_FLANGER_MIN_WAVEFORM                  (0)
+#define AL_FLANGER_MAX_WAVEFORM                  (1)
+#define AL_FLANGER_DEFAULT_WAVEFORM              (1)
+
+#define AL_FLANGER_MIN_PHASE                     (-180)
+#define AL_FLANGER_MAX_PHASE                     (180)
+#define AL_FLANGER_DEFAULT_PHASE                 (0)
+
+#define AL_FLANGER_MIN_RATE                      (0.0f)
+#define AL_FLANGER_MAX_RATE                      (10.0f)
+#define AL_FLANGER_DEFAULT_RATE                  (0.27f)
+
+#define AL_FLANGER_MIN_DEPTH                     (0.0f)
+#define AL_FLANGER_MAX_DEPTH                     (1.0f)
+#define AL_FLANGER_DEFAULT_DEPTH                 (1.0f)
+
+#define AL_FLANGER_MIN_FEEDBACK                  (-1.0f)
+#define AL_FLANGER_MAX_FEEDBACK                  (1.0f)
+#define AL_FLANGER_DEFAULT_FEEDBACK              (-0.5f)
+
+#define AL_FLANGER_MIN_DELAY                     (0.0f)
+#define AL_FLANGER_MAX_DELAY                     (0.004f)
+#define AL_FLANGER_DEFAULT_DELAY                 (0.002f)
+
+/* Frequency shifter effect */
+#define AL_FREQUENCY_SHIFTER_MIN_FREQUENCY       (0.0f)
+#define AL_FREQUENCY_SHIFTER_MAX_FREQUENCY       (24000.0f)
+#define AL_FREQUENCY_SHIFTER_DEFAULT_FREQUENCY   (0.0f)
+
+#define AL_FREQUENCY_SHIFTER_MIN_LEFT_DIRECTION  (0)
+#define AL_FREQUENCY_SHIFTER_MAX_LEFT_DIRECTION  (2)
+#define AL_FREQUENCY_SHIFTER_DEFAULT_LEFT_DIRECTION (0)
+
+#define AL_FREQUENCY_SHIFTER_DIRECTION_DOWN      (0)
+#define AL_FREQUENCY_SHIFTER_DIRECTION_UP        (1)
+#define AL_FREQUENCY_SHIFTER_DIRECTION_OFF       (2)
+
+#define AL_FREQUENCY_SHIFTER_MIN_RIGHT_DIRECTION (0)
+#define AL_FREQUENCY_SHIFTER_MAX_RIGHT_DIRECTION (2)
+#define AL_FREQUENCY_SHIFTER_DEFAULT_RIGHT_DIRECTION (0)
+
+/* Vocal morpher effect */
+#define AL_VOCAL_MORPHER_MIN_PHONEMEA            (0)
+#define AL_VOCAL_MORPHER_MAX_PHONEMEA            (29)
+#define AL_VOCAL_MORPHER_DEFAULT_PHONEMEA        (0)
+
+#define AL_VOCAL_MORPHER_MIN_PHONEMEA_COARSE_TUNING (-24)
+#define AL_VOCAL_MORPHER_MAX_PHONEMEA_COARSE_TUNING (24)
+#define AL_VOCAL_MORPHER_DEFAULT_PHONEMEA_COARSE_TUNING (0)
+
+#define AL_VOCAL_MORPHER_MIN_PHONEMEB            (0)
+#define AL_VOCAL_MORPHER_MAX_PHONEMEB            (29)
+#define AL_VOCAL_MORPHER_DEFAULT_PHONEMEB        (10)
+
+#define AL_VOCAL_MORPHER_MIN_PHONEMEB_COARSE_TUNING (-24)
+#define AL_VOCAL_MORPHER_MAX_PHONEMEB_COARSE_TUNING (24)
+#define AL_VOCAL_MORPHER_DEFAULT_PHONEMEB_COARSE_TUNING (0)
+
+#define AL_VOCAL_MORPHER_PHONEME_A               (0)
+#define AL_VOCAL_MORPHER_PHONEME_E               (1)
+#define AL_VOCAL_MORPHER_PHONEME_I               (2)
+#define AL_VOCAL_MORPHER_PHONEME_O               (3)
+#define AL_VOCAL_MORPHER_PHONEME_U               (4)
+#define AL_VOCAL_MORPHER_PHONEME_AA              (5)
+#define AL_VOCAL_MORPHER_PHONEME_AE              (6)
+#define AL_VOCAL_MORPHER_PHONEME_AH              (7)
+#define AL_VOCAL_MORPHER_PHONEME_AO              (8)
+#define AL_VOCAL_MORPHER_PHONEME_EH              (9)
+#define AL_VOCAL_MORPHER_PHONEME_ER              (10)
+#define AL_VOCAL_MORPHER_PHONEME_IH              (11)
+#define AL_VOCAL_MORPHER_PHONEME_IY              (12)
+#define AL_VOCAL_MORPHER_PHONEME_UH              (13)
+#define AL_VOCAL_MORPHER_PHONEME_UW              (14)
+#define AL_VOCAL_MORPHER_PHONEME_B               (15)
+#define AL_VOCAL_MORPHER_PHONEME_D               (16)
+#define AL_VOCAL_MORPHER_PHONEME_F               (17)
+#define AL_VOCAL_MORPHER_PHONEME_G               (18)
+#define AL_VOCAL_MORPHER_PHONEME_J               (19)
+#define AL_VOCAL_MORPHER_PHONEME_K               (20)
+#define AL_VOCAL_MORPHER_PHONEME_L               (21)
+#define AL_VOCAL_MORPHER_PHONEME_M               (22)
+#define AL_VOCAL_MORPHER_PHONEME_N               (23)
+#define AL_VOCAL_MORPHER_PHONEME_P               (24)
+#define AL_VOCAL_MORPHER_PHONEME_R               (25)
+#define AL_VOCAL_MORPHER_PHONEME_S               (26)
+#define AL_VOCAL_MORPHER_PHONEME_T               (27)
+#define AL_VOCAL_MORPHER_PHONEME_V               (28)
+#define AL_VOCAL_MORPHER_PHONEME_Z               (29)
+
+#define AL_VOCAL_MORPHER_WAVEFORM_SINUSOID       (0)
+#define AL_VOCAL_MORPHER_WAVEFORM_TRIANGLE       (1)
+#define AL_VOCAL_MORPHER_WAVEFORM_SAWTOOTH       (2)
+
+#define AL_VOCAL_MORPHER_MIN_WAVEFORM            (0)
+#define AL_VOCAL_MORPHER_MAX_WAVEFORM            (2)
+#define AL_VOCAL_MORPHER_DEFAULT_WAVEFORM        (0)
+
+#define AL_VOCAL_MORPHER_MIN_RATE                (0.0f)
+#define AL_VOCAL_MORPHER_MAX_RATE                (10.0f)
+#define AL_VOCAL_MORPHER_DEFAULT_RATE            (1.41f)
+
+/* Pitch shifter effect */
+#define AL_PITCH_SHIFTER_MIN_COARSE_TUNE         (-12)
+#define AL_PITCH_SHIFTER_MAX_COARSE_TUNE         (12)
+#define AL_PITCH_SHIFTER_DEFAULT_COARSE_TUNE     (12)
+
+#define AL_PITCH_SHIFTER_MIN_FINE_TUNE           (-50)
+#define AL_PITCH_SHIFTER_MAX_FINE_TUNE           (50)
+#define AL_PITCH_SHIFTER_DEFAULT_FINE_TUNE       (0)
+
+/* Ring modulator effect */
+#define AL_RING_MODULATOR_MIN_FREQUENCY          (0.0f)
+#define AL_RING_MODULATOR_MAX_FREQUENCY          (8000.0f)
+#define AL_RING_MODULATOR_DEFAULT_FREQUENCY      (440.0f)
+
+#define AL_RING_MODULATOR_MIN_HIGHPASS_CUTOFF    (0.0f)
+#define AL_RING_MODULATOR_MAX_HIGHPASS_CUTOFF    (24000.0f)
+#define AL_RING_MODULATOR_DEFAULT_HIGHPASS_CUTOFF (800.0f)
+
+#define AL_RING_MODULATOR_SINUSOID               (0)
+#define AL_RING_MODULATOR_SAWTOOTH               (1)
+#define AL_RING_MODULATOR_SQUARE                 (2)
+
+#define AL_RING_MODULATOR_MIN_WAVEFORM           (0)
+#define AL_RING_MODULATOR_MAX_WAVEFORM           (2)
+#define AL_RING_MODULATOR_DEFAULT_WAVEFORM       (0)
+
+/* Autowah effect */
+#define AL_AUTOWAH_MIN_ATTACK_TIME               (0.0001f)
+#define AL_AUTOWAH_MAX_ATTACK_TIME               (1.0f)
+#define AL_AUTOWAH_DEFAULT_ATTACK_TIME           (0.06f)
+
+#define AL_AUTOWAH_MIN_RELEASE_TIME              (0.0001f)
+#define AL_AUTOWAH_MAX_RELEASE_TIME              (1.0f)
+#define AL_AUTOWAH_DEFAULT_RELEASE_TIME          (0.06f)
+
+#define AL_AUTOWAH_MIN_RESONANCE                 (2.0f)
+#define AL_AUTOWAH_MAX_RESONANCE                 (1000.0f)
+#define AL_AUTOWAH_DEFAULT_RESONANCE             (1000.0f)
+
+#define AL_AUTOWAH_MIN_PEAK_GAIN                 (0.00003f)
+#define AL_AUTOWAH_MAX_PEAK_GAIN                 (31621.0f)
+#define AL_AUTOWAH_DEFAULT_PEAK_GAIN             (11.22f)
+
+/* Compressor effect */
+#define AL_COMPRESSOR_MIN_ONOFF                  (0)
+#define AL_COMPRESSOR_MAX_ONOFF                  (1)
+#define AL_COMPRESSOR_DEFAULT_ONOFF              (1)
+
+/* Equalizer effect */
+#define AL_EQUALIZER_MIN_LOW_GAIN                (0.126f)
+#define AL_EQUALIZER_MAX_LOW_GAIN                (7.943f)
+#define AL_EQUALIZER_DEFAULT_LOW_GAIN            (1.0f)
+
+#define AL_EQUALIZER_MIN_LOW_CUTOFF              (50.0f)
+#define AL_EQUALIZER_MAX_LOW_CUTOFF              (800.0f)
+#define AL_EQUALIZER_DEFAULT_LOW_CUTOFF          (200.0f)
+
+#define AL_EQUALIZER_MIN_MID1_GAIN               (0.126f)
+#define AL_EQUALIZER_MAX_MID1_GAIN               (7.943f)
+#define AL_EQUALIZER_DEFAULT_MID1_GAIN           (1.0f)
+
+#define AL_EQUALIZER_MIN_MID1_CENTER             (200.0f)
+#define AL_EQUALIZER_MAX_MID1_CENTER             (3000.0f)
+#define AL_EQUALIZER_DEFAULT_MID1_CENTER         (500.0f)
+
+#define AL_EQUALIZER_MIN_MID1_WIDTH              (0.01f)
+#define AL_EQUALIZER_MAX_MID1_WIDTH              (1.0f)
+#define AL_EQUALIZER_DEFAULT_MID1_WIDTH          (1.0f)
+
+#define AL_EQUALIZER_MIN_MID2_GAIN               (0.126f)
+#define AL_EQUALIZER_MAX_MID2_GAIN               (7.943f)
+#define AL_EQUALIZER_DEFAULT_MID2_GAIN           (1.0f)
+
+#define AL_EQUALIZER_MIN_MID2_CENTER             (1000.0f)
+#define AL_EQUALIZER_MAX_MID2_CENTER             (8000.0f)
+#define AL_EQUALIZER_DEFAULT_MID2_CENTER         (3000.0f)
+
+#define AL_EQUALIZER_MIN_MID2_WIDTH              (0.01f)
+#define AL_EQUALIZER_MAX_MID2_WIDTH              (1.0f)
+#define AL_EQUALIZER_DEFAULT_MID2_WIDTH          (1.0f)
+
+#define AL_EQUALIZER_MIN_HIGH_GAIN               (0.126f)
+#define AL_EQUALIZER_MAX_HIGH_GAIN               (7.943f)
+#define AL_EQUALIZER_DEFAULT_HIGH_GAIN           (1.0f)
+
+#define AL_EQUALIZER_MIN_HIGH_CUTOFF             (4000.0f)
+#define AL_EQUALIZER_MAX_HIGH_CUTOFF             (16000.0f)
+#define AL_EQUALIZER_DEFAULT_HIGH_CUTOFF         (6000.0f)
+
+
+/* Source parameter value ranges and defaults. */
+#define AL_MIN_AIR_ABSORPTION_FACTOR             (0.0f)
+#define AL_MAX_AIR_ABSORPTION_FACTOR             (10.0f)
+#define AL_DEFAULT_AIR_ABSORPTION_FACTOR         (0.0f)
+
+#define AL_MIN_ROOM_ROLLOFF_FACTOR               (0.0f)
+#define AL_MAX_ROOM_ROLLOFF_FACTOR               (10.0f)
+#define AL_DEFAULT_ROOM_ROLLOFF_FACTOR           (0.0f)
+
+#define AL_MIN_CONE_OUTER_GAINHF                 (0.0f)
+#define AL_MAX_CONE_OUTER_GAINHF                 (1.0f)
+#define AL_DEFAULT_CONE_OUTER_GAINHF             (1.0f)
+
+#define AL_MIN_DIRECT_FILTER_GAINHF_AUTO         AL_FALSE
+#define AL_MAX_DIRECT_FILTER_GAINHF_AUTO         AL_TRUE
+#define AL_DEFAULT_DIRECT_FILTER_GAINHF_AUTO     AL_TRUE
+
+#define AL_MIN_AUXILIARY_SEND_FILTER_GAIN_AUTO   AL_FALSE
+#define AL_MAX_AUXILIARY_SEND_FILTER_GAIN_AUTO   AL_TRUE
+#define AL_DEFAULT_AUXILIARY_SEND_FILTER_GAIN_AUTO AL_TRUE
+
+#define AL_MIN_AUXILIARY_SEND_FILTER_GAINHF_AUTO AL_FALSE
+#define AL_MAX_AUXILIARY_SEND_FILTER_GAINHF_AUTO AL_TRUE
+#define AL_DEFAULT_AUXILIARY_SEND_FILTER_GAINHF_AUTO AL_TRUE
+
+
+/* Listener parameter value ranges and defaults. */
+#define AL_MIN_METERS_PER_UNIT                   FLT_MIN
+#define AL_MAX_METERS_PER_UNIT                   FLT_MAX
+#define AL_DEFAULT_METERS_PER_UNIT               (1.0f)
+
+
+#ifdef __cplusplus
+}  /* extern "C" */
+#endif
+
+#endif /* AL_EFX_H */
diff --git a/src/sound/thirdparty/mpg123.h b/src/sound/thirdparty/mpg123.h
new file mode 100644
index 0000000000..d7b7ef8318
--- /dev/null
+++ b/src/sound/thirdparty/mpg123.h
@@ -0,0 +1,1202 @@
+/*
+	libmpg123: MPEG Audio Decoder library (version 1.22.0)
+
+	copyright 1995-2010 by the mpg123 project - free software under the terms of the LGPL 2.1
+	see COPYING and AUTHORS files in distribution or http://mpg123.org
+*/
+
+#ifndef MPG123_LIB_H
+#define MPG123_LIB_H
+
+/** \file mpg123.h The header file for the libmpg123 MPEG Audio decoder */
+
+/* A macro to check at compile time which set of API functions to expect.
+   This should be incremented at least each time a new symbol is added to the header. */
+#define MPG123_API_VERSION 41
+
+/* These aren't actually in use... seems to work without using libtool. */
+#ifdef BUILD_MPG123_DLL
+/* The dll exports. */
+#define MPG123_EXPORT __declspec(dllexport)
+#else
+#ifdef LINK_MPG123_DLL
+/* The exe imports. */
+#define MPG123_EXPORT __declspec(dllimport)
+#else
+/* Nothing on normal/UNIX builds */
+#define MPG123_EXPORT
+#endif
+#endif
+
+#ifndef MPG123_NO_CONFIGURE /* Enable use of this file without configure. */
+#include <stdlib.h>
+#include <sys/types.h>
+
+/* Simplified large file handling.
+	I used to have a check here that prevents building for a library with conflicting large file setup
+	(application that uses 32 bit offsets with library that uses 64 bits).
+	While that was perfectly fine in an environment where there is one incarnation of the library,
+	it hurt GNU/Linux and Solaris systems with multilib where the distribution fails to provide the
+	correct header matching the 32 bit library (where large files need explicit support) or
+	the 64 bit library (where there is no distinction).
+
+	New approach: When the app defines _FILE_OFFSET_BITS, it wants non-default large file support,
+	and thus functions with added suffix (mpg123_open_64).
+	Any mismatch will be caught at link time because of the _FILE_OFFSET_BITS setting used when
+	building libmpg123. Plus, there's dual mode large file support in mpg123 since 1.12 now.
+	Link failure is not the expected outcome of any half-sane usage anymore.
+
+	More complication: What about client code defining _LARGEFILE64_SOURCE? It might want direct access to the _64 functions, along with the ones without suffix. Well, that's possible now via defining MPG123_NO_LARGENAME and MPG123_LARGESUFFIX, respectively, for disabling or enforcing the suffix names.
+*/
+
+/*
+	Now, the renaming of large file aware functions.
+	By default, it appends underscore _FILE_OFFSET_BITS (so, mpg123_seek_64 for mpg123_seek), if _FILE_OFFSET_BITS is defined. You can force a different suffix via MPG123_LARGESUFFIX (that must include the underscore), or you can just disable the whole mess by defining MPG123_NO_LARGENAME.
+*/
+#if (!defined MPG123_NO_LARGENAME) && ((defined _FILE_OFFSET_BITS) || (defined MPG123_LARGESUFFIX))
+
+/* Need some trickery to concatenate the value(s) of the given macro(s). */
+#define MPG123_MACROCAT_REALLY(a, b) a ## b
+#define MPG123_MACROCAT(a, b) MPG123_MACROCAT_REALLY(a, b)
+#ifndef MPG123_LARGESUFFIX
+#define MPG123_LARGESUFFIX MPG123_MACROCAT(_, _FILE_OFFSET_BITS)
+#endif
+#define MPG123_LARGENAME(func) MPG123_MACROCAT(func, MPG123_LARGESUFFIX)
+
+#define mpg123_open         MPG123_LARGENAME(mpg123_open)
+#define mpg123_open_fd      MPG123_LARGENAME(mpg123_open_fd)
+#define mpg123_open_handle  MPG123_LARGENAME(mpg123_open_handle)
+#define mpg123_framebyframe_decode MPG123_LARGENAME(mpg123_framebyframe_decode)
+#define mpg123_decode_frame MPG123_LARGENAME(mpg123_decode_frame)
+#define mpg123_tell         MPG123_LARGENAME(mpg123_tell)
+#define mpg123_tellframe    MPG123_LARGENAME(mpg123_tellframe)
+#define mpg123_tell_stream  MPG123_LARGENAME(mpg123_tell_stream)
+#define mpg123_seek         MPG123_LARGENAME(mpg123_seek)
+#define mpg123_feedseek     MPG123_LARGENAME(mpg123_feedseek)
+#define mpg123_seek_frame   MPG123_LARGENAME(mpg123_seek_frame)
+#define mpg123_timeframe    MPG123_LARGENAME(mpg123_timeframe)
+#define mpg123_index        MPG123_LARGENAME(mpg123_index)
+#define mpg123_set_index    MPG123_LARGENAME(mpg123_set_index)
+#define mpg123_position     MPG123_LARGENAME(mpg123_position)
+#define mpg123_length       MPG123_LARGENAME(mpg123_length)
+#define mpg123_set_filesize MPG123_LARGENAME(mpg123_set_filesize)
+#define mpg123_replace_reader MPG123_LARGENAME(mpg123_replace_reader)
+#define mpg123_replace_reader_handle MPG123_LARGENAME(mpg123_replace_reader_handle)
+#define mpg123_framepos MPG123_LARGENAME(mpg123_framepos)
+
+#endif /* largefile hackery */
+
+#endif /* MPG123_NO_CONFIGURE */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** \defgroup mpg123_init mpg123 library and handle setup
+ *
+ * Functions to initialise and shutdown the mpg123 library and handles.
+ * The parameters of handles have workable defaults, you only have to tune them when you want to tune something;-)
+ * Tip: Use a RVA setting...
+ *
+ * @{
+ */
+
+/** Opaque structure for the libmpg123 decoder handle. */
+struct mpg123_handle_struct;
+
+/** Opaque structure for the libmpg123 decoder handle.
+ *  Most functions take a pointer to a mpg123_handle as first argument and operate on its data in an object-oriented manner.
+ */
+typedef struct mpg123_handle_struct mpg123_handle;
+
+/** Function to initialise the mpg123 library. 
+ *	This function is not thread-safe. Call it exactly once per process, before any other (possibly threaded) work with the library.
+ *
+ *	\return MPG123_OK if successful, otherwise an error number.
+ */
+MPG123_EXPORT int  mpg123_init(void);
+
+/** Function to close down the mpg123 library. 
+ *	This function is not thread-safe. Call it exactly once per process, before any other (possibly threaded) work with the library. */
+MPG123_EXPORT void mpg123_exit(void);
+
+/** Create a handle with optional choice of decoder (named by a string, see mpg123_decoders() or mpg123_supported_decoders()).
+ *  and optional retrieval of an error code to feed to mpg123_plain_strerror().
+ *  Optional means: Any of or both the parameters may be NULL.
+ *
+ *  \return Non-NULL pointer when successful.
+ */
+MPG123_EXPORT mpg123_handle *mpg123_new(const char* decoder, int *error);
+
+/** Delete handle, mh is either a valid mpg123 handle or NULL. */
+MPG123_EXPORT void mpg123_delete(mpg123_handle *mh);
+
+/** Enumeration of the parameters types that it is possible to set/get. */
+enum mpg123_parms
+{
+	MPG123_VERBOSE = 0,        /**< set verbosity value for enabling messages to stderr, >= 0 makes sense (integer) */
+	MPG123_FLAGS,          /**< set all flags, p.ex val = MPG123_GAPLESS|MPG123_MONO_MIX (integer) */
+	MPG123_ADD_FLAGS,      /**< add some flags (integer) */
+	MPG123_FORCE_RATE,     /**< when value > 0, force output rate to that value (integer) */
+	MPG123_DOWN_SAMPLE,    /**< 0=native rate, 1=half rate, 2=quarter rate (integer) */
+	MPG123_RVA,            /**< one of the RVA choices above (integer) */
+	MPG123_DOWNSPEED,      /**< play a frame N times (integer) */
+	MPG123_UPSPEED,        /**< play every Nth frame (integer) */
+	MPG123_START_FRAME,    /**< start with this frame (skip frames before that, integer) */ 
+	MPG123_DECODE_FRAMES,  /**< decode only this number of frames (integer) */
+	MPG123_ICY_INTERVAL,   /**< stream contains ICY metadata with this interval (integer) */
+	MPG123_OUTSCALE,       /**< the scale for output samples (amplitude - integer or float according to mpg123 output format, normally integer) */
+	MPG123_TIMEOUT,        /**< timeout for reading from a stream (not supported on win32, integer) */
+	MPG123_REMOVE_FLAGS,   /**< remove some flags (inverse of MPG123_ADD_FLAGS, integer) */
+	MPG123_RESYNC_LIMIT,   /**< Try resync on frame parsing for that many bytes or until end of stream (<0 ... integer). This can enlarge the limit for skipping junk on beginning, too (but not reduce it).  */
+	MPG123_INDEX_SIZE      /**< Set the frame index size (if supported). Values <0 mean that the index is allowed to grow dynamically in these steps (in positive direction, of course) -- Use this when you really want a full index with every individual frame. */
+	,MPG123_PREFRAMES /**< Decode/ignore that many frames in advance for layer 3. This is needed to fill bit reservoir after seeking, for example (but also at least one frame in advance is needed to have all "normal" data for layer 3). Give a positive integer value, please.*/
+	,MPG123_FEEDPOOL  /**< For feeder mode, keep that many buffers in a pool to avoid frequent malloc/free. The pool is allocated on mpg123_open_feed(). If you change this parameter afterwards, you can trigger growth and shrinkage during decoding. The default value could change any time. If you care about this, then set it. (integer) */
+	,MPG123_FEEDBUFFER /**< Minimal size of one internal feeder buffer, again, the default value is subject to change. (integer) */
+};
+
+/** Flag bits for MPG123_FLAGS, use the usual binary or to combine. */
+enum mpg123_param_flags
+{
+	 MPG123_FORCE_MONO   = 0x7  /**<     0111 Force some mono mode: This is a test bitmask for seeing if any mono forcing is active. */
+	,MPG123_MONO_LEFT    = 0x1  /**<     0001 Force playback of left channel only.  */
+	,MPG123_MONO_RIGHT   = 0x2  /**<     0010 Force playback of right channel only. */
+	,MPG123_MONO_MIX     = 0x4  /**<     0100 Force playback of mixed mono.         */
+	,MPG123_FORCE_STEREO = 0x8  /**<     1000 Force stereo output.                  */
+	,MPG123_FORCE_8BIT   = 0x10 /**< 00010000 Force 8bit formats.                   */
+	,MPG123_QUIET        = 0x20 /**< 00100000 Suppress any printouts (overrules verbose).                    */
+	,MPG123_GAPLESS      = 0x40 /**< 01000000 Enable gapless decoding (default on if libmpg123 has support). */
+	,MPG123_NO_RESYNC    = 0x80 /**< 10000000 Disable resync stream after error.                             */
+	,MPG123_SEEKBUFFER   = 0x100 /**< 000100000000 Enable small buffer on non-seekable streams to allow some peek-ahead (for better MPEG sync). */
+	,MPG123_FUZZY        = 0x200 /**< 001000000000 Enable fuzzy seeks (guessing byte offsets or using approximate seek points from Xing TOC) */
+	,MPG123_FORCE_FLOAT  = 0x400 /**< 010000000000 Force floating point output (32 or 64 bits depends on mpg123 internal precision). */
+	,MPG123_PLAIN_ID3TEXT = 0x800 /**< 100000000000 Do not translate ID3 text data to UTF-8. ID3 strings will contain the raw text data, with the first byte containing the ID3 encoding code. */
+	,MPG123_IGNORE_STREAMLENGTH = 0x1000 /**< 1000000000000 Ignore any stream length information contained in the stream, which can be contained in a 'TLEN' frame of an ID3v2 tag or a Xing tag */
+	,MPG123_SKIP_ID3V2 = 0x2000 /**< 10 0000 0000 0000 Do not parse ID3v2 tags, just skip them. */
+	,MPG123_IGNORE_INFOFRAME = 0x4000 /**< 100 0000 0000 0000 Do not parse the LAME/Xing info frame, treat it as normal MPEG data. */
+	,MPG123_AUTO_RESAMPLE = 0x8000 /**< 1000 0000 0000 0000 Allow automatic internal resampling of any kind (default on if supported). Especially when going lowlevel with replacing output buffer, you might want to unset this flag. Setting MPG123_DOWNSAMPLE or MPG123_FORCE_RATE will override this. */
+	,MPG123_PICTURE = 0x10000 /**< 17th bit: Enable storage of pictures from tags (ID3v2 APIC). */
+};
+
+/** choices for MPG123_RVA */
+enum mpg123_param_rva
+{
+	 MPG123_RVA_OFF   = 0 /**< RVA disabled (default).   */
+	,MPG123_RVA_MIX   = 1 /**< Use mix/track/radio gain. */
+	,MPG123_RVA_ALBUM = 2 /**< Use album/audiophile gain */
+	,MPG123_RVA_MAX   = MPG123_RVA_ALBUM /**< The maximum RVA code, may increase in future. */
+};
+
+/* TODO: Assess the possibilities and troubles of changing parameters during playback. */
+
+/** Set a specific parameter, for a specific mpg123_handle, using a parameter 
+ *  type key chosen from the mpg123_parms enumeration, to the specified value.
+ * \return MPG123_OK on success
+ */
+MPG123_EXPORT int mpg123_param(mpg123_handle *mh, enum mpg123_parms type, long value, double fvalue);
+
+/** Get a specific parameter, for a specific mpg123_handle. 
+ *  See the mpg123_parms enumeration for a list of available parameters.
+ *  \return MPG123_OK on success
+ */
+MPG123_EXPORT int mpg123_getparam(mpg123_handle *mh, enum mpg123_parms type, long *val, double *fval);
+
+/** Feature set available for query with mpg123_feature. */
+enum mpg123_feature_set
+{
+	 MPG123_FEATURE_ABI_UTF8OPEN = 0     /**< mpg123 expects path names to be given in UTF-8 encoding instead of plain native. */
+	,MPG123_FEATURE_OUTPUT_8BIT          /**< 8bit output   */
+	,MPG123_FEATURE_OUTPUT_16BIT         /**< 16bit output  */
+	,MPG123_FEATURE_OUTPUT_32BIT         /**< 32bit output  */
+	,MPG123_FEATURE_INDEX                /**< support for building a frame index for accurate seeking */
+	,MPG123_FEATURE_PARSE_ID3V2          /**< id3v2 parsing */
+	,MPG123_FEATURE_DECODE_LAYER1        /**< mpeg layer-1 decoder enabled */
+	,MPG123_FEATURE_DECODE_LAYER2        /**< mpeg layer-2 decoder enabled */
+	,MPG123_FEATURE_DECODE_LAYER3        /**< mpeg layer-3 decoder enabled */
+	,MPG123_FEATURE_DECODE_ACCURATE      /**< accurate decoder rounding    */
+	,MPG123_FEATURE_DECODE_DOWNSAMPLE    /**< downsample (sample omit)     */
+	,MPG123_FEATURE_DECODE_NTOM          /**< flexible rate decoding       */
+	,MPG123_FEATURE_PARSE_ICY            /**< ICY support                  */
+	,MPG123_FEATURE_TIMEOUT_READ         /**< Reader with timeout (network). */
+};
+
+/** Query libmpg123 feature, 1 for success, 0 for unimplemented functions. */
+MPG123_EXPORT int mpg123_feature(const enum mpg123_feature_set key);
+
+/* @} */
+
+
+/** \defgroup mpg123_error mpg123 error handling
+ *
+ * Functions to get text version of the error numbers and an enumeration
+ * of the error codes returned by libmpg123.
+ *
+ * Most functions operating on a mpg123_handle simply return MPG123_OK (0)
+ * on success and MPG123_ERR (-1) on failure, setting the internal error
+ * variable of the handle to the specific error code. If there was not a valid
+ * (non-NULL) handle provided to a function operating on one, MPG123_BAD_HANDLE
+ * may be returned if this can not be confused with a valid positive return
+ * value.
+ * Meaning: A function expected to return positive integers on success will
+ * always indicate error or a special condition by returning a negative one.
+ *
+ * Decoding/seek functions may also return message codes MPG123_DONE,
+ * MPG123_NEW_FORMAT and MPG123_NEED_MORE (all negative, see below on how to
+ * react). Note that calls to those can be nested, so generally watch out
+ * for these codes after initial handle setup.
+ * Especially any function that needs information about the current stream
+ * to work will try to at least parse the beginning if that did not happen
+ * yet.
+ *
+ * On a function that is supposed to return MPG123_OK on success and
+ * MPG123_ERR on failure, make sure you check for != MPG123_OK, not
+ * == MPG123_ERR, as the error code could get more specific in future,
+ * or there is just a special message from a decoding routine as indicated
+ * above.
+ *
+ * @{
+ */
+
+/** Enumeration of the message and error codes and returned by libmpg123 functions. */
+enum mpg123_errors
+{
+	MPG123_DONE=-12,	/**< Message: Track ended. Stop decoding. */
+	MPG123_NEW_FORMAT=-11,	/**< Message: Output format will be different on next call. Note that some libmpg123 versions between 1.4.3 and 1.8.0 insist on you calling mpg123_getformat() after getting this message code. Newer verisons behave like advertised: You have the chance to call mpg123_getformat(), but you can also just continue decoding and get your data. */
+	MPG123_NEED_MORE=-10,	/**< Message: For feed reader: "Feed me more!" (call mpg123_feed() or mpg123_decode() with some new input data). */
+	MPG123_ERR=-1,			/**< Generic Error */
+	MPG123_OK=0, 			/**< Success */
+	MPG123_BAD_OUTFORMAT, 	/**< Unable to set up output format! */
+	MPG123_BAD_CHANNEL,		/**< Invalid channel number specified. */
+	MPG123_BAD_RATE,		/**< Invalid sample rate specified.  */
+	MPG123_ERR_16TO8TABLE,	/**< Unable to allocate memory for 16 to 8 converter table! */
+	MPG123_BAD_PARAM,		/**< Bad parameter id! */
+	MPG123_BAD_BUFFER,		/**< Bad buffer given -- invalid pointer or too small size. */
+	MPG123_OUT_OF_MEM,		/**< Out of memory -- some malloc() failed. */
+	MPG123_NOT_INITIALIZED,	/**< You didn't initialize the library! */
+	MPG123_BAD_DECODER,		/**< Invalid decoder choice. */
+	MPG123_BAD_HANDLE,		/**< Invalid mpg123 handle. */
+	MPG123_NO_BUFFERS,		/**< Unable to initialize frame buffers (out of memory?). */
+	MPG123_BAD_RVA,			/**< Invalid RVA mode. */
+	MPG123_NO_GAPLESS,		/**< This build doesn't support gapless decoding. */
+	MPG123_NO_SPACE,		/**< Not enough buffer space. */
+	MPG123_BAD_TYPES,		/**< Incompatible numeric data types. */
+	MPG123_BAD_BAND,		/**< Bad equalizer band. */
+	MPG123_ERR_NULL,		/**< Null pointer given where valid storage address needed. */
+	MPG123_ERR_READER,		/**< Error reading the stream. */
+	MPG123_NO_SEEK_FROM_END,/**< Cannot seek from end (end is not known). */
+	MPG123_BAD_WHENCE,		/**< Invalid 'whence' for seek function.*/
+	MPG123_NO_TIMEOUT,		/**< Build does not support stream timeouts. */
+	MPG123_BAD_FILE,		/**< File access error. */
+	MPG123_NO_SEEK,			/**< Seek not supported by stream. */
+	MPG123_NO_READER,		/**< No stream opened. */
+	MPG123_BAD_PARS,		/**< Bad parameter handle. */
+	MPG123_BAD_INDEX_PAR,	/**< Bad parameters to mpg123_index() and mpg123_set_index() */
+	MPG123_OUT_OF_SYNC,	/**< Lost track in bytestream and did not try to resync. */
+	MPG123_RESYNC_FAIL,	/**< Resync failed to find valid MPEG data. */
+	MPG123_NO_8BIT,	/**< No 8bit encoding possible. */
+	MPG123_BAD_ALIGN,	/**< Stack aligmnent error */
+	MPG123_NULL_BUFFER,	/**< NULL input buffer with non-zero size... */
+	MPG123_NO_RELSEEK,	/**< Relative seek not possible (screwed up file offset) */
+	MPG123_NULL_POINTER, /**< You gave a null pointer somewhere where you shouldn't have. */
+	MPG123_BAD_KEY,	/**< Bad key value given. */
+	MPG123_NO_INDEX,	/**< No frame index in this build. */
+	MPG123_INDEX_FAIL,	/**< Something with frame index went wrong. */
+	MPG123_BAD_DECODER_SETUP,	/**< Something prevents a proper decoder setup */
+	MPG123_MISSING_FEATURE  /**< This feature has not been built into libmpg123. */
+	,MPG123_BAD_VALUE /**< A bad value has been given, somewhere. */
+	,MPG123_LSEEK_FAILED /**< Low-level seek failed. */
+	,MPG123_BAD_CUSTOM_IO /**< Custom I/O not prepared. */
+	,MPG123_LFS_OVERFLOW /**< Offset value overflow during translation of large file API calls -- your client program cannot handle that large file. */
+	,MPG123_INT_OVERFLOW /**< Some integer overflow. */
+};
+
+/** Return a string describing that error errcode means. */
+MPG123_EXPORT const char* mpg123_plain_strerror(int errcode);
+
+/** Give string describing what error has occured in the context of handle mh.
+ *  When a function operating on an mpg123 handle returns MPG123_ERR, you should check for the actual reason via
+ *  char *errmsg = mpg123_strerror(mh)
+ *  This function will catch mh == NULL and return the message for MPG123_BAD_HANDLE. */
+MPG123_EXPORT const char* mpg123_strerror(mpg123_handle *mh);
+
+/** Return the plain errcode intead of a string.
+ *  \return error code recorded in handle or MPG123_BAD_HANDLE
+ */
+MPG123_EXPORT int mpg123_errcode(mpg123_handle *mh);
+
+/*@}*/
+
+
+/** \defgroup mpg123_decoder mpg123 decoder selection
+ *
+ * Functions to list and select the available decoders.
+ * Perhaps the most prominent feature of mpg123: You have several (optimized) decoders to choose from (on x86 and PPC (MacOS) systems, that is).
+ *
+ * @{
+ */
+
+/** Return a NULL-terminated array of generally available decoder names (plain 8bit ASCII). */
+MPG123_EXPORT const char **mpg123_decoders(void);
+
+/** Return a NULL-terminated array of the decoders supported by the CPU (plain 8bit ASCII). */
+MPG123_EXPORT const char **mpg123_supported_decoders(void);
+
+/** Set the chosen decoder to 'decoder_name'
+ * \return MPG123_OK on success
+ */
+MPG123_EXPORT int mpg123_decoder(mpg123_handle *mh, const char* decoder_name);
+
+/** Get the currently active decoder engine name.
+    The active decoder engine can vary depening on output constraints,
+    mostly non-resampling, integer output is accelerated via 3DNow & Co. but for other modes a fallback engine kicks in.
+    Note that this can return a decoder that is ony active in the hidden and not available as decoder choice from the outside.
+    \return The decoder name or NULL on error. */
+MPG123_EXPORT const char* mpg123_current_decoder(mpg123_handle *mh);
+
+/*@}*/
+
+
+/** \defgroup mpg123_output mpg123 output audio format 
+ *
+ * Functions to get and select the format of the decoded audio.
+ *
+ * Before you dive in, please be warned that you might get confused by this. This seems to happen a lot, therefore I am trying to explain in advance.
+ *
+ * The mpg123 library decides what output format to use when encountering the first frame in a stream, or actually any frame that is still valid but differs from the frames before in the prompted output format. At such a deciding point, an internal table of allowed encodings, sampling rates and channel setups is consulted. According to this table, an output format is chosen and the decoding engine set up accordingly (including ptimized routines for different output formats). This might seem unusual but it just follows from the non-existence of "MPEG audio files" with defined overall properties. There are streams, streams are concatenations of (semi) independent frames. We store streams on disk and call them "MPEG audio files", but that does not change their nature as the decoder is concerned (the LAME/Xing header for gapless decoding makes things interesting again).
+ *
+ * To get to the point: What you do with mpg123_format() and friends is to fill the internal table of allowed formats before it is used. That includes removing support for some formats or adding your forced sample rate (see MPG123_FORCE_RATE) that will be used with the crude internal resampler. Also keep in mind that the sample encoding is just a question of choice -- the MPEG frames do only indicate their native sampling rate and channel count. If you want to decode to integer or float samples, 8 or 16 bit ... that is your decision. In a "clean" world, libmpg123 would always decode to 32 bit float and let you handle any sample conversion. But there are optimized routines that work faster by directly decoding to the desired encoding / accuracy. We prefer efficiency over conceptual tidyness.
+ *
+ * People often start out thinking that mpg123_format() should change the actual decoding format on the fly. That is wrong. It only has effect on the next natural change of output format, when libmpg123 will consult its format table again. To make life easier, you might want to call mpg123_format_none() before any thing else and then just allow one desired encoding and a limited set of sample rates / channel choices that you actually intend to deal with. You can force libmpg123 to decode everything to 44100 KHz, stereo, 16 bit integer ... it will duplicate mono channels and even do resampling if needed (unless that feature is disabled in the build, same with some encodings). But I have to stress that the resampling of libmpg123 is very crude and doesn't even contain any kind of "proper" interpolation.
+ *
+ * In any case, watch out for MPG123_NEW_FORMAT as return message from decoding routines and call mpg123_getformat() to get the currently active output format.
+ *
+ * @{
+ */
+
+/** An enum over all sample types possibly known to mpg123.
+ *  The values are designed as bit flags to allow bitmasking for encoding families.
+ *
+ *  Note that (your build of) libmpg123 does not necessarily support all these.
+ *  Usually, you can expect the 8bit encodings and signed 16 bit.
+ *  Also 32bit float will be usual beginning with mpg123-1.7.0 .
+ *  What you should bear in mind is that (SSE, etc) optimized routines may be absent
+ *  for some formats. We do have SSE for 16, 32 bit and float, though.
+ *  24 bit integer is done via postprocessing of 32 bit output -- just cutting
+ *  the last byte, no rounding, even. If you want better, do it yourself.
+ *
+ *  All formats are in native byte order. If you need different endinaness, you
+ *  can simply postprocess the output buffers (libmpg123 wouldn't do anything else).
+ *  mpg123_encsize() can be helpful there.
+ */
+enum mpg123_enc_enum
+{
+	 MPG123_ENC_8      = 0x00f  /**<      0000 0000 1111 Some 8 bit  integer encoding. */
+	,MPG123_ENC_16     = 0x040  /**<      0000 0100 0000 Some 16 bit integer encoding. */
+	,MPG123_ENC_24     = 0x4000 /**< 0100 0000 0000 0000 Some 24 bit integer encoding. */
+	,MPG123_ENC_32     = 0x100  /**<      0001 0000 0000 Some 32 bit integer encoding. */
+	,MPG123_ENC_SIGNED = 0x080  /**<      0000 1000 0000 Some signed integer encoding. */
+	,MPG123_ENC_FLOAT  = 0xe00  /**<      1110 0000 0000 Some float encoding. */
+	,MPG123_ENC_SIGNED_16   = (MPG123_ENC_16|MPG123_ENC_SIGNED|0x10) /**<           1101 0000 signed 16 bit */
+	,MPG123_ENC_UNSIGNED_16 = (MPG123_ENC_16|0x20)                   /**<           0110 0000 unsigned 16 bit */
+	,MPG123_ENC_UNSIGNED_8  = 0x01                                   /**<           0000 0001 unsigned 8 bit */
+	,MPG123_ENC_SIGNED_8    = (MPG123_ENC_SIGNED|0x02)               /**<           1000 0010 signed 8 bit */
+	,MPG123_ENC_ULAW_8      = 0x04                                   /**<           0000 0100 ulaw 8 bit */
+	,MPG123_ENC_ALAW_8      = 0x08                                   /**<           0000 1000 alaw 8 bit */
+	,MPG123_ENC_SIGNED_32   = MPG123_ENC_32|MPG123_ENC_SIGNED|0x1000 /**< 0001 0001 1000 0000 signed 32 bit */
+	,MPG123_ENC_UNSIGNED_32 = MPG123_ENC_32|0x2000                   /**< 0010 0001 0000 0000 unsigned 32 bit */
+	,MPG123_ENC_SIGNED_24   = MPG123_ENC_24|MPG123_ENC_SIGNED|0x1000 /**< 0101 0000 1000 0000 signed 24 bit */
+	,MPG123_ENC_UNSIGNED_24 = MPG123_ENC_24|0x2000                   /**< 0110 0000 0000 0000 unsigned 24 bit */
+	,MPG123_ENC_FLOAT_32    = 0x200                                  /**<      0010 0000 0000 32bit float */
+	,MPG123_ENC_FLOAT_64    = 0x400                                  /**<      0100 0000 0000 64bit float */
+	,MPG123_ENC_ANY = ( MPG123_ENC_SIGNED_16  | MPG123_ENC_UNSIGNED_16 | MPG123_ENC_UNSIGNED_8
+	                  | MPG123_ENC_SIGNED_8   | MPG123_ENC_ULAW_8      | MPG123_ENC_ALAW_8
+	                  | MPG123_ENC_SIGNED_32  | MPG123_ENC_UNSIGNED_32
+	                  | MPG123_ENC_SIGNED_24  | MPG123_ENC_UNSIGNED_24
+	                  | MPG123_ENC_FLOAT_32   | MPG123_ENC_FLOAT_64 ) /**< Any encoding on the list. */
+};
+
+/** They can be combined into one number (3) to indicate mono and stereo... */
+enum mpg123_channelcount
+{
+	 MPG123_MONO   = 1
+	,MPG123_STEREO = 2
+};
+
+/** An array of supported standard sample rates
+ *  These are possible native sample rates of MPEG audio files.
+ *  You can still force mpg123 to resample to a different one, but by default you will only get audio in one of these samplings.
+ *  \param list Store a pointer to the sample rates array there.
+ *  \param number Store the number of sample rates there. */
+MPG123_EXPORT void mpg123_rates(const long **list, size_t *number);
+
+/** An array of supported audio encodings.
+ *  An audio encoding is one of the fully qualified members of mpg123_enc_enum (MPG123_ENC_SIGNED_16, not MPG123_SIGNED).
+ *  \param list Store a pointer to the encodings array there.
+ *  \param number Store the number of encodings there. */
+MPG123_EXPORT void mpg123_encodings(const int **list, size_t *number);
+
+/** Return the size (in bytes) of one mono sample of the named encoding.
+ * \param encoding The encoding value to analyze.
+ * \return positive size of encoding in bytes, 0 on invalid encoding. */
+MPG123_EXPORT int mpg123_encsize(int encoding);
+
+/** Configure a mpg123 handle to accept no output format at all, 
+ *  use before specifying supported formats with mpg123_format
+ *  \return MPG123_OK on success
+ */
+MPG123_EXPORT int mpg123_format_none(mpg123_handle *mh);
+
+/** Configure mpg123 handle to accept all formats 
+ *  (also any custom rate you may set) -- this is default.
+ *  \return MPG123_OK on success
+ */
+MPG123_EXPORT int mpg123_format_all(mpg123_handle *mh);
+
+/** Set the audio format support of a mpg123_handle in detail:
+ *  \param mh audio decoder handle
+ *  \param rate The sample rate value (in Hertz).
+ *  \param channels A combination of MPG123_STEREO and MPG123_MONO.
+ *  \param encodings A combination of accepted encodings for rate and channels, p.ex MPG123_ENC_SIGNED16 | MPG123_ENC_ULAW_8 (or 0 for no support). Please note that some encodings may not be supported in the library build and thus will be ignored here.
+ *  \return MPG123_OK on success, MPG123_ERR if there was an error. */
+MPG123_EXPORT int mpg123_format(mpg123_handle *mh, long rate, int channels, int encodings);
+
+/** Check to see if a specific format at a specific rate is supported 
+ *  by mpg123_handle.
+ *  \return 0 for no support (that includes invalid parameters), MPG123_STEREO, 
+ *          MPG123_MONO or MPG123_STEREO|MPG123_MONO. */
+MPG123_EXPORT int mpg123_format_support(mpg123_handle *mh, long rate, int encoding);
+
+/** Get the current output format written to the addresses given.
+ *  \return MPG123_OK on success
+ */
+MPG123_EXPORT int mpg123_getformat(mpg123_handle *mh, long *rate, int *channels, int *encoding);
+
+/*@}*/
+
+
+/** \defgroup mpg123_input mpg123 file input and decoding
+ *
+ * Functions for input bitstream and decoding operations.
+ * Decoding/seek functions may also return message codes MPG123_DONE, MPG123_NEW_FORMAT and MPG123_NEED_MORE (please read up on these on how to react!).
+ * @{
+ */
+
+/* reading samples / triggering decoding, possible return values: */
+/** Enumeration of the error codes returned by libmpg123 functions. */
+
+/** Open and prepare to decode the specified file by filesystem path.
+ *  This does not open HTTP urls; libmpg123 contains no networking code.
+ *  If you want to decode internet streams, use mpg123_open_fd() or mpg123_open_feed().
+ *  \param path filesystem path
+ *  \return MPG123_OK on success
+ */
+MPG123_EXPORT int mpg123_open(mpg123_handle *mh, const char *path);
+
+/** Use an already opened file descriptor as the bitstream input
+ *  mpg123_close() will _not_ close the file descriptor.
+ */
+MPG123_EXPORT int mpg123_open_fd(mpg123_handle *mh, int fd);
+
+/** Use an opaque handle as bitstream input. This works only with the
+ *  replaced I/O from mpg123_replace_reader_handle()!
+ *  mpg123_close() will call the cleanup callback for your handle (if you gave one).
+ *  \return MPG123_OK on success
+ */
+MPG123_EXPORT int mpg123_open_handle(mpg123_handle *mh, void *iohandle);
+
+/** Open a new bitstream and prepare for direct feeding
+ *  This works together with mpg123_decode(); you are responsible for reading and feeding the input bitstream.
+ *  \return MPG123_OK on success
+ */
+MPG123_EXPORT int mpg123_open_feed(mpg123_handle *mh);
+
+/** Closes the source, if libmpg123 opened it.
+ *  \return MPG123_OK on success
+ */
+MPG123_EXPORT int mpg123_close(mpg123_handle *mh);
+
+/** Read from stream and decode up to outmemsize bytes.
+ *  \param outmemory address of output buffer to write to
+ *  \param outmemsize maximum number of bytes to write
+ *  \param done address to store the number of actually decoded bytes to
+ *  \return MPG123_OK or error/message code
+ */
+MPG123_EXPORT int mpg123_read(mpg123_handle *mh, unsigned char *outmemory, size_t outmemsize, size_t *done);
+
+/** Feed data for a stream that has been opened with mpg123_open_feed().
+ *  It's give and take: You provide the bytestream, mpg123 gives you the decoded samples.
+ *  \param in input buffer
+ *  \param size number of input bytes
+ *  \return MPG123_OK or error/message code.
+ */
+MPG123_EXPORT int mpg123_feed(mpg123_handle *mh, const unsigned char *in, size_t size);
+
+/** Decode MPEG Audio from inmemory to outmemory. 
+ *  This is very close to a drop-in replacement for old mpglib.
+ *  When you give zero-sized output buffer the input will be parsed until 
+ *  decoded data is available. This enables you to get MPG123_NEW_FORMAT (and query it) 
+ *  without taking decoded data.
+ *  Think of this function being the union of mpg123_read() and mpg123_feed() (which it actually is, sort of;-).
+ *  You can actually always decide if you want those specialized functions in separate steps or one call this one here.
+ *  \param inmemory input buffer
+ *  \param inmemsize number of input bytes
+ *  \param outmemory output buffer
+ *  \param outmemsize maximum number of output bytes
+ *  \param done address to store the number of actually decoded bytes to
+ *  \return error/message code (watch out especially for MPG123_NEED_MORE)
+ */
+MPG123_EXPORT int mpg123_decode(mpg123_handle *mh, const unsigned char *inmemory, size_t inmemsize, unsigned char *outmemory, size_t outmemsize, size_t *done);
+
+/** Decode next MPEG frame to internal buffer
+ *  or read a frame and return after setting a new format.
+ *  \param num current frame offset gets stored there
+ *  \param audio This pointer is set to the internal buffer to read the decoded audio from.
+ *  \param bytes number of output bytes ready in the buffer
+ *  \return MPG123_OK or error/message code
+ */
+MPG123_EXPORT int mpg123_decode_frame(mpg123_handle *mh, off_t *num, unsigned char **audio, size_t *bytes);
+
+/** Decode current MPEG frame to internal buffer.
+ * Warning: This is experimental API that might change in future releases!
+ * Please watch mpg123 development closely when using it.
+ *  \param num last frame offset gets stored there
+ *  \param audio this pointer is set to the internal buffer to read the decoded audio from.
+ *  \param bytes number of output bytes ready in the buffer
+ *  \return MPG123_OK or error/message code
+ */
+MPG123_EXPORT int mpg123_framebyframe_decode(mpg123_handle *mh, off_t *num, unsigned char **audio, size_t *bytes);
+
+/** Find, read and parse the next mp3 frame
+ * Warning: This is experimental API that might change in future releases!
+ * Please watch mpg123 development closely when using it.
+ *  \return MPG123_OK or error/message code
+ */
+MPG123_EXPORT int mpg123_framebyframe_next(mpg123_handle *mh);
+
+/** Get access to the raw input data for the last parsed frame.
+ * This gives you a direct look (and write access) to the frame body data.
+ * Together with the raw header, you can reconstruct the whole raw MPEG stream without junk and meta data, or play games by actually modifying the frame body data before decoding this frame (mpg123_framebyframe_decode()).
+ * A more sane use would be to use this for CRC checking (see mpg123_info() and MPG123_CRC), the first two bytes of the body make up the CRC16 checksum, if present.
+ * You can provide NULL for a parameter pointer when you are not interested in the value.
+ *
+ * \param header the 4-byte MPEG header
+ * \param bodydata pointer to the frame body stored in the handle (without the header)
+ * \param bodybytes size of frame body in bytes (without the header)
+ * \return MPG123_OK if there was a yet un-decoded frame to get the
+ *    data from, MPG123_BAD_HANDLE or MPG123_ERR otherwise (without further
+ *    explanation, the error state of the mpg123_handle is not modified by
+ *    this function).
+ */
+MPG123_EXPORT int mpg123_framedata(mpg123_handle *mh, unsigned long *header, unsigned char **bodydata, size_t *bodybytes);
+
+/** Get the input position (byte offset in stream) of the last parsed frame.
+ * This can be used for external seek index building, for example.
+ * It just returns the internally stored offset, regardless of validity -- you ensure that a valid frame has been parsed before! */
+MPG123_EXPORT off_t mpg123_framepos(mpg123_handle *mh);
+
+/*@}*/
+
+
+/** \defgroup mpg123_seek mpg123 position and seeking
+ *
+ * Functions querying and manipulating position in the decoded audio bitstream.
+ * The position is measured in decoded audio samples, or MPEG frame offset for the specific functions.
+ * If gapless code is in effect, the positions are adjusted to compensate the skipped padding/delay - meaning, you should not care about that at all and just use the position defined for the samples you get out of the decoder;-)
+ * The general usage is modelled after stdlib's ftell() and fseek().
+ * Especially, the whence parameter for the seek functions has the same meaning as the one for fseek() and needs the same constants from stdlib.h: 
+ * - SEEK_SET: set position to (or near to) specified offset
+ * - SEEK_CUR: change position by offset from now
+ * - SEEK_END: set position to offset from end
+ *
+ * Note that sample-accurate seek only works when gapless support has been enabled at compile time; seek is frame-accurate otherwise.
+ * Also, really sample-accurate seeking (meaning that you get the identical sample value after seeking compared to plain decoding up to the position) is only guaranteed when you do not mess with the position code by using MPG123_UPSPEED, MPG123_DOWNSPEED or MPG123_START_FRAME. The first two mainly should cause trouble with NtoM resampling, but in any case with these options in effect, you have to keep in mind that the sample offset is not the same as counting the samples you get from decoding since mpg123 counts the skipped samples, too (or the samples played twice only once)!
+ * Short: When you care about the sample position, don't mess with those parameters;-)
+ * Also, seeking is not guaranteed to work for all streams (underlying stream may not support it).
+ * And yet another caveat: If the stream is concatenated out of differing pieces (Frankenstein stream), seeking may suffer, too.
+ *
+ * @{
+ */
+
+/** Returns the current position in samples.
+ *  On the next successful read, you'd get that sample.
+ *  \return sample offset or MPG123_ERR (null handle)
+ */
+MPG123_EXPORT off_t mpg123_tell(mpg123_handle *mh);
+
+/** Returns the frame number that the next read will give you data from.
+ *  \return frame offset or MPG123_ERR (null handle)
+ */
+MPG123_EXPORT off_t mpg123_tellframe(mpg123_handle *mh);
+
+/** Returns the current byte offset in the input stream.
+ *  \return byte offset or MPG123_ERR (null handle)
+ */
+MPG123_EXPORT off_t mpg123_tell_stream(mpg123_handle *mh);
+
+/** Seek to a desired sample offset. 
+ *  Set whence to SEEK_SET, SEEK_CUR or SEEK_END.
+ *  \return The resulting offset >= 0 or error/message code */
+MPG123_EXPORT off_t mpg123_seek(mpg123_handle *mh, off_t sampleoff, int whence);
+
+/** Seek to a desired sample offset in data feeding mode. 
+ *  This just prepares things to be right only if you ensure that the next chunk of input data will be from input_offset byte position.
+ *  \param input_offset The position it expects to be at the 
+ *                      next time data is fed to mpg123_decode().
+ *  \return The resulting offset >= 0 or error/message code */
+MPG123_EXPORT off_t mpg123_feedseek(mpg123_handle *mh, off_t sampleoff, int whence, off_t *input_offset);
+
+/** Seek to a desired MPEG frame index.
+ *  Set whence to SEEK_SET, SEEK_CUR or SEEK_END.
+ *  \return The resulting offset >= 0 or error/message code */
+MPG123_EXPORT off_t mpg123_seek_frame(mpg123_handle *mh, off_t frameoff, int whence);
+
+/** Return a MPEG frame offset corresponding to an offset in seconds.
+ *  This assumes that the samples per frame do not change in the file/stream, which is a good assumption for any sane file/stream only.
+ *  \return frame offset >= 0 or error/message code */
+MPG123_EXPORT off_t mpg123_timeframe(mpg123_handle *mh, double sec);
+
+/** Give access to the frame index table that is managed for seeking.
+ *  You are asked not to modify the values... Use mpg123_set_index to set the
+ *  seek index
+ *  \param offsets pointer to the index array
+ *  \param step one index byte offset advances this many MPEG frames
+ *  \param fill number of recorded index offsets; size of the array
+ *  \return MPG123_OK on success
+ */
+MPG123_EXPORT int mpg123_index(mpg123_handle *mh, off_t **offsets, off_t *step, size_t *fill);
+
+/** Set the frame index table
+ *  Setting offsets to NULL and fill > 0 will allocate fill entries. Setting offsets
+ *  to NULL and fill to 0 will clear the index and free the allocated memory used by the index.
+ *  \param offsets pointer to the index array
+ *  \param step    one index byte offset advances this many MPEG frames
+ *  \param fill    number of recorded index offsets; size of the array
+ *  \return MPG123_OK on success
+ */
+MPG123_EXPORT int mpg123_set_index(mpg123_handle *mh, off_t *offsets, off_t step, size_t fill);
+
+/** Get information about current and remaining frames/seconds.
+ *  WARNING: This function is there because of special usage by standalone mpg123 and may be removed in the final version of libmpg123!
+ *  You provide an offset (in frames) from now and a number of output bytes 
+ *  served by libmpg123 but not yet played. You get the projected current frame 
+ *  and seconds, as well as the remaining frames/seconds. This does _not_ care 
+ *  about skipped samples due to gapless playback. */
+MPG123_EXPORT int mpg123_position( mpg123_handle *mh, off_t frame_offset, off_t buffered_bytes, off_t *current_frame, off_t *frames_left, double *current_seconds, double *seconds_left);
+
+/*@}*/
+
+
+/** \defgroup mpg123_voleq mpg123 volume and equalizer
+ *
+ * @{
+ */
+
+enum mpg123_channels
+{
+	 MPG123_LEFT=0x1	/**< The Left Channel. */
+	,MPG123_RIGHT=0x2	/**< The Right Channel. */
+	,MPG123_LR=0x3	/**< Both left and right channel; same as MPG123_LEFT|MPG123_RIGHT */
+};
+
+/** Set the 32 Band Audio Equalizer settings.
+ *  \param channel Can be MPG123_LEFT, MPG123_RIGHT or MPG123_LEFT|MPG123_RIGHT for both.
+ *  \param band The equaliser band to change (from 0 to 31)
+ *  \param val The (linear) adjustment factor.
+ *  \return MPG123_OK on success
+ */
+MPG123_EXPORT int mpg123_eq(mpg123_handle *mh, enum mpg123_channels channel, int band, double val);
+
+/** Get the 32 Band Audio Equalizer settings.
+ *  \param channel Can be MPG123_LEFT, MPG123_RIGHT or MPG123_LEFT|MPG123_RIGHT for (arithmetic mean of) both.
+ *  \param band The equaliser band to change (from 0 to 31)
+ *  \return The (linear) adjustment factor (zero for pad parameters) */
+MPG123_EXPORT double mpg123_geteq(mpg123_handle *mh, enum mpg123_channels channel, int band);
+
+/** Reset the 32 Band Audio Equalizer settings to flat
+ *  \return MPG123_OK on success
+ */
+MPG123_EXPORT int mpg123_reset_eq(mpg123_handle *mh);
+
+/** Set the absolute output volume including the RVA setting, 
+ *  vol<0 just applies (a possibly changed) RVA setting. */
+MPG123_EXPORT int mpg123_volume(mpg123_handle *mh, double vol);
+
+/** Adjust output volume including the RVA setting by chosen amount */
+MPG123_EXPORT int mpg123_volume_change(mpg123_handle *mh, double change);
+
+/** Return current volume setting, the actual value due to RVA, and the RVA 
+ *  adjustment itself. It's all as double float value to abstract the sample 
+ *  format. The volume values are linear factors / amplitudes (not percent) 
+ *  and the RVA value is in decibels. */
+MPG123_EXPORT int mpg123_getvolume(mpg123_handle *mh, double *base, double *really, double *rva_db);
+
+/* TODO: Set some preamp in addition / to replace internal RVA handling? */
+
+/*@}*/
+
+
+/** \defgroup mpg123_status mpg123 status and information
+ *
+ * @{
+ */
+
+/** Enumeration of the mode types of Variable Bitrate */
+enum mpg123_vbr {
+	MPG123_CBR=0,	/**< Constant Bitrate Mode (default) */
+	MPG123_VBR,		/**< Variable Bitrate Mode */
+	MPG123_ABR		/**< Average Bitrate Mode */
+};
+
+/** Enumeration of the MPEG Versions */
+enum mpg123_version {
+	MPG123_1_0=0,	/**< MPEG Version 1.0 */
+	MPG123_2_0,		/**< MPEG Version 2.0 */
+	MPG123_2_5		/**< MPEG Version 2.5 */
+};
+
+
+/** Enumeration of the MPEG Audio mode.
+ *  Only the mono mode has 1 channel, the others have 2 channels. */
+enum mpg123_mode {
+	MPG123_M_STEREO=0,	/**< Standard Stereo. */
+	MPG123_M_JOINT,		/**< Joint Stereo. */
+	MPG123_M_DUAL,		/**< Dual Channel. */
+	MPG123_M_MONO		/**< Single Channel. */
+};
+
+
+/** Enumeration of the MPEG Audio flag bits */
+enum mpg123_flags {
+	MPG123_CRC=0x1,			/**< The bitstream is error protected using 16-bit CRC. */
+	MPG123_COPYRIGHT=0x2,	/**< The bitstream is copyrighted. */
+	MPG123_PRIVATE=0x4,		/**< The private bit has been set. */
+	MPG123_ORIGINAL=0x8	/**< The bitstream is an original, not a copy. */
+};
+
+/** Data structure for storing information about a frame of MPEG Audio */
+struct mpg123_frameinfo
+{
+	enum mpg123_version version;	/**< The MPEG version (1.0/2.0/2.5). */
+	int layer;						/**< The MPEG Audio Layer (MP1/MP2/MP3). */
+	long rate; 						/**< The sampling rate in Hz. */
+	enum mpg123_mode mode;			/**< The audio mode (Mono, Stereo, Joint-stero, Dual Channel). */
+	int mode_ext;					/**< The mode extension bit flag. */
+	int framesize;					/**< The size of the frame (in bytes, including header). */
+	enum mpg123_flags flags;		/**< MPEG Audio flag bits. Just now I realize that it should be declared as int, not enum. It's a bitwise combination of the enum values. */
+	int emphasis;					/**< The emphasis type. */
+	int bitrate;					/**< Bitrate of the frame (kbps). */
+	int abr_rate;					/**< The target average bitrate. */
+	enum mpg123_vbr vbr;			/**< The VBR mode. */
+};
+
+/** Get frame information about the MPEG audio bitstream and store it in a mpg123_frameinfo structure.
+ *  \return MPG123_OK on success
+ */
+MPG123_EXPORT int mpg123_info(mpg123_handle *mh, struct mpg123_frameinfo *mi);
+
+/** Get the safe output buffer size for all cases (when you want to replace the internal buffer) */
+MPG123_EXPORT size_t mpg123_safe_buffer(void); 
+
+/** Make a full parsing scan of each frame in the file. ID3 tags are found. An accurate length 
+ *  value is stored. Seek index will be filled. A seek back to current position 
+ *  is performed. At all, this function refuses work when stream is 
+ *  not seekable. 
+ *  \return MPG123_OK on success
+ */
+MPG123_EXPORT int mpg123_scan(mpg123_handle *mh);
+
+/** Return, if possible, the full (expected) length of current track in samples.
+  * \return length >= 0 or MPG123_ERR if there is no length guess possible. */
+MPG123_EXPORT off_t mpg123_length(mpg123_handle *mh);
+
+/** Override the value for file size in bytes.
+  * Useful for getting sensible track length values in feed mode or for HTTP streams.
+  * \return MPG123_OK on success
+  */
+MPG123_EXPORT int mpg123_set_filesize(mpg123_handle *mh, off_t size);
+
+/** Returns the time (seconds) per frame; <0 is error. */
+MPG123_EXPORT double mpg123_tpf(mpg123_handle *mh);
+
+/** Returns the samples per frame for the most recently parsed frame; <0 is error. */
+MPG123_EXPORT int mpg123_spf(mpg123_handle *mh);
+
+/** Get and reset the clip count. */
+MPG123_EXPORT long mpg123_clip(mpg123_handle *mh);
+
+
+/** The key values for state information from mpg123_getstate(). */
+enum mpg123_state
+{
+	 MPG123_ACCURATE = 1 /**< Query if positons are currently accurate (integer value, 0 if false, 1 if true). */
+	,MPG123_BUFFERFILL   /**< Get fill of internal (feed) input buffer as integer byte count returned as long and as double. An error is returned on integer overflow while converting to (signed) long, but the returned floating point value shold still be fine. */
+	,MPG123_FRANKENSTEIN /**< Stream consists of carelessly stitched together files. Seeking may yield unexpected results (also with MPG123_ACCURATE, it may be confused). */
+	,MPG123_FRESH_DECODER /**< Decoder structure has been updated, possibly indicating changed stream (integer value, 0 if false, 1 if true). Flag is cleared after retrieval. */
+};
+
+/** Get various current decoder/stream state information.
+ *  \param key the key to identify the information to give.
+ *  \param val the address to return (long) integer values to
+ *  \param fval the address to return floating point values to
+ *  \return MPG123_OK on success
+ */
+MPG123_EXPORT int mpg123_getstate(mpg123_handle *mh, enum mpg123_state key, long *val, double *fval);
+
+/*@}*/
+
+
+/** \defgroup mpg123_metadata mpg123 metadata handling
+ *
+ * Functions to retrieve the metadata from MPEG Audio files and streams.
+ * Also includes string handling functions.
+ *
+ * @{
+ */
+
+/** Data structure for storing strings in a safer way than a standard C-String.
+ *  Can also hold a number of null-terminated strings. */
+typedef struct 
+{
+	char* p;     /**< pointer to the string data */
+	size_t size; /**< raw number of bytes allocated */
+	size_t fill; /**< number of used bytes (including closing zero byte) */
+} mpg123_string;
+
+/** Create and allocate memory for a new mpg123_string */
+MPG123_EXPORT void mpg123_init_string(mpg123_string* sb);
+
+/** Free-up mempory for an existing mpg123_string */
+MPG123_EXPORT void mpg123_free_string(mpg123_string* sb);
+
+/** Change the size of a mpg123_string
+ *  \return 0 on error, 1 on success */
+MPG123_EXPORT int  mpg123_resize_string(mpg123_string* sb, size_t news);
+
+/** Increase size of a mpg123_string if necessary (it may stay larger).
+ *  Note that the functions for adding and setting in current libmpg123 use this instead of mpg123_resize_string().
+ *  That way, you can preallocate memory and safely work afterwards with pieces.
+ *  \return 0 on error, 1 on success */
+MPG123_EXPORT int  mpg123_grow_string(mpg123_string* sb, size_t news);
+
+/** Copy the contents of one mpg123_string string to another.
+ *  \return 0 on error, 1 on success */
+MPG123_EXPORT int  mpg123_copy_string(mpg123_string* from, mpg123_string* to);
+
+/** Append a C-String to an mpg123_string
+ *  \return 0 on error, 1 on success */
+MPG123_EXPORT int  mpg123_add_string(mpg123_string* sb, const char* stuff);
+
+/** Append a C-substring to an mpg123 string
+ *  \return 0 on error, 1 on success
+ *  \param from offset to copy from
+ *  \param count number of characters to copy (a null-byte is always appended) */
+MPG123_EXPORT int  mpg123_add_substring(mpg123_string *sb, const char *stuff, size_t from, size_t count);
+
+/** Set the conents of a mpg123_string to a C-string
+ *  \return 0 on error, 1 on success */
+MPG123_EXPORT int  mpg123_set_string(mpg123_string* sb, const char* stuff);
+
+/** Set the contents of a mpg123_string to a C-substring
+ *  \return 0 on error, 1 on success
+ *  \param from offset to copy from
+ *  \param count number of characters to copy (a null-byte is always appended) */
+MPG123_EXPORT int  mpg123_set_substring(mpg123_string *sb, const char *stuff, size_t from, size_t count);
+
+/** Count characters in a mpg123 string (non-null bytes or UTF-8 characters).
+ *  \return character count
+ *  \param sb the string
+ *  \param utf8 a flag to tell if the string is in utf8 encoding
+ *  Even with the fill property, the character count is not obvious as there could be multiple trailing null bytes.
+*/
+MPG123_EXPORT size_t mpg123_strlen(mpg123_string *sb, int utf8);
+
+/** Remove trailing \r and \n, if present.
+ *  \return 0 on error, 1 on success
+ *  \param sb the string
+ */
+MPG123_EXPORT int mpg123_chomp_string(mpg123_string *sb);
+
+/** The mpg123 text encodings. This contains encodings we encounter in ID3 tags or ICY meta info. */
+enum mpg123_text_encoding
+{
+	 mpg123_text_unknown  = 0 /**< Unkown encoding... mpg123_id3_encoding can return that on invalid codes. */
+	,mpg123_text_utf8     = 1 /**< UTF-8 */
+	,mpg123_text_latin1   = 2 /**< ISO-8859-1. Note that sometimes latin1 in ID3 is abused for totally different encodings. */
+	,mpg123_text_icy      = 3 /**< ICY metadata encoding, usually CP-1252 but we take it as UTF-8 if it qualifies as such. */
+	,mpg123_text_cp1252   = 4 /**< Really CP-1252 without any guessing. */
+	,mpg123_text_utf16    = 5 /**< Some UTF-16 encoding. The last of a set of leading BOMs (byte order mark) rules.
+	                           *   When there is no BOM, big endian ordering is used. Note that UCS-2 qualifies as UTF-8 when
+	                           *   you don't mess with the reserved code points. If you want to decode little endian data
+	                           *   without BOM you need to prepend 0xff 0xfe yourself. */
+	,mpg123_text_utf16bom = 6 /**< Just an alias for UTF-16, ID3v2 has this as distinct code. */
+	,mpg123_text_utf16be  = 7 /**< Another alias for UTF16 from ID3v2. Note, that, because of the mess that is reality,
+	                           *   BOMs are used if encountered. There really is not much distinction between the UTF16 types for mpg123
+	                           *   One exception: Since this is seen in ID3v2 tags, leading null bytes are skipped for all other UTF16
+	                           *   types (we expect a BOM before real data there), not so for utf16be!*/
+	,mpg123_text_max      = 7 /**< Placeholder for the maximum encoding value. */
+};
+
+/** The encoding byte values from ID3v2. */
+enum mpg123_id3_enc
+{
+	 mpg123_id3_latin1   = 0 /**< Note: This sometimes can mean anything in practice... */
+	,mpg123_id3_utf16bom = 1 /**< UTF16, UCS-2 ... it's all the same for practical purposes. */
+	,mpg123_id3_utf16be  = 2 /**< Big-endian UTF-16, BOM see note for mpg123_text_utf16be. */
+	,mpg123_id3_utf8     = 3 /**< Our lovely overly ASCII-compatible 8 byte encoding for the world. */
+	,mpg123_id3_enc_max  = 3 /**< Placeholder to check valid range of encoding byte. */
+};
+
+/** Convert ID3 encoding byte to mpg123 encoding index. */
+MPG123_EXPORT enum mpg123_text_encoding mpg123_enc_from_id3(unsigned char id3_enc_byte);
+
+/** Store text data in string, after converting to UTF-8 from indicated encoding
+ *  \return 0 on error, 1 on success (on error, mpg123_free_string is called on sb)
+ *  \param sb  target string
+ *  \param enc mpg123 text encoding value
+ *  \param source source buffer with plain unsigned bytes (you might need to cast from char *)
+ *  \param source_size number of bytes in the source buffer
+ *
+ *  A prominent error can be that you provided an unknown encoding value, or this build of libmpg123 lacks support for certain encodings (ID3 or ICY stuff missing).
+ *  Also, you might want to take a bit of care with preparing the data; for example, strip leading zeroes (I have seen that).
+ */
+MPG123_EXPORT int mpg123_store_utf8(mpg123_string *sb, enum mpg123_text_encoding enc, const unsigned char *source, size_t source_size);
+
+/** Sub data structure for ID3v2, for storing various text fields (including comments).
+ *  This is for ID3v2 COMM, TXXX and all the other text fields.
+ *  Only COMM and TXXX have a description, only COMM and USLT have a language.
+ *  You should consult the ID3v2 specification for the use of the various text fields ("frames" in ID3v2 documentation, I use "fields" here to separate from MPEG frames). */
+typedef struct
+{
+	char lang[3]; /**< Three-letter language code (not terminated). */
+	char id[4];   /**< The ID3v2 text field id, like TALB, TPE2, ... (4 characters, no string termination). */
+	mpg123_string description; /**< Empty for the generic comment... */
+	mpg123_string text;        /**< ... */
+} mpg123_text;
+
+/** The picture type values from ID3v2. */
+enum mpg123_id3_pic_type
+{
+	 mpg123_id3_pic_other          =  0
+	,mpg123_id3_pic_icon           =  1
+	,mpg123_id3_pic_other_icon     =  2
+	,mpg123_id3_pic_front_cover    =  3
+	,mpg123_id3_pic_back_cover     =  4
+	,mpg123_id3_pic_leaflet        =  5
+	,mpg123_id3_pic_media          =  6
+	,mpg123_id3_pic_lead           =  7
+	,mpg123_id3_pic_artist         =  8
+	,mpg123_id3_pic_conductor      =  9
+	,mpg123_id3_pic_orchestra      = 10
+	,mpg123_id3_pic_composer       = 11
+	,mpg123_id3_pic_lyricist       = 12
+	,mpg123_id3_pic_location       = 13
+	,mpg123_id3_pic_recording      = 14
+	,mpg123_id3_pic_performance    = 15
+	,mpg123_id3_pic_video          = 16
+	,mpg123_id3_pic_fish           = 17
+	,mpg123_id3_pic_illustration   = 18
+	,mpg123_id3_pic_artist_logo    = 19
+	,mpg123_id3_pic_publisher_logo = 20
+};
+
+/** Sub data structure for ID3v2, for storing picture data including comment.
+ *  This is for the ID3v2 APIC field. You should consult the ID3v2 specification
+ *  for the use of the APIC field ("frames" in ID3v2 documentation, I use "fields"
+ *  here to separate from MPEG frames). */
+typedef struct
+{
+	char type;
+	mpg123_string description;
+	mpg123_string mime_type;
+	size_t size;
+	unsigned char* data;
+} mpg123_picture;
+
+/** Data structure for storing IDV3v2 tags.
+ *  This structure is not a direct binary mapping with the file contents.
+ *  The ID3v2 text frames are allowed to contain multiple strings.
+ *  So check for null bytes until you reach the mpg123_string fill.
+ *  All text is encoded in UTF-8. */
+typedef struct
+{
+	unsigned char version; /**< 3 or 4 for ID3v2.3 or ID3v2.4. */
+	mpg123_string *title;   /**< Title string (pointer into text_list). */
+	mpg123_string *artist;  /**< Artist string (pointer into text_list). */
+	mpg123_string *album;   /**< Album string (pointer into text_list). */
+	mpg123_string *year;    /**< The year as a string (pointer into text_list). */
+	mpg123_string *genre;   /**< Genre String (pointer into text_list). The genre string(s) may very well need postprocessing, esp. for ID3v2.3. */
+	mpg123_string *comment; /**< Pointer to last encountered comment text with empty description. */
+	/* Encountered ID3v2 fields are appended to these lists.
+	   There can be multiple occurences, the pointers above always point to the last encountered data. */
+	mpg123_text    *comment_list; /**< Array of comments. */
+	size_t          comments;     /**< Number of comments. */
+	mpg123_text    *text;         /**< Array of ID3v2 text fields (including USLT) */
+	size_t          texts;        /**< Numer of text fields. */
+	mpg123_text    *extra;        /**< The array of extra (TXXX) fields. */
+	size_t          extras;       /**< Number of extra text (TXXX) fields. */
+	mpg123_picture  *picture;     /**< Array of ID3v2 pictures fields (APIC). */
+	size_t           pictures;    /**< Number of picture (APIC) fields. */
+} mpg123_id3v2;
+
+/** Data structure for ID3v1 tags (the last 128 bytes of a file).
+ *  Don't take anything for granted (like string termination)!
+ *  Also note the change ID3v1.1 did: comment[28] = 0; comment[29] = track_number
+ *  It is your task to support ID3v1 only or ID3v1.1 ...*/
+typedef struct
+{
+	char tag[3];         /**< Always the string "TAG", the classic intro. */
+	char title[30];      /**< Title string.  */
+	char artist[30];     /**< Artist string. */
+	char album[30];      /**< Album string. */
+	char year[4];        /**< Year string. */
+	char comment[30];    /**< Comment string. */
+	unsigned char genre; /**< Genre index. */
+} mpg123_id3v1;
+
+#define MPG123_ID3     0x3 /**< 0011 There is some ID3 info. Also matches 0010 or NEW_ID3. */
+#define MPG123_NEW_ID3 0x1 /**< 0001 There is ID3 info that changed since last call to mpg123_id3. */
+#define MPG123_ICY     0xc /**< 1100 There is some ICY info. Also matches 0100 or NEW_ICY.*/
+#define MPG123_NEW_ICY 0x4 /**< 0100 There is ICY info that changed since last call to mpg123_icy. */
+
+/** Query if there is (new) meta info, be it ID3 or ICY (or something new in future).
+   The check function returns a combination of flags. */
+MPG123_EXPORT int mpg123_meta_check(mpg123_handle *mh); /* On error (no valid handle) just 0 is returned. */
+
+/** Clean up meta data storage (ID3v2 and ICY), freeing memory. */
+MPG123_EXPORT void mpg123_meta_free(mpg123_handle *mh);
+
+/** Point v1 and v2 to existing data structures wich may change on any next read/decode function call.
+ *  v1 and/or v2 can be set to NULL when there is no corresponding data.
+ *  \return MPG123_OK on success
+ */
+MPG123_EXPORT int mpg123_id3(mpg123_handle *mh, mpg123_id3v1 **v1, mpg123_id3v2 **v2);
+
+/** Point icy_meta to existing data structure wich may change on any next read/decode function call.
+ *  \return MPG123_OK on success
+ */
+MPG123_EXPORT int mpg123_icy(mpg123_handle *mh, char **icy_meta); /* same for ICY meta string */
+
+/** Decode from windows-1252 (the encoding ICY metainfo used) to UTF-8.
+ *  Note that this is very similar to mpg123_store_utf8(&sb, mpg123_text_icy, icy_text, strlen(icy_text+1)) .
+ *  \param icy_text The input data in ICY encoding
+ *  \return pointer to newly allocated buffer with UTF-8 data (You free() it!) */
+MPG123_EXPORT char* mpg123_icy2utf8(const char* icy_text);
+
+
+/* @} */
+
+
+/** \defgroup mpg123_advpar mpg123 advanced parameter API
+ *
+ *  Direct access to a parameter set without full handle around it.
+ *	Possible uses:
+ *    - Influence behaviour of library _during_ initialization of handle (MPG123_VERBOSE).
+ *    - Use one set of parameters for multiple handles.
+ *
+ *	The functions for handling mpg123_pars (mpg123_par() and mpg123_fmt() 
+ *  family) directly return a fully qualified mpg123 error code, the ones 
+ *  operating on full handles normally MPG123_OK or MPG123_ERR, storing the 
+ *  specific error code itseld inside the handle. 
+ *
+ * @{
+ */
+
+/** Opaque structure for the libmpg123 decoder parameters. */
+struct mpg123_pars_struct;
+
+/** Opaque structure for the libmpg123 decoder parameters. */
+typedef struct mpg123_pars_struct   mpg123_pars;
+
+/** Create a handle with preset parameters. */
+MPG123_EXPORT mpg123_handle *mpg123_parnew(mpg123_pars *mp, const char* decoder, int *error);
+
+/** Allocate memory for and return a pointer to a new mpg123_pars */
+MPG123_EXPORT mpg123_pars *mpg123_new_pars(int *error);
+
+/** Delete and free up memory used by a mpg123_pars data structure */
+MPG123_EXPORT void         mpg123_delete_pars(mpg123_pars* mp);
+
+/** Configure mpg123 parameters to accept no output format at all, 
+ * use before specifying supported formats with mpg123_format
+ *  \return MPG123_OK on success
+ */
+MPG123_EXPORT int mpg123_fmt_none(mpg123_pars *mp);
+
+/** Configure mpg123 parameters to accept all formats 
+ *  (also any custom rate you may set) -- this is default. 
+ *  \return MPG123_OK on success
+ */
+MPG123_EXPORT int mpg123_fmt_all(mpg123_pars *mp);
+
+/** Set the audio format support of a mpg123_pars in detail:
+	\param rate The sample rate value (in Hertz).
+	\param channels A combination of MPG123_STEREO and MPG123_MONO.
+	\param encodings A combination of accepted encodings for rate and channels, p.ex MPG123_ENC_SIGNED16|MPG123_ENC_ULAW_8 (or 0 for no support).
+	\return MPG123_OK on success
+*/
+MPG123_EXPORT int mpg123_fmt(mpg123_pars *mp, long rate, int channels, int encodings); /* 0 is good, -1 is error */
+
+/** Check to see if a specific format at a specific rate is supported 
+ *  by mpg123_pars.
+ *  \return 0 for no support (that includes invalid parameters), MPG123_STEREO, 
+ *          MPG123_MONO or MPG123_STEREO|MPG123_MONO. */
+MPG123_EXPORT int mpg123_fmt_support(mpg123_pars *mp,   long rate, int encoding);
+
+/** Set a specific parameter, for a specific mpg123_pars, using a parameter 
+ *  type key chosen from the mpg123_parms enumeration, to the specified value. */
+MPG123_EXPORT int mpg123_par(mpg123_pars *mp, enum mpg123_parms type, long value, double fvalue);
+
+/** Get a specific parameter, for a specific mpg123_pars. 
+ *  See the mpg123_parms enumeration for a list of available parameters. */
+MPG123_EXPORT int mpg123_getpar(mpg123_pars *mp, enum mpg123_parms type, long *val, double *fval);
+
+/* @} */
+
+
+/** \defgroup mpg123_lowio mpg123 low level I/O
+  * You may want to do tricky stuff with I/O that does not work with mpg123's default file access or you want to make it decode into your own pocket...
+  *
+  * @{ */
+
+/** Replace default internal buffer with user-supplied buffer.
+  * Instead of working on it's own private buffer, mpg123 will directly use the one you provide for storing decoded audio.
+  * Note that the required buffer size could be bigger than expected from output
+  * encoding if libmpg123 has to convert from primary decoder output (p.ex. 32 bit
+  * storage for 24 bit output.
+  * \param data pointer to user buffer
+  * \param size of buffer in bytes
+  * \return MPG123_OK on success
+  */
+MPG123_EXPORT int mpg123_replace_buffer(mpg123_handle *mh, unsigned char *data, size_t size);
+
+/** The max size of one frame's decoded output with current settings.
+ *  Use that to determine an appropriate minimum buffer size for decoding one frame. */
+MPG123_EXPORT size_t mpg123_outblock(mpg123_handle *mh);
+
+/** Replace low-level stream access functions; read and lseek as known in POSIX.
+ *  You can use this to make any fancy file opening/closing yourself, 
+ *  using mpg123_open_fd() to set the file descriptor for your read/lseek (doesn't need to be a "real" file descriptor...).
+ *  Setting a function to NULL means that the default internal read is 
+ *  used (active from next mpg123_open call on).
+ *  Note: As it would be troublesome to mess with this while having a file open,
+ *  this implies mpg123_close(). */
+MPG123_EXPORT int mpg123_replace_reader(mpg123_handle *mh, ssize_t (*r_read) (int, void *, size_t), off_t (*r_lseek)(int, off_t, int));
+
+/** Replace I/O functions with your own ones operating on some kind of handle instead of integer descriptors.
+ *  The handle is a void pointer, so you can pass any data you want...
+ *  mpg123_open_handle() is the call you make to use the I/O defined here.
+ *  There is no fallback to internal read/seek here.
+ *  Note: As it would be troublesome to mess with this while having a file open,
+ *  this mpg123_close() is implied here.
+ *  \param r_read The callback for reading (behaviour like posix read).
+ *  \param r_lseek The callback for seeking (like posix lseek).
+ *  \param cleanup A callback to clean up an I/O handle on mpg123_close, can be NULL for none (you take care of cleaning your handles). */
+MPG123_EXPORT int mpg123_replace_reader_handle(mpg123_handle *mh, ssize_t (*r_read) (void *, void *, size_t), off_t (*r_lseek)(void *, off_t, int), void (*cleanup)(void*));
+
+/* @} */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/src/sound/thirdparty/sndfile.h b/src/sound/thirdparty/sndfile.h
new file mode 100644
index 0000000000..49564e83f1
--- /dev/null
+++ b/src/sound/thirdparty/sndfile.h
@@ -0,0 +1,666 @@
+/*
+** Copyright (C) 1999-2011Erik de Castro Lopo <erikd@mega-nerd.com>
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU Lesser General Public License as published by
+** the Free Software Foundation; either version 2.1 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+** GNU Lesser General Public License for more details.
+**
+** You should have received a copy of the GNU Lesser General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+/*
+** sndfile.h -- system-wide definitions
+**
+** API documentation is in the doc/ directory of the source code tarball
+** and at http://www.mega-nerd.com/libsndfile/api.html.
+*/
+
+#ifndef SNDFILE_H
+#define SNDFILE_H
+
+/* This is the version 1.0.X header file. */
+#define	SNDFILE_1
+
+#include <stdio.h>
+#include <sys/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif	/* __cplusplus */
+
+/* The following file types can be read and written.
+** A file type would consist of a major type (ie SF_FORMAT_WAV) bitwise
+** ORed with a minor type (ie SF_FORMAT_PCM). SF_FORMAT_TYPEMASK and
+** SF_FORMAT_SUBMASK can be used to separate the major and minor file
+** types.
+*/
+
+enum
+{	/* Major formats. */
+	SF_FORMAT_WAV			= 0x010000,		/* Microsoft WAV format (little endian default). */
+	SF_FORMAT_AIFF			= 0x020000,		/* Apple/SGI AIFF format (big endian). */
+	SF_FORMAT_AU			= 0x030000,		/* Sun/NeXT AU format (big endian). */
+	SF_FORMAT_RAW			= 0x040000,		/* RAW PCM data. */
+	SF_FORMAT_PAF			= 0x050000,		/* Ensoniq PARIS file format. */
+	SF_FORMAT_SVX			= 0x060000,		/* Amiga IFF / SVX8 / SV16 format. */
+	SF_FORMAT_NIST			= 0x070000,		/* Sphere NIST format. */
+	SF_FORMAT_VOC			= 0x080000,		/* VOC files. */
+	SF_FORMAT_IRCAM			= 0x0A0000,		/* Berkeley/IRCAM/CARL */
+	SF_FORMAT_W64			= 0x0B0000,		/* Sonic Foundry's 64 bit RIFF/WAV */
+	SF_FORMAT_MAT4			= 0x0C0000,		/* Matlab (tm) V4.2 / GNU Octave 2.0 */
+	SF_FORMAT_MAT5			= 0x0D0000,		/* Matlab (tm) V5.0 / GNU Octave 2.1 */
+	SF_FORMAT_PVF			= 0x0E0000,		/* Portable Voice Format */
+	SF_FORMAT_XI			= 0x0F0000,		/* Fasttracker 2 Extended Instrument */
+	SF_FORMAT_HTK			= 0x100000,		/* HMM Tool Kit format */
+	SF_FORMAT_SDS			= 0x110000,		/* Midi Sample Dump Standard */
+	SF_FORMAT_AVR			= 0x120000,		/* Audio Visual Research */
+	SF_FORMAT_WAVEX			= 0x130000,		/* MS WAVE with WAVEFORMATEX */
+	SF_FORMAT_SD2			= 0x160000,		/* Sound Designer 2 */
+	SF_FORMAT_FLAC			= 0x170000,		/* FLAC lossless file format */
+	SF_FORMAT_CAF			= 0x180000,		/* Core Audio File format */
+	SF_FORMAT_WVE			= 0x190000,		/* Psion WVE format */
+	SF_FORMAT_OGG			= 0x200000,		/* Xiph OGG container */
+	SF_FORMAT_MPC2K			= 0x210000,		/* Akai MPC 2000 sampler */
+	SF_FORMAT_RF64			= 0x220000,		/* RF64 WAV file */
+
+	/* Subtypes from here on. */
+
+	SF_FORMAT_PCM_S8		= 0x0001,		/* Signed 8 bit data */
+	SF_FORMAT_PCM_16		= 0x0002,		/* Signed 16 bit data */
+	SF_FORMAT_PCM_24		= 0x0003,		/* Signed 24 bit data */
+	SF_FORMAT_PCM_32		= 0x0004,		/* Signed 32 bit data */
+
+	SF_FORMAT_PCM_U8		= 0x0005,		/* Unsigned 8 bit data (WAV and RAW only) */
+
+	SF_FORMAT_FLOAT			= 0x0006,		/* 32 bit float data */
+	SF_FORMAT_DOUBLE		= 0x0007,		/* 64 bit float data */
+
+	SF_FORMAT_ULAW			= 0x0010,		/* U-Law encoded. */
+	SF_FORMAT_ALAW			= 0x0011,		/* A-Law encoded. */
+	SF_FORMAT_IMA_ADPCM		= 0x0012,		/* IMA ADPCM. */
+	SF_FORMAT_MS_ADPCM		= 0x0013,		/* Microsoft ADPCM. */
+
+	SF_FORMAT_GSM610		= 0x0020,		/* GSM 6.10 encoding. */
+	SF_FORMAT_VOX_ADPCM		= 0x0021,		/* OKI / Dialogix ADPCM */
+
+	SF_FORMAT_G721_32		= 0x0030,		/* 32kbs G721 ADPCM encoding. */
+	SF_FORMAT_G723_24		= 0x0031,		/* 24kbs G723 ADPCM encoding. */
+	SF_FORMAT_G723_40		= 0x0032,		/* 40kbs G723 ADPCM encoding. */
+
+	SF_FORMAT_DWVW_12		= 0x0040, 		/* 12 bit Delta Width Variable Word encoding. */
+	SF_FORMAT_DWVW_16		= 0x0041, 		/* 16 bit Delta Width Variable Word encoding. */
+	SF_FORMAT_DWVW_24		= 0x0042, 		/* 24 bit Delta Width Variable Word encoding. */
+	SF_FORMAT_DWVW_N		= 0x0043, 		/* N bit Delta Width Variable Word encoding. */
+
+	SF_FORMAT_DPCM_8		= 0x0050,		/* 8 bit differential PCM (XI only) */
+	SF_FORMAT_DPCM_16		= 0x0051,		/* 16 bit differential PCM (XI only) */
+
+	SF_FORMAT_VORBIS		= 0x0060,		/* Xiph Vorbis encoding. */
+
+	/* Endian-ness options. */
+
+	SF_ENDIAN_FILE			= 0x00000000,	/* Default file endian-ness. */
+	SF_ENDIAN_LITTLE		= 0x10000000,	/* Force little endian-ness. */
+	SF_ENDIAN_BIG			= 0x20000000,	/* Force big endian-ness. */
+	SF_ENDIAN_CPU			= 0x30000000,	/* Force CPU endian-ness. */
+
+	SF_FORMAT_SUBMASK		= 0x0000FFFF,
+	SF_FORMAT_TYPEMASK		= 0x0FFF0000,
+	SF_FORMAT_ENDMASK		= 0x30000000
+} ;
+
+/*
+** The following are the valid command numbers for the sf_command()
+** interface.  The use of these commands is documented in the file
+** command.html in the doc directory of the source code distribution.
+*/
+
+enum
+{	SFC_GET_LIB_VERSION				= 0x1000,
+	SFC_GET_LOG_INFO				= 0x1001,
+	SFC_GET_CURRENT_SF_INFO			= 0x1002,
+
+
+	SFC_GET_NORM_DOUBLE				= 0x1010,
+	SFC_GET_NORM_FLOAT				= 0x1011,
+	SFC_SET_NORM_DOUBLE				= 0x1012,
+	SFC_SET_NORM_FLOAT				= 0x1013,
+	SFC_SET_SCALE_FLOAT_INT_READ	= 0x1014,
+	SFC_SET_SCALE_INT_FLOAT_WRITE	= 0x1015,
+
+	SFC_GET_SIMPLE_FORMAT_COUNT		= 0x1020,
+	SFC_GET_SIMPLE_FORMAT			= 0x1021,
+
+	SFC_GET_FORMAT_INFO				= 0x1028,
+
+	SFC_GET_FORMAT_MAJOR_COUNT		= 0x1030,
+	SFC_GET_FORMAT_MAJOR			= 0x1031,
+	SFC_GET_FORMAT_SUBTYPE_COUNT	= 0x1032,
+	SFC_GET_FORMAT_SUBTYPE			= 0x1033,
+
+	SFC_CALC_SIGNAL_MAX				= 0x1040,
+	SFC_CALC_NORM_SIGNAL_MAX		= 0x1041,
+	SFC_CALC_MAX_ALL_CHANNELS		= 0x1042,
+	SFC_CALC_NORM_MAX_ALL_CHANNELS	= 0x1043,
+	SFC_GET_SIGNAL_MAX				= 0x1044,
+	SFC_GET_MAX_ALL_CHANNELS		= 0x1045,
+
+	SFC_SET_ADD_PEAK_CHUNK			= 0x1050,
+	SFC_SET_ADD_HEADER_PAD_CHUNK	= 0x1051,
+
+	SFC_UPDATE_HEADER_NOW			= 0x1060,
+	SFC_SET_UPDATE_HEADER_AUTO		= 0x1061,
+
+	SFC_FILE_TRUNCATE				= 0x1080,
+
+	SFC_SET_RAW_START_OFFSET		= 0x1090,
+
+	SFC_SET_DITHER_ON_WRITE			= 0x10A0,
+	SFC_SET_DITHER_ON_READ			= 0x10A1,
+
+	SFC_GET_DITHER_INFO_COUNT		= 0x10A2,
+	SFC_GET_DITHER_INFO				= 0x10A3,
+
+	SFC_GET_EMBED_FILE_INFO			= 0x10B0,
+
+	SFC_SET_CLIPPING				= 0x10C0,
+	SFC_GET_CLIPPING				= 0x10C1,
+
+	SFC_GET_INSTRUMENT				= 0x10D0,
+	SFC_SET_INSTRUMENT				= 0x10D1,
+
+	SFC_GET_LOOP_INFO				= 0x10E0,
+
+	SFC_GET_BROADCAST_INFO			= 0x10F0,
+	SFC_SET_BROADCAST_INFO			= 0x10F1,
+
+	SFC_GET_CHANNEL_MAP_INFO		= 0x1100,
+	SFC_SET_CHANNEL_MAP_INFO		= 0x1101,
+
+	SFC_RAW_DATA_NEEDS_ENDSWAP		= 0x1110,
+
+	/* Support for Wavex Ambisonics Format */
+	SFC_WAVEX_SET_AMBISONIC			= 0x1200,
+	SFC_WAVEX_GET_AMBISONIC			= 0x1201,
+
+	SFC_SET_VBR_ENCODING_QUALITY	= 0x1300,
+
+	/* Following commands for testing only. */
+	SFC_TEST_IEEE_FLOAT_REPLACE		= 0x6001,
+
+	/*
+	** SFC_SET_ADD_* values are deprecated and will disappear at some
+	** time in the future. They are guaranteed to be here up to and
+	** including version 1.0.8 to avoid breakage of existng software.
+	** They currently do nothing and will continue to do nothing.
+	*/
+	SFC_SET_ADD_DITHER_ON_WRITE		= 0x1070,
+	SFC_SET_ADD_DITHER_ON_READ		= 0x1071
+} ;
+
+
+/*
+** String types that can be set and read from files. Not all file types
+** support this and even the file types which support one, may not support
+** all string types.
+*/
+
+enum
+{	SF_STR_TITLE					= 0x01,
+	SF_STR_COPYRIGHT				= 0x02,
+	SF_STR_SOFTWARE					= 0x03,
+	SF_STR_ARTIST					= 0x04,
+	SF_STR_COMMENT					= 0x05,
+	SF_STR_DATE						= 0x06,
+	SF_STR_ALBUM					= 0x07,
+	SF_STR_LICENSE					= 0x08,
+	SF_STR_TRACKNUMBER				= 0x09,
+	SF_STR_GENRE					= 0x10
+} ;
+
+/*
+** Use the following as the start and end index when doing metadata
+** transcoding.
+*/
+
+#define	SF_STR_FIRST	SF_STR_TITLE
+#define	SF_STR_LAST		SF_STR_GENRE
+
+enum
+{	/* True and false */
+	SF_FALSE	= 0,
+	SF_TRUE		= 1,
+
+	/* Modes for opening files. */
+	SFM_READ	= 0x10,
+	SFM_WRITE	= 0x20,
+	SFM_RDWR	= 0x30,
+
+	SF_AMBISONIC_NONE		= 0x40,
+	SF_AMBISONIC_B_FORMAT	= 0x41
+} ;
+
+/* Public error values. These are guaranteed to remain unchanged for the duration
+** of the library major version number.
+** There are also a large number of private error numbers which are internal to
+** the library which can change at any time.
+*/
+
+enum
+{	SF_ERR_NO_ERROR				= 0,
+	SF_ERR_UNRECOGNISED_FORMAT	= 1,
+	SF_ERR_SYSTEM				= 2,
+	SF_ERR_MALFORMED_FILE		= 3,
+	SF_ERR_UNSUPPORTED_ENCODING	= 4
+} ;
+
+
+/* Channel map values (used with SFC_SET/GET_CHANNEL_MAP).
+*/
+
+enum
+{	SF_CHANNEL_MAP_INVALID = 0,
+	SF_CHANNEL_MAP_MONO = 1,
+	SF_CHANNEL_MAP_LEFT,					/* Apple calls this 'Left' */
+	SF_CHANNEL_MAP_RIGHT,					/* Apple calls this 'Right' */
+	SF_CHANNEL_MAP_CENTER,					/* Apple calls this 'Center' */
+	SF_CHANNEL_MAP_FRONT_LEFT,
+	SF_CHANNEL_MAP_FRONT_RIGHT,
+	SF_CHANNEL_MAP_FRONT_CENTER,
+	SF_CHANNEL_MAP_REAR_CENTER,				/* Apple calls this 'Center Surround', Msft calls this 'Back Center' */
+	SF_CHANNEL_MAP_REAR_LEFT,				/* Apple calls this 'Left Surround', Msft calls this 'Back Left' */
+	SF_CHANNEL_MAP_REAR_RIGHT,				/* Apple calls this 'Right Surround', Msft calls this 'Back Right' */
+	SF_CHANNEL_MAP_LFE,						/* Apple calls this 'LFEScreen', Msft calls this 'Low Frequency'  */
+	SF_CHANNEL_MAP_FRONT_LEFT_OF_CENTER,	/* Apple calls this 'Left Center' */
+	SF_CHANNEL_MAP_FRONT_RIGHT_OF_CENTER,	/* Apple calls this 'Right Center */
+	SF_CHANNEL_MAP_SIDE_LEFT,				/* Apple calls this 'Left Surround Direct' */
+	SF_CHANNEL_MAP_SIDE_RIGHT,				/* Apple calls this 'Right Surround Direct' */
+	SF_CHANNEL_MAP_TOP_CENTER,				/* Apple calls this 'Top Center Surround' */
+	SF_CHANNEL_MAP_TOP_FRONT_LEFT,			/* Apple calls this 'Vertical Height Left' */
+	SF_CHANNEL_MAP_TOP_FRONT_RIGHT,			/* Apple calls this 'Vertical Height Right' */
+	SF_CHANNEL_MAP_TOP_FRONT_CENTER,		/* Apple calls this 'Vertical Height Center' */
+	SF_CHANNEL_MAP_TOP_REAR_LEFT,			/* Apple and MS call this 'Top Back Left' */
+	SF_CHANNEL_MAP_TOP_REAR_RIGHT,			/* Apple and MS call this 'Top Back Right' */
+	SF_CHANNEL_MAP_TOP_REAR_CENTER,			/* Apple and MS call this 'Top Back Center' */
+
+	SF_CHANNEL_MAP_AMBISONIC_B_W,
+	SF_CHANNEL_MAP_AMBISONIC_B_X,
+	SF_CHANNEL_MAP_AMBISONIC_B_Y,
+	SF_CHANNEL_MAP_AMBISONIC_B_Z,
+
+	SF_CHANNEL_MAP_MAX
+} ;
+
+
+/* A SNDFILE* pointer can be passed around much like stdio.h's FILE* pointer. */
+
+typedef	struct SNDFILE_tag	SNDFILE ;
+
+/* The following typedef is system specific and is defined when libsndfile is
+** compiled. sf_count_t will be a 64 bit value when the underlying OS allows
+** 64 bit file offsets.
+** On windows, we need to allow the same header file to be compiler by both GCC
+** and the Microsoft compiler.
+*/
+
+#if (defined (_MSCVER) || defined (_MSC_VER))
+typedef __int64		sf_count_t ;
+#define SF_COUNT_MAX		0x7fffffffffffffffi64
+#else
+typedef __int64	sf_count_t ;
+#define SF_COUNT_MAX		0x7FFFFFFFFFFFFFFFLL
+#endif
+
+
+/* A pointer to a SF_INFO structure is passed to sf_open () and filled in.
+** On write, the SF_INFO structure is filled in by the user and passed into
+** sf_open ().
+*/
+
+struct SF_INFO
+{	sf_count_t	frames ;		/* Used to be called samples.  Changed to avoid confusion. */
+	int			samplerate ;
+	int			channels ;
+	int			format ;
+	int			sections ;
+	int			seekable ;
+} ;
+
+typedef	struct SF_INFO SF_INFO ;
+
+/* The SF_FORMAT_INFO struct is used to retrieve information about the sound
+** file formats libsndfile supports using the sf_command () interface.
+**
+** Using this interface will allow applications to support new file formats
+** and encoding types when libsndfile is upgraded, without requiring
+** re-compilation of the application.
+**
+** Please consult the libsndfile documentation (particularly the information
+** on the sf_command () interface) for examples of its use.
+*/
+
+typedef struct
+{	int			format ;
+	const char	*name ;
+	const char	*extension ;
+} SF_FORMAT_INFO ;
+
+/*
+** Enums and typedefs for adding dither on read and write.
+** See the html documentation for sf_command(), SFC_SET_DITHER_ON_WRITE
+** and SFC_SET_DITHER_ON_READ.
+*/
+
+enum
+{	SFD_DEFAULT_LEVEL	= 0,
+	SFD_CUSTOM_LEVEL	= 0x40000000,
+
+	SFD_NO_DITHER		= 500,
+	SFD_WHITE			= 501,
+	SFD_TRIANGULAR_PDF	= 502
+} ;
+
+typedef struct
+{	int			type ;
+	double		level ;
+	const char	*name ;
+} SF_DITHER_INFO ;
+
+/* Struct used to retrieve information about a file embedded within a
+** larger file. See SFC_GET_EMBED_FILE_INFO.
+*/
+
+typedef struct
+{	sf_count_t	offset ;
+	sf_count_t	length ;
+} SF_EMBED_FILE_INFO ;
+
+/*
+**	Structs used to retrieve music sample information from a file.
+*/
+
+enum
+{	/*
+	**	The loop mode field in SF_INSTRUMENT will be one of the following.
+	*/
+	SF_LOOP_NONE = 800,
+	SF_LOOP_FORWARD,
+	SF_LOOP_BACKWARD,
+	SF_LOOP_ALTERNATING
+} ;
+
+typedef struct
+{	int gain ;
+	char basenote, detune ;
+	char velocity_lo, velocity_hi ;
+	char key_lo, key_hi ;
+	int loop_count ;
+
+	struct
+	{	int mode ;
+		unsigned int start ;
+		unsigned int end ;
+		unsigned int count ;
+	} loops [16] ; /* make variable in a sensible way */
+} SF_INSTRUMENT ;
+
+
+
+/* Struct used to retrieve loop information from a file.*/
+typedef struct
+{
+	short	time_sig_num ;	/* any positive integer    > 0  */
+	short	time_sig_den ;	/* any positive power of 2 > 0  */
+	int		loop_mode ;		/* see SF_LOOP enum             */
+
+	int		num_beats ;		/* this is NOT the amount of quarter notes !!!*/
+							/* a full bar of 4/4 is 4 beats */
+							/* a full bar of 7/8 is 7 beats */
+
+	float	bpm ;			/* suggestion, as it can be calculated using other fields:*/
+							/* file's lenght, file's sampleRate and our time_sig_den*/
+							/* -> bpms are always the amount of _quarter notes_ per minute */
+
+	int	root_key ;			/* MIDI note, or -1 for None */
+	int future [6] ;
+} SF_LOOP_INFO ;
+
+
+/*	Struct used to retrieve broadcast (EBU) information from a file.
+**	Strongly (!) based on EBU "bext" chunk format used in Broadcast WAVE.
+*/
+#define	SF_BROADCAST_INFO_VAR(coding_hist_size) \
+			struct \
+			{	char			description [256] ; \
+				char			originator [32] ; \
+				char			originator_reference [32] ; \
+				char			origination_date [10] ; \
+				char			origination_time [8] ; \
+				unsigned int	time_reference_low ; \
+				unsigned int	time_reference_high ; \
+				short			version ; \
+				char			umid [64] ; \
+				char			reserved [190] ; \
+				unsigned int	coding_history_size ; \
+				char			coding_history [coding_hist_size] ; \
+			}
+
+/* SF_BROADCAST_INFO is the above struct with coding_history field of 256 bytes. */
+typedef SF_BROADCAST_INFO_VAR (256) SF_BROADCAST_INFO ;
+
+
+/*	Virtual I/O functionality. */
+
+typedef sf_count_t		(*sf_vio_get_filelen)	(void *user_data) ;
+typedef sf_count_t		(*sf_vio_seek)		(sf_count_t offset, int whence, void *user_data) ;
+typedef sf_count_t		(*sf_vio_read)		(void *ptr, sf_count_t count, void *user_data) ;
+typedef sf_count_t		(*sf_vio_write)		(const void *ptr, sf_count_t count, void *user_data) ;
+typedef sf_count_t		(*sf_vio_tell)		(void *user_data) ;
+
+struct SF_VIRTUAL_IO
+{	sf_vio_get_filelen	get_filelen ;
+	sf_vio_seek			seek ;
+	sf_vio_read			read ;
+	sf_vio_write		write ;
+	sf_vio_tell			tell ;
+} ;
+
+typedef	struct SF_VIRTUAL_IO SF_VIRTUAL_IO ;
+
+
+/* Open the specified file for read, write or both. On error, this will
+** return a NULL pointer. To find the error number, pass a NULL SNDFILE
+** to sf_strerror ().
+** All calls to sf_open() should be matched with a call to sf_close().
+*/
+
+SNDFILE* 	sf_open		(const char *path, int mode, SF_INFO *sfinfo) ;
+
+
+/* Use the existing file descriptor to create a SNDFILE object. If close_desc
+** is TRUE, the file descriptor will be closed when sf_close() is called. If
+** it is FALSE, the descritor will not be closed.
+** When passed a descriptor like this, the library will assume that the start
+** of file header is at the current file offset. This allows sound files within
+** larger container files to be read and/or written.
+** On error, this will return a NULL pointer. To find the error number, pass a
+** NULL SNDFILE to sf_strerror ().
+** All calls to sf_open_fd() should be matched with a call to sf_close().
+
+*/
+
+SNDFILE* 	sf_open_fd	(int fd, int mode, SF_INFO *sfinfo, int close_desc) ;
+
+SNDFILE* 	sf_open_virtual	(SF_VIRTUAL_IO *sfvirtual, int mode, SF_INFO *sfinfo, void *user_data) ;
+
+
+/* sf_error () returns a error number which can be translated to a text
+** string using sf_error_number().
+*/
+
+int		sf_error		(SNDFILE *sndfile) ;
+
+
+/* sf_strerror () returns to the caller a pointer to the current error message for
+** the given SNDFILE.
+*/
+
+const char* sf_strerror (SNDFILE *sndfile) ;
+
+
+/* sf_error_number () allows the retrieval of the error string for each internal
+** error number.
+**
+*/
+
+const char*	sf_error_number	(int errnum) ;
+
+
+/* The following two error functions are deprecated but they will remain in the
+** library for the forseeable future. The function sf_strerror() should be used
+** in their place.
+*/
+
+int		sf_perror		(SNDFILE *sndfile) ;
+int		sf_error_str	(SNDFILE *sndfile, char* str, size_t len) ;
+
+
+/* Return TRUE if fields of the SF_INFO struct are a valid combination of values. */
+
+int		sf_command	(SNDFILE *sndfile, int command, void *data, int datasize) ;
+
+
+/* Return TRUE if fields of the SF_INFO struct are a valid combination of values. */
+
+int		sf_format_check	(const SF_INFO *info) ;
+
+
+/* Seek within the waveform data chunk of the SNDFILE. sf_seek () uses
+** the same values for whence (SEEK_SET, SEEK_CUR and SEEK_END) as
+** stdio.h function fseek ().
+** An offset of zero with whence set to SEEK_SET will position the
+** read / write pointer to the first data sample.
+** On success sf_seek returns the current position in (multi-channel)
+** samples from the start of the file.
+** Please see the libsndfile documentation for moving the read pointer
+** separately from the write pointer on files open in mode SFM_RDWR.
+** On error all of these functions return -1.
+*/
+
+sf_count_t	sf_seek 		(SNDFILE *sndfile, sf_count_t frames, int whence) ;
+
+
+/* Functions for retrieving and setting string data within sound files.
+** Not all file types support this features; AIFF and WAV do. For both
+** functions, the str_type parameter must be one of the SF_STR_* values
+** defined above.
+** On error, sf_set_string() returns non-zero while sf_get_string()
+** returns NULL.
+*/
+
+int sf_set_string (SNDFILE *sndfile, int str_type, const char* str) ;
+
+const char* sf_get_string (SNDFILE *sndfile, int str_type) ;
+
+
+/* Return the library version string. */
+
+const char * sf_version_string (void) ;
+
+
+/* Functions for reading/writing the waveform data of a sound file.
+*/
+
+sf_count_t	sf_read_raw		(SNDFILE *sndfile, void *ptr, sf_count_t bytes) ;
+sf_count_t	sf_write_raw 	(SNDFILE *sndfile, const void *ptr, sf_count_t bytes) ;
+
+
+/* Functions for reading and writing the data chunk in terms of frames.
+** The number of items actually read/written = frames * number of channels.
+**     sf_xxxx_raw		read/writes the raw data bytes from/to the file
+**     sf_xxxx_short	passes data in the native short format
+**     sf_xxxx_int		passes data in the native int format
+**     sf_xxxx_float	passes data in the native float format
+**     sf_xxxx_double	passes data in the native double format
+** All of these read/write function return number of frames read/written.
+*/
+
+sf_count_t	sf_readf_short	(SNDFILE *sndfile, short *ptr, sf_count_t frames) ;
+sf_count_t	sf_writef_short	(SNDFILE *sndfile, const short *ptr, sf_count_t frames) ;
+
+sf_count_t	sf_readf_int	(SNDFILE *sndfile, int *ptr, sf_count_t frames) ;
+sf_count_t	sf_writef_int 	(SNDFILE *sndfile, const int *ptr, sf_count_t frames) ;
+
+sf_count_t	sf_readf_float	(SNDFILE *sndfile, float *ptr, sf_count_t frames) ;
+sf_count_t	sf_writef_float	(SNDFILE *sndfile, const float *ptr, sf_count_t frames) ;
+
+sf_count_t	sf_readf_double		(SNDFILE *sndfile, double *ptr, sf_count_t frames) ;
+sf_count_t	sf_writef_double	(SNDFILE *sndfile, const double *ptr, sf_count_t frames) ;
+
+
+/* Functions for reading and writing the data chunk in terms of items.
+** Otherwise similar to above.
+** All of these read/write function return number of items read/written.
+*/
+
+sf_count_t	sf_read_short	(SNDFILE *sndfile, short *ptr, sf_count_t items) ;
+sf_count_t	sf_write_short	(SNDFILE *sndfile, const short *ptr, sf_count_t items) ;
+
+sf_count_t	sf_read_int		(SNDFILE *sndfile, int *ptr, sf_count_t items) ;
+sf_count_t	sf_write_int 	(SNDFILE *sndfile, const int *ptr, sf_count_t items) ;
+
+sf_count_t	sf_read_float	(SNDFILE *sndfile, float *ptr, sf_count_t items) ;
+sf_count_t	sf_write_float	(SNDFILE *sndfile, const float *ptr, sf_count_t items) ;
+
+sf_count_t	sf_read_double	(SNDFILE *sndfile, double *ptr, sf_count_t items) ;
+sf_count_t	sf_write_double	(SNDFILE *sndfile, const double *ptr, sf_count_t items) ;
+
+
+/* Close the SNDFILE and clean up all memory allocations associated with this
+** file.
+** Returns 0 on success, or an error number.
+*/
+
+int		sf_close		(SNDFILE *sndfile) ;
+
+
+/* If the file is opened SFM_WRITE or SFM_RDWR, call fsync() on the file
+** to force the writing of data to disk. If the file is opened SFM_READ
+** no action is taken.
+*/
+
+void	sf_write_sync	(SNDFILE *sndfile) ;
+
+
+
+/* The function sf_wchar_open() is Windows Only!
+** Open a file passing in a Windows Unicode filename. Otherwise, this is
+** the same as sf_open().
+**
+** In order for this to work, you need to do the following:
+**
+**		#include <windows.h>
+**		#define ENABLE_SNDFILE_WINDOWS_PROTOTYPES 1
+**		#including <sndfile.h>
+*/
+
+#if (defined (ENABLE_SNDFILE_WINDOWS_PROTOTYPES) && ENABLE_SNDFILE_WINDOWS_PROTOTYPES)
+SNDFILE* sf_wchar_open (LPCWSTR wpath, int mode, SF_INFO *sfinfo) ;
+#endif
+
+
+
+#ifdef __cplusplus
+}		/* extern "C" */
+#endif	/* __cplusplus */
+
+#endif	/* SNDFILE_H */
+

From a7cb7bbb9cbe9cc2a98c94e504c3ac44706adbb4 Mon Sep 17 00:00:00 2001
From: "alexey.lysiuk" <alexey.lysiuk@gmail.com>
Date: Mon, 17 Apr 2017 18:42:35 +0300
Subject: [PATCH 23/29] Backported changes from newer sndfile.h to fix non-MSVC
 compilation

---
 src/sound/thirdparty/sndfile.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/sound/thirdparty/sndfile.h b/src/sound/thirdparty/sndfile.h
index 49564e83f1..b5aa57fa76 100644
--- a/src/sound/thirdparty/sndfile.h
+++ b/src/sound/thirdparty/sndfile.h
@@ -30,6 +30,7 @@
 #define	SNDFILE_1
 
 #include <stdio.h>
+#include <stdint.h>
 #include <sys/types.h>
 
 #ifdef __cplusplus
@@ -315,7 +316,7 @@ typedef	struct SNDFILE_tag	SNDFILE ;
 typedef __int64		sf_count_t ;
 #define SF_COUNT_MAX		0x7fffffffffffffffi64
 #else
-typedef __int64	sf_count_t ;
+typedef int64_t	sf_count_t ;
 #define SF_COUNT_MAX		0x7FFFFFFFFFFFFFFFLL
 #endif
 

From 03b77c05051022fe60b8dd926e1bd91095e0bae4 Mon Sep 17 00:00:00 2001
From: "alexey.lysiuk" <alexey.lysiuk@gmail.com>
Date: Mon, 17 Apr 2017 19:21:57 +0300
Subject: [PATCH 24/29] Set names for mpg123 and sndfile macOS dynamic
 libraries

---
 src/sound/mpg123_decoder.cpp  | 2 +-
 src/sound/sndfile_decoder.cpp | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/sound/mpg123_decoder.cpp b/src/sound/mpg123_decoder.cpp
index 4aaac0025a..25a422f6b7 100644
--- a/src/sound/mpg123_decoder.cpp
+++ b/src/sound/mpg123_decoder.cpp
@@ -51,7 +51,7 @@ FModule MPG123Module{"MPG123"};
 #ifdef _WIN32
 #define MPG123LIB "libmpg123-0.dll"
 #elif defined(__APPLE__)
-#define MPG123LIB ""
+#define MPG123LIB "libmpg123.0.dylib"
 #else
 #define MPG123LIB "libmpg123.so.1"
 #endif
diff --git a/src/sound/sndfile_decoder.cpp b/src/sound/sndfile_decoder.cpp
index f905a980d7..c4c81c6b0b 100644
--- a/src/sound/sndfile_decoder.cpp
+++ b/src/sound/sndfile_decoder.cpp
@@ -53,7 +53,7 @@ FModule SndFileModule{"SndFile"};
 #ifdef _WIN32
 #define SNDFILELIB "libsndfile-1.dll"
 #elif defined(__APPLE__)
-#define SNDFILELIB ""
+#define SNDFILELIB "libsndfile.1.dylib"
 #else
 #define SNDFILELIB "libsndfile.so.1"
 #endif

From b6774e723bd570ef8be2d2f820e5b05bc0dec01a Mon Sep 17 00:00:00 2001
From: "alexey.lysiuk" <alexey.lysiuk@gmail.com>
Date: Tue, 18 Apr 2017 10:42:05 +0300
Subject: [PATCH 25/29] Fixed non-functional XInput support when built with
 modern Windows SDKs

https://mantis.zdoom.org/view.php?id=568
---
 src/win32/i_xinput.cpp | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/win32/i_xinput.cpp b/src/win32/i_xinput.cpp
index c6cd535a71..8b967746fb 100644
--- a/src/win32/i_xinput.cpp
+++ b/src/win32/i_xinput.cpp
@@ -671,8 +671,10 @@ FXInputManager::FXInputManager()
 		InputSetState = (XInputSetStateType)GetProcAddress(XInputDLL, "XInputSetState");
 		InputGetCapabilities = (XInputGetCapabilitiesType)GetProcAddress(XInputDLL, "XInputGetCapabilities");
 		InputEnable = (XInputEnableType)GetProcAddress(XInputDLL, "XInputEnable");
-		if (InputGetState == NULL || InputSetState == NULL || InputGetCapabilities == NULL ||
-			InputEnable == NULL)
+		// Treat XInputEnable() function as optional
+		// It is not available in xinput9_1_0.dll which is XINPUT_DLL in modern SDKs
+		// See https://msdn.microsoft.com/en-us/library/windows/desktop/hh405051(v=vs.85).aspx
+		if (InputGetState == NULL || InputSetState == NULL || InputGetCapabilities == NULL)
 		{
 			FreeLibrary(XInputDLL);
 			XInputDLL = NULL;
@@ -781,7 +783,7 @@ void FXInputManager::GetDevices(TArray<IJoystickConfig *> &sticks)
 
 bool FXInputManager::WndProcHook(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, LRESULT *result)
 {
-	if (message == WM_ACTIVATE)
+	if (nullptr != InputEnable && message == WM_ACTIVATE)
 	{
 		if (LOWORD(wParam) == WA_INACTIVE)
 		{

From 60a802b6bf401f84ee7e729ad6e42d0b8543ab32 Mon Sep 17 00:00:00 2001
From: "alexey.lysiuk" <alexey.lysiuk@gmail.com>
Date: Tue, 18 Apr 2017 10:45:22 +0300
Subject: [PATCH 26/29] Removed all dependencies from Appveyor configuration
 file

---
 .appveyor.yml | 21 ---------------------
 1 file changed, 21 deletions(-)

diff --git a/.appveyor.yml b/.appveyor.yml
index ef64bce499..c02cfca649 100644
--- a/.appveyor.yml
+++ b/.appveyor.yml
@@ -16,19 +16,6 @@ configuration:
   - Debug
   - Release
 
-cache:
-  - ci_deps_win_v01.zip
-
-environment:
-  # Update dependencies here: https://github.com/coelckers/gzdoom/releases/tag/ci_deps
-  DEPS_URL: https://github.com/coelckers/gzdoom/releases/download/ci_deps/
-  DEPS_FILENAME: ci_deps_win_v01.zip
-
-install:
-  - if not exist "%DEPS_FILENAME%"
-    appveyor DownloadFile "%DEPS_URL%%DEPS_FILENAME%"
-  - 7z x -y "%DEPS_FILENAME%"
-
 before_build:
   - md build
   - cd build
@@ -38,14 +25,6 @@ before_build:
   - set DEPS_LIB_DIR=%APPVEYOR_BUILD_FOLDER%\ci_deps_win\lib\%PLATFORM%
   - cmake -G "%CMAKE_GENERATOR_NAME%" -T "v140_xp"
     -DCMAKE_BUILD_TYPE="%CONFIGURATION%"
-    -DFMOD_INCLUDE_DIR="%DEPS_INCLUDE_DIR%"
-    -DFMOD_LIBRARY="%DEPS_LIB_DIR%\fmodex.lib"
-    -DOPENAL_INCLUDE_DIR="%DEPS_INCLUDE_DIR%"
-    -DOPENAL_LIBRARY="%DEPS_LIB_DIR%\OpenAL32.lib"
-    -DMPG123_INCLUDE_DIR="%DEPS_INCLUDE_DIR%"
-    -DMPG123_LIBRARIES="%DEPS_LIB_DIR%\libmpg123-0.lib"
-    -DSNDFILE_INCLUDE_DIR="%DEPS_INCLUDE_DIR%"
-    -DSNDFILE_LIBRARY="%DEPS_LIB_DIR%\libsndfile-1.lib"
     ..
 
 build:

From 11e6cfc4c2199354aab87004314674c6a388890a Mon Sep 17 00:00:00 2001
From: "alexey.lysiuk" <alexey.lysiuk@gmail.com>
Date: Tue, 18 Apr 2017 10:49:11 +0300
Subject: [PATCH 27/29] Removed dependencies from most of Travis configurations

---
 .travis.yml | 29 ++++-------------------------
 1 file changed, 4 insertions(+), 25 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 97211cc76c..6d4cc4bb79 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -14,15 +14,13 @@ matrix:
     - os: osx
       osx_image: xcode8.2
       env:
-        - CMAKE_OPTIONS="-DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_DEPLOYMENT_TARGET=10.7 -DFORCE_INTERNAL_ZLIB=YES -DFORCE_INTERNAL_JPEG=YES -DFORCE_INTERNAL_BZIP2=YES -DFORCE_INTERNAL_GME=YES"
-        - FMOD_LIBRARY=libfmodex.dylib
+        - CMAKE_OPTIONS="-DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_DEPLOYMENT_TARGET=10.7"
 
     - os: linux
       compiler: gcc
       env:
         - GCC_VERSION=5
         - CMAKE_OPTIONS="-DCMAKE_BUILD_TYPE=Release"
-        - FMOD_LIBRARY=libfmodex64.so
       addons:
         apt:
           sources:
@@ -30,19 +28,12 @@ matrix:
           packages:
             - g++-5
             - libsdl2-dev
-            - libgme-dev
-            - libopenal-dev
-            - libmpg123-dev
-            - libsndfile-dev
-            - libfluidsynth-dev
-            - libgtk-3-dev
 
     - os: linux
       compiler: gcc
       env:
         - GCC_VERSION=6
-        - CMAKE_OPTIONS="-DCMAKE_BUILD_TYPE=RelWithDebInfo -DDYN_FLUIDSYNTH=NO"
-        - FMOD_LIBRARY=libfmodex64.so
+        - CMAKE_OPTIONS="-DCMAKE_BUILD_TYPE=RelWithDebInfo"
       addons:
         apt:
           sources:
@@ -50,19 +41,12 @@ matrix:
           packages:
             - g++-6
             - libsdl2-dev
-            - libgme-dev
-            - libopenal-dev
-            - libmpg123-dev
-            - libsndfile-dev
-            - libfluidsynth-dev
-            - libgtk-3-dev
 
     - os: linux
       compiler: clang
       env:
         - CLANG_VERSION=3.9
-        - CMAKE_OPTIONS="-DCMAKE_BUILD_TYPE=Debug -DDYN_OPENAL=NO"
-        - FMOD_LIBRARY=libfmodex64.so
+        - CMAKE_OPTIONS="-DCMAKE_BUILD_TYPE=Debug -DDYN_OPENAL=NO -DDYN_SNDFILE=NO -DDYN_MPG123=NO -DDYN_FLUIDSYNTH=NO"
       addons:
         apt:
           sources:
@@ -80,21 +64,16 @@ matrix:
             - libgtk-3-dev
 
 before_install:
-  - if [ "$TRAVIS_OS_NAME" = "osx" ]; then brew update; brew install mpg123 libsndfile fluidsynth; fi
   - if [ -n "$GCC_VERSION" ]; then export CC="gcc-${GCC_VERSION}" CXX="g++-${GCC_VERSION}"; fi
   - if [ -n "$CLANG_VERSION" ]; then export CC="clang-${CLANG_VERSION}" CXX="clang++-${CLANG_VERSION}"; fi
   - $CC --version
   - $CXX --version
-  # Update dependencies here: https://github.com/coelckers/gzdoom/releases/tag/ci_deps
-  - export FMOD_FILENAME=fmod-4.44.64-${TRAVIS_OS_NAME}.tar.bz2
-  - curl -LO "https://github.com/coelckers/gzdoom/releases/download/ci_deps/${FMOD_FILENAME}"
-  - tar -xf "${FMOD_FILENAME}"
 
 script:
   - echo ${TRAVIS_BUILD_DIR}
   - mkdir build
   - cd build
-  - cmake ${CMAKE_OPTIONS} -DFMOD_INCLUDE_DIR="${TRAVIS_BUILD_DIR}/fmod/inc" -DFMOD_LIBRARY="${TRAVIS_BUILD_DIR}/fmod/lib/${FMOD_LIBRARY}" ..
+  - cmake ${CMAKE_OPTIONS} ..
   - make -j2
 
 notifications:

From 1d84b28fc2b7a2e1d3abbfb4f049024dc67da126 Mon Sep 17 00:00:00 2001
From: "alexey.lysiuk" <alexey.lysiuk@gmail.com>
Date: Tue, 18 Apr 2017 15:37:45 +0300
Subject: [PATCH 28/29] Added support for bool type in SetUserVariable() ACS
 function

https://mantis.zdoom.org/view.php?id=462
---
 src/p_acs.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/p_acs.cpp b/src/p_acs.cpp
index 58288d9e13..5af056e3e5 100644
--- a/src/p_acs.cpp
+++ b/src/p_acs.cpp
@@ -5040,7 +5040,7 @@ bool GetVarAddrType(AActor *self, FName varname, int index, void *&addr, PType *
 	}
 	addr = baddr;
 	// We don't want Int subclasses like Name or Color to be accessible here.
-	if (!type->isInt() && !type->isFloat())
+	if (!type->isInt() && !type->isFloat() && type != TypeBool)
 	{
 		// For reading, we also support Name and String types.
 		if (readonly && (type == TypeName || type == TypeString))

From 8db239d34f568ea8a660d24584992e64f47fc5ef Mon Sep 17 00:00:00 2001
From: "alexey.lysiuk" <alexey.lysiuk@gmail.com>
Date: Tue, 18 Apr 2017 16:40:31 +0300
Subject: [PATCH 29/29] Fixed build with NO_OPENAL defined

https://mantis.zdoom.org/view.php?id=596
---
 src/sound/oalsound.cpp | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/sound/oalsound.cpp b/src/sound/oalsound.cpp
index f173903ec0..f897e66b5d 100644
--- a/src/sound/oalsound.cpp
+++ b/src/sound/oalsound.cpp
@@ -122,6 +122,10 @@ void I_BuildALDeviceList(FOptionValues *opt)
 #endif
 }
 
+
+ReverbContainer *ForcedEnvironment;
+
+
 #ifndef NO_OPENAL
 
 
@@ -630,8 +634,6 @@ public:
 };
 
 
-ReverbContainer *ForcedEnvironment;
-
 #define AREA_SOUND_RADIUS  (32.f)
 
 #define PITCH_MULT (0.7937005f) /* Approx. 4 semitones lower; what Nash suggested */