aboutsummaryrefslogtreecommitdiff
path: root/engines/touche
diff options
context:
space:
mode:
Diffstat (limited to 'engines/touche')
-rw-r--r--engines/touche/console.cpp19
-rw-r--r--engines/touche/console.h3
-rw-r--r--engines/touche/detection.cpp16
-rw-r--r--engines/touche/menu.cpp8
-rw-r--r--engines/touche/resource.cpp5
-rw-r--r--engines/touche/touche.cpp89
-rw-r--r--engines/touche/touche.h13
7 files changed, 133 insertions, 20 deletions
diff --git a/engines/touche/console.cpp b/engines/touche/console.cpp
index 51ef5fc639..2c4c6a0da1 100644
--- a/engines/touche/console.cpp
+++ b/engines/touche/console.cpp
@@ -26,9 +26,28 @@
namespace Touche {
ToucheConsole::ToucheConsole(ToucheEngine *vm) : GUI::Debugger(), _vm(vm) {
+ DCmd_Register("startMusic", WRAP_METHOD(ToucheConsole, Cmd_StartMusic));
+ DCmd_Register("stopMusic", WRAP_METHOD(ToucheConsole, Cmd_StopMusic));
}
ToucheConsole::~ToucheConsole() {
}
+bool ToucheConsole::Cmd_StartMusic(int argc, const char **argv) {
+ if (argc != 2) {
+ DebugPrintf("Usage: startMusic <num>\n");
+ return true;
+ }
+
+ int num = atoi(argv[1]);
+
+ _vm->startMusic(num);
+ return false;
+}
+
+bool ToucheConsole::Cmd_StopMusic(int argc, const char **argv) {
+ _vm->stopMusic();
+ return false;
+}
+
} // End of namespace Touche
diff --git a/engines/touche/console.h b/engines/touche/console.h
index e3cdc9d48b..43a303ad77 100644
--- a/engines/touche/console.h
+++ b/engines/touche/console.h
@@ -36,6 +36,9 @@ public:
private:
ToucheEngine *_vm;
+
+ bool Cmd_StartMusic(int argc, const char **argv);
+ bool Cmd_StopMusic(int argc, const char **argv);
};
} // End of namespace Touche
diff --git a/engines/touche/detection.cpp b/engines/touche/detection.cpp
index e4bbe0c4c1..0662e718d5 100644
--- a/engines/touche/detection.cpp
+++ b/engines/touche/detection.cpp
@@ -43,7 +43,7 @@ static const ADGameDescription gameDescriptions[] = {
"",
AD_ENTRY1s("touche.dat", "2af0177f8887e3430f345e6b4d8b1414", 26350211),
Common::EN_ANY,
- Common::kPlatformPC,
+ Common::kPlatformDOS,
ADGF_NO_FLAGS,
GUIO0()
},
@@ -52,7 +52,7 @@ static const ADGameDescription gameDescriptions[] = {
"",
AD_ENTRY1s("touche.dat", "95967f0b51d2e813e99ca00325098340", 26350190),
Common::EN_ANY,
- Common::kPlatformPC,
+ Common::kPlatformDOS,
ADGF_NO_FLAGS,
GUIO0()
},
@@ -61,7 +61,7 @@ static const ADGameDescription gameDescriptions[] = {
"",
AD_ENTRY1s("touche.dat", "1caa20bb4d4fc2ce8eb867b6610082b3", 26558232),
Common::FR_FRA,
- Common::kPlatformPC,
+ Common::kPlatformDOS,
ADGF_NO_FLAGS,
GUIO0()
},
@@ -70,7 +70,7 @@ static const ADGameDescription gameDescriptions[] = {
"",
AD_ENTRY1s("touche.dat", "be2ae6454b3325e410946f2322547cd4", 26625537),
Common::DE_DEU,
- Common::kPlatformPC,
+ Common::kPlatformDOS,
ADGF_NO_FLAGS,
GUIO0()
},
@@ -79,7 +79,7 @@ static const ADGameDescription gameDescriptions[] = {
"",
AD_ENTRY1s("touche.dat", "64e95ba1decf5a5a60f8fa1840f40c62", 26529523),
Common::ES_ESP,
- Common::kPlatformPC,
+ Common::kPlatformDOS,
ADGF_NO_FLAGS,
GUIO0()
},
@@ -88,7 +88,7 @@ static const ADGameDescription gameDescriptions[] = {
"",
AD_ENTRY1s("touche.dat", "1f442331d4b327c3488a9f6ffe9bdd25", 26367792),
Common::IT_ITA,
- Common::kPlatformPC,
+ Common::kPlatformDOS,
ADGF_NO_FLAGS,
GUIO0()
},
@@ -97,7 +97,7 @@ static const ADGameDescription gameDescriptions[] = {
"",
AD_ENTRY1s("touche.dat", "42d19a0bef65465109020440a9caa228", 26487370),
Common::PL_POL,
- Common::kPlatformPC,
+ Common::kPlatformDOS,
ADGF_NO_FLAGS,
GUIO0()
},
@@ -106,7 +106,7 @@ static const ADGameDescription gameDescriptions[] = {
"Demo",
AD_ENTRY1s("touche.dat", "ddaed436445b2e77294ed19e8ae4aa2c", 8720683),
Common::EN_ANY,
- Common::kPlatformPC,
+ Common::kPlatformDOS,
ADGF_DEMO,
GUIO0()
},
diff --git a/engines/touche/menu.cpp b/engines/touche/menu.cpp
index c58e2f1a33..85ca519f05 100644
--- a/engines/touche/menu.cpp
+++ b/engines/touche/menu.cpp
@@ -103,7 +103,7 @@ struct MenuData {
void addCharToDescription(int slot, char chr) {
char *description = saveLoadDescriptionsTable[slot];
int descriptionLen = strlen(description);
- if (descriptionLen < 32 && isprint(static_cast<unsigned char>(chr))) {
+ if (descriptionLen < 32 && Common::isPrint(chr)) {
description[descriptionLen] = chr;
description[descriptionLen + 1] = 0;
}
@@ -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..5c133ccbc6 100644
--- a/engines/touche/touche.cpp
+++ b/engines/touche/touche.cpp
@@ -32,6 +32,8 @@
#include "common/keyboard.h"
#include "common/textconsole.h"
+#include "audio/mixer.h"
+
#include "engines/util.h"
#include "graphics/cursorman.h"
#include "graphics/palette.h"
@@ -58,6 +60,8 @@ ToucheEngine::ToucheEngine(OSystem *system, Common::Language language)
_playSoundCounter = 0;
+ _musicVolume = 0;
+
_processRandomPaletteCounter = 0;
_fastWalkMode = false;
@@ -90,6 +94,7 @@ ToucheEngine::~ToucheEngine() {
DebugMan.clearAllDebugChannels();
delete _console;
+ stopMusic();
delete _midiPlayer;
}
@@ -100,7 +105,7 @@ Common::Error ToucheEngine::run() {
setupOpcodes();
- _midiPlayer = new MidiPlayer;
+ initMusic();
// Setup mixer
syncSoundSettings();
@@ -120,7 +125,7 @@ Common::Error ToucheEngine::run() {
}
void ToucheEngine::restart() {
- _midiPlayer->stop();
+ stopMusic();
_gameState = kGameStateGameLoop;
_displayQuitDialog = false;
@@ -216,7 +221,7 @@ void ToucheEngine::readConfigurationSettings() {
_talkTextMode = kTalkModeVoiceOnly;
}
}
- _midiPlayer->setVolume(ConfMan.getInt("music_volume"));
+ setMusicVolume(ConfMan.getInt("music_volume"));
}
void ToucheEngine::writeConfigurationSettings() {
@@ -234,7 +239,7 @@ void ToucheEngine::writeConfigurationSettings() {
ConfMan.setBool("subtitles", true);
break;
}
- ConfMan.setInt("music_volume", _midiPlayer->getVolume());
+ ConfMan.setInt("music_volume", getMusicVolume());
ConfMan.flushToDisk();
}
@@ -3307,4 +3312,80 @@ bool ToucheEngine::canSaveGameStateCurrently() {
return _gameState == kGameStateGameLoop && _flagsTable[618] == 0 && !_hideInventoryTexts;
}
+void ToucheEngine::initMusic() {
+ // Detect External Music Files
+ bool extMusic = true;
+ for (int num = 0; num < 26 && extMusic; num++) {
+ Common::String extMusicFilename = Common::String::format("track%02d", num+1);
+ Audio::SeekableAudioStream *musicStream = Audio::SeekableAudioStream::openStreamFile(extMusicFilename);
+ if (!musicStream)
+ extMusic = false;
+ delete musicStream;
+ }
+
+ if (!extMusic) {
+ _midiPlayer = new MidiPlayer;
+ debug(1, "initMusic(): Using midi music!");
+ } else
+ debug(1, "initMusic(): Using external digital music!");
+}
+
+void ToucheEngine::startMusic(int num) {
+ debug(1, "startMusic(%d)", num);
+ uint32 size;
+
+ stopMusic();
+
+ if (_midiPlayer) {
+ const uint32 offs = res_getDataOffset(kResourceTypeMusic, num, &size);
+ _fData.seek(offs);
+ _midiPlayer->play(_fData, size, true);
+ } else {
+ Common::String extMusicFilename = Common::String::format("track%02d", num);
+ Audio::SeekableAudioStream *extMusicFileStream = Audio::SeekableAudioStream::openStreamFile(extMusicFilename);
+ if (!extMusicFileStream) {
+ error("Unable to open %s for reading", extMusicFilename.c_str());
+ }
+ Audio::LoopingAudioStream *loopStream = new Audio::LoopingAudioStream(extMusicFileStream, 0);
+ _mixer->playStream(Audio::Mixer::kMusicSoundType, &_musicHandle, loopStream, -1, _musicVolume);
+ }
+}
+
+void ToucheEngine::stopMusic() {
+ debug(1, "stopMusic()");
+ if (_midiPlayer)
+ _midiPlayer->stop();
+ else {
+ _mixer->stopHandle(_musicHandle);
+ }
+}
+
+int ToucheEngine::getMusicVolume() {
+ if (_midiPlayer)
+ _musicVolume = _midiPlayer->getVolume();
+ return _musicVolume;
+}
+
+void ToucheEngine::setMusicVolume(int volume) {
+ debug(1, "setMusicVolume(%d)", volume);
+ _musicVolume = CLIP(volume, 0, 255);
+
+ if (_midiPlayer)
+ _midiPlayer->setVolume(_musicVolume);
+ else {
+ _mixer->setChannelVolume(_musicHandle, _musicVolume);
+ }
+}
+
+void ToucheEngine::adjustMusicVolume(int diff) {
+ debug(1, "adjustMusicVolume(%d)", diff);
+ _musicVolume = CLIP(_musicVolume + diff, 0, 255);
+
+ if (_midiPlayer)
+ _midiPlayer->adjustVolume(diff);
+ else {
+ _mixer->setChannelVolume(_musicHandle, _musicVolume);
+ }
+}
+
} // namespace Touche
diff --git a/engines/touche/touche.h b/engines/touche/touche.h
index 949727b665..6ac43e7dfe 100644
--- a/engines/touche/touche.h
+++ b/engines/touche/touche.h
@@ -31,6 +31,7 @@
#include "common/util.h"
#include "audio/mixer.h"
+#include "audio/audiostream.h"
#include "engines/engine.h"
@@ -646,6 +647,18 @@ protected:
MidiPlayer *_midiPlayer;
+ int _musicVolume;
+ Audio::SoundHandle _musicHandle;
+
+ void initMusic();
+public: // To allow access from console
+ void startMusic(int num);
+ void stopMusic();
+protected:
+ int getMusicVolume();
+ void setMusicVolume(int volume);
+ void adjustMusicVolume(int diff);
+
Common::Language _language;
Common::RandomSource _rnd;