[Scummvm-cvs-logs] CVS: scummvm/simon sound.cpp,1.8,1.9 sound.h,1.2,1.3
Oliver Kiehl
olki at users.sourceforge.net
Sat Jan 11 08:01:08 CET 2003
Update of /cvsroot/scummvm/scummvm/simon
In directory sc8-pr-cvs1:/tmp/cvs-serv21316
Modified Files:
sound.cpp sound.h
Log Message:
added voice support for simon 2 mac and simon 3 amiga
Index: sound.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/simon/sound.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- sound.cpp 17 Dec 2002 01:06:04 -0000 1.8
+++ sound.cpp 11 Jan 2003 16:00:54 -0000 1.9
@@ -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 @@
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);
- }
- } 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);
+ 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);
+ }
}
- }
#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::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;
@@ -225,6 +249,13 @@
/* only needed for mp3 */
_file->seek(0, SEEK_END);
_offsets[res] = _file->pos();
+}
+
+SimonSound::Sound::Sound(SoundMixer *mixer, File *file, uint32 *offsets)
+{
+ _mixer = mixer;
+ _file = file;
+ _offsets = offsets;
}
#if !defined(__GNUC__)
Index: sound.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/simon/sound.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- sound.h 7 Dec 2002 17:35:34 -0000 1.2
+++ sound.h 11 Jan 2003 16:00:55 -0000 1.3
@@ -30,12 +30,14 @@
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 @@
};
byte _game;
+ const char *_gameDataPath;
+
int _voice_index;
int _ambient_index;
SoundMixer *_mixer;
@@ -61,6 +65,9 @@
bool _effects_paused;
bool _ambient_paused;
+
+ uint16 *_filenums;
+ uint32 *_offsets;
public:
PlayingSoundHandle _voice_handle;
More information about the Scummvm-git-logs
mailing list