aboutsummaryrefslogtreecommitdiff
path: root/engines/scumm
diff options
context:
space:
mode:
authorJohannes Schickel2014-06-04 18:51:15 +0200
committerJohannes Schickel2014-06-04 18:51:15 +0200
commit4069f63eb0caf668e03636df1c697e3fd0724414 (patch)
treec864c587b4594271426178d126c62dcc8acd6e81 /engines/scumm
parenteeed91c42025329bb06cc99eb08e0ce23ab828e4 (diff)
downloadscummvm-rg350-4069f63eb0caf668e03636df1c697e3fd0724414.tar.gz
scummvm-rg350-4069f63eb0caf668e03636df1c697e3fd0724414.tar.bz2
scummvm-rg350-4069f63eb0caf668e03636df1c697e3fd0724414.zip
SCUMM: Save/load music/sfx data in AD player.
This makes sure that the currently playing music and sfx are resumed when loading a save game.
Diffstat (limited to 'engines/scumm')
-rw-r--r--engines/scumm/players/player_ad.cpp47
-rw-r--r--engines/scumm/players/player_ad.h10
-rw-r--r--engines/scumm/saveload.h2
3 files changed, 51 insertions, 8 deletions
diff --git a/engines/scumm/players/player_ad.cpp b/engines/scumm/players/player_ad.cpp
index 08519b42cf..5ed50ab65c 100644
--- a/engines/scumm/players/player_ad.cpp
+++ b/engines/scumm/players/player_ad.cpp
@@ -185,8 +185,51 @@ void Player_AD::saveLoadWithSerializer(Serializer *ser) {
return;
}
- // TODO: Be nicer than the original and save the data to continue the
- // currently played sound resources on load?
+ if (ser->getVersion() >= VER(96)) {
+ int32 res[4] = {
+ _soundPlaying, _sfx[0].resource, _sfx[1].resource, _sfx[2].resource
+ };
+
+ // The first thing we save is a list of sound resources being played
+ // at the moment.
+ ser->saveLoadArrayOf(res, 4, sizeof(res[0]), sleInt32);
+
+ // If we are loading start the music again at this point.
+ if (ser->isLoading()) {
+ if (res[0] != -1) {
+ startSound(res[0]);
+ }
+ }
+
+ uint32 musicOffset = _curOffset;
+
+ static const SaveLoadEntry musicData[] = {
+ MKLINE(Player_AD, _engineMusicTimer, sleInt32, VER(96)),
+ MKLINE(Player_AD, _musicTimer, sleUint32, VER(96)),
+ MKLINE(Player_AD, _internalMusicTimer, sleUint32, VER(96)),
+ MKLINE(Player_AD, _curOffset, sleUint32, VER(96)),
+ MKLINE(Player_AD, _nextEventTimer, sleUint32, VER(96)),
+ MKEND()
+ };
+
+ ser->saveLoadEntries(this, musicData);
+
+ // We seek back to the old music position.
+ if (ser->isLoading()) {
+ SWAP(musicOffset, _curOffset);
+ musicSeekTo(musicOffset);
+ }
+
+ // Finally start up the SFX. This makes sure that they are not
+ // accidently stopped while seeking to the old music position.
+ if (ser->isLoading()) {
+ for (int i = 1; i < ARRAYSIZE(res); ++i) {
+ if (res[i] != -1) {
+ startSound(res[i]);
+ }
+ }
+ }
+ }
}
int Player_AD::readBuffer(int16 *buffer, const int numSamples) {
diff --git a/engines/scumm/players/player_ad.h b/engines/scumm/players/player_ad.h
index f5e7ecccbc..63a8503f47 100644
--- a/engines/scumm/players/player_ad.h
+++ b/engines/scumm/players/player_ad.h
@@ -81,7 +81,7 @@ private:
int _samplesTillCallbackRemainder;
int _soundPlaying;
- int _engineMusicTimer;
+ int32 _engineMusicTimer;
struct SfxSlot;
@@ -120,8 +120,8 @@ private:
const byte *_musicData;
uint _timerLimit;
uint _musicTicks;
- uint _musicTimer;
- uint _internalMusicTimer;
+ uint32 _musicTimer;
+ uint32 _internalMusicTimer;
bool _loopFlag;
uint _musicLoopStart;
uint _instrumentOffset[16];
@@ -138,8 +138,8 @@ private:
uint _mdvdrState;
- uint _curOffset;
- uint _nextEventTimer;
+ uint32 _curOffset;
+ uint32 _nextEventTimer;
static const uint _noteFrequencies[12];
static const uint _mdvdrTable[6];
diff --git a/engines/scumm/saveload.h b/engines/scumm/saveload.h
index bd8ae3ff59..01ed21ece5 100644
--- a/engines/scumm/saveload.h
+++ b/engines/scumm/saveload.h
@@ -47,7 +47,7 @@ namespace Scumm {
* only saves/loads those which are valid for the version of the savegame
* which is being loaded/saved currently.
*/
-#define CURRENT_VER 95
+#define CURRENT_VER 96
/**
* An auxillary macro, used to specify savegame versions. We use this instead