From c34af3993771db881b27ebdbdd4d531cbc9c48b4 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 3 Aug 2016 22:25:47 -0400 Subject: TITANIC: Correct sound manager methods to return existing WaveFile class --- engines/titanic/module.mk | 1 - engines/titanic/sound/sound.cpp | 51 ++++++++++++------------- engines/titanic/sound/sound.h | 34 +++++++++++------ engines/titanic/sound/sound_manager.cpp | 8 ++-- engines/titanic/sound/sound_manager.h | 28 +++++++------- engines/titanic/sound/sound_resource.cpp | 32 ---------------- engines/titanic/sound/sound_resource.h | 35 ----------------- engines/titanic/sound/wave_file.cpp | 5 +++ engines/titanic/sound/wave_file.h | 2 + engines/titanic/true_talk/true_talk_manager.cpp | 6 +-- 10 files changed, 75 insertions(+), 127 deletions(-) delete mode 100644 engines/titanic/sound/sound_resource.cpp delete mode 100644 engines/titanic/sound/sound_resource.h (limited to 'engines') diff --git a/engines/titanic/module.mk b/engines/titanic/module.mk index d029a1762f..b4780d8a5c 100644 --- a/engines/titanic/module.mk +++ b/engines/titanic/module.mk @@ -410,7 +410,6 @@ MODULE_OBJS := \ sound/seasonal_music_player.o \ sound/sound.o \ sound/sound_manager.o \ - sound/sound_resource.o \ sound/titania_speech.o \ sound/trigger_auto_music_player.o \ sound/view_auto_sound_player.o \ diff --git a/engines/titanic/sound/sound.cpp b/engines/titanic/sound/sound.cpp index 34214f5cd0..e8084d79e0 100644 --- a/engines/titanic/sound/sound.cpp +++ b/engines/titanic/sound/sound.cpp @@ -71,7 +71,7 @@ void CSound::fn3(int handle, int val2, int val3) { warning("TODO: CSound::fn3"); } -void CSound::fn4(CSoundResource *soundRes, int val) { +void CSound::fn4(WaveFile *waveFile, int val) { // TODO } @@ -79,7 +79,7 @@ void CSound::checkSounds() { for (CSoundItemList::iterator i = _sounds.begin(); i != _sounds.end(); ++i) { CSoundItem *soundItem = *i; if (soundItem->_field24 && soundItem->_field28) { - if (_soundManager.isActive(soundItem->_soundResource)) { + if (_soundManager.isActive(soundItem->_waveFile)) { _sounds.remove(soundItem); delete soundItem; } @@ -91,7 +91,7 @@ void CSound::removeOldest() { for (CSoundItemList::iterator i = _sounds.reverse_begin(); i != _sounds.end(); --i) { CSoundItem *soundItem = *i; - if (soundItem->_field28 && !_soundManager.isActive(soundItem->_soundResource)) { + if (soundItem->_field28 && !_soundManager.isActive(soundItem->_waveFile)) { _sounds.remove(soundItem); delete soundItem; break; @@ -99,12 +99,11 @@ void CSound::removeOldest() { } } -CSoundItem *CSound::getTrueTalkSound(CDialogueFile *dialogueFile, int index) { - warning("TODO: CSound::getTrueTalkSound"); - return nullptr; +WaveFile *CSound::getTrueTalkSound(CDialogueFile *dialogueFile, int index) { + return loadSpeech(dialogueFile, index); } -CSoundResource *CSound::loadSound(const CString &name) { +WaveFile *CSound::loadSound(const CString &name) { checkSounds(); // Check whether an entry for the given name is already active @@ -114,15 +113,15 @@ CSoundResource *CSound::loadSound(const CString &name) { // Found it, so move it to the front of the list and return _sounds.remove(soundItem); _sounds.push_front(soundItem); - return soundItem->_soundResource; + return soundItem->_waveFile; } } // Create new sound item CSoundItem *soundItem = new CSoundItem(name); - soundItem->_soundResource = _soundManager.loadSound(name); + soundItem->_waveFile = _soundManager.loadSound(name); - if (!soundItem->_soundResource) { + if (!soundItem->_waveFile) { // Couldn't load sound, so destroy new item and return delete soundItem; return 0; @@ -136,21 +135,21 @@ CSoundResource *CSound::loadSound(const CString &name) { if (_sounds.size() > 10) removeOldest(); - return soundItem->_soundResource; + return soundItem->_waveFile; } int CSound::playSound(const CString &name, CProximity &prox) { - CSoundResource *soundRes = loadSound(name); - if (!soundRes) + WaveFile *waveFile = loadSound(name); + if (!waveFile) return -1; - prox._field6C = soundRes->fn1(); - fn4(soundRes, prox._field60); + prox._field6C = waveFile->fn1(); + fn4(waveFile, prox._field60); - return _soundManager.playSound(*soundRes, prox); + return _soundManager.playSound(*waveFile, prox); } -CSoundResource *CSound::loadSpeech(CDialogueFile *dialogueFile, int speechId) { +WaveFile *CSound::loadSpeech(CDialogueFile *dialogueFile, int speechId) { checkSounds(); // Check whether an entry for the given name is already active @@ -161,15 +160,15 @@ CSoundResource *CSound::loadSpeech(CDialogueFile *dialogueFile, int speechId) { // Found it, so move it to the front of the list and return _sounds.remove(soundItem); _sounds.push_front(soundItem); - return soundItem->_soundResource; + return soundItem->_waveFile; } } // Create new sound item CSoundItem *soundItem = new CSoundItem(dialogueFile->getFile(), speechId); - soundItem->_soundResource = _soundManager.loadSpeech(dialogueFile, speechId); + soundItem->_waveFile = _soundManager.loadSpeech(dialogueFile, speechId); - if (!soundItem->_soundResource) { + if (!soundItem->_waveFile) { // Couldn't load speech, so destroy new item and return delete soundItem; return 0; @@ -183,18 +182,18 @@ CSoundResource *CSound::loadSpeech(CDialogueFile *dialogueFile, int speechId) { if (_sounds.size() > 10) removeOldest(); - return soundItem->_soundResource; + return soundItem->_waveFile; } int CSound::playSpeech(CDialogueFile *dialogueFile, int speechId, CProximity &prox) { - CSoundResource *soundRes = loadSpeech(dialogueFile, speechId); - if (!soundRes) + WaveFile *waveFile = loadSpeech(dialogueFile, speechId); + if (!waveFile) return -1; - prox._field6C = soundRes->fn1(); - fn4(soundRes, prox._field60); + prox._field6C = waveFile->fn1(); + fn4(waveFile, prox._field60); - return _soundManager.playSound(*soundRes, prox); + return _soundManager.playSound(*waveFile, prox); } } // End of namespace Titanic diff --git a/engines/titanic/sound/sound.h b/engines/titanic/sound/sound.h index bc61d488ef..c14c9e17c4 100644 --- a/engines/titanic/sound/sound.h +++ b/engines/titanic/sound/sound.h @@ -26,7 +26,7 @@ #include "titanic/support/simple_file.h" #include "titanic/sound/proximity.h" #include "titanic/sound/sound_manager.h" -#include "titanic/sound/sound_resource.h" +#include "titanic/sound/wave_file.h" #include "titanic/core/list.h" #include "titanic/core/view_item.h" #include "titanic/true_talk/dialogue_file.h" @@ -38,17 +38,17 @@ class CGameManager; class CSoundItem : public ListItem { public: CString _name; - CSoundResource *_soundResource; + WaveFile *_waveFile; File *_dialogueFileHandle; int _speechId; int _field24; int _field28; public: - CSoundItem() : ListItem(), _soundResource(nullptr), _dialogueFileHandle(nullptr), + CSoundItem() : ListItem(), _waveFile(nullptr), _dialogueFileHandle(nullptr), _speechId(0), _field24(0), _field28(0) {} - CSoundItem(const CString &name) : ListItem(), _name(name), _soundResource(nullptr), + CSoundItem(const CString &name) : ListItem(), _name(name), _waveFile(nullptr), _dialogueFileHandle(nullptr), _speechId(0), _field24(0), _field28(0) {} - CSoundItem(File *dialogueFile, int speechId) : ListItem(), _soundResource(nullptr), + CSoundItem(File *dialogueFile, int speechId) : ListItem(), _waveFile(nullptr), _dialogueFileHandle(dialogueFile), _speechId(speechId), _field24(0), _field28(0) {} int fn1(); @@ -115,21 +115,31 @@ public: bool fn1(int val); void fn2(int handle); void fn3(int handle, int val2, int val3); - void fn4(CSoundResource *soundRes, int val); + void fn4(WaveFile *waveFile, int val); void managerProc8(int v) { _soundManager.proc8(v); } - CSoundItem *getTrueTalkSound(CDialogueFile *dialogueFile, int index); + /** + * Loads a TrueTalk dialogue + * @param dialogueFile Dialogue file reference + * @param speechId Speech Id within dialogue + * @returns Wave file instance + */ + WaveFile *getTrueTalkSound(CDialogueFile *dialogueFile, int index); /** - * Load a sound - * @param name Name of sound resource - * @returns Sound item record + * Load a speech resource + * @param dialogueFile Dialogue file reference + * @param speechId Speech Id within dialogue + * @returns Wave file instance */ - CSoundResource *loadSpeech(CDialogueFile *dialogueFile, int speechId); + WaveFile *loadSpeech(CDialogueFile *dialogueFile, int speechId); /** * Play a speech + * @param dialogueFile Dialogue file reference + * @param speechId Speech Id within dialogue + * @param prox Proximity instance */ int playSpeech(CDialogueFile *dialogueFile, int speechId, CProximity &prox); @@ -138,7 +148,7 @@ public: * @param name Name of sound resource * @returns Sound item record */ - CSoundResource *loadSound(const CString &name); + WaveFile *loadSound(const CString &name); /** * Play a sound diff --git a/engines/titanic/sound/sound_manager.cpp b/engines/titanic/sound/sound_manager.cpp index 5cc5b597aa..61ad59ce7f 100644 --- a/engines/titanic/sound/sound_manager.cpp +++ b/engines/titanic/sound/sound_manager.cpp @@ -34,12 +34,12 @@ QSoundManager::QSoundManager() : _field18(0), _field1C(0) { Common::fill(&_field4A0[0], &_field4A0[16], 0); } -CSoundResource *QSoundManager::loadSound(const CString &name) { +WaveFile *QSoundManager::loadSound(const CString &name) { warning("TODO"); return nullptr; } -CSoundResource *QSoundManager::loadSpeech(CDialogueFile *dialogueFile, int speechId) { +WaveFile *QSoundManager::loadSpeech(CDialogueFile *dialogueFile, int speechId) { warning("TODO"); return nullptr; } @@ -49,7 +49,7 @@ int QSoundManager::proc5() const { return 0; } -int QSoundManager::playSound(CSoundResource &soundRes, CProximity &prox) { +int QSoundManager::playSound(WaveFile &soundRes, CProximity &prox) { warning("TODO"); return 0; } @@ -87,7 +87,7 @@ bool QSoundManager::proc14() { return false; } -bool QSoundManager::isActive(const CSoundResource *soundRes) const { +bool QSoundManager::isActive(const WaveFile *waveFile) const { warning("TODO"); return false; } diff --git a/engines/titanic/sound/sound_manager.h b/engines/titanic/sound/sound_manager.h index 5a3aa2f01d..85ee00a3f7 100644 --- a/engines/titanic/sound/sound_manager.h +++ b/engines/titanic/sound/sound_manager.h @@ -25,7 +25,7 @@ #include "titanic/support/simple_file.h" #include "titanic/sound/proximity.h" -#include "titanic/sound/sound_resource.h" +#include "titanic/sound/wave_file.h" #include "titanic/true_talk/dialogue_file.h" namespace Titanic { @@ -44,23 +44,23 @@ public: /** * Loads a sound * @param name Name of sound resource - * @returns Loaded sound handle + * @returns Loaded wave file */ - virtual CSoundResource *loadSound(const CString &name) { return nullptr; } + virtual WaveFile *loadSound(const CString &name) { return nullptr; } /** * Loads a speech resource from a dialogue file * @param name Name of sound resource - * @returns Loaded sound handle + * @returns Loaded wave file */ - virtual CSoundResource *loadSpeech(CDialogueFile *dialogueFile, int speechId) { return 0; } + virtual WaveFile *loadSpeech(CDialogueFile *dialogueFile, int speechId) { return 0; } virtual int proc5() const { return 0; } /** - * Start playing a previously loaded sound resource + * Start playing a previously loaded wave file */ - virtual int playSound(CSoundResource &soundRes, CProximity &prox) = 0; + virtual int playSound(WaveFile &waveFile, CProximity &prox) = 0; virtual void proc7() = 0; virtual void proc8(int v) = 0; @@ -74,7 +74,7 @@ public: /** * Returns true if the given sound is currently active */ - virtual bool isActive(const CSoundResource *soundRes) const { return false; } + virtual bool isActive(const WaveFile *waveFile) const { return false; } virtual int proc16() const { return 0; } virtual void WaveMixPump() {} @@ -134,23 +134,23 @@ public: /** * Loads a sound * @param name Name of sound resource - * @returns Loaded sound handle + * @returns Loaded wave file */ - virtual CSoundResource *loadSound(const CString &name); + virtual WaveFile *loadSound(const CString &name); /** * Loads a speech resource from a dialogue file * @param name Name of sound resource - * @returns Loaded sound handle + * @returns Loaded wave file */ - virtual CSoundResource *loadSpeech(CDialogueFile *dialogueFile, int speechId); + virtual WaveFile *loadSpeech(CDialogueFile *dialogueFile, int speechId); virtual int proc5() const; /** * Start playing a previously loaded sound resource */ - virtual int playSound(CSoundResource &soundRes, CProximity &prox); + virtual int playSound(WaveFile &waveFile, CProximity &prox); virtual void proc7(); virtual void proc8(int v); @@ -164,7 +164,7 @@ public: /** * Returns true if the given sound is currently active */ - virtual bool isActive(const CSoundResource *soundRes) const; + virtual bool isActive(const WaveFile *soundRes) const; virtual int proc16() const; virtual void WaveMixPump(); diff --git a/engines/titanic/sound/sound_resource.cpp b/engines/titanic/sound/sound_resource.cpp deleted file mode 100644 index 2184a25f52..0000000000 --- a/engines/titanic/sound/sound_resource.cpp +++ /dev/null @@ -1,32 +0,0 @@ -/* 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 "titanic/sound/sound_resource.h" - -namespace Titanic { - -int CSoundResource::fn1() { - // TODO - return 0; -} - -} // End of namespace Titanic z diff --git a/engines/titanic/sound/sound_resource.h b/engines/titanic/sound/sound_resource.h deleted file mode 100644 index b88988ed21..0000000000 --- a/engines/titanic/sound/sound_resource.h +++ /dev/null @@ -1,35 +0,0 @@ -/* 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 TITANIC_SOUND_RESOURCE_H -#define TITANIC_SOUND_RESOURCE_H - -namespace Titanic { - -class CSoundResource { -public: - int fn1(); -}; - -} // End of namespace Titanic - -#endif /* TITANIC_SOUND_RESOURCE_H */ diff --git a/engines/titanic/sound/wave_file.cpp b/engines/titanic/sound/wave_file.cpp index 288f5f525d..2459f1eee6 100644 --- a/engines/titanic/sound/wave_file.cpp +++ b/engines/titanic/sound/wave_file.cpp @@ -24,4 +24,9 @@ namespace Titanic { +int WaveFile::fn1() { + // TODO + return 0; +} + } // End of namespace Titanic z diff --git a/engines/titanic/sound/wave_file.h b/engines/titanic/sound/wave_file.h index 0bb836ef74..b27e5e7707 100644 --- a/engines/titanic/sound/wave_file.h +++ b/engines/titanic/sound/wave_file.h @@ -47,6 +47,8 @@ public: WaveFile() : _field0(2), _field4(0), _field8(0), _handle(0), _owner(nullptr), _field14(1), _field18(0), _field1C(0), _field20(0), _field24(0), _field28(0), _field2C(-1) {} + + int fn1(); }; } // End of namespace Titanic diff --git a/engines/titanic/true_talk/true_talk_manager.cpp b/engines/titanic/true_talk/true_talk_manager.cpp index 072832af4d..977fc892c6 100644 --- a/engines/titanic/true_talk/true_talk_manager.cpp +++ b/engines/titanic/true_talk/true_talk_manager.cpp @@ -408,10 +408,10 @@ int CTrueTalkManager::readDialogSound() { _field18 = 0; for (uint idx = 0; idx < _titleEngine._indexes.size(); ++idx) { - CSoundItem *soundItem = _gameManager->_sound.getTrueTalkSound( + WaveFile *waveFile = _gameManager->_sound.getTrueTalkSound( _dialogueFile, _titleEngine._indexes[idx] - _dialogueId); - if (soundItem) { - _field18 = soundItem->fn1(); + if (waveFile) { + _field18 = waveFile->fn1(); } } -- cgit v1.2.3