[Scummvm-cvs-logs] SF.net SVN: scummvm:[54035] scummvm/trunk/engines/m4

dreammaster at users.sourceforge.net dreammaster at users.sourceforge.net
Tue Nov 2 01:51:13 CET 2010


Revision: 54035
          http://scummvm.svn.sourceforge.net/scummvm/?rev=54035&view=rev
Author:   dreammaster
Date:     2010-11-02 00:51:12 +0000 (Tue, 02 Nov 2010)

Log Message:
-----------
M4: Converted all printf's to debug

Modified Paths:
--------------
    scummvm/trunk/engines/m4/assets.cpp
    scummvm/trunk/engines/m4/converse.cpp
    scummvm/trunk/engines/m4/events.cpp
    scummvm/trunk/engines/m4/font.cpp
    scummvm/trunk/engines/m4/globals.cpp
    scummvm/trunk/engines/m4/graphics.cpp
    scummvm/trunk/engines/m4/hotspot.cpp
    scummvm/trunk/engines/m4/m4.cpp
    scummvm/trunk/engines/m4/m4.h
    scummvm/trunk/engines/m4/m4_scene.cpp
    scummvm/trunk/engines/m4/mads_anim.cpp
    scummvm/trunk/engines/m4/mads_menus.cpp
    scummvm/trunk/engines/m4/rails.cpp
    scummvm/trunk/engines/m4/resource.cpp
    scummvm/trunk/engines/m4/script.cpp
    scummvm/trunk/engines/m4/script.h
    scummvm/trunk/engines/m4/sound.cpp
    scummvm/trunk/engines/m4/woodscript.cpp
    scummvm/trunk/engines/m4/ws_machine.cpp
    scummvm/trunk/engines/m4/ws_sequence.cpp

Modified: scummvm/trunk/engines/m4/assets.cpp
===================================================================
--- scummvm/trunk/engines/m4/assets.cpp	2010-11-02 00:15:18 UTC (rev 54034)
+++ scummvm/trunk/engines/m4/assets.cpp	2010-11-02 00:51:12 UTC (rev 54035)
@@ -147,9 +147,9 @@
 
 	uint32 header = _stream->readUint32LE();
 	if (header == HEAD_M4SS) {
-		printf("LE-encoded sprite\n");
+		debugC(kDebugGraphics, "LE-encoded sprite\n");
 	} else {
-		printf("BE-encoded sprite\n");
+		debugC(kDebugGraphics, "BE-encoded sprite\n");
 		isBigEndian = true;
 	}
 
@@ -163,7 +163,7 @@
 	_stream->skip(6 * 4);
 	_frameCount = (!isBigEndian) ? _stream->readUint32LE() : _stream->readUint32BE();
 
-	printf("SpriteAsset::SpriteAsset() srcSize = %d; frameRate = %04X; pixelSpeed = %04X; maxWidth = %d; maxHeight = %d; frameCount = %d\n", _srcSize, _frameRate, _pixelSpeed, _maxWidth, _maxHeight, _frameCount);
+	debugC(kDebugGraphics, "SpriteAsset::SpriteAsset() srcSize = %d; frameRate = %04X; pixelSpeed = %04X; maxWidth = %d; maxHeight = %d; frameCount = %d\n", _srcSize, _frameRate, _pixelSpeed, _maxWidth, _maxHeight, _frameCount);
 
 	for (int curFrame = 0; curFrame < _frameCount; curFrame++) {
 		frameOffset = (!isBigEndian) ? _stream->readUint32LE() : _stream->readUint32BE();
@@ -345,7 +345,7 @@
 	if (chunkType == CELS___SS) {
 		chunkSize = (!isBigEndian) ? _stream->readUint32LE() : _stream->readUint32BE();
 	} else {
-		warning("SpriteAsset::parseSprite() Expected chunk type %08X, got %08X", CELS___SS, chunkType);
+		debugC(kDebugGraphics, "SpriteAsset::parseSprite() Expected chunk type %08X, got %08X", CELS___SS, chunkType);
 	}
 
 	return chunkSize;
@@ -362,14 +362,14 @@
 	frameHeader.comp = (!isBigEndian) ? _stream->readUint32LE() : _stream->readUint32BE();
 	frameHeader.frame = NULL;
 	_stream->seek(8 * 4, SEEK_CUR);
-	//printf("SpriteAsset::loadFrameHeader() stream = %d; x = %d; y = %d; w = %d; h = %d; comp = %d\n", frameHeader.stream, frameHeader.x, frameHeader.y, frameHeader.w, frameHeader.h, frameHeader.comp);
+	//debugC(kDebugGraphics, "SpriteAsset::loadFrameHeader() stream = %d; x = %d; y = %d; w = %d; h = %d; comp = %d\n", frameHeader.stream, frameHeader.x, frameHeader.y, frameHeader.w, frameHeader.h, frameHeader.comp);
 }
 
 M4Sprite *SpriteAsset::getFrame(int frameIndex) {
 	if ((uint)frameIndex < _frames.size()) {
 		return _frames[frameIndex].frame;
 	} else {
-		warning("SpriteAsset::getFrame: Invalid frame %d, out of %d", frameIndex, _frames.size());
+		debugC(kDebugGraphics, "SpriteAsset::getFrame: Invalid frame %d, out of %d", frameIndex, _frames.size());
 		return _frames[_frames.size() - 1].frame;
 	}
 }
