diff options
-rw-r--r-- | engines/titanic/core/game_object.cpp | 48 | ||||
-rw-r--r-- | engines/titanic/core/game_object.h | 20 | ||||
-rw-r--r-- | engines/titanic/game/television.cpp | 24 | ||||
-rw-r--r-- | engines/titanic/game/television.h | 2 | ||||
-rw-r--r-- | engines/titanic/module.mk | 1 | ||||
-rw-r--r-- | engines/titanic/sound/sound.cpp | 4 | ||||
-rw-r--r-- | engines/titanic/sound/sound.h | 6 | ||||
-rw-r--r-- | engines/titanic/sound/sound_manager.cpp | 4 | ||||
-rw-r--r-- | engines/titanic/sound/sound_manager.h | 8 | ||||
-rw-r--r-- | engines/titanic/sound/wave_file.cpp | 27 | ||||
-rw-r--r-- | engines/titanic/sound/wave_file.h | 54 |
11 files changed, 142 insertions, 56 deletions
diff --git a/engines/titanic/core/game_object.cpp b/engines/titanic/core/game_object.cpp index d1991a4baa..1d5c974db5 100644 --- a/engines/titanic/core/game_object.cpp +++ b/engines/titanic/core/game_object.cpp @@ -325,18 +325,6 @@ bool CGameObject::soundFn1(int val) { return false; } -void CGameObject::soundFn2(int val, int val2) { - if (val != 0 && val != -1) { - CGameManager *gameManager = getGameManager(); - if (gameManager) { - if (val2) - gameManager->_sound.fn3(val, 0, val2); - else - gameManager->_sound.fn2(val); - } - } -} - void CGameObject::setVisible(bool val) { if (val != _visible) { _visible = val; @@ -456,7 +444,16 @@ void CGameObject::sound8(bool flag) const { getGameManager()->_sound.managerProc8(flag ? 3 : 0); } -bool CGameObject::playSound(const CString &name, int val2, int val3, int val4) { +void CGameObject::loadSound(const CString &name) { + CGameManager *gameManager = getGameManager(); + if (gameManager) { + g_vm->_filesManager.preload(name); + if (!name.empty()) + gameManager->_sound.loadSound(name); + } +} + +int CGameObject::playSound(const CString &name, int val2, int val3, int val4) { CProximity prox; prox._field8 = val2; prox._fieldC = val3; @@ -464,12 +461,24 @@ bool CGameObject::playSound(const CString &name, int val2, int val3, int val4) { return playSound(name, prox); } -bool CGameObject::playSound(const CString &name, CProximity &prox) { +int CGameObject::playSound(const CString &name, CProximity &prox) { if (prox._field28 == 2) { // TODO } - return false; + return 0; +} + +void CGameObject::stopSound(int handle, int val2) { + if (handle != 0 && handle != -1) { + CGameManager *gameManager = getGameManager(); + if (gameManager) { + if (val2) + gameManager->_sound.fn3(handle, 0, val2); + else + gameManager->_sound.fn2(handle); + } + } } int CGameObject::addTimer(int endVal, uint firstDuration, uint duration) { @@ -749,13 +758,4 @@ void CGameObject::checkPlayMovie(const CString &name, int flags) { } } -void CGameObject::loadSound(const CString &name) { - CGameManager *gameManager = getGameManager(); - if (gameManager) { - g_vm->_filesManager.preload(name); - if (!name.empty()) - gameManager->_sound.loadSound(name); - } -} - } // End of namespace Titanic diff --git a/engines/titanic/core/game_object.h b/engines/titanic/core/game_object.h index 5bcba778f4..01fe503005 100644 --- a/engines/titanic/core/game_object.h +++ b/engines/titanic/core/game_object.h @@ -123,20 +123,29 @@ protected: CViewItem * parseView(const CString &viewString); bool soundFn1(int val); - void soundFn2(int val, int val2); void petFn2(int val); void petFn3(CTreeItem *item); void incState38(); /** + * Load a sound + */ + void loadSound(const CString &name); + + /** * Plays a sound */ - bool playSound(const CString &name, int val2, int val3, int val4); + int playSound(const CString &name, int val2, int val3, int val4); /** * Plays a sound */ - bool playSound(const CString &name, CProximity &prox); + int playSound(const CString &name, CProximity &prox); + + /** + * Stop a sound + */ + void stopSound(int handle, int val2); /** * Adds a timer @@ -220,11 +229,6 @@ protected: * Support function for drag moving */ void dragMove(const Point &pt); - - /** - * Load a sound - */ - void loadSound(const CString &name); public: int _field60; CursorId _cursorId; diff --git a/engines/titanic/game/television.cpp b/engines/titanic/game/television.cpp index 888400960d..280f7f25d6 100644 --- a/engines/titanic/game/television.cpp +++ b/engines/titanic/game/television.cpp @@ -51,7 +51,7 @@ int CTelevision::_v5; int CTelevision::_v6; CTelevision::CTelevision() : CBackground(), _fieldE0(1), - _fieldE4(7), _isOn(false), _fieldEC(0), _fieldF0(0) { + _fieldE4(7), _isOn(false), _fieldEC(0), _soundHandle(0) { } void CTelevision::init() { @@ -76,7 +76,7 @@ void CTelevision::save(SimpleFile *file, int indent) const { file->writeNumberLine(_v3, indent); file->writeNumberLine(_fieldEC, indent); file->writeNumberLine(_v4, indent); - file->writeNumberLine(_fieldF0, indent); + file->writeNumberLine(_soundHandle, indent); file->writeNumberLine(_v5, indent); file->writeNumberLine(_v6, indent); @@ -93,7 +93,7 @@ void CTelevision::load(SimpleFile *file) { _v3 = file->readNumber(); _fieldEC = file->readNumber(); _v4 = file->readNumber(); - _fieldF0 = file->readNumber(); + _soundHandle = file->readNumber(); _v5 = file->readNumber(); _v6 = file->readNumber(); @@ -103,8 +103,8 @@ void CTelevision::load(SimpleFile *file) { bool CTelevision::LeaveViewMsg(CLeaveViewMsg *msg) { clearPet(); if (_isOn) { - if (soundFn1(_fieldF0)) - soundFn2(_fieldF0, 0); + if (soundFn1(_soundHandle)) + stopSound(_soundHandle, 0); loadFrame(622); stopMovie(); @@ -153,8 +153,8 @@ static const int END_FRAMES[8] = { 0, 55, 111, 167, 223, 279, 335, 391 }; bool CTelevision::PETUpMsg(CPETUpMsg *msg) { if (msg->_name == "Television" && _isOn) { - if (soundFn1(_fieldF0)) - soundFn2(_fieldF0, 0); + if (soundFn1(_soundHandle)) + stopSound(_soundHandle, 0); _fieldE0 = _fieldE0 % _fieldE4 + 1; stopMovie(); @@ -166,8 +166,8 @@ bool CTelevision::PETUpMsg(CPETUpMsg *msg) { bool CTelevision::PETDownMsg(CPETDownMsg *msg) { if (msg->_name == "Television" && _isOn) { - if (soundFn1(_fieldF0)) - soundFn2(_fieldF0, 0); + if (soundFn1(_soundHandle)) + stopSound(_soundHandle, 0); if (--_fieldE0 < 1) _fieldE0 += _fieldE4; @@ -215,8 +215,8 @@ bool CTelevision::PETActivateMsg(CPETActivateMsg *msg) { _fieldE0 = 1; } else { stopMovie(); - if (soundFn1(_fieldF0)) - soundFn2(_fieldF0, 0); + if (soundFn1(_soundHandle)) + stopSound(_soundHandle, 0); setVisible(false); } @@ -236,7 +236,7 @@ bool CTelevision::MovieEndMsg(CMovieEndMsg *msg) { if (_fieldE0 == 3 && compareRoomNameTo("SGTState") && !getPassengerClass()) { playSound("z#47.wav", 100, 0, 0); - _fieldF0 = playSound("b#20.wav", 100, 0, 0); + _soundHandle = playSound("b#20.wav", 100, 0, 0); CTreeItem *magazine = getRoot()->findByName("Magazine"); if (magazine) { diff --git a/engines/titanic/game/television.h b/engines/titanic/game/television.h index 4c16a320ab..64202c7917 100644 --- a/engines/titanic/game/television.h +++ b/engines/titanic/game/television.h @@ -56,7 +56,7 @@ private: int _fieldE4; bool _isOn; int _fieldEC; - int _fieldF0; + int _soundHandle; public: CLASSDEF CTelevision(); diff --git a/engines/titanic/module.mk b/engines/titanic/module.mk index f570311add..778226dfa2 100644 --- a/engines/titanic/module.mk +++ b/engines/titanic/module.mk @@ -412,6 +412,7 @@ MODULE_OBJS := \ sound/view_auto_sound_player.o \ sound/view_toggles_other_music.o \ sound/water_lapping_sounds.o \ + sound/wave_file.o \ star_control/star_control.o \ star_control/star_control_sub1.o \ star_control/star_control_sub2.o \ diff --git a/engines/titanic/sound/sound.cpp b/engines/titanic/sound/sound.cpp index 68fb3aeeb6..3e4f154c35 100644 --- a/engines/titanic/sound/sound.cpp +++ b/engines/titanic/sound/sound.cpp @@ -56,11 +56,11 @@ bool CSound::fn1(int val) { return false; } -void CSound::fn2(int val) { +void CSound::fn2(int handle) { warning("TODO: CSound::fn3"); } -void CSound::fn3(int val, int val2, int val3) { +void CSound::fn3(int handle, int val2, int val3) { warning("TODO: CSound::fn3"); } diff --git a/engines/titanic/sound/sound.h b/engines/titanic/sound/sound.h index 19a8edfc21..dfbee0a9dd 100644 --- a/engines/titanic/sound/sound.h +++ b/engines/titanic/sound/sound.h @@ -35,7 +35,7 @@ class CGameManager; class CSoundItem : public ListItem { public: CString _name; - uint _soundHandle; + int _soundHandle; int _field1C; int _field20; int _field24; @@ -113,8 +113,8 @@ public: uint loadSound(const CString &name); bool fn1(int val); - void fn2(int val); - void fn3(int val, int val2, int val3); + void fn2(int handle); + void fn3(int handle, int val2, int val3); void managerProc8(int v) { _soundManager.proc8(v); } }; diff --git a/engines/titanic/sound/sound_manager.cpp b/engines/titanic/sound/sound_manager.cpp index 5c26527e09..fa1e5fb166 100644 --- a/engines/titanic/sound/sound_manager.cpp +++ b/engines/titanic/sound/sound_manager.cpp @@ -34,7 +34,7 @@ QSoundManager::QSoundManager() : _field18(0), _field1C(0) { Common::fill(&_field4A0[0], &_field4A0[16], 0); } -uint QSoundManager::loadSound(const CString &name) { +int QSoundManager::loadSound(const CString &name) { warning("TODO"); return 0; } @@ -86,7 +86,7 @@ bool QSoundManager::proc14() { return false; } -bool QSoundManager::isActive(uint handle) const { +bool QSoundManager::isActive(int handle) const { warning("TODO"); return false; } diff --git a/engines/titanic/sound/sound_manager.h b/engines/titanic/sound/sound_manager.h index 84d9aeb5bd..e9fd1faf0a 100644 --- a/engines/titanic/sound/sound_manager.h +++ b/engines/titanic/sound/sound_manager.h @@ -42,7 +42,7 @@ public: * @param name Name of sound resource * @returns Loaded sound handle */ - virtual uint loadSound(const CString &name) { return 0; } + virtual int loadSound(const CString &name) { return 0; } virtual int proc4() const { return 0; } virtual int proc5() const { return 0; } @@ -55,7 +55,7 @@ public: virtual void proc12() {} virtual void proc13() {} virtual bool proc14() = 0; - virtual bool isActive(uint handle) const { return false; } + virtual bool isActive(int handle) const { return false; } virtual int proc16() const { return 0; } virtual void WaveMixPump() {} virtual int proc18() const { return 0; } @@ -111,7 +111,7 @@ public: * @param name Name of sound resource * @returns Loaded sound handle */ - virtual uint loadSound(const CString &name); + virtual int loadSound(const CString &name); virtual int proc4(); virtual int proc5(); @@ -124,7 +124,7 @@ public: virtual void proc12(); virtual void proc13(); virtual bool proc14(); - virtual bool isActive(uint handle) const; + virtual bool isActive(int handle) const; virtual int proc16(); virtual void WaveMixPump(); virtual int proc18() const; diff --git a/engines/titanic/sound/wave_file.cpp b/engines/titanic/sound/wave_file.cpp new file mode 100644 index 0000000000..288f5f525d --- /dev/null +++ b/engines/titanic/sound/wave_file.cpp @@ -0,0 +1,27 @@ +/* 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/wave_file.h" + +namespace Titanic { + +} // End of namespace Titanic z diff --git a/engines/titanic/sound/wave_file.h b/engines/titanic/sound/wave_file.h new file mode 100644 index 0000000000..0bb836ef74 --- /dev/null +++ b/engines/titanic/sound/wave_file.h @@ -0,0 +1,54 @@ +/* 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_WAVE_FILE_H +#define TITANIC_WAVE_FILE_H + +#include "titanic/support/simple_file.h" + +namespace Titanic { + +class CSoundManager; + +class WaveFile { +public: + int _field0; + int _field4; + int _field8; + uint _handle; + CSoundManager *_owner; + int _field14; + int _field18; + int _field1C; + int _field20; + int _field24; + int _field28; + int _field2C; +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) {} +}; + +} // End of namespace Titanic + +#endif /* TITANIC_WAVE_FILE_H */ |