aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2009-06-20 08:15:01 +0000
committerPaul Gilbert2009-06-20 08:15:01 +0000
commit4f622ab295f53ad9d2417d1d1ee2b1fddfa98298 (patch)
tree7b6fa54078bb40b6aa8fe0d105623e7e9bebefd4
parent61f20f4d88c7264b31a97cc15d6ddeda16a69956 (diff)
downloadscummvm-rg350-4f622ab295f53ad9d2417d1d1ee2b1fddfa98298.tar.gz
scummvm-rg350-4f622ab295f53ad9d2417d1d1ee2b1fddfa98298.tar.bz2
scummvm-rg350-4f622ab295f53ad9d2417d1d1ee2b1fddfa98298.zip
Added proper saving of music state to savegames so music resumes when a savegame is loaded.
svn-id: r41702
-rw-r--r--engines/cruise/saveload.cpp3
-rw-r--r--engines/cruise/sound.cpp22
-rw-r--r--engines/cruise/sound.h1
3 files changed, 21 insertions, 5 deletions
diff --git a/engines/cruise/saveload.cpp b/engines/cruise/saveload.cpp
index 6fd2034c5e..d151950c5e 100644
--- a/engines/cruise/saveload.cpp
+++ b/engines/cruise/saveload.cpp
@@ -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);
diff --git a/engines/cruise/sound.cpp b/engines/cruise/sound.cpp
index 3f8782d1ae..45bf186174 100644
--- a/engines/cruise/sound.cpp
+++ b/engines/cruise/sound.cpp
@@ -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
diff --git a/engines/cruise/sound.h b/engines/cruise/sound.h
index e6b00a98d6..bf5183cdda 100644
--- a/engines/cruise/sound.h
+++ b/engines/cruise/sound.h
@@ -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;