diff options
author | Borja Lorente | 2016-06-13 20:29:08 +0200 |
---|---|---|
committer | Borja Lorente | 2016-08-14 18:24:58 +0200 |
commit | 5719ea30760c85113b4536f7b70295422e95ae9e (patch) | |
tree | f024e7403989255ea35522e35587e020de3fd34a | |
parent | 9564866ec360dbab39973a5b982b748f6c060637 (diff) | |
download | scummvm-rg350-5719ea30760c85113b4536f7b70295422e95ae9e.tar.gz scummvm-rg350-5719ea30760c85113b4536f7b70295422e95ae9e.tar.bz2 scummvm-rg350-5719ea30760c85113b4536f7b70295422e95ae9e.zip |
MACVENTURE: Add save game loading
-rw-r--r-- | engines/macventure/macventure.cpp | 7 | ||||
-rw-r--r-- | engines/macventure/macventure.h | 16 | ||||
-rw-r--r-- | engines/macventure/module.mk | 4 | ||||
-rw-r--r-- | engines/macventure/object.cpp | 30 | ||||
-rw-r--r-- | engines/macventure/object.h | 54 | ||||
-rw-r--r-- | engines/macventure/world.cpp | 98 | ||||
-rw-r--r-- | engines/macventure/world.h | 73 |
7 files changed, 275 insertions, 7 deletions
diff --git a/engines/macventure/macventure.cpp b/engines/macventure/macventure.cpp index 5827ecc370..92ae709b5e 100644 --- a/engines/macventure/macventure.cpp +++ b/engines/macventure/macventure.cpp @@ -37,12 +37,6 @@ enum { kMaxMenuTitleLength = 30 }; -enum { - kGlobalSettingsID = 0x80, - kDiplomaGeometryID = 0x81, - kTextHuffmanTableID = 0x83 -}; - MacVentureEngine::MacVentureEngine(OSystem *syst, const ADGameDescription *gameDesc) : Engine(syst) { _gameDescription = gameDesc; _rnd = new Common::RandomSource("macventure"); @@ -79,6 +73,7 @@ Common::Error MacVentureEngine::run() { error("Could not load the engine settings"); _gui = new Gui(this, _resourceManager); + _world = new World(this, _resourceManager); _shouldQuit = false; while (!_shouldQuit) { diff --git a/engines/macventure/macventure.h b/engines/macventure/macventure.h index da1f66a277..3a20bbe2a8 100644 --- a/engines/macventure/macventure.h +++ b/engines/macventure/macventure.h @@ -31,12 +31,14 @@ #include "gui/debugger.h" #include "macventure/gui.h" +#include "macventure/world.h" struct ADGameDescription; namespace MacVenture { class Console; +class World; enum { kScreenWidth = 512, @@ -50,6 +52,19 @@ enum { // the current limitation is 32 debug levels (1 << 31 is the last one) }; +enum { + kGlobalSettingsID = 0x80, + kDiplomaGeometryID = 0x81, + kTextHuffmanTableID = 0x83 +}; + +enum { + kSaveGameStrID = 0x82, + kDiplomaFilenameID = 0x83, + kClickToContinueTextID = 0x84, + kStartGameFilenameID = 0x85 +}; + struct GlobalSettings { uint16 numObjects; // number of game objects defined uint16 numGlobals; // number of globals defined @@ -102,6 +117,7 @@ private: // Attributes Console *_debugger; Gui *_gui; + World *_world; // Engine state GlobalSettings _globalSettings; diff --git a/engines/macventure/module.mk b/engines/macventure/module.mk index 3f11d15856..2fac1b5347 100644 --- a/engines/macventure/module.mk +++ b/engines/macventure/module.mk @@ -3,7 +3,9 @@ MODULE := engines/macventure MODULE_OBJS := \ detection.o \ gui.o \ - macventure.o + object.o \ + macventure.o \ + world.o \ MODULE_DIRS += \ engines/macventure diff --git a/engines/macventure/object.cpp b/engines/macventure/object.cpp new file mode 100644 index 0000000000..18a734ccd1 --- /dev/null +++ b/engines/macventure/object.cpp @@ -0,0 +1,30 @@ +/* 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 "macventure/object.h" + +namespace MacVenture { + +Object::Object() {} +Object::~Object() {} + +} // End of namespace MacVenture
\ No newline at end of file diff --git a/engines/macventure/object.h b/engines/macventure/object.h new file mode 100644 index 0000000000..ebd64ad14f --- /dev/null +++ b/engines/macventure/object.h @@ -0,0 +1,54 @@ +/* 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 MACVENTURE_OBJECT_H +#define MACVENTURE_OBJECT_H + +#include "macventure/macventure.h" + +namespace MacVenture { + +struct ContainerHeader { + uint32 header; +}; + +struct ObjectGroup { + uint32 bitOffset; // Actually uint24, but we don't have that + uint32 offset; +}; + +struct ContainerSubHeader { + uint16 numObjects; + uint16 *huff; + uint8 *lengths; + ObjectGroup *groups; +}; + +class Object { +public: + Object(); + ~Object(); +}; + +} // End of namespace MacVenture + +#endif
\ No newline at end of file diff --git a/engines/macventure/world.cpp b/engines/macventure/world.cpp new file mode 100644 index 0000000000..223541d152 --- /dev/null +++ b/engines/macventure/world.cpp @@ -0,0 +1,98 @@ +#include "macventure/world.h" + +#include "common/file.h" + +namespace MacVenture { + +World::World(MacVentureEngine *engine, Common::MacResManager *resMan) { + _resourceManager = resMan; + _engine = engine; + + if (!loadStartGameFileName()) + error("Could not load initial game configuration"); + + Common::File saveGameFile; + if (!saveGameFile.open(_startGameFileName)) + error("Could not load initial game configuration"); + + Common::SeekableReadStream *saveGameRes = saveGameFile.readStream(saveGameFile.size()); + + _saveGame = new SaveGame(_engine, saveGameRes); + + delete saveGameRes; + saveGameFile.close(); +} + + +World::~World() { + + if (_saveGame) + delete _saveGame; +} + +bool World::loadStartGameFileName() { + Common::SeekableReadStream *res; + + res = _resourceManager->getResource(MKTAG('S', 'T', 'R', ' '), kStartGameFilenameID); + if (!res) + return false; + + byte length = res->readByte(); + char *fileName = new char[length + 1]; + res->read(fileName, length); + fileName[length] = '\0'; + _startGameFileName = Common::String(fileName, length); + _startGameFileName.replace(_startGameFileName.end(), _startGameFileName.end(), ".TXT"); + + return true; +} + +// SaveGame +SaveGame::SaveGame(MacVentureEngine *engine, Common::SeekableReadStream *res) { + _groups = Common::Array<AttributeGroup>(); + loadGroups(engine, res); + _globals = Common::Array<uint16>(); + loadGlobals(engine, res); + _text = Common::String(); + loadText(engine, res); +} + +SaveGame::~SaveGame() { +} + +const Common::Array<AttributeGroup>& MacVenture::SaveGame::getGroups() { + return _groups; +} + +const Common::Array<uint16>& MacVenture::SaveGame::getGlobals() { + return _globals; +} + +const Common::String & MacVenture::SaveGame::getText() { + return _text; +} + +void SaveGame::loadGroups(MacVentureEngine *engine, Common::SeekableReadStream * res) { + GlobalSettings settings = engine->getGlobalSettings(); + for (int i = 0; i < settings.numGroups; ++i) { + AttributeGroup g; + for (int j = 0; j < settings.numObjects; ++j) + g.push_back(res->readUint16BE()); + + _groups.push_back(g); + } +} + +void SaveGame::loadGlobals(MacVentureEngine *engine, Common::SeekableReadStream * res) { + GlobalSettings settings = engine->getGlobalSettings(); + for (int i = 0; i < settings.numGlobals; ++i) { + _globals.push_back(res->readUint16BE()); + } +} + +void SaveGame::loadText(MacVentureEngine *engine, Common::SeekableReadStream * res) { + _text = "Placeholder Console Text"; +} + + +} // End of namespace MacVenture diff --git a/engines/macventure/world.h b/engines/macventure/world.h new file mode 100644 index 0000000000..0a7eb25526 --- /dev/null +++ b/engines/macventure/world.h @@ -0,0 +1,73 @@ +/* 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 MACVENTURE_WORLD_H +#define MACVENTURE_WORLD_H + +#include "macventure/macventure.h" + +namespace MacVenture { + +typedef Common::Array<uint16> AttributeGroup; + +class SaveGame { +public: + SaveGame(MacVentureEngine *engine, Common::SeekableReadStream *res); + ~SaveGame(); + + const Common::Array<AttributeGroup> &getGroups(); + const Common::Array<uint16> &getGlobals(); + const Common::String &getText(); + +private: + void loadGroups(MacVentureEngine *engine, Common::SeekableReadStream *res); + void loadGlobals(MacVentureEngine *engine, Common::SeekableReadStream *res); + void loadText(MacVentureEngine *engine, Common::SeekableReadStream *res); + +private: + Common::Array<AttributeGroup> _groups; + Common::Array<uint16> _globals; + Common::String _text; +}; + +class World { +public: + World(MacVentureEngine *engine, Common::MacResManager *resMan); + ~World(); + +private: + bool loadStartGameFileName(); + +private: + MacVentureEngine *_engine; + Common::MacResManager *_resourceManager; + + Common::String _startGameFileName; + + SaveGame *_saveGame; + +}; + +} // End of namespace MacVenture + +#endif + |