diff options
author | johndoe123 | 2014-03-22 02:32:44 +0100 |
---|---|---|
committer | Eugene Sandulenko | 2018-07-20 06:43:33 +0000 |
commit | fc4266bcadaf7c01bf558ef78a9702254803ca77 (patch) | |
tree | 7ff02c71ff2da542dbdaacbf3eae754da44ecfa2 /engines/illusions | |
parent | 812c7fc3a83f57b9ba181c47d3699155c16ab379 (diff) | |
download | scummvm-rg350-fc4266bcadaf7c01bf558ef78a9702254803ca77.tar.gz scummvm-rg350-fc4266bcadaf7c01bf558ef78a9702254803ca77.tar.bz2 scummvm-rg350-fc4266bcadaf7c01bf558ef78a9702254803ca77.zip |
ILLUSIONS: Add TalkThread
Diffstat (limited to 'engines/illusions')
-rw-r--r-- | engines/illusions/actor.cpp | 12 | ||||
-rw-r--r-- | engines/illusions/actor.h | 4 | ||||
-rw-r--r-- | engines/illusions/illusions.cpp | 30 | ||||
-rw-r--r-- | engines/illusions/illusions.h | 7 | ||||
-rw-r--r-- | engines/illusions/module.mk | 1 | ||||
-rw-r--r-- | engines/illusions/scriptman.cpp | 49 | ||||
-rw-r--r-- | engines/illusions/scriptman.h | 7 | ||||
-rw-r--r-- | engines/illusions/scriptopcodes.cpp | 25 | ||||
-rw-r--r-- | engines/illusions/scriptopcodes.h | 1 | ||||
-rw-r--r-- | engines/illusions/scriptresource.cpp | 8 | ||||
-rw-r--r-- | engines/illusions/scriptresource.h | 1 | ||||
-rw-r--r-- | engines/illusions/talkthread.cpp | 301 | ||||
-rw-r--r-- | engines/illusions/talkthread.h | 75 | ||||
-rw-r--r-- | engines/illusions/thread.cpp | 4 |
14 files changed, 501 insertions, 24 deletions
diff --git a/engines/illusions/actor.cpp b/engines/illusions/actor.cpp index bcaf72bb54..933ebee18e 100644 --- a/engines/illusions/actor.cpp +++ b/engines/illusions/actor.cpp @@ -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; } diff --git a/engines/illusions/actor.h b/engines/illusions/actor.h index 63ae4f84bc..28c539a667 100644 --- a/engines/illusions/actor.h +++ b/engines/illusions/actor.h @@ -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); }; diff --git a/engines/illusions/illusions.cpp b/engines/illusions/illusions.cpp index d758c1fd0f..45c587dd55 100644 --- a/engines/illusions/illusions.cpp +++ b/engines/illusions/illusions.cpp @@ -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 diff --git a/engines/illusions/illusions.h b/engines/illusions/illusions.h index 2fa76319df..1b44a0721c 100644 --- a/engines/illusions/illusions.h +++ b/engines/illusions/illusions.h @@ -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 diff --git a/engines/illusions/module.mk b/engines/illusions/module.mk index de705ddc5c..49a6e2a1a0 100644 --- a/engines/illusions/module.mk +++ b/engines/illusions/module.mk @@ -25,6 +25,7 @@ MODULE_OBJS := \ spritedecompressqueue.o \ spritedrawqueue.o \ talkresource.o \ + talkthread.o \ thread.o \ time.o \ timerthread.o \ diff --git a/engines/illusions/scriptman.cpp b/engines/illusions/scriptman.cpp index 2ba39c7ae5..eaaeaa57a7 100644 --- a/engines/illusions/scriptman.cpp +++ b/engines/illusions/scriptman.cpp @@ -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); } diff --git a/engines/illusions/scriptman.h b/engines/illusions/scriptman.h index 0ce0ef133c..fc11cdfec3 100644 --- a/engines/illusions/scriptman.h +++ b/engines/illusions/scriptman.h @@ -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; diff --git a/engines/illusions/scriptopcodes.cpp b/engines/illusions/scriptopcodes.cpp index 6d32800d77..0212b10d10 100644 --- a/engines/illusions/scriptopcodes.cpp +++ b/engines/illusions/scriptopcodes.cpp @@ -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) { diff --git a/engines/illusions/scriptopcodes.h b/engines/illusions/scriptopcodes.h index 060171d50a..209aa78017 100644 --- a/engines/illusions/scriptopcodes.h +++ b/engines/illusions/scriptopcodes.h @@ -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); diff --git a/engines/illusions/scriptresource.cpp b/engines/illusions/scriptresource.cpp index 29f123e492..6aa8ec6c9d 100644 --- a/engines/illusions/scriptresource.cpp +++ b/engines/illusions/scriptresource.cpp @@ -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 diff --git a/engines/illusions/scriptresource.h b/engines/illusions/scriptresource.h index 79c46c82a7..e2df45a34d 100644 --- a/engines/illusions/scriptresource.h +++ b/engines/illusions/scriptresource.h @@ -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: diff --git a/engines/illusions/talkthread.cpp b/engines/illusions/talkthread.cpp new file mode 100644 index 0000000000..50c62660c4 --- /dev/null +++ b/engines/illusions/talkthread.cpp @@ -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 diff --git a/engines/illusions/talkthread.h b/engines/illusions/talkthread.h new file mode 100644 index 0000000000..fd0e3d0ba0 --- /dev/null +++ b/engines/illusions/talkthread.h @@ -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 diff --git a/engines/illusions/thread.cpp b/engines/illusions/thread.cpp index 83e0ce5ab4..0a9b0d90b4 100644 --- a/engines/illusions/thread.cpp +++ b/engines/illusions/thread.cpp @@ -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); |