ILLUSIONS: Add TalkThread
This commit is contained in:
parent
812c7fc3a8
commit
fc4266bcad
14 changed files with 501 additions and 24 deletions
|
@ -83,7 +83,7 @@ Actor::Actor(IllusionsEngine *vm)
|
|||
_notifyThreadId1 = 0;
|
||||
_notifyThreadId2 = 0;
|
||||
_surfaceTextFlag = 0;
|
||||
_field30 = 0;
|
||||
_entryTblPtr = 0;
|
||||
_seqCodeIp = 0;
|
||||
_sequenceId = 0;
|
||||
_seqCodeValue1 = 0;
|
||||
|
@ -360,11 +360,11 @@ void Control::clearNotifyThreadId2() {
|
|||
if (_actor->_subobjects[i]) {
|
||||
Control *subControl = _vm->_dict->getObjectControl(_actor->_subobjects[i]);
|
||||
subControl->_actor->_flags &= ~0x80;
|
||||
subControl->_actor->_field30 = 0;
|
||||
subControl->_actor->_entryTblPtr = 0;
|
||||
subControl->_actor->_notifyThreadId2 = 0;
|
||||
}
|
||||
_actor->_flags &= ~0x80;
|
||||
_actor->_field30 = 0;
|
||||
_actor->_entryTblPtr = 0;
|
||||
_actor->_notifyThreadId2 = 0;
|
||||
}
|
||||
|
||||
|
@ -582,7 +582,7 @@ void Control::sequenceActor() {
|
|||
|
||||
}
|
||||
|
||||
void Control::startSequenceActorIntern(uint32 sequenceId, int value, int value2, uint32 notifyThreadId) {
|
||||
void Control::startSequenceActorIntern(uint32 sequenceId, int value, byte *entryTblPtr, uint32 notifyThreadId) {
|
||||
|
||||
stopActor();
|
||||
|
||||
|
@ -609,9 +609,9 @@ void Control::startSequenceActorIntern(uint32 sequenceId, int value, int value2,
|
|||
_actor->initSequenceStack();
|
||||
stopSequenceActor();
|
||||
_actor->_linkIndex2 = 0;
|
||||
if (value2) {
|
||||
if (entryTblPtr) {
|
||||
_actor->_flags |= 0x80;
|
||||
_actor->_field30 = value2;
|
||||
_actor->_entryTblPtr = entryTblPtr;
|
||||
_actor->_notifyThreadId1 = 0;
|
||||
_actor->_notifyThreadId2 = notifyThreadId;
|
||||
}
|
||||
|
|
|
@ -119,7 +119,7 @@ public:
|
|||
uint32 _notifyId3C;
|
||||
|
||||
uint32 _notifyThreadId2;
|
||||
int _field30;
|
||||
byte *_entryTblPtr;
|
||||
|
||||
int _surfaceTextFlag;
|
||||
|
||||
|
@ -185,7 +185,7 @@ public:
|
|||
Common::Point _position;
|
||||
Common::Point _subobjectsPos[kSubObjectsCount];
|
||||
// TODO 0000001C - 00000054 unknown
|
||||
void startSequenceActorIntern(uint32 sequenceId, int value, int value2, uint32 notifyThreadId);
|
||||
void startSequenceActorIntern(uint32 sequenceId, int value, byte *entryTblPtr, uint32 notifyThreadId);
|
||||
void execSequenceOpcode(OpCall &opCall);
|
||||
};
|
||||
|
||||
|
|
|
@ -367,7 +367,35 @@ Common::Point IllusionsEngine::getNamedPointPosition(uint32 namedPointId) {
|
|||
}
|
||||
|
||||
void IllusionsEngine::playVideo(uint32 videoId, uint32 objectId, uint32 priority, uint32 threadId) {
|
||||
|
||||
// TODO
|
||||
}
|
||||
|
||||
bool IllusionsEngine::isSoundActive() {
|
||||
// TODO
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IllusionsEngine::cueVoice(byte *voiceName) {
|
||||
// TODO
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IllusionsEngine::isVoiceCued() {
|
||||
// TODO
|
||||
return false;
|
||||
}
|
||||
|
||||
void IllusionsEngine::startVoice(int volume, int panX) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
void IllusionsEngine::stopVoice() {
|
||||
// TODO
|
||||
}
|
||||
|
||||
bool IllusionsEngine::isVoicePlaying() {
|
||||
// TODO
|
||||
return false;
|
||||
}
|
||||
|
||||
} // End of namespace Illusions
|
||||
|
|
|
@ -113,6 +113,13 @@ public:
|
|||
int convertPanXCoord(int16 x);
|
||||
Common::Point getNamedPointPosition(uint32 namedPointId);
|
||||
void playVideo(uint32 videoId, uint32 objectId, uint32 value, uint32 threadId);
|
||||
|
||||
bool isSoundActive();
|
||||
bool cueVoice(byte *voiceName);
|
||||
bool isVoiceCued();
|
||||
void startVoice(int volume, int panX);
|
||||
void stopVoice();
|
||||
bool isVoicePlaying();
|
||||
|
||||
#if 0
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ MODULE_OBJS := \
|
|||
spritedecompressqueue.o \
|
||||
spritedrawqueue.o \
|
||||
talkresource.o \
|
||||
talkthread.o \
|
||||
thread.o \
|
||||
time.o \
|
||||
timerthread.o \
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "illusions/scriptman.h"
|
||||
#include "illusions/scriptthread.h"
|
||||
#include "illusions/scriptopcodes.h"
|
||||
#include "illusions/talkthread.h"
|
||||
#include "illusions/timerthread.h"
|
||||
|
||||
namespace Illusions {
|
||||
|
@ -128,6 +129,9 @@ ScriptMan::ScriptMan(IllusionsEngine *vm)
|
|||
: _vm(vm), _pauseCtr(0), _doScriptThreadInit(false) {
|
||||
_threads = new ThreadList(vm);
|
||||
_scriptOpcodes = new ScriptOpcodes(vm);
|
||||
_field8 = 1;
|
||||
_fieldA = 0;
|
||||
_fieldE = 240;
|
||||
}
|
||||
|
||||
ScriptMan::~ScriptMan() {
|
||||
|
@ -158,8 +162,8 @@ void ScriptMan::startAnonScriptThread(int32 threadId, uint32 callingThreadId,
|
|||
|
||||
uint32 ScriptMan::startTempScriptThread(byte *scriptCodeIp, uint32 callingThreadId,
|
||||
uint32 value8, uint32 valueC, uint32 value10) {
|
||||
debug("Starting temp script thread");
|
||||
uint32 tempThreadId = newTempThreadId();
|
||||
debug("Starting temp script thread %08X", tempThreadId);
|
||||
newScriptThread(tempThreadId, callingThreadId, 0, scriptCodeIp, value8, valueC, value10);
|
||||
return tempThreadId;
|
||||
}
|
||||
|
@ -173,21 +177,56 @@ uint32 ScriptMan::startTimerThread(uint32 duration, uint32 threadId) {
|
|||
}
|
||||
|
||||
uint32 ScriptMan::startAbortableThread(byte *scriptCodeIp1, byte *scriptCodeIp2, uint32 callingThreadId) {
|
||||
debug("Starting abortable thread");
|
||||
uint32 tempThreadId = newTempThreadId();
|
||||
debug("Starting abortable thread %08X", tempThreadId);
|
||||
uint32 scriptThreadId = startTempScriptThread(scriptCodeIp1, tempThreadId, 0, 0, 0);
|
||||
AbortableThread *abortableThread = new AbortableThread(_vm, tempThreadId, callingThreadId, 0, scriptThreadId, scriptCodeIp2);
|
||||
AbortableThread *abortableThread = new AbortableThread(_vm, tempThreadId, callingThreadId, 0,
|
||||
scriptThreadId, scriptCodeIp2);
|
||||
_threads->startThread(abortableThread);
|
||||
return tempThreadId;
|
||||
}
|
||||
|
||||
uint32 ScriptMan::startTalkThread(int16 duration, uint32 objectId, uint32 talkId, uint32 sequenceId1,
|
||||
uint32 sequenceId2, uint32 namedPointId, uint32 callingThreadId) {
|
||||
debug("Starting talk thread");
|
||||
uint32 tempThreadId = newTempThreadId();
|
||||
// TODO endTalkThreadsNoNotify();
|
||||
TalkThread *talkThread = new TalkThread(_vm, tempThreadId, callingThreadId, 0,
|
||||
duration, objectId, talkId, sequenceId1, sequenceId2, namedPointId);
|
||||
_threads->startThread(talkThread);
|
||||
return tempThreadId;
|
||||
}
|
||||
|
||||
void ScriptMan::setCurrFontId(uint32 fontId) {
|
||||
_fontId = fontId;
|
||||
}
|
||||
|
||||
bool ScriptMan::checkActiveTalkThreads() {
|
||||
// TODO
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32 ScriptMan::clipTextDuration(uint32 duration) {
|
||||
switch (_field8) {
|
||||
case 2:
|
||||
if (duration == 0)
|
||||
duration = 240;
|
||||
break;
|
||||
case 3:
|
||||
if (duration < _fieldA)
|
||||
duration = _fieldA;
|
||||
break;
|
||||
case 4:
|
||||
if (duration > _fieldA)
|
||||
duration = _fieldA;
|
||||
break;
|
||||
}
|
||||
return duration;
|
||||
}
|
||||
|
||||
void ScriptMan::reset() {
|
||||
// TODO _scriptResource->_blockCounters.clear();
|
||||
// TODO _scriptResource->_properties.clear();
|
||||
_scriptResource->_blockCounters.clear();
|
||||
_scriptResource->_properties.clear();
|
||||
// TODO script_sub_417FF0(1, 0);
|
||||
}
|
||||
|
||||
|
|
|
@ -81,7 +81,11 @@ public:
|
|||
uint32 startAbortableTimerThread(uint32 duration, uint32 threadId);
|
||||
uint32 startTimerThread(uint32 duration, uint32 threadId);
|
||||
uint32 startAbortableThread(byte *scriptCodeIp1, byte *scriptCodeIp2, uint32 callingThreadId);
|
||||
uint32 startTalkThread(int16 duration, uint32 objectId, uint32 talkId, uint32 sequenceId1,
|
||||
uint32 sequenceId2, uint32 namedPointId, uint32 callingThreadId);
|
||||
void setCurrFontId(uint32 fontId);
|
||||
bool checkActiveTalkThreads();
|
||||
uint32 clipTextDuration(uint32 duration);
|
||||
void reset();
|
||||
bool enterScene(uint32 sceneId, uint32 threadId);
|
||||
void exitScene(uint32 threadId);
|
||||
|
@ -101,6 +105,9 @@ public:
|
|||
uint32 _nextTempThreadId;
|
||||
|
||||
uint32 _fontId;
|
||||
int _field8;
|
||||
uint32 _fieldA, _fieldE;
|
||||
|
||||
uint32 _prevSceneId;
|
||||
|
||||
ThreadList *_threads;
|
||||
|
|
|
@ -130,6 +130,7 @@ void ScriptOpcodes::initOpcodes() {
|
|||
OPCODE(150, opRunSpecialCode);
|
||||
OPCODE(161, opSetActorUsePan);
|
||||
OPCODE(168, opStartAbortableThread);
|
||||
OPCODE(169, opKillThread);
|
||||
OPCODE(175, opSetSceneIdThreadId);
|
||||
OPCODE(176, opStackPush0);
|
||||
OPCODE(177, opSetFontId);
|
||||
|
@ -278,17 +279,17 @@ void ScriptOpcodes::opStartSequenceActor(ScriptThread *scriptThread, OpCall &opC
|
|||
}
|
||||
|
||||
void ScriptOpcodes::opStartTalkThread(ScriptThread *scriptThread, OpCall &opCall) {
|
||||
ARG_INT16(value);
|
||||
ARG_INT16(duration);
|
||||
ARG_UINT32(objectId);
|
||||
ARG_UINT32(talkId);
|
||||
ARG_UINT32(sequenceId1);
|
||||
ARG_UINT32(sequenceId2);
|
||||
ARG_UINT32(value2);
|
||||
ARG_UINT32(namedPointId);
|
||||
// NOTE Skipped checking for stalled sequence, not sure if needed
|
||||
// TODO _vm->_scriptMan->startTalkThread(value, objectId, talkId, sequenceId1, sequenceId2, value2, opCall._callerThreadId);
|
||||
_vm->_scriptMan->startTalkThread(duration, objectId, talkId, sequenceId1, sequenceId2, namedPointId, opCall._callerThreadId);
|
||||
|
||||
//DEBUG Resume calling thread, later done after talking is finished
|
||||
_vm->notifyThreadId(opCall._threadId);
|
||||
//_vm->notifyThreadId(opCall._threadId);
|
||||
}
|
||||
|
||||
void ScriptOpcodes::opAppearActor(ScriptThread *scriptThread, OpCall &opCall) {
|
||||
|
@ -429,7 +430,7 @@ void ScriptOpcodes::opActivateButton(ScriptThread *scriptThread, OpCall &opCall)
|
|||
void ScriptOpcodes::opJumpIf(ScriptThread *scriptThread, OpCall &opCall) {
|
||||
ARG_INT16(jumpOffs)
|
||||
int16 value = _vm->_scriptMan->_stack.pop();
|
||||
if (!value)
|
||||
if (value == 0)
|
||||
opCall._deltaOfs += jumpOffs;
|
||||
}
|
||||
|
||||
|
@ -450,10 +451,11 @@ void ScriptOpcodes::opCompareBlockCounter(ScriptThread *scriptThread, OpCall &op
|
|||
ARG_INT16(compareOp);
|
||||
ARG_INT16(rvalue);
|
||||
int16 lvalue = _vm->_scriptMan->_scriptResource->_blockCounters.get(index);
|
||||
debug("lvalue = %d", lvalue);
|
||||
bool compareResult = false;
|
||||
switch (compareOp) {
|
||||
case 1:
|
||||
compareResult = lvalue == rvalue;
|
||||
compareResult = false;//lvalue == rvalue;
|
||||
break;
|
||||
case 2:
|
||||
compareResult = lvalue != rvalue;
|
||||
|
@ -471,6 +473,7 @@ void ScriptOpcodes::opCompareBlockCounter(ScriptThread *scriptThread, OpCall &op
|
|||
compareResult = lvalue <= rvalue;
|
||||
break;
|
||||
}
|
||||
debug(" compareResult -> %d", compareResult);
|
||||
_vm->_scriptMan->_stack.push(compareResult ? 1 : 0);
|
||||
}
|
||||
|
||||
|
@ -529,8 +532,14 @@ void ScriptOpcodes::opStartAbortableThread(ScriptThread *scriptThread, OpCall &o
|
|||
ARG_SKIP(2);
|
||||
ARG_INT16(codeOffs);
|
||||
ARG_INT16(skipOffs);
|
||||
_vm->_scriptMan->startAbortableThread(opCall._code + opCall._opSize + codeOffs,
|
||||
opCall._code + opCall._opSize + skipOffs, opCall._callerThreadId);
|
||||
_vm->_scriptMan->startAbortableThread(opCall._code + codeOffs,
|
||||
opCall._code + skipOffs, opCall._callerThreadId);
|
||||
}
|
||||
|
||||
void ScriptOpcodes::opKillThread(ScriptThread *scriptThread, OpCall &opCall) {
|
||||
ARG_SKIP(2);
|
||||
ARG_UINT32(threadId);
|
||||
_vm->_scriptMan->_threads->killThread(threadId);
|
||||
}
|
||||
|
||||
void ScriptOpcodes::opSetSceneIdThreadId(ScriptThread *scriptThread, OpCall &opCall) {
|
||||
|
|
|
@ -107,6 +107,7 @@ protected:
|
|||
void opRunSpecialCode(ScriptThread *scriptThread, OpCall &opCall);
|
||||
void opSetActorUsePan(ScriptThread *scriptThread, OpCall &opCall);
|
||||
void opStartAbortableThread(ScriptThread *scriptThread, OpCall &opCall);
|
||||
void opKillThread(ScriptThread *scriptThread, OpCall &opCall);
|
||||
void opSetSceneIdThreadId(ScriptThread *scriptThread, OpCall &opCall);
|
||||
void opStackPush0(ScriptThread *scriptThread, OpCall &opCall);
|
||||
void opSetFontId(ScriptThread *scriptThread, OpCall &opCall);
|
||||
|
|
|
@ -59,6 +59,12 @@ void Properties::init(uint count, byte *properties) {
|
|||
_properties = properties;
|
||||
}
|
||||
|
||||
void Properties::clear() {
|
||||
uint size = (_count >> 3) + 1;
|
||||
for (uint i = 0; i < size; ++i)
|
||||
_properties[i] = 0;
|
||||
}
|
||||
|
||||
bool Properties::get(uint32 propertyId) {
|
||||
uint index;
|
||||
byte mask;
|
||||
|
@ -103,7 +109,7 @@ byte BlockCounters::get(uint index) {
|
|||
}
|
||||
|
||||
void BlockCounters::set(uint index, byte value) {
|
||||
_blockCounters[index - 1] = (get(index - 1) ^ value) & 0x3F;
|
||||
_blockCounters[index - 1] ^= (_blockCounters[index - 1] ^ value) & 0x3F;
|
||||
}
|
||||
|
||||
// TriggerCause
|
||||
|
|
|
@ -45,6 +45,7 @@ class Properties {
|
|||
public:
|
||||
Properties();
|
||||
void init(uint count, byte *properties);
|
||||
void clear();
|
||||
bool get(uint32 propertyId);
|
||||
void set(uint32 propertyId, bool value);
|
||||
public:
|
||||
|
|
301
engines/illusions/talkthread.cpp
Normal file
301
engines/illusions/talkthread.cpp
Normal file
|
@ -0,0 +1,301 @@
|
|||
/* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "illusions/illusions.h"
|
||||
#include "illusions/talkthread.h"
|
||||
#include "illusions/actor.h"
|
||||
#include "illusions/dictionary.h"
|
||||
#include "illusions/input.h"
|
||||
#include "illusions/scriptman.h"
|
||||
#include "illusions/talkresource.h"
|
||||
#include "illusions/time.h"
|
||||
|
||||
namespace Illusions {
|
||||
|
||||
// TalkThread
|
||||
|
||||
TalkThread::TalkThread(IllusionsEngine *vm, uint32 threadId, uint32 callingThreadId, uint notifyFlags,
|
||||
int16 duration, uint32 objectId, uint32 talkId, uint32 sequenceId1, uint32 sequenceId2,
|
||||
uint32 namedPointId)
|
||||
: Thread(vm, threadId, callingThreadId, notifyFlags), _objectId(objectId), _talkId(talkId),
|
||||
_sequenceId1(0), _sequenceId2(0) {
|
||||
_type = kTTTalkThread;
|
||||
|
||||
if (sequenceId1 && _vm->_dict->getObjectControl(objectId)) {
|
||||
_sequenceId1 = sequenceId1;
|
||||
_sequenceId2 = sequenceId2;
|
||||
}
|
||||
|
||||
if (!callingThreadId)
|
||||
_sequenceId2 = 0;
|
||||
|
||||
_namedPointId = namedPointId;
|
||||
|
||||
if (duration)
|
||||
_status = 1;
|
||||
else if (_vm->_scriptMan->checkActiveTalkThreads())
|
||||
_status = 2;
|
||||
else
|
||||
_status = 3;
|
||||
|
||||
_flags = 0x0E;
|
||||
|
||||
_durationMult = _vm->_scriptMan->clipTextDuration(_vm->_scriptMan->_fieldE);
|
||||
_textDuration = _durationMult;
|
||||
_defDurationMult = _vm->_scriptMan->clipTextDuration(240);
|
||||
_textStartTime = 0;
|
||||
_textEndTime = 0;
|
||||
_textDurationElapsed = 0;
|
||||
_entryText = 0;
|
||||
_currEntryText = 0;
|
||||
_voiceDurationElapsed = 0;
|
||||
_voiceDuration = duration;
|
||||
_voiceStartTime = getCurrentTime();
|
||||
_voiceEndTime = _voiceStartTime + duration;
|
||||
_entryTblPtr = 0;
|
||||
|
||||
/* TODO
|
||||
if (callingThreadId)
|
||||
thread->tag = *(_DWORD *)(krndictGetIDValue(callingThreadId) + 20);
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
int TalkThread::onUpdate() {
|
||||
|
||||
TalkEntry *talkEntry;
|
||||
|
||||
switch (_status) {
|
||||
|
||||
case 1:
|
||||
if (isTimerExpired(_voiceStartTime, _voiceEndTime)) {
|
||||
if (_vm->_scriptMan->checkActiveTalkThreads())
|
||||
_status = 2;
|
||||
else
|
||||
_status = 3;
|
||||
}
|
||||
return kTSYield;
|
||||
|
||||
case 2:
|
||||
if (_vm->_scriptMan->checkActiveTalkThreads())
|
||||
return kTSYield;
|
||||
_status = 3;
|
||||
// Fallthrough to status 3
|
||||
|
||||
case 3:
|
||||
talkEntry = getTalkResourceEntry(_talkId);
|
||||
_flags = 0;
|
||||
_currEntryText = 0;
|
||||
_entryText = talkEntry->_text;
|
||||
_entryTblPtr = talkEntry->_tblPtr;
|
||||
if (_sequenceId1) {
|
||||
_pauseCtr = 0;
|
||||
// TODO _field30 = v6;
|
||||
} else {
|
||||
_flags = 3;
|
||||
// TODO _field30 = 0;
|
||||
}
|
||||
if (_vm->isSoundActive()) {
|
||||
if (!_vm->cueVoice(talkEntry->_voiceName) && !_durationMult)
|
||||
_durationMult = _defDurationMult;
|
||||
} else {
|
||||
_flags |= 4;
|
||||
if (_durationMult == 0)
|
||||
_durationMult = _defDurationMult;
|
||||
}
|
||||
if (_objectId == 0 || _durationMult == 0)
|
||||
_flags |= 8;
|
||||
_status = 4;
|
||||
// Fallthrough to status 4
|
||||
|
||||
case 4:
|
||||
if (!(_flags & 4) && !_vm->isVoiceCued())
|
||||
return kTSYield;
|
||||
_status = 5;
|
||||
// Fallthrough to status 5
|
||||
|
||||
case 5:
|
||||
if (!(_flags & 8))
|
||||
refreshText();
|
||||
if (!(_flags & 2)) {
|
||||
Control *control = _vm->_dict->getObjectControl(_objectId);
|
||||
// TODOcontrol->startTalkActor(_sequenceId1, _entryTblPtr, _threadId);
|
||||
}
|
||||
if (!(_flags & 4)) {
|
||||
int16 panX = 0;
|
||||
if (_namedPointId) {
|
||||
// TODO pt.x = (unsigned int)artcntrlGetNamedPointPosition((Point)_namedPointId);
|
||||
// TODO panX = convertPanXCoord(pt.x);
|
||||
}
|
||||
_vm->startVoice(255, panX);
|
||||
}
|
||||
_vm->_input->discardButtons(16);
|
||||
_status = 6;
|
||||
return kTSYield;
|
||||
|
||||
case 6:
|
||||
if (!(_flags & 4) && !_vm->isVoicePlaying())
|
||||
_flags |= 4;
|
||||
if (!(_flags & 8) && isTimerExpired(_textStartTime, _textEndTime)) {
|
||||
// TODO _vm->removeText();
|
||||
if (_entryText && *_entryText) {
|
||||
refreshText();
|
||||
_vm->_input->discardButtons(16);
|
||||
} else {
|
||||
_flags |= 8;
|
||||
}
|
||||
}
|
||||
if ((_flags & 4) && (_flags & 8)) {
|
||||
if (_sequenceId2) {
|
||||
Control *control = _vm->_dict->getObjectControl(_objectId);
|
||||
control->startSequenceActor(_sequenceId2, 2, 0);
|
||||
}
|
||||
if (_sequenceId1) {
|
||||
Control *control = _vm->_dict->getObjectControl(_objectId);
|
||||
control->clearNotifyThreadId2();
|
||||
}
|
||||
_flags |= 2;
|
||||
}
|
||||
if (_objectId && _vm->_input->pollButton(0x10)) {
|
||||
if (!(_flags & 8)) {
|
||||
// TODO _vm->removeText();
|
||||
if (_entryText && *_entryText)
|
||||
refreshText();
|
||||
else
|
||||
_flags |= 8;
|
||||
}
|
||||
if (_flags & 8) {
|
||||
if (!(_flags & 4)) {
|
||||
_vm->stopVoice();
|
||||
_flags |= 4;
|
||||
}
|
||||
if (!(_flags & 2)) {
|
||||
if (_sequenceId2) {
|
||||
Control *control = _vm->_dict->getObjectControl(_objectId);
|
||||
control->startSequenceActor(_sequenceId2, 2, 0);
|
||||
}
|
||||
if (_sequenceId1) {
|
||||
Control *control = _vm->_dict->getObjectControl(_objectId);
|
||||
control->clearNotifyThreadId2();
|
||||
}
|
||||
_flags |= 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((_flags & 8) && (_flags & 2) && (_flags & 4)) {
|
||||
_vm->_input->discardButtons(0x10);
|
||||
_status = 7;
|
||||
return kTSTerminate;
|
||||
}
|
||||
return kTSYield;
|
||||
|
||||
case 7:
|
||||
if (!(_flags & 2)) {
|
||||
if (_sequenceId2) {
|
||||
Control *control = _vm->_dict->getObjectControl(_objectId);
|
||||
control->startSequenceActor(_sequenceId2, 2, 0);
|
||||
}
|
||||
if (_sequenceId1) {
|
||||
Control *control = _vm->_dict->getObjectControl(_objectId);
|
||||
control->clearNotifyThreadId2();
|
||||
}
|
||||
_flags |= 2;
|
||||
}
|
||||
if (!(_flags & 8)) {
|
||||
// TODO _vm->removeText();
|
||||
_flags |= 8;
|
||||
}
|
||||
if (!(_flags & 4)) {
|
||||
_vm->stopVoice();
|
||||
_flags |= 4;
|
||||
}
|
||||
return kTSTerminate;
|
||||
|
||||
}
|
||||
|
||||
return kTSTerminate;
|
||||
|
||||
}
|
||||
|
||||
void TalkThread::onSuspend() {
|
||||
}
|
||||
|
||||
void TalkThread::onNotify() {
|
||||
}
|
||||
|
||||
void TalkThread::onPause() {
|
||||
}
|
||||
|
||||
void TalkThread::onResume() {
|
||||
}
|
||||
|
||||
void TalkThread::onTerminated() {
|
||||
}
|
||||
|
||||
void TalkThread::refreshText() {
|
||||
_currEntryText = _entryText;
|
||||
int charCount = insertText();
|
||||
uint32 duration = _durationMult;
|
||||
if (charCount < 80) {
|
||||
duration = _durationMult * charCount / 80;
|
||||
if (duration < 25 * _durationMult / 100)
|
||||
duration = 25 * _durationMult / 100;
|
||||
if (duration < 60)
|
||||
duration = 60;
|
||||
}
|
||||
_textDuration = duration;
|
||||
_textStartTime = getCurrentTime();
|
||||
_textEndTime = _textStartTime + _textDuration;
|
||||
}
|
||||
|
||||
static char *debugW2I(byte *wstr) {
|
||||
static char buf[65];
|
||||
char *p = buf;
|
||||
while (*wstr != 0) {
|
||||
*p++ = *wstr;
|
||||
wstr += 2;
|
||||
}
|
||||
*p = 0;
|
||||
return buf;
|
||||
}
|
||||
|
||||
int TalkThread::insertText() {
|
||||
int charCount = 100;
|
||||
|
||||
debug("[%s]", debugW2I(_currEntryText));
|
||||
_entryText = 0;
|
||||
|
||||
// TODO _vm->getDimensions1(&dimensions);
|
||||
// TODO _vm->insertText(_currEntryText, _vm->_scriptMan->currFontId, dimensions, 0, 2, 0, 0, 0, 0, 0, 0, &outTextPtr);
|
||||
// TODO _vm->charCount = (char *)outTextPtr - (char *)text;
|
||||
// TODO _entryText = outTextPtr;
|
||||
// TODO _vm->getPoint1(&pt);
|
||||
// TODO _vm->updateTextInfoPosition(pt);
|
||||
return charCount >> 1;
|
||||
}
|
||||
|
||||
TalkEntry *TalkThread::getTalkResourceEntry(uint32 talkId) {
|
||||
TalkEntry *talkEntry = _vm->_dict->findTalkEntry(talkId);
|
||||
return talkEntry;
|
||||
}
|
||||
|
||||
} // End of namespace Illusions
|
75
engines/illusions/talkthread.h
Normal file
75
engines/illusions/talkthread.h
Normal file
|
@ -0,0 +1,75 @@
|
|||
/* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ILLUSIONS_TALKTHREAD_H
|
||||
#define ILLUSIONS_TALKTHREAD_H
|
||||
|
||||
#include "illusions/thread.h"
|
||||
|
||||
namespace Illusions {
|
||||
|
||||
class IllusionsEngine;
|
||||
struct TalkEntry;
|
||||
|
||||
class TalkThread : public Thread {
|
||||
public:
|
||||
TalkThread(IllusionsEngine *vm, uint32 threadId, uint32 callingThreadId, uint notifyFlags,
|
||||
int16 duration, uint32 objectId, uint32 talkId, uint32 sequenceId1, uint32 sequenceId2,
|
||||
uint32 namedPointId);
|
||||
virtual int onUpdate();
|
||||
virtual void onSuspend();
|
||||
virtual void onNotify();
|
||||
virtual void onPause();
|
||||
virtual void onResume();
|
||||
virtual void onTerminated();
|
||||
public:
|
||||
//field0 dw
|
||||
int _status;
|
||||
uint _flags;
|
||||
uint32 _textStartTime;
|
||||
uint32 _textEndTime;
|
||||
uint32 _textDuration;
|
||||
uint32 _defDurationMult;
|
||||
uint32 _textDurationElapsed;
|
||||
uint32 _durationMult;
|
||||
//field12 dw
|
||||
uint32 _objectId;
|
||||
uint32 _talkId;
|
||||
uint32 _sequenceId1;
|
||||
uint32 _sequenceId2;
|
||||
byte *_entryTblPtr;
|
||||
byte *_entryText;
|
||||
byte *_currEntryText;
|
||||
//field30 dd
|
||||
uint32 _namedPointId;
|
||||
uint32 _voiceStartTime;
|
||||
uint32 _voiceEndTime;
|
||||
uint32 _voiceDuration;
|
||||
uint32 _voiceDurationElapsed;
|
||||
void refreshText();
|
||||
int insertText();
|
||||
TalkEntry *getTalkResourceEntry(uint32 talkId);
|
||||
};
|
||||
|
||||
} // End of namespace Illusions
|
||||
|
||||
#endif // ILLUSIONS_TALKTHREAD_H
|
|
@ -101,8 +101,10 @@ int Thread::update() {
|
|||
|
||||
void Thread::terminate() {
|
||||
if (!_terminated) {
|
||||
if (!(_notifyFlags & 1))
|
||||
if (!(_notifyFlags & 1)) {
|
||||
debug("Thread::terminate() _callingThreadId: %08X", _callingThreadId);
|
||||
_vm->notifyThreadId(_callingThreadId);
|
||||
}
|
||||
_callingThreadId = 0;
|
||||
onTerminated();
|
||||
// TODO _vm->removeThread(_threadId, this);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue