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

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Thu Jun 4 13:28:06 CEST 2009


Revision: 41163
          http://scummvm.svn.sourceforge.net/scummvm/?rev=41163&view=rev
Author:   fingolfin
Date:     2009-06-04 11:28:05 +0000 (Thu, 04 Jun 2009)

Log Message:
-----------
SCI: Renamed various debug related global variables to have a g_ prefix; and moved any 'extern' decls of them into a new header file

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

Added Paths:
-----------
    scummvm/trunk/engines/sci/debug.h

Modified: scummvm/trunk/engines/sci/console.cpp
===================================================================
--- scummvm/trunk/engines/sci/console.cpp	2009-06-04 11:03:45 UTC (rev 41162)
+++ scummvm/trunk/engines/sci/console.cpp	2009-06-04 11:28:05 UTC (rev 41163)
@@ -27,6 +27,7 @@
 
 #include "sci/sci.h"
 #include "sci/console.h"
+#include "sci/debug.h"
 #include "sci/resource.h"
 #include "sci/vocabulary.h"
 #include "sci/engine/savegame.h"
@@ -47,21 +48,21 @@
 
 extern EngineState *g_EngineState;
 
-int debug_sleeptime_factor = 1;
-int debug_simulated_key = 0;
-bool debug_track_mouse_clicks = false;
-bool debug_weak_validations = true;
+int g_debug_sleeptime_factor = 1;
+int g_debug_simulated_key = 0;
+bool g_debug_track_mouse_clicks = false;
+bool g_debug_weak_validations = true;
 
 
 Console::Console(SciEngine *vm) : GUI::Debugger() {
 	_vm = vm;
 
 	// Variables
-	DVar_Register("sleeptime_factor",	&debug_sleeptime_factor, DVAR_INT, 0);
+	DVar_Register("sleeptime_factor",	&g_debug_sleeptime_factor, DVAR_INT, 0);
 	DVar_Register("gc_interval",		&script_gc_interval, DVAR_INT, 0);
-	DVar_Register("simulated_key",		&debug_simulated_key, DVAR_INT, 0);
-	DVar_Register("track_mouse_clicks",	&debug_track_mouse_clicks, DVAR_BOOL, 0);
-	DVar_Register("weak_validations",	&debug_weak_validations, DVAR_BOOL, 0);
+	DVar_Register("simulated_key",		&g_debug_simulated_key, DVAR_INT, 0);
+	DVar_Register("track_mouse_clicks",	&g_debug_track_mouse_clicks, DVAR_BOOL, 0);
+	DVar_Register("weak_validations",	&g_debug_weak_validations, DVAR_BOOL, 0);
 
 	// General
 	DCmd_Register("help",				WRAP_METHOD(Console, cmdHelp));
@@ -667,7 +668,7 @@
 		g_EngineState->successor = newstate; // Set successor
 
 		script_abort_flag = SCRIPT_ABORT_WITH_REPLAY; // Abort current game
-		_debugstate_valid = 0;
+		g_debugstate_valid = 0;
 
 		shrink_execution_stack(g_EngineState, g_EngineState->execution_stack_base + 1);
 		return 0;
@@ -698,7 +699,7 @@
 
 	g_EngineState->restarting_flags |= SCI_GAME_IS_RESTARTING_NOW;
 	script_abort_flag = 1;
-	_debugstate_valid = 0;
+	g_debugstate_valid = 0;
 
 	return false;
 }
