diff options
-rw-r--r-- | engines/voyeur/files.cpp | 143 | ||||
-rw-r--r-- | engines/voyeur/files.h | 105 | ||||
-rw-r--r-- | engines/voyeur/graphics.cpp | 27 | ||||
-rw-r--r-- | engines/voyeur/graphics.h | 38 | ||||
-rw-r--r-- | engines/voyeur/module.mk | 3 | ||||
-rw-r--r-- | engines/voyeur/voyeur.cpp | 18 | ||||
-rw-r--r-- | engines/voyeur/voyeur.h | 8 |
7 files changed, 340 insertions, 2 deletions
diff --git a/engines/voyeur/files.cpp b/engines/voyeur/files.cpp new file mode 100644 index 0000000000..4480f48f18 --- /dev/null +++ b/engines/voyeur/files.cpp @@ -0,0 +1,143 @@ +/* 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 "voyeur/files.h" + +namespace Voyeur { + +FilesManager::FilesManager() { + _decompressSize = 0x7000; +} + +bool FilesManager::openBOLTLib(const Common::String &filename, BoltFile *&boltFile) { + if (boltFile != NULL) { + _curLibPtr = boltFile; + return true; + } + + // TODO: Specific library classes for buoy.blt versus stampblt.blt + // Create the bolt file interface object and load the index + boltFile = _curLibPtr = new BoltFile(); + return true; +} + +/*------------------------------------------------------------------------*/ + +#define BOLT_GROUP_SIZE 16 + +BoltFile *BoltFile::_curLibPtr = NULL; +BoltGroup *BoltFile::_curGroupPtr = NULL; +byte *BoltFile::_curMemInfoPtr = NULL; +int BoltFile::_fromGroupFlag = 0; + +BoltFile::BoltFile() { + if (!_curFd.open("buoy.blt")) + error("Could not open buoy.blt"); + _curFilePosition = 0; + + // Read in the file header + byte header[16]; + _curFd.read(&header[0], 16); + + if (strncmp((const char *)&header[0], "BOLT", 4) != 0) + error("Tried to load non-bolt file"); + + int totalGroups = header[11] ? header[11] : 0x100; + for (int i = 0; i < totalGroups; ++i) + _groups.push_back(BoltGroup(_curFd.readStream(_curFd.size()))); +} + +BoltFile::~BoltFile() { + _curFd.close(); +} + +bool BoltFile::getBoltGroup(uint32 id) { + ++_fromGroupFlag; + _curLibPtr = this; + _curGroupPtr = &_groups[(id >> 8) & 0xff]; + int count = _curGroupPtr->_count ? _curGroupPtr->_count : 256; + + if (_curGroupPtr->_groupPtr) { + // Group already loaded + _curMemInfoPtr = _curGroupPtr->_groupPtr; + } else { + // Load the group + _curGroupPtr->load(); + } + + if (_curGroupPtr->_callInitGro) + initGro(); + + if ((id >> 16) == 0) { + if (!_curGroupPtr->_loaded) { + _curGroupPtr->load(); + } else { + id &= 0xff00; + for (int idx = 0; idx < count; ++idx, ++id) { + byte *member = getBoltMember(id); + assert(member); + } + } + } + + resolveAll(); + --_fromGroupFlag; + return true; +} + +/*------------------------------------------------------------------------*/ + +BoltGroup::BoltGroup(Common::SeekableReadStream *f): _file(f) { + byte buffer[BOLT_GROUP_SIZE]; + + _groupPtr = NULL; + + _file->read(&buffer[0], BOLT_GROUP_SIZE); + _loaded = false; + _callInitGro = buffer[1] != 0; + _count = buffer[3]; + _fileOffset = READ_LE_UINT32(&buffer[8]); +} + +void BoltGroup::load() { + _file->seek(_fileOffset); + + byte header[4]; + _file->read(&header[0], 4); + + // Read the entries + int count = _count ? _count : 256; + for (int i = 0; i < count; ++i) + _entries.push_back(BoltEntry(_file)); +} + +/*------------------------------------------------------------------------*/ + +BoltEntry::BoltEntry(Common::SeekableReadStream *f): _file(f) { + +} + +void BoltEntry::load() { + +} + +} // End of namespace Voyeur diff --git a/engines/voyeur/files.h b/engines/voyeur/files.h new file mode 100644 index 0000000000..1db1fdf4b0 --- /dev/null +++ b/engines/voyeur/files.h @@ -0,0 +1,105 @@ +/* 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 VOYEUR_FILES_H +#define VOYEUR_FILES_H + +#include "common/scummsys.h" +#include "common/file.h" +#include "common/str.h" + +namespace Voyeur { + +class VoyeurEngine; +class BoltGroup; +class BoltEntry; + +class BoltFile { +private: + static BoltFile *_curLibPtr; + static BoltGroup *_curGroupPtr; + static byte *_curMemInfoPtr; + static int _fromGroupFlag; +private: + Common::File _curFd; + int _curFilePosition; + Common::Array<BoltGroup> _groups; +private: + bool getBoltGroup(uint32 id); + void resolveAll() {} + byte *getBoltMember(uint32 id) { return NULL; } +public: + BoltFile(); + ~BoltFile(); + + // Methods copied into bolt virtual table + void initType() {} + void termType() {} + void initMem() {} + void termMem() {} + void initGro() {} + void termGro() {} +}; + +class BoltGroup { +private: + Common::SeekableReadStream *_file; +public: + bool _loaded; + bool _callInitGro; + int _count; + int _fileOffset; + byte *_groupPtr; + Common::Array<BoltEntry> _entries; +public: + BoltGroup(Common::SeekableReadStream *f); + + void load(); +}; + + +class BoltEntry { +private: + Common::SeekableReadStream *_file; +public: + int _fileOffset; +public: + BoltEntry(Common::SeekableReadStream *f); + + void load(); +}; + +class FilesManager { +private: + int _decompressSize; +public: + BoltFile *_curLibPtr; +public: + FilesManager(); + + bool openBOLTLib(const Common::String &filename, BoltFile *&boltFile); + +}; + +} // End of namespace Voyeur + +#endif /* VOYEUR_VOYEUR_H */ diff --git a/engines/voyeur/graphics.cpp b/engines/voyeur/graphics.cpp new file mode 100644 index 0000000000..008b014be1 --- /dev/null +++ b/engines/voyeur/graphics.cpp @@ -0,0 +1,27 @@ +/* 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 "voyeur/graphics.h" + +namespace Voyeur { + +} // End of namespace Voyeur diff --git a/engines/voyeur/graphics.h b/engines/voyeur/graphics.h new file mode 100644 index 0000000000..f1b568e064 --- /dev/null +++ b/engines/voyeur/graphics.h @@ -0,0 +1,38 @@ +/* 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 VOYEUR_GRAPHICS_H +#define VOYEUR_GRAPHICS_H + +#include "common/scummsys.h" +#include "graphics/surface.h" + +namespace Voyeur { + +class GraphicsManager { +public: + GraphicsManager() {} +}; + +} // End of namespace Voyeur + +#endif /* VOYEUR_VOYEUR_H */ diff --git a/engines/voyeur/module.mk b/engines/voyeur/module.mk index c4dad92c37..24984cd8d3 100644 --- a/engines/voyeur/module.mk +++ b/engines/voyeur/module.mk @@ -2,6 +2,9 @@ MODULE := engines/voyeur MODULE_OBJS := \ detection.o \ + events.o \ + files.o \ + graphics.o \ voyeur.o # This module can be built as a plugin diff --git a/engines/voyeur/voyeur.cpp b/engines/voyeur/voyeur.cpp index 580bacbd6f..dc3fcb221a 100644 --- a/engines/voyeur/voyeur.cpp +++ b/engines/voyeur/voyeur.cpp @@ -32,9 +32,11 @@ VoyeurEngine *g_vm; VoyeurEngine::VoyeurEngine(OSystem *syst, const VoyeurGameDescription *gameDesc) : Engine(syst), _gameDescription(gameDesc), _randomSource("Voyeur") { DebugMan.addDebugChannel(kDebugPath, "Path", "Pathfinding debug level"); + _bVoyBoltFile = NULL; } VoyeurEngine::~VoyeurEngine() { + delete _bVoyBoltFile; } Common::String VoyeurEngine::generateSaveName(int slot) { @@ -73,17 +75,29 @@ Common::Error VoyeurEngine::saveGameState(int slot, const Common::String &desc) Common::Error VoyeurEngine::run() { ESP_Init(); + globalInitBolt(); + _eventManager.resetMouse(); + + //doHeadTitle(); + return Common::kNoError; } + int VoyeurEngine::getRandomNumber(int maxNumber) { return _randomSource.getRandomNumber(maxNumber); } -void VoyeurEngine::ESP_Init() { +void VoyeurEngine::initialiseManagers() { _eventManager.setVm(this); +} + +void VoyeurEngine::ESP_Init() { +} + +void VoyeurEngine::globalInitBolt() { + _filesManager.openBOLTLib("buoy.blt", _bVoyBoltFile); - _eventManager.resetMouse(); } diff --git a/engines/voyeur/voyeur.h b/engines/voyeur/voyeur.h index 627f7d8108..8b5eb75ba0 100644 --- a/engines/voyeur/voyeur.h +++ b/engines/voyeur/voyeur.h @@ -24,6 +24,8 @@ #define VOYEUR_VOYEUR_H #include "voyeur/events.h" +#include "voyeur/files.h" +#include "voyeur/graphics.h" #include "common/scummsys.h" #include "common/system.h" #include "common/error.h" @@ -60,8 +62,14 @@ private: const VoyeurGameDescription *_gameDescription; Common::RandomSource _randomSource; EventManager _eventManager; + FilesManager _filesManager; + GraphicsManager _graphicsManager; + + BoltFile *_bVoyBoltFile; void ESP_Init(); + void initialiseManagers(); + void globalInitBolt(); protected: // Engine APIs virtual Common::Error run(); |