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-06-26 13:42:05 +00:00
|
|
|
#include "avalanche/sequence2.h"
|
|
|
|
#include "avalanche/gyro2.h"
|
|
|
|
#include "avalanche/timeout2.h"
|
|
|
|
#include "avalanche/celer2.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-06-28 16:41:04 +00:00
|
|
|
void Sequence::first_show(byte what) {
|
2013-09-05 05:47:40 +00:00
|
|
|
// First, we need to blank out the entire array.
|
2013-09-04 15:54:08 +00:00
|
|
|
for (uint i = 0; i < sizeof(seq); i++)
|
2013-06-28 16:41:04 +00:00
|
|
|
seq[i] = 0;
|
2013-06-26 13:42:05 +00:00
|
|
|
|
2013-09-05 05:47:40 +00:00
|
|
|
// Then it's just the same as then_show.
|
2013-06-28 16:41:04 +00:00
|
|
|
then_show(what);
|
2013-06-26 13:42:05 +00:00
|
|
|
|
2013-06-28 16:41:04 +00:00
|
|
|
}
|
2013-06-26 13:42:05 +00:00
|
|
|
|
2013-06-28 16:41:04 +00:00
|
|
|
void Sequence::then_show(byte what) {
|
2013-09-04 15:54:08 +00:00
|
|
|
for (int16 fv = 0; fv < seq_length; fv++) {
|
2013-06-28 16:41:04 +00:00
|
|
|
if (seq[fv] == 0) {
|
|
|
|
seq[fv] = 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
|
|
|
}
|
|
|
|
|
|
|
|
void Sequence::then_flip(byte where, byte ped) {
|
|
|
|
then_show(now_flip);
|
|
|
|
|
2013-09-06 14:23:57 +00:00
|
|
|
_vm->_gyro->_dna._flipToWhere = where;
|
|
|
|
_vm->_gyro->_dna._flipToPed = ped;
|
2013-06-28 16:41:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Sequence::start_to_close() {
|
2013-07-24 16:42:41 +00:00
|
|
|
_vm->_timeout->lose_timer(_vm->_timeout->reason_sequencer);
|
|
|
|
_vm->_timeout->set_up_timer(7, _vm->_timeout->procsequence, _vm->_timeout->reason_sequencer);
|
2013-06-28 16:41:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Sequence::start_to_open() {
|
2013-09-06 14:23:57 +00:00
|
|
|
_vm->_gyro->_dna._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-05 05:47:40 +00:00
|
|
|
start_to_close(); // Apart from that, it's the same thing.
|
2013-06-28 16:41:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-09-05 05:47:40 +00:00
|
|
|
// This PROC is called by Timeout when it's time to do another frame.
|
2013-06-28 16:41:04 +00:00
|
|
|
void Sequence::shove_left() {
|
2013-09-05 05:47:40 +00:00
|
|
|
memcpy(seq, seq+1, seq_length - 1); // Shift everything to the left.
|
2013-06-28 16:41:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Sequence::call_sequencer() {
|
|
|
|
switch (seq[0]) {
|
|
|
|
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-06 14:23:57 +00:00
|
|
|
_vm->_gyro->_dna._userMovesAvvy = true;
|
2013-09-07 17:09:06 +00:00
|
|
|
_vm->_animation->fliproom(_vm->_gyro->_dna._flipToWhere, _vm->_gyro->_dna._flipToPed);
|
2013-06-30 12:10:33 +00:00
|
|
|
if (seq[0] == 177)
|
|
|
|
shove_left();
|
2013-06-28 16:41:04 +00:00
|
|
|
break;
|
2013-06-26 13:42:05 +00:00
|
|
|
}
|
|
|
|
|
2013-06-28 16:41:04 +00:00
|
|
|
if ((seq[0] >= 1) && (seq[0] <= 176)) {
|
2013-09-05 05:47:40 +00:00
|
|
|
// Show a frame.
|
2013-09-03 20:22:42 +00:00
|
|
|
_vm->_celer->drawBackgroundSprite(-1, -1, seq[0]);
|
2013-06-28 16:41:04 +00:00
|
|
|
shove_left();
|
|
|
|
}
|
2013-09-07 07:00:34 +00:00
|
|
|
|
2013-09-05 05:47:40 +00:00
|
|
|
start_to_close(); // 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.
|