diff options
-rw-r--r-- | engines/titanic/core/view_item.cpp | 4 | ||||
-rw-r--r-- | engines/titanic/core/view_item.h | 2 | ||||
-rw-r--r-- | engines/titanic/sound/sound.cpp | 5 | ||||
-rw-r--r-- | engines/titanic/sound/sound.h | 7 | ||||
-rw-r--r-- | engines/titanic/support/proximity.cpp | 5 | ||||
-rw-r--r-- | engines/titanic/support/proximity.h | 15 | ||||
-rw-r--r-- | engines/titanic/true_talk/true_talk_manager.cpp | 119 | ||||
-rw-r--r-- | engines/titanic/true_talk/true_talk_manager.h | 9 | ||||
-rw-r--r-- | engines/titanic/true_talk/tt_talker.cpp | 2 | ||||
-rw-r--r-- | engines/titanic/true_talk/tt_talker.h | 8 |
10 files changed, 156 insertions, 20 deletions
diff --git a/engines/titanic/core/view_item.cpp b/engines/titanic/core/view_item.cpp index b829ae5a70..07c01423e0 100644 --- a/engines/titanic/core/view_item.cpp +++ b/engines/titanic/core/view_item.cpp @@ -306,4 +306,8 @@ void CViewItem::handleButtonUpMsg(CMouseButtonUpMsg *msg) { } } +void CViewItem::fn1(double val1, double val2, double val3) { + warning("TODO: CViewItem::fn1"); +} + } // End of namespace Titanic diff --git a/engines/titanic/core/view_item.h b/engines/titanic/core/view_item.h index 67b2113142..d85117a0ec 100644 --- a/engines/titanic/core/view_item.h +++ b/engines/titanic/core/view_item.h @@ -96,6 +96,8 @@ public: * Finds a link which connects to another designated view */ CLinkItem *findLink(CViewItem *newView); + + void fn1(double val1, double val2, double val3); }; } // End of namespace Titanic diff --git a/engines/titanic/sound/sound.cpp b/engines/titanic/sound/sound.cpp index cf7689d937..dc8d0eeb21 100644 --- a/engines/titanic/sound/sound.cpp +++ b/engines/titanic/sound/sound.cpp @@ -69,6 +69,11 @@ void CSound::fn3(int handle, int val2, int val3) { warning("TODO: CSound::fn3"); } +int CSound::playSpeech(CDialogueFile *dialogueFile, int speechId, const CProximity &prox) { + warning("TODO: CSound::playSpeech"); + return 0; +} + uint CSound::loadSound(const CString &name) { checkSounds(); diff --git a/engines/titanic/sound/sound.h b/engines/titanic/sound/sound.h index 33996de1ca..f550493624 100644 --- a/engines/titanic/sound/sound.h +++ b/engines/titanic/sound/sound.h @@ -24,6 +24,7 @@ #define TITANIC_SOUND_H #include "titanic/support/simple_file.h" +#include "titanic/support/proximity.h" #include "titanic/sound/sound_manager.h" #include "titanic/core/list.h" #include "titanic/core/view_item.h" @@ -118,6 +119,12 @@ public: bool fn1(int val); void fn2(int handle); void fn3(int handle, int val2, int val3); + + /** + * Play a speech + */ + int playSpeech(CDialogueFile *dialogueFile, int speechId, const CProximity &prox); + void managerProc8(int v) { _soundManager.proc8(v); } CSoundItem *getTrueTalkSound(CDialogueFile *dialogueFile, int index); diff --git a/engines/titanic/support/proximity.cpp b/engines/titanic/support/proximity.cpp index f7c90f7caf..4a832b9217 100644 --- a/engines/titanic/support/proximity.cpp +++ b/engines/titanic/support/proximity.cpp @@ -21,16 +21,17 @@ */ #include "titanic/support/proximity.h" +#include "titanic/true_talk/tt_talker.h" namespace Titanic { CProximity::CProximity() : _field4(0), _field8(100), _fieldC(0), - _field10(-1), _field14(0), _field18(0), _field1C(0x3FF00000), + _speechHandle(-1), _field14(0), _field18(0), _field1C(0x3FF00000), _field20(0), _field24(10), _field28(0), _field2C(0), _field30(0x3F000000), _field34(0), _double1(0.0), _double2(0.0), _double3(0.0), _field44(0), _field48(0), _field4C(0), _field50(0), _field54(0), _field58(0), _field5C(0), - _field60(0), _field64(0), _field68(0) { + _field60(0), _method1(nullptr), _talker(nullptr), _field6C(0) { } } // End of namespace Titanic diff --git a/engines/titanic/support/proximity.h b/engines/titanic/support/proximity.h index 69979eaeaf..935e2e6b1c 100644 --- a/engines/titanic/support/proximity.h +++ b/engines/titanic/support/proximity.h @@ -23,21 +23,27 @@ #ifndef TITANIC_PROXIMITY_H #define TITANIC_PROXIMITY_H +#include "common/scummsys.h" + namespace Titanic { +typedef bool (*CProximityFn)(int val); + +class TTtalker; + class CProximity { public: int _field4; int _field8; int _fieldC; - int _field10; + int _speechHandle; int _field14; int _field18; int _field1C; int _field20; int _field24; int _field28; - int _field2C; + uint32 _field2C; int _field30; int _field34; double _double1; @@ -51,8 +57,9 @@ public: int _field58; int _field5C; int _field60; - int _field64; - int _field68; + CProximityFn _method1; + TTtalker *_talker; + int _field6C; public: CProximity(); }; diff --git a/engines/titanic/true_talk/true_talk_manager.cpp b/engines/titanic/true_talk/true_talk_manager.cpp index da3b207434..bff4ba60ba 100644 --- a/engines/titanic/true_talk/true_talk_manager.cpp +++ b/engines/titanic/true_talk/true_talk_manager.cpp @@ -24,6 +24,7 @@ #include "titanic/core/tree_item.h" #include "titanic/npcs/true_talk_npc.h" #include "titanic/game_manager.h" +#include "titanic/titanic.h" #define MKTAG_BE(a3,a2,a1,a0) ((uint32)((a3) | ((a2) << 8) | ((a1) << 16) | ((a0) << 24))) @@ -195,14 +196,14 @@ void CTrueTalkManager::saveNPC(SimpleFile *file, int charId) const { void CTrueTalkManager::preLoad() { // Delete any previous talkers - for (TTTalkerList::iterator i = _talkers.begin(); i != _talkers.end(); ++i) + for (TTtalkerList::iterator i = _talkers.begin(); i != _talkers.end(); ++i) delete *i; _talkers.clear(); } void CTrueTalkManager::removeCompleted() { - for (TTTalkerList::iterator i = _talkers.begin(); i != _talkers.end(); ) { - TTTalker *talker = *i; + for (TTtalkerList::iterator i = _talkers.begin(); i != _talkers.end(); ) { + TTtalker *talker = *i; if (talker->_done) { i = _talkers.erase(i); @@ -327,12 +328,12 @@ void CTrueTalkManager::setDialogue(CTrueTalkNPC *npc, TTroomScript *roomScript, return; int soundId = readDialogSound(); - TTTalker *talker = new TTTalker(this, npc); + TTtalker *talker = new TTtalker(this, npc); _talkers.push_back(talker); bool isParrot = npc->getName().contains("parrot"); triggerNPC(npc); - setTalker(talker, roomScript, view, isParrot); + playSpeech(talker, roomScript, view, isParrot); talker->speechStarted(dialogueStr, _titleEngine._indexes[0], soundId); } @@ -422,8 +423,107 @@ void CTrueTalkManager::triggerNPC(CTrueTalkNPC *npc) { } } -void CTrueTalkManager::setTalker(TTTalker *talker, TTroomScript *roomScript, CViewItem *view, bool isParrot) { - warning("TODO: CTrueTalkManager::setTalker"); +void CTrueTalkManager::playSpeech(TTtalker *talker, TTroomScript *roomScript, CViewItem *view, bool isParrot) { + uint milli, index; + switch (roomScript->_scriptId) { + case 101: + milli = 300; + index = 16; + break; + case 106: + case 107: + case 110: + case 114: + case 115: + case 122: + milli = 130; + index = 10; + break; + case 108: + case 109: + milli = 200; + index = 10; + break; + case 111: + case 116: + case 121: + milli = 80; + index = 12; + break; + case 112: + case 124: + case 128: + case 130: + milli = 80; + index = 4; + break; + case 132: + milli = 60; + index = 4; + break; + default: + milli = 0; + index = 4; + break; + } + + // Setup proximities + CProximity p1, p2, p3; + if (isParrot) { + p1._field24 = 3; + p2._field24 = 5; + p3._field24 = 4; + } else { + p1._field24 = 0; + p2._field24 = 1; + p3._field24 = 2; + } + + if (milli > 0) { + p3._field8 = (index * 3) / 2; + p3._field28 = 1; + p3._field2C = 0xC3070000; + p3._field30 = 0x3F800000; + p3._field34 = 0; + + p3._field8 = (index * 3) / 4; + p2._field28 = 0; + p2._field2C = 0x43070000; + p2._field30 = 0x3F800000; + p2._field34 = 0; + } + + _gameManager->_sound.managerProc8(p1._field24); + if (view) { + p1._field28 = 2; + view->fn1(p1._double1, p1._double2, p1._double3); + } + + for (uint idx = 0; idx < _titleEngine._indexes.size(); ++idx) { + uint id = _titleEngine._indexes[idx]; + if (id > 100000) + continue; + + if (idx == (_titleEngine._indexes.size() - 1)) { + // Final iteration of speech segments to play + p1._method1 = &proximityMethod1; + p1._talker = talker; + } + + // Start the + p1._speechHandle = _gameManager->_sound.playSpeech(_dialogueFile, id - _dialogueId, p1); + if (!milli) + continue; + + if (idx == 0) + g_vm->_events->sleep(milli); + + p3._speechHandle = _gameManager->_sound.playSpeech(_dialogueFile, id - _dialogueId, p3); + if (idx == 0) + g_vm->_events->sleep(milli); + + p2._speechHandle = _gameManager->_sound.playSpeech(_dialogueFile, id - _dialogueId, p2); + } } int CTrueTalkManager::getStateVal(int stateNum) { @@ -444,4 +544,9 @@ bool CTrueTalkManager::triggerAction(int action, int param) { return true; } +bool CTrueTalkManager::proximityMethod1(int val) { + // TODO + return false; +} + } // End of namespace Titanic diff --git a/engines/titanic/true_talk/true_talk_manager.h b/engines/titanic/true_talk/true_talk_manager.h index 524f13e1f2..3467fe1cb5 100644 --- a/engines/titanic/true_talk/true_talk_manager.h +++ b/engines/titanic/true_talk/true_talk_manager.h @@ -47,7 +47,7 @@ private: CDialogueFile *_dialogueFile; int _dialogueId; int _field18; - TTTalkerList _talkers; + TTtalkerList _talkers; private: /** * Loads the statics for the class @@ -101,7 +101,12 @@ private: */ void triggerNPC(CTrueTalkNPC *npc); - void setTalker(TTTalker *talker, TTroomScript *roomScript, CViewItem *view, bool isParrot); + /** + * Plays speech specified by the manager's indexes array + */ + void playSpeech(TTtalker *talker, TTroomScript *roomScript, CViewItem *view, bool isParrot); + + static bool proximityMethod1(int val); public: static int _v1; static int _v2; diff --git a/engines/titanic/true_talk/tt_talker.cpp b/engines/titanic/true_talk/tt_talker.cpp index 3e86fdf597..1eb7fc8b2e 100644 --- a/engines/titanic/true_talk/tt_talker.cpp +++ b/engines/titanic/true_talk/tt_talker.cpp @@ -25,7 +25,7 @@ namespace Titanic { -void TTTalker::speechStarted(const CString &dialogueStr, uint dialogueId, uint soundId) { +void TTtalker::speechStarted(const CString &dialogueStr, uint dialogueId, uint soundId) { _dialogueId = dialogueId; CTrueTalkNotifySpeechStartedMsg msg(soundId, dialogueId, 0); diff --git a/engines/titanic/true_talk/tt_talker.h b/engines/titanic/true_talk/tt_talker.h index 622bcc67d1..9bb59fbe64 100644 --- a/engines/titanic/true_talk/tt_talker.h +++ b/engines/titanic/true_talk/tt_talker.h @@ -31,7 +31,7 @@ namespace Titanic { class CTrueTalkManager; -class TTTalker : public ListItem { +class TTtalker : public ListItem { public: CTrueTalkManager *_owner; CTrueTalkNPC *_npc; @@ -40,15 +40,15 @@ public: int _field24; int _done; public: - TTTalker() : _owner(nullptr), _npc(nullptr), + TTtalker() : _owner(nullptr), _npc(nullptr), _dialogueId(0), _field24(0), _done(0) {} - TTTalker(CTrueTalkManager *owner, CTrueTalkNPC *npc) : + TTtalker(CTrueTalkManager *owner, CTrueTalkNPC *npc) : _owner(owner), _npc(npc), _dialogueId(0), _field24(0), _done(0) {} void speechStarted(const CString &dialogueStr, uint dialogueId, uint soundId); }; -class TTTalkerList : public List<TTTalker> { +class TTtalkerList : public List<TTtalker> { }; } // End of namespace Titanic |