From 8c9420a8349b0cdb93dcace36c2bd5f93e03476f Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 23 Feb 2014 19:33:26 -0500 Subject: MADS: Added game initialisation code --- engines/mads/scene.cpp | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 engines/mads/scene.cpp (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp new file mode 100644 index 0000000000..f6bbf32e40 --- /dev/null +++ b/engines/mads/scene.cpp @@ -0,0 +1,37 @@ +/* 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 "common/scummsys.h" +#include "mads/scene.h" + +namespace MADS { + +Scene::Scene() { + _sectionNum = 1; + _sectionNum2 = -1; + _priorSectionNum = 0; + _priorSceneId = 0; + _nextSceneId = 0; + _currentSceneId = 0; +} + +} // End of namespace MADS -- cgit v1.2.3 From 8ee283d921ec88bad61469e136a31aef0ff5b9ca Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 23 Feb 2014 21:34:20 -0500 Subject: MADS: Implemented sound player logic and outer game loop --- engines/mads/scene.cpp | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index f6bbf32e40..cf7ba6c674 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -34,4 +34,44 @@ Scene::Scene() { _currentSceneId = 0; } +void Scene::clearSprites(bool flag) { + for (int i = 0; i < TEXT_DISPLAY_COUNT; ++i) + _textDisplay[i]._active = false; + + if (flag) + _spriteList.clear(); + + _spriteSlots.clear(); + _spriteSlots.push_back(SpriteSlot(ST_FULL_SCREEN_REFRESH, -1)); +} + +/*------------------------------------------------------------------------*/ + +SpriteSlot::SpriteSlot() { + _spriteType = ST_NONE; + _seqIndex = 0; + _spriteListIndex = 0; + _frameNumber = 0; + _depth = 0; + _scale = 0; +} + +SpriteSlot::SpriteSlot(SpriteType type, int seqIndex) { + _spriteType = type; + _seqIndex = seqIndex; + _spriteListIndex = 0; + _frameNumber = 0; + _depth = 0; + _scale = 0; +} + +/*------------------------------------------------------------------------*/ + +TextDisplay::TextDisplay() { + _active = false; + _spacing = 0; + _expire = 0; + _col1 = _col2 = 0; +} + } // End of namespace MADS -- cgit v1.2.3 From 37b788b7ddb679f32653be326ae96ad9132feb1f Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 24 Feb 2014 00:20:53 -0500 Subject: MADS: Added skeleton framework for game scene classes --- engines/mads/scene.cpp | 105 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 103 insertions(+), 2 deletions(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index cf7ba6c674..46190d12be 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -22,16 +22,26 @@ #include "common/scummsys.h" #include "mads/scene.h" +#include "mads/mads.h" +#include "mads/nebular/nebular_scenes.h" namespace MADS { -Scene::Scene() { +Scene::Scene(MADSEngine *vm): _vm(vm) { _sectionNum = 1; - _sectionNum2 = -1; + _sectionNumPrior = -1; _priorSectionNum = 0; _priorSceneId = 0; _nextSceneId = 0; _currentSceneId = 0; + _vocabCount = 0; + _vocabBuffer = nullptr; + _sceneLogic = nullptr; +} + +Scene::~Scene() { + delete[] _vocabBuffer; + delete _sceneLogic; } void Scene::clearSprites(bool flag) { @@ -45,6 +55,86 @@ void Scene::clearSprites(bool flag) { _spriteSlots.push_back(SpriteSlot(ST_FULL_SCREEN_REFRESH, -1)); } +/** + * Releases any sprites used by the player + */ +void Scene::releasePlayerSprites() { + Player &player = _vm->_game->player(); + + if (player._spritesLoaded && player._numSprites > 0) { + int spriteEnd = player._spriteListStart + player._numSprites - 1; + do { + deleteSpriteEntry(spriteEnd); + } while (--spriteEnd >= player._spriteListStart); + } +} + +void Scene::deleteSpriteEntry(int listIndex) { + delete _spriteList[listIndex]; + _spriteList.remove_at(listIndex); +} + +void Scene::clearDynamicHotspots() { + _dynamicHotspots.clear(); + _dynamicHotspotsChanged = false; +} + +void Scene::clearVocab() { + freeVocab(); + _vocabCount = 0; +} + +void Scene::freeVocab() { + delete[] _vocabBuffer; + _vocabBuffer = nullptr; +} + +void Scene::addActiveVocab(int vocabId) { + if (activeVocabIndexOf(vocabId) == -1) { + assert(_activeVocabs.size() < 200); + _activeVocabs.push_back(vocabId); + } +} + +int Scene::activeVocabIndexOf(int vocabId) { + for (uint i = 0; i < _activeVocabs.size(); ++i) { + if (_activeVocabs[i] == vocabId) + return i; + } + + return -1; +} + +void Scene::addVisitedScene(int sceneId) { + if (!visitedScenesExists(sceneId)) + _visitedScenes.push_back(sceneId); +} + +bool Scene::visitedScenesExists(int sceneId) { + for (int i = 0; i < _visitedScenes.size(); ++i) { + if (_visitedScenes[i] == sceneId) + return true; + } + + return false; +} + +void Scene::loadScene() { + delete _sceneLogic; + + switch (_vm->getGameID()) { + case GType_RexNebular: + _sceneLogic = Nebular::SceneFactory::createScene(this); + break; + default: + error("Unknown game"); + } +} + +void Scene::free() { + warning("TODO: Scene::free"); +} + /*------------------------------------------------------------------------*/ SpriteSlot::SpriteSlot() { @@ -74,4 +164,15 @@ TextDisplay::TextDisplay() { _col1 = _col2 = 0; } +/*------------------------------------------------------------------------*/ + +DynamicHotspot::DynamicHotspot() { + _seqIndex = 0; + _facing = 0; + _descId = 0; + _field14 = 0; + _articleNumber = 0; + _cursor = 0; +} + } // End of namespace MADS -- cgit v1.2.3 From 4c867aa62fea19f2bff7d3aa632b340aae110306 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 24 Feb 2014 00:38:49 -0500 Subject: MADS: Shift some fields and methods to Dialogs and Game classes --- engines/mads/scene.cpp | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index 46190d12be..406c3cc616 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -34,7 +34,6 @@ Scene::Scene(MADSEngine *vm): _vm(vm) { _priorSceneId = 0; _nextSceneId = 0; _currentSceneId = 0; - _vocabCount = 0; _vocabBuffer = nullptr; _sceneLogic = nullptr; } @@ -81,7 +80,7 @@ void Scene::clearDynamicHotspots() { void Scene::clearVocab() { freeVocab(); - _vocabCount = 0; + _activeVocabs.clear(); } void Scene::freeVocab() { @@ -105,20 +104,6 @@ int Scene::activeVocabIndexOf(int vocabId) { return -1; } -void Scene::addVisitedScene(int sceneId) { - if (!visitedScenesExists(sceneId)) - _visitedScenes.push_back(sceneId); -} - -bool Scene::visitedScenesExists(int sceneId) { - for (int i = 0; i < _visitedScenes.size(); ++i) { - if (_visitedScenes[i] == sceneId) - return true; - } - - return false; -} - void Scene::loadScene() { delete _sceneLogic; -- cgit v1.2.3 From cc16e42f2029955e066450d63bfb666b9ab47109 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 24 Feb 2014 20:05:35 -0500 Subject: MADS: Beginnings of scene-specific data loading --- engines/mads/scene.cpp | 113 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 112 insertions(+), 1 deletion(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index 406c3cc616..19071d1352 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -36,6 +36,17 @@ Scene::Scene(MADSEngine *vm): _vm(vm) { _currentSceneId = 0; _vocabBuffer = nullptr; _sceneLogic = nullptr; + + _verbList.push_back(VerbInit(VERB_LOOK, 2, 0)); + _verbList.push_back(VerbInit(VERB_TAKE, 2, 0)); + _verbList.push_back(VerbInit(VERB_PUSH, 2, 0)); + _verbList.push_back(VerbInit(VERB_OPEN, 2, 0)); + _verbList.push_back(VerbInit(VERB_PUT, 1, -1)); + _verbList.push_back(VerbInit(VERB_TALKTO, 2, 0)); + _verbList.push_back(VerbInit(VERB_GIVE, 1, 2)); + _verbList.push_back(VerbInit(VERB_PULL, 2, 0)); + _verbList.push_back(VerbInit(VERB_CLOSE, 2, 0)); + _verbList.push_back(VerbInit(VERB_THROW, 1, 2)); } Scene::~Scene() { @@ -104,7 +115,17 @@ int Scene::activeVocabIndexOf(int vocabId) { return -1; } -void Scene::loadScene() { +void Scene::clearSequenceList() { + _sequenceList.clear(); +} + +void Scene::clearMessageList() { + _messageList.clear(); + _talkFont = "*FONTCONV.FF"; + _textSpacing = -1; +} + +void Scene::loadSceneLogic() { delete _sceneLogic; switch (_vm->getGameID()) { @@ -116,6 +137,31 @@ void Scene::loadScene() { } } +void Scene::loadHotspots() { + File f(Resources::formatName(RESPREFIX_RM, _currentSceneId, ".HH")); + int count = f.readUint16LE(); + + _hotspotList.clear(); + for (int i = 0; i < count; ++i) + _hotspotList.push_back(Hotspot(f)); +} + +void Scene::loadVocab() { + // Add all the verbs to the active vocab list + for (uint i = 0; i < _verbList.size(); ++i) + addActiveVocab(_verbList[i]._id); + + // Load the vocabs for any object descriptions and custom actions + for (uint objIndex = 0; objIndex < _vm->_game->_objects.size(); ++objIndex) { + InventoryObject &io = _vm->_game->_objects[objIndex]; + addActiveVocab(io._descId); + + if (io._vocabCount > 0) { + // TODO + } + } +} + void Scene::free() { warning("TODO: Scene::free"); } @@ -160,4 +206,69 @@ DynamicHotspot::DynamicHotspot() { _cursor = 0; } +/*------------------------------------------------------------------------*/ + +SequenceEntry::SequenceEntry() { + _spriteListIndex = 0; + _flipped =0; + _frameIndex = 0; + _frameStart = 0; + _numSprites = 0; + _animType = 0; + _frameInc = 0; + _depth = 0; + _scale = 0; + _dynamicHotspotIndex = -1; + _triggerCountdown = 0; + _doneFlag = 0; + _entries._count = 0; + _abortMode = 0; + _actionNouns[0] = _actionNouns[1] = _actionNouns[2] = 0; + _numTicks = 0; + _extraTicks = 0; + _timeout = 0; +} + +KernelMessage::KernelMessage() { + _flags = 0; + _seqInex = 0; + _asciiChar = '\0'; + _asciiChar2 = '\0'; + _colors = 0; + Common::Point _posiition; + _msgOffset = 0; + _numTicks = 0; + _frameTimer2 = 0; + _frameTimer = 0; + _timeout = 0; + _field1C = 0; + _abortMode = 0; + _nounList[0] = _nounList[1] = _nounList[2] = 0; +} + +/*------------------------------------------------------------------------*/ + +Hotspot::Hotspot() { + _facing = 0; + _articleNumber = 0; + _cursor = 0; + _vocabId = 0; + _verbId = 0; +} + +Hotspot::Hotspot(Common::SeekableReadStream &f) { + _bounds.left = f.readSint16LE(); + _bounds.top = f.readSint16LE(); + _bounds.right = f.readSint16LE(); + _bounds.bottom = f.readSint16LE(); + _feetPos.x = f.readSint16LE(); + _feetPos.y = f.readSint16LE(); + _facing = f.readByte(); + _articleNumber = f.readByte(); + f.skip(1); + _cursor = f.readByte(); + _vocabId = f.readUint16LE(); + _verbId = f.readUint16LE(); +} + } // End of namespace MADS -- cgit v1.2.3 From c9057bd6a8ee2b039e2ba528b1e2e59814b8ef88 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 25 Feb 2014 09:21:19 -0500 Subject: MADS: Moved scene data classes into their own code file --- engines/mads/scene.cpp | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index 19071d1352..09e965bac3 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -28,9 +28,6 @@ namespace MADS { Scene::Scene(MADSEngine *vm): _vm(vm) { - _sectionNum = 1; - _sectionNumPrior = -1; - _priorSectionNum = 0; _priorSceneId = 0; _nextSceneId = 0; _currentSceneId = 0; @@ -47,6 +44,7 @@ Scene::Scene(MADSEngine *vm): _vm(vm) { _verbList.push_back(VerbInit(VERB_PULL, 2, 0)); _verbList.push_back(VerbInit(VERB_CLOSE, 2, 0)); _verbList.push_back(VerbInit(VERB_THROW, 1, 2)); + Common::fill((byte *)&_nullPalette[0], (byte *)&_nullPalette[3], 0); } Scene::~Scene() { @@ -156,16 +154,43 @@ void Scene::loadVocab() { InventoryObject &io = _vm->_game->_objects[objIndex]; addActiveVocab(io._descId); - if (io._vocabCount > 0) { - // TODO + for (int vocabIndex = 0; vocabIndex _game->player(); - - if (player._spritesLoaded && player._numSprites > 0) { - int spriteEnd = player._spriteListStart + player._numSprites - 1; - do { - deleteSpriteEntry(spriteEnd); - } while (--spriteEnd >= player._spriteListStart); - } -} - -void Scene::deleteSpriteEntry(int listIndex) { - delete _spriteList[listIndex]; - _spriteList.remove_at(listIndex); -} - void Scene::clearDynamicHotspots() { _dynamicHotspots.clear(); _dynamicHotspotsChanged = false; @@ -135,6 +105,18 @@ void Scene::loadSceneLogic() { } } +void Scene::loadScene(int sceneId, const Common::String &prefix, bool palFlag) { + // Store the previously active scene number and set the new one + _priorSceneId = _currentSceneId; + _currentSceneId = sceneId; + + _v1 = 0; + if (palFlag) + _vm->_palette->resetGamePalette(18, 10); + + +} + void Scene::loadHotspots() { File f(Resources::formatName(RESPREFIX_RM, _currentSceneId, ".HH")); int count = f.readUint16LE(); @@ -177,9 +159,9 @@ void Scene::loadVocabStrings() { f.read(d, f.size()); - int vocabId = 1; +// int vocabId = 1; for (uint strIndex = 0; strIndex < _activeVocabs.size(); ++strIndex) { - + // TODO: Rest of this method } } @@ -191,109 +173,4 @@ void Scene::setPalette(RGB4 *p) { _scenePalette = p; } -/*------------------------------------------------------------------------*/ - -SpriteSlot::SpriteSlot() { - _spriteType = ST_NONE; - _seqIndex = 0; - _spriteListIndex = 0; - _frameNumber = 0; - _depth = 0; - _scale = 0; -} - -SpriteSlot::SpriteSlot(SpriteType type, int seqIndex) { - _spriteType = type; - _seqIndex = seqIndex; - _spriteListIndex = 0; - _frameNumber = 0; - _depth = 0; - _scale = 0; -} - -/*------------------------------------------------------------------------*/ - -TextDisplay::TextDisplay() { - _active = false; - _spacing = 0; - _expire = 0; - _col1 = _col2 = 0; -} - -/*------------------------------------------------------------------------*/ - -DynamicHotspot::DynamicHotspot() { - _seqIndex = 0; - _facing = 0; - _descId = 0; - _field14 = 0; - _articleNumber = 0; - _cursor = 0; -} - -/*------------------------------------------------------------------------*/ - -SequenceEntry::SequenceEntry() { - _spriteListIndex = 0; - _flipped =0; - _frameIndex = 0; - _frameStart = 0; - _numSprites = 0; - _animType = 0; - _frameInc = 0; - _depth = 0; - _scale = 0; - _dynamicHotspotIndex = -1; - _triggerCountdown = 0; - _doneFlag = 0; - _entries._count = 0; - _abortMode = 0; - _actionNouns[0] = _actionNouns[1] = _actionNouns[2] = 0; - _numTicks = 0; - _extraTicks = 0; - _timeout = 0; -} - -KernelMessage::KernelMessage() { - _flags = 0; - _seqInex = 0; - _asciiChar = '\0'; - _asciiChar2 = '\0'; - _colors = 0; - Common::Point _posiition; - _msgOffset = 0; - _numTicks = 0; - _frameTimer2 = 0; - _frameTimer = 0; - _timeout = 0; - _field1C = 0; - _abortMode = 0; - _nounList[0] = _nounList[1] = _nounList[2] = 0; -} - -/*------------------------------------------------------------------------*/ - -Hotspot::Hotspot() { - _facing = 0; - _articleNumber = 0; - _cursor = 0; - _vocabId = 0; - _verbId = 0; -} - -Hotspot::Hotspot(Common::SeekableReadStream &f) { - _bounds.left = f.readSint16LE(); - _bounds.top = f.readSint16LE(); - _bounds.right = f.readSint16LE(); - _bounds.bottom = f.readSint16LE(); - _feetPos.x = f.readSint16LE(); - _feetPos.y = f.readSint16LE(); - _facing = f.readByte(); - _articleNumber = f.readByte(); - f.skip(1); - _cursor = f.readByte(); - _vocabId = f.readUint16LE(); - _verbId = f.readUint16LE(); -} - } // End of namespace MADS -- cgit v1.2.3 From c49d7196fcabf18d9e97711f67b864808ca7848a Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 25 Feb 2014 23:10:51 -0500 Subject: MADS: In progress implementation of loadScene --- engines/mads/scene.cpp | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index 7bbb4e98ae..138cab500a 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -33,6 +33,8 @@ Scene::Scene(MADSEngine *vm): _vm(vm), _spriteSlots(vm) { _currentSceneId = 0; _vocabBuffer = nullptr; _sceneLogic = nullptr; + _sceneInfo = nullptr; + _scenePalette = nullptr; _verbList.push_back(VerbInit(VERB_LOOK, 2, 0)); _verbList.push_back(VerbInit(VERB_TAKE, 2, 0)); @@ -50,6 +52,7 @@ Scene::Scene(MADSEngine *vm): _vm(vm), _spriteSlots(vm) { Scene::~Scene() { delete[] _vocabBuffer; delete _sceneLogic; + delete _sceneInfo; } void Scene::clearDynamicHotspots() { @@ -84,11 +87,11 @@ int Scene::activeVocabIndexOf(int vocabId) { } void Scene::clearSequenceList() { - _sequenceList.clear(); + _sequences.clear(); } void Scene::clearMessageList() { - _messageList.clear(); + _messages.clear(); _talkFont = "*FONTCONV.FF"; _textSpacing = -1; } @@ -114,16 +117,22 @@ void Scene::loadScene(int sceneId, const Common::String &prefix, bool palFlag) { if (palFlag) _vm->_palette->resetGamePalette(18, 10); + _spriteSlots.clear(false); + _sequences.clear(); + _messages.clear(); + setPalette(_nullPalette); + _sceneInfo = SceneInfo::load(_vm, _currentSceneId, _v1, Common::String(), _vm->_game->_v2 ? 17 : 16, + _depthSurface, _backgroundSurface); } void Scene::loadHotspots() { File f(Resources::formatName(RESPREFIX_RM, _currentSceneId, ".HH")); int count = f.readUint16LE(); - _hotspotList.clear(); + _hotspots.clear(); for (int i = 0; i < count; ++i) - _hotspotList.push_back(Hotspot(f)); + _hotspots.push_back(Hotspot(f)); } void Scene::loadVocab() { @@ -142,10 +151,10 @@ void Scene::loadVocab() { } // Load scene hotspot list vocabs and verbs - for (uint i = 0; i < _hotspotList.size(); ++i) { - addActiveVocab(_hotspotList[i]._vocabId); - if (_hotspotList[i]._verbId) - addActiveVocab(_hotspotList[i]._verbId); + for (uint i = 0; i < _hotspots.size(); ++i) { + addActiveVocab(_hotspots[i]._vocabId); + if (_hotspots[i]._verbId) + addActiveVocab(_hotspots[i]._verbId); } loadVocabStrings(); @@ -170,7 +179,7 @@ void Scene::free() { } void Scene::setPalette(RGB4 *p) { - _scenePalette = p; +// _scenePalette = p; } } // End of namespace MADS -- cgit v1.2.3 From badb8d97444767b7d8fea0f877ac044249696a5f Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 28 Feb 2014 20:37:42 -0500 Subject: MADS: More work implementing scene info loading --- engines/mads/scene.cpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index 138cab500a..e9ae3e6ddd 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -34,7 +34,6 @@ Scene::Scene(MADSEngine *vm): _vm(vm), _spriteSlots(vm) { _vocabBuffer = nullptr; _sceneLogic = nullptr; _sceneInfo = nullptr; - _scenePalette = nullptr; _verbList.push_back(VerbInit(VERB_LOOK, 2, 0)); _verbList.push_back(VerbInit(VERB_TAKE, 2, 0)); @@ -46,7 +45,6 @@ Scene::Scene(MADSEngine *vm): _vm(vm), _spriteSlots(vm) { _verbList.push_back(VerbInit(VERB_PULL, 2, 0)); _verbList.push_back(VerbInit(VERB_CLOSE, 2, 0)); _verbList.push_back(VerbInit(VERB_THROW, 1, 2)); - Common::fill((byte *)&_nullPalette[0], (byte *)&_nullPalette[3], 0); } Scene::~Scene() { @@ -121,7 +119,7 @@ void Scene::loadScene(int sceneId, const Common::String &prefix, bool palFlag) { _sequences.clear(); _messages.clear(); - setPalette(_nullPalette); + // TODO: palletteUsage reset? setPalette(_nullPalette); _sceneInfo = SceneInfo::load(_vm, _currentSceneId, _v1, Common::String(), _vm->_game->_v2 ? 17 : 16, _depthSurface, _backgroundSurface); } @@ -178,8 +176,4 @@ void Scene::free() { warning("TODO: Scene::free"); } -void Scene::setPalette(RGB4 *p) { -// _scenePalette = p; -} - } // End of namespace MADS -- cgit v1.2.3 From 411a4054006be03c0c465b2707c5ef7c50eb87a1 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 1 Mar 2014 22:53:08 -0500 Subject: MADS: Further fixes for SceneInfo data loading --- engines/mads/scene.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index e9ae3e6ddd..c640ff8da1 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -120,7 +120,8 @@ void Scene::loadScene(int sceneId, const Common::String &prefix, bool palFlag) { _messages.clear(); // TODO: palletteUsage reset? setPalette(_nullPalette); - _sceneInfo = SceneInfo::load(_vm, _currentSceneId, _v1, Common::String(), _vm->_game->_v2 ? 17 : 16, + _sceneInfo = SceneInfo::init(_vm); + _sceneInfo->load(_currentSceneId, _v1, Common::String(), _vm->_game->_v2 ? 17 : 16, _depthSurface, _backgroundSurface); } -- cgit v1.2.3 From 4bd1217dafbc2c28b731bd58d4ebd7b0b16a712e Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 2 Mar 2014 10:49:20 -0500 Subject: MADS: Added loading for scene nodes and hotspost --- engines/mads/scene.cpp | 76 +++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 69 insertions(+), 7 deletions(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index c640ff8da1..af53710c34 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -22,6 +22,7 @@ #include "common/scummsys.h" #include "mads/scene.h" +#include "mads/compression.h" #include "mads/mads.h" #include "mads/nebular/nebular_scenes.h" @@ -34,6 +35,8 @@ Scene::Scene(MADSEngine *vm): _vm(vm), _spriteSlots(vm) { _vocabBuffer = nullptr; _sceneLogic = nullptr; _sceneInfo = nullptr; + _animFlag = false; + _animVal1 = 0; _verbList.push_back(VerbInit(VERB_LOOK, 2, 0)); _verbList.push_back(VerbInit(VERB_TAKE, 2, 0)); @@ -123,15 +126,46 @@ void Scene::loadScene(int sceneId, const Common::String &prefix, bool palFlag) { _sceneInfo = SceneInfo::init(_vm); _sceneInfo->load(_currentSceneId, _v1, Common::String(), _vm->_game->_v2 ? 17 : 16, _depthSurface, _backgroundSurface); + + // Initialise palette animation for the scene + initPaletteAnimation(_sceneInfo->_palAnimData, false); + + // Copy over nodes + _nodes.clear(); + for (uint i = 0; i < _sceneInfo->_nodes.size(); ++i) + _nodes.push_back(_sceneInfo->_nodes[i]); + + // Load hotspots + loadHotspots(); + + // Load vocab + loadVocab(); + + // Load palette usage + _vm->_palette->_paletteUsage.load(1, 0xF); + + // Load interface + int flags = _vm->_game->_v2 ? 0x4101 : 0x4100; + if (!_vm->_textWindowStill) + flags |= 0x200; + // TODO } void Scene::loadHotspots() { File f(Resources::formatName(RESPREFIX_RM, _currentSceneId, ".HH")); - int count = f.readUint16LE(); + MadsPack madsPack(&f); + + Common::SeekableReadStream *stream = madsPack.getItemStream(0); + int count = stream->readUint16LE(); + delete stream; + stream = madsPack.getItemStream(1); _hotspots.clear(); for (int i = 0; i < count; ++i) - _hotspots.push_back(Hotspot(f)); + _hotspots.push_back(Hotspot(*stream)); + + delete stream; + f.close(); } void Scene::loadVocab() { @@ -163,14 +197,42 @@ void Scene::loadVocabStrings() { freeVocab(); File f("*VOCAB.DAT"); - byte *d = new byte[ f.size()]; - f.read(d, f.size()); - + char *textStrings = new char[f.size()]; + f.read(textStrings, f.size()); -// int vocabId = 1; for (uint strIndex = 0; strIndex < _activeVocabs.size(); ++strIndex) { - // TODO: Rest of this method + const char *s = textStrings; + for (int vocabIndex = 0; vocabIndex < _activeVocabs[strIndex]; ++vocabIndex) + s += strlen(s) + 1; + + _vocabStrings.push_back(s); } + + delete[] textStrings; + f.close(); +} + +void Scene::initPaletteAnimation(Common::Array &animData, bool animFlag) { + // Initialise the animation palette and ticks list + _animTicksList.clear(); + _animPalData.clear(); + + for (uint i = 0; i < animData.size(); ++i) { + _animTicksList.push_back(_vm->_events->getFrameCounter()); + _animPalData.push_back(animData[i]); + } + + // Save the initial starting palette + Common::copy(&_vm->_palette->_mainPalette[0], &_vm->_palette->_mainPalette[PALETTE_SIZE], + &_vm->_palette->_savedPalette[0]); + + // Calculate total + _animCount = 0; + for (uint i = 0; i < _animPalData.size(); ++i) + _animCount += _animPalData[i].r; + + _animVal1 = (_animCount > 16) ? 3 : 0; + _animFlag = animFlag; } void Scene::free() { -- cgit v1.2.3 From 7912f81f2cef0a3dfad86d1a87d68771c13f7744 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 2 Mar 2014 11:38:56 -0500 Subject: MADS: Added skeleton file for animation class --- engines/mads/scene.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index af53710c34..eaa1cab7fa 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -148,7 +148,8 @@ void Scene::loadScene(int sceneId, const Common::String &prefix, bool palFlag) { int flags = _vm->_game->_v2 ? 0x4101 : 0x4100; if (!_vm->_textWindowStill) flags |= 0x200; - // TODO + _animation = Animation::init(_vm, this); + } void Scene::loadHotspots() { -- cgit v1.2.3 From cc810add7479b024138f31fc559f5a9cf7f7a459 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 2 Mar 2014 16:42:39 -0500 Subject: MADS: In progress implementing animation loader --- engines/mads/scene.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index eaa1cab7fa..e6c02b89e0 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -37,6 +37,7 @@ Scene::Scene(MADSEngine *vm): _vm(vm), _spriteSlots(vm) { _sceneInfo = nullptr; _animFlag = false; _animVal1 = 0; + _depthStyle = 0; _verbList.push_back(VerbInit(VERB_LOOK, 2, 0)); _verbList.push_back(VerbInit(VERB_TAKE, 2, 0)); -- cgit v1.2.3 From 4931c8257df6d5dbc3d7fa1bc2b85f859cec17d9 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 2 Mar 2014 18:37:09 -0500 Subject: MADS: Further animation loading and final section of scene loading code --- engines/mads/scene.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index e6c02b89e0..23c118eaf2 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -149,8 +149,24 @@ void Scene::loadScene(int sceneId, const Common::String &prefix, bool palFlag) { int flags = _vm->_game->_v2 ? 0x4101 : 0x4100; if (!_vm->_textWindowStill) flags |= 0x200; + _animation = Animation::init(_vm, this); + MSurface surface; + _animation->load(surface, _interfaceSurface, prefix, flags, nullptr, nullptr); + _vm->_palette->_paletteUsage.load(0); + + _bandsRange = _sceneInfo->_yBandsEnd - _sceneInfo->_yBandsStart; + _scaleRange = _sceneInfo->_maxScale - _sceneInfo->_minScale; + + _spriteSlots.clear(false); + _screenY = 0; + _interfaceY = MADS_SCENE_HEIGHT; + _spritesCount = _sprites.size(); + + warning("TODO: sub_1EA80 / showMouse"); + + warning("TODO: inventory_anim_allocate"); } void Scene::loadHotspots() { -- cgit v1.2.3 From b816b9990d98633794f42ba49aeb971d6f9d930b Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 2 Mar 2014 19:29:54 -0500 Subject: MADS: Added skeleton class for actions --- engines/mads/scene.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index 23c118eaf2..90f5cbd0cf 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -38,6 +38,7 @@ Scene::Scene(MADSEngine *vm): _vm(vm), _spriteSlots(vm) { _animFlag = false; _animVal1 = 0; _depthStyle = 0; + _v1A = _v1C = 0; _verbList.push_back(VerbInit(VERB_LOOK, 2, 0)); _verbList.push_back(VerbInit(VERB_TAKE, 2, 0)); -- cgit v1.2.3 From 72163a233f980a385c432fbf66fd6bb21f6acdf2 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 2 Mar 2014 20:06:21 -0500 Subject: MADS: Moved Player class into it's own file --- engines/mads/scene.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index 90f5cbd0cf..2f12139246 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -28,7 +28,7 @@ namespace MADS { -Scene::Scene(MADSEngine *vm): _vm(vm), _spriteSlots(vm) { +Scene::Scene(MADSEngine *vm): _vm(vm), _spriteSlots(vm), _action(_vm) { _priorSceneId = 0; _nextSceneId = 0; _currentSceneId = 0; -- cgit v1.2.3 From a0996b7384e5c3321af97347613120d2f90ab64e Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 2 Mar 2014 20:50:35 -0500 Subject: MADS: Implemented more of the multi-scene loop --- engines/mads/scene.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index 2f12139246..2c6cb8a112 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -39,6 +39,8 @@ Scene::Scene(MADSEngine *vm): _vm(vm), _spriteSlots(vm), _action(_vm) { _animVal1 = 0; _depthStyle = 0; _v1A = _v1C = 0; + _roomChanged = false; + _reloadSceneFlag = false; _verbList.push_back(VerbInit(VERB_LOOK, 2, 0)); _verbList.push_back(VerbInit(VERB_TAKE, 2, 0)); @@ -254,6 +256,19 @@ void Scene::initPaletteAnimation(Common::Array &animData, bool animFlag) { _animFlag = animFlag; } +bool Scene::getDepthHighBits(const Common::Point &pt) { + if (_sceneInfo->_depthStyle == 2) { + return 0; + } else { + const byte *p = _depthSurface.getBasePtr(pt.x, pt.y); + return (*p & 0x70) >> 4; + } +} + +void Scene::loop() { + +} + void Scene::free() { warning("TODO: Scene::free"); } -- cgit v1.2.3 From 3a842a079c668e9dfc52a6056119d4932e8ef56d Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 2 Mar 2014 23:09:17 -0500 Subject: MADS: Bulk of implementation of ScreenObjects::check --- engines/mads/scene.cpp | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index 2c6cb8a112..86b59ccc8b 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -28,7 +28,8 @@ namespace MADS { -Scene::Scene(MADSEngine *vm): _vm(vm), _spriteSlots(vm), _action(_vm) { +Scene::Scene(MADSEngine *vm): _vm(vm), _spriteSlots(vm), _action(_vm), + _dynamicHotspots(vm), _screenObjects(vm), _interface(vm) { _priorSceneId = 0; _nextSceneId = 0; _currentSceneId = 0; @@ -60,11 +61,6 @@ Scene::~Scene() { delete _sceneInfo; } -void Scene::clearDynamicHotspots() { - _dynamicHotspots.clear(); - _dynamicHotspotsChanged = false; -} - void Scene::clearVocab() { freeVocab(); _activeVocabs.clear(); @@ -155,7 +151,7 @@ void Scene::loadScene(int sceneId, const Common::String &prefix, bool palFlag) { _animation = Animation::init(_vm, this); MSurface surface; - _animation->load(surface, _interfaceSurface, prefix, flags, nullptr, nullptr); + _animation->load(surface, _interface, prefix, flags, nullptr, nullptr); _vm->_palette->_paletteUsage.load(0); @@ -266,7 +262,34 @@ bool Scene::getDepthHighBits(const Common::Point &pt) { } void Scene::loop() { + _nextSceneId = _currentSceneId; + + while (!_vm->shouldQuit() && !_reloadSceneFlag && _nextSceneId == _currentSceneId) { + // Handle drawing a game frame + doFrame(); + + if (_vm->_dialogs->_pendingDialog != DIALOG_NONE && !_vm->_game->_abortTimers + && _vm->_game->_player._stepEnabled) + _reloadSceneFlag = true; + } +} + +void Scene::doFrame() { + Player &player = _vm->_game->_player; + + if (_action._selectedAction || !player._stepEnabled) { + _action.clear(); + _action._selectedAction = 0; + } + + if (!_vm->_game->_abortTimers && !player._unk3) { + if (_dynamicHotspots._changed) + _dynamicHotspots.refresh(); + } +} +void Scene::leftClick() { + warning("TODO: Scene::leftClick"); } void Scene::free() { -- cgit v1.2.3 From d8026b9ef72d7ca22721486244309ccd4a003cae Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 3 Mar 2014 00:42:41 -0500 Subject: MADS: Implementing Scene::doFrame --- engines/mads/scene.cpp | 95 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index 86b59ccc8b..47b9bfac0d 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -42,6 +42,8 @@ Scene::Scene(MADSEngine *vm): _vm(vm), _spriteSlots(vm), _action(_vm), _v1A = _v1C = 0; _roomChanged = false; _reloadSceneFlag = false; + _destFacing = 0; + _freeAnimationFlag = false; _verbList.push_back(VerbInit(VERB_LOOK, 2, 0)); _verbList.push_back(VerbInit(VERB_TAKE, 2, 0)); @@ -276,6 +278,7 @@ void Scene::loop() { void Scene::doFrame() { Player &player = _vm->_game->_player; + bool flag = false; if (_action._selectedAction || !player._stepEnabled) { _action.clear(); @@ -285,6 +288,75 @@ void Scene::doFrame() { if (!_vm->_game->_abortTimers && !player._unk3) { if (_dynamicHotspots._changed) _dynamicHotspots.refresh(); + + _screenObjects.check(player._stepEnabled && !_action._startWalkFlag && + !_vm->_game->_abortTimers2); + } + + if (_action._selectedAction && player._stepEnabled && !_action._startWalkFlag && + !_vm->_game->_abortTimers && !player._unk3) { + _action.startAction(); + if (_action._activeAction._verbId == Nebular::NOUN_LOOK_AT) { + _action._activeAction._verbId = VERB_LOOK; + _action._savedSelectedRow = false; + } + + flag = true; + } + + if (flag || (_vm->_game->_abortTimers && _vm->_game->_abortTimersMode == ABORTMODE_2)) { + doPreactions(); + } + + checkStartWalk(); + if (!_vm->_game->_abortTimers2) + _vm->_events->_currentTimer = _vm->_events->getFrameCounter(); + + if ((_action._inProgress && !player._moving && !_action._startWalkFlag && + player._newDirection == player._direction) || + (_vm->_game->_abortTimers && _vm->_game->_abortTimersMode == ABORTMODE_0)) { + doAction(); + } + + if (_currentSceneId != _nextSceneId) { + _freeAnimationFlag = true; + } else { + doSceneStep(); + checkKeyboard(); + + if (_currentSceneId != _nextSceneId) { + _freeAnimationFlag = true; + } else { + player.nextFrame(); + + // Cursor update code + CursorType cursorId = CURSOR_ARROW; + if (_action._v83338 == 1 && !_screenObjects._v7FECA && + _screenObjects._category == CAT_HOTSPOT) { + int idx = _screenObjects._selectedObject - _interface._screenObjectsCount; + if (idx >= (int)_hotspots.size()) { + idx -= _hotspots.size(); + _vm->_events->_newCursorId = _dynamicHotspots[idx]._cursor; + } else { + _vm->_events->_newCursorId = _hotspots[idx]._cursor; + } + + cursorId = _vm->_events->_newCursorId == CURSOR_NONE ? + CURSOR_ARROW : _vm->_events->_newCursorId; + } + + if (!player._stepEnabled) + cursorId = CURSOR_WAIT; + if (cursorId >= _vm->_events->_cursorSprites->getCount()) + cursorId = (CursorType)_vm->_events->_cursorSprites->getCount(); + _vm->_events->_newCursorId = cursorId; + + if (cursorId != _vm->_events->_cursorId) { + _vm->_events->setCursor(cursorId); + } + + // TODO: Rest of Scene::doFrame + } } } @@ -292,6 +364,29 @@ void Scene::leftClick() { warning("TODO: Scene::leftClick"); } +void Scene::doPreactions() { + warning("TODO: Scene::doPreactions"); +} + +void Scene::doAction() { + warning("TODO: Scene::doAction"); +} + +void Scene::checkStartWalk() { + if (_action._startWalkFlag && _action._walkFlag) { + _vm->_game->_player.setDest(_destPos, _destFacing); + _action._startWalkFlag = false; + } +} + +void Scene::doSceneStep() { + warning("TODO: Scene::doSceneStep"); +} + +void Scene::checkKeyboard() { + warning("TODO: Scene::checkKeyboard"); +} + void Scene::free() { warning("TODO: Scene::free"); } -- cgit v1.2.3 From 3a3a295758a87817e9d66d3c06df56859ef55529 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 3 Mar 2014 20:53:27 -0500 Subject: MADS: Implemented sequence list, improvements for sprite assets --- engines/mads/scene.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index 47b9bfac0d..6efbdf5072 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -29,7 +29,8 @@ namespace MADS { Scene::Scene(MADSEngine *vm): _vm(vm), _spriteSlots(vm), _action(_vm), - _dynamicHotspots(vm), _screenObjects(vm), _interface(vm) { + _dynamicHotspots(vm), _screenObjects(vm), _interface(vm), + _sequences(vm) { _priorSceneId = 0; _nextSceneId = 0; _currentSceneId = 0; @@ -355,6 +356,10 @@ void Scene::doFrame() { _vm->_events->setCursor(cursorId); } + if (!_vm->_game->_abortTimers) + _sequences.tick(); + + // TODO: Rest of Scene::doFrame } } -- cgit v1.2.3 From 9e356dd945863a4c4dfa89f2a94dd1a56c2d03a6 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 3 Mar 2014 23:40:23 -0500 Subject: MADS: Implemented extra message and dirty area classes --- engines/mads/scene.cpp | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index 6efbdf5072..a0888f7d68 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -29,8 +29,8 @@ namespace MADS { Scene::Scene(MADSEngine *vm): _vm(vm), _spriteSlots(vm), _action(_vm), - _dynamicHotspots(vm), _screenObjects(vm), _interface(vm), - _sequences(vm) { + _dirtyAreas(_vm), _dynamicHotspots(vm), _interface(vm), _messages(vm), + _screenObjects(vm), _sequences(vm), _textDisplay(vm) { _priorSceneId = 0; _nextSceneId = 0; _currentSceneId = 0; @@ -45,6 +45,8 @@ Scene::Scene(MADSEngine *vm): _vm(vm), _spriteSlots(vm), _action(_vm), _reloadSceneFlag = false; _destFacing = 0; _freeAnimationFlag = false; + _animation = nullptr; + _activeAnimation = nullptr; _verbList.push_back(VerbInit(VERB_LOOK, 2, 0)); _verbList.push_back(VerbInit(VERB_TAKE, 2, 0)); @@ -356,9 +358,21 @@ void Scene::doFrame() { _vm->_events->setCursor(cursorId); } - if (!_vm->_game->_abortTimers) + if (!_vm->_game->_abortTimers) { + // Handle any active sequences _sequences.tick(); + // Handle any active animation + if (_activeAnimation) + _activeAnimation->update(); + } + + // If the debugget flag is set, show the mouse position + if (_vm->_debugger->_showMousePos) { + Common::Point pt = _vm->_events->mousePos(); + Common::String msg = Common::String::format("(%d,%d)", pt.x, pt.y); + _messages.add(Common::Point(5, 5), 0x203, 0, 0, 1, msg); + } // TODO: Rest of Scene::doFrame } -- cgit v1.2.3 From f6888eef1069ac5df07c3f4dcc3a30755bc4ebb0 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 4 Mar 2014 09:33:57 -0500 Subject: MADS: Implementation of timer functionality for Scene::doFrame --- engines/mads/scene.cpp | 39 +++++++++++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 4 deletions(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index a0888f7d68..4d62e64f31 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -29,7 +29,7 @@ namespace MADS { Scene::Scene(MADSEngine *vm): _vm(vm), _spriteSlots(vm), _action(_vm), - _dirtyAreas(_vm), _dynamicHotspots(vm), _interface(vm), _messages(vm), + _dirtyAreas(_vm), _dynamicHotspots(vm), _interface(vm), _kernelMessages(vm), _screenObjects(vm), _sequences(vm), _textDisplay(vm) { _priorSceneId = 0; _nextSceneId = 0; @@ -97,7 +97,7 @@ void Scene::clearSequenceList() { } void Scene::clearMessageList() { - _messages.clear(); + _kernelMessages.clear(); _talkFont = "*FONTCONV.FF"; _textSpacing = -1; } @@ -125,7 +125,7 @@ void Scene::loadScene(int sceneId, const Common::String &prefix, bool palFlag) { _spriteSlots.clear(false); _sequences.clear(); - _messages.clear(); + _kernelMessages.clear(); // TODO: palletteUsage reset? setPalette(_nullPalette); _sceneInfo = SceneInfo::init(_vm); @@ -371,14 +371,45 @@ void Scene::doFrame() { if (_vm->_debugger->_showMousePos) { Common::Point pt = _vm->_events->mousePos(); Common::String msg = Common::String::format("(%d,%d)", pt.x, pt.y); - _messages.add(Common::Point(5, 5), 0x203, 0, 0, 1, msg); + _kernelMessages.add(Common::Point(5, 5), 0x203, 0, 0, 1, msg); } + if (!_vm->_game->_abortTimers) { + if (_reloadSceneFlag || _currentSceneId != _nextSceneId) + _kernelMessages.reset(); + _kernelMessages.update(); + } + + _vm->_game->_abortTimers2 = !_vm->_game->_abortTimers2; + + warning("TODO: image_inter_list_call"); + + // Write any text needed by the interface + if (_vm->_game->_abortTimers2) + _interface.writeText(); + + // Draw any elements + drawElements(_vm->_game->_abortTimers2, _vm->_game->_abortTimers2); + + // Handle message updates + if (_vm->_game->_abortTimers2) { + uint32 priorTime = _vm->_game->_priorFrameTimer; + uint32 newTime = _vm->_events->getFrameCounter(); + _sequences.delay(newTime, priorTime); + _kernelMessages.delay(newTime, priorTime); + } + + warning("TODO: sub_1DA5A"); + // TODO: Rest of Scene::doFrame } } } +void Scene::drawElements(bool transitionFlag, bool surfaceFlag) { + +} + void Scene::leftClick() { warning("TODO: Scene::leftClick"); } -- cgit v1.2.3 From 1607a9104700e987cacfec41aaafd25d979aeb98 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 4 Mar 2014 20:06:48 -0500 Subject: MADS: Finished remainder of Scene::doFrame --- engines/mads/scene.cpp | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index 4d62e64f31..db252a95a4 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -368,10 +368,12 @@ void Scene::doFrame() { } // If the debugget flag is set, show the mouse position + int mouseTextIndex = 0; if (_vm->_debugger->_showMousePos) { Common::Point pt = _vm->_events->mousePos(); Common::String msg = Common::String::format("(%d,%d)", pt.x, pt.y); - _kernelMessages.add(Common::Point(5, 5), 0x203, 0, 0, 1, msg); + mouseTextIndex = _kernelMessages.add(Common::Point(5, 5), + 0x203, 0, 0, 1, msg); } if (!_vm->_game->_abortTimers) { @@ -399,11 +401,26 @@ void Scene::doFrame() { _kernelMessages.delay(newTime, priorTime); } - warning("TODO: sub_1DA5A"); + if (_vm->_debugger->_showMousePos) + // Mouse position display isn't persistent, so remove it + _kernelMessages.remove(mouseTextIndex); - // TODO: Rest of Scene::doFrame + + warning("TODO: sub_1DA3E"); } } + + if (_vm->_game->_abortTimers2) + _animFlag = true; + _vm->_game->_abortTimers2 = 0; + + if (_freeAnimationFlag) { + _activeAnimation->free(); + _activeAnimation = nullptr; + } + + // TODO: Verify correctness of frame wait + } void Scene::drawElements(bool transitionFlag, bool surfaceFlag) { -- cgit v1.2.3 From 568fc31b3090a70aa922479991540d4f5c2e918c Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 4 Mar 2014 22:33:27 -0500 Subject: MADS: Beginnings of code support for Scene::drawElements --- engines/mads/scene.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index db252a95a4..994f58230e 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -424,7 +424,14 @@ void Scene::doFrame() { } void Scene::drawElements(bool transitionFlag, bool surfaceFlag) { + // Draw any background objects + _spriteSlots.drawBackground(); + // Merge any identified dirty areas + _dirtyAreas.merge(1, _dirtyAreas.size()); + + // Copy dirty areas to the main display surface + _dirtyAreas.copy(&_vm->_screen, &_backgroundSurface, _posAdjust); } void Scene::leftClick() { -- cgit v1.2.3 From 23ebeec600f8210601dd45fc42c21a596fa6d127 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 5 Mar 2014 07:27:39 -0500 Subject: MADS: Further implementation of drawElements --- engines/mads/scene.cpp | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index 994f58230e..1d489ddb2d 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -164,7 +164,6 @@ void Scene::loadScene(int sceneId, const Common::String &prefix, bool palFlag) { _scaleRange = _sceneInfo->_maxScale - _sceneInfo->_minScale; _spriteSlots.clear(false); - _screenY = 0; _interfaceY = MADS_SCENE_HEIGHT; _spritesCount = _sprites.size(); @@ -432,6 +431,28 @@ void Scene::drawElements(bool transitionFlag, bool surfaceFlag) { // Copy dirty areas to the main display surface _dirtyAreas.copy(&_vm->_screen, &_backgroundSurface, _posAdjust); + + // Set dirty areas + _spriteSlots.setDirtyAreas(); + _textDisplay.setDirtyAreas(); + + // + _vm->_screen.setPointer(&_vm->_screen); + _interface.setBounds(Common::Rect(_vm->_screen._offset.x, _vm->_screen._offset.y, + _vm->_screen._offset.x + _vm->_screen.w, _vm->_screen._offset.y + _vm->_screen.h)); + + if (transitionFlag) { + // Fading in the screen + _vm->_screen.transition(transitionFlag, surfaceFlag); + _vm->_sound->startQueuedCommands(); + } else { + // Copy dirty areas to the screen + _dirtyAreas.copy(&_vm->_screen, &_backgroundSurface, _vm->_screen._offset); + } + + warning("TODO: sub_115A2"); + _spriteSlots.cleanUp(); + _textDisplay.cleanUp(); } void Scene::leftClick() { -- cgit v1.2.3 From d98f890029936dfa8139cf8dce4756ec92bc2568 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 5 Mar 2014 09:04:53 -0500 Subject: MADS: Completed implementing drawElements and support methods --- engines/mads/scene.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index 1d489ddb2d..7359562180 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -423,18 +423,30 @@ void Scene::doFrame() { } void Scene::drawElements(bool transitionFlag, bool surfaceFlag) { - // Draw any background objects + // Draw any sprites + _dirtyAreas.clear(); _spriteSlots.drawBackground(); + // Process dirty areas + _textDisplay.setDirtyAreas(); + // Merge any identified dirty areas - _dirtyAreas.merge(1, _dirtyAreas.size()); + _dirtyAreas.merge(1, DIRTY_AREAS_SIZE); // Copy dirty areas to the main display surface _dirtyAreas.copy(&_vm->_screen, &_backgroundSurface, _posAdjust); - // Set dirty areas + // Handle dirty areas for foreground objects _spriteSlots.setDirtyAreas(); - _textDisplay.setDirtyAreas(); + _textDisplay.setDirtyAreas2(); + _dirtyAreas.merge(1, DIRTY_AREAS_SIZE); + + + // Draw foreground sprites + _spriteSlots.drawForeground(&_vm->_screen); + + // Draw text elements onto the view + _textDisplay.draw(&_vm->_screen); // _vm->_screen.setPointer(&_vm->_screen); -- cgit v1.2.3 From 73a7140be775693533db183f353fc9c82c14fa53 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 5 Mar 2014 21:36:02 -0500 Subject: MADS: Starting implementation of scene group 8 --- engines/mads/scene.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index 7359562180..b285229926 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -107,7 +107,7 @@ void Scene::loadSceneLogic() { switch (_vm->getGameID()) { case GType_RexNebular: - _sceneLogic = Nebular::SceneFactory::createScene(this); + _sceneLogic = Nebular::SceneFactory::createScene(_vm); break; default: error("Unknown game"); -- cgit v1.2.3 From c9186f51b9502a4cfb1881f2db4f92eeb6227144 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 6 Mar 2014 20:30:05 -0500 Subject: MADS: Added in Rex Nebular globals class --- engines/mads/scene.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index b285229926..f974be4d1e 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -28,9 +28,10 @@ namespace MADS { -Scene::Scene(MADSEngine *vm): _vm(vm), _spriteSlots(vm), _action(_vm), - _dirtyAreas(_vm), _dynamicHotspots(vm), _interface(vm), _kernelMessages(vm), - _screenObjects(vm), _sequences(vm), _textDisplay(vm) { +Scene::Scene(MADSEngine *vm): _vm(vm), _action(_vm), _dirtyAreas(_vm), + _dynamicHotspots(vm), _interface(vm), _kernelMessages(vm), + _screenObjects(vm), _sequences(vm), _spriteSlots(vm), + _textDisplay(vm) { _priorSceneId = 0; _nextSceneId = 0; _currentSceneId = 0; @@ -47,6 +48,7 @@ Scene::Scene(MADSEngine *vm): _vm(vm), _spriteSlots(vm), _action(_vm), _freeAnimationFlag = false; _animation = nullptr; _activeAnimation = nullptr; + _textSpacing = -1; _verbList.push_back(VerbInit(VERB_LOOK, 2, 0)); _verbList.push_back(VerbInit(VERB_TAKE, 2, 0)); @@ -424,7 +426,6 @@ void Scene::doFrame() { void Scene::drawElements(bool transitionFlag, bool surfaceFlag) { // Draw any sprites - _dirtyAreas.clear(); _spriteSlots.drawBackground(); // Process dirty areas -- cgit v1.2.3 From a77ed90618664e50705b3e59dd2111faec2f5f39 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 6 Mar 2014 22:31:41 -0500 Subject: MADS: Implementing support methods needed for scene 804 initialisation --- engines/mads/scene.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index f974be4d1e..bbf46f164c 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -28,10 +28,10 @@ namespace MADS { -Scene::Scene(MADSEngine *vm): _vm(vm), _action(_vm), _dirtyAreas(_vm), - _dynamicHotspots(vm), _interface(vm), _kernelMessages(vm), - _screenObjects(vm), _sequences(vm), _spriteSlots(vm), - _textDisplay(vm) { +Scene::Scene(MADSEngine *vm): _vm(vm), _action(_vm), _depthSurface(vm), + _dirtyAreas(_vm), _dynamicHotspots(vm), _interface(vm), + _kernelMessages(vm), _screenObjects(vm), _sequences(vm), + _sprites(vm), _spriteSlots(vm), _textDisplay(vm) { _priorSceneId = 0; _nextSceneId = 0; _currentSceneId = 0; -- cgit v1.2.3 From 3399516c5e4c2931adf76a25944cb3e46f9934ee Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 7 Mar 2014 23:07:36 -0500 Subject: MADS: Implemented remainder of scene 804 setup code and support methods --- engines/mads/scene.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index bbf46f164c..c7a6edee20 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -46,7 +46,7 @@ Scene::Scene(MADSEngine *vm): _vm(vm), _action(_vm), _depthSurface(vm), _reloadSceneFlag = false; _destFacing = 0; _freeAnimationFlag = false; - _animation = nullptr; + _animationData = nullptr; _activeAnimation = nullptr; _textSpacing = -1; @@ -156,9 +156,9 @@ void Scene::loadScene(int sceneId, const Common::String &prefix, bool palFlag) { if (!_vm->_textWindowStill) flags |= 0x200; - _animation = Animation::init(_vm, this); + _animationData = Animation::init(_vm, this); MSurface surface; - _animation->load(surface, _interface, prefix, flags, nullptr, nullptr); + _animationData->load(surface, _interface, prefix, flags, nullptr, nullptr); _vm->_palette->_paletteUsage.load(0); @@ -495,6 +495,17 @@ void Scene::checkKeyboard() { warning("TODO: Scene::checkKeyboard"); } +void Scene::loadAnimation(const Common::String &resName, int abortTimers) { + assert(_activeAnimation == nullptr); + MSurface sceneSurface; + InterfaceSurface interfaceSurface(_vm); + + _activeAnimation = Animation::init(_vm, this); + _activeAnimation->load(sceneSurface, interfaceSurface, resName, + _vm->_game->_v2 ? 1 : 0, nullptr, nullptr); + _activeAnimation->startAnimation(abortTimers); +} + void Scene::free() { warning("TODO: Scene::free"); } -- cgit v1.2.3 From c2587af8f29b2b79beae7fda5a9b983614840b17 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 8 Mar 2014 14:05:17 -0500 Subject: MADS: Clarified Events::_currentTimer as Scene::_frameStartTime --- engines/mads/scene.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index c7a6edee20..17c579bddd 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -49,6 +49,7 @@ Scene::Scene(MADSEngine *vm): _vm(vm), _action(_vm), _depthSurface(vm), _animationData = nullptr; _activeAnimation = nullptr; _textSpacing = -1; + _frameStartTime = 0; _verbList.push_back(VerbInit(VERB_LOOK, 2, 0)); _verbList.push_back(VerbInit(VERB_TAKE, 2, 0)); @@ -314,7 +315,7 @@ void Scene::doFrame() { checkStartWalk(); if (!_vm->_game->_abortTimers2) - _vm->_events->_currentTimer = _vm->_events->getFrameCounter(); + _frameStartTime = _vm->_events->getFrameCounter(); if ((_action._inProgress && !player._moving && !_action._startWalkFlag && player._newDirection == player._direction) || -- cgit v1.2.3 From 5536b8a933f792f45d08ab5126e826a9a20fa476 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 8 Mar 2014 15:42:07 -0500 Subject: MADS: Fixes for sprite list initialisation --- engines/mads/scene.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index 17c579bddd..8521c2e0b4 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -126,7 +126,7 @@ void Scene::loadScene(int sceneId, const Common::String &prefix, bool palFlag) { if (palFlag) _vm->_palette->resetGamePalette(18, 10); - _spriteSlots.clear(false); + _spriteSlots.reset(false); _sequences.clear(); _kernelMessages.clear(); @@ -166,7 +166,7 @@ void Scene::loadScene(int sceneId, const Common::String &prefix, bool palFlag) { _bandsRange = _sceneInfo->_yBandsEnd - _sceneInfo->_yBandsStart; _scaleRange = _sceneInfo->_maxScale - _sceneInfo->_minScale; - _spriteSlots.clear(false); + _spriteSlots.reset(false); _interfaceY = MADS_SCENE_HEIGHT; _spritesCount = _sprites.size(); -- cgit v1.2.3 From 8cd85f3a000ab755da7b13c8589d3c67c081122a Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 8 Mar 2014 16:06:37 -0500 Subject: MADS: Fixes for drawing scene elements --- engines/mads/scene.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index 8521c2e0b4..11a59356c0 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -422,7 +422,7 @@ void Scene::doFrame() { } // TODO: Verify correctness of frame wait - + _vm->_events->waitForNextFrame(); } void Scene::drawElements(bool transitionFlag, bool surfaceFlag) { -- cgit v1.2.3 From 680b5a4487a6c1b08f79c4a657b63715e69240de Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 10 Mar 2014 00:00:39 -0400 Subject: MADS: In progress implementation of PaletteUsage::process --- engines/mads/scene.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index 11a59356c0..15577971e0 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -384,16 +384,15 @@ void Scene::doFrame() { _kernelMessages.update(); } - _vm->_game->_abortTimers2 = !_vm->_game->_abortTimers2; - - warning("TODO: image_inter_list_call"); + _imageInterEntries.call(_vm->_game->_abortTimers2 == kTransitionFadeIn ? 0xff : 0, + _vm->_game->_abortTimers2); // Write any text needed by the interface if (_vm->_game->_abortTimers2) _interface.writeText(); // Draw any elements - drawElements(_vm->_game->_abortTimers2, _vm->_game->_abortTimers2); + drawElements((ScreenTransition)_vm->_game->_abortTimers2, _vm->_game->_abortTimers2); // Handle message updates if (_vm->_game->_abortTimers2) { @@ -425,7 +424,7 @@ void Scene::doFrame() { _vm->_events->waitForNextFrame(); } -void Scene::drawElements(bool transitionFlag, bool surfaceFlag) { +void Scene::drawElements(ScreenTransition transitionType, bool surfaceFlag) { // Draw any sprites _spriteSlots.drawBackground(); @@ -455,9 +454,9 @@ void Scene::drawElements(bool transitionFlag, bool surfaceFlag) { _interface.setBounds(Common::Rect(_vm->_screen._offset.x, _vm->_screen._offset.y, _vm->_screen._offset.x + _vm->_screen.w, _vm->_screen._offset.y + _vm->_screen.h)); - if (transitionFlag) { + if (transitionType) { // Fading in the screen - _vm->_screen.transition(transitionFlag, surfaceFlag); + _vm->_screen.transition(transitionType, surfaceFlag); _vm->_sound->startQueuedCommands(); } else { // Copy dirty areas to the screen -- cgit v1.2.3 From 408f5e79df5e8a33367fdf2a9c17b424953edace Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 12 Mar 2014 22:45:33 -0400 Subject: MADS: General cleanup and minor fixes --- engines/mads/scene.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index 15577971e0..ebc35f0f27 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -170,7 +170,9 @@ void Scene::loadScene(int sceneId, const Common::String &prefix, bool palFlag) { _interfaceY = MADS_SCENE_HEIGHT; _spritesCount = _sprites.size(); - warning("TODO: sub_1EA80 / showMouse"); + _interface.setup(_screenObjects._v832EC); + + warning("TODO: showMouse"); warning("TODO: inventory_anim_allocate"); } -- cgit v1.2.3 From 84fb90e7a52daffd862159d54cda4817aa930a6f Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 13 Mar 2014 20:56:03 -0400 Subject: MADS: Fix GCC warnings and memory leaks --- engines/mads/scene.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index ebc35f0f27..ef5fd78f74 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -41,7 +41,8 @@ Scene::Scene(MADSEngine *vm): _vm(vm), _action(_vm), _depthSurface(vm), _animFlag = false; _animVal1 = 0; _depthStyle = 0; - _v1A = _v1C = 0; + _v1A = 0; + _v1C = 0; _roomChanged = false; _reloadSceneFlag = false; _destFacing = 0; -- cgit v1.2.3 From 3f0cd4771c94a83c72f09f74ba351a3905357d1c Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 13 Mar 2014 22:25:16 -0400 Subject: MADS: Fixed handling of dirty rects to copy areas to the physical screen --- engines/mads/scene.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index ef5fd78f74..8bf0b6a527 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -438,7 +438,7 @@ void Scene::drawElements(ScreenTransition transitionType, bool surfaceFlag) { _dirtyAreas.merge(1, DIRTY_AREAS_SIZE); // Copy dirty areas to the main display surface - _dirtyAreas.copy(&_vm->_screen, &_backgroundSurface, _posAdjust); + _dirtyAreas.copy(&_backgroundSurface, &_vm->_screen, _posAdjust); // Handle dirty areas for foreground objects _spriteSlots.setDirtyAreas(); @@ -463,7 +463,7 @@ void Scene::drawElements(ScreenTransition transitionType, bool surfaceFlag) { _vm->_sound->startQueuedCommands(); } else { // Copy dirty areas to the screen - _dirtyAreas.copy(&_vm->_screen, &_backgroundSurface, _vm->_screen._offset); + _dirtyAreas.copyToScreen(_vm->_screen._offset); } warning("TODO: sub_115A2"); -- cgit v1.2.3 From b652e2eafd3de5436b45619659b5299d945074be Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 15 Mar 2014 18:43:39 -0400 Subject: MADS: Merged the InterfaceSurface and UserInterface classes --- engines/mads/scene.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index 8bf0b6a527..d1e83f6d0a 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -29,9 +29,9 @@ namespace MADS { Scene::Scene(MADSEngine *vm): _vm(vm), _action(_vm), _depthSurface(vm), - _dirtyAreas(_vm), _dynamicHotspots(vm), _interface(vm), - _kernelMessages(vm), _screenObjects(vm), _sequences(vm), - _sprites(vm), _spriteSlots(vm), _textDisplay(vm) { + _dirtyAreas(_vm), _dynamicHotspots(vm), _kernelMessages(vm), + _screenObjects(vm), _sequences(vm), _sprites(vm), _spriteSlots(vm), + _textDisplay(vm), _userInterface(vm) { _priorSceneId = 0; _nextSceneId = 0; _currentSceneId = 0; @@ -159,8 +159,8 @@ void Scene::loadScene(int sceneId, const Common::String &prefix, bool palFlag) { flags |= 0x200; _animationData = Animation::init(_vm, this); - MSurface surface; - _animationData->load(surface, _interface, prefix, flags, nullptr, nullptr); + UserInterface surface(_vm); + _animationData->load(surface, _userInterface, prefix, flags, nullptr, nullptr); _vm->_palette->_paletteUsage.load(0); @@ -171,7 +171,7 @@ void Scene::loadScene(int sceneId, const Common::String &prefix, bool palFlag) { _interfaceY = MADS_SCENE_HEIGHT; _spritesCount = _sprites.size(); - _interface.setup(_screenObjects._v832EC); + _userInterface.setup(_screenObjects._v832EC); warning("TODO: showMouse"); @@ -341,7 +341,7 @@ void Scene::doFrame() { CursorType cursorId = CURSOR_ARROW; if (_action._v83338 == 1 && !_screenObjects._v7FECA && _screenObjects._category == CAT_HOTSPOT) { - int idx = _screenObjects._selectedObject - _interface._screenObjectsCount; + int idx = _screenObjects._selectedObject - _userInterface._screenObjectsCount; if (idx >= (int)_hotspots.size()) { idx -= _hotspots.size(); _vm->_events->_newCursorId = _dynamicHotspots[idx]._cursor; @@ -392,7 +392,7 @@ void Scene::doFrame() { // Write any text needed by the interface if (_vm->_game->_abortTimers2) - _interface.writeText(); + _userInterface.writeText(); // Draw any elements drawElements((ScreenTransition)_vm->_game->_abortTimers2, _vm->_game->_abortTimers2); @@ -454,7 +454,7 @@ void Scene::drawElements(ScreenTransition transitionType, bool surfaceFlag) { // _vm->_screen.setPointer(&_vm->_screen); - _interface.setBounds(Common::Rect(_vm->_screen._offset.x, _vm->_screen._offset.y, + _userInterface.setBounds(Common::Rect(_vm->_screen._offset.x, _vm->_screen._offset.y, _vm->_screen._offset.x + _vm->_screen.w, _vm->_screen._offset.y + _vm->_screen.h)); if (transitionType) { @@ -500,11 +500,11 @@ void Scene::checkKeyboard() { void Scene::loadAnimation(const Common::String &resName, int abortTimers) { assert(_activeAnimation == nullptr); - MSurface sceneSurface; - InterfaceSurface interfaceSurface(_vm); + MSurface depthSurface; + UserInterface interfaceSurface(_vm); _activeAnimation = Animation::init(_vm, this); - _activeAnimation->load(sceneSurface, interfaceSurface, resName, + _activeAnimation->load(interfaceSurface, depthSurface, resName, _vm->_game->_v2 ? 1 : 0, nullptr, nullptr); _activeAnimation->startAnimation(abortTimers); } -- cgit v1.2.3 From 630679a5c8d72242866638b470cd361c0d5c6b0a Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 15 Mar 2014 21:33:15 -0400 Subject: MADS: Completed UserInterface::loadElements --- engines/mads/scene.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index d1e83f6d0a..9ece16fab5 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -51,6 +51,7 @@ Scene::Scene(MADSEngine *vm): _vm(vm), _action(_vm), _depthSurface(vm), _activeAnimation = nullptr; _textSpacing = -1; _frameStartTime = 0; + _layer = LAYER_GUI; _verbList.push_back(VerbInit(VERB_LOOK, 2, 0)); _verbList.push_back(VerbInit(VERB_TAKE, 2, 0)); -- cgit v1.2.3 From 39a36064ac91ad7864c04dfe4d88c97824f070ae Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 16 Mar 2014 17:50:47 -0400 Subject: MADS: In progress text draw methods for user interface --- engines/mads/scene.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index 9ece16fab5..0258f15bb8 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -393,7 +393,7 @@ void Scene::doFrame() { // Write any text needed by the interface if (_vm->_game->_abortTimers2) - _userInterface.writeText(); + _userInterface.drawTextElements(); // Draw any elements drawElements((ScreenTransition)_vm->_game->_abortTimers2, _vm->_game->_abortTimers2); -- cgit v1.2.3 From acba8f9254a724ce9c57f5ddd81e6b9264c07274 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 16 Mar 2014 23:40:21 -0400 Subject: MADS: Implementing user interface text display methods --- engines/mads/scene.cpp | 31 +++++++++++-------------------- 1 file changed, 11 insertions(+), 20 deletions(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index 0258f15bb8..88533a9ffd 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -35,14 +35,11 @@ Scene::Scene(MADSEngine *vm): _vm(vm), _action(_vm), _depthSurface(vm), _priorSceneId = 0; _nextSceneId = 0; _currentSceneId = 0; - _vocabBuffer = nullptr; _sceneLogic = nullptr; _sceneInfo = nullptr; _animFlag = false; _animVal1 = 0; _depthStyle = 0; - _v1A = 0; - _v1C = 0; _roomChanged = false; _reloadSceneFlag = false; _destFacing = 0; @@ -66,21 +63,14 @@ Scene::Scene(MADSEngine *vm): _vm(vm), _action(_vm), _depthSurface(vm), } Scene::~Scene() { - delete[] _vocabBuffer; delete _sceneLogic; delete _sceneInfo; } void Scene::clearVocab() { - freeVocab(); _activeVocabs.clear(); } -void Scene::freeVocab() { - delete[] _vocabBuffer; - _vocabBuffer = nullptr; -} - void Scene::addActiveVocab(int vocabId) { if (activeVocabIndexOf(vocabId) == -1) { assert(_activeVocabs.size() < 200); @@ -222,21 +212,22 @@ void Scene::loadVocab() { } void Scene::loadVocabStrings() { - freeVocab(); + _vocabStrings.clear(); File f("*VOCAB.DAT"); + Common::String msg; - char *textStrings = new char[f.size()]; - f.read(textStrings, f.size()); - - for (uint strIndex = 0; strIndex < _activeVocabs.size(); ++strIndex) { - const char *s = textStrings; - for (int vocabIndex = 0; vocabIndex < _activeVocabs[strIndex]; ++vocabIndex) - s += strlen(s) + 1; + for (;;) { + char c = (char)f.readByte(); + if (f.eos()) break; - _vocabStrings.push_back(s); + if (c == '\0') { + _vocabStrings.push_back(msg); + msg = ""; + } else { + msg += c; + } } - delete[] textStrings; f.close(); } -- cgit v1.2.3 From 0c8a3a47e28075bd559be43bde910587af35d8ab Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 17 Mar 2014 21:53:22 -0400 Subject: MADS: Transformed ImageInterEntries to be User Interface UISlots --- engines/mads/scene.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index 88533a9ffd..ed5fca5f6e 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -379,7 +379,7 @@ void Scene::doFrame() { _kernelMessages.update(); } - _imageInterEntries.call(_vm->_game->_abortTimers2 == kTransitionFadeIn ? 0xff : 0, + _userInterface._uiSlots.call(_vm->_game->_abortTimers2 == kTransitionFadeIn ? 0xff : 0, _vm->_game->_abortTimers2); // Write any text needed by the interface -- cgit v1.2.3 From 4875c83f1023585ff7c807f5633aac84eb5e3c2b Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 18 Mar 2014 19:56:29 -0400 Subject: MADS: Implemented DirtyArea::setUISlot --- engines/mads/scene.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index ed5fca5f6e..60b33853a4 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -379,7 +379,7 @@ void Scene::doFrame() { _kernelMessages.update(); } - _userInterface._uiSlots.call(_vm->_game->_abortTimers2 == kTransitionFadeIn ? 0xff : 0, + _userInterface._uiSlots.draw(_vm->_game->_abortTimers2 == kTransitionFadeIn ? 0xff : 0, _vm->_game->_abortTimers2); // Write any text needed by the interface -- cgit v1.2.3 From 5b4b7a5ca972f533c7a6129e84fd5d26e3b2ebb6 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 18 Mar 2014 22:37:33 -0400 Subject: MADS: Finished UISlots::draw method --- engines/mads/scene.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index 60b33853a4..79ac2ceab1 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -379,8 +379,8 @@ void Scene::doFrame() { _kernelMessages.update(); } - _userInterface._uiSlots.draw(_vm->_game->_abortTimers2 == kTransitionFadeIn ? 0xff : 0, - _vm->_game->_abortTimers2); + _userInterface._uiSlots.draw(_vm->_game->_abortTimers2 == kTransitionFadeIn, + _vm->_game->_abortTimers2 != 0); // Write any text needed by the interface if (_vm->_game->_abortTimers2) -- cgit v1.2.3 From 53eac0d7c045c734e897df1c0246cab185af0463 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 18 Mar 2014 23:13:13 -0400 Subject: MADS: Fixes for scene background loading --- engines/mads/scene.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index 79ac2ceab1..02ef916958 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -150,8 +150,8 @@ void Scene::loadScene(int sceneId, const Common::String &prefix, bool palFlag) { flags |= 0x200; _animationData = Animation::init(_vm, this); - UserInterface surface(_vm); - _animationData->load(surface, _userInterface, prefix, flags, nullptr, nullptr); + MSurface depthSurface; + _animationData->load(_userInterface, depthSurface, prefix, flags, nullptr, nullptr); _vm->_palette->_paletteUsage.load(0); -- cgit v1.2.3 From db017b746dded2ea287c04c37fbb88ef82492781 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 19 Mar 2014 19:44:51 -0400 Subject: MADS: Moved ScreenObjects into the Game class --- engines/mads/scene.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index 02ef916958..741ba82be4 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -30,7 +30,7 @@ namespace MADS { Scene::Scene(MADSEngine *vm): _vm(vm), _action(_vm), _depthSurface(vm), _dirtyAreas(_vm), _dynamicHotspots(vm), _kernelMessages(vm), - _screenObjects(vm), _sequences(vm), _sprites(vm), _spriteSlots(vm), + _sequences(vm), _sprites(vm), _spriteSlots(vm), _textDisplay(vm), _userInterface(vm) { _priorSceneId = 0; _nextSceneId = 0; @@ -162,7 +162,7 @@ void Scene::loadScene(int sceneId, const Common::String &prefix, bool palFlag) { _interfaceY = MADS_SCENE_HEIGHT; _spritesCount = _sprites.size(); - _userInterface.setup(_screenObjects._v832EC); + _userInterface.setup(_vm->_game->_screenObjects._v832EC); warning("TODO: showMouse"); @@ -289,7 +289,7 @@ void Scene::doFrame() { if (_dynamicHotspots._changed) _dynamicHotspots.refresh(); - _screenObjects.check(player._stepEnabled && !_action._startWalkFlag && + _vm->_game->_screenObjects.check(player._stepEnabled && !_action._startWalkFlag && !_vm->_game->_abortTimers2); } @@ -331,9 +331,9 @@ void Scene::doFrame() { // Cursor update code CursorType cursorId = CURSOR_ARROW; - if (_action._v83338 == 1 && !_screenObjects._v7FECA && - _screenObjects._category == CAT_HOTSPOT) { - int idx = _screenObjects._selectedObject - _userInterface._screenObjectsCount; + if (_action._v83338 == 1 && !_vm->_game->_screenObjects._v7FECA && + _vm->_game->_screenObjects._category == CAT_HOTSPOT) { + int idx = _vm->_game->_screenObjects._selectedObject - _userInterface._screenObjectsCount; if (idx >= (int)_hotspots.size()) { idx -= _hotspots.size(); _vm->_events->_newCursorId = _dynamicHotspots[idx]._cursor; -- cgit v1.2.3 From 8d252f4f0e81cfd43e5b311df4a1ed5fb478953b Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 19 Mar 2014 23:33:18 -0400 Subject: MADS: Implemented methods for checking action at mouse position and clicking --- engines/mads/scene.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index 741ba82be4..baf51fea12 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -49,6 +49,8 @@ Scene::Scene(MADSEngine *vm): _vm(vm), _action(_vm), _depthSurface(vm), _textSpacing = -1; _frameStartTime = 0; _layer = LAYER_GUI; + _lookFlag = false; + _highlightedHotspot = 0; _verbList.push_back(VerbInit(VERB_LOOK, 2, 0)); _verbList.push_back(VerbInit(VERB_TAKE, 2, 0)); @@ -463,10 +465,6 @@ void Scene::drawElements(ScreenTransition transitionType, bool surfaceFlag) { _textDisplay.cleanUp(); } -void Scene::leftClick() { - warning("TODO: Scene::leftClick"); -} - void Scene::doPreactions() { warning("TODO: Scene::doPreactions"); } -- cgit v1.2.3 From 436949eba2c51593ad35bab25af1f5fe17f3fe7a Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 20 Mar 2014 08:34:56 -0400 Subject: MADS: Implemented more action logic for highlighting hotspots --- engines/mads/scene.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index baf51fea12..154e4c38bd 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -425,13 +425,13 @@ void Scene::drawElements(ScreenTransition transitionType, bool surfaceFlag) { // Draw any sprites _spriteSlots.drawBackground(); - // Process dirty areas + // Set up dirty areas for any text display _textDisplay.setDirtyAreas(); // Merge any identified dirty areas _dirtyAreas.merge(1, DIRTY_AREAS_SIZE); - // Copy dirty areas to the main display surface + // Copy background for the dirty areas to the screen _dirtyAreas.copy(&_backgroundSurface, &_vm->_screen, _posAdjust); // Handle dirty areas for foreground objects @@ -439,14 +439,13 @@ void Scene::drawElements(ScreenTransition transitionType, bool surfaceFlag) { _textDisplay.setDirtyAreas2(); _dirtyAreas.merge(1, DIRTY_AREAS_SIZE); - // Draw foreground sprites _spriteSlots.drawForeground(&_vm->_screen); // Draw text elements onto the view _textDisplay.draw(&_vm->_screen); - // + // _vm->_screen.setPointer(&_vm->_screen); _userInterface.setBounds(Common::Rect(_vm->_screen._offset.x, _vm->_screen._offset.y, _vm->_screen._offset.x + _vm->_screen.w, _vm->_screen._offset.y + _vm->_screen.h)); -- cgit v1.2.3 From 79f51c4ebd377ae91ec639ecf935c5fc4b2d2a32 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 20 Mar 2014 21:59:43 -0400 Subject: MADS: Minor initial sprite slots loading fixes, missing code from SequenceList::loadSprites --- engines/mads/scene.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index 154e4c38bd..e65460611e 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -288,9 +288,11 @@ void Scene::doFrame() { } if (!_vm->_game->_abortTimers && !player._unk3) { + // Refresh the dynamic hotspots if they've changed if (_dynamicHotspots._changed) _dynamicHotspots.refresh(); + // Check all on-screen visual objects _vm->_game->_screenObjects.check(player._stepEnabled && !_action._startWalkFlag && !_vm->_game->_abortTimers2); } -- cgit v1.2.3 From 2b141aaba681a3c7b848010cd58768f55f4434a3 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 21 Mar 2014 09:27:22 -0400 Subject: MADS: Fixes for screen objects loading and checking --- engines/mads/scene.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index e65460611e..ee5ff1f503 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -337,7 +337,9 @@ void Scene::doFrame() { CursorType cursorId = CURSOR_ARROW; if (_action._v83338 == 1 && !_vm->_game->_screenObjects._v7FECA && _vm->_game->_screenObjects._category == CAT_HOTSPOT) { - int idx = _vm->_game->_screenObjects._selectedObject - _userInterface._screenObjectsCount; + int idx = _vm->_game->_screenObjects._selectedObject - _vm->_game->_screenObjects._hotspotsIndex; + assert(idx >= 0); + if (idx >= (int)_hotspots.size()) { idx -= _hotspots.size(); _vm->_events->_newCursorId = _dynamicHotspots[idx]._cursor; @@ -482,7 +484,15 @@ void Scene::checkStartWalk() { } void Scene::doSceneStep() { - warning("TODO: Scene::doSceneStep"); + _vm->_game->_abortTimersMode2 = ABORTMODE_1; + _sceneLogic->step(); + _vm->_game->_sectionHandler->step(); + + _vm->_game->_player.step(); + _vm->_game->_player._unk3 = 0; + + if (_vm->_game->_abortTimersMode == ABORTMODE_1) + _vm->_game->_abortTimers = 0; } void Scene::checkKeyboard() { -- cgit v1.2.3 From adddf02e70a82e34e990f932f9955b947f7dcbc0 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 22 Mar 2014 19:25:26 +0100 Subject: MADS: Implemente Scene::changeDepthSurface() --- engines/mads/scene.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index ee5ff1f503..e01720f788 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -514,4 +514,10 @@ void Scene::free() { warning("TODO: Scene::free"); } +void Scene::changeDepthSurface(int arg1) { + _v1 = arg1; + _sceneInfo->loadCodes(_depthSurface, nullptr); + _spriteSlots.fullRefresh(); +} + } // End of namespace MADS -- cgit v1.2.3 From db4e74f4dd1994bd468f78eca57800f9f3970b11 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 22 Mar 2014 21:20:39 +0100 Subject: MADS: Add _v8425C, set _globals._v7 as uint32 --- engines/mads/scene.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index e01720f788..9ad494d07d 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -48,6 +48,7 @@ Scene::Scene(MADSEngine *vm): _vm(vm), _action(_vm), _depthSurface(vm), _activeAnimation = nullptr; _textSpacing = -1; _frameStartTime = 0; + _v8425C = 0; _layer = LAYER_GUI; _lookFlag = false; _highlightedHotspot = 0; -- cgit v1.2.3 From 2ac614d898159096933df061c5c0bd221cf8d16b Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 22 Mar 2014 22:30:45 +0100 Subject: MADS: Add some variables in / move a variable to _globals --- engines/mads/scene.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index 9ad494d07d..e01720f788 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -48,7 +48,6 @@ Scene::Scene(MADSEngine *vm): _vm(vm), _action(_vm), _depthSurface(vm), _activeAnimation = nullptr; _textSpacing = -1; _frameStartTime = 0; - _v8425C = 0; _layer = LAYER_GUI; _lookFlag = false; _highlightedHotspot = 0; -- cgit v1.2.3 From a7c4fc7e234f604923aae0d08e03c6b8268688f4 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 22 Mar 2014 18:26:41 -0400 Subject: MADS: In progress implementing ScreenObjects::elementHighlighted --- engines/mads/scene.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index e01720f788..e357f8b1ad 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -337,7 +337,8 @@ void Scene::doFrame() { CursorType cursorId = CURSOR_ARROW; if (_action._v83338 == 1 && !_vm->_game->_screenObjects._v7FECA && _vm->_game->_screenObjects._category == CAT_HOTSPOT) { - int idx = _vm->_game->_screenObjects._selectedObject - _vm->_game->_screenObjects._hotspotsIndex; + int idx = _vm->_game->_screenObjects._selectedObject - + _userInterface._categoryIndexes[CAT_HOTSPOT - 1]; assert(idx >= 0); if (idx >= (int)_hotspots.size()) { -- cgit v1.2.3 From 0b351f79d8ad874ce07fed54eb745a277da28edc Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 22 Mar 2014 21:55:36 -0400 Subject: MADS: Further fixes for hotspot highlighting --- engines/mads/scene.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index e357f8b1ad..da64def95d 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -29,8 +29,8 @@ namespace MADS { Scene::Scene(MADSEngine *vm): _vm(vm), _action(_vm), _depthSurface(vm), - _dirtyAreas(_vm), _dynamicHotspots(vm), _kernelMessages(vm), - _sequences(vm), _sprites(vm), _spriteSlots(vm), + _dirtyAreas(_vm), _dynamicHotspots(vm), _hotspots(vm), + _kernelMessages(vm), _sequences(vm), _sprites(vm), _spriteSlots(vm), _textDisplay(vm), _userInterface(vm) { _priorSceneId = 0; _nextSceneId = 0; -- cgit v1.2.3 From 0d158075019940ccf25b4e5b9bd4676e9a06f87d Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 23 Mar 2014 09:19:28 -0400 Subject: MADS: Fixes for animating inventory item --- engines/mads/scene.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index da64def95d..cfdfa87c61 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -386,7 +386,7 @@ void Scene::doFrame() { _kernelMessages.update(); } - _userInterface._uiSlots.draw(_vm->_game->_abortTimers2 == kTransitionFadeIn, + _userInterface._uiSlots.draw(_vm->_game->_abortTimers2 == 0, _vm->_game->_abortTimers2 != 0); // Write any text needed by the interface -- cgit v1.2.3 From 7f4dbf7d48b6db8d82d33b569c22f104fc153dd3 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 23 Mar 2014 18:48:00 -0400 Subject: MADS: Implemented more action handling methods --- engines/mads/scene.cpp | 54 +++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 51 insertions(+), 3 deletions(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index cfdfa87c61..565ef47395 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -302,7 +302,7 @@ void Scene::doFrame() { _action.startAction(); if (_action._activeAction._verbId == Nebular::NOUN_LOOK_AT) { _action._activeAction._verbId = VERB_LOOK; - _action._savedSelectedRow = false; + _action._savedFields._selectedRow = false; } flag = true; @@ -470,11 +470,59 @@ void Scene::drawElements(ScreenTransition transitionType, bool surfaceFlag) { } void Scene::doPreactions() { - warning("TODO: Scene::doPreactions"); + if (_vm->_game->_screenObjects._v832EC == 0 || _vm->_game->_screenObjects._v832EC == 2) { + _vm->_game->_abortTimersMode2 = ABORTMODE_2; + _action.checkAction(); + _sceneLogic->preActions(); + + if (_vm->_game->_abortTimersMode == ABORTMODE_2) + _vm->_game->_abortTimers = 0; + } } void Scene::doAction() { - warning("TODO: Scene::doAction"); + int flag = 0; + + _vm->_game->_abortTimersMode2 = ABORTMODE_0; + if ((_action._inProgress || _vm->_game->_abortTimers) && !_action._v8453A) { + _sceneLogic->actions(); + _action._inProgress = true; + flag = -1; + } + + if (_vm->_game->_screenObjects._v832EC == 1) { + _action._inProgress = false; + } else { + if ((_action._inProgress || _vm->_game->_abortTimers) || + (!flag && _action._v8453A == flag)) { + _vm->_game->_sectionHandler->sectionPtr2(); + _action._inProgress = true; + flag = -1; + } + + if ((_action._inProgress || _vm->_game->_abortTimers) && (!flag || _action._v8453A == flag)) { + _vm->_game->doObjectAction(); + } + + if (!_action._savedFields._lookFlag) { + if (!_action._inProgress) { + _action._v8453A = -1; + _sceneLogic->postActions(); + } + + if (!_action._inProgress) { + _action._v8453A = -1; + warning("TODO: PtrUnk4"); + } + + if (_action._inProgress) + warning("TODO: sub_1D9DE"); + } + } + + _action._inProgress = false; + if (_vm->_game->_abortTimersMode == ABORTMODE_0) + _vm->_game->_abortTimers = 0; } void Scene::checkStartWalk() { -- cgit v1.2.3 From c57acfb154999b3976c07d6512657c02cc4ef468 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 24 Mar 2014 01:14:16 +0100 Subject: MADS: Implement scene 203 --- engines/mads/scene.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index 565ef47395..00460a9d70 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -569,4 +569,10 @@ void Scene::changeDepthSurface(int arg1) { _spriteSlots.fullRefresh(); } +void Scene::resetScene() { + _vm->_game->clearQuotes(); + _spriteSlots.fullRefresh(true); + _sequences.clear(); +} + } // End of namespace MADS -- cgit v1.2.3 From ce9a15f010d84c8596380eec5226ef22704022e5 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 23 Mar 2014 21:52:18 -0400 Subject: MADS: Fix the setting/clearing of _mouseReleased flag --- engines/mads/scene.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index 00460a9d70..8360c1e396 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -272,6 +272,12 @@ void Scene::loop() { // Handle drawing a game frame doFrame(); + // Reset mouse flags + _vm->_events->resetMouseFlags(); + + // TODO: Verify correctness of frame wait + _vm->_events->waitForNextFrame(); + if (_vm->_dialogs->_pendingDialog != DIALOG_NONE && !_vm->_game->_abortTimers && _vm->_game->_player._stepEnabled) _reloadSceneFlag = true; @@ -421,9 +427,6 @@ void Scene::doFrame() { _activeAnimation->free(); _activeAnimation = nullptr; } - - // TODO: Verify correctness of frame wait - _vm->_events->waitForNextFrame(); } void Scene::drawElements(ScreenTransition transitionType, bool surfaceFlag) { -- cgit v1.2.3 From 0dfa60ae00428ad83c6b6d19963e2d7352707637 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 23 Mar 2014 22:11:35 -0400 Subject: MADS: Refactored out and fixed cursor changes for hotspots --- engines/mads/scene.cpp | 61 ++++++++++++++++++++++++++++---------------------- 1 file changed, 34 insertions(+), 27 deletions(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index 8360c1e396..1b3143f60e 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -340,33 +340,7 @@ void Scene::doFrame() { player.nextFrame(); // Cursor update code - CursorType cursorId = CURSOR_ARROW; - if (_action._v83338 == 1 && !_vm->_game->_screenObjects._v7FECA && - _vm->_game->_screenObjects._category == CAT_HOTSPOT) { - int idx = _vm->_game->_screenObjects._selectedObject - - _userInterface._categoryIndexes[CAT_HOTSPOT - 1]; - assert(idx >= 0); - - if (idx >= (int)_hotspots.size()) { - idx -= _hotspots.size(); - _vm->_events->_newCursorId = _dynamicHotspots[idx]._cursor; - } else { - _vm->_events->_newCursorId = _hotspots[idx]._cursor; - } - - cursorId = _vm->_events->_newCursorId == CURSOR_NONE ? - CURSOR_ARROW : _vm->_events->_newCursorId; - } - - if (!player._stepEnabled) - cursorId = CURSOR_WAIT; - if (cursorId >= _vm->_events->_cursorSprites->getCount()) - cursorId = (CursorType)_vm->_events->_cursorSprites->getCount(); - _vm->_events->_newCursorId = cursorId; - - if (cursorId != _vm->_events->_cursorId) { - _vm->_events->setCursor(cursorId); - } + updateCursor(); if (!_vm->_game->_abortTimers) { // Handle any active sequences @@ -562,6 +536,39 @@ void Scene::loadAnimation(const Common::String &resName, int abortTimers) { _activeAnimation->startAnimation(abortTimers); } +void Scene::updateCursor() { + Player &player = _vm->_game->_player; + + CursorType cursorId = CURSOR_ARROW; + if (_action._v83338 == 1 && !_vm->_game->_screenObjects._v7FECA && + _vm->_game->_screenObjects._category == CAT_HOTSPOT) { + int idx = _vm->_game->_screenObjects._selectedObject - + _userInterface._categoryIndexes[CAT_HOTSPOT - 1]; + assert(idx >= 0); + + if (idx >= (int)_hotspots.size()) { + idx -= _hotspots.size(); + _vm->_events->_newCursorId = _dynamicHotspots[idx]._cursor; + } else { + idx = _hotspots.size() - idx - 1; + _vm->_events->_newCursorId = _hotspots[idx]._cursor; + } + + cursorId = _vm->_events->_newCursorId == CURSOR_NONE ? + CURSOR_ARROW : _vm->_events->_newCursorId; + } + + if (!player._stepEnabled) + cursorId = CURSOR_WAIT; + if (cursorId >= _vm->_events->_cursorSprites->getCount()) + cursorId = (CursorType)_vm->_events->_cursorSprites->getCount(); + _vm->_events->_newCursorId = cursorId; + + if (cursorId != _vm->_events->_cursorId) { + _vm->_events->setCursor(cursorId); + } +} + void Scene::free() { warning("TODO: Scene::free"); } -- cgit v1.2.3 From 407021d245f1e0446867824c6306337f18fe8eb3 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 25 Mar 2014 22:07:33 -0400 Subject: MADS: Added a Facing enum for the player directions --- engines/mads/scene.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index 1b3143f60e..6a42ed9005 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -42,7 +42,7 @@ Scene::Scene(MADSEngine *vm): _vm(vm), _action(_vm), _depthSurface(vm), _depthStyle = 0; _roomChanged = false; _reloadSceneFlag = false; - _destFacing = 0; + _targetFacing = FACING_NONE; _freeAnimationFlag = false; _animationData = nullptr; _activeAnimation = nullptr; @@ -504,7 +504,7 @@ void Scene::doAction() { void Scene::checkStartWalk() { if (_action._startWalkFlag && _action._walkFlag) { - _vm->_game->_player.setDest(_destPos, _destFacing); + _vm->_game->_player.setDest(_destPos, _targetFacing); _action._startWalkFlag = false; } } -- cgit v1.2.3 From f9e2c1c71f29f6dc1ba8e860d597fe93bc79646a Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 26 Mar 2014 09:32:33 -0400 Subject: MADS: Cleaned up game initialisation code to use more constants --- engines/mads/scene.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index 6a42ed9005..c90a54c317 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -323,7 +323,7 @@ void Scene::doFrame() { _frameStartTime = _vm->_events->getFrameCounter(); if ((_action._inProgress && !player._moving && !_action._startWalkFlag && - player._newDirection == player._direction) || + player._turnToFacing == player._facing) || (_vm->_game->_abortTimers && _vm->_game->_abortTimersMode == ABORTMODE_0)) { doAction(); } -- cgit v1.2.3 From 0a4c4c8eda3500915372a6c9987e524016ec566f Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 26 Mar 2014 22:58:24 -0400 Subject: MADS: Walking is now sort of working --- engines/mads/scene.cpp | 3 --- 1 file changed, 3 deletions(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index c90a54c317..f16b2c3889 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -272,9 +272,6 @@ void Scene::loop() { // Handle drawing a game frame doFrame(); - // Reset mouse flags - _vm->_events->resetMouseFlags(); - // TODO: Verify correctness of frame wait _vm->_events->waitForNextFrame(); -- cgit v1.2.3 From 6c85572d76245f616ae3bf2ac1ccc713d8271fa9 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 27 Mar 2014 22:38:28 -0400 Subject: MADS: Initial cleanup of action/player handling --- engines/mads/scene.cpp | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index f16b2c3889..aa57a7e6b3 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -275,7 +275,7 @@ void Scene::loop() { // TODO: Verify correctness of frame wait _vm->_events->waitForNextFrame(); - if (_vm->_dialogs->_pendingDialog != DIALOG_NONE && !_vm->_game->_abortTimers + if (_vm->_dialogs->_pendingDialog != DIALOG_NONE && !_vm->_game->_trigger && _vm->_game->_player._stepEnabled) _reloadSceneFlag = true; } @@ -290,18 +290,18 @@ void Scene::doFrame() { _action._selectedAction = 0; } - if (!_vm->_game->_abortTimers && !player._unk3) { + if (!_vm->_game->_trigger && !player._unk3) { // Refresh the dynamic hotspots if they've changed if (_dynamicHotspots._changed) _dynamicHotspots.refresh(); // Check all on-screen visual objects _vm->_game->_screenObjects.check(player._stepEnabled && !_action._startWalkFlag && - !_vm->_game->_abortTimers2); + !_vm->_game->_fx); } if (_action._selectedAction && player._stepEnabled && !_action._startWalkFlag && - !_vm->_game->_abortTimers && !player._unk3) { + !_vm->_game->_trigger && !player._unk3) { _action.startAction(); if (_action._activeAction._verbId == Nebular::NOUN_LOOK_AT) { _action._activeAction._verbId = VERB_LOOK; @@ -311,17 +311,17 @@ void Scene::doFrame() { flag = true; } - if (flag || (_vm->_game->_abortTimers && _vm->_game->_abortTimersMode == ABORTMODE_2)) { + if (flag || (_vm->_game->_trigger && _vm->_game->_abortTimersMode == ABORTMODE_2)) { doPreactions(); } checkStartWalk(); - if (!_vm->_game->_abortTimers2) + if (!_vm->_game->_fx) _frameStartTime = _vm->_events->getFrameCounter(); if ((_action._inProgress && !player._moving && !_action._startWalkFlag && player._turnToFacing == player._facing) || - (_vm->_game->_abortTimers && _vm->_game->_abortTimersMode == ABORTMODE_0)) { + (_vm->_game->_trigger && _vm->_game->_abortTimersMode == ABORTMODE_0)) { doAction(); } @@ -339,7 +339,7 @@ void Scene::doFrame() { // Cursor update code updateCursor(); - if (!_vm->_game->_abortTimers) { + if (!_vm->_game->_trigger) { // Handle any active sequences _sequences.tick(); @@ -357,24 +357,24 @@ void Scene::doFrame() { 0x203, 0, 0, 1, msg); } - if (!_vm->_game->_abortTimers) { + if (!_vm->_game->_trigger) { if (_reloadSceneFlag || _currentSceneId != _nextSceneId) _kernelMessages.reset(); _kernelMessages.update(); } - _userInterface._uiSlots.draw(_vm->_game->_abortTimers2 == 0, - _vm->_game->_abortTimers2 != 0); + _userInterface._uiSlots.draw(_vm->_game->_fx == 0, + _vm->_game->_fx != 0); // Write any text needed by the interface - if (_vm->_game->_abortTimers2) + if (_vm->_game->_fx) _userInterface.drawTextElements(); // Draw any elements - drawElements((ScreenTransition)_vm->_game->_abortTimers2, _vm->_game->_abortTimers2); + drawElements((ScreenTransition)_vm->_game->_fx, _vm->_game->_fx); // Handle message updates - if (_vm->_game->_abortTimers2) { + if (_vm->_game->_fx) { uint32 priorTime = _vm->_game->_priorFrameTimer; uint32 newTime = _vm->_events->getFrameCounter(); _sequences.delay(newTime, priorTime); @@ -390,9 +390,9 @@ void Scene::doFrame() { } } - if (_vm->_game->_abortTimers2) + if (_vm->_game->_fx) _animFlag = true; - _vm->_game->_abortTimers2 = 0; + _vm->_game->_fx = kTransitionNone; if (_freeAnimationFlag) { _activeAnimation->free(); @@ -450,7 +450,7 @@ void Scene::doPreactions() { _sceneLogic->preActions(); if (_vm->_game->_abortTimersMode == ABORTMODE_2) - _vm->_game->_abortTimers = 0; + _vm->_game->_trigger = 0; } } @@ -458,7 +458,7 @@ void Scene::doAction() { int flag = 0; _vm->_game->_abortTimersMode2 = ABORTMODE_0; - if ((_action._inProgress || _vm->_game->_abortTimers) && !_action._v8453A) { + if ((_action._inProgress || _vm->_game->_trigger) && !_action._v8453A) { _sceneLogic->actions(); _action._inProgress = true; flag = -1; @@ -467,14 +467,14 @@ void Scene::doAction() { if (_vm->_game->_screenObjects._v832EC == 1) { _action._inProgress = false; } else { - if ((_action._inProgress || _vm->_game->_abortTimers) || + if ((_action._inProgress || _vm->_game->_trigger) || (!flag && _action._v8453A == flag)) { _vm->_game->_sectionHandler->sectionPtr2(); _action._inProgress = true; flag = -1; } - if ((_action._inProgress || _vm->_game->_abortTimers) && (!flag || _action._v8453A == flag)) { + if ((_action._inProgress || _vm->_game->_trigger) && (!flag || _action._v8453A == flag)) { _vm->_game->doObjectAction(); } @@ -496,7 +496,7 @@ void Scene::doAction() { _action._inProgress = false; if (_vm->_game->_abortTimersMode == ABORTMODE_0) - _vm->_game->_abortTimers = 0; + _vm->_game->_trigger = 0; } void Scene::checkStartWalk() { @@ -515,7 +515,7 @@ void Scene::doSceneStep() { _vm->_game->_player._unk3 = 0; if (_vm->_game->_abortTimersMode == ABORTMODE_1) - _vm->_game->_abortTimers = 0; + _vm->_game->_trigger = 0; } void Scene::checkKeyboard() { @@ -537,7 +537,7 @@ void Scene::updateCursor() { Player &player = _vm->_game->_player; CursorType cursorId = CURSOR_ARROW; - if (_action._v83338 == 1 && !_vm->_game->_screenObjects._v7FECA && + if (_action._interAwaiting == 1 && !_vm->_game->_screenObjects._v7FECA && _vm->_game->_screenObjects._category == CAT_HOTSPOT) { int idx = _vm->_game->_screenObjects._selectedObject - _userInterface._categoryIndexes[CAT_HOTSPOT - 1]; -- cgit v1.2.3 From b9daf53bcd14332624f3d18fd21514b1f9146107 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 28 Mar 2014 09:19:55 -0400 Subject: MADS: Cleanup of direction setup, fix sprite mirroring for walking --- engines/mads/scene.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index aa57a7e6b3..62702518fc 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -290,7 +290,7 @@ void Scene::doFrame() { _action._selectedAction = 0; } - if (!_vm->_game->_trigger && !player._unk3) { + if (!_vm->_game->_trigger && !player._trigger) { // Refresh the dynamic hotspots if they've changed if (_dynamicHotspots._changed) _dynamicHotspots.refresh(); @@ -301,7 +301,7 @@ void Scene::doFrame() { } if (_action._selectedAction && player._stepEnabled && !_action._startWalkFlag && - !_vm->_game->_trigger && !player._unk3) { + !_vm->_game->_trigger && !player._trigger) { _action.startAction(); if (_action._activeAction._verbId == Nebular::NOUN_LOOK_AT) { _action._activeAction._verbId = VERB_LOOK; @@ -512,7 +512,7 @@ void Scene::doSceneStep() { _vm->_game->_sectionHandler->step(); _vm->_game->_player.step(); - _vm->_game->_player._unk3 = 0; + _vm->_game->_player._trigger = 0; if (_vm->_game->_abortTimersMode == ABORTMODE_1) _vm->_game->_trigger = 0; -- cgit v1.2.3 From fac216be332ac1540d5ddcf0cffcc7ccf34c4a81 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 28 Mar 2014 23:07:22 -0400 Subject: MADS: Cleanup of Scene::checkStartWalk to become Player::newWalk --- engines/mads/scene.cpp | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index 62702518fc..2e788115db 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -42,7 +42,6 @@ Scene::Scene(MADSEngine *vm): _vm(vm), _action(_vm), _depthSurface(vm), _depthStyle = 0; _roomChanged = false; _reloadSceneFlag = false; - _targetFacing = FACING_NONE; _freeAnimationFlag = false; _animationData = nullptr; _activeAnimation = nullptr; @@ -296,11 +295,11 @@ void Scene::doFrame() { _dynamicHotspots.refresh(); // Check all on-screen visual objects - _vm->_game->_screenObjects.check(player._stepEnabled && !_action._startWalkFlag && + _vm->_game->_screenObjects.check(player._stepEnabled && !player._needToWalk && !_vm->_game->_fx); } - if (_action._selectedAction && player._stepEnabled && !_action._startWalkFlag && + if (_action._selectedAction && player._stepEnabled && !player._needToWalk && !_vm->_game->_trigger && !player._trigger) { _action.startAction(); if (_action._activeAction._verbId == Nebular::NOUN_LOOK_AT) { @@ -315,11 +314,11 @@ void Scene::doFrame() { doPreactions(); } - checkStartWalk(); + player.newWalk(); if (!_vm->_game->_fx) _frameStartTime = _vm->_events->getFrameCounter(); - if ((_action._inProgress && !player._moving && !_action._startWalkFlag && + if ((_action._inProgress && !player._moving && !player._needToWalk && player._turnToFacing == player._facing) || (_vm->_game->_trigger && _vm->_game->_abortTimersMode == ABORTMODE_0)) { doAction(); @@ -499,13 +498,6 @@ void Scene::doAction() { _vm->_game->_trigger = 0; } -void Scene::checkStartWalk() { - if (_action._startWalkFlag && _action._walkFlag) { - _vm->_game->_player.setDest(_destPos, _targetFacing); - _action._startWalkFlag = false; - } -} - void Scene::doSceneStep() { _vm->_game->_abortTimersMode2 = ABORTMODE_1; _sceneLogic->step(); -- cgit v1.2.3 From 71b1343adf6e886cfd2e1a0040a12b5025672d14 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 29 Mar 2014 11:18:07 -0400 Subject: MADS: Implemented NebularGame::step --- engines/mads/scene.cpp | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index 2e788115db..f61928f6d0 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -310,7 +310,7 @@ void Scene::doFrame() { flag = true; } - if (flag || (_vm->_game->_trigger && _vm->_game->_abortTimersMode == ABORTMODE_2)) { + if (flag || (_vm->_game->_trigger && _vm->_game->_triggerMode == KERNEL_TRIGGER_PREPARE)) { doPreactions(); } @@ -320,7 +320,7 @@ void Scene::doFrame() { if ((_action._inProgress && !player._moving && !player._needToWalk && player._turnToFacing == player._facing) || - (_vm->_game->_trigger && _vm->_game->_abortTimersMode == ABORTMODE_0)) { + (_vm->_game->_trigger && _vm->_game->_triggerMode == KERNEL_TRIGGER_PARSER)) { doAction(); } @@ -444,11 +444,11 @@ void Scene::drawElements(ScreenTransition transitionType, bool surfaceFlag) { void Scene::doPreactions() { if (_vm->_game->_screenObjects._v832EC == 0 || _vm->_game->_screenObjects._v832EC == 2) { - _vm->_game->_abortTimersMode2 = ABORTMODE_2; + _vm->_game->_triggerSetupMode = KERNEL_TRIGGER_PREPARE; _action.checkAction(); _sceneLogic->preActions(); - if (_vm->_game->_abortTimersMode == ABORTMODE_2) + if (_vm->_game->_triggerMode == KERNEL_TRIGGER_PREPARE) _vm->_game->_trigger = 0; } } @@ -456,7 +456,7 @@ void Scene::doPreactions() { void Scene::doAction() { int flag = 0; - _vm->_game->_abortTimersMode2 = ABORTMODE_0; + _vm->_game->_triggerSetupMode = KERNEL_TRIGGER_PARSER; if ((_action._inProgress || _vm->_game->_trigger) && !_action._v8453A) { _sceneLogic->actions(); _action._inProgress = true; @@ -494,19 +494,17 @@ void Scene::doAction() { } _action._inProgress = false; - if (_vm->_game->_abortTimersMode == ABORTMODE_0) + if (_vm->_game->_triggerMode == KERNEL_TRIGGER_PARSER) _vm->_game->_trigger = 0; } void Scene::doSceneStep() { - _vm->_game->_abortTimersMode2 = ABORTMODE_1; + _vm->_game->_triggerSetupMode = KERNEL_TRIGGER_DAEMON; _sceneLogic->step(); _vm->_game->_sectionHandler->step(); + _vm->_game->step(); - _vm->_game->_player.step(); - _vm->_game->_player._trigger = 0; - - if (_vm->_game->_abortTimersMode == ABORTMODE_1) + if (_vm->_game->_triggerMode == KERNEL_TRIGGER_DAEMON) _vm->_game->_trigger = 0; } -- cgit v1.2.3 From addb3e2900ee417fb71a75f9afae08b00007daa5 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 29 Mar 2014 13:38:52 -0400 Subject: MADS: Minor renamings and added display of walk nodes to debugger --- engines/mads/scene.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index f61928f6d0..b8b8888e53 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -136,6 +136,10 @@ void Scene::loadScene(int sceneId, const Common::String &prefix, bool palFlag) { for (uint i = 0; i < _sceneInfo->_nodes.size(); ++i) _nodes.push_back(_sceneInfo->_nodes[i]); + // Add two more empty nodes for the start and end points of any walk sequence + _nodes.push_back(SceneNode()); + _nodes.push_back(SceneNode()); + // Load hotspots loadHotspots(); -- cgit v1.2.3 From f3db90b646d4af5b6daf43d11e99d59de0649b03 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 29 Mar 2014 17:12:12 -0400 Subject: MADS: Refactored pathfinder into it's own class --- engines/mads/scene.cpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index b8b8888e53..83c059444d 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -132,13 +132,7 @@ void Scene::loadScene(int sceneId, const Common::String &prefix, bool palFlag) { initPaletteAnimation(_sceneInfo->_palAnimData, false); // Copy over nodes - _nodes.clear(); - for (uint i = 0; i < _sceneInfo->_nodes.size(); ++i) - _nodes.push_back(_sceneInfo->_nodes[i]); - - // Add two more empty nodes for the start and end points of any walk sequence - _nodes.push_back(SceneNode()); - _nodes.push_back(SceneNode()); + _rails.load(_sceneInfo->_nodes, &_depthSurface, _sceneInfo->_depthStyle); // Load hotspots loadHotspots(); -- cgit v1.2.3 From 195c53a68853db6a77c6a63d392968ba912cf2f4 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 30 Mar 2014 22:37:08 -0400 Subject: MADS: Added some missing code for scene change freeing --- engines/mads/scene.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index 83c059444d..21d09fb056 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -555,7 +555,21 @@ void Scene::updateCursor() { } void Scene::free() { - warning("TODO: Scene::free"); + if (_animationData) { + delete _animationData; + _animationData = nullptr; + } + if (_activeAnimation) { + delete _activeAnimation; + _activeAnimation = nullptr; + } + + _hotspots.clear(); + _backgroundSurface.free(); + _depthSurface.free(); + + delete _sceneInfo; + _sceneInfo = nullptr; } void Scene::changeDepthSurface(int arg1) { -- cgit v1.2.3 From 0c1001fbf4c37379ec685b036e63d6d59055997a Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 1 Apr 2014 22:50:03 -0400 Subject: MADS: Minor variable renaming and remove incorrect variable set in scene loop --- engines/mads/scene.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index 21d09fb056..71e6873de5 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -263,8 +263,6 @@ bool Scene::getDepthHighBits(const Common::Point &pt) { } void Scene::loop() { - _nextSceneId = _currentSceneId; - while (!_vm->shouldQuit() && !_reloadSceneFlag && _nextSceneId == _currentSceneId) { // Handle drawing a game frame doFrame(); -- cgit v1.2.3 From 041773705be6dd1fb09d71e482f4974247cee61f Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 2 Apr 2014 20:28:57 -0400 Subject: MADS: Fix/clean up ending of ScreenObjects::check --- engines/mads/scene.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index 71e6873de5..d37834ab55 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -582,4 +582,8 @@ void Scene::resetScene() { _sequences.clear(); } +void Scene::backgroundAnimation() { + warning("TODO: Scene::backgroundAnimation"); +} + } // End of namespace MADS -- cgit v1.2.3 From f0458042f212e10155e4206312e46ce0beb7c06f Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 2 Apr 2014 22:27:11 -0400 Subject: MADS: In progress cleanup of checkActionAtMousePos --- engines/mads/scene.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index d37834ab55..97a131a665 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -49,7 +49,6 @@ Scene::Scene(MADSEngine *vm): _vm(vm), _action(_vm), _depthSurface(vm), _frameStartTime = 0; _layer = LAYER_GUI; _lookFlag = false; - _highlightedHotspot = 0; _verbList.push_back(VerbInit(VERB_LOOK, 2, 0)); _verbList.push_back(VerbInit(VERB_TAKE, 2, 0)); -- cgit v1.2.3 From 74c6bafed4eb80f93284a60219f27c150eb2baf5 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 2 Apr 2014 22:41:25 -0400 Subject: MADS: Further clean up/renaming of checkActionAtMousePos --- engines/mads/scene.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index 97a131a665..9e27f2724e 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -522,7 +522,7 @@ void Scene::updateCursor() { Player &player = _vm->_game->_player; CursorType cursorId = CURSOR_ARROW; - if (_action._interAwaiting == 1 && !_vm->_game->_screenObjects._v7FECA && + if (_action._interAwaiting == 1 && !_vm->_events->_anyStroke && _vm->_game->_screenObjects._category == CAT_HOTSPOT) { int idx = _vm->_game->_screenObjects._selectedObject - _userInterface._categoryIndexes[CAT_HOTSPOT - 1]; -- cgit v1.2.3 From d163ee088a9f3e49463fddd05a41d1b1530e77db Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 3 Apr 2014 22:02:12 -0400 Subject: MADS: Renamings for saving fields in MADSAction::startAction --- engines/mads/scene.cpp | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index 9e27f2724e..a71eade786 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -160,7 +160,7 @@ void Scene::loadScene(int sceneId, const Common::String &prefix, bool palFlag) { _interfaceY = MADS_SCENE_HEIGHT; _spritesCount = _sprites.size(); - _userInterface.setup(_vm->_game->_screenObjects._v832EC); + _userInterface.setup(_vm->_game->_screenObjects._inputMode); warning("TODO: showMouse"); @@ -299,7 +299,7 @@ void Scene::doFrame() { _action.startAction(); if (_action._activeAction._verbId == Nebular::NOUN_LOOK_AT) { _action._activeAction._verbId = VERB_LOOK; - _action._savedFields._selectedRow = false; + _action._savedFields._command = false; } flag = true; @@ -438,7 +438,8 @@ void Scene::drawElements(ScreenTransition transitionType, bool surfaceFlag) { } void Scene::doPreactions() { - if (_vm->_game->_screenObjects._v832EC == 0 || _vm->_game->_screenObjects._v832EC == 2) { + if (_vm->_game->_screenObjects._inputMode == kInputBuildingSentences || + _vm->_game->_screenObjects._inputMode == kInputLimitedSentences) { _vm->_game->_triggerSetupMode = KERNEL_TRIGGER_PREPARE; _action.checkAction(); _sceneLogic->preActions(); @@ -449,37 +450,38 @@ void Scene::doPreactions() { } void Scene::doAction() { - int flag = 0; + bool flag = false; _vm->_game->_triggerSetupMode = KERNEL_TRIGGER_PARSER; - if ((_action._inProgress || _vm->_game->_trigger) && !_action._v8453A) { + if ((_action._inProgress || _vm->_game->_trigger) && !_action._savedFields._commandError) { _sceneLogic->actions(); _action._inProgress = true; - flag = -1; + flag = true; } - if (_vm->_game->_screenObjects._v832EC == 1) { + if (_vm->_game->_screenObjects._inputMode == kInputConversation) { _action._inProgress = false; } else { if ((_action._inProgress || _vm->_game->_trigger) || - (!flag && _action._v8453A == flag)) { + (!flag && _action._savedFields._commandError == flag)) { _vm->_game->_sectionHandler->sectionPtr2(); _action._inProgress = true; - flag = -1; + flag = true; } - if ((_action._inProgress || _vm->_game->_trigger) && (!flag || _action._v8453A == flag)) { + if ((_action._inProgress || _vm->_game->_trigger) && + (!flag || _action._savedFields._commandError == flag)) { _vm->_game->doObjectAction(); } if (!_action._savedFields._lookFlag) { if (!_action._inProgress) { - _action._v8453A = -1; + _action._savedFields._commandError = true; _sceneLogic->postActions(); } if (!_action._inProgress) { - _action._v8453A = -1; + _action._savedFields._commandError = true; warning("TODO: PtrUnk4"); } -- cgit v1.2.3 From b778217d8eea64d385947a96a94cdea7c686c605 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 4 Apr 2014 20:57:09 -0400 Subject: MADS: Fix for actions get repeated endlessly --- engines/mads/scene.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index a71eade786..64260a69dc 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -455,8 +455,7 @@ void Scene::doAction() { _vm->_game->_triggerSetupMode = KERNEL_TRIGGER_PARSER; if ((_action._inProgress || _vm->_game->_trigger) && !_action._savedFields._commandError) { _sceneLogic->actions(); - _action._inProgress = true; - flag = true; + flag = !_action._inProgress; } if (_vm->_game->_screenObjects._inputMode == kInputConversation) { @@ -465,8 +464,7 @@ void Scene::doAction() { if ((_action._inProgress || _vm->_game->_trigger) || (!flag && _action._savedFields._commandError == flag)) { _vm->_game->_sectionHandler->sectionPtr2(); - _action._inProgress = true; - flag = true; + flag = !_action._inProgress; } if ((_action._inProgress || _vm->_game->_trigger) && -- cgit v1.2.3 From ebe4d369a54d852b7d789ac247a872799e68e495 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 5 Apr 2014 12:43:50 -0400 Subject: MADS: Fixes for actions triggering prematurely --- engines/mads/scene.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index 64260a69dc..02877aac9c 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -313,9 +313,10 @@ void Scene::doFrame() { if (!_vm->_game->_fx) _frameStartTime = _vm->_events->getFrameCounter(); - if ((_action._inProgress && !player._moving && !player._needToWalk && - player._turnToFacing == player._facing) || - (_vm->_game->_trigger && _vm->_game->_triggerMode == KERNEL_TRIGGER_PARSER)) { + // Handle parser actions as well as game triggers + if ((_action._inProgress && !player._moving && !player._needToWalk && + (player._facing == player._turnToFacing) && !_vm->_game->_trigger) || + (_vm->_game->_trigger && (_vm->_game->_triggerMode == KERNEL_TRIGGER_PARSER))) { doAction(); } -- cgit v1.2.3 From 06aeba275acb80df86ff103880c07ccc0e9738b1 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 5 Apr 2014 14:27:33 -0400 Subject: MADS: Fix right mouse button handling --- engines/mads/scene.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index 02877aac9c..2d95f86636 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -523,7 +523,7 @@ void Scene::updateCursor() { Player &player = _vm->_game->_player; CursorType cursorId = CURSOR_ARROW; - if (_action._interAwaiting == 1 && !_vm->_events->_anyStroke && + if (_action._interAwaiting == 1 && !_vm->_events->_rightMousePressed && _vm->_game->_screenObjects._category == CAT_HOTSPOT) { int idx = _vm->_game->_screenObjects._selectedObject - _userInterface._categoryIndexes[CAT_HOTSPOT - 1]; -- cgit v1.2.3 From 0b9c802bf0095568d71db5d10b3b6dbe075934fb Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 5 Apr 2014 17:19:51 -0400 Subject: MADS: Fix for actions getting aborted due to _commandError being set --- engines/mads/scene.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index 2d95f86636..140077418b 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -474,12 +474,12 @@ void Scene::doAction() { } if (!_action._savedFields._lookFlag) { - if (!_action._inProgress) { + if (_action._inProgress) { _action._savedFields._commandError = true; _sceneLogic->postActions(); } - if (!_action._inProgress) { + if (_action._inProgress) { _action._savedFields._commandError = true; warning("TODO: PtrUnk4"); } -- cgit v1.2.3 From ff7d2e2dbf60202cc24b26b1ac61c0e76e802191 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 5 Apr 2014 22:41:25 -0400 Subject: MADS: Add missing scene codes variant handling --- engines/mads/scene.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index 140077418b..9ef7d0b245 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -114,7 +114,7 @@ void Scene::loadScene(int sceneId, const Common::String &prefix, bool palFlag) { _priorSceneId = _currentSceneId; _currentSceneId = sceneId; - _v1 = 0; + _variant = 0; if (palFlag) _vm->_palette->resetGamePalette(18, 10); @@ -124,7 +124,7 @@ void Scene::loadScene(int sceneId, const Common::String &prefix, bool palFlag) { // TODO: palletteUsage reset? setPalette(_nullPalette); _sceneInfo = SceneInfo::init(_vm); - _sceneInfo->load(_currentSceneId, _v1, Common::String(), _vm->_game->_v2 ? 17 : 16, + _sceneInfo->load(_currentSceneId, _variant, Common::String(), _vm->_game->_v2 ? 17 : 16, _depthSurface, _backgroundSurface); // Initialise palette animation for the scene @@ -570,9 +570,9 @@ void Scene::free() { _sceneInfo = nullptr; } -void Scene::changeDepthSurface(int arg1) { - _v1 = arg1; - _sceneInfo->loadCodes(_depthSurface, nullptr); +void Scene::changeVariant(int variant) { + _variant = variant; + _sceneInfo->loadCodes(_depthSurface, variant); _spriteSlots.fullRefresh(); } -- cgit v1.2.3 From 2457905ed42820d27264a4beccc9ae45da746c18 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 6 Apr 2014 21:24:35 -0400 Subject: MADS: Fixes for switching between scenes --- engines/mads/scene.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index 9ef7d0b245..d297cb79ec 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -389,7 +389,7 @@ void Scene::doFrame() { _animFlag = true; _vm->_game->_fx = kTransitionNone; - if (_freeAnimationFlag) { + if (_freeAnimationFlag && _activeAnimation) { _activeAnimation->free(); _activeAnimation = nullptr; } @@ -570,6 +570,11 @@ void Scene::free() { _sceneInfo = nullptr; } +void Scene::removeSprites() { + for (int idx = _sprites.size() - 1; idx >= _spritesCount; --idx) + _sprites.remove(idx); +} + void Scene::changeVariant(int variant) { _variant = variant; _sceneInfo->loadCodes(_depthSurface, variant); -- cgit v1.2.3 From 66b7419f30eb4fb0f9df899eea664f529cfb84fd Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 7 Apr 2014 08:29:27 -0400 Subject: MADS: Remove stubbed methods that were undeed mouse handler calls --- engines/mads/scene.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index d297cb79ec..f5d1ce66f7 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -358,8 +358,7 @@ void Scene::doFrame() { _kernelMessages.update(); } - _userInterface._uiSlots.draw(_vm->_game->_fx == 0, - _vm->_game->_fx != 0); + _userInterface._uiSlots.draw(!_vm->_game->_fx, _vm->_game->_fx); // Write any text needed by the interface if (_vm->_game->_fx) @@ -395,7 +394,7 @@ void Scene::doFrame() { } } -void Scene::drawElements(ScreenTransition transitionType, bool surfaceFlag) { +void Scene::drawElements(ScreenTransition transitionType, bool surfaceFlag) { // Draw any sprites _spriteSlots.drawBackground(); @@ -433,7 +432,6 @@ void Scene::drawElements(ScreenTransition transitionType, bool surfaceFlag) { _dirtyAreas.copyToScreen(_vm->_screen._offset); } - warning("TODO: sub_115A2"); _spriteSlots.cleanUp(); _textDisplay.cleanUp(); } -- cgit v1.2.3 From f6a6ea974117cd8401a2caecdba9ef553821d41a Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 7 Apr 2014 08:34:13 -0400 Subject: MADS: Remove stub warning for originald debugger code not to be implemented --- engines/mads/scene.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index f5d1ce66f7..b178de5839 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -379,8 +379,8 @@ void Scene::doFrame() { // Mouse position display isn't persistent, so remove it _kernelMessages.remove(mouseTextIndex); - - warning("TODO: sub_1DA3E"); + // Original had a debugger check/call here to allow pausing after + // drawing each frame. Not implemented under ScummVM } } -- cgit v1.2.3 From 7e13f488abeb6a7530d591bae880fdb185c8fef1 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 7 Apr 2014 22:37:22 -0400 Subject: MADS: Implement loading logic for UI background animations --- engines/mads/scene.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index b178de5839..ac57e0bcbf 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -123,8 +123,12 @@ void Scene::loadScene(int sceneId, const Common::String &prefix, bool palFlag) { _kernelMessages.clear(); // TODO: palletteUsage reset? setPalette(_nullPalette); + int flags = SCENEFLAG_LOAD_SHADOW; + if (_vm->_dithering) + flags |= SCENEFLAG_DITHER; + _sceneInfo = SceneInfo::init(_vm); - _sceneInfo->load(_currentSceneId, _variant, Common::String(), _vm->_game->_v2 ? 17 : 16, + _sceneInfo->load(_currentSceneId, _variant, Common::String(), flags, _depthSurface, _backgroundSurface); // Initialise palette animation for the scene @@ -143,10 +147,12 @@ void Scene::loadScene(int sceneId, const Common::String &prefix, bool palFlag) { _vm->_palette->_paletteUsage.load(1, 0xF); // Load interface - int flags = _vm->_game->_v2 ? 0x4101 : 0x4100; - if (!_vm->_textWindowStill) - flags |= 0x200; - + flags = PALFLAG_RESERVED | ANIMFLAG_LOAD_BACKGROUND; + if (_vm->_dithering) + flags |= ANIMFLAG_DITHER; + if (_vm->_textWindowStill) + flags |= ANIMFLAG_LOAD_BACKGROUND_ONLY; + _animationData = Animation::init(_vm, this); MSurface depthSurface; _animationData->load(_userInterface, depthSurface, prefix, flags, nullptr, nullptr); @@ -513,7 +519,7 @@ void Scene::loadAnimation(const Common::String &resName, int abortTimers) { _activeAnimation = Animation::init(_vm, this); _activeAnimation->load(interfaceSurface, depthSurface, resName, - _vm->_game->_v2 ? 1 : 0, nullptr, nullptr); + _vm->_dithering ? ANIMFLAG_DITHER : 0, nullptr, nullptr); _activeAnimation->startAnimation(abortTimers); } @@ -585,8 +591,4 @@ void Scene::resetScene() { _sequences.clear(); } -void Scene::backgroundAnimation() { - warning("TODO: Scene::backgroundAnimation"); -} - } // End of namespace MADS -- cgit v1.2.3 From 531ebab4da814aac23a9b084772a6156bfb3b9b8 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 8 Apr 2014 22:04:43 -0400 Subject: MADS: Added preliminary keyboard handling and keypress process stub --- engines/mads/scene.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index ac57e0bcbf..8cb5fbcf87 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -509,7 +509,17 @@ void Scene::doSceneStep() { } void Scene::checkKeyboard() { - warning("TODO: Scene::checkKeyboard"); + if (_vm->_events->isKeyPressed()) { + Common::Event evt = _vm->_events->_pendingKeys.pop(); + _vm->_game->handleKeypress(evt); + } + + if ((_vm->_events->_mouseStatus & 3) == 3 && _vm->_game->_player._stepEnabled) { + _reloadSceneFlag = true; + _vm->_dialogs->_pendingDialog = DIALOG_GAME_MENU; + _action.clear(); + _action._selectedAction = 0; + } } void Scene::loadAnimation(const Common::String &resName, int abortTimers) { -- cgit v1.2.3 From 21a0e38f34324423e0f571ccb37a800737cd78d2 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 8 Apr 2014 22:21:45 -0400 Subject: MADS: Resolve some old TODOs --- engines/mads/scene.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index 8cb5fbcf87..76263bd0f6 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -168,7 +168,7 @@ void Scene::loadScene(int sceneId, const Common::String &prefix, bool palFlag) { _userInterface.setup(_vm->_game->_screenObjects._inputMode); - warning("TODO: showMouse"); + _vm->_events->showCursor(); warning("TODO: inventory_anim_allocate"); } -- cgit v1.2.3 From 09adb571d35c45941246bdce5db895d9d81fd59c Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 8 Apr 2014 23:01:46 -0400 Subject: MADS: Cleanup of verb/preposition flags handling --- engines/mads/scene.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index 76263bd0f6..02a066a0c6 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -50,16 +50,16 @@ Scene::Scene(MADSEngine *vm): _vm(vm), _action(_vm), _depthSurface(vm), _layer = LAYER_GUI; _lookFlag = false; - _verbList.push_back(VerbInit(VERB_LOOK, 2, 0)); - _verbList.push_back(VerbInit(VERB_TAKE, 2, 0)); - _verbList.push_back(VerbInit(VERB_PUSH, 2, 0)); - _verbList.push_back(VerbInit(VERB_OPEN, 2, 0)); - _verbList.push_back(VerbInit(VERB_PUT, 1, -1)); - _verbList.push_back(VerbInit(VERB_TALKTO, 2, 0)); - _verbList.push_back(VerbInit(VERB_GIVE, 1, 2)); - _verbList.push_back(VerbInit(VERB_PULL, 2, 0)); - _verbList.push_back(VerbInit(VERB_CLOSE, 2, 0)); - _verbList.push_back(VerbInit(VERB_THROW, 1, 2)); + _verbList.push_back(VerbInit(VERB_LOOK, VERB_THAT, PREP_NONE)); + _verbList.push_back(VerbInit(VERB_TAKE, VERB_THAT, PREP_NONE)); + _verbList.push_back(VerbInit(VERB_PUSH, VERB_THAT, PREP_NONE)); + _verbList.push_back(VerbInit(VERB_OPEN, VERB_THAT, PREP_NONE)); + _verbList.push_back(VerbInit(VERB_PUT, VERB_THIS, PREP_RELATIONAL)); + _verbList.push_back(VerbInit(VERB_TALKTO, VERB_THAT, PREP_NONE)); + _verbList.push_back(VerbInit(VERB_GIVE, VERB_THIS, PREP_TO)); + _verbList.push_back(VerbInit(VERB_PULL, VERB_THAT, PREP_NONE)); + _verbList.push_back(VerbInit(VERB_CLOSE, VERB_THAT, PREP_NONE)); + _verbList.push_back(VerbInit(VERB_THROW, VERB_THIS, PREP_TO)); } Scene::~Scene() { -- cgit v1.2.3 From 9ef9dd24c273950328a4f5ea99b36c91b4a4de81 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 11 Apr 2014 08:52:18 -0400 Subject: MADS: Replace warning with call to stubbed unhandledAction method --- engines/mads/scene.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index 02a066a0c6..9f8c922861 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -489,7 +489,7 @@ void Scene::doAction() { } if (_action._inProgress) - warning("TODO: sub_1D9DE"); + _vm->_game->unhandledAction(); } } -- cgit v1.2.3 From 2a979e59a0481f62d67b8b323c79cccaa6552d0a Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 12 Apr 2014 11:00:29 -0400 Subject: MADS: Refactoring PaletteUsage to use external data arrays --- engines/mads/scene.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index 9f8c922861..92c5cedc04 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -50,6 +50,8 @@ Scene::Scene(MADSEngine *vm): _vm(vm), _action(_vm), _depthSurface(vm), _layer = LAYER_GUI; _lookFlag = false; + _paletteUsageF.push_back(PaletteUsage::UsageEntry(0xF)); + _verbList.push_back(VerbInit(VERB_LOOK, VERB_THAT, PREP_NONE)); _verbList.push_back(VerbInit(VERB_TAKE, VERB_THAT, PREP_NONE)); _verbList.push_back(VerbInit(VERB_PUSH, VERB_THAT, PREP_NONE)); @@ -121,8 +123,8 @@ void Scene::loadScene(int sceneId, const Common::String &prefix, bool palFlag) { _spriteSlots.reset(false); _sequences.clear(); _kernelMessages.clear(); + _vm->_palette->_paletteUsage.load(&_scenePaletteUsage); - // TODO: palletteUsage reset? setPalette(_nullPalette); int flags = SCENEFLAG_LOAD_SHADOW; if (_vm->_dithering) flags |= SCENEFLAG_DITHER; @@ -144,7 +146,7 @@ void Scene::loadScene(int sceneId, const Common::String &prefix, bool palFlag) { loadVocab(); // Load palette usage - _vm->_palette->_paletteUsage.load(1, 0xF); + _vm->_palette->_paletteUsage.load(&_paletteUsageF); // Load interface flags = PALFLAG_RESERVED | ANIMFLAG_LOAD_BACKGROUND; @@ -157,7 +159,7 @@ void Scene::loadScene(int sceneId, const Common::String &prefix, bool palFlag) { MSurface depthSurface; _animationData->load(_userInterface, depthSurface, prefix, flags, nullptr, nullptr); - _vm->_palette->_paletteUsage.load(0); + _vm->_palette->_paletteUsage.load(&_scenePaletteUsage); _bandsRange = _sceneInfo->_yBandsEnd - _sceneInfo->_yBandsStart; _scaleRange = _sceneInfo->_maxScale - _sceneInfo->_minScale; @@ -576,6 +578,7 @@ void Scene::free() { _activeAnimation = nullptr; } + _vm->_palette->_paletteUsage.load(nullptr); _hotspots.clear(); _backgroundSurface.free(); _depthSurface.free(); -- cgit v1.2.3 From f4165c5f8a2a15a6b3cdf1ce46732e2e5efe772a Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 12 Apr 2014 22:08:21 -0400 Subject: MADS: Field/method renaming --- engines/mads/scene.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index 92c5cedc04..1aa1fd7f32 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -37,7 +37,7 @@ Scene::Scene(MADSEngine *vm): _vm(vm), _action(_vm), _depthSurface(vm), _currentSceneId = 0; _sceneLogic = nullptr; _sceneInfo = nullptr; - _animFlag = false; + _cyclingActive = false; _animVal1 = 0; _depthStyle = 0; _roomChanged = false; @@ -257,7 +257,7 @@ void Scene::initPaletteAnimation(Common::Array &animData, bool animFlag) { _animCount += _animPalData[i].r; _animVal1 = (_animCount > 16) ? 3 : 0; - _animFlag = animFlag; + _cyclingActive = animFlag; } bool Scene::getDepthHighBits(const Common::Point &pt) { @@ -393,7 +393,7 @@ void Scene::doFrame() { } if (_vm->_game->_fx) - _animFlag = true; + _cyclingActive = true; _vm->_game->_fx = kTransitionNone; if (_freeAnimationFlag && _activeAnimation) { @@ -403,7 +403,7 @@ void Scene::doFrame() { } void Scene::drawElements(ScreenTransition transitionType, bool surfaceFlag) { - // Draw any sprites + // Draw any sprite backgrounds _spriteSlots.drawBackground(); // Set up dirty areas for any text display @@ -420,8 +420,8 @@ void Scene::drawElements(ScreenTransition transitionType, bool surfaceFlag) { _textDisplay.setDirtyAreas2(); _dirtyAreas.merge(1, DIRTY_AREAS_SIZE); - // Draw foreground sprites - _spriteSlots.drawForeground(&_vm->_screen); + // Draw sprites that have changed + _spriteSlots.drawSprites(&_vm->_screen); // Draw text elements onto the view _textDisplay.draw(&_vm->_screen); -- cgit v1.2.3 From 7b907be93775167eab8efab45bea3b9a2776e288 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 15 Apr 2014 19:28:29 -0400 Subject: MADS: General cleanup and minor renamings --- engines/mads/scene.cpp | 5 ----- 1 file changed, 5 deletions(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index 1aa1fd7f32..a112228859 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -426,11 +426,6 @@ void Scene::drawElements(ScreenTransition transitionType, bool surfaceFlag) { // Draw text elements onto the view _textDisplay.draw(&_vm->_screen); - // - _vm->_screen.setPointer(&_vm->_screen); - _userInterface.setBounds(Common::Rect(_vm->_screen._offset.x, _vm->_screen._offset.y, - _vm->_screen._offset.x + _vm->_screen.w, _vm->_screen._offset.y + _vm->_screen.h)); - if (transitionType) { // Fading in the screen _vm->_screen.transition(transitionType, surfaceFlag); -- cgit v1.2.3 From 0b340a034330fd5124b1534544a8ef9500349411 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 15 Apr 2014 23:51:41 -0400 Subject: MADS: Fix depth issues with sitting in chair in scene 101 --- engines/mads/scene.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index a112228859..948688e7a2 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -313,7 +313,7 @@ void Scene::doFrame() { flag = true; } - if (flag || (_vm->_game->_trigger && _vm->_game->_triggerMode == KERNEL_TRIGGER_PREPARE)) { + if (flag || (_vm->_game->_trigger && _vm->_game->_triggerMode == SEQUENCE_TRIGGER_PREPARE)) { doPreactions(); } @@ -324,7 +324,7 @@ void Scene::doFrame() { // Handle parser actions as well as game triggers if ((_action._inProgress && !player._moving && !player._needToWalk && (player._facing == player._turnToFacing) && !_vm->_game->_trigger) || - (_vm->_game->_trigger && (_vm->_game->_triggerMode == KERNEL_TRIGGER_PARSER))) { + (_vm->_game->_trigger && (_vm->_game->_triggerMode == SEQUENCE_TRIGGER_PARSER))) { doAction(); } @@ -442,11 +442,11 @@ void Scene::drawElements(ScreenTransition transitionType, bool surfaceFlag) { void Scene::doPreactions() { if (_vm->_game->_screenObjects._inputMode == kInputBuildingSentences || _vm->_game->_screenObjects._inputMode == kInputLimitedSentences) { - _vm->_game->_triggerSetupMode = KERNEL_TRIGGER_PREPARE; + _vm->_game->_triggerSetupMode = SEQUENCE_TRIGGER_PREPARE; _action.checkAction(); _sceneLogic->preActions(); - if (_vm->_game->_triggerMode == KERNEL_TRIGGER_PREPARE) + if (_vm->_game->_triggerMode == SEQUENCE_TRIGGER_PREPARE) _vm->_game->_trigger = 0; } } @@ -454,7 +454,7 @@ void Scene::doPreactions() { void Scene::doAction() { bool flag = false; - _vm->_game->_triggerSetupMode = KERNEL_TRIGGER_PARSER; + _vm->_game->_triggerSetupMode = SEQUENCE_TRIGGER_PARSER; if ((_action._inProgress || _vm->_game->_trigger) && !_action._savedFields._commandError) { _sceneLogic->actions(); flag = !_action._inProgress; @@ -491,17 +491,17 @@ void Scene::doAction() { } _action._inProgress = false; - if (_vm->_game->_triggerMode == KERNEL_TRIGGER_PARSER) + if (_vm->_game->_triggerMode == SEQUENCE_TRIGGER_PARSER) _vm->_game->_trigger = 0; } void Scene::doSceneStep() { - _vm->_game->_triggerSetupMode = KERNEL_TRIGGER_DAEMON; + _vm->_game->_triggerSetupMode = SEQUENCE_TRIGGER_DAEMON; _sceneLogic->step(); _vm->_game->_sectionHandler->step(); _vm->_game->step(); - if (_vm->_game->_triggerMode == KERNEL_TRIGGER_DAEMON) + if (_vm->_game->_triggerMode == SEQUENCE_TRIGGER_DAEMON) _vm->_game->_trigger = 0; } -- cgit v1.2.3 From 9f67216b11c8c744430d106f36a77068ed8e55d6 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 16 Apr 2014 08:44:12 -0400 Subject: MADS: Fix to stop game ending when loading a cutscene scene --- engines/mads/scene.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index 948688e7a2..e2892fbbd1 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -563,7 +563,7 @@ void Scene::updateCursor() { } } -void Scene::free() { +void Scene::freeCurrentScene() { if (_animationData) { delete _animationData; _animationData = nullptr; -- cgit v1.2.3 From 45084a4702bbdbc4a560470fa1dc12dba3549a61 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 16 Apr 2014 22:59:07 -0400 Subject: MADS: Fix scene animation data being unloaded prematurely --- engines/mads/scene.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index e2892fbbd1..99151c1267 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -398,6 +398,7 @@ void Scene::doFrame() { if (_freeAnimationFlag && _activeAnimation) { _activeAnimation->free(); + _freeAnimationFlag = false; _activeAnimation = nullptr; } } -- cgit v1.2.3 From 559efad195b2ec7e77bd9192328d9e48b2a81e29 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 19 Apr 2014 14:46:28 -0400 Subject: MADS: Moved Animation::free to be Scene::freeAnimation --- engines/mads/scene.cpp | 38 +++++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index 99151c1267..65d1c04c0c 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -396,11 +396,8 @@ void Scene::doFrame() { _cyclingActive = true; _vm->_game->_fx = kTransitionNone; - if (_freeAnimationFlag && _activeAnimation) { - _activeAnimation->free(); - _freeAnimationFlag = false; - _activeAnimation = nullptr; - } + if (_freeAnimationFlag) + freeAnimation(); } void Scene::drawElements(ScreenTransition transitionType, bool surfaceFlag) { @@ -600,4 +597,35 @@ void Scene::resetScene() { _sequences.clear(); } +void Scene::freeAnimation() { + if (_activeAnimation) { + Player &player = _vm->_game->_player; + + if (!_freeAnimationFlag) { + _spriteSlots.fullRefresh(true); + _sequences.scan(); + } + + // Refresh the player + if (player._visible) { + player._forceRefresh = true; + player.update(); + } + + // Remove any kernel messages in use by the animation + for (uint i = 0; i < _activeAnimation->_messages.size(); ++i) { + int msgIndex = _activeAnimation->_messages[i]._kernelMsgIndex; + if (msgIndex >= 0) + _kernelMessages.remove(msgIndex); + } + + // Delete the animation + delete _activeAnimation; + _activeAnimation = nullptr; + } + + _freeAnimationFlag = false; +} + + } // End of namespace MADS -- cgit v1.2.3 From 34d0bc72b571e5e6e0b4b4f3ee1a627cbf470d72 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 19 Apr 2014 23:26:27 +0200 Subject: MADS: Implement scene 313, come renaming in RGB4 structure, used by AnimPalData --- engines/mads/scene.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index 65d1c04c0c..aff4aa36aa 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -254,7 +254,7 @@ void Scene::initPaletteAnimation(Common::Array &animData, bool animFlag) { // Calculate total _animCount = 0; for (uint i = 0; i < _animPalData.size(); ++i) - _animCount += _animPalData[i].r; + _animCount += _animPalData[i]._colorCount; _animVal1 = (_animCount > 16) ? 3 : 0; _cyclingActive = animFlag; -- cgit v1.2.3 From 1362414e77bfbd17d7a0224ce5fb7275c793c7c4 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 19 Apr 2014 22:49:14 -0400 Subject: MADS: Implement palette animation code --- engines/mads/scene.cpp | 74 ++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 60 insertions(+), 14 deletions(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index aff4aa36aa..78a36d97d1 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -38,7 +38,8 @@ Scene::Scene(MADSEngine *vm): _vm(vm), _action(_vm), _depthSurface(vm), _sceneLogic = nullptr; _sceneInfo = nullptr; _cyclingActive = false; - _animVal1 = 0; + _cyclingThreshold = 0; + _cyclingDelay = 0; _depthStyle = 0; _roomChanged = false; _reloadSceneFlag = false; @@ -134,7 +135,7 @@ void Scene::loadScene(int sceneId, const Common::String &prefix, bool palFlag) { _depthSurface, _backgroundSurface); // Initialise palette animation for the scene - initPaletteAnimation(_sceneInfo->_palAnimData, false); + initPaletteAnimation(_sceneInfo->_paletteCycles, false); // Copy over nodes _rails.load(_sceneInfo->_nodes, &_depthSurface, _sceneInfo->_depthStyle); @@ -237,29 +238,75 @@ void Scene::loadVocabStrings() { f.close(); } -void Scene::initPaletteAnimation(Common::Array &animData, bool animFlag) { +void Scene::initPaletteAnimation(Common::Array &palCycles, bool animFlag) { // Initialise the animation palette and ticks list - _animTicksList.clear(); - _animPalData.clear(); + _cycleTicks.clear(); + _paletteCycles.clear(); - for (uint i = 0; i < animData.size(); ++i) { - _animTicksList.push_back(_vm->_events->getFrameCounter()); - _animPalData.push_back(animData[i]); + for (uint i = 0; i < palCycles.size(); ++i) { + _cycleTicks.push_back(_vm->_events->getFrameCounter()); + _paletteCycles.push_back(palCycles[i]); } // Save the initial starting palette Common::copy(&_vm->_palette->_mainPalette[0], &_vm->_palette->_mainPalette[PALETTE_SIZE], - &_vm->_palette->_savedPalette[0]); + &_vm->_palette->_cyclingPalette[0]); // Calculate total - _animCount = 0; - for (uint i = 0; i < _animPalData.size(); ++i) - _animCount += _animPalData[i]._colorCount; + _totalCycleColors = 0; + for (uint i = 0; i < _paletteCycles.size(); ++i) + _totalCycleColors += _paletteCycles[i]._colorCount; - _animVal1 = (_animCount > 16) ? 3 : 0; + _cyclingThreshold = (_totalCycleColors > 16) ? 3 : 0; _cyclingActive = animFlag; } +void Scene::animatePalette() { + byte rgb[3]; + + if (_cyclingActive) { + Scene::_cyclingDelay++; + if (_cyclingDelay >= _cyclingThreshold) { + uint32 frameCounter = _vm->_events->getFrameCounter(); + bool changesFlag = false; + for (int idx = 0; idx < _paletteCycles.size(); idx++) { + if (frameCounter >= (_cycleTicks[idx] + _paletteCycles[idx]._ticks)) { + _cycleTicks[idx] = frameCounter; + int count = _paletteCycles[idx]._colorCount; + int first = _paletteCycles[idx]._firstColorIndex; + int listIndex = _paletteCycles[idx]._firstListColor; + changesFlag = true; + + if (count > 1) { + // Make a copy of the last color + byte *pSrc = &_vm->_palette->_cyclingPalette[first * 3]; + byte *pEnd = pSrc + count * 3; + Common::copy(pEnd - 3, pEnd, &rgb[0]); + + // Shift the cycle palette forward one entry + Common::copy_backward(pSrc, pEnd - 3, pEnd); + + // Move the saved color to the start of the cycle + Common::copy(&rgb[0], &rgb[3], pSrc); + + if (++listIndex >= count) + listIndex = 0; + } + + _paletteCycles[idx]._firstListColor = listIndex; + } + } + + if (changesFlag) { + _vm->_palette->setPalette(_vm->_palette->_cyclingPalette, + _paletteCycles[0]._firstColorIndex, _totalCycleColors); + } + + _cyclingDelay = 0; + } + } +} + bool Scene::getDepthHighBits(const Common::Point &pt) { if (_sceneInfo->_depthStyle == 2) { return 0; @@ -627,5 +674,4 @@ void Scene::freeAnimation() { _freeAnimationFlag = false; } - } // End of namespace MADS -- cgit v1.2.3 From a31cae55a113e2103d6e5359bd27f64f84c16ed5 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 20 Apr 2014 11:14:11 -0400 Subject: MADS: Added extra initialisation of Scene class fields --- engines/mads/scene.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index 78a36d97d1..40a0a8f106 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -40,6 +40,7 @@ Scene::Scene(MADSEngine *vm): _vm(vm), _action(_vm), _depthSurface(vm), _cyclingActive = false; _cyclingThreshold = 0; _cyclingDelay = 0; + _totalCycleColors = 0; _depthStyle = 0; _roomChanged = false; _reloadSceneFlag = false; @@ -50,6 +51,11 @@ Scene::Scene(MADSEngine *vm): _vm(vm), _action(_vm), _depthSurface(vm), _frameStartTime = 0; _layer = LAYER_GUI; _lookFlag = false; + _bandsRange = 0; + _scaleRange = 0; + _interfaceY = 0; + _spritesCount = 0; + _variant = 0; _paletteUsageF.push_back(PaletteUsage::UsageEntry(0xF)); -- cgit v1.2.3 From 2ccaea811f7c1859fc474eda92e7ceb48b3d5adf Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 20 Apr 2014 11:32:55 -0400 Subject: MADS: Fix update of palette due to palette cycling --- engines/mads/scene.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index 40a0a8f106..e6888162d3 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -304,8 +304,9 @@ void Scene::animatePalette() { } if (changesFlag) { - _vm->_palette->setPalette(_vm->_palette->_cyclingPalette, - _paletteCycles[0]._firstColorIndex, _totalCycleColors); + int firstColor = _paletteCycles[0]._firstColorIndex; + byte *pSrc = &_vm->_palette->_cyclingPalette[firstColor * 3]; + _vm->_palette->setPalette(pSrc, firstColor, _totalCycleColors); } _cyclingDelay = 0; -- cgit v1.2.3 From aedf8593034303066bf83d041f63731aa65a3ef6 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 22 Apr 2014 23:28:23 +0200 Subject: MADS: Fix compilation warning --- engines/mads/scene.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index e6888162d3..9d0332e600 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -275,7 +275,7 @@ void Scene::animatePalette() { if (_cyclingDelay >= _cyclingThreshold) { uint32 frameCounter = _vm->_events->getFrameCounter(); bool changesFlag = false; - for (int idx = 0; idx < _paletteCycles.size(); idx++) { + for (uint16 idx = 0; idx < _paletteCycles.size(); idx++) { if (frameCounter >= (_cycleTicks[idx] + _paletteCycles[idx]._ticks)) { _cycleTicks[idx] = frameCounter; int count = _paletteCycles[idx]._colorCount; -- cgit v1.2.3 From 0e9e6cda40ee0bf739e6c7a6320a81307df7c8b9 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 22 Apr 2014 23:00:41 -0400 Subject: MADS: Beginnings of savegame synchronisation --- engines/mads/scene.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index 9d0332e600..239a91c585 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -681,4 +681,9 @@ void Scene::freeAnimation() { _freeAnimationFlag = false; } +void Scene::synchronize(Common::Serializer &s) { + _action._activeAction.synchronize(s); + _rails.synchronize(s); +} + } // End of namespace MADS -- cgit v1.2.3 From c1a90cdda1f1424cb9b6b2e91b82c47cf0913335 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 23 Apr 2014 21:01:48 -0400 Subject: MADS: Further synchronization implementation --- engines/mads/scene.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index 239a91c585..24218479ce 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -684,6 +684,7 @@ void Scene::freeAnimation() { void Scene::synchronize(Common::Serializer &s) { _action._activeAction.synchronize(s); _rails.synchronize(s); + _userInterface.synchronize(s); } } // End of namespace MADS -- cgit v1.2.3 From f330106be2368df453fec7799a2d061c829f525d Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 24 Apr 2014 08:24:23 -0400 Subject: MADS: Hook game scene into synchronisation logic --- engines/mads/scene.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index 24218479ce..9217be6d5d 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -685,6 +685,7 @@ void Scene::synchronize(Common::Serializer &s) { _action._activeAction.synchronize(s); _rails.synchronize(s); _userInterface.synchronize(s); + _sceneLogic->synchronize(s); } } // End of namespace MADS -- cgit v1.2.3 From 9c30f3e0734271a2a259c1dc75202cef88f370f3 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sun, 27 Apr 2014 21:17:11 +0300 Subject: MADS: Hook up the new skeleton scene logic for Phantom and Dragonsphere Also, add a HACK to stub out the sprite refresh code for these games, as sprites aren't loaded yet --- engines/mads/scene.cpp | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index 9217be6d5d..545ee03fd0 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -24,7 +24,9 @@ #include "mads/scene.h" #include "mads/compression.h" #include "mads/mads.h" +#include "mads/dragonsphere/dragonsphere_scenes.h" #include "mads/nebular/nebular_scenes.h" +#include "mads/phantom/phantom_scenes.h" namespace MADS { @@ -113,8 +115,14 @@ void Scene::loadSceneLogic() { case GType_RexNebular: _sceneLogic = Nebular::SceneFactory::createScene(_vm); break; + case GType_Dragonsphere: + _sceneLogic = Dragonsphere::SceneFactory::createScene(_vm); + break; + case GType_Phantom: + _sceneLogic = Phantom::SceneFactory::createScene(_vm); + break; default: - error("Unknown game"); + error("Scene logic: Unknown game"); } } @@ -185,6 +193,7 @@ void Scene::loadScene(int sceneId, const Common::String &prefix, bool palFlag) { void Scene::loadHotspots() { File f(Resources::formatName(RESPREFIX_RM, _currentSceneId, ".HH")); MadsPack madsPack(&f); + bool isV2 = (_vm->getGameID() != GType_RexNebular); Common::SeekableReadStream *stream = madsPack.getItemStream(0); int count = stream->readUint16LE(); @@ -193,7 +202,7 @@ void Scene::loadHotspots() { stream = madsPack.getItemStream(1); _hotspots.clear(); for (int i = 0; i < count; ++i) - _hotspots.push_back(Hotspot(*stream)); + _hotspots.push_back(Hotspot(*stream, isV2)); delete stream; f.close(); @@ -467,6 +476,19 @@ void Scene::drawElements(ScreenTransition transitionType, bool surfaceFlag) { // Copy background for the dirty areas to the screen _dirtyAreas.copy(&_backgroundSurface, &_vm->_screen, _posAdjust); + // TODO: Remove this HACK when sprites are implemented for V2 games + if (_vm->getGameID() != GType_RexNebular) { + if (transitionType) { + // Fading in the screen + _vm->_screen.transition(transitionType, surfaceFlag); + _vm->_sound->startQueuedCommands(); + } else { + // Copy dirty areas to the screen + _dirtyAreas.copyToScreen(_vm->_screen._offset); + } + return; + } + // Handle dirty areas for foreground objects _spriteSlots.setDirtyAreas(); _textDisplay.setDirtyAreas2(); -- cgit v1.2.3 From 82933592ff152138a539864fde80705d391bc25e Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 28 Apr 2014 21:33:31 -0400 Subject: MADS: Fix original engine bug with highlighted hotspots between scenes --- engines/mads/scene.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index 545ee03fd0..f4b2cb1ec8 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -184,7 +184,8 @@ void Scene::loadScene(int sceneId, const Common::String &prefix, bool palFlag) { _spritesCount = _sprites.size(); _userInterface.setup(_vm->_game->_screenObjects._inputMode); - + + _vm->_game->_screenObjects._category = CAT_NONE; _vm->_events->showCursor(); warning("TODO: inventory_anim_allocate"); @@ -608,7 +609,7 @@ void Scene::updateCursor() { Player &player = _vm->_game->_player; CursorType cursorId = CURSOR_ARROW; - if (_action._interAwaiting == 1 && !_vm->_events->_rightMousePressed && + if (_action._interAwaiting == AWAITING_COMMAND && !_vm->_events->_rightMousePressed && _vm->_game->_screenObjects._category == CAT_HOTSPOT) { int idx = _vm->_game->_screenObjects._selectedObject - _userInterface._categoryIndexes[CAT_HOTSPOT - 1]; -- cgit v1.2.3 From 88cf2c7caab3ce74460a980640b9fe832f4fba5f Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 1 May 2014 09:17:10 -0400 Subject: MADS: Fix actions being triggered at the end of animation sequences --- engines/mads/scene.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index f4b2cb1ec8..5c86e4590e 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -594,7 +594,7 @@ void Scene::checkKeyboard() { } } -void Scene::loadAnimation(const Common::String &resName, int abortTimers) { +void Scene::loadAnimation(const Common::String &resName, int trigger) { assert(_activeAnimation == nullptr); MSurface depthSurface; UserInterface interfaceSurface(_vm); @@ -602,7 +602,7 @@ void Scene::loadAnimation(const Common::String &resName, int abortTimers) { _activeAnimation = Animation::init(_vm, this); _activeAnimation->load(interfaceSurface, depthSurface, resName, _vm->_dithering ? ANIMFLAG_DITHER : 0, nullptr, nullptr); - _activeAnimation->startAnimation(abortTimers); + _activeAnimation->startAnimation(trigger); } void Scene::updateCursor() { -- cgit v1.2.3 From b5949010a61e3d12f22ea762ed8d09cc1a79b850 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 1 May 2014 22:36:36 -0400 Subject: MADS: Implemented more savegame synchronization --- engines/mads/scene.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index 5c86e4590e..e53061c750 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -705,10 +705,14 @@ void Scene::freeAnimation() { } void Scene::synchronize(Common::Serializer &s) { - _action._activeAction.synchronize(s); + _action.synchronize(s); _rails.synchronize(s); _userInterface.synchronize(s); - _sceneLogic->synchronize(s); + s.syncAsByte(_reloadSceneFlag); + s.syncAsByte(_roomChanged); + s.syncAsUint16LE(_nextSceneId); + s.syncAsUint16LE(_priorSceneId); + _dynamicHotspots.synchronize(s); } } // End of namespace MADS -- cgit v1.2.3 From d88e165e00cc70540af05c06f4f32b1907bdcc09 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 6 May 2014 04:39:12 +0300 Subject: MADS: Fix loading of V2 hotspots --- engines/mads/scene.cpp | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index e53061c750..62a0e2031c 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -477,26 +477,15 @@ void Scene::drawElements(ScreenTransition transitionType, bool surfaceFlag) { // Copy background for the dirty areas to the screen _dirtyAreas.copy(&_backgroundSurface, &_vm->_screen, _posAdjust); - // TODO: Remove this HACK when sprites are implemented for V2 games - if (_vm->getGameID() != GType_RexNebular) { - if (transitionType) { - // Fading in the screen - _vm->_screen.transition(transitionType, surfaceFlag); - _vm->_sound->startQueuedCommands(); - } else { - // Copy dirty areas to the screen - _dirtyAreas.copyToScreen(_vm->_screen._offset); - } - return; - } - // Handle dirty areas for foreground objects - _spriteSlots.setDirtyAreas(); + if (_vm->getGameID() == GType_RexNebular) // TODO: Implement for V2 games + _spriteSlots.setDirtyAreas(); _textDisplay.setDirtyAreas2(); _dirtyAreas.merge(1, DIRTY_AREAS_SIZE); // Draw sprites that have changed - _spriteSlots.drawSprites(&_vm->_screen); + if (_vm->getGameID() == GType_RexNebular) // TODO: Implement for V2 games + _spriteSlots.drawSprites(&_vm->_screen); // Draw text elements onto the view _textDisplay.draw(&_vm->_screen); -- cgit v1.2.3 From 3600205ba23c813533711e2eeeafd2b4867623bb Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Thu, 8 May 2014 02:52:54 +0300 Subject: MADS: Use the font friendly name in Scene::clearMessageList() --- engines/mads/scene.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index 62a0e2031c..609e2335e4 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -104,7 +104,7 @@ void Scene::clearSequenceList() { void Scene::clearMessageList() { _kernelMessages.clear(); - _talkFont = "*FONTCONV.FF"; + _talkFont = FONT_CONVERSATION; _textSpacing = -1; } -- cgit v1.2.3 From b7dd01fdefd910c3c0f6291145ceab4060ae1a70 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Thu, 8 May 2014 11:43:23 +0300 Subject: MADS: Remove trailing whitespace --- engines/mads/scene.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index 609e2335e4..32956e6484 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -32,7 +32,7 @@ namespace MADS { Scene::Scene(MADSEngine *vm): _vm(vm), _action(_vm), _depthSurface(vm), _dirtyAreas(_vm), _dynamicHotspots(vm), _hotspots(vm), - _kernelMessages(vm), _sequences(vm), _sprites(vm), _spriteSlots(vm), + _kernelMessages(vm), _sequences(vm), _sprites(vm), _spriteSlots(vm), _textDisplay(vm), _userInterface(vm) { _priorSceneId = 0; _nextSceneId = 0; @@ -169,11 +169,11 @@ void Scene::loadScene(int sceneId, const Common::String &prefix, bool palFlag) { flags |= ANIMFLAG_DITHER; if (_vm->_textWindowStill) flags |= ANIMFLAG_LOAD_BACKGROUND_ONLY; - + _animationData = Animation::init(_vm, this); MSurface depthSurface; _animationData->load(_userInterface, depthSurface, prefix, flags, nullptr, nullptr); - + _vm->_palette->_paletteUsage.load(&_scenePaletteUsage); _bandsRange = _sceneInfo->_yBandsEnd - _sceneInfo->_yBandsStart; @@ -184,7 +184,7 @@ void Scene::loadScene(int sceneId, const Common::String &prefix, bool palFlag) { _spritesCount = _sprites.size(); _userInterface.setup(_vm->_game->_screenObjects._inputMode); - + _vm->_game->_screenObjects._category = CAT_NONE; _vm->_events->showCursor(); @@ -386,7 +386,7 @@ void Scene::doFrame() { _frameStartTime = _vm->_events->getFrameCounter(); // Handle parser actions as well as game triggers - if ((_action._inProgress && !player._moving && !player._needToWalk && + if ((_action._inProgress && !player._moving && !player._needToWalk && (player._facing == player._turnToFacing) && !_vm->_game->_trigger) || (_vm->_game->_trigger && (_vm->_game->_triggerMode == SEQUENCE_TRIGGER_PARSER))) { doAction(); @@ -420,7 +420,7 @@ void Scene::doFrame() { if (_vm->_debugger->_showMousePos) { Common::Point pt = _vm->_events->mousePos(); Common::String msg = Common::String::format("(%d,%d)", pt.x, pt.y); - mouseTextIndex = _kernelMessages.add(Common::Point(5, 5), + mouseTextIndex = _kernelMessages.add(Common::Point(5, 5), 0x203, 0, 0, 1, msg); } @@ -504,7 +504,7 @@ void Scene::drawElements(ScreenTransition transitionType, bool surfaceFlag) { } void Scene::doPreactions() { - if (_vm->_game->_screenObjects._inputMode == kInputBuildingSentences || + if (_vm->_game->_screenObjects._inputMode == kInputBuildingSentences || _vm->_game->_screenObjects._inputMode == kInputLimitedSentences) { _vm->_game->_triggerSetupMode = SEQUENCE_TRIGGER_PREPARE; _action.checkAction(); @@ -533,7 +533,7 @@ void Scene::doAction() { flag = !_action._inProgress; } - if ((_action._inProgress || _vm->_game->_trigger) && + if ((_action._inProgress || _vm->_game->_trigger) && (!flag || _action._savedFields._commandError == flag)) { _vm->_game->doObjectAction(); } @@ -589,7 +589,7 @@ void Scene::loadAnimation(const Common::String &resName, int trigger) { UserInterface interfaceSurface(_vm); _activeAnimation = Animation::init(_vm, this); - _activeAnimation->load(interfaceSurface, depthSurface, resName, + _activeAnimation->load(interfaceSurface, depthSurface, resName, _vm->_dithering ? ANIMFLAG_DITHER : 0, nullptr, nullptr); _activeAnimation->startAnimation(trigger); } -- cgit v1.2.3 From 600a715661333565e8546dfcafabf5e1da95d340 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sat, 10 May 2014 13:22:45 +0300 Subject: MADS: Split verbs from nouns --- engines/mads/scene.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index 32956e6484..601acc5ec6 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -369,7 +369,7 @@ void Scene::doFrame() { if (_action._selectedAction && player._stepEnabled && !player._needToWalk && !_vm->_game->_trigger && !player._trigger) { _action.startAction(); - if (_action._activeAction._verbId == Nebular::NOUN_LOOK_AT) { + if (_action._activeAction._verbId == Nebular::VERB_LOOK_AT) { _action._activeAction._verbId = VERB_LOOK; _action._savedFields._command = false; } -- cgit v1.2.3 From e7bef9019a71105a19c9f4eff567b8df47387a8b Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 18 May 2014 12:29:48 +0200 Subject: MADS: Implement scene 803, add an ongoingGame global flag to exit the multiple game loops --- engines/mads/scene.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index 601acc5ec6..3ef88fa630 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -255,7 +255,7 @@ void Scene::loadVocabStrings() { } void Scene::initPaletteAnimation(Common::Array &palCycles, bool animFlag) { - // Initialise the animation palette and ticks list + // Initialize the animation palette and ticks list _cycleTicks.clear(); _paletteCycles.clear(); @@ -334,7 +334,7 @@ bool Scene::getDepthHighBits(const Common::Point &pt) { } void Scene::loop() { - while (!_vm->shouldQuit() && !_reloadSceneFlag && _nextSceneId == _currentSceneId) { + while (!_vm->shouldQuit() && !_reloadSceneFlag && (_nextSceneId == _currentSceneId) && _vm->_game->_ongoingGame) { // Handle drawing a game frame doFrame(); -- cgit v1.2.3 From e1a06ae543f0926118d2b82aa5344752e11ead1d Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 18 May 2014 12:34:15 +0200 Subject: MADS: Replace _ongoingGame by the use of quitGame() --- engines/mads/scene.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index 3ef88fa630..84e4edc08d 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -334,7 +334,7 @@ bool Scene::getDepthHighBits(const Common::Point &pt) { } void Scene::loop() { - while (!_vm->shouldQuit() && !_reloadSceneFlag && (_nextSceneId == _currentSceneId) && _vm->_game->_ongoingGame) { + while (!_vm->shouldQuit() && !_reloadSceneFlag && (_nextSceneId == _currentSceneId)) { // Handle drawing a game frame doFrame(); -- cgit v1.2.3 From e409f4dedd989b49184a865f59dc152e85303489 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 20 May 2014 05:43:49 +0300 Subject: MADS: Add debugger commands for the game vocab --- engines/mads/scene.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index 84e4edc08d..0c241eb9ab 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -254,6 +254,10 @@ void Scene::loadVocabStrings() { f.close(); } +uint32 Scene::getVocabStringsCount() const { + return _vocabStrings.size(); +} + void Scene::initPaletteAnimation(Common::Array &palCycles, bool animFlag) { // Initialize the animation palette and ticks list _cycleTicks.clear(); -- cgit v1.2.3 From 057f239ed6f701da4e4a1c6a6624bc41e4d8c93c Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 21 May 2014 08:32:39 -0400 Subject: MADS: Remove some redundant TODOs --- engines/mads/scene.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index 0c241eb9ab..0e3960c0f8 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -187,8 +187,6 @@ void Scene::loadScene(int sceneId, const Common::String &prefix, bool palFlag) { _vm->_game->_screenObjects._category = CAT_NONE; _vm->_events->showCursor(); - - warning("TODO: inventory_anim_allocate"); } void Scene::loadHotspots() { -- cgit v1.2.3 From 722b32506e5d28a5037b1bb1bef6f8759af13423 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 24 May 2014 14:44:12 -0400 Subject: MADS: Replaced a TODO with a stubbed method --- engines/mads/scene.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index 0e3960c0f8..d589010194 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -548,7 +548,7 @@ void Scene::doAction() { if (_action._inProgress) { _action._savedFields._commandError = true; - warning("TODO: PtrUnk4"); + _sceneLogic->unhandledAction(); } if (_action._inProgress) -- cgit v1.2.3 From 8f9a75a9255fbccb8be3bbe6fc35aafec00a4260 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 24 May 2014 18:19:54 -0400 Subject: MADS: Add _sceneSurface subsurface, so sprite drawing is cropped correctly --- engines/mads/scene.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index d589010194..944c082817 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -61,6 +61,11 @@ Scene::Scene(MADSEngine *vm): _vm(vm), _action(_vm), _depthSurface(vm), _paletteUsageF.push_back(PaletteUsage::UsageEntry(0xF)); + // Set up a scene surface that maps to our physical screen drawing surface + _sceneSurface.init(MADS_SCREEN_WIDTH, MADS_SCENE_HEIGHT, MADS_SCREEN_WIDTH, + _vm->_screen.getPixels(), Graphics::PixelFormat::createFormatCLUT8()); + + // Set up the verb list _verbList.push_back(VerbInit(VERB_LOOK, VERB_THAT, PREP_NONE)); _verbList.push_back(VerbInit(VERB_TAKE, VERB_THAT, PREP_NONE)); _verbList.push_back(VerbInit(VERB_PUSH, VERB_THAT, PREP_NONE)); @@ -487,7 +492,7 @@ void Scene::drawElements(ScreenTransition transitionType, bool surfaceFlag) { // Draw sprites that have changed if (_vm->getGameID() == GType_RexNebular) // TODO: Implement for V2 games - _spriteSlots.drawSprites(&_vm->_screen); + _spriteSlots.drawSprites(&_sceneSurface); // Draw text elements onto the view _textDisplay.draw(&_vm->_screen); -- cgit v1.2.3 From ea19581ae30bed434da8c9426c7b6defd702fc88 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 25 May 2014 13:23:05 -0400 Subject: MADS: Standardised on passing depth surfaces as DepthSurface --- engines/mads/scene.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index 944c082817..13913030df 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -176,7 +176,7 @@ void Scene::loadScene(int sceneId, const Common::String &prefix, bool palFlag) { flags |= ANIMFLAG_LOAD_BACKGROUND_ONLY; _animationData = Animation::init(_vm, this); - MSurface depthSurface; + DepthSurface depthSurface(_vm); _animationData->load(_userInterface, depthSurface, prefix, flags, nullptr, nullptr); _vm->_palette->_paletteUsage.load(&_scenePaletteUsage); @@ -592,7 +592,7 @@ void Scene::checkKeyboard() { void Scene::loadAnimation(const Common::String &resName, int trigger) { assert(_activeAnimation == nullptr); - MSurface depthSurface; + DepthSurface depthSurface(_vm); UserInterface interfaceSurface(_vm); _activeAnimation = Animation::init(_vm, this); -- cgit v1.2.3 From 6f046eafded01e00beddc7533989a06c50b05624 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 25 May 2014 14:39:15 -0400 Subject: MADS: Fix for assert when a scene uses more than one animation --- engines/mads/scene.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index 13913030df..4af956a9f6 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -591,7 +591,11 @@ void Scene::checkKeyboard() { } void Scene::loadAnimation(const Common::String &resName, int trigger) { - assert(_activeAnimation == nullptr); + // WORKAROUND: If there's already a previous active animation used by the + // scene, then free it before we create the new one + if (_activeAnimation) + freeAnimation(); + DepthSurface depthSurface(_vm); UserInterface interfaceSurface(_vm); -- cgit v1.2.3 From 9866aba2e43da914a17d17b695456ca25a875469 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Tue, 27 May 2014 00:58:25 +0200 Subject: MADS: Slight formatting fixes. --- engines/mads/scene.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index 4af956a9f6..7b54034753 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -30,10 +30,11 @@ namespace MADS { -Scene::Scene(MADSEngine *vm): _vm(vm), _action(_vm), _depthSurface(vm), - _dirtyAreas(_vm), _dynamicHotspots(vm), _hotspots(vm), - _kernelMessages(vm), _sequences(vm), _sprites(vm), _spriteSlots(vm), - _textDisplay(vm), _userInterface(vm) { +Scene::Scene(MADSEngine *vm) + : _vm(vm), _action(_vm), _depthSurface(vm), + _dirtyAreas(_vm), _dynamicHotspots(vm), _hotspots(vm), + _kernelMessages(vm), _sequences(vm), _sprites(vm), _spriteSlots(vm), + _textDisplay(vm), _userInterface(vm) { _priorSceneId = 0; _nextSceneId = 0; _currentSceneId = 0; -- cgit v1.2.3 From 9099b36caa88d7675a03fb0bd283acf4e1122474 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Tue, 27 May 2014 00:58:25 +0200 Subject: MADS: initialise -> initialize. --- engines/mads/scene.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index 7b54034753..d2d4bd818a 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -154,7 +154,7 @@ void Scene::loadScene(int sceneId, const Common::String &prefix, bool palFlag) { _sceneInfo->load(_currentSceneId, _variant, Common::String(), flags, _depthSurface, _backgroundSurface); - // Initialise palette animation for the scene + // Initialize palette animation for the scene initPaletteAnimation(_sceneInfo->_paletteCycles, false); // Copy over nodes -- cgit v1.2.3 From 2168d43d5d8c66cc4316e2bd0450ef108b27fda5 Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Wed, 28 May 2014 23:25:49 +0200 Subject: MADS: Janitorial - Trim more trailing whitespace --- engines/mads/scene.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/mads/scene.cpp') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index d2d4bd818a..e98648f009 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -596,7 +596,7 @@ void Scene::loadAnimation(const Common::String &resName, int trigger) { // scene, then free it before we create the new one if (_activeAnimation) freeAnimation(); - + DepthSurface depthSurface(_vm); UserInterface interfaceSurface(_vm); -- cgit v1.2.3