Added proper saving of music state to savegames so music resumes when a savegame is loaded.

svn-id: r41702
This commit is contained in:
Paul Gilbert 2009-06-20 08:15:01 +00:00
parent 61f20f4d88
commit 4f622ab295
3 changed files with 21 additions and 5 deletions

View File

@ -820,6 +820,7 @@ Common::Error loadSavegameData(int saveGameIdx) {
printInfoBlackBox("Loading in progress...");
initVars();
_vm->sound().stopMusic();
// Skip over the savegame header
CruiseSavegameHeader header;
@ -928,8 +929,6 @@ Common::Error loadSavegameData(int saveGameIdx) {
currentcellHead = currentcellHead->next;
}
//TODO: here, restart music
if (strlen(currentCtpName)) {
loadCtFromSave = 1;
initCt(currentCtpName);

View File

@ -211,6 +211,9 @@ public:
uint8 numOrders() const { assert(_sfxData); return _sfxData[470]; }
void setNumOrders(uint8 v) { assert(_sfxData); _sfxData[470] = v; }
void setPattern(int offset, uint8 value) { assert(_sfxData); _sfxData[472 + offset] = value; }
const char *musicName() { return _musicName; }
// Note: Original game never actually uses looping variable. Songs are hardcoded to loop
bool looping() const { return _looping; }
void setLooping(bool v) { _looping = v; }
};
@ -701,8 +704,20 @@ void PCSoundFxPlayer::doSync(Common::Serializer &s) {
s.syncBytes((byte *)_musicName, 33);
uint16 v = (uint16)songLoaded();
s.syncAsSint16LE(v);
if (s.isLoading() && v) {
load(_musicName);
for (int i = 0; i < NUM_CHANNELS; ++i) {
_instrumentsChannelTable[i] = -1;
}
}
s.syncAsSint16LE(_songPlayed);
s.syncAsSint16LE(_looping);
s.syncAsSint16LE(_currentPos);
s.syncAsSint16LE(_currentOrder);
s.syncAsSint16LE(_playing);
}
PCSound::PCSound(Audio::Mixer *mixer, CruiseEngine *vm) {
@ -791,7 +806,6 @@ bool PCSound::musicLooping() const {
void PCSound::musicLoop(bool v) {
_player->setLooping(v);
warning("TODO: set music looping");
}
void PCSound::startNote(int channel, int volume, int speed) {
@ -815,9 +829,11 @@ void PCSound::startSound(int channelNum, const byte *ptr, int size, int speed, i
}
void PCSound::doSync(Common::Serializer &s) {
warning("TODO: doSync fx properties");
_player->doSync(s);
// _soundDriver->doSync(s);
}
const char *PCSound::musicName() {
return _player->musicName();
}
} // End of namespace Cruise

View File

@ -59,6 +59,7 @@ public:
virtual void stopSound(int channel);
void doSync(Common::Serializer &s);
const char *musicName();
void stopChannel(int channel);
bool isPlaying() const;
bool songLoaded() const;