[Scummvm-git-logs] scummvm master -> 22201ba764214a766f39f2df4d536b10132c127a

yinsimei roseline.yin at gmail.com
Sat Jul 15 17:52:19 CEST 2017


This automated email contains information about 11 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
c25a6ba4af SLUDGE: Complete snapshot
3672d99d4e SLUDGE: Complete parallax
cd384d10b2 SLUDGE: Add credit scrolling
d53c43d092 SLUDGE: Add a color into stack machine
8c8e5c44d8 SLUDGE: Remove openGl-related function fixFont
59f9157106 SLUDGE: Remove gl-related graphics.h
8c57d2d825 SLUDGE: Remove unused memwatch
a3876ee8c1 SLUDGE: Clean useless #if 0's
8963519346 SLUDGE: Clean unused extern variables
a44cf28ea3 SLUDGE: Remove unused function displayFatal
22201ba764 SLUDGE: Move PixelFormat init to constructor


Commit: c25a6ba4af63cf7f59cb0bd3945243b38607ff88
    https://github.com/scummvm/scummvm/commit/c25a6ba4af63cf7f59cb0bd3945243b38607ff88
Author: Simei Yin (roseline.yin at gmail.com)
Date: 2017-07-15T17:51:57+02:00

Commit Message:
SLUDGE: Complete snapshot

Changed paths:
    engines/sludge/backdrop.cpp
    engines/sludge/backdrop.h


diff --git a/engines/sludge/backdrop.cpp b/engines/sludge/backdrop.cpp
index 25008b0..84d68fb 100644
--- a/engines/sludge/backdrop.cpp
+++ b/engines/sludge/backdrop.cpp
@@ -32,6 +32,8 @@
 #include "sludge/fileset.h"
 #include "sludge/backdrop.h"
 #include "sludge/moreio.h"
+#include "sludge/statusba.h"
+#include "sludge/talk.h"
 #include "sludge/zbuffer.h"
 #include "sludge/graphics.h"
 #include "sludge/sludge.h"
@@ -61,6 +63,7 @@ extern int zBufferToSet;
 
 Graphics::Surface lightMap;
 Graphics::Surface backdropSurface;
+Graphics::Surface snapshotSurface;
 
 float snapTexW = 1.0;
 float snapTexH = 1.0;
@@ -77,127 +80,40 @@ extern int cameraX, cameraY;
 extern float cameraZoom;
 
 void nosnapshot() {
-#if 0
-	deleteTextures(1, &snapshotTextureName);
-	snapshotTextureName = 0;
-#endif
+	if (snapshotSurface.getPixels())
+		snapshotSurface.free();
 }
 
 void saveSnapshot(Common::WriteStream *stream) {
-#if 0
-	if (snapshotTextureName) {
+	if (snapshotSurface.getPixels()) {
 		stream->writeByte(1);               // 1 for snapshot follows
-		saveCoreHSI(stream, snapshotTextureName, winWidth, winHeight);
+		Image::writePNG(*stream, snapshotSurface);
 	} else {
 		stream->writeByte(0);
 	}
-#endif
 }
 
 bool snapshot() {
-
 	nosnapshot();
 	if (!freeze())
 		return false;
-#if 0
-	setPixelCoords(true);
-	glGenTextures(1, &snapshotTextureName);
-
-	int w = winWidth;
-	int h = winHeight;
-	if (!NPOT_textures) {
-		w = getNextPOT(winWidth);
-		h = getNextPOT(winHeight);
-		snapTexW = ((double)winWidth) / w;
-		snapTexH = ((double)winHeight) / h;
-	}
-
-	glBindTexture(GL_TEXTURE_2D, snapshotTextureName);
-	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
-	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
-	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
-	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
-
-	texImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, snapshotTextureName);
-
-	// Render scene
-	glDepthMask(GL_TRUE);
-	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);// Clear The Screen
-	glDepthMask(GL_FALSE);
 
-	drawBackDrop();// Draw the room
-	drawZBuffer(cameraX, cameraY, false);
-
-	glEnable(GL_DEPTH_TEST);
-
-	drawPeople();// Then add any moving characters...
-
-	glDisable(GL_DEPTH_TEST);
-
-	viewSpeech();// ...and anything being said
+	// draw snapshot to backdrop
+	displayBase();
+	viewSpeech(); // ...and anything being said
 	drawStatusBar();
-				 // Copy Our ViewPort To The Texture
-	copyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, viewportOffsetX, viewportOffsetY, winWidth, winHeight, snapshotTextureName);
 
