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

thebluegr at users.sourceforge.net thebluegr at users.sourceforge.net
Sat Jun 6 18:43:13 CEST 2009


Revision: 41227
          http://scummvm.svn.sourceforge.net/scummvm/?rev=41227&view=rev
Author:   thebluegr
Date:     2009-06-06 16:43:13 +0000 (Sat, 06 Jun 2009)

Log Message:
-----------
Moved some more debug commands to ScummVM's coneole

Modified Paths:
--------------
    scummvm/trunk/engines/sci/console.cpp
    scummvm/trunk/engines/sci/console.h
    scummvm/trunk/engines/sci/debug.h
    scummvm/trunk/engines/sci/engine/game.cpp
    scummvm/trunk/engines/sci/engine/grammar.cpp
    scummvm/trunk/engines/sci/engine/kevent.cpp
    scummvm/trunk/engines/sci/engine/kgraphics.cpp
    scummvm/trunk/engines/sci/engine/said.cpp
    scummvm/trunk/engines/sci/engine/scriptdebug.cpp
    scummvm/trunk/engines/sci/vocabulary.cpp
    scummvm/trunk/engines/sci/vocabulary.h

Modified: scummvm/trunk/engines/sci/console.cpp
===================================================================
--- scummvm/trunk/engines/sci/console.cpp	2009-06-06 15:41:17 UTC (rev 41226)
+++ scummvm/trunk/engines/sci/console.cpp	2009-06-06 16:43:13 UTC (rev 41227)
@@ -52,7 +52,19 @@
 int g_debug_simulated_key = 0;
 bool g_debug_track_mouse_clicks = false;
 bool g_debug_weak_validations = true;
+// Script related variables
+int g_debug_seeking = 0; // Stepping forward until some special condition is met
+int g_debug_seek_special = 0;  // Used for special seeks
+int g_debug_seek_level = 0; // Used for seekers that want to check their exec stack depth
 
+enum DebugSeeking {
+	kDebugSeekNothing = 0,
+	kDebugSeekCallk = 1,        // Step forward until callk is found
+	kDebugSeekLevelRet = 2,     // Step forward until returned from this level
+	kDebugSeekSpecialCallk = 3, // Step forward until a /special/ callk is found
+	kDebugSeekSO = 4,           // Step forward until specified PC (after the send command) and stack depth
+	kDebugSeekGlobal = 5        // Step forward until one specified global variable is modified
+};
 
 Console::Console(SciEngine *vm) : GUI::Debugger() {
 	_vm = vm;
@@ -80,6 +92,7 @@
 	DCmd_Register("parser_words",		WRAP_METHOD(Console, cmdParserWords));
 	DCmd_Register("sentence_fragments",	WRAP_METHOD(Console, cmdSentenceFragments));
 	DCmd_Register("parse",				WRAP_METHOD(Console, cmdParse));
+	DCmd_Register("set_parse_nodes",	WRAP_METHOD(Console, cmdSetParseNodes));
 	// Resources
 	DCmd_Register("hexdump",			WRAP_METHOD(Console, cmdHexDump));
 	DCmd_Register("resource_id",		WRAP_METHOD(Console, cmdResourceId));
@@ -141,6 +154,9 @@
 	DCmd_Register("dissect_script",		WRAP_METHOD(Console, cmdDissectScript));
 	DCmd_Register("set_acc",			WRAP_METHOD(Console, cmdSetAccumulator));
 	DCmd_Register("backtrace",			WRAP_METHOD(Console, cmdBacktrace));
+	DCmd_Register("step_event",			WRAP_METHOD(Console, cmdStepEvent));
+	DCmd_Register("step_ret",			WRAP_METHOD(Console, cmdStepRet));
+	DCmd_Register("step_global",		WRAP_METHOD(Console, cmdStepGlobal));
 	// Breakpoints
 	DCmd_Register("bp_list",			WRAP_METHOD(Console, cmdBreakpointList));
 	DCmd_Register("bp_del",				WRAP_METHOD(Console, cmdBreakpointDelete));
@@ -220,6 +236,7 @@
 	DebugPrintf(" parser_words - Shows the words from the parse node tree\n");
 	DebugPrintf(" sentence_fragments - Shows the sentence fragments (used to build Parse trees)\n");
 	DebugPrintf(" parse - Parses a sequence of words and prints the resulting parse tree\n");
+	DebugPrintf(" set_parse_nodes - Sets the contents of all parse nodes\n");
 	DebugPrintf("\n");
 	DebugPrintf("Resources:\n");
 	DebugPrintf(" hexdump - Dumps the specified resource to standard output\n");
@@ -290,6 +307,9 @@
 	DebugPrintf(" dissect_script - Examines a script\n");
 	DebugPrintf(" set_acc - Sets the accumulator\n");
 	DebugPrintf(" backtrace - Dumps the send/self/super/call/calle/callb stack\n");
+	DebugPrintf(" step_event - Steps forward until a SCI event is received.\n");
+	DebugPrintf(" step_ret - Steps forward until ret is called on the current execution stack level.\n");
+	DebugPrintf(" step_global - Steps until the global variable with the specified index is modified.\n");
 	DebugPrintf("\n");
 	DebugPrintf("Breakpoints:\n");
 	DebugPrintf(" bp_list - Lists the current breakpoints\n");
@@ -391,6 +411,98 @@
 	return true;
 }
 
