aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/simon/res.cpp2
-rw-r--r--engines/simon/simon.h2
-rw-r--r--engines/simon/sound.cpp37
-rw-r--r--engines/simon/sound.h2
-rw-r--r--engines/simon/vga.cpp12
5 files changed, 43 insertions, 12 deletions
diff --git a/engines/simon/res.cpp b/engines/simon/res.cpp
index 67fa3501c2..e4ac479e7b 100644
--- a/engines/simon/res.cpp
+++ b/engines/simon/res.cpp
@@ -710,7 +710,7 @@ byte *SimonEngine::loadVGAFile(uint id, uint type, uint32 &dstSize) {
return dst;
}
-void SimonEngine::loadSound(uint sound, uint pan, uint vol, uint type) {
+void SimonEngine::loadSound(uint sound, int pan, int vol, uint type) {
byte *dst;
if (getFeatures() & GF_ZLIBCOMP) {
diff --git a/engines/simon/simon.h b/engines/simon/simon.h
index 8be62e5306..d39d842675 100644
--- a/engines/simon/simon.h
+++ b/engines/simon/simon.h
@@ -496,7 +496,7 @@ protected:
void loadGamePcFile();
void decompressData(const char *srcName, byte *dst, uint32 offset, uint32 srcSize, uint32 dstSize);
void loadOffsets(const char *filename, int number, uint32 &file, uint32 &offset, uint32 &compressedSize, uint32 &size);
- void loadSound(uint sound, uint pan, uint vol, uint type);
+ void loadSound(uint sound, int pan, int vol, uint type);
void loadVoice(uint speechId);
void palette_fadeout(uint32 *pal_values, uint num);
diff --git a/engines/simon/sound.cpp b/engines/simon/sound.cpp
index b9a2bf6539..7f28dfdd56 100644
--- a/engines/simon/sound.cpp
+++ b/engines/simon/sound.cpp
@@ -265,7 +265,6 @@ Sound::Sound(SimonEngine *vm, const GameSpecificSettings *gss, Audio::Mixer *mix
if (_vm->getGameType() == GType_SIMON1)
loadSfxFile(gss);
}
-
}
Sound::~Sound() {
@@ -585,7 +584,7 @@ void Sound::playVoiceData(byte *soundData, uint sound) {
playSoundData(&_voiceHandle, soundData, sound);
}
-void Sound::playSoundData(Audio::SoundHandle *handle, byte *soundData, uint sound, uint pan, uint vol, bool loop) {
+void Sound::playSoundData(Audio::SoundHandle *handle, byte *soundData, uint sound, int pan, int vol, bool loop) {
byte *buffer, flags;
uint16 compType;
int blockAlign, rate;
@@ -596,6 +595,38 @@ void Sound::playSoundData(Audio::SoundHandle *handle, byte *soundData, uint soun
error("playSoundData: Not a valid WAV data");
}
+ // The Feeble Files originally used DirectSound, which specifies volume
+ // and panning differently than ScummVM does, using a logarithmic scale
+ // rather than a linear one.
+ //
+ // Volume is a value between -10,000 and 0.
+ // Panning is a value between -10,000 and 10,000.
+ //
+ // In both cases, the -10,000 represents -100 dB. When panning, only
+ // one speaker's volume is affected - just like in ScummVM - with
+ // negative values affecting the left speaker, and positive values
+ // affecting the right speaker. Thus -10,000 means the left speaker is
+ // silent.
+
+ int v, p;
+
+ vol = CLIP(vol, -10000, 0);
+ pan = CLIP(pan, -10000, 10000);
+
+ if (vol) {
+ v = (int)((double)Audio::Mixer::kMaxChannelVolume * pow(10.0, (double)vol / 2000.0) + 0.5);
+ } else {
+ v = Audio::Mixer::kMaxChannelVolume;
+ }
+
+ if (pan < 0) {
+ p = (int)(255.0 * pow(10.0, (double)pan / 2000.0) + 127.5);
+ } else if (pan > 0) {
+ p = (int)(255.0 * pow(10.0, (double)pan / -2000.0) - 127.5);
+ } else {
+ p = 0;
+ }
+
if (loop == true)
flags |= Audio::Mixer::FLAG_LOOP;
@@ -610,7 +641,7 @@ void Sound::playSoundData(Audio::SoundHandle *handle, byte *soundData, uint soun
memcpy(buffer, soundData + stream.pos(), size);
}
- _mixer->playRaw(handle, buffer, size, rate, flags | Audio::Mixer::FLAG_AUTOFREE);
+ _mixer->playRaw(handle, buffer, size, rate, flags | Audio::Mixer::FLAG_AUTOFREE, -1, v, p);
}
void Sound::stopSfx5() {
diff --git a/engines/simon/sound.h b/engines/simon/sound.h
index 350f30273d..9f5d612678 100644
--- a/engines/simon/sound.h
+++ b/engines/simon/sound.h
@@ -76,7 +76,7 @@ public:
void playAmbientData(byte *soundData, uint sound, uint pan, uint vol);
void playSfxData(byte *soundData, uint sound, uint pan, uint vol);
void playSfx5Data(byte *soundData, uint sound, uint pan, uint vol);
- void playSoundData(Audio::SoundHandle *handle, byte *soundData, uint sound, uint pan = 0, uint vol = 0, bool loop = false);
+ void playSoundData(Audio::SoundHandle *handle, byte *soundData, uint sound, int pan = 0, int vol = 0, bool loop = false);
void playVoiceData(byte *soundData, uint sound);
void switchVoiceFile(const GameSpecificSettings *gss, uint disc);
diff --git a/engines/simon/vga.cpp b/engines/simon/vga.cpp
index a12d199e28..b97040db9d 100644
--- a/engines/simon/vga.cpp
+++ b/engines/simon/vga.cpp
@@ -1965,8 +1965,8 @@ void SimonEngine::vc52_playSound() {
}
if (getGameType() == GType_FF) {
- uint16 pan = vcReadNextWord();
- uint16 vol = vcReadNextWord();
+ int16 pan = vcReadNextWord();
+ int16 vol = vcReadNextWord();
if (ambient)
loadSound(sound, pan, vol, 2);
@@ -1986,11 +1986,11 @@ void SimonEngine::vc52_playSound() {
void SimonEngine::vc53_panSFX() {
VgaSprite *vsp = findCurSprite();
- int32 pan;
+ int pan;
uint16 sound = vcReadNextWord();
int16 xoffs = vcReadNextWord();
- uint16 vol = vcReadNextWord();
+ int16 vol = vcReadNextWord();
pan = (vsp->x - _scrollX + xoffs) * 8 - 2560;
if (pan < -10000)
@@ -2488,8 +2488,8 @@ void SimonEngine::vc82_getPathValue() {
void SimonEngine::vc83_playSoundLoop() {
uint sound = vcReadNextWord();
- uint vol = vcReadNextWord();
- uint pan = vcReadNextWord();
+ int16 vol = vcReadNextWord();
+ int16 pan = vcReadNextWord();
loadSound(sound, pan, vol, 3);
}