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

m_kiewitz at users.sourceforge.net m_kiewitz at users.sourceforge.net
Sat Jan 2 10:39:18 CET 2010


Revision: 46878
          http://scummvm.svn.sourceforge.net/scummvm/?rev=46878&view=rev
Author:   m_kiewitz
Date:     2010-01-02 09:39:17 +0000 (Sat, 02 Jan 2010)

Log Message:
-----------
SCI: console behaviour changed for vmvars command, now allows entering decimal values, also accepts hexadecimal values (use e.g. 12h). hexadecimal addresses are still accepted as well

Modified Paths:
--------------
    scummvm/trunk/engines/sci/console.cpp

Modified: scummvm/trunk/engines/sci/console.cpp
===================================================================
--- scummvm/trunk/engines/sci/console.cpp	2010-01-02 08:53:06 UTC (rev 46877)
+++ scummvm/trunk/engines/sci/console.cpp	2010-01-02 09:39:17 UTC (rev 46878)
@@ -66,7 +66,7 @@
 bool g_debug_track_mouse_clicks = false;
 
 // Refer to the "addresses" command on how to pass address parameters
-static int parse_reg_t(EngineState *s, const char *str, reg_t *dest);
+static int parse_reg_t(EngineState *s, const char *str, reg_t *dest, bool mayBeValue);
 
 Console::Console(SciEngine *vm) : GUI::Debugger() {
 	_vm = vm;
@@ -1681,7 +1681,7 @@
 
 	reg_t addr;
 	
-	if (parse_reg_t(_vm->_gamestate, argv[1], &addr)) {
+	if (parse_reg_t(_vm->_gamestate, argv[1], &addr, false)) {
 		DebugPrintf("Invalid address passed.\n");
 		DebugPrintf("Check the \"addresses\" command on how to use addresses\n");
 		return true;
@@ -1710,7 +1710,7 @@
 
 	reg_t addr;
 	
-	if (parse_reg_t(_vm->_gamestate, argv[1], &addr)) {
+	if (parse_reg_t(_vm->_gamestate, argv[1], &addr, false)) {
 		DebugPrintf("Invalid address passed.\n");
 		DebugPrintf("Check the \"addresses\" command on how to use addresses\n");
 		return true;
@@ -1740,7 +1740,7 @@
 
 	reg_t addr;
 	
-	if (parse_reg_t(_vm->_gamestate, argv[1], &addr)) {
+	if (parse_reg_t(_vm->_gamestate, argv[1], &addr, false)) {
 		DebugPrintf("Invalid address passed.\n");
 		DebugPrintf("Check the \"addresses\" command on how to use addresses\n");
 		return true;
@@ -1812,9 +1812,10 @@
 		DebugPrintf("%s var %d == %04x:%04x\n", varnames[vartype], idx, PRINT_REG(scriptState.variables[vartype][idx]));
 		break;
 	case 4:
-		if (parse_reg_t(_vm->_gamestate, argv[3], &scriptState.variables[vartype][idx])) {
-			DebugPrintf("Invalid address passed.\n");
+		if (parse_reg_t(_vm->_gamestate, argv[3], &scriptState.variables[vartype][idx], true)) {
+			DebugPrintf("Invalid value/address passed.\n");
 			DebugPrintf("Check the \"addresses\" command on how to use addresses\n");
+			DebugPrintf("Or pass a decimal or hexadecimal value directly (e.g. 12, 1Ah)\n");
 			return true;
 		}
 		break;
@@ -1862,7 +1863,7 @@
 
 	reg_t val;
 	
-	if (parse_reg_t(_vm->_gamestate, argv[1], &val)) {
+	if (parse_reg_t(_vm->_gamestate, argv[1], &val, false)) {
 		DebugPrintf("Invalid address passed.\n");
 		DebugPrintf("Check the \"addresses\" command on how to use addresses\n");
 		return true;
@@ -1900,7 +1901,7 @@
 
 	reg_t addr;
 	
-	if (parse_reg_t(_vm->_gamestate, argv[1], &addr)) {
+	if (parse_reg_t(_vm->_gamestate, argv[1], &addr, false)) {
 		DebugPrintf("Invalid address passed.\n");
 		DebugPrintf("Check the \"addresses\" command on how to use addresses\n");
 		return true;
@@ -1923,14 +1924,14 @@
 	reg_t reg = NULL_REG;
 	reg_t reg_end = NULL_REG;
 
-	if (parse_reg_t(_vm->_gamestate, argv[1], &reg)) {
+	if (parse_reg_t(_vm->_gamestate, argv[1], &reg, false)) {
 		DebugPrintf("Invalid address passed.\n");
 		DebugPrintf("Check the \"addresses\" command on how to use addresses\n");
 		return true;
 	}
 
 	if (argc > 2) {
-		if (parse_reg_t(_vm->_gamestate, argv[2], &reg_end)) {
+		if (parse_reg_t(_vm->_gamestate, argv[2], &reg_end, false)) {
 			DebugPrintf("Invalid address passed.\n");
 			DebugPrintf("Check the \"addresses\" command on how to use addresses\n");
 			return true;
@@ -2030,7 +2031,7 @@
 
 	reg_t addr;
 	
-	if (parse_reg_t(_vm->_gamestate, argv[1], &addr)) {
+	if (parse_reg_t(_vm->_gamestate, argv[1], &addr, false)) {
 		DebugPrintf("Invalid address passed.\n");
 		DebugPrintf("Check the \"addresses\" command on how to use addresses\n");
 		return true;
@@ -2071,7 +2072,7 @@
 
 	reg_t val;
 	
-	if (parse_reg_t(_vm->_gamestate, argv[1], &val)) {
+	if (parse_reg_t(_vm->_gamestate, argv[1], &val, false)) {
 		DebugPrintf("Invalid address passed.\n");
 		DebugPrintf("Check the \"addresses\" command on how to use addresses\n");
 		return true;
@@ -2228,7 +2229,7 @@
 
 	reg_t objAddr = NULL_REG;
 
-	if (parse_reg_t(_vm->_gamestate, argv[1], &objAddr)) {
+	if (parse_reg_t(_vm->_gamestate, argv[1], &objAddr, false)) {
 		DebugPrintf("Invalid address passed.\n");
 		DebugPrintf("Check the \"addresses\" command on how to use addresses\n");
 		return true;
@@ -2277,7 +2278,7 @@
 	int do_bytes = 0;
 	int size;
 
-	if (parse_reg_t(_vm->_gamestate, argv[1], &vpc)) {
+	if (parse_reg_t(_vm->_gamestate, argv[1], &vpc, false)) {
 		DebugPrintf("Invalid address passed.\n");
 		DebugPrintf("Check the \"addresses\" command on how to use addresses\n");
 		return true;
@@ -2321,7 +2322,7 @@
 
 	reg_t object;
 	
-	if (parse_reg_t(_vm->_gamestate, argv[1], &object)) {
+	if (parse_reg_t(_vm->_gamestate, argv[1], &object, false)) {
 		DebugPrintf("Invalid address \"%s\" passed.\n", argv[1]);
 		DebugPrintf("Check the \"addresses\" command on how to use addresses\n");
 		return true;
@@ -2357,7 +2358,7 @@
 	stackframe[0] = make_reg(0, selector_id);
 	stackframe[1] = make_reg(0, send_argc);
 	for (int i = 0; i < send_argc; i++) {
-		if (parse_reg_t(_vm->_gamestate, argv[3+i], &stackframe[2+i])) {
+		if (parse_reg_t(_vm->_gamestate, argv[3+i], &stackframe[2+i], false)) {
 			DebugPrintf("Invalid address \"%s\" passed.\n", argv[3+i]);
 			DebugPrintf("Check the \"addresses\" command on how to use addresses\n");
 			return true;
@@ -2782,7 +2783,7 @@
 
 	reg_t id;
 	
-	if (parse_reg_t(_vm->_gamestate, argv[1], &id)) {
+	if (parse_reg_t(_vm->_gamestate, argv[1], &id, false)) {
 		DebugPrintf("Invalid address passed.\n");
 		DebugPrintf("Check the \"addresses\" command on how to use addresses\n");
 		return true;
@@ -2843,7 +2844,7 @@
 }
 
 // Returns 0 on success
-static int parse_reg_t(EngineState *s, const char *str, reg_t *dest) {
+static int parse_reg_t(EngineState *s, const char *str, reg_t *dest, bool mayBeValue) {
 	// Pointer to the part of str which contains a numeric offset (if any)
 	const char *offsetStr = NULL;
 
@@ -2948,7 +2949,25 @@
 
 		if (!colon) {
 			// No segment specified
-			offsetStr = str;
+			if (mayBeValue) {
+				// We assume that this is not an offset, but a straight (decimal) value
+				int val;
+				int length = strlen(str);
+				const char *lastchar = str + length - (length ? 1 : 0);
+				if (*lastchar != 'h') {
+					val = strtol(str, &endptr, 10);
+					if (*endptr)
+						return 1;
+				} else {
+					val = strtol(str, &endptr, 16);
+					if (endptr != lastchar)
+						return 1;
+				}
+				dest->offset = val;
+			} else {
+				// We require an address, so interpret it as an offset (hexadecimal)
+				offsetStr = str;
+			}
 			dest->segment = 0;
 		} else {
 			offsetStr = colon + 1;


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