+enum {
+	kParseEndOfInput = 0,
+	kParseOpeningParenthesis = 1,
+	kParseClosingParenthesis = 2,
+	kParseNil = 3,
+	kParseNumber = 4
+};
+
+int parseNodes(EngineState *s, int *i, int *pos, int type, int nr, int argc, const char **argv) {
+	int nextToken = 0, nextValue = 0, newPos = 0, oldPos = 0;
+
+	if (type == kParseNil)
+		return 0;
+
+	if (type == kParseNumber) {
+		s->parser_nodes[*pos += 1].type = kParseTreeLeafNode;
+		s->parser_nodes[*pos].content.value = nr;
+		return *pos;
+	}
+	if (type == kParseEndOfInput) {
+		sciprintf("Unbalanced parentheses\n");
+		return -1;
+	}
+	if (type == kParseClosingParenthesis) {
+		sciprintf("Syntax error at token %d\n", *i);
+		return -1;
+	}
+
+	s->parser_nodes[oldPos = ++(*pos)].type = kParseTreeBranchNode;
+
+	for (int j = 0; j <= 1; j++) {
+		if (*i == argc) {
+			nextToken = kParseEndOfInput;
+		} else {
+			const char *token = argv[(*i)++];
+
+			if (!strcmp(token, "(")) {
+				nextToken = kParseOpeningParenthesis;
+			} else if (!strcmp(token, ")")) {
+				nextToken = kParseClosingParenthesis;
+			} else if (!strcmp(token, "nil")) {
+				nextToken = kParseNil;
+			} else {
+				nextValue = strtol(token, NULL, 0);
+				nextToken = kParseNumber;
+			}
+		}
+
+		if ((newPos = s->parser_nodes[oldPos].content.branches[j] = parseNodes(s, i, pos, nextToken, nextValue, argc, argv)) == -1)
+			return -1;
+	}
+
+	const char *token = argv[(*i)++];
+	if (strcmp(token, ")"))
+		sciprintf("Expected ')' at token %d\n", *i);
+
+	return oldPos;
+}
+
+bool Console::cmdSetParseNodes(int argc, const char **argv) {
+	if (argc < 2) {
+		DebugPrintf("Sets the contents of all parse nodes.\n");
+		DebugPrintf("Usage: %s <parse node1> <parse node2> ... <parse noden>\n", argv[0]);
+		DebugPrintf("Tokens should be separated by blanks and enclosed in parentheses\n");
+		return true;
+	}
+
+	int i = 0;
+	int pos = -1;
+	int nextToken = 0, nextValue = 0;
+
+	const char *token = argv[i++];
+
+	if (!strcmp(token, "(")) {
+		nextToken = kParseOpeningParenthesis;
+	} else if (!strcmp(token, ")")) {
+		nextToken = kParseClosingParenthesis;
+	} else if (!strcmp(token, "nil")) {
+		nextToken = kParseNil;
+	} else {
+		nextValue = strtol(token, NULL, 0);
+		nextToken = kParseNumber;
+	}
+
+	if (parseNodes(g_EngineState, &i, &pos, nextToken, nextValue, argc, argv) == -1)
+		return 1;
+
+	vocab_dump_parse_tree("debug-parse-tree", g_EngineState->parser_nodes);
+
+	return true;
+}
+
 bool Console::cmdRegisters(int argc, const char **argv) {
 	DebugPrintf("Current register values:\n");
 #if 0
@@ -832,7 +944,7 @@
 
 	for (int i = 0; i < end; i++) {
 		DebugPrintf(" Node %03x: ", i);
-		if (g_EngineState->parser_nodes[i].type == PARSE_TREE_NODE_LEAF)
+		if (g_EngineState->parser_nodes[i].type == kParseTreeLeafNode)
 			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],
@@ -1954,6 +2066,35 @@
 	return true;
 }
 