@@ -2347,9 +2348,9 @@
 	if (!scumm_stricmp(argv[1], "game")) {
 		// Quit gracefully
 		script_abort_flag = 1; // Terminate VM
-		_debugstate_valid = 0;
-		_debug_seeking = 0;
-		_debug_step_running = 0;
+		g_debugstate_valid = 0;
+		g_debug_seeking = 0;
+		g_debug_step_running = 0;
 
 	} else if (!scumm_stricmp(argv[1], "now")) {
 		// Quit ungracefully

Added: scummvm/trunk/engines/sci/debug.h
===================================================================
--- scummvm/trunk/engines/sci/debug.h	                        (rev 0)
+++ scummvm/trunk/engines/sci/debug.h	2009-06-04 11:28:05 UTC (rev 41163)
@@ -0,0 +1,47 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef SCI_DEBUG_H
+#define SCI_DEBUG_H
+
+namespace Sci {
+
+// Various global variables used for debugging are declared here
+
+extern int g_stop_on_event;
+
+extern int g_debugstate_valid;
+extern int g_debug_seeking;
+extern int g_debug_step_running;
+
+extern int g_debug_sleeptime_factor;
+extern int g_debug_simulated_key;
+extern bool g_debug_track_mouse_clicks;
+extern bool g_debug_weak_validations;
+
+
+} // End of namespace Sci
+
+#endif


Property changes on: scummvm/trunk/engines/sci/debug.h
___________________________________________________________________
Added: svn:mime-type
   + text/plain
Added: svn:keywords
   + Date Rev Author URL Id
Added: svn:eol-style
   + native

Modified: scummvm/trunk/engines/sci/engine/kernel.h
===================================================================
--- scummvm/trunk/engines/sci/engine/kernel.h	2009-06-04 11:03:45 UTC (rev 41162)
+++ scummvm/trunk/engines/sci/engine/kernel.h	2009-06-04 11:28:05 UTC (rev 41163)
@@ -38,11 +38,6 @@
 struct Node;	// from vm.h
 struct List;	// from vm.h
 
-extern int stop_on_event;
-
-extern int _debug_seeking;
-extern int _debug_step_running;
-
 #define AVOIDPATH_DYNMEM_STRING "AvoidPath polyline"
 //#define DEBUG_PARSER	// enable for parser debugging
 

Modified: scummvm/trunk/engines/sci/engine/kevent.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kevent.cpp	2009-06-04 11:03:45 UTC (rev 41162)
+++ scummvm/trunk/engines/sci/engine/kevent.cpp	2009-06-04 11:28:05 UTC (rev 41163)
@@ -28,13 +28,12 @@
 #include "sci/engine/kernel.h"
 #include "sci/gfx/gfx_widgets.h"
 #include "sci/gfx/gfx_state_internal.h"	// required for GfxPort, GfxVisual
-#include "sci/console.h"	// for debug_simulated_key
+#include "sci/console.h"
+#include "sci/debug.h"	// for g_debug_simulated_key
 
 namespace Sci {
 
-int stop_on_event = 0;
-extern int debug_simulated_key;
-extern bool debug_track_mouse_clicks;
+int g_stop_on_event = 0;
 
 #define SCI_VARIABLE_GAME_SPEED 3
 
@@ -53,13 +52,13 @@
 
 	// If there's a simkey pending, and the game wants a keyboard event, use the
 	// simkey instead of a normal event
-	if (debug_simulated_key && (mask & SCI_EVT_KEYBOARD)) {
+	if (g_debug_simulated_key && (mask & SCI_EVT_KEYBOARD)) {
 		PUT_SEL32V(obj, type, SCI_EVT_KEYBOARD); // Keyboard event
-		PUT_SEL32V(obj, message, debug_simulated_key);
+		PUT_SEL32V(obj, message, g_debug_simulated_key);
 		PUT_SEL32V(obj, modifiers, SCI_EVM_NUMLOCK); // Numlock on
 		PUT_SEL32V(obj, x, s->gfx_state->pointer_pos.x);
 		PUT_SEL32V(obj, y, s->gfx_state->pointer_pos.y);
-		debug_simulated_key = 0;
+		g_debug_simulated_key = 0;
 		return make_reg(0, 1);
 	}
 
@@ -91,10 +90,10 @@
 	case SCI_EVT_KEYBOARD:
 		if ((e.buckybits & SCI_EVM_LSHIFT) && (e.buckybits & SCI_EVM_RSHIFT) && (e.data == '-')) {
 			sciprintf("Debug mode activated\n");
-			_debug_seeking = _debug_step_running = 0;
+			g_debug_seeking = g_debug_step_running = 0;
 		} else if ((e.buckybits & SCI_EVM_CTRL) && (e.data == '`')) {
 			sciprintf("Debug mode activated\n");
-			_debug_seeking = _debug_step_running = 0;
+			g_debug_seeking = g_debug_step_running = 0;
 		} else {
 			PUT_SEL32V(obj, type, SCI_EVT_KEYBOARD); // Keyboard event
 			s->r_acc = make_reg(0, 1);
@@ -110,7 +109,7 @@
 		int extra_bits = 0;
 
 		// track left buttton clicks, if requested
-		if (e.type == SCI_EVT_MOUSE_PRESS && e.data == 1 && debug_track_mouse_clicks) {
+		if (e.type == SCI_EVT_MOUSE_PRESS && e.data == 1 && g_debug_track_mouse_clicks) {
 			((SciEngine *)g_engine)->getDebugger()->DebugPrintf("Mouse clicked at %d, %d\n", 
 						s->gfx_state->pointer_pos.x, s->gfx_state->pointer_pos.y);
 		}
@@ -138,8 +137,8 @@
 		s->r_acc = NULL_REG; // Unknown or no event
 	}
 
-	if ((s->r_acc.offset) && (stop_on_event)) {
-		stop_on_event = 0;
+	if ((s->r_acc.offset) && (g_stop_on_event)) {
+		g_stop_on_event = 0;
 	}
 
 	return s->r_acc;

Modified: scummvm/trunk/engines/sci/engine/kgraphics.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kgraphics.cpp	2009-06-04 11:03:45 UTC (rev 41162)
+++ scummvm/trunk/engines/sci/engine/kgraphics.cpp	2009-06-04 11:28:05 UTC (rev 41163)
@@ -27,7 +27,7 @@
 #include "common/events.h"
 
 #include "sci/sci.h"
-#include "sci/console.h"	// for debug_sleeptime_factor
+#include "sci/debug.h"	// for g_debug_sleeptime_factor
 #include "sci/resource.h"
 #include "sci/engine/state.h"
 #include "sci/engine/kernel.h"
@@ -369,8 +369,6 @@
 	return s->r_acc;
 }
 
-extern int oldx, oldy;
-
 reg_t kMoveCursor(EngineState *s, int funct_nr, int argc, reg_t *argv) {
 	Common::Point newpos;
 
@@ -647,8 +645,6 @@
 	return s->r_acc;
 }
 
-extern int debug_sleeptime_factor;
-
 reg_t kWait(EngineState *s, int funct_nr, int argc, reg_t *argv) {
 	uint32 time;
 	int sleep_time = UKPV(0);
@@ -660,7 +656,7 @@
 	// Reset optimization flags: Game is playing along nicely anyway
 	s->kernel_opt_flags &= ~(KERNEL_OPT_FLAG_GOT_EVENT | KERNEL_OPT_FLAG_GOT_2NDEVENT);
 
-	sleep_time *= debug_sleeptime_factor;
+	sleep_time *= g_debug_sleeptime_factor;
 	GFX_ASSERT(gfxop_sleep(s->gfx_state, sleep_time * 1000 / 60));
 
 	return s->r_acc;

Modified: scummvm/trunk/engines/sci/engine/kmisc.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kmisc.cpp	2009-06-04 11:03:45 UTC (rev 41162)
+++ scummvm/trunk/engines/sci/engine/kmisc.cpp	2009-06-04 11:28:05 UTC (rev 41163)
@@ -28,6 +28,7 @@
 #include <time.h>	// FIXME: For struct tm
 
 #include "sci/sci.h"
+#include "sci/debug.h"
 #include "sci/engine/state.h"
 #include "sci/engine/kernel.h"
 #include "sci/engine/gc.h"
@@ -95,7 +96,7 @@
 reg_t kSetDebug(EngineState *s, int funct_nr, int argc, reg_t *argv) {
 	sciprintf("Debug mode activated\n");
 
-	_debug_seeking = _debug_step_running = 0;
+	g_debug_seeking = g_debug_step_running = 0;
 	return s->r_acc;
 }
 

Modified: scummvm/trunk/engines/sci/engine/scriptdebug.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/scriptdebug.cpp	2009-06-04 11:03:45 UTC (rev 41162)
+++ scummvm/trunk/engines/sci/engine/scriptdebug.cpp	2009-06-04 11:28:05 UTC (rev 41163)
@@ -26,6 +26,7 @@
 // Script debugger functionality. Absolutely not threadsafe.
 
 #include "sci/sci.h"
+#include "sci/debug.h"
 #include "sci/engine/state.h"
 #include "sci/engine/gc.h"
 #include "sci/engine/kernel_types.h"
@@ -46,13 +47,13 @@
 
 namespace Sci {
 
-int _debugstate_valid = 0; // Set to 1 while script_debug is running
-int _debug_step_running = 0; // Set to >0 to allow multiple stepping
-int _debug_commands_not_hooked = 1; // Commands not hooked to the console yet?
-int _debug_seeking = 0; // Stepping forward until some special condition is met
-int _debug_seek_level = 0; // Used for seekers that want to check their exec stack depth
-int _debug_seek_special = 0;  // Used for special seeks(1)
-reg_t _debug_seek_reg = NULL_REG;  // Used for special seeks(2)
+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)
+static reg_t s_debug_seek_reg = NULL_REG;  // Used for special seeks(2)
 
 #define _DEBUG_SEEK_NOTHING 0
 #define _DEBUG_SEEK_CALLK 1 // Step forward until callk is found
@@ -121,9 +122,9 @@
 }
 
 int c_step(EngineState *s, const Common::Array<cmd_param_t> &cmdParams) {
-	_debugstate_valid = 0;
+	g_debugstate_valid = 0;
 	if (cmdParams.size() && (cmdParams[0].val > 0))
-		_debug_step_running = cmdParams[0].val - 1;
+		g_debug_step_running = cmdParams[0].val - 1;
 
 	return 0;
 }
@@ -133,39 +134,39 @@
 int c_stepover(EngineState *s, const Common::Array<cmd_param_t> &cmdParams) {
 	int opcode, opnumber;
 
-	if (!_debugstate_valid) {
+	if (!g_debugstate_valid) {
 		sciprintf("Not in debug state\n");
 		return 1;
 	}
 
-	_debugstate_valid = 0;
+	g_debugstate_valid = 0;
 	opcode = s->_heap[*p_pc];
 	opnumber = opcode >> 1;
 	if (opnumber == 0x22 /* callb */ || opnumber == 0x23 /* calle */ ||
 	        opnumber == 0x25 /* send */ || opnumber == 0x2a /* self */ || opnumber == 0x2b /* super */) {
-		_debug_seeking = _DEBUG_SEEK_SO;
-		_debug_seek_level = s->_executionStack.size()-1;
-		// Store in _debug_seek_special the offset of the next command after send
+		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
 		switch (opcode) {
 		case 0x46: // calle W
-			_debug_seek_special = *p_pc + 5;
+			s_debug_seek_special = *p_pc + 5;
 			break;
 
 		case 0x44: // callb W
 		case 0x47: // calle B
 		case 0x56: // super W
-			_debug_seek_special = *p_pc + 4;
+			s_debug_seek_special = *p_pc + 4;
 			break;
 
 		case 0x45: // callb B
 		case 0x57: // super B
 		case 0x4A: // send W
 		case 0x54: // self W
-			_debug_seek_special = *p_pc + 3;
+			s_debug_seek_special = *p_pc + 3;
 			break;
 
 		default:
-			_debug_seek_special = *p_pc + 2;
+			s_debug_seek_special = *p_pc + 2;
 		}
 	}
 
@@ -319,7 +320,7 @@
 	opsize = scr[pos.offset];
 	opcode = opsize >> 1;
 
-	if (!_debugstate_valid) {
+	if (!g_debugstate_valid) {
 		sciprintf("Not in debug state\n");
 		return retval;
 	}
@@ -540,7 +541,7 @@
 extern int debug_widget_pos;
 
 static int c_gfx_print_widget(EngineState *s, const Common::Array<cmd_param_t> &cmdParams) {
-	if (!_debugstate_valid) {
+	if (!g_debugstate_valid) {
 		sciprintf("Not in debug state\n");
 		return 1;
 	}
@@ -695,9 +696,9 @@
 }
 
 static int c_sg(EngineState *s, const Common::Array<cmd_param_t> &cmdParams) {
-	_debug_seeking = _DEBUG_SEEK_GLOBAL;
-	_debug_seek_special = cmdParams[0].val;
-	_debugstate_valid = 0;
+	g_debug_seeking = _DEBUG_SEEK_GLOBAL;
+	s_debug_seek_special = cmdParams[0].val;
+	g_debugstate_valid = 0;
 
 	return 0;
 }
@@ -706,7 +707,7 @@
 	int callk_index;
 	char *endptr;
 
-	if (!_debugstate_valid) {
+	if (!g_debugstate_valid) {
 		sciprintf("Not in debug state\n");
 		return 1;
 	}
@@ -730,27 +731,27 @@
 			}
 		}
 
-		_debug_seeking = _DEBUG_SEEK_SPECIAL_CALLK;
-		_debug_seek_special = callk_index;
-		_debugstate_valid = 0;
+		g_debug_seeking = _DEBUG_SEEK_SPECIAL_CALLK;
+		s_debug_seek_special = callk_index;
+		g_debugstate_valid = 0;
 	} else {
-		_debug_seeking = _DEBUG_SEEK_CALLK;
-		_debugstate_valid = 0;
+		g_debug_seeking = _DEBUG_SEEK_CALLK;
+		g_debugstate_valid = 0;
 	}
 
 	return 0;
 }
 
 static int c_sret(EngineState *s, const Common::Array<cmd_param_t> &cmdParams) {
-	_debug_seeking = _DEBUG_SEEK_LEVEL_RET;
-	_debug_seek_level = s->_executionStack.size()-1;
-	_debugstate_valid = 0;
+	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) {
-	_debug_seeking = 0;
-	_debugstate_valid = 0;
+	g_debug_seeking = 0;
+	g_debugstate_valid = 0;
 	return 0;
 }
 
@@ -899,8 +900,8 @@
 // Breakpoint commands
 
 int c_se(EngineState *s, const Common::Array<cmd_param_t> &cmdParams) {
-	stop_on_event = 1;
-	_debugstate_valid = 0;
+	g_stop_on_event = 1;
+	g_debugstate_valid = 0;
 
 	return 0;
 }
@@ -909,7 +910,7 @@
 	SegmentId *segids, reg_t **variables, reg_t **variables_base, int *variables_nr, int bp) {
 	// Do we support a separate console?
 
-	int old_debugstate = _debugstate_valid;
+	int old_debugstate = g_debugstate_valid;
 
 	p_var_segs = segids;
 	p_vars = variables;
@@ -921,15 +922,15 @@
 	p_objp = objp;
 	p_restadjust = restadjust;
 	sciprintf("%d: acc=%04x:%04x  ", script_step_counter, PRINT_REG(s->r_acc));
-	_debugstate_valid = 1;
+	g_debugstate_valid = 1;
 	disassemble(s, *pc, 0, 1);
-	if (_debug_seeking == _DEBUG_SEEK_GLOBAL)
-		sciprintf("Global %d (0x%x) = %04x:%04x\n", _debug_seek_special,
-		          _debug_seek_special, PRINT_REG(s->script_000->locals_block->_locals[_debug_seek_special]));
+	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]));
 
-	_debugstate_valid = old_debugstate;
+	g_debugstate_valid = old_debugstate;
 
-	if (_debug_seeking && !bp) { // Are we looking for something special?
+	if (g_debug_seeking && !bp) { // Are we looking for something special?
 		MemObject *mobj = GET_SEGMENT(*s->seg_manager, pc->segment, MEM_OBJ_SCRIPT);
 
 		if (mobj) {
@@ -941,9 +942,9 @@
 			int paramb1 = pc->offset + 1 >= code_buf_size ? 0 : code_buf[pc->offset + 1];
 			int paramf1 = (opcode & 1) ? paramb1 : (pc->offset + 2 >= code_buf_size ? 0 : (int16)READ_LE_UINT16(code_buf + pc->offset + 1));
 
-			switch (_debug_seeking) {
+			switch (g_debug_seeking) {
 			case _DEBUG_SEEK_SPECIAL_CALLK:
-				if (paramb1 != _debug_seek_special)
+				if (paramb1 != s_debug_seek_special)
 					return;
 
 			case _DEBUG_SEEK_CALLK: {
@@ -953,13 +954,13 @@
 			}
 
 			case _DEBUG_SEEK_LEVEL_RET: {
-				if ((op != op_ret) || (_debug_seek_level < (int)s->_executionStack.size()-1))
+				if ((op != op_ret) || (s_debug_seek_level < (int)s->_executionStack.size()-1))
 					return;
 				break;
 			}
 
 			case _DEBUG_SEEK_SO:
-				if ((*pc != _debug_seek_reg) || (int)s->_executionStack.size()-1 != _debug_seek_level)
+				if ((*pc != s_debug_seek_reg) || (int)s->_executionStack.size()-1 != s_debug_seek_level)
 					return;
 				break;
 
@@ -971,20 +972,20 @@
 					return; // param or temp
 				if ((op & 0x3) && s->_executionStack.back().local_segment > 0)
 					return; // locals and not running in script.000
-				if (paramf1 != _debug_seek_special)
+				if (paramf1 != s_debug_seek_special)
 					return; // CORRECT global?
 				break;
 
 			}
 
-			_debug_seeking = _DEBUG_SEEK_NOTHING;
+			g_debug_seeking = _DEBUG_SEEK_NOTHING;
 			// OK, found whatever we were looking for
 		}
 	}
 
-	_debugstate_valid = (_debug_step_running == 0);
+	g_debugstate_valid = (g_debug_step_running == 0);
 
-	if (_debugstate_valid) {
+	if (g_debugstate_valid) {
 		p_pc = pc;
 		p_sp = sp;
 		p_pp = pp;
@@ -998,8 +999,8 @@
 		sciprintf("Step #%d\n", script_step_counter);
 		disassemble(s, *pc, 0, 1);
 
-		if (_debug_commands_not_hooked) {
-			_debug_commands_not_hooked = 0;
+		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");
@@ -1043,10 +1044,10 @@
 		} // If commands were not hooked up
 	}
 
-	if (_debug_step_running)
-		_debug_step_running--;
+	if (g_debug_step_running)
+		g_debug_step_running--;
 
-	while (_debugstate_valid) {
+	while (g_debugstate_valid) {
 		int skipfirst = 0;
 		const char *commandstring;
 

Modified: scummvm/trunk/engines/sci/engine/vm.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/vm.cpp	2009-06-04 11:03:45 UTC (rev 41162)
+++ scummvm/trunk/engines/sci/engine/vm.cpp	2009-06-04 11:28:05 UTC (rev 41163)
@@ -27,7 +27,7 @@
 #include "common/stack.h"
 
 #include "sci/sci.h"
-#include "sci/console.h"	// for debug_weak_validations
+#include "sci/debug.h"	// for g_debug_weak_validations
 #include "sci/resource.h"
 #include "sci/engine/state.h"
 #include "sci/engine/intmap.h"
@@ -46,18 +46,14 @@
 #undef STRICT_READ // Disallows reading from out-of-bounds parameters and locals
 
 
-int script_abort_flag = 0; // Set to 1 to abort execution
-int script_step_counter = 0; // Counts the number of steps executed
-int script_gc_interval = GC_INTERVAL; // Number of steps in between gcs
+int script_abort_flag = 0; // Set to 1 to abort execution	// FIXME: Avoid non-const global vars
+int script_step_counter = 0; // Counts the number of steps executed	// FIXME: Avoid non-const global vars
+int script_gc_interval = GC_INTERVAL; // Number of steps in between gcs	// FIXME: Avoid non-const global vars
 
-extern int _debug_step_running;
-extern int _debug_seeking;
-extern bool debug_weak_validations;
 
+static bool breakpointFlag = false;	// FIXME: Avoid non-const global vars
+static reg_t _dummy_register;		// FIXME: Avoid non-const global vars
 
-static bool breakpointFlag = false;
-static reg_t _dummy_register;
-
 // validation functionality
 
 #ifndef DISABLE_VALIDATIONS
@@ -90,7 +86,7 @@
 
 static int validate_arithmetic(reg_t reg) {
 	if (reg.segment) {
-		if (debug_weak_validations)
+		if (g_debug_weak_validations)
 			warning("[VM] Attempt to read arithmetic value from non-zero segment [%04x]\n", reg.segment);
 		else
 			error("[VM] Attempt to read arithmetic value from non-zero segment [%04x]\n", reg.segment);
@@ -102,7 +98,7 @@
 
 static int signed_validate_arithmetic(reg_t reg) {
 	if (reg.segment) {
-		if (debug_weak_validations)
+		if (g_debug_weak_validations)
 			warning("[VM] Attempt to read arithmetic value from non-zero segment [%04x]\n", reg.segment);
 		else
 			error("[VM] Attempt to read arithmetic value from non-zero segment [%04x]\n", reg.segment);
@@ -129,7 +125,7 @@
 			strcat(txt, tmp);
 		}
 
-		if (debug_weak_validations)
+		if (g_debug_weak_validations)
 			warning(txt);
 		else
 			error(txt);
@@ -400,7 +396,7 @@
 			default:
 				sciprintf("Send error: Variable selector %04x in %04x:%04x called with %04x params\n", selector, PRINT_REG(send_obj), argc);
 				script_debug_flag = 1; // Enter debug mode
-				_debug_seeking = _debug_step_running = 0;
+				g_debug_seeking = g_debug_step_running = 0;
 #endif
 			}
 			break;
@@ -1431,8 +1427,8 @@
 
 #if 0
 		if (script_error_flag) {
-			_debug_step_running = 0; // Stop multiple execution
-			_debug_seeking = 0; // Stop special seeks
+			g_debug_step_running = 0; // Stop multiple execution
+			g_debug_seeking = 0; // Stop special seeks
 			xs->addr.pc.offset = old_pc_offset;
 			xs->sp = old_sp;
 		} else
@@ -2065,9 +2061,9 @@
 
 void quit_vm() {
 	script_abort_flag = 1; // Terminate VM
-	_debugstate_valid = 0;
-	_debug_seeking = 0;
-	_debug_step_running = 0;
+	g_debugstate_valid = 0;
+	g_debug_seeking = 0;
+	g_debug_step_running = 0;
 }
 
 void shrink_execution_stack(EngineState *s, uint size) {

Modified: scummvm/trunk/engines/sci/engine/vm.h
===================================================================
--- scummvm/trunk/engines/sci/engine/vm.h	2009-06-04 11:03:45 UTC (rev 41162)
+++ scummvm/trunk/engines/sci/engine/vm.h	2009-06-04 11:28:05 UTC (rev 41163)
@@ -806,11 +806,6 @@
 extern int script_step_counter;
 
 
-extern int _debugstate_valid;
-extern int _debug_seeking;
-extern int _debug_step_running;
-
-
 typedef int kernel_function(struct EngineState *s);
 
 extern kernel_function* kfuncs[];


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