aboutsummaryrefslogtreecommitdiff
path: root/engines/fullpipe/sound.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/fullpipe/sound.cpp')
-rw-r--r--engines/fullpipe/sound.cpp32
1 files changed, 22 insertions, 10 deletions
diff --git a/engines/fullpipe/sound.cpp b/engines/fullpipe/sound.cpp
index c82c2c414c..cd6647177e 100644
--- a/engines/fullpipe/sound.cpp
+++ b/engines/fullpipe/sound.cpp
@@ -29,6 +29,7 @@
#include "fullpipe/messages.h"
#include "fullpipe/statics.h"
+#include "common/config-manager.h"
#include "common/memstream.h"
#include "audio/mixer.h"
#include "audio/audiostream.h"
@@ -43,8 +44,14 @@ SoundList::SoundList() {
_libHandle = 0;
}
+SoundList::~SoundList() {
+ for (int i = 0; i < _soundItemsCount; i++)
+ delete _soundItems[i];
+ free(_soundItems);
+}
+
bool SoundList::load(MfcArchive &file, char *fname) {
- debug(5, "SoundList::load()");
+ debugC(5, kDebugLoading, "SoundList::load()");
_soundItemsCount = file.readUint32LE();
_soundItems = (Sound **)calloc(_soundItemsCount, sizeof(Sound *));
@@ -107,7 +114,7 @@ Sound::~Sound() {
}
bool Sound::load(MfcArchive &file, NGIArchive *archive) {
- debug(5, "Sound::load()");
+ debugC(5, kDebugLoading, "Sound::load()");
MemoryObject::load(file);
@@ -132,7 +139,7 @@ bool Sound::load(MfcArchive &file, NGIArchive *archive) {
}
void Sound::updateVolume() {
- debug(3, "STUB Sound::updateVolume()");
+ // not needed in our implementation
}
void Sound::setPanAndVolumeByStaticAni() {
@@ -162,7 +169,7 @@ void Sound::setPanAndVolumeByStaticAni() {
dx = ani->_oy - g_fp->_sceneRect.bottom;
}
- par = 0;
+ par = 0;
if (dx > 800) {
setPanAndVolume(-3500, 0);
@@ -208,8 +215,8 @@ void Sound::setPanAndVolumeByStaticAni() {
}
void Sound::setPanAndVolume(int vol, int pan) {
- g_fp->_mixer->setChannelVolume(*_handle, vol / 39); // 0..10000
- g_fp->_mixer->setChannelBalance(*_handle, pan / 78); // -10000..10000
+ g_fp->_mixer->setChannelVolume(*_handle, MIN((vol + 10000) / 39, 255)); // -10000..0
+ g_fp->_mixer->setChannelBalance(*_handle, CLIP(pan / 78, -127, 127)); // -10000..10000
}
void Sound::play(int flag) {
@@ -472,7 +479,8 @@ void global_messageHandler_handleSound(ExCommand *cmd) {
Sound *snd = 0;
for (int i = 0; i < g_fp->_currSoundListCount; i++)
- snd = g_fp->_currSoundList1[i]->getSoundItemById(cmd->_messageNum);
+ if ((snd = g_fp->_currSoundList1[i]->getSoundItemById(cmd->_messageNum)) != NULL)
+ break;
if (!snd)
return;
@@ -489,7 +497,7 @@ void global_messageHandler_handleSound(ExCommand *cmd) {
snd->setPanAndVolume(g_fp->_sfxVolume, 0);
if (snd->getVolume() > -3500)
- snd->play(cmd->_keyCode);
+ snd->play(cmd->_param);
} else if (cmd->_field_14 & 2) {
snd->stop();
}
@@ -514,8 +522,11 @@ void FullpipeEngine::stopAllSoundInstances(int id) {
}
void FullpipeEngine::updateSoundVolume() {
+ ConfMan.setInt("sfx_volume", MAX((_sfxVolume + 10000) / 39, 255));
+ syncSoundSettings();
+
for (int i = 0; i < _currSoundListCount; i++)
- for (int j = 0; i < _currSoundList1[i]->getCount(); j++) {
+ for (int j = 0; j < _currSoundList1[i]->getCount(); j++) {
_currSoundList1[i]->getSoundByIndex(j)->setPanAndVolume(_sfxVolume, 0);
}
}
@@ -523,7 +534,8 @@ void FullpipeEngine::updateSoundVolume() {
void FullpipeEngine::setMusicVolume(int vol) {
_musicVolume = vol;
- g_fp->_mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, vol);
+ ConfMan.setInt("music_volume", _musicVolume);
+ syncSoundSettings();
}
} // End of namespace Fullpipe