+bool Console::cmdStepEvent(int argc, const char **argv) {
+	g_stop_on_event = 1;
+	g_debugstate_valid = 0;
+
+	return true;
+}
+
+bool Console::cmdStepRet(int argc, const char **argv) {
+	g_debug_seeking = kDebugSeekLevelRet;
+	g_debug_seek_level = g_EngineState->_executionStack.size() - 1;
+	g_debugstate_valid = 0;
+
+	return true;
+}
+
+bool Console::cmdStepGlobal(int argc, const char **argv) {
+	if (argc != 2) {
+		DebugPrintf("Steps until the global variable with the specified index is modified.\n");
+		DebugPrintf("Usage: %s <global variable index>\n", argv[0]);
+		return true;
+	}
+
+	g_debug_seeking = kDebugSeekGlobal;
+	g_debug_seek_special = atoi(argv[1]);
+	g_debugstate_valid = 0;
+
+	return true;
+}
+
 bool Console::cmdBreakpointList(int argc, const char **argv) {
 	Breakpoint *bp = g_EngineState->bp_list;
 	int i = 0;
@@ -2858,29 +2999,29 @@
 	opnumber = opcode >> 1;
 	if (opnumber == 0x22 /* callb */ || opnumber == 0x23 /* calle */ ||
 	        opnumber == 0x25 /* send */ || opnumber == 0x2a /* self */ || opnumber == 0x2b /* super */) {
-		g_debug_seeking = _DEBUG_SEEK_SO;
-		s_debug_seek_level = s->_executionStack.size()-1;
-		// Store in s_debug_seek_special the offset of the next command after send
+		g_debug_seeking = kDebugSeekSO;
+		g_debug_seek_level = s->_executionStack.size()-1;
+		// Store in g_debug_seek_special the offset of the next command after send
 		switch (opcode) {
 		case 0x46: // calle W
-			s_debug_seek_special = *p_pc + 5;
+			g_debug_seek_special = *p_pc + 5;
 			break;
 
 		case 0x44: // callb W
 		case 0x47: // calle B
 		case 0x56: // super W
-			s_debug_seek_special = *p_pc + 4;
+			g_debug_seek_special = *p_pc + 4;
 			break;
 
 		case 0x45: // callb B
 		case 0x57: // super B
 		case 0x4A: // send W
 		case 0x54: // self W
-			s_debug_seek_special = *p_pc + 3;
+			g_debug_seek_special = *p_pc + 3;
 			break;
 
 		default:
-			s_debug_seek_special = *p_pc + 2;
+			g_debug_seek_special = *p_pc + 2;
 		}
 	}
 

Modified: scummvm/trunk/engines/sci/console.h
===================================================================
--- scummvm/trunk/engines/sci/console.h	2009-06-06 15:41:17 UTC (rev 41226)
+++ scummvm/trunk/engines/sci/console.h	2009-06-06 16:43:13 UTC (rev 41227)
@@ -59,9 +59,10 @@
 	bool cmdSuffixes(int argc, const char **argv);
 	bool cmdParseGrammar(int argc, const char **argv);
 	bool cmdParserNodes(int argc, const char **argv);
-	bool cmdParserWords(int argc, const char **argv);
+	bool cmdParserWords(int argc, const char **argv);	
 	bool cmdSentenceFragments(int argc, const char **argv);
 	bool cmdParse(int argc, const char **argv);
+	bool cmdSetParseNodes(int argc, const char **argv);
 	// Resources
 	bool cmdHexDump(int argc, const char **argv);
 	bool cmdResourceId(int argc, const char **argv);
@@ -121,6 +122,9 @@
 	bool cmdDissectScript(int argc, const char **argv);
 	bool cmdSetAccumulator(int argc, const char **argv);
 	bool cmdBacktrace(int argc, const char **argv);
+	bool cmdStepEvent(int argc, const char **argv);
+	bool cmdStepRet(int argc, const char **argv);
+	bool cmdStepGlobal(int argc, const char **argv);
 	// Breakpoints
 	bool cmdBreakpointList(int argc, const char **argv);
 	bool cmdBreakpointDelete(int argc, const char **argv);

Modified: scummvm/trunk/engines/sci/debug.h
===================================================================
--- scummvm/trunk/engines/sci/debug.h	2009-06-06 15:41:17 UTC (rev 41226)
+++ scummvm/trunk/engines/sci/debug.h	2009-06-06 16:43:13 UTC (rev 41227)
@@ -40,8 +40,11 @@
 extern int g_debug_simulated_key;
 extern bool g_debug_track_mouse_clicks;
 extern bool g_debug_weak_validations;
+// Script related variables
+extern int g_debug_seeking;
+extern int g_debug_seek_special;
+extern int g_debug_seek_level;
 
-
 } // End of namespace Sci
 
 #endif

