diff options
| -rw-r--r-- | engines/glk/debugger.cpp | 60 | ||||
| -rw-r--r-- | engines/glk/debugger.h | 52 | ||||
| -rw-r--r-- | engines/glk/events.cpp | 12 | ||||
| -rw-r--r-- | engines/glk/glk.cpp | 4 | ||||
| -rw-r--r-- | engines/glk/glk.h | 9 | ||||
| -rw-r--r-- | engines/glk/module.mk | 1 | 
6 files changed, 135 insertions, 3 deletions
| diff --git a/engines/glk/debugger.cpp b/engines/glk/debugger.cpp new file mode 100644 index 0000000000..57188db756 --- /dev/null +++ b/engines/glk/debugger.cpp @@ -0,0 +1,60 @@ +/* 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 "common/file.h" +#include "glk/glk.h" +#include "glk/debugger.h" + +namespace Glk { + +Debugger::Debugger(GlkEngine *vm) : GUI::Debugger(), _vm(vm) { +	registerCmd("dumppic", WRAP_METHOD(Debugger, cmdExit)); +} + +int Debugger::strToInt(const char *s) { +	if (!*s) +		// No string at all +		return 0; +	else if (toupper(s[strlen(s) - 1]) != 'H') +		// Standard decimal string +		return atoi(s); + +	// Hexadecimal string +	uint tmp = 0; +	int read = sscanf(s, "%xh", &tmp); +	if (read < 1) +		error("strToInt failed on string \"%s\"", s); +	return (int)tmp; +} + +bool Debugger::cmdDumpPic(int argc, const char **argv) { +	if (argc != 2) { +		debugPrintf("Format: dumppic <picture number>"); +	} else { +		int picNum = strToInt(argv[1]); +		warning("TODO: dumpPic %d", picNum); +	} + +	return true; +} + +} // End of namespace Glk diff --git a/engines/glk/debugger.h b/engines/glk/debugger.h new file mode 100644 index 0000000000..d09ef99ae8 --- /dev/null +++ b/engines/glk/debugger.h @@ -0,0 +1,52 @@ +/* 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 GLK_DEBUGGER_H +#define GLK_DEBUGGER_H + +#include "common/scummsys.h" +#include "gui/debugger.h" + +namespace Glk { + +class GlkEngine; + +class Debugger : public GUI::Debugger { +private: +	GlkEngine *_vm; + +	/** +	 * Dump a picture +	 */ +	bool cmdDumpPic(int argc, const char **argv); +protected: +	/** +	 * Convert a numeric string to an integer +	 */ +	int strToInt(const char *s); +public: +	Debugger(GlkEngine *vm); +}; + +} // End of namespace Glk + +#endif diff --git a/engines/glk/events.cpp b/engines/glk/events.cpp index efcf2c5bc6..ba132b5fbe 100644 --- a/engines/glk/events.cpp +++ b/engines/glk/events.cpp @@ -184,12 +184,20 @@ void Events::pollEvents() {  		g_system->getEventManager()->pollEvent(event);  		switch (event.type) { -		case Common::EVENT_KEYDOWN: -			if (!isModifierKey(event.kbd.keycode)) { +		case Common::EVENT_KEYDOWN: { +			// Check for debugger +			Debugger *dbg = g_vm->_debugger; +			if (dbg && event.kbd.keycode == Common::KEYCODE_d && (event.kbd.flags & Common::KBD_CTRL)) { +				// Attach to the debugger +				dbg->attach(); +				dbg->onFrame(); +			} else if (!isModifierKey(event.kbd.keycode)) { +				// Handle all other keypresses  				setCursor(CURSOR_NONE);  				handleKeyDown(event.kbd);  			}  			return; +		}  		case Common::EVENT_LBUTTONDOWN:  		case Common::EVENT_RBUTTONDOWN: diff --git a/engines/glk/glk.cpp b/engines/glk/glk.cpp index 455c42b46c..892094a0b7 100644 --- a/engines/glk/glk.cpp +++ b/engines/glk/glk.cpp @@ -47,7 +47,7 @@ GlkEngine *g_vm;  GlkEngine::GlkEngine(OSystem *syst, const GlkGameDescription &gameDesc) :  		_gameDescription(gameDesc), Engine(syst), _random("Glk"), _blorb(nullptr), -		_clipboard(nullptr), _conf(nullptr), _events(nullptr), _pictures(nullptr), +		_clipboard(nullptr), _conf(nullptr), _debugger(nullptr), _events(nullptr), _pictures(nullptr),  		_screen(nullptr), _selection(nullptr), _sounds(nullptr), _windows(nullptr),  		_copySelect(false), _terminated(false), _pcSpeaker(nullptr),  		gli_register_obj(nullptr), gli_unregister_obj(nullptr), gli_register_arr(nullptr), @@ -65,6 +65,7 @@ GlkEngine::~GlkEngine() {  	delete _blorb;  	delete _clipboard;  	delete _conf; +	delete _debugger;  	delete _events;  	delete _pcSpeaker;  	delete _pictures; @@ -79,6 +80,7 @@ void GlkEngine::initialize() {  	initGraphicsMode();  	_conf = new Conf(getInterpreterType()); +	_debugger = createDebugger();  	_screen = createScreen();  	_screen->initialize();  	_clipboard = new Clipboard(); diff --git a/engines/glk/glk.h b/engines/glk/glk.h index 9c65fca3e6..e6516f1ee1 100644 --- a/engines/glk/glk.h +++ b/engines/glk/glk.h @@ -28,6 +28,7 @@  #include "common/system.h"  #include "common/serializer.h"  #include "engines/engine.h" +#include "glk/debugger.h"  #include "glk/glk_types.h"  #include "glk/streams.h"  #include "glk/pc_speaker.h" @@ -99,6 +100,13 @@ protected:  	virtual Screen *createScreen();  	/** +	 * Creates a debugger instance +	 */ +	virtual Debugger *createDebugger() { +		return new Debugger(this); +	} + +	/**  	 * Main game loop for the individual interpreters  	 */  	virtual void runGame() = 0; @@ -106,6 +114,7 @@ public:  	Blorb *_blorb;  	Clipboard *_clipboard;  	Conf *_conf; +	Debugger *_debugger;  	Events *_events;  	Pictures *_pictures;  	Screen *_screen; diff --git a/engines/glk/module.mk b/engines/glk/module.mk index e3c329a87c..8c15aa7938 100644 --- a/engines/glk/module.mk +++ b/engines/glk/module.mk @@ -3,6 +3,7 @@ MODULE := engines/glk  MODULE_OBJS := \  	blorb.o \  	conf.o \ +	debugger.o \  	detection.o \  	events.o \  	fonts.o \ | 
