2013-06-26 13:42:05 +00:00
|
|
|
/* 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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This code is based on the original source code of Lord Avalot d'Argent version 1.3.
|
|
|
|
* Copyright (c) 1994-1995 Mike, Mark and Thomas Thurman.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* SEQUENCE The sequencer. */
|
|
|
|
|
2013-06-28 16:41:04 +00:00
|
|
|
#include "avalanche/avalanche.h"
|
2013-09-15 11:03:21 +00:00
|
|
|
#include "avalanche/sequence.h"
|
|
|
|
#include "avalanche/gyro.h"
|
2013-09-08 09:30:23 +00:00
|
|
|
#include "avalanche/timer.h"
|
2013-09-19 18:53:47 +00:00
|
|
|
#include "avalanche/background.h"
|
2013-09-07 17:09:06 +00:00
|
|
|
#include "avalanche/animation.h"
|
2013-06-26 13:42:05 +00:00
|
|
|
|
2013-06-29 14:36:40 +00:00
|
|
|
#include "common/scummsys.h"
|
|
|
|
|
2013-06-26 13:42:05 +00:00
|
|
|
namespace Avalanche {
|
|
|
|
|
2013-07-24 17:43:10 +00:00
|
|
|
Sequence::Sequence(AvalancheEngine *vm) {
|
2013-06-28 16:41:04 +00:00
|
|
|
_vm = vm;
|
|
|
|
}
|
2013-06-26 13:42:05 +00:00
|
|
|
|
2013-09-07 22:02:20 +00:00
|
|
|
void Sequence::firstShow(byte what) {
|
2013-09-21 17:12:44 +00:00
|
|
|
_seq[0] = what;
|
2013-06-26 13:42:05 +00:00
|
|
|
|
2013-09-21 17:12:44 +00:00
|
|
|
for (uint i = 1; i < kSeqLength; i++)
|
|
|
|
_seq[i] = 0;
|
2013-06-28 16:41:04 +00:00
|
|
|
}
|
2013-06-26 13:42:05 +00:00
|
|
|
|
2013-09-07 22:02:20 +00:00
|
|
|
void Sequence::thenShow(byte what) {
|
|
|
|
for (int16 i = 0; i < kSeqLength; i++) {
|
|
|
|
if (_seq[i] == 0) {
|
|
|
|
_seq[i] = what;
|
2013-06-26 13:42:05 +00:00
|
|
|
return;
|
|
|
|
}
|
2013-06-30 20:01:05 +00:00
|
|
|
}
|
2013-06-28 16:41:04 +00:00
|
|
|
}
|
|
|
|
|
2013-09-07 22:02:20 +00:00
|
|
|
void Sequence::thenFlip(byte where, byte ped) {
|
|
|
|
thenShow(kNowFlip);
|
2013-06-28 16:41:04 +00:00
|
|
|
|
2013-09-13 19:30:03 +00:00
|
|
|
_vm->_gyro->_flipToWhere = where;
|
|
|
|
_vm->_gyro->_flipToPed = ped;
|
2013-06-28 16:41:04 +00:00
|
|
|
}
|
|
|
|
|
2013-09-07 22:02:20 +00:00
|
|
|
void Sequence::startToClose() {
|
2013-09-09 21:34:12 +00:00
|
|
|
_vm->_timer->loseTimer(Timer::kReasonSequencer);
|
|
|
|
_vm->_timer->addTimer(7, Timer::kProcSequence, Timer::kReasonSequencer);
|
2013-06-28 16:41:04 +00:00
|
|
|
}
|
|
|
|
|
2013-09-07 22:02:20 +00:00
|
|
|
void Sequence::startToOpen() {
|
2013-09-13 19:30:03 +00:00
|
|
|
_vm->_gyro->_userMovesAvvy = false; // They can't move.
|
2013-09-07 21:03:27 +00:00
|
|
|
_vm->_animation->stopWalking(); // And they're not moving now.
|
2013-09-07 22:02:20 +00:00
|
|
|
startToClose(); // Apart from that, it's the same thing.
|
2013-06-28 16:41:04 +00:00
|
|
|
}
|
|
|
|
|
2013-09-07 22:02:20 +00:00
|
|
|
void Sequence::shoveLeft() {
|
2013-09-21 17:22:21 +00:00
|
|
|
for (uint i = 0; i < kSeqLength - 1; i++)
|
|
|
|
_seq[i] = _seq[i + 1];
|
|
|
|
_seq[kSeqLength - 1] = 0;
|
2013-06-28 16:41:04 +00:00
|
|
|
}
|
|
|
|
|
2013-09-07 22:02:20 +00:00
|
|
|
void Sequence::callSequencer() {
|
|
|
|
switch (_seq[0]) {
|
2013-06-28 16:41:04 +00:00
|
|
|
case 0:
|
2013-08-29 10:07:04 +00:00
|
|
|
return; // No more routines.
|
2013-09-07 07:00:34 +00:00
|
|
|
break;
|
2013-08-29 10:07:04 +00:00
|
|
|
case 177: // Flip room.
|
2013-09-13 19:30:03 +00:00
|
|
|
_vm->_gyro->_userMovesAvvy = true;
|
|
|
|
_vm->_animation->flipRoom(_vm->_gyro->_flipToWhere, _vm->_gyro->_flipToPed);
|
2013-09-07 22:02:20 +00:00
|
|
|
if (_seq[0] == 177)
|
|
|
|
shoveLeft();
|
2013-06-28 16:41:04 +00:00
|
|
|
break;
|
2013-06-26 13:42:05 +00:00
|
|
|
}
|
|
|
|
|
2013-09-21 17:22:21 +00:00
|
|
|
if (_seq[0] <= 176) { // Show a frame.
|
2013-09-19 18:53:47 +00:00
|
|
|
_vm->_background->drawBackgroundSprite(-1, -1, _seq[0] - 1);
|
2013-09-07 22:02:20 +00:00
|
|
|
shoveLeft();
|
2013-06-28 16:41:04 +00:00
|
|
|
}
|
2013-09-07 07:00:34 +00:00
|
|
|
|
2013-09-07 22:02:20 +00:00
|
|
|
startToClose(); // Make sure this PROC gets called again.
|
2013-06-28 16:41:04 +00:00
|
|
|
}
|
2013-06-26 13:42:05 +00:00
|
|
|
|
|
|
|
} // End of namespace Avalanche.
|