aboutsummaryrefslogtreecommitdiff
path: root/engines/agos
diff options
context:
space:
mode:
Diffstat (limited to 'engines/agos')
-rw-r--r--engines/agos/agos.h10
-rw-r--r--engines/agos/input.cpp22
-rw-r--r--engines/agos/res_snd.cpp81
-rw-r--r--engines/agos/script.cpp7
-rw-r--r--engines/agos/script_e1.cpp12
-rw-r--r--engines/agos/vga_s2.cpp2
6 files changed, 78 insertions, 56 deletions
diff --git a/engines/agos/agos.h b/engines/agos/agos.h
index e40b1b10a5..e4b97e1425 100644
--- a/engines/agos/agos.h
+++ b/engines/agos/agos.h
@@ -1186,8 +1186,10 @@ protected:
virtual void windowNewLine(WindowBlock *window);
void windowDrawChar(WindowBlock *window, uint x, uint y, byte chr);
- virtual void loadMusic(uint music);
- void loadModule(uint music);
+ void loadMusic(uint track);
+ void playModule(uint music);
+ virtual void playMusic(uint16 track, uint16 track);
+ void stopMusic();
void checkTimerCallback();
void delay(uint delay);
@@ -1478,7 +1480,7 @@ protected:
virtual void userGame(bool load);
virtual int userGameGetKey(bool *b, char *buf, uint maxChar);
- virtual void loadMusic(uint music);
+ virtual void playMusic(uint16 music, uint16 track);
virtual void vcStopAnimation(uint zone, uint sprite);
};
@@ -1521,8 +1523,6 @@ protected:
virtual uint setupIconHitArea(WindowBlock *window, uint num, uint x, uint y, Item *item_ptr);
virtual void playSpeech(uint speech_id, uint vga_sprite_id);
-
- virtual void loadMusic(uint music);
};
class AGOSEngine_Feeble : public AGOSEngine_Simon2 {
diff --git a/engines/agos/input.cpp b/engines/agos/input.cpp
index 3f2efc86b4..0d5a185026 100644
--- a/engines/agos/input.cpp
+++ b/engines/agos/input.cpp
@@ -558,21 +558,33 @@ bool AGOSEngine::processSpecialKeys() {
_speech ^= 1;
}
case '+':
- _midi.setVolume(_midi.getVolume() + 16);
+ if ((getPlatform() == Common::kPlatformAcorn && (getFeatures() & GF_TALKIE)) ||
+ getPlatform() == Common::kPlatformPC || getPlatform() == Common::kPlatformWindows) {
+ _midi.setVolume(_midi.getVolume() + 16);
+ }
_mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, _mixer->getVolumeForSoundType(Audio::Mixer::kMusicSoundType) + 16);
break;
case '-':
- _midi.setVolume(_midi.getVolume() - 16);
+ if ((getPlatform() == Common::kPlatformAcorn && (getFeatures() & GF_TALKIE)) ||
+ getPlatform() == Common::kPlatformPC || getPlatform() == Common::kPlatformWindows) {
+ _midi.setVolume(_midi.getVolume() - 16);
+ }
_mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, _mixer->getVolumeForSoundType(Audio::Mixer::kMusicSoundType) - 16);
break;
case 'm':
- _midi.pause(_musicPaused ^= 1);
+ if ((getPlatform() == Common::kPlatformAcorn && (getFeatures() & GF_TALKIE)) ||
+ getPlatform() == Common::kPlatformPC || getPlatform() == Common::kPlatformWindows) {
+ _midi.pause(_musicPaused ^= 1);
+ } else {
+ // TODO
+ }
break;
case 's':
- if (getGameId() == GID_SIMON1DOS)
+ if (getGameId() == GID_SIMON1DOS) {
_midi._enable_sfx ^= 1;
- else
+ } else {
_sound->effectsPause(_effectsPaused ^= 1);
+ }
break;
case 'b':
_sound->ambientPause(_ambientPaused ^= 1);
diff --git a/engines/agos/res_snd.cpp b/engines/agos/res_snd.cpp
index cbdb8f9baf..a55903c9b2 100644
--- a/engines/agos/res_snd.cpp
+++ b/engines/agos/res_snd.cpp
@@ -120,9 +120,26 @@ void AGOSEngine::skipSpeech() {
}
}
-void AGOSEngine::loadModule(uint music) {
- _mixer->stopHandle(_modHandle);
+void AGOSEngine::loadMusic(uint music) {
+ char buf[4];
+
+ stopMusic();
+ _gameFile->seek(_gameOffsetsPtr[_musicIndexBase + music - 1], SEEK_SET);
+ _gameFile->read(buf, 4);
+ if (!memcmp(buf, "FORM", 4)) {
+ _gameFile->seek(_gameOffsetsPtr[_musicIndexBase + music - 1], SEEK_SET);
+ _midi.loadXMIDI(_gameFile);
+ } else {
+ _gameFile->seek(_gameOffsetsPtr[_musicIndexBase + music - 1], SEEK_SET);
+ _midi.loadMultipleSMF(_gameFile);
+ }
+
+ _lastMusicPlayed = music;
+ _nextMusicToPlay = -1;
+}
+
+void AGOSEngine::playModule(uint music) {
char filename[15];
File f;
@@ -135,7 +152,7 @@ void AGOSEngine::loadModule(uint music) {
f.open(filename);
if (f.isOpen() == false) {
- error("loadModule: Can't load module from '%s'", filename);
+ error("playModule: Can't load module from '%s'", filename);
}
Audio::AudioStream *audioStream;
@@ -145,7 +162,7 @@ void AGOSEngine::loadModule(uint music) {
uint srcSize = f.size();
byte *srcBuf = (byte *)malloc(srcSize);
if (f.read(srcBuf, srcSize) != srcSize)
- error("loadModule: Read failed");
+ error("playModule: Read failed");
uint dstSize = READ_BE_UINT32(srcBuf + srcSize - 4);
byte *dstBuf = (byte *)malloc(dstSize);
@@ -162,29 +179,8 @@ void AGOSEngine::loadModule(uint music) {
_mixer->playInputStream(Audio::Mixer::kMusicSoundType, &_modHandle, audioStream);
}
-void AGOSEngine_Simon2::loadMusic(uint music) {
- char buf[4];
-
- _midi.stop();
- _gameFile->seek(_gameOffsetsPtr[_musicIndexBase + music - 1], SEEK_SET);
- _gameFile->read(buf, 4);
- if (!memcmp(buf, "FORM", 4)) {
- _gameFile->seek(_gameOffsetsPtr[_musicIndexBase + music - 1], SEEK_SET);
- _midi.loadXMIDI(_gameFile);
- } else {
- _gameFile->seek(_gameOffsetsPtr[_musicIndexBase + music - 1], SEEK_SET);
- _midi.loadMultipleSMF(_gameFile);
- }
-
- _lastMusicPlayed = music;
- _nextMusicToPlay = -1;
-}
-
-void AGOSEngine_Simon1::loadMusic(uint music) {
- char buf[4];
-
- _midi.stop();
- _midi.setLoop(true); // Must do this BEFORE loading music. (GMF may have its own override.)
+void AGOSEngine_Simon1::playMusic(uint16 music, uint16 track) {
+ stopMusic();
// Support for compressed music from the ScummVM Music Enhancement Project
AudioCD.stop();
@@ -195,14 +191,18 @@ void AGOSEngine_Simon1::loadMusic(uint music) {
if (getGameId() == GID_SIMON1ACORN) {
// TODO: Add support for Desktop Tracker format
} else if (getPlatform() == Common::kPlatformAmiga) {
- loadModule(music);
+ playModule(music);
} else if (getFeatures() & GF_TALKIE) {
+ char buf[4];
+
// WORKAROUND: For a script bug in the CD versions
// We skip this music resource, as it was replaced by
// a sound effect, and the script was never updated.
if (music == 35)
return;
+ _midi.setLoop(true); // Must do this BEFORE loading music. (GMF may have its own override.)
+
_gameFile->seek(_gameOffsetsPtr[_musicIndexBase + music], SEEK_SET);
_gameFile->read(buf, 4);
if (!memcmp(buf, "GMF\x1", 4)) {
@@ -214,13 +214,16 @@ void AGOSEngine_Simon1::loadMusic(uint music) {
}
_midi.startTrack(0);
+ _midi.startTrack(track);
} else {
char filename[15];
File f;
sprintf(filename, "MOD%d.MUS", music);
f.open(filename);
if (f.isOpen() == false)
- error("loadMusic: Can't load music from '%s'", filename);
+ error("playMusic: Can't load music from '%s'", filename);
+
+ _midi.setLoop(true); // Must do this BEFORE loading music. (GMF may have its own override.)
if (getFeatures() & GF_DEMO)
_midi.loadS1D(&f);
@@ -228,16 +231,18 @@ void AGOSEngine_Simon1::loadMusic(uint music) {
_midi.loadSMF(&f, music);
_midi.startTrack(0);
+ _midi.startTrack(track);
}
}
-void AGOSEngine::loadMusic(uint music) {
+void AGOSEngine::playMusic(uint16 music, uint16 track) {
+ stopMusic();
+
if (getPlatform() == Common::kPlatformAmiga) {
- loadModule(music);
+ playModule(music);
} else if (getPlatform() == Common::kPlatformAtariST) {
// TODO: Add support for music formats used
} else {
- _midi.stop();
_midi.setLoop(true); // Must do this BEFORE loading music.
char filename[15];
@@ -245,10 +250,20 @@ void AGOSEngine::loadMusic(uint music) {
sprintf(filename, "MOD%d.MUS", music);
f.open(filename);
if (f.isOpen() == false)
- error("loadMusic: Can't load music from '%s'", filename);
+ error("playMusic: Can't load music from '%s'", filename);
_midi.loadS1D(&f);
_midi.startTrack(0);
+ _midi.startTrack(track);
+ }
+}
+
+void AGOSEngine::stopMusic() {
+ if ((getPlatform() == Common::kPlatformAcorn && (getFeatures() & GF_TALKIE)) ||
+ getPlatform() == Common::kPlatformPC || getPlatform() == Common::kPlatformWindows) {
+ _midi.stop();
+ } else {
+ _mixer->stopHandle(_modHandle);
}
}
diff --git a/engines/agos/script.cpp b/engines/agos/script.cpp
index d3197f6d90..5e86766066 100644
--- a/engines/agos/script.cpp
+++ b/engines/agos/script.cpp
@@ -722,13 +722,12 @@ void AGOSEngine::o_doClassIcons() {
void AGOSEngine::o_playTune() {
// 127: play tune
- int music = getVarOrWord();
- int track = getVarOrWord();
+ uint16 music = getVarOrWord();
+ uint16 track = getVarOrWord();
if (music != _lastMusicPlayed) {
_lastMusicPlayed = music;
- loadMusic(music);
- _midi.startTrack(track);
+ playMusic(music, track);
}
}
diff --git a/engines/agos/script_e1.cpp b/engines/agos/script_e1.cpp
index 06c347f391..60e49a1499 100644
--- a/engines/agos/script_e1.cpp
+++ b/engines/agos/script_e1.cpp
@@ -843,20 +843,16 @@ void AGOSEngine_Elvira1::oe1_ifTime() {
void AGOSEngine_Elvira1::oe1_playTune() {
// 264: play tune
- int music = getVarOrWord();
- int track = getVarOrWord();
+ uint16 music = getVarOrWord();
+ uint16 track = getVarOrWord();
if (music != _lastMusicPlayed) {
_lastMusicPlayed = music;
// No tune under water
if (music == 4) {
- if (getPlatform() == Common::kPlatformAmiga)
- _mixer->stopHandle(_modHandle);
- else
- _midi.stop();
+ stopMusic();
} else {
- loadMusic(music);
- _midi.startTrack(track);
+ playMusic(music, track);
}
}
}
diff --git a/engines/agos/vga_s2.cpp b/engines/agos/vga_s2.cpp
index 9e482e95f4..84b86cfc7d 100644
--- a/engines/agos/vga_s2.cpp
+++ b/engines/agos/vga_s2.cpp
@@ -194,7 +194,7 @@ void AGOSEngine::vc72_segue() {
int16 loop = vcReadNextWord();
if (track == -1 || track == 999) {
- _midi.stop();
+ stopMusic();
} else {
_midi.setLoop(loop != 0);
_midi.startTrack(track);