aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/mutationofjb/commands/changecommand.cpp180
-rw-r--r--engines/mutationofjb/commands/changecommand.h31
-rw-r--r--engines/mutationofjb/commands/command.cpp2
-rw-r--r--engines/mutationofjb/commands/command.h3
-rw-r--r--engines/mutationofjb/commands/endblockcommand.cpp41
-rw-r--r--engines/mutationofjb/commands/endblockcommand.h7
-rw-r--r--engines/mutationofjb/commands/ifcommand.cpp7
-rw-r--r--engines/mutationofjb/commands/ifcommand.h3
-rw-r--r--engines/mutationofjb/debug.cpp162
-rw-r--r--engines/mutationofjb/debug.h40
-rw-r--r--engines/mutationofjb/module.mk1
-rw-r--r--engines/mutationofjb/mutationofjb.cpp22
-rw-r--r--engines/mutationofjb/mutationofjb.h12
-rw-r--r--engines/mutationofjb/script.cpp28
-rw-r--r--engines/mutationofjb/script.h46
15 files changed, 538 insertions, 47 deletions
diff --git a/engines/mutationofjb/commands/changecommand.cpp b/engines/mutationofjb/commands/changecommand.cpp
index 54c6d1e616..e9bb9cc2e6 100644
--- a/engines/mutationofjb/commands/changecommand.cpp
+++ b/engines/mutationofjb/commands/changecommand.cpp
@@ -96,6 +96,30 @@ bool ChangeCommandParser::parseValueString(const Common::String &valueString, ui
} else if (valueString.hasPrefix("CA")) {
reg = ChangeCommand::CA;
ccv._byteVal = parseInteger(val, op);
+ } else if (valueString.hasPrefix("DS")) {
+ reg = ChangeCommand::DS;
+ ccv._byteVal = parseInteger(val, op);
+ } else if (valueString.hasPrefix("DL")) {
+ reg = ChangeCommand::DL;
+ ccv._byteVal = parseInteger(val, op);
+ } else if (valueString.hasPrefix("ND")) {
+ reg = ChangeCommand::ND;
+ ccv._byteVal = parseInteger(val, op);
+ } else if (valueString.hasPrefix("NO")) {
+ reg = ChangeCommand::NO;
+ ccv._byteVal = parseInteger(val, op);
+ } else if (valueString.hasPrefix("NS")) {
+ reg = ChangeCommand::NS;
+ ccv._byteVal = parseInteger(val, op);
+ } else if (valueString.hasPrefix("PF")) {
+ reg = ChangeCommand::PF;
+ ccv._byteVal = parseInteger(val, op);
+ } else if (valueString.hasPrefix("PL")) {
+ reg = ChangeCommand::PL;
+ ccv._byteVal = parseInteger(val, op);
+ } else if (valueString.hasPrefix("PD")) {
+ reg = ChangeCommand::PD;
+ ccv._byteVal = parseInteger(val, op);
}
return true;
@@ -115,7 +139,7 @@ bool ChangeDoorCommandParser::parse(const Common::String &line, ScriptParseConte
return false;
}
- command = new ChangeObjectCommand(sceneId, objectId, reg, op, val);
+ command = new ChangeDoorCommand(sceneId, objectId, reg, op, val);
return true;
}
@@ -149,7 +173,24 @@ bool ChangeStaticCommandParser::parse(const Common::String &line, ScriptParseCon
return false;
}
- command = new ChangeObjectCommand(sceneId, objectId, reg, op, val);
+ command = new ChangeStaticCommand(sceneId, objectId, reg, op, val);
+ return true;
+}
+
+bool ChangeSceneCommandParser::parse(const Common::String &line, ScriptParseContext &, Command *&command) {
+ if (!line.hasPrefix("CHANGE ")) {
+ return false;
+ }
+ uint8 sceneId = 0;
+ uint8 objectId = 0;
+ ChangeCommand::ChangeRegister reg;
+ ChangeCommand::ChangeOperation op;
+ ChangeCommandValue val;
+ if (!parseValueString(line.c_str() + 8, sceneId, objectId, reg, op, val)) {
+ return false;
+ }
+
+ command = new ChangeSceneCommand(sceneId, objectId, reg, op, val);
return true;
}
@@ -173,6 +214,86 @@ int ChangeCommandParser::parseInteger(const char *val, ChangeCommand::ChangeOper
return atoi(val);
}
+
+const char *ChangeCommand::getRegisterAsString() const {
+ switch (_register) {
+ case NM: return "NM";
+ case LT: return "LT";
+ case SX: return "SX";
+ case SY: return "SY";
+ case XX: return "XX";
+ case YY: return "YY";
+ case XL: return "XL";
+ case YL: return "YL";
+ case WX: return "WX";
+ case WY: return "WY";
+ case SP: return "SP";
+ case AC: return "AC";
+ case FA: return "FA";
+ case FR: return "FR";
+ case NA: return "NA";
+ case FS: return "FS";
+ case CA: return "CA";
+ case DS: return "DS";
+ case DL: return "DL";
+ case ND: return "ND";
+ case NO: return "NO";
+ case NS: return "NS";
+ case PF: return "PF";
+ case PL: return "PL";
+ case PD: return "PD";
+ default: return "(unknown)";
+ }
+}
+
+Common::String ChangeCommand::getValueAsString() const {
+ switch (_register) {
+ case NM:
+ return Common::String::format("\"%s\"", _value._strVal);
+ case LT:
+ case YY:
+ case YL:
+ case WY:
+ case SP:
+ case AC:
+ case FA:
+ case FR:
+ case NA:
+ case FS:
+ case CA:
+ case DS:
+ case DL:
+ case ND:
+ case NO:
+ case NS:
+ case PF:
+ case PL:
+ case PD:
+ return Common::String::format("%d", (int)_value._byteVal);
+ case SX:
+ case SY:
+ case XX:
+ case XL:
+ case WX:
+ return Common::String::format("%d", (int)_value._wordVal);
+ default:
+ return "(unknown)";
+ }
+}
+
+const char *ChangeCommand::getOperationAsString() const {
+ switch (_operation) {
+ case SetValue:
+ return "=";
+ case AddValue:
+ return "+=";
+ case SubtractValue:
+ return "-=";
+ default:
+ return "(unknown)";
+ }
+}
+
Command::ExecuteResult ChangeDoorCommand::execute(GameData &gameData) {
Scene *const scene = gameData.getScene(_sceneId);
if (!scene) {
@@ -226,6 +347,10 @@ Command::ExecuteResult ChangeDoorCommand::execute(GameData &gameData) {
return Finished;
}
+Common::String ChangeDoorCommand::debugString() const {
+ return Common::String::format("scene%d.door%d.%s %s %s", _sceneId, _entityId, getRegisterAsString(), getOperationAsString(), getValueAsString().c_str());
+}
+
Command::ExecuteResult ChangeObjectCommand::execute(GameData &gameData) {
Scene *const scene = gameData.getScene(_sceneId);
if (!scene) {
@@ -285,6 +410,10 @@ Command::ExecuteResult ChangeObjectCommand::execute(GameData &gameData) {
return Finished;
}
+Common::String ChangeObjectCommand::debugString() const {
+ return Common::String::format("scene%d.object%d.%s %s %s", _sceneId, _entityId, getRegisterAsString(), getOperationAsString(), getValueAsString().c_str());
+}
+
Command::ExecuteResult ChangeStaticCommand::execute(GameData &gameData) {
Scene *const scene = gameData.getScene(_sceneId);
if (!scene) {
@@ -331,4 +460,51 @@ Command::ExecuteResult ChangeStaticCommand::execute(GameData &gameData) {
return Finished;
}
+
+Common::String ChangeStaticCommand::debugString() const {
+ return Common::String::format("scene%d.static%d.%s %s %s", _sceneId, _entityId, getRegisterAsString(), getOperationAsString(), getValueAsString().c_str());
+}
+
+Command::ExecuteResult ChangeSceneCommand::execute(GameData &gameData) {
+ Scene *const scene = gameData.getScene(_sceneId);
+ if (!scene) {
+ return Finished;
+ }
+
+ switch (_register) {
+ case DS:
+ scene->_startup = _value._byteVal;
+ break;
+ case DL:
+ scene->_DL = _value._byteVal;
+ break;
+ case ND:
+ scene->_noDoors = _value._byteVal;
+ break;
+ case NO:
+ scene->_noObjects = _value._byteVal;
+ break;
+ case NS:
+ scene->_noStatics = _value._byteVal;
+ break;
+ case PF:
+ scene->_palRotStart = _value._byteVal;
+ break;
+ case PL:
+ scene->_palRotEnd = _value._byteVal;
+ break;
+ case PD:
+ scene->_palRotPeriod = _value._byteVal;
+ break;
+ default:
+ warning("Scene does not support changing this register.");
+ break;
+ }
+
+ return Finished;
+}
+
+Common::String ChangeSceneCommand::debugString() const {
+ return Common::String::format("scene%d.%s %s %s", _sceneId, getRegisterAsString(), getOperationAsString(), getValueAsString().c_str());
+}
}
diff --git a/engines/mutationofjb/commands/changecommand.h b/engines/mutationofjb/commands/changecommand.h
index 5b9a91e47e..d590fa5518 100644
--- a/engines/mutationofjb/commands/changecommand.h
+++ b/engines/mutationofjb/commands/changecommand.h
@@ -50,7 +50,15 @@ public:
FR,
NA,
FS,
- CA
+ CA,
+ DS, // Startup
+ DL,
+ ND, // Number of doors
+ NO, // Number of objects
+ NS, // Number of statics
+ PF, // Palette rotation first
+ PL, // Palette rotation last
+ PD // Palette rotation delay
};
enum ChangeOperation {
@@ -63,6 +71,10 @@ public:
_sceneId(sceneId), _entityId(entityId), _register(reg), _operation(op), _value(val)
{}
protected:
+ const char *getRegisterAsString() const;
+ Common::String getValueAsString() const;
+ const char *getOperationAsString() const;
+
uint8 _sceneId;
uint8 _entityId;
ChangeRegister _register;
@@ -91,7 +103,10 @@ public:
virtual bool parse(const Common::String &line, ScriptParseContext &parseCtx, Command *&command) override;
};
-
+class ChangeSceneCommandParser : public ChangeCommandParser {
+public:
+ virtual bool parse(const Common::String &line, ScriptParseContext &parseCtx, Command *&command) override;
+};
class ChangeDoorCommand : public ChangeCommand {
public:
@@ -99,6 +114,7 @@ public:
: ChangeCommand(sceneId, doorId, reg, op, val)
{}
virtual ExecuteResult execute(GameData &gameData) override;
+ virtual Common::String debugString() const;
};
class ChangeObjectCommand : public ChangeCommand {
@@ -107,6 +123,7 @@ public:
: ChangeCommand(sceneId, objectId, reg, op, val)
{}
virtual ExecuteResult execute(GameData &gameData) override;
+ virtual Common::String debugString() const;
};
class ChangeStaticCommand : public ChangeCommand {
@@ -115,6 +132,16 @@ public:
: ChangeCommand(sceneId, staticId, reg, op, val)
{}
virtual ExecuteResult execute(GameData &gameData) override;
+ virtual Common::String debugString() const;
+};
+
+class ChangeSceneCommand : public ChangeCommand {
+public:
+ ChangeSceneCommand(uint8 sceneId, uint8 staticId, ChangeRegister reg, ChangeOperation op, const ChangeCommandValue& val)
+ : ChangeCommand(sceneId, staticId, reg, op, val)
+ {}
+ virtual ExecuteResult execute(GameData &gameData) override;
+ virtual Common::String debugString() const;
};
}
diff --git a/engines/mutationofjb/commands/command.cpp b/engines/mutationofjb/commands/command.cpp
index af4c28e7eb..943986e89d 100644
--- a/engines/mutationofjb/commands/command.cpp
+++ b/engines/mutationofjb/commands/command.cpp
@@ -25,7 +25,7 @@
namespace MutationOfJB {
-void CommandParser::transition(ScriptParseContext &, Command *, Command *) {}
+void CommandParser::transition(ScriptParseContext &, Command *, Command *, CommandParser *) {}
CommandParser::~CommandParser() {}
Command::~Command() {}
diff --git a/engines/mutationofjb/commands/command.h b/engines/mutationofjb/commands/command.h
index f8c160e3cb..ccfdea25f0 100644
--- a/engines/mutationofjb/commands/command.h
+++ b/engines/mutationofjb/commands/command.h
@@ -42,7 +42,7 @@ public:
virtual bool parse(const Common::String &line, ScriptParseContext &parseCtx, Command *&command) = 0;
/* Old command - created by this parser. */
- virtual void transition(ScriptParseContext &parseCtx, Command *oldCommand, Command *newCommand);
+ virtual void transition(ScriptParseContext &parseCtx, Command *oldCommand, Command *newCommand, CommandParser *newCommandParser);
};
class Command {
@@ -59,6 +59,7 @@ public:
virtual Command *next() const = 0;
virtual SeqCommand *asSeqCommand();
+ virtual Common::String debugString() const = 0;
};
}
diff --git a/engines/mutationofjb/commands/endblockcommand.cpp b/engines/mutationofjb/commands/endblockcommand.cpp
index 218be1a31f..be610c7c9a 100644
--- a/engines/mutationofjb/commands/endblockcommand.cpp
+++ b/engines/mutationofjb/commands/endblockcommand.cpp
@@ -41,15 +41,17 @@ bool EndBlockCommandParser::parse(const Common::String &line, ScriptParseContext
// This is the start or end of section/block.
if (line.size() >= 4 && (line.hasPrefix("#L ") || line.hasPrefix("-L "))) {
- ScriptParseContext::ActionInfo ai = {ScriptParseContext::Look, line.c_str() + 3, "", firstChar == '#'};
- parseCtx._actionInfos.push_back(ai);
- debug("# Look: %s", line.c_str() + 3);
+ ActionInfo ai = {ActionInfo::Look, line.c_str() + 3, "", firstChar == '#', nullptr};
+ parseCtx._lookActionInfos.push_back(ai);
+ _pendingActionInfos.push_back(&parseCtx._lookActionInfos.back());
} else if (line.size() >= 4 && (line.hasPrefix("#W ") || line.hasPrefix("-W "))) {
- ScriptParseContext::ActionInfo ai = {ScriptParseContext::Walk, line.c_str() + 3, "", firstChar == '#'};
- parseCtx._actionInfos.push_back(ai);
+ ActionInfo ai = {ActionInfo::Walk, line.c_str() + 3, "", firstChar == '#', nullptr};
+ parseCtx._walkActionInfos.push_back(ai);
+ _pendingActionInfos.push_back(&parseCtx._walkActionInfos.back());
} else if (line.size() >= 4 && (line.hasPrefix("#T ") || line.hasPrefix("-T "))) {
- ScriptParseContext::ActionInfo ai = {ScriptParseContext::Talk, line.c_str() + 3, "", firstChar == '#'};
- parseCtx._actionInfos.push_back(ai);
+ ActionInfo ai = {ActionInfo::Talk, line.c_str() + 3, "", firstChar == '#', nullptr};
+ parseCtx._talkActionInfos.push_back(ai);
+ _pendingActionInfos.push_back(&parseCtx._talkActionInfos.back());
} else if (line.size() >= 4 && (line.hasPrefix("#U ") || line.hasPrefix("-U "))) {
int secondObjPos = -1;
for (int i = 3; i < (int) line.size(); ++i) {
@@ -58,13 +60,15 @@ bool EndBlockCommandParser::parse(const Common::String &line, ScriptParseContext
break;
}
}
- ScriptParseContext::ActionInfo ai = {
- ScriptParseContext::Talk,
+ ActionInfo ai = {
+ ActionInfo::Use,
line.c_str() + 3,
(secondObjPos != -1) ? line.c_str() + secondObjPos : "",
- firstChar == '#'
+ firstChar == '#',
+ nullptr
};
- parseCtx._actionInfos.push_back(ai);
+ parseCtx._useActionInfos.push_back(ai);
+ _pendingActionInfos.push_back(&parseCtx._useActionInfos.back());
} else if ((line.hasPrefix("#ELSE") || line.hasPrefix("=ELSE"))) {
_elseFound = true;
_ifTag = 0;
@@ -78,7 +82,7 @@ bool EndBlockCommandParser::parse(const Common::String &line, ScriptParseContext
return true;
}
-void EndBlockCommandParser::transition(ScriptParseContext &parseCtx, Command *, Command *newCommand) {
+void EndBlockCommandParser::transition(ScriptParseContext &parseCtx, Command *, Command *newCommand, CommandParser *newCommandParser) {
if (_elseFound) {
if (newCommand) {
ScriptParseContext::ConditionalCommandInfos::iterator it = parseCtx._pendingCondCommands.begin();
@@ -96,6 +100,14 @@ void EndBlockCommandParser::transition(ScriptParseContext &parseCtx, Command *,
_elseFound = false;
_ifTag = 0;
}
+
+ if (!_pendingActionInfos.empty() && newCommandParser != this) {
+ debug("Fixing pending action info.\n");
+ for (Common::Array<ActionInfo *>::iterator it = _pendingActionInfos.begin(); it != _pendingActionInfos.end(); ++it) {
+ (*it)->_command = newCommand;
+ }
+ _pendingActionInfos.clear();
+ }
}
Command::ExecuteResult EndBlockCommand::execute(GameData &) {
@@ -105,4 +117,9 @@ Command::ExecuteResult EndBlockCommand::execute(GameData &) {
Command *EndBlockCommand::next() const {
return nullptr;
}
+
+Common::String EndBlockCommand::debugString() const {
+ return "ENDBLOCK";
+}
+
}
diff --git a/engines/mutationofjb/commands/endblockcommand.h b/engines/mutationofjb/commands/endblockcommand.h
index 1ac636c6d5..51f799367c 100644
--- a/engines/mutationofjb/commands/endblockcommand.h
+++ b/engines/mutationofjb/commands/endblockcommand.h
@@ -25,19 +25,23 @@
#include "mutationofjb/commands/command.h"
#include "common/scummsys.h"
+#include "common/array.h"
namespace MutationOfJB {
+class ActionInfo;
+
class EndBlockCommandParser : public CommandParser {
public:
EndBlockCommandParser() : _elseFound(false), _ifTag(0) {}
virtual bool parse(const Common::String &line, ScriptParseContext &parseCtx, Command *&command);
- virtual void transition(ScriptParseContext &parseCtx, Command *oldCommand, Command *newCommand);
+ virtual void transition(ScriptParseContext &parseCtx, Command *oldCommand, Command *newCommand, CommandParser *newCommandParser);
private:
bool _elseFound;
char _ifTag;
+ Common::Array<ActionInfo*> _pendingActionInfos;
};
class EndBlockCommand : public Command {
@@ -46,6 +50,7 @@ public:
virtual ExecuteResult execute(GameData &gameData) override;
virtual Command *next() const override;
+ virtual Common::String debugString() const;
};
}
diff --git a/engines/mutationofjb/commands/ifcommand.cpp b/engines/mutationofjb/commands/ifcommand.cpp
index 8026c841e1..a41875f33b 100644
--- a/engines/mutationofjb/commands/ifcommand.cpp
+++ b/engines/mutationofjb/commands/ifcommand.cpp
@@ -58,7 +58,7 @@ bool IfCommandParser::parse(const Common::String &line, ScriptParseContext &pars
return true;
}
-void IfCommandParser::transition(ScriptParseContext &, Command *oldCommand, Command *newCommand) {
+void IfCommandParser::transition(ScriptParseContext &, Command *oldCommand, Command *newCommand, CommandParser *) {
if (!oldCommand || !newCommand) {
warning(_("Unexpected empty command in transition"));
return;
@@ -92,5 +92,10 @@ Command::ExecuteResult IfCommand::execute(GameData &gameData) {
return Finished;
}
+
+Common::String IfCommand::debugString() const {
+ return Common::String::format("IF scene%d.object%d.WX %s %d", _sceneId, _objectId, _negative ? "!=" : "==", _value);
+}
+
}
diff --git a/engines/mutationofjb/commands/ifcommand.h b/engines/mutationofjb/commands/ifcommand.h
index 290260be93..9462278483 100644
--- a/engines/mutationofjb/commands/ifcommand.h
+++ b/engines/mutationofjb/commands/ifcommand.h
@@ -33,7 +33,7 @@ class ScriptParseContext;
class IfCommandParser : public CommandParser {
public:
virtual bool parse(const Common::String &line, ScriptParseContext &parseCtx, Command *&command);
- virtual void transition(ScriptParseContext &parseCtx, Command *oldCommand, Command *newCommand);
+ virtual void transition(ScriptParseContext &parseCtx, Command *oldCommand, Command *newCommand, CommandParser *newCommandParser);
};
class IfCommand : public ConditionalCommand {
@@ -43,6 +43,7 @@ public:
IfCommand(uint8 sceneId, uint8 objectId, uint16 value, bool negative);
virtual ExecuteResult execute(GameData &gameData) override;
+ virtual Common::String debugString() const;
private:
uint8 _sceneId;
diff --git a/engines/mutationofjb/debug.cpp b/engines/mutationofjb/debug.cpp
new file mode 100644
index 0000000000..4861ab1f52
--- /dev/null
+++ b/engines/mutationofjb/debug.cpp
@@ -0,0 +1,162 @@
+/* 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 "mutationofjb/debug.h"
+#include "mutationofjb/mutationofjb.h"
+#include "mutationofjb/script.h"
+#include "mutationofjb/commands/command.h"
+#include "common/debug-channels.h"
+#include "common/translation.h"
+#include "common/scummsys.h"
+
+namespace MutationOfJB {
+
+/*
+TODO
+static Common::String convertTo7bitASCII() {
+ return Common::String();
+}
+*/
+
+Console::Console(MutationOfJBEngine *vm) : _vm(vm) {
+ registerCmd("listsections", WRAP_METHOD(Console, cmd_listsections));
+ registerCmd("showsection", WRAP_METHOD(Console, cmd_showsection));
+}
+
+bool Console::cmd_listsections(int argc, const char **argv) {
+ if (argc == 3) {
+ Script *script = nullptr;
+ if (strcmp(argv[1], "G") == 0) {
+ script = _vm->getGlobalScript();
+ } else if (strcmp(argv[1], "L") == 0) {
+ script = _vm->getLocalScript();
+ }
+ if (!script) {
+ debugPrintf(_("Choose 'G' (global) or 'L' (local) script.\n"));
+ } else {
+ if (strcmp(argv[2], "L") == 0) {
+ const ActionInfos &actionInfos = script->getLookActionInfos();
+ for (ActionInfos::const_iterator it = actionInfos.begin(); it != actionInfos.end(); ++it) {
+ const ActionInfo &actionInfo = *it;
+ debugPrintf(_("Look %s\n"), actionInfo._object1Name.c_str());
+ }
+ } else if (strcmp(argv[2], "W") == 0) {
+ const ActionInfos &actionInfos = script->getWalkActionInfos();
+ for (ActionInfos::const_iterator it = actionInfos.begin(); it != actionInfos.end(); ++it) {
+ const ActionInfo &actionInfo = *it;
+ debugPrintf(_("Walk %s\n"), actionInfo._object1Name.c_str());
+ }
+ } else if (strcmp(argv[2], "T") == 0) {
+ const ActionInfos &actionInfos = script->getTalkActionInfos();
+ for (ActionInfos::const_iterator it = actionInfos.begin(); it != actionInfos.end(); ++it) {
+ const ActionInfo &actionInfo = *it;
+ debugPrintf(_("Talk %s\n"), actionInfo._object1Name.c_str());
+ }
+ } else if (strcmp(argv[2], "U") == 0) {
+ const ActionInfos &actionInfos = script->getUseActionInfos();
+ for (ActionInfos::const_iterator it = actionInfos.begin(); it != actionInfos.end(); ++it) {
+ const ActionInfo &actionInfo = *it;
+ debugPrintf(_("Use %s\n"), actionInfo._object1Name.c_str());
+ }
+ } else {
+ debugPrintf(_("Choose 'L' (look), 'W' (walk), 'T' (talk) or 'U' (use).\n"));
+ }
+ }
+ } else {
+ debugPrintf(_("listsections <G|L> <L|W|T|U>\n"));
+ }
+ return true;
+}
+
+bool Console::cmd_showsection(int argc, const char **argv) {
+ if (argc == 4) {
+ Script *script = nullptr;
+ if (strcmp(argv[1], "G") == 0) {
+ script = _vm->getGlobalScript();
+ } else if (strcmp(argv[1], "L") == 0) {
+ script = _vm->getLocalScript();
+ }
+ if (!script) {
+ debugPrintf(_("Choose 'G' (global) or 'L' (local) script.\n"));
+ } else {
+ Command *command = nullptr;
+ bool found = false;
+ if (strcmp(argv[2], "L") == 0) {
+ const ActionInfos &actionInfos = script->getLookActionInfos();
+ for (ActionInfos::const_iterator it = actionInfos.begin(); it != actionInfos.end(); ++it) {
+ const ActionInfo &actionInfo = *it;
+ if (actionInfo._object1Name == argv[3]) {
+ found = true;
+ command = actionInfo._command;
+ break;
+ }
+ }
+ } else if (strcmp(argv[2], "W") == 0) {
+ const ActionInfos &actionInfos = script->getWalkActionInfos();
+ for (ActionInfos::const_iterator it = actionInfos.begin(); it != actionInfos.end(); ++it) {
+ const ActionInfo &actionInfo = *it;
+ if (actionInfo._object1Name == argv[3]) {
+ found = true;
+ command = actionInfo._command;
+ break;
+ }
+ }
+ } else if (strcmp(argv[2], "T") == 0) {
+ const ActionInfos &actionInfos = script->getTalkActionInfos();
+ for (ActionInfos::const_iterator it = actionInfos.begin(); it != actionInfos.end(); ++it) {
+ const ActionInfo &actionInfo = *it;
+ if (actionInfo._object1Name == argv[3]) {
+ found = true;
+ command = actionInfo._command;
+ break;
+ }
+ }
+ } else if (strcmp(argv[2], "U") == 0) {
+ const ActionInfos &actionInfos = script->getUseActionInfos();
+ for (ActionInfos::const_iterator it = actionInfos.begin(); it != actionInfos.end(); ++it) {
+ const ActionInfo &actionInfo = *it;
+ if (actionInfo._object1Name == argv[3]) {
+ found = true;
+ command = actionInfo._command;
+ break;
+ }
+ }
+ } else {
+ debugPrintf(_("Choose 'L' (look), 'W' (walk), 'T' (talk) or 'U' (use).\n"));
+ }
+
+ if (found) {
+ if (command) {
+ debugPrintf("%s\n", command->debugString().c_str());
+ }
+ } else {
+ debugPrintf("Section not found.\n");
+ }
+ }
+ } else {
+ debugPrintf(_("showsection <G|L> <L|W|T|U> <sectionname>\n"));
+ }
+
+ return true;
+}
+
+}
diff --git a/engines/mutationofjb/debug.h b/engines/mutationofjb/debug.h
new file mode 100644
index 0000000000..86ee8448c5
--- /dev/null
+++ b/engines/mutationofjb/debug.h
@@ -0,0 +1,40 @@
+/* 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 "gui/debugger.h"
+
+namespace MutationOfJB {
+
+class MutationOfJBEngine;
+
+class Console : public GUI::Debugger {
+public:
+ Console(MutationOfJBEngine *vm);
+ virtual ~Console(void) {}
+private:
+ bool cmd_listsections(int argc, const char **argv);
+ bool cmd_showsection(int argc, const char **argv);
+ MutationOfJBEngine *_vm;
+};
+
+}
+
diff --git a/engines/mutationofjb/module.mk b/engines/mutationofjb/module.mk
index 16a0c3b06f..09f00db9df 100644
--- a/engines/mutationofjb/module.mk
+++ b/engines/mutationofjb/module.mk
@@ -7,6 +7,7 @@ MODULE_OBJS := \
commands/endblockcommand.o \
commands/ifcommand.o \
commands/seqcommand.o \
+ debug.o \
detection.o \
encryptedfile.o \
game.o \
diff --git a/engines/mutationofjb/mutationofjb.cpp b/engines/mutationofjb/mutationofjb.cpp
index 59553d4d34..3576fd5ca8 100644
--- a/engines/mutationofjb/mutationofjb.cpp
+++ b/engines/mutationofjb/mutationofjb.cpp
@@ -37,14 +37,17 @@
#include "mutationofjb/encryptedfile.h"
#include "mutationofjb/util.h"
#include "mutationofjb/script.h"
+#include "mutationofjb/debug.h"
namespace MutationOfJB {
MutationOfJBEngine::MutationOfJBEngine(OSystem *syst)
: Engine(syst),
- _console(nullptr),
- _room(nullptr),
- _screen(nullptr)
+ _console(nullptr),
+ _room(nullptr),
+ _screen(nullptr),
+ _globalScript(nullptr),
+ _localScript(nullptr)
{
debug("MutationOfJBEngine::MutationOfJBEngine");
}
@@ -99,8 +102,8 @@ Common::Error MutationOfJBEngine::run() {
EncryptedFile globalScriptFile;
globalScriptFile.open("global.atn");
- Script *script = new Script;
- script->loadFromStream(globalScriptFile);
+ _globalScript = new Script;
+ _globalScript->loadFromStream(globalScriptFile);
globalScriptFile.close();
while(!shouldQuit()) {
@@ -141,4 +144,13 @@ Common::Error MutationOfJBEngine::run() {
return Common::kNoError;
}
+
+Script *MutationOfJBEngine::getGlobalScript() {
+ return _globalScript;
+}
+
+Script *MutationOfJBEngine::getLocalScript() {
+ return _localScript;
+}
+
}
diff --git a/engines/mutationofjb/mutationofjb.h b/engines/mutationofjb/mutationofjb.h
index 75bd6788d6..efd8898ecf 100644
--- a/engines/mutationofjb/mutationofjb.h
+++ b/engines/mutationofjb/mutationofjb.h
@@ -24,7 +24,6 @@
#define MUTATIONOFJB_MUTATIONOFJB_H
#include "engines/engine.h"
-#include "gui/debugger.h"
namespace Graphics {
class Screen;
@@ -35,6 +34,7 @@ namespace MutationOfJB {
class Console;
class Room;
struct GameData;
+class Script;
class MutationOfJBEngine : public Engine {
public:
@@ -42,6 +42,9 @@ public:
~MutationOfJBEngine();
virtual Common::Error run();
+ Script *getGlobalScript();
+ Script *getLocalScript();
+
private:
bool loadGameData(bool partB);
void setupCursor();
@@ -50,13 +53,10 @@ private:
Room *_room;
GameData *_gameData;
Graphics::Screen *_screen;
+ Script *_globalScript;
+ Script *_localScript;
};
-class Console : public GUI::Debugger {
-public:
- Console(MutationOfJBEngine *vm) {}
- virtual ~Console(void) {}
-};
}
diff --git a/engines/mutationofjb/script.cpp b/engines/mutationofjb/script.cpp
index 0deeccbb73..8985e067fd 100644
--- a/engines/mutationofjb/script.cpp
+++ b/engines/mutationofjb/script.cpp
@@ -40,6 +40,7 @@ static CommandParser** getParsers() {
new ChangeDoorCommandParser,
new ChangeObjectCommandParser,
new ChangeStaticCommandParser,
+ new ChangeSceneCommandParser,
nullptr
};
@@ -97,8 +98,12 @@ bool Script::loadFromStream(Common::SeekableReadStream &stream) {
break;
}
}
+ if (!currentParser) {
+ continue;
+ }
+
if (lastParser) {
- lastParser->transition(parseCtx, lastCmd, currentCmd);
+ lastParser->transition(parseCtx, lastCmd, currentCmd, currentParser);
}
if (currentCmd) {
@@ -109,6 +114,11 @@ bool Script::loadFromStream(Common::SeekableReadStream &stream) {
lastParser = currentParser;
}
+ _lookActionInfos = parseCtx._lookActionInfos;
+ _walkActionInfos = parseCtx._walkActionInfos;
+ _talkActionInfos = parseCtx._talkActionInfos;
+ _useActionInfos = parseCtx._useActionInfos;
+
Common::HashMap<Common::String, Command *> macros;
Common::HashMap<Common::String, Command *> labels;
@@ -126,4 +136,20 @@ Script::~Script() {
destroy();
}
+const ActionInfos &Script::getLookActionInfos() const {
+ return _lookActionInfos;
+}
+
+const ActionInfos &Script::getWalkActionInfos() const {
+ return _walkActionInfos;
+}
+
+const ActionInfos &Script::getTalkActionInfos() const {
+ return _talkActionInfos;
+}
+
+const ActionInfos &Script::getUseActionInfos() const {
+ return _useActionInfos;
+}
+
}
diff --git a/engines/mutationofjb/script.h b/engines/mutationofjb/script.h
index da90a2411f..be04dc5e85 100644
--- a/engines/mutationofjb/script.h
+++ b/engines/mutationofjb/script.h
@@ -36,6 +36,24 @@ class Command;
class ConditionalCommand;
typedef Common::Array<Command*> Commands;
+
+struct ActionInfo {
+ enum Action {
+ Walk,
+ Talk,
+ Look,
+ Use
+ };
+
+ Action _action;
+ Common::String _object1Name;
+ Common::String _object2Name;
+ bool _walkTo;
+ Command *_command;
+};
+
+typedef Common::Array<ActionInfo> ActionInfos;
+
class ScriptParseContext
{
public:
@@ -56,21 +74,11 @@ public:
ConditionalCommandInfos _pendingCondCommands;
- enum Action {
- Walk,
- Talk,
- Look,
- Use
- };
+ ActionInfos _lookActionInfos;
+ ActionInfos _walkActionInfos;
+ ActionInfos _talkActionInfos;
+ ActionInfos _useActionInfos;
- struct ActionInfo {
- Action _action;
- Common::String _object1Name;
- Common::String _object2Name;
- bool walkTo;
- };
- typedef Common::Array<ActionInfo> ActionInfos;
- ActionInfos _actionInfos;
private:
};
@@ -78,9 +86,19 @@ class Script {
public:
bool loadFromStream(Common::SeekableReadStream &stream);
~Script();
+
+ const ActionInfos &getLookActionInfos() const;
+ const ActionInfos &getWalkActionInfos() const;
+ const ActionInfos &getTalkActionInfos() const;
+ const ActionInfos &getUseActionInfos() const;
+
private:
void destroy();
Commands _allCommands;
+ ActionInfos _lookActionInfos;
+ ActionInfos _walkActionInfos;
+ ActionInfos _talkActionInfos;
+ ActionInfos _useActionInfos;
};
}