diff options
author | Ľubomír Remák | 2018-03-20 18:58:45 +0100 |
---|---|---|
committer | Eugene Sandulenko | 2018-08-25 23:12:01 +0200 |
commit | 1d84041508b3acaf7a47fde81e7e334c004507b8 (patch) | |
tree | 17a1e5fb8eeb5ef0a5c680d591223ba1fb6603e7 /engines | |
parent | fb75e483e43a00bb20329dd0b5db92a3588a2d2e (diff) | |
download | scummvm-rg350-1d84041508b3acaf7a47fde81e7e334c004507b8.tar.gz scummvm-rg350-1d84041508b3acaf7a47fde81e7e334c004507b8.tar.bz2 scummvm-rg350-1d84041508b3acaf7a47fde81e7e334c004507b8.zip |
MUTATIONOFJB: Add Game class.
Diffstat (limited to 'engines')
-rw-r--r-- | engines/mutationofjb/commands/additemcommand.cpp | 2 | ||||
-rw-r--r-- | engines/mutationofjb/commands/changecommand.h | 2 | ||||
-rw-r--r-- | engines/mutationofjb/commands/gotocommand.cpp | 2 | ||||
-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/labelcommand.cpp | 1 | ||||
-rw-r--r-- | engines/mutationofjb/commands/removeallitemscommand.cpp | 2 | ||||
-rw-r--r-- | engines/mutationofjb/commands/removeitemcommand.cpp | 2 | ||||
-rw-r--r-- | engines/mutationofjb/debug.cpp | 9 | ||||
-rw-r--r-- | engines/mutationofjb/game.cpp | 177 | ||||
-rw-r--r-- | engines/mutationofjb/game.h | 142 | ||||
-rw-r--r-- | engines/mutationofjb/gamedata.cpp | 193 | ||||
-rw-r--r-- | engines/mutationofjb/gamedata.h | 165 | ||||
-rw-r--r-- | engines/mutationofjb/module.mk | 1 | ||||
-rw-r--r-- | engines/mutationofjb/mutationofjb.cpp | 63 | ||||
-rw-r--r-- | engines/mutationofjb/mutationofjb.h | 13 | ||||
-rw-r--r-- | engines/mutationofjb/script.h | 5 |
18 files changed, 446 insertions, 339 deletions
diff --git a/engines/mutationofjb/commands/additemcommand.cpp b/engines/mutationofjb/commands/additemcommand.cpp index b0c7d21f28..58ec5675fb 100644 --- a/engines/mutationofjb/commands/additemcommand.cpp +++ b/engines/mutationofjb/commands/additemcommand.cpp @@ -21,7 +21,7 @@ */ #include "mutationofjb/commands/additemcommand.h" -#include "mutationofjb/game.h" +#include "mutationofjb/gamedata.h" /* "ADDITEM" " " <item> diff --git a/engines/mutationofjb/commands/changecommand.h b/engines/mutationofjb/commands/changecommand.h index af9a608e03..5ba386bf02 100644 --- a/engines/mutationofjb/commands/changecommand.h +++ b/engines/mutationofjb/commands/changecommand.h @@ -21,7 +21,7 @@ */ #include "mutationofjb/commands/seqcommand.h" -#include "mutationofjb/game.h" +#include "mutationofjb/gamedata.h" namespace MutationOfJB { diff --git a/engines/mutationofjb/commands/gotocommand.cpp b/engines/mutationofjb/commands/gotocommand.cpp index 92cce14479..40560f3bfb 100644 --- a/engines/mutationofjb/commands/gotocommand.cpp +++ b/engines/mutationofjb/commands/gotocommand.cpp @@ -22,7 +22,7 @@ #include "mutationofjb/commands/gotocommand.h" #include "mutationofjb/commands/labelcommand.h" -#include "mutationofjb/game.h" +#include "mutationofjb/gamedata.h" #include "mutationofjb/script.h" /* diff --git a/engines/mutationofjb/commands/ifcommand.cpp b/engines/mutationofjb/commands/ifcommand.cpp index 44c6b18735..f78335ad60 100644 --- a/engines/mutationofjb/commands/ifcommand.cpp +++ b/engines/mutationofjb/commands/ifcommand.cpp @@ -21,7 +21,7 @@ */ #include "mutationofjb/commands/ifcommand.h" -#include "mutationofjb/game.h" +#include "mutationofjb/gamedata.h" #include "mutationofjb/script.h" #include "common/str.h" #include "common/translation.h" diff --git a/engines/mutationofjb/commands/ifitemcommand.cpp b/engines/mutationofjb/commands/ifitemcommand.cpp index 6f467da0bd..7512ba5955 100644 --- a/engines/mutationofjb/commands/ifitemcommand.cpp +++ b/engines/mutationofjb/commands/ifitemcommand.cpp @@ -21,7 +21,7 @@ */ #include "mutationofjb/commands/ifitemcommand.h" -#include "mutationofjb/game.h" +#include "mutationofjb/gamedata.h" #include "mutationofjb/script.h" #include "mutationofjb/util.h" #include "common/str.h" diff --git a/engines/mutationofjb/commands/ifpiggycommand.cpp b/engines/mutationofjb/commands/ifpiggycommand.cpp index 2ecd437611..cad0a14eb1 100644 --- a/engines/mutationofjb/commands/ifpiggycommand.cpp +++ b/engines/mutationofjb/commands/ifpiggycommand.cpp @@ -21,7 +21,7 @@ */ #include "mutationofjb/commands/ifpiggycommand.h" -#include "mutationofjb/game.h" +#include "mutationofjb/gamedata.h" #include "mutationofjb/script.h" #include "mutationofjb/util.h" #include "common/str.h" diff --git a/engines/mutationofjb/commands/labelcommand.cpp b/engines/mutationofjb/commands/labelcommand.cpp index 4540a83aa3..15a10cafd4 100644 --- a/engines/mutationofjb/commands/labelcommand.cpp +++ b/engines/mutationofjb/commands/labelcommand.cpp @@ -22,7 +22,6 @@ #include "mutationofjb/commands/labelcommand.h" #include "mutationofjb/commands/gotocommand.h" -#include "mutationofjb/game.h" #include "mutationofjb/script.h" /* diff --git a/engines/mutationofjb/commands/removeallitemscommand.cpp b/engines/mutationofjb/commands/removeallitemscommand.cpp index 8c6309f46c..8043864715 100644 --- a/engines/mutationofjb/commands/removeallitemscommand.cpp +++ b/engines/mutationofjb/commands/removeallitemscommand.cpp @@ -21,7 +21,7 @@ */ #include "mutationofjb/commands/removeallitemscommand.h" -#include "mutationofjb/game.h" +#include "mutationofjb/gamedata.h" /* "DELALLITEMS" diff --git a/engines/mutationofjb/commands/removeitemcommand.cpp b/engines/mutationofjb/commands/removeitemcommand.cpp index c6aad0e6e8..e4d9601824 100644 --- a/engines/mutationofjb/commands/removeitemcommand.cpp +++ b/engines/mutationofjb/commands/removeitemcommand.cpp @@ -21,7 +21,7 @@ */ #include "mutationofjb/commands/removeitemcommand.h" -#include "mutationofjb/game.h" +#include "mutationofjb/gamedata.h" /* "DELITEM" " " <item> diff --git a/engines/mutationofjb/debug.cpp b/engines/mutationofjb/debug.cpp index 87f0091a29..e6393242e2 100644 --- a/engines/mutationofjb/debug.cpp +++ b/engines/mutationofjb/debug.cpp @@ -21,6 +21,7 @@ */ #include "mutationofjb/debug.h" +#include "mutationofjb/game.h" #include "mutationofjb/mutationofjb.h" #include "mutationofjb/script.h" #include "mutationofjb/commands/command.h" @@ -61,9 +62,9 @@ bool Console::cmd_listsections(int argc, const char **argv) { if (argc == 3) { Script *script = nullptr; if (strcmp(argv[1], "G") == 0) { - script = _vm->getGlobalScript(); + script = _vm->getGame().getGlobalScript(); } else if (strcmp(argv[1], "L") == 0) { - script = _vm->getLocalScript(); + script = _vm->getGame().getLocalScript(); } if (!script) { debugPrintf(_("Choose 'G' (global) or 'L' (local) script.\n")); @@ -135,9 +136,9 @@ bool Console::cmd_showsection(int argc, const char **argv) { if (argc >= 4) { Script *script = nullptr; if (strcmp(argv[1], "G") == 0) { - script = _vm->getGlobalScript(); + script = _vm->getGame().getGlobalScript(); } else if (strcmp(argv[1], "L") == 0) { - script = _vm->getLocalScript(); + script = _vm->getGame().getLocalScript(); } if (!script) { debugPrintf(_("Choose 'G' (global) or 'L' (local) script.\n")); diff --git a/engines/mutationofjb/game.cpp b/engines/mutationofjb/game.cpp index 4b6d98e77b..6fe6b958d7 100644 --- a/engines/mutationofjb/game.cpp +++ b/engines/mutationofjb/game.cpp @@ -21,171 +21,64 @@ */ #include "mutationofjb/game.h" -#include "common/stream.h" +#include "mutationofjb/gamedata.h" +#include "mutationofjb/encryptedfile.h" +#include "mutationofjb/mutationofjb.h" +#include "mutationofjb/room.h" +#include "mutationofjb/script.h" +#include "mutationofjb/util.h" #include "common/util.h" -#include "common/translation.h" namespace MutationOfJB { -static bool readString(Common::ReadStream &stream, char *str) { - char buf[MAX_STR_LENGTH]; - memset(str, 0, MAX_STR_LENGTH + 1); +Game::Game(MutationOfJBEngine* vm) : _vm(vm) { + _gameData = new GameData; + loadGameData(false); - uint8 len = stream.readByte(); - stream.read(buf, MAX_STR_LENGTH); + EncryptedFile globalScriptFile; + globalScriptFile.open("global.atn"); + _globalScript = new Script; + _globalScript->loadFromStream(globalScriptFile); + globalScriptFile.close(); - len = MIN(len, MAX_STR_LENGTH); - memcpy(str, buf, len); + _localScript = nullptr; + _room = new Room(_vm->getScreen()); - return true; -} - -bool Door::loadFromStream(Common::ReadStream &stream) { - readString(stream, _name); - - _destSceneId = stream.readByte(); - _destX = stream.readUint16LE(); - _destY = stream.readUint16LE(); - _x = stream.readUint16LE(); - _y = stream.readByte(); - _width = stream.readUint16LE(); - _height = stream.readByte(); - _walkToX = stream.readUint16LE(); - _walkToY = stream.readByte(); - _SP = stream.readByte(); - - return true; + changeScene(13, false); // Initial scene. } -bool Object::loadFromStream(Common::ReadStream &stream) { - _AC = stream.readByte(); - _FA = stream.readByte(); - _FR = stream.readByte(); - _NA = stream.readByte(); - _FS = stream.readByte(); - _unknown = stream.readByte(); - _CA = stream.readByte(); - _x = stream.readUint16LE(); - _y = stream.readByte(); - _XL = stream.readUint16LE(); - _YL = stream.readByte(); - _WX = stream.readUint16LE(); - _WY = stream.readByte(); - _SP = stream.readByte(); - - return true; +GameData &Game::getGameData() { + return *_gameData; } -bool Static::loadFromStream(Common::ReadStream &stream) { - _active = stream.readByte(); - readString(stream, _name); - _x = stream.readUint16LE(); - _y = stream.readByte(); - _width = stream.readUint16LE(); - _height = stream.readByte(); - _walkToX = stream.readUint16LE(); - _walkToY = stream.readByte(); - _SP = stream.readByte(); - - return true; +Script *Game::getGlobalScript() const { + return _globalScript; } -bool Bitmap::loadFromStream(Common::ReadStream &stream) { - _frame = stream.readByte(); - _isVisible = stream.readByte(); - _x1 = stream.readUint16LE(); - _y1 = stream.readByte(); - _x2 = stream.readUint16LE(); - _y2 = stream.readByte(); - - return true; +Script *Game::getLocalScript() const { + return _localScript; } -bool Scene::loadFromStream(Common::ReadStream &stream) { - int i; - - _startup = stream.readByte(); - _unknown001 = stream.readByte(); - _unknown002 = stream.readByte(); - _unknown003 = stream.readByte(); - _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); +bool Game::loadGameData(bool partB) { + EncryptedFile file; + const char *fileName = !partB ? "startup.dat" : "startupb.dat"; + file.open(fileName); + if (!file.isOpen()) { + reportFileMissingError(fileName); + return false; } - _noStatics = stream.readByte(); - _noStatics = MIN(_noStatics, (uint8) ARRAYSIZE(_statics)); - for (i = 0; i < ARRAYSIZE(_statics); ++i) { - _statics[i].loadFromStream(stream); - } + _gameData->loadFromStream(file); - for (i = 0; i < ARRAYSIZE(_bitmaps); ++i) { - _bitmaps[i].loadFromStream(stream); - } - - _obstacleY1 = stream.readUint16LE(); - _palRotStart = stream.readByte(); - _palRotEnd = stream.readByte(); - _palRotPeriod = stream.readByte(); - stream.read(_unknown38A, 80); + file.close(); return true; } -Door *Scene::getDoor(uint8 doorId) { - if (doorId == 0 || doorId > _noDoors) { - warning(_("Door %d does not exist"), doorId); - return nullptr; - } - return &_doors[doorId - 1]; -} - -Object *Scene::getObject(uint8 objectId) { - if (objectId == 0 || objectId > _noObjects) { - warning(_("Object %d does not exist"), objectId); - return nullptr; - } - - return &_objects[objectId - 1]; -} - -Static *Scene::getStatic(uint8 staticId) { - if (staticId == 0 || staticId > _noStatics) { - warning(_("Static %d does not exist"), staticId); - return nullptr; - } - - return &_statics[staticId - 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); - } - - return true; +void Game::changeScene(uint8 sceneId, bool partB) { + _gameData->_currentScene = sceneId; + _room->load(_gameData->_currentScene, partB); } } diff --git a/engines/mutationofjb/game.h b/engines/mutationofjb/game.h index 6eafc79e4a..4b4ab43343 100644 --- a/engines/mutationofjb/game.h +++ b/engines/mutationofjb/game.h @@ -24,139 +24,33 @@ #define MUTATIONOFJB_GAME_H #include "common/scummsys.h" -#include "mutationofjb/inventory.h" - -namespace Common { - class ReadStream; -} namespace MutationOfJB { -static const uint8 MAX_STR_LENGTH = 0x14; - -struct Door { - /* - Door name. - Can be empty - deactivates door completely. - */ - char _name[MAX_STR_LENGTH + 1]; - /* - Scene ID where the door leads. - Can be 0 - you can hover your mouse over it, but clicking it doesn't do anything (unless scripted). - */ - uint8 _destSceneId; - /* X coordinate for player's position after going through the door. */ - uint16 _destX; - /* Y coordinate for player's position after going through the door. */ - uint16 _destY; - /* X coordinate of the door rectangle. */ - uint16 _x; - /* Y coordinate of the door rectangle. */ - uint8 _y; - /* Width of the door rectangle. */ - uint16 _width; - /* Height of the door rectangle. */ - uint8 _height; - /* X coordinate for position towards player will walk after clicking the door. */ - uint16 _walkToX; - /* Y coordinate for position towards player will walk after clicking the door. */ - uint8 _walkToY; - /* Unknown for now - likely not even used. */ - uint8 _SP; - - bool loadFromStream(Common::ReadStream &stream); -}; - -struct Object { - uint8 _AC; - uint8 _FA; - uint8 _FR; - uint8 _NA; - uint8 _FS; - uint8 _unknown; - uint8 _CA; - uint16 _x; - uint8 _y; - uint16 _XL; - uint8 _YL; - uint16 _WX; - uint8 _WY; - uint8 _SP; - - bool loadFromStream(Common::ReadStream &stream); -}; - -struct Static { - uint8 _active; - char _name[MAX_STR_LENGTH + 1]; - uint16 _x; - uint8 _y; - uint16 _width; - uint8 _height; - uint16 _walkToX; - uint8 _walkToY; - uint8 _SP; - - bool loadFromStream(Common::ReadStream &stream); -}; - -struct Bitmap { - uint8 _frame; - uint8 _isVisible; - uint16 _x1; - uint8 _y1; - uint16 _x2; - uint8 _y2; - - bool loadFromStream(Common::ReadStream &stream); -}; +class MutationOfJBEngine; +class GameData; +class Script; +class Room; - -struct Scene { - - Door *getDoor(uint8 objectId); - Object *getObject(uint8 objectId); - Static *getStatic(uint8 staticId); - - uint8 _startup; - uint8 _unknown001; - uint8 _unknown002; - uint8 _unknown003; - uint8 _DL; - - uint8 _noDoors; - Door _doors[5]; - - uint8 _noObjects; - Object _objects[9]; - - uint8 _noStatics; - Static _statics[15]; - - Bitmap _bitmaps[10]; - - uint16 _obstacleY1; - uint8 _palRotStart; - uint8 _palRotEnd; - uint8 _palRotPeriod; - uint8 _unknown38A[80]; - - bool loadFromStream(Common::ReadStream &stream); -}; - -struct GameData { +class Game { public: - GameData(); - Scene *getScene(uint8 sceneId); + Game(MutationOfJBEngine* vm); + GameData &getGameData(); + + Script *getGlobalScript() const; + Script *getLocalScript() const; - bool loadFromStream(Common::ReadStream &stream); + void changeScene(uint8 sceneId, bool partB); - uint8 _currentScene; - Inventory _inventory; - Common::String _currentAPK; private: - Scene _scenes[45]; + bool loadGameData(bool partB); + + MutationOfJBEngine *_vm; + GameData *_gameData; + Script *_globalScript; + Script *_localScript; + Room *_room; }; } diff --git a/engines/mutationofjb/gamedata.cpp b/engines/mutationofjb/gamedata.cpp new file mode 100644 index 0000000000..cc85da3a6f --- /dev/null +++ b/engines/mutationofjb/gamedata.cpp @@ -0,0 +1,193 @@ +/* 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/gamedata.h" +#include "common/stream.h" +#include "common/util.h" +#include "common/translation.h" + +namespace MutationOfJB { + +static bool readString(Common::ReadStream &stream, char *str) { + char buf[MAX_STR_LENGTH]; + memset(str, 0, MAX_STR_LENGTH + 1); + + uint8 len = stream.readByte(); + stream.read(buf, MAX_STR_LENGTH); + + len = MIN(len, MAX_STR_LENGTH); + memcpy(str, buf, len); + + return true; +} + +bool Door::loadFromStream(Common::ReadStream &stream) { + readString(stream, _name); + + _destSceneId = stream.readByte(); + _destX = stream.readUint16LE(); + _destY = stream.readUint16LE(); + _x = stream.readUint16LE(); + _y = stream.readByte(); + _width = stream.readUint16LE(); + _height = stream.readByte(); + _walkToX = stream.readUint16LE(); + _walkToY = stream.readByte(); + _SP = stream.readByte(); + + return true; +} + +bool Object::loadFromStream(Common::ReadStream &stream) { + _AC = stream.readByte(); + _FA = stream.readByte(); + _FR = stream.readByte(); + _NA = stream.readByte(); + _FS = stream.readByte(); + _unknown = stream.readByte(); + _CA = stream.readByte(); + _x = stream.readUint16LE(); + _y = stream.readByte(); + _XL = stream.readUint16LE(); + _YL = stream.readByte(); + _WX = stream.readUint16LE(); + _WY = stream.readByte(); + _SP = stream.readByte(); + + return true; +} + +bool Static::loadFromStream(Common::ReadStream &stream) { + _active = stream.readByte(); + readString(stream, _name); + _x = stream.readUint16LE(); + _y = stream.readByte(); + _width = stream.readUint16LE(); + _height = stream.readByte(); + _walkToX = stream.readUint16LE(); + _walkToY = stream.readByte(); + _SP = stream.readByte(); + + return true; +} + +bool Bitmap::loadFromStream(Common::ReadStream &stream) { + _frame = stream.readByte(); + _isVisible = stream.readByte(); + _x1 = stream.readUint16LE(); + _y1 = stream.readByte(); + _x2 = stream.readUint16LE(); + _y2 = stream.readByte(); + + return true; +} + +bool Scene::loadFromStream(Common::ReadStream &stream) { + int i; + + _startup = stream.readByte(); + _unknown001 = stream.readByte(); + _unknown002 = stream.readByte(); + _unknown003 = stream.readByte(); + _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); + } + + for (i = 0; i < ARRAYSIZE(_bitmaps); ++i) { + _bitmaps[i].loadFromStream(stream); + } + + _obstacleY1 = stream.readUint16LE(); + _palRotStart = stream.readByte(); + _palRotEnd = stream.readByte(); + _palRotPeriod = stream.readByte(); + stream.read(_unknown38A, 80); + + return true; +} + +Door *Scene::getDoor(uint8 doorId) { + if (doorId == 0 || doorId > _noDoors) { + warning(_("Door %d does not exist"), doorId); + return nullptr; + } + + return &_doors[doorId - 1]; +} + +Object *Scene::getObject(uint8 objectId) { + if (objectId == 0 || objectId > _noObjects) { + warning(_("Object %d does not exist"), objectId); + return nullptr; + } + + return &_objects[objectId - 1]; +} + +Static *Scene::getStatic(uint8 staticId) { + if (staticId == 0 || staticId > _noStatics) { + warning(_("Static %d does not exist"), staticId); + return nullptr; + } + + return &_statics[staticId - 1]; +} + + +GameData::GameData() + : _currentScene(0), + _partB(false) {} + +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); + } + + return true; +} + +} diff --git a/engines/mutationofjb/gamedata.h b/engines/mutationofjb/gamedata.h new file mode 100644 index 0000000000..23e238a826 --- /dev/null +++ b/engines/mutationofjb/gamedata.h @@ -0,0 +1,165 @@ +/* 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_GAMEDATA_H +#define MUTATIONOFJB_GAMEDATA_H + +#include "common/scummsys.h" +#include "mutationofjb/inventory.h" + +namespace Common { +class ReadStream; +} + +namespace MutationOfJB { + +static const uint8 MAX_STR_LENGTH = 0x14; + +struct Door { + /* + Door name. + Can be empty - deactivates door completely. + */ + char _name[MAX_STR_LENGTH + 1]; + /* + Scene ID where the door leads. + Can be 0 - you can hover your mouse over it, but clicking it doesn't do anything (unless scripted). + */ + uint8 _destSceneId; + /* X coordinate for player's position after going through the door. */ + uint16 _destX; + /* Y coordinate for player's position after going through the door. */ + uint16 _destY; + /* X coordinate of the door rectangle. */ + uint16 _x; + /* Y coordinate of the door rectangle. */ + uint8 _y; + /* Width of the door rectangle. */ + uint16 _width; + /* Height of the door rectangle. */ + uint8 _height; + /* X coordinate for position towards player will walk after clicking the door. */ + uint16 _walkToX; + /* Y coordinate for position towards player will walk after clicking the door. */ + uint8 _walkToY; + /* Unknown for now - likely not even used. */ + uint8 _SP; + + bool loadFromStream(Common::ReadStream &stream); +}; + +struct Object { + uint8 _AC; + uint8 _FA; + uint8 _FR; + uint8 _NA; + uint8 _FS; + uint8 _unknown; + uint8 _CA; + uint16 _x; + uint8 _y; + uint16 _XL; + uint8 _YL; + uint16 _WX; + uint8 _WY; + uint8 _SP; + + bool loadFromStream(Common::ReadStream &stream); +}; + +struct Static { + uint8 _active; + char _name[MAX_STR_LENGTH + 1]; + uint16 _x; + uint8 _y; + uint16 _width; + uint8 _height; + uint16 _walkToX; + uint8 _walkToY; + uint8 _SP; + + bool loadFromStream(Common::ReadStream &stream); +}; + +struct Bitmap { + uint8 _frame; + uint8 _isVisible; + uint16 _x1; + uint8 _y1; + uint16 _x2; + uint8 _y2; + + bool loadFromStream(Common::ReadStream &stream); +}; + + +struct Scene { + + Door *getDoor(uint8 objectId); + Object *getObject(uint8 objectId); + Static *getStatic(uint8 staticId); + + uint8 _startup; + uint8 _unknown001; + uint8 _unknown002; + uint8 _unknown003; + uint8 _DL; + + uint8 _noDoors; + Door _doors[5]; + + uint8 _noObjects; + Object _objects[9]; + + uint8 _noStatics; + Static _statics[15]; + + Bitmap _bitmaps[10]; + + uint16 _obstacleY1; + uint8 _palRotStart; + uint8 _palRotEnd; + uint8 _palRotPeriod; + uint8 _unknown38A[80]; + + bool loadFromStream(Common::ReadStream &stream); +}; + +struct GameData { +public: + GameData(); + Scene *getScene(uint8 sceneId); + + bool loadFromStream(Common::ReadStream &stream); + + uint8 _currentScene; + bool _partB; + Inventory _inventory; + Common::String _currentAPK; +private: + Scene _scenes[45]; + +}; + +} + +#endif diff --git a/engines/mutationofjb/module.mk b/engines/mutationofjb/module.mk index 8ad1507c3c..4137581b72 100644 --- a/engines/mutationofjb/module.mk +++ b/engines/mutationofjb/module.mk @@ -19,6 +19,7 @@ MODULE_OBJS := \ detection.o \ encryptedfile.o \ game.o \ + gamedata.o \ inventory.o \ mutationofjb.o \ room.o \ diff --git a/engines/mutationofjb/mutationofjb.cpp b/engines/mutationofjb/mutationofjb.cpp index 17ff7b5018..66de1f7a9f 100644 --- a/engines/mutationofjb/mutationofjb.cpp +++ b/engines/mutationofjb/mutationofjb.cpp @@ -32,11 +32,8 @@ #include "engines/util.h" #include "mutationofjb/mutationofjb.h" -#include "mutationofjb/room.h" #include "mutationofjb/game.h" -#include "mutationofjb/encryptedfile.h" -#include "mutationofjb/util.h" -#include "mutationofjb/script.h" +#include "mutationofjb/gamedata.h" #include "mutationofjb/debug.h" namespace MutationOfJB { @@ -44,10 +41,7 @@ namespace MutationOfJB { MutationOfJBEngine::MutationOfJBEngine(OSystem *syst) : Engine(syst), _console(nullptr), - _room(nullptr), - _screen(nullptr), - _globalScript(nullptr), - _localScript(nullptr) { + _screen(nullptr) { debug("MutationOfJBEngine::MutationOfJBEngine"); } @@ -55,21 +49,6 @@ MutationOfJBEngine::~MutationOfJBEngine() { debug("MutationOfJBEngine::~MutationOfJBEngine"); } -bool MutationOfJBEngine::loadGameData(bool partB) { - EncryptedFile file; - const char *fileName = !partB ? "startup.dat" : "startupb.dat"; - file.open(fileName); - if (!file.isOpen()) { - reportFileMissingError(fileName); - return false; - } - - _gameData->loadFromStream(file); - - file.close(); - - return true; -} void MutationOfJBEngine::setupCursor() { const uint8 white[] = {0xFF, 0xFF, 0xFF}; @@ -82,27 +61,24 @@ void MutationOfJBEngine::setupCursor() { CursorMan.showMouse(true); } +Graphics::Screen *MutationOfJBEngine::getScreen() const { + return _screen; +} + +Game &MutationOfJBEngine::getGame() { + return *_game; +} + Common::Error MutationOfJBEngine::run() { debug("MutationOfJBEngine::run"); initGraphics(320, 200); _console = new Console(this); - _screen = new Graphics::Screen; - setupCursor(); - - _gameData = new GameData; - _gameData->_currentScene = 13; - loadGameData(false); + _screen = new Graphics::Screen(); + _game = new Game(this); - _room = new Room(_screen); - _room->load(_gameData->_currentScene, false); - - EncryptedFile globalScriptFile; - globalScriptFile.open("global.atn"); - _globalScript = new Script; - _globalScript->loadFromStream(globalScriptFile); - globalScriptFile.close(); + setupCursor(); while(!shouldQuit()) { Common::Event event; @@ -118,13 +94,12 @@ Common::Error MutationOfJBEngine::run() { } case Common::EVENT_LBUTTONDOWN: { - const Scene *const scene = _gameData->getScene(_gameData->_currentScene); + const Scene *const scene = _game->getGameData().getScene(_game->getGameData()._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); + _game->changeScene(door._destSceneId, false); } } } @@ -143,12 +118,4 @@ 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 efd8898ecf..893cca9772 100644 --- a/engines/mutationofjb/mutationofjb.h +++ b/engines/mutationofjb/mutationofjb.h @@ -32,9 +32,7 @@ namespace Graphics { namespace MutationOfJB { class Console; -class Room; -struct GameData; -class Script; +class Game; class MutationOfJBEngine : public Engine { public: @@ -42,19 +40,16 @@ public: ~MutationOfJBEngine(); virtual Common::Error run(); - Script *getGlobalScript(); - Script *getLocalScript(); + Graphics::Screen *getScreen() const; + Game &getGame(); private: bool loadGameData(bool partB); void setupCursor(); Console *_console; - Room *_room; - GameData *_gameData; Graphics::Screen *_screen; - Script *_globalScript; - Script *_localScript; + Game *_game; }; diff --git a/engines/mutationofjb/script.h b/engines/mutationofjb/script.h index 7c5e569702..66d137c8db 100644 --- a/engines/mutationofjb/script.h +++ b/engines/mutationofjb/script.h @@ -59,13 +59,12 @@ struct ActionInfo { typedef Common::Array<ActionInfo> ActionInfos; typedef Common::Array<GotoCommand *> GotoCommands; -class ScriptParseContext -{ +class ScriptParseContext { public: ScriptParseContext(Common::SeekableReadStream &stream); bool readLine(Common::String &line); void addConditionalCommand(ConditionalCommand *command, char tag); - void addLookSection(const Common::String & item, bool walkTo); + void addLookSection(const Common::String &item, bool walkTo); Common::SeekableReadStream &_stream; Command *_currentCommand; |