aboutsummaryrefslogtreecommitdiff
path: root/engines/lab/labmusic.cpp
diff options
context:
space:
mode:
authorFilippos Karapetis2015-07-21 22:26:06 +0300
committerEugene Sandulenko2015-12-15 00:05:02 +0100
commitd0171440df2d7b372563f342eac6cdd11488311f (patch)
treee0496fb5fd89f6ad42496622cd69df1f6ccad791 /engines/lab/labmusic.cpp
parentf085a3187edb2ac6077c00a995309b25869db336 (diff)
downloadscummvm-rg350-d0171440df2d7b372563f342eac6cdd11488311f.tar.gz
scummvm-rg350-d0171440df2d7b372563f342eac6cdd11488311f.tar.bz2
scummvm-rg350-d0171440df2d7b372563f342eac6cdd11488311f.zip
LAB: Move checkRoomMusic to the Music class. Some cleanup
Diffstat (limited to 'engines/lab/labmusic.cpp')
-rw-r--r--engines/lab/labmusic.cpp50
1 files changed, 26 insertions, 24 deletions
diff --git a/engines/lab/labmusic.cpp b/engines/lab/labmusic.cpp
index ecb5fd174b..3f35579e2c 100644
--- a/engines/lab/labmusic.cpp
+++ b/engines/lab/labmusic.cpp
@@ -40,10 +40,13 @@
namespace Lab {
#define MUSICBUFSIZE (2 * 65536L)
-
#define SAMPLESPEED 15000L
+#define CLOWNROOM 123
+#define DIMROOM 80
+
Music *g_music;
+extern uint16 RoomNum; // TODO: Move into a class
Music::Music() {
_file = 0;
@@ -60,6 +63,9 @@ Music::Music() {
_loopSoundEffect = false;
_queuingAudioStream = NULL;
_doNotFilestopSoundEffect = false;
+ _lastMusicRoom = 1;
+ _doReset = true;
+ _waitTillFinished = false;
}
/*****************************************************************************/
@@ -144,15 +150,6 @@ void Music::fillbuffer(byte *musicBuffer) {
}
/*****************************************************************************/
-/* Fills up the buffers that have already been played if necessary; if doit */
-/* is set to TRUE then it will fill up all empty buffers. Otherwise, it */
-/* Check if there are MINBUFFERS or less buffers that are playing. */
-/*****************************************************************************/
-void Music::fillUpMusic(bool doit) {
- updateMusic();
-}
-
-/*****************************************************************************/
/* Starts up the music initially. */
/*****************************************************************************/
void Music::startMusic(bool startatbegin) {
@@ -241,18 +238,6 @@ void Music::resumeBackMusic() {
}
/*****************************************************************************/
-/* Checks to see if need to fill buffers fill of music. */
-/*****************************************************************************/
-void Music::checkMusic() {
- updateMusic();
-
- if (!_musicOn)
- return;
-
- fillUpMusic(false);
-}
-
-/*****************************************************************************/
/* Turns the music on and off. */
/*****************************************************************************/
void Music::setMusic(bool on) {
@@ -268,6 +253,23 @@ void Music::setMusic(bool on) {
_musicOn = on;
}
+/******************************************************************************/
+/* Checks the music that should be playing in a particular room. */
+/******************************************************************************/
+void Music::checkRoomMusic() {
+ if ((_lastMusicRoom == RoomNum) || !_musicOn)
+ return;
+
+ if (RoomNum == CLOWNROOM)
+ g_music->changeMusic("Music:Laugh");
+ else if (RoomNum == DIMROOM)
+ g_music->changeMusic("Music:Rm81");
+ else if (_doReset)
+ g_music->resetMusic();
+
+ _lastMusicRoom = RoomNum;
+}
+
/*****************************************************************************/
/* Changes the background music to something else. */
/*****************************************************************************/
@@ -348,14 +350,14 @@ byte **Music::newOpen(const char *name, uint32 &size) {
if (_musicOn) {
updateMusic();
- fillUpMusic(true);
+ updateMusic();
}
if (!_doNotFilestopSoundEffect && isSoundEffectActive())
stopSoundEffect();
file = openFile(name, size);
- checkMusic();
+ updateMusic();
return file;
}