aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--base/engine.cpp44
-rw-r--r--base/gameDetector.cpp7
-rw-r--r--base/gameDetector.h2
-rw-r--r--base/main.cpp51
-rw-r--r--scumm/debugger.cpp3
-rw-r--r--simon/debugger.cpp1
6 files changed, 59 insertions, 49 deletions
diff --git a/base/engine.cpp b/base/engine.cpp
index adf4546d31..b69e6c6a2a 100644
--- a/base/engine.cpp
+++ b/base/engine.cpp
@@ -158,50 +158,6 @@ void CDECL warning(const char *s, ...) {
#endif
}
-static void debugHelper(char *buf) {
-#ifndef _WIN32_WCE
- printf("%s\n", buf);
-#endif
-
-#if defined( USE_WINDBG )
- strcat(buf, "\n");
-#if defined( _WIN32_WCE )
- TCHAR buf_unicode[1024];
- MultiByteToWideChar(CP_ACP, 0, buf, strlen(buf) + 1, buf_unicode, sizeof(buf_unicode));
- OutputDebugString(buf_unicode);
-#else
- OutputDebugString(buf);
-#endif
-#endif
-
- fflush(stdout);
-}
-
-void CDECL debug(int level, const char *s, ...) {
- char buf[STRINGBUFLEN];
- va_list va;
-
- if (level > ConfMan.getInt("debuglevel"))
- return;
-
- va_start(va, s);
- vsprintf(buf, s, va);
- va_end(va);
-
- debugHelper(buf);
-}
-
-void CDECL debug(const char *s, ...) {
- char buf[STRINGBUFLEN];
- va_list va;
-
- va_start(va, s);
- vsprintf(buf, s, va);
- va_end(va);
-
- debugHelper(buf);
-}
-
void checkHeap() {
#if defined(_MSC_VER)
if (_heapchk() != _HEAPOK) {
diff --git a/base/gameDetector.cpp b/base/gameDetector.cpp
index bbee79d7f2..31b619fa55 100644
--- a/base/gameDetector.cpp
+++ b/base/gameDetector.cpp
@@ -333,9 +333,9 @@ void GameDetector::parseCommandLine(int argc, char **argv) {
DO_OPTION_OPT('d', "debuglevel")
if (option != NULL)
ConfMan.set("debuglevel", (int)strtol(option, 0, 10), kTransientDomain);
- int debuglevel = ConfMan.getInt("debuglevel");
- if (debuglevel)
- printf("Debuglevel (from command line): %d\n", debuglevel);
+ gDebugLevel = ConfMan.getInt("debuglevel");
+ if (gDebugLevel)
+ printf("Debuglevel (from command line): %d\n", gDebugLevel);
else
printf("Debuglevel (from command line): 0 - Game only\n");
END_OPTION
@@ -510,6 +510,7 @@ ShowHelpAndExit:
void GameDetector::setTarget(const String &name) {
_targetName = name;
ConfMan.setActiveDomain(name);
+ gDebugLevel = ConfMan.getInt("debuglevel");
}
bool GameDetector::detectGame() {
diff --git a/base/gameDetector.h b/base/gameDetector.h
index e74176d5a4..fc45afd613 100644
--- a/base/gameDetector.h
+++ b/base/gameDetector.h
@@ -38,6 +38,8 @@ enum {
GF_DEFAULT_TO_1X_SCALER = 1 << 30
};
+extern int gDebugLevel;
+
struct GameSettings {
const char *name;
const char *description;
diff --git a/base/main.cpp b/base/main.cpp
index 432e967c97..1fbe8262cb 100644
--- a/base/main.cpp
+++ b/base/main.cpp
@@ -119,7 +119,7 @@ const char *gScummVMFeatures = ""
#ifdef USE_MPEG2
"MPEG2 "
#endif
- ;
+ ;
#if defined(WIN32) && defined(NO_CONSOLE)
#include <cstdio>
@@ -184,6 +184,9 @@ static void do_memory_test(void) {
#endif
+
+int gDebugLevel = 0;
+
static bool launcherDialog(GameDetector &detector, OSystem *system) {
system->beginGFXTransaction();
@@ -349,6 +352,8 @@ extern "C" int scummvm_main(GameDetector &detector, int argc, char *argv[]) {
else
ConfMan.loadDefaultConfigFile();
+ gDebugLevel = ConfMan.getInt("debuglevel");
+
// Update the config file
ConfMan.set("versioninfo", gScummVMVersion, Common::ConfigManager::kApplicationDomain);
@@ -417,6 +422,50 @@ extern "C" int scummvm_main(GameDetector &detector, int argc, char *argv[]) {
END_OF_MAIN();
#endif
+static void debugHelper(char *buf) {
+#ifndef _WIN32_WCE
+ printf("%s\n", buf);
+#endif
+
+#if defined( USE_WINDBG )
+ strcat(buf, "\n");
+#if defined( _WIN32_WCE )
+ TCHAR buf_unicode[1024];
+ MultiByteToWideChar(CP_ACP, 0, buf, strlen(buf) + 1, buf_unicode, sizeof(buf_unicode));
+ OutputDebugString(buf_unicode);
+#else
+ OutputDebugString(buf);
+#endif
+#endif
+
+ fflush(stdout);
+}
+
+void CDECL debug(int level, const char *s, ...) {
+ char buf[STRINGBUFLEN];
+ va_list va;
+
+ if (level > gDebugLevel)
+ return;
+
+ va_start(va, s);
+ vsprintf(buf, s, va);
+ va_end(va);
+
+ debugHelper(buf);
+}
+
+void CDECL debug(const char *s, ...) {
+ char buf[STRINGBUFLEN];
+ va_list va;
+
+ va_start(va, s);
+ vsprintf(buf, s, va);
+ va_end(va);
+
+ debugHelper(buf);
+}
+
/*
#if !defined(__PALM_OS__) && !defined(_WIN32_WCE)
void *operator new(size_t size) {
diff --git a/scumm/debugger.cpp b/scumm/debugger.cpp
index d99d20d81d..2a94c96b93 100644
--- a/scumm/debugger.cpp
+++ b/scumm/debugger.cpp
@@ -44,7 +44,7 @@ void CDECL debugC(int channel, const char *s, ...) {
// FIXME: Still spew all debug at -d9, for crashes in startup etc.
// Add setting from commandline ( / abstract channel interface)
- if (!(g_scumm->_debugFlags & channel) && (ConfMan.getInt("debuglevel") < 9))
+ if (!(g_scumm->_debugFlags & channel) && (gDebugLevel < 9))
return;
va_start(va, s);
@@ -596,6 +596,7 @@ bool ScummDebugger::Cmd_DebugLevel(int argc, const char **argv) {
} else { // set level
int level = atoi(argv[1]);
ConfMan.set("debuglevel", level, Common::ConfigManager::kTransientDomain);
+ gDebugLevel = ConfMan.getInt("debuglevel");
if (level > 0) {
_vm->_debugMode = true;
DebugPrintf("Debug level set to level %d\n", level);
diff --git a/simon/debugger.cpp b/simon/debugger.cpp
index d498daf171..e0c35e991c 100644
--- a/simon/debugger.cpp
+++ b/simon/debugger.cpp
@@ -91,6 +91,7 @@ bool Debugger::Cmd_DebugLevel(int argc, const char **argv) {
} else { // set level
int level = atoi(argv[1]);
ConfMan.set("debuglevel", level, Common::ConfigManager::kTransientDomain);
+ gDebugLevel = ConfMan.getInt("debuglevel");
if (level > 0 && level < 10) {
_vm->_debugMode = true;
DebugPrintf("Debug level set to level %d\n", level);