[Scummvm-cvs-logs] SF.net SVN: scummvm: [25381] scummvm/trunk/engines/scumm

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Sun Feb 4 13:41:50 CET 2007


Revision: 25381
          http://scummvm.svn.sourceforge.net/scummvm/?rev=25381&view=rev
Author:   fingolfin
Date:     2007-02-04 04:41:49 -0800 (Sun, 04 Feb 2007)

Log Message:
-----------
Switch SCUMM engine to use the common special debug flags support (thus making it possible to use --debugflags with it)

Modified Paths:
--------------
    scummvm/trunk/engines/scumm/debugger.cpp
    scummvm/trunk/engines/scumm/scumm.cpp
    scummvm/trunk/engines/scumm/scumm.h

Modified: scummvm/trunk/engines/scumm/debugger.cpp
===================================================================
--- scummvm/trunk/engines/scumm/debugger.cpp	2007-02-04 12:14:11 UTC (rev 25380)
+++ scummvm/trunk/engines/scumm/debugger.cpp	2007-02-04 12:41:49 UTC (rev 25381)
@@ -38,27 +38,13 @@
 
 namespace Scumm {
 
-// Debug channel lookup table for Debugger console
-static const dbgChannelDesc debugChannels[] = {
-	{"SCRIPTS", "Track script execution", DEBUG_SCRIPTS},
-	{"OPCODES", "Track opcode execution", DEBUG_OPCODES},
-	{"IMUSE", "Track iMUSE events", DEBUG_IMUSE},
-	{"RESOURCE", "Track resource loading/management", DEBUG_RESOURCE},
-	{"VARS", "Track variable changes", DEBUG_VARS},
-	{"ACTORS", "Actor-related debug", DEBUG_ACTORS},
-	{"SOUND", "Sound related debug", DEBUG_SOUND},
-	{"INSANE", "Track INSANE", DEBUG_INSANE},
-	{"SMUSH", "Track SMUSH", DEBUG_SMUSH}
-};
-
-
 void CDECL debugC(int channel, const char *s, ...) {
 	char buf[STRINGBUFLEN];
 	va_list va;
 
 	// FIXME: Still spew all debug at -d9, for crashes in startup etc.
 	//	  Add setting from commandline ( / abstract channel interface)
-	if (!(g_scumm->_debugFlags & channel) && (gDebugLevel < 9))
+	if (!(Common::getEnabledSpecialDebugLevels() & channel) && (gDebugLevel < 9))
 		return;
 
 	va_start(va, s);
@@ -112,7 +98,9 @@
 	DCmd_Register("imuse",     WRAP_METHOD(ScummDebugger, Cmd_IMuse));
 }
 
-ScummDebugger::~ScummDebugger() {} // we need this here for __SYMBIAN32__
+ScummDebugger::~ScummDebugger() {
+	 // we need this destructor, even if it is empty, for __SYMBIAN32__
+}
 
 void ScummDebugger::preEnter() {
 	// Pause sound output
@@ -505,25 +493,25 @@
 }
 
 bool ScummDebugger::Cmd_Debug(int argc, const char **argv) {
-	int numChannels = sizeof(debugChannels) / sizeof(dbgChannelDesc);
+	Common::Array<Common::EngineDebugLevel> lvls = Common::listSpecialDebugLevels();
 
 	bool setFlag = false;	// Remove or add debug channel?
 
-	if ((argc == 1) && (_vm->_debugFlags == 0)) {
+	if ((argc == 1) && (Common::getEnabledSpecialDebugLevels() == 0)) {
 		DebugPrintf("No debug flags are enabled\n");
 		DebugPrintf("Available Channels: ");
-		for (int i = 0; i < numChannels; i++) {
-			DebugPrintf("%s, ", debugChannels[i].channel);
+		for (uint i = 0; i < lvls.size(); i++) {
+			DebugPrintf("%s, ", lvls[i].option.c_str());
 		}
 		DebugPrintf("\n");
 		return true;
 	}
 
-	if ((argc == 1) && (_vm->_debugFlags > 0)) {
-		for (int i = 0; i < numChannels; i++) {
-			if (_vm->_debugFlags & debugChannels[i].flag)
-				DebugPrintf("%s - %s\n", debugChannels[i].channel,
-							 debugChannels[i].desc);
+	if ((argc == 1) && (Common::getEnabledSpecialDebugLevels() > 0)) {
+		for (uint i = 0; i < lvls.size(); i++) {
+			if (lvls[i].enabled)
+				DebugPrintf("%s - %s\n", lvls[i].option.c_str(),
+							 lvls[i].description.c_str());
 		}
 		return true;
 	}
@@ -536,25 +524,25 @@
 	} else {
 		DebugPrintf("Syntax: Debug +CHANNEL, or Debug -CHANNEL\n");
 		DebugPrintf("Available Channels: ");
-		for (int i = 0; i < numChannels; i++) {
-			DebugPrintf("%s, ", debugChannels[i].channel);
+		for (uint i = 0; i < lvls.size(); i++) {
+			DebugPrintf("%s, ", lvls[i].option.c_str());
 			DebugPrintf("\n");
 		}
 	}
 
 	// Identify flag
 	const char *realFlag = argv[1] + 1;
-	for (int i = 0; i < numChannels; i++) {
-		if ((scumm_stricmp(debugChannels[i].channel, realFlag)) == 0) {
+	for (uint i = 0; i < lvls.size(); i++) {
+		if ((scumm_stricmp(lvls[i].option.c_str(), realFlag)) == 0) {
 			if (setFlag) {
-				_vm->_debugFlags |= debugChannels[i].flag;
+				enableSpecialDebugLevel(lvls[i].option);
 				DebugPrintf("Enable ");
 			} else {
-				_vm->_debugFlags &= ~debugChannels[i].flag;
+				disableSpecialDebugLevel(lvls[i].option);
 				DebugPrintf("Disable ");
 			}
 
-			DebugPrintf("%s\n", debugChannels[i].desc);
+			DebugPrintf("%s\n", lvls[i].description.c_str());
 			return true;
 		}
 	}

Modified: scummvm/trunk/engines/scumm/scumm.cpp
===================================================================
--- scummvm/trunk/engines/scumm/scumm.cpp	2007-02-04 12:14:11 UTC (rev 25380)
+++ scummvm/trunk/engines/scumm/scumm.cpp	2007-02-04 12:41:49 UTC (rev 25381)
@@ -80,6 +80,25 @@
 ScummEngine *g_scumm = 0;
 
 
+struct dbgChannelDesc {
+	const char *channel, *desc;
+	uint32 flag;
+};
+
+
+// Debug channel lookup table for Debugger console
+static const dbgChannelDesc debugChannels[] = {
+	{"SCRIPTS", "Track script execution", DEBUG_SCRIPTS},
+	{"OPCODES", "Track opcode execution", DEBUG_OPCODES},
+	{"IMUSE", "Track iMUSE events", DEBUG_IMUSE},
+	{"RESOURCE", "Track resource loading/management", DEBUG_RESOURCE},
+	{"VARS", "Track variable changes", DEBUG_VARS},
+	{"ACTORS", "Actor-related debug", DEBUG_ACTORS},
+	{"SOUND", "Sound related debug", DEBUG_SOUND},
+	{"INSANE", "Track INSANE", DEBUG_INSANE},
+	{"SMUSH", "Track SMUSH", DEBUG_SMUSH}
+};
+
 ScummEngine::ScummEngine(OSystem *syst, const DetectorResult &dr)
 	: Engine(syst),
 	  _game(dr.game),
@@ -112,7 +131,6 @@
 	_musicEngine = NULL;
 	_verbs = NULL;
 	_objs = NULL;
-	_debugFlags = 0;
 	_sound = NULL;
 	memset(&vm, 0, sizeof(vm));
 	_quit = false;
@@ -502,9 +520,16 @@
 	if (_renderMode == Common::kRenderHercA || _renderMode == Common::kRenderHercG) {
 		_herculesBuf = (byte *)malloc(Common::kHercW * Common::kHercH);
 	}
+
+	// Add debug levels	
+	for (int i = 0; i < ARRAYSIZE(debugChannels); ++i)
+		Common::addSpecialDebugLevel(debugChannels[i].flag,  debugChannels[i].channel, debugChannels[i].desc);
 }
 
+
 ScummEngine::~ScummEngine() {
+	Common::clearAllSpecialDebugLevels();
+
 	if (_musicEngine) {
 		_musicEngine->terminate();
 		delete _musicEngine;
@@ -558,6 +583,7 @@
 	delete _gdi;
 }
 
+
 ScummEngine_v5::ScummEngine_v5(OSystem *syst, const DetectorResult &dr)
  : ScummEngine(syst, dr) {
 

Modified: scummvm/trunk/engines/scumm/scumm.h
===================================================================
--- scummvm/trunk/engines/scumm/scumm.h	2007-02-04 12:14:11 UTC (rev 25380)
+++ scummvm/trunk/engines/scumm/scumm.h	2007-02-04 12:41:49 UTC (rev 25381)
@@ -135,11 +135,6 @@
 /* SCUMM Debug Channels */
 void CDECL debugC(int level, const char *s, ...);
 
-struct dbgChannelDesc {
-	const char *channel, *desc;
-	uint32 flag;
-};
-
 enum {
 	DEBUG_GENERAL	=	1 << 0,		// General debug
 	DEBUG_SCRIPTS	=	1 << 2,		// Track script execution (start/stop/pause)
@@ -440,9 +435,6 @@
 	/** Central resource data. */
 	ResourceManager *_res;
 
-	// Misc utility functions
-	uint32 _debugFlags;	// Used by the debugger
-
 protected:
 	VirtualMachineState vm;
 


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