SWORD1: Added basic debugging console to engine

SWORD1 does not currently use Debug Channels, but this does provide a base for adding them along with any other debugging commands.

svn-id: r54140
This commit is contained in:
David Turner 2010-11-08 12:22:58 +00:00
parent c76f0c6c02
commit cb734285a5
5 changed files with 109 additions and 0 deletions

View File

@ -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.
*
* $URL$
* $Id$
*
*/
#include "sword1/console.h"
#include "sword1/sword1.h"
namespace Sword1 {
SwordConsole::SwordConsole(SwordEngine *vm) : GUI::Debugger(), _vm(vm) {
}
SwordConsole::~SwordConsole() {
}
void SwordConsole::preEnter() {
}
void SwordConsole::postEnter() {
}
} // End of namespace Sword

50
engines/sword1/console.h Normal file
View File

@ -0,0 +1,50 @@
/* 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$
*
*/
#ifndef SWORD1_CONSOLE_H
#define SWORD1_CONSOLE_H
#include "gui/debugger.h"
namespace Sword1 {
class SwordEngine;
class SwordConsole : public GUI::Debugger {
public:
SwordConsole(SwordEngine *vm);
virtual ~SwordConsole(void);
protected:
virtual void preEnter();
virtual void postEnter();
private:
SwordEngine *_vm;
};
} // End of namespace Sword1
#endif

View File

@ -2,6 +2,7 @@ MODULE := engines/sword1
MODULE_OBJS := \
animation.o \
console.o \
control.o \
debug.o \
detection.o \

View File

@ -66,6 +66,8 @@ SwordEngine::SwordEngine(OSystem *syst)
SearchMan.addSubDirectoryMatching(gameDataDir, "smackshi");
SearchMan.addSubDirectoryMatching(gameDataDir, "english");//PSX Demo
SearchMan.addSubDirectoryMatching(gameDataDir, "italian");//PSX Demo
_console = new SwordConsole(this);
}
SwordEngine::~SwordEngine() {
@ -78,6 +80,7 @@ SwordEngine::~SwordEngine() {
delete _mouse;
delete _objectMan;
delete _resMan;
delete _console;
}
Common::Error SwordEngine::init() {
@ -678,6 +681,13 @@ uint8 SwordEngine::mainLoop() {
if (retCode == CONTROL_NOTHING_DONE)
_screen->fullRefresh();
}
// Check for Debugger Activation
if (_keyPressed.hasFlags(Common::KBD_CTRL) && _keyPressed.keycode == Common::KEYCODE_d) {
this->getDebugger()->attach();
this->getDebugger()->onFrame();
}
_mouseState = 0;
_keyPressed.reset();
} while ((Logic::_scriptVars[SCREEN] == Logic::_scriptVars[NEW_SCREEN]) && (retCode == 0) && (!shouldQuit()));

View File

@ -30,6 +30,7 @@
#include "common/events.h"
#include "common/util.h"
#include "sword1/sworddefs.h"
#include "sword1/console.h"
/**
* This is the namespace of the Sword1 engine.
@ -106,6 +107,8 @@ protected:
virtual bool hasFeature(EngineFeature f) const;
virtual void syncSoundSettings();
GUI::Debugger *getDebugger() { return _console; }
Common::Error loadGameState(int slot);
bool canLoadGameStateCurrently();
Common::Error saveGameState(int slot, const char *desc);
@ -121,6 +124,8 @@ private:
void reinitRes(); //Reinits the resources after a GMM load
SwordConsole *_console;
uint8 mainLoop();
Common::Point _mouseCoord;