Modified: scummvm/trunk/engines/sci/engine/game.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/game.cpp	2009-06-06 15:41:17 UTC (rev 41226)
+++ scummvm/trunk/engines/sci/engine/game.cpp	2009-06-06 16:43:13 UTC (rev 41227)
@@ -499,7 +499,7 @@
 	s->game_obj = game_obj;
 
 	// Mark parse tree as unused
-	s->parser_nodes[0].type = PARSE_TREE_NODE_LEAF;
+	s->parser_nodes[0].type = kParseTreeLeafNode;
 	s->parser_nodes[0].content.value = 0;
 
 	s->_menubar = new Menubar(); // Create menu bar

Modified: scummvm/trunk/engines/sci/engine/grammar.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/grammar.cpp	2009-06-06 15:41:17 UTC (rev 41226)
+++ scummvm/trunk/engines/sci/engine/grammar.cpp	2009-06-06 16:43:13 UTC (rev 41227)
@@ -414,7 +414,7 @@
 static int _vbpt_pareno(parse_tree_node_t *nodes, int *pos, int base) {
 	// Opens parentheses
 	nodes[base].content.branches[0] = (*pos) + 1;
-	nodes[++(*pos)].type = PARSE_TREE_NODE_BRANCH;
+	nodes[++(*pos)].type = kParseTreeBranchNode;
 	nodes[*pos].content.branches[0] = 0;
 	nodes[*pos].content.branches[1] = 0;
 	return *pos;
@@ -423,7 +423,7 @@
 static int _vbpt_parenc(parse_tree_node_t *nodes, int *pos, int paren) {
 	// Closes parentheses for appending
 	nodes[paren].content.branches[1] = ++(*pos);
-	nodes[*pos].type = PARSE_TREE_NODE_BRANCH;
+	nodes[*pos].type = kParseTreeBranchNode;
 	nodes[*pos].content.branches[0] = 0;
 	nodes[*pos].content.branches[1] = 0;
 	return *pos;
@@ -432,10 +432,10 @@
 static int _vbpt_append(parse_tree_node_t *nodes, int *pos, int base, int value) {
 	// writes one value to an existing base node and creates a successor node for writing
 	nodes[base].content.branches[0] = ++(*pos);
-	nodes[*pos].type = PARSE_TREE_NODE_LEAF;
+	nodes[*pos].type = kParseTreeLeafNode;
 	nodes[*pos].content.value = value;
 	nodes[base].content.branches[1] = ++(*pos);
-	nodes[*pos].type = PARSE_TREE_NODE_BRANCH;
+	nodes[*pos].type = kParseTreeBranchNode;
 	nodes[*pos].content.branches[0] = 0;
 	nodes[*pos].content.branches[1] = 0;
 	return *pos;
@@ -443,7 +443,7 @@
 
 static int _vbpt_terminate(parse_tree_node_t *nodes, int *pos, int base, int value) {
 	// Terminates, overwriting a nextwrite forknode
-	nodes[base].type = PARSE_TREE_NODE_LEAF;
+	nodes[base].type = kParseTreeLeafNode;
 	nodes[base].content.value = value;
 	return *pos;
 }
@@ -554,14 +554,14 @@
 	{
 		int temp, pos;
 
-		nodes[0].type = PARSE_TREE_NODE_BRANCH;
+		nodes[0].type = kParseTreeBranchNode;
 		nodes[0].content.branches[0] = 1;
 		nodes[0].content.branches[1] = 2;
 
-		nodes[1].type = PARSE_TREE_NODE_LEAF;
+		nodes[1].type = kParseTreeLeafNode;
 		nodes[1].content.value = 0x141;
 
-		nodes[2].type = PARSE_TREE_NODE_BRANCH;
+		nodes[2].type = kParseTreeBranchNode;
 		nodes[2].content.branches[0] = 0;
 		nodes[2].content.branches[1] = 0;
 

Modified: scummvm/trunk/engines/sci/engine/kevent.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kevent.cpp	2009-06-06 15:41:17 UTC (rev 41226)
+++ scummvm/trunk/engines/sci/engine/kevent.cpp	2009-06-06 16:43:13 UTC (rev 41227)
@@ -139,6 +139,27 @@
 
 	if ((s->r_acc.offset) && (g_stop_on_event)) {
 		g_stop_on_event = 0;
+
+		// A SCI event occured, and we have been asked to stop, so open the debug console
+		GUI::Debugger *con = ((Sci::SciEngine*)g_engine)->getDebugger();
+		con->DebugPrintf("SCI event occured: ");
+		switch (e.type) {
+		case SCI_EVT_QUIT:
+			con->DebugPrintf("quit event\n");
+			break;
+		case SCI_EVT_KEYBOARD:
+			con->DebugPrintf("keyboard event\n");
+			break;
+		case SCI_EVT_MOUSE_RELEASE:
+		case SCI_EVT_MOUSE_PRESS:
+			con->DebugPrintf("mouse click event\n");
+			break;
+		default:
+			con->DebugPrintf("unknown or no event (event type %d)\n", e.type);
+		}
+
+		con->attach();
+		con->onFrame();
 	}
 
 	return s->r_acc;

Modified: scummvm/trunk/engines/sci/engine/kgraphics.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kgraphics.cpp	2009-06-06 15:41:17 UTC (rev 41226)
+++ scummvm/trunk/engines/sci/engine/kgraphics.cpp	2009-06-06 16:43:13 UTC (rev 41227)
@@ -348,8 +348,8 @@
 
 		// Set pointer position, if requested
 		if (argc > 2) {
-			Common::Point newpos = Common::Point(SKPV(2) + s->port->_bounds.x, SKPV(3) + s->port->_bounds.y);
-			GFX_ASSERT(gfxop_set_pointer_position(s->gfx_state, newpos));
+			Common::Point newPos = Common::Point(SKPV(2) + s->port->_bounds.x, SKPV(3) + s->port->_bounds.y);
+			GFX_ASSERT(gfxop_set_pointer_position(s->gfx_state, newPos));
 		}
 		break;
 	case 3 :
@@ -370,26 +370,26 @@
 }
 
 reg_t kMoveCursor(EngineState *s, int funct_nr, int argc, reg_t *argv) {
-	Common::Point newpos;
+	Common::Point newPos;
 
-	newpos = s->gfx_state->pointer_pos;
+	newPos = s->gfx_state->pointer_pos;
 
 	if (argc == 1) {
 		// Case ignored on IBM PC
 	} else {
-		newpos.x = SKPV(0) + s->port->zone.x;
-		newpos.y = SKPV(1) + s->port->zone.y;
+		newPos.x = SKPV(0) + s->port->zone.x;
+		newPos.y = SKPV(1) + s->port->zone.y;
 
-		if (newpos.x > s->port->zone.x + s->port->zone.width)
-			newpos.x = s->port->zone.x + s->port->zone.width;
-		if (newpos.y > s->port->zone.y + s->port->zone.height)
-			newpos.y = s->port->zone.y + s->port->zone.height;
+		if (newPos.x > s->port->zone.x + s->port->zone.width)
+			newPos.x = s->port->zone.x + s->port->zone.width;
+		if (newPos.y > s->port->zone.y + s->port->zone.height)
+			newPos.y = s->port->zone.y + s->port->zone.height;
 
-		if (newpos.x < 0) newpos.x = 0;
-		if (newpos.y < 0) newpos.y = 0;
+		if (newPos.x < 0) newPos.x = 0;
+		if (newPos.y < 0) newPos.y = 0;
 	}
 
-	GFX_ASSERT(gfxop_set_pointer_position(s->gfx_state, newpos));
+	GFX_ASSERT(gfxop_set_pointer_position(s->gfx_state, newPos));
 
 	return s->r_acc;
 }

Modified: scummvm/trunk/engines/sci/engine/said.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/said.cpp	2009-06-06 15:41:17 UTC (rev 41226)
+++ scummvm/trunk/engines/sci/engine/said.cpp	2009-06-06 16:43:13 UTC (rev 41227)
@@ -1918,7 +1918,7 @@
 #define SAID_NEXT_NODE said_next_node()
 
 static int said_leaf_node(tree_t pos, int value) {
-	said_tree[pos].type = PARSE_TREE_NODE_LEAF;
+	said_tree[pos].type = kParseTreeLeafNode;
 
 	if (value != VALUE_IGNORE)
 		said_tree[pos].content.value = value;
@@ -1927,7 +1927,7 @@
 }
 
 static int said_branch_node(tree_t pos, int left, int right) {
-	said_tree[pos].type = PARSE_TREE_NODE_BRANCH;
+	said_tree[pos].type = kParseTreeBranchNode;
 
 	if (left != VALUE_IGNORE)
 		said_tree[pos].content.branches[0] = left;
@@ -2057,12 +2057,12 @@
 // primitive functions
 
 #define AUG_READ_BRANCH(a, br, p) \
-	if (tree[p].type != PARSE_TREE_NODE_BRANCH) \
+	if (tree[p].type != kParseTreeBranchNode) \
 		return 0; \
 	a = tree[p].content.branches[br];
 
 #define AUG_READ_VALUE(a, p) \
-	if (tree[p].type != PARSE_TREE_NODE_LEAF) \
+	if (tree[p].type != kParseTreeLeafNode) \
 		return 0; \
 	a = tree[p].content.value;
 

Modified: scummvm/trunk/engines/sci/engine/scriptdebug.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/scriptdebug.cpp	2009-06-06 15:41:17 UTC (rev 41226)
+++ scummvm/trunk/engines/sci/engine/scriptdebug.cpp	2009-06-06 16:43:13 UTC (rev 41227)
@@ -49,18 +49,8 @@
 
 int g_debugstate_valid = 0; // Set to 1 while script_debug is running
 int g_debug_step_running = 0; // Set to >0 to allow multiple stepping
-static bool s_debug_commands_hooked = false; // Commands hooked to the console yet?
-int g_debug_seeking = 0; // Stepping forward until some special condition is met
-static int s_debug_seek_level = 0; // Used for seekers that want to check their exec stack depth
-static int s_debug_seek_special = 0;  // Used for special seeks(1)
+extern int g_debug_seek_special;
 
-#define _DEBUG_SEEK_NOTHING 0
-#define _DEBUG_SEEK_CALLK 1 // Step forward until callk is found
-#define _DEBUG_SEEK_LEVEL_RET 2 // Step forward until returned from this level
-#define _DEBUG_SEEK_SPECIAL_CALLK 3 // Step forward until a /special/ callk is found
-#define _DEBUG_SEEK_SO 5 // Step forward until specified PC (after the send command) and stack depth
-#define _DEBUG_SEEK_GLOBAL 6 // Step forward until one specified global variable is modified
-
 static reg_t *p_pc;
 static StackPtr *p_sp;
 static StackPtr *p_pp;
@@ -105,89 +95,6 @@
 	return 0;
 }
 
-enum {
-	_parse_eoi,
-	_parse_token_pareno,
-	_parse_token_parenc,
-	_parse_token_nil,
-	_parse_token_number
-};
-
-int _parse_getinp(int *i, int *nr, const Common::Array<cmd_param_t> &cmdParams) {
-	const char *token;
-
-	if ((unsigned)*i == cmdParams.size())
-		return _parse_eoi;
-
-	token = cmdParams[(*i)++].str;
-
-	if (!strcmp(token, "("))
-		return _parse_token_pareno;
-
-	if (!strcmp(token, ")"))
-		return _parse_token_parenc;
-
-	if (!strcmp(token, "nil"))
-		return _parse_token_nil;
-
-	*nr = strtol(token, NULL, 0);
-
-	return _parse_token_number;
-}
-
-int _parse_nodes(EngineState *s, int *i, int *pos, int type, int nr, const Common::Array<cmd_param_t> &cmdParams) {
-	int nexttk, nextval, newpos, oldpos;
-
-	if (type == _parse_token_nil)
-		return 0;
-
-	if (type == _parse_token_number) {
-		s->parser_nodes[*pos += 1].type = PARSE_TREE_NODE_LEAF;
-		s->parser_nodes[*pos].content.value = nr;
-		return *pos;
-	}
-	if (type == _parse_eoi) {
-		sciprintf("Unbalanced parentheses\n");
-		return -1;
-	}
-	if (type == _parse_token_parenc) {
-		sciprintf("Syntax error at token %d\n", *i);
-		return -1;
-	}
-	s->parser_nodes[oldpos = ++(*pos)].type = PARSE_TREE_NODE_BRANCH;
-
-	nexttk = _parse_getinp(i, &nextval, cmdParams);
-	if ((newpos = s->parser_nodes[oldpos].content.branches[0] = _parse_nodes(s, i, pos, nexttk, nextval, cmdParams)) == -1)
-		return -1;
-
-	nexttk = _parse_getinp(i, &nextval, cmdParams);
-	if ((newpos = s->parser_nodes[oldpos].content.branches[1] = _parse_nodes(s, i, pos, nexttk, nextval, cmdParams)) == -1)
-		return -1;
-
-	if (_parse_getinp(i, &nextval, cmdParams) != _parse_token_parenc)
-		sciprintf("Expected ')' at token %d\n", *i);
-
-	return oldpos;
-}
-
-int c_set_parse_nodes(EngineState *s, const Common::Array<cmd_param_t> &cmdParams) {
-	int i = 0;
-	int foo, bar;
-	int pos = -1;
-
-	if (!s) {
-		sciprintf("Not in debug state\n");
-		return 1;
-	}
-
-	bar = _parse_getinp(&i, &foo, cmdParams);
-	if (_parse_nodes(s, &i, &pos, bar, foo, cmdParams) == -1)
-		return 1;
-
-	vocab_dump_parse_tree("debug-parse-tree", s->parser_nodes);
-	return 0;
-}
-
 extern const char *selector_name(EngineState *s, int selector);
 
 int prop_ofs_to_id(EngineState *s, int prop_ofs, reg_t objp) {
@@ -528,15 +435,10 @@
 	return 0;
 }
 
-static int c_sg(EngineState *s, const Common::Array<cmd_param_t> &cmdParams) {
-	g_debug_seeking = _DEBUG_SEEK_GLOBAL;
-	s_debug_seek_special = cmdParams[0].val;
-	g_debugstate_valid = 0;
-
-	return 0;
-}
-
 static int c_snk(EngineState *s, const Common::Array<cmd_param_t> &cmdParams) {
+// TODO: disabled till this is moved in console.cpp
+#if 0
+
 	int callk_index;
 	char *endptr;
 
@@ -564,24 +466,18 @@
 			}
 		}
 
-		g_debug_seeking = _DEBUG_SEEK_SPECIAL_CALLK;
-		s_debug_seek_special = callk_index;
+		g_debug_seeking = kDebugSeekSpecialCallk;
+		g_debug_seek_special = callk_index;
 		g_debugstate_valid = 0;
 	} else {
-		g_debug_seeking = _DEBUG_SEEK_CALLK;
+		g_debug_seeking = kDebugSeekCallk;
 		g_debugstate_valid = 0;
 	}
+#endif
 
 	return 0;
 }
 
