Initial commit
This commit is contained in:
53
engines/illusions/threads/abortablethread.cpp
Normal file
53
engines/illusions/threads/abortablethread.cpp
Normal file
@@ -0,0 +1,53 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "illusions/illusions.h"
|
||||
#include "illusions/threads/abortablethread.h"
|
||||
#include "illusions/input.h"
|
||||
#include "illusions/time.h"
|
||||
|
||||
namespace Illusions {
|
||||
|
||||
// AbortableThread
|
||||
|
||||
AbortableThread::AbortableThread(IllusionsEngine *vm, uint32 threadId, uint32 callingThreadId, uint notifyFlags,
|
||||
uint32 scriptThreadId, byte *scriptCodeIp)
|
||||
: Thread(vm, threadId, callingThreadId, notifyFlags), _scriptThreadId(scriptThreadId),
|
||||
_scriptCodeIp(scriptCodeIp), _status(1) {
|
||||
_type = kTTAbortableThread;
|
||||
_sceneId = _vm->getCurrentScene();
|
||||
_vm->_input->discardEvent(kEventAbort);
|
||||
}
|
||||
|
||||
int AbortableThread::onUpdate() {
|
||||
if (_status != 1 || _pauseCtr < 0)
|
||||
return kTSTerminate;
|
||||
if (_vm->_input->pollEvent(kEventAbort)) {
|
||||
_vm->_threads->killThread(_scriptThreadId);
|
||||
++_pauseCtr;
|
||||
_vm->startTempScriptThread(_scriptCodeIp, _threadId, 0, 0, 0);
|
||||
_status = 2;
|
||||
return kTSSuspend;
|
||||
}
|
||||
return kTSYield;
|
||||
}
|
||||
|
||||
} // End of namespace Illusions
|
||||
44
engines/illusions/threads/abortablethread.h
Normal file
44
engines/illusions/threads/abortablethread.h
Normal file
@@ -0,0 +1,44 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ILLUSIONS_ABORTABLETHREAD_H
|
||||
#define ILLUSIONS_ABORTABLETHREAD_H
|
||||
|
||||
#include "illusions/thread.h"
|
||||
|
||||
namespace Illusions {
|
||||
|
||||
class IllusionsEngine;
|
||||
|
||||
class AbortableThread : public Thread {
|
||||
public:
|
||||
AbortableThread(IllusionsEngine *vm, uint32 threadId, uint32 callingThreadId, uint notifyFlags,
|
||||
uint32 scriptThreadId, byte *scriptCodeIp);
|
||||
int onUpdate() override;
|
||||
public:
|
||||
int _status;
|
||||
byte *_scriptCodeIp;
|
||||
uint32 _scriptThreadId;
|
||||
};
|
||||
|
||||
} // End of namespace Illusions
|
||||
|
||||
#endif // ILLUSIONS_ABORTABLETHREAD_H
|
||||
57
engines/illusions/threads/causethread_duckman.cpp
Normal file
57
engines/illusions/threads/causethread_duckman.cpp
Normal file
@@ -0,0 +1,57 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "illusions/duckman/illusions_duckman.h"
|
||||
#include "illusions/threads/causethread_duckman.h"
|
||||
#include "illusions/actor.h"
|
||||
#include "illusions/input.h"
|
||||
|
||||
namespace Illusions {
|
||||
|
||||
// CauseThread_Duckman
|
||||
|
||||
CauseThread_Duckman::CauseThread_Duckman(IllusionsEngine_Duckman *vm, uint32 threadId, uint32 callingThreadId, uint notifyFlags,
|
||||
uint32 triggerThreadId)
|
||||
: Thread(vm, threadId, callingThreadId, notifyFlags), _vm(vm), _triggerThreadId(triggerThreadId), _flag(false) {
|
||||
_type = kTTCauseThread;
|
||||
_sceneId = _vm->getCurrentScene();
|
||||
}
|
||||
|
||||
int CauseThread_Duckman::onUpdate() {
|
||||
if (_flag) {
|
||||
if (_vm->getCurrentScene() == _sceneId) {
|
||||
Control *cursorCursor = _vm->getObjectControl(Illusions::CURSOR_OBJECT_ID);
|
||||
cursorCursor->appearActor();
|
||||
_vm->_input->discardEvent(kEventLeftClick);
|
||||
}
|
||||
return kTSTerminate;
|
||||
} else {
|
||||
_sceneId = _vm->getCurrentScene();
|
||||
Control *cursorCursor = _vm->getObjectControl(Illusions::CURSOR_OBJECT_ID);
|
||||
cursorCursor->disappearActor();
|
||||
_vm->_input->discardEvent(kEventLeftClick);
|
||||
_vm->startScriptThread(_triggerThreadId, _threadId);
|
||||
_flag = true;
|
||||
return kTSSuspend;
|
||||
}
|
||||
}
|
||||
|
||||
} // End of namespace Illusions
|
||||
44
engines/illusions/threads/causethread_duckman.h
Normal file
44
engines/illusions/threads/causethread_duckman.h
Normal file
@@ -0,0 +1,44 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ILLUSIONS_CAUSETHREAD_DUCKMAN_H
|
||||
#define ILLUSIONS_CAUSETHREAD_DUCKMAN_H
|
||||
|
||||
#include "illusions/thread.h"
|
||||
|
||||
namespace Illusions {
|
||||
|
||||
class IllusionsEngine_Duckman;
|
||||
|
||||
class CauseThread_Duckman : public Thread {
|
||||
public:
|
||||
CauseThread_Duckman(IllusionsEngine_Duckman *vm, uint32 threadId, uint32 callingThreadId, uint notifyFlags,
|
||||
uint32 triggerThreadId);
|
||||
int onUpdate() override;
|
||||
public:
|
||||
IllusionsEngine_Duckman *_vm;
|
||||
bool _flag;
|
||||
uint32 _triggerThreadId;
|
||||
};
|
||||
|
||||
} // End of namespace Illusions
|
||||
|
||||
#endif // ILLUSIONS_CAUSETHREAD_DUCKMAN_H
|
||||
70
engines/illusions/threads/scriptthread.cpp
Normal file
70
engines/illusions/threads/scriptthread.cpp
Normal file
@@ -0,0 +1,70 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "illusions/illusions.h"
|
||||
#include "illusions/threads/scriptthread.h"
|
||||
#include "illusions/scriptopcodes.h"
|
||||
|
||||
namespace Illusions {
|
||||
|
||||
// ScriptThread
|
||||
|
||||
ScriptThread::ScriptThread(IllusionsEngine *vm, uint32 threadId, uint32 callingThreadId, uint notifyFlags,
|
||||
byte *scriptCodeIp, uint32 value8, uint32 valueC, uint32 value10)
|
||||
: Thread(vm, threadId, callingThreadId, notifyFlags), _scriptCodeIp(scriptCodeIp), _value8(value8),
|
||||
_valueC(valueC), _value10(value10), _sequenceStalled(0) {
|
||||
_type = kTTScriptThread;
|
||||
_sceneId = _vm->getCurrentScene();
|
||||
}
|
||||
|
||||
int ScriptThread::onUpdate() {
|
||||
OpCall opCall;
|
||||
opCall._result = kTSRun;
|
||||
opCall._callerThreadId = _threadId;
|
||||
while (!_terminated && opCall._result == kTSRun) {
|
||||
loadOpcode(opCall);
|
||||
execOpcode(opCall);
|
||||
_scriptCodeIp += opCall._deltaOfs;
|
||||
}
|
||||
if (_terminated)
|
||||
opCall._result = kTSTerminate;
|
||||
return opCall._result;
|
||||
}
|
||||
|
||||
void ScriptThread::loadOpcode(OpCall &opCall) {
|
||||
if (_vm->getGameId() == kGameIdDuckman) {
|
||||
opCall._op = _scriptCodeIp[0] & 0x7F;
|
||||
opCall._opSize = _scriptCodeIp[1];
|
||||
opCall._threadId = _scriptCodeIp[0] & 0x80 ? _threadId : 0;
|
||||
} else {
|
||||
opCall._op = _scriptCodeIp[0];
|
||||
opCall._opSize = _scriptCodeIp[1] >> 1;
|
||||
opCall._threadId = _scriptCodeIp[1] & 1 ? _threadId : 0;
|
||||
}
|
||||
opCall._code = _scriptCodeIp + 2;
|
||||
opCall._deltaOfs = opCall._opSize;
|
||||
}
|
||||
|
||||
void ScriptThread::execOpcode(OpCall &opCall) {
|
||||
_vm->_scriptOpcodes->execOpcode(this, opCall);
|
||||
}
|
||||
|
||||
} // End of namespace Illusions
|
||||
49
engines/illusions/threads/scriptthread.h
Normal file
49
engines/illusions/threads/scriptthread.h
Normal file
@@ -0,0 +1,49 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ILLUSIONS_SCRIPTTHREAD_H
|
||||
#define ILLUSIONS_SCRIPTTHREAD_H
|
||||
|
||||
#include "illusions/thread.h"
|
||||
|
||||
namespace Illusions {
|
||||
|
||||
class IllusionsEngine;
|
||||
struct OpCall;
|
||||
|
||||
class ScriptThread : public Thread {
|
||||
public:
|
||||
ScriptThread(IllusionsEngine *vm, uint32 threadId, uint32 callingThreadId, uint notifyFlags,
|
||||
byte *scriptCodeIp, uint32 value8, uint32 valueC, uint32 value10);
|
||||
int onUpdate() override;
|
||||
public:
|
||||
int16 _sequenceStalled;
|
||||
byte *_scriptCodeIp;
|
||||
uint32 _value8;
|
||||
uint32 _valueC;
|
||||
uint32 _value10;
|
||||
void loadOpcode(OpCall &opCall);
|
||||
void execOpcode(OpCall &opCall);
|
||||
};
|
||||
|
||||
} // End of namespace Illusions
|
||||
|
||||
#endif // ILLUSIONS_SCRIPTTHREAD_H
|
||||
416
engines/illusions/threads/talkthread.cpp
Normal file
416
engines/illusions/threads/talkthread.cpp
Normal file
@@ -0,0 +1,416 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "illusions/illusions.h"
|
||||
#include "illusions/threads/talkthread.h"
|
||||
#include "illusions/actor.h"
|
||||
#include "illusions/dictionary.h"
|
||||
#include "illusions/input.h"
|
||||
#include "illusions/resources/talkresource.h"
|
||||
#include "illusions/screentext.h"
|
||||
#include "illusions/sound.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->checkActiveTalkThreads())
|
||||
_status = 2;
|
||||
else
|
||||
_status = 3;
|
||||
|
||||
_flags = 0x0E;
|
||||
|
||||
_durationMult = _vm->clipTextDuration(_vm->getSubtitleDuration());
|
||||
_textDuration = _durationMult;
|
||||
_defDurationMult = _vm->clipTextDuration(240);
|
||||
_textStartTime = 0;
|
||||
_textEndTime = 0;
|
||||
_textDurationElapsed = 0;
|
||||
_entryText = nullptr;
|
||||
_currEntryText = nullptr;
|
||||
_voiceDurationElapsed = 0;
|
||||
_voiceDuration = duration;
|
||||
_voiceStartTime = getCurrentTime();
|
||||
_voiceEndTime = _voiceStartTime + duration;
|
||||
_entryTblPtr = nullptr;
|
||||
|
||||
if (callingThreadId) {
|
||||
Thread *callingThread = _vm->_threads->findThread(callingThreadId);
|
||||
if (callingThread)
|
||||
_sceneId = callingThread->_sceneId;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int TalkThread::onUpdate() {
|
||||
|
||||
TalkEntry *talkEntry;
|
||||
|
||||
switch (_status) {
|
||||
|
||||
case 1:
|
||||
if (isTimerExpired(_voiceStartTime, _voiceEndTime)) {
|
||||
if (_vm->checkActiveTalkThreads())
|
||||
_status = 2;
|
||||
else
|
||||
_status = 3;
|
||||
}
|
||||
return kTSYield;
|
||||
|
||||
case 2:
|
||||
if (_vm->checkActiveTalkThreads())
|
||||
return kTSYield;
|
||||
_status = 3;
|
||||
// fall through
|
||||
|
||||
case 3:
|
||||
talkEntry = getTalkResourceEntry(_talkId);
|
||||
_flags = 0;
|
||||
_currEntryText = nullptr;
|
||||
_entryText = talkEntry->_text;
|
||||
_entryTblPtr = talkEntry->_tblPtr;
|
||||
if (_sequenceId1) {
|
||||
_pauseCtr = 0;
|
||||
} else {
|
||||
_flags |= 2;
|
||||
_flags |= 1;
|
||||
}
|
||||
if (_vm->isSoundActive()) {
|
||||
if (!_vm->_soundMan->cueVoice((char*)talkEntry->_voiceName) && !_durationMult)
|
||||
_durationMult = _defDurationMult;
|
||||
} else {
|
||||
_flags |= 4;
|
||||
if (_durationMult == 0)
|
||||
_durationMult = _defDurationMult;
|
||||
}
|
||||
if (_objectId == 0 || _durationMult == 0)
|
||||
_flags |= 8;
|
||||
_status = 4;
|
||||
// fall through
|
||||
|
||||
case 4:
|
||||
if (!(_flags & 4) && !_vm->_soundMan->isVoiceCued())
|
||||
return kTSYield;
|
||||
_status = 5;
|
||||
// fall through
|
||||
|
||||
case 5:
|
||||
if (!(_flags & 8))
|
||||
refreshText();
|
||||
if (!(_flags & 2)) {
|
||||
Control *control = _vm->_dict->getObjectControl(_objectId);
|
||||
control->startTalkActor(_sequenceId1, _entryTblPtr, _threadId);
|
||||
}
|
||||
if (!(_flags & 4)) {
|
||||
int16 panX = 0;
|
||||
if (_namedPointId) {
|
||||
Common::Point pt = _vm->getNamedPointPosition(_namedPointId);
|
||||
panX = _vm->convertPanXCoord(pt.x);
|
||||
}
|
||||
_vm->_soundMan->startVoice(255, panX);
|
||||
}
|
||||
_vm->_input->discardEvent(kEventSkip);
|
||||
_status = 6;
|
||||
return kTSYield;
|
||||
|
||||
case 6:
|
||||
if (!(_flags & 4) && !_vm->_soundMan->isVoicePlaying())
|
||||
_flags |= 4;
|
||||
if (!(_flags & 8) && isTimerExpired(_textStartTime, _textEndTime)) {
|
||||
_vm->_screenText->removeText();
|
||||
if (_entryText && *_entryText) {
|
||||
refreshText();
|
||||
_vm->_input->discardEvent(kEventSkip);
|
||||
} 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;
|
||||
}
|
||||
//#define DEBUG_SPEEDUP_TALK
|
||||
#ifdef DEBUG_SPEEDUP_TALK
|
||||
if (true) {
|
||||
#else
|
||||
if (_objectId && _vm->_input->pollEvent(kEventSkip)) {
|
||||
#endif
|
||||
if (!(_flags & 8)) {
|
||||
_vm->_screenText->removeText();
|
||||
if (_entryText && *_entryText)
|
||||
refreshText();
|
||||
else
|
||||
_flags |= 8;
|
||||
}
|
||||
if (_flags & 8) {
|
||||
if (!(_flags & 4)) {
|
||||
_vm->_soundMan->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->discardEvent(kEventSkip);
|
||||
_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)) {
|
||||
_vm->_screenText->removeText();
|
||||
_flags |= 8;
|
||||
}
|
||||
if (!(_flags & 4)) {
|
||||
_vm->_soundMan->stopVoice();
|
||||
_flags |= 4;
|
||||
}
|
||||
return kTSTerminate;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return kTSTerminate;
|
||||
}
|
||||
|
||||
void TalkThread::onSuspend() {
|
||||
switch (_status) {
|
||||
case 1:
|
||||
_voiceDurationElapsed = getDurationElapsed(_voiceStartTime, _voiceEndTime);
|
||||
_status = 7;
|
||||
break;
|
||||
case 4:
|
||||
_vm->_soundMan->stopCueingVoice();
|
||||
_status = 7;
|
||||
break;
|
||||
case 6:
|
||||
case 7:
|
||||
if (!(_flags & 4)) {
|
||||
_vm->_soundMan->stopVoice();
|
||||
_flags |= 4;
|
||||
}
|
||||
if (!(_flags & 8)) {
|
||||
_vm->_screenText->removeText();
|
||||
_flags |= 8;
|
||||
}
|
||||
_status = 7;
|
||||
break;
|
||||
default:
|
||||
_status = 7;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void TalkThread::onPause() {
|
||||
switch (_status) {
|
||||
case 1:
|
||||
_voiceDurationElapsed = getDurationElapsed(_voiceStartTime, _voiceEndTime);
|
||||
break;
|
||||
case 4:
|
||||
_vm->_soundMan->stopCueingVoice();
|
||||
break;
|
||||
case 6:
|
||||
case 7:
|
||||
if (!(_flags & 4)) {
|
||||
_vm->_soundMan->pauseVoice();
|
||||
}
|
||||
if (!(_flags & 8)) {
|
||||
_textDurationElapsed = getDurationElapsed(_textStartTime, _textEndTime);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void TalkThread::onUnpause() {
|
||||
switch (_status) {
|
||||
case 1:
|
||||
_voiceStartTime = getCurrentTime();
|
||||
if (_voiceDuration <= _voiceDurationElapsed) {
|
||||
_voiceDurationElapsed = 0;
|
||||
_voiceEndTime = _voiceStartTime;
|
||||
} else {
|
||||
_voiceDurationElapsed = 0;
|
||||
_voiceEndTime = _voiceStartTime + _voiceDuration - _voiceDurationElapsed;
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
if (_vm->isSoundActive()) {
|
||||
TalkEntry *talkEntry = getTalkResourceEntry(_talkId);
|
||||
_vm->_soundMan->cueVoice((char*)talkEntry->_voiceName);
|
||||
}
|
||||
break;
|
||||
case 6:
|
||||
if (!(_flags & 4)) {
|
||||
_vm->_soundMan->unpauseVoice();
|
||||
}
|
||||
if (!(_flags & 8)) {
|
||||
_textStartTime = getCurrentTime();
|
||||
if (_textDuration <= _textDurationElapsed) {
|
||||
_textDurationElapsed = 0;
|
||||
_textEndTime = _textStartTime;
|
||||
} else {
|
||||
_textDurationElapsed = 0;
|
||||
_textEndTime = _textStartTime + _textDuration - _textDurationElapsed;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void TalkThread::onTerminated() {
|
||||
if (_status == 4) {
|
||||
_vm->_soundMan->stopCueingVoice();
|
||||
} else if (_status == 6) {
|
||||
if (!(_flags & 4)) {
|
||||
_vm->_soundMan->stopVoice();
|
||||
_flags |= 4;
|
||||
}
|
||||
if (!(_flags & 8)) {
|
||||
_vm->_screenText->removeText();
|
||||
_flags |= 8;
|
||||
}
|
||||
if (!(_flags & 2)) {
|
||||
if (_sequenceId2) {
|
||||
Control *control = _vm->_dict->getObjectControl(_objectId);
|
||||
control->startSequenceActor(_sequenceId2, 2, 0);
|
||||
}
|
||||
_flags |= 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TalkThread::onKill() {
|
||||
_callingThreadId = 0;
|
||||
sendMessage(kMsgClearSequenceId1, 0);
|
||||
sendMessage(kMsgClearSequenceId2, 0);
|
||||
}
|
||||
|
||||
uint32 TalkThread::sendMessage(int msgNum, uint32 msgValue) {
|
||||
switch (msgNum) {
|
||||
case kMsgQueryTalkThreadActive:
|
||||
if (_status != 1 && _status != 2)
|
||||
return 1;
|
||||
break;
|
||||
case kMsgClearSequenceId1:
|
||||
_sequenceId1 = 0;
|
||||
_flags |= 3;
|
||||
break;
|
||||
case kMsgClearSequenceId2:
|
||||
_sequenceId2 = 0;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
int TalkThread::insertText() {
|
||||
debug("%08X %08X [%s]", _threadId, _talkId, debugW2I(_currEntryText));
|
||||
WidthHeight dimensions;
|
||||
_vm->getDefaultTextDimensions(dimensions);
|
||||
uint16 *outTextPtr;
|
||||
_vm->_screenText->insertText(_currEntryText, 0x120001, dimensions,
|
||||
Common::Point(0, 0), TEXT_FLAG_CENTER_ALIGN, 0, 0, 0, 0, 0, outTextPtr);
|
||||
_entryText = outTextPtr;
|
||||
Common::Point pt;
|
||||
_vm->getDefaultTextPosition(pt);
|
||||
_vm->_screenText->updateTextInfoPosition(pt);
|
||||
int charCount = (_entryText - _currEntryText) / 2;
|
||||
return charCount;
|
||||
}
|
||||
|
||||
TalkEntry *TalkThread::getTalkResourceEntry(uint32 talkId) {
|
||||
TalkEntry *talkEntry = _vm->_dict->findTalkEntry(talkId);
|
||||
return talkEntry;
|
||||
}
|
||||
|
||||
} // End of namespace Illusions
|
||||
81
engines/illusions/threads/talkthread.h
Normal file
81
engines/illusions/threads/talkthread.h
Normal file
@@ -0,0 +1,81 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ILLUSIONS_TALKTHREAD_H
|
||||
#define ILLUSIONS_TALKTHREAD_H
|
||||
|
||||
#include "illusions/thread.h"
|
||||
|
||||
namespace Illusions {
|
||||
|
||||
class IllusionsEngine;
|
||||
struct TalkEntry;
|
||||
|
||||
enum {
|
||||
kMsgQueryTalkThreadActive = 0,
|
||||
kMsgClearSequenceId1 = 1,
|
||||
kMsgClearSequenceId2 = 2
|
||||
};
|
||||
|
||||
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);
|
||||
int onUpdate() override;
|
||||
void onSuspend() override;
|
||||
void onPause() override;
|
||||
void onUnpause() override;
|
||||
void onTerminated() override;
|
||||
void onKill() override;
|
||||
uint32 sendMessage(int msgNum, uint32 msgValue) override;
|
||||
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;
|
||||
uint16 *_entryText;
|
||||
uint16 *_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
|
||||
323
engines/illusions/threads/talkthread_duckman.cpp
Normal file
323
engines/illusions/threads/talkthread_duckman.cpp
Normal file
@@ -0,0 +1,323 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "illusions/duckman/illusions_duckman.h"
|
||||
#include "illusions/threads/talkthread_duckman.h"
|
||||
#include "illusions/actor.h"
|
||||
#include "illusions/dictionary.h"
|
||||
#include "illusions/input.h"
|
||||
#include "illusions/resources/talkresource.h"
|
||||
#include "illusions/screentext.h"
|
||||
#include "illusions/sound.h"
|
||||
#include "illusions/time.h"
|
||||
|
||||
namespace Illusions {
|
||||
|
||||
// TalkThread_Duckman
|
||||
|
||||
TalkThread_Duckman::TalkThread_Duckman(IllusionsEngine_Duckman *vm, uint32 threadId, uint32 callingThreadId, uint notifyFlags,
|
||||
uint32 objectId, uint32 talkId, uint32 sequenceId1, uint32 sequenceId2)
|
||||
: Thread(vm, threadId, callingThreadId, notifyFlags), _vm(vm), _objectId(objectId), _talkId(talkId) {
|
||||
_type = kTTTalkThread;
|
||||
|
||||
if ((sequenceId1 & 0xFFFF0000) == 0x60000) {
|
||||
_sequenceId1 = sequenceId1;
|
||||
_sequenceId2 = sequenceId2;
|
||||
_namedPointId1 = 0;
|
||||
_namedPointId2 = 0;
|
||||
} else {
|
||||
_sequenceId1 = 0;
|
||||
_sequenceId2 = 0;
|
||||
_namedPointId1 = sequenceId1;
|
||||
_namedPointId2 = sequenceId2;
|
||||
}
|
||||
|
||||
if (_vm->checkActiveTalkThreads())
|
||||
_status = 1;
|
||||
else
|
||||
_status = 2;
|
||||
|
||||
_durationMult = _vm->clipTextDuration(_vm->_subtitleDuration);
|
||||
_textDuration = _durationMult;
|
||||
_defDurationMult = _vm->clipTextDuration(240);
|
||||
|
||||
_sceneId = _vm->getCurrentScene();
|
||||
|
||||
}
|
||||
|
||||
int TalkThread_Duckman::onUpdate() {
|
||||
|
||||
TalkEntry *talkEntry;
|
||||
|
||||
switch (_status) {
|
||||
|
||||
case 1:
|
||||
if (_vm->checkActiveTalkThreads())
|
||||
return kTSYield;
|
||||
_status = 3;
|
||||
// fall through
|
||||
|
||||
case 2:
|
||||
talkEntry = getTalkResourceEntry(_talkId);
|
||||
_flags = 0;
|
||||
_currEntryText = nullptr;
|
||||
_entryText = talkEntry->_text;
|
||||
_entryTblPtr = talkEntry->_tblPtr;
|
||||
if (_sequenceId1) {
|
||||
_pauseCtrPtr = &_pauseCtr;
|
||||
_pauseCtr = 0;
|
||||
} else {
|
||||
_pauseCtrPtr = nullptr;
|
||||
_flags |= 2;
|
||||
_flags |= 1;
|
||||
}
|
||||
if (_vm->isSoundActive()) {
|
||||
if (!_vm->_soundMan->cueVoice((char*)talkEntry->_voiceName) && !_durationMult)
|
||||
_durationMult = _defDurationMult;
|
||||
} else {
|
||||
_flags |= 4;
|
||||
if (_durationMult == 0)
|
||||
_durationMult = _defDurationMult;
|
||||
}
|
||||
if (_objectId == 0 || _durationMult == 0)
|
||||
_flags |= 8;
|
||||
_status = 3;
|
||||
// fall through
|
||||
|
||||
case 3:
|
||||
if (!(_flags & 4) && !_vm->_soundMan->isVoiceCued())
|
||||
return kTSYield;
|
||||
_status = 4;
|
||||
// fall through
|
||||
|
||||
case 4:
|
||||
if (!(_flags & 8) ) {
|
||||
uint32 actorTypeId = _vm->getObjectActorTypeId(_objectId);
|
||||
getActorTypeColor(actorTypeId, _color);
|
||||
refreshText();
|
||||
}
|
||||
if (!(_flags & 2)) {
|
||||
Control *control = _vm->_dict->getObjectControl(_objectId);
|
||||
control->startTalkActor(_sequenceId1, _entryTblPtr, _threadId);
|
||||
}
|
||||
if (!(_flags & 4)) {
|
||||
int16 panX = 0;
|
||||
if (_flags & 1) {
|
||||
if (_namedPointId2) {
|
||||
panX = _vm->getNamedPointPosition(_namedPointId2).x;
|
||||
panX = _vm->convertPanXCoord(panX);
|
||||
}
|
||||
} else {
|
||||
Control *control = _vm->_dict->getObjectControl(_objectId);
|
||||
panX = control->getActorPosition().x;
|
||||
panX = _vm->convertPanXCoord(panX);
|
||||
}
|
||||
_vm->_soundMan->startVoice(255, panX);
|
||||
}
|
||||
_vm->_input->discardEvent(kEventSkip);
|
||||
_status = 5;
|
||||
return kTSYield;
|
||||
|
||||
case 5:
|
||||
if (!(_flags & 4) && !_vm->_soundMan->isVoicePlaying())
|
||||
_flags |= 4;
|
||||
if (!(_flags & 8) && isTimerExpired(_textStartTime, _textEndTime)) {
|
||||
_vm->_screenText->removeText();
|
||||
if (_entryText && *_entryText) {
|
||||
refreshText();
|
||||
_vm->_input->discardEvent(kEventSkip);
|
||||
} else {
|
||||
_flags |= 8;
|
||||
}
|
||||
}
|
||||
if (!(_flags & 2)) {
|
||||
if (*_pauseCtrPtr < 0) {
|
||||
++(*_pauseCtrPtr);
|
||||
Control *control = _vm->_dict->getObjectControl(_objectId);
|
||||
control->startSequenceActor(_sequenceId2, 2, 0);
|
||||
_flags |= 2;
|
||||
}
|
||||
}
|
||||
if (_objectId && _vm->_input->pollEvent(kEventSkip)) {
|
||||
if (!(_flags & 8)) {
|
||||
_vm->_screenText->removeText();
|
||||
if (_entryText && *_entryText)
|
||||
refreshText();
|
||||
else
|
||||
_flags |= 8;
|
||||
}
|
||||
if (_flags & 8) {
|
||||
if (!(_flags & 4)) {
|
||||
_vm->_soundMan->stopVoice();
|
||||
_flags |= 4;
|
||||
}
|
||||
if (!(_flags & 2)) {
|
||||
Control *control = _vm->_dict->getObjectControl(_objectId);
|
||||
control->clearNotifyThreadId1();
|
||||
control->startSequenceActor(_sequenceId2, 2, 0);
|
||||
_flags |= 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((_flags & 8) && (_flags & 2) && (_flags & 4)) {
|
||||
_vm->_input->discardEvent(kEventSkip);
|
||||
return kTSTerminate;
|
||||
}
|
||||
return kTSYield;
|
||||
|
||||
case 6:
|
||||
if (!(_flags & 2)) {
|
||||
Control *control = _vm->_dict->getObjectControl(_objectId);
|
||||
if (*_pauseCtrPtr >= 0) {
|
||||
control->clearNotifyThreadId1();
|
||||
} else {
|
||||
++(*_pauseCtrPtr);
|
||||
}
|
||||
control->startSequenceActor(_sequenceId2, 2, 0);
|
||||
_flags |= 2;
|
||||
}
|
||||
return kTSTerminate;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return kTSTerminate;
|
||||
|
||||
}
|
||||
|
||||
void TalkThread_Duckman::onPause() {
|
||||
if (_status == 5) {
|
||||
if (!(_flags & 4)) {
|
||||
_vm->_soundMan->pauseVoice();
|
||||
}
|
||||
if (!(_flags & 8))
|
||||
_textDurationElapsed = getDurationElapsed(_textStartTime, _textEndTime);
|
||||
}
|
||||
}
|
||||
|
||||
void TalkThread_Duckman::onUnpause() {
|
||||
if (_status == 3) {
|
||||
TalkEntry *talkEntry = getTalkResourceEntry(_talkId);
|
||||
if (!_vm->isSoundActive())
|
||||
_vm->_soundMan->cueVoice((char*)talkEntry->_voiceName);
|
||||
} else if (_status == 5) {
|
||||
if (!(_flags & 4)) {
|
||||
_vm->_soundMan->unpauseVoice();
|
||||
}
|
||||
if (!(_flags & 8)) {
|
||||
_textStartTime = getCurrentTime();
|
||||
if (_textDuration <= _textDurationElapsed)
|
||||
_textEndTime = _textStartTime;
|
||||
else
|
||||
_textEndTime = _textStartTime + _textDuration - _textDurationElapsed;
|
||||
_textDurationElapsed = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TalkThread_Duckman::onResume() {
|
||||
}
|
||||
|
||||
void TalkThread_Duckman::onTerminated() {
|
||||
if (_status == 5) {
|
||||
if (!(_flags & 4))
|
||||
_vm->_soundMan->stopVoice();
|
||||
if (!(_flags & 8)) {
|
||||
_vm->_screenText->removeText();
|
||||
}
|
||||
if (!(_flags & 2)) {
|
||||
Control *control = _vm->_dict->getObjectControl(_objectId);
|
||||
if (control) {
|
||||
control->clearNotifyThreadId1();
|
||||
control->startSequenceActor(_sequenceId2, 2, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TalkThread_Duckman::onKill() {
|
||||
_callingThreadId = 0;
|
||||
sendMessage(kMsgClearSequenceId1, 0);
|
||||
sendMessage(kMsgClearSequenceId2, 0);
|
||||
}
|
||||
|
||||
uint32 TalkThread_Duckman::sendMessage(int msgNum, uint32 msgValue) {
|
||||
switch (msgNum) {
|
||||
case kMsgQueryTalkThreadActive:
|
||||
if (_status != 1)
|
||||
return 1;
|
||||
break;
|
||||
case kMsgClearSequenceId1:
|
||||
_sequenceId1 = 0;
|
||||
_flags |= 3;
|
||||
break;
|
||||
case kMsgClearSequenceId2:
|
||||
_sequenceId2 = 0;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void TalkThread_Duckman::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;
|
||||
}
|
||||
|
||||
int TalkThread_Duckman::insertText() {
|
||||
debug(0, "%08X %08X [%s]", _threadId, _talkId, debugW2I(_currEntryText));
|
||||
WidthHeight dimensions;
|
||||
_vm->getDefaultTextDimensions(dimensions);
|
||||
uint16 *outTextPtr;
|
||||
_vm->_screenText->insertText(_currEntryText, 0x120001, dimensions,
|
||||
Common::Point(0, 0), TEXT_FLAG_CENTER_ALIGN, 0, 0, _color.r, _color.g, _color.b, outTextPtr);
|
||||
_entryText = outTextPtr;
|
||||
Common::Point pt;
|
||||
_vm->getDefaultTextPosition(pt);
|
||||
_vm->_screenText->updateTextInfoPosition(pt);
|
||||
int charCount = _entryText - _currEntryText;
|
||||
return charCount;
|
||||
}
|
||||
|
||||
TalkEntry *TalkThread_Duckman::getTalkResourceEntry(uint32 talkId) {
|
||||
TalkEntry *talkEntry = _vm->_dict->findTalkEntry(talkId);
|
||||
return talkEntry;
|
||||
}
|
||||
|
||||
void TalkThread_Duckman::getActorTypeColor(uint32 actorTypeId, RGB &color) {
|
||||
ActorType *actorType = _vm->_dict->findActorType(actorTypeId);
|
||||
color = actorType->_color;
|
||||
}
|
||||
|
||||
} // End of namespace Illusions
|
||||
85
engines/illusions/threads/talkthread_duckman.h
Normal file
85
engines/illusions/threads/talkthread_duckman.h
Normal file
@@ -0,0 +1,85 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ILLUSIONS_TALKTHREAD_DUCKMAN_H
|
||||
#define ILLUSIONS_TALKTHREAD_DUCKMAN_H
|
||||
|
||||
#include "illusions/thread.h"
|
||||
|
||||
namespace Illusions {
|
||||
|
||||
class IllusionsEngine_Duckman;
|
||||
struct TalkEntry;
|
||||
|
||||
enum {
|
||||
kMsgQueryTalkThreadActive = 0,
|
||||
kMsgClearSequenceId1 = 1,
|
||||
kMsgClearSequenceId2 = 2
|
||||
};
|
||||
|
||||
class TalkThread_Duckman : public Thread {
|
||||
public:
|
||||
TalkThread_Duckman(IllusionsEngine_Duckman *vm, uint32 threadId, uint32 callingThreadId, uint notifyFlags,
|
||||
uint32 objectId, uint32 talkId, uint32 sequenceId1, uint32 sequenceId2);
|
||||
int onUpdate() override;
|
||||
void onPause() override;
|
||||
void onUnpause() override;
|
||||
void onResume() override;
|
||||
void onTerminated() override;
|
||||
void onKill() override;
|
||||
uint32 sendMessage(int msgNum, uint32 msgValue) override;
|
||||
public:
|
||||
IllusionsEngine_Duckman *_vm;
|
||||
//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;
|
||||
uint32 _namedPointId1;
|
||||
uint32 _namedPointId2;
|
||||
byte *_entryTblPtr;
|
||||
uint16 *_entryText;
|
||||
uint16 *_currEntryText;
|
||||
//field30 dd
|
||||
uint32 _voiceStartTime;
|
||||
uint32 _voiceEndTime;
|
||||
uint32 _voiceDuration;
|
||||
uint32 _voiceDurationElapsed;
|
||||
int *_pauseCtrPtr;
|
||||
RGB _color;
|
||||
void refreshText();
|
||||
int insertText();
|
||||
TalkEntry *getTalkResourceEntry(uint32 talkId);
|
||||
void getActorTypeColor(uint32 actorTypeId, RGB &color);
|
||||
};
|
||||
|
||||
} // End of namespace Illusions
|
||||
|
||||
#endif // ILLUSIONS_TALKTHREAD_H
|
||||
79
engines/illusions/threads/timerthread.cpp
Normal file
79
engines/illusions/threads/timerthread.cpp
Normal file
@@ -0,0 +1,79 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "illusions/illusions.h"
|
||||
#include "illusions/threads/timerthread.h"
|
||||
#include "illusions/input.h"
|
||||
#include "illusions/time.h"
|
||||
|
||||
namespace Illusions {
|
||||
|
||||
// TimerThread
|
||||
|
||||
TimerThread::TimerThread(IllusionsEngine *vm, uint32 threadId, uint32 callingThreadId, uint notifyFlags,
|
||||
uint32 duration, bool isAbortable)
|
||||
: Thread(vm, threadId, callingThreadId, notifyFlags), _duration(duration), _isAbortable(isAbortable) {
|
||||
_type = kTTTimerThread;
|
||||
_startTime = getCurrentTime();
|
||||
_endTime = _startTime + _duration;
|
||||
|
||||
if (callingThreadId) {
|
||||
Thread *callingThread = _vm->_threads->findThread(callingThreadId);
|
||||
if (callingThread)
|
||||
_sceneId = callingThread->_sceneId;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int TimerThread::onUpdate() {
|
||||
if (isTimerExpired(_startTime, _endTime) ||
|
||||
(_isAbortable && _vm->_input->pollEvent(kEventAbort)))
|
||||
return kTSTerminate;
|
||||
return kTSYield;
|
||||
}
|
||||
|
||||
void TimerThread::onSuspend() {
|
||||
onPause();
|
||||
}
|
||||
|
||||
void TimerThread::onNotify() {
|
||||
onUnpause();
|
||||
}
|
||||
|
||||
void TimerThread::onPause() {
|
||||
_durationElapsed = getDurationElapsed(_startTime, _endTime);
|
||||
}
|
||||
|
||||
void TimerThread::onUnpause() {
|
||||
uint32 currTime = getCurrentTime();
|
||||
_startTime = currTime;
|
||||
if (_duration <= _durationElapsed)
|
||||
_endTime = currTime;
|
||||
else
|
||||
_endTime = currTime + _duration - _durationElapsed;
|
||||
_durationElapsed = 0;
|
||||
}
|
||||
|
||||
void TimerThread::onResume() {
|
||||
onNotify();
|
||||
}
|
||||
|
||||
} // End of namespace Illusions
|
||||
49
engines/illusions/threads/timerthread.h
Normal file
49
engines/illusions/threads/timerthread.h
Normal file
@@ -0,0 +1,49 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ILLUSIONS_TIMERTHREAD_H
|
||||
#define ILLUSIONS_TIMERTHREAD_H
|
||||
|
||||
#include "illusions/thread.h"
|
||||
|
||||
namespace Illusions {
|
||||
|
||||
class IllusionsEngine;
|
||||
|
||||
class TimerThread : public Thread {
|
||||
public:
|
||||
TimerThread(IllusionsEngine *vm, uint32 threadId, uint32 callingThreadId, uint notifyFlags,
|
||||
uint32 duration, bool isAbortable);
|
||||
int onUpdate() override;
|
||||
void onSuspend() override;
|
||||
void onNotify() override;
|
||||
void onPause() override;
|
||||
void onUnpause() override;
|
||||
void onResume() override;
|
||||
public:
|
||||
uint32 _startTime, _endTime;
|
||||
uint32 _duration, _durationElapsed;
|
||||
bool _isAbortable;
|
||||
};
|
||||
|
||||
} // End of namespace Illusions
|
||||
|
||||
#endif // ILLUSIONS_TIMERTHREAD_H
|
||||
Reference in New Issue
Block a user