aboutsummaryrefslogtreecommitdiff
path: root/engines/sword1/music.cpp
diff options
context:
space:
mode:
authorEugene Sandulenko2009-02-28 10:46:33 +0000
committerEugene Sandulenko2009-02-28 10:46:33 +0000
commit5aa50ec889109864cbdd13298b4026c8ed78f484 (patch)
treef5cdded9d2cd6e5742152df99d176641551b03de /engines/sword1/music.cpp
parentc62834cc0c4033acb2d37a65dbcd6a998b88cc76 (diff)
downloadscummvm-rg350-5aa50ec889109864cbdd13298b4026c8ed78f484.tar.gz
scummvm-rg350-5aa50ec889109864cbdd13298b4026c8ed78f484.tar.bz2
scummvm-rg350-5aa50ec889109864cbdd13298b4026c8ed78f484.zip
Patch #2638336: Broken Sword PSX Support
svn-id: r38956
Diffstat (limited to 'engines/sword1/music.cpp')
-rw-r--r--engines/sword1/music.cpp43
1 files changed, 40 insertions, 3 deletions
diff --git a/engines/sword1/music.cpp b/engines/sword1/music.cpp
index 27e7568fcc..8553b6a286 100644
--- a/engines/sword1/music.cpp
+++ b/engines/sword1/music.cpp
@@ -29,7 +29,10 @@
#include "common/util.h"
#include "common/system.h"
+#include "sword1/sword1.h"
#include "sword1/music.h"
+#include "sword1/vag.h"
+
#include "sound/aiff.h"
#include "sound/flac.h"
#include "sound/mixer.h"
@@ -252,6 +255,35 @@ bool MusicHandle::play(const char *fileBase, bool loop) {
return true;
}
+bool MusicHandle::playPSX(uint16 id, bool loop) {
+ stop();
+
+ if (!_file.isOpen())
+ if (!_file.open("tunes.dat"))
+ return false;
+
+ Common::File tableFile;
+ if (!tableFile.open("tunes.tab"))
+ return false;
+
+ tableFile.seek((id - 1) * 8, SEEK_SET);
+ uint32 offset = tableFile.readUint32LE() * 0x800;
+ uint32 size = tableFile.readUint32LE();
+
+ tableFile.close();
+
+ if (size != 0xffffffff) {
+ _file.seek(offset, SEEK_SET);
+ _audioSource = new VagStream(_file.readStream(size), loop);
+ fadeUp();
+ } else {
+ _audioSource = NULL;
+ return false;
+ }
+
+ return true;
+}
+
void MusicHandle::fadeDown() {
if (streaming()) {
if (_fading < 0)
@@ -276,8 +308,7 @@ bool MusicHandle::endOfData() const {
return !streaming();
}
-// is we don't have an audiosource, return some dummy values.
-// shouldn't happen anyways.
+// if we don't have an audiosource, return some dummy values.
bool MusicHandle::streaming(void) const {
return (_audioSource) ? (!_audioSource->endOfStream()) : false;
}
@@ -411,7 +442,13 @@ void Music::startMusic(int32 tuneId, int32 loopFlag) {
/* The handle will load the music file now. It can take a while, so unlock
the mutex before, to have the soundthread playing normally.
As the corresponding _converter is NULL, the handle will be ignored by the playing thread */
- if (_handles[newStream].play(_tuneList[tuneId], loopFlag != 0)) {
+ if (SwordEngine::isPsx()) { ;
+ if (_handles[newStream].playPSX(tuneId, loopFlag != 0)) {
+ _mutex.lock();
+ _converter[newStream] = Audio::makeRateConverter(_handles[newStream].getRate(), _mixer->getOutputRate(), _handles[newStream].isStereo(), false);
+ _mutex.unlock();
+ }
+ } else if (_handles[newStream].play(_tuneList[tuneId], loopFlag != 0)) {
_mutex.lock();
_converter[newStream] = Audio::makeRateConverter(_handles[newStream].getRate(), _mixer->getOutputRate(), _handles[newStream].isStereo(), false);
_mutex.unlock();