aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorWalter van Niftrik2016-12-22 15:36:59 +0100
committerWalter van Niftrik2016-12-22 16:42:04 +0100
commitd658f0c0b636e1253ee6d66661c332b43a020cbf (patch)
treec43453422b2936d11905f490efe259f3d9cd9c18 /engines
parent2d7e9f4eac286aabe2e5be86a9cd1aeb14ffcf37 (diff)
downloadscummvm-rg350-d658f0c0b636e1253ee6d66661c332b43a020cbf.tar.gz
scummvm-rg350-d658f0c0b636e1253ee6d66661c332b43a020cbf.tar.bz2
scummvm-rg350-d658f0c0b636e1253ee6d66661c332b43a020cbf.zip
ADL: Add region support to script dumper
Diffstat (limited to 'engines')
-rw-r--r--engines/adl/adl.h1
-rw-r--r--engines/adl/adl_v4.h2
-rw-r--r--engines/adl/console.cpp50
-rw-r--r--engines/adl/console.h1
4 files changed, 38 insertions, 16 deletions
diff --git a/engines/adl/adl.h b/engines/adl/adl.h
index 87e99a5537..67d9a73cdf 100644
--- a/engines/adl/adl.h
+++ b/engines/adl/adl.h
@@ -393,6 +393,7 @@ private:
virtual void drawItem(Item &item, const Common::Point &pos) = 0;
virtual void loadRoom(byte roomNr) = 0;
virtual void showRoom() = 0;
+ virtual void switchRegion(byte region) { }
// Engine
Common::Error run();
diff --git a/engines/adl/adl_v4.h b/engines/adl/adl_v4.h
index 1bc7664d58..0ddd1b9b7e 100644
--- a/engines/adl/adl_v4.h
+++ b/engines/adl/adl_v4.h
@@ -51,6 +51,7 @@ protected:
// AdlEngine
virtual Common::String loadMessage(uint idx) const;
virtual Common::String getItemDescription(const Item &item) const;
+ virtual void switchRegion(byte region);
// AdlEngine_v2
virtual void adjustDataBlockPtr(byte &track, byte &sector, byte &offset, byte &size) const;
@@ -67,7 +68,6 @@ protected:
void restoreRoomState(byte room);
void backupVars();
void restoreVars();
- void switchRegion(byte region);
int o4_isItemInRoom(ScriptEnv &e);
int o4_isVarGT(ScriptEnv &e);
diff --git a/engines/adl/console.cpp b/engines/adl/console.cpp
index c35e8b02aa..0ac3cb8df4 100644
--- a/engines/adl/console.cpp
+++ b/engines/adl/console.cpp
@@ -112,35 +112,55 @@ bool Console::Cmd_ValidCommands(int argc, const char **argv) {
return true;
}
-bool Console::Cmd_DumpScripts(int argc, const char **argv) {
- if (argc != 1) {
- debugPrintf("Usage: %s\n", argv[0]);
- return true;
- }
-
- bool oldFlag = DebugMan.isDebugChannelEnabled(kDebugChannelScript);
-
- DebugMan.enableDebugChannel("Script");
-
- _engine->_dumpFile = new Common::DumpFile();
-
+void Console::dumpScripts(const Common::String &prefix) {
for (byte roomNr = 1; roomNr <= _engine->_state.rooms.size(); ++roomNr) {
_engine->loadRoom(roomNr);
if (_engine->_roomData.commands.size() != 0) {
- _engine->_dumpFile->open(Common::String::format("%03d.ADL", roomNr).c_str());
+ _engine->_dumpFile->open(prefix + Common::String::format("%03d.ADL", roomNr).c_str());
_engine->doAllCommands(_engine->_roomData.commands, IDI_ANY, IDI_ANY);
_engine->_dumpFile->close();
}
}
_engine->loadRoom(_engine->_state.room);
- _engine->_dumpFile->open("GLOBAL.ADL");
+ _engine->_dumpFile->open(prefix + "GLOBAL.ADL");
_engine->doAllCommands(_engine->_globalCommands, IDI_ANY, IDI_ANY);
_engine->_dumpFile->close();
- _engine->_dumpFile->open("RESPONSE.ADL");
+ _engine->_dumpFile->open(prefix + "RESPONSE.ADL");
_engine->doAllCommands(_engine->_roomCommands, IDI_ANY, IDI_ANY);
_engine->_dumpFile->close();
+}
+
+bool Console::Cmd_DumpScripts(int argc, const char **argv) {
+ if (argc != 1) {
+ debugPrintf("Usage: %s\n", argv[0]);
+ return true;
+ }
+
+ bool oldFlag = DebugMan.isDebugChannelEnabled(kDebugChannelScript);
+
+ DebugMan.enableDebugChannel("Script");
+
+ _engine->_dumpFile = new Common::DumpFile();
+
+ if (_engine->_state.regions.empty()) {
+ dumpScripts();
+ } else {
+ const byte oldRegion = _engine->_state.region;
+ const byte oldPrevRegion = _engine->_state.prevRegion;
+ const byte oldRoom = _engine->_state.room;
+
+ for (byte regionNr = 1; regionNr <= _engine->_state.regions.size(); ++regionNr) {
+ _engine->switchRegion(regionNr);
+ dumpScripts(Common::String::format("%03d-", regionNr));
+ }
+
+ _engine->switchRegion(oldRegion);
+ _engine->_state.prevRegion = oldPrevRegion;
+ _engine->_state.room = oldRoom;
+ _engine->loadRoom(oldRoom);
+ }
delete _engine->_dumpFile;
_engine->_dumpFile = nullptr;
diff --git a/engines/adl/console.h b/engines/adl/console.h
index a8c6adc1cc..8b3ab6b3cf 100644
--- a/engines/adl/console.h
+++ b/engines/adl/console.h
@@ -56,6 +56,7 @@ private:
void printItem(const Item &item);
void printWordMap(const Common::HashMap<Common::String, uint> &wordMap);
+ void dumpScripts(const Common::String &prefix = Common::String());
AdlEngine *_engine;
};