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);
|
Resources::getReference().saveToStream(f);
|
||||||
Game::getReference().saveToStream(f);
|
Game::getReference().saveToStream(f);
|
||||||
|
Sound.saveToStream(f);
|
||||||
Room::getReference().saveToStream(f);
|
Room::getReference().saveToStream(f);
|
||||||
Fights.saveToStream(f);
|
Fights.saveToStream(f);
|
||||||
|
|
||||||
@ -207,6 +208,7 @@ bool LureEngine::loadGame(uint8 slotNumber) {
|
|||||||
// Load in the data
|
// Load in the data
|
||||||
Resources::getReference().loadFromStream(f);
|
Resources::getReference().loadFromStream(f);
|
||||||
Game::getReference().loadFromStream(f);
|
Game::getReference().loadFromStream(f);
|
||||||
|
Sound.loadFromStream(f);
|
||||||
Room::getReference().loadFromStream(f);
|
Room::getReference().loadFromStream(f);
|
||||||
Fights.loadFromStream(f);
|
Fights.loadFromStream(f);
|
||||||
|
|
||||||
|
@ -42,6 +42,7 @@ SoundManager::SoundManager() {
|
|||||||
_descs = Disk::getReference().getEntry(SOUND_DESC_RESOURCE_ID);
|
_descs = Disk::getReference().getEntry(SOUND_DESC_RESOURCE_ID);
|
||||||
_numDescs = _descs->size() / sizeof(SoundDescResource);
|
_numDescs = _descs->size() / sizeof(SoundDescResource);
|
||||||
_soundData = NULL;
|
_soundData = NULL;
|
||||||
|
_paused = false;
|
||||||
|
|
||||||
int midiDriver = MidiDriver::detectMusicDriver(MDT_MIDI | MDT_ADLIB | MDT_PREFER_MIDI);
|
int midiDriver = MidiDriver::detectMusicDriver(MDT_MIDI | MDT_ADLIB | MDT_PREFER_MIDI);
|
||||||
_nativeMT32 = ((midiDriver == MD_MT32) || ConfMan.getBool("native_mt32"));
|
_nativeMT32 = ((midiDriver == MD_MT32) || ConfMan.getBool("native_mt32"));
|
||||||
@ -87,6 +88,36 @@ SoundManager::~SoundManager() {
|
|||||||
g_system->deleteMutex(_soundMutex);
|
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) {
|
void SoundManager::loadSection(uint16 sectionId) {
|
||||||
debugC(ERROR_BASIC, kLureDebugSounds, "SoundManager::loadSection = %xh", sectionId);
|
debugC(ERROR_BASIC, kLureDebugSounds, "SoundManager::loadSection = %xh", sectionId);
|
||||||
killSounds();
|
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) {
|
SoundDescResource *SoundManager::findSound(uint8 soundNumber) {
|
||||||
debugC(ERROR_BASIC, kLureDebugSounds, "SoundManager::findSound soundNumber=%d", soundNumber);
|
debugC(ERROR_BASIC, kLureDebugSounds, "SoundManager::findSound soundNumber=%d", soundNumber);
|
||||||
ManagedList<SoundDescResource *>::iterator i;
|
ManagedList<SoundDescResource *>::iterator i;
|
||||||
@ -499,6 +541,9 @@ void SoundManager::onTimer(void *data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SoundManager::doTimer() {
|
void SoundManager::doTimer() {
|
||||||
|
if (_paused)
|
||||||
|
return;
|
||||||
|
|
||||||
g_system->lockMutex(_soundMutex);
|
g_system->lockMutex(_soundMutex);
|
||||||
|
|
||||||
ManagedList<MidiMusic *>::iterator i;
|
ManagedList<MidiMusic *>::iterator i;
|
||||||
|
@ -118,6 +118,7 @@ private:
|
|||||||
bool _isPlaying;
|
bool _isPlaying;
|
||||||
bool _nativeMT32;
|
bool _nativeMT32;
|
||||||
Common::MutexRef _soundMutex;
|
Common::MutexRef _soundMutex;
|
||||||
|
bool _paused;
|
||||||
|
|
||||||
// Internal support methods
|
// Internal support methods
|
||||||
void bellsBodge();
|
void bellsBodge();
|
||||||
@ -128,6 +129,9 @@ public:
|
|||||||
SoundManager();
|
SoundManager();
|
||||||
~SoundManager();
|
~SoundManager();
|
||||||
|
|
||||||
|
void saveToStream(WriteStream *stream);
|
||||||
|
void loadFromStream(ReadStream *stream);
|
||||||
|
|
||||||
void loadSection(uint16 sectionId);
|
void loadSection(uint16 sectionId);
|
||||||
void killSounds();
|
void killSounds();
|
||||||
void addSound(uint8 soundIndex, bool tidyFlag = true);
|
void addSound(uint8 soundIndex, bool tidyFlag = true);
|
||||||
@ -137,10 +141,14 @@ public:
|
|||||||
void setVolume(uint8 soundNumber, uint8 volume);
|
void setVolume(uint8 soundNumber, uint8 volume);
|
||||||
void setVolume(uint8 volume);
|
void setVolume(uint8 volume);
|
||||||
void tidySounds();
|
void tidySounds();
|
||||||
|
uint8 descIndexOf(uint8 soundNumber);
|
||||||
SoundDescResource *findSound(uint8 soundNumber);
|
SoundDescResource *findSound(uint8 soundNumber);
|
||||||
void removeSounds();
|
void removeSounds();
|
||||||
void restoreSounds();
|
void restoreSounds();
|
||||||
void fadeOut();
|
void fadeOut();
|
||||||
|
void pause() { _paused = true; }
|
||||||
|
void resume() { _paused = false; }
|
||||||
|
bool getPaused() { return _paused; }
|
||||||
|
|
||||||
// The following methods implement the external sound player module
|
// The following methods implement the external sound player module
|
||||||
void musicInterface_Initialise();
|
void musicInterface_Initialise();
|
||||||
|
Loading…
Reference in New Issue
Block a user