aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFilippos Karapetis2015-12-07 10:44:54 +0200
committerWillem Jan Palenstijn2015-12-23 21:33:53 +0100
commit156ad539ffe30c9a09952f7b97e285a5a5096b0d (patch)
tree32a0a16e61d7701f0458fc096856634ed642ccb0
parent6bba608fc06658cec8f0bc09874739ae8b4bc9e4 (diff)
downloadscummvm-rg350-156ad539ffe30c9a09952f7b97e285a5a5096b0d.tar.gz
scummvm-rg350-156ad539ffe30c9a09952f7b97e285a5a5096b0d.tar.bz2
scummvm-rg350-156ad539ffe30c9a09952f7b97e285a5a5096b0d.zip
LAB: Move readSound() into the Music class
-rw-r--r--engines/lab/anim.cpp44
-rw-r--r--engines/lab/anim.h1
-rw-r--r--engines/lab/music.cpp49
-rw-r--r--engines/lab/music.h4
4 files changed, 51 insertions, 47 deletions
diff --git a/engines/lab/anim.cpp b/engines/lab/anim.cpp
index bb5c5e9e88..c5493e03e6 100644
--- a/engines/lab/anim.cpp
+++ b/engines/lab/anim.cpp
@@ -668,48 +668,4 @@ bool Anim::readDiff(byte *buffer, bool playOnce) {
return true;
}
-void Anim::readSound(bool waitTillFinished, Common::File *file) {
- uint32 magicBytes = file->readUint32LE();
- if (magicBytes != 1219009121L)
- return;
-
- uint32 soundTag = file->readUint32LE();
- uint32 soundSize = file->readUint32LE();
-
- if (soundTag == 0)
- file->skip(soundSize); // skip the header
- else
- return;
-
- while (soundTag != 65535) {
- _vm->_music->updateMusic();
- soundTag = file->readUint32LE();
- soundSize = file->readUint32LE() - 8;
-
- if ((soundTag == 30) || (soundTag == 31)) {
- if (waitTillFinished) {
- while (_vm->_music->isSoundEffectActive()) {
- _vm->_music->updateMusic();
- _vm->waitTOF();
- }
- }
-
- file->skip(4);
-
- uint16 sampleRate = file->readUint16LE();
- file->skip(2);
- byte *soundData = (byte *)malloc(soundSize);
- file->read(soundData, soundSize);
- _vm->_music->playSoundEffect(sampleRate, soundSize, soundData);
- } else if (soundTag == 65535L) {
- if (waitTillFinished) {
- while (_vm->_music->isSoundEffectActive()) {
- _vm->_music->updateMusic();
- _vm->waitTOF();
- }
- }
- } else
- file->skip(soundSize);
- }
-}
} // End of namespace Lab
diff --git a/engines/lab/anim.h b/engines/lab/anim.h
index 98413472ea..a0438d862d 100644
--- a/engines/lab/anim.h
+++ b/engines/lab/anim.h
@@ -111,7 +111,6 @@ public:
void unDiff(byte *newBuf, byte *oldBuf, byte *diffData, uint16 bytesperrow, bool isV);
bool readDiff(byte *buffer, bool playOnce);
void diffNextFrame();
- void readSound(bool waitTillFinished, Common::File *file);
void stopDiff();
void stopDiffEnd();
};
diff --git a/engines/lab/music.cpp b/engines/lab/music.cpp
index ddc6cbdaa6..1260fd81fe 100644
--- a/engines/lab/music.cpp
+++ b/engines/lab/music.cpp
@@ -321,9 +321,56 @@ bool Music::readMusic(const char *filename, bool waitTillFinished) {
return false;
_vm->_anim->_doBlack = false;
- _vm->_anim->readSound(waitTillFinished, file);
+ readSound(waitTillFinished, file);
return true;
}
+void Music::readSound(bool waitTillFinished, Common::File *file) {
+ uint32 magicBytes = file->readUint32LE();
+ if (magicBytes != 1219009121L)
+ return;
+
+ uint32 soundTag = file->readUint32LE();
+ uint32 soundSize = file->readUint32LE();
+
+ if (soundTag == 0)
+ file->skip(soundSize); // skip the header
+ else
+ return;
+
+ while (soundTag != 65535) {
+ updateMusic();
+ soundTag = file->readUint32LE();
+ soundSize = file->readUint32LE() - 8;
+
+ if ((soundTag == 30) || (soundTag == 31)) {
+ if (waitTillFinished) {
+ while (isSoundEffectActive()) {
+ updateMusic();
+ _vm->waitTOF();
+ }
+ }
+
+ file->skip(4);
+
+ uint16 sampleRate = file->readUint16LE();
+ file->skip(2);
+ byte *soundData = (byte *)malloc(soundSize);
+ file->read(soundData, soundSize);
+ playSoundEffect(sampleRate, soundSize, soundData);
+ }
+ else if (soundTag == 65535L) {
+ if (waitTillFinished) {
+ while (isSoundEffectActive()) {
+ updateMusic();
+ _vm->waitTOF();
+ }
+ }
+ }
+ else
+ file->skip(soundSize);
+ }
+}
+
} // End of namespace Lab
diff --git a/engines/lab/music.h b/engines/lab/music.h
index 7905da74a5..942f7372ce 100644
--- a/engines/lab/music.h
+++ b/engines/lab/music.h
@@ -77,9 +77,11 @@ public:
bool _doReset;
private:
- LabEngine *_vm;
void fillbuffer(byte *musicBuffer);
void startMusic(bool restartFl);
+ void readSound(bool waitTillFinished, Common::File *file);
+
+ LabEngine *_vm;
Common::File *_file;
Common::File *_tFile;