[Scummvm-cvs-logs] SF.net SVN: scummvm:[44151] scummvm/trunk/engines/sci
fingolfin at users.sourceforge.net
fingolfin at users.sourceforge.net
Thu Sep 17 15:21:19 CEST 2009
Revision: 44151
http://scummvm.svn.sourceforge.net/scummvm/?rev=44151&view=rev
Author: fingolfin
Date: 2009-09-17 13:21:19 +0000 (Thu, 17 Sep 2009)
Log Message:
-----------
SCI: Move parts of struct ScriptState into a new struct DebugState
Modified Paths:
--------------
scummvm/trunk/engines/sci/console.cpp
scummvm/trunk/engines/sci/debug.h
scummvm/trunk/engines/sci/engine/kevent.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
scummvm/trunk/engines/sci/sci.cpp
Modified: scummvm/trunk/engines/sci/console.cpp
===================================================================
--- scummvm/trunk/engines/sci/console.cpp 2009-09-17 13:20:58 UTC (rev 44150)
+++ scummvm/trunk/engines/sci/console.cpp 2009-09-17 13:21:19 UTC (rev 44151)
@@ -183,11 +183,11 @@
DCmd_Register("active_object", WRAP_METHOD(Console, cmdViewActiveObject));
DCmd_Register("acc_object", WRAP_METHOD(Console, cmdViewAccumulatorObject));
- scriptState.seeking = kDebugSeekNothing;
- scriptState.seekLevel = 0;
- scriptState.runningStep = 0;
- scriptState.stopOnEvent = false;
- scriptState.debugging = false;
+ g_debugState.seeking = kDebugSeekNothing;
+ g_debugState.seekLevel = 0;
+ g_debugState.runningStep = 0;
+ g_debugState.stopOnEvent = false;
+ g_debugState.debugging = false;
}
Console::~Console() {
@@ -2113,23 +2113,23 @@
bool Console::cmdStep(int argc, const char **argv) {
if (argc == 2 && atoi(argv[1]) > 0)
- scriptState.runningStep = atoi(argv[1]) - 1;
- scriptState.debugging = true;
+ g_debugState.runningStep = atoi(argv[1]) - 1;
+ g_debugState.debugging = true;
return false;
}
bool Console::cmdStepEvent(int argc, const char **argv) {
- scriptState.stopOnEvent = true;
- scriptState.debugging = true;
+ g_debugState.stopOnEvent = true;
+ g_debugState.debugging = true;
return false;
}
bool Console::cmdStepRet(int argc, const char **argv) {
- scriptState.seeking = kDebugSeekLevelRet;
- scriptState.seekLevel = _vm->_gamestate->_executionStack.size() - 1;
- scriptState.debugging = true;
+ g_debugState.seeking = kDebugSeekLevelRet;
+ g_debugState.seekLevel = _vm->_gamestate->_executionStack.size() - 1;
+ g_debugState.debugging = true;
return false;
}
@@ -2141,9 +2141,9 @@
return true;
}
- scriptState.seeking = kDebugSeekGlobal;
- scriptState.seekSpecial = atoi(argv[1]);
- scriptState.debugging = true;
+ g_debugState.seeking = kDebugSeekGlobal;
+ g_debugState.seekSpecial = atoi(argv[1]);
+ g_debugState.debugging = true;
return false;
}
@@ -2171,12 +2171,12 @@
}
}
- scriptState.seeking = kDebugSeekSpecialCallk;
- scriptState.seekSpecial = callk_index;
+ g_debugState.seeking = kDebugSeekSpecialCallk;
+ g_debugState.seekSpecial = callk_index;
} else {
- scriptState.seeking = kDebugSeekCallk;
+ g_debugState.seeking = kDebugSeekCallk;
}
- scriptState.debugging = true;
+ g_debugState.debugging = true;
return false;
}
@@ -2343,14 +2343,14 @@
xstack->fp += argc;
_vm->_gamestate->_executionStackPosChanged = true;
- scriptState.debugging = true;
+ g_debugState.debugging = true;
return false;
}
bool Console::cmdGo(int argc, const char **argv) {
// CHECKME: is this necessary?
- scriptState.seeking = kDebugSeekNothing;
+ g_debugState.seeking = kDebugSeekNothing;
return Cmd_Exit(argc, argv);
}
@@ -2764,8 +2764,8 @@
if (!scumm_stricmp(argv[1], "game")) {
// Quit gracefully
script_abort_flag = 1; // Terminate VM
- scriptState.seeking = kDebugSeekNothing;
- scriptState.runningStep = 0;
+ g_debugState.seeking = kDebugSeekNothing;
+ g_debugState.runningStep = 0;
} else if (!scumm_stricmp(argv[1], "now")) {
// Quit ungracefully
@@ -3255,29 +3255,29 @@
opnumber = opcode >> 1;
if (opnumber == 0x22 /* callb */ || opnumber == 0x23 /* calle */ ||
opnumber == 0x25 /* send */ || opnumber == 0x2a /* self */ || opnumber == 0x2b /* super */) {
- scriptState.seeking = kDebugSeekSO;
- scriptState.seekLevel = s->_executionStack.size()-1;
- // Store in scriptState.seekSpecial the offset of the next command after send
+ g_debugState.seeking = kDebugSeekSO;
+ g_debugState.seekLevel = s->_executionStack.size()-1;
+ // Store in g_debugState.seekSpecial the offset of the next command after send
switch (opcode) {
case 0x46: // calle W
- scriptState.seekSpecial = *p_pc + 5;
+ g_debugState.seekSpecial = *p_pc + 5;
break;
case 0x44: // callb W
case 0x47: // calle B
case 0x56: // super W
- scriptState.seekSpecial = *p_pc + 4;
+ g_debugState.seekSpecial = *p_pc + 4;
break;
case 0x45: // callb B
case 0x57: // super B
case 0x4A: // send W
case 0x54: // self W
- scriptState.seekSpecial = *p_pc + 3;
+ g_debugState.seekSpecial = *p_pc + 3;
break;
default:
- scriptState.seekSpecial = *p_pc + 2;
+ g_debugState.seekSpecial = *p_pc + 2;
}
}
Modified: scummvm/trunk/engines/sci/debug.h
===================================================================
--- scummvm/trunk/engines/sci/debug.h 2009-09-17 13:20:58 UTC (rev 44150)
+++ scummvm/trunk/engines/sci/debug.h 2009-09-17 13:21:19 UTC (rev 44151)
@@ -40,7 +40,7 @@
kDebugSeekGlobal = 5 // Step forward until one specified global variable is modified
};
-struct ScriptState {
+struct DebugState {
bool debugging;
bool stopOnEvent;
DebugSeeking seeking; // Stepping forward until some special condition is met
@@ -49,12 +49,6 @@
int seekSpecial; // Used for special seeks
int old_pc_offset;
StackPtr old_sp;
- ExecStack *xs;
- int16 restAdjust;
- reg_t *variables[4]; // global, local, temp, param, as immediate pointers
- reg_t *variables_base[4]; // Used for referencing VM ops
- SegmentId variables_seg[4]; // Same as above, contains segment IDs
- int variables_max[4]; // Max. values for all variables
};
// Various global variables used for debugging are declared here
@@ -62,7 +56,7 @@
extern int g_debug_simulated_key;
extern bool g_debug_track_mouse_clicks;
extern bool g_debug_weak_validations;
-extern ScriptState scriptState;
+extern DebugState g_debugState;
} // End of namespace Sci
Modified: scummvm/trunk/engines/sci/engine/kevent.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kevent.cpp 2009-09-17 13:20:58 UTC (rev 44150)
+++ scummvm/trunk/engines/sci/engine/kevent.cpp 2009-09-17 13:21:19 UTC (rev 44151)
@@ -74,12 +74,12 @@
case SCI_EVT_KEYBOARD:
if ((e.buckybits & SCI_EVM_LSHIFT) && (e.buckybits & SCI_EVM_RSHIFT) && (e.data == '-')) {
printf("Debug mode activated\n");
- scriptState.seeking = kDebugSeekNothing;
- scriptState.runningStep = 0;
+ g_debugState.seeking = kDebugSeekNothing;
+ g_debugState.runningStep = 0;
} else if ((e.buckybits & SCI_EVM_CTRL) && (e.data == '`')) {
printf("Debug mode activated\n");
- scriptState.seeking = kDebugSeekNothing;
- scriptState.runningStep = 0;
+ g_debugState.seeking = kDebugSeekNothing;
+ g_debugState.runningStep = 0;
} else {
PUT_SEL32V(obj, type, SCI_EVT_KEYBOARD); // Keyboard event
s->r_acc = make_reg(0, 1);
@@ -123,8 +123,8 @@
s->r_acc = NULL_REG; // Unknown or no event
}
- if ((s->r_acc.offset) && (scriptState.stopOnEvent)) {
- scriptState.stopOnEvent = false;
+ if ((s->r_acc.offset) && (g_debugState.stopOnEvent)) {
+ g_debugState.stopOnEvent = false;
// A SCI event occured, and we have been asked to stop, so open the debug console
Console *con = ((Sci::SciEngine*)g_engine)->getSciDebugger();
Modified: scummvm/trunk/engines/sci/engine/kmisc.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kmisc.cpp 2009-09-17 13:20:58 UTC (rev 44150)
+++ scummvm/trunk/engines/sci/engine/kmisc.cpp 2009-09-17 13:21:19 UTC (rev 44151)
@@ -101,8 +101,8 @@
reg_t kSetDebug(EngineState *s, int, int argc, reg_t *argv) {
printf("Debug mode activated\n");
- scriptState.seeking = kDebugSeekNothing;
- scriptState.runningStep = 0;
+ g_debugState.seeking = kDebugSeekNothing;
+ g_debugState.runningStep = 0;
return s->r_acc;
}
Modified: scummvm/trunk/engines/sci/engine/scriptdebug.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/scriptdebug.cpp 2009-09-17 13:20:58 UTC (rev 44150)
+++ scummvm/trunk/engines/sci/engine/scriptdebug.cpp 2009-09-17 13:21:19 UTC (rev 44151)
@@ -63,7 +63,7 @@
extern const char *selector_name(EngineState *s, int selector);
-ScriptState scriptState;
+DebugState g_debugState;
int propertyOffsetToId(SegManager *segMan, int prop_ofs, reg_t objp) {
Object *obj = segMan->getObject(objp);
@@ -355,11 +355,11 @@
#endif
#if 0
- if (!scriptState.debugging)
+ if (!g_debugState.debugging)
return;
#endif
- if (scriptState.seeking && !bp) { // Are we looking for something special?
+ if (g_debugState.seeking && !bp) { // Are we looking for something special?
SegmentObj *mobj = GET_SEGMENT(*s->segMan, scriptState.xs->addr.pc.segment, SEG_TYPE_SCRIPT);
if (mobj) {
@@ -371,9 +371,9 @@
int paramb1 = scriptState.xs->addr.pc.offset + 1 >= code_buf_size ? 0 : code_buf[scriptState.xs->addr.pc.offset + 1];
int paramf1 = (opcode & 1) ? paramb1 : (scriptState.xs->addr.pc.offset + 2 >= code_buf_size ? 0 : (int16)READ_LE_UINT16(code_buf + scriptState.xs->addr.pc.offset + 1));
- switch (scriptState.seeking) {
+ switch (g_debugState.seeking) {
case kDebugSeekSpecialCallk:
- if (paramb1 != scriptState.seekSpecial)
+ if (paramb1 != g_debugState.seekSpecial)
return;
case kDebugSeekCallk: {
@@ -383,7 +383,7 @@
}
case kDebugSeekLevelRet: {
- if ((op != op_ret) || (scriptState.seekLevel < (int)s->_executionStack.size()-1))
+ if ((op != op_ret) || (g_debugState.seekLevel < (int)s->_executionStack.size()-1))
return;
break;
}
@@ -395,7 +395,7 @@
return; // param or temp
if ((op & 0x3) && s->_executionStack.back().local_segment > 0)
return; // locals and not running in script.000
- if (paramf1 != scriptState.seekSpecial)
+ if (paramf1 != g_debugState.seekSpecial)
return; // CORRECT global?
break;
@@ -408,7 +408,7 @@
break;
}
- scriptState.seeking = kDebugSeekNothing;
+ g_debugState.seeking = kDebugSeekNothing;
// OK, found whatever we were looking for
}
}
@@ -416,12 +416,12 @@
printf("Step #%d\n", script_step_counter);
disassemble(s, scriptState.xs->addr.pc, 0, 1);
- if (scriptState.runningStep) {
- scriptState.runningStep--;
+ if (g_debugState.runningStep) {
+ g_debugState.runningStep--;
return;
}
- scriptState.debugging = false;
+ g_debugState.debugging = false;
Console *con = ((Sci::SciEngine*)g_engine)->getSciDebugger();
con->attach();
Modified: scummvm/trunk/engines/sci/engine/vm.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/vm.cpp 2009-09-17 13:20:58 UTC (rev 44150)
+++ scummvm/trunk/engines/sci/engine/vm.cpp 2009-09-17 13:21:19 UTC (rev 44151)
@@ -46,6 +46,7 @@
#undef STRICT_SEND // Disallows variable sends with more than one parameter
#undef STRICT_READ // Disallows reading from out-of-bounds parameters and locals
+ScriptState scriptState;
int script_abort_flag = 0; // Set to 1 to abort execution. Set to 2 to force a replay afterwards // FIXME: Avoid non-const global vars
int script_step_counter = 0; // Counts the number of steps executed // FIXME: Avoid non-const global vars
@@ -230,7 +231,7 @@
if (bp->type == BREAK_EXPORT && bp->data.address == bpaddress) {
Console *con = ((SciEngine *)g_engine)->getSciDebugger();
con->DebugPrintf("Break on script %d, export %d\n", script, pubfunct);
- scriptState.debugging = true;
+ g_debugState.debugging = true;
breakpointFlag = true;
break;
}
@@ -298,7 +299,7 @@
con->DebugPrintf("Break on %s (in [%04x:%04x])\n", method_name, PRINT_REG(send_obj));
print_send_action = 1;
breakpointFlag = true;
- scriptState.debugging = true;
+ g_debugState.debugging = true;
break;
}
bp = bp->next;
@@ -355,7 +356,7 @@
break;
#ifdef STRICT_SEND
default:
- scriptState.seeking = scriptState.runningStep = 0;
+ g_debugState.seeking = g_debugState.runningStep = 0;
error("Send error: Variable selector %04x in %04x:%04x called with %04x params", selector, PRINT_REG(send_obj), argc);
#endif
}
@@ -555,8 +556,8 @@
int var_type; // See description below
int var_number;
- scriptState.old_pc_offset = scriptState.xs->addr.pc.offset;
- scriptState.old_sp = scriptState.xs->sp;
+ g_debugState.old_pc_offset = scriptState.xs->addr.pc.offset;
+ g_debugState.old_sp = scriptState.xs->sp;
if (s->_executionStackPosChanged) {
Script *scr;
@@ -616,7 +617,7 @@
// Debug if this has been requested:
// TODO: re-implement sci_debug_flags
- if (scriptState.debugging /* sci_debug_flags*/) {
+ if (g_debugState.debugging /* sci_debug_flags*/) {
script_debug(s, breakpointFlag);
breakpointFlag = false;
}
@@ -1917,8 +1918,8 @@
void quit_vm() {
script_abort_flag = 1; // Terminate VM
- scriptState.seeking = kDebugSeekNothing;
- scriptState.runningStep = 0;
+ g_debugState.seeking = kDebugSeekNothing;
+ g_debugState.runningStep = 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-09-17 13:20:58 UTC (rev 44150)
+++ scummvm/trunk/engines/sci/engine/vm.h 2009-09-17 13:21:19 UTC (rev 44151)
@@ -212,13 +212,6 @@
int real_y, z, index_nr; /* Used for sorting */
};
-enum {
- VAR_GLOBAL = 0,
- VAR_LOCAL = 1,
- VAR_TEMP = 2,
- VAR_PARAM = 3
-};
-
enum ExecStackType {
EXEC_STACK_TYPE_CALL = 0,
EXEC_STACK_TYPE_KERNEL = 1,
@@ -248,7 +241,31 @@
reg_t* getVarPointer(SegManager *segMan) const;
};
+enum {
+ VAR_GLOBAL = 0,
+ VAR_LOCAL = 1,
+ VAR_TEMP = 2,
+ VAR_PARAM = 3
+};
+/**
+ * Structure for storing the current internal state of the VM.
+ */
+struct ScriptState {
+ ExecStack *xs;
+ int16 restAdjust;
+ reg_t *variables[4]; // global, local, temp, param, as immediate pointers
+ reg_t *variables_base[4]; // Used for referencing VM ops
+ SegmentId variables_seg[4]; // Same as above, contains segment IDs
+ int variables_max[4]; // Max. values for all variables
+};
+
+/**
+ * The current internal state of the VM.
+ */
+extern ScriptState scriptState;
+
+
// These types are used both as identifiers and as elements of bitfields
enum BreakpointType {
/**
Modified: scummvm/trunk/engines/sci/sci.cpp
===================================================================
--- scummvm/trunk/engines/sci/sci.cpp 2009-09-17 13:20:58 UTC (rev 44150)
+++ scummvm/trunk/engines/sci/sci.cpp 2009-09-17 13:21:19 UTC (rev 44151)
@@ -208,12 +208,12 @@
GUI::Debugger *SciEngine::getDebugger() {
if (_gamestate) {
ExecStack *xs = &(_gamestate->_executionStack.back());
- xs->addr.pc.offset = scriptState.old_pc_offset;
- xs->sp = scriptState.old_sp;
+ xs->addr.pc.offset = g_debugState.old_pc_offset;
+ xs->sp = g_debugState.old_sp;
}
- scriptState.runningStep = 0; // Stop multiple execution
- scriptState.seeking = kDebugSeekNothing; // Stop special seeks
+ g_debugState.runningStep = 0; // Stop multiple execution
+ g_debugState.seeking = kDebugSeekNothing; // Stop special seeks
return _console;
}
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