aboutsummaryrefslogtreecommitdiff
path: root/engines/lab/processroom.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/lab/processroom.cpp')
-rw-r--r--engines/lab/processroom.cpp59
1 files changed, 34 insertions, 25 deletions
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index 997eb75dce..44c8d65d7c 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -143,8 +143,10 @@ void LabEngine::drawDirection(const CloseData *closePtr) {
uint16 LabEngine::processArrow(uint16 curDirection, uint16 arrow) {
if (arrow == 1) { // Forward
uint16 room = _rooms[_roomNum]._doors[curDirection];
- if (room != 0)
+ if (room != 0) {
+ _music->checkRoomMusic(_roomNum, room);
_roomNum = room;
+ }
return curDirection;
} else if (arrow == 0) { // Left
@@ -235,26 +237,33 @@ bool LabEngine::takeItem(Common::Point pos) {
void LabEngine::doActions(const ActionList &actionList) {
ActionList::const_iterator action;
for (action = actionList.begin(); action != actionList.end(); ++action) {
- updateMusicAndEvents();
+ updateEvents();
switch (action->_actionType) {
case kActionPlaySound:
- _music->readMusic(action->_messages[0], false, true);
+ _music->loadSoundEffect(action->_messages[0], false, true);
break;
case kActionPlaySoundNoWait: // only used in scene 7 (street, when teleporting to the surreal maze)
- _music->readMusic(action->_messages[0], false, false);
+ _music->loadSoundEffect(action->_messages[0], false, false);
break;
case kActionPlaySoundLooping:
- _music->readMusic(action->_messages[0], true, false);
+ _music->loadSoundEffect(action->_messages[0], true, false);
break;
- case kActionShowDiff:
+ case kActionShowDiff: {
+ bool curWait = _anim->_waitForEffect;
+ // Pause the engine until the sound is finished
+ _anim->_waitForEffect = true;
_graphics->readPict(action->_messages[0], true);
+
+ // Restore the previous value of _waitForEffect
+ _anim->_waitForEffect = curWait;
break;
+ }
- case kActionShowDiffLooping:
+ case kActionShowDiffLooping: // used in scene 44 (heart of the labyrinth, minotaur)
_graphics->readPict(action->_messages[0], false);
break;
@@ -327,6 +336,7 @@ void LabEngine::doActions(const ActionList &actionList) {
break;
}
+ _music->checkRoomMusic(_roomNum, action->_param1);
_roomNum = action->_param1;
_direction = action->_param2 - 1;
_closeDataPtr = nullptr;
@@ -370,51 +380,50 @@ void LabEngine::doActions(const ActionList &actionList) {
_graphics->screenUpdate();
while (_system->getMillis() < targetMillis) {
- updateMusicAndEvents();
+ updateEvents();
_anim->diffNextFrame();
}
}
break;
- case kActionStopMusic:
- _music->setMusic(false);
+ case kActionStopMusic: // used in scene 44 (heart of the labyrinth, minotaur)
+ _music->freeMusic();
break;
- case kActionStartMusic:
- _music->setMusic(true);
+ case kActionStartMusic: // unused
+ error("Unused opcode kActionStartMusic has been called");
break;
- case kActionChangeMusic:
- _music->changeMusic(action->_messages[0]);
+ case kActionChangeMusic: // used in scene 46 (museum exhibit, for the alarm)
+ _music->changeMusic(action->_messages[0], true, false);
break;
- case kActionResetMusic:
- _music->resetMusic();
+ case kActionResetMusic: // used in scene 45 (sheriff's office, after museum)
+ _music->resetMusic(true);
break;
case kActionFillMusic:
- updateMusicAndEvents();
+ error("Unused opcode kActionFillMusic has been called");
break;
- case kActionWaitSound:
+ case kActionWaitSound: // used in scene 44 (heart of the labyrinth / ending)
while (_music->isSoundEffectActive()) {
- updateMusicAndEvents();
+ updateEvents();
_anim->diffNextFrame();
waitTOF();
}
-
break;
case kActionClearSound:
_music->stopSoundEffect();
break;
- case kActionWinMusic:
+ case kActionWinMusic: // used in scene 44 (heart of the labyrinth / ending)
_music->freeMusic();
- _music->initMusic("Music:WinGame");
+ _music->changeMusic("Music:WinGame", false, false);
break;
- case kActionWinGame:
+ case kActionWinGame: // used in scene 44 (heart of the labyrinth / ending)
_quitLab = true;
showLab2Teaser();
break;
@@ -473,7 +482,7 @@ bool LabEngine::doActionRuleSub(int16 action, int16 roomNum, const CloseData *cl
if (closePtr) {
RuleList *rules = &(_rooms[_roomNum]._rules);
- if (!rules && (roomNum == 0)) {
+ if (rules->empty() && (roomNum == 0)) {
_resource->readViews(roomNum);
rules = &(_rooms[roomNum]._rules);
}
@@ -521,7 +530,7 @@ bool LabEngine::doOperateRuleSub(int16 itemNum, int16 roomNum, const CloseData *
if (closePtr->_closeUpType > 0) {
RuleList *rules = &(_rooms[roomNum]._rules);
- if (!rules && (roomNum == 0)) {
+ if (rules->empty() && (roomNum == 0)) {
_resource->readViews(roomNum);
rules = &(_rooms[roomNum]._rules);
}