aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorPaul Gilbert2014-03-23 14:26:50 -0400
committerPaul Gilbert2014-03-23 14:26:50 -0400
commita22318959989caf91916ba792f80103afe71092a (patch)
tree430db9fc73b040445cc68ed3614f768f7d82088e /engines
parent9ef27c4ea0359d3dce74c49b5f2e9b37050097ae (diff)
downloadscummvm-rg350-a22318959989caf91916ba792f80103afe71092a.tar.gz
scummvm-rg350-a22318959989caf91916ba792f80103afe71092a.tar.bz2
scummvm-rg350-a22318959989caf91916ba792f80103afe71092a.zip
MADS: Added extra debugger commands
Diffstat (limited to 'engines')
-rw-r--r--engines/mads/debugger.cpp104
-rw-r--r--engines/mads/debugger.h6
-rw-r--r--engines/mads/hotspots.h1
3 files changed, 109 insertions, 2 deletions
diff --git a/engines/mads/debugger.cpp b/engines/mads/debugger.cpp
index 34b12c1680..3bc4ed2c16 100644
--- a/engines/mads/debugger.cpp
+++ b/engines/mads/debugger.cpp
@@ -20,6 +20,7 @@
*
*/
+#include "common/file.h"
#include "mads/mads.h"
#include "mads/debugger.h"
@@ -29,8 +30,15 @@ Debugger::Debugger(MADSEngine *vm) : GUI::Debugger(), _vm(vm) {
_showMousePos = false;
DCmd_Register("continue", WRAP_METHOD(Debugger, Cmd_Exit));
+ DCmd_Register("scene", WRAP_METHOD(Debugger, Cmd_Mouse));
+ DCmd_Register("scene", WRAP_METHOD(Debugger, Cmd_LoadScene));
+ DCmd_Register("show_hotspots", WRAP_METHOD(Debugger, Cmd_ShowHotSpots));
+ DCmd_Register("list_hotspots", WRAP_METHOD(Debugger, Cmd_ListHotSpots));
+ DCmd_Register("play_sound", WRAP_METHOD(Debugger, Cmd_PlaySound));
+ DCmd_Register("show_codes", WRAP_METHOD(Debugger, Cmd_ShowCodes));
+ DCmd_Register("dump_file", WRAP_METHOD(Debugger, Cmd_DumpFile));
}
-/*
+
static int strToInt(const char *s) {
if (!*s)
// No string at all
@@ -46,7 +54,6 @@ static int strToInt(const char *s) {
error("strToInt failed on string \"%s\"", s);
return (int)tmp;
}
-*/
bool Debugger::Cmd_Mouse(int argc, const char **argv) {
if (argc < 2) {
@@ -58,4 +65,97 @@ bool Debugger::Cmd_Mouse(int argc, const char **argv) {
return true;
}
+bool Debugger::Cmd_LoadScene(int argc, const char **argv) {
+ if (argc != 2) {
+ DebugPrintf("Usage: %s <scene number>\n", argv[0]);
+ return true;
+ } else {
+ _vm->_game->_scene._nextSceneId = strToInt(argv[1]);
+ return false;
+ }
+}
+
+bool Debugger::Cmd_ShowHotSpots(int argc, const char **argv) {
+ Scene &scene = _vm->_game->_scene;
+
+ // hotspots
+ byte hotspotCol = _vm->getRandomNumber(255);
+ for (uint i = 0; i < scene._hotspots.size(); i++) {
+ scene._backgroundSurface.frameRect(scene._hotspots[i]._bounds, hotspotCol);
+ }
+
+ // Dynamic hotspots (red)
+ hotspotCol = _vm->getRandomNumber(255);
+ for (uint i = 0; i < scene._dynamicHotspots.size(); i++) {
+ scene._backgroundSurface.frameRect(scene._dynamicHotspots[i]._bounds, hotspotCol);
+ }
+
+ scene._spriteSlots.fullRefresh();
+ return false;
+}
+
+bool Debugger::Cmd_ListHotSpots(int argc, const char **argv) {
+ Hotspots &hotspots = _vm->_game->_scene._hotspots;
+
+ DebugPrintf("%d hotspots present\n", hotspots.size());
+
+ for (uint index = 0; index < hotspots.size(); ++index) {
+ DebugPrintf("(%d): %p x1 = %d; y1 = %d; x2 = %d; y2 = %d\n",
+ index, (void *)&hotspots[index],
+ hotspots[index]._bounds.left, hotspots[index]._bounds.top,
+ hotspots[index]._bounds.right, hotspots[index]._bounds.bottom);
+ }
+
+ return true;
+}
+
+bool Debugger::Cmd_PlaySound(int argc, const char **argv) {
+ if (argc < 2) {
+ DebugPrintf("Usage: %s <sound file>\n", argv[0]);
+ } else {
+ int commandId = strToInt(argv[1]);
+ int param = (argc >= 3) ? strToInt(argv[2]) : 0;
+
+ _vm->_sound->command(commandId, param);
+ }
+
+ return false;
+}
+
+bool Debugger::Cmd_ShowCodes(int argc, const char **argv) {
+ Scene &scene = _vm->_game->_scene;
+
+ scene._depthSurface.copyTo(&scene._backgroundSurface);
+ scene._spriteSlots.fullRefresh();
+
+ return false;
+}
+
+bool Debugger::Cmd_DumpFile(int argc, const char **argv) {
+ if (argc != 2) {
+ DebugPrintf("Usage: %s <resource>\n", argv[0]);
+ } else {
+ Common::DumpFile outFile;
+ Common::File inFile;
+
+ if (!inFile.open(argv[1])) {
+ DebugPrintf("Specified resource does not exist\n");
+ } else {
+ outFile.open(argv[1]);
+ byte *data = new byte[inFile.size()];
+
+ inFile.read(data, inFile.size());
+ outFile.write(data, inFile.size());
+
+ delete[] data;
+ inFile.close();
+ outFile.close();
+
+ DebugPrintf("File written successfully.\n");
+ }
+ }
+
+ return true;
+}
+
} // End of namespace MADS
diff --git a/engines/mads/debugger.h b/engines/mads/debugger.h
index 983b9931fc..de450b1446 100644
--- a/engines/mads/debugger.h
+++ b/engines/mads/debugger.h
@@ -35,6 +35,12 @@ private:
MADSEngine *_vm;
protected:
bool Cmd_Mouse(int argc, const char **argv);
+ bool Cmd_LoadScene(int argc, const char **argv);
+ bool Cmd_ShowHotSpots(int argc, const char **argv);
+ bool Cmd_ListHotSpots(int argc, const char **argv);
+ bool Cmd_PlaySound(int argc, const char **argv);
+ bool Cmd_ShowCodes(int argc, const char **argv);
+ bool Cmd_DumpFile(int argc, const char **argv);
public:
bool _showMousePos;
public:
diff --git a/engines/mads/hotspots.h b/engines/mads/hotspots.h
index a53b86d880..ec9f12dc77 100644
--- a/engines/mads/hotspots.h
+++ b/engines/mads/hotspots.h
@@ -57,6 +57,7 @@ public:
public:
DynamicHotspots(MADSEngine *vm);
+ int size() const { return _entries.size(); }
DynamicHotspot &operator[](uint idx) { return _entries[idx]; }
int add(int descId, int vocabId, int seqIndex, const Common::Rect &bounds);
int setPosition(int index, int xp, int yp, int facing);