aboutsummaryrefslogtreecommitdiff
path: root/queen
diff options
context:
space:
mode:
authorJoost Peters2004-03-09 00:52:07 +0000
committerJoost Peters2004-03-09 00:52:07 +0000
commit1020f97ceab9f1a606abf0bf6a0160b4136fab46 (patch)
tree07ac56b5bbe4fa0cf43e973a125079ebe0c8ff2e /queen
parent8b39133cab44244b6b4e3eeb303e91d0860a09b1 (diff)
downloadscummvm-rg350-1020f97ceab9f1a606abf0bf6a0160b4136fab46.tar.gz
scummvm-rg350-1020f97ceab9f1a606abf0bf6a0160b4136fab46.tar.bz2
scummvm-rg350-1020f97ceab9f1a606abf0bf6a0160b4136fab46.zip
Enable music volume slider in Journal
svn-id: r13222
Diffstat (limited to 'queen')
-rw-r--r--queen/journal.cpp9
-rw-r--r--queen/music.cpp21
-rw-r--r--queen/music.h9
-rw-r--r--queen/queen.cpp6
4 files changed, 32 insertions, 13 deletions
diff --git a/queen/journal.cpp b/queen/journal.cpp
index fd8aff06f8..ab27425274 100644
--- a/queen/journal.cpp
+++ b/queen/journal.cpp
@@ -240,8 +240,8 @@ void Journal::handleNormalMode(int16 zoneNum, int x) {
_vm->sound()->toggleSfx();
drawConfigPanel();
} else if (zoneNum == ZN_MUSIC_VOLUME) {
- // int val = (x - 136) * 100 / 130;
- // XXX alter_current_volume();
+ int val = (x - 136) * 255 / 130;
+ _vm->music()->setVolume(val);
drawConfigPanel();
} else if (zoneNum >= ZN_DESC_FIRST && zoneNum <= ZN_DESC_LAST) {
_currentSaveSlot = zoneNum - ZN_DESC_FIRST;
@@ -430,9 +430,8 @@ void Journal::drawConfigPanel() {
_vm->checkOptionSettings();
drawSlideBar(_vm->talkSpeed(), 130, 100, BOB_TALK_SPEED, 136 - 4, 164, FRAME_BLUE_PIN);
- // XXX music_volume
- drawSlideBar(100, 130, 100, BOB_MUSIC_VOLUME, 136 - 4, 177, FRAME_GREEN_PIN);
-
+ drawSlideBar(_vm->music()->volume(), 130, 255, BOB_MUSIC_VOLUME, 136 - 4, 177, FRAME_GREEN_PIN);
+
drawCheckBox(_vm->sound()->sfxOn(), BOB_SFX_TOGGLE, 221, 155, FRAME_CHECK_BOX);
drawCheckBox(_vm->sound()->speechOn(), BOB_SPEECH_TOGGLE, 158, 155, FRAME_CHECK_BOX);
drawCheckBox(_vm->subtitles(), BOB_TEXT_TOGGLE, 125, 167, FRAME_CHECK_BOX);
diff --git a/queen/music.cpp b/queen/music.cpp
index d60c89b6d2..f9512318c3 100644
--- a/queen/music.cpp
+++ b/queen/music.cpp
@@ -42,7 +42,7 @@ static const byte mt32_to_gm[128] = {
47, 117, 127, 118, 118, 116, 115, 119, 115, 112, 55, 124, 123, 0, 14, 117 // 7x
};
- MusicPlayer::MusicPlayer(MidiDriver *driver, byte *data, uint32 size) : _driver(driver), _isPlaying(false), _looping(false), _randomLoop(false), _volume(255), _queuePos(0), _musicData(data), _musicDataSize(size) {
+ MusicPlayer::MusicPlayer(MidiDriver *driver, byte *data, uint32 size) : _driver(driver), _isPlaying(false), _looping(false), _randomLoop(false), _masterVolume(192), _queuePos(0), _musicData(data), _musicDataSize(size) {
memset(_channel, 0, sizeof(_channel));
queueClear();
_lastSong = _currentSong = 0;
@@ -61,6 +61,23 @@ static const byte mt32_to_gm[128] = {
delete _parser;
}
+ void MusicPlayer::setVolume(int volume) {
+ if (volume < 0)
+ volume = 0;
+ else if (volume > 255)
+ volume = 255;
+
+ if (_masterVolume == volume)
+ return;
+
+ _masterVolume = volume;
+
+ for (int i = 0; i < 16; ++i) {
+ if (_channel[i])
+ _channel[i]->volume(_channelVolume[i] * _masterVolume / 255);
+ }
+ }
+
bool MusicPlayer::queueSong(uint16 songNum) {
uint8 emptySlots = 0;
for (int i = 0; i < MUSIC_QUEUE_SIZE; i++)
@@ -111,7 +128,7 @@ static const byte mt32_to_gm[128] = {
// Adjust volume changes by master volume
byte volume = (byte)((b >> 16) & 0x7F);
_channelVolume[channel] = volume;
- //volume = volume * _masterVolume / 255;
+ volume = volume * _masterVolume / 255;
b = (b & 0xFF00FFFF) | (volume << 16);
} else if ((b & 0xF0) == 0xC0 && !_nativeMT32) {
b = (b & 0xFFFF00FF) | mt32_to_gm[(b >> 8) & 0xFF] << 8;
diff --git a/queen/music.h b/queen/music.h
index 948efdb628..42d5429b6d 100644
--- a/queen/music.h
+++ b/queen/music.h
@@ -35,7 +35,9 @@ class MusicPlayer : public MidiDriver {
public:
MusicPlayer(MidiDriver *driver, byte *data, uint32 size);
~MusicPlayer();
-
+ void setVolume(int volume);
+ int getVolume() { return _masterVolume; }
+
void hasNativeMT32(bool b) { _nativeMT32 = b; }
void playMusic();
void stopMusic();
@@ -81,7 +83,7 @@ protected:
bool _isPlaying;
bool _looping;
bool _randomLoop;
- byte _volume;
+ byte _masterVolume;
uint8 _queuePos;
int16 _currentSong;
int16 _lastSong; //first song from previous queue
@@ -103,6 +105,9 @@ public:
void playMusic() { _player->playMusic(); }
void stopSong() { _player->stopMusic(); }
+ void setVolume(int vol) { _player->setVolume(vol); }
+ int volume() { return _player->getVolume(); }
+
protected:
byte *_musicData;
uint32 _musicDataSize;
diff --git a/queen/queen.cpp b/queen/queen.cpp
index 52ab3a9b82..1bc8c1fba7 100644
--- a/queen/queen.cpp
+++ b/queen/queen.cpp
@@ -134,8 +134,6 @@ void QueenEngine::checkOptionSettings() {
_talkSpeed = 100;
}
- // XXX check master_volume value
-
// ensure text is always on when voice is off
if (!_sound->speechOn()) {
_subtitles = true;
@@ -143,7 +141,7 @@ void QueenEngine::checkOptionSettings() {
}
void QueenEngine::readOptionSettings() {
- // XXX master_volume
+ _music->setVolume(ConfMan.getInt("music_volume"));
_sound->musicToggle(!ConfMan.getBool("music_mute"));
_sound->sfxToggle(!ConfMan.getBool("sfx_mute"));
_talkSpeed = ConfMan.getInt("talkspeed");
@@ -153,7 +151,7 @@ void QueenEngine::readOptionSettings() {
}
void QueenEngine::writeOptionSettings() {
- // XXX master_volume
+ ConfMan.set("music_volume", _music->volume());
ConfMan.set("music_mute", !_sound->musicOn());
ConfMan.set("sfx_mute", !_sound->sfxOn());
ConfMan.set("talkspeed", _talkSpeed);