aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/sci/sfx/music.cpp16
-rw-r--r--engines/sci/sfx/music.h5
-rw-r--r--engines/sci/sfx/soundcmd.cpp44
3 files changed, 40 insertions, 25 deletions
diff --git a/engines/sci/sfx/music.cpp b/engines/sci/sfx/music.cpp
index 6111655d62..66b5acfda7 100644
--- a/engines/sci/sfx/music.cpp
+++ b/engines/sci/sfx/music.cpp
@@ -343,7 +343,7 @@ void SciMusic::onTimer() {
_mutex.lock();
uint sz = _playList.size();
for (uint i = 0; i < sz; i++) {
- if (_playList[i]->status != kPlaying)
+ if (_playList[i]->status != kSndStatusPlaying)
continue;
if (_playList[i]->pMidiParser) {
if (_playList[i]->FadeStep)
@@ -353,7 +353,7 @@ void SciMusic::onTimer() {
} else if (_playList[i]->pStreamAud) {
if (!_pMixer->isSoundHandleActive(_playList[i]->hCurrentAud)) {
_playList[i]->ticker = 0xFFFF;
- _playList[i]->status = kStopped;
+ _playList[i]->status = kSndStatusStopped;
// Signal the engine scripts that the sound is done playing
// FIXME: is there any other place this can be triggered properly?
@@ -399,16 +399,16 @@ void SciMusic::soundPlay(MusicEntry *pSnd) {
pSnd->pStreamAud, -1, pSnd->volume, 0, false);
} else if (pSnd->pMidiParser) {
pSnd->pMidiParser->setVolume(pSnd->volume);
- if (pSnd->status == kStopped)
+ if (pSnd->status == kSndStatusStopped)
pSnd->pMidiParser->jumpToTick(0);
}
- pSnd->status = kPlaying;
+ pSnd->status = kSndStatusPlaying;
//_mutex.unlock();
}
//---------------------------------------------
void SciMusic::soundStop(MusicEntry *pSnd) {
//_mutex.lock();
- pSnd->status = kStopped;
+ pSnd->status = kSndStatusStopped;
if (pSnd->pStreamAud)
_pMixer->stopHandle(pSnd->hCurrentAud);
if (pSnd->pMidiParser)
@@ -430,7 +430,7 @@ void SciMusic::soundSetPriority(MusicEntry *pSnd, byte prio) {
//---------------------------------------------
void SciMusic::soundKill(MusicEntry *pSnd) {
//_mutex.lock();
- pSnd->status = kStopped;
+ pSnd->status = kSndStatusStopped;
if (pSnd->pMidiParser) {
pSnd->pMidiParser->unloadMusic();
delete pSnd->pMidiParser;
@@ -454,7 +454,7 @@ void SciMusic::soundKill(MusicEntry *pSnd) {
}
//---------------------------------------------
void SciMusic::soundPause(MusicEntry *pSnd) {
- pSnd->status = kPaused;
+ pSnd->status = kSndStatusPaused;
if (pSnd->pStreamAud)
_pMixer->pauseHandle(pSnd->hCurrentAud, true);
else if (pSnd->pMidiParser)
@@ -611,7 +611,7 @@ void MidiParser_SCI::parseNextEvent(EventInfo &info) {
jumpToTick(_loopTick);
_pSnd->loop--;
} else {
- _pSnd->status = kStopped;
+ _pSnd->status = kSndStatusStopped;
PUT_SEL32V(segMan, _pSnd->soundObj, signal, 0xFFFF);
}
}
diff --git a/engines/sci/sfx/music.h b/engines/sci/sfx/music.h
index 91ca0626f2..057bd21cf8 100644
--- a/engines/sci/sfx/music.h
+++ b/engines/sci/sfx/music.h
@@ -64,7 +64,10 @@ enum kTrackType {
};
enum kSndStatus {
- kStopped = 0, kPaused, kPlaying
+ kSndStatusStopped = 0,
+ kSndStatusInitialized = 1,
+ kSndStatusPaused = 2,
+ kSndStatusPlaying = 3
};
class MidiParser_SCI;
diff --git a/engines/sci/sfx/soundcmd.cpp b/engines/sci/sfx/soundcmd.cpp
index a30a2cb6b8..d696225e55 100644
--- a/engines/sci/sfx/soundcmd.cpp
+++ b/engines/sci/sfx/soundcmd.cpp
@@ -42,14 +42,6 @@ namespace Sci {
#define DEFROBNICATE_HANDLE(handle) (make_reg((handle >> 16) & 0xffff, handle & 0xffff))
#endif
-/* Sound status */
-enum {
- _K_SOUND_STATUS_STOPPED = 0,
- _K_SOUND_STATUS_INITIALIZED = 1,
- _K_SOUND_STATUS_PAUSED = 2,
- _K_SOUND_STATUS_PLAYING = 3
-};
-
#define SOUNDCOMMAND(x) _soundCommands.push_back(new MusicEntryCommand(#x, &SoundCommandParser::x))
#ifdef USE_OLD_MUSIC_FUNCTIONS
@@ -272,7 +264,7 @@ void SoundCommandParser::cmdInitHandle(reg_t obj, int16 value) {
#endif
if (!_hasNodePtr)
- PUT_SEL32V(_segMan, obj, state, _K_SOUND_STATUS_INITIALIZED);
+ PUT_SEL32V(_segMan, obj, state, kSndStatusInitialized);
else
PUT_SEL32(_segMan, obj, nodePtr, obj);
@@ -301,7 +293,7 @@ void SoundCommandParser::cmdInitHandle(reg_t obj, int16 value) {
newSound->FadeStep = 0;
newSound->FadeTicker = 0;
newSound->FadeTickerStep = 0;
- newSound->status = kStopped;
+ newSound->status = kSndStatusStopped;
_music->_playList.push_back(newSound);
// In SCI1.1 games, sound effects are started from here. If we can find
@@ -407,11 +399,13 @@ void SoundCommandParser::cmdPlayHandle(reg_t obj, int16 value) {
}
PUT_SEL32V(_segMan, obj, handle, 0x1234);
- PUT_SEL32V(_segMan, obj, signal, 0);
if (_hasNodePtr) {
PUT_SEL32V(_segMan, obj, min, 0);
PUT_SEL32V(_segMan, obj, sec, 0);
PUT_SEL32V(_segMan, obj, frame, 0);
+ PUT_SEL32V(_segMan, obj, signal, 0);
+ } else {
+ PUT_SEL32V(_segMan, obj, state, kSndStatusPlaying);
}
_music->_playList[slot]->loop = GET_SEL32V(_segMan, obj, loop) == 0xFFFF ? 1 : 0;
_music->_playList[slot]->prio = GET_SEL32V(_segMan, obj, priority);
@@ -438,6 +432,9 @@ void SoundCommandParser::changeHandleStatus(reg_t obj, int newStatus) {
#endif
void SoundCommandParser::cmdDisposeHandle(reg_t obj, int16 value) {
+ if (!obj.segment)
+ return;
+
#ifdef USE_OLD_MUSIC_FUNCTIONS
SongHandle handle = FROBNICATE_HANDLE(obj);
changeHandleStatus(obj, SOUND_STATUS_STOPPED);
@@ -462,11 +459,15 @@ void SoundCommandParser::cmdDisposeHandle(reg_t obj, int16 value) {
_music->soundKill(_music->_playList[slot]);
if (_hasNodePtr)
PUT_SEL32(_segMan, obj, nodePtr, NULL_REG);
-
+ else
+ PUT_SEL32V(_segMan, obj, state, kSndStatusStopped);
#endif
}
void SoundCommandParser::cmdStopHandle(reg_t obj, int16 value) {
+ if (!obj.segment)
+ return;
+
#ifdef USE_OLD_MUSIC_FUNCTIONS
changeHandleStatus(obj, SOUND_STATUS_STOPPED);
@@ -480,7 +481,10 @@ void SoundCommandParser::cmdStopHandle(reg_t obj, int16 value) {
}
PUT_SEL32V(_segMan, obj, handle, 0);
- PUT_SEL32V(_segMan, obj, signal, SIGNAL_OFFSET);
+ if (!_hasNodePtr)
+ PUT_SEL32V(_segMan, obj, state, kSndStatusStopped);
+ else
+ PUT_SEL32V(_segMan, obj, signal, SIGNAL_OFFSET);
_music->_playList[slot]->dataInc = 0;
_music->soundStop(_music->_playList[slot]);
@@ -503,10 +507,15 @@ void SoundCommandParser::cmdPauseHandle(reg_t obj, int16 value) {
return;
}
- if (value)
+ if (!_hasNodePtr) {
+ PUT_SEL32V(_segMan, obj, state, kSndStatusPaused);
_music->soundPause(_music->_playList[slot]);
- else
- _music->soundPlay(_music->_playList[slot]);
+ } else {
+ if (value)
+ _music->soundPause(_music->_playList[slot]);
+ else
+ _music->soundPlay(_music->_playList[slot]);
+ }
#endif
}
@@ -525,6 +534,7 @@ void SoundCommandParser::cmdResumeHandle(reg_t obj, int16 value) {
return;
}
+ PUT_SEL32V(_segMan, obj, state, kSndStatusPlaying);
_music->soundPlay(_music->_playList[slot]);
#endif
}
@@ -777,6 +787,8 @@ void SoundCommandParser::cmdGetAudioCapability(reg_t obj, int16 value) {
}
void SoundCommandParser::cmdGetPlayNext(reg_t obj, int16 value) {
+ // TODO
+ warning("STUB: cmdGetPlayNext");
}
void SoundCommandParser::cmdSetHandleVolume(reg_t obj, int16 value) {