aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/sherlock/talk.cpp66
-rw-r--r--engines/sherlock/talk.h11
2 files changed, 64 insertions, 13 deletions
diff --git a/engines/sherlock/talk.cpp b/engines/sherlock/talk.cpp
index 26c2e523f3..6596431b8b 100644
--- a/engines/sherlock/talk.cpp
+++ b/engines/sherlock/talk.cpp
@@ -831,37 +831,83 @@ void Talk::clearSequences() {
_sequenceStack.clear();
}
+/**
+ * Pulls a background object sequence from the sequence stack and restore's the
+ * object's sequence
+ */
void Talk::pullSequence() {
- // TODO
+ Scene &scene = *_vm->_scene;
+
+ SequenceEntry seq = _sequenceStack.pop();
+ if (seq._objNum != -1) {
+ Object &obj = scene._bgShapes[seq._objNum];
+
+ if (obj._seqSize < MAX_TALK_SEQUENCES) {
+ warning("Tried to restore too few frames");
+ } else {
+ for (int idx = 0; idx < MAX_TALK_SEQUENCES; ++idx)
+ obj._sequences[idx] = seq._sequences[idx];
+
+ obj._frameNumber = seq._frameNumber;
+ obj._seqTo = seq._seqTo;
+ }
+ }
}
-void Talk::pushSequence(int speak) {
- // TODO
+/**
+ * Push the sequence of a background object that's an NPC that needs to be
+ * saved onto the sequence stack.
+ */
+void Talk::pushSequence(int speaker) {
+ People &people = *_vm->_people;
+ Scene &scene = *_vm->_scene;
+
+ // Only proceed if a speaker is specified
+ if (speaker == -1)
+ return;
+
+ SequenceEntry seqEntry;
+ if (!speaker) {
+ seqEntry._objNum = -1;
+ } else {
+ seqEntry._objNum = people.findSpeaker(speaker);
+
+ Object &obj = scene._bgShapes[seqEntry._objNum];
+ for (uint idx = 0; idx < MAX_TALK_SEQUENCES; ++idx)
+ seqEntry._sequences.push_back(obj._sequences[idx]);
+
+ seqEntry._frameNumber = obj._frameNumber;
+ seqEntry._seqTo = obj._seqTo;
+ }
+
+ _sequenceStack.push(seqEntry);
+ if (_sequenceStack.size() >= 5)
+ error("sequence stack overflow");
}
/**
* Change the sequence of a background object corresponding to a given speaker.
* The new sequence will display the character as "listening"
*/
-void Talk::setStillSeq(int speak) {
+void Talk::setStillSeq(int speaker) {
People &people = *_vm->_people;
Scene &scene = *_vm->_scene;
// Don't bother doing anything if no specific speaker is specified
- if (speak == -1)
+ if (speaker == -1)
return;
- if (speak) {
- int objNum = people.findSpeaker(speak);
+ if (speaker) {
+ int objNum = people.findSpeaker(speaker);
if (objNum != -1) {
Object &obj = scene._bgShapes[objNum];
if (obj._seqSize < MAX_TALK_SEQUENCES) {
- warning("Tried to copy too many still frames");
+ warning("Tried to copy too few still frames");
} else {
for (uint idx = 0; idx < MAX_TALK_SEQUENCES; ++idx) {
- obj._sequences[idx] = STILL_SEQUENCES[speak][idx];
- if (idx > 0 && !TALK_SEQUENCES[speak][idx] && !TALK_SEQUENCES[speak][idx - 1])
+ obj._sequences[idx] = STILL_SEQUENCES[speaker][idx];
+ if (idx > 0 && !TALK_SEQUENCES[speaker][idx] && !TALK_SEQUENCES[speaker][idx - 1])
break;
}
diff --git a/engines/sherlock/talk.h b/engines/sherlock/talk.h
index 3b02f92bc6..0cd0a8c638 100644
--- a/engines/sherlock/talk.h
+++ b/engines/sherlock/talk.h
@@ -38,6 +38,11 @@ struct SavedSequence {
Common::Array<byte> _sequences;
};
+struct SequenceEntry : public SavedSequence {
+ int _frameNumber;
+ int _seqTo;
+};
+
struct Statement {
Common::String _statement;
Common::String _reply;
@@ -80,8 +85,8 @@ private:
SherlockEngine *_vm;
int _saveSeqNum;
Common::Array<SavedSequence> _savedSequences;
+ Common::Stack<SequenceEntry> _sequenceStack;
Common::Array<Statement> _statements;
- Common::Stack<int> _sequenceStack;
TalkHistoryEntry _talkHistory[500];
int _speaker;
int _talkIndex;
@@ -116,10 +121,10 @@ public:
void drawInterface();
- void setStillSeq(int speak);
+ void setStillSeq(int speaker);
void clearSequences();
void pullSequence();
- void pushSequence(int speak);
+ void pushSequence(int speaker);
bool isSequencesEmpty() const { return _sequenceStack.empty(); }
};