-static int c_sret(EngineState *s, const Common::Array<cmd_param_t> &cmdParams) {
-	g_debug_seeking = _DEBUG_SEEK_LEVEL_RET;
-	s_debug_seek_level = s->_executionStack.size()-1;
-	g_debugstate_valid = 0;
-	return 0;
-}
-
 static int c_go(EngineState *s, const Common::Array<cmd_param_t> &cmdParams) {
 	g_debug_seeking = 0;
 	g_debugstate_valid = 0;
@@ -645,15 +541,10 @@
 
 // Breakpoint commands
 
-int c_se(EngineState *s, const Common::Array<cmd_param_t> &cmdParams) {
-	g_stop_on_event = 1;
-	g_debugstate_valid = 0;
-
-	return 0;
-}
-
 void script_debug(EngineState *s, reg_t *pc, StackPtr *sp, StackPtr *pp, reg_t *objp, int *restadjust,
 	SegmentId *segids, reg_t **variables, reg_t **variables_base, int *variables_nr, int bp) {
+// TODO: disabled till this is moved in console.cpp
+#if 0
 	// Do we support a separate console?
 
 	int old_debugstate = g_debugstate_valid;
@@ -670,9 +561,9 @@
 	sciprintf("%d: acc=%04x:%04x  ", script_step_counter, PRINT_REG(s->r_acc));
 	g_debugstate_valid = 1;
 	disassemble(s, *pc, 0, 1);
-	if (g_debug_seeking == _DEBUG_SEEK_GLOBAL)
-		sciprintf("Global %d (0x%x) = %04x:%04x\n", s_debug_seek_special,
-		          s_debug_seek_special, PRINT_REG(s->script_000->locals_block->_locals[s_debug_seek_special]));
+	if (g_debug_seeking == kDebugSeekGlobal)
+		sciprintf("Global %d (0x%x) = %04x:%04x\n", g_debug_seek_special,
+		          g_debug_seek_special, PRINT_REG(s->script_000->locals_block->_locals[g_debug_seek_special]));
 
 	g_debugstate_valid = old_debugstate;
 
@@ -689,39 +580,40 @@
 			int paramf1 = (opcode & 1) ? paramb1 : (pc->offset + 2 >= code_buf_size ? 0 : (int16)READ_LE_UINT16(code_buf + pc->offset + 1));
 
 			switch (g_debug_seeking) {
-			case _DEBUG_SEEK_SPECIAL_CALLK:
-				if (paramb1 != s_debug_seek_special)
+			case kDebugSeekSpecialCallk:
+				if (paramb1 != g_debug_seek_special)
 					return;
 
-			case _DEBUG_SEEK_CALLK: {
+			case kDebugSeekCallk: {
 				if (op != op_callk)
 					return;
 				break;
 			}
 
-			case _DEBUG_SEEK_LEVEL_RET: {
-				if ((op != op_ret) || (s_debug_seek_level < (int)s->_executionStack.size()-1))
+			case kDebugSeekLevelRet: {
+				if ((op != op_ret) || (g_debug_seek_level < (int)s->_executionStack.size()-1))
 					return;
 				break;
 			}
 
-			case _DEBUG_SEEK_GLOBAL:
+			case kDebugSeekGlobal:
 				if (op < op_sag)
 					return;
 				if ((op & 0x3) > 1)
 					return; // param or temp
 				if ((op & 0x3) && s->_executionStack.back().local_segment > 0)
 					return; // locals and not running in script.000
-				if (paramf1 != s_debug_seek_special)
+				if (paramf1 != g_debug_seek_special)
 					return; // CORRECT global?
 				break;
 
 			}
 
-			g_debug_seeking = _DEBUG_SEEK_NOTHING;
+			g_debug_seeking = kDebugSeekNothing;
 			// OK, found whatever we were looking for
 		}
 	}
+#endif
 
 	g_debugstate_valid = (g_debug_step_running == 0);
 
@@ -739,9 +631,6 @@
 		sciprintf("Step #%d\n", script_step_counter);
 		disassemble(s, *pc, 0, 1);
 
-		if (!s_debug_commands_hooked) {
-			s_debug_commands_hooked = true;
-
 			con_hook_command(c_step, "s", "i*", "Executes one or several operations\n\nEXAMPLES\n\n"
 			                 "    s 4\n\n  Execute 4 commands\n\n    s\n\n  Execute next command");
 			con_hook_command(c_disasm_addr, "disasm-addr", "!as*", "Disassembles one or more commands\n\n"
@@ -753,17 +642,8 @@
 			con_hook_command(c_disasm, "disasm", "!as", "Disassembles a method by name\n\nUSAGE\n\n  disasm <obj> <method>\n\n");
 			con_hook_command(c_snk, "snk", "s*", "Steps forward until it hits the next\n  callk operation.\n"
 			                 "  If invoked with a parameter, it will\n  look for that specific callk.\n");
-			con_hook_command(c_se, "se", "", "Steps forward until an SCI event is received.\n");
 			con_hook_command(c_send, "send", "!asa*", "Sends a message to an object\nExample: send ?fooScript cue");
-			con_hook_command(c_sret, "sret", "", "Steps forward until ret is called\n  on the current execution stack\n  level.");
 			con_hook_command(c_go, "go", "", "Executes the script.\n");
-			con_hook_command(c_set_parse_nodes, "set_parse_nodes", "s*", "Sets the contents of all parse nodes.\n"
-			                 "  Input token must be separated by\n  blanks.");
-			con_hook_command(c_sg, "sg", "!i",
-			                 "Steps until the global variable with the\n"
-			                 "specified index is modified.\n\nSEE ALSO\n\n"
-			                 "  s.1, snk.1, so.1, bpx.1");
-		} // If commands were not hooked up
 	}
 
 	if (g_debug_step_running)

Modified: scummvm/trunk/engines/sci/vocabulary.cpp
===================================================================
--- scummvm/trunk/engines/sci/vocabulary.cpp	2009-06-06 15:41:17 UTC (rev 41226)
+++ scummvm/trunk/engines/sci/vocabulary.cpp	2009-06-06 16:43:13 UTC (rev 41227)
@@ -488,7 +488,7 @@
 		return;
 	}
 
-	if (nodes[nr].type == PARSE_TREE_NODE_LEAF)
+	if (nodes[nr].type == kParseTreeLeafNode)
 		//sciprintf("[%03x]%04x", nr, nodes[nr].content.value);
 		sciprintf("%x", nodes[nr].content.value);
 	else {
@@ -518,7 +518,7 @@
 	int rbranch = nodes[nr].content.branches[1];
 	int i;
 
-	if (nodes[nr].type == PARSE_TREE_NODE_LEAF) {
+	if (nodes[nr].type == kParseTreeLeafNode) {
 		sciprintf("vocab_dump_parse_tree: Error: consp is nil for element %03x\n", nr);
 		return;
 	}
@@ -529,7 +529,7 @@
 	}
 
 	if (lbranch) {
-		if (nodes[lbranch].type == PARSE_TREE_NODE_BRANCH) {
+		if (nodes[lbranch].type == kParseTreeBranchNode) {
 			sciprintf("\n");
 			for (i = 0; i < blanks; i++)
 				sciprintf("    ");
@@ -544,7 +544,7 @@
 	}/* else sciprintf ("nil");*/
 
 	if (rbranch) {
-		if (nodes[rbranch].type == PARSE_TREE_NODE_BRANCH)
+		if (nodes[rbranch].type == kParseTreeBranchNode)
 			_vocab_recursive_ptree_dump(nodes, rbranch, nr, blanks);
 		else
 			sciprintf("%x", nodes[rbranch].content.value);

Modified: scummvm/trunk/engines/sci/vocabulary.h
===================================================================
--- scummvm/trunk/engines/sci/vocabulary.h	2009-06-06 15:41:17 UTC (rev 41226)
+++ scummvm/trunk/engines/sci/vocabulary.h	2009-06-06 16:43:13 UTC (rev 41227)
@@ -160,10 +160,11 @@
 	int data[10];
 };
 
-#define PARSE_TREE_NODE_LEAF 0
-#define PARSE_TREE_NODE_BRANCH 1
+enum ParseTypes {
+	kParseTreeLeafNode = 0,
+	kParseTreeBranchNode = 1
+};
 
-
 struct parse_tree_node_t {
 	short type;  /* leaf or branch */
 	union {


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