[Scummvm-cvs-logs] SF.net SVN: scummvm:[41043] scummvm/trunk/engines/sci

thebluegr at users.sourceforge.net thebluegr at users.sourceforge.net
Sat May 30 22:01:43 CEST 2009


Revision: 41043
          http://scummvm.svn.sourceforge.net/scummvm/?rev=41043&view=rev
Author:   thebluegr
Date:     2009-05-30 20:01:43 +0000 (Sat, 30 May 2009)

Log Message:
-----------
Moved 4 mode commands to console.cpp: "sentence_fragments", "parser_nodes", "status_bar" and "track_mouse"

Modified Paths:
--------------
    scummvm/trunk/engines/sci/console.cpp
    scummvm/trunk/engines/sci/console.h
    scummvm/trunk/engines/sci/engine/kevent.cpp
    scummvm/trunk/engines/sci/engine/scriptdebug.cpp

Modified: scummvm/trunk/engines/sci/console.cpp
===================================================================
--- scummvm/trunk/engines/sci/console.cpp	2009-05-30 19:59:53 UTC (rev 41042)
+++ scummvm/trunk/engines/sci/console.cpp	2009-05-30 20:01:43 UTC (rev 41043)
@@ -32,6 +32,7 @@
 #include "sci/engine/savegame.h"
 #include "sci/engine/state.h"
 #include "sci/engine/gc.h"
+#include "sci/gfx/gfx_gui.h"	// for sciw_set_status_bar
 #include "sci/gfx/gfx_state_internal.h"
 #include "sci/gfx/gfx_widgets.h"	// for gfxw_find_port
 #include "sci/vocabulary.h"
@@ -43,6 +44,7 @@
 extern EngineState *g_EngineState;
 
 int _kdebug_cheap_event_hack = 0;
+bool _kdebug_track_mouse_clicks = false;
 
 Console::Console(SciEngine *vm) : GUI::Debugger() {
 	_vm = vm;
@@ -68,6 +70,8 @@
 	DCmd_Register("restore_game",		WRAP_METHOD(Console, cmdRestoreGame));
 	DCmd_Register("restart_game",		WRAP_METHOD(Console, cmdRestartGame));
 	DCmd_Register("class_table",		WRAP_METHOD(Console, cmdClassTable));
+	DCmd_Register("sentence_fragments",	WRAP_METHOD(Console, cmdSentenceFragments));
+	DCmd_Register("parser_nodes",		WRAP_METHOD(Console, cmdParserNodes));
 	DCmd_Register("parser_words",		WRAP_METHOD(Console, cmdParserWords));
 	DCmd_Register("draw_pic",			WRAP_METHOD(Console, cmdDrawPic));
 	DCmd_Register("draw_rect",			WRAP_METHOD(Console, cmdDrawRect));
@@ -78,7 +82,9 @@
 	DCmd_Register("visual_state",		WRAP_METHOD(Console, cmdVisualState));
 	DCmd_Register("dynamic_views",		WRAP_METHOD(Console, cmdDynamicViews));
 	DCmd_Register("dropped_views",		WRAP_METHOD(Console, cmdDroppedViews));
+	DCmd_Register("status_bar",			WRAP_METHOD(Console, cmdStatusBarColors));
 	DCmd_Register("simkey",				WRAP_METHOD(Console, cmdSimulateKey));
+	DCmd_Register("track_mouse",		WRAP_METHOD(Console, cmdTrackMouse));
 	DCmd_Register("segment_table",		WRAP_METHOD(Console, cmdPrintSegmentTable));
 	DCmd_Register("segment_info",		WRAP_METHOD(Console, cmdSegmentInfo));
 	DCmd_Register("segment_kill",		WRAP_METHOD(Console, cmdKillSegment));
@@ -553,6 +559,70 @@
 	return true;
 }
 
+bool Console::cmdSentenceFragments(int argc, const char **argv) {
+	DebugPrintf("Sentence fragments (used to build Parse trees\n");
+
+	for (uint i = 0; i < g_EngineState->_parserBranches.size(); i++) {
+		int j = 0;
+
+		DebugPrintf("R%02d: [%x] ->", i, g_EngineState->_parserBranches[i].id);
+		while ((j < 10) && g_EngineState->_parserBranches[i].data[j]) {
+			int dat = g_EngineState->_parserBranches[i].data[j++];
+
+			switch (dat) {
+			case VOCAB_TREE_NODE_COMPARE_TYPE:
+				dat = g_EngineState->_parserBranches[i].data[j++];
+				DebugPrintf(" C(%x)", dat);
+				break;
+
+			case VOCAB_TREE_NODE_COMPARE_GROUP:
+				dat = g_EngineState->_parserBranches[i].data[j++];
+				DebugPrintf(" WG(%x)", dat);
+				break;
+
+			case VOCAB_TREE_NODE_FORCE_STORAGE:
+				dat = g_EngineState->_parserBranches[i].data[j++];
+				DebugPrintf(" FORCE(%x)", dat);
+				break;
+
+			default:
+				if (dat > VOCAB_TREE_NODE_LAST_WORD_STORAGE) {
+					int dat2 = g_EngineState->_parserBranches[i].data[j++];
+					DebugPrintf(" %x[%x]", dat, dat2);
+				} else
+					DebugPrintf(" ?%x?", dat);
+			}
+		}
+		DebugPrintf("\n");
+	}
+
+	DebugPrintf("%d rules.\n", g_EngineState->_parserBranches.size());
+
+	return true;
+}
+
+bool Console::cmdParserNodes(int argc, const char **argv) {
+	if (argc != 2) {
+		DebugPrintf("Shows the specified number of nodes from the parse node tree\n");
+		DebugPrintf("Usage: %s <nr>\n", argv[0]);
+		DebugPrintf("where <nr> is the number of nodes to show from the parse node tree\n");
+		return true;
+	}
+
+	int end = MIN<int>(atoi(argv[1]), VOCAB_TREE_NODES);
+
+	for (int i = 0; i < end; i++) {
+		DebugPrintf(" Node %03x: ", i);
+		if (g_EngineState->parser_nodes[i].type == PARSE_TREE_NODE_LEAF)
+			DebugPrintf("Leaf: %04x\n", g_EngineState->parser_nodes[i].content.value);
+		else
+			DebugPrintf("Branch: ->%04x, ->%04x\n", g_EngineState->parser_nodes[i].content.branches[0],
+			          g_EngineState->parser_nodes[i].content.branches[1]);
+	}
+
+	return true;
+}
+
 bool Console::cmdParserWords(int argc, const char **argv) {
 	if (g_EngineState->_parserWords.empty()) {
 		DebugPrintf("No words.\n");
@@ -710,6 +780,26 @@
 	return true;
 }
 
+bool Console::cmdStatusBarColors(int argc, const char **argv) {
+	if (argc != 3) {
+		DebugPrintf("Sets the colors of the status bar\n");
+		DebugPrintf("Usage: %s <foreground color> <background color>\n", argv[0]);
+		return true;
+	}
+
+	g_EngineState->titlebar_port->_color = g_EngineState->ega_colors[atoi(argv[1])];
+	g_EngineState->titlebar_port->_bgcolor = g_EngineState->ega_colors[atoi(argv[2])];
+
+	g_EngineState->status_bar_foreground = atoi(argv[1]);
+	g_EngineState->status_bar_background = atoi(argv[2]);
+
+	sciw_set_status_bar(g_EngineState, g_EngineState->titlebar_port, g_EngineState->_statusBarText, 
+							g_EngineState->status_bar_foreground, g_EngineState->status_bar_background);
+	gfxop_update(g_EngineState->gfx_state);
+
+	return false;
+}
+
 bool Console::cmdSimulateKey(int argc, const char **argv) {
 	if (argc != 2) {
 		DebugPrintf("Simulate a keypress with the specified scancode\n");
@@ -722,6 +812,26 @@
 	return true;
 }
 
+bool Console::cmdTrackMouse(int argc, const char **argv) {
+	if (argc != 2) {
+		DebugPrintf("Toggles mouse position tracking\n");
+		DebugPrintf("Usage: %s <on/off>\n", argv[0]);
+		DebugPrintf("If switched on, left mouse clicks will print\n");
+		DebugPrintf("the coordinates clicked in the debug console\n");
+		return true;
+	}
+
+	if (!scumm_stricmp(argv[1], "on")) {
+		_kdebug_track_mouse_clicks = true;
+		DebugPrintf("Mouse tracking turned on\n");
+	} else if (!scumm_stricmp(argv[1], "off")) {
+		_kdebug_track_mouse_clicks = false;
+		DebugPrintf("Mouse tracking turned off\n");
+	}
+
+	return true;
+}
+
 bool Console::cmdPrintSegmentTable(int argc, const char **argv) {
 	DebugPrintf("Segment table:\n");
 

Modified: scummvm/trunk/engines/sci/console.h
===================================================================
--- scummvm/trunk/engines/sci/console.h	2009-05-30 19:59:53 UTC (rev 41042)
+++ scummvm/trunk/engines/sci/console.h	2009-05-30 20:01:43 UTC (rev 41043)
@@ -61,6 +61,8 @@
 	bool cmdRestoreGame(int argc, const char **argv);
 	bool cmdRestartGame(int argc, const char **argv);
 	bool cmdClassTable(int argc, const char **argv);
+	bool cmdSentenceFragments(int argc, const char **argv);
+	bool cmdParserNodes(int argc, const char **argv);
 	bool cmdParserWords(int argc, const char **argv);
 	bool cmdDrawPic(int argc, const char **argv);
 	bool cmdDrawRect(int argc, const char **argv);
@@ -71,7 +73,9 @@
 	bool cmdVisualState(int argc, const char **argv);
 	bool cmdDynamicViews(int argc, const char **argv);
 	bool cmdDroppedViews(int argc, const char **argv);
+	bool cmdStatusBarColors(int argc, const char **argv);
 	bool cmdSimulateKey(int argc, const char **argv);
+	bool cmdTrackMouse(int argc, const char **argv);
 	bool cmdPrintSegmentTable(int argc, const char **argv);
 	bool cmdSegmentInfo(int argc, const char **argv);
 	bool cmdKillSegment(int argc, const char **argv);

Modified: scummvm/trunk/engines/sci/engine/kevent.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kevent.cpp	2009-05-30 19:59:53 UTC (rev 41042)
+++ scummvm/trunk/engines/sci/engine/kevent.cpp	2009-05-30 20:01:43 UTC (rev 41043)
@@ -34,6 +34,7 @@
 
 int stop_on_event = 0;
 extern int _kdebug_cheap_event_hack;
+extern bool _kdebug_track_mouse_clicks;
 
 #define SCI_VARIABLE_GAME_SPEED 3
 
@@ -45,10 +46,8 @@
 	int modifier_mask = s->version <= SCI_VERSION_0 ? SCI_EVM_ALL : SCI_EVM_NO_FOOLOCK;
 
 	if (s->kernel_opt_flags & KERNEL_OPT_FLAG_GOT_2NDEVENT) {
-		// Penalty time- too many requests to this function without
-		// waiting!
+		// Penalty time- too many requests to this function without waiting!
 		int delay = s->script_000->locals_block->_locals[SCI_VARIABLE_GAME_SPEED].offset;
-
 		gfxop_sleep(s->gfx_state, delay * 1000 / 60);
 	}
 
@@ -112,6 +111,12 @@
 	case SCI_EVT_MOUSE_PRESS: {
 		int extra_bits = 0;
 
+		// track left buttton clicks, if requested
+		if (e.type == SCI_EVT_MOUSE_PRESS && e.data == 1 && _kdebug_track_mouse_clicks) {
+			((SciEngine *)g_engine)->_console->DebugPrintf("Mouse clicked at %d, %d\n", 
+						s->gfx_state->pointer_pos.x, s->gfx_state->pointer_pos.y);
+		}
+
 		if (mask & e.type) {
 			switch (e.data) {
 			case 2:

Modified: scummvm/trunk/engines/sci/engine/scriptdebug.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/scriptdebug.cpp	2009-05-30 19:59:53 UTC (rev 41042)
+++ scummvm/trunk/engines/sci/engine/scriptdebug.cpp	2009-05-30 20:01:43 UTC (rev 41043)
@@ -443,18 +443,6 @@
 	return 0;
 }
 
-static int c_mousepos(EngineState *s, const Common::Array<cmd_param_t> &cmdParams) {
-	sci_event_t event;
-
-	sciprintf("Click somewhere in the game window...\n");
-
-	while (event = gfxop_get_event(s->gfx_state, SCI_EVT_MOUSE_RELEASE), event.type != SCI_EVT_MOUSE_RELEASE) {};
-
-	sciprintf("Mouse pointer at (%d, %d)\n", s->gfx_state->pointer_pos.x, s->gfx_state->pointer_pos.y);
-
-	return 0;
-}
-
 int c_debuginfo(EngineState *s) {
 	if (!_debugstate_valid) {
 		sciprintf("Not in debug state\n");
@@ -528,69 +516,6 @@
 }
 #endif
 
-int c_sim_parse(EngineState *s, const Common::Array<cmd_param_t> &cmdParams) {
-	unsigned int i;
-	const char *operators = ",&/()[]#<>";
-
-	if (!_debugstate_valid) {
-		sciprintf("Not in debug state\n");
-		return 1;
-	}
-
-	if (cmdParams.size() == 0) {
-		s->parser_valid = 0;
-		return 0;
-	}
-
-	for (i = 0; i < cmdParams.size(); i++) {
-		int flag = 0;
-		Common::String token = cmdParams[i].str;
-
-		if (token.size() == 1) {// could be an operator
-			int j = 0;
-			while (operators[j] && (operators[j] != token[0]))
-				j++;
-			if (operators[j]) {
-				s->parser_nodes[i].type = 1;
-				s->parser_nodes[i].content.value = j + 0xf0;
-				flag = 1; // found an operator
-			}
-		}
-
-		if (!flag) {
-			const char *openb = strchr(token.c_str(), '['); // look for opening braces
-			ResultWord result;
-
-			if (openb)
-				token = Common::String(token.begin(), openb);	// remove them and the rest
-
-			result = vocab_lookup_word(token.c_str(), token.size(), s->_parserWords, s->_parserSuffixes);
-
-			if (result._class != -1) {
-				s->parser_nodes[i].type = 0;
-				s->parser_nodes[i].content.value = result._group;
-			} else { // group name was specified directly?
-				int val = strtol(token.c_str(), NULL, 0);
-				if (val) {
-					s->parser_nodes[i].type = 0;
-					s->parser_nodes[i].content.value = val;
-				} else { // invalid and not matched
-					sciprintf("Couldn't interpret '%s'\n", token.c_str());
-					s->parser_valid = 0;
-					return 1;
-				}
-			}
-		}
-
-	}
-
-	s->parser_nodes[cmdParams.size()].type = -1; // terminate
-
-	s->parser_valid = 2;
-
-	return 0;
-}
-
 int c_viewinfo(EngineState *s, const Common::Array<cmd_param_t> &cmdParams) {
 	int view = cmdParams[0].val;
 	int palette = cmdParams[1].val;
@@ -634,51 +559,6 @@
 	return 0;
 }
 
-int c_list_sentence_fragments(EngineState *s, const Common::Array<cmd_param_t> &cmdParams) {
-	if (!s) {
-		sciprintf("Not in debug state\n");
-		return 1;
-	}
-
-	for (uint i = 0; i < s->_parserBranches.size(); i++) {
-		int j = 0;
-
-		sciprintf("R%02d: [%x] ->", i, s->_parserBranches[i].id);
-		while ((j < 10) && s->_parserBranches[i].data[j]) {
-			int dat = s->_parserBranches[i].data[j++];
-
-			switch (dat) {
-			case VOCAB_TREE_NODE_COMPARE_TYPE:
-				dat = s->_parserBranches[i].data[j++];
-				sciprintf(" C(%x)", dat);
-				break;
-
-			case VOCAB_TREE_NODE_COMPARE_GROUP:
-				dat = s->_parserBranches[i].data[j++];
-				sciprintf(" WG(%x)", dat);
-				break;
-
-			case VOCAB_TREE_NODE_FORCE_STORAGE:
-				dat = s->_parserBranches[i].data[j++];
-				sciprintf(" FORCE(%x)", dat);
-				break;
-
-			default:
-				if (dat > VOCAB_TREE_NODE_LAST_WORD_STORAGE) {
-					int dat2 = s->_parserBranches[i].data[j++];
-					sciprintf(" %x[%x]", dat, dat2);
-				} else
-					sciprintf(" ?%x?", dat);
-			}
-		}
-		sciprintf("\n");
-	}
-
-	sciprintf("%d rules.\n", s->_parserBranches.size());
-
-	return 0;
-}
-
 enum {
 	_parse_eoi,
 	_parse_token_pareno,
@@ -1110,27 +990,6 @@
 	return retval;
 }
 
-int c_dumpnodes(EngineState *s, const Common::Array<cmd_param_t> &cmdParams) {
-	int end = MIN<int>(cmdParams[0].val, VOCAB_TREE_NODES);
-	int i;
-
-	if (!_debugstate_valid) {
-		sciprintf("Not in debug state\n");
-		return 1;
-	}
-
-	for (i = 0; i < end; i++) {
-		sciprintf(" Node %03x: ", i);
-		if (s->parser_nodes[i].type == PARSE_TREE_NODE_LEAF)
-			sciprintf("Leaf: %04x\n", s->parser_nodes[i].content.value);
-		else
-			sciprintf("Branch: ->%04x, ->%04x\n", s->parser_nodes[i].content.branches[0],
-			          s->parser_nodes[i].content.branches[1]);
-	}
-
-	return 0;
-}
-
 static const char *varnames[] = {"global", "local", "temp", "param"};
 static const char *varabbrev = "gltp";
 
@@ -1998,24 +1857,6 @@
 	return 0;
 }
 
-int c_statusbar(EngineState *s, const Common::Array<cmd_param_t> &cmdParams) {
-	if (!s) {
-		sciprintf("Not in debug state\n");
-		return 1;
-	}
-
-	s->titlebar_port->_color = s->ega_colors[cmdParams[0].val];
-	s->titlebar_port->_bgcolor = s->ega_colors[cmdParams[1].val];
-
-	s->status_bar_foreground = cmdParams[0].val;
-	s->status_bar_background = cmdParams[1].val;
-
-	sciw_set_status_bar(s, s->titlebar_port, s->_statusBarText, s->status_bar_foreground, s->status_bar_background);
-	gfxop_update(s->gfx_state);
-
-	return 0;
-}
-
 static void _print_address(void * _, reg_t addr) {
 	if (addr.segment)
 		sciprintf("  %04x:%04x\n", PRINT_REG(addr));
@@ -2199,7 +2040,6 @@
 			                 "  splitting it up in resource type\n  and resource number.");
 			con_hook_command(c_visible_map, "set_vismap", "i", "Sets the visible map.\n  Default is 0 (visual).\n"
 			                 "  Other useful values are:\n  1: Priority\n  2: Control\n  3: Auxiliary\n");
-			con_hook_command(c_statusbar, "statusbar", "ii", "Sets the colors of the status bar. Also controllable from the script.\n");
 			con_hook_command(c_bpx, "bpx", "s", "Sets a breakpoint on the execution of\n  the specified method.\n\n  EXAMPLE:\n"
 			                 "  bpx ego::doit\n\n  May also be used to set a breakpoint\n  that applies whenever an object\n"
 			                 "  of a specific type is touched:\n  bpx foo::\n");
@@ -2207,12 +2047,8 @@
 			con_hook_command(c_bplist, "bplist", "", "Lists all breakpoints.\n");
 			con_hook_command(c_bpdel, "bpdel", "i", "Deletes a breakpoint with specified index.");
 			con_hook_command(c_go, "go", "", "Executes the script.\n");
-			con_hook_command(c_dumpnodes, "dumpnodes", "i", "shows the specified number of nodes\nfrom the parse node tree");
-			con_hook_command(c_mousepos, "mousepos", "", "Reveal the location of a mouse click.\n\n");
 			con_hook_command(c_viewinfo, "viewinfo", "ii", "Displays the number of loops\n  and cels of each loop"
 			                 " for the\n  specified view resource and palette.");
-			con_hook_command(c_list_sentence_fragments, "list_sentence_fragments", "", "Lists all sentence fragments (which\n"
-			                 "  are used to build Parse trees).");
 			con_hook_command(c_parse, "parse", "s", "Parses a sequence of words and prints\n  the resulting parse tree.\n"
 			                 "  The word sequence must be provided as a\n  single string.");
 			con_hook_command(c_set_parse_nodes, "set_parse_nodes", "s*", "Sets the contents of all parse nodes.\n"


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