aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--scumm/script_v6.cpp28
-rw-r--r--scumm/script_v7he.cpp2
-rw-r--r--scumm/sound.cpp47
-rw-r--r--scumm/sound.h8
4 files changed, 47 insertions, 38 deletions
diff --git a/scumm/script_v6.cpp b/scumm/script_v6.cpp
index f71083d565..19adb9013c 100644
--- a/scumm/script_v6.cpp
+++ b/scumm/script_v6.cpp
@@ -1024,19 +1024,19 @@ void ScummEngine_v6::o6_getOwner() {
}
void ScummEngine_v6::o6_startSound() {
+ int offset = 0;
+ int snd = 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 ((_features & GF_HUMONGOUS) && (_gameId != GID_PUTTDEMO))
+ offset = pop();
+
if (_features & GF_DIGI_IMUSE)
- _imuseDigital->startSfx(pop(), 64);
- else {
- if ((_features & GF_HUMONGOUS) && (_gameId != GID_PUTTDEMO)) {
- // Seems to range between 952 - 9000
- // 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().
- int offset = pop();
- debug(2, "o6_startSound: offset %d", offset);
- }
- _sound->addSoundToQueue(pop());
- }
+ _imuseDigital->startSfx(snd, 64);
+ else
+ _sound->addSoundToQueue(snd, offset);
}
void ScummEngine_v6::o6_stopSound() {
@@ -1046,8 +1046,8 @@ void ScummEngine_v6::o6_stopSound() {
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() {
diff --git a/scumm/script_v7he.cpp b/scumm/script_v7he.cpp
index 549291b587..ec9fb043e9 100644
--- a/scumm/script_v7he.cpp
+++ b/scumm/script_v7he.cpp
@@ -686,7 +686,7 @@ void ScummEngine_v7he::o7_startSound() {
case 255:
// _sound->addSoundToQueue(_heSndSoundId, _heSndOffset, _heSndTimer, _heSndLoop);
- _sound->addSoundToQueue(_heSndSoundId);
+ _sound->addSoundToQueue(_heSndSoundId, _heSndOffset);
debug(2, "o7_startSound stub (%d, %d, %d, %d)", _heSndSoundId, _heSndOffset, _heSndTimer, _heSndLoop);
_heSndLoop = 0;
break;
diff --git a/scumm/sound.cpp b/scumm/sound.cpp
index 8a4f58d511..2be3532c37 100644
--- a/scumm/sound.cpp
+++ b/scumm/sound.cpp
@@ -75,7 +75,8 @@ Sound::Sound(ScummEngine *parent)
_sfxMode(0) {
memset(_soundQue, 0, sizeof(_soundQue));
- memset(_soundQue2, 0, sizeof(_soundQue2));
+ memset(_soundQue2Sound, 0, sizeof(_soundQue2Sound));
+ memset(_soundQue2Offset, 0, sizeof(_soundQue2Offset));
memset(_mouthSyncTimes, 0, sizeof(_mouthSyncTimes));
}
@@ -84,29 +85,31 @@ Sound::~Sound() {
delete _sfxFile;
}
-void Sound::addSoundToQueue(int sound) {
+void Sound::addSoundToQueue(int sound, int offset) {
_vm->VAR(_vm->VAR_LAST_SOUND) = sound;
// Music resources are in separate file
if (!((_vm->_heversion >= 70) && sound >= 4000))
_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();
@@ -115,9 +118,11 @@ void Sound::processSoundQues() {
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) {
@@ -148,7 +153,7 @@ void Sound::setOverrideFreq(int freq) {
_overrideFreq = freq;
}
-void Sound::playSound(int soundID) {
+void Sound::playSound(int soundID, int offset) {
byte *ptr;
char *sound;
int size = -1;
@@ -235,7 +240,7 @@ void Sound::playSound(int soundID) {
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;
@@ -244,7 +249,7 @@ void Sound::playSound(int soundID) {
// 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')) {
@@ -769,7 +774,7 @@ bool Sound::isSoundInQueue(int sound) const {
i = _soundQue2Pos;
while (i--) {
- if (_soundQue2[i] == sound)
+ if (_soundQue2Sound[i] == sound)
return true;
}
@@ -813,9 +818,12 @@ void Sound::stopSound(int a) {
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() {
@@ -827,7 +835,8 @@ void Sound::stopAllSounds() {
// 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();
diff --git a/scumm/sound.h b/scumm/sound.h
index f2d1cde327..71bd62c4a2 100644
--- a/scumm/sound.h
+++ b/scumm/sound.h
@@ -55,7 +55,7 @@ protected:
ScummEngine *_vm;
int16 _soundQuePos, _soundQue[0x100];
- int16 _soundQue2Pos, _soundQue2[10];
+ int16 _soundQue2Pos, _soundQue2Sound[10], _soundQue2Offset[10];
File *_sfxFile;
SoundMode _soundMode;
@@ -84,11 +84,11 @@ public:
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);