@@ -486,7 +486,7 @@
 
 bool AssetManager::loadAsset(const char *assetName, RGB8 *palette) {
 
-	printf("AssetManager::loadAsset() %s\n", assetName);
+	debugC(kDebugGraphics, "AssetManager::loadAsset() %s\n", assetName);
 
 	// TODO, better use MemoryReadStreamEndian?
 	//convertAssetToLE(assetData, assetSize);
@@ -500,34 +500,34 @@
 		chunkSize = assetS->readUint32LE() - 12; // sub 12 for the chunk header
 		chunkHash = assetS->readUint32LE();
 
-		printf("hash = %d\n", chunkHash);
+		debugC(kDebugGraphics, "hash = %d\n", chunkHash);
 
 		// Until loading code is complete, so that chunks not fully read are skipped correctly
 		uint32 nextOfs = assetS->pos() + chunkSize;
 
 		switch (chunkType) {
 		case CHUNK_MACH:
-			printf("MACH\n");
+			debugC(kDebugGraphics, "MACH\n");
 			clearAssets(kAssetTypeMACH, chunkHash, chunkHash);
 			_MACH[chunkHash] = new MachineAsset(_vm, assetS, chunkSize, assetName);
 			break;
 		case CHUNK_SEQU:
-			printf("SEQU\n");
+			debugC(kDebugGraphics, "SEQU\n");
 			clearAssets(kAssetTypeSEQU, chunkHash, chunkHash);
 			_SEQU[chunkHash] = new SequenceAsset(_vm, assetS, chunkSize, assetName);
 			break;
 		case CHUNK_DATA:
-			printf("DATA\n");
+			debugC(kDebugGraphics, "DATA\n");
 			clearAssets(kAssetTypeDATA, chunkHash, chunkHash);
 			_DATA[chunkHash] = new DataAsset(_vm, assetS, chunkSize, assetName);
 			break;
 		case CHUNK_CELS:
-			printf("CELS\n");
+			debugC(kDebugGraphics, "CELS\n");
 			clearAssets(kAssetTypeCELS, chunkHash, chunkHash);
 			_CELS[chunkHash] = new SpriteAsset(_vm, assetS, chunkSize, assetName);
 			break;
 		default:
-			printf("AssetManager::loadAsset() Unknown chunk type %08X\n", chunkType);
+			debug(kDebugGraphics, "AssetManager::loadAsset() Unknown chunk type %08X\n", chunkType);
 		}
 
 		// Until loading code is complete (see above)
@@ -568,7 +568,7 @@
 
 	if (!alreadyLoaded) {
 
-		printf("AssetManager::addSpriteAsset() asset %s not loaded, loading into %d\n", assetName, hash);
+		debugC(kDebugGraphics, "AssetManager::addSpriteAsset() asset %s not loaded, loading into %d\n", assetName, hash);
 
 		clearAssets(kAssetTypeCELS, hash, hash);
 
@@ -578,7 +578,7 @@
 
 	} else {
 
-		printf("AssetManager::addSpriteAsset()  asset %s already loaded in %d\n", assetName, hash);
+		debugC(kDebugGraphics, "AssetManager::addSpriteAsset()  asset %s already loaded in %d\n", assetName, hash);
 
 		/* TODO/FIXME
 		if (_CELS[hash].palOffset >= 0 && palette)

Modified: scummvm/trunk/engines/m4/converse.cpp
===================================================================
--- scummvm/trunk/engines/m4/converse.cpp	2010-11-02 00:15:18 UTC (rev 54034)
+++ scummvm/trunk/engines/m4/converse.cpp	2010-11-02 00:51:12 UTC (rev 54035)
@@ -118,7 +118,7 @@
 			_activeItems.push_back(node->entries[i]);
 
 			if (node->entries[i]->autoSelect || strlen(node->entries[i]->text) == 0) {
-				//printf("Auto selecting entry %i of node %i\n", i, nodeIndex);
+				//warning(kDebugConversations, "Auto selecting entry %i of node %i\n", i, nodeIndex);
 				selectEntry(i);
 				return;
 			}
@@ -134,11 +134,11 @@
 
 		// Fallthrough
 		if (node->fallthroughMinEntries >= 0 && node->fallthroughOffset >= 0) {
-			//printf("Current node falls through node at offset %i when entries are less or equal than %i\n",
+			//warning(kDebugConversations, "Current node falls through node at offset %i when entries are less or equal than %i\n",
 			//		node->fallthroughOffset, node->fallthroughMinEntries);
 			if (_activeItems.size() <= (uint32)node->fallthroughMinEntries) {
 				const EntryInfo *entryInfo = _m4Vm->_converse->getEntryInfo(node->fallthroughOffset);
-				//printf("Entries are less than or equal to %i, falling through to node at offset %i, index %i\n",
+				//warning(kDebugConversations, "Entries are less than or equal to %i, falling through to node at offset %i, index %i\n",
 				//		node->fallthroughMinEntries, node->fallthroughOffset, entryInfo->nodeIndex);
 				setNode(entryInfo->nodeIndex);
 				return;
@@ -227,10 +227,10 @@
 
 	// Hide selected entry, unless it has a persistent flag set
 	if (!(_activeItems[entryIndex]->flags & kEntryPersists)) {
-		//printf("Hiding selected entry\n");
+		//debug(kDebugConversations, "Hiding selected entry\n");
 		_m4Vm->_converse->getNode(_currentNodeIndex)->entries[entryIndex]->visible = false;
 	} else {
-		//printf("Selected entry is persistent, not hiding it\n");
+		//debug(kDebugConversations, "Selected entry is persistent, not hiding it\n");
 	}
 }
 
@@ -286,7 +286,7 @@
 			}
 		} else {
 			int selectedWeight = _vm->_random->getRandomNumber(currentEntry->totalWeight - 1) + 1;
-			//printf("Selected weight: %i\n", selectedWeight);
+			//debug(kDebugConversations, "Selected weight: %i\n", selectedWeight);
 			int previousWeight = 1;
 			int currentWeight = 0;
 
@@ -313,7 +313,7 @@
 
 	// If we reached here, there are no more replies, so perform the active entry's actions
 
-	//printf("Current selection does %i actions\n", _activeItems[entryIndex]->actions.size());
+	//debug(kDebugConversations, "Current selection does %i actions\n", _activeItems[entryIndex]->actions.size());
 	for (uint32 i = 0; i < _activeItems[_highlightedIndex]->actions.size(); i++) {
 		if (!_m4Vm->_converse->performAction(_activeItems[_highlightedIndex]->actions[i]))
 			break;
@@ -399,30 +399,30 @@
 		return;
 	}
 	size = convS->readUint32LE();	// is this used at all?
-	if (debugFlag) printf("Conv chunk size (external header): %i\n", size);
+	if (debugFlag) debug(kDebugConversations, "Conv chunk size (external header): %i\n", size);
 
 	// Conversation name, which is the conversation file's name
 	// without the extension
 	convS->read(buffer, 8);
-	if (debugFlag) printf("Conversation name: %s\n", buffer);
+	if (debugFlag) debug(kDebugConversations, "Conversation name: %s\n", buffer);
 
 	while (true) {
 		chunkPos = convS->pos();
 		chunk = convS->readUint32LE();	// read chunk
 		if (convS->eos()) break;
 
-		if (debugFlag) printf("***** Pos: %i -> ", chunkPos);
+		if (debugFlag) debug(kDebugConversations, "***** Pos: %i -> ", chunkPos);
 		switch (chunk) {
 			case CHUNK_DECL:	// Declare
-				if (debugFlag) printf("DECL chunk\n");
+				if (debugFlag) debug(kDebugConversations, "DECL chunk\n");
 				data = convS->readUint32LE();
-				if (debugFlag) printf("Tag: %i\n", data);
+				if (debugFlag) debug(kDebugConversations, "Tag: %i\n", data);
 				if (data > 0)
 					warning("Tag > 0 in DECL chunk, value is: %i", data);		// TODO
 				val = convS->readUint32LE();
-				if (debugFlag) printf("Value: %i\n", val);
+				if (debugFlag) debug(kDebugConversations, "Value: %i\n", val);
 				data = convS->readUint32LE();
-				if (debugFlag) printf("Flags: %i\n", data);
+				if (debugFlag) debug(kDebugConversations, "Flags: %i\n", data);
 				if (data > 0)
 					warning("Flags != 0 in DECL chunk, value is %i", data);		// TODO
 				setValue(chunkPos, val);
@@ -437,23 +437,23 @@
 				curEntry->fallthroughMinEntries = -1;
 				curEntry->fallthroughOffset = -1;
 				if (chunk == CHUNK_NODE) {
-					if (debugFlag) printf("NODE chunk\n");
+					if (debugFlag) debug(kDebugConversations, "NODE chunk\n");
 				} else {
-					if (debugFlag) printf("LNOD chunk\n");
+					if (debugFlag) debug(kDebugConversations, "LNOD chunk\n");
 				}
 				curNode = convS->readUint32LE();
-				if (debugFlag) printf("Node number: %i\n", curNode);
+				if (debugFlag) debug(kDebugConversations, "Node number: %i\n", curNode);
 				data = convS->readUint32LE();
-				if (debugFlag) printf("Tag: %i\n", data);
+				if (debugFlag) debug(kDebugConversations, "Tag: %i\n", data);
 				if (chunk == CHUNK_LNOD) {
 					autoSelectIndex = convS->readUint32LE();
-					if (debugFlag) printf("Autoselect entry number: %i\n", autoSelectIndex);
+					if (debugFlag) debug(kDebugConversations, "Autoselect entry number: %i\n", autoSelectIndex);
 				}
 				size = convS->readUint32LE();
-				if (debugFlag) printf("Number of entries: %i\n", size);
+				if (debugFlag) debug(kDebugConversations, "Number of entries: %i\n", size);
 				for (i = 0; i < size; i++) {
 					data = convS->readUint32LE();
-					if (debugFlag) printf("Entry %i: %i\n", i + 1, data);
+					if (debugFlag) debug(kDebugConversations, "Entry %i: %i\n", i + 1, data);
 				}
 				_convNodes.push_back(curEntry);
 				setEntryInfo(curEntry->offset, curEntry->entryType, curNode, -1);
@@ -465,14 +465,14 @@
 				curEntry->entryType = kEntry;
 				strcpy(curEntry->voiceFile, "");
 				strcpy(curEntry->text, "");
-				if (debugFlag) printf("ETRY chunk\n");
+				if (debugFlag) debug(kDebugConversations, "ETRY chunk\n");
 				data = convS->readUint32LE();
-				if (debugFlag) printf("Unknown (attributes perhaps?): %i\n", data);
+				if (debugFlag) debug(kDebugConversations, "Unknown (attributes perhaps?): %i\n", data);
 				data = convS->readUint32LE();
-				if (debugFlag) printf("Entry flags: ");
+				if (debugFlag) debug(kDebugConversations, "Entry flags: ");
 				if (debugFlag) if (data & kEntryInitial) printf ("Initial ");
 				if (debugFlag) if (data & kEntryPersists) printf ("Persists ");
-				if (debugFlag) printf("\n");
+				if (debugFlag) debug(kDebugConversations, "\n");
 				curEntry->flags = data;
 				curEntry->visible = (curEntry->flags & kEntryInitial) ? true : false;
 				if (autoSelectIndex >= 0) {
@@ -517,28 +517,28 @@
 				if (chunk == CHUNK_WPRL || chunk == CHUNK_WRPL) {
 					replyEntry->entryType = kWeightedReply;
 					replyEntry->totalWeight = 0;
-					if (debugFlag) printf("WRPL chunk\n");
+					if (debugFlag) debug(kDebugConversations, "WRPL chunk\n");
 					size = convS->readUint32LE();
-					if (debugFlag) printf("Weighted reply %i - %i entries:\n", i, size);
+					if (debugFlag) debug(kDebugConversations, "Weighted reply %i - %i entries:\n", i, size);
 					for (i = 0; i < size; i++) {
 						weightedEntry = new ConvEntry();
 						weightedEntry->offset = chunkPos;
 						strcpy(weightedEntry->voiceFile, "");
 						weightedEntry->entryType = kWeightedReply;
 						data = convS->readUint32LE();
-						if (debugFlag) printf("- Weight: %i ", data);
+						if (debugFlag) debug(kDebugConversations, "- Weight: %i ", data);
 						weightedEntry->weight = data;
 						replyEntry->totalWeight += weightedEntry->weight;
 						data = convS->readUint32LE();
-						if (debugFlag) printf("offset: %i\n", data);
+						if (debugFlag) debug(kDebugConversations, "offset: %i\n", data);
 						replyEntry->entries.push_back(weightedEntry);
 					}
 					currentWeightedEntry = 0;
 				} else {
 					replyEntry->entryType = kReply;
-					if (debugFlag) printf("RPLY chunk\n");
+					if (debugFlag) debug(kDebugConversations, "RPLY chunk\n");
 					data = convS->readUint32LE();
-					if (debugFlag) printf("Reply data offset: %i\n", data);
+					if (debugFlag) debug(kDebugConversations, "Reply data offset: %i\n", data);
 				}
 
 				if (!curEntry)
@@ -563,9 +563,9 @@
 				{
 				ConvEntry* parentEntry = NULL;
 				if (chunk == CHUNK_TEXT) {
-					if (debugFlag) printf("TEXT chunk\n");
+					if (debugFlag) debug(kDebugConversations, "TEXT chunk\n");
 				} else {
-					if (debugFlag) printf("MESG chunk\n");
+					if (debugFlag) debug(kDebugConversations, "MESG chunk\n");
 				}
 
 				if (replyEntry == NULL) {
@@ -580,22 +580,22 @@
 				}
 
 				size = convS->readUint32LE();
-				if (debugFlag) printf("Entry data size: %i\n", size);
+				if (debugFlag) debug(kDebugConversations, "Entry data size: %i\n", size);
 				convS->read(buffer, 8);
 				size -= 8;		// subtract maximum length of voice file name
 				// If the file name is 8 characters, it will not be 0-terminated, so use strncpy
 				strncpy(parentEntry->voiceFile, buffer, 8);
 				parentEntry->voiceFile[8] = '\0';
-				if (debugFlag) printf("Voice file: %s\n", parentEntry->voiceFile);
+				if (debugFlag) debug(kDebugConversations, "Voice file: %s\n", parentEntry->voiceFile);
 
 				if (chunk == CHUNK_TEXT) {
 					convS->read(buffer, size);
-					if (debugFlag) printf("Text: %s\n", buffer);
+					if (debugFlag) debug(kDebugConversations, "Text: %s\n", buffer);
 					sprintf(parentEntry->text, "%s", buffer);
 				} else {
 					while (size > 0) {
 						data = convS->readUint32LE();
-						if (debugFlag) printf("Unknown: %i\n", data);	// TODO
+						if (debugFlag) debug(kDebugConversations, "Unknown: %i\n", data);	// TODO
 						size -= 4;
 					}
 				}
@@ -612,7 +612,7 @@
 			case CHUNK_CASN:	// Conditional assign
 			case CHUNK_ASGN:	// Assign
 				curAction = new EntryAction();
-				if (debugFlag) printf("ASGN chunk\n");
+				if (debugFlag) debug(kDebugConversations, "ASGN chunk\n");
 				curAction->actionType = kAssignValue;
 
 				// Conditional part
@@ -655,32 +655,32 @@
 
 				if (chunk == CHUNK_GOTO || chunk == CHUNK_CCGO) {
 					curAction->actionType = kGotoEntry;
-					if (debugFlag) printf("GOTO chunk\n");
+					if (debugFlag) debug(kDebugConversations, "GOTO chunk\n");
 				} else if (chunk == CHUNK_HIDE || chunk == CHUNK_CHDE) {
 					curAction->actionType = kHideEntry;
-					if (debugFlag) printf("HIDE chunk\n");
+					if (debugFlag) debug(kDebugConversations, "HIDE chunk\n");
 				} else if (chunk == CHUNK_UHID || chunk == CHUNK_CUHD) {
 					curAction->actionType = kUnhideEntry;
-					if (debugFlag) printf("UHID chunk\n");
+					if (debugFlag) debug(kDebugConversations, "UHID chunk\n");
 				} else if (chunk == CHUNK_DSTR || chunk == CHUNK_CDST) {
 					curAction->actionType = kDestroyEntry;
-					if (debugFlag) printf("DSTR chunk\n");
+					if (debugFlag) debug(kDebugConversations, "DSTR chunk\n");
 				} else if (chunk == CHUNK_EXIT || chunk == CHUNK_CEGO) {
 					curAction->actionType = kExitConv;
-					if (debugFlag) printf("EXIT chunk\n");
+					if (debugFlag) debug(kDebugConversations, "EXIT chunk\n");
 				}
 				data = convS->readUint32LE();
-				if (debugFlag) printf("Offset: %i\n", data);
+				if (debugFlag) debug(kDebugConversations, "Offset: %i\n", data);
 				curAction->targetOffset = data;
 				curEntry->actions.push_back(curAction);
 				break;
 			case CHUNK_FALL:	// Fallthrough
-				if (debugFlag) printf("FALL chunk\n");
+				if (debugFlag) debug(kDebugConversations, "FALL chunk\n");
 				size = convS->readUint32LE();
-				if (debugFlag) printf("Minimum nodes: %i\n", size);
+				if (debugFlag) debug(kDebugConversations, "Minimum nodes: %i\n", size);
 				_convNodes[curNode]->fallthroughMinEntries = size;
 				data = convS->readUint32LE();
-				if (debugFlag) printf("Offset: %i\n", data);
+				if (debugFlag) debug(kDebugConversations, "Offset: %i\n", data);
 				_convNodes[curNode]->fallthroughOffset = data;
 				break;
 			// ----------------------------------------------------------------------------
@@ -718,35 +718,35 @@
 	// ------------------------------------------------------------
 	// Chunk 0
 	convS = convDataD.getItemStream(0);
-	printf("Chunk 0\n");
-	printf("Conv stream size: %i\n", convS->size());
+	debug(kDebugConversations, "Chunk 0\n");
+	debug(kDebugConversations, "Conv stream size: %i\n", convS->size());
 
 	while (!convS->eos()) { // FIXME (eos changed)
-		printf("%i ", convS->readByte());
+		debug(kDebugConversations, "%i ", convS->readByte());
 	}
-	printf("\n");
+	debug(kDebugConversations, "\n");
 
 	// ------------------------------------------------------------
 	// Chunk 1
 	convS = convDataD.getItemStream(1);
-	printf("Chunk 1\n");
-	printf("Conv stream size: %i\n", convS->size());
+	debug(kDebugConversations, "Chunk 1\n");
+	debug(kDebugConversations, "Conv stream size: %i\n", convS->size());
 
 	while (!convS->eos()) { // FIXME (eos changed)
-		printf("%i ", convS->readByte());
+		debug(kDebugConversations, "%i ", convS->readByte());
 	}
-	printf("\n");
+	debug(kDebugConversations, "\n");
 
 	// ------------------------------------------------------------
 	// Chunk 2
 	convS = convDataD.getItemStream(2);
-	printf("Chunk 2\n");
-	printf("Conv stream size: %i\n", convS->size());
+	debug(kDebugConversations, "Chunk 2\n");
+	debug(kDebugConversations, "Conv stream size: %i\n", convS->size());
 
 	while (!convS->eos()) { // FIXME (eos changed)
-		printf("%i ", convS->readByte());
+		debug(kDebugConversations, "%i ", convS->readByte());
 	}
-	printf("\n");
+	debug(kDebugConversations, "\n");
 
 	// ------------------------------------------------------------
 	// CNV file
@@ -769,46 +769,46 @@
 	// TODO: finish this
 	// Chunk 0
 	convS = convData.getItemStream(0);
-	printf("Chunk 0\n");
-	printf("Conv stream size: %i\n", convS->size());
-	printf("%i ", convS->readUint16LE());
-	printf("%i ", convS->readUint16LE());
-	printf("%i ", convS->readUint16LE());
-	printf("%i ", convS->readUint16LE());
-	printf("%i ", convS->readUint16LE());
-	printf("%i ", convS->readUint16LE());
-	printf("\n");
+	debug(kDebugConversations, "Chunk 0\n");
+	debug(kDebugConversations, "Conv stream size: %i\n", convS->size());
+	debug(kDebugConversations, "%i ", convS->readUint16LE());
+	debug(kDebugConversations, "%i ", convS->readUint16LE());
+	debug(kDebugConversations, "%i ", convS->readUint16LE());
+	debug(kDebugConversations, "%i ", convS->readUint16LE());
+	debug(kDebugConversations, "%i ", convS->readUint16LE());
+	debug(kDebugConversations, "%i ", convS->readUint16LE());
+	debug(kDebugConversations, "\n");
 	count = convS->readUint16LE();	// conversation face count (usually 2)
-	printf("Conversation faces: %i\n", count);
+	debug(kDebugConversations, "Conversation faces: %i\n", count);
 	for (i = 0; i < 5; i++) {
 		convS->read(buffer, 16);
-		printf("Face %i: %s ", i + 1, buffer);
+		debug(kDebugConversations, "Face %i: %s ", i + 1, buffer);
 	}
-	printf("\n");
+	debug(kDebugConversations, "\n");
 
 	// 5 face slots
 	// 1 = face slot has a face (with the filename specified above)
 	// 0 = face slot doesn't contain face data
 	for (i = 0; i < 5; i++) {
-		printf("%i ", convS->readUint16LE());
+		debug(kDebugConversations, "%i ", convS->readUint16LE());
 	}
-	printf("\n");
+	debug(kDebugConversations, "\n");
 
 	convS->read(buffer, 14);		// speech file
-	printf("Speech file: %s\n", buffer);
+	debug(kDebugConversations, "Speech file: %s\n", buffer);
 
 	while (!convS->eos()) { // FIXME: eos changed
-		printf("%i ", convS->readByte());
+		debug(kDebugConversations, "%i ", convS->readByte());
 	}
-	printf("\n");
+	debug(kDebugConversations, "\n");
 
 	delete convS;
 
 	// ------------------------------------------------------------
 	// Chunk 1: Conversation nodes
 	convS = convData.getItemStream(1);
-	printf("Chunk 1: conversation nodes\n");
-	printf("Conv stream size: %i\n", convS->size());
+	debug(kDebugConversations, "Chunk 1: conversation nodes\n");
+	debug(kDebugConversations, "Conv stream size: %i\n", convS->size());
 
 	while (true) {
 		uint16 id = convS->readUint16LE();
@@ -828,12 +828,12 @@
 		unk = convS->readUint16LE();
 		assert (unk == 65535);
 		_convNodes.push_back(curEntry);
-		printf("Node %i, ID %i, entries %i\n", _convNodes.size(), curEntry->id, curEntry->entryCount);
+		debug(kDebugConversations, "Node %i, ID %i, entries %i\n", _convNodes.size(), curEntry->id, curEntry->entryCount);
 		// flags = 0: node has more than 1 entry
 		// flags = 65535: node has 1 entry
 	}
-	printf("Conversation has %i nodes\n", _convNodes.size());
-	printf("\n");
+	debug(kDebugConversations, "Conversation has %i nodes\n", _convNodes.size());
+	debug(kDebugConversations, "\n");
 
 	delete convS;
 
@@ -844,14 +844,14 @@
 	// ------------------------------------------------------------
 	// Chunk 5 contains the conversation strings
 	convS = convData.getItemStream(5);
-	//printf("Chunk 5: conversation strings\n");
-	//printf("Conv stream size: %i\n", convS->size());
+	//debug(kDebugConversations, "Chunk 5: conversation strings\n");
+	//debug(kDebugConversations, "Conv stream size: %i\n", convS->size());
 
 	*buffer = 0;
 
 	while (true) {
 		//if (curPos == 0)
-		//	printf("%i: Offset %i: ", _convStrings.size(), convS->pos());
+		//	debug(kDebugConversations, "%i: Offset %i: ", _convStrings.size(), convS->pos());
 		uint8 b = convS->readByte();
 		if (convS->eos()) break;
 
@@ -862,7 +862,7 @@
 		}
 		if (buffer[curPos - 1] == '\0') {
 			// end of string
-			//printf("%s\n", buffer);
+			//debug(kDebugConversations, "%s\n", buffer);
 			buf = new char[strlen(buffer) + 1];
 			strcpy(buf, buffer);
 			_convStrings.push_back(buf);
@@ -876,8 +876,8 @@
 	// ------------------------------------------------------------
 	// Chunk 2: entry data
 	convS = convData.getItemStream(2);
-	//printf("Chunk 2 - entry data\n");
-	//printf("Conv stream size: %i\n", convS->size());
+	//debug(kDebugConversations, "Chunk 2 - entry data\n");
+	//debug(kDebugConversations, "Conv stream size: %i\n", convS->size());
 
 	for (i = 0; i < _convNodes.size(); i++) {
 		for (j = 0; j < _convNodes[i]->entryCount; j++) {
@@ -892,7 +892,7 @@
 			curEntry->size = convS->readUint16LE();
 
 			_convNodes[i]->entries.push_back(curEntry);
-			//printf("Node %i, entry %i, id %i, offset %i, size %i, text: %s\n",
+			//debug(kDebugConversations, "Node %i, entry %i, id %i, offset %i, size %i, text: %s\n",
 			//		i, j, curEntry->id, curEntry->offset, curEntry->size, curEntry->text);
 		}
 	}
@@ -902,8 +902,8 @@
 	// ------------------------------------------------------------
 	// Chunk 3: message (MESG) chunks, created from the strings of chunk 5
 	convS = convData.getItemStream(3);
-	//printf("Chunk 3 - MESG chunk data\n");
-	//printf("Conv stream size: %i\n", convS->size());
+	//debug(kDebugConversations, "Chunk 3 - MESG chunk data\n");
+	//debug(kDebugConversations, "Conv stream size: %i\n", convS->size());
 
 	while (true) {
 		uint16 index = convS->readUint16LE();
@@ -913,15 +913,15 @@
 		stringIndex = index;
 		stringCount = convS->readUint16LE();
 		*buffer = 0;
-		//printf("Message: %i\n", _madsMessageList.size());
+		//debug(kDebugConversations, "Message: %i\n", _madsMessageList.size());
 		for (i = stringIndex; i < stringIndex + stringCount; i++) {
-			//printf("%i: %s\n", i, _convStrings[i]);
+			//debug(kDebugConversations, "%i: %s\n", i, _convStrings[i]);
 			curMessage->messageStrings.push_back(_convStrings[i]);
 		}
 		_madsMessageList.push_back(curMessage);
-		//printf("----------\n");
+		//debug(kDebugConversations, "----------\n");
 	}
-	//printf("\n");
+	//debug(kDebugConversations, "\n");
 
 	delete convS;
 
@@ -929,31 +929,31 @@
 	// TODO: finish this
 	// Chunk 6: conversation script
 	convS = convData.getItemStream(6);
-	printf("Chunk 6\n");
-	printf("Conv stream size: %i\n", convS->size());
+	debug(kDebugConversations, "Chunk 6\n");
+	debug(kDebugConversations, "Conv stream size: %i\n", convS->size());
 	/*while (!convS->eos()) { // FIXME (eos changed)
-		printf("%i ", convS->readByte());
-		printf("%i ", convS->readByte());
-		printf("%i ", convS->readByte());
-		printf("%i ", convS->readByte());
-		printf("%i ", convS->readByte());
-		printf("%i ", convS->readByte());
-		printf("%i ", convS->readByte());
-		printf("%i ", convS->readByte());
-		printf("%i ", convS->readByte());
-		printf("%i ", convS->readByte());
-		printf("\n");
+		debug(kDebugConversations, "%i ", convS->readByte());
+		debug(kDebugConversations, "%i ", convS->readByte());
+		debug(kDebugConversations, "%i ", convS->readByte());
+		debug(kDebugConversations, "%i ", convS->readByte());
+		debug(kDebugConversations, "%i ", convS->readByte());
+		debug(kDebugConversations, "%i ", convS->readByte());
+		debug(kDebugConversations, "%i ", convS->readByte());
+		debug(kDebugConversations, "%i ", convS->readByte());
+		debug(kDebugConversations, "%i ", convS->readByte());
+		debug(kDebugConversations, "%i ", convS->readByte());
+		debug(kDebugConversations, "\n");
 	}
 	return;*/
 
 	for (i = 0; i < _convNodes.size(); i++) {
 		for (j = 0; j < _convNodes[i]->entryCount; j++) {
-			printf("*** Node %i entry %i data size %i\n", i, j, _convNodes[i]->entries[j]->size);
-			printf("Entry ID %i, text %s\n", _convNodes[i]->entries[j]->id, _convNodes[i]->entries[j]->text);
+			debug(kDebugConversations, "*** Node %i entry %i data size %i\n", i, j, _convNodes[i]->entries[j]->size);
+			debug(kDebugConversations, "Entry ID %i, text %s\n", _convNodes[i]->entries[j]->id, _convNodes[i]->entries[j]->text);
 			Common::SubReadStream *entryStream = new Common::SubReadStream(convS, _convNodes[i]->entries[j]->size);
 			readConvEntryActions(entryStream, _convNodes[i]->entries[j]);
 			delete entryStream;
-			printf("--------------------\n");
+			debug(kDebugConversations, "--------------------\n");
 		}
 	}
 
@@ -978,50 +978,50 @@
 
 		switch (chunk) {
 		case 1:
-			printf("TODO: chunk type %i\n", chunk);
+			debug(kDebugConversations, "TODO: chunk type %i\n", chunk);
 			break;
 		case 2:
-			printf("HIDE\n");
+			debug(kDebugConversations, "HIDE\n");
 			convS->readByte();
 			count = convS->readByte();
-			printf("%i entries: ", count);
+			debug(kDebugConversations, "%i entries: ", count);
 			for (int i = 0; i < count; i++)
-				printf("%i %d", i, convS->readUint16LE());
-			printf("\n");
+				debug(kDebugConversations, "%i %d", i, convS->readUint16LE());
+			debug(kDebugConversations, "\n");
 			break;
 		case 3:
-			printf("UNHIDE\n");
+			debug(kDebugConversations, "UNHIDE\n");
 			convS->readByte();
 			count = convS->readByte();
-			printf("%i entries: ", count);
+			debug(kDebugConversations, "%i entries: ", count);
 			for (int i = 0; i < count; i++)
-				printf("%i %d", i, convS->readUint16LE());
-			printf("\n");
+				debug(kDebugConversations, "%i %d", i, convS->readUint16LE());
+			debug(kDebugConversations, "\n");
 			break;
 		case 4:		// MESSAGE
-			printf("MESSAGE\n");
+			debug(kDebugConversations, "MESSAGE\n");
 
 			if (type == 255) {
-				//printf("unconditional\n");
+				//debug(kDebugConversations, "unconditional\n");
 			} else if (type == 11) {
-				//printf("conditional\n");
+				//debug(kDebugConversations, "conditional\n");
 			} else {
-				printf("unknown type: %i\n", type);
+				debug(kDebugConversations, "unknown type: %i\n", type);
 			}
 
 			// Conditional part
 			if (type == 11) {
 				unk = convS->readUint16LE();	//	1
 				if (unk != 1)
-					printf("Message: unk != 1 (it's %i)\n", unk);
+					debug(kDebugConversations, "Message: unk != 1 (it's %i)\n", unk);
 
 					var = convS->readUint16LE();
 					val = convS->readUint16LE();
-					printf("Var %i == %i\n", var, val);
+					debug(kDebugConversations, "Var %i == %i\n", var, val);
 			}
 			unk = convS->readUint16LE();	//	256
 			if (unk != 256)
-				printf("Message: unk != 256 (it's %i)\n", unk);
+				debug(kDebugConversations, "Message: unk != 256 (it's %i)\n", unk);
 
 			// it seems that the first text entry is set when the message
 			// chunk is supposed to be shown unconditionally, whereas the second text
@@ -1031,74 +1031,74 @@
 
 			if (hasText1 == 1) {
 				messageIndex = convS->readUint16LE();
-				printf("Message 1 index: %i, text:\n", messageIndex);
+				debug(kDebugConversations, "Message 1 index: %i, text:\n", messageIndex);
 				for (uint32 i = 0; i < _madsMessageList[messageIndex]->messageStrings.size(); i++) {
-					printf("%s\n", _madsMessageList[messageIndex]->messageStrings[i]);
+					debug(kDebugConversations, "%s\n", _madsMessageList[messageIndex]->messageStrings[i]);
 				}
 			}
 
 			if (hasText2 == 1) {
 				messageIndex = convS->readUint16LE();
 				if (hasText1 == 0) {
-					printf("Message 2 index: %i, text:\n", messageIndex);
+					debug(kDebugConversations, "Message 2 index: %i, text:\n", messageIndex);
 					for (uint32 i = 0; i < _madsMessageList[messageIndex]->messageStrings.size(); i++) {
-						printf("%s\n", _madsMessageList[messageIndex]->messageStrings[i]);
+						debug(kDebugConversations, "%s\n", _madsMessageList[messageIndex]->messageStrings[i]);
 					}
 				}
 			}
 
 			break;
 		case 5:		// AUTO
-			printf("AUTO\n");
+			debug(kDebugConversations, "AUTO\n");
 			for (int k = 0; k < 4; k++)
 				convS->readByte();
 			messageIndex = convS->readUint16LE();
-			printf("Message index: %i, text:\n", messageIndex);
+			debug(kDebugConversations, "Message index: %i, text:\n", messageIndex);
 			for (uint32 i = 0; i < _madsMessageList[messageIndex]->messageStrings.size(); i++) {
-				printf("%s\n", _madsMessageList[messageIndex]->messageStrings[i]);
+				debug(kDebugConversations, "%s\n", _madsMessageList[messageIndex]->messageStrings[i]);
 			}
 
 			convS->readUint16LE();
 			break;
 		case 6:
-			printf("TODO: chunk type %i\n", chunk);
+			debug(kDebugConversations, "TODO: chunk type %i\n", chunk);
 			break;
 		case 7:		// GOTO
 			unk = convS->readUint32LE();	// 0
 			if (unk != 0 && unk != 1)
-				printf("Goto: unk != 0 or 1 (it's %i)\n", unk);
+				debug(kDebugConversations, "Goto: unk != 0 or 1 (it's %i)\n", unk);
 
 			target = convS->readUint16LE();
 			convS->readUint16LE();	// 255
 
 			if (unk != 0)
-				printf("Goto: unk != 0 (it's %i)\n", unk);
+				debug(kDebugConversations, "Goto: unk != 0 (it's %i)\n", unk);
 
 			if (target != 65535)
-				printf("GOTO node %i\n", target);
+				debug(kDebugConversations, "GOTO node %i\n", target);
 			else
-				printf("GOTO exit\n");
+				debug(kDebugConversations, "GOTO exit\n");
 			break;
 		case 8:
-			printf("TODO: chunk type %i\n", chunk);
+			debug(kDebugConversations, "TODO: chunk type %i\n", chunk);
 			break;
 		case 9:		// ASSIGN
-			//printf("ASSIGN\n");
+			//debug(kDebugConversations, "ASSIGN\n");
 			unk = convS->readUint32LE();	// 0
 
 			if (unk != 0)
-				printf("Assign: unk != 0 (it's %i)\n", unk);
+				debug(kDebugConversations, "Assign: unk != 0 (it's %i)\n", unk);
 
 			val = convS->readUint16LE();
 			var = convS->readUint16LE();
-			//printf("Var %i = %i\n", var, val);
+			//debug(kDebugConversations, "Var %i = %i\n", var, val);
 			break;
 		default:
 			printf ("Unknown chunk type! (%i)\n", chunk);
 			break;
 		}
 	}
-	printf("\n");
+	debug(kDebugConversations, "\n");
 }
 
 void Converse::setEntryInfo(int32 offset, EntryType type, int32 nodeIndex, int32 entryIndex) {
@@ -1109,7 +1109,7 @@
 	info.nodeIndex = nodeIndex;
 	info.entryIndex = entryIndex;
 	_offsetMap[hashOffset] = info;
-	//printf("Set entry info: offset %i, type %i, node %i, entry %i\n", offset, type, nodeIndex, entryIndex);
+	//debug(kDebugConversations, "Set entry info: offset %i, type %i, node %i, entry %i\n", offset, type, nodeIndex, entryIndex);
 }
 
 const EntryInfo* Converse::getEntryInfo(int32 offset) {
@@ -1172,7 +1172,7 @@
 	}
 
 	if (action->actionType == kAssignValue) {
-		//printf("Assigning variable at offset %i to value %i\n",
+		//debug(kDebugConversations, "Assigning variable at offset %i to value %i\n",
 		//		action->targetOffset, action->value);
 		setValue(action->targetOffset, action->value);
 		return true;		// nothing else to do in an assignment action
@@ -1190,24 +1190,24 @@
 
 	switch (action->actionType) {
 	case kGotoEntry:
-		//printf("Goto entry at offset %i. Associated node is %i, entry %i\n",
+		//debug(kDebugConversations, "Goto entry at offset %i. Associated node is %i, entry %i\n",
 		//	action->targetOffset, entryInfo->nodeIndex, entryInfo->entryIndex);
 		_vm->_conversationView->setNode(entryInfo->nodeIndex);
 		if (entryInfo->entryIndex >= 0)
 			_vm->_conversationView->selectEntry(entryInfo->entryIndex);
 		return false;
 	case kHideEntry:
-		//printf("Hide entry at offset %i. Associated node is %i, entry %i\n",
+		//debug(kDebugConversations, "Hide entry at offset %i. Associated node is %i, entry %i\n",
 		//	targetEntry->offset, entryInfo->nodeIndex, entryInfo->entryIndex);
 		targetEntry->visible = false;
 		return true;
 	case kUnhideEntry:
-		//printf("Show entry at offset %i. Associated node is %i, entry %i\n",
+		//debug(kDebugConversations, "Show entry at offset %i. Associated node is %i, entry %i\n",
 		//	targetEntry->offset, entryInfo->nodeIndex, entryInfo->entryIndex);
 		targetEntry->visible = true;
 		return true;
 	case kDestroyEntry:
-		//printf("Destroy entry at offset %i. Associated node is %i, entry %i\n",
+		//debug(kDebugConversations, "Destroy entry at offset %i. Associated node is %i, entry %i\n",
 		//	targetEntry->offset, entryInfo->nodeIndex, entryInfo->entryIndex);
 		if (entryInfo->entryIndex >= 0)
 			getNode(entryInfo->nodeIndex)->entries.remove_at(entryInfo->entryIndex);
@@ -1216,7 +1216,7 @@
 		targetEntry->visible = true;
 		return true;
 	case kExitConv:
-		//printf("Exit conversation\n");
+		//debug(kDebugConversations, "Exit conversation\n");
 		endConversation();
 		return false;
 	default:

Modified: scummvm/trunk/engines/m4/events.cpp
===================================================================
--- scummvm/trunk/engines/m4/events.cpp	2010-11-02 00:15:18 UTC (rev 54034)
+++ scummvm/trunk/engines/m4/events.cpp	2010-11-02 00:51:12 UTC (rev 54035)
@@ -235,7 +235,7 @@
 	cursorPalette = _cursorSprites->getPalette();
 	_vm->_palette->setPalette(cursorPalette, 0, colorCount);
 
-	//printf("Cursor count: %d\n", _cursorSprites->getCount());
+	//debug(kDebugCore, "Cursor count: %d\n", _cursorSprites->getCount());
 
 	_vm->res()->toss(seriesName);
 

Modified: scummvm/trunk/engines/m4/font.cpp
===================================================================
--- scummvm/trunk/engines/m4/font.cpp	2010-11-02 00:15:18 UTC (rev 54034)
+++ scummvm/trunk/engines/m4/font.cpp	2010-11-02 00:51:12 UTC (rev 54035)
@@ -82,7 +82,7 @@
 	Common::SeekableReadStream *fontFile = _vm->res()->openFile(filename);
 
 	if (fontFile->readUint32LE() != MKID_BE('FONT')) {
-		printf("Font::Font: FONT tag expected\n");
+		debug(kDebugGraphics, "Font::Font: FONT tag expected\n");
 		return;
 	}
 
@@ -90,10 +90,10 @@
 	_maxWidth = fontFile->readByte();
 	uint32 fontSize = fontFile->readUint32LE();
 
-	//printf("Font::Font: _maxWidth = %d, _maxHeight = %d, fontSize = %d\n", _maxWidth, _maxHeight, fontSize);
+	//debug(kDebugGraphics, "Font::Font: _maxWidth = %d, _maxHeight = %d, fontSize = %d\n", _maxWidth, _maxHeight, fontSize);
 
 	if (fontFile->readUint32LE() != MKID_BE('WIDT')) {
-		printf("Font::Font: WIDT tag expected\n");
+		debug(kDebugGraphics, "Font::Font: WIDT tag expected\n");
 		return;
 	}
 
@@ -101,7 +101,7 @@
 	fontFile->read(_charWidths, 256);
 
 	if (fontFile->readUint32LE() != MKID_BE('OFFS')) {
-		printf("Font::Font: OFFS tag expected\n");
+		debug(kDebugGraphics, "Font::Font: OFFS tag expected\n");
 		return;
 	}
 
@@ -111,7 +111,7 @@
 		_charOffs[i] = fontFile->readUint16LE();
 
 	if (fontFile->readUint32LE() != MKID_BE('PIXS')) {
-		printf("Font::Font: PIXS tag expected\n");
+		debug(kDebugGraphics, "Font::Font: PIXS tag expected\n");
 		return;
 	}
 

Modified: scummvm/trunk/engines/m4/globals.cpp
===================================================================
--- scummvm/trunk/engines/m4/globals.cpp	2010-11-02 00:15:18 UTC (rev 54034)
+++ scummvm/trunk/engines/m4/globals.cpp	2010-11-02 00:51:12 UTC (rev 54035)
@@ -75,7 +75,7 @@
 
 bool Kernel::handleTrigger(int32 triggerNum) {
 
-	printf("betweenRooms = %d; triggerNum = %08X\n", betweenRooms, (uint)triggerNum);
+	debug(kDebugScript, "betweenRooms = %d; triggerNum = %08X\n", betweenRooms, (uint)triggerNum);
 
 	if (betweenRooms)
 		return true;
@@ -89,10 +89,10 @@
 
 	int room = (triggerNum >> 16) & 0xFFF;
 
-	printf("room = %d; currentRoom = %d\n", room, currentRoom); fflush(stdout);
+	debug(kDebugScript, "room = %d; currentRoom = %d\n", room, currentRoom); fflush(stdout);
 
 	if (room != currentRoom) {
-		printf("Kernel::handleTrigger() Trigger from another room\n");
+		debug(kDebugScript, "Kernel::handleTrigger() Trigger from another room\n");
 		return false;
 	}
 
@@ -123,7 +123,7 @@
 		break;
 
 	case KT_DAEMON:
-		printf("KT_DAEMON\n");
+		debug(kDebugScript, "KT_DAEMON\n");
 		fflush(stdout);
 		triggerMode = KT_DAEMON;
 		daemonTriggerAvailable = false;
@@ -140,7 +140,7 @@
 		break;
 
 	default:
-		printf("Kernel::handleTrigger() Unknown trigger mode %d\n", mode);
+		debug(kDebugScript, "Kernel::handleTrigger() Unknown trigger mode %d\n", mode);
 
 	}
 
@@ -181,7 +181,7 @@
 	if (_globalDaemonFn)
 		_vm->_script->runFunction(_globalDaemonFn);
 	else {
-		printf("Kernel::globalDaemon() _globalDaemonFn is NULL\n");
+		debug(kDebugScript, "Kernel::globalDaemon() _globalDaemonFn is NULL\n");
 	}
 }
 
@@ -189,7 +189,7 @@
 	if (_globalParserFn)
 		_vm->_script->runFunction(_globalParserFn);
 	else {
-		printf("Kernel::globalParser() _globalParserFn is NULL\n");
+		debug(kDebugScript, "Kernel::globalParser() _globalParserFn is NULL\n");
 	}
 }
 
@@ -197,7 +197,7 @@
 	if (_sectionInitFn)
 		_vm->_script->runFunction(_sectionInitFn);
 	else {
-		printf("Kernel::sectionInit() _sectionInitFn is NULL\n");
+		debug(kDebugScript, "Kernel::sectionInit() _sectionInitFn is NULL\n");
 	}
 }
 
@@ -205,7 +205,7 @@
 	if (_sectionDaemonFn)
 		_vm->_script->runFunction(_sectionDaemonFn);
 	else {
-		printf("Kernel::sectionDaemon() _sectionDaemonFn is NULL\n");
+		debug(kDebugScript, "Kernel::sectionDaemon() _sectionDaemonFn is NULL\n");
 	}
 }
 
@@ -213,7 +213,7 @@
 	if (_sectionParserFn)
 		_vm->_script->runFunction(_sectionParserFn);
 	else {
-		printf("Kernel::sectionParser() _sectionParserFn is NULL\n");
+		debug(kDebugScript, "Kernel::sectionParser() _sectionParserFn is NULL\n");
 	}
 }
 
@@ -221,7 +221,7 @@
 	if (_roomInitFn)
 		_vm->_script->runFunction(_roomInitFn);
 	else {
-		printf("Kernel::roomInit() _roomInitFn is NULL\n");
+		debug(kDebugScript, "Kernel::roomInit() _roomInitFn is NULL\n");
 	}
 }
 
