diff options
author | Walter van Niftrik | 2015-05-29 00:17:50 -0400 |
---|---|---|
committer | Matthew Hoops | 2015-07-07 20:19:45 -0400 |
commit | f7c785b37b5fb00029ebb04362f8a733f556e3dd (patch) | |
tree | 91199d4716e2fd11dfc84592884bad1dea16d01f /engines/sky | |
parent | 22d985f3c265162419ab8c65dd47b48ac385f463 (diff) | |
download | scummvm-rg350-f7c785b37b5fb00029ebb04362f8a733f556e3dd.tar.gz scummvm-rg350-f7c785b37b5fb00029ebb04362f8a733f556e3dd.tar.bz2 scummvm-rg350-f7c785b37b5fb00029ebb04362f8a733f556e3dd.zip |
SKY: Implement original music volume handling
Diffstat (limited to 'engines/sky')
-rw-r--r-- | engines/sky/music/adlibchannel.cpp | 8 | ||||
-rw-r--r-- | engines/sky/music/adlibchannel.h | 1 | ||||
-rw-r--r-- | engines/sky/music/adlibmusic.cpp | 6 |
3 files changed, 11 insertions, 4 deletions
diff --git a/engines/sky/music/adlibchannel.cpp b/engines/sky/music/adlibchannel.cpp index b57f20f0f8..c7acb9b6c1 100644 --- a/engines/sky/music/adlibchannel.cpp +++ b/engines/sky/music/adlibchannel.cpp @@ -45,6 +45,8 @@ AdLibChannel::AdLibChannel(OPL::OPL *opl, uint8 *pMusicData, uint16 startOfData) _channelData.frequency = 0; _channelData.instrumentData = NULL; + _musicVolume = 128; + uint16 instrumentDataLoc; if (SkyEngine::_systemVars.gameVersion == 109) { @@ -86,7 +88,7 @@ bool AdLibChannel::isActive() { } void AdLibChannel::updateVolume(uint16 pVolume) { - // Do nothing. The mixer handles the music volume for us. + _musicVolume = pVolume; } /* This class uses the same area for the register mirror as the original @@ -208,6 +210,8 @@ void AdLibChannel::setupChannelVolume(uint8 volume) { uint32 resVol = ((volume + 1) * (_channelData.instrumentData->totOutLev_Op2 + 1)) << 1; resVol &= 0xFFFF; resVol *= (_channelData.channelVolume + 1) << 1; + resVol >>= 8; + resVol *= _musicVolume << 1; resVol >>= 16; assert(resVol < 0x81); resultOp = ((_channelData.instrumentData->scalingLevel << 6) & 0xC0) | _opOutputTable[resVol]; @@ -216,6 +220,8 @@ void AdLibChannel::setupChannelVolume(uint8 volume) { resVol = ((volume + 1) * (_channelData.instrumentData->totOutLev_Op1 + 1)) << 1; resVol &= 0xFFFF; resVol *= (_channelData.channelVolume + 1) << 1; + resVol >>= 8; + resVol *= _musicVolume << 1; resVol >>= 16; } else resVol = _channelData.instrumentData->totOutLev_Op1; diff --git a/engines/sky/music/adlibchannel.h b/engines/sky/music/adlibchannel.h index 240dd5c8c0..4504e3b570 100644 --- a/engines/sky/music/adlibchannel.h +++ b/engines/sky/music/adlibchannel.h @@ -68,6 +68,7 @@ public: private: OPL::OPL *_opl; uint8 *_musicData; + uint16 _musicVolume; AdLibChannelType _channelData; InstrumentStruct *_instruments; diff --git a/engines/sky/music/adlibmusic.cpp b/engines/sky/music/adlibmusic.cpp index c13d6150ec..3607dfbd13 100644 --- a/engines/sky/music/adlibmusic.cpp +++ b/engines/sky/music/adlibmusic.cpp @@ -40,7 +40,7 @@ AdLibMusic::AdLibMusic(Audio::Mixer *pMixer, Disk *pDisk) : MusicBase(pMixer, pD error("Failed to create OPL"); _opl->start(new Common::Functor0Mem<void, AdLibMusic>(this, &AdLibMusic::onTimer), 50); - _mixer->playStream(Audio::Mixer::kMusicSoundType, &_soundHandle, this, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO, true); + _mixer->playStream(Audio::Mixer::kPlainSoundType, &_soundHandle, this, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO, true); } AdLibMusic::~AdLibMusic() { @@ -93,8 +93,8 @@ void AdLibMusic::startDriver() { void AdLibMusic::setVolume(uint16 param) { _musicVolume = param; - // FIXME: This is bad. There's no real volume control here. - _mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, 2 * param); + for (uint8 cnt = 0; cnt < _numberOfChannels; cnt++) + _channels[cnt]->updateVolume(_musicVolume); } bool AdLibMusic::isStereo() const { |