[Scummvm-cvs-logs] CVS: scummvm/scumm script_v6.cpp,1.293.2.23,1.293.2.24 script_v6he.cpp,2.15.2.8,2.15.2.9 sound.cpp,1.320.2.9,1.320.2.10 sound.h,1.62.2.2,1.62.2.3
Travis Howell
kirben at users.sourceforge.net
Fri Aug 13 02:38:26 CEST 2004
Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21856/scumm
Modified Files:
Tag: branch-0-6-0
script_v6.cpp script_v6he.cpp sound.cpp sound.h
Log Message:
Back port:
Sound offset support in HE games
Music fix for 3DO HE games
Clear sound vars on startup
Index: script_v6.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v6.cpp,v
retrieving revision 1.293.2.23
retrieving revision 1.293.2.24
diff -u -d -r1.293.2.23 -r1.293.2.24
--- script_v6.cpp 13 Aug 2004 09:11:10 -0000 1.293.2.23
+++ script_v6.cpp 13 Aug 2004 09:37:35 -0000 1.293.2.24
@@ -1081,8 +1081,8 @@
void ScummEngine_v6::o6_startMusic() {
if (_features & GF_DIGI_IMUSE)
error("o6_startMusic() It shouldn't be called here for imuse digital");
- else
- _sound->addSoundToQueue(pop());
+
+ _sound->addSoundToQueue(pop());
}
void ScummEngine_v6::o6_stopObjectScript() {
Index: script_v6he.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v6he.cpp,v
retrieving revision 2.15.2.8
retrieving revision 2.15.2.9
diff -u -d -r2.15.2.8 -r2.15.2.9
--- script_v6he.cpp 13 Aug 2004 09:10:20 -0000 2.15.2.8
+++ script_v6he.cpp 13 Aug 2004 09:37:35 -0000 2.15.2.9
@@ -397,13 +397,15 @@
}
void ScummEngine_v6he::o6_startSound() {
- if (_gameId != GID_PUTTDEMO) {
- // Seems to range between 952 - 9000
- int offset = pop();
- debug(2, "o6_startSound: offset %d", offset);
- }
+ int offset = 0;
- _sound->addSoundToQueue(pop());
+ // In Fatty Bear's Birthday Surprise the piano uses offsets 1 - 23 to
+ // indicate which note to play, but only when using the standard piano
+ // sound. See also o6_soundOps()
+ if (_gameId != GID_PUTTDEMO)
+ offset = pop();
+
+ _sound->addSoundToQueue(pop(), offset);
}
void ScummEngine_v6he::o6_roomOps() {
Index: sound.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/sound.cpp,v
retrieving revision 1.320.2.9
retrieving revision 1.320.2.10
diff -u -d -r1.320.2.9 -r1.320.2.10
--- sound.cpp 13 Aug 2004 02:43:04 -0000 1.320.2.9
+++ sound.cpp 13 Aug 2004 09:37:35 -0000 1.320.2.10
@@ -49,14 +49,31 @@
};
-Sound::Sound(ScummEngine *parent) {
- memset(this,0,sizeof(Sound)); // palmos
+Sound::Sound(ScummEngine *parent)
+ :
+ _vm(parent),
+ _soundQuePos(0),
+ _soundQue2Pos(0),
+ _sfxFile(0),
+ _talk_sound_a1(0),
+ _talk_sound_a2(0),
+ _talk_sound_b1(0),
+ _talk_sound_b2(0),
+ _talk_sound_mode(0),
+ _talk_sound_channel(0),
+ _mouthSyncMode(false),
+ _endOfMouthSync(false),
+ _curSoundPos(0),
+ _overrideFreq(0),
+ _currentCDSound(0),
+ _currentMusic(0),
+ _soundsPaused(false),
+ _sfxMode(0) {
- _vm = parent;
- _overrideFreq = 0;
- _currentCDSound = 0;
-
- _sfxFile = 0;
+ memset(_soundQue, 0, sizeof(_soundQue));
+ memset(_soundQue2Sound, 0, sizeof(_soundQue2Sound));
+ memset(_soundQue2Offset, 0, sizeof(_soundQue2Offset));
+ memset(_mouthSyncTimes, 0, sizeof(_mouthSyncTimes));
}
Sound::~Sound() {
@@ -64,27 +81,29 @@
delete _sfxFile;
}
-void Sound::addSoundToQueue(int sound) {
+void Sound::addSoundToQueue(int sound, int offset) {
_vm->VAR(_vm->VAR_LAST_SOUND) = sound;
_vm->ensureResourceLoaded(rtSound, sound);
- addSoundToQueue2(sound);
+ addSoundToQueue2(sound, offset);
}
-void Sound::addSoundToQueue2(int sound) {
+void Sound::addSoundToQueue2(int sound, int offset) {
if ((_vm->_features & GF_HUMONGOUS) && _soundQue2Pos) {
int i = _soundQue2Pos;
while (i--) {
- if (_soundQue2[i] == sound)
+ if (_soundQue2Sound[i] == sound)
return;
}
}
- assert(_soundQue2Pos < ARRAYSIZE(_soundQue2));
- _soundQue2[_soundQue2Pos++] = sound;
+ assert(_soundQue2Pos < ARRAYSIZE(_soundQue2Sound));
+ _soundQue2Sound[_soundQue2Pos] = sound;
+ _soundQue2Offset[_soundQue2Pos] = offset;
+ _soundQue2Pos++;
}
void Sound::processSoundQues() {
- int i = 0, d, num;
+ int i = 0, num, offset, snd;
int data[16];
processSfxQueues();
@@ -93,9 +112,11 @@
return;
while (_soundQue2Pos) {
- d = _soundQue2[--_soundQue2Pos];
- if (d)
- playSound(d);
+ _soundQue2Pos--;
+ snd = _soundQue2Sound[_soundQue2Pos];
+ offset = _soundQue2Offset[_soundQue2Pos];
+ if (snd)
+ playSound(snd, offset);
}
while (i < _soundQuePos) {
@@ -126,7 +147,7 @@
_overrideFreq = freq;
}
-void Sound::playSound(int soundID) {
+void Sound::playSound(int soundID, int offset) {
byte *ptr;
char *sound;
int size;
@@ -168,7 +189,7 @@
if (READ_UINT32(ptr) != MKID('SDAT'))
return; // abort
- size = READ_BE_UINT32(ptr+4) - 8;
+ size = READ_BE_UINT32(ptr+4) - offset - 8;
if (_overrideFreq) {
// Used by the piano in Fatty Bear's Birthday Surprise
rate = _overrideFreq;
@@ -177,12 +198,11 @@
// Allocate a sound buffer, copy the data into it, and play
sound = (char *)malloc(size);
- memcpy(sound, ptr + 8, size);
+ memcpy(sound, ptr + offset + 8, size);
_vm->_mixer->playRaw(NULL, sound, size, rate, flags, soundID);
}
else if (READ_UINT32(ptr) == MKID('MRAW')) {
// pcm music in 3DO humongous games
- // TODO play via imuse so isSoundRunning can properly report music value?
ptr += 8 + READ_BE_UINT32(ptr+12);
if (READ_UINT32(ptr) != MKID('SDAT'))
return;
@@ -194,7 +214,9 @@
// Allocate a sound buffer, copy the data into it, and play
sound = (char *)malloc(size);
memcpy(sound, ptr + 8, size);
- _vm->_mixer->playRaw(NULL, sound, size, rate, flags, soundID);
+ _currentMusic = soundID;
+ _vm->_mixer->stopHandle(_musicChannelHandle);
+ _vm->_mixer->playRaw(&_musicChannelHandle, sound, size, rate, flags, soundID);
}
// Support for sampled sound effects in Monkey Island 1 and 2
else if (READ_UINT32(ptr) == MKID('SBL ')) {
@@ -643,11 +665,14 @@
if (_vm->_features & GF_HUMONGOUS) {
if (sound == -2) {
return !isSfxFinished();
- } else if (sound == -1) {
+ } else if (sound == -1 || sound == _currentMusic) {
// getSoundStatus(), with a -1, will return the
// ID number of the first active music it finds.
// TODO handle MRAW (pcm music) in humongous games
- return _vm->_imuse->getSoundStatus(sound);
+ if (_currentMusic)
+ return (_musicChannelHandle.isActive()) ? _currentMusic : 0;
+ else
+ return _vm->_imuse->getSoundStatus(sound);
}
}
@@ -699,7 +724,7 @@
i = _soundQue2Pos;
while (i--) {
- if (_soundQue2[i] == sound)
+ if (_soundQue2Sound[i] == sound)
return true;
}
@@ -724,7 +749,10 @@
// Stop current sfx
} else if (a == -1) {
// Stop current music
- _vm->_imuse->stopSound(_vm->_imuse->getSoundStatus(-1));
+ if (_currentMusic)
+ _vm->_mixer->stopID(_currentMusic);
+ else
+ _vm->_imuse->stopSound(_vm->_imuse->getSoundStatus(-1));
}
}
@@ -740,9 +768,12 @@
if (_vm->_musicEngine)
_vm->_musicEngine->stopSound(a);
- for (i = 0; i < ARRAYSIZE(_soundQue2); i++)
- if (_soundQue2[i] == a)
- _soundQue2[i] = 0;
+ for (i = 0; i < ARRAYSIZE(_soundQue2Sound); i++) {
+ if (_soundQue2Sound[i] == a) {
+ _soundQue2Sound[i] = 0;
+ _soundQue2Offset[i] = 0;
+ }
+ }
}
void Sound::stopAllSounds() {
@@ -754,7 +785,8 @@
// Clear the (secondary) sound queue
_soundQue2Pos = 0;
- memset(_soundQue2, 0, sizeof(_soundQue2));
+ memset(_soundQue2Sound, 0, sizeof(_soundQue2Sound));
+ memset(_soundQue2Offset, 0, sizeof(_soundQue2Offset));
if (_vm->_musicEngine) {
_vm->_musicEngine->stopAllSounds();
Index: sound.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/sound.h,v
retrieving revision 1.62.2.2
retrieving revision 1.62.2.3
diff -u -d -r1.62.2.2 -r1.62.2.3
--- sound.h 13 Aug 2004 02:43:05 -0000 1.62.2.2
+++ sound.h 13 Aug 2004 09:37:35 -0000 1.62.2.3
@@ -39,7 +39,7 @@
class Sound {
protected:
int16 _soundQuePos, _soundQue[0x100];
- int16 _soundQue2Pos, _soundQue2[10];
+ int16 _soundQue2Pos, _soundQue2Sound[10], _soundQue2Offset[10];
File *_sfxFile;
uint32 _talk_sound_a1, _talk_sound_a2, _talk_sound_b1, _talk_sound_b2;
@@ -57,22 +57,24 @@
int _overrideFreq;
int _currentCDSound;
+ int _currentMusic;
ScummEngine *_vm;
public:
PlayingSoundHandle _talkChannelHandle; // Handle of mixer channel actor is talking on
+ PlayingSoundHandle _musicChannelHandle; // Handle of mixer channel music is on
bool _soundsPaused;
byte _sfxMode;
public:
Sound(ScummEngine *parent);
~Sound();
- void addSoundToQueue(int sound);
- void addSoundToQueue2(int sound);
+ void addSoundToQueue(int sound, int offset = 0);
+ void addSoundToQueue2(int sound, int offset = 0);
void processSoundQues();
void setOverrideFreq(int freq);
- void playSound(int sound);
+ void playSound(int sound, int offset = 0);
void startTalkSound(uint32 offset, uint32 b, int mode, PlayingSoundHandle *handle = NULL);
void stopTalkSound();
bool isMouthSyncOff(uint pos);
More information about the Scummvm-git-logs
mailing list