diff options
author | Strangerke | 2016-04-12 07:26:30 +0200 |
---|---|---|
committer | Eugene Sandulenko | 2016-05-10 09:54:21 +0200 |
commit | 52f0712b66fff3351ae6c2b5fd8e1abcdaad6001 (patch) | |
tree | c6fac5a33b374f7530722954d24af430b1ee91d2 /engines/gnap | |
parent | 03027be392de3dbf698361abf2395f3d7cc4e53e (diff) | |
download | scummvm-rg350-52f0712b66fff3351ae6c2b5fd8e1abcdaad6001.tar.gz scummvm-rg350-52f0712b66fff3351ae6c2b5fd8e1abcdaad6001.tar.bz2 scummvm-rg350-52f0712b66fff3351ae6c2b5fd8e1abcdaad6001.zip |
GNAP: Add debugger
Diffstat (limited to 'engines/gnap')
-rw-r--r-- | engines/gnap/debugger.cpp | 42 | ||||
-rw-r--r-- | engines/gnap/debugger.h | 54 | ||||
-rw-r--r-- | engines/gnap/gnap.cpp | 25 | ||||
-rw-r--r-- | engines/gnap/gnap.h | 2 | ||||
-rw-r--r-- | engines/gnap/module.mk | 1 |
5 files changed, 116 insertions, 8 deletions
diff --git a/engines/gnap/debugger.cpp b/engines/gnap/debugger.cpp new file mode 100644 index 0000000000..07f3f6714c --- /dev/null +++ b/engines/gnap/debugger.cpp @@ -0,0 +1,42 @@ +/* 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. + * + */ + +#include "gnap/debugger.h" +#include "gnap/gnap.h" + +namespace Gnap { + +Debugger::Debugger(GnapEngine *vm) : GUI::Debugger(), _vm(vm) { + // Register methods + registerCmd("hotspots", WRAP_METHOD(Debugger, Cmd_Hotspots)); + + // Set fields + _showHotspotNumber = false; +} + +bool Debugger::Cmd_Hotspots(int argc, const char **argv) { + _showHotspotNumber ^= 1; + + return true; +} + +} // End of namespace Gnap diff --git a/engines/gnap/debugger.h b/engines/gnap/debugger.h new file mode 100644 index 0000000000..ac83cc5504 --- /dev/null +++ b/engines/gnap/debugger.h @@ -0,0 +1,54 @@ +/* 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 GNAP_DEBUGGER_H +#define GNAP_DEBUGGER_H + +#include "common/scummsys.h" +#include "gui/debugger.h" + +namespace Gnap { + +class GnapEngine; + +class Debugger : public GUI::Debugger { +private: + GnapEngine *_vm; +public: + /* + * Specifies whether to show the hotspot IDs + */ + bool _showHotspotNumber; +protected: + /** + * List the active hotspots during the current time period + */ + bool Cmd_Hotspots(int argc, const char **argv); + +public: + Debugger(GnapEngine *vm); + virtual ~Debugger() {} +}; + +} // End of namespace Gnap + +#endif diff --git a/engines/gnap/gnap.cpp b/engines/gnap/gnap.cpp index 19dd353667..793cc2f3e7 100644 --- a/engines/gnap/gnap.cpp +++ b/engines/gnap/gnap.cpp @@ -139,7 +139,8 @@ Common::Error GnapEngine::run() { _sequenceCache = new SequenceCache(_dat); _gameSys = new GameSys(this); _soundMan = new SoundMan(this); - + _debugger = new Debugger(this); + _menuBackgroundSurface = nullptr; initGlobalSceneVars(); @@ -213,6 +214,7 @@ Common::Error GnapEngine::run() { delete _soundCache; delete _spriteCache; delete _dat; + delete _debugger; delete _exe; @@ -227,6 +229,13 @@ void GnapEngine::updateEvents() { while (_eventMan->pollEvent(event)) { switch (event.type) { case Common::EVENT_KEYDOWN: + // Check for debugger + if (event.kbd.keycode == Common::KEYCODE_d && (event.kbd.flags & Common::KBD_CTRL)) { + // Attach to the debugger + _debugger->attach(); + _debugger->onFrame(); + } + _keyPressState[event.kbd.keycode] = 1; _keyDownState[event.kbd.keycode] = 1; break; @@ -387,13 +396,13 @@ void GnapEngine::updateCursorByHotspot() { if (!_isWaiting) { int hotspotIndex = getHotspotIndexAtPos(_mouseX, _mouseY); -#if 1 - // NOTE This causes some display glitches so don't worry - char t[256]; - sprintf(t, "hotspot = %d", hotspotIndex); - _gameSys->fillSurface(0, 10, 10, 80, 16, 0, 0, 0); - _gameSys->drawTextToSurface(0, 10, 10, 255, 255, 255, t); -#endif + if (_debugger->_showHotspotNumber) { + // NOTE This causes some display glitches so don't worry + char t[256]; + sprintf(t, "hotspot = %d", hotspotIndex); + _gameSys->fillSurface(0, 10, 10, 80, 16, 0, 0, 0); + _gameSys->drawTextToSurface(0, 10, 10, 255, 255, 255, t); + } if (hotspotIndex < 0) setCursor(kDisabledCursors[_verbCursor]); diff --git a/engines/gnap/gnap.h b/engines/gnap/gnap.h index aa6e8d57e4..2773845542 100644 --- a/engines/gnap/gnap.h +++ b/engines/gnap/gnap.h @@ -39,6 +39,7 @@ #include "graphics/pixelformat.h" #include "graphics/wincursor.h" +#include "gnap/debugger.h" #include "gnap/resource.h" struct ADGameDescription; @@ -304,6 +305,7 @@ public: SequenceCache *_sequenceCache; GameSys *_gameSys; SoundMan *_soundMan; + Debugger *_debugger; int _lastUpdateClock; diff --git a/engines/gnap/module.mk b/engines/gnap/module.mk index 7a3fc3a9a0..a2e5c77c82 100644 --- a/engines/gnap/module.mk +++ b/engines/gnap/module.mk @@ -2,6 +2,7 @@ MODULE := engines/gnap MODULE_OBJS := \ datarchive.o \ + debugger.o \ detection.o \ gamesys.o \ gnap.o \ |