mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-15 22:28:10 +00:00
LAB: Move readSound() into the Music class
This commit is contained in:
parent
6bba608fc0
commit
156ad539ff
@ -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
|
||||
|
@ -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();
|
||||
};
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user