aboutsummaryrefslogtreecommitdiff
path: root/engines/mads/sequence.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/mads/sequence.cpp')
-rw-r--r--engines/mads/sequence.cpp44
1 files changed, 28 insertions, 16 deletions
diff --git a/engines/mads/sequence.cpp b/engines/mads/sequence.cpp
index 05f00afb5a..e5bf1631c2 100644
--- a/engines/mads/sequence.cpp
+++ b/engines/mads/sequence.cpp
@@ -8,12 +8,12 @@
* 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.
@@ -95,8 +95,8 @@ bool SequenceList::addSubEntry(int index, SequenceTrigger mode, int frameIndex,
}
int SequenceList::add(int spriteListIndex, bool flipped, int frameIndex, int triggerCountdown, int delayTicks, int extraTicks, int numTicks,
- int msgX, int msgY, bool nonFixed, int scale, int depth, int frameInc, SpriteAnimType animType, int numSprites,
- int frameStart) {
+ int msgX, int msgY, bool nonFixed, int scale, int depth, int frameInc, SpriteAnimType animType, int numSprites,
+ int frameStart) {
Scene &scene = _vm->_game->_scene;
// Find a free slot
@@ -144,7 +144,7 @@ int SequenceList::add(int spriteListIndex, bool flipped, int frameIndex, int tri
return seqIndex;
}
-int SequenceList::addTimer(int timeout, int abortVal) {
+int SequenceList::addTimer(int timeout, int endTrigger) {
Scene &scene = _vm->_game->_scene;
uint seqIndex;
for (seqIndex = 0; seqIndex < _entries.size(); ++seqIndex) {
@@ -164,7 +164,7 @@ int SequenceList::addTimer(int timeout, int abortVal) {
se._entries._count = 0;
se._triggerMode = _vm->_game->_triggerSetupMode;
se._actionNouns = _vm->_game->_scene._action._activeAction;
- addSubEntry(seqIndex, SEQUENCE_TRIGGER_EXPIRE, 0, abortVal);
+ addSubEntry(seqIndex, SEQUENCE_TRIGGER_EXPIRE, 0, endTrigger);
return seqIndex;
}
@@ -181,6 +181,19 @@ void SequenceList::remove(int seqIndex) {
scene._spriteSlots.deleteTimer(seqIndex);
}
+int SequenceList::findByTrigger(int trigger) {
+ for (uint idx = 0; idx < _entries.size(); ++idx) {
+ if (_entries[idx]._active) {
+ for (int subIdx = 0; subIdx < _entries[idx]._entries._count; ++subIdx) {
+ if (_entries[idx]._entries._trigger[subIdx] == trigger)
+ return idx;
+ }
+ }
+ }
+
+ return -1;
+}
+
void SequenceList::setSpriteSlot(int seqIndex, SpriteSlot &spriteSlot) {
Scene &scene = _vm->_game->_scene;
SequenceEntry &timerEntry = _entries[seqIndex];
@@ -466,28 +479,28 @@ int SequenceList::startCycle(int srcSpriteIndex, bool flipped, int cycleIndex) {
return result;
}
-int SequenceList::startReverseCycle(int srcSpriteIndex, bool flipped, int numTicks,
+int SequenceList::startPingPongCycle(int srcSpriteIndex, bool flipped, int numTicks,
int triggerCountdown, int timeoutTicks, int extraTicks) {
SpriteAsset *sprites = _vm->_game->_scene._sprites[srcSpriteIndex];
MSprite *frame = sprites->getFrame(0);
int depth = _vm->_game->_scene._depthSurface.getDepth(Common::Point(
frame->_offset.x + frame->w / 2, frame->_offset.y + frame->h / 2));
- return add(srcSpriteIndex, flipped, sprites->getCount(), triggerCountdown, timeoutTicks,
- extraTicks, numTicks, 0, 0, true, 100, depth - 1, -1, ANIMTYPE_REVERSIBLE, 0, 0);
+ return add(srcSpriteIndex, flipped, 1, triggerCountdown, timeoutTicks,
+ extraTicks, numTicks, 0, 0, true, 100, depth - 1, 1, ANIMTYPE_PING_PONG, 0, 0);
}
-void SequenceList::updateTimeout(int spriteIdx, int seqIndex) {
+void SequenceList::updateTimeout(int srcSeqIndex, int destSeqIndex) {
Player &player = _vm->_game->_player;
int timeout;
- if (spriteIdx >= 0)
- timeout = _entries[spriteIdx]._timeout;
+ if (srcSeqIndex >= 0)
+ timeout = _entries[srcSeqIndex]._timeout;
else
timeout = player._priorTimer + player._ticksAmount;
- if (seqIndex >= 0)
- _entries[seqIndex]._timeout = timeout;
+ if (destSeqIndex >= 0)
+ _entries[destSeqIndex]._timeout = timeout;
else
player._priorTimer = timeout - player._ticksAmount;
@@ -526,8 +539,7 @@ void SequenceList::setMotion(int seqIndex, int flags, int deltaX, int deltaY) {
if (deltaY > 0) {
se._posSign.y = 1;
- }
- else if (deltaY < 0) {
+ } else if (deltaY < 0) {
se._posSign.y = -1;
} else {
se._posSign.y = 0;