@@ -229,7 +229,7 @@
 	if (_roomDaemonFn)
 		_vm->_script->runFunction(_roomDaemonFn);
 	else {
-		printf("Kernel::roomDaemon() _roomDaemonFn is NULL\n");
+		debug(kDebugScript, "Kernel::roomDaemon() _roomDaemonFn is NULL\n");
 	}
 }
 
@@ -237,7 +237,7 @@
 	if (_roomPreParserFn)
 		_vm->_script->runFunction(_roomPreParserFn);
 	else {
-		printf("Kernel::roomPreParser() _roomPreParserFn is NULL\n");
+		debug(kDebugScript, "Kernel::roomPreParser() _roomPreParserFn is NULL\n");
 	}
 }
 
@@ -245,7 +245,7 @@
 	if (_roomParserFn)
 		_vm->_script->runFunction(_roomParserFn);
 	else {
-		printf("Kernel::roomParser() _roomParserFn is NULL\n");
+		debug(kDebugScript, "Kernel::roomParser() _roomParserFn is NULL\n");
 	}
 }
 
@@ -351,7 +351,7 @@
 	Common::SeekableReadStream *messageS = _vm->res()->get("messages.dat");
 
 	int16 count = messageS->readUint16LE();
-	//printf("%i messages\n", count);
+	//debug(kDebugScript, "%i messages\n", count);
 
 	for (int i = 0; i < count; i++) {
 		MessageItem curMessage;
@@ -365,7 +365,7 @@
 		if (i == count - 1)
 			curMessage.compSize = messageS->size() - curMessage.offset;
 
-		//printf("id: %i, offset: %i, uncomp size: %i\n", curMessage->id, curMessage->offset, curMessage->uncompSize);
+		//debug(kDebugScript, "id: %i, offset: %i, uncomp size: %i\n", curMessage->id, curMessage->offset, curMessage->uncompSize);
 		_madsMessages.push_back(curMessage);
 	}
 

Modified: scummvm/trunk/engines/m4/graphics.cpp
===================================================================
--- scummvm/trunk/engines/m4/graphics.cpp	2010-11-02 00:15:18 UTC (rev 54034)
+++ scummvm/trunk/engines/m4/graphics.cpp	2010-11-02 00:51:12 UTC (rev 54035)
@@ -213,7 +213,7 @@
 	int scaledHeight = scaleValue(info.height, info.scaleY, errY);
 
 	/*
-	printf("M4Surface::drawSprite() info.width = %d; info.scaleX = %d; info.height = %d; info.scaleY = %d; scaledWidth = %d; scaledHeight = %d\n",
+	debug(kDebugGraphics, "M4Surface::drawSprite() info.width = %d; info.scaleX = %d; info.height = %d; info.scaleY = %d; scaledWidth = %d; scaledHeight = %d\n",
 		info.width, info.scaleX, info.height, info.scaleY, scaledWidth, scaledHeight); fflush(stdout);
 	*/
 
@@ -233,7 +233,7 @@
 		scaledHeight = y + scaledHeight;
 	}
 
-	//printf("M4Surface::drawSprite() width = %d; height = %d; scaledWidth = %d; scaledHeight = %d\n", info.width, info.height, scaledWidth, scaledHeight); fflush(stdout);
+	//debug(kDebugGraphics, "M4Surface::drawSprite() width = %d; height = %d; scaledWidth = %d; scaledHeight = %d\n", info.width, info.height, scaledWidth, scaledHeight); fflush(stdout);
 
 	// Check if sprite is inside the screen. If it's not, there's no need to draw it
 	if (scaledWidth + x <= 0 || scaledHeight + y <= 0)	// check left and top (in case x,y are negative)
@@ -703,7 +703,7 @@
 		else
 			compressedTileDataSize = tileDataUncomp->readUint32LE() - tileOfs;
 
-		//printf("Tile: %i, compressed size: %i\n", i, compressedTileDataSize);
+		//debug(kDebugGraphics, "Tile: %i, compressed size: %i\n", i, compressedTileDataSize);
 
 		newTile->clear();
 
@@ -787,7 +787,7 @@
 	uint8 blackIndex = 0;
 
 	// Debug
-	//printf("loadBackground(): %dx%d picture (%d bytes) - %dx%d tiles of size %dx%d\n",
+	//debug(kDebugGraphics, "loadBackground(): %dx%d picture (%d bytes) - %dx%d tiles of size %dx%d\n",
 	//	   widthVal, heightVal, size, tilesX, tilesY, tileWidth, tileHeight);
 
 	// BGR data, which is converted to RGB8
@@ -807,7 +807,7 @@
 	// note that the height of the scene in game scenes is smaller than 480, as the bottom part of the
 	// screen is the inventory
 	assert(width() == (int)widthVal);
-	//printf("width(): %d, widthVal: %d, height(): %d, heightVal: %d\n", width(), widthVal, height(), heightVal);
+	//debug(kDebugGraphics, "width(): %d, widthVal: %d, height(): %d, heightVal: %d\n", width(), widthVal, height(), heightVal);
 
 	tileBuffer->create(tileWidth, tileHeight, 1);
 

Modified: scummvm/trunk/engines/m4/hotspot.cpp
===================================================================
--- scummvm/trunk/engines/m4/hotspot.cpp	2010-11-02 00:15:18 UTC (rev 54034)
+++ scummvm/trunk/engines/m4/hotspot.cpp	2010-11-02 00:51:12 UTC (rev 54035)
@@ -227,7 +227,7 @@
 			// This looks to be some sort of bitmask. Perhaps it signifies
 			// the valid verbs for this hotspot
 			index = hotspotStream->readUint16LE();		// unknown
-			//printf("%i ", index);
+			//debug(kDebugCore, "%i ", index);
 		}
 
 		if (_vm->isM4())

Modified: scummvm/trunk/engines/m4/m4.cpp
===================================================================
--- scummvm/trunk/engines/m4/m4.cpp	2010-11-02 00:15:18 UTC (rev 54034)
+++ scummvm/trunk/engines/m4/m4.cpp	2010-11-02 00:51:12 UTC (rev 54035)
@@ -121,6 +121,7 @@
 	DebugMan.addDebugChannel(kDebugScript, "script", "Script debug level");
 	DebugMan.addDebugChannel(kDebugGraphics, "graphics", "Graphics debug level");
 	DebugMan.addDebugChannel(kDebugConversations, "conversations", "Conversations debugging");
+	DebugMan.addDebugChannel(kDebugSound, "sound", "Sounds debug level");
 
 	_resourceManager = NULL;
 	_globals = NULL;
@@ -289,7 +290,7 @@
 		Common::MemoryReadStream *sourceUnc;
 		for (int i = 0; i < packData.getCount(); i++) {
 			sourceUnc = packData.getItemStream(i);
-			printf("Dumping compressed chunk %i of %i, size is %i\n", i + 1, packData.getCount(), sourceUnc->size());
+			debug(kDebugCore, "Dumping compressed chunk %i of %i, size is %i\n", i + 1, packData.getCount(), sourceUnc->size());
 			while (!sourceUnc->eos()) {
 				bytesRead = sourceUnc->read(buffer, DUMP_BUFFER_SIZE);
 				f.write(buffer, bytesRead);
@@ -344,7 +345,7 @@
 	for (int i = 1; i < 58; i++) {
 		_vm->_kernel->trigger = i;
 		_script->runFunction(func);
-		printf("=================================\n");
+		debug(kDebugCore, "=================================\n");
 		fflush(stdout);
 	}
 #endif
@@ -541,7 +542,7 @@
 
 	// Test code to dump all messages to the console
 	//for (int i = 0; i < _globals->getMessagesSize(); i++)
-	//printf("%s\n----------\n", _globals->loadMessage(i));
+	//debug(kDebugCore, "%s\n----------\n", _globals->loadMessage(i));
 
 	if (getGameType() == GType_RexNebular) {
 		MadsGameLogic::initialiseGlobals();

Modified: scummvm/trunk/engines/m4/m4.h
===================================================================
--- scummvm/trunk/engines/m4/m4.h	2010-11-02 00:15:18 UTC (rev 54034)
+++ scummvm/trunk/engines/m4/m4.h	2010-11-02 00:51:12 UTC (rev 54035)
@@ -116,7 +116,9 @@
 enum {
 	kDebugScript = 1 << 0,
 	kDebugConversations = 1 << 1,
-	kDebugGraphics = 1 << 2
+	kDebugGraphics = 1 << 2,
+	kDebugSound = 1 << 3,
+	kDebugCore = 1 << 4
 };
 
 #define MESSAGE_BASIC 1

Modified: scummvm/trunk/engines/m4/m4_scene.cpp
===================================================================
--- scummvm/trunk/engines/m4/m4_scene.cpp	2010-11-02 00:15:18 UTC (rev 54034)
+++ scummvm/trunk/engines/m4/m4_scene.cpp	2010-11-02 00:51:12 UTC (rev 54035)
@@ -61,7 +61,7 @@
 	_sceneSprites = new SpriteAsset(_vm, sceneS, sceneS->size(), filename);
 	_vm->res()->toss(filename);
 
-	printf("Scene has %d sprites, each one having %d colors\n", _sceneSprites->getCount(), _sceneSprites->getColorCount());
+	debug(kDebugGraphics, "Scene has %d sprites, each one having %d colors\n", _sceneSprites->getCount(), _sceneSprites->getColorCount());
 }
 
 void M4Scene::loadSceneResources(int sceneNumber) {
@@ -136,7 +136,7 @@
 //			RGB8* spritePalette = _sceneSpriteCodes->getPalette();
 		//_vm->_palette->setPalette(spritePalette, 0, colorCount);
 
-		printf("Scene has %d sprite codes, each one having %d colors\n", _sceneSpriteCodes->getCount(), colorCount);
+		debug(kDebugGraphics, "Scene has %d sprite codes, each one having %d colors\n", _sceneSpriteCodes->getCount(), colorCount);
 
 		// Note that toss() deletes the MemoryReadStream
 		_vm->res()->toss(filename);
@@ -252,7 +252,7 @@
 			*/
 
 			// Player said.... (for scene scripts)
-			printf("Player said: %s %s\n", currentHotSpot->getVerb(), currentHotSpot->getVocab());
+			debug(kDebugGraphics, "Player said: %s %s\n", currentHotSpot->getVerb(), currentHotSpot->getVocab());
 
 			// FIXME: This should be moved somewhere else, and is incomplete
 			if (_m4Vm->scene()->getInterface()->_inventory.getSelectedIndex() == -1) {
@@ -268,7 +268,7 @@
 			strcpy(_vm->_player->object, "");
 			_vm->_player->commandReady = true;
 
-			printf("## Player said: %s %s\n", _vm->_player->verb, _vm->_player->noun);
+			debug(kDebugGraphics, "## Player said: %s %s\n", _vm->_player->verb, _vm->_player->noun);
 
 		}
 	}

Modified: scummvm/trunk/engines/m4/mads_anim.cpp
===================================================================
--- scummvm/trunk/engines/m4/mads_anim.cpp	2010-11-02 00:15:18 UTC (rev 54034)
+++ scummvm/trunk/engines/m4/mads_anim.cpp	2010-11-02 00:51:12 UTC (rev 54035)
@@ -721,21 +721,21 @@
 
 	case 'O':
 		param = param + 2;
-		//printf("O:%i ", atoi(param));
+		//warning(kDebugGraphics, "O:%i ", atoi(param));
 		_transition = atoi(param);
 		break;
 
 	case 'R':
 		param = param + 2;
-		//printf("R:%s ", param);
+		//warning(kDebugGraphics, "R:%s ", param);
 		break;
 
 	case 'W':
-		//printf("W ");
+		//warning(kDebugGraphics, "W ");
 		break;
 
 	case 'X':
-		//printf("X ");
+		//warning(kDebugGraphics, "X ");
 		break;
 
 	default:

Modified: scummvm/trunk/engines/m4/mads_menus.cpp
===================================================================
--- scummvm/trunk/engines/m4/mads_menus.cpp	2010-11-02 00:15:18 UTC (rev 54034)
+++ scummvm/trunk/engines/m4/mads_menus.cpp	2010-11-02 00:51:12 UTC (rev 54035)
@@ -546,7 +546,7 @@
 		M4Sprite *spr = _menuItem->getFrame(0);
 
 		if ((x >= pt.x - 25) && (y >= pt.y - spr->height()) && (x < (pt.x - 25 + spr->width())) && (y < (pt.y)))  {
-			printf("x = %d, y = %d, index = %d\n", x, y, index);
+			debug(kDebugGraphics, "x = %d, y = %d, index = %d\n", x, y, index);
 			return index;
 		}
 	}

Modified: scummvm/trunk/engines/m4/rails.cpp
===================================================================
--- scummvm/trunk/engines/m4/rails.cpp	2010-11-02 00:15:18 UTC (rev 54034)
+++ scummvm/trunk/engines/m4/rails.cpp	2010-11-02 00:51:12 UTC (rev 54035)
@@ -233,7 +233,7 @@
 
 	valid = isLineWalkable(_nodes[node1]->x, _nodes[node1]->y,
 		_nodes[node2]->x, _nodes[node2]->y);
-	printf("test code says: %d\n", valid);
+	debug(kDebugCore, "test code says: %d\n", valid);
 
 	// Check if the line passes through a forbidden rectangle
 	if (valid) {
@@ -255,7 +255,7 @@
 		_edges.insert_at(index, (int16*)(distance >> 16));
 	}
 
-	printf("node1 = %d, node2 = %d, valid = %d\n", node1, node2, valid);
+	debug(kDebugCore, "node1 = %d, node2 = %d, valid = %d\n", node1, node2, valid);
 
 }
 

Modified: scummvm/trunk/engines/m4/resource.cpp
===================================================================
--- scummvm/trunk/engines/m4/resource.cpp	2010-11-02 00:15:18 UTC (rev 54034)
+++ scummvm/trunk/engines/m4/resource.cpp	2010-11-02 00:51:12 UTC (rev 54035)
@@ -43,12 +43,12 @@
 	hashFile.open(hashFilename);
 
 	if (!hashFile.isOpen()) {
-		printf("FileSystem::FileSystem: error opening hash %s\n", hashFilename);
+		debug(kDebugCore, "FileSystem::FileSystem: error opening hash %s\n", hashFilename);
 	}
 
 	hashSize = hashFile.readUint32LE();
 
