aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFilippos Karapetis2016-09-19 09:39:25 +0300
committerFilippos Karapetis2016-10-03 00:32:52 +0300
commit182debe9083a57c8f96ea5214450193feb2c6558 (patch)
treef26a04978cfc3ccf1fd37e572224fd4bcebb0821
parente60fbde1d2b736d7f44c51d27e75639837d19cfe (diff)
downloadscummvm-rg350-182debe9083a57c8f96ea5214450193feb2c6558.tar.gz
scummvm-rg350-182debe9083a57c8f96ea5214450193feb2c6558.tar.bz2
scummvm-rg350-182debe9083a57c8f96ea5214450193feb2c6558.zip
CHEWY: Add a console, with a "dump" command to dump resources
-rw-r--r--engines/chewy/chewy.cpp5
-rw-r--r--engines/chewy/chewy.h3
-rw-r--r--engines/chewy/console.cpp63
-rw-r--r--engines/chewy/console.h44
-rw-r--r--engines/chewy/module.mk1
5 files changed, 116 insertions, 0 deletions
diff --git a/engines/chewy/chewy.cpp b/engines/chewy/chewy.cpp
index 130e31b64c..8051c877db 100644
--- a/engines/chewy/chewy.cpp
+++ b/engines/chewy/chewy.cpp
@@ -38,6 +38,8 @@ ChewyEngine::ChewyEngine(OSystem *syst, const ChewyGameDescription *gameDesc)
_gameDescription(gameDesc),
_rnd("chewy") {
+ _console = new Console(this);
+
const Common::FSNode gameDataDir(ConfMan.get("path"));
SearchMan.addSubDirectoryMatching(gameDataDir, "back");
@@ -75,8 +77,11 @@ Common::Error ChewyEngine::run() {
while (g_system->getEventManager()->pollEvent(event)) {
if ((event.type == Common::EVENT_KEYDOWN && event.kbd.keycode == Common::KEYCODE_ESCAPE) || event.type == Common::EVENT_LBUTTONUP)
g_engine->quitGame();
+ if (event.type == Common::EVENT_KEYDOWN && event.kbd.flags & Common::KBD_CTRL && event.kbd.keycode == Common::KEYCODE_d)
+ _console->attach();
}
+ _console->onFrame();
g_system->delayMillis(10);
}
diff --git a/engines/chewy/chewy.h b/engines/chewy/chewy.h
index 99eafe6646..b832144efa 100644
--- a/engines/chewy/chewy.h
+++ b/engines/chewy/chewy.h
@@ -33,6 +33,7 @@
#include "common/random.h"
#include "engines/engine.h"
+#include "chewy/console.h"
namespace Chewy {
@@ -49,6 +50,8 @@ protected:
void initialize();
+ Console *_console;
+
public:
ChewyEngine(OSystem *syst, const ChewyGameDescription *gameDesc);
virtual ~ChewyEngine();
diff --git a/engines/chewy/console.cpp b/engines/chewy/console.cpp
new file mode 100644
index 0000000000..09f6110d64
--- /dev/null
+++ b/engines/chewy/console.cpp
@@ -0,0 +1,63 @@
+/* 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 "chewy/console.h"
+#include "gui/debugger.h"
+#include "chewy/chewy.h"
+#include "chewy/resource.h"
+
+namespace Chewy {
+
+ Console::Console(ChewyEngine *vm) : GUI::Debugger(), _vm(vm) {
+ registerCmd("dump", WRAP_METHOD(Console, Cmd_Dump));
+}
+
+Console::~Console() {
+}
+
+bool Console::Cmd_Dump(int argc, const char **argv) {
+ if (argc < 4) {
+ debugPrintf("Usage: dump <file> <resource number> <dump file name>\n");
+ return true;
+ }
+
+ Common::String filename = argv[1];
+ int resNum = atoi(argv[2]);
+ Common::String dumpFilename = argv[3];
+
+ Resource *res = new Resource(filename);
+ TBFChunk *chunk = res->getChunk(resNum);
+ byte *data = res->getChunkData(resNum);
+
+ Common::DumpFile outFile;
+ outFile.open(dumpFilename);
+ outFile.write(data, chunk->unpackedSize);
+ outFile.flush();
+ outFile.close();
+
+ delete[] data;
+ delete res;
+
+ return true;
+}
+
+} // End of namespace Drascula
diff --git a/engines/chewy/console.h b/engines/chewy/console.h
new file mode 100644
index 0000000000..b6b32e6e03
--- /dev/null
+++ b/engines/chewy/console.h
@@ -0,0 +1,44 @@
+/* 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 CHEWY_CONSOLE_H
+#define CHEWY_CONSOLE_H
+
+#include "gui/debugger.h"
+
+namespace Chewy {
+
+class ChewyEngine;
+
+class Console : public GUI::Debugger {
+public:
+ Console(ChewyEngine *vm);
+ virtual ~Console(void);
+
+private:
+ ChewyEngine *_vm;
+
+ bool Cmd_Dump(int argc, const char **argv);
+};
+
+} // End of namespace Drascula
+#endif
diff --git a/engines/chewy/module.mk b/engines/chewy/module.mk
index c9621c6273..137a7fb97c 100644
--- a/engines/chewy/module.mk
+++ b/engines/chewy/module.mk
@@ -2,6 +2,7 @@ MODULE := engines/chewy
MODULE_OBJS = \
chewy.o \
+ console.o \
detection.o \
resource.o