aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/engine
diff options
context:
space:
mode:
authorFilippos Karapetis2009-07-03 14:22:50 +0000
committerFilippos Karapetis2009-07-03 14:22:50 +0000
commit6fa8541aed68e72fd4f1cdeb13a46ec95547b275 (patch)
tree6d4fd58ddf8c42bb34ccf153273cb9e441e30534 /engines/sci/engine
parent69da51e71d71bb700a4e5e5419f64f482cb9fabc (diff)
downloadscummvm-rg350-6fa8541aed68e72fd4f1cdeb13a46ec95547b275.tar.gz
scummvm-rg350-6fa8541aed68e72fd4f1cdeb13a46ec95547b275.tar.bz2
scummvm-rg350-6fa8541aed68e72fd4f1cdeb13a46ec95547b275.zip
- Pushed debugstate into debug.h
- When an error occurs, manipulate the execution stack before error() opens the console inside getDebugger(), like FreeSCI did. Added another method for obtaining the SCI console for use by the engine itself. svn-id: r42062
Diffstat (limited to 'engines/sci/engine')
-rw-r--r--engines/sci/engine/grammar.cpp4
-rw-r--r--engines/sci/engine/kevent.cpp6
-rw-r--r--engines/sci/engine/kmisc.cpp2
-rw-r--r--engines/sci/engine/vm.cpp18
4 files changed, 7 insertions, 23 deletions
diff --git a/engines/sci/engine/grammar.cpp b/engines/sci/engine/grammar.cpp
index 275a31a0d4..e75441432d 100644
--- a/engines/sci/engine/grammar.cpp
+++ b/engines/sci/engine/grammar.cpp
@@ -351,7 +351,7 @@ parse_rule_list_t *Vocabulary::buildGNF(bool verbose) {
int ntrules_nr;
parse_rule_list_t *ntlist = NULL;
parse_rule_list_t *tlist, *new_tlist;
- GUI::Debugger *con = ((SciEngine *)g_engine)->getDebugger();
+ Console *con = ((SciEngine *)g_engine)->getSciDebugger();
for (uint i = 1; i < _parserBranches.size(); i++) { // branch rule 0 is treated specially
parse_rule_t *rule = _vbuild_rule(&_parserBranches[i]);
@@ -477,7 +477,7 @@ static int _vbpt_write_subexpression(parse_tree_node_t *nodes, int *pos, parse_r
}
int Vocabulary::parseGNF(parse_tree_node_t *nodes, const ResultWordList &words, bool verbose) {
- GUI::Debugger *con = ((SciEngine *)g_engine)->getDebugger();
+ Console *con = ((SciEngine *)g_engine)->getSciDebugger();
// Get the start rules:
parse_rule_list_t *work = _vocab_clone_rule_list_by_id(_parserRules, _parserBranches[0].data[1]);
parse_rule_list_t *results = NULL;
diff --git a/engines/sci/engine/kevent.cpp b/engines/sci/engine/kevent.cpp
index 3b37506e6c..e40368a5c0 100644
--- a/engines/sci/engine/kevent.cpp
+++ b/engines/sci/engine/kevent.cpp
@@ -33,8 +33,6 @@
namespace Sci {
-extern DebugState debugState;
-
#define SCI_VARIABLE_GAME_SPEED 3
reg_t kGetEvent(EngineState *s, int funct_nr, int argc, reg_t *argv) {
@@ -112,7 +110,7 @@ reg_t kGetEvent(EngineState *s, int funct_nr, int argc, reg_t *argv) {
// track left buttton clicks, if requested
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",
+ ((SciEngine *)g_engine)->getSciDebugger()->DebugPrintf("Mouse clicked at %d, %d\n",
s->gfx_state->pointer_pos.x, s->gfx_state->pointer_pos.y);
}
@@ -143,7 +141,7 @@ reg_t kGetEvent(EngineState *s, int funct_nr, int argc, reg_t *argv) {
debugState.stopOnEvent = false;
// A SCI event occured, and we have been asked to stop, so open the debug console
- GUI::Debugger *con = ((Sci::SciEngine*)g_engine)->getDebugger();
+ Console *con = ((Sci::SciEngine*)g_engine)->getSciDebugger();
con->DebugPrintf("SCI event occured: ");
switch (e.type) {
case SCI_EVT_QUIT:
diff --git a/engines/sci/engine/kmisc.cpp b/engines/sci/engine/kmisc.cpp
index 99665bae7d..98fba97f0e 100644
--- a/engines/sci/engine/kmisc.cpp
+++ b/engines/sci/engine/kmisc.cpp
@@ -93,8 +93,6 @@ reg_t kFlushResources(EngineState *s, int funct_nr, int argc, reg_t *argv) {
return s->r_acc;
}
-extern DebugState debugState;
-
reg_t kSetDebug(EngineState *s, int funct_nr, int argc, reg_t *argv) {
sciprintf("Debug mode activated\n");
diff --git a/engines/sci/engine/vm.cpp b/engines/sci/engine/vm.cpp
index 30b2f07edd..44b119ab46 100644
--- a/engines/sci/engine/vm.cpp
+++ b/engines/sci/engine/vm.cpp
@@ -49,7 +49,6 @@ reg_t NULL_REG = {0, 0};
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
int script_gc_interval = GC_INTERVAL; // Number of steps in between gcs // FIXME: Avoid non-const global vars
-extern DebugState debugState;
static bool breakpointFlag = false; // FIXME: Avoid non-const global vars
static reg_t _dummy_register; // FIXME: Avoid non-const global vars
@@ -606,14 +605,12 @@ void run_vm(EngineState *s, int restoring) {
while (1) {
byte opcode;
- int old_pc_offset;
- StackPtr old_sp;
byte opnumber;
int var_type; // See description below
int var_number;
- old_pc_offset = xs->addr.pc.offset;
- old_sp = xs->sp;
+ debugState.old_pc_offset = xs->addr.pc.offset;
+ debugState.old_sp = xs->sp;
if (s->_executionStackPosChanged) {
Script *scr;
@@ -1424,16 +1421,7 @@ void run_vm(EngineState *s, int restoring) {
opnumber);
}
//#endif
-
-#if 0
- if (script_error_flag) {
- debugState.runningStep = 0; // Stop multiple execution
- debugState.seeking = 0; // Stop special seeks
- xs->addr.pc.offset = old_pc_offset;
- xs->sp = old_sp;
- } else
-#endif
- ++script_step_counter;
+ ++script_step_counter;
}
}