From c676bb99237a1d2eeb9965aae4fe78503cea9b46 Mon Sep 17 00:00:00 2001 From: Borja Lorente Date: Sun, 12 Jun 2016 23:08:24 +0200 Subject: [PATCH] MACVENTURE: Load general settings --- engines/macventure/macventure.cpp | 57 +++++++++++++++++++++++++++++-- engines/macventure/macventure.h | 28 ++++++++++++++- 2 files changed, 81 insertions(+), 4 deletions(-) diff --git a/engines/macventure/macventure.cpp b/engines/macventure/macventure.cpp index 19021278cb4..6e2d7edaab2 100644 --- a/engines/macventure/macventure.cpp +++ b/engines/macventure/macventure.cpp @@ -37,6 +37,12 @@ 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"); @@ -65,13 +71,13 @@ Common::Error MacVentureEngine::run() { // Additional setup. debug("MacVentureEngine::init"); - // Your main even loop should be (invoked from) here. - debug("MacVentureEngine::go: Hello, World!"); - _resourceManager = new Common::MacResManager(); if (!_resourceManager->open(getGameFileName())) error("Could not open %s as a resource fork", getGameFileName()); + if (!loadGlobalSettings()) + error("Could not load the engine settings"); + _gui = new Gui(this, _resourceManager); _shouldQuit = false; @@ -87,6 +93,51 @@ Common::Error MacVentureEngine::run() { return Common::kNoError; } +bool MacVentureEngine::loadGlobalSettings() { + Common::MacResIDArray resArray; + Common::SeekableReadStream *res; + + if ((resArray = _resourceManager->getResIDArray(MKTAG('G', 'N', 'R', 'L'))).size() == 0) + return false; + + res = _resourceManager->getResource(MKTAG('G', 'N', 'R', 'L'), kGlobalSettingsID); + if (res) { + _globalSettings.numObjects = res->readUint16BE(); + _globalSettings.numGlobals = res->readUint16BE(); + _globalSettings.numCommands = res->readUint16BE(); + _globalSettings.numAttributes = res->readUint16BE(); + _globalSettings.numGroups = res->readUint16BE(); + res->readUint16BE(); // unknown + _globalSettings.invTop = res->readUint16BE(); + _globalSettings.invLeft = res->readUint16BE(); + _globalSettings.invWidth = res->readUint16BE(); + _globalSettings.invHeight = res->readUint16BE(); + _globalSettings.invOffsetY = res->readUint16BE(); + _globalSettings.invOffsetX = res->readSint16BE(); + _globalSettings.defaultFont = res->readUint16BE(); + _globalSettings.defaultSize = res->readUint16BE(); + + _globalSettings.attrIndices = new uint8[_globalSettings.numAttributes]; + res->read(_globalSettings.attrIndices, _globalSettings.numAttributes); + + _globalSettings.attrMasks = new uint16[_globalSettings.numAttributes]; + for (int i = 0; i < _globalSettings.numAttributes; i++) + _globalSettings.attrMasks[i] = res->readUint16BE(); + + _globalSettings.attrShifts = new uint8[_globalSettings.numAttributes]; + res->read(_globalSettings.attrShifts, _globalSettings.numAttributes); + + _globalSettings.cmdArgCnts = new uint8[_globalSettings.numCommands]; + res->read(_globalSettings.cmdArgCnts, _globalSettings.numCommands); + + + + return true; + } + + return false; +} + void MacVentureEngine::requestQuit() { _shouldQuit = true; } diff --git a/engines/macventure/macventure.h b/engines/macventure/macventure.h index b8d065b8769..ffc1c2a9f2b 100644 --- a/engines/macventure/macventure.h +++ b/engines/macventure/macventure.h @@ -50,6 +50,27 @@ enum { // the current limitation is 32 debug levels (1 << 31 is the last one) }; +struct GlobalSettings { + uint16 numObjects; // number of game objects defined + uint16 numGlobals; // number of globals defined + uint16 numCommands; // number of commands defined + uint16 numAttributes; // number of attributes + uint16 numGroups; // number of object groups + uint16 invTop; // inventory window bounds + uint16 invLeft; + uint16 invHeight; + uint16 invWidth; + uint16 invOffsetY; // positioning offset for + uint16 invOffsetX; // new inventory windows + uint16 defaultFont; // default font + uint16 defaultSize; // default font size + uint8 *attrIndices; // attribute indices into attribute table + uint16 *attrMasks; // attribute masks + uint8 *attrShifts; // attribute bit shifts + uint8 *cmdArgCnts; // command argument counts + uint8 *commands; // command buttons +}; + class MacVentureEngine : public Engine { public: @@ -61,6 +82,9 @@ public: void requestQuit(); void requestUnpause(); + // Data loading + bool loadGlobalSettings(); + // Data retrieval bool isPaused(); Common::String getCommandsPausedString(); @@ -76,10 +100,12 @@ private: // Attributes Common::MacResManager *_resourceManager; Console *_debugger; - Gui *_gui; + // Engine state + GlobalSettings _globalSettings; bool _shouldQuit; + bool _paused; private: // Methods