[Scummvm-cvs-logs] CVS: scummvm/simon simon.cpp,1.73,1.74 simon.h,1.13,1.14 vga.cpp,1.5,1.6 items.cpp,1.16,1.17
Oliver Kiehl
olki at users.sourceforge.net
Wed Nov 13 08:35:27 CET 2002
Update of /cvsroot/scummvm/scummvm/simon
In directory usw-pr-cvs1:/tmp/cvs-serv3641
Modified Files:
simon.cpp simon.h vga.cpp items.cpp
Log Message:
fixed looping problem, removed useless code and renamed playSound to playEffects
Index: simon.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/simon/simon.cpp,v
retrieving revision 1.73
retrieving revision 1.74
diff -u -d -r1.73 -r1.74
--- simon.cpp 13 Nov 2002 13:42:16 -0000 1.73
+++ simon.cpp 13 Nov 2002 16:34:22 -0000 1.74
@@ -4849,7 +4849,7 @@
#ifdef USE_MAD
-void SimonState::playMP3(File *sound_file, uint32 *offsets, uint sound, PlayingSoundHandle *sound_handle, byte flags)
+int SimonState::playMP3(File *sound_file, uint32 *offsets, uint sound, PlayingSoundHandle *sound_handle, byte flags)
{
sound_file->seek(offsets[sound], SEEK_SET);
@@ -4858,11 +4858,11 @@
byte *buffer = (byte *)malloc(size);
sound_file->read(buffer, size);
- _mixer->playMP3(sound_handle, buffer, size, flags);
+ return _mixer->playMP3(sound_handle, buffer, size, flags);
}
#endif
-void SimonState::playVoc(File *sound_file, uint32 *offsets, uint sound, PlayingSoundHandle *sound_handle, byte flags)
+int SimonState::playVoc(File *sound_file, uint32 *offsets, uint sound, PlayingSoundHandle *sound_handle, byte flags)
{
VocHeader voc_hdr;
VocBlockHeader voc_block_hdr;
@@ -4872,8 +4872,7 @@
if (sound_file->read(&voc_hdr, sizeof(voc_hdr)) != sizeof(voc_hdr) ||
strncmp((char *)voc_hdr.desc, "Creative Voice File\x1A", 10) != 0) {
- warning("playVoc(%d): cannot read voc header", sound);
- return;
+ error("playVoc(%d): cannot read voc header", sound);
}
sound_file->read(&voc_block_hdr, sizeof(voc_block_hdr));
@@ -4894,10 +4893,10 @@
byte *buffer = (byte *)malloc(size);
sound_file->read(buffer, size);
- _mixer->playRaw(sound_handle, buffer, size, samples_per_sec, flags);
+ return _mixer->playRaw(sound_handle, buffer, size, samples_per_sec, flags);
}
-void SimonState::playWav(File *sound_file, uint32 *offsets, uint sound, PlayingSoundHandle *sound_handle, byte flags)
+int SimonState::playWav(File *sound_file, uint32 *offsets, uint sound, PlayingSoundHandle *sound_handle, byte flags)
{
WaveHeader wave_hdr;
uint32 data[2];
@@ -4909,8 +4908,7 @@
|| wave_hdr.fmt != MKID('fmt ') || READ_LE_UINT16(&wave_hdr.format_tag) != 1
|| READ_LE_UINT16(&wave_hdr.channels) != 1
|| READ_LE_UINT16(&wave_hdr.bits_per_sample) != 8) {
- warning("playWav(%d): cannot read RIFF header", sound);
- return;
+ error("playWav(%d): cannot read RIFF header", sound);
}
sound_file->seek(FROM_LE_32(wave_hdr.size) - sizeof(wave_hdr) + 20, SEEK_CUR);
@@ -4919,14 +4917,13 @@
data[1] = sound_file->readUint32LE();
if ( //fread(data, sizeof(data), 1, sound_file) != 1 ||
data[0] != 'atad') {
- warning("playWav(%d): cannot read data header", sound);
- return;
+ error("playWav(%d): cannot read data header", sound);
}
byte *buffer = (byte *)malloc(data[1]);
sound_file->read(buffer, data[1]);
- _mixer->playRaw(sound_handle, buffer, data[1], FROM_LE_32(wave_hdr.samples_per_sec), flags);
+ return _mixer->playRaw(sound_handle, buffer, data[1], FROM_LE_32(wave_hdr.samples_per_sec), flags);
}
void SimonState::playVoice(uint voice)
@@ -4934,9 +4931,6 @@
if (_voice_offsets == NULL)
return;
- if (_voice_sound != 0)
- _mixer->stop(_voice_sound);
-
#ifdef USE_MAD
if (_voice_type == FORMAT_MP3) {
playMP3(_voice_file, _voice_offsets, voice, &_voice_sound, SoundMixer::FLAG_AUTOFREE);
@@ -4952,10 +4946,10 @@
#endif
}
-void SimonState::playSound(uint sound)
+void SimonState::playEffects(uint sound)
{
- if (_effects_sound != 0)
- _mixer->stop(_effects_sound);
+ if (_effects_offsets == NULL)
+ return;
if (_game == GAME_SIMON1TALKIE) { /* simon 1 talkie */
#ifdef USE_MAD
@@ -4974,20 +4968,28 @@
} else if (_game & GAME_SIMON2) { /* simon 2 dos / talkie */
playVoc(_game_file, _effects_offsets, sound, &_effects_sound, SoundMixer::FLAG_UNSIGNED|SoundMixer::FLAG_AUTOFREE);
} else { /* simon 1 dos */
- warning("playSound(%d)", sound);
+ warning("playEffects(%d)", sound);
}
}
void SimonState::playAmbient(uint sound)
{
- if (_effects_sound != 0)
- _mixer->stop(_ambient_sound);
+ if (_effects_offsets == NULL)
+ return;
+
+ if (sound == _ambient_playing)
+ return;
+
+ _ambient_playing = sound;
+
+ if (_ambient_sound)
+ _mixer->stop(_ambient_index);
if (_game & GAME_WIN) {
- playWav(_game_file, _effects_offsets, sound, &_ambient_sound,
+ _ambient_index = playWav(_game_file, _effects_offsets, sound, &_ambient_sound,
SoundMixer::FLAG_LOOP|SoundMixer::FLAG_UNSIGNED|SoundMixer::FLAG_AUTOFREE);
} else {
- playVoc(_game_file, _effects_offsets, sound, &_ambient_sound,
+ _ambient_index = playVoc(_game_file, _effects_offsets, sound, &_ambient_sound,
SoundMixer::FLAG_LOOP|SoundMixer::FLAG_UNSIGNED|SoundMixer::FLAG_AUTOFREE);
}
}
Index: simon.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/simon/simon.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- simon.h 10 Nov 2002 16:25:03 -0000 1.13
+++ simon.h 13 Nov 2002 16:34:22 -0000 1.14
@@ -338,6 +338,8 @@
PlayingSoundHandle _effects_sound;
PlayingSoundHandle _voice_sound;
PlayingSoundHandle _ambient_sound;
+ int _ambient_index;
+ uint _ambient_playing;
int _timer_id;
@@ -775,12 +777,12 @@
void initSound();
void playVoice(uint voice);
- void playSound(uint sound);
+ void playEffects(uint sound);
void playAmbient(uint sound);
- void playVoc(File *sound_file, uint32 *offsets, uint sound, PlayingSoundHandle *sound_handle, byte flags);
- void playWav(File *sound_file, uint32 *offsets, uint sound, PlayingSoundHandle *sound_handle, byte flags);
- void playMP3(File *sound_file, uint32 *offsets, uint sound, PlayingSoundHandle *sound_handle, byte flags);
+ int playVoc(File *sound_file, uint32 *offsets, uint sound, PlayingSoundHandle *sound_handle, byte flags);
+ int playWav(File *sound_file, uint32 *offsets, uint sound, PlayingSoundHandle *sound_handle, byte flags);
+ int playMP3(File *sound_file, uint32 *offsets, uint sound, PlayingSoundHandle *sound_handle, byte flags);
void playMusic(uint music);
void checkTimerCallback();
Index: vga.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/simon/vga.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- vga.cpp 10 Nov 2002 16:28:18 -0000 1.5
+++ vga.cpp 13 Nov 2002 16:34:22 -0000 1.6
@@ -1604,13 +1604,13 @@
uint16 a = vc_read_next_word();
if (!(_game & GAME_SIMON2)) {
- playSound(a);
+ playEffects(a);
} else {
if (a >= 0x8000) {
a = -a;
playAmbient(a);
} else {
- playSound(a);
+ playEffects(a);
}
}
}
Index: items.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/simon/items.cpp,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- items.cpp 13 Nov 2002 06:02:50 -0000 1.16
+++ items.cpp 13 Nov 2002 16:34:22 -0000 1.17
@@ -1644,7 +1644,7 @@
void SimonState::o_unk_163(uint a)
{
- playSound(a);
+ playEffects(a);
}
void SimonState::o_unk_160(uint a)
More information about the Scummvm-git-logs
mailing list