-	setPixelCoords(false);
-#endif
+	// copy backdrop to snapshot
+	snapshotSurface.copyFrom(backdropSurface);
+
 	unfreeze(false);
 	return true;
 }
 
 bool restoreSnapshot(Common::SeekableReadStream *stream) {
-	uint picWidth = stream->readUint16BE();
-	uint picHeight = stream->readUint16BE();
-
-	if ((picWidth != winWidth) || (picHeight != winHeight))
+	if (!(ImgLoader::loadImage(stream, &snapshotSurface))) {
 		return false;
-#if 0
-	uint t1, t2, n;
-	uint16 c;
-	GLubyte *target;
-	if (!NPOT_textures) {
-		picWidth = getNextPOT(picWidth);
-		picHeight = getNextPOT(picHeight);
-		snapTexW = ((double)winWidth) / picWidth;
-		snapTexH = ((double)winHeight) / picHeight;
-	}
-	GLubyte *snapshotTexture = new GLubyte [picHeight * picWidth * 4];
-	if (!snapshotTexture) return fatal("Out of memory while restoring snapshot.");
-
-	for (t2 = 0; t2 < winHeight; t2++) {
-		t1 = 0;
-		while (t1 < winWidth) {
-			c = (uint16)stream->readUint16BE();
-			if (c & 32) {
-				n = stream->readByte() + 1;
-				c -= 32;
-			} else {
-				n = 1;
-			}
-
-			while (n --) {
-				target = snapshotTexture + 4 * picWidth * t2 + t1 * 4;
-				target[0] = (GLubyte) redValue(c);
-				target[1] = (GLubyte) greenValue(c);
-				target[2] = (GLubyte) blueValue(c);
-				target[3] = (GLubyte) 255;
-				t1++;
-			}
-		}
 	}
-
-	if (!snapshotTextureName) glGenTextures(1, &snapshotTextureName);
-	glBindTexture(GL_TEXTURE_2D, snapshotTextureName);
-	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
-	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
-	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
-	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
-
-	texImage2D(GL_TEXTURE_2D, 0, GL_RGBA, picWidth, picHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, snapshotTexture, snapshotTextureName);
-
-	delete snapshotTexture;
-	snapshotTexture = NULL;
-#endif
 	return true;
 }
 
diff --git a/engines/sludge/backdrop.h b/engines/sludge/backdrop.h
index dbab0df..14a31eb 100644
--- a/engines/sludge/backdrop.h
+++ b/engines/sludge/backdrop.h
@@ -58,9 +58,6 @@ void drawBackDrop();
 void blankScreen(int x1, int y1, int x2, int y2);
 void darkScreen();
 void saveHSI(Common::WriteStream *stream);
-#if 0
-void saveCoreHSI(Common::WriteStream *stream, GLuint texture, int w, int h);
-#endif
 bool loadHSI(Common::SeekableReadStream *stream, int, int, bool);
 bool mixHSI(Common::SeekableReadStream *stream, int x = 0, int y = 0);
 void drawHorizontalLine(uint, uint, uint);


Commit: 3672d99d4e8b892473723e867b7ad1cfcf095363
    https://github.com/scummvm/scummvm/commit/3672d99d4e8b892473723e867b7ad1cfcf095363
Author: Simei Yin (roseline.yin at gmail.com)
Date: 2017-07-15T17:51:57+02:00

Commit Message:
SLUDGE: Complete parallax

Changed paths:
    engines/sludge/backdrop.cpp
    engines/sludge/backdrop.h
    engines/sludge/freeze.cpp


diff --git a/engines/sludge/backdrop.cpp b/engines/sludge/backdrop.cpp
index 84d68fb..c23cd6a 100644
--- a/engines/sludge/backdrop.cpp
+++ b/engines/sludge/backdrop.cpp
@@ -389,46 +389,26 @@ inline int sortOutPCamera(int cX, int fX, int sceneMax, int boxMax) {
 void drawBackDrop() {
 	if (!backdropExists)
 		return;
-	renderSurface.copyRectToSurface(backdropSurface, 0, 0, Common::Rect(0, 0, backdropSurface.w, backdropSurface.h));
-#if 0
-	setPrimaryColor(1.0, 1.0, 1.0, 1.0);
-
-	//glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
-	glEnable(GL_BLEND);
 
-	glUseProgram(shader.smartScaler);
-	GLuint uniform = glGetUniformLocation(shader.smartScaler, "useLightTexture");
-	if (uniform >= 0) glUniform1i(uniform, 0);
-
-	setPMVMatrix(shader.smartScaler);
-
-	if (gameSettings.antiAlias == 1) {
-		glUniform1i(glGetUniformLocation(shader.smartScaler, "antialias"), 1);
-	} else {
-		glUniform1i(glGetUniformLocation(shader.smartScaler, "antialias"), 0);
-	}
+	// TODO: apply lightmap shader
 
+	// draw parallaxStuff
 	if (parallaxStuff) {
+		// TODO: simulate image repeating effect
+		warning("Drawing parallaxStuff");
+#if 0
 		parallaxLayer *ps = parallaxStuff;
 
+		// go to the parallax at bottom
 		while (ps->next) ps = ps->next;
 
+		// draw parallax one by one
 		while (ps) {
-			ps->cameraX = sortOutPCamera(cameraX, ps->fractionX, (int)(sceneWidth - (float)winWidth / cameraZoom), (int)(ps->width - (float)winWidth / cameraZoom));
-			ps->cameraY = sortOutPCamera(cameraY, ps->fractionY, (int)(sceneHeight - (float)winHeight / cameraZoom), (int)(ps->height - (float)winHeight / cameraZoom));
-			glBindTexture(GL_TEXTURE_2D, ps->textureName);
-
-			float w = (ps->wrapS) ? sceneWidth : ps->width;
-			float h = (ps->wrapT) ? sceneHeight : ps->height;
-			float texw;
-			float texh;
-			if (!NPOT_textures) {
-				texw = (ps->wrapS) ? (float) sceneWidth / ps->width : (float) ps->width / getNextPOT(ps->width);
-				texh = (ps->wrapT) ? (float) sceneHeight / ps->height : (float) ps->height / getNextPOT(ps->height);
-			} else {
-				texw = (ps->wrapS) ? (float) sceneWidth / ps->width : 1.0;
-				texh = (ps->wrapT) ? (float) sceneHeight / ps->height : 1.0;
-			}
+			ps->cameraX = sortOutPCamera(cameraX, ps->fractionX, (int)(sceneWidth - (float)winWidth / cameraZoom), (int)(ps->surface.w - (float)winWidth / cameraZoom));
+			ps->cameraY = sortOutPCamera(cameraY, ps->fractionY, (int)(sceneHeight - (float)winHeight / cameraZoom), (int)(ps->surface.h - (float)winHeight / cameraZoom));
+
+			uint w = (ps->wrapS) ? sceneWidth : ps->surface.w;
+			uint h = (ps->wrapT) ? sceneHeight : ps->surface.h;
 
 			const GLfloat vertices[] = {
 				(GLfloat) - ps->cameraX, (GLfloat) - ps->cameraY, 0.1f,
@@ -447,30 +427,12 @@ void drawBackDrop() {
 
 			ps = ps->prev;
 		}
+#endif
 	}
 
-	glBindTexture(GL_TEXTURE_2D, backdropTextureName);
-
-	const GLfloat backdropTexCoords[] = {
-		0.0f, 0.0f,
-		backdropTexW, 0.0f,
-		0.0f, backdropTexH,
-		backdropTexW, backdropTexH
-	};
-
-	const GLfloat vertices[] = {
-		(GLfloat) - cameraX, (GLfloat) - cameraY, 0.,
-		(GLfloat)sceneWidth - (GLfloat)cameraX, (GLfloat) - cameraY, 0.,
-		(GLfloat) - cameraX, (GLfloat)sceneHeight - (GLfloat)cameraY, 0.,
-		(GLfloat)sceneWidth - (GLfloat)cameraX, (GLfloat)sceneHeight - (GLfloat)cameraY, 0.
-	};
-
-	drawQuad(shader.smartScaler, vertices, 1, backdropTexCoords);
-
-	glDisable(GL_BLEND);
-
-	glUseProgram(0);
-#endif
+	// draw backdrop
+	Graphics::TransparentSurface tmp(backdropSurface, false);
+	tmp.blit(renderSurface, 0, 0);
 }
 
 bool loadLightMap(int v) {
@@ -578,22 +540,14 @@ bool loadParallax(uint16 v, uint16 fracX, uint16 fracY) {
 	}
 	nP->prev = NULL;
 
-#if 0
-	int picWidth;
-	int picHeight;
-
 	if (!ImgLoader::loadImage(bigDataFile, &nP->surface, 0))
 		return false;
 
-	if (!NPOT_textures) {
-		picWidth = getNextPOT(picWidth);
-		picHeight = getNextPOT(picHeight);
-	}
-
 	nP->fileNum = v;
 	nP->fractionX = fracX;
 	nP->fractionY = fracY;
 
+	// 65535 is the value of AUTOFIT constant in Sludge
 	if (fracX == 65535) {
 		nP->wrapS = false;
 		if (nP->surface.w < winWidth) {
@@ -614,27 +568,18 @@ bool loadParallax(uint16 v, uint16 fracX, uint16 fracY) {
 		nP->wrapT = true;
 	}
 
-	glGenTextures(1, &nP->textureName);
-	glBindTexture(GL_TEXTURE_2D, nP->textureName);
+	// TODO: reinterpret this part
+#if 0
 	if (nP->wrapS)
-	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
+		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
 	else
-	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
 	if (nP->wrapT)
-	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
+		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
 	else
-	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
-
-	if (gameSettings.antiAlias < 0) {
-		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
-	} else {
-		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
-		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
-	}
-
-	texImage2D(GL_TEXTURE_2D, 0, GL_RGBA, picWidth, picHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, nP->texture, nP->textureName);
+		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
 #endif
+
 	finishAccess();
 	setResourceForFatal(-1);
 	return true;
diff --git a/engines/sludge/backdrop.h b/engines/sludge/backdrop.h
index 14a31eb..30d5fe2 100644
--- a/engines/sludge/backdrop.h
+++ b/engines/sludge/backdrop.h
@@ -38,6 +38,12 @@ enum {
 extern uint winWidth, winHeight, sceneWidth, sceneHeight;
 extern int lightMapMode;
 
+
+/**
+ * parallax layers can scroll at different speeds
+ * to the background image, giving the illusion of
+ * depth to a scene as it moves.
+ */
 struct parallaxLayer {
 	Graphics::Surface surface;
 	int speedX, speedY;
@@ -77,7 +83,6 @@ extern Graphics::Surface lightMap;
 void killParallax();
 bool loadParallax(uint16 v, uint16 fracX, uint16 fracY);
 void saveParallaxRecursive(parallaxLayer *me, Common::WriteStream *fp);
-void reloadParallaxTextures();
 
 void nosnapshot();
 bool snapshot();
diff --git a/engines/sludge/freeze.cpp b/engines/sludge/freeze.cpp
index deaa4eb..01bc9a6 100644
--- a/engines/sludge/freeze.cpp
+++ b/engines/sludge/freeze.cpp
@@ -206,7 +206,6 @@ void unfreeze(bool killImage) {
 
 	killParallax();
 	parallaxStuff = frozenStuff->parallaxStuff;
-	reloadParallaxTextures();
 
 	deleteAnim(mouseCursorAnim);
 	mouseCursorAnim = frozenStuff->mouseCursorAnim;


Commit: cd384d10b2d48bce7e40674b287e77612bec7e34
    https://github.com/scummvm/scummvm/commit/cd384d10b2d48bce7e40674b287e77612bec7e34
Author: Simei Yin (roseline.yin at gmail.com)
Date: 2017-07-15T17:51:57+02:00

Commit Message:
SLUDGE: Add credit scrolling

Changed paths:
    engines/sludge/backdrop.cpp


diff --git a/engines/sludge/backdrop.cpp b/engines/sludge/backdrop.cpp
index c23cd6a..ac818893 100644
--- a/engines/sludge/backdrop.cpp
+++ b/engines/sludge/backdrop.cpp
@@ -62,6 +62,7 @@ bool backdropExists = false;
 extern int zBufferToSet;
 
 Graphics::Surface lightMap;
+Graphics::Surface OrigBackdropSurface;
 Graphics::Surface backdropSurface;
 Graphics::Surface snapshotSurface;
 
@@ -310,63 +311,28 @@ void blankScreen(int x1, int y1, int x2, int y2) {
 #endif
 }
 
+// This function is very useful for scrolling credits, but very little else
 void hardScroll(int distance) {
-	if (ABS(distance) >= (int)sceneHeight) {
-		blankScreen(0, 0, sceneWidth, sceneHeight);
-		return;
-	}
-
+	// scroll 0 distance, return
 	if (!distance)
 		return;
-#if 0
-	const GLfloat backdropTexCoords[] = {
-		0.0f, 0.0f,
-		backdropTexW, 0.0f,
-		0.0f, backdropTexH,
-		backdropTexW, backdropTexH
-	};
-
-	setPixelCoords(true);
-
-	uint xoffset = 0;
-	while (xoffset < sceneWidth) {
-		int w = (sceneWidth - xoffset < viewportWidth) ? sceneWidth - xoffset : viewportWidth;
 
-		uint yoffset = 0;
-		while (yoffset < sceneHeight) {
-			int h = (sceneHeight - yoffset < viewportHeight) ? sceneHeight - yoffset : viewportHeight;
-
-			glClear(GL_COLOR_BUFFER_BIT);   // Clear The Screen
-
-			// Render the backdrop
-			glBindTexture(GL_TEXTURE_2D, backdropTextureName);
-			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
-			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
-
-			const GLfloat vertices[] = {
-				(GLfloat) - xoffset, (GLfloat) - distance - yoffset, 0.,
-				(GLfloat)sceneWidth - xoffset, (GLfloat) - distance - yoffset, 0.,
-				(GLfloat) - xoffset, (GLfloat)sceneHeight - distance - yoffset, 0.,
-				(GLfloat)sceneWidth - xoffset, (GLfloat)sceneHeight - distance - yoffset, 0.
-			};
+	// blank screen
+	blankScreen(0, 0, sceneWidth, sceneHeight);
 
-			glUseProgram(shader.texture);
-
-			setPMVMatrix(shader.texture);
-
-			drawQuad(shader.texture, vertices, 1, backdropTexCoords);
-
-			glUseProgram(0);
-
-			// Copy Our ViewPort To The Texture
-			copyTexSubImage2D(GL_TEXTURE_2D, 0, xoffset, yoffset, viewportOffsetX, viewportOffsetY, w, h, backdropTextureName);
+	// scroll more than backdrop height, screen stay blank
+	if (ABS(distance) >= (int)sceneHeight) {
+		return;
+	}
 
-			yoffset += viewportHeight;
-		}
-		xoffset += viewportWidth;
+	// copy part of the backdrop to it
+	if (distance > 0) {
+		backdropSurface.copyRectToSurface(OrigBackdropSurface, 0, 0,
+				Common::Rect(0, distance, backdropSurface.w, backdropSurface.h));
+	} else {
+		backdropSurface.copyRectToSurface(OrigBackdropSurface, 0, -distance,
+				Common::Rect(0, 0, backdropSurface.w, backdropSurface.h + distance));
 	}
-	setPixelCoords(false);
-#endif
 }
 
 void drawVerticalLine(uint x, uint y1, uint y2) {
@@ -741,6 +707,7 @@ bool loadHSI(Common::SeekableReadStream *stream, int x, int y, bool reserve) {
 
 	deleteTextures(1, &tmpTex);
 #endif
+	OrigBackdropSurface.copyFrom(backdropSurface);
 	backdropExists = true;
 
 	return true;


Commit: d53c43d092ed505185ad30086ffb78f1b04332a3
    https://github.com/scummvm/scummvm/commit/d53c43d092ed505185ad30086ffb78f1b04332a3
Author: Simei Yin (roseline.yin at gmail.com)
Date: 2017-07-15T17:51:57+02:00

Commit Message:
SLUDGE: Add a color into stack machine

Changed paths:
    engines/sludge/backdrop.cpp


diff --git a/engines/sludge/backdrop.cpp b/engines/sludge/backdrop.cpp
index ac818893..c1830d8 100644
--- a/engines/sludge/backdrop.cpp
+++ b/engines/sludge/backdrop.cpp
@@ -924,7 +924,6 @@ void saveParallaxRecursive(parallaxLayer *me, Common::WriteStream *stream) {
 }
 
 bool getRGBIntoStack(uint x, uint y, stackHandler *sH) {
-#if 0
 	if (x >= sceneWidth || y >= sceneHeight) {
 		return fatal("Co-ordinates are outside current scene!");
 	}
@@ -933,25 +932,18 @@ bool getRGBIntoStack(uint x, uint y, stackHandler *sH) {
 
 	newValue.varType = SVT_NULL;
 
-	saveTexture(backdropTextureName, backdropTexture);
-
-	GLubyte *target;
-	if (!NPOT_textures) {
-		target = backdropTexture + 4 * getNextPOT(sceneWidth) * y + x * 4;
-	} else {
-		target = backdropTexture + 4 * sceneWidth * y + x * 4;
-	}
+	byte *target = (byte *)renderSurface.getBasePtr(x, y);
 
-	setVariable(newValue, SVT_INT, target[2]);
+	setVariable(newValue, SVT_INT, target[1]);
 	if (!addVarToStackQuick(newValue, sH->first)) return false;
 	sH->last = sH->first;
 
-	setVariable(newValue, SVT_INT, target[1]);
+	setVariable(newValue, SVT_INT, target[2]);
 	if (!addVarToStackQuick(newValue, sH->first)) return false;
 
-	setVariable(newValue, SVT_INT, target[0]);
+	setVariable(newValue, SVT_INT, target[3]);
 	if (!addVarToStackQuick(newValue, sH->first)) return false;
-#endif
+
 	return true;
 }
 


Commit: 8c8e5c44d8d84f27e2d41829364266c9968f4d98
    https://github.com/scummvm/scummvm/commit/8c8e5c44d8d84f27e2d41829364266c9968f4d98
Author: Simei Yin (roseline.yin at gmail.com)
Date: 2017-07-15T17:51:57+02:00

Commit Message:
SLUDGE: Remove openGl-related function fixFont

Changed paths:
    engines/sludge/builtin.cpp
    engines/sludge/fonttext.cpp
    engines/sludge/fonttext.h
    engines/sludge/statusba.cpp
    engines/sludge/talk.cpp


diff --git a/engines/sludge/builtin.cpp b/engines/sludge/builtin.cpp
index 9821eff..d93d8b4 100644
--- a/engines/sludge/builtin.cpp
+++ b/engines/sludge/builtin.cpp
@@ -889,7 +889,6 @@ builtIn(pasteString) {
 	trimStack(fun->stack);
 	if (x == IN_THE_CENTRE)
 		x = (winWidth - stringWidth(newText)) >> 1;
-	fixFont(pastePalette);
 	pasteStringToBackdrop(newText, x, y, pastePalette);
 	return BR_CONTINUE;
 }
@@ -2215,7 +2214,6 @@ builtIn(burnString) {
 	trimStack(fun->stack);
 	if (x == IN_THE_CENTRE)
 		x = (winWidth - stringWidth(newText)) >> 1;
-	fixFont(pastePalette);
 	burnStringToBackdrop(newText, x, y, pastePalette);
 	return BR_CONTINUE;
 }
diff --git a/engines/sludge/fonttext.cpp b/engines/sludge/fonttext.cpp
index 591e4a3..f1394b0 100644
--- a/engines/sludge/fonttext.cpp
+++ b/engines/sludge/fonttext.cpp
@@ -126,33 +126,6 @@ void burnStringToBackdrop(const Common::String &theText, int xOff, int y, sprite
 	}
 }
 
-void fixFont(spritePalette &spal) {
-#if 0
-	delete [] spal.tex_names;
-	delete [] spal.burnTex_names;
-	delete [] spal.tex_h;
-	delete [] spal.tex_w;
-
-	spal.numTextures = theFont.myPalette.numTextures;
-
-	spal.tex_names = new GLuint [spal.numTextures];
-	if (! checkNew(spal.tex_names)) return;
-	spal.burnTex_names = new GLuint [spal.numTextures];
-	if (! checkNew(spal.burnTex_names)) return;
-	spal.tex_w = new int [spal.numTextures];
-	if (! checkNew(spal.tex_w)) return;
-	spal.tex_h = new int [spal.numTextures];
-	if (! checkNew(spal.tex_h)) return;
-
-	for (int i = 0; i < theFont.myPalette.numTextures; i++) {
-		spal.tex_names[i] = theFont.myPalette.tex_names[i];
-		spal.burnTex_names[i] = theFont.myPalette.burnTex_names[i];
-		spal.tex_w[i] = theFont.myPalette.tex_w[i];
-		spal.tex_h[i] = theFont.myPalette.tex_h[i];
-	}
-#endif
-}
-
 void setFontColour(spritePalette &sP, byte r, byte g, byte b) {
 	sP.originalRed = r;
 	sP.originalGreen = g;
diff --git a/engines/sludge/fonttext.h b/engines/sludge/fonttext.h
index 4ddd614..3967770 100644
--- a/engines/sludge/fonttext.h
+++ b/engines/sludge/fonttext.h
@@ -28,7 +28,6 @@ namespace Sludge {
 
 bool loadFont(int filenum, const Common::String &charOrder, int);
 void pasteString(const Common::String &theText, int, int, spritePalette &);
-void fixFont(spritePalette &spal);
 void setFontColour(spritePalette &sP, byte r, byte g, byte b);
 int stringWidth(const Common::String &theText);
 int stringLength(const Common::String &theText);
diff --git a/engines/sludge/statusba.cpp b/engines/sludge/statusba.cpp
index 6bebb0d..79c4f01 100644
--- a/engines/sludge/statusba.cpp
+++ b/engines/sludge/statusba.cpp
@@ -88,8 +88,6 @@ void positionStatus(int x, int y) {
 void drawStatusBar() {
 	int y = nowStatus->statusY, n = 0;
 	statusBar *stat = nowStatus->firstStatusBar;
-	fixFont(litVerbLinePalette);
-	fixFont(verbLinePalette);
 	while (stat) {
 		switch (nowStatus->alignStatus) {
 		case IN_THE_CENTRE:
diff --git a/engines/sludge/talk.cpp b/engines/sludge/talk.cpp
index a1f51bb..4523a7f 100644
--- a/engines/sludge/talk.cpp
+++ b/engines/sludge/talk.cpp
@@ -203,7 +203,6 @@ int wrapSpeech(const Common::String &theText, int objT, int sampleFile, bool ani
 void viewSpeech() {
 	int viewY = speech->speechY;
 	speechLine *viewLine = speech->allSpeech;
-	fixFont(speech->talkCol);
 	while (viewLine) {
 		pasteString(viewLine->textLine, viewLine->x, viewY, speech->talkCol);
 		viewY -= fontHeight / cameraZoom;


Commit: 59f915710679f007f99a33caadf30aee44d6f37a
    https://github.com/scummvm/scummvm/commit/59f915710679f007f99a33caadf30aee44d6f37a
Author: Simei Yin (roseline.yin at gmail.com)
Date: 2017-07-15T17:51:57+02:00

Commit Message:
SLUDGE: Remove gl-related graphics.h

Changed paths:
  R engines/sludge/graphics.cpp
  R engines/sludge/graphics.h
    engines/sludge/backdrop.cpp
    engines/sludge/backdrop.h
    engines/sludge/bg_effects.cpp
    engines/sludge/builtin.cpp
    engines/sludge/freeze.cpp
    engines/sludge/main_loop.cpp
    engines/sludge/module.mk
    engines/sludge/movie.cpp
    engines/sludge/newfatal.cpp
    engines/sludge/sludger.cpp
    engines/sludge/sprites.cpp
    engines/sludge/thumbnail.cpp
    engines/sludge/transition.cpp
    engines/sludge/zbuffer.cpp


diff --git a/engines/sludge/backdrop.cpp b/engines/sludge/backdrop.cpp
index c1830d8..f0ab6ef 100644
--- a/engines/sludge/backdrop.cpp
+++ b/engines/sludge/backdrop.cpp
@@ -35,7 +35,6 @@
 #include "sludge/statusba.h"
 #include "sludge/talk.h"
 #include "sludge/zbuffer.h"
-#include "sludge/graphics.h"
 #include "sludge/sludge.h"
 #include "sludge/sludger.h"
 #include "sludge/variable.h"
@@ -69,6 +68,7 @@ Graphics::Surface snapshotSurface;
 float snapTexW = 1.0;
 float snapTexH = 1.0;
 
+uint winWidth, winHeight;
 int lightMapMode = LIGHTMAPMODE_PIXEL;
 parallaxLayer *parallaxStuff = NULL;
 int cameraPX = 0, cameraPY = 0;
@@ -164,7 +164,6 @@ bool reserveBackdrop() {
 	cameraZoom = 1.0;
 	input.mouseX = (int)((float)input.mouseX / cameraZoom);
 	input.mouseY = (int)((float)input.mouseY / cameraZoom);
-	setPixelCoords(false);
 #if 0
 	int picWidth = sceneWidth;
 	int picHeight = sceneHeight;
diff --git a/engines/sludge/backdrop.h b/engines/sludge/backdrop.h
index 30d5fe2..d239356 100644
--- a/engines/sludge/backdrop.h
+++ b/engines/sludge/backdrop.h
@@ -23,7 +23,8 @@
 #ifndef SLUDGE_BACKDROP_H
 #define SLUDGE_BACKDROP_H
 
-#include "sludge/graphics.h"
+#include "graphics/surface.h"
+
 #include "sludge/variable.h"
 
 namespace Sludge {
diff --git a/engines/sludge/bg_effects.cpp b/engines/sludge/bg_effects.cpp
index 0ec538d..0168e91 100644
--- a/engines/sludge/bg_effects.cpp
+++ b/engines/sludge/bg_effects.cpp
@@ -25,7 +25,6 @@
 
 #include "sludge/allfiles.h"
 #include "sludge/backdrop.h"
-#include "sludge/graphics.h"
 #include "sludge/moreio.h"
 #include "sludge/newfatal.h"
 
diff --git a/engines/sludge/builtin.cpp b/engines/sludge/builtin.cpp
index d93d8b4..61590a5 100644
--- a/engines/sludge/builtin.cpp
+++ b/engines/sludge/builtin.cpp
@@ -48,7 +48,6 @@
 #include "sludge/freeze.h"
 #include "sludge/language.h"
 #include "sludge/thumbnail.h"
-#include "sludge/graphics.h"
 #include "sludge/sludge.h"
 #include "sludge/utf8.h"
 
@@ -492,7 +491,6 @@ builtIn(zoomCamera) {
 		cameraZoom = (float)winWidth / sceneWidth;
 	if ((float)winHeight / cameraZoom > sceneHeight)
 		cameraZoom = (float)winHeight / sceneHeight;
-	setPixelCoords(false);
 
 	input.mouseX = input.mouseX / cameraZoom;
 	input.mouseY = input.mouseY / cameraZoom;
@@ -965,7 +963,6 @@ builtIn(launch) {
 		if (g_sludge->launchMe.empty())
 			return BR_ERROR;
 	}
-	setGraphicsWindow(false);
 	setVariable(fun->reg, SVT_INT, 1);
 	launchResult = &fun->reg;
 
diff --git a/engines/sludge/freeze.cpp b/engines/sludge/freeze.cpp
index 01bc9a6..35dcd56 100644
--- a/engines/sludge/freeze.cpp
+++ b/engines/sludge/freeze.cpp
@@ -20,7 +20,6 @@
  *
  */
 #include "sludge/allfiles.h"
-#include "sludge/graphics.h"
 #include "sludge/newfatal.h"
 #include "sludge/sprites.h"
 #include "sludge/sprbanks.h"
@@ -87,12 +86,6 @@ bool freeze() {
 
 	// Grab a copy of the current scene
 	freezeGraphics();
-	int picWidth = sceneWidth;
-	int picHeight = sceneHeight;
-	if (!NPOT_textures) {
-		picWidth = getNextPOT(picWidth);
-		picHeight = getNextPOT(picHeight);
-	}
 	newFreezer->backdropSurface.copyFrom(backdropSurface);
 	newFreezer->sceneWidth = sceneWidth;
 	newFreezer->sceneHeight = sceneHeight;
@@ -175,7 +168,6 @@ void unfreeze(bool killImage) {
 	cameraZoom = frozenStuff->cameraZoom;
 	input.mouseX = (int)(input.mouseX / cameraZoom);
 	input.mouseY = (int)(input.mouseY / cameraZoom);
-	setPixelCoords(false);
 
 	killAllPeople();
 	allPeople = frozenStuff->allPeople;
diff --git a/engines/sludge/graphics.cpp b/engines/sludge/graphics.cpp
deleted file mode 100644
index d43ae4e..0000000
--- a/engines/sludge/graphics.cpp
+++ /dev/null
@@ -1,500 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * 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 2
- * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#include "sludge/allfiles.h"
-#include "sludge/graphics.h"
-#include "sludge/language.h"
-#include "sludge/newfatal.h"
-#include "sludge/sprbanks.h"
-#include "sludge/zbuffer.h"
-#include "sludge/backdrop.h"
-#include "sludge/movie.h"
-
-namespace Sludge {
-
-uint winWidth, winHeight;
-int viewportHeight, viewportWidth;
-int viewportOffsetX = 0, viewportOffsetY = 0;
-
-extern float cameraZoom;
-
-bool NPOT_textures = true;
-
-extern int specialSettings;
-
-void setMovieViewport();
-
-extern uint sceneWidth, sceneHeight;
-extern zBufferData zBuffer;
-extern int lightMapNumber;
-
-// This is for swapping settings between rendering to texture or to the screen
-void setPixelCoords(bool pixels) {
-#if 0
-	static int current = -1;
-//	if (current == pixels) return;
-	current = pixels;
-
-	glBindTexture(GL_TEXTURE_2D, backdropTextureName);
-
-	if (pixels) {
-
-		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
-		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
-
-		glClear(GL_COLOR_BUFFER_BIT);
-
-		const GLfloat bPMVMatrix[] = {
-			2.0f / viewportWidth, .0, .0, .0,
-			.0, 2.0f / viewportHeight, .0, .0,
-			.0, .0, 1.0f, .0,
-			-1.0, -1.0f, .0, 1.0f
-
-		};
-		for (int i = 0; i < 16; i++) {
-			aPMVMatrix[i] = bPMVMatrix[i];
-		}
-	} else {
-		if (gameSettings.antiAlias < 0) {
-			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
-		} else {
-			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
-			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
-		}
-
-		GLfloat w = (GLfloat) winWidth / cameraZoom;
-		GLfloat h = (GLfloat) winHeight / cameraZoom;
-
-		const GLfloat bPMVMatrix[] = {
-			2.0f / w, .0, .0, .0,
-			.0, -2.0f / h, .0, .0,
-			.0, .0, 1.0f, .0,
-			-1.0, 1.0f, .0, 1.0f
-
-		};
-		for (int i = 0; i < 16; i++) {
-			aPMVMatrix[i] = bPMVMatrix[i];
-		}
-	}
-#endif
-}
-
-// This is for setting windowed or fullscreen graphics.
-// Used for switching, and for initial window creation.
-void setGraphicsWindow(bool fullscreen, bool restoreGraphics, bool resize) {
-#if defined(PANDORA)
-	fullscreen = true;
-#endif
-#if 0
-	GLubyte *snapTexture = NULL;
-
-	Uint32 videoflags = 0;
-
-	if (! desktopW) {
-
-		// Get video hardware information
-		const SDL_VideoInfo *videoInfo = SDL_GetVideoInfo();
-		desktopW = videoInfo->current_w;
-		desktopH = videoInfo->current_h;
-
-	} else if (restoreGraphics && fullscreen == runningFullscreen & ! resize) return;
-
-	runningFullscreen = fullscreen;
-
-	if (restoreGraphics) {
-		/*
-		 * Save the textures
-		 */
-		if (backdropTextureName) {
-			if (backdropTexture) delete backdropTexture;
-			int picWidth = sceneWidth;
-			int picHeight = sceneHeight;
-			if (! NPOT_textures) {
-				picWidth = getNextPOT(picWidth);
-				picHeight = getNextPOT(picHeight);
-			}
-			backdropTexture = new GLubyte [picHeight * picWidth * 4];
-			if (! checkNew(backdropTexture)) return;
-
-			saveTexture(backdropTextureName, backdropTexture);
-		}
-		if (snapshotTextureName) {
-			int picWidth = winWidth;
-			int picHeight = winHeight;
-			if (! NPOT_textures) {
-				picWidth = getNextPOT(picWidth);
-				picHeight = getNextPOT(picHeight);
-			}
-			snapTexture = new GLubyte [picHeight * picWidth * 4];
-			if (! checkNew(snapTexture)) return;
-
-			saveTexture(snapshotTextureName, snapTexture);
-		}
-	}
-
-	/*
-	 * Set the graphics mode
-	 */
-	float winAspect = (float) winWidth / winHeight;
-
-	if (fullscreen) {
-		specialSettings &= ~SPECIAL_INVISIBLE;
-
-		videoflags = SDL_SWSURFACE | SDL_FULLSCREEN;
-
-		if (gameSettings.fixedPixels) {
-			viewportWidth = realWinWidth = winWidth;
-			viewportHeight = realWinHeight = winHeight;
-			viewportOffsetY = 0;
-			viewportOffsetX = 0;
-		} else {
-			realWinWidth = desktopW;
-			realWinHeight = desktopH;
-
-			float realAspect = (float) realWinWidth / realWinHeight;
-
-			if (realAspect > winAspect) {
-				viewportHeight = realWinHeight;
-				viewportWidth = (int)(realWinHeight * winAspect);
-				viewportOffsetY = 0;
-				viewportOffsetX = (realWinWidth - viewportWidth) / 2;
-			} else {
-				viewportWidth = realWinWidth;
-				viewportHeight = (int)((float) realWinWidth / winAspect);
-				viewportOffsetY = (realWinHeight - viewportHeight) / 2;
-				viewportOffsetX = 0;
-			}
-		}
-
-	} else {
-		videoflags = SDL_SWSURFACE;
-
-		if (resize) {
-			float realAspect = (float) desktopW / desktopH;
-
-			if (realAspect > winAspect) {
-				realWinWidth = (int)(realWinHeight * winAspect);
-			} else {
-				realWinHeight = (int)(realWinWidth / winAspect);
-			}
-
-			realAspect = (float) realWinWidth / realWinHeight;
-
-			if (realAspect > winAspect) {
-				viewportHeight = realWinHeight;
-				viewportWidth = (int)(realWinHeight * winAspect);
-				viewportOffsetY = 0;
-				viewportOffsetX = (realWinWidth - viewportWidth) / 2;
-			} else {
-				viewportWidth = realWinWidth;
-				viewportHeight = (int)((float) realWinWidth / winAspect);
-				viewportOffsetY = (realWinHeight - viewportHeight) / 2;
-				viewportOffsetX = 0;
-			}
-		} else {
-
-			if (gameSettings.fixedPixels) {
-				viewportWidth = realWinWidth = winWidth;
-				viewportHeight = realWinHeight = winHeight;
-				viewportOffsetY = 0;
-				viewportOffsetX = 0;
-			} else {
-				realWinHeight = desktopH * 3 / 4;
-				realWinWidth = (int)(realWinHeight * winAspect);
-
-				if (realWinWidth > desktopW) {
-					realWinWidth = desktopW;
-					realWinHeight = (int)((float) realWinWidth / winAspect);
-				}
-
-				viewportHeight = realWinHeight;
-				viewportWidth = realWinWidth;
-				viewportOffsetY = 0;
-				viewportOffsetX = 0;
-			}
-		}
-	}
-
-	debugHeader();
-
-	if (SDL_SetVideoMode(realWinWidth, realWinHeight, 32, videoflags) == 0) {
-		msgBox("Startup Error: Couldn't set video mode.", SDL_GetError());
-		SDL_Quit();
-		exit(2);
-	}
-	debugOut("Video mode %d %d set successfully.\n", realWinWidth, realWinHeight);
-
-	if (EGL_Open()) {
-		msgBox("Startup Error", "Couldn't initialize EGL.");
-		SDL_Quit();
-		exit(1);
-	}
-	EGL_Init();
-
-	GLint uniform;
-	const char *Vertex;
-	const char *Fragment;
-
-	Vertex = shaderFileRead("scale.vert");
-
-	/*  const GLubyte *str;
-	 int glDerivativesAvailable;
-	 str = glGetString (GL_EXTENSIONS);
-	 glDerivativesAvailable = (strstr((const char *)str, "GL_OES_standard_derivatives") != NULL);
-	 if (!glDerivativesAvailable) {
-	 debugOut("Extension \"GL_OES_standard_derivatives\" not available. Advanced anti-aliasing is not possible. Using linear anti-aliasing instead.");
-	 gameSettings.antiAlias = -1;
-	 */
-	Fragment = shaderFileRead("scale_noaa.frag");
-//	}
-
-	Fragment = joinStrings("precision mediump float;\n", Fragment);
-
-	if (! Vertex || ! Fragment) {
-		fatal("Error loading \"scale\" shader program!", "Try re-installing the game. (scale.frag, scale_noaa.frag or scale.vert was not found.)");
-		gameSettings.antiAlias = -1;
-		shader.smartScaler = 0;
-	} else {
-
-		shader.smartScaler = buildShaders(Vertex, Fragment);
-
-		if (! shader.smartScaler) {
-			fatal("Error building \"scale\" shader program!");
-			gameSettings.antiAlias = -1;
-			shader.smartScaler = 0;
-		} else {
-			debugOut("Built shader program: %d (smartScaler)\n", shader.smartScaler);
-
-			glUseProgram(shader.smartScaler);
-			uniform = glGetUniformLocation(shader.smartScaler, "Texture");
-			if (uniform >= 0) glUniform1i(uniform, 0);
-			uniform = glGetUniformLocation(shader.smartScaler, "lightTexture");
-			if (uniform >= 0) glUniform1i(uniform, 1);
-			uniform = glGetUniformLocation(shader.smartScaler, "useLightTexture");
-			if (uniform >= 0) glUniform1i(uniform, 0);
-			uniform = glGetUniformLocation(shader.smartScaler, "antialias");
-			if (uniform >= 0) glUniform1i(uniform, 0);
-			uniform = glGetUniformLocation(shader.smartScaler, "scale");
-
-			float scale = (float)realWinWidth / (float)winWidth * 0.25;
-			if (scale > 1.0) scale = 1.0;
-			if (uniform >= 0) glUniform1f(uniform, scale);
-
-		}
-	}
-
-	Vertex = shaderFileRead("fixScaleSprite.vert");
-	Fragment = shaderFileRead("fixScaleSprite.frag");
-
-	Fragment = joinStrings("precision mediump float;\n", Fragment);
-
-	if (! Vertex || ! Fragment) {
-		fatal("Error loading \"fixScaleSprite\" shader program!", "Try re-installing the game. (fixScaleSprite.frag or fixScaleSprite.vert was not found.)");
-		shader.paste = 0;
-	} else {
-
-		shader.paste = buildShaders(Vertex, Fragment);
-		if (! shader.paste) {
-			fatal("Error building \"fixScaleSprite\" shader program!");
-		} else {
-			debugOut("Built shader program: %d (fixScaleSprite)\n", shader.paste);
-
-			glUseProgram(shader.paste);
-			uniform = glGetUniformLocation(shader.paste, "tex0");
-			if (uniform >= 0) glUniform1i(uniform, 0);
-			uniform = glGetUniformLocation(shader.paste, "tex1");
-			if (uniform >= 0) glUniform1i(uniform, 1);
-			uniform = glGetUniformLocation(shader.paste, "tex2");
-			if (uniform >= 0) glUniform1i(uniform, 2);
-			uniform = glGetUniformLocation(shader.paste, "useLightTexture");
-			if (uniform >= 0) glUniform1i(uniform, 0);
-
-		}
-	}
-
-	Vertex = shaderFileRead("yuv.vert");
-	Fragment = shaderFileRead("yuv.frag");
-
-	Fragment = joinStrings("precision mediump float;\n", Fragment);
-
-	if (! Vertex || ! Fragment) {
-		fatal("Error loading \"yuv\" shader program!", "Try re-installing the game. (yuv.frag or yuv.vert was not found.)");
-		shader.yuv = 0;
-	} else {
-
-		shader.yuv = buildShaders(Vertex, Fragment);
-		if (! shader.yuv) {
-			fatal("Error building \"yuv\" shader program!");
-		} else {
-			debugOut("Built shader program: %d (yuv)\n", shader.yuv);
-
-			glUseProgram(shader.yuv);
-			uniform = glGetUniformLocation(shader.yuv, "Ytex");
-			if (uniform >= 0) glUniform1i(uniform, 0);
-			uniform = glGetUniformLocation(shader.yuv, "Utex");
-			if (uniform >= 0) glUniform1i(uniform, 1);
-			uniform = glGetUniformLocation(shader.yuv, "Vtex");
-			if (uniform >= 0) glUniform1i(uniform, 2);
-
-		}
-	}
-
-	Vertex = shaderFileRead("texture.vert");
-	Fragment = shaderFileRead("texture.frag");
-
-	Fragment = joinStrings("precision mediump float;\n", Fragment);
-
-	if (! Vertex || ! Fragment) {
-		fatal("Error loading \"texture\" shader program!", "Try re-installing the game. (texture.frag or texture.vert was not found.)");
-		shader.texture = 0;
-	} else {
-
-		shader.texture = buildShaders(Vertex, Fragment);
-		if (! shader.texture) {
-			fatal("Error building \"texture\" shader program!");
-		} else {
-			debugOut("Built shader program: %d (texture)\n", shader.texture);
-
-			glUseProgram(shader.texture);
-			uniform = glGetUniformLocation(shader.texture, "sampler2d");
-			if (uniform >= 0) glUniform1i(uniform, 0);
-			uniform = glGetUniformLocation(shader.texture, "zBuffer");
-			if (uniform >= 0) glUniform1i(uniform, 0);
-			uniform = glGetUniformLocation(shader.texture, "zBufferLayer");
-			if (uniform >= 0) glUniform1f(uniform, 0.);
-			uniform = glGetUniformLocation(shader.texture, "modulateColor");
-			if (uniform >= 0) glUniform1i(uniform, 0);
-		}
-	}
-
-	Vertex = shaderFileRead("color.vert");
-	Fragment = shaderFileRead("color.frag");
-
-	Fragment = joinStrings("precision mediump float;\n", Fragment);
-
-	if (! Vertex || ! Fragment) {
-		fatal("Error loading \"color\" shader program!", "Try re-installing the game. (color.frag or color.vert was not found.)");
-		shader.color = 0;
-	} else {
-
-		shader.color = buildShaders(Vertex, Fragment);
-		if (! shader.color) {
-			fatal("Error building \"color\" shader program!");
-		} else {
-			debugOut("Built shader program: %d (color)\n", shader.color);
-			glUseProgram(shader.color);
-		}
-	}
-	glUseProgram(0);
-
-	glViewport(viewportOffsetX, viewportOffsetY, viewportWidth, viewportHeight);
-
-	/*
-	 * Set up OpenGL for 2D rendering.
-	 */
-	glDisable(GL_DEPTH_TEST);
-	glDisable(GL_CULL_FACE);
-	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-	setPixelCoords(false);
-
-	glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
-	if (restoreGraphics) {
-		/*
-		 * Restore the textures
-		 */
-		if (backdropTextureName) {
-			if (!glIsTexture(backdropTextureName)) {
-				glGenTextures(1, &backdropTextureName);
-			}
-			glBindTexture(GL_TEXTURE_2D, backdropTextureName);
-			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
-			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
-
-			if (gameSettings.antiAlias < 0) {
-				glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-				glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
-			} else {
-				glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
-				glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
-			}
-			// Restore the backdrop
-			texImage2D(GL_TEXTURE_2D, 0, GL_RGBA, sceneWidth, sceneHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, backdropTexture, backdropTextureName);
-
-		}
-		if (snapshotTextureName) {
-			if (!glIsTexture(snapshotTextureName)) {
-				glGenTextures(1, &snapshotTextureName);
-			}
-			glBindTexture(GL_TEXTURE_2D, snapshotTextureName);
-			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
-			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
-
-			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
-			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
-
-			// Restore the backdrop
-			texImage2D(GL_TEXTURE_2D, 0, GL_RGBA, winWidth, winHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, snapTexture, snapshotTextureName);
-			delete snapTexture;
-		}
-
-		if (yTextureName) {
-			if (!glIsTexture(yTextureName)) {
-				glGenTextures(1, &yTextureName);
-				glGenTextures(1, &uTextureName);
-				glGenTextures(1, &vTextureName);
-			}
-		}
-
-		reloadSpriteTextures();
-		reloadParallaxTextures();
-		zBuffer.texName = 0;
-		if (zBuffer.numPanels) {
-			setZBuffer(zBuffer.originalNum);
-		}
-		lightMap.name = 0;
-		if (lightMapNumber) {
-			loadLightMap(lightMapNumber);
-		}
-
-		sludgeDisplay();
-	}
-
-	if (movieIsPlaying)
-	setMovieViewport();
-#endif
-}
-
-// I found this function on a coding forum on the 'net.
-// Looks a bit weird, but it should work.
-int getNextPOT(int n) {
-	--n;
-	n |= n >> 16;
-	n |= n >> 8;
-	n |= n >> 4;
-	n |= n >> 2;
-	n |= n >> 1;
-	++n;
-	return n;
-}
-
-} // End of namespace Sludge
diff --git a/engines/sludge/graphics.h b/engines/sludge/graphics.h
deleted file mode 100644
index 463d384..0000000
--- a/engines/sludge/graphics.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * 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 2
- * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-#ifndef SLUDGE_GRAPHICS_H
-#define SLUDGE_GRAPHICS_H
-
-#include "graphics/surface.h"
-
-namespace Sludge {
-
-extern uint winWidth, winHeight;
-extern int viewportHeight, viewportWidth;
-extern int viewportOffsetX, viewportOffsetY;
-extern int realWinWidth, realWinHeight;
-
-extern bool NPOT_textures;
-
-void setPixelCoords(bool pixels);
-void setGraphicsWindow(bool fullscreen, bool restoreGraphics = true, bool resize = false);
-
-int getNextPOT(int n);
-
-}
- // End of namespace Sludge
-
-#endif
diff --git a/engines/sludge/main_loop.cpp b/engines/sludge/main_loop.cpp
index 614d3a9..51b3913 100644
--- a/engines/sludge/main_loop.cpp
+++ b/engines/sludge/main_loop.cpp
@@ -43,7 +43,6 @@
 #include "sludge/timing.h"
 #include "sludge/sound.h"
 #include "sludge/sludger.h"
-#include "sludge/graphics.h"
 #include "sludge/helpers.h"
 #include "sludge/sludge.h"
 #include "sludge/specialsettings.h"
diff --git a/engines/sludge/module.mk b/engines/sludge/module.mk
index f96a5b6..704f7f7 100644
--- a/engines/sludge/module.mk
+++ b/engines/sludge/module.mk
@@ -11,7 +11,6 @@ MODULE_OBJS := \
 	floor.o \
 	freeze.o \
 	fonttext.o \
-	graphics.o \
 	helpers.o \
 	hsi.o \
 	imgloader.o \
diff --git a/engines/sludge/movie.cpp b/engines/sludge/movie.cpp
index c569fb4..bb56a45 100644
--- a/engines/sludge/movie.cpp
+++ b/engines/sludge/movie.cpp
@@ -39,7 +39,6 @@
 
 #include "sludge/newfatal.h"
 #include "sludge/timing.h"
-#include "sludge/graphics.h"
 #include "sludge/movie.h"
 #include "sludge/sound.h"
 
diff --git a/engines/sludge/newfatal.cpp b/engines/sludge/newfatal.cpp
index f224256..027c9b0 100644
--- a/engines/sludge/newfatal.cpp
+++ b/engines/sludge/newfatal.cpp
@@ -25,7 +25,6 @@
 #include "sludge/allfiles.h"
 #include "sludge/sound.h"
 #include "sludge/errors.h"
-#include "sludge/graphics.h"
 #include "sludge/sludge.h"
 #include "sludge/version.h"
 
diff --git a/engines/sludge/sludger.cpp b/engines/sludge/sludger.cpp
index 49edb2b..9364aab 100644
--- a/engines/sludge/sludger.cpp
+++ b/engines/sludge/sludger.cpp
@@ -45,7 +45,6 @@
 #include "sludge/fileset.h"
 #include "sludge/transition.h"
 #include "sludge/language.h"
-#include "sludge/graphics.h"
 #include "sludge/variable.h"
 #include "sludge/sludge.h"
 #include "sludge/specialsettings.h"
diff --git a/engines/sludge/sprites.cpp b/engines/sludge/sprites.cpp
index 6225785..1b9b977 100644
--- a/engines/sludge/sprites.cpp
+++ b/engines/sludge/sprites.cpp
@@ -32,7 +32,6 @@
 #include "sludge/backdrop.h"
 #include "sludge/sludger.h"
 #include "sludge/zbuffer.h"
-#include "sludge/graphics.h"
 #include "sludge/imgloader.h"
 #include "sludge/sludge.h"
 
diff --git a/engines/sludge/thumbnail.cpp b/engines/sludge/thumbnail.cpp
index eb026b7..820e5af 100644
--- a/engines/sludge/thumbnail.cpp
+++ b/engines/sludge/thumbnail.cpp
@@ -25,7 +25,6 @@
 #include "sludge/moreio.h"
 #include "sludge/sludger.h"
 #include "sludge/backdrop.h"
-#include "sludge/graphics.h"
 #include "sludge/newfatal.h"
 #include "sludge/version.h"
 
diff --git a/engines/sludge/transition.cpp b/engines/sludge/transition.cpp
index c3665e3..83ec7df 100644
--- a/engines/sludge/transition.cpp
+++ b/engines/sludge/transition.cpp
@@ -22,7 +22,6 @@
 
 #include "sludge/allfiles.h"
 #include "sludge/backdrop.h"
-#include "sludge/graphics.h"
 #include "sludge/newfatal.h"
 
 #if 0
diff --git a/engines/sludge/zbuffer.cpp b/engines/sludge/zbuffer.cpp
index e09e57d..ea9fdfe 100644
--- a/engines/sludge/zbuffer.cpp
+++ b/engines/sludge/zbuffer.cpp
@@ -29,7 +29,6 @@
 #include "sludge/fileset.h"
 #include "sludge/moreio.h"
 #include "sludge/newfatal.h"
-#include "sludge/graphics.h"
 #include "sludge/sludge.h"
 #include "sludge/sprites.h"
 


Commit: 8c57d2d82540d1b7656375c808812ac4cba9d232
    https://github.com/scummvm/scummvm/commit/8c57d2d82540d1b7656375c808812ac4cba9d232
Author: Simei Yin (roseline.yin at gmail.com)
Date: 2017-07-15T17:51:57+02:00

Commit Message:
SLUDGE: Remove unused memwatch

Changed paths:
  R engines/sludge/memwatch.cpp
  R engines/sludge/memwatch.h
    engines/sludge/module.mk


diff --git a/engines/sludge/memwatch.cpp b/engines/sludge/memwatch.cpp
deleted file mode 100644
index e654f92..0000000
--- a/engines/sludge/memwatch.cpp
+++ /dev/null
@@ -1,73 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * 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 2
- * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#include "common/debug.h"
-
-#include "sludge/allfiles.h"
-
-namespace Sludge {
-
-void *allKnownMem[3000];
-int allKnownNum = 0;
-
-void outputKnownMem() {
-#if 0
-	FILE *debu = fopen("debuTURN.txt", "at");
-
-	fprintf(debu, "%i lumps:", allKnownNum);
-	for (int i = 0; i < allKnownNum; i ++) {
-		fprintf(debu, " %p", allKnownMem[i]);
-	}
-	fprintf(debu, "\n");
-	fclose(debu);
-#endif
-}
-
-void adding(void *mem) {
-	allKnownMem[allKnownNum] = mem;
-	allKnownNum++;
-
-	outputKnownMem();
-	if (allKnownNum == 3000) {
-		debug("Error! Array too full!");
-#if 0
-		exit(1);
-#endif
-	}
-}
-
-void deleting(void *mem) {
-	allKnownNum--;
-	for (int i = 0; i <= allKnownNum; i++) {
-		if (allKnownMem[i] == mem) {
-			allKnownMem[i] = allKnownMem[allKnownNum];
-			outputKnownMem();
-			return;
-		}
-	}
-#if 0
-	//db ("Error! Deleted a block which hasn't been allocated!");
-	exit(1);
-#endif
-}
-
-} // End of namespace Sludge
diff --git a/engines/sludge/memwatch.h b/engines/sludge/memwatch.h
deleted file mode 100644
index 6f8cd9c..0000000
--- a/engines/sludge/memwatch.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * 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 2
- * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-#ifndef SLUDGE_MEMWATCH_H
-#define SLUDGE_MEMWATCH_H
-
-namespace Sludge {
-
-void adding(void *);
-void deleting(void *);
-
-} // End of namespace Sludge
-
-#endif
diff --git a/engines/sludge/module.mk b/engines/sludge/module.mk
index 704f7f7..491b17d 100644
--- a/engines/sludge/module.mk
+++ b/engines/sludge/module.mk
@@ -17,7 +17,6 @@ MODULE_OBJS := \
 	language.o \
 	loadsave.o \
 	main_loop.o \
-	memwatch.o \
 	moreio.o \
 	movie.o \
 	newfatal.o \


Commit: a3876ee8c1bf43ad998681188f83266a85ab64b8
    https://github.com/scummvm/scummvm/commit/a3876ee8c1bf43ad998681188f83266a85ab64b8
Author: Simei Yin (roseline.yin at gmail.com)
Date: 2017-07-15T17:51:57+02:00

Commit Message:
SLUDGE: Clean useless #if 0's

Changed paths:
    engines/sludge/backdrop.cpp
    engines/sludge/bg_effects.cpp
    engines/sludge/builtin.cpp
    engines/sludge/fileset.cpp
    engines/sludge/loadsave.cpp
    engines/sludge/main_loop.cpp
    engines/sludge/movie.cpp
    engines/sludge/objtypes.cpp
    engines/sludge/sludger.cpp
    engines/sludge/sprites.cpp
    engines/sludge/talk.cpp
    engines/sludge/thumbnail.cpp
    engines/sludge/transition.cpp
    engines/sludge/variable.cpp
    engines/sludge/variable.h
    engines/sludge/zbuffer.cpp


diff --git a/engines/sludge/backdrop.cpp b/engines/sludge/backdrop.cpp
index f0ab6ef..9e211f4 100644
--- a/engines/sludge/backdrop.cpp
+++ b/engines/sludge/backdrop.cpp
@@ -48,15 +48,6 @@ extern Graphics::Surface renderSurface;
 bool freeze();
 void unfreeze(bool);    // Because FREEZE.H needs a load of other includes
 
-#if 0
-GLubyte *backdropTexture = NULL;
-GLuint backdropTextureName = 0;
-GLfloat backdropTexW = 1.0;
-GLfloat backdropTexH = 1.0;
-
-GLuint snapshotTextureName = 0;
-#endif
-
 bool backdropExists = false;
 extern int zBufferToSet;
 
@@ -121,10 +112,6 @@ bool restoreSnapshot(Common::SeekableReadStream *stream) {
 void killBackDrop() {
 	if (backdropSurface.getPixels())
 		backdropSurface.free();
-#if 0
-	deleteTextures(1, &backdropTextureName);
-	backdropTextureName = 0;
-#endif
 	backdropExists = false;
 }
 
@@ -133,27 +120,16 @@ void killLightMap() {
 		lightMap.free();
 	}
 	lightMapNumber = 0;
-#if 0
-	deleteTextures(1, &lightMap.name);
-	lightMap.name = 0;
-#endif
 }
 
 void killParallax() {
-
 	while (parallaxStuff) {
-
 		parallaxLayer *k = parallaxStuff;
 		parallaxStuff = k->next;
-#if 0
-		// Now kill the image
-		deleteTextures(1, &k->textureName);
-#endif
 		k->surface.free();
 		delete k;
 		k = NULL;
 	}
-
 }
 
 bool reserveBackdrop() {
@@ -164,36 +140,7 @@ bool reserveBackdrop() {
 	cameraZoom = 1.0;
 	input.mouseX = (int)((float)input.mouseX / cameraZoom);
 	input.mouseY = (int)((float)input.mouseY / cameraZoom);
-#if 0
-	int picWidth = sceneWidth;
-	int picHeight = sceneHeight;
-
-	glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
-
-	if (backdropTexture) delete backdropTexture;
-	if (!NPOT_textures) {
-		picWidth = getNextPOT(sceneWidth);
-		picHeight = getNextPOT(sceneHeight);
-		backdropTexW = ((double)sceneWidth) / picWidth;
-		backdropTexH = ((double)sceneHeight) / picHeight;
-	}
-	backdropTexture = new GLubyte [picWidth * picHeight * 4];
-	if (!checkNew(backdropTexture)) return false;
-
-	if (!backdropTextureName) glGenTextures(1, &backdropTextureName);
-	glBindTexture(GL_TEXTURE_2D, backdropTextureName);
-	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
-	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
-	if (gameSettings.antiAlias < 0) {
-		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
-	} else {
-		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
-		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
-	}
 
-	texImage2D(GL_TEXTURE_2D, 0, GL_RGBA, picWidth, picHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, backdropTexture, backdropTextureName);
-#endif
 	return true;
 }
 
@@ -269,45 +216,6 @@ void blankScreen(int x1, int y1, int x2, int y2) {
 		y2 = (int)sceneHeight;
 
 	backdropSurface.fillRect(Common::Rect(x1, y1, x2, y2), currentBlankColour);
-
-#if 0
-	setPixelCoords(true);
-
-	int xoffset = 0;
-	while (xoffset < picWidth) {
-		int w = (picWidth - xoffset < viewportWidth) ? picWidth - xoffset : viewportWidth;
-
-		int yoffset = 0;
-		while (yoffset < picHeight) {
-			int h = (picHeight - yoffset < viewportHeight) ? picHeight - yoffset : viewportHeight;
-
-			// Render the scene
-
-			const GLfloat vertices[] = {
-				-10.325f, -1.325f, 0.0f,
-				w + 1.325f, -1.325f, 0.0f,
-				-10.325f, h + 1.325f, 0.0f,
-				w + 1.325f, h + 1.325f, 0.0f
-			};
-
-			glUseProgram(shader.color);
-
-			setPMVMatrix(shader.color);
-			setPrimaryColor(redValue(currentBlankColour) / 255.0f, greenValue(currentBlankColour) / 255.0f, blueValue(currentBlankColour) / 255.0f, 1.0f);
-			drawQuad(shader.color, vertices, 0);
-
-			glUseProgram(0);
-
-			// Copy Our ViewPort To The Texture
-			copyTexSubImage2D(GL_TEXTURE_2D, 0, x1 + xoffset, y1 + yoffset, viewportOffsetX, viewportOffsetY, w, h, backdropTextureName);
-
-			yoffset += viewportHeight;
-		}
-		xoffset += viewportWidth;
-	}
-
-	setPixelCoords(false);
-#endif
 }
 
 // This function is very useful for scrolling credits, but very little else
@@ -411,38 +319,12 @@ bool loadLightMap(int v) {
 	if (!ImgLoader::loadImage(bigDataFile, &lightMap))
 		return false;
 
-#if 0
-	int newPicWidth = lightMap.w;
-	int newPicHeight = lightMap.h;
-
 	if (lightMapMode == LIGHTMAPMODE_HOTSPOT) {
 		if (lightMap.w != sceneWidth || lightMap.h != sceneHeight) {
 			return fatal("Light map width and height don't match scene width and height. That is required for lightmaps in HOTSPOT mode.");
 		}
 	}
 
-	if (!NPOT_textures) {
-		newPicWidth = getNextPOT(lightMap.w);
-		newPicHeight = getNextPOT(lightMap.h);
-		lightMap.texW = (double) lightMap.w / newPicWidth;
-		lightMap.texH = (double) lightMap.h / newPicHeight;
-	} else {
-		lightMap.texW = 1.0;
-		lightMap.texH = 1.0;
-	}
-
-	glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
-#endif
-#if 0
-	if (!lightMap.name) glGenTextures(1, &lightMap.name);
-	glBindTexture(GL_TEXTURE_2D, lightMap.name);
-	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
-	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
-	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
-	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
-
-	texImage2D(GL_TEXTURE_2D, 0, GL_RGBA, newPicWidth, newPicHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, lightMap.data, lightMap.name);
-#endif
 	finishAccess();
 
 	setResourceForFatal(-1);
@@ -450,45 +332,6 @@ bool loadLightMap(int v) {
 	return true;
 }
 
-void reloadParallaxTextures() {
-#if 0
-	parallaxLayer *nP = parallaxStuff;
-	if (!nP) return;
-
-	while (nP) {
-		//fprintf (stderr, "Reloading parallax. (%d, %d) ", nP->width, nP->height);
-		nP->textureName = 0;
-
-		glGenTextures(1, &nP->textureName);
-		glBindTexture(GL_TEXTURE_2D, nP->textureName);
-		if (nP->wrapS)
-		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
-		else
-		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
-		if (nP->wrapT)
-		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
-		else
-		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
-
-		if (gameSettings.antiAlias < 0) {
-			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
-		} else {
-			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
-			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
-		}
-
-		if (!NPOT_textures) {
-			texImage2D(GL_TEXTURE_2D, 0, GL_RGBA, getNextPOT(nP->width), getNextPOT(nP->height), 0, GL_RGBA, GL_UNSIGNED_BYTE, nP->texture, nP->textureName);
-		} else {
-			texImage2D(GL_TEXTURE_2D, 0, GL_RGBA, nP->width, nP->height, 0, GL_RGBA, GL_UNSIGNED_BYTE, nP->texture, nP->textureName);
-		}
-
-		nP = nP->next;
-	}
-#endif
-}
-
 bool loadParallax(uint16 v, uint16 fracX, uint16 fracY) {
 	setResourceForFatal(v);
 	if (!openFileFromNum(v))
@@ -550,129 +393,6 @@ bool loadParallax(uint16 v, uint16 fracX, uint16 fracY) {
 	return true;
 }
 
-extern int viewportOffsetX, viewportOffsetY;
-
-#if 0
-void makeGlArray(GLuint &tmpTex, const GLubyte *texture, int picWidth, int picHeight) {
-	glGenTextures(1, &tmpTex);
-	glBindTexture(GL_TEXTURE_2D, tmpTex);
-	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
-	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
-	if (gameSettings.antiAlias < 0) {
-		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
-	} else {
-		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
-		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
-	}
-	texImage2D(GL_TEXTURE_2D, 0, GL_RGBA, picWidth, picHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, texture, tmpTex);
-
-}
-
-void renderToTexture(GLuint tmpTex, int x, int y, int picWidth, int picHeight, int realPicWidth, int realPicHeight) {
-	GLfloat texCoordW = 1.0;
-	GLfloat texCoordH = 1.0;
-	if (!NPOT_textures) {
-		picWidth = getNextPOT(picWidth);
-		picHeight = getNextPOT(picHeight);
-		texCoordW = ((double)realPicWidth) / picWidth;
-		texCoordH = ((double)realPicHeight) / picHeight;
-	}
-
-	float btx1;
-	float btx2;
-	float bty1;
-	float bty2;
-	if (!NPOT_textures) {
-		btx1 = backdropTexW * x / sceneWidth;
-		btx2 = backdropTexW * (x + realPicWidth) / sceneWidth;
-		bty1 = backdropTexH * y / sceneHeight;
-		bty2 = backdropTexH * (y + realPicHeight) / sceneHeight;
-	} else {
-		btx1 = (float) x / sceneWidth;
-		btx2 = (float)(x + realPicWidth) / sceneWidth;
-		bty1 = (float) y / sceneHeight;
-		bty2 = (float)(y + realPicHeight) / sceneHeight;
-	}
-
-	const GLfloat btexCoords[] = {
-		btx1, bty1,
-		btx2, bty1,
-		btx1, bty2,
-		btx2, bty2
-	};
-
-	setPixelCoords(true);
-
-	int xoffset = 0;
-	while (xoffset < realPicWidth) {
-		int w = (realPicWidth - xoffset < viewportWidth) ? realPicWidth - xoffset : viewportWidth;
-
-		int yoffset = 0;
-		while (yoffset < realPicHeight) {
-			int h = (realPicHeight - yoffset < viewportHeight) ? realPicHeight - yoffset : viewportHeight;
-
-			glClear(GL_COLOR_BUFFER_BIT);   // Clear The Screen
-
-			const GLfloat vertices[] = {
-				(GLfloat) - xoffset, (GLfloat) - yoffset, 0.,
-				(GLfloat)realPicWidth - xoffset, (GLfloat) - yoffset, 0.,
-				(GLfloat) - xoffset, (GLfloat) - yoffset + realPicHeight, 0.,
-				(GLfloat)realPicWidth - xoffset, (GLfloat) - yoffset + realPicHeight, 0.
-			};
-
-			const GLfloat texCoords[] = {
-				0.0f, 0.0f,
-				texCoordW, 0.0f,
-				0.0f, texCoordH,
-				texCoordW, texCoordH
-			};
-
-			if (backdropExists) {
-				// Render the sprite to the backdrop
-				// (using mulitexturing, so the old backdrop is seen where alpha < 1.0)
-				glActiveTexture(GL_TEXTURE2);
-				glBindTexture(GL_TEXTURE_2D, backdropTextureName);
-				glActiveTexture(GL_TEXTURE0);
-
-				glUseProgram(shader.paste);
-				GLint uniform = glGetUniformLocation(shader.paste, "useLightTexture");
-				if (uniform >= 0) glUniform1i(uniform, 0);// No lighting
-
-				setPMVMatrix(shader.paste);
-
-				setPrimaryColor(1.0, 1.0, 1.0, 1.0);
-				glBindTexture(GL_TEXTURE_2D, tmpTex);
-				//glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
-
-				drawQuad(shader.paste, vertices, 3, texCoords, NULL, btexCoords);
-
-				glUseProgram(0);
-
-			} else {
-				// It's all new - nothing special to be done.
-				glUseProgram(shader.texture);
-				setPMVMatrix(shader.texture);
-
-				glBindTexture(GL_TEXTURE_2D, tmpTex);
-
-				setPrimaryColor(1.0, 0.0, 0.0, 0.0);
-
-				drawQuad(shader.texture, vertices, 1, texCoords);
-
-				glUseProgram(0);
-			}
-
-			// Copy Our ViewPort To The Texture
-			copyTexSubImage2D(GL_TEXTURE_2D, 0, x + xoffset, y + yoffset, viewportOffsetX, viewportOffsetY, w, h, backdropTextureName);
-
-			yoffset += viewportHeight;
-		}
-		xoffset += viewportWidth;
-	}
-	setPixelCoords(false);
-}
-#endif
 bool loadHSI(Common::SeekableReadStream *stream, int x, int y, bool reserve) {
 	debug(kSludgeDebugGraphics, "Load HSI");
 	if (reserve) {
@@ -685,7 +405,8 @@ bool loadHSI(Common::SeekableReadStream *stream, int x, int y, bool reserve) {
 	uint realPicWidth = backdropSurface.w;
 	uint realPicHeight = backdropSurface.h;
 
-	if (reserve) { // resize backdrop
+	// resize backdrop
+	if (reserve) {
 		if (!resizeBackdrop(realPicWidth, realPicHeight))
 			return false;
 	}
@@ -698,14 +419,7 @@ bool loadHSI(Common::SeekableReadStream *stream, int x, int y, bool reserve) {
 		debug(kSludgeDebugGraphics, "Illegal back drop size");
 		return false;
 	}
-#if 0
-	GLuint tmpTex;
-	makeGlArray(tmpTex, backdropTexture, picWidth, picHeight);
-
-	renderToTexture(tmpTex, x, y, picWidth, picHeight, realPicWidth, realPicHeight);
 
-	deleteTextures(1, &tmpTex);
-#endif
 	OrigBackdropSurface.copyFrom(backdropSurface);
 	backdropExists = true;
 
@@ -731,183 +445,10 @@ bool mixHSI(Common::SeekableReadStream *stream, int x, int y) {
 	Graphics::TransparentSurface tmp(mixSurface, false);
 	tmp.blit(backdropSurface, x, y, Graphics::FLIP_NONE, nullptr, TS_ARGB(255, 255 >> 1, 255, 255));
 	mixSurface.free();
-;
-#if 0
-	float btx1, tx1;
-	float btx2, tx2;
-	float bty1, ty1;
-	float bty2, ty2;
-
-	if (!NPOT_textures) {
-		tx1 = 0.0;
-		ty1 = 0.0;
-		tx2 = ((double)picWidth) / getNextPOT(picWidth);
-		ty2 = ((double)picHeight) / getNextPOT(picHeight);
-		picWidth = getNextPOT(picWidth);
-		picHeight = getNextPOT(picHeight);
-		btx1 = backdropTexW * x / sceneWidth;
-		btx2 = backdropTexW * (x + realPicWidth) / sceneWidth;
-		bty1 = backdropTexH * y / sceneHeight;
-		bty2 = backdropTexH * (y + realPicHeight) / sceneHeight;
-	} else {
-		tx1 = 0.0;
-		ty1 = 0.0;
-		tx2 = 1.0;
-		ty2 = 1.0;
-		btx1 = (float) x / sceneWidth;
-		btx2 = (float)(x + picWidth) / sceneWidth;
-		bty1 = (float) y / sceneHeight;
-		bty2 = (float)(y + picHeight) / sceneHeight;
-	}
-
-	const GLfloat texCoords[] = {
-		tx1, ty1,
-		tx2, ty1,
-		tx1, ty2,
-		tx2, ty2
-	};
-
-	const GLfloat btexCoords[] = {
-		btx1, bty1,
-		btx2, bty1,
-		btx1, bty2,
-		btx2, bty2
-	};
-
-	GLuint tmpTex;
-	makeGlArray(tmpTex, backdropTexture, picWidth, picHeight);
-
-	setPixelCoords(true);
-
-	int xoffset = 0;
-	while (xoffset < realPicWidth) {
-		int w = (realPicWidth - xoffset < viewportWidth) ? realPicWidth - xoffset : viewportWidth;
-
-		int yoffset = 0;
-		while (yoffset < realPicHeight) {
-			int h = (realPicHeight - yoffset < viewportHeight) ? realPicHeight - yoffset : viewportHeight;
-
-			glClear(GL_COLOR_BUFFER_BIT);   // Clear The Screen
-
-			// Render the sprite to the backdrop
-			// (using mulitexturing, so the backdrop is seen where alpha < 1.0)
-			glActiveTexture(GL_TEXTURE2);
-			glBindTexture(GL_TEXTURE_2D, backdropTextureName);
-			glActiveTexture(GL_TEXTURE0);
-
-			glUseProgram(shader.paste);
-			GLint uniform = glGetUniformLocation(shader.paste, "useLightTexture");
-			if (uniform >= 0) glUniform1i(uniform, 0);// No lighting
-
-			setPMVMatrix(shader.paste);
-
-			setPrimaryColor(1.0, 1.0, 1.0, 0.5);
-
-			glBindTexture(GL_TEXTURE_2D, tmpTex);
-			//glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
-
-			const GLfloat vertices[] = {
-				(GLfloat) - xoffset, (GLfloat) - yoffset, 0.,
-				(GLfloat)realPicWidth - xoffset, (GLfloat) - yoffset, 0.,
-				(GLfloat) - xoffset, (GLfloat) - yoffset + realPicHeight, 0.,
-				(GLfloat)realPicWidth - xoffset, (GLfloat) - yoffset + realPicHeight, 0.
-			};
-
-			drawQuad(shader.paste, vertices, 3, texCoords, NULL, btexCoords);
 
-			// Copy Our ViewPort To The Texture
-			glUseProgram(0);
-
-			copyTexSubImage2D(GL_TEXTURE_2D, 0, (int)((x < 0) ? xoffset : x + xoffset), (int)((y < 0) ? yoffset : y + yoffset), (int)((x < 0) ? viewportOffsetX - x : viewportOffsetX), (int)((y < 0) ? viewportOffsetY - y : viewportOffsetY), w, h, backdropTextureName);
-
-			yoffset += viewportHeight;
-		}
-
-		xoffset += viewportWidth;
-	}
-	deleteTextures(1, &tmpTex);
-	setPixelCoords(false);
-#endif
 	return true;
 }
 
-#if 0
-void saveCoreHSI(Common::WriteStream *stream, GLuint texture, int w, int h) {
-	GLint tw, th;
-	glBindTexture(GL_TEXTURE_2D, texture);
-	getTextureDimensions(texture, &tw, &th);
-
-	GLushort *image = new GLushort[tw * th];
-	if (!checkNew(image))
-		return;
-	glPixelStorei(GL_PACK_ALIGNMENT, 1);
-//	glGetTexImage(GL_TEXTURE_2D, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, image);
-	setPixelCoords(true);
-
-	//glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
-
-	const GLfloat texCoords[] = { 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f };
-
-	int xoffset = 0;
-	while (xoffset < tw) {
-		int w = (tw - xoffset < viewportWidth) ? tw - xoffset : viewportWidth;
-
-		int yoffset = 0;
-		while (yoffset < th) {
-			int h = (th - yoffset < viewportHeight) ? th - yoffset : viewportHeight;
-			glClear (GL_COLOR_BUFFER_BIT);   // Clear The Screen
-			const GLfloat vertices[] = { (GLfloat)-xoffset, (GLfloat)-yoffset, 0., (GLfloat)w - xoffset, (GLfloat)-yoffset, 0., (GLfloat)-xoffset, (GLfloat)-yoffset + h, 0., (GLfloat)w - xoffset,
-					(GLfloat)-yoffset + h, 0. };
-
-			glUseProgram(shader.texture);
-			setPMVMatrix(shader.texture);
-			drawQuad(shader.texture, vertices, 1, texCoords);
-			glUseProgram(0);
-
-			for (int i = 0; i < h; i++) {
-				glReadPixels(viewportOffsetX, viewportOffsetY + i, w, 1, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, image + xoffset + (yoffset + i) * tw);
-			}
-			yoffset += viewportHeight;
-		}
-
-		xoffset += viewportWidth;
-	}
-	//glReadPixels(viewportOffsetX, viewportOffsetY, tw, th, GL_RGBA, GL_UNSIGNED_BYTE, data);
-	setPixelCoords(false);
-
-	int x, y, lookAhead;
-	uint16 *fromHere, *lookPointer;
-
-	stream->writeUint16BE(w);
-	stream->writeUint16BE(h);
-
-	for (y = 0; y < h; y++) {
-		fromHere = image + (y * tw);
-		x = 0;
-		while (x < w) {
-			lookPointer = fromHere + 1;
-			for (lookAhead = x + 1; lookAhead < w; lookAhead++) {
-				if (lookAhead - x == 256)
-					break;
-				if (*fromHere != *lookPointer)
-					break;
-				lookPointer++;
-			}
-			if (lookAhead == x + 1) {
-				put2bytes((*fromHere) & 65503, stream);
-			} else {
-				stream->writeUint16BE(*fromHere | 32);
-				stream->writeByte(lookAhead - x - 1);
-			}
-			fromHere = lookPointer;
-			x = lookAhead;
-		}
-	}
-	delete[] image;
-	image = NULL;
-}
-#endif
-
 void saveHSI(Common::WriteStream *stream) {
 	Image::writePNG(*stream, backdropSurface);
 }
diff --git a/engines/sludge/bg_effects.cpp b/engines/sludge/bg_effects.cpp
index 0168e91..920be44 100644
--- a/engines/sludge/bg_effects.cpp
+++ b/engines/sludge/bg_effects.cpp
@@ -31,11 +31,6 @@
 namespace Sludge {
 
 #if 0
-//extern uint16 **backDropImage;
-extern GLuint backdropTextureName;
-#endif
-
-#if 0
 // Raised
 static int s_matrixEffectDivide = 2;
 static int s_matrixEffectWidth = 3;
diff --git a/engines/sludge/builtin.cpp b/engines/sludge/builtin.cpp
index 61590a5..dbf9dfc 100644
--- a/engines/sludge/builtin.cpp
+++ b/engines/sludge/builtin.cpp
@@ -77,17 +77,12 @@ extern Common::String *allUserFunc;
 extern Common::String *allBIFNames;
 extern inputType input;
 
-#if 0
-extern GLuint backdropTextureName;
-#endif
-
 extern float speechSpeed;
 extern byte brightnessLevel;
 extern byte fadeMode;
 extern uint16 saveEncoding;
 extern frozenStuffStruct *frozenStuff;
 extern uint currentBlankColour;
-extern uint languageID;
 extern byte currentBurnR, currentBurnG, currentBurnB;
 
 int paramNum[] = { -1, 0, 1, 1, -1, -1, 1, 3, 4, 1, 0, 0, 8, -1,    // SAY->MOVEMOUSE
@@ -1010,19 +1005,11 @@ builtIn(callEvent) {
 	return BR_CONTINUE;
 }
 
-#if 0
-SDL_Event quit_event;
-#endif
-
 bool reallyWantToQuit = false;
 
 builtIn(quitGame) {
 	UNUSEDALL
 	reallyWantToQuit = true;
-#if 0
-	quit_event.type = SDL_QUIT;
-	SDL_PushEvent(&quit_event);
-#endif
 	return BR_CONTINUE;
 }
 
@@ -2627,7 +2614,6 @@ builtReturn callBuiltIn(int whichFunc, int numParams, loadedFunction *fun) {
 		}
 
 		if (builtInFunctionArray[whichFunc].func) {
-			//fprintf (stderr, "Calling %i: %s\n", whichFunc, builtInFunctionNames[whichFunc]);
 			return builtInFunctionArray[whichFunc].func(numParams, fun);
 		}
 	}
diff --git a/engines/sludge/fileset.cpp b/engines/sludge/fileset.cpp
index 058ae15..daec8bd 100644
--- a/engines/sludge/fileset.cpp
+++ b/engines/sludge/fileset.cpp
@@ -38,56 +38,36 @@ Common::File *bigDataFile = NULL;
 uint32 startOfDataIndex, startOfTextIndex, startOfSubIndex, startOfObjectIndex;
 
 bool openSubSlice(int num) {
-//	FILE * dbug = fopen ("debuggy.txt", "at");
-
-//	fprintf (dbug, "\nTrying to open sub %i\n", num);
-
 	if (sliceBusy) {
 		fatal("Can't read from data file", "I'm already reading something");
 		return false;
 	}
-//	fprintf (dbug, "Going to position %li\n", startOfSubIndex + (num << 2));
 	bigDataFile->seek(startOfSubIndex + (num << 2), 0);
 	bigDataFile->seek(bigDataFile->readUint32LE(), 0);
-//	fprintf (dbug, "Told to skip forward to %li\n", ftell (bigDataFile));
-//	fclose (dbug);
 
 	return sliceBusy = true;
 }
 
 bool openObjectSlice(int num) {
-//	FILE * dbug = fopen ("debuggy.txt", "at");
-
-//	fprintf (dbug, "\nTrying to open object %i\n", num);
-
 	if (sliceBusy) {
 		fatal("Can't read from data file", "I'm already reading something");
 		return false;
 	}
 
-//	fprintf (dbug, "Going to position %li\n", startOfObjectIndex + (num << 2));
 	bigDataFile->seek(startOfObjectIndex + (num << 2), 0);
 	bigDataFile->seek(bigDataFile->readUint32LE(), 0);
-//	fprintf (dbug, "Told to skip forward to %li\n", ftell (bigDataFile));
-//	fclose (dbug);
 	return sliceBusy = true;
 }
 
 uint openFileFromNum(int num) {
-//	FILE * dbug = fopen ("debuggy.txt", "at");
-
 	if (sliceBusy) {
 		fatal("Can't read from data file", "I'm already reading something");
 		return 0;
 	}
 
-//	fprintf (dbug, "\nTrying to open file %i\n", num);
-//	fprintf (dbug, "Jumping to %li (for index) \n", startOfDataIndex + (num << 2));
 	bigDataFile->seek(startOfDataIndex + (num << 2), 0);
 	bigDataFile->seek(bigDataFile->readUint32LE(), 1);
-//	fprintf (dbug, "Jumping to %li (for data) \n", ftell (bigDataFile));
 	sliceBusy = true;
-//	fclose (dbug);
 
 	return bigDataFile->readUint32LE();
 }
diff --git a/engines/sludge/loadsave.cpp b/engines/sludge/loadsave.cpp
index 3ab1b13..0757067 100644
--- a/engines/sludge/loadsave.cpp
+++ b/engines/sludge/loadsave.cpp
@@ -109,8 +109,6 @@ void saveStack(variableStack *vs, Common::WriteStream *stream) {
 		search = search->next;
 	}
 
-	stackDebug((stackfp, "  stack contains %d elements\n", elements));
-
 	stream->writeUint16BE(elements);
 	search = vs;
 	for (a = 0; a < elements; a++) {
@@ -131,7 +129,6 @@ variableStack *loadStack(Common::SeekableReadStream *stream, variableStack **las
 			return NULL;
 		loadVariable(&(nS->thisVar), stream);
 		if (last && a == elements - 1) {
-			stackDebug((stackfp, "Setting last to %p\n", nS));
 			*last = nS;
 		}
 		nS->next = NULL;
@@ -189,13 +186,9 @@ stackHandler *loadStackRef(Common::SeekableReadStream *stream) {
 	stackHandler *nsh;
 
 	if (stream->readByte()) {    // It's one we've loaded already...
-		stackDebug((stackfp, "loadStackRef (duplicate, get from library)\n"));
-
 		nsh = getStackFromLibrary(stream->readUint16BE());
 		nsh->timesUsed++;
 	} else {
-		stackDebug((stackfp, "loadStackRef (new one)\n"));
-
 		// Load the new stack
 
 		nsh = new stackHandler;
@@ -204,12 +197,6 @@ stackHandler *loadStackRef(Common::SeekableReadStream *stream) {
 		nsh->last = NULL;
 		nsh->first = loadStack(stream, &nsh->last);
 		nsh->timesUsed = 1;
-		stackDebug((stackfp, "  first = %p\n", nsh->first));
-		if (nsh->first)
-			stackDebug((stackfp, "  first->next = %p\n", nsh->first->next));
-		stackDebug((stackfp, "  last = %p\n", nsh->last));
-		if (nsh->last)
-			stackDebug((stackfp, "  last->next = %p\n", nsh->last->next));
 
 		// Add it to the library of loaded stacks
 
diff --git a/engines/sludge/main_loop.cpp b/engines/sludge/main_loop.cpp
index 51b3913..1f8a44e 100644
--- a/engines/sludge/main_loop.cpp
+++ b/engines/sludge/main_loop.cpp
@@ -69,42 +69,6 @@ Graphics::Surface renderSurface;
 
 int dialogValue = 0;
 
-void setGameFilePath(char *f) {
-#if 0
-	char currentDir[1000];
-	if (!getcwd(currentDir, 998)) {
-		debugOut("Can't get current directory.\n");
-	}
-
-	int got = -1, a;
-
-	for (a = 0; f[a]; a ++) {
-		if (f[a] == PATHSLASH) got = a;
-	}
-
-	if (got != -1) {
-		f[got] = 0;
-		if (chdir(f)) {
-			debugOut("Error: Failed changing to directory %s\n", f);
-		}
-		f[got] = PATHSLASH;
-	}
-
-	gamePath = new char[400];
-	if (!checkNew(gamePath)) return;
-
-	if (!getcwd(gamePath, 398)) {
-		debugOut("Can't get game directory.\n");
-	}
-
-	if (chdir(currentDir)) {
-		debugOut("Error: Failed changing to directory %s\n", currentDir);
-	}
-#endif
-}
-
-void saveHSI(Common::WriteStream *writer);
-
 extern bool reallyWantToQuit;
 
 int weAreDoneSoQuit;
@@ -165,39 +129,6 @@ void checkInput() {
 				break;
 
 			case Common::EVENT_KEYDOWN:
-#if 0
-				// A Windows key is pressed - let's leave fullscreen.
-				if (runningFullscreen) {
-					if (event.key.keysym.sym == SDLK_LSUPER || event.key.keysym.sym == SDLK_LSUPER) {
-						setGraphicsWindow(!runningFullscreen);
-					}
-				}
-				// Ignore Command keypresses - they're for the OS to handle.
-				if (event.key.keysym.mod & KMOD_META) {
-					// Command+F - let's switch to/from full screen
-					if ('f' == event.key.keysym.unicode) {
-						setGraphicsWindow(!runningFullscreen);
-					}
-					break;
-				} else if (event.key.keysym.mod & KMOD_ALT) {
-					// Alt + Enter also switches full screen mode
-					if (SDLK_RETURN == event.key.keysym.sym) {
-						setGraphicsWindow(!runningFullscreen);
-					}
-					if (SDLK_a == event.key.keysym.sym) {
-						gameSettings.antiAlias = !gameSettings.antiAlias;
-						break;
-					}
-					// Allow Alt+F4 to quit
-					if (SDLK_F4 == event.key.keysym.sym) {
-						SDL_Event event;
-						event.type = SDL_QUIT;
-						SDL_PushEvent(&event);
-					}
-
-					break;
-				}
-#endif
 				switch (event.kbd.keycode) {
 
 					case Common::KEYCODE_BACKSPACE:
@@ -213,19 +144,7 @@ void checkInput() {
 
 			case Common::EVENT_QUIT:
 				weAreDoneSoQuit = 1;
-#if 0
-				if (reallyWantToQuit) {
-					// The game file has requested that we quit
-					weAreDoneSoQuit = 1;
-				} else {
-					// The request is from elsewhere - ask for confirmation.
-					setGraphicsWindow(false);
-					//fprintf (stderr, "%s %s\n", gameName, getNumberedString(2));
-					if (msgBoxQuestion(gameName, getNumberedString(2))) {
-						weAreDoneSoQuit = 1;
-					}
-				}
-#endif
+				// TODO: if reallyWantToQuit, popup a message box to confirm
 				break;
 
 			default:
@@ -235,9 +154,6 @@ void checkInput() {
 }
 
 int main_loop(const char *filename)
-#if 0
-		try
-#endif
 		{
 	/* Dimensions of our window. */
 	winWidth = 640;
@@ -251,28 +167,6 @@ int main_loop(const char *filename)
 
 	// Init screen surface
 	renderSurface.create(g_system->getWidth(), g_system->getHeight(), g_system->getScreenFormat());
-#if 0
-	/* Initialize the SDL library */
-	if (SDL_Init(SDL_INIT_VIDEO) < 0) {
-		msgBox("Startup Error: Couldn't initialize SDL.", SDL_GetError());
-		exit(1);
-	}
-#endif
-	if (gameIcon) {
-#if 0
-		if (SDL_Surface *programIcon = SDL_CreateRGBSurfaceFrom(gameIcon, iconW, iconH, 32, iconW * 4, 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000)) {
-			SDL_WM_SetIcon(programIcon, NULL);
-			SDL_FreeSurface(programIcon);
-		}
-#endif
-		delete gameIcon;
-	}
-#if 0
-	// Needed to make menu shortcuts work (on Mac), i.e. Command+Q for quit
-	SDL_putenv((char *)"SDL_ENABLEAPPEVENTS=1");
-
-	setupOpenGLStuff();
-#endif
 
 	registerWindowForFatal();
 
@@ -292,19 +186,6 @@ int main_loop(const char *filename)
 
 	g_sludge->gameName = getNumberedString(1);
 
-#if 0
-	SDL_WM_SetCaption(gameName, gameName);
-
-	if ((specialSettings & (SPECIAL_MOUSE_1 | SPECIAL_MOUSE_2)) == SPECIAL_MOUSE_1) {
-		//  Hide the standard mouse cursor!
-		// This is done in a weird way because there's bugs with SDL_ShowCursor(SDL_DISABLE);
-		SDL_Cursor *cursor = NULL;
-		Uint8 data = 0;
-		SDL_FreeCursor(cursor);
-		cursor = SDL_CreateCursor(&data, &data, 1, 1, 0, 0);
-		SDL_SetCursor(cursor);
-	}
-#endif
 	if (!(specialSettings & SPECIAL_SILENT)) {
 		initSoundStuff(hMainWindow);
 	}
@@ -325,22 +206,8 @@ int main_loop(const char *filename)
 
 	killSoundStuff();
 
-#if 0
-	/* Clean up the SDL library */
-	SDL_Quit();
-#endif
-	displayFatal();
 	return (0);
 }
-#if 0
-catch (std::exception &ex) { //NOTE by reference, not value
-	std::cerr << "std::exception caught: " << ex.what() << std::endl;
-	return -1;
-} catch (...) {
-	std::cerr << "Unknown exception was never caught" << std::endl;
-	return -2;
-}
-#endif
 
 }
  // End of namespace Sludge
diff --git a/engines/sludge/movie.cpp b/engines/sludge/movie.cpp
index bb56a45..49a6919 100644
--- a/engines/sludge/movie.cpp
+++ b/engines/sludge/movie.cpp
@@ -19,21 +19,6 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  *
  */
-#if 0
-#include <SDL/SDL.h>
-#define VPX_CODEC_DISABLE_COMPAT 1
-#include "vpx/vpx_decoder.h"
-#include "vpx/vp8dx.h"
-#define interface (&vpx_codec_vp8_dx_algo)
-#include "vorbis/codec.h"
-#define OV_EXCLUDE_STATIC_CALLBACKS
-#include "vorbis/vorbisfile.h"
-
-#include "ogg/ogg.h"
-#include "libvorbis/vorbis_os.h"
-
-#include "AL/alure.h"
-#endif
 
 #include "sludge/specialsettings.h"
 
diff --git a/engines/sludge/objtypes.cpp b/engines/sludge/objtypes.cpp
index e0fae1b..f975167 100644
--- a/engines/sludge/objtypes.cpp
+++ b/engines/sludge/objtypes.cpp
@@ -82,28 +82,12 @@ objectType *loadObjectType(int i) {
 			newType->numCom = bigDataFile->readUint16BE();
 			newType->allCombis = (newType->numCom) ? new combination[newType->numCom] : NULL;
 
-#if DEBUG_COMBINATIONS
-			FILE *callEventLog = fopen("callEventLog.txt", "at");
-			if (callEventLog) {
-				fprintf(callEventLog, "Object type %d has %d combinations... ", i, newType -> numCom);
-			}
-#endif
 
 			for (a = 0; a < newType->numCom; a++) {
 				newType->allCombis[a].withObj = bigDataFile->readUint16BE();
 				newType->allCombis[a].funcNum = bigDataFile->readUint16BE();
-#if DEBUG_COMBINATIONS
-				if (callEventLog) {
-					fprintf(callEventLog, "%d(%d) ", newType -> allCombis[a].withObj, newType -> allCombis[a].funcNum);
-				}
-#endif
-			}
-#if DEBUG_COMBINATIONS
-			if (callEventLog) {
-				fprintf(callEventLog, "\n");
-				fclose(callEventLog);
 			}
-#endif
+
 			finishAccess();
 			newType->screenName = getNumberedString(nameNum);
 			newType->objectNum = i;
@@ -132,13 +116,6 @@ int getCombinationFunction(int withThis, int thisObject) {
 	int i, num = 0;
 	objectType *obj = findObjectType(thisObject);
 
-#if DEBUG_COMBINATIONS
-	FILE *callEventLog = fopen("callEventLog.txt", "at");
-	if (callEventLog) {
-		fprintf(callEventLog, "Combining %d and %d - ", thisObject, withThis);
-	}
-#endif
-
 	for (i = 0; i < obj->numCom; i++) {
 		if (obj->allCombis[i].withObj == withThis) {
 			num = obj->allCombis[i].funcNum;
@@ -146,13 +123,6 @@ int getCombinationFunction(int withThis, int thisObject) {
 		}
 	}
 
-#if DEBUG_COMBINATIONS
-	if (callEventLog) {
-		fprintf(callEventLog, "got function number %d\n", num);
-		fclose(callEventLog);
-	}
-#endif
-
 	return num;
 }
 
diff --git a/engines/sludge/sludger.cpp b/engines/sludge/sludger.cpp
index 9364aab..41d2dd8 100644
--- a/engines/sludge/sludger.cpp
+++ b/engines/sludge/sludger.cpp
@@ -502,14 +502,6 @@ bool initSludge(const Common::String &filename) {
 
 	Common::String gameName = encodeFilename(gameNameOrig);
 
-#if 0
-	changeToUserDir();
-
-	mkdir(gameName, 0000777);
-
-	if (chdir(gameName)) return fatal("This game's preference folder is inaccessible!\nI can't access the following directory (maybe there's a file with the same name, or maybe it's read-protected):", gameName);
-#endif
-
 	// Get language selected by user
 	gameSettings.languageID = g_sludge->getLanguageID();
 
@@ -521,11 +513,6 @@ bool initSludge(const Common::String &filename) {
 
 	if (!dataFol.empty()) {
 		Common::String dataFolder = encodeFilename(dataFol);
-#if 0
-		mkdir(dataFolder, 0000777);
-
-		if (chdir(dataFolder)) return fatal("This game's data folder is inaccessible!\nI can't access the following directory (maybe there's a file with the same name, or maybe it's read-protected):", dataFolder);
-#endif
 	}
 
 	positionStatus(10, winHeight - 15);
@@ -534,23 +521,6 @@ bool initSludge(const Common::String &filename) {
 }
 
 extern int cameraX, cameraY;
-extern float cameraZoom;
-
-bool checkColourChange(bool reset) {
-#if 0
-	static GLuint oldPixel;
-	static GLuint pixel;
-	glReadPixels((GLint)(viewportOffsetX + input.mouseX * viewportWidth / ((float)winWidth / cameraZoom)),
-			(GLint)(viewportOffsetY + (((float)winHeight / cameraZoom) - input.mouseY)*viewportHeight / ((float)winHeight / cameraZoom)),
-			1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &pixel);
-
-	if (reset || oldPixel != pixel) {
-		oldPixel = pixel;
-		return true;
-	}
-#endif
-	return false;
-}
 
 void displayBase() {
 	drawBackDrop();// Draw the room
@@ -1280,25 +1250,10 @@ int startNewFunctionNum(uint funcNum, uint numParamsExpected,
 
 int lastFramesPerSecond = -1;
 int thisFramesPerSecond = -1;
-#if 0
-Uint32 lastSeconds = 0;
-#endif
 
 bool handleInput() {
 	static int l = 0;
-#if 0
-	static Uint32 theTime;
 
-	theTime = SDL_GetTicks() / 1000;
-	if (lastSeconds != theTime) {
-		lastSeconds = theTime;
-		lastFramesPerSecond = thisFramesPerSecond;
-		thisFramesPerSecond = 1;
-	} else {
-		thisFramesPerSecond ++;
-	}
-//	lastFramesPerSecond = theTime.wSecond;
-#endif
 	if (!g_sludge->launchMe.empty()) {
 		if (l) {
 			// Still paused because of spawned thingy...
diff --git a/engines/sludge/sprites.cpp b/engines/sludge/sprites.cpp
index 1b9b977..735db7d 100644
--- a/engines/sludge/sprites.cpp
+++ b/engines/sludge/sprites.cpp
@@ -59,10 +59,6 @@ SpriteLayers spriteLayers;
 
 extern zBufferData zBuffer;
 
-#if 0
-extern GLuint backdropTextureName;
-#endif
-
 extern inputType input;
 extern int cameraX, cameraY;
 extern float cameraZoom;
@@ -304,103 +300,8 @@ void pasteSpriteToBackDrop(int x1, int y1, sprite &single, const spritePalette &
 	x1 -= single.xhot;
 	y1 -= single.yhot;
 	Graphics::TransparentSurface tmp(single.surface, false);
-	tmp.blit(backdropSurface, x1, y1, Graphics::FLIP_NONE, nullptr, TS_RGB(fontPal.originalRed, fontPal.originalGreen, fontPal.originalBlue));
-#if 0
-	float tx1 = (float)(single.tex_x) / fontPal.tex_w[single.texNum];
-	float ty1 = 0.0;
-	float tx2 = (float)(single.tex_x + single.width) / fontPal.tex_w[single.texNum];
-	float ty2 = (float)(single.height) / fontPal.tex_h[single.texNum];
-
-	float btx1;
-	float btx2;
-	float bty1;
-	float bty2;
-
-	int diffX = single.width;
-	int diffY = single.height;
-
-	x1 -= single.xhot;
-	y1 -= single.yhot;
-
-	if (! NPOT_textures) {
-		btx1 = backdropTexW * x1 / sceneWidth;
-		btx2 = backdropTexW * (x1 + single.width) / sceneWidth;
-		bty1 = backdropTexH * y1 / sceneHeight;
-		bty2 = backdropTexH * (y1 + single.height) / sceneHeight;
-	} else {
-		btx1 = (float) x1 / sceneWidth;
-		btx2 = (float)(x1 + single.width) / sceneWidth;
-		bty1 = (float) y1 / sceneHeight;
-		bty2 = (float)(y1 + single.height) / sceneHeight;
-	}
-
-	const GLfloat btexCoords[] = {
-		btx1, bty1,
-		btx2, bty1,
-		btx1, bty2,
-		btx2, bty2
-	};
-
-	if (x1 < 0) diffX += x1;
-	if (y1 < 0) diffY += y1;
-	if (x1 + diffX > sceneWidth) diffX = sceneWidth - x1;
-	if (y1 + diffY > sceneHeight) diffY = sceneHeight - y1;
-	if (diffX < 0) return;
-	if (diffY < 0) return;
-
-	setPixelCoords(true);
-
-	int xoffset = 0;
-	while (xoffset < diffX) {
-		int w = (diffX - xoffset < viewportWidth) ? diffX - xoffset : viewportWidth;
-
-		int yoffset = 0;
-		while (yoffset < diffY) {
-			int h = (diffY - yoffset < viewportHeight) ? diffY - yoffset : viewportHeight;
-
-			// Render the sprite to the backdrop
-			// (using mulitexturing, so the backdrop is seen where alpha < 1.0)
-			glActiveTexture(GL_TEXTURE2);
-			glBindTexture(GL_TEXTURE_2D, backdropTextureName);
-			glActiveTexture(GL_TEXTURE0);
-
-			glUseProgram(shader.paste);
-			GLint uniform = glGetUniformLocation(shader.paste, "useLightTexture");
-			if (uniform >= 0) glUniform1i(uniform, 0);// No lighting
-
-			setPMVMatrix(shader.paste);
-
-			setPrimaryColor(fontPal.originalRed / 255.f, fontPal.originalGreen / 255.f, fontPal.originalBlue / 255.f, 1.0f);
-			glBindTexture(GL_TEXTURE_2D, fontPal.tex_names[single.texNum]);
-			//glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
-
-			const GLfloat vertices[] = {
-				(GLfloat) - xoffset, (GLfloat) - yoffset, 0.,
-				(GLfloat)single.width - xoffset, (GLfloat) - yoffset, 0.,
-				(GLfloat) - xoffset, (GLfloat)single.height - yoffset, 0.,
-				(GLfloat)single.width - xoffset, (GLfloat)single.height - yoffset, 0.
-			};
-
-			const GLfloat texCoords[] = {
-				tx1, ty1,
-				tx2, ty1,
-				tx1, ty2,
-				tx2, ty2
-			};
-
-			drawQuad(shader.paste, vertices, 3, texCoords, NULL, btexCoords);
-
-			// Copy Our ViewPort To The Texture
-			glUseProgram(0);
-
-			copyTexSubImage2D(GL_TEXTURE_2D, 0, (int)((x1 < 0) ? xoffset : x1 + xoffset), (int)((y1 < 0) ? yoffset : y1 + yoffset), (int)((x1 < 0) ? viewportOffsetX - x1 : viewportOffsetX), (int)((y1 < 0) ? viewportOffsetY - y1 : viewportOffsetY), w, h, backdropTextureName);
-
-			yoffset += viewportHeight;
-		}
-		xoffset += viewportWidth;
-	}
-	setPixelCoords(false);
-#endif
+	tmp.blit(backdropSurface, x1, y1, Graphics::FLIP_NONE, nullptr,
+			TS_RGB(fontPal.originalRed, fontPal.originalGreen, fontPal.originalBlue));
 }
 
 void burnSpriteToBackDrop(int x1, int y1, sprite &single, const spritePalette &fontPal) {
@@ -507,10 +408,6 @@ void burnSpriteToBackDrop(int x1, int y1, sprite &single, const spritePalette &f
 #endif
 }
 
-#if 0
-extern GLuint backdropTextureName;
-#endif
-
 void fontSprite(bool flip, int x, int y, sprite &single, const spritePalette &fontPal) {
 	float x1 = (float)x - (float)single.xhot / cameraZoom;
 	float y1 = (float)y - (float)single.yhot / cameraZoom;
@@ -524,60 +421,6 @@ void fontSprite(bool flip, int x, int y, sprite &single, const spritePalette &fo
 		tmp2.blit(renderSurface, x1, y1, (flip ? Graphics::FLIP_H : Graphics::FLIP_NONE), 0, TS_RGB(fontPal.originalRed, fontPal.originalGreen, fontPal.originalBlue));
 
 	}
-
-#if 0
-	float x2 = x1 + (float) single.surface.w / cameraZoom;
-	float y2 = y1 + (float) single.surface.h / cameraZoom;
-	float tx1 = (float) (single.tex_x - 0.5) / fontPal.tex_w[single.texNum];
-	float ty1 = 0.0;
-	float tx2 = (float) (single.tex_x + single.width + (flip ? 1.0 : 0.5))
-			/ fontPal.tex_w[single.texNum];
-	float ty2 = (float) (single.height + 2) / fontPal.tex_h[single.texNum];
-
-	GLfloat vertices[] = {
-		x1, y1, 0.0f,
-		x2, y1, 0.0f,
-		x1, y2, 0.0f,
-		x2, y2, 0.0f
-	};
-	if (flip) {
-		vertices[0] = x2;
-		vertices[3] = x1;
-		vertices[6] = x2;
-		vertices[9] = x1;
-	}
-
-	const GLfloat texCoords[] = {
-		tx1, ty1,
-		tx2, ty1,
-		tx1, ty2,
-		tx2, ty2
-	};
-
-	//glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); // GL_MODULATE instead of decal mixes the colours!
-	setPrimaryColor(fontPal.originalRed / 255.f, fontPal.originalGreen / 255.f, fontPal.originalBlue / 255.f, 1.0f);
-
-	glBindTexture(GL_TEXTURE_2D, fontPal.tex_names[single.texNum]);
-
-	glUseProgram(shader.smartScaler);
-	GLuint uniform = glGetUniformLocation(shader.smartScaler, "useLightTexture");
-	if (uniform >= 0) glUniform1i(uniform, 0);
-
-	setPMVMatrix(shader.smartScaler);
-
-	if (gameSettings.antiAlias == 1) {
-		glUniform1i(glGetUniformLocation(shader.smartScaler, "antialias"), 1);
-	} else {
-		glUniform1i(glGetUniformLocation(shader.smartScaler, "antialias"), 0);
-	}
-
-	glEnable(GL_BLEND);
-
-	drawQuad(shader.smartScaler, vertices, 1, texCoords);
-
-	glDisable(GL_BLEND);
-	glUseProgram(0);
-#endif
 }
 
 void fontSprite(int x, int y, sprite &single, const spritePalette &fontPal) {
@@ -602,10 +445,6 @@ void setDrawMode(onScreenPerson *thisPerson) {
 #endif
 }
 
-#if 0
-extern GLuint backdropTextureName;
-#endif
-
 bool scaleSprite(sprite &single, const spritePalette &fontPal, onScreenPerson *thisPerson, bool mirror) {
 	float x = thisPerson->x;
 	float y = thisPerson->y;
diff --git a/engines/sludge/talk.cpp b/engines/sludge/talk.cpp
index 4523a7f..e92cd00 100644
--- a/engines/sludge/talk.cpp
+++ b/engines/sludge/talk.cpp
@@ -53,9 +53,7 @@ void initSpeech() {
 
 void killAllSpeech() {
 	if (speech->lastFile != -1) {
-#if 0
 		huntKillSound(speech->lastFile);
-#endif
 		speech->lastFile = -1;
 	}
 
@@ -111,13 +109,12 @@ int wrapSpeechXY(const Common::String &theText, int x, int y, int wrap, int samp
 		speechTime = 1;
 	if (sampleFile != -1) {
 		if (speechMode >= 1) {
-#if 0
 			if (startSound(sampleFile, false)) {
 				speechTime = -10;
 				speech->lastFile = sampleFile;
 				if (speechMode == 2) return -10;
 			}
-#endif
+
 		}
 	}
 	speech->speechY = y;
diff --git a/engines/sludge/thumbnail.cpp b/engines/sludge/thumbnail.cpp
index 820e5af..424feb4 100644
--- a/engines/sludge/thumbnail.cpp
+++ b/engines/sludge/thumbnail.cpp
@@ -35,10 +35,6 @@ void unfreeze(bool);    // Because FREEZE.H needs a load of other includes
 
 int thumbWidth = 0, thumbHeight = 0;
 
-#if 0
-extern GLuint backdropTextureName;
-#endif
-
 bool saveThumbnail(Common::WriteStream *stream) {
 #if 0
 	GLuint thumbnailTextureName = 0;
diff --git a/engines/sludge/transition.cpp b/engines/sludge/transition.cpp
index 83ec7df..306a51c 100644
--- a/engines/sludge/transition.cpp
+++ b/engines/sludge/transition.cpp
@@ -24,10 +24,6 @@
 #include "sludge/backdrop.h"
 #include "sludge/newfatal.h"
 
-#if 0
-extern GLuint snapshotTextureName;
-#endif
-
 namespace Sludge {
 
 extern byte brightnessLevel;
diff --git a/engines/sludge/variable.cpp b/engines/sludge/variable.cpp
index a1c736a..b13e123 100644
--- a/engines/sludge/variable.cpp
+++ b/engines/sludge/variable.cpp
@@ -194,12 +194,6 @@ bool copyStack(const variable &from, variable &to) {
 	return true;
 }
 
-/*void newStackVar (variable & thisVar) {
- unlinkVar (thisVar);
- thisVar.varType = VT_STACK;
- thisVar.varData.theStack = NULL;
- } */
-
 void addVariablesInSecond(variable &var1, variable &var2) {
 	if (var1.varType == SVT_INT && var2.varType == SVT_INT) {
 		var2.varData.intValue += var1.varData.intValue;
@@ -315,14 +309,6 @@ Common::String getTextFromAnyVar(const variable &from) {
 			return resourceNameFromNum(from.varData.intValue);
 		}
 
-			/*      case SVT_ANIM:
-			 {
-			 char * buff = new char[20];
-			 if (! checkNew (buff)) return NULL;
-			 sprintf (buff, "%p", from.varData.animHandler);
-			 return buff;
-			 }*/
-
 		case SVT_OBJTYPE: {
 			objectType *thisType = findObjectType(from.varData.intValue);
 			if (thisType)
diff --git a/engines/sludge/variable.h b/engines/sludge/variable.h
index 1cac125..6c0aff4 100644
--- a/engines/sludge/variable.h
+++ b/engines/sludge/variable.h
@@ -117,18 +117,6 @@ bool makeFastArrayFromStack(variable &to, const stackHandler *stacky);
 bool makeFastArraySize(variable &to, int size);
 variable *fastArrayGetByIndex(fastArrayHandler *vS, uint theIndex);
 
-#define DEBUG_STACKINESS    0
-
-#if DEBUG_STACKINESS
-#define stackDebug(params) {                            \
-		FILE * stackfp = fopen ("stackout.txt", "at");      \
-		fprintf params;                                     \
-		fclose (stackfp);                                   \
-	}
-#else
-#define stackDebug(a)  {}
-#endif
-
 } // End of namespace Sludge
 
 #endif
diff --git a/engines/sludge/zbuffer.cpp b/engines/sludge/zbuffer.cpp
index ea9fdfe..d9e66b8 100644
--- a/engines/sludge/zbuffer.cpp
+++ b/engines/sludge/zbuffer.cpp
@@ -178,59 +178,6 @@ void drawZBuffer(int x, int y, bool upsidedown) {
 		return;
 
 	resetSpriteLayers(&zBuffer, x, y, upsidedown);
+}
 
-#if 0
-	glEnable (GL_DEPTH_TEST);
-
-		glEnable(GL_DEPTH_TEST);
-		glEnable(GL_BLEND);
-		glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
-		glDepthMask(GL_TRUE);
-
-		glUseProgram(shader.texture);
-
-		setPMVMatrix(shader.texture);
-
-		//glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
-		glBindTexture(GL_TEXTURE_2D, zBuffer.texName);
-
-		setPrimaryColor(1.0, 1.0, 1.0, 1.0);
-
-		for (i = 1; i < zBuffer.numPanels; i++) {
-			GLfloat z = 1.0 - (double) i * (1.0 / 128.0);
-
-			GLfloat vy1 = -y, vy2 = zBuffer.height - y;
-			if (upsidedown) {
-				vy1 += zBuffer.height;
-				vy2 -= zBuffer.height;
-			}
-
-			const GLfloat vertices[] = {
-				(GLfloat) - x, vy1, z,
-				(GLfloat)zBuffer.width - x, vy1, z,
-				(GLfloat) - x, vy2, z,
-				(GLfloat)zBuffer.width - x, vy2, z
-			};
-
-			const GLfloat texCoords[] = {
-				0.0f, 0.0f,
-				backdropTexW, 0.0f,
-				0.0f, backdropTexH,
-				backdropTexW, backdropTexH
-			};
-
-			glUniform1i(glGetUniformLocation(shader.texture, "zBuffer"), 1);
-			glUniform1f(glGetUniformLocation(shader.texture, "zBufferLayer"), i);
-
-			drawQuad(shader.texture, vertices, 1, texCoords);
-			glUniform1i(glGetUniformLocation(shader.texture, "zBuffer"), 0);
-		}
-
-		glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
-		glDepthMask(GL_FALSE);
-		glDisable(GL_BLEND);
-		glUseProgram(0);
-#endif
-	}
-
-	} // End of namespace Sludge
+} // End of namespace Sludge


Commit: 89635193468b4b2967333cd181e06e7cb61ca4f2
    https://github.com/scummvm/scummvm/commit/89635193468b4b2967333cd181e06e7cb61ca4f2
Author: Simei Yin (roseline.yin at gmail.com)
Date: 2017-07-15T17:51:57+02:00

Commit Message:
SLUDGE: Clean unused extern variables

Changed paths:
    engines/sludge/builtin.cpp
    engines/sludge/loadsave.cpp
    engines/sludge/main_loop.cpp
    engines/sludge/objtypes.cpp
    engines/sludge/people.cpp
    engines/sludge/sludger.cpp
    engines/sludge/zbuffer.cpp


diff --git a/engines/sludge/builtin.cpp b/engines/sludge/builtin.cpp
index dbf9dfc..0d295af 100644
--- a/engines/sludge/builtin.cpp
+++ b/engines/sludge/builtin.cpp
@@ -68,10 +68,8 @@ extern eventHandlers *currentEvents;
 extern variableStack *noStack;
 extern statusStuff *nowStatus;
 extern screenRegion *overRegion;
-extern HWND hMainWindow;
 extern uint sceneWidth, sceneHeight;
 extern int numBIFNames, numUserFunc;
-extern char builtInFunctionNames[][25];
 
 extern Common::String *allUserFunc;
 extern Common::String *allBIFNames;
diff --git a/engines/sludge/loadsave.cpp b/engines/sludge/loadsave.cpp
index 0757067..6a653b9 100644
--- a/engines/sludge/loadsave.cpp
+++ b/engines/sludge/loadsave.cpp
@@ -64,12 +64,10 @@ extern personaAnimation *mouseCursorAnim;           // In cursor.cpp
 extern int mouseCursorFrameNum;                     // "    "   "
 extern int loadedFontNum, fontHeight;				// In fonttext.cpp
 extern uint fontTableSize;							// 
-extern int numFontColours;                          // "    "   "
 extern UTF8Converter fontOrder;                       // "    "   "
 extern FILETIME fileTime;                           // In sludger.cpp
 extern int speechMode;                              // "    "   "
 extern int lightMapNumber;                          // In backdrop.cpp
-extern uint sceneWidth, sceneHeight;        // "    "   "
 extern int cameraX, cameraY;                        // "    "   "
 extern float cameraZoom;
 extern byte brightnessLevel;               // "    "   "
diff --git a/engines/sludge/main_loop.cpp b/engines/sludge/main_loop.cpp
index 1f8a44e..d2dcd8e 100644
--- a/engines/sludge/main_loop.cpp
+++ b/engines/sludge/main_loop.cpp
@@ -49,8 +49,6 @@
 
 namespace Sludge {
 
-extern bool runningFullscreen;
-
 #ifndef MAX_PATH
 #define MAX_PATH        1024          // maximum size of a path name
 #endif
@@ -60,11 +58,9 @@ HWND hMainWindow = NULL;
 int realWinWidth = 640, realWinHeight = 480;
 extern float cameraZoom;
 
-extern int desiredfps;
 extern int specialSettings;
 extern inputType input;
 extern variableStack *noStack;
-extern Graphics::Surface backdropSurface;
 Graphics::Surface renderSurface;
 
 int dialogValue = 0;
diff --git a/engines/sludge/objtypes.cpp b/engines/sludge/objtypes.cpp
index f975167..8b7f258 100644
--- a/engines/sludge/objtypes.cpp
+++ b/engines/sludge/objtypes.cpp
@@ -31,7 +31,6 @@
 namespace Sludge {
 
 objectType *allObjectTypes = NULL;
-extern char *outputDir;
 
 #define DEBUG_COMBINATIONS  0
 
diff --git a/engines/sludge/people.cpp b/engines/sludge/people.cpp
index afc34cb..7d15086 100644
--- a/engines/sludge/people.cpp
+++ b/engines/sludge/people.cpp
@@ -50,12 +50,10 @@ extern variableStack *noStack;
 
 extern int ssgVersion;
 
-extern int cameraX, cameraY;
 screenRegion personRegion;
 extern screenRegion *lastRegion;
 extern flor *currentFloor;
 
-extern inputType input;
 onScreenPerson *allPeople = NULL;
 int16 scaleHorizon = 75;
 int16 scaleDivide = 150;
diff --git a/engines/sludge/sludger.cpp b/engines/sludge/sludger.cpp
index 41d2dd8..ff1e1f8 100644
--- a/engines/sludge/sludger.cpp
+++ b/engines/sludge/sludger.cpp
@@ -53,12 +53,9 @@
 namespace Sludge {
 
 extern personaAnimation *mouseCursorAnim;
-extern spritePalette pastePalette;
 extern int dialogValue;
-extern uint sceneWidth, sceneHeight;
 extern variable *launchResult;
 
-extern bool reallyWantToQuit;
 extern Graphics::Surface renderSurface;
 
 int numBIFNames = 0;
@@ -87,10 +84,8 @@ byte brightnessLevel = 255;
 eventHandlers mainHandlers;
 eventHandlers *currentEvents = &mainHandlers;
 
-extern HWND hMainWindow;
 extern screenRegion *overRegion;
 extern speechStruct *speech;
-extern statusStuff *nowStatus;
 extern loadedFunction *saverFunc;
 
 loadedFunction *allRunningFunctions = NULL;
diff --git a/engines/sludge/zbuffer.cpp b/engines/sludge/zbuffer.cpp
index d9e66b8..e3b3056 100644
--- a/engines/sludge/zbuffer.cpp
+++ b/engines/sludge/zbuffer.cpp
@@ -38,7 +38,6 @@ int zBufferToSet = -1;
 zBufferData zBuffer;
 extern uint sceneWidth, sceneHeight;
 extern Graphics::Surface backdropSurface;
-extern Graphics::Surface renderSurface;
 
 void killZBuffer() {
 	if (zBuffer.sprites) {


Commit: a44cf28ea334904fdd2ed0ad3ec830ac8ff758a6
    https://github.com/scummvm/scummvm/commit/a44cf28ea334904fdd2ed0ad3ec830ac8ff758a6
Author: Simei Yin (roseline.yin at gmail.com)
Date: 2017-07-15T17:51:57+02:00

Commit Message:
SLUDGE: Remove unused function displayFatal

Changed paths:
    engines/sludge/newfatal.cpp
    engines/sludge/newfatal.h


diff --git a/engines/sludge/newfatal.cpp b/engines/sludge/newfatal.cpp
index 027c9b0..acbcc14 100644
--- a/engines/sludge/newfatal.cpp
+++ b/engines/sludge/newfatal.cpp
@@ -53,14 +53,6 @@ bool hasFatal() {
 	return false;
 }
 
-void displayFatal() {
-	if (!g_sludge->fatalMessage.empty()) {
-#if 0
-		msgBox("SLUDGE v" TEXT_VERSION " fatal error!", fatalMessage);
-#endif
-	}
-}
-
 void registerWindowForFatal() {
 	g_sludge->fatalInfo = "There's an error with this SLUDGE game! If you're designing this game, please turn on verbose error messages in the project manager and recompile. If not, please contact the author saying where and how this problem occured.";
 }
diff --git a/engines/sludge/newfatal.h b/engines/sludge/newfatal.h
index f7e53a7..eb65db0 100644
--- a/engines/sludge/newfatal.h
+++ b/engines/sludge/newfatal.h
@@ -33,7 +33,6 @@ bool hasFatal();
 int fatal(const Common::String &str);
 int fatal(const Common::String &str1, const Common::String &str2);
 int checkNew(const void *mem);
-void displayFatal();
 void registerWindowForFatal();
 void setFatalInfo(const Common::String &userFunc, const Common::String &BIF);
 void setResourceForFatal(int n);


Commit: 22201ba764214a766f39f2df4d536b10132c127a
    https://github.com/scummvm/scummvm/commit/22201ba764214a766f39f2df4d536b10132c127a
Author: Simei Yin (roseline.yin at gmail.com)
Date: 2017-07-15T17:51:57+02:00

Commit Message:
SLUDGE: Move PixelFormat init to constructor

Changed paths:
    engines/sludge/sludge.cpp


diff --git a/engines/sludge/sludge.cpp b/engines/sludge/sludge.cpp
index e3754a7..6004e47 100644
--- a/engines/sludge/sludge.cpp
+++ b/engines/sludge/sludge.cpp
@@ -48,8 +48,9 @@ SludgeEngine::SludgeEngine(OSystem *syst, const SludgeGameDescription *gameDesc)
 	DebugMan.addDebugChannel(kSludgeDebugBuiltin, "Built-in", "Built-in debug level");
 	DebugMan.addDebugChannel(kSludgeDebugGraphics, "Graphics", "Graphics debug level");
 
-	// check init
-	debug("SludgeEngine::SludgeEngine");
+	// init graphics
+	_origFormat = new Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0);
+	_pixelFormat = new Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0);
 
 	// Init Strings
 	launchMe = "";
@@ -86,10 +87,6 @@ Common::Error SludgeEngine::run() {
 	// set global variable
 	g_sludge = this;
 
-	// init graphics
-	_origFormat = new Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0);
-	_pixelFormat = new Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0);
-
 	// create console
 	_console = new SludgeConsole(this);
 





More information about the Scummvm-git-logs mailing list