-	//printf("FileSystem::FileSystem: hashSize = %d\n", hashSize);
+	//debug(kDebugCore, "FileSystem::FileSystem: hashSize = %d\n", hashSize);
 
 	/* load file records and add them to the hash list */
 	for (uint i = 0; i < hashSize; i++) {
@@ -63,12 +63,12 @@
 
 		if (entry.filename[0]) {
 			/*
-			printf("  filename: %s\n", entry.filename);
-			printf("  hagfile: %d\n", entry.hagfile);
-			printf("  disks: %d\n", entry.disks);
-			printf("  offset: %08X\n", entry.offset);
-			printf("  size: %d\n", entry.size);
-			printf("  next: %08X\n", entry.next);
+			debug(kDebugCore, "  filename: %s\n", entry.filename);
+			debug(kDebugCore, "  hagfile: %d\n", entry.hagfile);
+			debug(kDebugCore, "  disks: %d\n", entry.disks);
+			debug(kDebugCore, "  offset: %08X\n", entry.offset);
+			debug(kDebugCore, "  size: %d\n", entry.size);
+			debug(kDebugCore, "  next: %08X\n", entry.next);
 			*/
 			_fileEntries[entry.filename] = entry;
 		}
@@ -90,7 +90,7 @@
 		_hagEntries[entry.fileIndex].hagFile->open(_hagEntries[entry.fileIndex].filename);
 
 		if (!_hagEntries[entry.fileIndex].hagFile->isOpen()) {
-			printf("FileSystem::FileSystem: error opening hag %s\n", _hagEntries[entry.fileIndex].filename);
+			debug(kDebugCore, "FileSystem::FileSystem: error opening hag %s\n", _hagEntries[entry.fileIndex].filename);
 		}
 
 	}
@@ -113,7 +113,7 @@
 	Common::SeekableReadStream *result = NULL;
 
 	if (hfe) {
-		//printf("FileSystem::loadFile() success opening %s\n", filename);
+		//debug(kDebugCore, "FileSystem::loadFile() success opening %s\n", filename);
 		HashHagEntry *hagEntry = &_hagEntries[hfe->hagfile];
 
 		if (preloadFlag) {
@@ -128,7 +128,7 @@
 				hfe->offset + hfe->size);
 
 	} else {
-		printf("FileSystem::loadFile() error opening %s\n", resourceName);
+		debug(kDebugCore, "FileSystem::loadFile() error opening %s\n", resourceName);
 	}
 
 	return result;
@@ -207,7 +207,7 @@
 
 		if (!strcmp(r->name, resourceName)) {
 			r->flags |= kResourcePurge;
-			//printf("M4ResourceManager::toss: mark resource %s to be purged\n", resourceName);
+			//debug(kDebugCore, "M4ResourceManager::toss: mark resource %s to be purged\n", resourceName);
 		}
 	}
 }
