aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFilippos Karapetis2015-07-21 22:26:06 +0300
committerEugene Sandulenko2015-12-15 00:05:02 +0100
commitd0171440df2d7b372563f342eac6cdd11488311f (patch)
treee0496fb5fd89f6ad42496622cd69df1f6ccad791
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
-rw-r--r--engines/lab/engine.cpp30
-rw-r--r--engines/lab/labmusic.cpp50
-rw-r--r--engines/lab/processroom.cpp40
3 files changed, 44 insertions, 76 deletions
diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 54050f2ffd..34ca89c192 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -69,7 +69,7 @@ int followCrumbs();
void mayShowCrumbIndicator();
void mayShowCrumbIndicatorOff();
-bool Alternate = false, ispal = false, noupdatediff = false, MainDisplay = true, QuitLab = false, DoNotReset = false;
+bool Alternate = false, ispal = false, noupdatediff = false, MainDisplay = true, QuitLab = false;
extern const char *NewFileName; /* When ProcessRoom.c decides to change the filename
of the current picture. */
@@ -118,11 +118,6 @@ extern char *GOFORWARDDIR, *NOPATH, *TAKEITEM, *USEONWHAT, *TAKEWHAT, *MOVEWHAT,
#define LEVERSMONITOR 82
-#define CLOWNROOM 123
-#define DIMROOM 80
-
-
-
static byte *MovePanelBuffer, *InvPanelBuffer;
static uint32 MovePanelBufferSize, InvPanelBufferSize;
static Image *MoveImages[20], *InvImages[10];
@@ -398,27 +393,6 @@ void eatMessages() {
return;
}
-static uint16 lastmusicroom = 1;
-
-
-/******************************************************************************/
-/* Checks the music that should be playing in a particular room. */
-/******************************************************************************/
-static void checkRoomMusic() {
- if ((lastmusicroom == RoomNum) || !g_music->_musicOn)
- return;
-
- if (RoomNum == CLOWNROOM)
- g_music->changeMusic("Music:Laugh");
- else if (RoomNum == DIMROOM)
- g_music->changeMusic("Music:Rm81");
- else if (!DoNotReset)
- g_music->resetMusic();
-
- lastmusicroom = RoomNum;
-}
-
-
/******************************************************************************/
/* Checks whether the close up is one of the special case closeups. */
/******************************************************************************/
@@ -791,7 +765,7 @@ static void mainGameLoop() {
if (Msg == NULL) { /* Does music load and next animation frame when you've run out of messages */
GotMessage = false;
- checkRoomMusic();
+ g_music->checkRoomMusic();
g_music->updateMusic();
diffNextFrame();
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;
}
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index c6acf36a32..3c5d1f62dd 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -44,26 +44,18 @@ namespace Lab {
/* Global parser data */
+#define NOFILE "no file"
+
RoomData *Rooms;
InventoryData *Inventory;
uint16 NumInv, RoomNum, ManyRooms, HighestCondition, Direction;
-
-extern char *FACINGNORTH, *FACINGEAST, *FACINGSOUTH, *FACINGWEST;
-extern bool LongWinInFront;
-
-#define NOFILE "no file"
-
-extern const char *CurFileName;
-
-const char *ViewPath = "LAB:Rooms/";
-
const char *NewFileName;
-extern bool DoNotDrawMessage;
-extern bool NoFlip, IsBM, noupdatediff, waitForEffect, mwaitForEffect, QuitLab, soundplaying, MusicOn, DoBlack, DoNotReset;
+extern bool DoNotDrawMessage, IsBM, noupdatediff, QuitLab, MusicOn, DoBlack, LongWinInFront;
extern char diffcmap[256 * 3];
-
+extern const char *CurFileName;
extern CloseDataPtr CPtr;
+extern char *FACINGNORTH, *FACINGEAST, *FACINGSOUTH, *FACINGWEST;
/*****************************************************************************/
/* Generates a random number. */
@@ -373,26 +365,26 @@ static void doActions(ActionPtr APtr, CloseDataPtr *LCPtr) {
uint32 StartSecs, StartMicros, CurSecs, CurMicros;
while (APtr) {
- g_music->checkMusic();
+ g_music->updateMusic();
switch (APtr->ActionType) {
case PLAYSOUND:
- mwaitForEffect = true; /* Plays a sound, but waits for it to be done before continuing */
g_music->_loopSoundEffect = false;
- readMusic((char *)APtr->Data);
- mwaitForEffect = false;
+ g_music->_waitTillFinished = true;
+ readMusic((char *)APtr->Data, true);
+ g_music->_waitTillFinished = false;
break;
case PLAYSOUNDB:
- mwaitForEffect = false; /* Plays a sound in the background. */
g_music->_loopSoundEffect = false;
- readMusic((char *)APtr->Data);
+ g_music->_waitTillFinished = false;
+ readMusic((char *)APtr->Data, false);
break;
case PLAYSOUNDCONT:
g_music->_doNotFilestopSoundEffect = true;
g_music->_loopSoundEffect = true;
- readMusic((char *)APtr->Data);
+ readMusic((char *)APtr->Data, g_music->_waitTillFinished);
break;
case SHOWDIFF:
@@ -542,7 +534,7 @@ static void doActions(ActionPtr APtr, CloseDataPtr *LCPtr) {
WSDL_UpdateScreen();
while (1) {
- g_music->checkMusic();
+ g_music->updateMusic();
diffNextFrame();
getTime(&CurSecs, &CurMicros);
@@ -563,16 +555,16 @@ static void doActions(ActionPtr APtr, CloseDataPtr *LCPtr) {
case CHANGEMUSIC:
g_music->changeMusic((const char *)APtr->Data);
- DoNotReset = true;
+ g_music->setMusicReset(false);
break;
case RESETMUSIC:
g_music->resetMusic();
- DoNotReset = false;
+ g_music->setMusicReset(true);
break;
case FILLMUSIC:
- g_music->fillUpMusic(true);
+ g_music->updateMusic();
break;
case WAITSOUND: