aboutsummaryrefslogtreecommitdiff
path: root/simon
diff options
context:
space:
mode:
authorOliver Kiehl2003-01-11 16:00:55 +0000
committerOliver Kiehl2003-01-11 16:00:55 +0000
commit237783a24dff7e9089826eeec9971280497eae28 (patch)
tree22c476e41980cc0f598feb5a383345dc4746ad28 /simon
parent2636e2806acc5b8a6c96c44b786c9c3e9136741a (diff)
downloadscummvm-rg350-237783a24dff7e9089826eeec9971280497eae28.tar.gz
scummvm-rg350-237783a24dff7e9089826eeec9971280497eae28.tar.bz2
scummvm-rg350-237783a24dff7e9089826eeec9971280497eae28.zip
added voice support for simon 2 mac and simon 3 amiga
svn-id: r6398
Diffstat (limited to 'simon')
-rw-r--r--simon/sound.cpp97
-rw-r--r--simon/sound.h7
2 files changed, 71 insertions, 33 deletions
diff --git a/simon/sound.cpp b/simon/sound.cpp
index 853a9b93d2..5e90ece0d9 100644
--- a/simon/sound.cpp
+++ b/simon/sound.cpp
@@ -25,6 +25,7 @@
SimonSound::SimonSound(const byte game, const GameSpecificSettings *gss, const char *gameDataPath, SoundMixer *mixer)
{
_game = game;
+ _gameDataPath = gameDataPath;
_mixer = mixer;
_effects_paused = false;
@@ -40,50 +41,65 @@ SimonSound::SimonSound(const byte game, const GameSpecificSettings *gss, const c
File *file2 = new File();
const char *s;
+ // for simon2 mac/amiga, only read index file
+ if (_game == GAME_SIMON2MAC) {
+ file->open("voices.idx", gameDataPath);
+ file->seek(0, SEEK_END);
+ int end = file->pos();
+ file->seek(0, SEEK_SET);
+ _filenums = (uint16 *)malloc(end / 3 + 1);
+ _offsets = (uint32 *)malloc((end / 6) * 4 + 1);
+
+ for (int i = 1; i <= end / 6; i++) {
+ _filenums[i] = file->readUint16BE();
+ _offsets[i] = file->readUint32BE();
+ }
+ } else {
#ifdef USE_MAD
- file->open(gss->mp3_filename, gameDataPath);
- if (file->isOpen() == false) {
+ file->open(gss->mp3_filename, gameDataPath);
+ if (file->isOpen() == false) {
#endif
- if (_game & GAME_WIN) {
- s = gss->wav_filename;
- file->open(s, gameDataPath);
- if (file->isOpen() == false) {
- warning("Cannot open voice file %s", s);
- } else {
- _voice = new WavSound(_mixer, file);
+ if (_game & GAME_WIN) {
+ s = gss->wav_filename;
+ file->open(s, gameDataPath);
+ if (file->isOpen() == false) {
+ warning("Cannot open voice file %s", s);
+ } else {
+ _voice = new WavSound(_mixer, file);
+ }
+ } else if (_game & GAME_TALKIE) {
+ s = gss->voc_filename;
+ file->open(s, gameDataPath);
+ if (file->isOpen() == false) {
+ warning("Cannot open voice file %s", s);
+ } else {
+ _voice = new VocSound(_mixer, file);
+ }
}
- } else if (_game & GAME_TALKIE) {
- s = gss->voc_filename;
- file->open(s, gameDataPath);
- if (file->isOpen() == false) {
- warning("Cannot open voice file %s", s);
- } else {
- _voice = new VocSound(_mixer, file);
- }
- }
#ifdef USE_MAD
- } else {
- _voice = new MP3Sound(_mixer, file);
- }
+ } else {
+ _voice = new MP3Sound(_mixer, file);
+ }
#endif
- if (_game == GAME_SIMON1TALKIE) {
+ if (_game == GAME_SIMON1TALKIE) {
#ifdef USE_MAD
- file2->open(gss->mp3_effects_filename, gameDataPath);
- if (file2->isOpen() == false) {
-#endif
- s = gss->voc_effects_filename;
- file2->open(s, gameDataPath);
+ file2->open(gss->mp3_effects_filename, gameDataPath);
if (file2->isOpen() == false) {
- warning("Cannot open effects file %s", s);
+#endif
+ s = gss->voc_effects_filename;
+ file2->open(s, gameDataPath);
+ if (file2->isOpen() == false) {
+ warning("Cannot open effects file %s", s);
+ } else {
+ _effects = new VocSound(_mixer, file2);
+ }
+#ifdef USE_MAD
} else {
- _effects = new VocSound(_mixer, file2);
+ _effects = new MP3Sound(_mixer, file2);
}
-#ifdef USE_MAD
- } else {
- _effects = new MP3Sound(_mixer, file2);
- }
#endif
+ }
}
}
@@ -123,6 +139,14 @@ void SimonSound::loadSfxTable(File *gameFile, uint32 base)
void SimonSound::playVoice(uint sound)
{
+ if (_game == GAME_SIMON2MAC) {
+ char filename[16];
+ sprintf(filename, "voices%d.dat", _filenums[sound]);
+ File *file = new File();
+ file->open(filename, _gameDataPath);
+ _voice = new WavSound(_mixer, file, _offsets);
+ }
+
if (!_voice)
return;
@@ -227,6 +251,13 @@ SimonSound::Sound::Sound(SoundMixer *mixer, File *file, uint32 base)
_offsets[res] = _file->pos();
}
+SimonSound::Sound::Sound(SoundMixer *mixer, File *file, uint32 *offsets)
+{
+ _mixer = mixer;
+ _file = file;
+ _offsets = offsets;
+}
+
#if !defined(__GNUC__)
#pragma START_PACK_STRUCTS
#endif
diff --git a/simon/sound.h b/simon/sound.h
index 3ad0564528..58408b2864 100644
--- a/simon/sound.h
+++ b/simon/sound.h
@@ -30,12 +30,14 @@ private:
public:
Sound(SoundMixer *mixer, File *file, uint32 base = 0);
+ Sound(SoundMixer *mixer, File *file, uint32 *offsets);
virtual int playSound(uint sound, PlayingSoundHandle *handle, byte flags = 0) = 0;
};
class WavSound : public Sound {
public:
WavSound(SoundMixer *mixer, File *file, uint32 base = 0) : Sound(mixer, file, base) {};
+ WavSound(SoundMixer *mixer, File *file, uint32 *offsets) : Sound(mixer, file, offsets) {};
int playSound(uint sound, PlayingSoundHandle *handle, byte flags = 0);
};
@@ -52,6 +54,8 @@ private:
};
byte _game;
+ const char *_gameDataPath;
+
int _voice_index;
int _ambient_index;
SoundMixer *_mixer;
@@ -62,6 +66,9 @@ private:
bool _effects_paused;
bool _ambient_paused;
+ uint16 *_filenums;
+ uint32 *_offsets;
+
public:
PlayingSoundHandle _voice_handle;
PlayingSoundHandle _effects_handle;