[Scummvm-cvs-logs] scummvm master -> 892710a0a3610d21f7a716f9c48ca8a7702f999c
lordhoto
lordhoto at gmail.com
Sat Sep 8 01:21:23 CEST 2012
This automated email contains information about 6 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
b1074543b5 CINE: Skip resource header in loadSpl.
c850effc6d CINE: Implement sfx repeat and volume fade for FW Amiga/AtariST.
0fe5e0e6bd CINE: Fix Paula frequency.
35e61b7c7a CINE: Remove unused Sound::update method.
b48f5b78b7 CINE: Implement panning for sfx for FW Amiga and AtariST.
892710a0a3 CINE: Fix sfx channel use in Amiga and AtariST versions of FW.
Commit: b1074543b575bdca64b228272f2dfddda2e98cff
https://github.com/scummvm/scummvm/commit/b1074543b575bdca64b228272f2dfddda2e98cff
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2012-09-07T16:15:32-07:00
Commit Message:
CINE: Skip resource header in loadSpl.
This implements a long standing TODO in PaulaSound::playSound.
Changed paths:
engines/cine/anim.cpp
engines/cine/script_fw.cpp
engines/cine/sound.cpp
engines/cine/sound.h
diff --git a/engines/cine/anim.cpp b/engines/cine/anim.cpp
index 9b21036..075a59c 100644
--- a/engines/cine/anim.cpp
+++ b/engines/cine/anim.cpp
@@ -535,7 +535,7 @@ int loadSpl(const char *resourceName, int16 idx) {
entry = idx < 0 ? emptyAnimSpace() : idx;
assert(entry >= 0);
- g_cine->_animDataTable[entry].load(dataPtr, ANIM_RAW, g_cine->_partBuffer[foundFileIdx].unpackedSize, 1, foundFileIdx, 0, currentPartName);
+ g_cine->_animDataTable[entry].load(dataPtr + 0x16, ANIM_RAW, g_cine->_partBuffer[foundFileIdx].unpackedSize - 0x16, 1, foundFileIdx, 0, currentPartName);
free(dataPtr);
return entry + 1;
diff --git a/engines/cine/script_fw.cpp b/engines/cine/script_fw.cpp
index 885a43f..a4e7314 100644
--- a/engines/cine/script_fw.cpp
+++ b/engines/cine/script_fw.cpp
@@ -1818,6 +1818,9 @@ int FWScript::o1_playSample() {
if (g_cine->getPlatform() == Common::kPlatformAmiga || g_cine->getPlatform() == Common::kPlatformAtariST) {
if (size == 0xFFFF) {
size = g_cine->_animDataTable[anim]._width * g_cine->_animDataTable[anim]._height;
+ } else if (size > g_cine->_animDataTable[anim]._width * g_cine->_animDataTable[anim]._height) {
+ warning("o1_playSample: Got invalid sample size %d for sample %d", size, anim);
+ size = g_cine->_animDataTable[anim]._width * g_cine->_animDataTable[anim]._height;
}
if (channel < 10) { // || _currentOpcode == 0x78
int channel1, channel2;
diff --git a/engines/cine/sound.cpp b/engines/cine/sound.cpp
index b92c537..6cf3d9b 100644
--- a/engines/cine/sound.cpp
+++ b/engines/cine/sound.cpp
@@ -1052,12 +1052,10 @@ void PaulaSound::playSound(int channel, int frequency, const uint8 *data, int si
// TODO: handle volume slides and repeat
debugC(5, kCineDebugSound, "PaulaSound::playSound() channel %d size %d", channel, size);
stopSound(channel);
- size = MIN<int>(size - SPL_HDR_SIZE, READ_BE_UINT16(data + 4));
- // TODO: consider skipping the header in loadSpl directly
if (size > 0) {
byte *sound = (byte *)malloc(size);
if (sound) {
- memcpy(sound, data + SPL_HDR_SIZE, size);
+ memcpy(sound, data, size);
playSoundChannel(channel, frequency, sound, size, volume);
}
}
diff --git a/engines/cine/sound.h b/engines/cine/sound.h
index afc0994..7caa41b 100644
--- a/engines/cine/sound.h
+++ b/engines/cine/sound.h
@@ -95,8 +95,7 @@ public:
enum {
PAULA_FREQ = 7093789,
- NUM_CHANNELS = 4,
- SPL_HDR_SIZE = 22
+ NUM_CHANNELS = 4
};
protected:
Commit: c850effc6d30cc8de9fcbdd8ac429b1d6da624e1
https://github.com/scummvm/scummvm/commit/c850effc6d30cc8de9fcbdd8ac429b1d6da624e1
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2012-09-07T16:16:07-07:00
Commit Message:
CINE: Implement sfx repeat and volume fade for FW Amiga/AtariST.
This fixes bug 3091660 "FW: Looping samples don't loop in Amiga version".
Changed paths:
engines/cine/sound.cpp
engines/cine/sound.h
diff --git a/engines/cine/sound.cpp b/engines/cine/sound.cpp
index 6cf3d9b..b66ce5a 100644
--- a/engines/cine/sound.cpp
+++ b/engines/cine/sound.cpp
@@ -998,11 +998,18 @@ void PCSound::stopSound(int channel) {
}
PaulaSound::PaulaSound(Audio::Mixer *mixer, CineEngine *vm)
- : Sound(mixer, vm) {
+ : Sound(mixer, vm), _sfxTimer(0) {
_moduleStream = 0;
+ // The original is using the following timer frequency:
+ // 0.709379Mhz / 8000 = 88.672375Hz
+ // 1000000 / 88.672375Hz = 11277.46944863us
+ g_system->getTimerManager()->installTimerProc(&PaulaSound::sfxTimerProc, 11277, this, "PaulaSound::sfxTimerProc");
}
PaulaSound::~PaulaSound() {
+ Common::StackLock lock(_mutex);
+
+ g_system->getTimerManager()->removeTimerProc(&PaulaSound::sfxTimerProc);
for (int i = 0; i < NUM_CHANNELS; ++i) {
stopSound(i);
}
@@ -1011,6 +1018,10 @@ PaulaSound::~PaulaSound() {
void PaulaSound::loadMusic(const char *name) {
debugC(5, kCineDebugSound, "PaulaSound::loadMusic('%s')", name);
+ for (int i = 0; i < NUM_CHANNELS; ++i) {
+ stopSound(i);
+ }
+
if (_vm->getGameType() == GType_FW) {
// look for separate files
Common::File f;
@@ -1049,21 +1060,38 @@ void PaulaSound::fadeOutMusic() {
}
void PaulaSound::playSound(int channel, int frequency, const uint8 *data, int size, int volumeStep, int stepCount, int volume, int repeat) {
- // TODO: handle volume slides and repeat
debugC(5, kCineDebugSound, "PaulaSound::playSound() channel %d size %d", channel, size);
+ Common::StackLock lock(_mutex);
+ assert(frequency > 0);
+
stopSound(channel);
if (size > 0) {
byte *sound = (byte *)malloc(size);
if (sound) {
+ // Create the audio stream
memcpy(sound, data, size);
- playSoundChannel(channel, frequency, sound, size, volume);
+
+ // Clear the first and last 16 bits like in the original.
+ sound[0] = sound[1] = sound[size - 2] = sound[size - 1] = 0;
+
+ Audio::SeekableAudioStream *stream = Audio::makeRawStream(sound, size, PAULA_FREQ / frequency, 0);
+
+ // Initialize the volume control
+ _channelsTable[channel].initialize(volume, volumeStep, stepCount);
+
+ // Start the sfx
+ _mixer->playStream(Audio::Mixer::kSFXSoundType, &_channelsTable[channel].handle,
+ Audio::makeLoopingAudioStream(stream, repeat ? 0 : 1),
+ -1, volume * Audio::Mixer::kMaxChannelVolume / 63);
}
}
}
void PaulaSound::stopSound(int channel) {
debugC(5, kCineDebugSound, "PaulaSound::stopSound() channel %d", channel);
- _mixer->stopHandle(_channelsTable[channel]);
+ Common::StackLock lock(_mutex);
+
+ _mixer->stopHandle(_channelsTable[channel].handle);
}
void PaulaSound::update() {
@@ -1071,12 +1099,42 @@ void PaulaSound::update() {
// TODO
}
-void PaulaSound::playSoundChannel(int channel, int frequency, uint8 *data, int size, int volume) {
- assert(frequency > 0);
- frequency = PAULA_FREQ / frequency;
- Audio::AudioStream *stream = Audio::makeRawStream(data, size, frequency, 0);
- _mixer->playStream(Audio::Mixer::kSFXSoundType, &_channelsTable[channel], stream);
- _mixer->setChannelVolume(_channelsTable[channel], volume * Audio::Mixer::kMaxChannelVolume / 63);
+void PaulaSound::sfxTimerProc(void *param) {
+ PaulaSound *sound = (PaulaSound *)param;
+ sound->sfxTimerCallback();
+}
+
+void PaulaSound::sfxTimerCallback() {
+ Common::StackLock lock(_mutex);
+
+ if (_sfxTimer < 6) {
+ ++_sfxTimer;
+
+ for (int i = 0; i < NUM_CHANNELS; ++i) {
+ // Only process active channels
+ if (!_mixer->isSoundHandleActive(_channelsTable[i].handle)) {
+ continue;
+ }
+
+ if (_channelsTable[i].curStep) {
+ --_channelsTable[i].curStep;
+ } else {
+ _channelsTable[i].curStep = _channelsTable[i].stepCount;
+ const int volume = CLIP(_channelsTable[i].volume + _channelsTable[i].volumeStep, 0, 63);
+ _channelsTable[i].volume = volume;
+ // Unlike the original we stop silent sounds
+ if (volume) {
+ _mixer->setChannelVolume(_channelsTable[i].handle, volume * Audio::Mixer::kMaxChannelVolume / 63);
+ } else {
+ _mixer->stopHandle(_channelsTable[i].handle);
+ }
+ }
+ }
+ } else {
+ _sfxTimer = 0;
+ // Possible TODO: The original only ever started sounds here. This
+ // should not be noticable though. So we do not do it for now.
+ }
}
} // End of namespace Cine
diff --git a/engines/cine/sound.h b/engines/cine/sound.h
index 7caa41b..61ebd45 100644
--- a/engines/cine/sound.h
+++ b/engines/cine/sound.h
@@ -24,6 +24,7 @@
#define CINE_SOUND_H_
#include "common/util.h"
+#include "common/mutex.h"
#include "audio/mixer.h"
namespace Audio {
@@ -99,10 +100,26 @@ public:
};
protected:
+ Common::Mutex _mutex;
+
+ struct SfxChannel {
+ Audio::SoundHandle handle;
+ int volume;
+ int volumeStep;
+ int curStep;
+ int stepCount;
+
+ void initialize(int vol, int volStep, int stepCnt) {
+ volume = vol;
+ volumeStep = volStep;
+ curStep = stepCount = stepCnt;
+ }
+ };
+ SfxChannel _channelsTable[NUM_CHANNELS];
+ int _sfxTimer;
+ static void sfxTimerProc(void *param);
+ void sfxTimerCallback();
- void playSoundChannel(int channel, int frequency, uint8 *data, int size, int volume);
-
- Audio::SoundHandle _channelsTable[NUM_CHANNELS];
Audio::SoundHandle _moduleHandle;
Audio::AudioStream *_moduleStream;
};
Commit: 0fe5e0e6bde4921a018b3fdc597adbb7d3745ed5
https://github.com/scummvm/scummvm/commit/0fe5e0e6bde4921a018b3fdc597adbb7d3745ed5
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2012-09-07T16:16:09-07:00
Commit Message:
CINE: Fix Paula frequency.
This should fix the frequency of sound effects.
Changed paths:
engines/cine/sound.h
diff --git a/engines/cine/sound.h b/engines/cine/sound.h
index 61ebd45..0787568 100644
--- a/engines/cine/sound.h
+++ b/engines/cine/sound.h
@@ -95,7 +95,7 @@ public:
virtual void update();
enum {
- PAULA_FREQ = 7093789,
+ PAULA_FREQ = 3579545,
NUM_CHANNELS = 4
};
Commit: 35e61b7c7a62cc8692ec258189a2690a7494c30c
https://github.com/scummvm/scummvm/commit/35e61b7c7a62cc8692ec258189a2690a7494c30c
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2012-09-07T16:16:09-07:00
Commit Message:
CINE: Remove unused Sound::update method.
Changed paths:
engines/cine/main_loop.cpp
engines/cine/sound.cpp
engines/cine/sound.h
diff --git a/engines/cine/main_loop.cpp b/engines/cine/main_loop.cpp
index c3eb78e..c822f1c 100644
--- a/engines/cine/main_loop.cpp
+++ b/engines/cine/main_loop.cpp
@@ -217,7 +217,6 @@ void manageEvents() {
g_system->delayMillis(20);
} while (g_system->getMillis() < nextFrame);
- g_sound->update();
mouseData.left = mouseLeft;
mouseData.right = mouseRight;
}
diff --git a/engines/cine/sound.cpp b/engines/cine/sound.cpp
index b66ce5a..97336b1 100644
--- a/engines/cine/sound.cpp
+++ b/engines/cine/sound.cpp
@@ -1094,11 +1094,6 @@ void PaulaSound::stopSound(int channel) {
_mixer->stopHandle(_channelsTable[channel].handle);
}
-void PaulaSound::update() {
- // process volume slides and start sound playback
- // TODO
-}
-
void PaulaSound::sfxTimerProc(void *param) {
PaulaSound *sound = (PaulaSound *)param;
sound->sfxTimerCallback();
diff --git a/engines/cine/sound.h b/engines/cine/sound.h
index 0787568..515d469 100644
--- a/engines/cine/sound.h
+++ b/engines/cine/sound.h
@@ -48,7 +48,6 @@ public:
virtual void playSound(int channel, int frequency, const uint8 *data, int size, int volumeStep, int stepCount, int volume, int repeat) = 0;
virtual void stopSound(int channel) = 0;
- virtual void update() {}
protected:
@@ -92,7 +91,6 @@ public:
virtual void playSound(int channel, int frequency, const uint8 *data, int size, int volumeStep, int stepCount, int volume, int repeat);
virtual void stopSound(int channel);
- virtual void update();
enum {
PAULA_FREQ = 3579545,
Commit: b48f5b78b759981a0c29b2d7ccbecc7bb0076a1b
https://github.com/scummvm/scummvm/commit/b48f5b78b759981a0c29b2d7ccbecc7bb0076a1b
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2012-09-07T16:16:10-07:00
Commit Message:
CINE: Implement panning for sfx for FW Amiga and AtariST.
Changed paths:
engines/cine/sound.cpp
engines/cine/sound.h
diff --git a/engines/cine/sound.cpp b/engines/cine/sound.cpp
index 97336b1..ead17b1 100644
--- a/engines/cine/sound.cpp
+++ b/engines/cine/sound.cpp
@@ -1082,7 +1082,8 @@ void PaulaSound::playSound(int channel, int frequency, const uint8 *data, int si
// Start the sfx
_mixer->playStream(Audio::Mixer::kSFXSoundType, &_channelsTable[channel].handle,
Audio::makeLoopingAudioStream(stream, repeat ? 0 : 1),
- -1, volume * Audio::Mixer::kMaxChannelVolume / 63);
+ -1, volume * Audio::Mixer::kMaxChannelVolume / 63,
+ _channelBalance[channel]);
}
}
}
@@ -1132,4 +1133,14 @@ void PaulaSound::sfxTimerCallback() {
}
}
+const int PaulaSound::_channelBalance[NUM_CHANNELS] = {
+ // L/R/R/L This is according to the Hardware Reference Manual.
+ // TODO: It seems the order is swapped for some Amiga models:
+ // http://www.amiga.org/forums/archive/index.php/t-7862.html
+ // Maybe we should consider using R/L/L/R to match Amiga 500?
+ // This also is a bit more drastic to what WineUAE defaults,
+ // which is only 70% of full panning.
+ -127, 127, 127, -127
+};
+
} // End of namespace Cine
diff --git a/engines/cine/sound.h b/engines/cine/sound.h
index 515d469..fe1c5a9 100644
--- a/engines/cine/sound.h
+++ b/engines/cine/sound.h
@@ -114,6 +114,7 @@ protected:
}
};
SfxChannel _channelsTable[NUM_CHANNELS];
+ static const int _channelBalance[NUM_CHANNELS];
int _sfxTimer;
static void sfxTimerProc(void *param);
void sfxTimerCallback();
Commit: 892710a0a3610d21f7a716f9c48ca8a7702f999c
https://github.com/scummvm/scummvm/commit/892710a0a3610d21f7a716f9c48ca8a7702f999c
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2012-09-07T16:16:10-07:00
Commit Message:
CINE: Fix sfx channel use in Amiga and AtariST versions of FW.
This fixes a channel assignment issue in opcode 119. This also implements
opcode 120, which is basically a stereo channel swapped version of 119
(o1_playSample).
This affects the Amiga and AtariST versions. I put a TODO to check the DOS
version here.
Changed paths:
engines/cine/script.h
engines/cine/script_fw.cpp
diff --git a/engines/cine/script.h b/engines/cine/script.h
index 3fc86c5..a07c8d6 100644
--- a/engines/cine/script.h
+++ b/engines/cine/script.h
@@ -227,6 +227,7 @@ protected:
int o1_op72();
int o1_op73();
int o1_playSample();
+ int o1_playSampleSwapped();
int o1_disableSystemMenu();
int o1_loadMask5();
int o1_unloadMask5();
diff --git a/engines/cine/script_fw.cpp b/engines/cine/script_fw.cpp
index a4e7314..b4fe68c 100644
--- a/engines/cine/script_fw.cpp
+++ b/engines/cine/script_fw.cpp
@@ -196,7 +196,7 @@ void FWScript::setupTable() {
{ 0, 0 },
{ &FWScript::o1_playSample, "bbwbww" },
/* 78 */
- { &FWScript::o1_playSample, "bbwbww" },
+ { &FWScript::o1_playSampleSwapped, "bbwbww" },
{ &FWScript::o1_disableSystemMenu, "b" },
{ &FWScript::o1_loadMask5, "b" },
{ &FWScript::o1_unloadMask5, "b" }
@@ -1828,8 +1828,8 @@ int FWScript::o1_playSample() {
channel1 = 0;
channel2 = 1;
} else {
- channel1 = 2;
- channel2 = 3;
+ channel1 = 3;
+ channel2 = 2;
}
g_sound->playSound(channel1, freq, data, size, -1, volume, 63, repeat);
g_sound->playSound(channel2, freq, data, size, 1, volume, 0, repeat);
@@ -1863,6 +1863,53 @@ int FWScript::o1_playSample() {
return 0;
}
+int FWScript::o1_playSampleSwapped() {
+ // TODO: The DOS version probably does not have any stereo support here
+ // since the only stereo output it supports should be the Roland MT-32.
+ // So it probably does the same as o1_playSample here. Checking this will
+ // be a good idea never the less.
+ if (g_cine->getPlatform() == Common::kPlatformPC) {
+ return o1_playSample();
+ }
+
+ debugC(5, kCineDebugScript, "Line: %d: playSampleInversed()", _line);
+
+ byte anim = getNextByte();
+ byte channel = getNextByte();
+
+ uint16 freq = getNextWord();
+ byte repeat = getNextByte();
+
+ int16 volume = getNextWord();
+ uint16 size = getNextWord();
+
+ const byte *data = g_cine->_animDataTable[anim].data();
+
+ if (!data) {
+ return 0;
+ }
+
+ if (size == 0xFFFF) {
+ size = g_cine->_animDataTable[anim]._width * g_cine->_animDataTable[anim]._height;
+ } else if (size > g_cine->_animDataTable[anim]._width * g_cine->_animDataTable[anim]._height) {
+ warning("o1_playSampleSwapped: Got invalid sample size %d for sample %d", size, anim);
+ size = g_cine->_animDataTable[anim]._width * g_cine->_animDataTable[anim]._height;
+ }
+
+ int channel1, channel2;
+ if (channel == 0) {
+ channel1 = 1;
+ channel2 = 0;
+ } else {
+ channel1 = 2;
+ channel2 = 3;
+ }
+
+ g_sound->playSound(channel1, freq, data, size, -1, volume, 63, repeat);
+ g_sound->playSound(channel2, freq, data, size, 1, volume, 0, repeat);
+ return 0;
+}
+
int FWScript::o1_disableSystemMenu() {
byte param = getNextByte();
@@ -2747,7 +2794,7 @@ void decompileScript(const byte *scriptPtr, uint16 scriptSize, uint16 scriptIdx)
if (opcode - 1 == 0x77) {
sprintf(lineBuffer, "playSample(%d,%d,%d,%d,%d,%d)\n", param1, param2, param3, param4, param5, param6);
} else if (opcode - 1 == 0x78) {
- sprintf(lineBuffer, "OP_78(%d,%d,%d,%d,%d,%d)\n", param1, param2, param3, param4, param5, param6);
+ sprintf(lineBuffer, "playSampleSwapped(%d,%d,%d,%d,%d,%d)\n", param1, param2, param3, param4, param5, param6);
}
break;
More information about the Scummvm-git-logs
mailing list