mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-22 18:37:01 +00:00
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.
This commit is contained in:
parent
eeed91c420
commit
4069f63eb0
@ -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) {
|
||||
|
@ -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];
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user