aboutsummaryrefslogtreecommitdiff
path: root/engines/sci
diff options
context:
space:
mode:
authorFilippos Karapetis2009-05-30 13:36:51 +0000
committerFilippos Karapetis2009-05-30 13:36:51 +0000
commita21f34cf916e98f5d2ed558d79456a58ec9fa683 (patch)
tree49088d32a7d46c5235a08d15895188f4290ab7aa /engines/sci
parent4dcfaead8dbc4db1ada479066fa8c11f075154ab (diff)
downloadscummvm-rg350-a21f34cf916e98f5d2ed558d79456a58ec9fa683.tar.gz
scummvm-rg350-a21f34cf916e98f5d2ed558d79456a58ec9fa683.tar.bz2
scummvm-rg350-a21f34cf916e98f5d2ed558d79456a58ec9fa683.zip
Moved more script debug commands to console.cpp: "visual_state", "dynamic_views", "dropped_views", "gc" and "gc_objects". Removed the "gfx_free_widgets" and "sleep" commands (they weren't really useful)
svn-id: r41030
Diffstat (limited to 'engines/sci')
-rw-r--r--engines/sci/console.cpp58
-rw-r--r--engines/sci/console.h5
-rw-r--r--engines/sci/engine/scriptdebug.cpp104
3 files changed, 63 insertions, 104 deletions
diff --git a/engines/sci/console.cpp b/engines/sci/console.cpp
index 0a1cbf902b..95c37074e0 100644
--- a/engines/sci/console.cpp
+++ b/engines/sci/console.cpp
@@ -31,6 +31,7 @@
#include "sci/vocabulary.h"
#include "sci/engine/savegame.h"
#include "sci/engine/state.h"
+#include "sci/engine/gc.h"
#include "sci/gfx/gfx_state_internal.h"
#include "sci/vocabulary.h"
@@ -67,6 +68,11 @@ Console::Console(SciEngine *vm) : GUI::Debugger() {
DCmd_Register("parser_words", WRAP_METHOD(Console, cmdParserWords));
DCmd_Register("current_port", WRAP_METHOD(Console, cmdCurrentPort));
DCmd_Register("parse_grammar", WRAP_METHOD(Console, cmdParseGrammar));
+ 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("gc", WRAP_METHOD(Console, cmdInvokeGC));
+ DCmd_Register("gc_objects", WRAP_METHOD(Console, cmdGCObjects));
DCmd_Register("exit", WRAP_METHOD(Console, cmdExit));
// These were in sci.cpp
@@ -568,6 +574,58 @@ bool Console::cmdParseGrammar(int argc, const char **argv) {
return true;
}
+bool Console::cmdVisualState(int argc, const char **argv) {
+ DebugPrintf("State of the current visual widget:\n");
+
+ if (g_EngineState->visual)
+ g_EngineState->visual->print(0);
+ else
+ DebugPrintf("The visual widget is uninitialized.\n");
+
+ return true;
+}
+
+bool Console::cmdDynamicViews(int argc, const char **argv) {
+ DebugPrintf("List of active dynamic views:\n");
+
+ if (g_EngineState->dyn_views)
+ g_EngineState->dyn_views->print(0);
+ else
+ DebugPrintf("The list is empty.\n");
+
+ return true;
+}
+
+bool Console::cmdDroppedViews(int argc, const char **argv) {
+ DebugPrintf("List of dropped dynamic views:\n");
+
+ if (g_EngineState->drop_views)
+ g_EngineState->drop_views->print(0);
+ else
+ DebugPrintf("The list is empty.\n");
+
+ return true;
+}
+
+bool Console::cmdInvokeGC(int argc, const char **argv) {
+ DebugPrintf("Performing garbage collection...\n");
+ run_gc(g_EngineState);
+ return true;
+}
+
+bool Console::cmdGCObjects(int argc, const char **argv) {
+ reg_t_hash_map *use_map = find_all_used_references(g_EngineState);
+
+ DebugPrintf("Reachable object references (normalised):\n");
+ for (reg_t_hash_map::iterator i = use_map->begin(); i != use_map->end(); ++i) {
+ DebugPrintf(" - %04x:%04x\n", PRINT_REG(i->_key));
+ }
+
+ delete use_map;
+
+ return true;
+}
+
bool Console::cmdExit(int argc, const char **argv) {
if (argc != 2) {
DebugPrintf("%s game - exit gracefully\n", argv[0]);
diff --git a/engines/sci/console.h b/engines/sci/console.h
index 7f6122f18f..873497fa53 100644
--- a/engines/sci/console.h
+++ b/engines/sci/console.h
@@ -64,6 +64,11 @@ private:
bool cmdParserWords(int argc, const char **argv);
bool cmdCurrentPort(int argc, const char **argv);
bool cmdParseGrammar(int argc, const char **argv);
+ bool cmdVisualState(int argc, const char **argv);
+ bool cmdDynamicViews(int argc, const char **argv);
+ bool cmdDroppedViews(int argc, const char **argv);
+ bool cmdInvokeGC(int argc, const char **argv);
+ bool cmdGCObjects(int argc, const char **argv);
bool cmdExit(int argc, const char **argv);
private:
diff --git a/engines/sci/engine/scriptdebug.cpp b/engines/sci/engine/scriptdebug.cpp
index d7d85bc3fa..c40221fefe 100644
--- a/engines/sci/engine/scriptdebug.cpp
+++ b/engines/sci/engine/scriptdebug.cpp
@@ -1583,48 +1583,6 @@ static int c_gfx_priority(EngineState *s, const Common::Array<cmd_param_t> &cmdP
return 0;
}
-static int c_gfx_print_visual(EngineState *s, const Common::Array<cmd_param_t> &cmdParams) {
- if (!_debugstate_valid) {
- sciprintf("Not in debug state\n");
- return 1;
- }
-
- if (s->visual)
- s->visual->print(0);
- else
- sciprintf("visual is uninitialized.\n");
-
- return 0;
-}
-
-static int c_gfx_print_dynviews(EngineState *s, const Common::Array<cmd_param_t> &cmdParams) {
- if (!_debugstate_valid) {
- sciprintf("Not in debug state\n");
- return 1;
- }
-
- if (!s->dyn_views)
- sciprintf("No dynview list active.\n");
- else
- s->dyn_views->print(0);
-
- return 0;
-}
-
-static int c_gfx_print_dropviews(EngineState *s, const Common::Array<cmd_param_t> &cmdParams) {
- if (!_debugstate_valid) {
- sciprintf("Not in debug state\n");
- return 1;
- }
-
- if (!s->drop_views)
- sciprintf("No dropped dynview list active.\n");
- else
- s->drop_views->print(0);
-
- return 0;
-}
-
static int c_gfx_drawpic(EngineState *s, const Common::Array<cmd_param_t> &cmdParams) {
int flags = 1, default_palette = 0;
@@ -1867,21 +1825,6 @@ static int c_gfx_draw_viewobj(EngineState *s, const Common::Array<cmd_param_t> &
}
#endif
-static int c_gfx_flush_resources(EngineState *s, const Common::Array<cmd_param_t> &cmdParams) {
- if (!_debugstate_valid) {
- sciprintf("Not in debug state\n");
- return 1;
- }
-
- gfxop_set_pointer_cursor(s->gfx_state, GFXOP_NO_POINTER);
- sciprintf("Flushing resources...\n");
- delete s->visual;
- s->gfx_state->gfxResMan->freeAllResources();
- s->visual = NULL;
-
- return 0;
-}
-
static int c_gfx_update_zone(EngineState *s, const Common::Array<cmd_param_t> &cmdParams) {
if (!_debugstate_valid) {
sciprintf("Not in debug state\n");
@@ -2278,12 +2221,6 @@ int c_simsoundcue(EngineState *s, const Common::Array<cmd_param_t> &cmdParams) {
return 0;
}
-#define ASSERT_PARAMS(number) \
- if (cmdParams.size() <= number) {\
- sciprintf("Operation '%s' needs %d parameters\n", op, number); \
- return 1;\
- }
-
#define GETRECT(ll, rr, tt, bb) \
ll = GET_SELECTOR(pos, ll); \
rr = GET_SELECTOR(pos, rr); \
@@ -2606,12 +2543,6 @@ int c_statusbar(EngineState *s, const Common::Array<cmd_param_t> &cmdParams) {
return 0;
}
-// int c_sleep(EngineState *s, const Common::Array<cmd_param_t> &cmdParams) {
-// sleep(cmdParams[0].val);
-//
-// return 0;
-// }
-
static void _print_address(void * _, reg_t addr) {
if (addr.segment)
sciprintf(" %04x:%04x\n", PRINT_REG(addr));
@@ -2662,25 +2593,6 @@ static int c_gc_normalise(EngineState *s, const Common::Array<cmd_param_t> &cmdP
return 0;
}
-static int c_gc(EngineState *s, const Common::Array<cmd_param_t> &cmdParams) {
- run_gc(s);
-
- return 0;
-}
-
-static int c_gc_list_reachable(EngineState *s, const Common::Array<cmd_param_t> &cmdParams) {
- reg_t_hash_map *use_map = find_all_used_references(s);
-
- sciprintf("Reachable references (normalised):\n");
- for (reg_t_hash_map::iterator i = use_map->begin(); i != use_map->end(); ++i) {
- sciprintf(" - %04x:%04x\n", PRINT_REG(i->_key));
- }
-
- delete use_map;
-
- return 0;
-}
-
void script_debug(EngineState *s, reg_t *pc, StackPtr *sp, StackPtr *pp, reg_t *objp, int *restadjust,
SegmentId *segids, reg_t **variables, reg_t **variables_base, int *variables_nr, int bp) {
// Do we support a separate console?
@@ -2885,12 +2797,8 @@ void script_debug(EngineState *s, reg_t *pc, StackPtr *sp, StackPtr *pp, reg_t *
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
- con_hook_command(c_gfx_flush_resources, "gfx_free_widgets", "", "Frees all dynamically allocated\n widgets (for memory profiling).\n");
con_hook_command(c_gfx_print_port, "gfx_print_port", "i*", "Displays all information about the\n specified port,"
" or the current port\n if no port was specified.");
- con_hook_command(c_gfx_print_visual, "gfx_print_visual", "", "Displays all information about the\n current widget state");
- con_hook_command(c_gfx_print_dynviews, "gfx_print_dynviews", "", "Shows the dynview list");
- con_hook_command(c_gfx_print_dropviews, "gfx_print_dropviews", "", "Shows the list of dropped\n dynviews");
con_hook_command(c_gfx_drawpic, "gfx_drawpic", "ii*", "Draws a pic resource\n\nUSAGE\n gfx_drawpic <nr> [<pal> [<fl>]]\n"
" where <nr> is the number of the pic resource\n to draw\n <pal> is the optional default\n palette for the pic (0 is"
"\n assumed if not specified)\n <fl> are any pic draw flags (default\n is 1)");
@@ -2967,8 +2875,6 @@ void script_debug(EngineState *s, reg_t *pc, StackPtr *sp, StackPtr *pp, reg_t *
" sfx-01-track <song> <offset>\n\n"
"SEE ALSO\n\n"
" sfx-01-header.1\n\n");
-// con_hook_command(c_sleep, "sleep", "i", "Suspends everything for the\n"
-// " specified number of seconds");
con_hook_command(c_gc_show_reachable, "gc-list-reachable", "!a",
"Prints all addresses directly reachable from\n"
" the memory object specified as parameter.\n\n"
@@ -2988,16 +2894,6 @@ void script_debug(EngineState *s, reg_t *pc, StackPtr *sp, StackPtr *pp, reg_t *
"SEE ALSO\n\n"
" gc-list-freeable.1, gc-list-reachable.1, gc.1,\n"
" gc-all-reachable.1");
- con_hook_command(c_gc, "gc", "",
- "Performs garbage collection.\n\n"
- "SEE ALSO\n\n"
- " gc-list-freeable.1, gc-list-reachable.1,\n"
- " gc-all-reachable.1, gc-normalise.1");
- con_hook_command(c_gc_list_reachable, "gc-all-reachable", "",
- "Lists all reachable objects, normalised.\n\n"
- "SEE ALSO\n\n"
- " gc-list-freeable.1, gc-list-reachable.1,\n"
- " gc.1, gc-normalise.1");
/*
con_hook_int(&script_debug_flag, "script_debug_flag", "Set != 0 to enable debugger\n");