aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorĽubomír Remák2018-02-22 23:47:16 +0100
committerEugene Sandulenko2018-08-25 23:12:01 +0200
commitf7d5a825a053199ddbf4d7c564e84e9f9709d958 (patch)
treeceb20f74e8a40ae8553f5d06a24139aa21813714
parent356a6809c31224f4ed2bfcc5e6bacd131f144026 (diff)
downloadscummvm-rg350-f7d5a825a053199ddbf4d7c564e84e9f9709d958.tar.gz
scummvm-rg350-f7d5a825a053199ddbf4d7c564e84e9f9709d958.tar.bz2
scummvm-rg350-f7d5a825a053199ddbf4d7c564e84e9f9709d958.zip
MUTATIONOFJB: Start implementation of ATN scripts (IF command).
-rw-r--r--engines/mutationofjb/commands/command.cpp33
-rw-r--r--engines/mutationofjb/commands/command.h58
-rw-r--r--engines/mutationofjb/commands/conditionalcommand.cpp41
-rw-r--r--engines/mutationofjb/commands/conditionalcommand.h41
-rw-r--r--engines/mutationofjb/commands/ifcommand.cpp88
-rw-r--r--engines/mutationofjb/commands/ifcommand.h52
-rw-r--r--engines/mutationofjb/commands/seqcommand.cpp40
-rw-r--r--engines/mutationofjb/commands/seqcommand.h44
-rw-r--r--engines/mutationofjb/game.cpp25
-rw-r--r--engines/mutationofjb/game.h19
-rw-r--r--engines/mutationofjb/module.mk5
-rw-r--r--engines/mutationofjb/mutationofjb.cpp14
-rw-r--r--engines/mutationofjb/room.cpp3
-rw-r--r--engines/mutationofjb/script.cpp75
-rw-r--r--engines/mutationofjb/script.h64
15 files changed, 588 insertions, 14 deletions
diff --git a/engines/mutationofjb/commands/command.cpp b/engines/mutationofjb/commands/command.cpp
new file mode 100644
index 0000000000..d0b3f826e3
--- /dev/null
+++ b/engines/mutationofjb/commands/command.cpp
@@ -0,0 +1,33 @@
+/* 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/commands/command.h"
+#include "common/scummsys.h"
+
+namespace MutationOfJB {
+Command::~Command() {}
+
+SeqCommand *Command::asSeqCommand() {
+ return nullptr;
+}
+
+}
diff --git a/engines/mutationofjb/commands/command.h b/engines/mutationofjb/commands/command.h
new file mode 100644
index 0000000000..beae9d2833
--- /dev/null
+++ b/engines/mutationofjb/commands/command.h
@@ -0,0 +1,58 @@
+/* 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 MUTATIONOFJB_COMMAND_H
+#define MUTATIONOFJB_COMMAND_H
+
+namespace Common {
+ class String;
+}
+
+namespace MutationOfJB {
+
+class GameData;
+class SeqCommand;
+class IfCommand;
+class CallMacroCommand;
+class ScriptParseContext;
+class Command;
+
+typedef bool (*CommandParseFunc)(const Common::String &line, ScriptParseContext &parseContext, Command *&command);
+
+class Command {
+public:
+ enum ExecuteResult {
+ None,
+ Finished,
+ InProgress
+ };
+
+ virtual ~Command();
+
+ virtual ExecuteResult execute(GameData &gameData) = 0;
+ virtual Command *next() const = 0;
+
+ virtual SeqCommand *asSeqCommand();
+};
+}
+
+#endif
diff --git a/engines/mutationofjb/commands/conditionalcommand.cpp b/engines/mutationofjb/commands/conditionalcommand.cpp
new file mode 100644
index 0000000000..3118e6d8cb
--- /dev/null
+++ b/engines/mutationofjb/commands/conditionalcommand.cpp
@@ -0,0 +1,41 @@
+/* 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/commands/conditionalcommand.h"
+#include "common/scummsys.h"
+
+namespace MutationOfJB {
+
+ConditionalCommand::ConditionalCommand() :
+ _trueCommand(nullptr),
+ _falseCommand(nullptr),
+ _cachedResult(false)
+{}
+
+Command *ConditionalCommand::next() const {
+ if (_cachedResult) {
+ return _trueCommand;
+ } else {
+ return _falseCommand;
+ }
+}
+};
diff --git a/engines/mutationofjb/commands/conditionalcommand.h b/engines/mutationofjb/commands/conditionalcommand.h
new file mode 100644
index 0000000000..e355662454
--- /dev/null
+++ b/engines/mutationofjb/commands/conditionalcommand.h
@@ -0,0 +1,41 @@
+/* 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/commands/command.h"
+#include "common/scummsys.h"
+
+namespace MutationOfJB {
+
+class ConditionalCommand : public Command {
+public:
+ ConditionalCommand();
+ void setTrueCommand(Command *command);
+ void setFalseCommand(Command *command);
+
+ virtual Command *next() const override;
+protected:
+ Command *_trueCommand;
+ Command *_falseCommand;
+ bool _cachedResult;
+};
+
+}
diff --git a/engines/mutationofjb/commands/ifcommand.cpp b/engines/mutationofjb/commands/ifcommand.cpp
new file mode 100644
index 0000000000..18b8081842
--- /dev/null
+++ b/engines/mutationofjb/commands/ifcommand.cpp
@@ -0,0 +1,88 @@
+/* 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/commands/ifcommand.h"
+#include "mutationofjb/game.h"
+#include "mutationofjb/script.h"
+#include "common/str.h"
+#include "common/translation.h"
+
+namespace MutationOfJB {
+
+bool IfCommand::ParseFunc(const Common::String &line, ScriptParseContext &parseContext, Command *&command)
+{
+ // IFtss oo val!
+ // <t> 1B Tag.
+ // <ss> 2B Scene.
+ // <oo> 2B Object ID.
+ // <val> VL Value.
+ // ! 1B Negation (optional).
+
+ if (line.size() < 10) {
+ return false;
+ }
+
+ if (strncmp(line.c_str(), "IF", 2) != 0) {
+ return false;
+ }
+
+ const char *const cstr = line.c_str();
+ const char tag = cstr[2];
+ const uint8 sceneId = atoi(cstr + 3);
+ const uint8 objectId = atoi(cstr + 6);
+ const uint8 value = atoi(cstr + 9);
+ const bool negative = (line.lastChar() == '!');
+
+ IfCommand *ifCommand = new IfCommand(sceneId, objectId, value, negative);
+
+ command = ifCommand;
+ parseContext.addConditionalCommand(ifCommand, tag);
+ return true;
+}
+
+IfCommand::IfCommand(uint8 sceneId, uint8 objectId, uint16 value, bool negative) :
+ _sceneId(sceneId),
+ _objectId(objectId),
+ _value(value),
+ _negative(negative)
+{}
+
+Command::ExecuteResult IfCommand::execute(GameData &gameData) {
+ Scene* const scene = gameData.getScene(_sceneId);
+ if (!scene) {
+ return Finished;
+ }
+
+ Object* const object = scene->getObject(_objectId);
+ if (!object) {
+ return Finished;
+ }
+
+ _cachedResult = (object->_WX == _value);
+ if (_negative) {
+ _cachedResult = !_cachedResult;
+ }
+
+ return Finished;
+}
+}
+
diff --git a/engines/mutationofjb/commands/ifcommand.h b/engines/mutationofjb/commands/ifcommand.h
new file mode 100644
index 0000000000..d33f34ffb0
--- /dev/null
+++ b/engines/mutationofjb/commands/ifcommand.h
@@ -0,0 +1,52 @@
+/* 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 MUTATIONOFJB_IFCOMMAND_H
+#define MUTATIONOFJB_IFCOMMAND_H
+
+#include "mutationofjb/commands/conditionalcommand.h"
+#include "common/scummsys.h"
+
+namespace MutationOfJB {
+
+class ScriptParseContext;
+
+class IfCommand : public ConditionalCommand {
+public:
+ static bool ParseFunc(const Common::String &line, ScriptParseContext &parseContext, Command *&command);
+
+ IfCommand(uint8 sceneId, uint8 objectId, uint16 value, bool negative);
+
+ virtual ExecuteResult execute(GameData &gameData) override;
+
+private:
+ uint8 _sceneId;
+ uint8 _objectId;
+ uint16 _value;
+ bool _negative;
+
+ bool _cachedResult;
+};
+
+}
+
+#endif
diff --git a/engines/mutationofjb/commands/seqcommand.cpp b/engines/mutationofjb/commands/seqcommand.cpp
new file mode 100644
index 0000000000..ab98497f21
--- /dev/null
+++ b/engines/mutationofjb/commands/seqcommand.cpp
@@ -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 "seqcommand.h"
+
+namespace MutationOfJB {
+
+void SeqCommand::setNextCommand(Command *nextCommand)
+{
+ _nextCommand = nextCommand;
+}
+
+Command *SeqCommand::next() const {
+ return _nextCommand;
+}
+
+SeqCommand *SeqCommand::asSeqCommand() {
+ return this;
+}
+
+}
diff --git a/engines/mutationofjb/commands/seqcommand.h b/engines/mutationofjb/commands/seqcommand.h
new file mode 100644
index 0000000000..b247fb22e1
--- /dev/null
+++ b/engines/mutationofjb/commands/seqcommand.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 MUTATIONOFJB_SEQCOMMAND_H
+#define MUTATIONOFJB_SEQCOMMAND_H
+
+#include "mutationofjb/commands/command.h"
+#include "common/scummsys.h"
+
+namespace MutationOfJB {
+
+class SeqCommand : public Command {
+public:
+ void setNextCommand(Command *nextCommand);
+ virtual Command *next() const override;
+ virtual SeqCommand *asSeqCommand();
+
+private:
+ Command *_nextCommand;
+};
+
+}
+
+#endif
+
diff --git a/engines/mutationofjb/game.cpp b/engines/mutationofjb/game.cpp
index 581077acd6..740fb1cab6 100644
--- a/engines/mutationofjb/game.cpp
+++ b/engines/mutationofjb/game.cpp
@@ -23,6 +23,7 @@
#include "mutationofjb/game.h"
#include "common/stream.h"
#include "common/util.h"
+#include "common/translation.h"
namespace MutationOfJB {
@@ -101,7 +102,7 @@ bool Bitmap::loadFromStream(Common::ReadStream &stream) {
return true;
}
-bool SceneInfo::loadFromStream(Common::ReadStream &stream) {
+bool Scene::loadFromStream(Common::ReadStream &stream) {
int i;
_startup = stream.readByte();
@@ -111,16 +112,19 @@ bool SceneInfo::loadFromStream(Common::ReadStream &stream) {
_DL = stream.readByte();
_noDoors = stream.readByte();
+ _noDoors = MIN(_noDoors, (uint8) ARRAYSIZE(_doors));
for (i = 0; i < ARRAYSIZE(_doors); ++i) {
_doors[i].loadFromStream(stream);
}
_noObjects = stream.readByte();
+ _noObjects = MIN(_noObjects, (uint8) ARRAYSIZE(_objects));
for (i = 0; i < ARRAYSIZE(_objects); ++i) {
_objects[i].loadFromStream(stream);
}
_noStatics = stream.readByte();
+ _noStatics = MIN(_noStatics, (uint8) ARRAYSIZE(_statics));
for (i = 0; i < ARRAYSIZE(_statics); ++i) {
_statics[i].loadFromStream(stream);
}
@@ -139,8 +143,27 @@ bool SceneInfo::loadFromStream(Common::ReadStream &stream) {
return true;
}
+Object *Scene::getObject(uint8 objectId) {
+ if (objectId == 0 || objectId > _noObjects) {
+ warning(_("Object %d does not exist"), objectId);
+ return nullptr;
+ }
+
+ return &_objects[objectId - 1];
+}
+
GameData::GameData() : _currentScene(0) {}
+Scene *GameData::getScene(uint8 sceneId)
+{
+ if (sceneId == 0 || sceneId > ARRAYSIZE(_scenes)) {
+ warning(_("Scene %d does not exist"), sceneId);
+ return nullptr;
+ }
+
+ return &_scenes[sceneId - 1];
+}
+
bool GameData::loadFromStream(Common::ReadStream &stream) {
for (int i = 0; i < ARRAYSIZE(_scenes); ++i) {
_scenes[i].loadFromStream(stream);
diff --git a/engines/mutationofjb/game.h b/engines/mutationofjb/game.h
index d8f2079e3a..d49a966001 100644
--- a/engines/mutationofjb/game.h
+++ b/engines/mutationofjb/game.h
@@ -22,13 +22,11 @@
#include "common/scummsys.h"
-namespace Common
-{
+namespace Common {
class ReadStream;
}
-namespace MutationOfJB
-{
+namespace MutationOfJB {
static const uint8 MAX_STR_LENGTH = 0x14;
@@ -93,7 +91,10 @@ struct Bitmap {
};
-struct SceneInfo {
+struct Scene {
+
+ Object *getObject(uint8 objectId);
+
uint8 _startup;
uint8 _unknown001;
uint8 _unknown002;
@@ -123,12 +124,16 @@ struct SceneInfo {
struct GameData
{
+public:
GameData();
+ Scene *getScene(uint8 sceneId);
+
+ bool loadFromStream(Common::ReadStream &stream);
- SceneInfo _scenes[45];
uint8 _currentScene;
+private:
+ Scene _scenes[45];
- bool loadFromStream(Common::ReadStream &stream);
};
}
diff --git a/engines/mutationofjb/module.mk b/engines/mutationofjb/module.mk
index 7baea826c1..e6c539a2c8 100644
--- a/engines/mutationofjb/module.mk
+++ b/engines/mutationofjb/module.mk
@@ -1,11 +1,16 @@
MODULE := engines/mutationofjb
MODULE_OBJS := \
+ commands/command.o \
+ commands/conditionalcommand.o \
+ commands/ifcommand.o \
+ commands/seqcommand.o \
detection.o \
encryptedfile.o \
game.o \
mutationofjb.o \
room.o \
+ script.o \
util.o
# This module can be built as a plugin
diff --git a/engines/mutationofjb/mutationofjb.cpp b/engines/mutationofjb/mutationofjb.cpp
index dc7f51869c..cdefbb9833 100644
--- a/engines/mutationofjb/mutationofjb.cpp
+++ b/engines/mutationofjb/mutationofjb.cpp
@@ -102,12 +102,14 @@ Common::Error MutationOfJBEngine::run() {
switch (event.type) {
case Common::EVENT_LBUTTONDOWN:
{
- const SceneInfo &sceneInfo = _gameData->_scenes[_gameData->_currentScene - 1];
- for (int i = 0; i < MIN(ARRAYSIZE(sceneInfo._doors), (int) sceneInfo._noDoors); ++i) {
- const Door &door = sceneInfo._doors[i];
- if ((event.mouse.x >= door._x) && (event.mouse.x < door._x + door._width) && (event.mouse.y >= door._y) && (event.mouse.y < door._y + door._height)) {
- _gameData->_currentScene = door._destSceneId;
- _room->load(_gameData->_currentScene, false);
+ const Scene* const scene = _gameData->getScene(_gameData->_currentScene);
+ if (scene) {
+ for (int i = 0; i < MIN(ARRAYSIZE(scene->_doors), (int) scene->_noDoors); ++i) {
+ const Door &door = scene->_doors[i];
+ if ((event.mouse.x >= door._x) && (event.mouse.x < door._x + door._width) && (event.mouse.y >= door._y) && (event.mouse.y < door._y + door._height)) {
+ _gameData->_currentScene = door._destSceneId;
+ _room->load(_gameData->_currentScene, false);
+ }
}
}
break;
diff --git a/engines/mutationofjb/room.cpp b/engines/mutationofjb/room.cpp
index 95a1a49d7c..eae430a1d5 100644
--- a/engines/mutationofjb/room.cpp
+++ b/engines/mutationofjb/room.cpp
@@ -132,6 +132,9 @@ void Room::loadBackground(EncryptedFile &file, uint32 size) {
}
lines++;
}
+ if (readBytes < size) {
+ file.seek(size - readBytes, SEEK_CUR);
+ }
_screen->update();
}
diff --git a/engines/mutationofjb/script.cpp b/engines/mutationofjb/script.cpp
new file mode 100644
index 0000000000..0280c86198
--- /dev/null
+++ b/engines/mutationofjb/script.cpp
@@ -0,0 +1,75 @@
+/* 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 "script.h"
+
+#include "common/hashmap.h"
+#include "common/hash-str.h"
+#include "common/stream.h"
+#include "mutationofjb/commands/command.h"
+
+namespace MutationOfJB {
+
+static CommandParseFunc* getParseFuncs() {
+ static CommandParseFunc funcs[] = {
+ nullptr
+ };
+
+ return funcs;
+}
+
+
+ScriptParseContext::ScriptParseContext(Common::SeekableReadStream &stream) : _stream(stream) {}
+
+bool ScriptParseContext::readLine(Common::String &line) {
+ do {
+ Common::String str = _stream.readLine();
+ if (str.empty() || str[0] != '.') {
+ line = str;
+ if (line[0] == '*') {
+ line.deleteChar(0);
+ }
+ return true;
+ }
+ } while(_stream.eos());
+
+ return false;
+}
+
+void ScriptParseContext::addConditionalCommand(ConditionalCommand *command, char tag) {
+ ConditionalCommandInfo cmi = {command, tag};
+ _pendingCondCommands.push_back(cmi);
+}
+
+bool Script::loadFromStream(Common::SeekableReadStream &stream) {
+
+ CommandParseFunc * const parseFuncs = getParseFuncs();
+
+ ScriptParseContext parseCtx(stream);
+
+ Common::HashMap<Common::String, Command *> macros;
+ Common::HashMap<Common::String, Command *> labels;
+
+ return true;
+}
+
+}
diff --git a/engines/mutationofjb/script.h b/engines/mutationofjb/script.h
new file mode 100644
index 0000000000..9c0f0f3b1c
--- /dev/null
+++ b/engines/mutationofjb/script.h
@@ -0,0 +1,64 @@
+/* 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 MUTATIONOFJB_SCRIPT_H
+#define MUTATIONOFJB_SCRIPT_H
+
+#include "common/array.h"
+
+namespace Common {
+ class SeekableReadStream;
+ class String;
+}
+
+namespace MutationOfJB {
+
+class ConditionalCommand;
+
+class ScriptParseContext
+{
+public:
+ ScriptParseContext(Common::SeekableReadStream &stream);
+ bool readLine(Common::String &line);
+ void addConditionalCommand(ConditionalCommand *command, char tag);
+ //void setLastIfCommand(IfCommand *command);
+
+private:
+ Common::SeekableReadStream &_stream;
+
+ struct ConditionalCommandInfo {
+ ConditionalCommand *command;
+ char tag;
+ };
+ Common::Array<ConditionalCommandInfo> _pendingCondCommands;
+};
+
+class Script {
+public:
+ bool loadFromStream(Common::SeekableReadStream &stream);
+private:
+
+};
+
+}
+
+#endif