aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/sci/graphics/robot.cpp18
-rw-r--r--engines/sci/graphics/robot.h1
-rw-r--r--engines/sci/sound/audio.cpp14
-rw-r--r--engines/sci/sound/audio.h1
4 files changed, 32 insertions, 2 deletions
diff --git a/engines/sci/graphics/robot.cpp b/engines/sci/graphics/robot.cpp
index 0792c6596e..3049fa7fce 100644
--- a/engines/sci/graphics/robot.cpp
+++ b/engines/sci/graphics/robot.cpp
@@ -27,8 +27,13 @@
#include "sci/engine/state.h"
#include "sci/graphics/screen.h"
#include "sci/graphics/robot.h"
+#include "sci/sound/audio.h"
+
+#include "sound/audiostream.h"
+#include "sound/mixer.h"
#include "common/file.h"
+#include "common/system.h"
namespace Sci {
@@ -64,9 +69,9 @@ void GfxRobot::initData(GuiResourceId resourceId) {
_audioSize = READ_LE_UINT16(_resourceData + 15);
//_frameSize = READ_LE_UINT32(_resourceData + 34);
- byte hasSound = _resourceData[25];
+ _hasSound = (_resourceData[25] != 0);
- debug("Robot %d, %d frames, sound: %d\n", resourceId, _frameCount, hasSound);
+ debug("Robot %d, %d frames, sound: %s\n", resourceId, _frameCount, _hasSound ? "yes" : "no");
}
// TODO: just trying around in here...
@@ -76,6 +81,15 @@ void GfxRobot::draw() {
int x, y;
int frame;
+ // Play the audio of the robot file (for debugging)
+#if 0
+ if (_hasSound) {
+ Audio::SoundHandle _audioHandle;
+ Audio::AudioStream *audioStream = g_sci->_audio->getRobotAudioStream(_resourceData);
+ g_system->getMixer()->playStream(Audio::Mixer::kSpeechSoundType, &_audioHandle, audioStream);
+ }
+#endif
+
return;
// Each frame contains these bytes:
diff --git a/engines/sci/graphics/robot.h b/engines/sci/graphics/robot.h
index 76dca35a82..a9f1d3c4df 100644
--- a/engines/sci/graphics/robot.h
+++ b/engines/sci/graphics/robot.h
@@ -52,6 +52,7 @@ private:
uint16 _frameCount;
uint32 _frameSize; // is width * height (pixelCount)
uint16 _audioSize;
+ bool _hasSound;
};
#endif
diff --git a/engines/sci/sound/audio.cpp b/engines/sci/sound/audio.cpp
index 829a94d90c..f2c13cf5f5 100644
--- a/engines/sci/sound/audio.cpp
+++ b/engines/sci/sound/audio.cpp
@@ -243,6 +243,20 @@ static byte *readSOLAudio(Common::SeekableReadStream *audioStream, uint32 &size,
return buffer;
}
+// FIXME: This doesn't work correctly yet, perhaps there are differences in the
+// way the audio in robot files is handled
+Audio::RewindableAudioStream *AudioPlayer::getRobotAudioStream(byte *buffer) {
+ const uint16 rbtHeaderSize = 19; // TODO: is this right?
+ const uint16 rbtAudioRate = 22050; // Seems to be hardcoded for all Robot videos
+ byte audioFlags = *(buffer + 6);
+ byte flags = 0;
+ uint32 audioSize = READ_LE_UINT16(buffer + 15) - rbtHeaderSize;
+
+ Common::MemoryReadStream dataStream(buffer + rbtHeaderSize - 1, audioSize, DisposeAfterUse::NO);
+ byte *data = readSOLAudio(&dataStream, audioSize, audioFlags, flags);
+ return Audio::makeRawStream(data, audioSize, rbtAudioRate, flags);
+}
+
Audio::RewindableAudioStream *AudioPlayer::getAudioStream(uint32 number, uint32 volume, int *sampleLen) {
Audio::SeekableAudioStream *audioSeekStream = 0;
Audio::RewindableAudioStream *audioStream = 0;
diff --git a/engines/sci/sound/audio.h b/engines/sci/sound/audio.h
index 7c1221fc4c..0f075f1b0f 100644
--- a/engines/sci/sound/audio.h
+++ b/engines/sci/sound/audio.h
@@ -65,6 +65,7 @@ public:
void setAudioRate(uint16 rate) { _audioRate = rate; }
Audio::SoundHandle *getAudioHandle() { return &_audioHandle; }
+ Audio::RewindableAudioStream *getRobotAudioStream(byte *buffer);
Audio::RewindableAudioStream *getAudioStream(uint32 number, uint32 volume, int *sampleLen);
int getAudioPosition();
int startAudio(uint16 module, uint32 tuple);