From 7c84cca81d4fd7eeadd3d6903d80e1e856c2d5a0 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Fri, 5 Jun 2009 19:04:14 +0000 Subject: [PATCH] Moved some more debug commands to ScummVM's coneole and removed some unused code svn-id: r41198 --- engines/sci/console.cpp | 239 ++++++++++++++++++++++- engines/sci/console.h | 1 + engines/sci/engine/kfile.cpp | 2 +- engines/sci/engine/scriptdebug.cpp | 297 ----------------------------- engines/sci/engine/vm.cpp | 4 +- engines/sci/engine/vm.h | 4 +- engines/sci/gfx/gfx_widgets.cpp | 12 +- engines/sci/gfx/gfx_widgets.h | 2 +- 8 files changed, 248 insertions(+), 313 deletions(-) diff --git a/engines/sci/console.cpp b/engines/sci/console.cpp index 685d0fbb91f..26ff08d065a 100644 --- a/engines/sci/console.cpp +++ b/engines/sci/console.cpp @@ -63,6 +63,7 @@ Console::Console(SciEngine *vm) : GUI::Debugger() { 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); + DVar_Register("script_abort_flag", &script_abort_flag, DVAR_INT, 0); // General DCmd_Register("help", WRAP_METHOD(Console, cmdHelp)); @@ -115,6 +116,9 @@ Console::Console(SciEngine *vm) : GUI::Debugger() { DCmd_Register("dynamic_views", WRAP_METHOD(Console, cmdDynamicViews)); DCmd_Register("dropped_views", WRAP_METHOD(Console, cmdDroppedViews)); DCmd_Register("status_bar", WRAP_METHOD(Console, cmdStatusBarColors)); +#ifdef GFXW_DEBUG_WIDGETS + DCmd_Register("print_widget", WRAP_METHOD(Console, cmdPrintWidget)); +#endif // Segments DCmd_Register("segment_table", WRAP_METHOD(Console, cmdPrintSegmentTable)); DCmd_Register("segment_info", WRAP_METHOD(Console, cmdSegmentInfo)); @@ -182,6 +186,14 @@ void Console::postEnter() { _vm->_mixer->pauseAll(false); } + +#if 0 +// Unused +#define LOOKUP_SPECIES(species) (\ + (species >= 1000) ? species : *(s->_classtable[species].scriptposp) \ + + s->_classtable[species].class_offset) +#endif + bool Console::cmdHelp(int argc, const char **argv) { DebugPrintf("\n"); DebugPrintf("Variables\n"); @@ -191,6 +203,7 @@ bool Console::cmdHelp(int argc, const char **argv) { DebugPrintf("simulated_key: Add a key with the specified scan code to the event list\n"); DebugPrintf("track_mouse_clicks: Toggles mouse click tracking to the console\n"); DebugPrintf("weak_validations: Turns some validation errors into warnings\n"); + DebugPrintf("script_abort_flag: Set to 1 to abort script execution. Set to 2 to force a replay afterwards\n"); DebugPrintf("\n"); DebugPrintf("Commands\n"); DebugPrintf("--------\n"); @@ -248,6 +261,9 @@ bool Console::cmdHelp(int argc, const char **argv) { DebugPrintf(" dynamic_views - Lists active dynamic views\n"); DebugPrintf(" dropped_views - Lists dropped dynamic views\n"); DebugPrintf(" status_bar - Sets the colors of the status bar\n"); +#ifdef GFXW_DEBUG_WIDGETS + DebugPrintf(" print_widget - Shows active widgets (no params) or information on the specified widget indices\n"); +#endif DebugPrintf("\n"); DebugPrintf("Segments:\n"); DebugPrintf(" segment_table - Lists all segments\n"); @@ -667,7 +683,7 @@ bool Console::cmdRestoreGame(int argc, const char **argv) { if (newstate) { g_EngineState->successor = newstate; // Set successor - script_abort_flag = SCRIPT_ABORT_WITH_REPLAY; // Abort current game + script_abort_flag = 2; // Abort current game with replay g_debugstate_valid = 0; shrink_execution_stack(g_EngineState, g_EngineState->execution_stack_base + 1); @@ -2678,4 +2694,225 @@ int printObject(EngineState *s, reg_t pos) { return 0; } +#define GETRECT(ll, rr, tt, bb) \ + ll = GET_SELECTOR(pos, ll); \ + rr = GET_SELECTOR(pos, rr); \ + tt = GET_SELECTOR(pos, tt); \ + bb = GET_SELECTOR(pos, bb); + +#if 0 +// TODO Re-implement this +static void viewobjinfo(EngineState *s, HeapPtr pos) { + char *signals[16] = { + "stop_update", + "updated", + "no_update", + "hidden", + "fixed_priority", + "always_update", + "force_update", + "remove", + "frozen", + "is_extra", + "hit_obstacle", + "doesnt_turn", + "no_cycler", + "ignore_horizon", + "ignore_actor", + "dispose!" + }; + + int x, y, z, priority; + int cel, loop, view, signal; + int nsLeft, nsRight, nsBottom, nsTop; + int lsLeft, lsRight, lsBottom, lsTop; + int brLeft, brRight, brBottom, brTop; + int i; + int have_rects = 0; + Common::Rect nsrect, nsrect_clipped, brrect; + + if (lookup_selector(s, pos, s->_kernel->_selectorMap.nsBottom, NULL) == kSelectorVariable) { + GETRECT(nsLeft, nsRight, nsBottom, nsTop); + GETRECT(lsLeft, lsRight, lsBottom, lsTop); + GETRECT(brLeft, brRight, brBottom, brTop); + have_rects = 1; + } + + GETRECT(view, loop, signal, cel); + + sciprintf("\n-- View information:\ncel %d/%d/%d at ", view, loop, cel); + + x = GET_SELECTOR(pos, x); + y = GET_SELECTOR(pos, y); + priority = GET_SELECTOR(pos, priority); + if (s->_kernel->_selectorMap.z > 0) { + z = GET_SELECTOR(pos, z); + sciprintf("(%d,%d,%d)\n", x, y, z); + } else + sciprintf("(%d,%d)\n", x, y); + + if (priority == -1) + sciprintf("No priority.\n\n"); + else + sciprintf("Priority = %d (band starts at %d)\n\n", priority, PRIORITY_BAND_FIRST(priority)); + + if (have_rects) { + sciprintf("nsRect: [%d..%d]x[%d..%d]\n", nsLeft, nsRight, nsTop, nsBottom); + sciprintf("lsRect: [%d..%d]x[%d..%d]\n", lsLeft, lsRight, lsTop, lsBottom); + sciprintf("brRect: [%d..%d]x[%d..%d]\n", brLeft, brRight, brTop, brBottom); + } + + nsrect = get_nsrect(s, pos, 0); + nsrect_clipped = get_nsrect(s, pos, 1); + brrect = set_base(s, pos); + sciprintf("new nsRect: [%d..%d]x[%d..%d]\n", nsrect.x, nsrect.xend, nsrect.y, nsrect.yend); + sciprintf("new clipped nsRect: [%d..%d]x[%d..%d]\n", nsrect_clipped.x, nsrect_clipped.xend, nsrect_clipped.y, nsrect_clipped.yend); + sciprintf("new brRect: [%d..%d]x[%d..%d]\n", brrect.x, brrect.xend, brrect.y, brrect.yend); + sciprintf("\n signals = %04x:\n", signal); + + for (i = 0; i < 16; i++) + if (signal & (1 << i)) + sciprintf(" %04x: %s\n", 1 << i, signals[i]); +} +#endif +#undef GETRECT + +#define GETRECT(ll, rr, tt, bb) \ + ll = GET_SELECTOR(pos, ll); \ + rr = GET_SELECTOR(pos, rr); \ + tt = GET_SELECTOR(pos, tt); \ + bb = GET_SELECTOR(pos, bb); + +#if 0 +// Draws the nsRect and brRect of a dynview object. nsRect is green, brRect is blue. +// TODO: Re-implement this +static int c_gfx_draw_viewobj(EngineState *s, const Common::Array &cmdParams) { + HeapPtr pos = (HeapPtr)(cmdParams[0].val); + int is_view; + int x, y, priority; + int nsLeft, nsRight, nsBottom, nsTop; + int brLeft, brRight, brBottom, brTop; + + if (!s) { + sciprintf("Not in debug state!\n"); + return 1; + } + + if ((pos < 4) || (pos > 0xfff0)) { + sciprintf("Invalid address.\n"); + return 1; + } + + if (((int16)READ_LE_UINT16(s->heap + pos + SCRIPT_OBJECT_MAGIC_OFFSET)) != SCRIPT_OBJECT_MAGIC_NUMBER) { + sciprintf("Not an object.\n"); + return 0; + } + + + is_view = (lookup_selector(s, pos, s->_kernel->_selectorMap.x, NULL) == kSelectorVariable) && + (lookup_selector(s, pos, s->_kernel->_selectorMap.brLeft, NULL) == kSelectorVariable) && + (lookup_selector(s, pos, s->_kernel->_selectorMap.signal, NULL) == kSelectorVariable) && + (lookup_selector(s, pos, s->_kernel->_selectorMap.nsTop, NULL) == kSelectorVariable); + + if (!is_view) { + sciprintf("Not a dynamic View object.\n"); + return 0; + } + + x = GET_SELECTOR(pos, x); + y = GET_SELECTOR(pos, y); + priority = GET_SELECTOR(pos, priority); + GETRECT(brLeft, brRight, brBottom, brTop); + GETRECT(nsLeft, nsRight, nsBottom, nsTop); + gfxop_set_clip_zone(s->gfx_state, gfx_rect_fullscreen); + + brTop += 10; + brBottom += 10; + nsTop += 10; + nsBottom += 10; + + gfxop_fill_box(s->gfx_state, gfx_rect(nsLeft, nsTop, nsRight - nsLeft + 1, nsBottom - nsTop + 1), s->ega_colors[2]); + gfxop_fill_box(s->gfx_state, gfx_rect(brLeft, brTop, brRight - brLeft + 1, brBottom - brTop + 1), s->ega_colors[1]); + gfxop_fill_box(s->gfx_state, gfx_rect(x - 1, y - 1, 3, 3), s->ega_colors[0]); + gfxop_fill_box(s->gfx_state, gfx_rect(x - 1, y, 3, 1), s->ega_colors[priority]); + gfxop_fill_box(s->gfx_state, gfx_rect(x, y - 1, 1, 3), s->ega_colors[priority]); + gfxop_update(s->gfx_state); + + return 0; +} +#endif +#undef GETRECT + +#if 0 +// Executes one operation skipping over sends +// TODO Re-implement this +int c_stepover(EngineState *s, const Common::Array &cmdParams) { + int opcode, opnumber; + + if (!g_debugstate_valid) { + sciprintf("Not in debug state\n"); + return 1; + } + + 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 */) { + 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 + s_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; + break; + + case 0x45: // callb B + case 0x57: // super B + case 0x4A: // send W + case 0x54: // self W + s_debug_seek_special = *p_pc + 3; + break; + + default: + s_debug_seek_special = *p_pc + 2; + } + } + + return 0; +} +#endif + +#ifdef GFXW_DEBUG_WIDGETS +extern GfxWidget *debug_widgets[]; +extern int debug_widget_pos; + +// If called with no parameters, it shows which widgets are active +// With parameters, it lists the widget corresponding to the numerical index specified (for each parameter). +bool Console::cmdPrintWidget(int argc, const char **argv) { + if (argc > 1) { + for (int i = 0; i < argc; i++) { + int widget_nr = atoi(argv[1]); + + DebugPrintf("===== Widget #%d:\n", widget_nr); + debug_widgets[widget_nr]->print(0); + } + } else if (debug_widget_pos > 1) { + DebugPrintf("Widgets 0-%d are active\n", debug_widget_pos - 1); + } else if (debug_widget_pos == 1) { + DebugPrintf("Widget 0 is active\n"); + } else { + DebugPrintf("No widgets are active\n"); + } + + return true; +} +#endif + } // End of namespace Sci diff --git a/engines/sci/console.h b/engines/sci/console.h index b97b14f354d..b2e66daa0f9 100644 --- a/engines/sci/console.h +++ b/engines/sci/console.h @@ -98,6 +98,7 @@ private: bool cmdDynamicViews(int argc, const char **argv); bool cmdDroppedViews(int argc, const char **argv); bool cmdStatusBarColors(int argc, const char **argv); + bool cmdPrintWidget(int argc, const char **argv); // Segments bool cmdPrintSegmentTable(int argc, const char **argv); bool cmdSegmentInfo(int argc, const char **argv); diff --git a/engines/sci/engine/kfile.cpp b/engines/sci/engine/kfile.cpp index 11d1cb457e5..87ddb46e50e 100644 --- a/engines/sci/engine/kfile.cpp +++ b/engines/sci/engine/kfile.cpp @@ -654,7 +654,7 @@ reg_t kRestoreGame(EngineState *s, int funct_nr, int argc, reg_t *argv) { if (newstate) { s->successor = newstate; - script_abort_flag = SCRIPT_ABORT_WITH_REPLAY; // Abort current game + script_abort_flag = 2; // Abort current game with replay shrink_execution_stack(s, s->execution_stack_base + 1); } else { s->r_acc = make_reg(0, 1); diff --git a/engines/sci/engine/scriptdebug.cpp b/engines/sci/engine/scriptdebug.cpp index 4581c0a37c6..26ba01b4400 100644 --- a/engines/sci/engine/scriptdebug.cpp +++ b/engines/sci/engine/scriptdebug.cpp @@ -53,7 +53,6 @@ static bool s_debug_commands_hooked = false; // Commands hooked to the console y 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 @@ -92,35 +91,12 @@ struct cmd_command_t : public cmd_mm_entry_t { const char *param; }; -#if 0 -// Unused -#define LOOKUP_SPECIES(species) (\ - (species >= 1000) ? species : *(s->_classtable[species].scriptposp) \ - + s->_classtable[species].class_offset) -#endif - // Dummy function, so that it compiles int con_hook_command(ConCommand command, const char *name, const char *param, const char *description) { return 0; } -static const char *_debug_get_input() { - char newinpbuf[256]; - - printf("> "); - if (!fgets(newinpbuf, 254, stdin)) - return NULL; - - size_t l = strlen(newinpbuf); - if (l > 0 && newinpbuf[0] != '\n') { - if (newinpbuf[l-1] == '\n') newinpbuf[l-1] = 0; - memcpy(inputbuf, newinpbuf, 256); - } - - return inputbuf; -} - int c_step(EngineState *s, const Common::Array &cmdParams) { g_debugstate_valid = 0; if (cmdParams.size() && (cmdParams[0].val > 0)) @@ -129,51 +105,6 @@ int c_step(EngineState *s, const Common::Array &cmdParams) { return 0; } -#if 0 -// TODO Re-implement con:so -int c_stepover(EngineState *s, const Common::Array &cmdParams) { - int opcode, opnumber; - - if (!g_debugstate_valid) { - sciprintf("Not in debug state\n"); - return 1; - } - - 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 */) { - 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 - s_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; - break; - - case 0x45: // callb B - case 0x57: // super B - case 0x4A: // send W - case 0x54: // self W - s_debug_seek_special = *p_pc + 3; - break; - - default: - s_debug_seek_special = *p_pc + 2; - } - } - - return 0; -} -#endif - enum { _parse_eoi, _parse_token_pareno, @@ -536,103 +467,6 @@ reg_t disassemble(EngineState *s, reg_t pos, int print_bw_tag, int print_bytecod return retval; } -#ifdef GFXW_DEBUG_WIDGETS -extern GfxWidget *debug_widgets[]; -extern int debug_widget_pos; - -static int c_gfx_print_widget(EngineState *s, const Common::Array &cmdParams) { - if (!g_debugstate_valid) { - sciprintf("Not in debug state\n"); - return 1; - } - - if (cmdParams.size()) { - unsigned int i; - for (i = 0; i < cmdParams.size() ; i++) { - int widget_nr = cmdParams[i].val; - - sciprintf("===== Widget #%d:\n", widget_nr); - debug_widgets[widget_nr]->print(0); - } - - } else if (debug_widget_pos > 1) - sciprintf("Widgets 0-%d are active\n", debug_widget_pos - 1); - else if (debug_widget_pos == 1) - sciprintf("Widget 0 is active\n"); - else - sciprintf("No widgets are active\n"); - - return 0; -} -#endif - -#define GETRECT(ll, rr, tt, bb) \ - ll = GET_SELECTOR(pos, ll); \ - rr = GET_SELECTOR(pos, rr); \ - tt = GET_SELECTOR(pos, tt); \ - bb = GET_SELECTOR(pos, bb); - -#if 0 -// Unreferenced - removed -static int c_gfx_draw_viewobj(EngineState *s, const Common::Array &cmdParams) { -// TODO: Re-implement gfx_draw_viewobj -#if 0 - HeapPtr pos = (HeapPtr)(cmdParams[0].val); - int is_view; - int x, y, priority; - int nsLeft, nsRight, nsBottom, nsTop; - int brLeft, brRight, brBottom, brTop; - - if (!s) { - sciprintf("Not in debug state!\n"); - return 1; - } - - if ((pos < 4) || (pos > 0xfff0)) { - sciprintf("Invalid address.\n"); - return 1; - } - - if (((int16)READ_LE_UINT16(s->heap + pos + SCRIPT_OBJECT_MAGIC_OFFSET)) != SCRIPT_OBJECT_MAGIC_NUMBER) { - sciprintf("Not an object.\n"); - return 0; - } - - - is_view = (lookup_selector(s, pos, s->_kernel->_selectorMap.x, NULL) == kSelectorVariable) && - (lookup_selector(s, pos, s->_kernel->_selectorMap.brLeft, NULL) == kSelectorVariable) && - (lookup_selector(s, pos, s->_kernel->_selectorMap.signal, NULL) == kSelectorVariable) && - (lookup_selector(s, pos, s->_kernel->_selectorMap.nsTop, NULL) == kSelectorVariable); - - if (!is_view) { - sciprintf("Not a dynamic View object.\n"); - return 0; - } - - x = GET_SELECTOR(pos, x); - y = GET_SELECTOR(pos, y); - priority = GET_SELECTOR(pos, priority); - GETRECT(brLeft, brRight, brBottom, brTop); - GETRECT(nsLeft, nsRight, nsBottom, nsTop); - gfxop_set_clip_zone(s->gfx_state, gfx_rect_fullscreen); - - brTop += 10; - brBottom += 10; - nsTop += 10; - nsBottom += 10; - - gfxop_fill_box(s->gfx_state, gfx_rect(nsLeft, nsTop, nsRight - nsLeft + 1, nsBottom - nsTop + 1), s->ega_colors[2]); - gfxop_fill_box(s->gfx_state, gfx_rect(brLeft, brTop, brRight - brLeft + 1, brBottom - brTop + 1), s->ega_colors[1]); - gfxop_fill_box(s->gfx_state, gfx_rect(x - 1, y - 1, 3, 3), s->ega_colors[0]); - gfxop_fill_box(s->gfx_state, gfx_rect(x - 1, y, 3, 1), s->ega_colors[priority]); - gfxop_fill_box(s->gfx_state, gfx_rect(x, y - 1, 1, 3), s->ega_colors[priority]); - gfxop_update(s->gfx_state); - - return 0; -#endif -} -#endif - static int c_disasm_addr(EngineState *s, const Common::Array &cmdParams) { reg_t vpc = cmdParams[0].reg; int op_count = 1; @@ -811,92 +645,6 @@ static int c_send(EngineState *s, const Common::Array &cmdParams) { return 0; } - -#define GETRECT(ll, rr, tt, bb) \ - ll = GET_SELECTOR(pos, ll); \ - rr = GET_SELECTOR(pos, rr); \ - tt = GET_SELECTOR(pos, tt); \ - bb = GET_SELECTOR(pos, bb); - -#if 0 -#ifdef __GNUC__ -#warning "Re-implement viewobjinfo" -#endif -static void viewobjinfo(EngineState *s, HeapPtr pos) { - char *signals[16] = { - "stop_update", - "updated", - "no_update", - "hidden", - "fixed_priority", - "always_update", - "force_update", - "remove", - "frozen", - "is_extra", - "hit_obstacle", - "doesnt_turn", - "no_cycler", - "ignore_horizon", - "ignore_actor", - "dispose!" - }; - - int x, y, z, priority; - int cel, loop, view, signal; - int nsLeft, nsRight, nsBottom, nsTop; - int lsLeft, lsRight, lsBottom, lsTop; - int brLeft, brRight, brBottom, brTop; - int i; - int have_rects = 0; - Common::Rect nsrect, nsrect_clipped, brrect; - - if (lookup_selector(s, pos, s->_kernel->_selectorMap.nsBottom, NULL) == kSelectorVariable) { - GETRECT(nsLeft, nsRight, nsBottom, nsTop); - GETRECT(lsLeft, lsRight, lsBottom, lsTop); - GETRECT(brLeft, brRight, brBottom, brTop); - have_rects = 1; - } - - GETRECT(view, loop, signal, cel); - - sciprintf("\n-- View information:\ncel %d/%d/%d at ", view, loop, cel); - - x = GET_SELECTOR(pos, x); - y = GET_SELECTOR(pos, y); - priority = GET_SELECTOR(pos, priority); - if (s->_kernel->_selectorMap.z > 0) { - z = GET_SELECTOR(pos, z); - sciprintf("(%d,%d,%d)\n", x, y, z); - } else - sciprintf("(%d,%d)\n", x, y); - - if (priority == -1) - sciprintf("No priority.\n\n"); - else - sciprintf("Priority = %d (band starts at %d)\n\n", priority, PRIORITY_BAND_FIRST(priority)); - - if (have_rects) { - sciprintf("nsRect: [%d..%d]x[%d..%d]\n", nsLeft, nsRight, nsTop, nsBottom); - sciprintf("lsRect: [%d..%d]x[%d..%d]\n", lsLeft, lsRight, lsTop, lsBottom); - sciprintf("brRect: [%d..%d]x[%d..%d]\n", brLeft, brRight, brTop, brBottom); - } - - nsrect = get_nsrect(s, pos, 0); - nsrect_clipped = get_nsrect(s, pos, 1); - brrect = set_base(s, pos); - sciprintf("new nsRect: [%d..%d]x[%d..%d]\n", nsrect.x, nsrect.xend, nsrect.y, nsrect.yend); - sciprintf("new clipped nsRect: [%d..%d]x[%d..%d]\n", nsrect_clipped.x, nsrect_clipped.xend, nsrect_clipped.y, nsrect_clipped.yend); - sciprintf("new brRect: [%d..%d]x[%d..%d]\n", brrect.x, brrect.xend, brrect.y, brrect.yend); - sciprintf("\n signals = %04x:\n", signal); - - for (i = 0; i < 16; i++) - if (signal & (1 << i)) - sciprintf(" %04x: %s\n", 1 << i, signals[i]); -} -#endif -#undef GETRECT - // Breakpoint commands int c_se(EngineState *s, const Common::Array &cmdParams) { @@ -959,13 +707,7 @@ void script_debug(EngineState *s, reg_t *pc, StackPtr *sp, StackPtr *pp, reg_t * break; } - case _DEBUG_SEEK_SO: - if ((*pc != s_debug_seek_reg) || (int)s->_executionStack.size()-1 != s_debug_seek_level) - return; - break; - case _DEBUG_SEEK_GLOBAL: - if (op < op_sag) return; if ((op & 0x3) > 1) @@ -1004,10 +746,6 @@ void script_debug(EngineState *s, reg_t *pc, StackPtr *sp, StackPtr *pp, reg_t * 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"); -#if 0 - // TODO Re-implement con:so - con_hook_command(c_stepover, "so", "", "Executes one operation skipping over sends"); -#endif con_hook_command(c_disasm_addr, "disasm-addr", "!as*", "Disassembles one or more commands\n\n" "USAGE\n\n disasm-addr [startaddr] \n\n" " Valid options are:\n" @@ -1023,50 +761,15 @@ void script_debug(EngineState *s, reg_t *pc, StackPtr *sp, StackPtr *pp, reg_t * 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."); - -#ifdef GFXW_DEBUG_WIDGETS - con_hook_command(c_gfx_print_widget, "gfx_print_widget", "i*", "If called with no parameters, it\n shows which widgets are active.\n" - " With parameters, it lists the\n widget corresponding to the\n numerical index specified (for\n each parameter)."); -#endif - -#if 0 - // TODO: Re-enable con:draw_viewobj - con_hook_command(c_gfx_draw_viewobj, "draw_viewobj", "i", "Draws the nsRect and brRect of a\n dynview object.\n\n nsRect is green, brRect\n" - " is blue.\n"); -#endif 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"); -/* - con_hook_int(&script_abort_flag, "script_abort_flag", "Set != 0 to abort execution\n"); -*/ } // If commands were not hooked up } if (g_debug_step_running) g_debug_step_running--; - - while (g_debugstate_valid) { - int skipfirst = 0; - const char *commandstring; - - // Suspend music playing - s->_sound.sfx_suspend(true); - - commandstring = _debug_get_input(); - - // Check if a specific destination has been given - if (commandstring && (commandstring[0] == '.' || commandstring[0] == ':')) - skipfirst = 1; - - //if (commandstring && commandstring[0] != ':') - // con_parse(s, commandstring + skipfirst); - sciprintf("\n"); - - // Resume music playing - s->_sound.sfx_suspend(false); - } } } // End of namespace Sci diff --git a/engines/sci/engine/vm.cpp b/engines/sci/engine/vm.cpp index fe9523197e2..fd8ce33f519 100644 --- a/engines/sci/engine/vm.cpp +++ b/engines/sci/engine/vm.cpp @@ -46,7 +46,7 @@ reg_t NULL_REG = {0, 0}; #undef STRICT_READ // Disallows reading from out-of-bounds parameters and locals -int script_abort_flag = 0; // Set to 1 to abort execution // FIXME: Avoid non-const global vars +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 @@ -1978,7 +1978,7 @@ static EngineState *_game_run(EngineState *s, int restoring) { s = successor; g_EngineState = s; - if (script_abort_flag == SCRIPT_ABORT_WITH_REPLAY) { + if (script_abort_flag == 2) { sciprintf("Restarting with replay()\n"); s->_executionStack.clear(); // Restart with replay diff --git a/engines/sci/engine/vm.h b/engines/sci/engine/vm.h index f8e11b9b883..5bfbe71ce9c 100644 --- a/engines/sci/engine/vm.h +++ b/engines/sci/engine/vm.h @@ -272,12 +272,10 @@ struct Breakpoint { Breakpoint *next; }; -#define SCRIPT_ABORT_WITH_REPLAY 1025 - /** * Set this to 1 to abort script execution immediately. Aborting will leave the * debug exec stack intact. - * Set it to SCRIPT_ABORT_WITH_REPLAY to force a replay afterwards. + * Set it to 2 to force a replay afterwards. */ extern int script_abort_flag; diff --git a/engines/sci/gfx/gfx_widgets.cpp b/engines/sci/gfx/gfx_widgets.cpp index ad9464811e6..e17ffae6f12 100644 --- a/engines/sci/gfx/gfx_widgets.cpp +++ b/engines/sci/gfx/gfx_widgets.cpp @@ -49,10 +49,8 @@ GfxWidget *debug_widgets[GFXW_DEBUG_WIDGETS]; int debug_widget_pos = 0; static void _gfxw_debug_add_widget(GfxWidget *widget) { - if (debug_widget_pos == GFXW_DEBUG_WIDGETS) { - GFXERROR("WIDGET DEBUG: Allocated the maximum number of %d widgets- Aborting!\n", GFXW_DEBUG_WIDGETS); - BREAKPOINT(); - } + if (debug_widget_pos == GFXW_DEBUG_WIDGETS) + error("WIDGET DEBUG: Allocated the maximum number of %d widgets- Aborting!\n", GFXW_DEBUG_WIDGETS); debug_widgets[debug_widget_pos++] = widget; } @@ -68,13 +66,11 @@ static void _gfxw_debug_remove_widget(GfxWidget *widget) { } if (found > 1) { - GFXERROR("While removing widget: Found it %d times!\n", found); - BREAKPOINT(); + error("While removing widget: Found it %d times!\n", found); } if (found == 0) { - GFXERROR("Attempted removal of unregistered widget!\n"); - BREAKPOINT(); + error("Attempted removal of unregistered widget!\n"); } } #else // !GFXW_DEBUG_WIDGETS diff --git a/engines/sci/gfx/gfx_widgets.h b/engines/sci/gfx/gfx_widgets.h index 5b43c2cad67..6c8e8486649 100644 --- a/engines/sci/gfx/gfx_widgets.h +++ b/engines/sci/gfx/gfx_widgets.h @@ -51,7 +51,7 @@ struct GfxWidget; /* Enable the next line to keep a list of pointers to all widgets, with up to the specified amount ** of members (/SLOW/) */ -/* #define GFXW_DEBUG_WIDGETS 2048 */ +//#define GFXW_DEBUG_WIDGETS 2048 /* Our strategy for dirty rectangle management */ #define GFXW_DIRTY_STRATEGY GFXOP_DIRTY_FRAMES_CLUSTERS