SCI/new music code: The loop selector for each music score is no longer cached, but read directly from the sound object

svn-id: r46792
This commit is contained in:
Filippos Karapetis 2009-12-31 08:30:30 +00:00
parent 762bdc7cad
commit 54245f712d
6 changed files with 10 additions and 15 deletions

View File

@ -116,7 +116,7 @@ void MusicEntry::saveLoadWithSerializer(Common::Serializer &s) {
uint32 restoreTime = 0;
s.syncAsSint32LE(restoreTime);
ticker = restoreTime * 60 / 1000;
s.syncAsSint32LE(loop);
s.skip(4); // loop
s.skip(4); // hold
// volume and dataInc will be synced from the sound objects
// when the sound list is reconstructed in gamestate_restore()
@ -134,7 +134,7 @@ void MusicEntry::saveLoadWithSerializer(Common::Serializer &s) {
s.syncAsSint16LE(dataInc);
s.syncAsSint16LE(ticker);
s.syncAsByte(prio);
s.syncAsByte(loop);
s.skip(1, VER(15), VER(15));
s.syncAsByte(volume);
s.syncAsByte(fadeTo);
s.syncAsSint16LE(fadeStep);

View File

@ -36,7 +36,7 @@ namespace Sci {
struct EngineState;
enum {
CURRENT_SAVEGAME_VERSION = 15,
CURRENT_SAVEGAME_VERSION = 16,
MINIMUM_SAVEGAME_VERSION = 9
};

View File

@ -200,10 +200,11 @@ void MidiParser_SCI::parseNextEvent(EventInfo &info) {
info.ext.data = _position._play_pos;
_position._play_pos += info.length;
if (info.ext.type == 0x2F) {// end of track reached
if (_pSnd->loop)
_pSnd->loop--;
PUT_SEL32V(segMan, _pSnd->soundObj, loop, _pSnd->loop);
if (_pSnd->loop) {
int16 loop = GET_SEL32V(segMan, _pSnd->soundObj, loop);
if (loop)
loop--;
PUT_SEL32V(segMan, _pSnd->soundObj, loop, loop);
if (loop) {
// We need to play it again...
jumpToTick(_loopTick);
} else {

View File

@ -557,7 +557,6 @@ MusicEntry::MusicEntry() {
dataInc = 0;
ticker = 0;
prio = 0;
loop = 0;
volume = 0;
pauseCounter = 0;

View File

@ -73,7 +73,6 @@ public:
uint16 dataInc;
uint16 ticker;
byte prio;
uint16 loop;
int16 volume;
int16 pauseCounter;

View File

@ -288,7 +288,6 @@ void SoundCommandParser::cmdInitHandle(reg_t obj, int16 value) {
if (number && _resMan->testResource(ResourceId(kResourceTypeSound, number)))
newSound->soundRes = new SoundResource(number, _resMan, _soundVersion);
newSound->soundObj = obj;
newSound->loop = GET_SEL32V(_segMan, obj, loop);
newSound->prio = GET_SEL32V(_segMan, obj, pri) & 0xFF;
newSound->volume = CLIP<int>(GET_SEL32V(_segMan, obj, vol), 0, Audio::Mixer::kMaxChannelVolume);
@ -421,7 +420,6 @@ void SoundCommandParser::cmdPlayHandle(reg_t obj, int16 value) {
PUT_SEL32V(_segMan, obj, state, kSoundPlaying);
}
musicSlot->loop = GET_SEL32V(_segMan, obj, loop);
musicSlot->prio = GET_SEL32V(_segMan, obj, priority);
// vol selector doesnt get used before sci1late
if (_soundVersion < SCI_VERSION_1_LATE)
@ -677,7 +675,6 @@ void SoundCommandParser::cmdUpdateHandle(reg_t obj, int16 value) {
return;
}
musicSlot->loop = GET_SEL32V(_segMan, obj, loop);
int16 objVol = CLIP<int>(GET_SEL32V(_segMan, obj, vol), 0, 255);
if (objVol != musicSlot->volume)
_music->soundSetVolume(musicSlot, objVol);
@ -895,11 +892,10 @@ void SoundCommandParser::cmdSetHandleLoop(reg_t obj, int16 value) {
return;
}
if (value == -1) {
musicSlot->loop = 0xFFFF;
PUT_SEL32V(_segMan, obj, loop, 0xFFFF);
} else {
musicSlot->loop = 1; // actually plays the music once
PUT_SEL32V(_segMan, obj, loop, 1); // actually plays the music once
}
PUT_SEL32V(_segMan, obj, loop, musicSlot->loop);
#endif
}