diff options
author | uruk | 2014-07-26 12:59:39 +0200 |
---|---|---|
committer | uruk | 2014-07-26 12:59:39 +0200 |
commit | 0bfde974cde8eea024d66d35b5444ad4c1469701 (patch) | |
tree | d0555acd355c0aeb114281d8a8a770d11f791c51 | |
parent | c78596a80e5dde89a37486417288be8cb65cc4b5 (diff) | |
download | scummvm-rg350-0bfde974cde8eea024d66d35b5444ad4c1469701.tar.gz scummvm-rg350-0bfde974cde8eea024d66d35b5444ad4c1469701.tar.bz2 scummvm-rg350-0bfde974cde8eea024d66d35b5444ad4c1469701.zip |
CGE2: Implement debug console and add a debug channel for opcodes.
-rw-r--r-- | engines/cge2/cge2.cpp | 14 | ||||
-rw-r--r-- | engines/cge2/cge2.h | 16 | ||||
-rw-r--r-- | engines/cge2/console.h | 43 | ||||
-rw-r--r-- | engines/cge2/events.cpp | 2 | ||||
-rw-r--r-- | engines/cge2/module.mk | 3 | ||||
-rw-r--r-- | engines/cge2/snail.cpp | 8 | ||||
-rw-r--r-- | engines/cge2/snail.h | 1 |
7 files changed, 80 insertions, 7 deletions
diff --git a/engines/cge2/cge2.cpp b/engines/cge2/cge2.cpp index 7c208d1215..6f4c34c607 100644 --- a/engines/cge2/cge2.cpp +++ b/engines/cge2/cge2.cpp @@ -27,6 +27,8 @@ #include "engines/util.h" #include "common/config-manager.h" +#include "common/debug.h" +#include "common/debug-channels.h" #include "cge2/cge2.h" #include "cge2/bitmap.h" #include "cge2/vga13h.h" @@ -43,6 +45,10 @@ namespace CGE2 { CGE2Engine::CGE2Engine(OSystem *syst, const ADGameDescription *gameDescription) : Engine(syst), _gameDescription(gameDescription), _randomSource("cge2") { + + // Debug/console setup + DebugMan.addDebugChannel(kCGE2DebugOpcode, "opcode", "CGE2 opcode debug channel"); + _resman = nullptr; _vga = nullptr; _midiPlayer = nullptr; @@ -109,6 +115,9 @@ CGE2Engine::CGE2Engine(OSystem *syst, const ADGameDescription *gameDescription) } void CGE2Engine::init() { + // Create debugger console + _console = new CGE2Console(this); + _resman = new ResourceManager(); _vga = new Vga(this); _fx = new Fx(this, 16); @@ -137,6 +146,11 @@ void CGE2Engine::init() { } void CGE2Engine::deinit() { + // Remove all of our debug levels here + DebugMan.clearAllDebugChannels(); + + delete _console; + delete _spare; delete _resman; delete _vga; diff --git a/engines/cge2/cge2.h b/engines/cge2/cge2.h index 94263ac641..833cb66c72 100644 --- a/engines/cge2/cge2.h +++ b/engines/cge2/cge2.h @@ -35,6 +35,7 @@ #include "engines/advancedDetector.h" #include "common/system.h" #include "cge2/fileio.h" +#include "cge2/console.h" #include "audio/mixer.h" namespace CGE2 { @@ -113,6 +114,11 @@ struct SavegameHeader; #define kSavegameStrSize 12 #define kSavegameStr "SCUMMVM_CGE2" +// our engine debug channels +enum { + kCGE2DebugOpcode = 1 << 0, +}; + enum CallbackType { kNullCB = 0, kQGame, kXScene, kSoundSetVolume }; @@ -128,6 +134,10 @@ private: uint32 _lastFrame, _lastTick; void tick(); + CGE2Console *_console; + void init(); + void deinit(); + Common::String generateSaveName(int slot); void writeSavegameHeader(Common::OutSaveFile *out, SavegameHeader &header); void syncGame(Common::SeekableReadStream *readStream, Common::WriteStream *writeStream); @@ -143,6 +153,9 @@ public: virtual Common::Error saveGameState(int slot, const Common::String &desc); virtual Common::Error loadGameState(int slot); virtual Common::Error run(); + GUI::Debugger *getDebugger() { + return _console; + } static bool readSavegameHeader(Common::InSaveFile *in, SavegameHeader &header); bool showTitle(const char *name); @@ -314,9 +327,6 @@ public: Sprite *_vol[2]; EventManager *_eventManager; Map *_map; -private: - void init(); - void deinit(); }; } // End of namespace CGE2 diff --git a/engines/cge2/console.h b/engines/cge2/console.h new file mode 100644 index 0000000000..cb2120d7e7 --- /dev/null +++ b/engines/cge2/console.h @@ -0,0 +1,43 @@ +/* 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. + * + */ + +#ifndef CGE2_CONSOLE_H +#define CGE2_CONSOLE_H + +#include "gui/debugger.h" + +namespace CGE2 { + +class CGE2Engine; + +class CGE2Console : public GUI::Debugger { +public: + CGE2Console(CGE2Engine *vm) : GUI::Debugger(), _vm(vm) {} + virtual ~CGE2Console() {} + +private: + CGE2Engine *_vm; +}; + +} // End of namespace CGE + +#endif // CGE2_CONSOLE_H diff --git a/engines/cge2/events.cpp b/engines/cge2/events.cpp index 914f1255be..25ca77fa74 100644 --- a/engines/cge2/events.cpp +++ b/engines/cge2/events.cpp @@ -89,14 +89,12 @@ bool Keyboard::getKey(Common::Event &event) { } return false; case Common::KEYCODE_d: - /* if (event.kbd.flags & Common::KBD_CTRL) { // Start the debugger _vm->getDebugger()->attach(); _vm->getDebugger()->onFrame(); return false; } - */ break; case Common::KEYCODE_x: if (event.kbd.flags & Common::KBD_ALT) { diff --git a/engines/cge2/module.mk b/engines/cge2/module.mk index 256087fd17..4b321d88a8 100644 --- a/engines/cge2/module.mk +++ b/engines/cge2/module.mk @@ -18,7 +18,8 @@ MODULE_OBJS = \ vmenu.o \ saveload.o \ toolbar.o \ - inventory.o + inventory.o \ + console.o # This module can be built as a plugin ifeq ($(ENABLE_CGE2), DYNAMIC_PLUGIN) diff --git a/engines/cge2/snail.cpp b/engines/cge2/snail.cpp index 8a1340f5dc..ba33dd04eb 100644 --- a/engines/cge2/snail.cpp +++ b/engines/cge2/snail.cpp @@ -40,7 +40,7 @@ const char *CommandHandler::_commandText[] = { "HIDE", "ROOM", "SAY", "SOUND", "KILL", "RSEQ", "SEQ", "SEND", "SWAP", "KEEP", "GIVE", "GETPOS", "GOTO", "PORT", "NEXT", "NNEXT", "MTNEXT", "FTNEXT", "RNNEXT", "RMTNEXT", "RFTNEXT", "RMNEAR", "RMMTAKE", "RMFTAKE", - "SETREF", "WALKTO", "REACH", "COVER", "UNCOVER", + "SETREF", "WALKTO", "REACH", "COVER", "UNCOVER", "EXEC", "GHOST", nullptr }; CommandHandler::CommandHandler(CGE2Engine *vm, bool turbo) @@ -102,6 +102,8 @@ void CommandHandler::runCommand() { if (tailCmd._commandType > kCmdSpr) spr = (tailCmd._ref < 0) ? ((Sprite *)tailCmd._spritePtr) : _vm->locate(tailCmd._ref); + debugC(1, kCGE2DebugOpcode, getComStr(tailCmd._commandType)); + switch (tailCmd._commandType) { case kCmdUse: break; @@ -742,6 +744,10 @@ int CommandHandler::getComId(const char *com) { return (i < 0) ? i : i + kCmdCom0 + 1; } +const char *CommandHandler::getComStr(CommandType cmdType) { + return _commandText[cmdType - kCmdNop]; +} + void CGE2Engine::feedSnail(Sprite *spr, Action snq, Hero *hero) { if (!spr || !spr->active()) return; diff --git a/engines/cge2/snail.h b/engines/cge2/snail.h index 3026f078c7..55da49045f 100644 --- a/engines/cge2/snail.h +++ b/engines/cge2/snail.h @@ -115,6 +115,7 @@ public: void reset(); void clear(); int getComId(const char *com); + const char *getComStr(CommandType cmdType); private: CGE2Engine *_vm; bool _turbo; |