From e76a89048159ff20e59358706f43885a9786723c Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sat, 19 Apr 2014 17:01:29 +0300 Subject: FULLPIPE: Implement ModalMainMenu::updateSoundVolume() --- engines/fullpipe/modal.cpp | 70 ++++++++++++++++++++++++++++++++++++++++++++++ engines/fullpipe/sound.cpp | 4 +++ engines/fullpipe/sound.h | 5 +++- 3 files changed, 78 insertions(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/fullpipe/modal.cpp b/engines/fullpipe/modal.cpp index 5c73dcfe08..aed98c1130 100644 --- a/engines/fullpipe/modal.cpp +++ b/engines/fullpipe/modal.cpp @@ -1034,6 +1034,76 @@ void ModalMainMenu::updateVolume() { } void ModalMainMenu::updateSoundVolume(Sound *snd) { + if (!snd->_objectId) + return; + + StaticANIObject *ani = g_fp->_currentScene->getStaticANIObject1ById(snd->_objectId, -1); + if (!ani) + return; + + int a, b; + + if (ani->_ox >= _screct.left) { + int par, pan; + + if (ani->_ox <= _screct.right) { + int dx; + + if (ani->_oy <= _screct.bottom) { + if (ani->_oy >= _screct.top) { + snd->setPanAndVolume(g_fp->_sfxVolume, 0); + + return; + } + dx = _screct.top - ani->_oy; + } else { + dx = ani->_oy - _screct.bottom; + } + + par = 0; + + if (dx > 800) { + snd->setPanAndVolume(-3500, 0); + return; + } + + pan = -3500; + a = g_fp->_sfxVolume - (-3500); + b = 800 - dx; + } else { + int dx = ani->_ox - _screct.right; + + if (dx > 800) { + snd->setPanAndVolume(-3500, 0); + return; + } + + pan = -3500; + par = dx * (-3500) / -800; + a = g_fp->_sfxVolume - (-3500); + b = 800 - dx; + } + + int32 pp = b * a; //(0x51EB851F * b * a) >> 32) >> 8; // TODO FIXME + + snd->setPanAndVolume(pan + (pp >> 31) + pp, par); + + return; + } + + int dx = _screct.left - ani->_ox; + if (dx <= 800) { + int32 s = 0x51EB851F * (800 - dx) * (g_fp->_sfxVolume - (-3500)); // TODO FIXME + int32 p = -3500 + (s >> 31) + (s >> 8); + + if (p > g_fp->_sfxVolume) + p = g_fp->_sfxVolume; + + snd->setPanAndVolume(p, dx * (-3500) / 800); + } else { + snd->setPanAndVolume(-3500, 0); + } + warning("STUB: ModalMainMenu::updateSoundVolume()"); } diff --git a/engines/fullpipe/sound.cpp b/engines/fullpipe/sound.cpp index 4270b13b38..aa91f25087 100644 --- a/engines/fullpipe/sound.cpp +++ b/engines/fullpipe/sound.cpp @@ -119,6 +119,10 @@ void Sound::setPanAndVolumeByStaticAni() { debug(3, "STUB Sound::setPanAndVolumeByStaticAni()"); } +void Sound::setPanAndVolume(int vol, int pan) { + warning("STUB: Sound::setPanAndVolume"); +} + void FullpipeEngine::setSceneMusicParameters(GameVar *var) { warning("STUB: FullpipeEngine::setSceneMusicParameters()"); // TODO: Finish this (MINDELAY, MAXDELAY, LOCAL, SEQUENCE, STARTDELAY etc) diff --git a/engines/fullpipe/sound.h b/engines/fullpipe/sound.h index 8ddfc753ce..e284e5efab 100644 --- a/engines/fullpipe/sound.h +++ b/engines/fullpipe/sound.h @@ -28,12 +28,14 @@ namespace Fullpipe { class Sound : public MemoryObject { int _id; char *_description; - int16 _objectId; int _directSoundBuffer; int _directSoundBuffers[7]; byte *_soundData; Audio::SoundHandle _handle; +public: + int16 _objectId; + public: Sound(); virtual ~Sound(); @@ -45,6 +47,7 @@ public: Audio::SoundHandle getHandle() const { return _handle; } void setPanAndVolumeByStaticAni(); + void setPanAndVolume(int vol, int pan); }; class SoundList : public CObject { -- cgit v1.2.3