[Scummvm-cvs-logs] SF.net SVN: scummvm:[40460] scummvm/trunk/engines/sci
fingolfin at users.sourceforge.net
fingolfin at users.sourceforge.net
Mon May 11 20:18:43 CEST 2009
Revision: 40460
http://scummvm.svn.sourceforge.net/scummvm/?rev=40460&view=rev
Author: fingolfin
Date: 2009-05-11 18:18:43 +0000 (Mon, 11 May 2009)
Log Message:
-----------
SCI: Hacked stuff up so that debugger commands also print on the GUI console
Modified Paths:
--------------
scummvm/trunk/engines/sci/console.cpp
scummvm/trunk/engines/sci/engine/said.cpp
scummvm/trunk/engines/sci/engine/said.y
scummvm/trunk/engines/sci/engine/scriptconsole.cpp
scummvm/trunk/engines/sci/sci.cpp
scummvm/trunk/engines/sci/scicore/sciconsole.cpp
scummvm/trunk/engines/sci/scicore/sciconsole.h
Modified: scummvm/trunk/engines/sci/console.cpp
===================================================================
--- scummvm/trunk/engines/sci/console.cpp 2009-05-11 18:02:48 UTC (rev 40459)
+++ scummvm/trunk/engines/sci/console.cpp 2009-05-11 18:18:43 UTC (rev 40460)
@@ -34,6 +34,7 @@
namespace Sci {
extern EngineState *g_EngineState;
+extern bool g_redirect_sciprintf_to_gui;
class ConsoleFunc : public Common::Functor2<int, const char **, bool> {
public:
@@ -48,7 +49,10 @@
tmp += ' ';
tmp += argv[i];
}
+ g_redirect_sciprintf_to_gui = true;
con_parse(g_EngineState, tmp.c_str());
+ sciprintf("\n");
+ g_redirect_sciprintf_to_gui = false;
return true;
#else
Modified: scummvm/trunk/engines/sci/engine/said.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/said.cpp 2009-05-11 18:02:48 UTC (rev 40459)
+++ scummvm/trunk/engines/sci/engine/said.cpp 2009-05-11 18:18:43 UTC (rev 40460)
@@ -2472,7 +2472,6 @@
int main (int argc, char *argv) {
byte block[] = {0x01, 0x00, 0xf8, 0xf5, 0x02, 0x01, 0xf6, 0xf2, 0x02, 0x01, 0xf2, 0x01, 0x03, 0xff};
EngineState s;
- con_passthrough = true;
s.parser_valid = 1;
said(&s, block);
Modified: scummvm/trunk/engines/sci/engine/said.y
===================================================================
--- scummvm/trunk/engines/sci/engine/said.y 2009-05-11 18:02:48 UTC (rev 40459)
+++ scummvm/trunk/engines/sci/engine/said.y 2009-05-11 18:18:43 UTC (rev 40460)
@@ -828,7 +828,6 @@
int main (int argc, char *argv) {
byte block[] = {0x01, 0x00, 0xf8, 0xf5, 0x02, 0x01, 0xf6, 0xf2, 0x02, 0x01, 0xf2, 0x01, 0x03, 0xff};
EngineState s;
- con_passthrough = true;
s.parser_valid = 1;
said(&s, block);
Modified: scummvm/trunk/engines/sci/engine/scriptconsole.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/scriptconsole.cpp 2009-05-11 18:02:48 UTC (rev 40459)
+++ scummvm/trunk/engines/sci/engine/scriptconsole.cpp 2009-05-11 18:18:43 UTC (rev 40460)
@@ -30,7 +30,6 @@
#include "sci/engine/state.h"
#include "sci/scicore/sciconsole.h"
-
#include "sci/sci.h" // For _console only
#include "sci/console.h" // For _console only
@@ -201,8 +200,6 @@
" a list of addresses and indices is provided.\n"
" ?obj.idx may be used to disambiguate 'obj'\n"
" by the index 'idx'.\n");
-
- con_hook_int(&con_passthrough, "con_passthrough", "scicon->stdout passthrough");
}
}
Modified: scummvm/trunk/engines/sci/sci.cpp
===================================================================
--- scummvm/trunk/engines/sci/sci.cpp 2009-05-11 18:02:48 UTC (rev 40459)
+++ scummvm/trunk/engines/sci/sci.cpp 2009-05-11 18:18:43 UTC (rev 40460)
@@ -78,8 +78,6 @@
"SCI0 palette- 0: EGA, 1:AGI/Amiga, 2:Grayscale\n");
con_hook_int(&sci01_priority_table_flags, "sci01_priority_table_flags",
"SCI01 priority table debugging flags: 1:Disable, 2:Print on change\n");
-
- con_passthrough = true; // enables all sciprintf data to be sent to stdout
}
static int init_gamestate(EngineState *gamestate, sci_version_t version) {
Modified: scummvm/trunk/engines/sci/scicore/sciconsole.cpp
===================================================================
--- scummvm/trunk/engines/sci/scicore/sciconsole.cpp 2009-05-11 18:02:48 UTC (rev 40459)
+++ scummvm/trunk/engines/sci/scicore/sciconsole.cpp 2009-05-11 18:18:43 UTC (rev 40460)
@@ -30,57 +30,48 @@
#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 {
#ifdef SCI_CONSOLE
-int con_passthrough = false;
-
-static void (*_con_string_callback)(char*) = NULL;
static void (*_con_pixmap_callback)(gfx_pixmap_t *) = NULL;
+bool g_redirect_sciprintf_to_gui = false;
+
int sciprintf(const char *fmt, ...) {
va_list argp;
- int bufsize = 256;
- int i;
- char *buf = (char *)sci_malloc(bufsize);
- if (NULL == fmt) {
- fprintf(stderr, "console.c: sciprintf(): NULL passed for parameter fmt\n");
- return -1;
- }
+ assert(fmt);
- if (NULL == buf) {
- fprintf(stderr, "console.c: sciprintf(): malloc failed for buf\n");
- return -1;
- }
-
+ // First determine how big a buffer we need
va_start(argp, fmt);
- while ((i = vsnprintf(buf, bufsize - 1, fmt, argp)) == -1 || (i >= bufsize - 2)) {
- // while we're out of space...
- va_end(argp);
- va_start(argp, fmt); // reset argp
+ int bufsize = vsnprintf(0, 0, fmt, argp);
+ assert(bufsize >= 0);
+ va_end(argp);
- free(buf);
- buf = (char *)sci_malloc(bufsize <<= 1);
- }
+ // Allocate buffer for the full printed string
+ char *buf = (char *)sci_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);
- if (con_passthrough)
- printf("%s", buf);
+ // Display the result suitably
+ if (g_redirect_sciprintf_to_gui)
+ ((SciEngine *)g_engine)->_console->DebugPrintf("%s", buf);
+ printf("%s", buf);
- if (_con_string_callback)
- _con_string_callback(buf);
- else
- free(buf);
+ free(buf);
return 1;
}
-void con_set_string_callback(void(*callback)(char *)) {
- _con_string_callback = callback;
-}
-
void con_set_pixmap_callback(void(*callback)(gfx_pixmap_t *)) {
_con_pixmap_callback = callback;
}
Modified: scummvm/trunk/engines/sci/scicore/sciconsole.h
===================================================================
--- scummvm/trunk/engines/sci/scicore/sciconsole.h 2009-05-11 18:02:48 UTC (rev 40459)
+++ scummvm/trunk/engines/sci/scicore/sciconsole.h 2009-05-11 18:18:43 UTC (rev 40460)
@@ -43,9 +43,6 @@
struct gfx_pixmap_t;
-/** If this flag is set, we echo all sciprintf() stuff to the text console. */
-extern int con_passthrough;
-
union cmd_param_t {
int32 val;
const char *str;
@@ -57,14 +54,6 @@
/*** FUNCTION DEFINITIONS ***/
-void con_set_string_callback(void(*callback)(char *));
-/* Sets the console string callback
-** Parameters: (void -> char *) callback: The closure to invoke after
-** a string for sciprintf() has been generated
-** This sets a single callback function to be used after sciprintf()
-** is used.
-*/
-
void con_set_pixmap_callback(void(*callback)(gfx_pixmap_t *));
/* Sets the console pixmap callback
** Parameters: (void -> gfx_pixmap_t *) callback: The closure to invoke after
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