@@ -510,7 +510,7 @@
 }
 
 Common::SeekableReadStream *M4ResourceManager::loadResource(const char *resourceName, bool preloadFlag) {
-	//printf("M4ResourceManager::loadResource() loading resource %s\n", resourceName);
+	//debug(kDebugCore, "M4ResourceManager::loadResource() loading resource %s\n", resourceName);
 	Common::SeekableReadStream* result = NULL;
 	if (_hfs) {
 		// actually load the resource

Modified: scummvm/trunk/engines/m4/script.cpp
===================================================================
--- scummvm/trunk/engines/m4/script.cpp	2010-11-02 00:15:18 UTC (rev 54034)
+++ scummvm/trunk/engines/m4/script.cpp	2010-11-02 00:51:12 UTC (rev 54035)
@@ -121,7 +121,7 @@
 
 void SeriesStreamBreakList::load(Common::File *fd) {
 	uint32 count = fd->readUint32LE();
-	printf("SeriesStreamBreakList::load() count = %d\n", count);
+	debug(kDebugScript, "SeriesStreamBreakList::load() count = %d\n", count);
 	for (uint32 i = 0; i < count; i++) {
 		SeriesStreamBreakItem *item = new SeriesStreamBreakItem();
 		item->frameNum = fd->readUint32LE();
@@ -135,7 +135,7 @@
 		item->value = fd->readUint32LE();
 		_items.push_back(item);
 
-		printf("%02d: frameNum = %d; digiName = %s; digiChannel = %d; digiVolume = %d; trigger = %d; flags = %d; variable = %d; value = %d\n",
+		debug(kDebugScript, "%02d: frameNum = %d; digiName = %s; digiChannel = %d; digiVolume = %d; trigger = %d; flags = %d; variable = %d; value = %d\n",
 			i, item->frameNum, item->digiName,	item->digiChannel, item->digiVolume, item->trigger, item->flags, item->variable.value, item->value);
 
 	}
@@ -146,7 +146,7 @@
 
 void SaidArray::load(Common::File *fd) {
 	uint32 count = fd->readUint32LE();
-	printf("SaidArray::load() count = %d\n", count);
+	debug(kDebugScript, "SaidArray::load() count = %d\n", count);
 	for (uint32 i = 0; i < count; i++) {
 		SaidArrayItem *item = new SaidArrayItem();
 		item->itemName = _inter->loadGlobalString(fd);
@@ -155,7 +155,7 @@
 		item->digiNameGear = _inter->loadGlobalString(fd);
 		_items.push_back(item);
 
-		printf("itemName = %s; digiNameLook = %s; digiNameTake = %s; digiNameGear = %s\n",
+		debug(kDebugScript, "itemName = %s; digiNameLook = %s; digiNameTake = %s; digiNameGear = %s\n",
 			item->itemName, item->digiNameLook, item->digiNameTake, item->digiNameGear);
 
 	}
@@ -166,7 +166,7 @@
 
 void ParserArray::load(Common::File *fd) {
 	uint32 count = fd->readUint32LE();
-	printf("ParserArray::load() count = %d\n", count);
+	debug(kDebugScript, "ParserArray::load() count = %d\n", count);
 	for (uint32 i = 0; i < count; i++) {
 		ParserArrayItem *item = new ParserArrayItem();
 		item->w0 = _inter->loadGlobalString(fd);
@@ -180,7 +180,7 @@
 		item->value = fd->readUint32LE();
 		_items.push_back(item);
 
-		printf("w0 = %s; w1 = %s; trigger = %d; testVariable = %d; testValue = %d; variable = %d; value = %d\n",
+		debug(kDebugScript, "w0 = %s; w1 = %s; trigger = %d; testVariable = %d; testValue = %d; variable = %d; value = %d\n",
 			item->w0, item->w1, item->trigger, item->testVariable.value, item->testValue, item->variable.value, item->value);
 
 	}
@@ -194,9 +194,9 @@
 }
 
 void ScriptFunction::load(Common::File *fd) {
-	printf("ScriptFunction::load()\n");
+	debug(kDebugScript, "ScriptFunction::load()\n");
 	uint32 size = fd->readUint32LE();
-	printf("ScriptFunction::load() size = %d\n", size);
+	debug(kDebugScript, "ScriptFunction::load() size = %d\n", size);
 	_code = fd->readStream(size);
 }
 
@@ -243,16 +243,16 @@
 	}
 
 	int functionCount = _scriptFile->readUint32LE();
-	printf("functionCount = %d\n", functionCount);
+	debug(kDebugScript, "functionCount = %d\n", functionCount);
 	for (int i = 0; i < functionCount; i++) {
 		uint32 offset = _scriptFile->readUint32LE();
-		printf("func(%d) offset = %08X\n", i, offset);
+		debug(kDebugScript, "func(%d) offset = %08X\n", i, offset);
 		uint32 len = _scriptFile->readUint32LE();
 		if (len > 0) {
 			char *funcName = new char[len + 1];
 			_scriptFile->read(funcName, len);
 			funcName[len] = '\0';
-			printf("func(%d) name = %s\n", i, funcName);
+			debug(kDebugScript, "func(%d) name = %s\n", i, funcName);
 			_functionNames[Common::String(funcName)] = _functions.size();
 			// DEBUG
 			_scriptFunctionNames.push_back(Common::String(funcName));
@@ -262,16 +262,16 @@
 	}
 
 	int dataCount = _scriptFile->readUint32LE();
-	printf("dataCount = %d\n", dataCount);
+	debug(kDebugScript, "dataCount = %d\n", dataCount);
 	for (int i = 0; i < dataCount; i++) {
 		uint32 offset = _scriptFile->readUint32LE();
 		ScriptDataType type = (ScriptDataType)_scriptFile->readUint32LE();
-		printf("data(%d) offset = %08X; type = %d\n", i, offset, type);
+		debug(kDebugScript, "data(%d) offset = %08X; type = %d\n", i, offset, type);
 		_data.push_back(new ScriptDataEntry(offset, type));
 	}
 
 	_globalVarCount = _scriptFile->readUint32LE();
-	printf("_globalVarCount = %d\n", _globalVarCount);
+	debug(kDebugScript, "_globalVarCount = %d\n", _globalVarCount);
 
 	uint32 stringOfs = _scriptFile->readUint32LE();
 	_scriptFile->seek(stringOfs);
@@ -324,11 +324,11 @@
 ScriptFunction *ScriptInterpreter::loadFunction(const Common::String &name) {
 	FunctionNameMap::iterator iter = _functionNames.find(name);
 	if (iter == _functionNames.end()) {
-		printf("ScriptInterpreter::loadFunction() Function '%s' not found!\n", name.c_str());
+		debug(kDebugScript, "ScriptInterpreter::loadFunction() Function '%s' not found!\n", name.c_str());
 		return NULL;
 	}
 	uint32 funcIndex = (*iter)._value;
-	printf("ScriptInterpreter::loadFunction() index('%s') = %d\n", name.c_str(), funcIndex);
+	debug(kDebugScript, "ScriptInterpreter::loadFunction() index('%s') = %d\n", name.c_str(), funcIndex);
 	return loadFunction(funcIndex);
 }
 
@@ -376,24 +376,24 @@
 }
 
 void ScriptInterpreter::dumpStack() {
-	printf("ScriptInterpreter::dumpStack()\n");
+	debug(kDebugScript, "ScriptInterpreter::dumpStack()\n");
 	for (int i = 0; i < _stackPtr; i++) {
-		printf("%03d. type = %02d; value = %d\n", i, _stack[i].type, _stack[i].value);
+		debug(kDebugScript, "%03d. type = %02d; value = %d\n", i, _stack[i].type, _stack[i].value);
 	}
 }
 
 void ScriptInterpreter::dumpRegisters() {
-	printf("ScriptInterpreter::dumpRegisters()\n");
+	debug(kDebugScript, "ScriptInterpreter::dumpRegisters()\n");
 	for (int i = 0; i < ARRAYSIZE(_registers); i++) {
-		printf("%03d. type = %02d; value = %d\n", i, _registers[i].type, _registers[i].value);
+		debug(kDebugScript, "%03d. type = %02d; value = %d\n", i, _registers[i].type, _registers[i].value);
 	}
 }
 
 void ScriptInterpreter::dumpGlobalVars() {
-	printf("ScriptInterpreter::dumpGlobalVars()\n");
+	debug(kDebugScript, "ScriptInterpreter::dumpGlobalVars()\n");
 	for (int i = 0; i < ARRAYSIZE(_globalVars); i++) {
 		if (_globalVars[i].type != -1)
-			printf("%03d. type = %02d; value = %d\n", i, _globalVars[i].type, _globalVars[i].value);
+			debug(kDebugScript, "%03d. type = %02d; value = %d\n", i, _globalVars[i].type, _globalVars[i].value);
 	}
 }
 
@@ -405,7 +405,7 @@
 		return value.value;
 
 	default:
-		printf("ScriptInterpreter::toInteger() Invalid type %d!\n", value.type);
+		debug(kDebugScript, "ScriptInterpreter::toInteger() Invalid type %d!\n", value.type);
 		return 0;
 
 	}
@@ -423,7 +423,7 @@
 		return _constStrings[value.value];
 
 	default:
-		printf("ScriptInterpreter::toString() Invalid type %d!\n", value.type);
+		debug(kDebugScript, "ScriptInterpreter::toString() Invalid type %d!\n", value.type);
 		return NULL;
 
 	}
@@ -462,7 +462,7 @@
 		break;
 
 	default:
-		printf("ScriptInterpreter::loadValue() Invalid value type %d!\n", value.type);
+		debug(kDebugScript, "ScriptInterpreter::loadValue() Invalid value type %d!\n", value.type);
 
 	}
 
@@ -471,7 +471,7 @@
 void ScriptInterpreter::copyValue(ScriptValue &destValue, ScriptValue &sourceValue) {
 
 	if (sourceValue.type == -1) {
-		printf("ScriptInterpreter::copyValue() Trying to read uninitialized value!\n");
+		debug(kDebugScript, "ScriptInterpreter::copyValue() Trying to read uninitialized value!\n");
 	}
 
 	switch (destValue.type) {
@@ -489,7 +489,7 @@
 		if (sourceValue.type == kInteger) {
 			_logicGlobals[destValue.value] = sourceValue.value;
 		} else {
-			printf("ScriptInterpreter::copyValue() Invalid source value type %d!\n", sourceValue.type);
+			debug(kDebugScript, "ScriptInterpreter::copyValue() Invalid source value type %d!\n", sourceValue.type);
 		}
 		break;
 
@@ -498,7 +498,7 @@
 		break;
 
 	default:
-		printf("ScriptInterpreter::copyValue() Invalid dest value type %d!\n", destValue.type);
+		debug(kDebugScript, "ScriptInterpreter::copyValue() Invalid dest value type %d!\n", destValue.type);
 
 	}
 
@@ -533,7 +533,7 @@
 		break;
 
 	default:
-		printf("ScriptInterpreter::derefValue() Invalid value type %d!\n", value.type);
+		debug(kDebugScript, "ScriptInterpreter::derefValue() Invalid value type %d!\n", value.type);
 
 	}
 
@@ -541,21 +541,21 @@
 
 void ScriptInterpreter::callKernelFunction(uint32 index) {
 
-	printf("ScriptInterpreter::callKernelFunction() index = %d\n", index);
+	debug(kDebugScript, "ScriptInterpreter::callKernelFunction() index = %d\n", index);
 
 	if (index > _kernelFunctionsMax) {
-		printf("ScriptInterpreter::callKernelFunction() Invalid kernel functionindex (%d)\n", index);
+		debug(kDebugScript, "ScriptInterpreter::callKernelFunction() Invalid kernel functionindex (%d)\n", index);
 		return;
 	}
 
-	printf("ScriptInterpreter::callKernelFunction() name = %s\n", _kernelFunctions[index].desc);
+	debug(kDebugScript, "ScriptInterpreter::callKernelFunction() name = %s\n", _kernelFunctions[index].desc);
 
 	int args = (this->*(_kernelFunctions[index].proc))();
 	// Now remove values from the stack if the function used any
 	if (args > 4)
 		_stackPtr -= args - 4;
 
-	printf("-------------\n");
+	debug(kDebugScript, "-------------\n");
 
 }
 
@@ -569,30 +569,30 @@
 }
 
 void ScriptInterpreter::dumpArgs(uint32 count) {
-	printf("ScriptInterpreter::dumpArgs() ");
+	debug(kDebugScript, "ScriptInterpreter::dumpArgs() ");
 	for (uint32 i = 0; i < count; i++) {
 		ScriptValue argValue = getArg(i);
 		if (argValue.type == kConstString) {
-			printf("'%s'", toString(argValue));
+			debug(kDebugScript, "'%s'", toString(argValue));
 		} else {
-			printf("%d", argValue.value);
+			debug(kDebugScript, "%d", argValue.value);
 		}
 		if (i + 1 < count)
-			printf(", ");
+			debug(kDebugScript, ", ");
 	}
-	printf("\n");
+	debug(kDebugScript, "\n");
 }
 
 void ScriptInterpreter::callFunction(uint32 index) {
 	// NOTE: This is a temporary hack for script functions not yet in the m4.dat
 	if (index == 0xFFFFFFFF)
 		return;
-	printf("ScriptInterpreter::callFunction() index = %d [%s]\n", index, _scriptFunctionNames[index].c_str());
+	debug(kDebugScript, "ScriptInterpreter::callFunction() index = %d [%s]\n", index, _scriptFunctionNames[index].c_str());
 	fflush(stdout);
 	ScriptFunction *subFunction = loadFunction(index);
 	if (!subFunction) {
 		// This *should* never happen since the linker checks this
-		printf("ScriptInterpreter::callFunction() Function %d could not be loaded!\n", index);
+		debug(kDebugScript, "ScriptInterpreter::callFunction() Function %d could not be loaded!\n", index);
 		return;
 	}
 	runFunction(subFunction);
@@ -600,7 +600,7 @@
 
 bool ScriptInterpreter::execOpcode(byte opcode) {
 
-	printf("opcode = %d (%s)\n", opcode, opcodeNames[opcode]);
+	debug(kDebugScript, "opcode = %d (%s)\n", opcode, opcodeNames[opcode]);
 
 	ScriptValue value1, value2, value3;
 	uint32 temp;
@@ -649,14 +649,14 @@
 
 	case opJmp:
 		temp = _runningFunction->readUint32();
-		printf("-> ofs = %08X\n", temp);
+		debug(kDebugScript, "-> ofs = %08X\n", temp);
 		_runningFunction->jumpAbsolute(temp);
 		return true;
 
 	case opJl:
 		temp = _runningFunction->readUint32();
 		if (_cmpFlags < 0) {
-			printf("-> ofs = %08X\n", temp);
+			debug(kDebugScript, "-> ofs = %08X\n", temp);
 			_runningFunction->jumpAbsolute(temp);
 		}
 		return true;
@@ -664,7 +664,7 @@
 	case opJle:
 		temp = _runningFunction->readUint32();
 		if (_cmpFlags <= 0) {
-			printf("-> ofs = %08X\n", temp);
+			debug(kDebugScript, "-> ofs = %08X\n", temp);
 			_runningFunction->jumpAbsolute(temp);
 		}
 		return true;
@@ -672,7 +672,7 @@
 	case opJg:
 		temp = _runningFunction->readUint32();
 		if (_cmpFlags > 0) {
-			printf("-> ofs = %08X\n", temp);
+			debug(kDebugScript, "-> ofs = %08X\n", temp);
 			_runningFunction->jumpAbsolute(temp);
 		}
 		return true;
@@ -680,7 +680,7 @@
 	case opJge:
 		temp = _runningFunction->readUint32();
 		if (_cmpFlags >= 0) {
-			printf("-> ofs = %08X\n", temp);
+			debug(kDebugScript, "-> ofs = %08X\n", temp);
 			_runningFunction->jumpAbsolute(temp);
 		}
 		return true;
@@ -688,7 +688,7 @@
 	case opJz:
 		temp = _runningFunction->readUint32();
 		if (_cmpFlags == 0) {
-			printf("-> ofs = %08X\n", temp);
+			debug(kDebugScript, "-> ofs = %08X\n", temp);
 			_runningFunction->jumpAbsolute(temp);
 		}
 		return true;
@@ -696,17 +696,17 @@
 	case opJnz:
 		temp = _runningFunction->readUint32();
 		if (_cmpFlags != 0) {
-			printf("-> ofs = %08X\n", temp);
+			debug(kDebugScript, "-> ofs = %08X\n", temp);
 			_runningFunction->jumpAbsolute(temp);
 		}
 		return true;
 
 	case opJmpByTable:
 		temp = _runningFunction->readUint32();
-		printf("-> index = %d\n", _registers[0].value);
+		debug(kDebugScript, "-> index = %d\n", _registers[0].value);
 		_runningFunction->jumpRelative(_registers[0].value * 4);
 		temp = _runningFunction->readUint32();
-		printf("-> ofs = %08X\n", temp);
+		debug(kDebugScript, "-> ofs = %08X\n", temp);
 		_runningFunction->jumpAbsolute(temp);
 		return true;
 
@@ -718,8 +718,8 @@
 		if (value1.type != kInteger || value2.type != kInteger)
 			warning("ScriptInterpreter::execOpcode() Trying to compare non-integer values (%d, %d, line %d)", value1.type, value2.type, _lineNum);
 		_cmpFlags = value1.value - value2.value;
-		printf("-> cmp %d, %d\n", value1.value, value2.value);
-		printf("-> _cmpFlags  = %d\n", _cmpFlags);
+		debug(kDebugScript, "-> cmp %d, %d\n", value1.value, value2.value);
+		debug(kDebugScript, "-> _cmpFlags  = %d\n", _cmpFlags);
 		return true;
 
 	case opCall:
@@ -773,7 +773,7 @@
 		return true;
 
 	default:
-		printf("Invalid opcode %d!\n", opcode);
+		debug(kDebugScript, "Invalid opcode %d!\n", opcode);
 		return false;
 
 	}
@@ -922,14 +922,14 @@
 int ScriptInterpreter::o1_preloadSound() {
 	const char *name = STRING(0);
 	int room = INTEGER(1);
-	printf("name = %s; room = %d\n", name, room);
+	debug(kDebugScript, "name = %s; room = %d\n", name, room);
 	return 2;
 }
 
 int ScriptInterpreter::o1_unloadSound() {
 	const char *name = STRING(0);
 	int room = INTEGER(1);
-	printf("name = %s; room = %d\n", name, room);
+	debug(kDebugScript, "name = %s; room = %d\n", name, room);
 	return 2;
 }
 
@@ -939,7 +939,7 @@
 	int volume = INTEGER(2);
 	int trigger = INTEGER(3);
 	int room = INTEGER(4);
-	printf("name = %s; channel = %d; volume = %d; trigger = %d; room = %d\n",
+	debug(kDebugScript, "name = %s; channel = %d; volume = %d; trigger = %d; room = %d\n",
 		name, channel, volume, trigger, room);
 
 	Common::String soundName = Common::String(name) + ".raw";
@@ -957,7 +957,7 @@
 	int volume = INTEGER(2);
 	int trigger = INTEGER(3);
 	int room = INTEGER(4);
-	printf("name = %s; channel = %d; volume = %d; trigger = %d; room = %d\n",
+	debug(kDebugScript, "name = %s; channel = %d; volume = %d; trigger = %d; room = %d\n",
 		name, channel, volume, trigger, room);
 
 	// HACK until fixed
@@ -968,14 +968,14 @@
 
 int ScriptInterpreter::o1_stopSound() {
 	int channel = INTEGER(0);
-	printf("channel = %d\n", channel);
+	debug(kDebugScript, "channel = %d\n", channel);
 	return 1;
 }
 
 int ScriptInterpreter::o1_fadeSetStart() {
 	// skip arg 0: palette ptr
 	int percent = INTEGER(1);
-	printf("percent = %d\n", percent);
+	debug(kDebugScript, "percent = %d\n", percent);
 	return 2;
 }
 
@@ -986,7 +986,7 @@
 	int percent = INTEGER(3);
 	int ticks = INTEGER(4);
 	int trigger = INTEGER(5);
-	printf("first = %d; last = %d; percent = %d; ticks = %d; trigger = %d\n",
+	debug(kDebugScript, "first = %d; last = %d; percent = %d; ticks = %d; trigger = %d\n",
 		first, last, percent, ticks, trigger);
 
 	// HACK until palette fading is implemented
@@ -1005,7 +1005,7 @@
 	int delay = INTEGER(2);
 	int ticks = INTEGER(3);
 	int trigger = INTEGER(4);
-	printf("first = %d; last = %d; delay = %d; ticks = %d; trigger = %d\n",
+	debug(kDebugScript, "first = %d; last = %d; delay = %d; ticks = %d; trigger = %d\n",
 		first, last, delay, ticks, trigger);
 
 	// HACK until palette cycling is implemented
@@ -1022,11 +1022,11 @@
 	const char *words[3];
 	for (int i = 0; i < 3; i++)
 		words[i] = STRING(i);
-	printf("'%s', '%s', '%s'\n", words[0], words[1], words[2]);
+	debug(kDebugScript, "'%s', '%s', '%s'\n", words[0], words[1], words[2]);
 
 	int result = _vm->_player->said(words[0], words[1], words[2]);
 
-	printf("   -> '%d'\n", result);
+	debug(kDebugScript, "   -> '%d'\n", result);
 	fflush(stdout);
 
 	RETURN(result);
@@ -1038,11 +1038,11 @@
 	for (int i = 0; i < 10; i++)
 		words[i] = STRING(i);
 
-	printf("'%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s'\n",
+	debug(kDebugScript, "'%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s'\n",
 		words[0], words[1], words[2], words[3], words[4], words[5], words[6], words[7], words[8], words[9]);
 
 	int result = _vm->_player->saidAny(words[0], words[1], words[2], words[3], words[4], words[5], words[6], words[7], words[8], words[9]);
-	printf("   -> '%d'\n", result);
+	debug(kDebugScript, "   -> '%d'\n", result);
 	fflush(stdout);
 
 	RETURN(result);
@@ -1059,13 +1059,13 @@
 	int y1 = INTEGER(1);
 	int x2 = INTEGER(2);
 	int y2 = INTEGER(3);
-	printf("(%d, %d); (%d, %d)\n", x1, y1, x2, y2);
+	debug(kDebugScript, "(%d, %d); (%d, %d)\n", x1, y1, x2, y2);
 	return 4;
 }
 
 int ScriptInterpreter::o1_playerHasItem() {
 	const char *name = STRING(0);
-	printf("item = '%s'\n", name);
+	debug(kDebugScript, "item = '%s'\n", name);
 	// TODO
 	RETURN(0);
 	return 1;
@@ -1075,14 +1075,14 @@
 	// skip arg 0: walker
 	int x = INTEGER(1);
 	int y = INTEGER(2);
-	printf("x = %d; y = %d\n", x, y);
+	debug(kDebugScript, "x = %d; y = %d\n", x, y);
 	return 3;
 }
 
 int ScriptInterpreter::o1_setWalkerFacing() {
 	// skip arg 0: walker
 	int facing = INTEGER(1);
-	printf("facing = %d\n", facing);
+	debug(kDebugScript, "facing = %d\n", facing);
 	return 2;
 }
 
@@ -1090,7 +1090,7 @@
 	// skip arg 0: hotspot list
 	const char *name = STRING(1);
 	int value = INTEGER(2);
-	printf("name = '%s' -> %d\n", name, value);
+	debug(kDebugScript, "name = '%s' -> %d\n", name, value);
 
 	_vm->_scene->getSceneResources().hotspots->setActive(name, (value != 0));
 
@@ -1121,7 +1121,7 @@
 	int firstFrame = INTEGER(9);
 	int lastFrame = INTEGER(10);
 
-	printf("name = %s; layer = %04X; flags = %08X; trigger = %d; frameRate = %d; loopCount = %d; scale = %d; x = %d; y = %d: firstFrame = %d; lastFrame = %d\n",
+	debug(kDebugScript, "name = %s; layer = %04X; flags = %08X; trigger = %d; frameRate = %d; loopCount = %d; scale = %d; x = %d; y = %d: firstFrame = %d; lastFrame = %d\n",
 		name, layer, flags, trigger, frameRate, loopCount, scale, x, y, firstFrame, lastFrame);
 		fflush(stdout);
 
@@ -1142,7 +1142,7 @@
 	int x = INTEGER(7);
 	int y = INTEGER(8);
 
-	printf("name = %s; layer = %04X; flags = %08X; trigger = %d; duration = %d; frameIndex = %d; scale = %d; x = %d; y = %d\n",
+	debug(kDebugScript, "name = %s; layer = %04X; flags = %08X; trigger = %d; duration = %d; frameIndex = %d; scale = %d; x = %d; y = %d\n",
 		name, layer, flags, trigger, duration, frameIndex, scale, x, y);
 		fflush(stdout);
 
@@ -1157,7 +1157,7 @@
 	int hash = INTEGER(1);
 	// skip arg 3: palette ptr
 
-	printf("name = %s; hash = %d\n", name, hash);
+	debug(kDebugScript, "name = %s; hash = %d\n", name, hash);
 	fflush(stdout);
 
 	int result = _vm->_ws->loadSeries(name, hash, NULL);
@@ -1189,7 +1189,7 @@
 	int value1 = INTEGER(0);
 	int value2 = INTEGER(1);
 	int value3 = INTEGER(2);
-	printf("%d; %d; %d\n", value1, value2, value3);
+	debug(kDebugScript, "%d; %d; %d\n", value1, value2, value3);
 	return 3;
 }
 
@@ -1197,13 +1197,13 @@
 	int value1 = INTEGER(0);
 	int value2 = INTEGER(1);
 	int value3 = INTEGER(2);
-	printf("%d; %d; %d\n", value1, value2, value3);
+	debug(kDebugScript, "%d; %d; %d\n", value1, value2, value3);
 	return 3;
 }
 
 int ScriptInterpreter::o1_dispatchTrigger() {
 	int trigger = INTEGER(0);
-	printf("trigger = %d\n", trigger);
+	debug(kDebugScript, "trigger = %d\n", trigger);
 
 	_vm->_kernel->sendTrigger(trigger);
 	//g_system->delayMillis(5000);
@@ -1229,7 +1229,7 @@
 		SaidArrayItem *item = saidArray[i];
 
 		if (_vm->_player->said("LOOK AT", item->itemName) && item->digiNameLook) {
-			printf("  -> LOOK AT: '%s'\n", item->digiNameLook);
+			debug(kDebugScript, "  -> LOOK AT: '%s'\n", item->digiNameLook);
 			Common::String soundName = Common::String(item->digiNameLook) + ".raw";
 			_vm->_sound->playVoice(soundName.c_str(), 100);
 			result = 1;
@@ -1237,7 +1237,7 @@
 		}
 
 		if (_vm->_player->said("TAKE", item->itemName) && item->digiNameTake) {
-			printf("  -> TAKE: '%s'\n", item->digiNameTake);
+			debug(kDebugScript, "  -> TAKE: '%s'\n", item->digiNameTake);
 			Common::String soundName = Common::String(item->digiNameTake) + ".raw";
 			_vm->_sound->playVoice(soundName.c_str(), 100);
 			result = 1;
@@ -1245,7 +1245,7 @@
 		}
 
 		if (_vm->_player->said("GEAR", item->itemName) && item->digiNameGear) {
-			printf("  -> GEAR: '%s'\n", item->digiNameGear);
+			debug(kDebugScript, "  -> GEAR: '%s'\n", item->digiNameGear);
 			Common::String soundName = Common::String(item->digiNameGear) + ".raw";
 			_vm->_sound->playVoice(soundName.c_str(), 100);
 			result = 1;
@@ -1253,11 +1253,11 @@
 		}
 
 		/*
-		printf("##### itemName = '%s'; digiNameLook = %s; digiNameTake = %s; digiNameGear = %s\n",
+		debug(kDebugScript, "##### itemName = '%s'; digiNameLook = %s; digiNameTake = %s; digiNameGear = %s\n",
 			item->itemName, item->digiNameLook, item->digiNameTake, item->digiNameGear);
 		*/
 	}
-	printf("   -> '%d'\n", result);
+	debug(kDebugScript, "   -> '%d'\n", result);
 	fflush(stdout);
 
 	RETURN(result);
@@ -1278,7 +1278,7 @@
 	int volume = INTEGER(4);
 	int slot = INTEGER(5);
 
-	printf("%s; %d; %d; %d; %d; %d\n", name, trigger, room, flag, volume, slot);
+	debug(kDebugScript, "%s; %d; %d; %d; %d; %d\n", name, trigger, room, flag, volume, slot);
 	fflush(stdout);
 	//g_system->delayMillis(5000);
 
@@ -1297,14 +1297,14 @@
 
 void ScriptInterpreter::getKernelVar(int index, ScriptValue &value) {
 
-	printf("ScriptInterpreter::getKernelVar() index = %d\n", index);
+	debug(kDebugScript, "ScriptInterpreter::getKernelVar() index = %d\n", index);
 
 	if (index > _kernelVarsMax) {
-		printf("ScriptInterpreter::getKernelVar() Invalid kernel var index %d!\n", index);
+		debug(kDebugScript, "ScriptInterpreter::getKernelVar() Invalid kernel var index %d!\n", index);
 		return;
 	}
 
-	printf("ScriptInterpreter::getKernelVar() name = %s\n", _kernelVars[index].desc);
+	debug(kDebugScript, "ScriptInterpreter::getKernelVar() name = %s\n", _kernelVars[index].desc);
 
 	ScriptKernelVariable var = _kernelVars[index].var;
 
@@ -1342,7 +1342,7 @@
 		break;
 
 	default:
-		printf("ScriptInterpreter::getKernelVar() Invalid kernel var %d!\n", var);
+		debug(kDebugScript, "ScriptInterpreter::getKernelVar() Invalid kernel var %d!\n", var);
 		//g_system->delayMillis(2000);
 
 	}
@@ -1351,14 +1351,14 @@
 
 void ScriptInterpreter::setKernelVar(int index, const ScriptValue &value) {
 
-	printf("ScriptInterpreter::setKernelVar() index = %d\n", index);
+	debug(kDebugScript, "ScriptInterpreter::setKernelVar() index = %d\n", index);
 
 	if (index > _kernelVarsMax) {
-		printf("ScriptInterpreter::setKernelVar() Invalid kernel var index %d!\n", index);
+		debug(kDebugScript, "ScriptInterpreter::setKernelVar() Invalid kernel var index %d!\n", index);
 		return;
 	}
 
-	printf("ScriptInterpreter::setKernelVar() name = %s\n", _kernelVars[index].desc);
+	debug(kDebugScript, "ScriptInterpreter::setKernelVar() name = %s\n", _kernelVars[index].desc);
 
 	ScriptKernelVariable var = _kernelVars[index].var;
 
@@ -1366,31 +1366,31 @@
 
 	case kKernelTrigger:
 		_vm->_kernel->trigger = toInteger(value);
-		printf("kKernelTrigger -> %d\n", toInteger(value));
+		debug(kDebugScript, "kKernelTrigger -> %d\n", toInteger(value));
 		break;
 
 	case kKernelTriggerMode:
 		_vm->_kernel->triggerMode = (KernelTriggerType)toInteger(value);
-		printf("kKernelTrigger -> %d\n", toInteger(value));
+		debug(kDebugScript, "kKernelTrigger -> %d\n", toInteger(value));
 		break;
 
 	case kKernelContinueHandlingTrigger:
 		_vm->_kernel->daemonTriggerAvailable = (toInteger(value) != 0);
-		printf("kKernelContinueHandlingTrigger -> %d\n", toInteger(value));
+		debug(kDebugScript, "kKernelContinueHandlingTrigger -> %d\n", toInteger(value));
 		break;
 
 	case kGameNewRoom:
 		_vm->_kernel->newRoom = toInteger(value);
-		printf("kGameNewRoom -> %d\n", toInteger(value));
+		debug(kDebugScript, "kGameNewRoom -> %d\n", toInteger(value));
 		break;
 
 	case kPlayerCommandReady:
 		// TODO
-		printf("kPlayerCommandReady -> %d\n", toInteger(value));
+		debug(kDebugScript, "kPlayerCommandReady -> %d\n", toInteger(value));
 		break;
 
 	default:
-		printf("ScriptInterpreter::setKernelVar() Invalid kernel var %d!\n", var);
+		debug(kDebugScript, "ScriptInterpreter::setKernelVar() Invalid kernel var %d!\n", var);
 		//g_system->delayMillis(2000);
 
 	}

Modified: scummvm/trunk/engines/m4/script.h
===================================================================
--- scummvm/trunk/engines/m4/script.h	2010-11-02 00:15:18 UTC (rev 54034)
+++ scummvm/trunk/engines/m4/script.h	2010-11-02 00:51:12 UTC (rev 54035)
@@ -305,7 +305,7 @@
 	// Is this ok?
 	template<class T>
 	const T& toData(const ScriptValue &value) {
-		printf("ScriptInterpreter::toData() index = %d; type = %d; max = %d\n", value.value, _data[value.value]->type, _data.size());
+		debug(kDebugScript, "ScriptInterpreter::toData() index = %d; type = %d; max = %d\n", value.value, _data[value.value]->type, _data.size());
 		assert((uint32)value.value < _data.size());
 		T *result = 0;
 		_dataCache->load(_scriptFile, _data[value.value]->offset, result);

Modified: scummvm/trunk/engines/m4/sound.cpp
===================================================================
--- scummvm/trunk/engines/m4/sound.cpp	2010-11-02 00:15:18 UTC (rev 54034)
+++ scummvm/trunk/engines/m4/sound.cpp	2010-11-02 00:51:12 UTC (rev 54035)
@@ -194,7 +194,7 @@
 
 	// Read header
 	_dsrFile.entryCount = fileStream->readUint16LE();
-	//printf("DSR has %i entries\n", _dsrFile.entryCount);
+	//warning(kDebugSound, "DSR has %i entries\n", _dsrFile.entryCount);
 
 	for (int i = 0; i < _dsrFile.entryCount; i++) {
 		DSREntry newEntry;
@@ -206,13 +206,13 @@
 		_dsrFile.dsrEntries.push_back(newEntry);
 
 		/*
-		printf("%i: ", i);
-		printf("frequency: %i ", newEntry->frequency);
-		printf("channels: %i ", newEntry->channels);
-		printf("comp: %i ", newEntry.compSize);
-		printf("uncomp: %i ", newEntry.uncompSize);
-		printf("offset: %i ", newEntry->offset);
-		printf("\n");
+		warning(kDebugSound, "%i: ", i);
+		warning(kDebugSound, "frequency: %i ", newEntry->frequency);
+		warning(kDebugSound, "channels: %i ", newEntry->channels);
+		warning(kDebugSound, "comp: %i ", newEntry.compSize);
+		warning(kDebugSound, "uncomp: %i ", newEntry.uncompSize);
+		warning(kDebugSound, "offset: %i ", newEntry->offset);
+		warning(kDebugSound, "\n");
 		*/
 	}
 

Modified: scummvm/trunk/engines/m4/woodscript.cpp
===================================================================
--- scummvm/trunk/engines/m4/woodscript.cpp	2010-11-02 00:15:18 UTC (rev 54034)
+++ scummvm/trunk/engines/m4/woodscript.cpp	2010-11-02 00:51:12 UTC (rev 54035)
@@ -46,7 +46,7 @@
 
 int Bytecode::loadInstruction(Instruction &instruction) {
 
-	//printf("Bytecode::loadInstruction() ip = %08X\n", _code->pos());
+	//debug(kDebugScript, "Bytecode::loadInstruction() ip = %08X\n", _code->pos());
 
 	int32 format, data;
 	uint32 code, code2;
@@ -90,7 +90,7 @@
 
 void Bytecode::jumpAbsolute(int32 ofs) {
 	_code->seek(ofs * 4);
-	//printf("Bytecode::jumpAbsolute() ofs = %08X\n", _code->pos());
+	//debug(kDebugScript, "Bytecode::jumpAbsolute() ofs = %08X\n", _code->pos());
 }
 
 void Bytecode::jumpRelative(int32 ofs) {
@@ -200,7 +200,7 @@
 Machine *WoodScript::createMachine(int32 machineHash, Sequence *parentSeq,
 	int32 dataHash, int32 dataRowIndex, int callbackHandler, const char *machineName) {
 
-	//printf("WoodScript::createMachine(%d)\n", machineHash); fflush(stdout);
+	//debug(kDebugScript, "WoodScript::createMachine(%d)\n", machineHash); fflush(stdout);
 
 	Machine *machine = new Machine(this, machineHash, parentSeq, dataHash, dataRowIndex, callbackHandler, machineName, _machineId);
 	_machineId++;
@@ -228,7 +228,7 @@
 	int32 frameRate, int32 loopCount, int32 s, int32 x, int32 y,
 	int32 firstFrame, int32 lastFrame) {
 
-	//printf("WoodScript::playSeries(%s)\n", seriesName);
+	//debug(kDebugScript, "WoodScript::playSeries(%s)\n", seriesName);
 
 	RGB8 *palette = NULL;
 	if (flags & SERIES_LOAD_PALETTE)
@@ -282,7 +282,7 @@
 }
 
 Machine *WoodScript::streamSeries(const char *seriesName, int32 frameRate, long layer, int32 triggerNum) {
-	//printf("WoodScript::streamSeries(%s)\n", seriesName);
+	//debug(kDebugScript, "WoodScript::streamSeries(%s)\n", seriesName);
 	_globals[kGlobTemp1] = frameRate << 16;
 	/* FIXME: Single frames from a stream series will be decompressed on-the-fly, contrary to
 			  "normal" sprite series, to save some memory, and since no random access to single

Modified: scummvm/trunk/engines/m4/ws_machine.cpp
===================================================================
--- scummvm/trunk/engines/m4/ws_machine.cpp	2010-11-02 00:15:18 UTC (rev 54034)
+++ scummvm/trunk/engines/m4/ws_machine.cpp	2010-11-02 00:51:12 UTC (rev 54035)
@@ -147,7 +147,7 @@
 
 int32 Machine::execInstruction() {
 
-	//printf("Machine::execInstruction()\n"); fflush(stdout);
+	//debug(kDebugScript, "Machine::execInstruction()\n"); fflush(stdout);
 
 	bool done = false;
 	Instruction instruction;
@@ -199,7 +199,7 @@
 
 	int32 instruction = -1;
 
-	//printf("---------------------------------------\n"); fflush(stdout);
+	//debug(kDebugScript, "---------------------------------------\n"); fflush(stdout);
 
 	while (instruction && instruction != 4 && _id == oldId && _recursionLevel == oldRecursionLevel &&
 		_code->pos() >= (uint32)startOffset && _code->pos() < (uint32)endOffset) {
@@ -208,7 +208,7 @@
 		//g_system->delayMillis(500);
 	}
 
-	//printf("---------------------------------------\n"); fflush(stdout);
+	//debug(kDebugScript, "---------------------------------------\n"); fflush(stdout);
 
 	if (instruction == 3) {
 		execInstruction();
@@ -221,7 +221,7 @@
 }
 
 bool Machine::m1_gotoState(Instruction &instruction) {
-	//printf("Machine::m1_gotoState() state = %d\n", (int32)instruction.argv[0] >> 16);
+	//debug(kDebugScript, "Machine::m1_gotoState() state = %d\n", (int32)instruction.argv[0] >> 16);
 
 	_currentState = (int32)instruction.argv[0] >> 16;
 	_recursionLevel = 0;
@@ -229,14 +229,14 @@
 }
 
 bool Machine::m1_jump(Instruction &instruction) {
-	//printf("Machine::m1_jump() ofs = %08X\n", (int32)instruction.argv[0] >> 16);
+	//debug(kDebugScript, "Machine::m1_jump() ofs = %08X\n", (int32)instruction.argv[0] >> 16);
 
 	_code->jumpRelative((int32)instruction.argv[0] >> 16);
 	return true;
 }
 
 bool Machine::m1_terminate(Instruction &instruction) {
-	//printf("Machine::m1_terminate()\n"); fflush(stdout);
+	//debug(kDebugScript, "Machine::m1_terminate()\n"); fflush(stdout);
 
 	_currentState = -1;
 	_recursionLevel = 0;
@@ -244,15 +244,15 @@
 }
 
 bool Machine::m1_startSequence(Instruction &instruction) {
-	//printf("Machine::m1_startSequence() sequence hash = %d\n", (uint32)instruction.argv[0] >> 16); fflush(stdout);
+	//debug(kDebugScript, "Machine::m1_startSequence() sequence hash = %d\n", (uint32)instruction.argv[0] >> 16); fflush(stdout);
 
 	int32 sequenceHash = instruction.argv[0] >> 16;
 	if (_sequence == NULL) {
-		//printf("Machine::m1_startSequence() creating new sequence\n");
+		//debug(kDebugScript, "Machine::m1_startSequence() creating new sequence\n");
 		_sequence = _ws->createSequence(this, sequenceHash);
 		_code->setSequence(_sequence);
 	} else {
-		//printf("Machine::m1_startSequence() using existing sequence\n");
+		//debug(kDebugScript, "Machine::m1_startSequence() using existing sequence\n");
 		_sequence->changeProgram(sequenceHash);
 		//_code->setSequence(_sequence);
 	}
@@ -260,28 +260,28 @@
 }
 
 bool Machine::m1_pauseSequence(Instruction &instruction) {
-	//printf("Machine::m1_pauseSequence()\n"); fflush(stdout);
+	//debug(kDebugScript, "Machine::m1_pauseSequence()\n"); fflush(stdout);
 
 	_sequence->pause();
 	return true;
 }
 
 bool Machine::m1_resumeSequence(Instruction &instruction) {
-	//printf("Machine::m1_resumeSequence()\n"); fflush(stdout);
+	//debug(kDebugScript, "Machine::m1_resumeSequence()\n"); fflush(stdout);
 
 	_sequence->resume();
 	return true;
 }
 
 bool Machine::m1_storeValue(Instruction &instruction) {
-	//printf("Machine::m1_storeValue() %p = %d (%08X)\n", (void*)instruction.argp[0], (uint32)instruction.argv[1], (uint32)instruction.argv[1]);
+	//debug(kDebugScript, "Machine::m1_storeValue() %p = %d (%08X)\n", (void*)instruction.argp[0], (uint32)instruction.argv[1], (uint32)instruction.argv[1]);
 
 	*instruction.argp[0] = instruction.getValue();
 	return true;
 }
 
 bool Machine::m1_sendMessage(Instruction &instruction) {
-	//printf("Machine::m1_sendMessage() %p = %d (%08X)\n", (void*)instruction.argp[0], (uint32)instruction.argv[1], (uint32)instruction.argv[1]);
+	//debug(kDebugScript, "Machine::m1_sendMessage() %p = %d (%08X)\n", (void*)instruction.argp[0], (uint32)instruction.argv[1], (uint32)instruction.argv[1]);
 
 #if 0
 //TODO
@@ -300,7 +300,7 @@
 }
 
 bool Machine::m1_broadcastMessage(Instruction &instruction) {
-	//printf("Machine::m1_broadcastMessage() %p = %d (%08X)\n", (void*)instruction.argp[0], (uint32)instruction.argv[1], (uint32)instruction.argv[1]);
+	//debug(kDebugScript, "Machine::m1_broadcastMessage() %p = %d (%08X)\n", (void*)instruction.argp[0], (uint32)instruction.argv[1], (uint32)instruction.argv[1]);
 
 #if 0
 //TODO
@@ -317,7 +317,7 @@
 }
 
 bool Machine::m1_replyMessage(Instruction &instruction) {
-	//printf("Machine::m1_replyMessage() messageHash = %d; messageValue = %d\n", (uint32)instruction.argv[0], (uint32)instruction.argv[1]);
+	//debug(kDebugScript, "Machine::m1_replyMessage() messageHash = %d; messageValue = %d\n", (uint32)instruction.argv[0], (uint32)instruction.argv[1]);
 #if 0
 	if (myArg2) {
 		msgValue = *myArg2;
@@ -331,28 +331,28 @@
 }
 
 bool Machine::m1_sendSystemMessage(Instruction &instruction) {
-	//printf("Machine::m1_sendSystemMessage() messageValue = %d\n", (uint32)instruction.argv[0]);
+	//debug(kDebugScript, "Machine::m1_sendSystemMessage() messageValue = %d\n", (uint32)instruction.argv[0]);
 #if 0
 #endif
 	return true;
 }
 
 bool Machine::m1_createMachine(Instruction &instruction) {
-	//printf("Machine::m1_createMachine()\n");
+	//debug(kDebugScript, "Machine::m1_createMachine()\n");
 #if 0
 #endif
 	return true;
 }
 
 bool Machine::m1_createMachineEx(Instruction &instruction) {
-	//printf("Machine::m1_createMachineEx()\n");
+	//debug(kDebugScript, "Machine::m1_createMachineEx()\n");
 #if 0
 #endif
 	return true;
 }
 
 bool Machine::m1_clearVars(Instruction &instruction) {
-	//printf("Machine::m1_clearVars()\n"); fflush(stdout);
+	//debug(kDebugScript, "Machine::m1_clearVars()\n"); fflush(stdout);
 
 	_sequence->clearVars();
 	return true;
@@ -360,7 +360,7 @@
 
 
 void Machine::m1_onEndSequence(Instruction &instruction) {
-	//printf("Machine::m1_onEndSequence() count = %08X\n", (uint32)instruction.argv[0] >> 16); fflush(stdout);
+	//debug(kDebugScript, "Machine::m1_onEndSequence() count = %08X\n", (uint32)instruction.argv[0] >> 16); fflush(stdout);
 
 	int32 count = instruction.argv[0] >> 16;
 	_sequence->issueEndOfSequenceRequest(_code->pos(), count);
@@ -368,7 +368,7 @@
 }
 
 void Machine::m1_onMessage(Instruction &instruction) {
-	//printf("Machine::m1_onEndSequence() count = %08X\n", (uint32)instruction.argv[0] >> 16); fflush(stdout);
+	//debug(kDebugScript, "Machine::m1_onEndSequence() count = %08X\n", (uint32)instruction.argv[0] >> 16); fflush(stdout);
 
 	// TODO: Add message to list
 
@@ -378,42 +378,42 @@
 }
 
 void Machine::m1_switchLt(Instruction &instruction) {
-	//printf("Machine::m1_switchLt() %d < %d -> %08X\n", (uint32)instruction.argv[1], (uint32)instruction.argv[2], (uint32)instruction.argv[0] >> 16); fflush(stdout);
+	//debug(kDebugScript, "Machine::m1_switchLt() %d < %d -> %08X\n", (uint32)instruction.argv[1], (uint32)instruction.argv[2], (uint32)instruction.argv[0] >> 16); fflush(stdout);
 
 	if (instruction.argv[1] >= instruction.argv[2])
 		_code->jumpRelative(instruction.argv[0] >> 16);
 }
 
 void Machine::m1_switchLe(Instruction &instruction) {
-	//printf("Machine::m1_switchLe() %d <= %d -> %08X\n", (uint32)instruction.argv[1], (uint32)instruction.argv[2], (uint32)instruction.argv[0] >> 16); fflush(stdout);
+	//debug(kDebugScript, "Machine::m1_switchLe() %d <= %d -> %08X\n", (uint32)instruction.argv[1], (uint32)instruction.argv[2], (uint32)instruction.argv[0] >> 16); fflush(stdout);
 
 	if (instruction.argv[1] > instruction.argv[2])
 		_code->jumpRelative(instruction.argv[0] >> 16);
 }
 
 void Machine::m1_switchEq(Instruction &instruction) {
-	//printf("Machine::m1_switchEq() %d == %d -> %08X\n", (uint32)instruction.argv[1], (uint32)instruction.argv[2], (uint32)instruction.argv[0] >> 16); fflush(stdout);
+	//debug(kDebugScript, "Machine::m1_switchEq() %d == %d -> %08X\n", (uint32)instruction.argv[1], (uint32)instruction.argv[2], (uint32)instruction.argv[0] >> 16); fflush(stdout);
 
 	if (instruction.argv[1] != instruction.argv[2])
 		_code->jumpRelative(instruction.argv[0] >> 16);
 }
 
 void Machine::m1_switchNe(Instruction &instruction) {
-	//printf("Machine::m1_switchNe() %d != %d -> %08X\n", (uint32)instruction.argv[1], (uint32)instruction.argv[2], (uint32)instruction.argv[0] >> 16); fflush(stdout);
+	//debug(kDebugScript, "Machine::m1_switchNe() %d != %d -> %08X\n", (uint32)instruction.argv[1], (uint32)instruction.argv[2], (uint32)instruction.argv[0] >> 16); fflush(stdout);
 
 	if (instruction.argv[1] == instruction.argv[2])
 		_code->jumpRelative(instruction.argv[0] >> 16);
 }
 
 void Machine::m1_switchGe(Instruction &instruction) {
-	//printf("Machine::m1_switchGe() %d >= %d -> %08X\n", (uint32)instruction.argv[1], (uint32)instruction.argv[2], (uint32)instruction.argv[0] >> 16); fflush(stdout);
+	//debug(kDebugScript, "Machine::m1_switchGe() %d >= %d -> %08X\n", (uint32)instruction.argv[1], (uint32)instruction.argv[2], (uint32)instruction.argv[0] >> 16); fflush(stdout);
 
 	if (instruction.argv[1] < instruction.argv[2])
 		_code->jumpRelative(instruction.argv[0] >> 16);
 }
 
 void Machine::m1_switchGt(Instruction &instruction) {
-	//printf("Machine::m1_switchGt() %d > %d -> %08X\n", (uint32)instruction.argv[1], (uint32)instruction.argv[2], (uint32)instruction.argv[0] >> 16); fflush(stdout);
+	//debug(kDebugScript, "Machine::m1_switchGt() %d > %d -> %08X\n", (uint32)instruction.argv[1], (uint32)instruction.argv[2], (uint32)instruction.argv[0] >> 16); fflush(stdout);
 
 	if (instruction.argv[1] <= instruction.argv[2])
 		_code->jumpRelative(instruction.argv[0] >> 16);

Modified: scummvm/trunk/engines/m4/ws_sequence.cpp
===================================================================
--- scummvm/trunk/engines/m4/ws_sequence.cpp	2010-11-02 00:15:18 UTC (rev 54034)
+++ scummvm/trunk/engines/m4/ws_sequence.cpp	2010-11-02 00:51:12 UTC (rev 54035)
@@ -201,7 +201,7 @@
 
 void Sequence::issueEndOfSequenceRequest(int32 codeOffset, int32 count) {
 
-	//printf("Sequence::issueEndOfSequenceRequest(%04X, %04X)\n", codeOffset, count); fflush(stdout);
+	//debug(kDebugScript, "Sequence::issueEndOfSequenceRequest(%04X, %04X)\n", codeOffset, count); fflush(stdout);
 	//g_system->delayMillis(5000);
 
 	_endOfSequenceRequest.codeOffset = codeOffset;
@@ -216,7 +216,7 @@
 
 	bool done = true;
 
-	//printf("_ws->getGlobal(kGlobTime) = %ld, _switchTime = %d\n", _ws->getGlobal(kGlobTime), _switchTime);
+	//debug(kDebugScript, "_ws->getGlobal(kGlobTime) = %ld, _switchTime = %d\n", _ws->getGlobal(kGlobTime), _switchTime);
 
 	if (_switchTime >= 0 && _ws->getGlobal(kGlobTime) >= _switchTime)
 		done = false;
@@ -246,7 +246,7 @@
 	SequenceAsset *sequenceAsset = _ws->assets()->getSequence(sequenceHash);
 
 	if (sequenceAsset->localVarCount() > _localVarCount) {
-		//printf("Sequence::changeProgram(%d) sequenceAsset->localVarCount() > _localVarCount\n", sequenceHash);
+		//debug(kDebugScript, "Sequence::changeProgram(%d) sequenceAsset->localVarCount() > _localVarCount\n", sequenceHash);
 		return false;
 	}
 
@@ -301,14 +301,14 @@
 }
 
 bool Sequence::s1_end(Instruction &instruction) {
-	//printf("Sequence::s1_end()\n");
+	//debug(kDebugScript, "Sequence::s1_end()\n");
 
 	_terminated = true;
 	return false;
 }
 
 bool Sequence::s1_clearVars(Instruction &instruction) {
-	//printf("Sequence::s1_clearVars()\n");
+	//debug(kDebugScript, "Sequence::s1_clearVars()\n");
 
 	clearVars();
 	_vars[kSeqVarMachineID] = _machine->getId();
@@ -316,14 +316,14 @@
 }
 
 bool Sequence::s1_set(Instruction &instruction) {
-	//printf("Sequence::s1_set()\n");
+	//debug(kDebugScript, "Sequence::s1_set()\n");
 
 	*instruction.argp[0] = instruction.getValue();
 	return true;
 }
 
 bool Sequence::s1_compare(Instruction &instruction) {
-	//printf("Sequence::s1_compare()\n");
+	//debug(kDebugScript, "Sequence::s1_compare()\n");
 
 	long value = instruction.getValue();
 	if (instruction.argv[0] < value)
@@ -336,28 +336,28 @@
 }
 
 bool Sequence::s1_add(Instruction &instruction) {
-	//printf("Sequence::s1_add()\n");
+	//debug(kDebugScript, "Sequence::s1_add()\n");
 
 	*instruction.argp[0] += instruction.getValue();
 	return true;
 }
 
 bool Sequence::s1_sub(Instruction &instruction) {
-	//printf("Sequence::s1_sub()\n");
+	//debug(kDebugScript, "Sequence::s1_sub()\n");
 
 	*instruction.argp[0] -= instruction.getValue();
 	return true;
 }
 
 bool Sequence::s1_mul(Instruction &instruction) {
-	//printf("Sequence::s1_mul()\n");
+	//debug(kDebugScript, "Sequence::s1_mul()\n");
 
 	*instruction.argp[0] = FixedMul(instruction.argv[0], instruction.getValue());
 	return true;
 }
 
 bool Sequence::s1_div(Instruction &instruction) {
-	//printf("Sequence::s1_div()\n");
+	//debug(kDebugScript, "Sequence::s1_div()\n");
 
 	// TODO: Catch divisor = 0 in FixedDiv
 	*instruction.argp[0] = FixedDiv(instruction.argv[0], instruction.getValue());
@@ -365,7 +365,7 @@
 }
 
 bool Sequence::s1_and(Instruction &instruction) {
-	//printf("Sequence::s1_and()\n");
+	//debug(kDebugScript, "Sequence::s1_and()\n");
 
 	*instruction.argp[0] = instruction.argv[0] & instruction.getValue();
 	if (*instruction.argp[0])
@@ -376,7 +376,7 @@
 }
 
 bool Sequence::s1_or(Instruction &instruction) {
-	//printf("Sequence::s1_or()\n");
+	//debug(kDebugScript, "Sequence::s1_or()\n");
 
 	*instruction.argp[0] = instruction.argv[0] | instruction.getValue();
 	if (*instruction.argp[0])
@@ -387,7 +387,7 @@
 }
 
 bool Sequence::s1_not(Instruction &instruction) {
-	//printf("Sequence::s1_not()\n");
+	//debug(kDebugScript, "Sequence::s1_not()\n");
 
 	if (instruction.argv[0] == 0) {
 		*instruction.argp[0] = 0x10000;
@@ -400,7 +400,7 @@
 }
 
 bool Sequence::s1_sin(Instruction &instruction) {
-	//printf("Sequence::s1_sin()\n");
+	//debug(kDebugScript, "Sequence::s1_sin()\n");
 
 	int32 tempAngle = *instruction.argp[1] >> 16;
 	if (tempAngle < 0)
@@ -417,7 +417,7 @@
 }
 
 bool Sequence::s1_cos(Instruction &instruction) {
-	//printf("Sequence::s1_cos()\n");
+	//debug(kDebugScript, "Sequence::s1_cos()\n");
 
 	int32 tempAngle = *instruction.argp[1] >> 16;
 	if (tempAngle < 0)
@@ -434,42 +434,42 @@
 }
 
 bool Sequence::s1_abs(Instruction &instruction) {
-	//printf("Sequence::s1_abs()\n");
+	//debug(kDebugScript, "Sequence::s1_abs()\n");
 
 	*instruction.argp[0] = ABS(instruction.argv[1]);
 	return true;
 }
 
 bool Sequence::s1_min(Instruction &instruction) {
-	//printf("Sequence::s1_min()\n");
+	//debug(kDebugScript, "Sequence::s1_min()\n");
 
 	*instruction.argp[0] = MIN(instruction.argv[1], instruction.argv[2]);
 	return true;
 }
 
 bool Sequence::s1_max(Instruction &instruction) {
-	//printf("Sequence::s1_max()\n");
+	//debug(kDebugScript, "Sequence::s1_max()\n");
 
 	*instruction.argp[0] = MAX(instruction.argv[1], instruction.argv[2]);
 	return true;
 }
 
 bool Sequence::s1_mod(Instruction &instruction) {
-	//printf("Sequence::s1_mod()\n");
+	//debug(kDebugScript, "Sequence::s1_mod()\n");
 
 	*instruction.argp[0] = instruction.argv[0] % instruction.getValue();
 	return true;
 }
 
 bool Sequence::s1_floor(Instruction &instruction) {
-	//printf("Sequence::s1_floor()\n");
+	//debug(kDebugScript, "Sequence::s1_floor()\n");
 
 	*instruction.argp[0] = instruction.getValue() & 0xffff0000;
 	return true;
 }
 
 bool Sequence::s1_round(Instruction &instruction) {
-	//printf("Sequence::s1_round()\n");
+	//debug(kDebugScript, "Sequence::s1_round()\n");
 
 	if ((*instruction.argp[1] & 0xffff) >= 0x8000)
 		*instruction.argp[0] = (*instruction.argp[1] + 0x10000) & 0xffff0000;
@@ -479,7 +479,7 @@
 }
 
 bool Sequence::s1_ceil(Instruction &instruction) {
-	//printf("Sequence::s1_ceil()\n");
+	//debug(kDebugScript, "Sequence::s1_ceil()\n");
 
 	if ((*instruction.argp[1] & 0xffff) >= 0)
 		*instruction.argp[0] = (*instruction.argp[1] + 0x10000) & 0xffff0000;
@@ -489,19 +489,19 @@
 }
 
 bool Sequence::s1_point(Instruction &instruction) {
-	printf("Sequence::s1_point()\n");
+	debug(kDebugScript, "Sequence::s1_point()\n");
 	// TODO
 	return true;
 }
 
 bool Sequence::s1_dist2d(Instruction &instruction) {
-	printf("Sequence::s1_dist2d()\n");
+	debug(kDebugScript, "Sequence::s1_dist2d()\n");
 	// TODO
 	return true;
 }
 
 bool Sequence::s1_crunch(Instruction &instruction) {
-	//printf("Sequence::s1_crunch()\n");
+	//debug(kDebugScript, "Sequence::s1_crunch()\n");
 
 	long deltaTime;
 
@@ -515,12 +515,12 @@
 
 	_startTime = _ws->getGlobal(kGlobTime);
 
-	//printf("deltaTime = %ld\n", deltaTime >> 16); fflush(stdout);
+	//debug(kDebugScript, "deltaTime = %ld\n", deltaTime >> 16); fflush(stdout);
 	//g_system->delayMillis(5000);
 
 	if (deltaTime >= 0) {
 		_switchTime = _ws->getGlobal(kGlobTime) + (deltaTime >> 16);
-		//printf("_ws->getGlobal(kGlobTime) = %ld\n", _ws->getGlobal(kGlobTime)); fflush(stdout);
+		//debug(kDebugScript, "_ws->getGlobal(kGlobTime) = %ld\n", _ws->getGlobal(kGlobTime)); fflush(stdout);
 		//g_system->delayMillis(5000);
 	} else {
 		_switchTime = -1;
@@ -532,7 +532,7 @@
 }
 
 bool Sequence::s1_branch(Instruction &instruction) {
-	//printf("Sequence::s1_branch()\n");
+	//debug(kDebugScript, "Sequence::s1_branch()\n");
 
 	uint32 ofs = instruction.argv[1] >> 16;
 	switch (instruction.argv[0] >> 16) {
@@ -569,7 +569,7 @@
 }
 
 bool Sequence::s1_setFrame(Instruction &instruction) {
-	//printf("Sequence::s1_setFrame()\n");
+	//debug(kDebugScript, "Sequence::s1_setFrame()\n");
 
 	int32 frameIndex;
 	if (instruction.argc == 3) {
@@ -580,8 +580,8 @@
 		frameIndex = (instruction.argv[0] & 0xFF0000) >> 16;
 	}
 
-	//printf("Sequence::s1_setFrame() spriteHash = %d\n", (uint32)instruction.argv[0] >> 24);
-	//printf("Sequence::s1_setFrame() frameIndex = %d\n", frameIndex);
+	//debug(kDebugScript, "Sequence::s1_setFrame() spriteHash = %d\n", (uint32)instruction.argv[0] >> 24);
+	//debug(kDebugScript, "Sequence::s1_setFrame() frameIndex = %d\n", frameIndex);
 
 	SpriteAsset *spriteAsset = _ws->assets()->getSprite((uint32)instruction.argv[0] >> 24);
 	_curFrame = spriteAsset->getFrame(frameIndex);
@@ -590,25 +590,25 @@
 }
 
 bool Sequence::s1_sendMessage(Instruction &instruction) {
-	printf("Sequence::s1_sendMessage()\n");
+	debug(kDebugScript, "Sequence::s1_sendMessage()\n");
 	// TODO
 	return true;
 }
 
 bool Sequence::s1_push(Instruction &instruction) {
-	printf("Sequence::s1_push()\n");
+	debug(kDebugScript, "Sequence::s1_push()\n");
 	// TODO
 	return true;
 }
 
 bool Sequence::s1_pop(Instruction &instruction) {
-	printf("Sequence::s1_pop()\n");
+	debug(kDebugScript, "Sequence::s1_pop()\n");
 	// TODO
 	return true;
 }
 
 bool Sequence::s1_jumpSub(Instruction &instruction) {
-	//printf("Sequence::s1_jumpSub()\n");
+	//debug(kDebugScript, "Sequence::s1_jumpSub()\n");
 
 	_returnHashes[_returnStackIndex] = _sequenceHash;
 	_returnOffsets[_returnStackIndex] = _code->pos();
@@ -628,7 +628,7 @@
 }
 
 bool Sequence::s1_return(Instruction &instruction) {
-	//printf("Sequence::s1_return()\n");
+	//debug(kDebugScript, "Sequence::s1_return()\n");
 
 	if (_returnStackIndex <= 0)
 		return s1_end(instruction);

@@ Diff output truncated at 100000 characters. @@

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list