aboutsummaryrefslogtreecommitdiff
path: root/engines/sherlock/tattoo
diff options
context:
space:
mode:
authorPaul Gilbert2015-08-18 20:53:31 -0400
committerPaul Gilbert2015-08-18 20:53:31 -0400
commitd4e5e447925d251afca20afec0e090b210740c82 (patch)
tree8e594456ed56d2bd478c358f214f71fd53f0dd59 /engines/sherlock/tattoo
parent21666d701e79dd83411a0ba19e00642a5c51e377 (diff)
downloadscummvm-rg350-d4e5e447925d251afca20afec0e090b210740c82.tar.gz
scummvm-rg350-d4e5e447925d251afca20afec0e090b210740c82.tar.bz2
scummvm-rg350-d4e5e447925d251afca20afec0e090b210740c82.zip
SHERLOCK: Standardize sequence stack code for both games
Diffstat (limited to 'engines/sherlock/tattoo')
-rw-r--r--engines/sherlock/tattoo/tattoo_people.cpp2
-rw-r--r--engines/sherlock/tattoo/tattoo_talk.cpp58
-rw-r--r--engines/sherlock/tattoo/tattoo_talk.h10
3 files changed, 52 insertions, 18 deletions
diff --git a/engines/sherlock/tattoo/tattoo_people.cpp b/engines/sherlock/tattoo/tattoo_people.cpp
index 4974b3df40..a208949ae1 100644
--- a/engines/sherlock/tattoo/tattoo_people.cpp
+++ b/engines/sherlock/tattoo/tattoo_people.cpp
@@ -1271,7 +1271,7 @@ void TattooPeople::setTalkSequence(int speaker, int sequenceNum) {
// See if the Object has to wait for an Abort Talk Code
if (obj.hasAborts()) {
- talk.pushTalkSequence(&obj);
+ talk.pushSequenceEntry(&obj);
obj._gotoSeq = sequenceNum;
}
else {
diff --git a/engines/sherlock/tattoo/tattoo_talk.cpp b/engines/sherlock/tattoo/tattoo_talk.cpp
index 49becbe3b4..455d41bd48 100644
--- a/engines/sherlock/tattoo/tattoo_talk.cpp
+++ b/engines/sherlock/tattoo/tattoo_talk.cpp
@@ -216,7 +216,6 @@ void TattooTalk::showTalk() {
TattooPeople &people = *(TattooPeople *)_vm->_people;
TattooUserInterface &ui = *(TattooUserInterface *)_vm->_ui;
- _sequenceStack.clear();
people.setListenSequence(_talkTo, 129);
_talkWidget.load();
@@ -897,33 +896,60 @@ OpcodeReturn TattooTalk::cmdCallTalkFile(const byte *&str) {
return RET_SUCCESS;
}
-void TattooTalk::pullSequence() {
+void TattooTalk::pushSequenceEntry(Object *obj) {
+ // Check if the shape is already on the stack
+ for (uint idx = 0; idx < TALK_SEQUENCE_STACK_SIZE; ++idx) {
+ if (_sequenceStack[idx]._obj == obj)
+ return;
+ }
+
+ // Find a free slot and save the details in it
+ for (uint idx = 0; idx < TALK_SEQUENCE_STACK_SIZE; ++idx) {
+ SequenceEntry &seq = _sequenceStack[idx];
+ if (seq._obj == nullptr) {
+ seq._obj = obj;
+ seq._frameNumber = obj->_frameNumber;
+ seq._sequenceNumber = obj->_sequenceNumber;
+ seq._seqStack = obj->_seqStack;
+ seq._seqTo = obj->_seqTo;
+ seq._seqCounter = obj->_seqCounter;
+ seq._seqCounter2 = obj->_seqCounter2;
+ return;
+ }
+ }
+
+ error("Ran out of talk sequence stack space");
+}
+
+void TattooTalk::pullSequence(int slot) {
People &people = *_vm->_people;
for (int idx = 0; idx < TALK_SEQUENCE_STACK_SIZE; ++idx) {
- TalkSequence &ts = _talkSequenceStack[idx];
+ SequenceEntry &seq = _sequenceStack[idx];
+ if (slot != -1 && idx != slot)
+ continue;
// Check for an entry in this slot
- if (ts._obj) {
- Object &o = *ts._obj;
+ if (seq._obj) {
+ Object &o = *seq._obj;
// See if we're not supposed to restore it until an Allow Talk Interrupt
- if (ts._obj->hasAborts()) {
- ts._obj->_gotoSeq = -1;
- ts._obj->_restoreSlot = idx;
+ if (seq._obj->hasAborts()) {
+ seq._obj->_gotoSeq = -1;
+ seq._obj->_restoreSlot = idx;
} else {
// Restore the object's sequence information immediately
- o._frameNumber = ts._frameNumber;
- o._sequenceNumber = ts._sequenceNumber;
- o._seqStack = ts._seqStack;
- o._seqTo = ts._seqTo;
- o._seqCounter = ts._seqCounter;
- o._seqCounter2 = ts._seqCounter2;
+ o._frameNumber = seq._frameNumber;
+ o._sequenceNumber = seq._sequenceNumber;
+ o._seqStack = seq._seqStack;
+ o._seqTo = seq._seqTo;
+ o._seqCounter = seq._seqCounter;
+ o._seqCounter2 = seq._seqCounter2;
o._gotoSeq = 0;
o._talkSeq = 0;
// Flag the slot as free again
- ts._obj = nullptr;
+ seq._obj = nullptr;
}
}
}
@@ -950,7 +976,7 @@ void TattooTalk::pullSequence() {
bool TattooTalk::isSequencesEmpty() const {
for (int idx = 0; idx < TALK_SEQUENCE_STACK_SIZE; ++idx) {
- if (_talkSequenceStack[idx]._obj)
+ if (_sequenceStack[idx]._obj)
return false;
}
diff --git a/engines/sherlock/tattoo/tattoo_talk.h b/engines/sherlock/tattoo/tattoo_talk.h
index 68db063751..3976f15e32 100644
--- a/engines/sherlock/tattoo/tattoo_talk.h
+++ b/engines/sherlock/tattoo/tattoo_talk.h
@@ -37,6 +37,8 @@ namespace Sherlock {
namespace Tattoo {
+#define TALK_SEQUENCE_STACK_SIZE 20
+
class WidgetTalk;
class TattooTalk : public Talk {
@@ -44,6 +46,7 @@ class TattooTalk : public Talk {
private:
WidgetTalk _talkWidget;
WidgetPassword _passwordWidget;
+ SequenceEntry _sequenceStack[TALK_SEQUENCE_STACK_SIZE];
OpcodeReturn cmdCallTalkFile(const byte *&str);
OpcodeReturn cmdSwitchSpeaker(const byte *&str);
@@ -102,10 +105,15 @@ public:
virtual ~TattooTalk() {}
/**
+ * Push the details of a passed object onto the saved sequences stack
+ */
+ virtual void pushSequenceEntry(Object *obj);
+
+ /**
* Pulls a background object sequence from the sequence stack and restore's the
* object's sequence
*/
- virtual void pullSequence();
+ virtual void pullSequence(int slot = -1);
/**
* Returns true if the script stack is empty