aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStrangerke2013-09-26 20:16:33 +0200
committerStrangerke2013-09-26 20:16:33 +0200
commitdf3fe7b0ec1c3afbba1539bf3cea510cef798ee1 (patch)
tree8a4ff3a7ccc9179c35081a1d699686541a1b2399
parent8efaa45425cdb8d10d7f3fbc58a3a143c3033ff2 (diff)
downloadscummvm-rg350-df3fe7b0ec1c3afbba1539bf3cea510cef798ee1.tar.gz
scummvm-rg350-df3fe7b0ec1c3afbba1539bf3cea510cef798ee1.tar.bz2
scummvm-rg350-df3fe7b0ec1c3afbba1539bf3cea510cef798ee1.zip
AVALANCHE: Objectify Sequence. This commit breaks savegames.
-rw-r--r--engines/avalanche/animation.cpp4
-rw-r--r--engines/avalanche/avalanche.cpp4
-rw-r--r--engines/avalanche/avalot.cpp74
-rw-r--r--engines/avalanche/parser.cpp5
-rw-r--r--engines/avalanche/sequence.cpp126
-rw-r--r--engines/avalanche/sequence.h32
-rw-r--r--engines/avalanche/timer.cpp11
7 files changed, 177 insertions, 79 deletions
diff --git a/engines/avalanche/animation.cpp b/engines/avalanche/animation.cpp
index 11e0555326..101eccbdfe 100644
--- a/engines/avalanche/animation.cpp
+++ b/engines/avalanche/animation.cpp
@@ -1177,9 +1177,7 @@ void Animation::hideInCupboard() {
appearPed(0, 2); // Walk out of the cupboard.
_vm->_dialogs->displayText("You leave the cupboard. Nice to be out of there!");
_vm->_avalot->_avvysInTheCupboard = false;
- _vm->_sequence->firstShow(8);
- _vm->_sequence->thenShow(7);
- _vm->_sequence->startToClose();
+ _vm->_sequence->startCupboardSeq();
}
} else {
// Not hiding in the cupboard
diff --git a/engines/avalanche/avalanche.cpp b/engines/avalanche/avalanche.cpp
index cddb8ba270..339d027cf9 100644
--- a/engines/avalanche/avalanche.cpp
+++ b/engines/avalanche/avalanche.cpp
@@ -115,6 +115,7 @@ const char *AvalancheEngine::getCopyrightString() const {
void AvalancheEngine::synchronize(Common::Serializer &sz) {
_animation->synchronize(sz);
_parser->synchronize(sz);
+ _sequence->synchronize(sz);
sz.syncAsByte(_avalot->_carryNum);
for (int i = 0; i < kObjectNum; i++)
@@ -256,8 +257,7 @@ void AvalancheEngine::synchronize(Common::Serializer &sz) {
sz.syncAsByte(_timer->_times[i]._action);
sz.syncAsByte(_timer->_times[i]._reason);
}
-
- sz.syncBytes(_sequence->_seq, _sequence->kSeqLength);
+
}
bool AvalancheEngine::canSaveGameStateCurrently() { // TODO: Refine these!!!
diff --git a/engines/avalanche/avalot.cpp b/engines/avalanche/avalot.cpp
index 42f29424ec..a290c7323d 100644
--- a/engines/avalanche/avalot.cpp
+++ b/engines/avalanche/avalot.cpp
@@ -1017,10 +1017,7 @@ void Avalot::enterRoom(Room roomId, byte ped) {
if (ped != 0) {
_vm->_background->draw(-1, -1, 5);
_vm->_graphics->refreshBackground();
- _vm->_sequence->firstShow(6);
- _vm->_sequence->thenShow(5);
- _vm->_sequence->thenShow(7);
- _vm->_sequence->startToClose();
+ _vm->_sequence->startMusicRoomSeq();
}
break;
@@ -1028,11 +1025,7 @@ void Avalot::enterRoom(Room roomId, byte ped) {
if (ped == 2) {
_vm->_background->draw(-1, -1, 2);
_vm->_graphics->refreshBackground();
- _vm->_sequence->firstShow(3);
- _vm->_sequence->thenShow(2);
- _vm->_sequence->thenShow(1);
- _vm->_sequence->thenShow(4);
- _vm->_sequence->startToClose();
+ _vm->_sequence->startNottsSeq();
}
break;
@@ -1040,10 +1033,7 @@ void Avalot::enterRoom(Room roomId, byte ped) {
if (ped == 2) {
_vm->_background->draw(-1, -1, 5);
_vm->_graphics->refreshBackground();
- _vm->_sequence->firstShow(6);
- _vm->_sequence->thenShow(5);
- _vm->_sequence->thenShow(7);
- _vm->_sequence->startToClose();
+ _vm->_sequence->startMusicRoomSeq();
}
break;
@@ -1068,16 +1058,7 @@ void Avalot::enterRoom(Room roomId, byte ped) {
_vm->_animation->_sprites[1].init(10, false, _vm->_animation); // Define the dart.
_vm->_background->draw(-1, -1, 0);
_vm->_graphics->refreshBackground();
- _vm->_sequence->firstShow(1);
- if (_arrowInTheDoor)
- _vm->_sequence->thenShow(3);
- else
- _vm->_sequence->thenShow(2);
-
- if (_takenPen)
- _vm->_background->draw(-1, -1, 3);
-
- _vm->_sequence->startToClose();
+ _vm->_sequence->startCardiffSeq2();
} else {
_vm->_background->draw(-1, -1, 0);
if (_arrowInTheDoor)
@@ -1092,10 +1073,7 @@ void Avalot::enterRoom(Room roomId, byte ped) {
if (ped == 1) {
_vm->_background->draw(-1, -1, 1);
_vm->_graphics->refreshBackground();
- _vm->_sequence->firstShow(2);
- _vm->_sequence->thenShow(1);
- _vm->_sequence->thenShow(3);
- _vm->_sequence->startToClose();
+ _vm->_sequence->startGardenSeq();
}
break;
@@ -1113,10 +1091,7 @@ void Avalot::enterRoom(Room roomId, byte ped) {
_vm->_background->draw(-1, -1, 1);
_vm->_graphics->refreshBackground();
- _vm->_sequence->firstShow(2);
- _vm->_sequence->thenShow(1);
- _vm->_sequence->thenShow(3);
- _vm->_sequence->startToClose();
+ _vm->_sequence->startGardenSeq();
}
break;
@@ -1152,11 +1127,7 @@ void Avalot::enterRoom(Room roomId, byte ped) {
// Shut the door
_vm->_background->draw(-1, -1, 2);
_vm->_graphics->refreshBackground();
- _vm->_sequence->firstShow(3);
- _vm->_sequence->firstShow(2);
- _vm->_sequence->thenShow(1);
- _vm->_sequence->thenShow(4);
- _vm->_sequence->startToClose();
+ _vm->_sequence->startDuckSeq();
}
break;
@@ -1993,53 +1964,42 @@ void Avalot::openDoor(Room whither, byte ped, byte magicnum) {
case kRoomOutsideYours:
case kRoomOutsideNottsPub:
case kRoomOutsideDucks:
- _vm->_sequence->firstShow(1);
- _vm->_sequence->thenShow(2);
- _vm->_sequence->thenShow(3);
+ _vm->_sequence->startOutsideSeq(whither, ped);
break;
case kRoomInsideCardiffCastle:
- _vm->_sequence->firstShow(1);
- _vm->_sequence->thenShow(5);
+ _vm->_sequence->startCardiffSeq(whither, ped);
break;
case kRoomAvvysGarden:
case kRoomEntranceHall:
case kRoomInsideAbbey:
case kRoomYourHall:
- _vm->_sequence->firstShow(1);
- _vm->_sequence->thenShow(2);
+ _vm->_sequence->startHallSeq(whither, ped);
break;
case kRoomMusicRoom:
case kRoomOutsideArgentPub:
- _vm->_sequence->firstShow(5);
- _vm->_sequence->thenShow(6);
+ _vm->_sequence->startMusicRoomSeq2(whither, ped);
break;
case kRoomLusties:
switch (magicnum) {
case 14:
if (_avvysInTheCupboard) {
_vm->_animation->hideInCupboard();
- _vm->_sequence->firstShow(8);
- _vm->_sequence->thenShow(7);
- _vm->_sequence->startToClose();
+ _vm->_sequence->startLustiesSeq1();
return;
} else {
_vm->_animation->appearPed(0, 5);
- _vm->_animation->_sprites[0]._facingDir = kDirRight; // added by TT 12/3/1995
- _vm->_sequence->firstShow(8);
- _vm->_sequence->thenShow(9);
+ _vm->_animation->_sprites[0]._facingDir = kDirRight;
+ _vm->_sequence->startLustiesSeq2(whither, ped);
}
break;
case 12:
- _vm->_sequence->firstShow(4);
- _vm->_sequence->thenShow(5);
- _vm->_sequence->thenShow(6);
+ _vm->_sequence->startLustiesSeq3(whither, ped);
break;
}
break;
+ default:
+ _vm->_sequence->startDummySeq(whither, ped);
}
-
- _vm->_sequence->thenFlip(whither, ped);
- _vm->_sequence->startToOpen();
}
void Avalot::setRoom(People persId, Room roomId) {
diff --git a/engines/avalanche/parser.cpp b/engines/avalanche/parser.cpp
index 064d6aa7ad..b8b461b053 100644
--- a/engines/avalanche/parser.cpp
+++ b/engines/avalanche/parser.cpp
@@ -1547,10 +1547,7 @@ void Parser::playHarp() {
void Parser::winSequence() {
_vm->_dialogs->displayScrollChain('q', 78);
- _vm->_sequence->firstShow(7);
- _vm->_sequence->thenShow(8);
- _vm->_sequence->thenShow(9);
- _vm->_sequence->startToClose();
+ _vm->_sequence->startWinSeq();
_vm->_timer->addTimer(30, Timer::kProcWinning, Timer::kReasonWinning);
}
diff --git a/engines/avalanche/sequence.cpp b/engines/avalanche/sequence.cpp
index 61de6b8bf3..472dca9862 100644
--- a/engines/avalanche/sequence.cpp
+++ b/engines/avalanche/sequence.cpp
@@ -104,4 +104,130 @@ void Sequence::callSequencer() {
startToClose(); // Make sure this PROC gets called again.
}
+void Sequence::startHallSeq(Room whither, byte ped) {
+ firstShow(1);
+ thenShow(2);
+ thenFlip(whither, ped);
+ startToOpen();
+}
+
+void Sequence::startOutsideSeq(Room whither, byte ped) {
+ firstShow(1);
+ thenShow(2);
+ thenShow(3);
+ thenFlip(whither, ped);
+ startToOpen();
+}
+
+void Sequence::startCardiffSeq(Room whither, byte ped) {
+ firstShow(1);
+ thenShow(5);
+ thenFlip(whither, ped);
+ startToOpen();
+}
+
+void Sequence::startNaughtyDukeSeq() {
+ firstShow(2);
+ startToClose();
+}
+
+void Sequence::startGardenSeq() {
+ firstShow(2);
+ thenShow(1);
+ thenShow(3);
+ startToClose();
+}
+
+// FIXME! 2 firstShow()!
+void Sequence::startDuckSeq() {
+ firstShow(3);
+ firstShow(2);
+ thenShow(1);
+ thenShow(4);
+ startToClose();
+}
+
+void Sequence::startNottsSeq() {
+ firstShow(3);
+ thenShow(2);
+ thenShow(1);
+ thenShow(4);
+ startToClose();
+}
+
+void Sequence::startLustiesSeq3(Room whither, byte ped) {
+ firstShow(4);
+ thenShow(5);
+ thenShow(6);
+ thenFlip(whither, ped);
+ startToOpen();
+}
+
+void Sequence::startMusicRoomSeq2(Room whither, byte ped) {
+ firstShow(5);
+ thenShow(6);
+ thenFlip(whither, ped);
+ startToOpen();
+}
+
+void Sequence::startGeidaLuteSeq() {
+ firstShow(5);
+ thenShow(6); // He falls asleep...
+ startToClose(); // Not really closing, but we're using the same procedure.
+}
+
+void Sequence::startMusicRoomSeq() {
+ firstShow(6);
+ thenShow(5);
+ thenShow(7);
+ startToClose();
+}
+
+void Sequence::startWinSeq() {
+ firstShow(7);
+ thenShow(8);
+ thenShow(9);
+ startToClose();
+}
+
+void Sequence::startCupboardSeq() {
+ firstShow(8);
+ thenShow(7);
+ startToClose();
+}
+
+void Sequence::startLustiesSeq1() {
+ firstShow(8);
+ thenShow(7);
+ startToClose();
+}
+
+void Sequence::startLustiesSeq2(Room whither, byte ped) {
+ firstShow(8);
+ thenShow(9);
+ thenFlip(whither, ped);
+ startToOpen();
+}
+
+void Sequence::startCardiffSeq2() {
+ firstShow(1);
+ if (_vm->_avalot->_arrowInTheDoor)
+ thenShow(3);
+ else
+ thenShow(2);
+
+ if (_vm->_avalot->_takenPen)
+ _vm->_background->draw(-1, -1, 3);
+
+ startToClose();
+}
+
+void Sequence::startDummySeq(Room whither, byte ped) {
+ thenFlip(whither, ped);
+ startToOpen();
+}
+
+void Sequence::synchronize(Common::Serializer &sz) {
+ sz.syncBytes(_seq, kSeqLength);
+}
} // End of namespace Avalanche.
diff --git a/engines/avalanche/sequence.h b/engines/avalanche/sequence.h
index a160b58a7e..2c84abb8bf 100644
--- a/engines/avalanche/sequence.h
+++ b/engines/avalanche/sequence.h
@@ -36,25 +36,45 @@ namespace Avalanche {
class AvalancheEngine;
class Sequence {
-public:
+private:
static const int16 kNowFlip = 177;
static const int16 kSeqLength = 10;
+public:
byte _seq[kSeqLength];
Sequence(AvalancheEngine *vm);
+ void synchronize(Common::Serializer &sz);
- void firstShow(byte what);
- void thenShow(byte what);
- void thenFlip(Room where, byte ped);
- void startToClose();
- void startToOpen();
void callSequencer();
+ void startCupboardSeq();
+ void startMusicRoomSeq();
+ void startMusicRoomSeq2(Room whither, byte ped);
+ void startGardenSeq();
+ void startGeidaLuteSeq();
+ void startWinSeq();
+ void startNaughtyDukeSeq();
+ void startLustiesSeq1();
+ void startLustiesSeq2(Room whither, byte ped);
+ void startLustiesSeq3(Room whither, byte ped);
+ void startHallSeq(Room whither, byte ped);
+ void startCardiffSeq(Room whither, byte ped);
+ void startOutsideSeq(Room whither, byte ped);
+ void startDuckSeq();
+ void startCardiffSeq2();
+ void startNottsSeq();
+ void startDummySeq(Room whither, byte ped);
+
private:
AvalancheEngine *_vm;
void shoveLeft(); // This is called by Timer when it's time to do another frame. It shifts everything to the left.
+ void firstShow(byte what);
+ void thenShow(byte what);
+ void thenFlip(Room where, byte ped);
+ void startToClose();
+ void startToOpen();
};
} // End of namespace Avalanche.
diff --git a/engines/avalanche/timer.cpp b/engines/avalanche/timer.cpp
index 52a5bff453..d1d25ba740 100644
--- a/engines/avalanche/timer.cpp
+++ b/engines/avalanche/timer.cpp
@@ -430,8 +430,7 @@ void Timer::naughtyDuke() { // This is when the Duke comes in and takes your mon
// Let's get the door opening.
_vm->_background->draw(-1, -1, 0);
- _vm->_sequence->firstShow(2);
- _vm->_sequence->startToClose();
+ _vm->_sequence->startNaughtyDukeSeq();
addTimer(50, kProcNaughtyDuke2, kReasonNaughtyDuke);
}
@@ -441,13 +440,13 @@ void Timer::naughtyDuke2() {
_vm->_dialogs->displayScrollChain('q', 48); // "Ha ha, it worked again!"
spr->walkTo(0); // Walk to the door.
spr->_vanishIfStill = true; // Then go away!
+
addTimer(32, kProcNaughtyDuke3, kReasonNaughtyDuke);
}
void Timer::naughtyDuke3() {
_vm->_background->draw(-1, -1, 0);
- _vm->_sequence->firstShow(2);
- _vm->_sequence->startToClose();
+ _vm->_sequence->startNaughtyDukeSeq();
}
void Timer::jump() {
@@ -694,9 +693,7 @@ void Timer::giveLuteToGeida() { // Moved here from Acci.
_vm->_dialogs->displayScrollChain('Q', 86);
_vm->_avalot->incScore(4);
_vm->_avalot->_lustieIsAsleep = true;
- _vm->_sequence->firstShow(5);
- _vm->_sequence->thenShow(6); // He falls asleep...
- _vm->_sequence->startToClose(); // Not really closing, but we're using the same procedure.
+ _vm->_sequence->startGeidaLuteSeq();
}
} // End of namespace Avalanche.