SHERLOCK: RT: Add missing talk sequence stack handling

This commit is contained in:
Paul Gilbert 2015-08-16 21:43:12 -04:00
parent 28dc37e627
commit c14f27aa48
6 changed files with 91 additions and 28 deletions

View File

@ -878,6 +878,28 @@ OpcodeReturn ScalpelTalk::cmdCallTalkFile(const byte *&str) {
return RET_SUCCESS;
}
void ScalpelTalk::pullSequence() {
Scene &scene = *_vm->_scene;
if (_sequenceStack.empty())
return;
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;
}
}
}
} // End of namespace Scalpel
} // End of namespace Sherlock

View File

@ -101,6 +101,12 @@ public:
* Trigger to play a 3DO talk dialog movie
*/
void talk3DOMovieTrigger(int subIndex);
/**
* Pulls a background object sequence from the sequence stack and restore's the
* object's sequence
*/
virtual void pullSequence();
};
} // End of namespace Scalpel

View File

@ -640,28 +640,6 @@ void Talk::clearSequences() {
_sequenceStack.clear();
}
void Talk::pullSequence() {
Scene &scene = *_vm->_scene;
if (_sequenceStack.empty() || IS_ROSE_TATTOO)
return;
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 speaker) {
People &people = *_vm->_people;
Scene &scene = *_vm->_scene;

View File

@ -330,12 +330,6 @@ public:
* Clears the stack of pending object sequences associated with speakers in the scene
*/
void clearSequences();
/**
* Pulls a background object sequence from the sequence stack and restore's the
* object's sequence
*/
void pullSequence();
/**
* Push the sequence of a background object that's an NPC that needs to be
@ -378,6 +372,12 @@ public:
* Prints a single conversation option in the interface window
*/
virtual int talkLine(int lineNum, int stateNum, byte color, int lineY, bool slamIt) { return 0; }
/**
* Pulls a background object sequence from the sequence stack and restore's the
* object's sequence
*/
virtual void pullSequence() = 0;
};
} // End of namespace Sherlock

View File

@ -897,6 +897,57 @@ OpcodeReturn TattooTalk::cmdCallTalkFile(const byte *&str) {
return RET_SUCCESS;
}
void TattooTalk::pullSequence() {
People &people = *_vm->_people;
for (int idx = 0; idx < TALK_SEQUENCE_STACK_SIZE; ++idx) {
TalkSequence &ts = _talkSequenceStack[idx];
// Check for an entry in this slot
if (ts._obj) {
Object &o = *ts._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;
} 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._gotoSeq = 0;
o._talkSeq = 0;
// Flag the slot as free again
ts._obj = nullptr;
}
}
}
// Handle restoring any character positioning
for (int idx = 0; idx < MAX_CHARACTERS; ++idx) {
Person &person = people[idx];
if (person._type == CHARACTER && !person._walkSequences.empty() && person._sequenceNumber >= TALK_UPRIGHT
&& person._sequenceNumber <= LISTEN_UPLEFT) {
person.gotoStand();
bool done = false;
do {
person.checkSprite();
for (int frameNum = 0; frameNum < person._frameNumber; ++frameNum) {
if (person._walkSequences[person._sequenceNumber]._sequences[frameNum] == 0)
done = true;
}
} while (!done);
}
}
}
} // End of namespace Tattoo
} // End of namespace Sherlock

View File

@ -100,6 +100,12 @@ protected:
public:
TattooTalk(SherlockEngine *vm);
virtual ~TattooTalk() {}
/**
* Pulls a background object sequence from the sequence stack and restore's the
* object's sequence
*/
virtual void pullSequence();
};
} // End of namespace Tattoo