diff options
-rw-r--r-- | engines/mads/animation.cpp | 34 | ||||
-rw-r--r-- | engines/mads/animation.h | 9 | ||||
-rw-r--r-- | engines/mads/game.cpp | 7 | ||||
-rw-r--r-- | engines/mads/game.h | 5 | ||||
-rw-r--r-- | engines/mads/interface.cpp | 45 | ||||
-rw-r--r-- | engines/mads/interface.h | 9 | ||||
-rw-r--r-- | engines/mads/nebular/nebular_scenes8.cpp | 9 | ||||
-rw-r--r-- | engines/mads/scene.cpp | 17 | ||||
-rw-r--r-- | engines/mads/scene.h | 10 | ||||
-rw-r--r-- | engines/mads/sequence.cpp | 2 | ||||
-rw-r--r-- | engines/mads/sprites.cpp | 26 | ||||
-rw-r--r-- | engines/mads/sprites.h | 19 |
12 files changed, 175 insertions, 17 deletions
diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp index d0c7d3079b..588e4eaf36 100644 --- a/engines/mads/animation.cpp +++ b/engines/mads/animation.cpp @@ -140,6 +140,8 @@ Animation *Animation::init(MADSEngine *vm, Scene *scene) { Animation::Animation(MADSEngine *vm, Scene *scene) : _vm(vm), _scene(scene) { _font = nullptr; _resetFlag = false; + _messageCtr = 0; + _skipLoad = false; } Animation::~Animation() { @@ -298,6 +300,32 @@ void Animation::load(MSurface &depthSurface, InterfaceSurface &interfaceSurface, f.close(); } +void Animation::startAnimation(int abortTimers) { + _messageCtr = 0; + _skipLoad = true; + + if (_header._manualFlag) { + _unkIndex = -1; + //SpriteAsset *asset = _scene->_sprites[_spriteListIndexes[_header._spritesIndex]]; + + // TODO: Weird stuff with _unkList. Seems like it's treated as pointers + // here, but in processText, it's used as POINTs? + + loadFrame(1); + } + + _currentFrame = 0; + _oldFrameEntry = 0; + _nextFrameTimer = _vm->_events->_currentTimer; + _abortTimers = abortTimers; + _abortTimersMode = _vm->_game->_abortTimersMode2; + _vm->_game->_scene._action._activeAction = _actionDetails; + + for (int idx = 0; idx < _header._messagesCount; ++idx) { + _messages[idx]._kernelMsgIndex = -1; + } +} + void Animation::loadFrame(int frameNumber) { Scene &scene = _vm->_game->_scene; if (_skipLoad) @@ -507,11 +535,11 @@ void Animation::update() { // Animation is complete if (_abortTimers != 0) { _vm->_game->_abortTimers = _abortTimers; - _vm->_game->_abortTimersMode = _abortMode; + _vm->_game->_abortTimersMode = _abortTimersMode; - if (_abortMode != ABORTMODE_1) { + if (_abortTimersMode != ABORTMODE_1) { // Copy the noun list - scene._action._action = _actionNouns; + scene._action._action = _actionDetails; } } } diff --git a/engines/mads/animation.h b/engines/mads/animation.h index 8df7b37439..ca04e86ed6 100644 --- a/engines/mads/animation.h +++ b/engines/mads/animation.h @@ -130,8 +130,8 @@ private: uint32 _nextScrollTimer; int _messageCtr; int _abortTimers; - AbortTimerMode _abortMode; - ActionDetails _actionNouns; + AbortTimerMode _abortTimersMode; + ActionDetails _actionDetails; /** * Load data for a given frame @@ -173,6 +173,11 @@ public: int flags, Common::Array<RGB4> *palAnimData, SceneInfo *sceneInfo); /** + * Setups up a loaded animation for playback + */ + void startAnimation(int abortTimers); + + /** * Update the animation */ void update(); diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp index 962e82ca18..08a5f97a3d 100644 --- a/engines/mads/game.cpp +++ b/engines/mads/game.cpp @@ -58,6 +58,7 @@ Game::Game(MADSEngine *vm): _vm(vm), _surface(nullptr), _objects(vm), _updateSceneFlag = false; _abortTimersMode = ABORTMODE_0; _abortTimersMode2 = ABORTMODE_0; + _ticksExpiry = 0; } Game::~Game() { @@ -176,7 +177,7 @@ void Game::sectionLoop() { } _vm->_events->initVars(); - _scene._v1A = -1; + _scene._v1A = true; _scene._v1C = -1; _objectHiliteVocabIdx = -1; @@ -230,8 +231,8 @@ void Game::sectionLoop() { _vm->_events->resetCursor(); _v1 = 3; - delete _scene._animation; - _scene._animation = nullptr; + delete _scene._animationData; + _scene._animationData = nullptr; _scene._reloadSceneFlag = false; diff --git a/engines/mads/game.h b/engines/mads/game.h index aa1810963d..143259dc2f 100644 --- a/engines/mads/game.h +++ b/engines/mads/game.h @@ -66,13 +66,11 @@ protected: SectionHandler *_sectionHandler; VisitedScenes _visitedScenes; Common::StringArray _quotes; - int _v1; int _v3; int _v5; int _v6; bool _updateSceneFlag; bool _playerSpritesFlag; - int _objectHiliteVocabIdx; /** * Constructor @@ -120,6 +118,7 @@ public: int _currentSectionNumber; InventoryObjects _objects; Scene _scene; + int _v1; int _v2; int _v4; int _abortTimers; @@ -128,6 +127,8 @@ public: AbortTimerMode _abortTimersMode2; uint32 _priorFrameTimer; Common::String _aaName; + uint32 _ticksExpiry; + int _objectHiliteVocabIdx; public: virtual ~Game(); diff --git a/engines/mads/interface.cpp b/engines/mads/interface.cpp index fa50cbd1be..e3105614ca 100644 --- a/engines/mads/interface.cpp +++ b/engines/mads/interface.cpp @@ -68,6 +68,47 @@ void InterfaceSurface::load(const Common::String &resName) { delete pixelsStream; } +void InterfaceSurface::setup(int id) { + Scene &scene = _vm->_game->_scene; + + if (scene._screenObjects._v832EC != id) { + Common::String resName = _vm->_game->_aaName; + + // Strip off any extension + const char *p = strchr(resName.c_str(), '.'); + if (p) { + resName = Common::String(resName.c_str(), p - 1); + } + + // Add on suffix if necessary + if (id) + resName += "A"; + + resName += ".INT"; + free(); + load(resName); + } + scene._screenObjects._v832EC = id; + + scene._imageInterEntries.clear(); + scene._imageInterEntries.add(-2, 0xff); + _vm->_game->_ticksExpiry = _vm->_events->getFrameCounter(); + scene._v1A = true; + _vm->_game->_objectHiliteVocabIdx = -1; + scene._v1C = -1; + + // Make a copy of the surface + copyTo(&_surface); + + if (_vm->_game->_v1 == 5) + scene._imageInterEntries.call(0); + + scene._action.clear(); + writeText(); + loadElements(); + scene._dynamicHotspots.refresh(); +} + void InterfaceSurface::elementHighlighted() { warning("TODO: InterfaceSurface::elementHighlighted"); } @@ -81,6 +122,10 @@ void InterfaceSurface::setBounds(const Common::Rect &r) { _bounds = r; } +void InterfaceSurface::loadElements() { + warning("TODO: InterfaceSurface::loadElements"); +} + /*------------------------------------------------------------------------*/ diff --git a/engines/mads/interface.h b/engines/mads/interface.h index 3295fa450e..0d7860b30a 100644 --- a/engines/mads/interface.h +++ b/engines/mads/interface.h @@ -26,17 +26,21 @@ #include "common/scummsys.h" #include "common/rect.h" #include "common/str.h" +#include "mads/msurface.h" namespace MADS { class InterfaceSurface : public MSurface { private: MADSEngine *_vm; + + void loadElements(); public: ScrCategory _category; int _screenObjectsCount; Common::Rect _bounds; Common::Rect *_rectP; + MSurface _surface; public: /** * Constructor @@ -48,6 +52,11 @@ public: */ void load(const Common::String &resName); + /** + * Set up the interface + */ + void setup(int id); + void elementHighlighted(); void writeText(); diff --git a/engines/mads/nebular/nebular_scenes8.cpp b/engines/mads/nebular/nebular_scenes8.cpp index b3997e110c..caad1e79a7 100644 --- a/engines/mads/nebular/nebular_scenes8.cpp +++ b/engines/mads/nebular/nebular_scenes8.cpp @@ -126,7 +126,14 @@ void Scene804::setup() { _scene->_sequences.setDepth(_globals._spriteIndexes[15], 8); } - // TODO: More setup + _scene->loadAnimation(Resources::formatName(804, 'r', 1, EXT_AA, "")); + + Scene8xx::enter1(); + + if (_globals[165] && !_globals[164]) { + _scene->_interface.setup(2); + _vm->_sound->command(19); + } } void Scene804::enter() { 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"); } diff --git a/engines/mads/scene.h b/engines/mads/scene.h index 3fe3a4eddf..e2aa1098ed 100644 --- a/engines/mads/scene.h +++ b/engines/mads/scene.h @@ -94,6 +94,7 @@ public: int _textSpacing; Common::Array<Hotspot> _hotspots; ScreenObjects _screenObjects; + ImageInterEntries _imageInterEntries; DirtyAreas _dirtyAreas; int _v1; SceneInfo *_sceneInfo; @@ -107,7 +108,7 @@ public: Common::Array<RGB4> _animPalData; SceneNodeList _nodes; Common::StringArray _vocabStrings; - Animation *_animation; + Animation *_animationData; Animation *_activeAnimation; bool _freeAnimationFlag; int _depthStyle; @@ -115,7 +116,7 @@ public: int _scaleRange; int _interfaceY; int _spritesCount; - int _v1A; + bool _v1A; int _v1C; MADSAction _action; bool _roomChanged; @@ -195,6 +196,11 @@ public: void leftClick(); /** + * Load an animation + */ + void loadAnimation(const Common::String &resName, int abortTimers = 0); + + /** * Clear the data for the scene */ void free(); diff --git a/engines/mads/sequence.cpp b/engines/mads/sequence.cpp index 23fa0528ab..93cc9ea39e 100644 --- a/engines/mads/sequence.cpp +++ b/engines/mads/sequence.cpp @@ -131,7 +131,7 @@ int SequenceList::add(int spriteListIndex, bool flipped, int frameIndex, int tri } int SequenceList::addTimer(int time, int abortVal) { - int seqIndex; + uint seqIndex; for (seqIndex = 0; seqIndex < _entries.size(); ++seqIndex) { if (!_entries[seqIndex]._active) break; diff --git a/engines/mads/sprites.cpp b/engines/mads/sprites.cpp index 321acf026d..9a56ed3895 100644 --- a/engines/mads/sprites.cpp +++ b/engines/mads/sprites.cpp @@ -359,4 +359,30 @@ int SpriteSets::addSprites(const Common::String &resName, int flags) { return add(new SpriteAsset(_vm, resName, flags)); } +/*------------------------------------------------------------------------*/ + +ImageInterEntry::ImageInterEntry() { + _field0 = 0; + _field2 = 0; + _field3 = 0; + _field4 = 0; + _field6 = 0; + _field8 = 0; +} + +/*------------------------------------------------------------------------*/ + +int ImageInterEntries::add(int field0, int field2) { + ImageInterEntry ie; + ie._field0 = field0; + ie._field2 = field2; + + push_back(ie); + return size() - 1; +} + +void ImageInterEntries::call(int v1) { + debug("TODO: ImageInterEntries::call"); +} + } // End of namespace MADS diff --git a/engines/mads/sprites.h b/engines/mads/sprites.h index 598b9e4e3b..b7e63a0d24 100644 --- a/engines/mads/sprites.h +++ b/engines/mads/sprites.h @@ -220,6 +220,25 @@ public: int addSprites(const Common::String &resName, int flags = 0); }; +class ImageInterEntry { +public: + int _field0; + int _field2; + int _field3; + int _field4; + int _field6; + int _field8; + + ImageInterEntry(); +}; + +class ImageInterEntries: public Common::Array<ImageInterEntry> { +public: + int add(int field0, int field2); + + void call(int v1); +}; + } // End of namespace MADS #endif /* MADS_SPRITES_H */ |