mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-14 05:38:56 +00:00
Added storing of playing sounds to savegame (note: only sounds flagged as restorable are restarted after loading a savegame)
svn-id: r29271
This commit is contained in:
parent
9d14d74e8d
commit
5f1ef91820
@ -166,6 +166,7 @@ bool LureEngine::saveGame(uint8 slotNumber, Common::String &caption) {
|
||||
|
||||
Resources::getReference().saveToStream(f);
|
||||
Game::getReference().saveToStream(f);
|
||||
Sound.saveToStream(f);
|
||||
Room::getReference().saveToStream(f);
|
||||
Fights.saveToStream(f);
|
||||
|
||||
@ -207,6 +208,7 @@ bool LureEngine::loadGame(uint8 slotNumber) {
|
||||
// Load in the data
|
||||
Resources::getReference().loadFromStream(f);
|
||||
Game::getReference().loadFromStream(f);
|
||||
Sound.loadFromStream(f);
|
||||
Room::getReference().loadFromStream(f);
|
||||
Fights.loadFromStream(f);
|
||||
|
||||
|
@ -42,6 +42,7 @@ SoundManager::SoundManager() {
|
||||
_descs = Disk::getReference().getEntry(SOUND_DESC_RESOURCE_ID);
|
||||
_numDescs = _descs->size() / sizeof(SoundDescResource);
|
||||
_soundData = NULL;
|
||||
_paused = false;
|
||||
|
||||
int midiDriver = MidiDriver::detectMusicDriver(MDT_MIDI | MDT_ADLIB | MDT_PREFER_MIDI);
|
||||
_nativeMT32 = ((midiDriver == MD_MT32) || ConfMan.getBool("native_mt32"));
|
||||
@ -87,6 +88,36 @@ SoundManager::~SoundManager() {
|
||||
g_system->deleteMutex(_soundMutex);
|
||||
}
|
||||
|
||||
void SoundManager::saveToStream(WriteStream *stream) {
|
||||
debugC(ERROR_BASIC, kLureDebugSounds, "SoundManager::saveToStream");
|
||||
ManagedList<SoundDescResource *>::iterator i;
|
||||
|
||||
for (i = _activeSounds.begin(); i != _activeSounds.end(); ++i) {
|
||||
SoundDescResource *rec = *i;
|
||||
stream->writeByte(rec->soundNumber);
|
||||
}
|
||||
stream->writeByte(0xff);
|
||||
}
|
||||
|
||||
void SoundManager::loadFromStream(ReadStream *stream) {
|
||||
// Stop any existing sounds playing
|
||||
killSounds();
|
||||
|
||||
// Load any playing sounds
|
||||
uint8 soundNumber;
|
||||
while ((soundNumber = stream->readByte()) != 0xff) {
|
||||
uint8 soundIndex = descIndexOf(soundNumber);
|
||||
if (soundIndex != 0xff) {
|
||||
// Make sure that the sound is allowed to be restored
|
||||
SoundDescResource &rec = soundDescs()[soundIndex];
|
||||
if ((rec.flags & SF_RESTORE) != 0)
|
||||
// Requeue the sound for playing
|
||||
addSound(soundIndex, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SoundManager::loadSection(uint16 sectionId) {
|
||||
debugC(ERROR_BASIC, kLureDebugSounds, "SoundManager::loadSection = %xh", sectionId);
|
||||
killSounds();
|
||||
@ -247,6 +278,17 @@ void SoundManager::setVolume(uint8 volume) {
|
||||
}
|
||||
}
|
||||
|
||||
uint8 SoundManager::descIndexOf(uint8 soundNumber) {
|
||||
SoundDescResource *rec = soundDescs();
|
||||
|
||||
for (uint8 index = 0; index < _numDescs; ++index, ++rec) {
|
||||
if (rec->soundNumber == soundNumber)
|
||||
return index;
|
||||
}
|
||||
|
||||
return 0xff; // Couldn't find entry
|
||||
}
|
||||
|
||||
SoundDescResource *SoundManager::findSound(uint8 soundNumber) {
|
||||
debugC(ERROR_BASIC, kLureDebugSounds, "SoundManager::findSound soundNumber=%d", soundNumber);
|
||||
ManagedList<SoundDescResource *>::iterator i;
|
||||
@ -499,6 +541,9 @@ void SoundManager::onTimer(void *data) {
|
||||
}
|
||||
|
||||
void SoundManager::doTimer() {
|
||||
if (_paused)
|
||||
return;
|
||||
|
||||
g_system->lockMutex(_soundMutex);
|
||||
|
||||
ManagedList<MidiMusic *>::iterator i;
|
||||
|
@ -118,6 +118,7 @@ private:
|
||||
bool _isPlaying;
|
||||
bool _nativeMT32;
|
||||
Common::MutexRef _soundMutex;
|
||||
bool _paused;
|
||||
|
||||
// Internal support methods
|
||||
void bellsBodge();
|
||||
@ -128,6 +129,9 @@ public:
|
||||
SoundManager();
|
||||
~SoundManager();
|
||||
|
||||
void saveToStream(WriteStream *stream);
|
||||
void loadFromStream(ReadStream *stream);
|
||||
|
||||
void loadSection(uint16 sectionId);
|
||||
void killSounds();
|
||||
void addSound(uint8 soundIndex, bool tidyFlag = true);
|
||||
@ -137,10 +141,14 @@ public:
|
||||
void setVolume(uint8 soundNumber, uint8 volume);
|
||||
void setVolume(uint8 volume);
|
||||
void tidySounds();
|
||||
uint8 descIndexOf(uint8 soundNumber);
|
||||
SoundDescResource *findSound(uint8 soundNumber);
|
||||
void removeSounds();
|
||||
void restoreSounds();
|
||||
void fadeOut();
|
||||
void pause() { _paused = true; }
|
||||
void resume() { _paused = false; }
|
||||
bool getPaused() { return _paused; }
|
||||
|
||||
// The following methods implement the external sound player module
|
||||
void musicInterface_Initialise();
|
||||
|
Loading…
Reference in New Issue
Block a user