diff options
author | Filippos Karapetis | 2009-05-30 20:01:43 +0000 |
---|---|---|
committer | Filippos Karapetis | 2009-05-30 20:01:43 +0000 |
commit | 329b93acc8cad97cf5c8c252afac820ae9f69db8 (patch) | |
tree | fdbe64f1614afec6f172cd80c0dcb9700049ae1b /engines | |
parent | 598feb771fffcdbe94feebe8889162e668e41fcc (diff) | |
download | scummvm-rg350-329b93acc8cad97cf5c8c252afac820ae9f69db8.tar.gz scummvm-rg350-329b93acc8cad97cf5c8c252afac820ae9f69db8.tar.bz2 scummvm-rg350-329b93acc8cad97cf5c8c252afac820ae9f69db8.zip |
Moved 4 mode commands to console.cpp: "sentence_fragments", "parser_nodes", "status_bar" and "track_mouse"
svn-id: r41043
Diffstat (limited to 'engines')
-rw-r--r-- | engines/sci/console.cpp | 110 | ||||
-rw-r--r-- | engines/sci/console.h | 4 | ||||
-rw-r--r-- | engines/sci/engine/kevent.cpp | 11 | ||||
-rw-r--r-- | engines/sci/engine/scriptdebug.cpp | 164 |
4 files changed, 122 insertions, 167 deletions
diff --git a/engines/sci/console.cpp b/engines/sci/console.cpp index 48a898c485..cda003f7ab 100644 --- a/engines/sci/console.cpp +++ b/engines/sci/console.cpp @@ -32,6 +32,7 @@ #include "sci/engine/savegame.h" #include "sci/engine/state.h" #include "sci/engine/gc.h" +#include "sci/gfx/gfx_gui.h" // for sciw_set_status_bar #include "sci/gfx/gfx_state_internal.h" #include "sci/gfx/gfx_widgets.h" // for gfxw_find_port #include "sci/vocabulary.h" @@ -43,6 +44,7 @@ namespace Sci { extern EngineState *g_EngineState; int _kdebug_cheap_event_hack = 0; +bool _kdebug_track_mouse_clicks = false; Console::Console(SciEngine *vm) : GUI::Debugger() { _vm = vm; @@ -68,6 +70,8 @@ Console::Console(SciEngine *vm) : GUI::Debugger() { DCmd_Register("restore_game", WRAP_METHOD(Console, cmdRestoreGame)); DCmd_Register("restart_game", WRAP_METHOD(Console, cmdRestartGame)); DCmd_Register("class_table", WRAP_METHOD(Console, cmdClassTable)); + DCmd_Register("sentence_fragments", WRAP_METHOD(Console, cmdSentenceFragments)); + DCmd_Register("parser_nodes", WRAP_METHOD(Console, cmdParserNodes)); DCmd_Register("parser_words", WRAP_METHOD(Console, cmdParserWords)); DCmd_Register("draw_pic", WRAP_METHOD(Console, cmdDrawPic)); DCmd_Register("draw_rect", WRAP_METHOD(Console, cmdDrawRect)); @@ -78,7 +82,9 @@ Console::Console(SciEngine *vm) : GUI::Debugger() { DCmd_Register("visual_state", WRAP_METHOD(Console, cmdVisualState)); DCmd_Register("dynamic_views", WRAP_METHOD(Console, cmdDynamicViews)); DCmd_Register("dropped_views", WRAP_METHOD(Console, cmdDroppedViews)); + DCmd_Register("status_bar", WRAP_METHOD(Console, cmdStatusBarColors)); DCmd_Register("simkey", WRAP_METHOD(Console, cmdSimulateKey)); + DCmd_Register("track_mouse", WRAP_METHOD(Console, cmdTrackMouse)); DCmd_Register("segment_table", WRAP_METHOD(Console, cmdPrintSegmentTable)); DCmd_Register("segment_info", WRAP_METHOD(Console, cmdSegmentInfo)); DCmd_Register("segment_kill", WRAP_METHOD(Console, cmdKillSegment)); @@ -553,6 +559,70 @@ bool Console::cmdClassTable(int argc, const char **argv) { return true; } +bool Console::cmdSentenceFragments(int argc, const char **argv) { + DebugPrintf("Sentence fragments (used to build Parse trees\n"); + + for (uint i = 0; i < g_EngineState->_parserBranches.size(); i++) { + int j = 0; + + DebugPrintf("R%02d: [%x] ->", i, g_EngineState->_parserBranches[i].id); + while ((j < 10) && g_EngineState->_parserBranches[i].data[j]) { + int dat = g_EngineState->_parserBranches[i].data[j++]; + + switch (dat) { + case VOCAB_TREE_NODE_COMPARE_TYPE: + dat = g_EngineState->_parserBranches[i].data[j++]; + DebugPrintf(" C(%x)", dat); + break; + + case VOCAB_TREE_NODE_COMPARE_GROUP: + dat = g_EngineState->_parserBranches[i].data[j++]; + DebugPrintf(" WG(%x)", dat); + break; + + case VOCAB_TREE_NODE_FORCE_STORAGE: + dat = g_EngineState->_parserBranches[i].data[j++]; + DebugPrintf(" FORCE(%x)", dat); + break; + + default: + if (dat > VOCAB_TREE_NODE_LAST_WORD_STORAGE) { + int dat2 = g_EngineState->_parserBranches[i].data[j++]; + DebugPrintf(" %x[%x]", dat, dat2); + } else + DebugPrintf(" ?%x?", dat); + } + } + DebugPrintf("\n"); + } + + DebugPrintf("%d rules.\n", g_EngineState->_parserBranches.size()); + + return true; +} + +bool Console::cmdParserNodes(int argc, const char **argv) { + if (argc != 2) { + DebugPrintf("Shows the specified number of nodes from the parse node tree\n"); + DebugPrintf("Usage: %s <nr>\n", argv[0]); + DebugPrintf("where <nr> is the number of nodes to show from the parse node tree\n"); + return true; + } + + int end = MIN<int>(atoi(argv[1]), VOCAB_TREE_NODES); + + for (int i = 0; i < end; i++) { + DebugPrintf(" Node %03x: ", i); + if (g_EngineState->parser_nodes[i].type == PARSE_TREE_NODE_LEAF) + DebugPrintf("Leaf: %04x\n", g_EngineState->parser_nodes[i].content.value); + else + DebugPrintf("Branch: ->%04x, ->%04x\n", g_EngineState->parser_nodes[i].content.branches[0], + g_EngineState->parser_nodes[i].content.branches[1]); + } + + return true; +} + bool Console::cmdParserWords(int argc, const char **argv) { if (g_EngineState->_parserWords.empty()) { DebugPrintf("No words.\n"); @@ -710,6 +780,26 @@ bool Console::cmdDroppedViews(int argc, const char **argv) { return true; } +bool Console::cmdStatusBarColors(int argc, const char **argv) { + if (argc != 3) { + DebugPrintf("Sets the colors of the status bar\n"); + DebugPrintf("Usage: %s <foreground color> <background color>\n", argv[0]); + return true; + } + + g_EngineState->titlebar_port->_color = g_EngineState->ega_colors[atoi(argv[1])]; + g_EngineState->titlebar_port->_bgcolor = g_EngineState->ega_colors[atoi(argv[2])]; + + g_EngineState->status_bar_foreground = atoi(argv[1]); + g_EngineState->status_bar_background = atoi(argv[2]); + + sciw_set_status_bar(g_EngineState, g_EngineState->titlebar_port, g_EngineState->_statusBarText, + g_EngineState->status_bar_foreground, g_EngineState->status_bar_background); + gfxop_update(g_EngineState->gfx_state); + + return false; +} + bool Console::cmdSimulateKey(int argc, const char **argv) { if (argc != 2) { DebugPrintf("Simulate a keypress with the specified scancode\n"); @@ -722,6 +812,26 @@ bool Console::cmdSimulateKey(int argc, const char **argv) { return true; } +bool Console::cmdTrackMouse(int argc, const char **argv) { + if (argc != 2) { + DebugPrintf("Toggles mouse position tracking\n"); + DebugPrintf("Usage: %s <on/off>\n", argv[0]); + DebugPrintf("If switched on, left mouse clicks will print\n"); + DebugPrintf("the coordinates clicked in the debug console\n"); + return true; + } + + if (!scumm_stricmp(argv[1], "on")) { + _kdebug_track_mouse_clicks = true; + DebugPrintf("Mouse tracking turned on\n"); + } else if (!scumm_stricmp(argv[1], "off")) { + _kdebug_track_mouse_clicks = false; + DebugPrintf("Mouse tracking turned off\n"); + } + + return true; +} + bool Console::cmdPrintSegmentTable(int argc, const char **argv) { DebugPrintf("Segment table:\n"); diff --git a/engines/sci/console.h b/engines/sci/console.h index 7b85099fa3..b209d34fa6 100644 --- a/engines/sci/console.h +++ b/engines/sci/console.h @@ -61,6 +61,8 @@ private: bool cmdRestoreGame(int argc, const char **argv); bool cmdRestartGame(int argc, const char **argv); bool cmdClassTable(int argc, const char **argv); + bool cmdSentenceFragments(int argc, const char **argv); + bool cmdParserNodes(int argc, const char **argv); bool cmdParserWords(int argc, const char **argv); bool cmdDrawPic(int argc, const char **argv); bool cmdDrawRect(int argc, const char **argv); @@ -71,7 +73,9 @@ private: bool cmdVisualState(int argc, const char **argv); bool cmdDynamicViews(int argc, const char **argv); bool cmdDroppedViews(int argc, const char **argv); + bool cmdStatusBarColors(int argc, const char **argv); bool cmdSimulateKey(int argc, const char **argv); + bool cmdTrackMouse(int argc, const char **argv); bool cmdPrintSegmentTable(int argc, const char **argv); bool cmdSegmentInfo(int argc, const char **argv); bool cmdKillSegment(int argc, const char **argv); diff --git a/engines/sci/engine/kevent.cpp b/engines/sci/engine/kevent.cpp index 152f343679..a453bcfcdc 100644 --- a/engines/sci/engine/kevent.cpp +++ b/engines/sci/engine/kevent.cpp @@ -34,6 +34,7 @@ namespace Sci { int stop_on_event = 0; extern int _kdebug_cheap_event_hack; +extern bool _kdebug_track_mouse_clicks; #define SCI_VARIABLE_GAME_SPEED 3 @@ -45,10 +46,8 @@ reg_t kGetEvent(EngineState *s, int funct_nr, int argc, reg_t *argv) { int modifier_mask = s->version <= SCI_VERSION_0 ? SCI_EVM_ALL : SCI_EVM_NO_FOOLOCK; if (s->kernel_opt_flags & KERNEL_OPT_FLAG_GOT_2NDEVENT) { - // Penalty time- too many requests to this function without - // waiting! + // Penalty time- too many requests to this function without waiting! int delay = s->script_000->locals_block->_locals[SCI_VARIABLE_GAME_SPEED].offset; - gfxop_sleep(s->gfx_state, delay * 1000 / 60); } @@ -112,6 +111,12 @@ reg_t kGetEvent(EngineState *s, int funct_nr, int argc, reg_t *argv) { case SCI_EVT_MOUSE_PRESS: { int extra_bits = 0; + // track left buttton clicks, if requested + if (e.type == SCI_EVT_MOUSE_PRESS && e.data == 1 && _kdebug_track_mouse_clicks) { + ((SciEngine *)g_engine)->_console->DebugPrintf("Mouse clicked at %d, %d\n", + s->gfx_state->pointer_pos.x, s->gfx_state->pointer_pos.y); + } + if (mask & e.type) { switch (e.data) { case 2: diff --git a/engines/sci/engine/scriptdebug.cpp b/engines/sci/engine/scriptdebug.cpp index c7eda6e2c7..2550bac45b 100644 --- a/engines/sci/engine/scriptdebug.cpp +++ b/engines/sci/engine/scriptdebug.cpp @@ -443,18 +443,6 @@ static int c_vr(EngineState *s, const Common::Array<cmd_param_t> &cmdParams) { return 0; } -static int c_mousepos(EngineState *s, const Common::Array<cmd_param_t> &cmdParams) { - sci_event_t event; - - sciprintf("Click somewhere in the game window...\n"); - - while (event = gfxop_get_event(s->gfx_state, SCI_EVT_MOUSE_RELEASE), event.type != SCI_EVT_MOUSE_RELEASE) {}; - - sciprintf("Mouse pointer at (%d, %d)\n", s->gfx_state->pointer_pos.x, s->gfx_state->pointer_pos.y); - - return 0; -} - int c_debuginfo(EngineState *s) { if (!_debugstate_valid) { sciprintf("Not in debug state\n"); @@ -528,69 +516,6 @@ int c_stepover(EngineState *s, const Common::Array<cmd_param_t> &cmdParams) { } #endif -int c_sim_parse(EngineState *s, const Common::Array<cmd_param_t> &cmdParams) { - unsigned int i; - const char *operators = ",&/()[]#<>"; - - if (!_debugstate_valid) { - sciprintf("Not in debug state\n"); - return 1; - } - - if (cmdParams.size() == 0) { - s->parser_valid = 0; - return 0; - } - - for (i = 0; i < cmdParams.size(); i++) { - int flag = 0; - Common::String token = cmdParams[i].str; - - if (token.size() == 1) {// could be an operator - int j = 0; - while (operators[j] && (operators[j] != token[0])) - j++; - if (operators[j]) { - s->parser_nodes[i].type = 1; - s->parser_nodes[i].content.value = j + 0xf0; - flag = 1; // found an operator - } - } - - if (!flag) { - const char *openb = strchr(token.c_str(), '['); // look for opening braces - ResultWord result; - - if (openb) - token = Common::String(token.begin(), openb); // remove them and the rest - - result = vocab_lookup_word(token.c_str(), token.size(), s->_parserWords, s->_parserSuffixes); - - if (result._class != -1) { - s->parser_nodes[i].type = 0; - s->parser_nodes[i].content.value = result._group; - } else { // group name was specified directly? - int val = strtol(token.c_str(), NULL, 0); - if (val) { - s->parser_nodes[i].type = 0; - s->parser_nodes[i].content.value = val; - } else { // invalid and not matched - sciprintf("Couldn't interpret '%s'\n", token.c_str()); - s->parser_valid = 0; - return 1; - } - } - } - - } - - s->parser_nodes[cmdParams.size()].type = -1; // terminate - - s->parser_valid = 2; - - return 0; -} - int c_viewinfo(EngineState *s, const Common::Array<cmd_param_t> &cmdParams) { int view = cmdParams[0].val; int palette = cmdParams[1].val; @@ -634,51 +559,6 @@ int c_viewinfo(EngineState *s, const Common::Array<cmd_param_t> &cmdParams) { return 0; } -int c_list_sentence_fragments(EngineState *s, const Common::Array<cmd_param_t> &cmdParams) { - if (!s) { - sciprintf("Not in debug state\n"); - return 1; - } - - for (uint i = 0; i < s->_parserBranches.size(); i++) { - int j = 0; - - sciprintf("R%02d: [%x] ->", i, s->_parserBranches[i].id); - while ((j < 10) && s->_parserBranches[i].data[j]) { - int dat = s->_parserBranches[i].data[j++]; - - switch (dat) { - case VOCAB_TREE_NODE_COMPARE_TYPE: - dat = s->_parserBranches[i].data[j++]; - sciprintf(" C(%x)", dat); - break; - - case VOCAB_TREE_NODE_COMPARE_GROUP: - dat = s->_parserBranches[i].data[j++]; - sciprintf(" WG(%x)", dat); - break; - - case VOCAB_TREE_NODE_FORCE_STORAGE: - dat = s->_parserBranches[i].data[j++]; - sciprintf(" FORCE(%x)", dat); - break; - - default: - if (dat > VOCAB_TREE_NODE_LAST_WORD_STORAGE) { - int dat2 = s->_parserBranches[i].data[j++]; - sciprintf(" %x[%x]", dat, dat2); - } else - sciprintf(" ?%x?", dat); - } - } - sciprintf("\n"); - } - - sciprintf("%d rules.\n", s->_parserBranches.size()); - - return 0; -} - enum { _parse_eoi, _parse_token_pareno, @@ -1110,27 +990,6 @@ reg_t disassemble(EngineState *s, reg_t pos, int print_bw_tag, int print_bytecod return retval; } -int c_dumpnodes(EngineState *s, const Common::Array<cmd_param_t> &cmdParams) { - int end = MIN<int>(cmdParams[0].val, VOCAB_TREE_NODES); - int i; - - if (!_debugstate_valid) { - sciprintf("Not in debug state\n"); - return 1; - } - - for (i = 0; i < end; i++) { - sciprintf(" Node %03x: ", i); - if (s->parser_nodes[i].type == PARSE_TREE_NODE_LEAF) - sciprintf("Leaf: %04x\n", s->parser_nodes[i].content.value); - else - sciprintf("Branch: ->%04x, ->%04x\n", s->parser_nodes[i].content.branches[0], - s->parser_nodes[i].content.branches[1]); - } - - return 0; -} - static const char *varnames[] = {"global", "local", "temp", "param"}; static const char *varabbrev = "gltp"; @@ -1998,24 +1857,6 @@ int c_type(EngineState *s, const Common::Array<cmd_param_t> &cmdParams) { return 0; } -int c_statusbar(EngineState *s, const Common::Array<cmd_param_t> &cmdParams) { - if (!s) { - sciprintf("Not in debug state\n"); - return 1; - } - - s->titlebar_port->_color = s->ega_colors[cmdParams[0].val]; - s->titlebar_port->_bgcolor = s->ega_colors[cmdParams[1].val]; - - s->status_bar_foreground = cmdParams[0].val; - s->status_bar_background = cmdParams[1].val; - - sciw_set_status_bar(s, s->titlebar_port, s->_statusBarText, s->status_bar_foreground, s->status_bar_background); - gfxop_update(s->gfx_state); - - return 0; -} - static void _print_address(void * _, reg_t addr) { if (addr.segment) sciprintf(" %04x:%04x\n", PRINT_REG(addr)); @@ -2199,7 +2040,6 @@ void script_debug(EngineState *s, reg_t *pc, StackPtr *sp, StackPtr *pp, reg_t * " splitting it up in resource type\n and resource number."); con_hook_command(c_visible_map, "set_vismap", "i", "Sets the visible map.\n Default is 0 (visual).\n" " Other useful values are:\n 1: Priority\n 2: Control\n 3: Auxiliary\n"); - con_hook_command(c_statusbar, "statusbar", "ii", "Sets the colors of the status bar. Also controllable from the script.\n"); con_hook_command(c_bpx, "bpx", "s", "Sets a breakpoint on the execution of\n the specified method.\n\n EXAMPLE:\n" " bpx ego::doit\n\n May also be used to set a breakpoint\n that applies whenever an object\n" " of a specific type is touched:\n bpx foo::\n"); @@ -2207,12 +2047,8 @@ void script_debug(EngineState *s, reg_t *pc, StackPtr *sp, StackPtr *pp, reg_t * con_hook_command(c_bplist, "bplist", "", "Lists all breakpoints.\n"); con_hook_command(c_bpdel, "bpdel", "i", "Deletes a breakpoint with specified index."); con_hook_command(c_go, "go", "", "Executes the script.\n"); - con_hook_command(c_dumpnodes, "dumpnodes", "i", "shows the specified number of nodes\nfrom the parse node tree"); - con_hook_command(c_mousepos, "mousepos", "", "Reveal the location of a mouse click.\n\n"); con_hook_command(c_viewinfo, "viewinfo", "ii", "Displays the number of loops\n and cels of each loop" " for the\n specified view resource and palette."); - con_hook_command(c_list_sentence_fragments, "list_sentence_fragments", "", "Lists all sentence fragments (which\n" - " are used to build Parse trees)."); con_hook_command(c_parse, "parse", "s", "Parses a sequence of words and prints\n the resulting parse tree.\n" " The word sequence must be provided as a\n single string."); con_hook_command(c_set_parse_nodes, "set_parse_nodes", "s*", "Sets the contents of all parse nodes.\n" |