aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2014-03-08 14:05:17 -0500
committerPaul Gilbert2014-03-08 14:05:17 -0500
commitc2587af8f29b2b79beae7fda5a9b983614840b17 (patch)
tree67635d112688964e628f2824aea72a82e8a6f75e
parent984099ae2ca9dd53b47e44e7815c560c68acbd61 (diff)
downloadscummvm-rg350-c2587af8f29b2b79beae7fda5a9b983614840b17.tar.gz
scummvm-rg350-c2587af8f29b2b79beae7fda5a9b983614840b17.tar.bz2
scummvm-rg350-c2587af8f29b2b79beae7fda5a9b983614840b17.zip
MADS: Clarified Events::_currentTimer as Scene::_frameStartTime
-rw-r--r--engines/mads/animation.cpp8
-rw-r--r--engines/mads/events.cpp1
-rw-r--r--engines/mads/events.h1
-rw-r--r--engines/mads/game.cpp7
-rw-r--r--engines/mads/player.cpp6
-rw-r--r--engines/mads/scene.cpp3
-rw-r--r--engines/mads/scene.h1
-rw-r--r--engines/mads/sequence.cpp8
8 files changed, 21 insertions, 14 deletions
diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp
index e4549d1054..fad5b27ea7 100644
--- a/engines/mads/animation.cpp
+++ b/engines/mads/animation.cpp
@@ -317,7 +317,7 @@ void Animation::startAnimation(int abortTimers) {
_currentFrame = 0;
_oldFrameEntry = 0;
- _nextFrameTimer = _vm->_events->_currentTimer;
+ _nextFrameTimer = _vm->_game->_scene._frameStartTime;
_abortTimers = abortTimers;
_abortTimersMode = _vm->_game->_abortTimersMode2;
_vm->_game->_scene._action._activeAction = _actionDetails;
@@ -402,7 +402,7 @@ void Animation::update() {
}
// If it's not time for the next frame, then exit
- if (_vm->_events->_currentTimer < _nextFrameTimer)
+ if (_vm->_game->_scene._frameStartTime < _nextFrameTimer)
return;
for (uint idx = 0; idx < scene._spriteSlots.size(); ++idx) {
@@ -546,7 +546,7 @@ void Animation::update() {
}
int frameNum = MIN(_currentFrame, (int)_miscEntries.size() - 1);
- _nextFrameTimer = _vm->_events->_currentTimer + _miscEntries[frameNum]._numTicks;
+ _nextFrameTimer = _vm->_game->_scene._frameStartTime + _miscEntries[frameNum]._numTicks;
}
void Animation::setCurrentFrame(int frameNumber) {
@@ -554,7 +554,7 @@ void Animation::setCurrentFrame(int frameNumber) {
_oldFrameEntry = 0;
_freeFlag = false;
- _nextScrollTimer = _nextFrameTimer = _vm->_events->_currentTimer;
+ _nextScrollTimer = _nextFrameTimer = _vm->_game->_scene._frameStartTime;
}
} // End of namespace MADS
diff --git a/engines/mads/events.cpp b/engines/mads/events.cpp
index 7fa31d7616..59cdfbfffb 100644
--- a/engines/mads/events.cpp
+++ b/engines/mads/events.cpp
@@ -41,7 +41,6 @@ EventsManager::EventsManager(MADSEngine *vm) {
_keyPressed = false;
_mouseClicked = false;
_mouseReleased = false;
- _currentTimer = 0;
_mouseButtons = 0;
_vD2 = 0;
_vD4 = 0;
diff --git a/engines/mads/events.h b/engines/mads/events.h
index f30e588bb4..6f716d8083 100644
--- a/engines/mads/events.h
+++ b/engines/mads/events.h
@@ -60,7 +60,6 @@ public:
bool _mouseReleased;
byte _mouseButtons;
bool _keyPressed;
- uint32 _currentTimer;
int _vCC;
int _vD2;
int _vD4;
diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index 08a5f97a3d..0367aa690f 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -84,6 +84,9 @@ void Game::run() {
break;
}
+ // Get the initial starting time for the first scene
+ _scene._frameStartTime = _vm->_events->getFrameCounter();
+
if (_saveSlot == -1 && protectionResult != -1 && protectionResult != -2) {
initSection(_sectionNumber);
_statusFlag = true;
@@ -199,7 +202,7 @@ void Game::sectionLoop() {
}
_abortTimers = 0;
_abortTimersMode2 = ABORTMODE_1;
- _priorFrameTimer = _vm->_events->_currentTimer;
+ _priorFrameTimer = _scene._frameStartTime;
// Call the scene logic for entering the given scene
_scene._sceneLogic->enter();
@@ -212,7 +215,7 @@ void Game::sectionLoop() {
_player.updateFrame();
_player._visible3 = _player._visible;
_player._special = _scene.getDepthHighBits(_player._playerPos);
- _player._priorTimer = _vm->_events->_currentTimer + _player._ticksAmount;
+ _player._priorTimer = _scene._frameStartTime + _player._ticksAmount;
_player.idle();
warning("TODO: _selectedObject IF block");
diff --git a/engines/mads/player.cpp b/engines/mads/player.cpp
index d19a0cb93e..ef2ce9f27c 100644
--- a/engines/mads/player.cpp
+++ b/engines/mads/player.cpp
@@ -94,9 +94,11 @@ void Player::setDest(const Common::Point &pt, int facing) {
}
void Player::nextFrame() {
+ Scene &scene = _vm->_game->_scene;
+
_priorTimer += _ticksAmount;
- if (_vm->_events->_currentTimer >= _priorTimer) {
- _priorTimer = _vm->_events->_currentTimer;
+ if (scene._frameStartTime >= _priorTimer) {
+ _priorTimer = scene._frameStartTime;
if (_moving) {
move();
} else {
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) ||
diff --git a/engines/mads/scene.h b/engines/mads/scene.h
index e2aa1098ed..969fb0b70d 100644
--- a/engines/mads/scene.h
+++ b/engines/mads/scene.h
@@ -124,6 +124,7 @@ public:
Common::Point _destPos;
int _destFacing;
Common::Point _posAdjust;
+ uint32 _frameStartTime;
/**
* Constructor
diff --git a/engines/mads/sequence.cpp b/engines/mads/sequence.cpp
index ec9c1a8c62..e8c5a37298 100644
--- a/engines/mads/sequence.cpp
+++ b/engines/mads/sequence.cpp
@@ -116,7 +116,7 @@ int SequenceList::add(int spriteListIndex, bool flipped, int frameIndex, int tri
_entries[seqIndex]._numTicks = numTicks;
_entries[seqIndex]._extraTicks = extraTicks;
- _entries[seqIndex]._timeout = _vm->_events->_currentTimer + delayTicks;
+ _entries[seqIndex]._timeout = scene._frameStartTime + delayTicks;
_entries[seqIndex]._triggerCountdown = triggerCountdown;
_entries[seqIndex]._doneFlag = false;
@@ -131,6 +131,7 @@ int SequenceList::add(int spriteListIndex, bool flipped, int frameIndex, int tri
}
int SequenceList::addTimer(int time, int abortVal) {
+ Scene &scene = _vm->_game->_scene;
uint seqIndex;
for (seqIndex = 0; seqIndex < _entries.size(); ++seqIndex) {
if (!_entries[seqIndex]._active)
@@ -143,7 +144,7 @@ int SequenceList::addTimer(int time, int abortVal) {
se._spritesIndex = -1;
se._numTicks = time;
se._extraTicks = 0;
- se._timeout = _vm->_events->_currentTimer + time;
+ se._timeout = scene._frameStartTime + time;
se._triggerCountdown = true;
se._doneFlag = false;
se._entries._count = 0;
@@ -309,12 +310,13 @@ bool SequenceList::loadSprites(int seqIndex) {
* Handles counting down entries in the timer list for action
*/
void SequenceList::tick() {
+ Scene &scene = _vm->_game->_scene;
for (uint idx = 0; idx < _entries.size(); ++idx) {
if ((_vm->_game->_abortTimers2 == 0) && (_vm->_game->_abortTimers != 0))
break;
SequenceEntry &seqEntry = _entries[idx];
- uint32 currentTimer = _vm->_events->_currentTimer;
+ uint32 currentTimer = scene._frameStartTime;
if (!seqEntry._active || (currentTimer < seqEntry._timeout))
continue;