aboutsummaryrefslogtreecommitdiff
path: root/engines/mohawk
diff options
context:
space:
mode:
authorBastien Bouclet2016-08-04 20:26:26 +0200
committerEugene Sandulenko2017-07-03 08:50:10 +0200
commit1b062d1e39988388468bb13af97276d5674bbcbe (patch)
tree7e329f01236b3c46cda387b5f8b14bccd301d4ca /engines/mohawk
parent2fbe284a311f2eef62126115ddd6d2bb483b3c4b (diff)
downloadscummvm-rg350-1b062d1e39988388468bb13af97276d5674bbcbe.tar.gz
scummvm-rg350-1b062d1e39988388468bb13af97276d5674bbcbe.tar.bz2
scummvm-rg350-1b062d1e39988388468bb13af97276d5674bbcbe.zip
MOHAWK: Move the sound lists to RivenCard
Diffstat (limited to 'engines/mohawk')
-rw-r--r--engines/mohawk/console.cpp6
-rw-r--r--engines/mohawk/riven_card.cpp71
-rw-r--r--engines/mohawk/riven_card.h9
-rw-r--r--engines/mohawk/riven_external.cpp10
-rw-r--r--engines/mohawk/riven_scripts.cpp3
-rw-r--r--engines/mohawk/riven_sound.cpp58
-rw-r--r--engines/mohawk/riven_sound.h3
7 files changed, 87 insertions, 73 deletions
diff --git a/engines/mohawk/console.cpp b/engines/mohawk/console.cpp
index 87a0cd4e94..9b4d0564e2 100644
--- a/engines/mohawk/console.cpp
+++ b/engines/mohawk/console.cpp
@@ -450,7 +450,7 @@ bool RivenConsole::Cmd_PlaySound(int argc, const char **argv) {
bool RivenConsole::Cmd_PlaySLST(int argc, const char **argv) {
if (argc < 2) {
- debugPrintf("Usage: playSLST <slst index> <card, default = current>\n");
+ debugPrintf("Usage: playSLST <slst index>\n");
return true;
}
@@ -458,9 +458,7 @@ bool RivenConsole::Cmd_PlaySLST(int argc, const char **argv) {
_vm->_sound->stopSound();
_vm->_sound->stopAllSLST();
- uint16 card = (argc == 3) ? (uint16)atoi(argv[2]) : _vm->getCurCard()->getId();
-
- _vm->_sound->playSLST((uint16)atoi(argv[1]), card);
+ _vm->getCurCard()->playSound((uint16)atoi(argv[1]));
return false;
}
diff --git a/engines/mohawk/riven_card.cpp b/engines/mohawk/riven_card.cpp
index 9bb5a2e91a..34045faef2 100644
--- a/engines/mohawk/riven_card.cpp
+++ b/engines/mohawk/riven_card.cpp
@@ -23,7 +23,6 @@
#include "mohawk/riven_card.h"
#include "mohawk/riven_graphics.h"
-#include "mohawk/riven_sound.h"
#include "mohawk/resource.h"
#include "mohawk/riven.h"
@@ -35,6 +34,7 @@ RivenCard::RivenCard(MohawkEngine_Riven *vm, uint16 id) :
_id(id) {
loadCardResource(id);
loadCardPictureList(id);
+ loadCardSoundList(id);
}
RivenCard::~RivenCard() {
@@ -91,7 +91,7 @@ void RivenCard::defaultLoadScript() {
// Activate the first sound list if none have been activated
if (!_vm->_activatedSLST)
- _vm->_sound->playSLST(1, _id);
+ playSound(1);
}
void RivenCard::loadCardPictureList(uint16 id) {
@@ -129,4 +129,71 @@ RivenCard::Picture RivenCard::getPicture(uint16 index) const {
error("Could not find picture %d in card %d", index, _id);
}
+void RivenCard::loadCardSoundList(uint16 id) {
+ Common::SeekableReadStream *slstStream = _vm->getResource(ID_SLST, id);
+
+ uint16 recordCount = slstStream->readUint16BE();
+ _soundList.resize(recordCount);
+
+ for (uint16 i = 0; i < recordCount; i++) {
+ SLSTRecord &slstRecord = _soundList[i];
+ slstRecord.index = slstStream->readUint16BE();
+
+ uint16 soundCount = slstStream->readUint16BE();
+
+ slstRecord.soundIds.resize(soundCount);
+ for (uint16 j = 0; j < soundCount; j++)
+ slstRecord.soundIds[j] = slstStream->readUint16BE();
+
+ slstRecord.fadeFlags = slstStream->readUint16BE();
+ slstRecord.loop = slstStream->readUint16BE();
+ slstRecord.globalVolume = slstStream->readUint16BE();
+ slstRecord.u0 = slstStream->readUint16BE(); // Unknown
+
+ if (slstRecord.u0 > 1)
+ warning("slstRecord.u0: %d non-boolean", slstRecord.u0);
+
+ slstRecord.suspend = slstStream->readUint16BE();
+
+ if (slstRecord.suspend != 0)
+ warning("slstRecord.suspend: %d non-zero", slstRecord.suspend);
+
+ slstRecord.volumes.resize(soundCount);
+ slstRecord.balances.resize(soundCount);
+ slstRecord.u2.resize(soundCount);
+
+ for (uint16 j = 0; j < soundCount; j++)
+ slstRecord.volumes[j] = slstStream->readUint16BE();
+
+ for (uint16 j = 0; j < soundCount; j++)
+ slstRecord.balances[j] = slstStream->readSint16BE(); // negative = left, 0 = center, positive = right
+
+ for (uint16 j = 0; j < soundCount; j++) {
+ slstRecord.u2[j] = slstStream->readUint16BE(); // Unknown
+
+ if (slstRecord.u2[j] != 255 && slstRecord.u2[j] != 256)
+ warning("slstRecord.u2[%d]: %d not 255 or 256", j, slstRecord.u2[j]);
+ }
+ }
+
+ delete slstStream;
+}
+
+void RivenCard::playSound(uint16 index, bool queue) {
+ if (index > 0 && index <= _soundList.size()) {
+ RivenScriptPtr script = _vm->_scriptMan->createScriptFromData(1, 40, 1, index);
+ _vm->_scriptMan->runScript(script, queue);
+ }
+}
+
+SLSTRecord RivenCard::getSound(uint16 index) const {
+ for (uint16 i = 0; i < _soundList.size(); i++) {
+ if (_soundList[i].index == index) {
+ return _soundList[i];
+ }
+ }
+
+ error("Could not find sound %d in card %d", index, _id);
+}
+
} // End of namespace Mohawk
diff --git a/engines/mohawk/riven_card.h b/engines/mohawk/riven_card.h
index 86e872497f..b83f330c79 100644
--- a/engines/mohawk/riven_card.h
+++ b/engines/mohawk/riven_card.h
@@ -24,6 +24,7 @@
#define RIVEN_CARD_H
#include "mohawk/riven_scripts.h"
+#include "mohawk/riven_sound.h"
#include "common/rect.h"
#include "common/system.h"
@@ -67,9 +68,16 @@ public:
/** Draw one of the card's pictures synchronously or asynchronously */
void drawPicture(uint16 index, bool queue = false);
+ /** Play the card's ambient sounds with the specified index */
+ void playSound(uint16 index, bool queue = false);
+
+ /** Get the card's sound description with the specified index */
+ SLSTRecord getSound(uint16 index) const;
+
private:
void loadCardResource(uint16 id);
void loadCardPictureList(uint16 id);
+ void loadCardSoundList(uint16 id);
void initializeZipMode();
void defaultLoadScript();
@@ -84,6 +92,7 @@ private:
// Resource lists
Common::Array<Picture> _pictureList;
+ Common::Array<SLSTRecord> _soundList;
};
} // End of namespace Mohawk
diff --git a/engines/mohawk/riven_external.cpp b/engines/mohawk/riven_external.cpp
index 72c944f52e..a7161dff7b 100644
--- a/engines/mohawk/riven_external.cpp
+++ b/engines/mohawk/riven_external.cpp
@@ -771,11 +771,11 @@ void RivenExternal::xblabbooknextpage(uint16 argc, uint16 *argv) {
void RivenExternal::xsoundplug(uint16 argc, uint16 *argv) {
if (_vm->_vars["bheat"] != 0)
- _vm->_sound->playSLST(1, _vm->getCurCard()->getId());
+ _vm->getCurCard()->playSound(1);
else if (_vm->_vars["bcratergg"] != 0)
- _vm->_sound->playSLST(2, _vm->getCurCard()->getId());
+ _vm->getCurCard()->playSound(2);
else
- _vm->_sound->playSLST(3, _vm->getCurCard()->getId());
+ _vm->getCurCard()->playSound(3);
}
void RivenExternal::xbchangeboiler(uint16 argc, uint16 *argv) {
@@ -841,9 +841,9 @@ void RivenExternal::xbchangeboiler(uint16 argc, uint16 *argv) {
}
if (argc > 1)
- _vm->_sound->playSLST(argv[1], _vm->getCurCard()->getId());
+ _vm->getCurCard()->playSound(argv[1]);
else if (argv[0] == 2)
- _vm->_sound->playSLST(1, _vm->getCurCard()->getId());
+ _vm->getCurCard()->playSound(1);
_vm->_cursor->setCursor(kRivenHideCursor);
_vm->_video->playMovieBlockingRiven(11);
diff --git a/engines/mohawk/riven_scripts.cpp b/engines/mohawk/riven_scripts.cpp
index 068f0024af..bdb30bd391 100644
--- a/engines/mohawk/riven_scripts.cpp
+++ b/engines/mohawk/riven_scripts.cpp
@@ -580,7 +580,8 @@ void RivenSimpleCommand::activateSLST(uint16 op, uint16 argc, uint16 *argv) {
return;
_vm->_activatedSLST = true;
- _vm->_sound->playSLST(argv[0], _vm->getCurCard()->getId());
+ SLSTRecord picture = _vm->getCurCard()->getSound(argv[0]);
+ _vm->_sound->playSLST(picture);
}
// Command 41: activate MLST record and play
diff --git a/engines/mohawk/riven_sound.cpp b/engines/mohawk/riven_sound.cpp
index 10a23a0719..569bbb478a 100644
--- a/engines/mohawk/riven_sound.cpp
+++ b/engines/mohawk/riven_sound.cpp
@@ -68,64 +68,6 @@ void RivenSoundManager::playSound(uint16 id, uint16 volume, bool playOnDraw) {
}
}
-void RivenSoundManager::playSLST(uint16 index, uint16 card) {
- Common::SeekableReadStream *slstStream = _vm->getResource(ID_SLST, card);
-
- uint16 recordCount = slstStream->readUint16BE();
-
- for (uint16 i = 0; i < recordCount; i++) {
- SLSTRecord slstRecord;
- slstRecord.index = slstStream->readUint16BE();
-
- uint16 soundCount = slstStream->readUint16BE();
- slstRecord.soundIds.resize(soundCount);
-
- for (uint16 j = 0; j < soundCount; j++)
- slstRecord.soundIds[j] = slstStream->readUint16BE();
-
- slstRecord.fadeFlags = slstStream->readUint16BE();
- slstRecord.loop = slstStream->readUint16BE();
- slstRecord.globalVolume = slstStream->readUint16BE();
- slstRecord.u0 = slstStream->readUint16BE(); // Unknown
-
- if (slstRecord.u0 > 1)
- warning("slstRecord.u0: %d non-boolean", slstRecord.u0);
-
- slstRecord.suspend = slstStream->readUint16BE();
-
- if (slstRecord.suspend != 0)
- warning("slstRecord.u1: %d non-zero", slstRecord.suspend);
-
- slstRecord.volumes.resize(soundCount);
- slstRecord.balances.resize(soundCount);
- slstRecord.u2.resize(soundCount);
-
- for (uint16 j = 0; j < soundCount; j++)
- slstRecord.volumes[j] = slstStream->readUint16BE();
-
- for (uint16 j = 0; j < soundCount; j++)
- slstRecord.balances[j] = slstStream->readSint16BE(); // negative = left, 0 = center, positive = right
-
- for (uint16 j = 0; j < soundCount; j++) {
- slstRecord.u2[j] = slstStream->readUint16BE(); // Unknown
-
- if (slstRecord.u2[j] != 255 && slstRecord.u2[j] != 256)
- warning("slstRecord.u2[%d]: %d not 255 or 256", j, slstRecord.u2[j]);
- }
-
- if (slstRecord.index == index) {
- playSLST(slstRecord);
- delete slstStream;
- return;
- }
- }
-
- delete slstStream;
-
- // If we have no matching entries, we do nothing and just let
- // the previous ambient sounds continue.
-}
-
void RivenSoundManager::playSLST(const SLSTRecord &slstRecord) {
if (slstRecord.soundIds.empty()) {
return;
diff --git a/engines/mohawk/riven_sound.h b/engines/mohawk/riven_sound.h
index c79ccc3e3a..d4e7872279 100644
--- a/engines/mohawk/riven_sound.h
+++ b/engines/mohawk/riven_sound.h
@@ -86,9 +86,6 @@ public:
/** Start playing an ambient sound list */
void playSLST(const SLSTRecord &slstRecord);
- /** Start playing an ambient sound list from a resource */
- void playSLST(uint16 index, uint16 card);
-
/** Stop playing the current ambient sounds */
void stopAllSLST(bool fade = false);