diff options
-rw-r--r-- | engines/macventure/macventure.cpp | 14 | ||||
-rw-r--r-- | engines/macventure/macventure.h | 10 | ||||
-rw-r--r-- | engines/macventure/world.cpp | 21 | ||||
-rw-r--r-- | engines/macventure/world.h | 3 |
4 files changed, 42 insertions, 6 deletions
diff --git a/engines/macventure/macventure.cpp b/engines/macventure/macventure.cpp index 0e3e5a5e5b..383832b80e 100644 --- a/engines/macventure/macventure.cpp +++ b/engines/macventure/macventure.cpp @@ -88,9 +88,9 @@ Common::Error MacVentureEngine::run() { _world = new World(this, _resourceManager); _shouldQuit = false; - while (!_shouldQuit) { + while (!(_gameState == kGameStateQuitting)) { processEvents(); - + _gui->draw(); g_system->updateScreen(); @@ -102,10 +102,12 @@ Common::Error MacVentureEngine::run() { void MacVentureEngine::requestQuit() { _shouldQuit = true; + _gameState = kGameStateQuitting; } void MacVentureEngine::requestUnpause() { _paused = false; + _gameState = kGameStatePlaying; } const GlobalSettings& MacVentureEngine::getGlobalSettings() const { @@ -130,8 +132,8 @@ void MacVentureEngine::processEvents() { continue; switch (event.type) { - case Common::EVENT_QUIT: - _shouldQuit = true; + case Common::EVENT_QUIT: + _gameState = kGameStateQuitting; break; default: break; @@ -222,10 +224,12 @@ bool MacVentureEngine::loadTextHuffman() { values[i] = res->readByte(); _textHuffman = new Common::Huffman(0, numEntries, masks, lengths, values); - + debug(5, "Text is huffman-encoded"); return true; } return false; } + + } // End of namespace MacVenture diff --git a/engines/macventure/macventure.h b/engines/macventure/macventure.h index 8e11612870..e4cda4e11b 100644 --- a/engines/macventure/macventure.h +++ b/engines/macventure/macventure.h @@ -100,6 +100,15 @@ struct GlobalSettings { uint8 *commands; // command buttons }; +enum GameState { + kGameStateInit, + kGameStatePlaying, + kGameStateWinnig, + kGameStateLosing, + kGameStateQuitting +}; + + class MacVentureEngine : public Engine { public: @@ -136,6 +145,7 @@ private: // Attributes World *_world; // Engine state + GameState _gameState; GlobalSettings _globalSettings; StringTable *_filenames; Common::Huffman *_textHuffman; diff --git a/engines/macventure/world.cpp b/engines/macventure/world.cpp index cdc0e1682e..209b3c1096 100644 --- a/engines/macventure/world.cpp +++ b/engines/macventure/world.cpp @@ -19,6 +19,9 @@ World::World(MacVentureEngine *engine, Common::MacResManager *resMan) { _saveGame = new SaveGame(_engine, saveGameRes); + debug("%x", _saveGame->getGroups()[0][1]); + debug(11, "Parent of player is %d", getObjAttr(1, 0)); + _objectConstants = new Container(_engine->getFilePath(kObjectPathID).c_str()); delete saveGameRes; @@ -35,6 +38,24 @@ World::~World() { delete _objectConstants; } + +uint32 World::getObjAttr(uint32 objID, uint32 attrID) { + uint32 res; + uint32 index = _engine->getGlobalSettings().attrIndices[attrID]; + if (!(index & 0x80)) { // It's not a constant + res = _saveGame->getGroups()[attrID][objID]; + } else { + Common::SeekableReadStream *objStream = _objectConstants->getItem(objID); + index &= 0x7F; + objStream->skip((index * 2) - 1); + res = objStream->readUint16BE(); + } + res &= _engine->getGlobalSettings().attrMasks[attrID]; + res >>= _engine->getGlobalSettings().attrShifts[attrID]; + debug(11, "Attribute %x from object %x is %x", attrID, objID, res); + return res; +} + bool World::loadStartGameFileName() { Common::SeekableReadStream *res; diff --git a/engines/macventure/world.h b/engines/macventure/world.h index eed7b50363..9a74e5ce3e 100644 --- a/engines/macventure/world.h +++ b/engines/macventure/world.h @@ -55,6 +55,8 @@ public: World(MacVentureEngine *engine, Common::MacResManager *resMan); ~World(); + uint32 getObjAttr(uint32 objID, uint32 attrID); + private: bool loadStartGameFileName(); @@ -67,7 +69,6 @@ private: SaveGame *_saveGame; Container *_objectConstants; Container *_gameText; - }; } // End of namespace MacVenture |