diff options
author | Filippos Karapetis | 2009-05-13 21:22:53 +0000 |
---|---|---|
committer | Filippos Karapetis | 2009-05-13 21:22:53 +0000 |
commit | 41af51d645cfa6b5c5e33692c9ff7edd2f386763 (patch) | |
tree | 90ff1a851009690ce9d11126adef638717297cfa /engines/sci/tools.cpp | |
parent | 049618ce15ee7e6656e5d1dd345161ff23bf3925 (diff) | |
download | scummvm-rg350-41af51d645cfa6b5c5e33692c9ff7edd2f386763.tar.gz scummvm-rg350-41af51d645cfa6b5c5e33692c9ff7edd2f386763.tar.bz2 scummvm-rg350-41af51d645cfa6b5c5e33692c9ff7edd2f386763.zip |
Simplified and re-enabled the debug code that shows pixmaps on screen and moved sciprintf() to tools.cpp
svn-id: r40542
Diffstat (limited to 'engines/sci/tools.cpp')
-rw-r--r-- | engines/sci/tools.cpp | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/engines/sci/tools.cpp b/engines/sci/tools.cpp index 429a6122ed..f21196b27b 100644 --- a/engines/sci/tools.cpp +++ b/engines/sci/tools.cpp @@ -24,6 +24,11 @@ */ #include "sci/tools.h" +#include "sci/engine/state.h" +#include "sci/scicore/sciconsole.h" + +#include "sci/sci.h" // For _console only +#include "sci/console.h" // For _console only namespace Sci { @@ -41,4 +46,41 @@ int sci_ffs(int bits) { return retval; } +#ifdef SCI_CONSOLE + +bool g_redirect_sciprintf_to_gui = false; + +int sciprintf(const char *fmt, ...) { + va_list argp; + + assert(fmt); + + // First determine how big a buffer we need + va_start(argp, fmt); + int bufsize = vsnprintf(0, 0, fmt, argp); + assert(bufsize >= 0); + va_end(argp); + + // Allocate buffer for the full printed string + char *buf = (char *)malloc(bufsize + 1); + assert(buf); + + // Print everything according to fmt into buf + va_start(argp, fmt); // reset argp + int bufsize2 = vsnprintf(buf, bufsize + 1, fmt, argp); + assert(bufsize == bufsize2); + va_end(argp); + + // Display the result suitably + if (g_redirect_sciprintf_to_gui) + ((SciEngine *)g_engine)->_console->DebugPrintf("%s", buf); + printf("%s", buf); + + free(buf); + + return 1; +} + +#endif // SCI_CONSOLE + } // End of namespace Sci |