diff options
Diffstat (limited to 'engines/sci/engine/savegame.cpp')
-rw-r--r-- | engines/sci/engine/savegame.cpp | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/engines/sci/engine/savegame.cpp b/engines/sci/engine/savegame.cpp index 09ccff39ac..3103be1463 100644 --- a/engines/sci/engine/savegame.cpp +++ b/engines/sci/engine/savegame.cpp @@ -47,6 +47,7 @@ #include "sci/sound/music.h" #ifdef ENABLE_SCI32 +#include "sci/graphics/palette32.h" #include "sci/graphics/frameout.h" #endif @@ -304,6 +305,7 @@ void EngineState::saveLoadWithSerializer(Common::Serializer &s) { _segMan->saveLoadWithSerializer(s); g_sci->_soundCmd->syncPlayList(s); + // NOTE: This will be GfxPalette32 for SCI32 engine games g_sci->_gfxPalette16->saveLoadWithSerializer(s); } @@ -721,6 +723,91 @@ void GfxPalette::saveLoadWithSerializer(Common::Serializer &s) { } } +#ifdef ENABLE_SCI32 +void saveLoadPalette32(Common::Serializer &s, Palette *const palette) { + s.syncAsUint32LE(palette->timestamp); + for (int i = 0; i < ARRAYSIZE(palette->colors); ++i) { + s.syncAsByte(palette->colors[i].used); + s.syncAsByte(palette->colors[i].r); + s.syncAsByte(palette->colors[i].g); + s.syncAsByte(palette->colors[i].b); + } +} + +void saveLoadOptionalPalette32(Common::Serializer &s, Palette **const palette) { + bool hasPalette; + if (s.isSaving()) { + hasPalette = (*palette != nullptr); + } + s.syncAsByte(hasPalette); + if (hasPalette) { + if (s.isLoading()) { + *palette = new Palette; + } + saveLoadPalette32(s, *palette); + } +} + +void GfxPalette32::saveLoadWithSerializer(Common::Serializer &s) { + if (s.getVersion() < 34) { + return; + } + + if (s.isLoading()) { + ++_version; + } + + s.syncAsSint16LE(_varyDirection); + s.syncAsSint16LE(_varyPercent); + s.syncAsSint16LE(_varyTargetPercent); + s.syncAsSint16LE(_varyFromColor); + s.syncAsSint16LE(_varyToColor); + s.syncAsUint16LE(_varyNumTimesPaused); + s.syncAsByte(_versionUpdated); + s.syncAsSint32LE(_varyTime); + s.syncAsUint32LE(_varyLastTick); + + for (int i = 0; i < ARRAYSIZE(_fadeTable); ++i) { + s.syncAsByte(_fadeTable[i]); + } + for (int i = 0; i < ARRAYSIZE(_cycleMap); ++i) { + s.syncAsByte(_cycleMap[i]); + } + + saveLoadOptionalPalette32(s, &_varyTargetPalette); + saveLoadOptionalPalette32(s, &_varyStartPalette); + // NOTE: _sourcePalette and _nextPalette are not saved + // by SCI engine + + for (int i = 0; i < ARRAYSIZE(_cyclers); ++i) { + PalCycler *cycler; + + bool hasCycler; + if (s.isSaving()) { + cycler = _cyclers[i]; + hasCycler = (cycler != nullptr); + } + s.syncAsByte(hasCycler); + + if (hasCycler) { + if (s.isLoading()) { + _cyclers[i] = cycler = new PalCycler; + } + + s.syncAsByte(cycler->fromColor); + s.syncAsUint16LE(cycler->numColorsToCycle); + s.syncAsByte(cycler->currentCycle); + s.syncAsByte(cycler->direction); + s.syncAsUint32LE(cycler->lastUpdateTick); + s.syncAsSint16LE(cycler->delay); + s.syncAsUint16LE(cycler->numTimesPaused); + } + } + + // TODO: _clutTable +} +#endif + void GfxPorts::saveLoadWithSerializer(Common::Serializer &s) { // reset() is called directly way earlier in gamestate_restore() if (s.getVersion() >= 27) { |