MACVENTURE: Add save game loading
This commit is contained in:
parent
9564866ec3
commit
5719ea3076
7 changed files with 275 additions and 7 deletions
|
@ -37,12 +37,6 @@ enum {
|
||||||
kMaxMenuTitleLength = 30
|
kMaxMenuTitleLength = 30
|
||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
|
||||||
kGlobalSettingsID = 0x80,
|
|
||||||
kDiplomaGeometryID = 0x81,
|
|
||||||
kTextHuffmanTableID = 0x83
|
|
||||||
};
|
|
||||||
|
|
||||||
MacVentureEngine::MacVentureEngine(OSystem *syst, const ADGameDescription *gameDesc) : Engine(syst) {
|
MacVentureEngine::MacVentureEngine(OSystem *syst, const ADGameDescription *gameDesc) : Engine(syst) {
|
||||||
_gameDescription = gameDesc;
|
_gameDescription = gameDesc;
|
||||||
_rnd = new Common::RandomSource("macventure");
|
_rnd = new Common::RandomSource("macventure");
|
||||||
|
@ -79,6 +73,7 @@ Common::Error MacVentureEngine::run() {
|
||||||
error("Could not load the engine settings");
|
error("Could not load the engine settings");
|
||||||
|
|
||||||
_gui = new Gui(this, _resourceManager);
|
_gui = new Gui(this, _resourceManager);
|
||||||
|
_world = new World(this, _resourceManager);
|
||||||
|
|
||||||
_shouldQuit = false;
|
_shouldQuit = false;
|
||||||
while (!_shouldQuit) {
|
while (!_shouldQuit) {
|
||||||
|
|
|
@ -31,12 +31,14 @@
|
||||||
#include "gui/debugger.h"
|
#include "gui/debugger.h"
|
||||||
|
|
||||||
#include "macventure/gui.h"
|
#include "macventure/gui.h"
|
||||||
|
#include "macventure/world.h"
|
||||||
|
|
||||||
struct ADGameDescription;
|
struct ADGameDescription;
|
||||||
|
|
||||||
namespace MacVenture {
|
namespace MacVenture {
|
||||||
|
|
||||||
class Console;
|
class Console;
|
||||||
|
class World;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
kScreenWidth = 512,
|
kScreenWidth = 512,
|
||||||
|
@ -50,6 +52,19 @@ enum {
|
||||||
// the current limitation is 32 debug levels (1 << 31 is the last one)
|
// 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 {
|
struct GlobalSettings {
|
||||||
uint16 numObjects; // number of game objects defined
|
uint16 numObjects; // number of game objects defined
|
||||||
uint16 numGlobals; // number of globals defined
|
uint16 numGlobals; // number of globals defined
|
||||||
|
@ -102,6 +117,7 @@ private: // Attributes
|
||||||
|
|
||||||
Console *_debugger;
|
Console *_debugger;
|
||||||
Gui *_gui;
|
Gui *_gui;
|
||||||
|
World *_world;
|
||||||
|
|
||||||
// Engine state
|
// Engine state
|
||||||
GlobalSettings _globalSettings;
|
GlobalSettings _globalSettings;
|
||||||
|
|
|
@ -3,7 +3,9 @@ MODULE := engines/macventure
|
||||||
MODULE_OBJS := \
|
MODULE_OBJS := \
|
||||||
detection.o \
|
detection.o \
|
||||||
gui.o \
|
gui.o \
|
||||||
macventure.o
|
object.o \
|
||||||
|
macventure.o \
|
||||||
|
world.o \
|
||||||
|
|
||||||
MODULE_DIRS += \
|
MODULE_DIRS += \
|
||||||
engines/macventure
|
engines/macventure
|
||||||
|
|
30
engines/macventure/object.cpp
Normal file
30
engines/macventure/object.cpp
Normal file
|
@ -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
|
54
engines/macventure/object.h
Normal file
54
engines/macventure/object.h
Normal file
|
@ -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
|
98
engines/macventure/world.cpp
Normal file
98
engines/macventure/world.cpp
Normal file
|
@ -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
|
73
engines/macventure/world.h
Normal file
73
engines/macventure/world.h
Normal file
|
@ -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
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue