2009-02-20 21:26:31 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
* $URL$
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
// Console module
|
|
|
|
|
|
|
|
#include "sci/sci.h"
|
|
|
|
#include "sci/console.h"
|
2009-06-04 11:28:05 +00:00
|
|
|
#include "sci/debug.h"
|
2009-12-04 17:38:24 +00:00
|
|
|
#include "sci/event.h"
|
2009-05-15 14:07:45 +00:00
|
|
|
#include "sci/resource.h"
|
2009-05-30 10:22:53 +00:00
|
|
|
#include "sci/engine/state.h"
|
2010-06-23 15:23:37 +00:00
|
|
|
#include "sci/engine/kernel.h"
|
2010-01-29 11:03:54 +00:00
|
|
|
#include "sci/engine/selector.h"
|
2010-02-13 17:44:58 +00:00
|
|
|
#include "sci/engine/savegame.h"
|
|
|
|
#include "sci/engine/gc.h"
|
|
|
|
#include "sci/engine/features.h"
|
2010-06-11 14:47:13 +00:00
|
|
|
#include "sci/sound/midiparser_sci.h"
|
2010-01-05 01:22:16 +00:00
|
|
|
#include "sci/sound/music.h"
|
2010-01-21 16:27:29 +00:00
|
|
|
#include "sci/sound/drivers/mididriver.h"
|
2010-01-05 01:37:57 +00:00
|
|
|
#include "sci/graphics/cursor.h"
|
2010-01-31 15:07:36 +00:00
|
|
|
#include "sci/graphics/screen.h"
|
2010-02-04 19:22:40 +00:00
|
|
|
#include "sci/graphics/paint.h"
|
2010-05-24 17:45:00 +00:00
|
|
|
#include "sci/graphics/paint16.h"
|
2010-06-15 15:44:24 +00:00
|
|
|
#include "sci/graphics/paint32.h"
|
2010-01-31 16:21:11 +00:00
|
|
|
#include "sci/graphics/palette.h"
|
2009-05-30 13:04:09 +00:00
|
|
|
|
2010-01-23 17:55:54 +00:00
|
|
|
#include "sci/parser/vocabulary.h"
|
|
|
|
|
2009-10-17 10:42:00 +00:00
|
|
|
#include "graphics/video/avi_decoder.h"
|
2009-12-30 10:09:48 +00:00
|
|
|
#include "sci/video/seq_decoder.h"
|
|
|
|
#ifdef ENABLE_SCI32
|
|
|
|
#include "sci/video/vmd_decoder.h"
|
|
|
|
#endif
|
2009-10-17 10:42:00 +00:00
|
|
|
|
2010-02-17 23:38:43 +00:00
|
|
|
#include "common/file.h"
|
2009-05-30 13:04:09 +00:00
|
|
|
#include "common/savefile.h"
|
2009-02-20 21:26:31 +00:00
|
|
|
|
|
|
|
namespace Sci {
|
|
|
|
|
2009-06-04 11:28:05 +00:00
|
|
|
int g_debug_sleeptime_factor = 1;
|
|
|
|
int g_debug_simulated_key = 0;
|
|
|
|
bool g_debug_track_mouse_clicks = false;
|
2009-06-06 16:43:13 +00:00
|
|
|
|
2009-10-04 18:36:58 +00:00
|
|
|
// Refer to the "addresses" command on how to pass address parameters
|
2010-01-02 09:39:17 +00:00
|
|
|
static int parse_reg_t(EngineState *s, const char *str, reg_t *dest, bool mayBeValue);
|
2009-10-04 18:36:58 +00:00
|
|
|
|
2010-07-12 23:20:33 +00:00
|
|
|
Console::Console(SciEngine *engine) : GUI::Debugger(),
|
|
|
|
_engine(engine), _debugState(engine->_debugState) {
|
2009-02-20 21:26:31 +00:00
|
|
|
|
2009-06-03 09:45:16 +00:00
|
|
|
// Variables
|
2009-06-04 11:28:05 +00:00
|
|
|
DVar_Register("sleeptime_factor", &g_debug_sleeptime_factor, DVAR_INT, 0);
|
2010-06-10 11:18:10 +00:00
|
|
|
DVar_Register("gc_interval", &engine->_gamestate->scriptGCInterval, DVAR_INT, 0);
|
2009-06-04 11:28:05 +00:00
|
|
|
DVar_Register("simulated_key", &g_debug_simulated_key, DVAR_INT, 0);
|
|
|
|
DVar_Register("track_mouse_clicks", &g_debug_track_mouse_clicks, DVAR_BOOL, 0);
|
2010-06-08 21:05:46 +00:00
|
|
|
DVar_Register("script_abort_flag", &_engine->_gamestate->abortScriptProcessing, DVAR_INT, 0);
|
2009-06-03 09:45:16 +00:00
|
|
|
|
|
|
|
// General
|
|
|
|
DCmd_Register("help", WRAP_METHOD(Console, cmdHelp));
|
2009-06-02 19:03:43 +00:00
|
|
|
// Kernel
|
2009-05-26 15:06:21 +00:00
|
|
|
// DCmd_Register("classes", WRAP_METHOD(Console, cmdClasses)); // TODO
|
|
|
|
DCmd_Register("opcodes", WRAP_METHOD(Console, cmdOpcodes));
|
2009-07-04 15:22:42 +00:00
|
|
|
DCmd_Register("selector", WRAP_METHOD(Console, cmdSelector));
|
2009-05-11 17:10:36 +00:00
|
|
|
DCmd_Register("selectors", WRAP_METHOD(Console, cmdSelectors));
|
2009-06-03 09:45:16 +00:00
|
|
|
DCmd_Register("functions", WRAP_METHOD(Console, cmdKernelFunctions));
|
|
|
|
DCmd_Register("class_table", WRAP_METHOD(Console, cmdClassTable));
|
2009-06-02 19:03:43 +00:00
|
|
|
// Parser
|
2009-05-12 08:14:24 +00:00
|
|
|
DCmd_Register("suffixes", WRAP_METHOD(Console, cmdSuffixes));
|
2009-06-02 19:03:43 +00:00
|
|
|
DCmd_Register("parse_grammar", WRAP_METHOD(Console, cmdParseGrammar));
|
2009-05-31 12:05:49 +00:00
|
|
|
DCmd_Register("parser_nodes", WRAP_METHOD(Console, cmdParserNodes));
|
|
|
|
DCmd_Register("parser_words", WRAP_METHOD(Console, cmdParserWords));
|
2009-06-03 09:45:16 +00:00
|
|
|
DCmd_Register("sentence_fragments", WRAP_METHOD(Console, cmdSentenceFragments));
|
2009-06-03 11:38:12 +00:00
|
|
|
DCmd_Register("parse", WRAP_METHOD(Console, cmdParse));
|
2009-06-06 16:43:13 +00:00
|
|
|
DCmd_Register("set_parse_nodes", WRAP_METHOD(Console, cmdSetParseNodes));
|
2010-07-18 13:31:05 +00:00
|
|
|
DCmd_Register("said", WRAP_METHOD(Console, cmdSaid));
|
2009-06-02 19:03:43 +00:00
|
|
|
// Resources
|
2010-01-28 01:45:20 +00:00
|
|
|
DCmd_Register("diskdump", WRAP_METHOD(Console, cmdDiskDump));
|
2009-05-23 19:59:42 +00:00
|
|
|
DCmd_Register("hexdump", WRAP_METHOD(Console, cmdHexDump));
|
2009-06-02 19:03:43 +00:00
|
|
|
DCmd_Register("resource_id", WRAP_METHOD(Console, cmdResourceId));
|
|
|
|
DCmd_Register("resource_size", WRAP_METHOD(Console, cmdResourceSize));
|
2009-05-30 13:04:09 +00:00
|
|
|
DCmd_Register("resource_types", WRAP_METHOD(Console, cmdResourceTypes));
|
2009-05-30 10:22:53 +00:00
|
|
|
DCmd_Register("list", WRAP_METHOD(Console, cmdList));
|
2009-06-02 19:03:43 +00:00
|
|
|
DCmd_Register("hexgrep", WRAP_METHOD(Console, cmdHexgrep));
|
2010-05-31 22:57:05 +00:00
|
|
|
DCmd_Register("verify_scripts", WRAP_METHOD(Console, cmdVerifyScripts));
|
2010-06-11 19:49:41 +00:00
|
|
|
DCmd_Register("show_instruments", WRAP_METHOD(Console, cmdShowInstruments));
|
2009-06-02 19:03:43 +00:00
|
|
|
// Game
|
2009-05-30 13:04:09 +00:00
|
|
|
DCmd_Register("save_game", WRAP_METHOD(Console, cmdSaveGame));
|
|
|
|
DCmd_Register("restore_game", WRAP_METHOD(Console, cmdRestoreGame));
|
|
|
|
DCmd_Register("restart_game", WRAP_METHOD(Console, cmdRestartGame));
|
2009-06-02 19:03:43 +00:00
|
|
|
DCmd_Register("version", WRAP_METHOD(Console, cmdGetVersion));
|
|
|
|
DCmd_Register("room", WRAP_METHOD(Console, cmdRoomNumber));
|
2010-01-27 20:03:45 +00:00
|
|
|
DCmd_Register("quit", WRAP_METHOD(Console, cmdQuit));
|
2010-01-02 14:11:38 +00:00
|
|
|
DCmd_Register("list_saves", WRAP_METHOD(Console, cmdListSaves));
|
2009-06-03 09:45:16 +00:00
|
|
|
// Graphics
|
2010-04-24 20:49:19 +00:00
|
|
|
DCmd_Register("show_map", WRAP_METHOD(Console, cmdShowMap));
|
2010-01-05 21:25:59 +00:00
|
|
|
DCmd_Register("set_palette", WRAP_METHOD(Console, cmdSetPalette));
|
2009-05-30 18:22:55 +00:00
|
|
|
DCmd_Register("draw_pic", WRAP_METHOD(Console, cmdDrawPic));
|
2010-01-05 21:03:33 +00:00
|
|
|
DCmd_Register("draw_cel", WRAP_METHOD(Console, cmdDrawCel));
|
2010-01-06 21:56:31 +00:00
|
|
|
#ifdef ENABLE_SCI32
|
|
|
|
DCmd_Register("draw_robot", WRAP_METHOD(Console, cmdDrawRobot));
|
|
|
|
#endif
|
2009-10-07 21:47:34 +00:00
|
|
|
DCmd_Register("undither", WRAP_METHOD(Console, cmdUndither));
|
2010-01-09 14:09:45 +00:00
|
|
|
DCmd_Register("pic_visualize", WRAP_METHOD(Console, cmdPicVisualize));
|
2009-10-17 10:42:00 +00:00
|
|
|
DCmd_Register("play_video", WRAP_METHOD(Console, cmdPlayVideo));
|
2009-06-02 19:03:43 +00:00
|
|
|
// Segments
|
2009-05-30 14:30:39 +00:00
|
|
|
DCmd_Register("segment_table", WRAP_METHOD(Console, cmdPrintSegmentTable));
|
2009-08-10 21:30:16 +00:00
|
|
|
DCmd_Register("segtable", WRAP_METHOD(Console, cmdPrintSegmentTable)); // alias
|
2009-05-30 16:36:37 +00:00
|
|
|
DCmd_Register("segment_info", WRAP_METHOD(Console, cmdSegmentInfo));
|
2009-08-10 21:30:16 +00:00
|
|
|
DCmd_Register("seginfo", WRAP_METHOD(Console, cmdSegmentInfo)); // alias
|
2009-05-30 16:36:37 +00:00
|
|
|
DCmd_Register("segment_kill", WRAP_METHOD(Console, cmdKillSegment));
|
2009-08-10 21:30:16 +00:00
|
|
|
DCmd_Register("segkill", WRAP_METHOD(Console, cmdKillSegment)); // alias
|
2009-06-02 19:03:43 +00:00
|
|
|
// Garbage collection
|
|
|
|
DCmd_Register("gc", WRAP_METHOD(Console, cmdGCInvoke));
|
2009-05-30 13:36:51 +00:00
|
|
|
DCmd_Register("gc_objects", WRAP_METHOD(Console, cmdGCObjects));
|
2009-06-02 21:07:34 +00:00
|
|
|
DCmd_Register("gc_reachable", WRAP_METHOD(Console, cmdGCShowReachable));
|
|
|
|
DCmd_Register("gc_freeable", WRAP_METHOD(Console, cmdGCShowFreeable));
|
|
|
|
DCmd_Register("gc_normalize", WRAP_METHOD(Console, cmdGCNormalize));
|
2009-06-02 19:03:43 +00:00
|
|
|
// Music/SFX
|
|
|
|
DCmd_Register("songlib", WRAP_METHOD(Console, cmdSongLib));
|
2010-01-23 14:39:03 +00:00
|
|
|
DCmd_Register("songinfo", WRAP_METHOD(Console, cmdSongInfo));
|
2009-06-02 19:03:43 +00:00
|
|
|
DCmd_Register("is_sample", WRAP_METHOD(Console, cmdIsSample));
|
2010-01-23 14:39:03 +00:00
|
|
|
DCmd_Register("startsound", WRAP_METHOD(Console, cmdStartSound));
|
|
|
|
DCmd_Register("togglesound", WRAP_METHOD(Console, cmdToggleSound));
|
|
|
|
DCmd_Register("stopallsounds", WRAP_METHOD(Console, cmdStopAllSounds));
|
2009-06-02 19:03:43 +00:00
|
|
|
DCmd_Register("sfx01_header", WRAP_METHOD(Console, cmdSfx01Header));
|
|
|
|
DCmd_Register("sfx01_track", WRAP_METHOD(Console, cmdSfx01Track));
|
2009-06-02 21:07:34 +00:00
|
|
|
// Script
|
|
|
|
DCmd_Register("addresses", WRAP_METHOD(Console, cmdAddresses));
|
2009-06-03 09:45:16 +00:00
|
|
|
DCmd_Register("registers", WRAP_METHOD(Console, cmdRegisters));
|
2009-06-02 21:07:34 +00:00
|
|
|
DCmd_Register("dissect_script", WRAP_METHOD(Console, cmdDissectScript));
|
2009-06-03 14:47:32 +00:00
|
|
|
DCmd_Register("backtrace", WRAP_METHOD(Console, cmdBacktrace));
|
2009-06-15 08:44:35 +00:00
|
|
|
DCmd_Register("bt", WRAP_METHOD(Console, cmdBacktrace)); // alias
|
2010-06-27 19:58:32 +00:00
|
|
|
DCmd_Register("trace", WRAP_METHOD(Console, cmdTrace));
|
|
|
|
DCmd_Register("t", WRAP_METHOD(Console, cmdTrace)); // alias
|
|
|
|
DCmd_Register("s", WRAP_METHOD(Console, cmdTrace)); // alias
|
|
|
|
DCmd_Register("stepover", WRAP_METHOD(Console, cmdStepOver));
|
|
|
|
DCmd_Register("p", WRAP_METHOD(Console, cmdStepOver)); // alias
|
|
|
|
DCmd_Register("step_ret", WRAP_METHOD(Console, cmdStepRet));
|
|
|
|
DCmd_Register("pret", WRAP_METHOD(Console, cmdStepRet)); // alias
|
2009-06-06 16:43:13 +00:00
|
|
|
DCmd_Register("step_event", WRAP_METHOD(Console, cmdStepEvent));
|
2009-06-15 08:44:35 +00:00
|
|
|
DCmd_Register("se", WRAP_METHOD(Console, cmdStepEvent)); // alias
|
2009-06-06 16:43:13 +00:00
|
|
|
DCmd_Register("step_global", WRAP_METHOD(Console, cmdStepGlobal));
|
2009-06-15 08:44:35 +00:00
|
|
|
DCmd_Register("sg", WRAP_METHOD(Console, cmdStepGlobal)); // alias
|
2009-06-06 20:29:37 +00:00
|
|
|
DCmd_Register("step_callk", WRAP_METHOD(Console, cmdStepCallk));
|
2009-06-15 08:44:35 +00:00
|
|
|
DCmd_Register("snk", WRAP_METHOD(Console, cmdStepCallk)); // alias
|
2009-10-03 20:25:27 +00:00
|
|
|
DCmd_Register("disasm", WRAP_METHOD(Console, cmdDisassemble));
|
|
|
|
DCmd_Register("disasm_addr", WRAP_METHOD(Console, cmdDisassembleAddress));
|
2009-06-08 08:38:10 +00:00
|
|
|
DCmd_Register("send", WRAP_METHOD(Console, cmdSend));
|
|
|
|
DCmd_Register("go", WRAP_METHOD(Console, cmdGo));
|
2009-06-03 11:38:12 +00:00
|
|
|
// Breakpoints
|
2009-06-02 23:29:58 +00:00
|
|
|
DCmd_Register("bp_list", WRAP_METHOD(Console, cmdBreakpointList));
|
2009-08-10 21:30:16 +00:00
|
|
|
DCmd_Register("bplist", WRAP_METHOD(Console, cmdBreakpointList)); // alias
|
2010-06-27 20:11:15 +00:00
|
|
|
DCmd_Register("bl", WRAP_METHOD(Console, cmdBreakpointList)); // alias
|
2009-06-02 23:29:58 +00:00
|
|
|
DCmd_Register("bp_del", WRAP_METHOD(Console, cmdBreakpointDelete));
|
2009-08-10 21:30:16 +00:00
|
|
|
DCmd_Register("bpdel", WRAP_METHOD(Console, cmdBreakpointDelete)); // alias
|
2010-06-27 20:11:15 +00:00
|
|
|
DCmd_Register("bc", WRAP_METHOD(Console, cmdBreakpointDelete)); // alias
|
2009-06-03 11:38:12 +00:00
|
|
|
DCmd_Register("bp_exec_method", WRAP_METHOD(Console, cmdBreakpointExecMethod));
|
2009-06-15 08:44:35 +00:00
|
|
|
DCmd_Register("bpx", WRAP_METHOD(Console, cmdBreakpointExecMethod)); // alias
|
2009-06-03 11:38:12 +00:00
|
|
|
DCmd_Register("bp_exec_function", WRAP_METHOD(Console, cmdBreakpointExecFunction));
|
2009-06-15 08:44:35 +00:00
|
|
|
DCmd_Register("bpe", WRAP_METHOD(Console, cmdBreakpointExecFunction)); // alias
|
2009-06-02 21:07:34 +00:00
|
|
|
// VM
|
2009-06-03 09:45:16 +00:00
|
|
|
DCmd_Register("script_steps", WRAP_METHOD(Console, cmdScriptSteps));
|
2009-06-02 21:07:34 +00:00
|
|
|
DCmd_Register("vm_varlist", WRAP_METHOD(Console, cmdVMVarlist));
|
2010-06-27 20:43:32 +00:00
|
|
|
DCmd_Register("vmvarlist", WRAP_METHOD(Console, cmdVMVarlist)); // alias
|
|
|
|
DCmd_Register("vl", WRAP_METHOD(Console, cmdVMVarlist)); // alias
|
2009-08-10 21:30:16 +00:00
|
|
|
DCmd_Register("vm_vars", WRAP_METHOD(Console, cmdVMVars));
|
2010-06-27 20:43:32 +00:00
|
|
|
DCmd_Register("vmvars", WRAP_METHOD(Console, cmdVMVars)); // alias
|
|
|
|
DCmd_Register("vv", WRAP_METHOD(Console, cmdVMVars)); // alias
|
2009-06-02 21:07:34 +00:00
|
|
|
DCmd_Register("stack", WRAP_METHOD(Console, cmdStack));
|
|
|
|
DCmd_Register("value_type", WRAP_METHOD(Console, cmdValueType));
|
2009-06-03 09:45:16 +00:00
|
|
|
DCmd_Register("view_listnode", WRAP_METHOD(Console, cmdViewListNode));
|
2009-06-03 14:47:32 +00:00
|
|
|
DCmd_Register("view_reference", WRAP_METHOD(Console, cmdViewReference));
|
2010-06-27 20:43:32 +00:00
|
|
|
DCmd_Register("vr", WRAP_METHOD(Console, cmdViewReference)); // alias
|
2009-06-02 23:29:58 +00:00
|
|
|
DCmd_Register("view_object", WRAP_METHOD(Console, cmdViewObject));
|
2010-06-27 20:43:32 +00:00
|
|
|
DCmd_Register("vo", WRAP_METHOD(Console, cmdViewObject)); // alias
|
2009-06-02 23:29:58 +00:00
|
|
|
DCmd_Register("active_object", WRAP_METHOD(Console, cmdViewActiveObject));
|
|
|
|
DCmd_Register("acc_object", WRAP_METHOD(Console, cmdViewAccumulatorObject));
|
2009-05-30 10:22:53 +00:00
|
|
|
|
2010-07-12 23:20:33 +00:00
|
|
|
_debugState.seeking = kDebugSeekNothing;
|
|
|
|
_debugState.seekLevel = 0;
|
|
|
|
_debugState.runningStep = 0;
|
|
|
|
_debugState.stopOnEvent = false;
|
|
|
|
_debugState.debugging = false;
|
|
|
|
_debugState.breakpointWasHit = false;
|
|
|
|
_debugState._breakpoints.clear(); // No breakpoints defined
|
|
|
|
_debugState._activeBreakpointTypes = 0;
|
2009-02-20 21:26:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Console::~Console() {
|
|
|
|
}
|
|
|
|
|
2009-06-03 14:09:25 +00:00
|
|
|
void Console::preEnter() {
|
2010-06-29 09:00:08 +00:00
|
|
|
if (g_sci && g_sci->_soundCmd)
|
|
|
|
g_sci->_soundCmd->pauseAll(true);
|
2009-06-03 14:09:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Console::postEnter() {
|
2010-06-29 09:00:08 +00:00
|
|
|
if (g_sci && g_sci->_soundCmd)
|
|
|
|
g_sci->_soundCmd->pauseAll(false);
|
2009-10-17 10:42:00 +00:00
|
|
|
|
|
|
|
if (!_videoFile.empty()) {
|
2010-02-13 17:43:31 +00:00
|
|
|
_engine->_gfxCursor->kernelHide();
|
2009-10-17 10:42:00 +00:00
|
|
|
|
2010-05-18 14:17:24 +00:00
|
|
|
Graphics::VideoDecoder *videoDecoder = 0;
|
|
|
|
|
2009-10-17 10:42:00 +00:00
|
|
|
if (_videoFile.hasSuffix(".seq")) {
|
2010-05-18 17:36:34 +00:00
|
|
|
SeqDecoder *seqDecoder = new SeqDecoder();
|
|
|
|
seqDecoder->setFrameDelay(_videoFrameDelay);
|
|
|
|
videoDecoder = seqDecoder;
|
2009-12-30 10:09:48 +00:00
|
|
|
#ifdef ENABLE_SCI32
|
2010-05-18 14:17:24 +00:00
|
|
|
} else if (_videoFile.hasSuffix(".vmd")) {
|
|
|
|
videoDecoder = new VMDDecoder(g_system->getMixer());
|
2009-12-30 10:09:48 +00:00
|
|
|
#endif
|
2010-05-18 14:17:24 +00:00
|
|
|
} else if (_videoFile.hasSuffix(".avi")) {
|
|
|
|
videoDecoder = new Graphics::AviDecoder(g_system->getMixer());
|
2009-10-17 10:42:00 +00:00
|
|
|
}
|
|
|
|
|
2010-05-18 14:17:24 +00:00
|
|
|
if (videoDecoder && videoDecoder->loadFile(_videoFile)) {
|
|
|
|
uint16 x = (g_system->getWidth() - videoDecoder->getWidth()) / 2;
|
|
|
|
uint16 y = (g_system->getHeight() - videoDecoder->getHeight()) / 2;
|
2010-06-16 23:28:20 +00:00
|
|
|
bool skipVideo = false;
|
2009-10-17 10:42:00 +00:00
|
|
|
|
2010-06-16 23:28:20 +00:00
|
|
|
while (!g_engine->shouldQuit() && !videoDecoder->endOfVideo() && !skipVideo) {
|
2010-05-18 14:17:24 +00:00
|
|
|
if (videoDecoder->needsUpdate()) {
|
|
|
|
Graphics::Surface *frame = videoDecoder->decodeNextFrame();
|
|
|
|
if (frame) {
|
|
|
|
g_system->copyRectToScreen((byte *)frame->pixels, frame->pitch, x, y, frame->w, frame->h);
|
|
|
|
|
|
|
|
if (videoDecoder->hasDirtyPalette())
|
|
|
|
videoDecoder->setSystemPalette();
|
|
|
|
|
|
|
|
g_system->updateScreen();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Common::Event event;
|
2010-06-16 23:28:20 +00:00
|
|
|
while (g_system->getEventManager()->pollEvent(event)) {
|
|
|
|
if ((event.type == Common::EVENT_KEYDOWN && event.kbd.keycode == Common::KEYCODE_ESCAPE) || event.type == Common::EVENT_LBUTTONUP)
|
|
|
|
skipVideo = true;
|
|
|
|
}
|
2010-05-18 14:17:24 +00:00
|
|
|
|
|
|
|
g_system->delayMillis(10);
|
|
|
|
}
|
|
|
|
|
|
|
|
delete videoDecoder;
|
|
|
|
} else
|
|
|
|
warning("Could not play video %s\n", _videoFile.c_str());
|
|
|
|
|
|
|
|
_engine->_gfxCursor->kernelShow();
|
2009-10-17 10:42:00 +00:00
|
|
|
_videoFile.clear();
|
|
|
|
_videoFrameDelay = 0;
|
|
|
|
}
|
2009-06-03 14:09:25 +00:00
|
|
|
}
|
|
|
|
|
2009-06-03 09:45:16 +00:00
|
|
|
bool Console::cmdHelp(int argc, const char **argv) {
|
|
|
|
DebugPrintf("\n");
|
|
|
|
DebugPrintf("Variables\n");
|
|
|
|
DebugPrintf("---------\n");
|
|
|
|
DebugPrintf("sleeptime_factor: Factor to multiply with wait times in kWait()\n");
|
|
|
|
DebugPrintf("gc_interval: Number of kernel calls in between garbage collections\n");
|
|
|
|
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");
|
2009-06-05 19:04:14 +00:00
|
|
|
DebugPrintf("script_abort_flag: Set to 1 to abort script execution. Set to 2 to force a replay afterwards\n");
|
2009-06-03 09:45:16 +00:00
|
|
|
DebugPrintf("\n");
|
2009-06-15 08:44:35 +00:00
|
|
|
DebugPrintf("Debug flags\n");
|
|
|
|
DebugPrintf("-----------\n");
|
|
|
|
DebugPrintf("debugflag_list - Lists the available debug flags and their status\n");
|
|
|
|
DebugPrintf("debugflag_enable - Enables a debug flag\n");
|
|
|
|
DebugPrintf("debugflag_disable - Disables a debug flag\n");
|
|
|
|
DebugPrintf("\n");
|
2009-06-03 09:45:16 +00:00
|
|
|
DebugPrintf("Commands\n");
|
|
|
|
DebugPrintf("--------\n");
|
|
|
|
DebugPrintf("Kernel:\n");
|
|
|
|
DebugPrintf(" opcodes - Lists the opcode names\n");
|
|
|
|
DebugPrintf(" selectors - Lists the selector names\n");
|
2009-07-04 15:22:42 +00:00
|
|
|
DebugPrintf(" selector - Attempts to find the requested selector by name\n");
|
2009-06-03 09:45:16 +00:00
|
|
|
DebugPrintf(" functions - Lists the kernel functions\n");
|
|
|
|
DebugPrintf(" class_table - Shows the available classes\n");
|
|
|
|
DebugPrintf("\n");
|
|
|
|
DebugPrintf("Parser:\n");
|
|
|
|
DebugPrintf(" suffixes - Lists the vocabulary suffixes\n");
|
|
|
|
DebugPrintf(" parse_grammar - Shows the parse grammar, in strict GNF\n");
|
|
|
|
DebugPrintf(" parser_nodes - Shows the specified number of nodes from the parse node tree\n");
|
|
|
|
DebugPrintf(" parser_words - Shows the words from the parse node tree\n");
|
|
|
|
DebugPrintf(" sentence_fragments - Shows the sentence fragments (used to build Parse trees)\n");
|
2009-06-03 11:38:12 +00:00
|
|
|
DebugPrintf(" parse - Parses a sequence of words and prints the resulting parse tree\n");
|
2009-06-06 16:43:13 +00:00
|
|
|
DebugPrintf(" set_parse_nodes - Sets the contents of all parse nodes\n");
|
2010-07-18 13:31:05 +00:00
|
|
|
DebugPrintf(" said - Match a string against a said spec\n");
|
2009-06-03 09:45:16 +00:00
|
|
|
DebugPrintf("\n");
|
|
|
|
DebugPrintf("Resources:\n");
|
2010-01-28 01:45:20 +00:00
|
|
|
DebugPrintf(" diskdump - Dumps the specified resource to disk as a patch file\n");
|
2009-06-03 09:45:16 +00:00
|
|
|
DebugPrintf(" hexdump - Dumps the specified resource to standard output\n");
|
|
|
|
DebugPrintf(" resource_id - Identifies a resource number by splitting it up in resource type and resource number\n");
|
|
|
|
DebugPrintf(" resource_size - Shows the size of a resource\n");
|
|
|
|
DebugPrintf(" resource_types - Shows the valid resource types\n");
|
|
|
|
DebugPrintf(" list - Lists all the resources of a given type\n");
|
|
|
|
DebugPrintf(" hexgrep - Searches some resources for a particular sequence of bytes, represented as hexadecimal numbers\n");
|
2010-05-31 22:57:05 +00:00
|
|
|
DebugPrintf(" verify_scripts - Performs sanity checks on SCI1.1-SCI2.1 game scripts (e.g. if they're up to 64KB in total)\n");
|
2010-06-11 19:49:41 +00:00
|
|
|
DebugPrintf(" show_instruments - Shows the instruments of a specific song, or all songs\n");
|
2009-06-03 09:45:16 +00:00
|
|
|
DebugPrintf("\n");
|
|
|
|
DebugPrintf("Game:\n");
|
|
|
|
DebugPrintf(" save_game - Saves the current game state to the hard disk\n");
|
|
|
|
DebugPrintf(" restore_game - Restores a saved game from the hard disk\n");
|
2010-01-02 14:11:38 +00:00
|
|
|
DebugPrintf(" list_saves - List all saved games including filenames\n");
|
2009-06-03 09:45:16 +00:00
|
|
|
DebugPrintf(" restart_game - Restarts the game\n");
|
|
|
|
DebugPrintf(" version - Shows the resource and interpreter versions\n");
|
2010-01-03 15:08:26 +00:00
|
|
|
DebugPrintf(" room - Gets or sets the current room number\n");
|
2010-01-27 20:06:07 +00:00
|
|
|
DebugPrintf(" quit - Quits the game\n");
|
2009-06-03 09:45:16 +00:00
|
|
|
DebugPrintf("\n");
|
|
|
|
DebugPrintf("Graphics:\n");
|
2010-04-24 20:49:19 +00:00
|
|
|
DebugPrintf(" show_map - Switches to visual, priority, control or display screen\n");
|
2010-01-05 21:25:59 +00:00
|
|
|
DebugPrintf(" set_palette - Sets a palette resource\n");
|
2009-06-03 09:45:16 +00:00
|
|
|
DebugPrintf(" draw_pic - Draws a pic resource\n");
|
2010-01-05 21:03:33 +00:00
|
|
|
DebugPrintf(" draw_cel - Draws a cel from a view resource\n");
|
2010-01-09 14:09:45 +00:00
|
|
|
DebugPrintf(" pic_visualize - Enables visualization of the drawing process of EGA pictures\n");
|
2009-10-07 21:47:34 +00:00
|
|
|
DebugPrintf(" undither - Enable/disable undithering\n");
|
2009-06-03 09:45:16 +00:00
|
|
|
DebugPrintf("\n");
|
|
|
|
DebugPrintf("Segments:\n");
|
2009-08-10 21:30:16 +00:00
|
|
|
DebugPrintf(" segment_table / segtable - Lists all segments\n");
|
|
|
|
DebugPrintf(" segment_info / seginfo - Provides information on the specified segment\n");
|
|
|
|
DebugPrintf(" segment_kill / segkill - Deletes the specified segment\n");
|
2009-06-03 09:45:16 +00:00
|
|
|
DebugPrintf("\n");
|
|
|
|
DebugPrintf("Garbage collection:\n");
|
|
|
|
DebugPrintf(" gc - Invokes the garbage collector\n");
|
|
|
|
DebugPrintf(" gc_objects - Lists all reachable objects, normalized\n");
|
|
|
|
DebugPrintf(" gc_reachable - Lists all addresses directly reachable from a given memory object\n");
|
|
|
|
DebugPrintf(" gc_freeable - Lists all addresses freeable in a given segment\n");
|
|
|
|
DebugPrintf(" gc_normalize - Prints the \"normal\" address of a given address\n");
|
|
|
|
DebugPrintf("\n");
|
|
|
|
DebugPrintf("Music/SFX:\n");
|
|
|
|
DebugPrintf(" songlib - Shows the song library\n");
|
2010-01-24 11:54:55 +00:00
|
|
|
DebugPrintf(" songinfo - Shows information about a specified song in the song library\n");
|
|
|
|
DebugPrintf(" togglesound - Starts/stops a sound in the song library\n");
|
|
|
|
DebugPrintf(" stopallsounds - Stops all sounds in the playlist\n");
|
|
|
|
DebugPrintf(" startsound - Starts the specified sound resource, replacing the first song in the song library\n");
|
2009-06-03 09:45:16 +00:00
|
|
|
DebugPrintf(" is_sample - Shows information on a given sound resource, if it's a PCM sample\n");
|
|
|
|
DebugPrintf(" sfx01_header - Dumps the header of a SCI01 song\n");
|
|
|
|
DebugPrintf(" sfx01_track - Dumps a track of a SCI01 song\n");
|
|
|
|
DebugPrintf("\n");
|
|
|
|
DebugPrintf("Script:\n");
|
|
|
|
DebugPrintf(" addresses - Provides information on how to pass addresses\n");
|
|
|
|
DebugPrintf(" registers - Shows the current register values\n");
|
|
|
|
DebugPrintf(" dissect_script - Examines a script\n");
|
2009-06-15 08:44:35 +00:00
|
|
|
DebugPrintf(" backtrace / bt - Dumps the send/self/super/call/calle/callb stack\n");
|
2010-06-27 19:58:32 +00:00
|
|
|
DebugPrintf(" trace / t / s - Executes one operation (no parameters) or several operations (specified as a parameter) \n");
|
|
|
|
DebugPrintf(" stepover / p - Executes one operation, skips over call/send\n");
|
|
|
|
DebugPrintf(" step_ret / pret - Steps forward until ret is called on the current execution stack level.\n");
|
2009-06-15 08:44:35 +00:00
|
|
|
DebugPrintf(" step_event / se - Steps forward until a SCI event is received.\n");
|
|
|
|
DebugPrintf(" step_global / sg - Steps until the global variable with the specified index is modified.\n");
|
|
|
|
DebugPrintf(" step_callk / snk - Steps forward until it hits the next callk operation, or a specific callk (specified as a parameter)\n");
|
2009-06-06 20:29:37 +00:00
|
|
|
DebugPrintf(" disasm - Disassembles a method by name\n");
|
|
|
|
DebugPrintf(" disasm_addr - Disassembles one or more commands\n");
|
2009-06-08 08:38:10 +00:00
|
|
|
DebugPrintf(" send - Sends a message to an object\n");
|
|
|
|
DebugPrintf(" go - Executes the script\n");
|
2009-06-03 11:38:12 +00:00
|
|
|
DebugPrintf("\n");
|
|
|
|
DebugPrintf("Breakpoints:\n");
|
2010-06-27 20:11:15 +00:00
|
|
|
DebugPrintf(" bp_list / bplist / bl - Lists the current breakpoints\n");
|
|
|
|
DebugPrintf(" bp_del / bpdel / bc - Deletes a breakpoint with the specified index\n");
|
2009-06-15 08:44:35 +00:00
|
|
|
DebugPrintf(" bp_exec_method / bpx - Sets a breakpoint on the execution of the specified method\n");
|
|
|
|
DebugPrintf(" bp_exec_function / bpe - Sets a breakpoint on the execution of the specified exported function\n");
|
2009-06-03 09:45:16 +00:00
|
|
|
DebugPrintf("\n");
|
|
|
|
DebugPrintf("VM:\n");
|
|
|
|
DebugPrintf(" script_steps - Shows the number of executed SCI operations\n");
|
2010-06-27 20:43:32 +00:00
|
|
|
DebugPrintf(" vm_varlist / vmvarlist / vl - Shows the addresses of variables in the VM\n");
|
|
|
|
DebugPrintf(" vm_vars / vmvars / vv - Displays or changes variables in the VM\n");
|
2009-06-03 09:45:16 +00:00
|
|
|
DebugPrintf(" stack - Lists the specified number of stack elements\n");
|
|
|
|
DebugPrintf(" value_type - Determines the type of a value\n");
|
|
|
|
DebugPrintf(" view_listnode - Examines the list node at the given address\n");
|
2009-06-15 08:44:35 +00:00
|
|
|
DebugPrintf(" view_reference / vr - Examines an arbitrary reference\n");
|
|
|
|
DebugPrintf(" view_object / vo - Examines the object at the given address\n");
|
2009-06-03 09:45:16 +00:00
|
|
|
DebugPrintf(" active_object - Shows information on the currently active object or class\n");
|
|
|
|
DebugPrintf(" acc_object - Shows information on the object or class at the address indexed by the accumulator\n");
|
|
|
|
DebugPrintf("\n");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
ResourceType parseResourceType(const char *resid) {
|
2009-05-23 19:59:42 +00:00
|
|
|
// Gets the resource number of a resource string, or returns -1
|
|
|
|
ResourceType res = kResourceTypeInvalid;
|
|
|
|
|
|
|
|
for (int i = 0; i < kResourceTypeInvalid; i++)
|
|
|
|
if (strcmp(getResourceTypeName((ResourceType)i), resid) == 0)
|
|
|
|
res = (ResourceType)i;
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2009-02-20 21:26:31 +00:00
|
|
|
bool Console::cmdGetVersion(int argc, const char **argv) {
|
2010-01-03 20:18:36 +00:00
|
|
|
const char *viewTypeDesc[] = { "Unknown", "EGA", "VGA", "VGA SCI1.1", "Amiga" };
|
|
|
|
|
2010-02-13 17:44:19 +00:00
|
|
|
bool hasVocab997 = g_sci->getResMan()->testResource(ResourceId(kResourceTypeVocab, VOCAB_RESOURCE_SELECTORS)) ? true : false;
|
2010-01-03 20:18:36 +00:00
|
|
|
|
2010-06-25 16:16:29 +00:00
|
|
|
DebugPrintf("Game ID: %s\n", _engine->getGameIdStr());
|
2010-02-13 11:58:15 +00:00
|
|
|
DebugPrintf("Emulated interpreter version: %s\n", getSciVersionDesc(getSciVersion()));
|
2010-01-03 20:18:36 +00:00
|
|
|
DebugPrintf("\n");
|
|
|
|
DebugPrintf("Detected features:\n");
|
|
|
|
DebugPrintf("------------------\n");
|
2010-02-13 17:44:58 +00:00
|
|
|
DebugPrintf("Sound type: %s\n", getSciVersionDesc(_engine->_features->detectDoSoundType()));
|
|
|
|
DebugPrintf("Graphics functions type: %s\n", getSciVersionDesc(_engine->_features->detectGfxFunctionsType()));
|
|
|
|
DebugPrintf("Lofs type: %s\n", getSciVersionDesc(_engine->_features->detectLofsType()));
|
2010-06-10 07:48:32 +00:00
|
|
|
DebugPrintf("Move count type: %s\n", (_engine->_features->handleMoveCount()) ? "increment" : "ignore");
|
2010-02-13 17:44:58 +00:00
|
|
|
DebugPrintf("SetCursor type: %s\n", getSciVersionDesc(_engine->_features->detectSetCursorType()));
|
2010-02-13 17:44:19 +00:00
|
|
|
DebugPrintf("View type: %s\n", viewTypeDesc[g_sci->getResMan()->getViewType()]);
|
2010-06-25 10:04:31 +00:00
|
|
|
DebugPrintf("Uses palette merging: %s\n", g_sci->_gfxPalette->isMerging() ? "yes" : "no");
|
2010-02-13 17:44:19 +00:00
|
|
|
DebugPrintf("Resource volume version: %s\n", g_sci->getResMan()->getVolVersionDesc());
|
|
|
|
DebugPrintf("Resource map version: %s\n", g_sci->getResMan()->getMapVersionDesc());
|
2010-01-03 20:18:36 +00:00
|
|
|
DebugPrintf("Contains selector vocabulary (vocab.997): %s\n", hasVocab997 ? "yes" : "no");
|
|
|
|
DebugPrintf("\n");
|
2009-02-22 01:33:16 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-05-26 15:06:21 +00:00
|
|
|
bool Console::cmdOpcodes(int argc, const char **argv) {
|
2009-08-27 23:39:59 +00:00
|
|
|
// Load the opcode table from vocab.998 if it exists, to obtain the opcode names
|
2010-02-13 17:44:19 +00:00
|
|
|
Resource *r = _engine->getResMan()->findResource(ResourceId(kResourceTypeVocab, 998), 0);
|
2009-08-27 23:39:59 +00:00
|
|
|
|
|
|
|
// If the resource couldn't be loaded, leave
|
|
|
|
if (!r) {
|
|
|
|
DebugPrintf("unable to load vocab.998");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
int count = READ_LE_UINT16(r->data);
|
|
|
|
|
2009-05-26 15:06:21 +00:00
|
|
|
DebugPrintf("Opcode names in numeric order [index: type name]:\n");
|
2009-08-27 23:39:59 +00:00
|
|
|
|
|
|
|
for (int i = 0; i < count; i++) {
|
|
|
|
int offset = READ_LE_UINT16(r->data + 2 + i * 2);
|
|
|
|
int len = READ_LE_UINT16(r->data + offset) - 2;
|
|
|
|
int type = READ_LE_UINT16(r->data + offset + 2);
|
|
|
|
// QFG3 has empty opcodes
|
2010-02-02 22:53:33 +00:00
|
|
|
Common::String name = len > 0 ? Common::String((const char *)r->data + offset + 4, len) : "Dummy";
|
2009-08-27 23:39:59 +00:00
|
|
|
DebugPrintf("%03x: %03x %20s | ", i, type, name.c_str());
|
|
|
|
if ((i % 3) == 2)
|
2009-05-26 15:06:21 +00:00
|
|
|
DebugPrintf("\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
DebugPrintf("\n");
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-07-04 15:22:42 +00:00
|
|
|
bool Console::cmdSelector(int argc, const char **argv) {
|
|
|
|
if (argc < 2) {
|
|
|
|
DebugPrintf("Attempts to find the requested selector by name.\n");
|
|
|
|
DebugPrintf("Usage: %s <selector name>\n", argv[0]);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-06-10 15:26:10 +00:00
|
|
|
Common::String name = argv[1];
|
|
|
|
int seeker = _engine->getKernel()->findSelector(name.c_str());
|
|
|
|
if (seeker >= 0) {
|
|
|
|
DebugPrintf("Selector %s found at %03x (%d)\n", name.c_str(), seeker, seeker);
|
|
|
|
return true;
|
2009-07-04 15:22:42 +00:00
|
|
|
}
|
|
|
|
|
2010-06-10 15:26:10 +00:00
|
|
|
DebugPrintf("Selector %s wasn't found\n", name.c_str());
|
2009-07-04 15:22:42 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-05-11 17:10:36 +00:00
|
|
|
bool Console::cmdSelectors(int argc, const char **argv) {
|
|
|
|
DebugPrintf("Selector names in numeric order:\n");
|
2009-08-31 20:09:36 +00:00
|
|
|
Common::String selectorName;
|
2010-02-03 01:32:03 +00:00
|
|
|
for (uint seeker = 0; seeker < _engine->getKernel()->getSelectorNamesSize(); seeker++) {
|
|
|
|
selectorName = _engine->getKernel()->getSelectorName(seeker);
|
2009-08-31 20:09:36 +00:00
|
|
|
if (selectorName != "BAD SELECTOR")
|
|
|
|
DebugPrintf("%03x: %20s | ", seeker, selectorName.c_str());
|
|
|
|
else
|
|
|
|
continue;
|
2009-05-26 15:06:21 +00:00
|
|
|
if ((seeker % 3) == 2)
|
2009-05-11 17:10:36 +00:00
|
|
|
DebugPrintf("\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
DebugPrintf("\n");
|
|
|
|
|
2010-01-29 14:57:18 +00:00
|
|
|
#if 0
|
|
|
|
// For debug/development
|
|
|
|
|
|
|
|
// If we ever need to modify static_selectors.cpp, this code will print the selectors
|
|
|
|
// in a ready to use format
|
|
|
|
Common::DumpFile *outFile = new Common::DumpFile();
|
|
|
|
outFile->open("selectors.txt");
|
|
|
|
char buf[50];
|
|
|
|
Common::String selName;
|
2010-02-03 01:32:03 +00:00
|
|
|
uint totalSize = _engine->getKernel()->getSelectorNamesSize();
|
2010-01-29 14:57:18 +00:00
|
|
|
uint seeker = 0;
|
|
|
|
while (seeker < totalSize) {
|
2010-02-03 01:32:03 +00:00
|
|
|
selName = "\"" + _engine->getKernel()->getSelectorName(seeker) + "\"";
|
2010-01-29 14:57:18 +00:00
|
|
|
sprintf(buf, "%15s, ", selName.c_str());
|
|
|
|
outFile->writeString(buf);
|
|
|
|
|
|
|
|
if (!((seeker + 1) % 5) && seeker)
|
|
|
|
outFile->writeByte('\n');
|
|
|
|
seeker++;
|
|
|
|
}
|
|
|
|
outFile->finalize();
|
|
|
|
outFile->close();
|
|
|
|
#endif
|
|
|
|
|
2009-05-11 17:10:36 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-06-03 09:45:16 +00:00
|
|
|
bool Console::cmdKernelFunctions(int argc, const char **argv) {
|
|
|
|
DebugPrintf("Kernel function names in numeric order:\n");
|
2010-02-03 01:32:03 +00:00
|
|
|
for (uint seeker = 0; seeker < _engine->getKernel()->getKernelNamesSize(); seeker++) {
|
|
|
|
DebugPrintf("%03x: %20s | ", seeker, _engine->getKernel()->getKernelName(seeker).c_str());
|
2009-05-26 15:06:21 +00:00
|
|
|
if ((seeker % 3) == 2)
|
2009-05-11 17:10:36 +00:00
|
|
|
DebugPrintf("\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
DebugPrintf("\n");
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-05-12 08:14:24 +00:00
|
|
|
bool Console::cmdSuffixes(int argc, const char **argv) {
|
2010-02-03 01:32:03 +00:00
|
|
|
_engine->getVocabulary()->printSuffixes();
|
2009-05-12 08:14:24 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-05-31 12:05:49 +00:00
|
|
|
bool Console::cmdParserWords(int argc, const char **argv) {
|
2010-02-03 01:32:03 +00:00
|
|
|
_engine->getVocabulary()->printParserWords();
|
2009-05-12 08:14:24 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-06-06 16:43:13 +00:00
|
|
|
bool Console::cmdSetParseNodes(int argc, const char **argv) {
|
|
|
|
if (argc < 2) {
|
|
|
|
DebugPrintf("Sets the contents of all parse nodes.\n");
|
|
|
|
DebugPrintf("Usage: %s <parse node1> <parse node2> ... <parse noden>\n", argv[0]);
|
|
|
|
DebugPrintf("Tokens should be separated by blanks and enclosed in parentheses\n");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
int i = 0;
|
|
|
|
int pos = -1;
|
|
|
|
int nextToken = 0, nextValue = 0;
|
|
|
|
|
|
|
|
const char *token = argv[i++];
|
|
|
|
|
|
|
|
if (!strcmp(token, "(")) {
|
|
|
|
nextToken = kParseOpeningParenthesis;
|
|
|
|
} else if (!strcmp(token, ")")) {
|
|
|
|
nextToken = kParseClosingParenthesis;
|
|
|
|
} else if (!strcmp(token, "nil")) {
|
|
|
|
nextToken = kParseNil;
|
|
|
|
} else {
|
|
|
|
nextValue = strtol(token, NULL, 0);
|
|
|
|
nextToken = kParseNumber;
|
|
|
|
}
|
|
|
|
|
2010-02-03 01:32:03 +00:00
|
|
|
if (_engine->getVocabulary()->parseNodes(&i, &pos, nextToken, nextValue, argc, argv) == -1)
|
2009-06-06 16:43:13 +00:00
|
|
|
return 1;
|
|
|
|
|
2010-02-03 01:32:03 +00:00
|
|
|
_engine->getVocabulary()->dumpParseTree();
|
2009-06-06 16:43:13 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-06-02 19:03:43 +00:00
|
|
|
bool Console::cmdRegisters(int argc, const char **argv) {
|
2010-06-06 23:00:33 +00:00
|
|
|
EngineState *s = _engine->_gamestate;
|
2009-06-02 19:03:43 +00:00
|
|
|
DebugPrintf("Current register values:\n");
|
2010-06-09 07:32:17 +00:00
|
|
|
DebugPrintf("acc=%04x:%04x prev=%04x:%04x &rest=%x\n", PRINT_REG(s->r_acc), PRINT_REG(s->r_prev), s->restAdjust);
|
2009-06-02 19:03:43 +00:00
|
|
|
|
2010-06-06 23:00:33 +00:00
|
|
|
if (!s->_executionStack.empty()) {
|
2009-09-21 21:35:43 +00:00
|
|
|
DebugPrintf("pc=%04x:%04x obj=%04x:%04x fp=ST:%04x sp=ST:%04x\n",
|
2010-06-06 23:00:33 +00:00
|
|
|
PRINT_REG(s->xs->addr.pc), PRINT_REG(s->xs->objp),
|
|
|
|
(unsigned)(s->xs->fp - s->stack_base), (unsigned)(s->xs->sp - s->stack_base));
|
2009-06-02 19:03:43 +00:00
|
|
|
} else
|
2009-06-02 21:07:34 +00:00
|
|
|
DebugPrintf("<no execution stack: pc,obj,fp omitted>\n");
|
2009-06-02 19:03:43 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-01-28 01:45:20 +00:00
|
|
|
bool Console::cmdDiskDump(int argc, const char **argv) {
|
|
|
|
if (argc != 3) {
|
|
|
|
DebugPrintf("Dumps the specified resource to disk as a patch file\n");
|
|
|
|
DebugPrintf("Usage: %s <resource type> <resource number>\n", argv[0]);
|
|
|
|
cmdResourceTypes(argc, argv);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
int resNum = atoi(argv[2]);
|
|
|
|
ResourceType res = parseResourceType(argv[1]);
|
|
|
|
|
|
|
|
if (res == kResourceTypeInvalid)
|
|
|
|
DebugPrintf("Resource type '%s' is not valid\n", argv[1]);
|
|
|
|
else {
|
2010-02-13 17:44:19 +00:00
|
|
|
Resource *resource = _engine->getResMan()->findResource(ResourceId(res, resNum), 0);
|
2010-01-28 01:45:20 +00:00
|
|
|
if (resource) {
|
|
|
|
char outFileName[50];
|
|
|
|
sprintf(outFileName, "%s.%03d", getResourceTypeName(res), resNum);
|
|
|
|
Common::DumpFile *outFile = new Common::DumpFile();
|
|
|
|
outFile->open(outFileName);
|
2010-02-17 23:37:59 +00:00
|
|
|
resource->writeToStream(outFile);
|
2010-01-28 01:45:20 +00:00
|
|
|
outFile->finalize();
|
|
|
|
outFile->close();
|
|
|
|
delete outFile;
|
|
|
|
DebugPrintf("Resource %s.%03d has been dumped to disk\n", argv[1], resNum);
|
|
|
|
} else {
|
|
|
|
DebugPrintf("Resource %s.%03d not found\n", argv[1], resNum);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-05-23 19:59:42 +00:00
|
|
|
bool Console::cmdHexDump(int argc, const char **argv) {
|
|
|
|
if (argc != 3) {
|
2009-06-03 09:45:16 +00:00
|
|
|
DebugPrintf("Dumps the specified resource to standard output\n");
|
2009-05-23 19:59:42 +00:00
|
|
|
DebugPrintf("Usage: %s <resource type> <resource number>\n", argv[0]);
|
2009-05-30 10:22:53 +00:00
|
|
|
cmdResourceTypes(argc, argv);
|
2009-05-23 19:59:42 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
int resNum = atoi(argv[2]);
|
|
|
|
ResourceType res = parseResourceType(argv[1]);
|
|
|
|
|
|
|
|
if (res == kResourceTypeInvalid)
|
|
|
|
DebugPrintf("Resource type '%s' is not valid\n", argv[1]);
|
|
|
|
else {
|
2010-02-13 17:44:19 +00:00
|
|
|
Resource *resource = _engine->getResMan()->findResource(ResourceId(res, resNum), 0);
|
2009-05-23 19:59:42 +00:00
|
|
|
if (resource) {
|
|
|
|
Common::hexdump(resource->data, resource->size, 16, 0);
|
2009-05-29 13:19:18 +00:00
|
|
|
DebugPrintf("Resource %s.%03d has been dumped to standard output\n", argv[1], resNum);
|
2009-05-23 19:59:42 +00:00
|
|
|
} else {
|
|
|
|
DebugPrintf("Resource %s.%03d not found\n", argv[1], resNum);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-06-02 19:03:43 +00:00
|
|
|
bool Console::cmdResourceId(int argc, const char **argv) {
|
|
|
|
if (argc != 2) {
|
|
|
|
DebugPrintf("Identifies a resource number by splitting it up in resource type and resource number\n");
|
|
|
|
DebugPrintf("Usage: %s <resource number>\n", argv[0]);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
int id = atoi(argv[1]);
|
|
|
|
DebugPrintf("%s.%d (0x%x)\n", getResourceTypeName((ResourceType)(id >> 11)), id & 0x7ff, id & 0x7ff);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-05-23 19:59:42 +00:00
|
|
|
bool Console::cmdDissectScript(int argc, const char **argv) {
|
|
|
|
if (argc != 2) {
|
|
|
|
DebugPrintf("Examines a script\n");
|
|
|
|
DebugPrintf("Usage: %s <script number>\n", argv[0]);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-02-03 01:32:03 +00:00
|
|
|
_engine->getKernel()->dissectScript(atoi(argv[1]), _engine->getVocabulary());
|
2009-05-23 19:59:42 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-05-27 16:45:42 +00:00
|
|
|
bool Console::cmdRoomNumber(int argc, const char **argv) {
|
2010-01-03 15:08:26 +00:00
|
|
|
// The room number is stored in global var 13
|
|
|
|
// The same functionality is provided by "vmvars g 13" (but this one is more straighforward)
|
|
|
|
|
|
|
|
if (argc != 2) {
|
2010-02-03 01:32:03 +00:00
|
|
|
DebugPrintf("Current room number is %d\n", _engine->_gamestate->currentRoomNumber());
|
2010-01-03 15:08:26 +00:00
|
|
|
DebugPrintf("Calling this command with the room number (in decimal or hexadecimal) changes the room\n");
|
|
|
|
} else {
|
|
|
|
Common::String roomNumberStr = argv[1];
|
|
|
|
int roomNumber = strtol(roomNumberStr.c_str(), NULL, roomNumberStr.hasSuffix("h") ? 16 : 10);
|
2010-02-03 01:32:03 +00:00
|
|
|
_engine->_gamestate->setRoomNumber(roomNumber);
|
2010-01-03 15:08:26 +00:00
|
|
|
DebugPrintf("Room number changed to %d (%x in hex)\n", roomNumber, roomNumber);
|
|
|
|
}
|
2009-05-27 16:45:42 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-05-29 08:59:13 +00:00
|
|
|
bool Console::cmdResourceSize(int argc, const char **argv) {
|
2009-05-29 13:19:18 +00:00
|
|
|
if (argc != 3) {
|
2009-05-29 08:59:13 +00:00
|
|
|
DebugPrintf("Shows the size of a resource\n");
|
2009-05-29 13:19:18 +00:00
|
|
|
DebugPrintf("Usage: %s <resource type> <resource number>\n", argv[0]);
|
2009-05-29 08:59:13 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
int resNum = atoi(argv[2]);
|
|
|
|
ResourceType res = parseResourceType(argv[1]);
|
|
|
|
|
|
|
|
if (res == kResourceTypeInvalid)
|
|
|
|
DebugPrintf("Resource type '%s' is not valid\n", argv[1]);
|
|
|
|
else {
|
2010-02-13 17:44:19 +00:00
|
|
|
Resource *resource = _engine->getResMan()->findResource(ResourceId(res, resNum), 0);
|
2009-05-29 08:59:13 +00:00
|
|
|
if (resource) {
|
|
|
|
DebugPrintf("Resource size: %d\n", resource->size);
|
|
|
|
} else {
|
|
|
|
DebugPrintf("Resource %s.%03d not found\n", argv[1], resNum);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-05-29 17:19:39 +00:00
|
|
|
bool Console::cmdResourceTypes(int argc, const char **argv) {
|
|
|
|
DebugPrintf("The %d valid resource types are:\n", kResourceTypeInvalid);
|
|
|
|
for (int i = 0; i < kResourceTypeInvalid; i++) {
|
|
|
|
DebugPrintf("%s", getResourceTypeName((ResourceType) i));
|
|
|
|
DebugPrintf((i < kResourceTypeInvalid - 1) ? ", " : "\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-05-30 10:22:53 +00:00
|
|
|
bool Console::cmdHexgrep(int argc, const char **argv) {
|
|
|
|
if (argc < 4) {
|
|
|
|
DebugPrintf("Searches some resources for a particular sequence of bytes, represented as hexadecimal numbers.\n");
|
|
|
|
DebugPrintf("Usage: %s <resource type> <resource number> <search string>\n", argv[0]);
|
|
|
|
DebugPrintf("<resource number> can be a specific resource number, or \"all\" for all of the resources of the specified type\n", argv[0]);
|
|
|
|
DebugPrintf("EXAMPLES:\n hexgrep script all e8 03 c8 00\n hexgrep pic 042 fe");
|
|
|
|
cmdResourceTypes(argc, argv);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
ResourceType restype = parseResourceType(argv[1]);
|
|
|
|
int resNumber = 0, resMax = 0;
|
|
|
|
char seekString[500];
|
|
|
|
Resource *script = NULL;
|
|
|
|
|
|
|
|
if (restype == kResourceTypeInvalid) {
|
|
|
|
DebugPrintf("Resource type '%s' is not valid\n", argv[1]);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!scumm_stricmp(argv[2], "all")) {
|
|
|
|
resNumber = 0;
|
|
|
|
resMax = 999;
|
|
|
|
} else {
|
|
|
|
resNumber = resMax = atoi(argv[2]);
|
|
|
|
}
|
|
|
|
|
|
|
|
strcpy(seekString, argv[3]);
|
|
|
|
|
|
|
|
// Construct the seek string
|
|
|
|
for (int i = 4; i < argc; i++) {
|
|
|
|
strcat(seekString, argv[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (; resNumber <= resMax; resNumber++) {
|
2010-02-13 17:44:19 +00:00
|
|
|
script = _engine->getResMan()->findResource(ResourceId(restype, resNumber), 0);
|
2010-02-02 22:53:33 +00:00
|
|
|
if (script) {
|
2009-05-30 10:22:53 +00:00
|
|
|
unsigned int seeker = 0, seekerold = 0;
|
|
|
|
uint32 comppos = 0;
|
|
|
|
int output_script_name = 0;
|
|
|
|
|
|
|
|
while (seeker < script->size) {
|
|
|
|
if (script->data[seeker] == seekString[comppos]) {
|
|
|
|
if (comppos == 0)
|
|
|
|
seekerold = seeker;
|
|
|
|
|
|
|
|
comppos++;
|
|
|
|
|
|
|
|
if (comppos == strlen(seekString)) {
|
|
|
|
comppos = 0;
|
|
|
|
seeker = seekerold + 1;
|
|
|
|
|
|
|
|
if (!output_script_name) {
|
|
|
|
DebugPrintf("\nIn %s.%03d:\n", getResourceTypeName((ResourceType)restype), resNumber);
|
|
|
|
output_script_name = 1;
|
|
|
|
}
|
|
|
|
DebugPrintf(" 0x%04x\n", seekerold);
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
comppos = 0;
|
|
|
|
|
|
|
|
seeker++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-05-31 22:57:05 +00:00
|
|
|
bool Console::cmdVerifyScripts(int argc, const char **argv) {
|
|
|
|
if (getSciVersion() < SCI_VERSION_1_1) {
|
|
|
|
DebugPrintf("This script check is only meant for SCI1.1-SCI2.1 games\n");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
Common::List<ResourceId> *resources = _engine->getResMan()->listResources(kResourceTypeScript);
|
2010-06-15 12:31:16 +00:00
|
|
|
Common::sort(resources->begin(), resources->end());
|
2010-05-31 22:57:05 +00:00
|
|
|
Common::List<ResourceId>::iterator itr = resources->begin();
|
|
|
|
|
|
|
|
DebugPrintf("%d SCI1.1-SCI2.1 scripts found, performing sanity checks...\n", resources->size());
|
|
|
|
|
|
|
|
Resource *script, *heap;
|
|
|
|
while (itr != resources->end()) {
|
|
|
|
script = _engine->getResMan()->findResource(*itr, false);
|
|
|
|
if (!script)
|
2010-06-15 12:31:16 +00:00
|
|
|
DebugPrintf("Error: script %d couldn't be loaded\n", itr->getNumber());
|
2010-05-31 22:57:05 +00:00
|
|
|
|
2010-06-15 12:31:16 +00:00
|
|
|
heap = _engine->getResMan()->findResource(ResourceId(kResourceTypeHeap, itr->getNumber()), false);
|
2010-05-31 22:57:05 +00:00
|
|
|
if (!heap)
|
2010-06-15 12:31:16 +00:00
|
|
|
DebugPrintf("Error: script %d doesn't have a corresponding heap\n", itr->getNumber());
|
2010-05-31 22:57:05 +00:00
|
|
|
|
|
|
|
if (script && heap && (script->size + heap->size > 65535))
|
|
|
|
DebugPrintf("Error: script and heap %d together are larger than 64KB (%d bytes)\n",
|
2010-06-15 12:31:16 +00:00
|
|
|
itr->getNumber(), script->size + heap->size);
|
2010-05-31 22:57:05 +00:00
|
|
|
|
|
|
|
++itr;
|
|
|
|
}
|
|
|
|
|
|
|
|
DebugPrintf("SCI1.1-SCI2.1 script check finished\n");
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-06-11 19:49:41 +00:00
|
|
|
bool Console::cmdShowInstruments(int argc, const char **argv) {
|
|
|
|
int songNumber = -1;
|
|
|
|
|
|
|
|
if (argc == 2)
|
|
|
|
songNumber = atoi(argv[1]);
|
|
|
|
|
2010-06-11 14:47:13 +00:00
|
|
|
SciVersion doSoundVersion = _engine->_features->detectDoSoundType();
|
|
|
|
MidiPlayer *player = MidiPlayer_Midi_create(doSoundVersion);
|
2010-06-16 21:07:26 +00:00
|
|
|
MidiParser_SCI *parser = new MidiParser_SCI(doSoundVersion, 0);
|
2010-06-11 14:47:13 +00:00
|
|
|
parser->setMidiDriver(player);
|
2010-06-11 19:49:41 +00:00
|
|
|
|
2010-06-11 14:47:13 +00:00
|
|
|
Common::List<ResourceId> *resources = _engine->getResMan()->listResources(kResourceTypeSound);
|
2010-06-15 12:31:16 +00:00
|
|
|
Common::sort(resources->begin(), resources->end());
|
2010-06-11 14:47:13 +00:00
|
|
|
Common::List<ResourceId>::iterator itr = resources->begin();
|
2010-06-11 19:49:41 +00:00
|
|
|
int instruments[128];
|
2010-06-12 09:29:28 +00:00
|
|
|
bool instrumentsSongs[128][1000];
|
|
|
|
|
2010-06-11 19:49:41 +00:00
|
|
|
for (int i = 0; i < 128; i++)
|
|
|
|
instruments[i] = 0;
|
|
|
|
|
2010-06-12 09:29:28 +00:00
|
|
|
for (int i = 0; i < 128; i++)
|
|
|
|
for (int j = 0; j < 1000; j++)
|
|
|
|
instrumentsSongs[i][j] = false;
|
|
|
|
|
2010-06-11 19:49:41 +00:00
|
|
|
if (songNumber == -1) {
|
|
|
|
DebugPrintf("%d sounds found, checking their instrument mappings...\n", resources->size());
|
|
|
|
DebugPrintf("Instruments:\n");
|
|
|
|
DebugPrintf("============\n");
|
|
|
|
}
|
2010-06-11 14:47:13 +00:00
|
|
|
|
|
|
|
SoundResource *sound;
|
|
|
|
|
|
|
|
while (itr != resources->end()) {
|
2010-06-15 12:31:16 +00:00
|
|
|
if (songNumber >= 0 && itr->getNumber() != songNumber) {
|
2010-06-11 19:49:41 +00:00
|
|
|
++itr;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2010-06-15 12:31:16 +00:00
|
|
|
sound = new SoundResource(itr->getNumber(), _engine->getResMan(), doSoundVersion);
|
2010-06-11 14:47:13 +00:00
|
|
|
int channelFilterMask = sound->getChannelFilterMask(player->getPlayId(), player->hasRhythmChannel());
|
|
|
|
SoundResource::Track *track = sound->getTrackByType(player->getPlayId());
|
|
|
|
if (track->digitalChannelNr != -1) {
|
|
|
|
// Skip digitized sound effects
|
|
|
|
delete sound;
|
2010-06-11 19:49:41 +00:00
|
|
|
++itr;
|
2010-06-11 14:47:13 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
parser->loadMusic(track, NULL, channelFilterMask, doSoundVersion);
|
|
|
|
const byte *channelData = parser->getMixedData();
|
|
|
|
|
2010-06-11 19:49:41 +00:00
|
|
|
byte curEvent = 0, prevEvent = 0, command = 0;
|
2010-06-11 14:47:13 +00:00
|
|
|
bool endOfTrack = false;
|
2010-06-11 19:49:41 +00:00
|
|
|
bool firstOneShown = false;
|
|
|
|
|
2010-06-15 12:31:16 +00:00
|
|
|
DebugPrintf("Song %d: ", itr->getNumber());
|
2010-06-11 14:47:13 +00:00
|
|
|
|
|
|
|
do {
|
|
|
|
while (*channelData == 0xF8)
|
|
|
|
channelData++;
|
|
|
|
|
|
|
|
channelData++; // delta
|
|
|
|
|
|
|
|
if ((*channelData & 0xF0) >= 0x80)
|
|
|
|
curEvent = *(channelData++);
|
|
|
|
else
|
2010-06-11 19:49:41 +00:00
|
|
|
curEvent = prevEvent;
|
2010-06-11 14:47:13 +00:00
|
|
|
if (curEvent < 0x80)
|
|
|
|
continue;
|
|
|
|
|
2010-06-11 19:49:41 +00:00
|
|
|
prevEvent = curEvent;
|
2010-06-11 14:47:13 +00:00
|
|
|
command = curEvent >> 4;
|
|
|
|
|
2010-06-18 15:18:14 +00:00
|
|
|
byte channel;
|
|
|
|
|
2010-06-11 14:47:13 +00:00
|
|
|
switch (command) {
|
|
|
|
case 0xC: // program change
|
2010-06-18 15:18:14 +00:00
|
|
|
channel = curEvent & 0x0F;
|
|
|
|
if (channel != 15) { // SCI special
|
|
|
|
byte instrument = *channelData++;
|
|
|
|
if (!firstOneShown)
|
|
|
|
firstOneShown = true;
|
|
|
|
else
|
|
|
|
DebugPrintf(",");
|
|
|
|
|
|
|
|
DebugPrintf(" %d", instrument);
|
|
|
|
instruments[instrument]++;
|
|
|
|
instrumentsSongs[instrument][itr->getNumber()] = true;
|
2010-06-11 19:49:41 +00:00
|
|
|
}
|
2010-06-11 14:47:13 +00:00
|
|
|
break;
|
|
|
|
case 0xD:
|
2010-06-11 19:49:41 +00:00
|
|
|
channelData++; // param1
|
|
|
|
break;
|
2010-06-11 14:47:13 +00:00
|
|
|
case 0xB:
|
2010-06-11 19:49:41 +00:00
|
|
|
channelData++; // param1
|
|
|
|
channelData++; // param2
|
2010-06-11 14:47:13 +00:00
|
|
|
break;
|
|
|
|
case 0x8:
|
|
|
|
case 0x9:
|
|
|
|
case 0xA:
|
|
|
|
case 0xE:
|
2010-06-11 19:49:41 +00:00
|
|
|
channelData++; // param1
|
|
|
|
channelData++; // param2
|
2010-06-11 14:47:13 +00:00
|
|
|
break;
|
|
|
|
case 0xF:
|
|
|
|
if ((curEvent & 0x0F) == 0x2) {
|
2010-06-11 19:49:41 +00:00
|
|
|
channelData++; // param1
|
|
|
|
channelData++; // param2
|
2010-06-11 14:47:13 +00:00
|
|
|
} else if ((curEvent & 0x0F) == 0x3) {
|
2010-06-11 19:49:41 +00:00
|
|
|
channelData++; // param1
|
2010-06-11 14:47:13 +00:00
|
|
|
} else if ((curEvent & 0x0F) == 0xF) { // META
|
|
|
|
byte type = *channelData++;
|
|
|
|
if (type == 0x2F) {// end of track reached
|
|
|
|
endOfTrack = true;
|
|
|
|
} else {
|
|
|
|
// no further processing necessary
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} while (!endOfTrack);
|
|
|
|
|
2010-06-11 19:49:41 +00:00
|
|
|
DebugPrintf("\n");
|
|
|
|
|
2010-06-11 14:47:13 +00:00
|
|
|
delete sound;
|
|
|
|
++itr;
|
|
|
|
}
|
|
|
|
|
|
|
|
delete parser;
|
|
|
|
delete player;
|
|
|
|
|
2010-06-11 19:49:41 +00:00
|
|
|
DebugPrintf("\n");
|
|
|
|
|
|
|
|
if (songNumber == -1) {
|
|
|
|
DebugPrintf("Used instruments: ");
|
|
|
|
for (int i = 0; i < 128; i++) {
|
|
|
|
if (instruments[i] > 0)
|
|
|
|
DebugPrintf("%d, ", i);
|
|
|
|
}
|
|
|
|
DebugPrintf("\n\n");
|
2010-06-12 09:29:28 +00:00
|
|
|
|
|
|
|
DebugPrintf("Used instruments in songs:\n");
|
|
|
|
for (int i = 0; i < 128; i++) {
|
|
|
|
if (instruments[i] > 0) {
|
|
|
|
DebugPrintf("Instrument %d: ", i);
|
|
|
|
for (int j = 0; j < 1000; j++) {
|
|
|
|
if (instrumentsSongs[i][j])
|
|
|
|
DebugPrintf("%d, ", j);
|
|
|
|
}
|
|
|
|
DebugPrintf("\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DebugPrintf("\n\n");
|
2010-06-11 19:49:41 +00:00
|
|
|
}
|
2010-06-11 14:47:13 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-05-30 10:22:53 +00:00
|
|
|
bool Console::cmdList(int argc, const char **argv) {
|
2009-06-07 19:15:55 +00:00
|
|
|
if (argc < 2) {
|
2009-06-03 09:45:16 +00:00
|
|
|
DebugPrintf("Lists all the resources of a given type\n");
|
2009-05-30 10:22:53 +00:00
|
|
|
cmdResourceTypes(argc, argv);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ResourceType res = parseResourceType(argv[1]);
|
|
|
|
if (res == kResourceTypeInvalid)
|
|
|
|
DebugPrintf("Unknown resource type: '%s'\n", argv[1]);
|
|
|
|
else {
|
2009-06-07 19:15:55 +00:00
|
|
|
int number = -1;
|
|
|
|
|
|
|
|
if ((res == kResourceTypeAudio36) || (res == kResourceTypeSync36)) {
|
|
|
|
if (argc != 3) {
|
|
|
|
DebugPrintf("Please specify map number\n");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
number = atoi(argv[2]);
|
|
|
|
}
|
|
|
|
|
2010-02-13 17:44:19 +00:00
|
|
|
Common::List<ResourceId> *resources = _engine->getResMan()->listResources(res, number);
|
2010-06-15 12:31:16 +00:00
|
|
|
Common::sort(resources->begin(), resources->end());
|
2009-06-07 19:15:55 +00:00
|
|
|
Common::List<ResourceId>::iterator itr = resources->begin();
|
|
|
|
|
|
|
|
int cnt = 0;
|
|
|
|
while (itr != resources->end()) {
|
|
|
|
if (number == -1) {
|
2010-06-15 12:31:16 +00:00
|
|
|
DebugPrintf("%8i", itr->getNumber());
|
2009-06-07 19:15:55 +00:00
|
|
|
if (++cnt % 10 == 0)
|
2009-05-30 10:22:53 +00:00
|
|
|
DebugPrintf("\n");
|
2010-06-15 12:31:16 +00:00
|
|
|
} else if (number == (int)itr->getNumber()) {
|
|
|
|
const uint32 tuple = itr->getTuple();
|
|
|
|
DebugPrintf("(%3i, %3i, %3i, %3i) ", (tuple >> 24) & 0xff, (tuple >> 16) & 0xff,
|
|
|
|
(tuple >> 8) & 0xff, tuple & 0xff);
|
2009-06-07 19:15:55 +00:00
|
|
|
if (++cnt % 4 == 0)
|
|
|
|
DebugPrintf("\n");
|
|
|
|
}
|
2010-01-13 23:58:25 +00:00
|
|
|
++itr;
|
2009-05-30 10:22:53 +00:00
|
|
|
}
|
|
|
|
DebugPrintf("\n");
|
2009-06-07 19:15:55 +00:00
|
|
|
|
|
|
|
delete resources;
|
2009-05-30 10:22:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-05-30 13:04:09 +00:00
|
|
|
bool Console::cmdSaveGame(int argc, const char **argv) {
|
|
|
|
if (argc != 2) {
|
2009-06-03 09:45:16 +00:00
|
|
|
DebugPrintf("Saves the current game state to the hard disk\n");
|
2009-05-30 13:04:09 +00:00
|
|
|
DebugPrintf("Usage: %s <filename>\n", argv[0]);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
int result = 0;
|
2010-02-03 01:32:03 +00:00
|
|
|
for (uint i = 0; i < _engine->_gamestate->_fileHandles.size(); i++)
|
|
|
|
if (_engine->_gamestate->_fileHandles[i].isOpen())
|
2009-05-30 13:04:09 +00:00
|
|
|
result++;
|
|
|
|
|
|
|
|
if (result)
|
|
|
|
DebugPrintf("Note: Game state has %d open file handles.\n", result);
|
|
|
|
|
|
|
|
Common::SaveFileManager *saveFileMan = g_engine->getSaveFileManager();
|
2009-10-11 15:51:43 +00:00
|
|
|
Common::OutSaveFile *out = saveFileMan->openForSaving(argv[1]);
|
|
|
|
const char *version = "";
|
|
|
|
if (!out) {
|
2009-05-30 13:04:09 +00:00
|
|
|
DebugPrintf("Error opening savegame \"%s\" for writing\n", argv[1]);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: enable custom descriptions? force filename into a specific format?
|
2010-06-15 08:39:03 +00:00
|
|
|
if (!gamestate_save(_engine->_gamestate, out, "debugging", version)) {
|
2009-05-30 13:04:09 +00:00
|
|
|
DebugPrintf("Saving the game state to '%s' failed\n", argv[1]);
|
2010-01-28 01:45:20 +00:00
|
|
|
} else {
|
|
|
|
out->finalize();
|
|
|
|
if (out->err()) {
|
|
|
|
warning("Writing the savegame failed.");
|
|
|
|
}
|
|
|
|
delete out;
|
2009-05-30 13:04:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Console::cmdRestoreGame(int argc, const char **argv) {
|
|
|
|
if (argc != 2) {
|
|
|
|
DebugPrintf("Restores a saved game from the hard disk\n");
|
|
|
|
DebugPrintf("Usage: %s <filename>\n", argv[0]);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
Common::SaveFileManager *saveFileMan = g_engine->getSaveFileManager();
|
2009-10-11 15:51:43 +00:00
|
|
|
Common::SeekableReadStream *in = saveFileMan->openForLoading(argv[1]);
|
|
|
|
if (in) {
|
2009-05-30 13:04:09 +00:00
|
|
|
// found a savegame file
|
2010-02-03 01:32:03 +00:00
|
|
|
gamestate_restore(_engine->_gamestate, in);
|
2009-05-30 13:04:09 +00:00
|
|
|
delete in;
|
|
|
|
}
|
|
|
|
|
2010-02-03 01:32:03 +00:00
|
|
|
if (_engine->_gamestate->r_acc == make_reg(0, 1)) {
|
2009-05-30 18:22:55 +00:00
|
|
|
DebugPrintf("Restoring gamestate '%s' failed.\n", argv[1]);
|
2010-01-31 01:26:06 +00:00
|
|
|
return true;
|
2009-05-30 13:04:09 +00:00
|
|
|
}
|
|
|
|
|
2010-07-16 19:40:51 +00:00
|
|
|
return Cmd_Exit(0, 0);
|
2009-05-30 13:04:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool Console::cmdRestartGame(int argc, const char **argv) {
|
2010-06-08 21:05:46 +00:00
|
|
|
_engine->_gamestate->abortScriptProcessing = kAbortRestartGame;;
|
2009-05-30 13:04:09 +00:00
|
|
|
|
2010-07-16 19:40:51 +00:00
|
|
|
return Cmd_Exit(0, 0);
|
2009-05-30 13:04:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool Console::cmdClassTable(int argc, const char **argv) {
|
|
|
|
DebugPrintf("Available classes:\n");
|
2010-05-29 23:56:37 +00:00
|
|
|
for (uint i = 0; i < _engine->_gamestate->_segMan->classTableSize(); i++) {
|
|
|
|
if (_engine->_gamestate->_segMan->_classTable[i].reg.segment) {
|
2009-09-21 21:35:43 +00:00
|
|
|
DebugPrintf(" Class 0x%x at %04x:%04x (script 0x%x)\n", i,
|
2010-05-29 23:56:37 +00:00
|
|
|
PRINT_REG(_engine->_gamestate->_segMan->_classTable[i].reg),
|
|
|
|
_engine->_gamestate->_segMan->_classTable[i].script);
|
2009-05-30 13:04:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-05-30 20:01:43 +00:00
|
|
|
bool Console::cmdSentenceFragments(int argc, const char **argv) {
|
2009-06-03 09:45:16 +00:00
|
|
|
DebugPrintf("Sentence fragments (used to build Parse trees)\n");
|
2009-05-30 20:01:43 +00:00
|
|
|
|
2010-02-03 01:32:03 +00:00
|
|
|
for (uint i = 0; i < _engine->getVocabulary()->getParserBranchesSize(); i++) {
|
2009-05-30 20:01:43 +00:00
|
|
|
int j = 0;
|
|
|
|
|
2010-02-03 01:32:03 +00:00
|
|
|
const parse_tree_branch_t &branch = _engine->getVocabulary()->getParseTreeBranch(i);
|
2009-05-31 15:08:47 +00:00
|
|
|
DebugPrintf("R%02d: [%x] ->", i, branch.id);
|
|
|
|
while ((j < 10) && branch.data[j]) {
|
|
|
|
int dat = branch.data[j++];
|
2009-05-30 20:01:43 +00:00
|
|
|
|
|
|
|
switch (dat) {
|
|
|
|
case VOCAB_TREE_NODE_COMPARE_TYPE:
|
2009-05-31 15:08:47 +00:00
|
|
|
dat = branch.data[j++];
|
2009-05-30 20:01:43 +00:00
|
|
|
DebugPrintf(" C(%x)", dat);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VOCAB_TREE_NODE_COMPARE_GROUP:
|
2009-05-31 15:08:47 +00:00
|
|
|
dat = branch.data[j++];
|
2009-05-30 20:01:43 +00:00
|
|
|
DebugPrintf(" WG(%x)", dat);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VOCAB_TREE_NODE_FORCE_STORAGE:
|
2009-05-31 15:08:47 +00:00
|
|
|
dat = branch.data[j++];
|
2009-05-30 20:01:43 +00:00
|
|
|
DebugPrintf(" FORCE(%x)", dat);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
if (dat > VOCAB_TREE_NODE_LAST_WORD_STORAGE) {
|
2009-05-31 15:08:47 +00:00
|
|
|
int dat2 = branch.data[j++];
|
2009-05-30 20:01:43 +00:00
|
|
|
DebugPrintf(" %x[%x]", dat, dat2);
|
|
|
|
} else
|
|
|
|
DebugPrintf(" ?%x?", dat);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
DebugPrintf("\n");
|
|
|
|
}
|
|
|
|
|
2010-02-03 01:32:03 +00:00
|
|
|
DebugPrintf("%d rules.\n", _engine->getVocabulary()->getParserBranchesSize());
|
2009-05-30 20:01:43 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-06-03 11:38:12 +00:00
|
|
|
bool Console::cmdParse(int argc, const char **argv) {
|
|
|
|
if (argc < 2) {
|
|
|
|
DebugPrintf("Parses a sequence of words with a GNF rule set and prints the resulting parse tree\n");
|
|
|
|
DebugPrintf("Usage: %s <word1> <word2> ... <wordn>\n", argv[0]);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
ResultWordList words;
|
|
|
|
char *error;
|
|
|
|
char string[1000];
|
|
|
|
|
|
|
|
// Construct the string
|
2010-07-17 12:37:02 +00:00
|
|
|
strcpy(string, argv[1]);
|
2009-06-03 11:38:12 +00:00
|
|
|
for (int i = 2; i < argc; i++) {
|
2010-07-17 12:37:02 +00:00
|
|
|
strcat(string, " ");
|
2009-06-03 11:38:12 +00:00
|
|
|
strcat(string, argv[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
DebugPrintf("Parsing '%s'\n", string);
|
2010-02-03 01:32:03 +00:00
|
|
|
bool res = _engine->getVocabulary()->tokenizeString(words, string, &error);
|
2009-06-03 11:38:12 +00:00
|
|
|
if (res && !words.empty()) {
|
|
|
|
int syntax_fail = 0;
|
|
|
|
|
2010-02-03 01:32:03 +00:00
|
|
|
_engine->getVocabulary()->synonymizeTokens(words);
|
2009-06-03 11:38:12 +00:00
|
|
|
|
|
|
|
DebugPrintf("Parsed to the following blocks:\n");
|
|
|
|
|
|
|
|
for (ResultWordList::const_iterator i = words.begin(); i != words.end(); ++i)
|
|
|
|
DebugPrintf(" Type[%04x] Group[%04x]\n", i->_class, i->_group);
|
|
|
|
|
2010-02-03 01:32:03 +00:00
|
|
|
if (_engine->getVocabulary()->parseGNF(words, true))
|
2009-06-03 11:38:12 +00:00
|
|
|
syntax_fail = 1; // Building a tree failed
|
|
|
|
|
|
|
|
if (syntax_fail)
|
|
|
|
DebugPrintf("Building a tree failed.\n");
|
|
|
|
else
|
2010-02-03 01:32:03 +00:00
|
|
|
_engine->getVocabulary()->dumpParseTree();
|
2009-06-03 11:38:12 +00:00
|
|
|
|
|
|
|
} else {
|
|
|
|
DebugPrintf("Unknown word: '%s'\n", error);
|
|
|
|
free(error);
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-07-18 13:31:05 +00:00
|
|
|
bool Console::cmdSaid(int argc, const char **argv) {
|
|
|
|
if (argc < 2) {
|
|
|
|
DebugPrintf("Matches a string against a said spec\n");
|
|
|
|
DebugPrintf("Usage: %s <string> > & <said spec>\n", argv[0]);
|
|
|
|
DebugPrintf("<string> is a sequence of actual words.\n");
|
|
|
|
DebugPrintf("<said spec> is a sequence of hex tokens.\n");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
ResultWordList words;
|
|
|
|
char *error;
|
|
|
|
char string[1000];
|
|
|
|
byte spec[1000];
|
|
|
|
|
|
|
|
int p;
|
|
|
|
// Construct the string
|
|
|
|
strcpy(string, argv[1]);
|
|
|
|
for (p = 2; p < argc && strcmp(argv[p],"&") != 0; p++) {
|
|
|
|
strcat(string, " ");
|
|
|
|
strcat(string, argv[p]);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (p >= argc-1) {
|
|
|
|
DebugPrintf("Matches a string against a said spec\n");
|
|
|
|
DebugPrintf("Usage: %s <string> > & <said spec>\n", argv[0]);
|
|
|
|
DebugPrintf("<string> is a sequence of actual words.\n");
|
|
|
|
DebugPrintf("<said spec> is a sequence of hex tokens.\n");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: Maybe turn this into a proper said spec compiler
|
|
|
|
unsigned int len = 0;
|
|
|
|
for (p++; p < argc; p++) {
|
|
|
|
if (strcmp(argv[p], ",") == 0) {
|
|
|
|
spec[len++] = 0xf0;
|
|
|
|
} else if (strcmp(argv[p], "&") == 0) {
|
|
|
|
spec[len++] = 0xf1;
|
|
|
|
} else if (strcmp(argv[p], "/") == 0) {
|
|
|
|
spec[len++] = 0xf2;
|
|
|
|
} else if (strcmp(argv[p], "(") == 0) {
|
|
|
|
spec[len++] = 0xf3;
|
|
|
|
} else if (strcmp(argv[p], ")") == 0) {
|
|
|
|
spec[len++] = 0xf4;
|
|
|
|
} else if (strcmp(argv[p], "[") == 0) {
|
|
|
|
spec[len++] = 0xf5;
|
|
|
|
} else if (strcmp(argv[p], "]") == 0) {
|
|
|
|
spec[len++] = 0xf6;
|
|
|
|
} else if (strcmp(argv[p], "#") == 0) {
|
|
|
|
spec[len++] = 0xf7;
|
|
|
|
} else if (strcmp(argv[p], "<") == 0) {
|
|
|
|
spec[len++] = 0xf8;
|
|
|
|
} else if (strcmp(argv[p], ">") == 0) {
|
|
|
|
spec[len++] = 0xf9;
|
|
|
|
} else if (strcmp(argv[p], "[<") == 0) {
|
|
|
|
spec[len++] = 0xf5;
|
|
|
|
spec[len++] = 0xf8;
|
|
|
|
} else if (strcmp(argv[p], "[/") == 0) {
|
|
|
|
spec[len++] = 0xf5;
|
|
|
|
spec[len++] = 0xf2;
|
|
|
|
} else if (strcmp(argv[p], "!*") == 0) {
|
|
|
|
spec[len++] = 0x0f;
|
|
|
|
spec[len++] = 0xfe;
|
|
|
|
} else if (strcmp(argv[p], "[!*]") == 0) {
|
|
|
|
spec[len++] = 0xf5;
|
|
|
|
spec[len++] = 0x0f;
|
|
|
|
spec[len++] = 0xfe;
|
|
|
|
spec[len++] = 0xf6;
|
|
|
|
} else {
|
|
|
|
unsigned int s = strtol(argv[p], 0, 16);
|
|
|
|
if (s >= 0xf0 && s <= 0xff) {
|
|
|
|
spec[len++] = s;
|
|
|
|
} else {
|
|
|
|
spec[len++] = s >> 8;
|
|
|
|
spec[len++] = s & 0xFF;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
spec[len++] = 0xFF;
|
|
|
|
|
|
|
|
printf("Matching '%s' against:", string);
|
|
|
|
_engine->getVocabulary()->decipherSaidBlock(spec);
|
|
|
|
|
|
|
|
bool res = _engine->getVocabulary()->tokenizeString(words, string, &error);
|
|
|
|
if (res && !words.empty()) {
|
|
|
|
int syntax_fail = 0;
|
|
|
|
|
|
|
|
_engine->getVocabulary()->synonymizeTokens(words);
|
|
|
|
|
|
|
|
DebugPrintf("Parsed to the following blocks:\n");
|
|
|
|
|
|
|
|
for (ResultWordList::const_iterator i = words.begin(); i != words.end(); ++i)
|
|
|
|
DebugPrintf(" Type[%04x] Group[%04x]\n", i->_class, i->_group);
|
|
|
|
|
|
|
|
if (_engine->getVocabulary()->parseGNF(words, true))
|
|
|
|
syntax_fail = 1; // Building a tree failed
|
|
|
|
|
|
|
|
if (syntax_fail)
|
|
|
|
DebugPrintf("Building a tree failed.\n");
|
|
|
|
else {
|
|
|
|
_engine->getVocabulary()->dumpParseTree();
|
|
|
|
_engine->getVocabulary()->parserIsValid = true;
|
|
|
|
|
|
|
|
int ret = said(_engine->_gamestate, (byte*)spec, true);
|
|
|
|
DebugPrintf("kSaid: %s\n", (ret == SAID_NO_MATCH ? "No match" : "Match"));
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
DebugPrintf("Unknown word: '%s'\n", error);
|
|
|
|
free(error);
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-05-30 20:01:43 +00:00
|
|
|
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);
|
|
|
|
|
2010-02-03 01:32:03 +00:00
|
|
|
_engine->getVocabulary()->printParserNodes(end);
|
2009-05-30 20:01:43 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-01-05 21:25:59 +00:00
|
|
|
bool Console::cmdSetPalette(int argc, const char **argv) {
|
|
|
|
if (argc < 2) {
|
|
|
|
DebugPrintf("Sets a palette resource\n");
|
|
|
|
DebugPrintf("Usage: %s <resourceId>\n", argv[0]);
|
|
|
|
DebugPrintf("where <resourceId> is the number of the palette resource to set\n");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint16 resourceId = atoi(argv[1]);
|
|
|
|
|
2010-02-13 17:43:31 +00:00
|
|
|
_engine->_gfxPalette->kernelSetFromResource(resourceId, true);
|
2010-01-05 21:25:59 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-05-30 18:22:55 +00:00
|
|
|
bool Console::cmdDrawPic(int argc, const char **argv) {
|
|
|
|
if (argc < 2) {
|
|
|
|
DebugPrintf("Draws a pic resource\n");
|
2010-01-05 21:03:33 +00:00
|
|
|
DebugPrintf("Usage: %s <resourceId>\n", argv[0]);
|
|
|
|
DebugPrintf("where <resourceId> is the number of the pic resource to draw\n");
|
2009-05-30 18:22:55 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-01-05 21:03:33 +00:00
|
|
|
uint16 resourceId = atoi(argv[1]);
|
|
|
|
|
2010-02-13 17:43:31 +00:00
|
|
|
_engine->_gfxPaint->kernelDrawPicture(resourceId, 100, false, false, false, 0);
|
|
|
|
_engine->_gfxScreen->copyToScreen();
|
2010-01-05 21:03:33 +00:00
|
|
|
return true;
|
|
|
|
}
|
2010-01-05 20:39:21 +00:00
|
|
|
|
2010-01-05 21:03:33 +00:00
|
|
|
bool Console::cmdDrawCel(int argc, const char **argv) {
|
|
|
|
if (argc < 4) {
|
|
|
|
DebugPrintf("Draws a cel from a view resource\n");
|
|
|
|
DebugPrintf("Usage: %s <resourceId> <loopNr> <celNr> \n", argv[0]);
|
|
|
|
DebugPrintf("where <resourceId> is the number of the view resource to draw\n");
|
2010-01-05 20:39:21 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-01-05 21:03:33 +00:00
|
|
|
uint16 resourceId = atoi(argv[1]);
|
|
|
|
uint16 loopNo = atoi(argv[2]);
|
|
|
|
uint16 celNo = atoi(argv[3]);
|
2009-05-30 18:22:55 +00:00
|
|
|
|
2010-02-13 17:43:31 +00:00
|
|
|
_engine->_gfxPaint->kernelDrawCel(resourceId, loopNo, celNo, 50, 50, 0, 0, false, NULL_REG);
|
2010-01-05 21:03:33 +00:00
|
|
|
return true;
|
2009-05-30 18:22:55 +00:00
|
|
|
}
|
|
|
|
|
2010-01-06 21:56:31 +00:00
|
|
|
#ifdef ENABLE_SCI32
|
|
|
|
bool Console::cmdDrawRobot(int argc, const char **argv) {
|
|
|
|
if (argc < 2) {
|
2010-01-28 19:28:56 +00:00
|
|
|
DebugPrintf("Draws frames from a robot resource\n");
|
2010-01-06 21:56:31 +00:00
|
|
|
DebugPrintf("Usage: %s <resourceId>\n", argv[0]);
|
|
|
|
DebugPrintf("where <resourceId> is the id of the robot resource to draw\n");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-01-28 19:28:56 +00:00
|
|
|
uint16 resourceId = atoi(argv[1]);
|
2010-01-06 21:56:31 +00:00
|
|
|
|
2010-06-15 15:44:24 +00:00
|
|
|
if (_engine->_gfxPaint32) {
|
|
|
|
_engine->_gfxPaint32->debugDrawRobot(resourceId);
|
|
|
|
} else {
|
|
|
|
DebugPrintf("command not available in non-sci32 games");
|
|
|
|
}
|
2010-01-06 21:56:31 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-10-07 21:47:34 +00:00
|
|
|
bool Console::cmdUndither(int argc, const char **argv) {
|
|
|
|
if (argc != 2) {
|
|
|
|
DebugPrintf("Enable/disable undithering.\n");
|
|
|
|
DebugPrintf("Usage: %s <0/1>\n", argv[0]);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool flag = atoi(argv[1]) ? true : false;
|
2010-02-13 17:43:31 +00:00
|
|
|
_engine->_gfxScreen->debugUnditherSetState(flag);
|
2010-05-24 17:45:00 +00:00
|
|
|
if (flag)
|
|
|
|
DebugPrintf("undithering ENABLED\n");
|
|
|
|
else
|
|
|
|
DebugPrintf("undithering DISABLED\n");
|
|
|
|
return true;
|
2009-10-07 21:47:34 +00:00
|
|
|
}
|
|
|
|
|
2010-01-09 14:09:45 +00:00
|
|
|
bool Console::cmdPicVisualize(int argc, const char **argv) {
|
|
|
|
if (argc != 2) {
|
|
|
|
DebugPrintf("Enable/disable picture visualization (EGA only)\n");
|
|
|
|
DebugPrintf("Usage: %s <0/1>\n", argv[0]);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool state = atoi(argv[1]) ? true : false;
|
|
|
|
|
2010-05-24 17:45:00 +00:00
|
|
|
if (_engine->_resMan->getViewType() == kViewEga) {
|
|
|
|
_engine->_gfxPaint16->debugSetEGAdrawingVisualize(state);
|
|
|
|
if (state)
|
|
|
|
DebugPrintf("picture visualization ENABLED\n");
|
|
|
|
else
|
|
|
|
DebugPrintf("picture visualization DISABLED\n");
|
|
|
|
} else {
|
|
|
|
DebugPrintf("picture visualization only available for EGA games\n");
|
|
|
|
}
|
|
|
|
return true;
|
2010-01-09 14:09:45 +00:00
|
|
|
}
|
|
|
|
|
2009-10-17 10:42:00 +00:00
|
|
|
bool Console::cmdPlayVideo(int argc, const char **argv) {
|
|
|
|
if (argc < 2) {
|
2009-12-30 10:09:48 +00:00
|
|
|
DebugPrintf("Plays a SEQ, AVI or VMD video.\n");
|
2009-10-17 10:42:00 +00:00
|
|
|
DebugPrintf("Usage: %s <video file name> <delay>\n", argv[0]);
|
|
|
|
DebugPrintf("The video file name should include the extension\n");
|
|
|
|
DebugPrintf("Delay is only used in SEQ videos and is measured in ticks (default: 10)\n");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
Common::String filename = argv[1];
|
|
|
|
filename.toLowercase();
|
|
|
|
|
2009-12-30 10:09:48 +00:00
|
|
|
if (filename.hasSuffix(".seq") || filename.hasSuffix(".avi") || filename.hasSuffix(".vmd")) {
|
2009-10-17 10:42:00 +00:00
|
|
|
_videoFile = filename;
|
|
|
|
_videoFrameDelay = (argc == 2) ? 10 : atoi(argv[2]);
|
2010-07-16 19:40:51 +00:00
|
|
|
return Cmd_Exit(0, 0);
|
2009-10-17 10:42:00 +00:00
|
|
|
} else {
|
|
|
|
DebugPrintf("Unknown video file type\n");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-30 13:04:09 +00:00
|
|
|
bool Console::cmdParseGrammar(int argc, const char **argv) {
|
|
|
|
DebugPrintf("Parse grammar, in strict GNF:\n");
|
|
|
|
|
2010-02-03 01:32:03 +00:00
|
|
|
_engine->getVocabulary()->buildGNF(true);
|
2009-05-30 13:04:09 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-05-30 14:30:39 +00:00
|
|
|
bool Console::cmdPrintSegmentTable(int argc, const char **argv) {
|
|
|
|
DebugPrintf("Segment table:\n");
|
|
|
|
|
2010-02-03 01:32:03 +00:00
|
|
|
for (uint i = 0; i < _engine->_gamestate->_segMan->_heap.size(); i++) {
|
|
|
|
SegmentObj *mobj = _engine->_gamestate->_segMan->_heap[i];
|
2009-05-30 14:30:39 +00:00
|
|
|
if (mobj && mobj->getType()) {
|
|
|
|
DebugPrintf(" [%04x] ", i);
|
|
|
|
|
|
|
|
switch (mobj->getType()) {
|
2009-09-17 00:45:12 +00:00
|
|
|
case SEG_TYPE_SCRIPT:
|
2010-06-28 11:22:20 +00:00
|
|
|
DebugPrintf("S script.%03d l:%d ", (*(Script *)mobj).getScriptNumber(), (*(Script *)mobj).getLockers());
|
2009-05-30 14:30:39 +00:00
|
|
|
break;
|
|
|
|
|
2009-09-17 00:45:12 +00:00
|
|
|
case SEG_TYPE_CLONES:
|
2009-05-30 14:30:39 +00:00
|
|
|
DebugPrintf("C clones (%d allocd)", (*(CloneTable *)mobj).entries_used);
|
|
|
|
break;
|
|
|
|
|
2009-09-17 00:45:12 +00:00
|
|
|
case SEG_TYPE_LOCALS:
|
2009-05-30 14:30:39 +00:00
|
|
|
DebugPrintf("V locals %03d", (*(LocalVariables *)mobj).script_id);
|
|
|
|
break;
|
|
|
|
|
2009-09-17 00:45:12 +00:00
|
|
|
case SEG_TYPE_STACK:
|
2009-09-22 00:35:46 +00:00
|
|
|
DebugPrintf("D data stack (%d)", (*(DataStack *)mobj)._capacity);
|
2009-05-30 14:30:39 +00:00
|
|
|
break;
|
|
|
|
|
2009-09-17 00:45:12 +00:00
|
|
|
case SEG_TYPE_SYS_STRINGS:
|
2009-05-30 14:30:39 +00:00
|
|
|
DebugPrintf("Y system string table");
|
|
|
|
break;
|
|
|
|
|
2009-09-17 00:45:12 +00:00
|
|
|
case SEG_TYPE_LISTS:
|
2009-05-30 14:30:39 +00:00
|
|
|
DebugPrintf("L lists (%d)", (*(ListTable *)mobj).entries_used);
|
|
|
|
break;
|
|
|
|
|
2009-09-17 00:45:12 +00:00
|
|
|
case SEG_TYPE_NODES:
|
2009-05-30 14:30:39 +00:00
|
|
|
DebugPrintf("N nodes (%d)", (*(NodeTable *)mobj).entries_used);
|
|
|
|
break;
|
|
|
|
|
2009-09-17 00:45:12 +00:00
|
|
|
case SEG_TYPE_HUNK:
|
2009-05-30 14:30:39 +00:00
|
|
|
DebugPrintf("H hunk (%d)", (*(HunkTable *)mobj).entries_used);
|
|
|
|
break;
|
|
|
|
|
2009-09-17 00:45:12 +00:00
|
|
|
case SEG_TYPE_DYNMEM:
|
2009-05-30 14:30:39 +00:00
|
|
|
DebugPrintf("M dynmem: %d bytes", (*(DynMem *)mobj)._size);
|
|
|
|
break;
|
|
|
|
|
2010-06-15 08:21:39 +00:00
|
|
|
#ifdef ENABLE_SCI32
|
|
|
|
case SEG_TYPE_ARRAY:
|
|
|
|
DebugPrintf("A SCI32 arrays (%d)", (*(ArrayTable *)mobj).entries_used);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SEG_TYPE_STRING:
|
|
|
|
DebugPrintf("T SCI32 strings (%d)", (*(StringTable *)mobj).entries_used);
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
|
2009-05-30 14:30:39 +00:00
|
|
|
default:
|
|
|
|
DebugPrintf("I Invalid (type = %x)", mobj->getType());
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2009-09-06 13:00:30 +00:00
|
|
|
DebugPrintf(" \n");
|
2009-05-30 14:30:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
DebugPrintf("\n");
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-05-30 16:36:37 +00:00
|
|
|
bool Console::segmentInfo(int nr) {
|
|
|
|
DebugPrintf("[%04x] ", nr);
|
|
|
|
|
2010-02-03 01:32:03 +00:00
|
|
|
if ((nr < 0) || ((uint)nr >= _engine->_gamestate->_segMan->_heap.size()) || !_engine->_gamestate->_segMan->_heap[nr])
|
2009-05-30 16:36:37 +00:00
|
|
|
return false;
|
|
|
|
|
2010-02-03 01:32:03 +00:00
|
|
|
SegmentObj *mobj = _engine->_gamestate->_segMan->_heap[nr];
|
2009-05-30 16:36:37 +00:00
|
|
|
|
|
|
|
switch (mobj->getType()) {
|
|
|
|
|
2009-09-17 00:45:12 +00:00
|
|
|
case SEG_TYPE_SCRIPT: {
|
2009-05-30 16:36:37 +00:00
|
|
|
Script *scr = (Script *)mobj;
|
2010-06-28 11:22:20 +00:00
|
|
|
DebugPrintf("script.%03d locked by %d, bufsize=%d (%x)\n", scr->getScriptNumber(), scr->getLockers(), (uint)scr->getBufSize(), (uint)scr->getBufSize());
|
2010-05-30 23:31:33 +00:00
|
|
|
if (scr->getExportTable())
|
2010-06-28 11:22:20 +00:00
|
|
|
DebugPrintf(" Exports: %4d at %d\n", scr->getExportsNr(), (int)(((const byte *)scr->getExportTable()) - ((const byte *)scr->getBuf())));
|
2009-05-30 16:36:37 +00:00
|
|
|
else
|
|
|
|
DebugPrintf(" Exports: none\n");
|
|
|
|
|
2010-05-30 23:31:33 +00:00
|
|
|
DebugPrintf(" Synonyms: %4d\n", scr->getSynonymsNr());
|
2009-05-30 16:36:37 +00:00
|
|
|
|
2009-09-16 23:32:27 +00:00
|
|
|
if (scr->_localsBlock)
|
|
|
|
DebugPrintf(" Locals : %4d in segment 0x%x\n", scr->_localsBlock->_locals.size(), scr->_localsSegment);
|
2009-05-30 16:36:37 +00:00
|
|
|
else
|
|
|
|
DebugPrintf(" Locals : none\n");
|
|
|
|
|
|
|
|
DebugPrintf(" Objects: %4d\n", scr->_objects.size());
|
2009-09-21 21:38:43 +00:00
|
|
|
|
|
|
|
ObjMap::iterator it;
|
|
|
|
const ObjMap::iterator end = scr->_objects.end();
|
|
|
|
for (it = scr->_objects.begin(); it != end; ++it) {
|
2009-05-30 16:36:37 +00:00
|
|
|
DebugPrintf(" ");
|
|
|
|
// Object header
|
2010-05-26 16:30:10 +00:00
|
|
|
const Object *obj = _engine->_gamestate->_segMan->getObject(it->_value.getPos());
|
2009-05-30 16:36:37 +00:00
|
|
|
if (obj)
|
2009-10-10 15:58:51 +00:00
|
|
|
DebugPrintf("[%04x:%04x] %s : %3d vars, %3d methods\n", PRINT_REG(it->_value.getPos()),
|
2010-02-03 01:32:03 +00:00
|
|
|
_engine->_gamestate->_segMan->getObjectName(it->_value.getPos()),
|
2009-10-10 15:58:51 +00:00
|
|
|
obj->getVarCount(), obj->getMethodCount());
|
2009-05-30 16:36:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2009-09-17 00:45:12 +00:00
|
|
|
case SEG_TYPE_LOCALS: {
|
2009-05-30 16:36:37 +00:00
|
|
|
LocalVariables *locals = (LocalVariables *)mobj;
|
|
|
|
DebugPrintf("locals for script.%03d\n", locals->script_id);
|
|
|
|
DebugPrintf(" %d (0x%x) locals\n", locals->_locals.size(), locals->_locals.size());
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2009-09-17 00:45:12 +00:00
|
|
|
case SEG_TYPE_STACK: {
|
2009-05-30 16:36:37 +00:00
|
|
|
DataStack *stack = (DataStack *)mobj;
|
|
|
|
DebugPrintf("stack\n");
|
2009-09-22 00:35:46 +00:00
|
|
|
DebugPrintf(" %d (0x%x) entries\n", stack->_capacity, stack->_capacity);
|
2009-05-30 16:36:37 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2009-09-17 00:45:12 +00:00
|
|
|
case SEG_TYPE_SYS_STRINGS: {
|
2009-05-30 16:36:37 +00:00
|
|
|
DebugPrintf("system string table - viewing currently disabled\n");
|
|
|
|
#if 0
|
|
|
|
SystemStrings *strings = &(mobj->data.sys_strings);
|
|
|
|
|
|
|
|
for (int i = 0; i < SYS_STRINGS_MAX; i++)
|
|
|
|
if (strings->strings[i].name)
|
|
|
|
DebugPrintf(" %s[%d]=\"%s\"\n", strings->strings[i].name, strings->strings[i].max_size, strings->strings[i].value);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2009-09-17 00:45:12 +00:00
|
|
|
case SEG_TYPE_CLONES: {
|
2009-05-30 16:36:37 +00:00
|
|
|
CloneTable *ct = (CloneTable *)mobj;
|
|
|
|
|
|
|
|
DebugPrintf("clones\n");
|
|
|
|
|
|
|
|
for (uint i = 0; i < ct->_table.size(); i++)
|
|
|
|
if (ct->isValidEntry(i)) {
|
|
|
|
reg_t objpos;
|
|
|
|
objpos.offset = i;
|
|
|
|
objpos.segment = nr;
|
2010-02-03 01:32:03 +00:00
|
|
|
DebugPrintf(" [%04x] %s; copy of ", i, _engine->_gamestate->_segMan->getObjectName(objpos));
|
2009-05-30 16:36:37 +00:00
|
|
|
// Object header
|
2010-05-26 16:30:10 +00:00
|
|
|
const Object *obj = _engine->_gamestate->_segMan->getObject(ct->_table[i].getPos());
|
2009-05-30 16:36:37 +00:00
|
|
|
if (obj)
|
2009-10-10 15:58:51 +00:00
|
|
|
DebugPrintf("[%04x:%04x] %s : %3d vars, %3d methods\n", PRINT_REG(ct->_table[i].getPos()),
|
2010-02-03 01:32:03 +00:00
|
|
|
_engine->_gamestate->_segMan->getObjectName(ct->_table[i].getPos()),
|
2009-10-10 15:58:51 +00:00
|
|
|
obj->getVarCount(), obj->getMethodCount());
|
2009-05-30 16:36:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2009-09-17 00:45:12 +00:00
|
|
|
case SEG_TYPE_LISTS: {
|
2009-05-30 16:36:37 +00:00
|
|
|
ListTable *lt = (ListTable *)mobj;
|
|
|
|
|
|
|
|
DebugPrintf("lists\n");
|
|
|
|
for (uint i = 0; i < lt->_table.size(); i++)
|
|
|
|
if (lt->isValidEntry(i)) {
|
|
|
|
DebugPrintf(" [%04x]: ", i);
|
|
|
|
printList(&(lt->_table[i]));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2009-09-17 00:45:12 +00:00
|
|
|
case SEG_TYPE_NODES: {
|
2009-05-30 16:36:37 +00:00
|
|
|
DebugPrintf("nodes (total %d)\n", (*(NodeTable *)mobj).entries_used);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2009-09-17 00:45:12 +00:00
|
|
|
case SEG_TYPE_HUNK: {
|
2009-05-30 16:36:37 +00:00
|
|
|
HunkTable *ht = (HunkTable *)mobj;
|
|
|
|
|
|
|
|
DebugPrintf("hunk (total %d)\n", ht->entries_used);
|
|
|
|
for (uint i = 0; i < ht->_table.size(); i++)
|
|
|
|
if (ht->isValidEntry(i)) {
|
|
|
|
DebugPrintf(" [%04x] %d bytes at %p, type=%s\n",
|
|
|
|
i, ht->_table[i].size, ht->_table[i].mem, ht->_table[i].type);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2009-09-17 00:45:12 +00:00
|
|
|
case SEG_TYPE_DYNMEM: {
|
2009-05-30 16:36:37 +00:00
|
|
|
DebugPrintf("dynmem (%s): %d bytes\n",
|
2009-09-14 22:34:53 +00:00
|
|
|
(*(DynMem *)mobj)._description.c_str(), (*(DynMem *)mobj)._size);
|
2009-05-30 16:36:37 +00:00
|
|
|
|
|
|
|
Common::hexdump((*(DynMem *)mobj)._buf, (*(DynMem *)mobj)._size, 16, 0);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2010-07-04 23:38:08 +00:00
|
|
|
#ifdef ENABLE_SCI32
|
|
|
|
case SEG_TYPE_STRING:
|
|
|
|
DebugPrintf("SCI32 strings\n");
|
|
|
|
break;
|
|
|
|
case SEG_TYPE_ARRAY:
|
|
|
|
DebugPrintf("SCI32 arrays\n");
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
|
2009-05-30 16:36:37 +00:00
|
|
|
default :
|
|
|
|
DebugPrintf("Invalid type %d\n", mobj->getType());
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
DebugPrintf("\n");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Console::cmdSegmentInfo(int argc, const char **argv) {
|
|
|
|
if (argc != 2) {
|
|
|
|
DebugPrintf("Provides information on the specified segment(s)\n");
|
|
|
|
DebugPrintf("Usage: %s <segment number>\n", argv[0]);
|
|
|
|
DebugPrintf("<segment number> can be a number, which shows the information of the segment with\n");
|
2010-07-07 14:19:36 +00:00
|
|
|
DebugPrintf("the specified number, or \"all\" to show information on all active segments\n");
|
2009-05-30 16:36:37 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!scumm_stricmp(argv[1], "all")) {
|
2010-02-03 01:32:03 +00:00
|
|
|
for (uint i = 0; i < _engine->_gamestate->_segMan->_heap.size(); i++)
|
2009-05-30 16:36:37 +00:00
|
|
|
segmentInfo(i);
|
|
|
|
} else {
|
2010-07-07 14:19:36 +00:00
|
|
|
int segmentNr;
|
|
|
|
if (!parseInteger(argv[1], segmentNr))
|
|
|
|
return true;
|
|
|
|
if (!segmentInfo(segmentNr))
|
|
|
|
DebugPrintf("Segment %04xh does not exist\n", segmentNr);
|
2009-05-30 16:36:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool Console::cmdKillSegment(int argc, const char **argv) {
|
|
|
|
if (argc != 2) {
|
|
|
|
DebugPrintf("Deletes the specified segment\n");
|
|
|
|
DebugPrintf("Usage: %s <segment number>\n", argv[0]);
|
|
|
|
return true;
|
|
|
|
}
|
2010-07-07 14:19:36 +00:00
|
|
|
int segmentNumber;
|
|
|
|
if (!parseInteger(argv[1], segmentNumber))
|
|
|
|
return true;
|
|
|
|
_engine->_gamestate->_segMan->getScript(segmentNumber)->setLockers(0);
|
2009-05-30 16:36:37 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-05-30 14:30:39 +00:00
|
|
|
bool Console::cmdShowMap(int argc, const char **argv) {
|
|
|
|
if (argc != 2) {
|
2010-07-07 14:19:36 +00:00
|
|
|
DebugPrintf("Switches to one of the following screen maps\n");
|
2009-05-30 14:30:39 +00:00
|
|
|
DebugPrintf("Usage: %s <screen map>\n", argv[0]);
|
|
|
|
DebugPrintf("Screen maps:\n");
|
2010-07-07 14:19:36 +00:00
|
|
|
DebugPrintf("- 0: visual map\n");
|
|
|
|
DebugPrintf("- 1: priority map\n");
|
|
|
|
DebugPrintf("- 2: control map\n");
|
|
|
|
DebugPrintf("- 3: display screen\n");
|
2009-05-30 14:30:39 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
int map = atoi(argv[1]);
|
|
|
|
|
|
|
|
switch (map) {
|
|
|
|
case 0:
|
|
|
|
case 1:
|
|
|
|
case 2:
|
2009-10-07 15:53:34 +00:00
|
|
|
case 3:
|
2010-02-13 17:43:31 +00:00
|
|
|
_engine->_gfxScreen->debugShowMap(map);
|
2009-05-30 14:30:39 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
DebugPrintf("Map %d is not available.\n", map);
|
|
|
|
return true;
|
|
|
|
}
|
2010-07-16 19:40:51 +00:00
|
|
|
return Cmd_Exit(0, 0);
|
2009-05-30 14:30:39 +00:00
|
|
|
}
|
|
|
|
|
2009-05-30 20:45:57 +00:00
|
|
|
bool Console::cmdSongLib(int argc, const char **argv) {
|
|
|
|
DebugPrintf("Song library:\n");
|
2010-06-29 09:00:08 +00:00
|
|
|
g_sci->_soundCmd->printPlayList(this);
|
2009-05-30 20:45:57 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-01-23 14:39:03 +00:00
|
|
|
bool Console::cmdSongInfo(int argc, const char **argv) {
|
|
|
|
if (argc != 2) {
|
|
|
|
DebugPrintf("Shows information about a given song in the playlist\n");
|
|
|
|
DebugPrintf("Usage: %s <song object>\n", argv[0]);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
reg_t addr;
|
2010-01-25 01:39:44 +00:00
|
|
|
|
2010-02-03 01:32:03 +00:00
|
|
|
if (parse_reg_t(_engine->_gamestate, argv[1], &addr, false)) {
|
2010-01-23 14:39:03 +00:00
|
|
|
DebugPrintf("Invalid address passed.\n");
|
|
|
|
DebugPrintf("Check the \"addresses\" command on how to use addresses\n");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-06-29 09:00:08 +00:00
|
|
|
g_sci->_soundCmd->printSongInfo(addr, this);
|
2010-01-23 14:39:03 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Console::cmdStartSound(int argc, const char **argv) {
|
|
|
|
if (argc != 2) {
|
|
|
|
DebugPrintf("Adds the requested sound resource to the playlist, and starts playing it\n");
|
|
|
|
DebugPrintf("Usage: %s <sound resource id>\n", argv[0]);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
int16 number = atoi(argv[1]);
|
|
|
|
|
2010-02-13 17:44:19 +00:00
|
|
|
if (!_engine->getResMan()->testResource(ResourceId(kResourceTypeSound, number))) {
|
2010-01-23 14:39:03 +00:00
|
|
|
DebugPrintf("Unable to load this sound resource, most probably it has an equivalent audio resource (SCI1.1)\n");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-06-29 09:00:08 +00:00
|
|
|
g_sci->_soundCmd->startNewSound(number);
|
2010-07-16 19:40:51 +00:00
|
|
|
return Cmd_Exit(0, 0);
|
2010-01-23 14:39:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool Console::cmdToggleSound(int argc, const char **argv) {
|
|
|
|
if (argc != 3) {
|
|
|
|
DebugPrintf("Plays or stops the specified sound in the playlist\n");
|
|
|
|
DebugPrintf("Usage: %s <address> <state>\n", argv[0]);
|
|
|
|
DebugPrintf("Where:\n");
|
|
|
|
DebugPrintf("- <address> is the address of the sound to play or stop.\n");
|
|
|
|
DebugPrintf("- <state> is the new state (play or stop).\n");
|
|
|
|
DebugPrintf("Check the \"addresses\" command on how to use addresses\n");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
reg_t id;
|
2010-01-25 01:39:44 +00:00
|
|
|
|
2010-02-03 01:32:03 +00:00
|
|
|
if (parse_reg_t(_engine->_gamestate, argv[1], &id, false)) {
|
2010-01-23 14:39:03 +00:00
|
|
|
DebugPrintf("Invalid address passed.\n");
|
|
|
|
DebugPrintf("Check the \"addresses\" command on how to use addresses\n");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
Common::String newState = argv[2];
|
|
|
|
newState.toLowercase();
|
|
|
|
|
|
|
|
if (newState == "play")
|
2010-07-09 12:06:41 +00:00
|
|
|
g_sci->_soundCmd->processPlaySound(id);
|
2010-01-23 14:39:03 +00:00
|
|
|
else if (newState == "stop")
|
2010-07-09 12:06:41 +00:00
|
|
|
g_sci->_soundCmd->processStopSound(id, false);
|
2010-01-23 14:39:03 +00:00
|
|
|
else
|
|
|
|
DebugPrintf("New state can either be 'play' or 'stop'");
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Console::cmdStopAllSounds(int argc, const char **argv) {
|
2010-06-29 09:00:08 +00:00
|
|
|
g_sci->_soundCmd->stopAllSounds();
|
2010-01-23 14:39:03 +00:00
|
|
|
|
|
|
|
DebugPrintf("All sounds have been stopped\n");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Console::cmdIsSample(int argc, const char **argv) {
|
|
|
|
if (argc != 2) {
|
|
|
|
DebugPrintf("Tests whether a given sound resource is a PCM sample, \n");
|
|
|
|
DebugPrintf("and displays information on it if it is.\n");
|
|
|
|
DebugPrintf("Usage: %s <sample id>\n", argv[0]);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
int16 number = atoi(argv[1]);
|
|
|
|
|
2010-02-13 17:44:19 +00:00
|
|
|
if (!_engine->getResMan()->testResource(ResourceId(kResourceTypeSound, number))) {
|
2010-01-23 14:39:03 +00:00
|
|
|
DebugPrintf("Unable to load this sound resource, most probably it has an equivalent audio resource (SCI1.1)\n");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-02-13 17:44:58 +00:00
|
|
|
SoundResource *soundRes = new SoundResource(number, _engine->getResMan(), _engine->_features->detectDoSoundType());
|
2010-01-23 14:39:03 +00:00
|
|
|
|
|
|
|
if (!soundRes) {
|
|
|
|
DebugPrintf("Not a sound resource!\n");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
SoundResource::Track *track = soundRes->getDigitalTrack();
|
|
|
|
if (!track || track->digitalChannelNr == -1) {
|
|
|
|
DebugPrintf("Valid song, but not a sample.\n");
|
|
|
|
delete soundRes;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-01-25 01:39:44 +00:00
|
|
|
DebugPrintf("Sample size: %d, sample rate: %d, channels: %d, digital channel number: %d\n",
|
2010-01-23 14:39:03 +00:00
|
|
|
track->digitalSampleSize, track->digitalSampleRate, track->channelCount, track->digitalChannelNr);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-06-02 19:03:43 +00:00
|
|
|
bool Console::cmdGCInvoke(int argc, const char **argv) {
|
2009-05-30 13:36:51 +00:00
|
|
|
DebugPrintf("Performing garbage collection...\n");
|
2010-02-03 01:32:03 +00:00
|
|
|
run_gc(_engine->_gamestate);
|
2009-05-30 13:36:51 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Console::cmdGCObjects(int argc, const char **argv) {
|
2010-07-01 16:05:47 +00:00
|
|
|
AddrSet *use_map = findAllActiveReferences(_engine->_gamestate);
|
2009-05-30 13:36:51 +00:00
|
|
|
|
|
|
|
DebugPrintf("Reachable object references (normalised):\n");
|
2010-07-01 16:05:47 +00:00
|
|
|
for (AddrSet::iterator i = use_map->begin(); i != use_map->end(); ++i) {
|
2009-05-30 13:36:51 +00:00
|
|
|
DebugPrintf(" - %04x:%04x\n", PRINT_REG(i->_key));
|
|
|
|
}
|
|
|
|
|
|
|
|
delete use_map;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-06-02 21:07:34 +00:00
|
|
|
bool Console::cmdGCShowReachable(int argc, const char **argv) {
|
|
|
|
if (argc != 2) {
|
|
|
|
DebugPrintf("Prints all addresses directly reachable from the memory object specified as parameter.\n");
|
|
|
|
DebugPrintf("Usage: %s <address>\n", argv[0]);
|
|
|
|
DebugPrintf("Check the \"addresses\" command on how to use addresses\n");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
reg_t addr;
|
2010-01-25 01:39:44 +00:00
|
|
|
|
2010-02-03 01:32:03 +00:00
|
|
|
if (parse_reg_t(_engine->_gamestate, argv[1], &addr, false)) {
|
2009-06-02 21:07:34 +00:00
|
|
|
DebugPrintf("Invalid address passed.\n");
|
|
|
|
DebugPrintf("Check the \"addresses\" command on how to use addresses\n");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-02-03 01:32:03 +00:00
|
|
|
SegmentObj *mobj = _engine->_gamestate->_segMan->getSegmentObj(addr.segment);
|
2009-06-02 21:07:34 +00:00
|
|
|
if (!mobj) {
|
|
|
|
DebugPrintf("Unknown segment : %x\n", addr.segment);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
DebugPrintf("Reachable from %04x:%04x:\n", PRINT_REG(addr));
|
2010-06-28 11:22:41 +00:00
|
|
|
const Common::Array<reg_t> tmp = mobj->listAllOutgoingReferences(addr);
|
|
|
|
for (Common::Array<reg_t>::const_iterator it = tmp.begin(); it != tmp.end(); ++it)
|
|
|
|
if (it->segment)
|
|
|
|
g_sci->getSciDebugger()->DebugPrintf(" %04x:%04x\n", PRINT_REG(*it));
|
2009-06-02 21:07:34 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Console::cmdGCShowFreeable(int argc, const char **argv) {
|
|
|
|
if (argc != 2) {
|
|
|
|
DebugPrintf("Prints all addresses freeable in the segment associated with the\n");
|
|
|
|
DebugPrintf("given address (offset is ignored).\n");
|
|
|
|
DebugPrintf("Usage: %s <address>\n", argv[0]);
|
|
|
|
DebugPrintf("Check the \"addresses\" command on how to use addresses\n");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
reg_t addr;
|
2010-01-25 01:39:44 +00:00
|
|
|
|
2010-02-03 01:32:03 +00:00
|
|
|
if (parse_reg_t(_engine->_gamestate, argv[1], &addr, false)) {
|
2009-06-02 21:07:34 +00:00
|
|
|
DebugPrintf("Invalid address passed.\n");
|
|
|
|
DebugPrintf("Check the \"addresses\" command on how to use addresses\n");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-02-03 01:32:03 +00:00
|
|
|
SegmentObj *mobj = _engine->_gamestate->_segMan->getSegmentObj(addr.segment);
|
2009-06-02 21:07:34 +00:00
|
|
|
if (!mobj) {
|
|
|
|
DebugPrintf("Unknown segment : %x\n", addr.segment);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
DebugPrintf("Freeable in segment %04x:\n", addr.segment);
|
2010-06-28 11:22:41 +00:00
|
|
|
const Common::Array<reg_t> tmp = mobj->listAllDeallocatable(addr.segment);
|
|
|
|
for (Common::Array<reg_t>::const_iterator it = tmp.begin(); it != tmp.end(); ++it)
|
|
|
|
if (it->segment)
|
|
|
|
g_sci->getSciDebugger()->DebugPrintf(" %04x:%04x\n", PRINT_REG(*it));
|
2009-06-02 21:07:34 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Console::cmdGCNormalize(int argc, const char **argv) {
|
|
|
|
if (argc != 2) {
|
|
|
|
DebugPrintf("Prints the \"normal\" address of a given address,\n");
|
|
|
|
DebugPrintf("i.e. the address we would free in order to free\n");
|
|
|
|
DebugPrintf("the object associated with the original address.\n");
|
|
|
|
DebugPrintf("Usage: %s <address>\n", argv[0]);
|
|
|
|
DebugPrintf("Check the \"addresses\" command on how to use addresses\n");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
reg_t addr;
|
2010-01-25 01:39:44 +00:00
|
|
|
|
2010-02-03 01:32:03 +00:00
|
|
|
if (parse_reg_t(_engine->_gamestate, argv[1], &addr, false)) {
|
2009-06-02 21:07:34 +00:00
|
|
|
DebugPrintf("Invalid address passed.\n");
|
|
|
|
DebugPrintf("Check the \"addresses\" command on how to use addresses\n");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-02-03 01:32:03 +00:00
|
|
|
SegmentObj *mobj = _engine->_gamestate->_segMan->getSegmentObj(addr.segment);
|
2009-06-02 21:07:34 +00:00
|
|
|
if (!mobj) {
|
|
|
|
DebugPrintf("Unknown segment : %x\n", addr.segment);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-02-03 01:32:03 +00:00
|
|
|
addr = mobj->findCanonicAddress(_engine->_gamestate->_segMan, addr);
|
2009-06-02 21:07:34 +00:00
|
|
|
DebugPrintf(" %04x:%04x\n", PRINT_REG(addr));
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-06-02 19:03:43 +00:00
|
|
|
bool Console::cmdVMVarlist(int argc, const char **argv) {
|
2010-06-06 23:00:33 +00:00
|
|
|
EngineState *s = _engine->_gamestate;
|
2009-07-02 23:16:40 +00:00
|
|
|
const char *varnames[] = {"global", "local", "temp", "param"};
|
2009-06-02 19:03:43 +00:00
|
|
|
|
|
|
|
DebugPrintf("Addresses of variables in the VM:\n");
|
|
|
|
|
|
|
|
for (int i = 0; i < 4; i++) {
|
2010-06-10 11:43:20 +00:00
|
|
|
DebugPrintf("%s vars at %04x:%04x ", varnames[i], PRINT_REG(make_reg(s->variablesSegment[i], s->variables[i] - s->variablesBase[i])));
|
|
|
|
if (s->variablesMax)
|
|
|
|
DebugPrintf(" total %d", s->variablesMax[i]);
|
2009-06-02 19:03:43 +00:00
|
|
|
DebugPrintf("\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-06-03 11:38:12 +00:00
|
|
|
bool Console::cmdVMVars(int argc, const char **argv) {
|
2010-06-27 15:50:51 +00:00
|
|
|
if (argc < 2) {
|
2009-06-03 11:38:12 +00:00
|
|
|
DebugPrintf("Displays or changes variables in the VM\n");
|
|
|
|
DebugPrintf("Usage: %s <type> <varnum> [<value>]\n", argv[0]);
|
2010-06-27 15:50:51 +00:00
|
|
|
DebugPrintf("First parameter is either g(lobal), l(ocal), t(emp), p(aram) or a(cc).\n");
|
|
|
|
DebugPrintf("Second parameter is the var number (not specified on acc)\n");
|
2009-06-03 11:38:12 +00:00
|
|
|
DebugPrintf("Third parameter (if specified) is the value to set the variable to, in address form\n");
|
|
|
|
DebugPrintf("Check the \"addresses\" command on how to use addresses\n");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-06-06 23:00:33 +00:00
|
|
|
EngineState *s = _engine->_gamestate;
|
2010-06-27 15:50:51 +00:00
|
|
|
const char *varNames[] = {"global", "local", "temp", "param", "acc"};
|
|
|
|
const char *varAbbrev = "gltpa";
|
|
|
|
const char *varType_pre = strchr(varAbbrev, *argv[1]);
|
|
|
|
int varType;
|
|
|
|
int varIndex = 0;
|
|
|
|
reg_t *curValue = NULL;
|
|
|
|
const char *setValue = NULL;
|
|
|
|
|
|
|
|
if (!varType_pre) {
|
2009-06-03 11:38:12 +00:00
|
|
|
DebugPrintf("Invalid variable type '%c'\n", *argv[1]);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-06-27 15:50:51 +00:00
|
|
|
varType = varType_pre - varAbbrev;
|
2009-06-03 11:38:12 +00:00
|
|
|
|
2010-06-27 15:50:51 +00:00
|
|
|
switch (varType) {
|
|
|
|
case 0:
|
|
|
|
case 1:
|
|
|
|
case 2:
|
|
|
|
case 3: {
|
|
|
|
// for global, local, temp and param, we need an index
|
|
|
|
if (argc < 3) {
|
|
|
|
DebugPrintf("Variable number must be specified for requested type\n");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (argc > 4) {
|
|
|
|
DebugPrintf("Too many arguments\n");
|
|
|
|
return true;
|
|
|
|
}
|
2010-05-22 21:46:40 +00:00
|
|
|
|
2010-07-07 14:19:36 +00:00
|
|
|
if (!parseInteger(argv[2], varIndex))
|
|
|
|
return true;
|
2010-06-27 15:50:51 +00:00
|
|
|
|
|
|
|
if (varIndex < 0) {
|
|
|
|
DebugPrintf("Variable number may not be negative\n");
|
2010-05-22 21:46:40 +00:00
|
|
|
return true;
|
|
|
|
}
|
2010-06-27 15:50:51 +00:00
|
|
|
|
|
|
|
if ((s->variablesMax) && (s->variablesMax[varType] <= varIndex)) {
|
|
|
|
DebugPrintf("Maximum variable number for this type is %d (0x%x)\n", s->variablesMax[varType], s->variablesMax[varType]);
|
2010-05-22 21:46:40 +00:00
|
|
|
return true;
|
|
|
|
}
|
2010-06-27 15:50:51 +00:00
|
|
|
curValue = &s->variables[varType][varIndex];
|
|
|
|
if (argc == 4)
|
|
|
|
setValue = argv[3];
|
|
|
|
break;
|
2010-05-22 21:46:40 +00:00
|
|
|
}
|
|
|
|
|
2010-06-27 15:50:51 +00:00
|
|
|
case 4:
|
|
|
|
// acc
|
|
|
|
if (argc > 3) {
|
|
|
|
DebugPrintf("Too many arguments\n");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
curValue = &s->r_acc;
|
|
|
|
if (argc == 3)
|
|
|
|
setValue = argv[2];
|
|
|
|
break;
|
2009-06-03 11:38:12 +00:00
|
|
|
|
2010-06-27 15:50:51 +00:00
|
|
|
default:
|
|
|
|
break;
|
2009-06-03 11:38:12 +00:00
|
|
|
}
|
|
|
|
|
2010-06-27 15:50:51 +00:00
|
|
|
if (!setValue) {
|
|
|
|
if (varType == 4)
|
2010-06-27 20:38:41 +00:00
|
|
|
DebugPrintf("%s == %04x:%04x", varNames[varType], PRINT_REG(*curValue));
|
2010-06-27 15:50:51 +00:00
|
|
|
else
|
2010-06-27 20:38:41 +00:00
|
|
|
DebugPrintf("%s var %d == %04x:%04x", varNames[varType], varIndex, PRINT_REG(*curValue));
|
|
|
|
printBasicVarInfo(*curValue);
|
|
|
|
DebugPrintf("\n");
|
2010-06-27 15:50:51 +00:00
|
|
|
} else {
|
|
|
|
if (parse_reg_t(s, setValue, curValue, true)) {
|
2010-01-02 09:39:17 +00:00
|
|
|
DebugPrintf("Invalid value/address passed.\n");
|
2009-06-03 14:47:32 +00:00
|
|
|
DebugPrintf("Check the \"addresses\" command on how to use addresses\n");
|
2010-01-02 09:39:17 +00:00
|
|
|
DebugPrintf("Or pass a decimal or hexadecimal value directly (e.g. 12, 1Ah)\n");
|
2009-06-03 14:47:32 +00:00
|
|
|
return true;
|
|
|
|
}
|
2009-06-03 11:38:12 +00:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-06-02 19:03:43 +00:00
|
|
|
bool Console::cmdStack(int argc, const char **argv) {
|
|
|
|
if (argc != 2) {
|
2009-06-03 09:45:16 +00:00
|
|
|
DebugPrintf("Lists the specified number of stack elements.\n");
|
2009-06-02 19:03:43 +00:00
|
|
|
DebugPrintf("Usage: %s <elements>\n", argv[0]);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-02-03 01:32:03 +00:00
|
|
|
if (_engine->_gamestate->_executionStack.empty()) {
|
2009-06-02 19:03:43 +00:00
|
|
|
DebugPrintf("No exec stack!");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-02-03 01:32:03 +00:00
|
|
|
ExecStack &xs = _engine->_gamestate->_executionStack.back();
|
2009-06-02 19:03:43 +00:00
|
|
|
int nr = atoi(argv[1]);
|
|
|
|
|
|
|
|
for (int i = nr; i > 0; i--) {
|
|
|
|
if ((xs.sp - xs.fp - i) == 0)
|
|
|
|
DebugPrintf("-- temp variables --\n");
|
2010-02-03 01:32:03 +00:00
|
|
|
if (xs.sp - i >= _engine->_gamestate->stack_base)
|
|
|
|
DebugPrintf("ST:%04x = %04x:%04x\n", (unsigned)(xs.sp - i - _engine->_gamestate->stack_base), PRINT_REG(xs.sp[-i]));
|
2009-06-02 19:03:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-06-02 21:07:34 +00:00
|
|
|
bool Console::cmdValueType(int argc, const char **argv) {
|
|
|
|
if (argc != 2) {
|
|
|
|
DebugPrintf("Determines the type of a value.\n");
|
|
|
|
DebugPrintf("The type can be one of the following:\n");
|
|
|
|
DebugPrintf("Invalid, list, object, reference or arithmetic\n");
|
|
|
|
DebugPrintf("Usage: %s <address>\n", argv[0]);
|
|
|
|
DebugPrintf("Check the \"addresses\" command on how to use addresses\n");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
reg_t val;
|
2010-01-25 01:39:44 +00:00
|
|
|
|
2010-02-03 01:32:03 +00:00
|
|
|
if (parse_reg_t(_engine->_gamestate, argv[1], &val, false)) {
|
2009-06-02 21:07:34 +00:00
|
|
|
DebugPrintf("Invalid address passed.\n");
|
|
|
|
DebugPrintf("Check the \"addresses\" command on how to use addresses\n");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-05-18 12:16:48 +00:00
|
|
|
int t = g_sci->getKernel()->findRegType(val);
|
2009-06-02 21:07:34 +00:00
|
|
|
|
2009-10-01 10:57:59 +00:00
|
|
|
switch (t) {
|
2010-07-05 14:36:31 +00:00
|
|
|
case SIG_TYPE_LIST:
|
2009-06-02 21:07:34 +00:00
|
|
|
DebugPrintf("List");
|
|
|
|
break;
|
2010-07-05 14:36:31 +00:00
|
|
|
case SIG_TYPE_OBJECT:
|
2009-06-02 21:07:34 +00:00
|
|
|
DebugPrintf("Object");
|
|
|
|
break;
|
2010-07-05 14:36:31 +00:00
|
|
|
case SIG_TYPE_REFERENCE:
|
2009-06-02 21:07:34 +00:00
|
|
|
DebugPrintf("Reference");
|
|
|
|
break;
|
2010-07-05 14:36:31 +00:00
|
|
|
case SIG_TYPE_INTEGER:
|
|
|
|
DebugPrintf("Integer");
|
|
|
|
case SIG_TYPE_INTEGER | SIG_TYPE_NULL:
|
2010-06-10 15:25:18 +00:00
|
|
|
DebugPrintf("Null");
|
2009-06-02 21:07:34 +00:00
|
|
|
break;
|
|
|
|
default:
|
2010-06-10 15:25:18 +00:00
|
|
|
DebugPrintf("Erroneous unknown type 0x%02x (%d decimal)\n", t, t);
|
2009-06-02 21:07:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-06-02 23:29:58 +00:00
|
|
|
bool Console::cmdViewListNode(int argc, const char **argv) {
|
2009-06-02 19:03:43 +00:00
|
|
|
if (argc != 2) {
|
2009-06-02 23:29:58 +00:00
|
|
|
DebugPrintf("Examines the list node at the given address.\n");
|
|
|
|
DebugPrintf("Usage: %s <address>\n", argv[0]);
|
|
|
|
DebugPrintf("Check the \"addresses\" command on how to use addresses\n");
|
2009-06-02 19:03:43 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-06-02 23:29:58 +00:00
|
|
|
reg_t addr;
|
2010-01-25 01:39:44 +00:00
|
|
|
|
2010-02-03 01:32:03 +00:00
|
|
|
if (parse_reg_t(_engine->_gamestate, argv[1], &addr, false)) {
|
2009-06-02 23:29:58 +00:00
|
|
|
DebugPrintf("Invalid address passed.\n");
|
|
|
|
DebugPrintf("Check the \"addresses\" command on how to use addresses\n");
|
|
|
|
return true;
|
|
|
|
}
|
2009-06-02 19:03:43 +00:00
|
|
|
|
2009-06-02 23:29:58 +00:00
|
|
|
printNode(addr);
|
2009-06-02 19:03:43 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-06-03 14:47:32 +00:00
|
|
|
bool Console::cmdViewReference(int argc, const char **argv) {
|
|
|
|
if (argc < 2) {
|
|
|
|
DebugPrintf("Examines an arbitrary reference.\n");
|
|
|
|
DebugPrintf("Usage: %s <start address> [<end address>]\n", argv[0]);
|
|
|
|
DebugPrintf("Where <start address> is the starting address to examine\n");
|
|
|
|
DebugPrintf("<end address>, if provided, is the address where examining ends at\n");
|
|
|
|
DebugPrintf("Check the \"addresses\" command on how to use addresses\n");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
reg_t reg = NULL_REG;
|
|
|
|
reg_t reg_end = NULL_REG;
|
|
|
|
|
2010-02-03 01:32:03 +00:00
|
|
|
if (parse_reg_t(_engine->_gamestate, argv[1], ®, false)) {
|
2009-06-03 14:47:32 +00:00
|
|
|
DebugPrintf("Invalid address passed.\n");
|
|
|
|
DebugPrintf("Check the \"addresses\" command on how to use addresses\n");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (argc > 2) {
|
2010-02-03 01:32:03 +00:00
|
|
|
if (parse_reg_t(_engine->_gamestate, argv[2], ®_end, false)) {
|
2009-06-03 14:47:32 +00:00
|
|
|
DebugPrintf("Invalid address passed.\n");
|
|
|
|
DebugPrintf("Check the \"addresses\" command on how to use addresses\n");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-05-18 12:16:48 +00:00
|
|
|
int type_mask = g_sci->getKernel()->findRegType(reg);
|
2009-06-03 14:47:32 +00:00
|
|
|
int filter;
|
|
|
|
int found = 0;
|
|
|
|
|
2009-10-01 10:57:59 +00:00
|
|
|
DebugPrintf("%04x:%04x is of type 0x%x: ", PRINT_REG(reg), type_mask);
|
2009-06-03 14:47:32 +00:00
|
|
|
|
|
|
|
if (reg.segment == 0 && reg.offset == 0) {
|
|
|
|
DebugPrintf("Null.\n");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-07-04 23:38:08 +00:00
|
|
|
if (reg_end.segment != reg.segment && reg_end != NULL_REG) {
|
2009-06-03 14:47:32 +00:00
|
|
|
DebugPrintf("Ending segment different from starting segment. Assuming no bound on dump.\n");
|
|
|
|
reg_end = NULL_REG;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (filter = 1; filter < 0xf000; filter <<= 1) {
|
|
|
|
int type = type_mask & filter;
|
|
|
|
|
|
|
|
if (found && type) {
|
|
|
|
DebugPrintf("--- Alternatively, it could be a ");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
case 0:
|
|
|
|
break;
|
2010-07-05 14:36:31 +00:00
|
|
|
case SIG_TYPE_LIST: {
|
2010-06-25 19:09:19 +00:00
|
|
|
List *list = _engine->_gamestate->_segMan->lookupList(reg);
|
2009-06-03 14:47:32 +00:00
|
|
|
|
|
|
|
DebugPrintf("list\n");
|
|
|
|
|
2010-06-25 19:09:19 +00:00
|
|
|
if (list)
|
|
|
|
printList(list);
|
2009-06-03 14:47:32 +00:00
|
|
|
else
|
|
|
|
DebugPrintf("Invalid list.\n");
|
|
|
|
}
|
|
|
|
break;
|
2010-07-05 14:36:31 +00:00
|
|
|
case SIG_TYPE_NODE:
|
2009-06-03 14:47:32 +00:00
|
|
|
DebugPrintf("list node\n");
|
|
|
|
printNode(reg);
|
|
|
|
break;
|
2010-07-05 14:36:31 +00:00
|
|
|
case SIG_TYPE_OBJECT:
|
2009-06-03 14:47:32 +00:00
|
|
|
DebugPrintf("object\n");
|
2009-07-08 13:08:51 +00:00
|
|
|
printObject(reg);
|
2009-06-03 14:47:32 +00:00
|
|
|
break;
|
2010-07-05 14:36:31 +00:00
|
|
|
case SIG_TYPE_REFERENCE: {
|
2010-06-15 08:21:39 +00:00
|
|
|
switch (_engine->_gamestate->_segMan->getSegmentType(reg.segment)) {
|
2010-06-15 11:44:55 +00:00
|
|
|
#ifdef ENABLE_SCI32
|
2010-06-15 08:21:39 +00:00
|
|
|
case SEG_TYPE_STRING: {
|
2010-07-04 23:38:08 +00:00
|
|
|
DebugPrintf("SCI32 string\n");
|
2010-06-15 08:21:39 +00:00
|
|
|
const SciString *str = _engine->_gamestate->_segMan->lookupString(reg);
|
|
|
|
Common::hexdump((const byte *) str->getRawData(), str->getSize(), 16, 0);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case SEG_TYPE_ARRAY: {
|
2010-07-04 23:38:08 +00:00
|
|
|
DebugPrintf("SCI32 array:\n");
|
2010-06-15 08:21:39 +00:00
|
|
|
const SciArray<reg_t> *array = _engine->_gamestate->_segMan->lookupArray(reg);
|
2010-07-04 23:38:08 +00:00
|
|
|
hexDumpReg(array->getRawData(), array->getSize(), 4, 0, true);
|
2010-06-15 08:21:39 +00:00
|
|
|
break;
|
|
|
|
}
|
2010-06-15 11:44:55 +00:00
|
|
|
#endif
|
2010-06-15 08:21:39 +00:00
|
|
|
default: {
|
|
|
|
int size;
|
|
|
|
const SegmentRef block = _engine->_gamestate->_segMan->dereference(reg);
|
|
|
|
size = block.maxSize;
|
2009-06-03 14:47:32 +00:00
|
|
|
|
2010-06-15 08:21:39 +00:00
|
|
|
DebugPrintf("raw data\n");
|
2009-06-03 14:47:32 +00:00
|
|
|
|
2010-06-15 08:21:39 +00:00
|
|
|
if (reg_end.segment != 0 && size < reg_end.offset - reg.offset) {
|
|
|
|
DebugPrintf("Block end out of bounds (size %d). Resetting.\n", size);
|
2010-06-17 23:13:30 +00:00
|
|
|
reg_end = NULL_REG;
|
2010-06-15 08:21:39 +00:00
|
|
|
}
|
2009-06-03 14:47:32 +00:00
|
|
|
|
2010-06-15 08:21:39 +00:00
|
|
|
if (reg_end.segment != 0 && (size >= reg_end.offset - reg.offset))
|
|
|
|
size = reg_end.offset - reg.offset;
|
2009-06-03 14:47:32 +00:00
|
|
|
|
2010-06-15 08:21:39 +00:00
|
|
|
if (reg_end.segment != 0)
|
|
|
|
DebugPrintf("Block size less than or equal to %d\n", size);
|
2009-06-03 14:47:32 +00:00
|
|
|
|
2010-07-04 23:38:08 +00:00
|
|
|
if (block.isRaw)
|
|
|
|
Common::hexdump(block.raw, size, 16, 0);
|
|
|
|
else
|
|
|
|
hexDumpReg(block.reg, size / 2, 4, 0);
|
2010-06-15 08:21:39 +00:00
|
|
|
}
|
2009-06-03 14:47:32 +00:00
|
|
|
}
|
|
|
|
break;
|
2010-06-15 08:21:39 +00:00
|
|
|
}
|
2010-07-05 14:36:31 +00:00
|
|
|
case SIG_TYPE_INTEGER:
|
2009-06-03 14:47:32 +00:00
|
|
|
DebugPrintf("arithmetic value\n %d (%04x)\n", (int16) reg.offset, reg.offset);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
DebugPrintf("unknown type %d.\n", type);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (type) {
|
|
|
|
DebugPrintf("\n");
|
|
|
|
found = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-06-02 23:29:58 +00:00
|
|
|
bool Console::cmdViewObject(int argc, const char **argv) {
|
2009-06-02 21:07:34 +00:00
|
|
|
if (argc != 2) {
|
2009-06-02 23:29:58 +00:00
|
|
|
DebugPrintf("Examines the object at the given address.\n");
|
2009-06-02 21:07:34 +00:00
|
|
|
DebugPrintf("Usage: %s <address>\n", argv[0]);
|
|
|
|
DebugPrintf("Check the \"addresses\" command on how to use addresses\n");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-06-02 23:29:58 +00:00
|
|
|
reg_t addr;
|
2010-01-25 01:39:44 +00:00
|
|
|
|
2010-02-03 01:32:03 +00:00
|
|
|
if (parse_reg_t(_engine->_gamestate, argv[1], &addr, false)) {
|
2009-06-02 21:07:34 +00:00
|
|
|
DebugPrintf("Invalid address passed.\n");
|
|
|
|
DebugPrintf("Check the \"addresses\" command on how to use addresses\n");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-06-02 23:29:58 +00:00
|
|
|
DebugPrintf("Information on the object at the given address:\n");
|
2009-07-08 13:08:51 +00:00
|
|
|
printObject(addr);
|
2009-06-02 21:07:34 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-06-02 23:29:58 +00:00
|
|
|
bool Console::cmdViewActiveObject(int argc, const char **argv) {
|
|
|
|
DebugPrintf("Information on the currently active object or class:\n");
|
2010-06-06 23:00:33 +00:00
|
|
|
printObject(_engine->_gamestate->xs->objp);
|
2009-06-02 23:29:58 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Console::cmdViewAccumulatorObject(int argc, const char **argv) {
|
|
|
|
DebugPrintf("Information on the currently active object or class at the address indexed by the accumulator:\n");
|
2010-02-03 01:32:03 +00:00
|
|
|
printObject(_engine->_gamestate->r_acc);
|
2009-06-02 23:29:58 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Console::cmdScriptSteps(int argc, const char **argv) {
|
2010-06-10 11:18:10 +00:00
|
|
|
DebugPrintf("Number of executed SCI operations: %d\n", _engine->_gamestate->scriptStepCounter);
|
2009-06-02 23:29:58 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-06-03 14:47:32 +00:00
|
|
|
bool Console::cmdBacktrace(int argc, const char **argv) {
|
2010-06-10 11:18:10 +00:00
|
|
|
DebugPrintf("Call stack (current base: 0x%x):\n", _engine->_gamestate->executionStackBase);
|
2009-06-03 14:47:32 +00:00
|
|
|
Common::List<ExecStack>::iterator iter;
|
|
|
|
uint i = 0;
|
|
|
|
|
2010-02-03 01:32:03 +00:00
|
|
|
for (iter = _engine->_gamestate->_executionStack.begin();
|
|
|
|
iter != _engine->_gamestate->_executionStack.end(); ++iter, ++i) {
|
2009-06-03 14:47:32 +00:00
|
|
|
ExecStack &call = *iter;
|
2010-02-03 01:32:03 +00:00
|
|
|
const char *objname = _engine->_gamestate->_segMan->getObjectName(call.sendp);
|
2009-06-03 14:47:32 +00:00
|
|
|
int paramc, totalparamc;
|
|
|
|
|
|
|
|
switch (call.type) {
|
2010-06-17 23:13:30 +00:00
|
|
|
case EXEC_STACK_TYPE_CALL: // Normal function
|
2010-06-28 14:21:56 +00:00
|
|
|
if (call.type == EXEC_STACK_TYPE_CALL)
|
|
|
|
DebugPrintf(" %x: script %d - ", i, (*(Script *)_engine->_gamestate->_segMan->_heap[call.addr.pc.segment]).getScriptNumber());
|
|
|
|
if (call.debugSelector != -1) {
|
|
|
|
DebugPrintf("%s::%s(", objname, _engine->getKernel()->getSelectorName(call.debugSelector).c_str());
|
|
|
|
} else if (call.debugExportId != -1) {
|
|
|
|
DebugPrintf("export %d (", call.debugExportId);
|
|
|
|
} else if (call.debugLocalCallOffset != -1) {
|
|
|
|
DebugPrintf("call %x (", call.debugLocalCallOffset);
|
|
|
|
}
|
2010-06-17 23:13:30 +00:00
|
|
|
break;
|
2009-06-03 14:47:32 +00:00
|
|
|
|
|
|
|
case EXEC_STACK_TYPE_KERNEL: // Kernel function
|
2010-06-28 14:21:56 +00:00
|
|
|
DebugPrintf(" %x:[%x] k%s(", i, call.debugOrigin, _engine->getKernel()->getKernelName(call.debugSelector).c_str());
|
2009-06-03 14:47:32 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case EXEC_STACK_TYPE_VARSELECTOR:
|
2010-06-28 14:21:56 +00:00
|
|
|
DebugPrintf(" %x:[%x] vs%s %s::%s (", i, call.debugOrigin, (call.argc) ? "write" : "read",
|
|
|
|
objname, _engine->getKernel()->getSelectorName(call.debugSelector).c_str());
|
2009-06-03 14:47:32 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
totalparamc = call.argc;
|
|
|
|
|
|
|
|
if (totalparamc > 16)
|
|
|
|
totalparamc = 16;
|
|
|
|
|
|
|
|
for (paramc = 1; paramc <= totalparamc; paramc++) {
|
2010-01-03 16:50:27 +00:00
|
|
|
DebugPrintf("%04x:%04x", PRINT_REG(call.variables_argp[paramc]));
|
2009-06-03 14:47:32 +00:00
|
|
|
|
|
|
|
if (paramc < call.argc)
|
2010-01-03 16:50:27 +00:00
|
|
|
DebugPrintf(", ");
|
2009-06-03 14:47:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (call.argc > 16)
|
2010-01-03 16:50:27 +00:00
|
|
|
DebugPrintf("...");
|
2009-06-03 14:47:32 +00:00
|
|
|
|
2010-06-28 14:21:56 +00:00
|
|
|
DebugPrintf(")\n ");
|
|
|
|
if (call.debugOrigin != -1)
|
|
|
|
DebugPrintf("by %x ", call.debugOrigin);
|
|
|
|
DebugPrintf("obj@%04x:%04x", PRINT_REG(call.objp));
|
2009-06-03 14:47:32 +00:00
|
|
|
if (call.type == EXEC_STACK_TYPE_CALL) {
|
2010-01-03 16:50:27 +00:00
|
|
|
DebugPrintf(" pc=%04x:%04x", PRINT_REG(call.addr.pc));
|
2009-06-03 14:47:32 +00:00
|
|
|
if (call.sp == CALL_SP_CARRY)
|
2010-01-03 16:50:27 +00:00
|
|
|
DebugPrintf(" sp,fp:carry");
|
2009-06-03 14:47:32 +00:00
|
|
|
else {
|
2010-02-03 01:32:03 +00:00
|
|
|
DebugPrintf(" sp=ST:%04x", (unsigned)(call.sp - _engine->_gamestate->stack_base));
|
|
|
|
DebugPrintf(" fp=ST:%04x", (unsigned)(call.fp - _engine->_gamestate->stack_base));
|
2009-06-03 14:47:32 +00:00
|
|
|
}
|
|
|
|
} else
|
2010-01-03 16:50:27 +00:00
|
|
|
DebugPrintf(" pc:none");
|
2009-06-03 14:47:32 +00:00
|
|
|
|
2010-02-03 01:32:03 +00:00
|
|
|
DebugPrintf(" argp:ST:%04x", (unsigned)(call.variables_argp - _engine->_gamestate->stack_base));
|
2010-01-03 16:50:27 +00:00
|
|
|
DebugPrintf("\n");
|
2009-06-03 14:47:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-06-27 19:58:32 +00:00
|
|
|
bool Console::cmdTrace(int argc, const char **argv) {
|
2009-06-06 20:29:37 +00:00
|
|
|
if (argc == 2 && atoi(argv[1]) > 0)
|
2010-07-12 23:20:33 +00:00
|
|
|
_debugState.runningStep = atoi(argv[1]) - 1;
|
|
|
|
_debugState.debugging = true;
|
2009-06-06 20:29:37 +00:00
|
|
|
|
2010-07-16 19:40:51 +00:00
|
|
|
return Cmd_Exit(0, 0);
|
2009-06-06 20:29:37 +00:00
|
|
|
}
|
|
|
|
|
2010-06-27 19:58:32 +00:00
|
|
|
bool Console::cmdStepOver(int argc, const char **argv) {
|
2010-07-12 23:20:33 +00:00
|
|
|
_debugState.seeking = kDebugSeekStepOver;
|
|
|
|
_debugState.seekLevel = _engine->_gamestate->_executionStack.size();
|
|
|
|
_debugState.debugging = true;
|
2010-06-27 19:58:32 +00:00
|
|
|
|
2010-07-16 19:40:51 +00:00
|
|
|
return Cmd_Exit(0, 0);
|
2010-06-27 19:58:32 +00:00
|
|
|
}
|
|
|
|
|
2009-06-06 16:43:13 +00:00
|
|
|
bool Console::cmdStepEvent(int argc, const char **argv) {
|
2010-07-12 23:20:33 +00:00
|
|
|
_debugState.stopOnEvent = true;
|
|
|
|
_debugState.debugging = true;
|
2009-06-06 16:43:13 +00:00
|
|
|
|
2010-07-16 19:40:51 +00:00
|
|
|
return Cmd_Exit(0, 0);
|
2009-06-06 16:43:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool Console::cmdStepRet(int argc, const char **argv) {
|
2010-07-12 23:20:33 +00:00
|
|
|
_debugState.seeking = kDebugSeekLevelRet;
|
|
|
|
_debugState.seekLevel = _engine->_gamestate->_executionStack.size() - 1;
|
|
|
|
_debugState.debugging = true;
|
2009-06-06 16:43:13 +00:00
|
|
|
|
2010-07-16 19:40:51 +00:00
|
|
|
return Cmd_Exit(0, 0);
|
2009-06-06 16:43:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool Console::cmdStepGlobal(int argc, const char **argv) {
|
|
|
|
if (argc != 2) {
|
|
|
|
DebugPrintf("Steps until the global variable with the specified index is modified.\n");
|
|
|
|
DebugPrintf("Usage: %s <global variable index>\n", argv[0]);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-07-12 23:20:33 +00:00
|
|
|
_debugState.seeking = kDebugSeekGlobal;
|
|
|
|
_debugState.seekSpecial = atoi(argv[1]);
|
|
|
|
_debugState.debugging = true;
|
2009-06-06 16:43:13 +00:00
|
|
|
|
2010-07-16 19:40:51 +00:00
|
|
|
return Cmd_Exit(0, 0);
|
2009-06-06 16:43:13 +00:00
|
|
|
}
|
|
|
|
|
2009-06-06 20:29:37 +00:00
|
|
|
bool Console::cmdStepCallk(int argc, const char **argv) {
|
|
|
|
int callk_index;
|
|
|
|
char *endptr;
|
|
|
|
|
|
|
|
if (argc == 2) {
|
|
|
|
/* Try to convert the parameter to a number. If the conversion stops
|
|
|
|
before end of string, assume that the parameter is a function name
|
|
|
|
and scan the function table to find out the index. */
|
|
|
|
callk_index = strtoul(argv[1], &endptr, 0);
|
|
|
|
if (*endptr != '\0') {
|
|
|
|
callk_index = -1;
|
2010-02-03 01:32:03 +00:00
|
|
|
for (uint i = 0; i < _engine->getKernel()->getKernelNamesSize(); i++)
|
|
|
|
if (argv[1] == _engine->getKernel()->getKernelName(i)) {
|
2009-06-06 20:29:37 +00:00
|
|
|
callk_index = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (callk_index == -1) {
|
|
|
|
DebugPrintf("Unknown kernel function '%s'\n", argv[1]);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-07-12 23:20:33 +00:00
|
|
|
_debugState.seeking = kDebugSeekSpecialCallk;
|
|
|
|
_debugState.seekSpecial = callk_index;
|
2009-06-06 20:29:37 +00:00
|
|
|
} else {
|
2010-07-12 23:20:33 +00:00
|
|
|
_debugState.seeking = kDebugSeekCallk;
|
2009-06-06 20:29:37 +00:00
|
|
|
}
|
2010-07-12 23:20:33 +00:00
|
|
|
_debugState.debugging = true;
|
2009-06-06 20:29:37 +00:00
|
|
|
|
2010-07-16 19:40:51 +00:00
|
|
|
return Cmd_Exit(0, 0);
|
2009-06-06 20:29:37 +00:00
|
|
|
}
|
|
|
|
|
2009-10-03 20:25:27 +00:00
|
|
|
bool Console::cmdDisassemble(int argc, const char **argv) {
|
2009-06-06 20:29:37 +00:00
|
|
|
if (argc != 3) {
|
|
|
|
DebugPrintf("Disassembles a method by name.\n");
|
|
|
|
DebugPrintf("Usage: %s <object> <method>\n", argv[0]);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
reg_t objAddr = NULL_REG;
|
|
|
|
|
2010-02-03 01:32:03 +00:00
|
|
|
if (parse_reg_t(_engine->_gamestate, argv[1], &objAddr, false)) {
|
2009-06-06 20:29:37 +00:00
|
|
|
DebugPrintf("Invalid address passed.\n");
|
|
|
|
DebugPrintf("Check the \"addresses\" command on how to use addresses\n");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-05-26 16:30:10 +00:00
|
|
|
const Object *obj = _engine->_gamestate->_segMan->getObject(objAddr);
|
2010-05-29 23:37:15 +00:00
|
|
|
int selectorId = _engine->getKernel()->findSelector(argv[2]);
|
2009-06-06 20:29:37 +00:00
|
|
|
reg_t addr;
|
|
|
|
|
|
|
|
if (!obj) {
|
|
|
|
DebugPrintf("Not an object.");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-05-29 23:37:15 +00:00
|
|
|
if (selectorId < 0) {
|
2009-06-06 20:29:37 +00:00
|
|
|
DebugPrintf("Not a valid selector name.");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-05-29 23:37:15 +00:00
|
|
|
if (lookupSelector(_engine->_gamestate->_segMan, objAddr, selectorId, NULL, &addr) != kSelectorMethod) {
|
2009-06-06 20:29:37 +00:00
|
|
|
DebugPrintf("Not a method.");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
do {
|
2010-02-03 01:32:03 +00:00
|
|
|
addr = disassemble(_engine->_gamestate, addr, 0, 0);
|
2009-06-06 20:29:37 +00:00
|
|
|
} while (addr.offset > 0);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-10-03 20:25:27 +00:00
|
|
|
bool Console::cmdDisassembleAddress(int argc, const char **argv) {
|
2009-06-06 20:29:37 +00:00
|
|
|
if (argc < 2) {
|
|
|
|
DebugPrintf("Disassembles one or more commands.\n");
|
|
|
|
DebugPrintf("Usage: %s [startaddr] <options>\n", argv[0]);
|
|
|
|
DebugPrintf("Valid options are:\n");
|
|
|
|
DebugPrintf(" bwt : Print byte/word tag\n");
|
|
|
|
DebugPrintf(" c<x> : Disassemble <x> bytes\n");
|
|
|
|
DebugPrintf(" bc : Print bytecode\n");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
reg_t vpc = NULL_REG;
|
|
|
|
int op_count = 1;
|
|
|
|
int do_bwc = 0;
|
|
|
|
int do_bytes = 0;
|
|
|
|
int size;
|
|
|
|
|
2010-02-03 01:32:03 +00:00
|
|
|
if (parse_reg_t(_engine->_gamestate, argv[1], &vpc, false)) {
|
2009-06-06 20:29:37 +00:00
|
|
|
DebugPrintf("Invalid address passed.\n");
|
|
|
|
DebugPrintf("Check the \"addresses\" command on how to use addresses\n");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-02-03 01:32:03 +00:00
|
|
|
SegmentRef ref = _engine->_gamestate->_segMan->dereference(vpc);
|
2009-09-22 00:36:24 +00:00
|
|
|
size = ref.maxSize + vpc.offset; // total segment size
|
2009-06-06 20:29:37 +00:00
|
|
|
|
2009-07-18 22:19:07 +00:00
|
|
|
for (int i = 2; i < argc; i++) {
|
2009-06-06 20:29:37 +00:00
|
|
|
if (!scumm_stricmp(argv[i], "bwt"))
|
|
|
|
do_bwc = 1;
|
|
|
|
else if (!scumm_stricmp(argv[i], "bc"))
|
|
|
|
do_bytes = 1;
|
|
|
|
else if (toupper(argv[i][0]) == 'C')
|
|
|
|
op_count = atoi(argv[i] + 1);
|
|
|
|
else {
|
|
|
|
DebugPrintf("Invalid option '%s'\n", argv[i]);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (op_count < 0) {
|
|
|
|
DebugPrintf("Invalid op_count\n");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
do {
|
2010-02-03 01:32:03 +00:00
|
|
|
vpc = disassemble(_engine->_gamestate, vpc, do_bwc, do_bytes);
|
2009-06-06 20:29:37 +00:00
|
|
|
} while ((vpc.offset > 0) && (vpc.offset + 6 < size) && (--op_count));
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-06-08 08:38:10 +00:00
|
|
|
bool Console::cmdSend(int argc, const char **argv) {
|
|
|
|
if (argc < 3) {
|
|
|
|
DebugPrintf("Sends a message to an object.\n");
|
|
|
|
DebugPrintf("Usage: %s <object> <selector name> <param1> <param2> ... <paramn>\n", argv[0]);
|
|
|
|
DebugPrintf("Example: send ?fooScript cue\n");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
reg_t object;
|
2010-01-25 01:39:44 +00:00
|
|
|
|
2010-02-03 01:32:03 +00:00
|
|
|
if (parse_reg_t(_engine->_gamestate, argv[1], &object, false)) {
|
2009-10-15 19:24:50 +00:00
|
|
|
DebugPrintf("Invalid address \"%s\" passed.\n", argv[1]);
|
2009-06-08 08:38:10 +00:00
|
|
|
DebugPrintf("Check the \"addresses\" command on how to use addresses\n");
|
|
|
|
return true;
|
|
|
|
}
|
2010-01-25 01:39:44 +00:00
|
|
|
|
2010-06-17 23:13:30 +00:00
|
|
|
const char *selectorName = argv[2];
|
|
|
|
int selectorId = _engine->getKernel()->findSelector(selectorName);
|
2009-06-08 08:38:10 +00:00
|
|
|
|
2010-05-29 23:37:15 +00:00
|
|
|
if (selectorId < 0) {
|
2010-06-17 23:13:30 +00:00
|
|
|
DebugPrintf("Unknown selector: \"%s\"\n", selectorName);
|
2009-07-06 10:39:22 +00:00
|
|
|
return true;
|
2009-06-08 08:38:10 +00:00
|
|
|
}
|
|
|
|
|
2010-05-26 16:30:10 +00:00
|
|
|
const Object *o = _engine->_gamestate->_segMan->getObject(object);
|
2009-06-08 08:38:10 +00:00
|
|
|
if (o == NULL) {
|
2009-07-06 10:39:22 +00:00
|
|
|
DebugPrintf("Address \"%04x:%04x\" is not an object\n", PRINT_REG(object));
|
|
|
|
return true;
|
2009-06-08 08:38:10 +00:00
|
|
|
}
|
|
|
|
|
2010-06-10 13:43:38 +00:00
|
|
|
SelectorType selector_type = lookupSelector(_engine->_gamestate->_segMan, object, selectorId, NULL, NULL);
|
2009-06-08 08:38:10 +00:00
|
|
|
|
|
|
|
if (selector_type == kSelectorNone) {
|
2010-06-17 23:13:30 +00:00
|
|
|
DebugPrintf("Object does not support selector: \"%s\"\n", selectorName);
|
2009-07-06 10:39:22 +00:00
|
|
|
return true;
|
2009-06-08 08:38:10 +00:00
|
|
|
}
|
|
|
|
|
2009-10-15 19:24:50 +00:00
|
|
|
// everything after the selector name is passed as an argument to the send
|
|
|
|
int send_argc = argc - 3;
|
2009-06-08 08:38:10 +00:00
|
|
|
|
2009-10-15 19:24:50 +00:00
|
|
|
// Create the data block for send_selecor() at the top of the stack:
|
|
|
|
// [selector_number][argument_counter][arguments...]
|
2010-02-03 01:32:03 +00:00
|
|
|
StackPtr stackframe = _engine->_gamestate->_executionStack.back().sp;
|
2010-05-29 23:37:15 +00:00
|
|
|
stackframe[0] = make_reg(0, selectorId);
|
2009-10-15 19:24:50 +00:00
|
|
|
stackframe[1] = make_reg(0, send_argc);
|
|
|
|
for (int i = 0; i < send_argc; i++) {
|
2010-02-03 01:32:03 +00:00
|
|
|
if (parse_reg_t(_engine->_gamestate, argv[3+i], &stackframe[2+i], false)) {
|
2009-10-15 19:24:50 +00:00
|
|
|
DebugPrintf("Invalid address \"%s\" passed.\n", argv[3+i]);
|
2009-06-08 08:38:10 +00:00
|
|
|
DebugPrintf("Check the \"addresses\" command on how to use addresses\n");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-02-03 01:32:03 +00:00
|
|
|
reg_t old_acc = _engine->_gamestate->r_acc;
|
2009-10-15 20:13:19 +00:00
|
|
|
|
2009-06-08 08:38:10 +00:00
|
|
|
// Now commit the actual function:
|
2009-10-15 19:24:50 +00:00
|
|
|
ExecStack *old_xstack, *xstack;
|
2010-02-03 01:32:03 +00:00
|
|
|
old_xstack = &_engine->_gamestate->_executionStack.back();
|
|
|
|
xstack = send_selector(_engine->_gamestate, object, object,
|
2009-10-15 19:24:50 +00:00
|
|
|
stackframe + 2 + send_argc,
|
|
|
|
2 + send_argc, stackframe);
|
2009-06-08 08:38:10 +00:00
|
|
|
|
2009-10-24 13:26:12 +00:00
|
|
|
bool restore_acc = old_xstack != xstack || argc == 3;
|
|
|
|
|
2009-10-15 19:24:50 +00:00
|
|
|
if (old_xstack != xstack) {
|
2010-02-03 01:32:03 +00:00
|
|
|
_engine->_gamestate->_executionStackPosChanged = true;
|
2009-10-15 19:24:50 +00:00
|
|
|
DebugPrintf("Message scheduled for execution\n");
|
2009-10-15 20:13:19 +00:00
|
|
|
|
2010-02-03 01:32:03 +00:00
|
|
|
// We call run_engine explictly so we can restore the value of r_acc
|
2009-10-24 13:26:12 +00:00
|
|
|
// after execution.
|
2010-07-20 23:15:07 +00:00
|
|
|
run_vm(_engine->_gamestate);
|
2009-10-15 20:13:19 +00:00
|
|
|
|
2009-10-24 13:26:12 +00:00
|
|
|
}
|
2009-10-15 20:13:19 +00:00
|
|
|
|
2009-10-24 13:26:12 +00:00
|
|
|
if (restore_acc) {
|
|
|
|
// varselector read or message executed
|
2010-02-03 01:32:03 +00:00
|
|
|
DebugPrintf("Message completed. Value returned: %04x:%04x\n", PRINT_REG(_engine->_gamestate->r_acc));
|
|
|
|
_engine->_gamestate->r_acc = old_acc;
|
2009-10-15 19:24:50 +00:00
|
|
|
}
|
2009-06-08 08:38:10 +00:00
|
|
|
|
2009-10-15 19:24:50 +00:00
|
|
|
return true;
|
2009-06-08 08:38:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool Console::cmdGo(int argc, const char **argv) {
|
2009-07-18 12:51:12 +00:00
|
|
|
// CHECKME: is this necessary?
|
2010-07-12 23:20:33 +00:00
|
|
|
_debugState.seeking = kDebugSeekNothing;
|
2009-06-08 08:38:10 +00:00
|
|
|
|
2009-07-18 12:51:12 +00:00
|
|
|
return Cmd_Exit(argc, argv);
|
2009-06-08 08:38:10 +00:00
|
|
|
}
|
|
|
|
|
2009-06-02 23:29:58 +00:00
|
|
|
bool Console::cmdBreakpointList(int argc, const char **argv) {
|
|
|
|
int i = 0;
|
|
|
|
int bpdata;
|
|
|
|
|
|
|
|
DebugPrintf("Breakpoint list:\n");
|
|
|
|
|
2010-07-12 23:20:33 +00:00
|
|
|
Common::List<Breakpoint>::const_iterator bp = _debugState._breakpoints.begin();
|
|
|
|
Common::List<Breakpoint>::const_iterator end = _debugState._breakpoints.end();
|
2010-02-02 22:52:41 +00:00
|
|
|
for (; bp != end; ++bp) {
|
2009-06-02 23:29:58 +00:00
|
|
|
DebugPrintf(" #%i: ", i);
|
|
|
|
switch (bp->type) {
|
|
|
|
case BREAK_SELECTOR:
|
2010-02-02 22:52:41 +00:00
|
|
|
DebugPrintf("Execute %s\n", bp->name.c_str());
|
2009-06-02 23:29:58 +00:00
|
|
|
break;
|
|
|
|
case BREAK_EXPORT:
|
2010-02-02 22:52:41 +00:00
|
|
|
bpdata = bp->address;
|
2009-06-02 23:29:58 +00:00
|
|
|
DebugPrintf("Execute script %d, export %d\n", bpdata >> 16, bpdata & 0xFFFF);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
2010-06-27 20:11:15 +00:00
|
|
|
if (!i)
|
|
|
|
DebugPrintf(" No breakpoints defined.\n");
|
|
|
|
|
2009-06-02 23:29:58 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Console::cmdBreakpointDelete(int argc, const char **argv) {
|
|
|
|
if (argc != 2) {
|
|
|
|
DebugPrintf("Deletes a breakpoint with the specified index.\n");
|
|
|
|
DebugPrintf("Usage: %s <breakpoint index>\n", argv[0]);
|
2010-06-27 20:11:15 +00:00
|
|
|
DebugPrintf("<index> * will remove all breakpoints\n");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strcmp(argv[1], "*") == 0) {
|
2010-07-12 23:20:33 +00:00
|
|
|
_debugState._breakpoints.clear();
|
|
|
|
_debugState._activeBreakpointTypes = 0;
|
2009-06-02 23:29:58 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-02-02 22:52:41 +00:00
|
|
|
const int idx = atoi(argv[1]);
|
2009-06-02 23:29:58 +00:00
|
|
|
|
2010-02-02 22:52:41 +00:00
|
|
|
// Find the breakpoint at index idx.
|
2010-07-12 23:20:33 +00:00
|
|
|
Common::List<Breakpoint>::iterator bp = _debugState._breakpoints.begin();
|
|
|
|
const Common::List<Breakpoint>::iterator end = _debugState._breakpoints.end();
|
2010-02-02 22:52:41 +00:00
|
|
|
for (int i = 0; bp != end && i < idx; ++bp, ++i) {
|
|
|
|
// do nothing
|
2009-06-02 23:29:58 +00:00
|
|
|
}
|
2010-02-02 22:52:41 +00:00
|
|
|
|
|
|
|
if (bp == end) {
|
2009-06-02 23:29:58 +00:00
|
|
|
DebugPrintf("Invalid breakpoint index %i\n", idx);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Delete it
|
2010-07-12 23:20:33 +00:00
|
|
|
_debugState._breakpoints.erase(bp);
|
2009-06-02 23:29:58 +00:00
|
|
|
|
2010-02-02 22:52:41 +00:00
|
|
|
// Update EngineState::_activeBreakpointTypes.
|
|
|
|
int type = 0;
|
2010-07-12 23:20:33 +00:00
|
|
|
for (bp = _debugState._breakpoints.begin(); bp != end; ++bp) {
|
2010-02-02 22:52:41 +00:00
|
|
|
type |= bp->type;
|
2009-06-02 23:29:58 +00:00
|
|
|
}
|
|
|
|
|
2010-07-12 23:20:33 +00:00
|
|
|
_debugState._activeBreakpointTypes = type;
|
2009-06-02 23:29:58 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-06-03 11:38:12 +00:00
|
|
|
bool Console::cmdBreakpointExecMethod(int argc, const char **argv) {
|
|
|
|
if (argc != 2) {
|
|
|
|
DebugPrintf("Sets a breakpoint on the execution of the specified method.\n");
|
|
|
|
DebugPrintf("Usage: %s <method name>\n", argv[0]);
|
|
|
|
DebugPrintf("Example: %s ego::doit\n", argv[0]);
|
|
|
|
DebugPrintf("May also be used to set a breakpoint that applies whenever an object\n");
|
|
|
|
DebugPrintf("of a specific type is touched: %s foo::\n", argv[0]);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Note: We can set a breakpoint on a method that has not been loaded yet.
|
|
|
|
Thus, we can't check whether the command argument is a valid method name.
|
|
|
|
A breakpoint set on an invalid method name will just never trigger. */
|
2010-02-02 22:52:41 +00:00
|
|
|
Breakpoint bp;
|
|
|
|
bp.type = BREAK_SELECTOR;
|
|
|
|
bp.name = argv[1];
|
|
|
|
|
2010-07-12 23:20:33 +00:00
|
|
|
_debugState._breakpoints.push_back(bp);
|
|
|
|
_debugState._activeBreakpointTypes |= BREAK_SELECTOR;
|
2009-06-03 11:38:12 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Console::cmdBreakpointExecFunction(int argc, const char **argv) {
|
|
|
|
// TODO/FIXME: Why does this accept 2 parameters (the high and the low part of the address)?"
|
|
|
|
if (argc != 3) {
|
|
|
|
DebugPrintf("Sets a breakpoint on the execution of the specified exported function.\n");
|
|
|
|
DebugPrintf("Usage: %s <addr1> <addr2>\n", argv[0]);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Note: We can set a breakpoint on a method that has not been loaded yet.
|
|
|
|
Thus, we can't check whether the command argument is a valid method name.
|
|
|
|
A breakpoint set on an invalid method name will just never trigger. */
|
2010-02-02 22:52:41 +00:00
|
|
|
Breakpoint bp;
|
|
|
|
bp.type = BREAK_EXPORT;
|
|
|
|
bp.address = (atoi(argv[1]) << 16 | atoi(argv[2]));
|
|
|
|
|
2010-07-12 23:20:33 +00:00
|
|
|
_debugState._breakpoints.push_back(bp);
|
|
|
|
_debugState._activeBreakpointTypes |= BREAK_EXPORT;
|
2009-06-03 11:38:12 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-06-02 19:03:43 +00:00
|
|
|
bool Console::cmdSfx01Header(int argc, const char **argv) {
|
|
|
|
if (argc != 2) {
|
|
|
|
DebugPrintf("Dumps the header of a SCI01 song\n");
|
|
|
|
DebugPrintf("Usage: %s <track>\n", argv[0]);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-02-13 17:44:19 +00:00
|
|
|
Resource *song = _engine->getResMan()->findResource(ResourceId(kResourceTypeSound, atoi(argv[1])), 0);
|
2009-06-02 19:03:43 +00:00
|
|
|
|
|
|
|
if (!song) {
|
|
|
|
DebugPrintf("Doesn't exist\n");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32 offset = 0;
|
|
|
|
|
|
|
|
DebugPrintf("SCI01 song track mappings:\n");
|
|
|
|
|
|
|
|
if (*song->data == 0xf0) // SCI1 priority spec
|
|
|
|
offset = 8;
|
|
|
|
|
|
|
|
if (song->size <= 0)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
while (song->data[offset] != 0xff) {
|
|
|
|
byte device_id = song->data[offset];
|
|
|
|
DebugPrintf("* Device %02x:\n", device_id);
|
|
|
|
offset++;
|
|
|
|
|
|
|
|
if (offset + 1 >= song->size)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
while (song->data[offset] != 0xff) {
|
|
|
|
int track_offset;
|
|
|
|
int end;
|
|
|
|
byte header1, header2;
|
|
|
|
|
|
|
|
if (offset + 7 >= song->size)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
offset += 2;
|
|
|
|
|
|
|
|
track_offset = READ_LE_UINT16(song->data + offset);
|
|
|
|
header1 = song->data[track_offset];
|
|
|
|
header2 = song->data[track_offset+1];
|
|
|
|
track_offset += 2;
|
|
|
|
|
|
|
|
end = READ_LE_UINT16(song->data + offset + 2);
|
|
|
|
DebugPrintf(" - %04x -- %04x", track_offset, track_offset + end);
|
|
|
|
|
|
|
|
if (track_offset == 0xfe)
|
|
|
|
DebugPrintf(" (PCM data)\n");
|
|
|
|
else
|
|
|
|
DebugPrintf(" (channel %d, special %d, %d playing notes, %d foo)\n",
|
|
|
|
header1 & 0xf, header1 >> 4, header2 & 0xf, header2 >> 4);
|
|
|
|
offset += 4;
|
|
|
|
}
|
|
|
|
offset++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int _parse_ticks(byte *data, int *offset_p, int size) {
|
|
|
|
int ticks = 0;
|
|
|
|
int tempticks;
|
|
|
|
int offset = 0;
|
|
|
|
|
|
|
|
do {
|
|
|
|
tempticks = data[offset++];
|
|
|
|
ticks += (tempticks == SCI_MIDI_TIME_EXPANSION_PREFIX) ? SCI_MIDI_TIME_EXPANSION_LENGTH : tempticks;
|
|
|
|
} while (tempticks == SCI_MIDI_TIME_EXPANSION_PREFIX && offset < size);
|
|
|
|
|
|
|
|
if (offset_p)
|
|
|
|
*offset_p = offset;
|
|
|
|
|
|
|
|
return ticks;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Specialised for SCI01 tracks (this affects the way cumulative cues are treated)
|
|
|
|
static void midi_hexdump(byte *data, int size, int notational_offset) {
|
|
|
|
int offset = 0;
|
|
|
|
int prev = 0;
|
|
|
|
const int MIDI_cmdlen[16] = {0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 1, 1, 2, 0};
|
|
|
|
|
|
|
|
if (*data == 0xf0) // SCI1 priority spec
|
|
|
|
offset = 8;
|
|
|
|
|
|
|
|
while (offset < size) {
|
|
|
|
int old_offset = offset;
|
|
|
|
int offset_mod;
|
|
|
|
int time = _parse_ticks(data + offset, &offset_mod, size);
|
|
|
|
int cmd;
|
|
|
|
int pleft;
|
|
|
|
int firstarg = 0;
|
|
|
|
int i;
|
|
|
|
int blanks = 0;
|
|
|
|
|
|
|
|
offset += offset_mod;
|
|
|
|
printf(" [%04x] %d\t",
|
|
|
|
old_offset + notational_offset, time);
|
|
|
|
|
|
|
|
cmd = data[offset];
|
|
|
|
if (!(cmd & 0x80)) {
|
|
|
|
cmd = prev;
|
|
|
|
if (prev < 0x80) {
|
|
|
|
printf("Track broken at %x after"
|
|
|
|
" offset mod of %d\n",
|
|
|
|
offset + notational_offset, offset_mod);
|
|
|
|
Common::hexdump(data, size, 16, notational_offset);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
printf("(rs %02x) ", cmd);
|
|
|
|
blanks += 8;
|
|
|
|
} else {
|
|
|
|
++offset;
|
|
|
|
printf("%02x ", cmd);
|
|
|
|
blanks += 3;
|
|
|
|
}
|
|
|
|
prev = cmd;
|
|
|
|
|
|
|
|
pleft = MIDI_cmdlen[cmd >> 4];
|
|
|
|
if (SCI_MIDI_CONTROLLER(cmd) && data[offset] == SCI_MIDI_CUMULATIVE_CUE)
|
|
|
|
--pleft; // This is SCI(0)1 specific
|
|
|
|
|
|
|
|
for (i = 0; i < pleft; i++) {
|
|
|
|
if (i == 0)
|
|
|
|
firstarg = data[offset];
|
|
|
|
printf("%02x ", data[offset++]);
|
|
|
|
blanks += 3;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (blanks < 16) {
|
|
|
|
blanks += 4;
|
|
|
|
printf(" ");
|
|
|
|
}
|
|
|
|
|
|
|
|
while (blanks < 20) {
|
|
|
|
++blanks;
|
|
|
|
printf(" ");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cmd == SCI_MIDI_EOT)
|
|
|
|
printf(";; EOT");
|
|
|
|
else if (cmd == SCI_MIDI_SET_SIGNAL) {
|
|
|
|
if (firstarg == SCI_MIDI_SET_SIGNAL_LOOP)
|
|
|
|
printf(";; LOOP point");
|
|
|
|
else
|
|
|
|
printf(";; CUE (%d)", firstarg);
|
|
|
|
} else if (SCI_MIDI_CONTROLLER(cmd)) {
|
|
|
|
if (firstarg == SCI_MIDI_CUMULATIVE_CUE)
|
|
|
|
printf(";; CUE (cumulative)");
|
|
|
|
else if (firstarg == SCI_MIDI_RESET_ON_SUSPEND)
|
|
|
|
printf(";; RESET-ON-SUSPEND flag");
|
|
|
|
}
|
|
|
|
printf("\n");
|
|
|
|
|
|
|
|
if (old_offset >= offset) {
|
|
|
|
printf("-- Not moving forward anymore,"
|
|
|
|
" aborting (%x/%x)\n", offset, old_offset);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Console::cmdSfx01Track(int argc, const char **argv) {
|
|
|
|
if (argc != 3) {
|
|
|
|
DebugPrintf("Dumps a track of a SCI01 song\n");
|
|
|
|
DebugPrintf("Usage: %s <track> <offset>\n", argv[0]);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-02-13 17:44:19 +00:00
|
|
|
Resource *song = _engine->getResMan()->findResource(ResourceId(kResourceTypeSound, atoi(argv[1])), 0);
|
2009-06-02 19:03:43 +00:00
|
|
|
|
|
|
|
int offset = atoi(argv[2]);
|
|
|
|
|
|
|
|
if (!song) {
|
|
|
|
DebugPrintf("Doesn't exist\n");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
midi_hexdump(song->data + offset, song->size, offset);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-01-27 20:03:45 +00:00
|
|
|
bool Console::cmdQuit(int argc, const char **argv) {
|
2009-05-29 17:19:39 +00:00
|
|
|
if (argc != 2) {
|
2009-05-30 13:04:09 +00:00
|
|
|
DebugPrintf("%s game - exit gracefully\n", argv[0]);
|
|
|
|
DebugPrintf("%s now - exit ungracefully\n", argv[0]);
|
2009-05-29 17:19:39 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!scumm_stricmp(argv[1], "game")) {
|
|
|
|
// Quit gracefully
|
2010-06-08 21:05:46 +00:00
|
|
|
_engine->_gamestate->abortScriptProcessing = kAbortQuitGame; // Terminate VM
|
2010-07-12 23:20:33 +00:00
|
|
|
_debugState.seeking = kDebugSeekNothing;
|
|
|
|
_debugState.runningStep = 0;
|
2009-05-29 17:19:39 +00:00
|
|
|
|
|
|
|
} else if (!scumm_stricmp(argv[1], "now")) {
|
|
|
|
// Quit ungracefully
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
|
2010-07-16 19:40:51 +00:00
|
|
|
return Cmd_Exit(0, 0);
|
2009-05-29 17:19:39 +00:00
|
|
|
}
|
|
|
|
|
2009-06-02 21:07:34 +00:00
|
|
|
bool Console::cmdAddresses(int argc, const char **argv) {
|
|
|
|
DebugPrintf("Address parameters may be passed in one of three forms:\n");
|
|
|
|
DebugPrintf(" - ssss:oooo -- where 'ssss' denotes a segment and 'oooo' an offset.\n");
|
|
|
|
DebugPrintf(" Example: \"a:c5\" would address something in segment 0xa at offset 0xc5.\n");
|
|
|
|
DebugPrintf(" - &scr:oooo -- where 'scr' is a script number and oooo an offset within that script; will\n");
|
|
|
|
DebugPrintf(" fail if the script is not currently loaded\n");
|
|
|
|
DebugPrintf(" - $REG -- where 'REG' is one of 'PC', 'ACC', 'PREV' or 'OBJ': References the address\n");
|
|
|
|
DebugPrintf(" indicated by the register of this name.\n");
|
|
|
|
DebugPrintf(" - $REG+n (or -n) -- Like $REG, but modifies the offset part by a specific amount (which\n");
|
|
|
|
DebugPrintf(" is specified in hexadecimal).\n");
|
|
|
|
DebugPrintf(" - ?obj -- Looks up an object with the specified name, uses its address. This will abort if\n");
|
|
|
|
DebugPrintf(" the object name is ambiguous; in that case, a list of addresses and indices is provided.\n");
|
|
|
|
DebugPrintf(" ?obj.idx may be used to disambiguate 'obj' by the index 'idx'.\n");
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-10-01 11:06:38 +00:00
|
|
|
// Returns 0 on success
|
2010-01-02 09:39:17 +00:00
|
|
|
static int parse_reg_t(EngineState *s, const char *str, reg_t *dest, bool mayBeValue) {
|
2009-10-02 20:20:45 +00:00
|
|
|
// Pointer to the part of str which contains a numeric offset (if any)
|
|
|
|
const char *offsetStr = NULL;
|
|
|
|
|
|
|
|
// Flag that tells whether the value stored in offsetStr is an absolute offset,
|
|
|
|
// or a relative offset against dest->offset.
|
|
|
|
bool relativeOffset = false;
|
|
|
|
|
2009-06-02 23:29:58 +00:00
|
|
|
// Non-NULL: Parse end of string for relative offsets
|
|
|
|
char *endptr;
|
|
|
|
|
2009-10-02 20:20:45 +00:00
|
|
|
if (*str == '$') { // Register: "$FOO" or "$FOO+NUM" or "$FOO-NUM
|
|
|
|
relativeOffset = true;
|
2009-06-02 23:29:58 +00:00
|
|
|
|
|
|
|
if (!scumm_strnicmp(str + 1, "PC", 2)) {
|
|
|
|
*dest = s->_executionStack.back().addr.pc;
|
2009-10-02 20:20:45 +00:00
|
|
|
offsetStr = str + 3;
|
2009-06-02 23:29:58 +00:00
|
|
|
} else if (!scumm_strnicmp(str + 1, "P", 1)) {
|
|
|
|
*dest = s->_executionStack.back().addr.pc;
|
2009-10-02 20:20:45 +00:00
|
|
|
offsetStr = str + 2;
|
2009-06-02 23:29:58 +00:00
|
|
|
} else if (!scumm_strnicmp(str + 1, "PREV", 4)) {
|
|
|
|
*dest = s->r_prev;
|
2009-10-02 20:20:45 +00:00
|
|
|
offsetStr = str + 5;
|
2009-06-02 23:29:58 +00:00
|
|
|
} else if (!scumm_strnicmp(str + 1, "ACC", 3)) {
|
|
|
|
*dest = s->r_acc;
|
2009-10-02 20:20:45 +00:00
|
|
|
offsetStr = str + 4;
|
2009-06-02 23:29:58 +00:00
|
|
|
} else if (!scumm_strnicmp(str + 1, "A", 1)) {
|
|
|
|
*dest = s->r_acc;
|
2009-10-02 20:20:45 +00:00
|
|
|
offsetStr = str + 2;
|
2009-06-02 23:29:58 +00:00
|
|
|
} else if (!scumm_strnicmp(str + 1, "OBJ", 3)) {
|
|
|
|
*dest = s->_executionStack.back().objp;
|
2009-10-02 20:20:45 +00:00
|
|
|
offsetStr = str + 4;
|
2009-06-02 23:29:58 +00:00
|
|
|
} else if (!scumm_strnicmp(str + 1, "O", 1)) {
|
|
|
|
*dest = s->_executionStack.back().objp;
|
2009-10-02 20:20:45 +00:00
|
|
|
offsetStr = str + 2;
|
2009-06-02 23:29:58 +00:00
|
|
|
} else
|
|
|
|
return 1; // No matching register
|
|
|
|
|
2009-10-02 20:20:45 +00:00
|
|
|
if (!*offsetStr)
|
|
|
|
offsetStr = NULL;
|
|
|
|
else if (*offsetStr != '+' && *offsetStr != '-')
|
2009-06-02 23:29:58 +00:00
|
|
|
return 1;
|
2009-10-02 20:20:45 +00:00
|
|
|
} else if (*str == '&') { // Script relative: "&SCRIPT-ID:OFFSET"
|
|
|
|
// Look up by script ID. The text from start till just before the colon
|
|
|
|
// (resp. end of string, if there is no colon) contains the script ID.
|
|
|
|
const char *colon = strchr(str, ':');
|
2009-06-02 23:29:58 +00:00
|
|
|
if (!colon)
|
|
|
|
return 1;
|
|
|
|
|
2009-10-02 20:20:45 +00:00
|
|
|
// Extract the script id and parse it
|
|
|
|
Common::String scriptStr(str, colon);
|
|
|
|
int script_nr = strtol(scriptStr.c_str() + 1, &endptr, 10);
|
2009-06-02 23:29:58 +00:00
|
|
|
if (*endptr)
|
|
|
|
return 1;
|
|
|
|
|
2009-10-02 20:20:45 +00:00
|
|
|
// Now lookup the script's segment
|
2009-10-04 18:38:18 +00:00
|
|
|
dest->segment = s->_segMan->getScriptSegment(script_nr);
|
2009-06-02 23:29:58 +00:00
|
|
|
if (!dest->segment) {
|
|
|
|
return 1;
|
|
|
|
}
|
2009-10-02 20:20:45 +00:00
|
|
|
|
|
|
|
// Finally, after the colon comes the offset
|
|
|
|
offsetStr = colon + 1;
|
2009-06-02 23:29:58 +00:00
|
|
|
|
2010-05-19 13:32:27 +00:00
|
|
|
} else {
|
|
|
|
// Now we either got an object name, or segment:offset or plain value
|
|
|
|
// segment:offset is recognized by the ":"
|
|
|
|
// plain value may be "123" or "123h" or "fffh" or "0xfff"
|
|
|
|
// object name is assumed if nothing else matches or a "?" is used as prefix as override
|
|
|
|
// object name may contain "+", "-" and "." for relative calculations, those chars are used nowhere else
|
|
|
|
|
|
|
|
// First we cycle through the string counting special chars
|
|
|
|
const char *strLoop = str;
|
|
|
|
int charsCount = strlen(str);
|
|
|
|
int charsCountObject = 0;
|
|
|
|
int charsCountSegmentOffset = 0;
|
|
|
|
int charsCountLetter = 0;
|
|
|
|
int charsCountNumber = 0;
|
|
|
|
bool charsForceHex = false;
|
|
|
|
bool charsForceObject = false;
|
|
|
|
|
|
|
|
while (*strLoop) {
|
|
|
|
switch (*strLoop) {
|
|
|
|
case '+':
|
|
|
|
case '-':
|
|
|
|
case '.':
|
|
|
|
charsCountObject++;
|
|
|
|
break;
|
|
|
|
case '?':
|
|
|
|
if (strLoop == str) {
|
|
|
|
charsForceObject = true;
|
|
|
|
str++; // skip over prefix
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ':':
|
|
|
|
charsCountSegmentOffset++;
|
|
|
|
break;
|
|
|
|
case 'h':
|
|
|
|
if (*(strLoop + 1) == 0)
|
|
|
|
charsForceHex = true;
|
|
|
|
else
|
|
|
|
charsCountObject++;
|
|
|
|
break;
|
|
|
|
case '0':
|
|
|
|
if (*(strLoop + 1) == 'x') {
|
|
|
|
str += 2; // skip "0x"
|
|
|
|
strLoop++; // skip "x"
|
|
|
|
charsForceHex = true;
|
|
|
|
}
|
|
|
|
charsCountNumber++;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
if ((*strLoop >= '0') && (*strLoop <= '9'))
|
|
|
|
charsCountNumber++;
|
|
|
|
if ((*strLoop >= 'a') && (*strLoop <= 'f'))
|
|
|
|
charsCountLetter++;
|
|
|
|
if ((*strLoop >= 'A') && (*strLoop <= 'F'))
|
|
|
|
charsCountLetter++;
|
|
|
|
if ((*strLoop >= 'i') && (*strLoop <= 'z'))
|
|
|
|
charsCountObject++;
|
|
|
|
if ((*strLoop >= 'I') && (*strLoop <= 'Z'))
|
|
|
|
charsCountObject++;
|
|
|
|
}
|
|
|
|
strLoop++;
|
|
|
|
}
|
2009-10-02 20:20:45 +00:00
|
|
|
|
2010-05-19 13:32:27 +00:00
|
|
|
if ((charsCountObject) && (charsCountSegmentOffset))
|
|
|
|
return 1; // input doesn't make sense
|
2009-06-02 23:29:58 +00:00
|
|
|
|
2010-05-19 13:32:27 +00:00
|
|
|
if (!charsForceObject) {
|
|
|
|
// input may be values/segment:offset
|
2009-06-02 23:29:58 +00:00
|
|
|
|
2010-05-19 13:32:27 +00:00
|
|
|
if (charsCountSegmentOffset) {
|
|
|
|
// ':' found, so must be segment:offset
|
|
|
|
const char *colon = strchr(str, ':');
|
2009-06-02 23:29:58 +00:00
|
|
|
|
2010-05-19 13:32:27 +00:00
|
|
|
offsetStr = colon + 1;
|
2009-06-02 23:29:58 +00:00
|
|
|
|
2010-05-19 13:32:27 +00:00
|
|
|
Common::String segmentStr(str, colon);
|
|
|
|
dest->segment = strtol(segmentStr.c_str(), &endptr, 16);
|
|
|
|
if (*endptr)
|
|
|
|
return 1;
|
|
|
|
} else {
|
|
|
|
int val = 0;
|
|
|
|
dest->segment = 0;
|
2009-06-02 23:29:58 +00:00
|
|
|
|
2010-05-19 13:32:27 +00:00
|
|
|
if (charsCountNumber == charsCount) {
|
|
|
|
// Only numbers in input, assume decimal value
|
2010-01-02 09:39:17 +00:00
|
|
|
val = strtol(str, &endptr, 10);
|
|
|
|
if (*endptr)
|
2010-05-19 13:32:27 +00:00
|
|
|
return 1; // strtol failed?
|
|
|
|
dest->offset = val;
|
|
|
|
return 0;
|
2010-01-02 09:39:17 +00:00
|
|
|
} else {
|
2010-05-19 13:32:27 +00:00
|
|
|
// We also got letters, check if there were only hexadecimal letters and '0x' at the start or 'h' at the end
|
|
|
|
if ((charsForceHex) && (!charsCountObject)) {
|
|
|
|
val = strtol(str, &endptr, 16);
|
|
|
|
if ((*endptr != 'h') && (*endptr != 0))
|
|
|
|
return 1;
|
|
|
|
dest->offset = val;
|
|
|
|
return 0;
|
|
|
|
} else {
|
|
|
|
// Something else was in input, assume object name
|
|
|
|
charsForceObject = true;
|
|
|
|
}
|
2010-01-02 09:39:17 +00:00
|
|
|
}
|
|
|
|
}
|
2010-05-19 13:32:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (charsForceObject) {
|
|
|
|
// We assume now that input is object name
|
|
|
|
// Object by name: "?OBJ" or "?OBJ.INDEX" or "?OBJ.INDEX+OFFSET" or "?OBJ.INDEX-OFFSET"
|
|
|
|
// The (optional) index can be used to distinguish multiple object with the same name.
|
|
|
|
int index = -1;
|
|
|
|
|
|
|
|
// Look for an offset. It starts with + or -
|
|
|
|
relativeOffset = true;
|
|
|
|
offsetStr = strchr(str, '+');
|
|
|
|
if (!offsetStr) // No + found, look for -
|
|
|
|
offsetStr = strchr(str, '-');
|
|
|
|
|
|
|
|
// Strip away the offset and the leading '?'
|
|
|
|
Common::String str_objname;
|
|
|
|
if (offsetStr)
|
|
|
|
str_objname = Common::String(str, offsetStr);
|
|
|
|
else
|
|
|
|
str_objname = str;
|
|
|
|
|
|
|
|
// Scan for a period, after which (if present) we'll find an index
|
|
|
|
const char *tmp = Common::find(str_objname.begin(), str_objname.end(), '.');
|
|
|
|
if (tmp != str_objname.end()) {
|
|
|
|
index = strtol(tmp + 1, &endptr, 16);
|
|
|
|
if (*endptr)
|
|
|
|
return -1;
|
|
|
|
// Chop of the index
|
|
|
|
str_objname = Common::String(str_objname.c_str(), tmp);
|
|
|
|
}
|
2009-06-02 23:29:58 +00:00
|
|
|
|
2010-05-19 13:32:27 +00:00
|
|
|
// Now all values are available; iterate over all objects.
|
|
|
|
*dest = s->_segMan->findObjectByName(str_objname, index);
|
|
|
|
if (dest->isNull())
|
2009-06-02 23:29:58 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
2009-10-02 20:20:45 +00:00
|
|
|
if (offsetStr) {
|
|
|
|
int val = strtol(offsetStr, &endptr, 16);
|
2009-06-02 23:29:58 +00:00
|
|
|
|
2009-10-02 20:20:45 +00:00
|
|
|
if (relativeOffset)
|
2009-06-02 23:29:58 +00:00
|
|
|
dest->offset += val;
|
|
|
|
else
|
|
|
|
dest->offset = val;
|
|
|
|
|
|
|
|
if (*endptr)
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-07-07 14:19:36 +00:00
|
|
|
bool Console::parseInteger(const char *argument, int &result) {
|
|
|
|
char *endPtr = 0;
|
|
|
|
int idxLen = strlen(argument);
|
|
|
|
const char *lastChar = argument + idxLen - (idxLen == 0 ? 0 : 1);
|
|
|
|
|
|
|
|
if ((strncmp(argument, "0x", 2) == 0) || (*lastChar == 'h')) {
|
|
|
|
// hexadecimal number
|
|
|
|
result = strtol(argument, &endPtr, 16);
|
|
|
|
if ((*endPtr != 0) && (*endPtr != 'h')) {
|
|
|
|
DebugPrintf("Invalid hexadecimal number '%s'\n", argument);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// decimal number
|
|
|
|
result = strtol(argument, &endPtr, 10);
|
|
|
|
if (*endPtr != 0) {
|
|
|
|
DebugPrintf("Invalid decimal number '%s'\n", argument);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-06-27 20:38:41 +00:00
|
|
|
void Console::printBasicVarInfo(reg_t variable) {
|
2010-07-07 18:35:07 +00:00
|
|
|
int regType = g_sci->getKernel()->findRegType(variable);
|
|
|
|
int segType = regType;
|
2010-06-27 20:38:41 +00:00
|
|
|
SegManager *segMan = g_sci->getEngineState()->_segMan;
|
|
|
|
|
2010-07-07 18:35:07 +00:00
|
|
|
segType &= SIG_TYPE_INTEGER | SIG_TYPE_OBJECT | SIG_TYPE_REFERENCE | SIG_TYPE_NODE | SIG_TYPE_LIST | SIG_TYPE_UNINITIALIZED | SIG_TYPE_ERROR;
|
2010-06-27 20:38:41 +00:00
|
|
|
|
|
|
|
switch (segType) {
|
2010-07-05 14:36:31 +00:00
|
|
|
case SIG_TYPE_INTEGER: {
|
2010-06-27 20:38:41 +00:00
|
|
|
uint16 content = variable.toUint16();
|
|
|
|
if (content >= 10)
|
|
|
|
DebugPrintf(" (%dd)", content);
|
|
|
|
break;
|
|
|
|
}
|
2010-07-05 14:36:31 +00:00
|
|
|
case SIG_TYPE_OBJECT:
|
2010-06-27 20:38:41 +00:00
|
|
|
DebugPrintf(" (object '%s')", segMan->getObjectName(variable));
|
|
|
|
break;
|
2010-07-05 14:36:31 +00:00
|
|
|
case SIG_TYPE_REFERENCE:
|
2010-06-27 20:38:41 +00:00
|
|
|
DebugPrintf(" (reference)");
|
|
|
|
break;
|
2010-07-05 14:36:31 +00:00
|
|
|
case SIG_TYPE_NODE:
|
2010-06-27 20:38:41 +00:00
|
|
|
DebugPrintf(" (node)");
|
|
|
|
break;
|
2010-07-05 14:36:31 +00:00
|
|
|
case SIG_TYPE_LIST:
|
2010-06-27 20:38:41 +00:00
|
|
|
DebugPrintf(" (list)");
|
|
|
|
break;
|
2010-07-05 14:36:31 +00:00
|
|
|
case SIG_TYPE_UNINITIALIZED:
|
|
|
|
DebugPrintf(" (uninitialized)");
|
|
|
|
break;
|
2010-07-07 18:35:07 +00:00
|
|
|
case SIG_TYPE_ERROR:
|
|
|
|
DebugPrintf(" (error)");
|
2010-07-06 14:26:29 +00:00
|
|
|
break;
|
2010-06-27 20:38:41 +00:00
|
|
|
default:
|
2010-06-27 21:04:47 +00:00
|
|
|
DebugPrintf(" (??\?)");
|
2010-06-27 20:38:41 +00:00
|
|
|
}
|
2010-07-07 18:35:07 +00:00
|
|
|
|
|
|
|
if (regType & SIG_IS_INVALID)
|
|
|
|
DebugPrintf(" IS INVALID!");
|
2010-06-27 20:38:41 +00:00
|
|
|
}
|
|
|
|
|
2010-06-25 19:09:19 +00:00
|
|
|
void Console::printList(List *list) {
|
|
|
|
reg_t pos = list->first;
|
2009-06-02 23:29:58 +00:00
|
|
|
reg_t my_prev = NULL_REG;
|
|
|
|
|
|
|
|
DebugPrintf("\t<\n");
|
|
|
|
|
|
|
|
while (!pos.isNull()) {
|
|
|
|
Node *node;
|
2010-05-18 13:05:09 +00:00
|
|
|
NodeTable *nt = (NodeTable *)_engine->_gamestate->_segMan->getSegment(pos.segment, SEG_TYPE_NODES);
|
2009-06-02 23:29:58 +00:00
|
|
|
|
|
|
|
if (!nt || !nt->isValidEntry(pos.offset)) {
|
|
|
|
DebugPrintf(" WARNING: %04x:%04x: Doesn't contain list node!\n",
|
|
|
|
PRINT_REG(pos));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
node = &(nt->_table[pos.offset]);
|
|
|
|
|
|
|
|
DebugPrintf("\t%04x:%04x : %04x:%04x -> %04x:%04x\n", PRINT_REG(pos), PRINT_REG(node->key), PRINT_REG(node->value));
|
|
|
|
|
|
|
|
if (my_prev != node->pred)
|
|
|
|
DebugPrintf(" WARNING: current node gives %04x:%04x as predecessor!\n",
|
|
|
|
PRINT_REG(node->pred));
|
|
|
|
|
|
|
|
my_prev = pos;
|
|
|
|
pos = node->succ;
|
|
|
|
}
|
|
|
|
|
2010-06-25 19:09:19 +00:00
|
|
|
if (my_prev != list->last)
|
2009-06-02 23:29:58 +00:00
|
|
|
DebugPrintf(" WARNING: Last node was expected to be %04x:%04x, was %04x:%04x!\n",
|
2010-06-25 19:09:19 +00:00
|
|
|
PRINT_REG(list->last), PRINT_REG(my_prev));
|
2009-06-02 23:29:58 +00:00
|
|
|
DebugPrintf("\t>\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
int Console::printNode(reg_t addr) {
|
2010-05-18 13:05:09 +00:00
|
|
|
SegmentObj *mobj = _engine->_gamestate->_segMan->getSegment(addr.segment, SEG_TYPE_LISTS);
|
2009-06-02 23:29:58 +00:00
|
|
|
|
|
|
|
if (mobj) {
|
|
|
|
ListTable *lt = (ListTable *)mobj;
|
|
|
|
List *list;
|
|
|
|
|
|
|
|
if (!lt->isValidEntry(addr.offset)) {
|
|
|
|
DebugPrintf("Address does not contain a list\n");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
list = &(lt->_table[addr.offset]);
|
|
|
|
|
|
|
|
DebugPrintf("%04x:%04x : first x last = (%04x:%04x, %04x:%04x)\n", PRINT_REG(addr), PRINT_REG(list->first), PRINT_REG(list->last));
|
|
|
|
} else {
|
|
|
|
NodeTable *nt;
|
|
|
|
Node *node;
|
2010-05-18 13:05:09 +00:00
|
|
|
mobj = _engine->_gamestate->_segMan->getSegment(addr.segment, SEG_TYPE_NODES);
|
2009-06-02 23:29:58 +00:00
|
|
|
|
|
|
|
if (!mobj) {
|
|
|
|
DebugPrintf("Segment #%04x is not a list or node segment\n", addr.segment);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
nt = (NodeTable *)mobj;
|
|
|
|
|
|
|
|
if (!nt->isValidEntry(addr.offset)) {
|
|
|
|
DebugPrintf("Address does not contain a node\n");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
node = &(nt->_table[addr.offset]);
|
|
|
|
|
|
|
|
DebugPrintf("%04x:%04x : prev x next = (%04x:%04x, %04x:%04x); maps %04x:%04x -> %04x:%04x\n",
|
|
|
|
PRINT_REG(addr), PRINT_REG(node->pred), PRINT_REG(node->succ), PRINT_REG(node->key), PRINT_REG(node->value));
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-07-08 13:08:51 +00:00
|
|
|
int Console::printObject(reg_t pos) {
|
2010-02-03 01:32:03 +00:00
|
|
|
EngineState *s = _engine->_gamestate; // for the several defines in this function
|
2010-05-26 16:30:10 +00:00
|
|
|
const Object *obj = s->_segMan->getObject(pos);
|
|
|
|
const Object *var_container = obj;
|
2009-10-10 15:58:51 +00:00
|
|
|
uint i;
|
2009-06-02 23:29:58 +00:00
|
|
|
|
|
|
|
if (!obj) {
|
2009-07-08 13:08:51 +00:00
|
|
|
DebugPrintf("[%04x:%04x]: Not an object.", PRINT_REG(pos));
|
2009-06-02 23:29:58 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Object header
|
2009-10-04 18:38:18 +00:00
|
|
|
DebugPrintf("[%04x:%04x] %s : %3d vars, %3d methods\n", PRINT_REG(pos), s->_segMan->getObjectName(pos),
|
2009-10-10 15:58:51 +00:00
|
|
|
obj->getVarCount(), obj->getMethodCount());
|
2009-06-02 23:29:58 +00:00
|
|
|
|
2010-06-03 10:16:21 +00:00
|
|
|
if (!obj->isClass())
|
2009-10-04 18:38:18 +00:00
|
|
|
var_container = s->_segMan->getObject(obj->getSuperClassSelector());
|
2009-07-08 13:08:51 +00:00
|
|
|
DebugPrintf(" -- member variables:\n");
|
2009-10-10 15:58:51 +00:00
|
|
|
for (i = 0; (uint)i < obj->getVarCount(); i++) {
|
2010-01-31 18:49:59 +00:00
|
|
|
DebugPrintf(" ");
|
2009-10-10 15:58:51 +00:00
|
|
|
if (i < var_container->getVarCount()) {
|
2009-09-17 16:50:53 +00:00
|
|
|
uint16 varSelector = var_container->getVarSelector(i);
|
2010-06-17 23:13:30 +00:00
|
|
|
DebugPrintf("[%03x] %s = ", varSelector, _engine->getKernel()->getSelectorName(varSelector).c_str());
|
2009-06-02 23:29:58 +00:00
|
|
|
} else
|
2009-07-08 13:08:51 +00:00
|
|
|
DebugPrintf("p#%x = ", i);
|
2009-06-02 23:29:58 +00:00
|
|
|
|
2009-10-10 15:58:51 +00:00
|
|
|
reg_t val = obj->getVariable(i);
|
2009-07-08 13:08:51 +00:00
|
|
|
DebugPrintf("%04x:%04x", PRINT_REG(val));
|
2009-06-02 23:29:58 +00:00
|
|
|
|
2010-01-31 18:14:19 +00:00
|
|
|
if (!val.segment)
|
|
|
|
DebugPrintf(" (%d)", val.offset);
|
|
|
|
|
2010-05-26 16:30:10 +00:00
|
|
|
const Object *ref = s->_segMan->getObject(val);
|
2009-06-02 23:29:58 +00:00
|
|
|
if (ref)
|
2009-10-04 18:38:18 +00:00
|
|
|
DebugPrintf(" (%s)", s->_segMan->getObjectName(val));
|
2009-06-02 23:29:58 +00:00
|
|
|
|
2009-07-08 13:08:51 +00:00
|
|
|
DebugPrintf("\n");
|
2009-06-02 23:29:58 +00:00
|
|
|
}
|
2009-07-08 13:08:51 +00:00
|
|
|
DebugPrintf(" -- methods:\n");
|
2009-10-10 15:58:51 +00:00
|
|
|
for (i = 0; i < obj->getMethodCount(); i++) {
|
2009-09-17 16:50:53 +00:00
|
|
|
reg_t fptr = obj->getFunction(i);
|
2010-06-17 23:13:30 +00:00
|
|
|
DebugPrintf(" [%03x] %s = %04x:%04x\n", obj->getFuncSelector(i), _engine->getKernel()->getSelectorName(obj->getFuncSelector(i)).c_str(), PRINT_REG(fptr));
|
2009-06-02 23:29:58 +00:00
|
|
|
}
|
2009-10-04 18:38:18 +00:00
|
|
|
if (s->_segMan->_heap[pos.segment]->getType() == SEG_TYPE_SCRIPT)
|
2010-06-28 11:22:20 +00:00
|
|
|
DebugPrintf("\nOwner script: %d\n", s->_segMan->getScript(pos.segment)->getScriptNumber());
|
2009-06-02 23:29:58 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-07-04 23:38:08 +00:00
|
|
|
void Console::hexDumpReg(const reg_t *data, int len, int regsPerLine, int startOffset, bool isArray) {
|
|
|
|
// reg_t version of Common::hexdump
|
|
|
|
assert(1 <= regsPerLine && regsPerLine <= 8);
|
|
|
|
int i;
|
|
|
|
byte c;
|
|
|
|
int offset = startOffset;
|
|
|
|
while (len >= regsPerLine) {
|
|
|
|
printf("%06x: ", offset);
|
|
|
|
for (i = 0; i < regsPerLine; i++) {
|
|
|
|
printf("%04x:%04x ", PRINT_REG(data[i]));
|
|
|
|
}
|
|
|
|
printf(" |");
|
|
|
|
for (i = 0; i < regsPerLine; i++) {
|
2010-07-18 17:48:48 +00:00
|
|
|
c = data[i].toUint16() & 0xff;
|
2010-07-04 23:38:08 +00:00
|
|
|
if (c < 32 || c >= 127)
|
|
|
|
c = '.';
|
|
|
|
printf("%c", c);
|
2010-07-18 17:48:48 +00:00
|
|
|
c = data[i].toUint16() >> 8;
|
2010-07-04 23:38:08 +00:00
|
|
|
if (c < 32 || c >= 127)
|
|
|
|
c = '.';
|
|
|
|
printf("%c", c);
|
|
|
|
}
|
|
|
|
printf("|\n");
|
|
|
|
data += regsPerLine;
|
|
|
|
len -= regsPerLine;
|
|
|
|
offset += regsPerLine * (isArray ? 1 : 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (len <= 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
printf("%06x: ", offset);
|
|
|
|
for (i = 0; i < regsPerLine; i++) {
|
|
|
|
if (i < len)
|
|
|
|
printf("%04x:%04x ", PRINT_REG(data[i]));
|
|
|
|
else
|
|
|
|
printf(" ");
|
|
|
|
}
|
|
|
|
printf(" |");
|
|
|
|
for (i = 0; i < len; i++) {
|
2010-07-18 17:48:48 +00:00
|
|
|
c = data[i].toUint16() & 0xff;
|
2010-07-04 23:38:08 +00:00
|
|
|
if (c < 32 || c >= 127)
|
|
|
|
c = '.';
|
|
|
|
printf("%c", c);
|
2010-07-18 17:48:48 +00:00
|
|
|
c = data[i].toUint16() >> 8;
|
2010-07-04 23:38:08 +00:00
|
|
|
if (c < 32 || c >= 127)
|
|
|
|
c = '.';
|
|
|
|
printf("%c", c);
|
|
|
|
}
|
|
|
|
for (; i < regsPerLine; i++)
|
|
|
|
printf(" ");
|
|
|
|
printf("|\n");
|
|
|
|
}
|
|
|
|
|
2009-02-20 21:26:31 +00:00
|
|
|
} // End of namespace Sci
|