diff options
author | Paul Gilbert | 2014-03-04 20:06:48 -0500 |
---|---|---|
committer | Paul Gilbert | 2014-03-04 20:06:48 -0500 |
commit | 1607a9104700e987cacfec41aaafd25d979aeb98 (patch) | |
tree | 06d7b94d3599c58c4cfb5f2c604b6bddb0acc2ee | |
parent | f6888eef1069ac5df07c3f4dcc3a30755bc4ebb0 (diff) | |
download | scummvm-rg350-1607a9104700e987cacfec41aaafd25d979aeb98.tar.gz scummvm-rg350-1607a9104700e987cacfec41aaafd25d979aeb98.tar.bz2 scummvm-rg350-1607a9104700e987cacfec41aaafd25d979aeb98.zip |
MADS: Finished remainder of Scene::doFrame
-rw-r--r-- | engines/mads/animation.cpp | 30 | ||||
-rw-r--r-- | engines/mads/animation.h | 8 | ||||
-rw-r--r-- | engines/mads/events.cpp | 11 | ||||
-rw-r--r-- | engines/mads/events.h | 10 | ||||
-rw-r--r-- | engines/mads/player.cpp | 9 | ||||
-rw-r--r-- | engines/mads/player.h | 5 | ||||
-rw-r--r-- | engines/mads/scene.cpp | 23 | ||||
-rw-r--r-- | engines/mads/scene_data.cpp | 7 | ||||
-rw-r--r-- | engines/mads/scene_data.h | 6 |
9 files changed, 92 insertions, 17 deletions
diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp index 941533fa63..c97d707f39 100644 --- a/engines/mads/animation.cpp +++ b/engines/mads/animation.cpp @@ -139,6 +139,7 @@ Animation *Animation::init(MADSEngine *vm, Scene *scene) { Animation::Animation(MADSEngine *vm, Scene *scene) : _vm(vm), _scene(scene) { _font = nullptr; + _resetFlag = false; } Animation::~Animation() { @@ -147,6 +148,31 @@ Animation::~Animation() { delete _spriteSets[i]; } +void Animation::free() { + Scene &scene = _vm->_game->_scene; + Player &player = _vm->_game->_player; + + if (!scene._freeAnimationFlag) { + scene._spriteSlots.fullRefresh(true); + scene._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 < _messages.size(); ++i) { + int msgIndex = _messages[i]._kernelMsgIndex; + scene._kernelMessages.remove(msgIndex); + } + + _resetFlag = false; + delete this; +} + void Animation::load(MSurface &depthSurface, InterfaceSurface &interfaceSurface, const Common::String &resName, int flags, Common::Array<RGB4> *palAnimData, SceneInfo *sceneInfo) { @@ -179,7 +205,7 @@ void Animation::load(MSurface &depthSurface, InterfaceSurface &interfaceSurface, for (int i = 0; i < aaHeader._spriteSetsCount; ++i) _spriteListIndexes.push_back(-1); - _kernelMessages.clear(); + _messages.clear(); if (aaHeader._messagesCount > 0) { // Chunk 2: Following is a list of any messages for the animation Common::SeekableReadStream *msgStream = madsPack.getItemStream(1); @@ -187,7 +213,7 @@ void Animation::load(MSurface &depthSurface, InterfaceSurface &interfaceSurface, for (int i = 0; i < aaHeader._messagesCount; ++i) { AnimMessage rec; rec.load(msgStream); - _kernelMessages.push_back(rec); + _messages.push_back(rec); } delete msgStream; diff --git a/engines/mads/animation.h b/engines/mads/animation.h index 484856f769..297abf4eee 100644 --- a/engines/mads/animation.h +++ b/engines/mads/animation.h @@ -119,11 +119,12 @@ public: static Animation *init(MADSEngine *vm, Scene *scene); public: Common::Array<int> _spriteListIndexes; - Common::Array<AnimMessage> _kernelMessages; + Common::Array<AnimMessage> _messages; Common::Array<AnimFrameEntry> _frameEntries; Common::Array<AnimMiscEntry> _miscEntries; Common::Array<SpriteAsset *> _spriteSets; Font *_font; + bool _resetFlag; public: /* * Destructor @@ -131,6 +132,11 @@ public: ~Animation(); /** + * Releases scene resources used by the animation, and then deletes it + */ + void free(); + + /** * Loads animation data */ void load(MSurface &depthSurface, InterfaceSurface &interfaceSurface, const Common::String &resName, diff --git a/engines/mads/events.cpp b/engines/mads/events.cpp index 0c2e2f2aea..1acb081d8a 100644 --- a/engines/mads/events.cpp +++ b/engines/mads/events.cpp @@ -35,7 +35,8 @@ namespace MADS { EventsManager::EventsManager(MADSEngine *vm) { _vm = vm; _cursorSprites = nullptr; - _gameCounter = 0; + _frameCounter = 0; + _frameNumber = 0; _priorFrameTime = 0; _keyPressed = false; _mouseClicked = false; @@ -140,7 +141,7 @@ void EventsManager::checkForNextFrameCounter() { // Check for next game frame uint32 milli = g_system->getMillis(); if ((milli - _priorFrameTime) >= GAME_FRAME_TIME) { - ++_gameCounter; + ++_frameCounter; _priorFrameTime = milli; // Give time to the debugger @@ -165,6 +166,12 @@ void EventsManager::delay(int cycles) { } } +void EventsManager::waitForNextFrame() { + uint32 frameNum = getFrameCounter(); + while (!_vm->shouldQuit() && !_vm->_game->_abortTimers && frameNum == _frameNumber) + delay(1); +} + void EventsManager::initVars() { _mousePos = Common::Point(-1, -1); _vD4 = _vCC; diff --git a/engines/mads/events.h b/engines/mads/events.h index 2782253bcc..add8fc34c0 100644 --- a/engines/mads/events.h +++ b/engines/mads/events.h @@ -37,7 +37,8 @@ class MADSEngine; class EventsManager { private: MADSEngine *_vm; - uint32 _gameCounter; + uint32 _frameCounter; + uint32 _frameNumber; uint32 _priorFrameTime; Common::Point _mousePos; Common::Point _currentPos; @@ -132,9 +133,14 @@ public: void delay(int amount); /** + * Wait for the next frame + */ + void waitForNextFrame(); + + /** * Gets the current frame counter */ - uint32 getFrameCounter() const { return _gameCounter; } + uint32 getFrameCounter() const { return _frameCounter; } void initVars(); }; diff --git a/engines/mads/player.cpp b/engines/mads/player.cpp index b0f4b72667..d19a0cb93e 100644 --- a/engines/mads/player.cpp +++ b/engines/mads/player.cpp @@ -40,6 +40,7 @@ Player::Player(MADSEngine *vm): _vm(vm) { _ticksAmount = 0; _priorTimer = 0; _unk3 = 0; + _forceRefresh = false; } void Player::reset() { @@ -80,6 +81,10 @@ void Player::updateFrame() { warning("TODO: Player::updateFrame"); } +void Player::update() { + warning("TODO: Player::update"); +} + void Player::resetActionList() { warning("TODO: Player::resetActionList"); } @@ -115,8 +120,4 @@ void Player::postUpdate() { warning("TODO: Player::postUpdate"); } -void Player::update() { - warning("TODO: Player::update"); -} - } // End of namespace MADS diff --git a/engines/mads/player.h b/engines/mads/player.h index 7792fb6bdd..cff131342d 100644 --- a/engines/mads/player.h +++ b/engines/mads/player.h @@ -43,8 +43,6 @@ private: void move(); void postUpdate(); - - void update(); public: int _direction; int _newDirection; @@ -66,6 +64,7 @@ public: int _ticksAmount; uint32 _priorTimer; int _unk3; + bool _forceRefresh; public: Player(MADSEngine *vm); @@ -79,6 +78,8 @@ public: void updateFrame(); + void update(); + void idle(); void setDest(const Common::Point &pt, int facing); 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) { diff --git a/engines/mads/scene_data.cpp b/engines/mads/scene_data.cpp index 5f60a1e56f..46ef2c3058 100644 --- a/engines/mads/scene_data.cpp +++ b/engines/mads/scene_data.cpp @@ -186,6 +186,13 @@ void SpriteSlots::deleteEntry(int index) { remove_at(index); } +void SpriteSlots::fullRefresh(bool clearAll) { + if (clearAll) + Common::Array<SpriteSlot>::clear(); + + push_back(SpriteSlot(ST_FULL_SCREEN_REFRESH, -1)); +} + /*------------------------------------------------------------------------*/ int SpriteSets::add(SpriteAsset *asset, int idx) { diff --git a/engines/mads/scene_data.h b/engines/mads/scene_data.h index b18eaffcbd..522cd178d0 100644 --- a/engines/mads/scene_data.h +++ b/engines/mads/scene_data.h @@ -158,6 +158,11 @@ public: */ void deleteEntry(int index); + /** + * Adds a full screen refresh to the sprite slots + */ + void fullRefresh(bool clearAll = false); + SpriteAsset &getSprite(int idx) { error("TODO"); } @@ -168,7 +173,6 @@ public: warning("TODO: SpriteSlots::indexOf"); return -1; } - }; class SpriteSets: public Common::Array<SpriteAsset *> { |