diff options
author | Ľubomír Remák | 2018-10-31 19:19:41 +0100 |
---|---|---|
committer | Ľubomír Remák | 2018-10-31 19:19:41 +0100 |
commit | b87391338e1e91aa213247420e4bfcb7e09e984d (patch) | |
tree | f676f490be356a22884e83ba6a6cf62c55726286 /engines/mutationofjb | |
parent | 3fb3f659f74e0682fe0ef3ab0dca7a47a0108a58 (diff) | |
download | scummvm-rg350-b87391338e1e91aa213247420e4bfcb7e09e984d.tar.gz scummvm-rg350-b87391338e1e91aa213247420e4bfcb7e09e984d.tar.bz2 scummvm-rg350-b87391338e1e91aa213247420e4bfcb7e09e984d.zip |
MUTATIONOFJB: Add basic support for RABLOAD command.
Also fix an issue with parsing IF command.
This commit makes the game completable (with many issues).
Diffstat (limited to 'engines/mutationofjb')
-rw-r--r-- | engines/mutationofjb/commands/conditionalcommand.cpp | 4 | ||||
-rw-r--r-- | engines/mutationofjb/commands/conditionalcommand.h | 5 | ||||
-rw-r--r-- | engines/mutationofjb/commands/ifcommand.cpp | 2 | ||||
-rw-r--r-- | engines/mutationofjb/commands/ifitemcommand.cpp | 2 | ||||
-rw-r--r-- | engines/mutationofjb/commands/ifpiggycommand.cpp | 2 | ||||
-rw-r--r-- | engines/mutationofjb/commands/loadplayercommand.cpp | 66 | ||||
-rw-r--r-- | engines/mutationofjb/commands/loadplayercommand.h | 55 | ||||
-rw-r--r-- | engines/mutationofjb/commands/talkcommand.h | 2 | ||||
-rw-r--r-- | engines/mutationofjb/module.mk | 1 | ||||
-rw-r--r-- | engines/mutationofjb/script.cpp | 2 |
10 files changed, 133 insertions, 8 deletions
diff --git a/engines/mutationofjb/commands/conditionalcommand.cpp b/engines/mutationofjb/commands/conditionalcommand.cpp index 56cc2bf9c2..9488dd5aaa 100644 --- a/engines/mutationofjb/commands/conditionalcommand.cpp +++ b/engines/mutationofjb/commands/conditionalcommand.cpp @@ -33,12 +33,12 @@ void ConditionalCommandParser::transition(ScriptParseContext &parseContext, Comm } ConditionalCommand *const condCommand = static_cast<ConditionalCommand *>(oldCommand); - parseContext.addConditionalCommand(condCommand, _lastTag, _firstHash); + parseContext.addConditionalCommand(condCommand, _tags.pop(), _firstHash); condCommand->setTrueCommand(newCommand); } void ConditionalCommandParser::finish(ScriptParseContext &) { - _lastTag = 0; + _tags.clear(); } diff --git a/engines/mutationofjb/commands/conditionalcommand.h b/engines/mutationofjb/commands/conditionalcommand.h index ea1a66afb0..1ca29b6bd6 100644 --- a/engines/mutationofjb/commands/conditionalcommand.h +++ b/engines/mutationofjb/commands/conditionalcommand.h @@ -25,16 +25,17 @@ #include "mutationofjb/commands/command.h" #include "common/scummsys.h" +#include "common/queue.h" namespace MutationOfJB { class ConditionalCommandParser : public CommandParser { public: - ConditionalCommandParser(bool firstHash = false) : _lastTag(0), _firstHash(firstHash) {} + ConditionalCommandParser(bool firstHash = false) : _firstHash(firstHash) {} virtual void transition(ScriptParseContext &parseCtx, Command *oldCommand, Command *newCommand, CommandParser *newCommandParser); virtual void finish(ScriptParseContext &parseCtx) override; protected: - char _lastTag; + Common::Queue<char> _tags; private: bool _firstHash; }; diff --git a/engines/mutationofjb/commands/ifcommand.cpp b/engines/mutationofjb/commands/ifcommand.cpp index fb48787af2..f4753a4311 100644 --- a/engines/mutationofjb/commands/ifcommand.cpp +++ b/engines/mutationofjb/commands/ifcommand.cpp @@ -69,7 +69,7 @@ bool IfCommandParser::parse(const Common::String &line, ScriptParseContext &, Co const uint8 value = atoi(cstr + 9); const bool negative = (line.lastChar() == '!'); - _lastTag = tag; + _tags.push(tag); command = new IfCommand(sceneId, objectId, value, negative); diff --git a/engines/mutationofjb/commands/ifitemcommand.cpp b/engines/mutationofjb/commands/ifitemcommand.cpp index 9695172369..2b9b4d3bea 100644 --- a/engines/mutationofjb/commands/ifitemcommand.cpp +++ b/engines/mutationofjb/commands/ifitemcommand.cpp @@ -60,7 +60,7 @@ bool IfItemCommandParser::parse(const Common::String &line, ScriptParseContext & item.deleteLastChar(); // Remove '!'. } - _lastTag = 0; + _tags.push(0); command = new IfItemCommand(item, negative); return true; diff --git a/engines/mutationofjb/commands/ifpiggycommand.cpp b/engines/mutationofjb/commands/ifpiggycommand.cpp index 4df1deb34a..57d12ef49e 100644 --- a/engines/mutationofjb/commands/ifpiggycommand.cpp +++ b/engines/mutationofjb/commands/ifpiggycommand.cpp @@ -49,7 +49,7 @@ bool IfPiggyCommandParser::parse(const Common::String &line, ScriptParseContext return false; } - _lastTag = 0; + _tags.push(0); command = new IfPiggyCommand(); return true; diff --git a/engines/mutationofjb/commands/loadplayercommand.cpp b/engines/mutationofjb/commands/loadplayercommand.cpp new file mode 100644 index 0000000000..757c3fa3ee --- /dev/null +++ b/engines/mutationofjb/commands/loadplayercommand.cpp @@ -0,0 +1,66 @@ +/* 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/loadplayercommand.h" + +#include "mutationofjb/game.h" +#include "mutationofjb/gamedata.h" +#include "mutationofjb/script.h" + +#include "common/str.h" + +/** @file + * "RABLOAD " <apkFrameFirst> " " <apkFrameLast> " " <playerFrameFirst> " " <palIndexFirst> " " <apkFilename> + * + * Load player frames from APK file specified by apkFileName. + * Only frames between apkFrameFirst and apkFrameLast are loaded onto position defined by playerFrameFirst. + * Player's palette is loaded at index defined by palIndexFirst. + */ + +namespace MutationOfJB { + +bool LoadPlayerCommandParser::parse(const Common::String &line, ScriptParseContext &, Command *&command) { + if (line.size() < 25 || !line.hasPrefix("RABLOAD ")) { + return false; + } + + const uint8 apkFrameFirst = atoi(line.c_str() + 8); + const uint8 apkFrameLast = atoi(line.c_str() + 12); + const uint8 playerFrameFirst = atoi(line.c_str() + 16); + const uint8 palIndexFirst = atoi(line.c_str() + 20); + const Common::String apkFileName = line.c_str() + 24; + + command = new LoadPlayerCommand(apkFrameFirst, apkFrameLast, playerFrameFirst, palIndexFirst, apkFileName); + return true; +} + +Command::ExecuteResult LoadPlayerCommand::execute(ScriptExecutionContext &scriptExeCtx) { + scriptExeCtx.getGameData()._currentAPK = _apkFileName; + + return Command::Finished; +} + +Common::String LoadPlayerCommand::debugString() const { + return Common::String::format("LOADPLAYER %u %u %u %u %s", (unsigned int) _apkFrameFirst, (unsigned int) _apkFrameLast, (unsigned int) _playerFrameFirst, (unsigned int) _palIndexFirst, _apkFileName.c_str()); +} + +} diff --git a/engines/mutationofjb/commands/loadplayercommand.h b/engines/mutationofjb/commands/loadplayercommand.h new file mode 100644 index 0000000000..4616e42474 --- /dev/null +++ b/engines/mutationofjb/commands/loadplayercommand.h @@ -0,0 +1,55 @@ +/* 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_LOADPLAYERCOMMAND_H +#define MUTATIONOFJB_LOADPLAYERCOMMAND_H + +#include "mutationofjb/commands/seqcommand.h" +#include "common/scummsys.h" +#include "mutationofjb/tasks/task.h" + +namespace MutationOfJB { + +class ConversationTask; + +class LoadPlayerCommandParser : public SeqCommandParser { +public: + virtual bool parse(const Common::String &line, ScriptParseContext &parseCtx, Command *&command) override; +}; + +class LoadPlayerCommand : public SeqCommand { +public: + LoadPlayerCommand(uint8 apkFrameFirst, uint8 apkFrameLast, uint8 playerFrameFirst, uint8 palIndexFirst, const Common::String &apkFileName) : _apkFrameFirst(apkFrameFirst), _apkFrameLast(apkFrameLast), _playerFrameFirst(playerFrameFirst), _palIndexFirst(palIndexFirst), _apkFileName(apkFileName) {} + virtual ExecuteResult execute(ScriptExecutionContext &scriptExecCtx) override; + virtual Common::String debugString() const override; + +private: + uint8 _apkFrameFirst; + uint8 _apkFrameLast; + uint8 _playerFrameFirst; + uint8 _palIndexFirst; + Common::String _apkFileName; +}; + +} + +#endif diff --git a/engines/mutationofjb/commands/talkcommand.h b/engines/mutationofjb/commands/talkcommand.h index 15b185c613..cf01ddd43b 100644 --- a/engines/mutationofjb/commands/talkcommand.h +++ b/engines/mutationofjb/commands/talkcommand.h @@ -46,7 +46,7 @@ public: TalkCommand(Mode mode) : _mode(mode) {} virtual ExecuteResult execute(ScriptExecutionContext &scriptExecCtx) override; - virtual Common::String debugString() const; + virtual Common::String debugString() const override; private: Mode _mode; diff --git a/engines/mutationofjb/module.mk b/engines/mutationofjb/module.mk index cc8eab159c..20272d05dc 100644 --- a/engines/mutationofjb/module.mk +++ b/engines/mutationofjb/module.mk @@ -14,6 +14,7 @@ MODULE_OBJS := \ commands/ifitemcommand.o \ commands/ifpiggycommand.o \ commands/labelcommand.o \ + commands/loadplayercommand.o \ commands/newroomcommand.o \ commands/removeallitemscommand.o \ commands/removeitemcommand.o \ diff --git a/engines/mutationofjb/script.cpp b/engines/mutationofjb/script.cpp index 4915530f32..a4bbb8f1ef 100644 --- a/engines/mutationofjb/script.cpp +++ b/engines/mutationofjb/script.cpp @@ -48,6 +48,7 @@ #include "mutationofjb/commands/setcolorcommand.h" #include "mutationofjb/commands/specialshowcommand.h" #include "mutationofjb/commands/switchpartcommand.h" +#include "mutationofjb/commands/loadplayercommand.h" #include "mutationofjb/game.h" namespace MutationOfJB { @@ -79,6 +80,7 @@ static CommandParser **getParsers() { new SetColorCommandParser, new SpecialShowCommandParser, new SwitchPartCommandParser, + new LoadPlayerCommandParser, nullptr }; |