aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorD G Turner2012-12-12 17:02:59 +0000
committerD G Turner2012-12-12 17:02:59 +0000
commit8b379a5718df054775d24adcd45d4c45b9d34e74 (patch)
treee4159600dd6c1521205924687d9cacbf91d64034 /engines
parent344d6bc2dad335527085767dfa0734478e658747 (diff)
downloadscummvm-rg350-8b379a5718df054775d24adcd45d4c45b9d34e74.tar.gz
scummvm-rg350-8b379a5718df054775d24adcd45d4c45b9d34e74.tar.bz2
scummvm-rg350-8b379a5718df054775d24adcd45d4c45b9d34e74.zip
TOUCHE: Add generic music functions to wrap MidiPlayer usages.
This is a precursor to adding code within these functions to select between MIDI and external digital music files.
Diffstat (limited to 'engines')
-rw-r--r--engines/touche/menu.cpp6
-rw-r--r--engines/touche/resource.cpp5
-rw-r--r--engines/touche/touche.cpp35
-rw-r--r--engines/touche/touche.h7
4 files changed, 42 insertions, 11 deletions
diff --git a/engines/touche/menu.cpp b/engines/touche/menu.cpp
index c58e2f1a33..57882fa6aa 100644
--- a/engines/touche/menu.cpp
+++ b/engines/touche/menu.cpp
@@ -260,7 +260,7 @@ void ToucheEngine::redrawMenu(void *menu) {
Graphics::drawRect(_offscreenBuffer, kScreenWidth, 106, 118, 340, 164, 0xF9, 0xF7);
switch (menuData->mode) {
case kMenuSettingsMode:
- drawVolumeSlideBar(_offscreenBuffer, kScreenWidth, _midiPlayer->getVolume());
+ drawVolumeSlideBar(_offscreenBuffer, kScreenWidth, getMusicVolume());
menuData->buttonsTable[5].data = 0;
menuData->buttonsTable[6].data = 0;
menuData->buttonsTable[7].data = 0;
@@ -307,10 +307,10 @@ void ToucheEngine::handleMenuAction(void *menu, int actionId) {
_talkTextMode = kTalkModeVoiceAndText;
break;
case kActionLowerVolume:
- _midiPlayer->adjustVolume(-16);
+ adjustMusicVolume(-16);
break;
case kActionUpperVolume:
- _midiPlayer->adjustVolume(+16);
+ adjustMusicVolume(+16);
break;
case kActionScrollUpSaves:
--_saveLoadCurrentPage;
diff --git a/engines/touche/resource.cpp b/engines/touche/resource.cpp
index 0790d726b7..9625224316 100644
--- a/engines/touche/resource.cpp
+++ b/engines/touche/resource.cpp
@@ -610,10 +610,7 @@ void ToucheEngine::res_stopSound() {
void ToucheEngine::res_loadMusic(int num) {
debugC(9, kDebugResource, "ToucheEngine::res_loadMusic() num=%d", num);
- uint32 size;
- const uint32 offs = res_getDataOffset(kResourceTypeMusic, num, &size);
- _fData.seek(offs);
- _midiPlayer->play(_fData, size, true);
+ startMusic(num);
}
void ToucheEngine::res_loadSpeech(int num) {
diff --git a/engines/touche/touche.cpp b/engines/touche/touche.cpp
index 4b989963f6..8fdbad5a1b 100644
--- a/engines/touche/touche.cpp
+++ b/engines/touche/touche.cpp
@@ -100,7 +100,7 @@ Common::Error ToucheEngine::run() {
setupOpcodes();
- _midiPlayer = new MidiPlayer;
+ initMusic();
// Setup mixer
syncSoundSettings();
@@ -120,7 +120,7 @@ Common::Error ToucheEngine::run() {
}
void ToucheEngine::restart() {
- _midiPlayer->stop();
+ stopMusic();
_gameState = kGameStateGameLoop;
_displayQuitDialog = false;
@@ -216,7 +216,7 @@ void ToucheEngine::readConfigurationSettings() {
_talkTextMode = kTalkModeVoiceOnly;
}
}
- _midiPlayer->setVolume(ConfMan.getInt("music_volume"));
+ setMusicVolume(ConfMan.getInt("music_volume"));
}
void ToucheEngine::writeConfigurationSettings() {
@@ -234,7 +234,7 @@ void ToucheEngine::writeConfigurationSettings() {
ConfMan.setBool("subtitles", true);
break;
}
- ConfMan.setInt("music_volume", _midiPlayer->getVolume());
+ ConfMan.setInt("music_volume", getMusicVolume());
ConfMan.flushToDisk();
}
@@ -3307,4 +3307,31 @@ bool ToucheEngine::canSaveGameStateCurrently() {
return _gameState == kGameStateGameLoop && _flagsTable[618] == 0 && !_hideInventoryTexts;
}
+void ToucheEngine::initMusic() {
+ _midiPlayer = new MidiPlayer;
+}
+
+void ToucheEngine::startMusic(int num) {
+ uint32 size;
+ const uint32 offs = res_getDataOffset(kResourceTypeMusic, num, &size);
+ _fData.seek(offs);
+ _midiPlayer->play(_fData, size, true);
+}
+
+void ToucheEngine::stopMusic() {
+ _midiPlayer->stop();
+}
+
+int ToucheEngine::getMusicVolume() {
+ return _midiPlayer->getVolume();
+}
+
+void ToucheEngine::setMusicVolume(int volume) {
+ _midiPlayer->setVolume(volume);
+}
+
+void ToucheEngine::adjustMusicVolume(int diff) {
+ _midiPlayer->adjustVolume(diff);
+}
+
} // namespace Touche
diff --git a/engines/touche/touche.h b/engines/touche/touche.h
index 949727b665..72993e2f6e 100644
--- a/engines/touche/touche.h
+++ b/engines/touche/touche.h
@@ -646,6 +646,13 @@ protected:
MidiPlayer *_midiPlayer;
+ void initMusic();
+ void startMusic(int num);
+ void stopMusic();
+ int getMusicVolume();
+ void setMusicVolume(int volume);
+ void adjustMusicVolume(int diff);
+
Common::Language _language;
Common::RandomSource _rnd;