From 3aa4f76ee422b42b6588296862e01eb3e8a50357 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Fri, 23 Jul 2010 07:36:55 +0000 Subject: SCI: Now saving the kPalVary state inside savegames svn-id: r51194 --- engines/sci/engine/savegame.cpp | 22 ++++++++++++++++++++++ engines/sci/engine/savegame.h | 2 +- engines/sci/graphics/helpers.h | 16 ++++++++++++++++ engines/sci/graphics/palette.h | 4 +++- 4 files changed, 42 insertions(+), 2 deletions(-) diff --git a/engines/sci/engine/savegame.cpp b/engines/sci/engine/savegame.cpp index c080120d7b..72f6ae28a7 100644 --- a/engines/sci/engine/savegame.cpp +++ b/engines/sci/engine/savegame.cpp @@ -40,6 +40,7 @@ #include "sci/engine/selector.h" #include "sci/engine/vm_types.h" #include "sci/engine/script.h" // for SCI_OBJ_EXPORTS and SCI_OBJ_SYNONYMS +#include "sci/graphics/palette.h" #include "sci/graphics/ports.h" #include "sci/sound/audio.h" #include "sci/sound/music.h" @@ -628,6 +629,27 @@ void StringTable::saveLoadWithSerializer(Common::Serializer &ser) { } #endif +void GfxPalette::saveLoadWithSerializer(Common::Serializer &s) { + if (s.getVersion() < 24) + return; + + if (s.isLoading() && _palVaryResourceId != -1) + palVaryRemoveTimer(); + + s.syncAsSint32LE(_palVaryResourceId); + _palVaryOriginPalette.saveLoadWithSerializer(s); + _palVaryTargetPalette.saveLoadWithSerializer(s); + s.syncAsSint16LE(_palVaryStep); + s.syncAsSint16LE(_palVaryStepStop); + s.syncAsSint16LE(_palVaryDirection); + s.syncAsUint16LE(_palVaryTicks); + s.syncAsSint32LE(_palVaryPaused); + s.syncAsSint32LE(_palVarySignal); + + if (s.isLoading() && _palVaryResourceId != -1) + palVaryInstallTimer(); +} + void SegManager::reconstructStack(EngineState *s) { DataStack *stack = (DataStack *)(_heap[findSegmentByType(SEG_TYPE_STACK)]); s->stack_base = stack->_entries; diff --git a/engines/sci/engine/savegame.h b/engines/sci/engine/savegame.h index 9a882f2bf7..799a68cbbe 100644 --- a/engines/sci/engine/savegame.h +++ b/engines/sci/engine/savegame.h @@ -36,7 +36,7 @@ namespace Sci { struct EngineState; enum { - CURRENT_SAVEGAME_VERSION = 23, + CURRENT_SAVEGAME_VERSION = 24, MINIMUM_SAVEGAME_VERSION = 12 }; diff --git a/engines/sci/graphics/helpers.h b/engines/sci/graphics/helpers.h index f0ffecfb59..115a4c996e 100644 --- a/engines/sci/graphics/helpers.h +++ b/engines/sci/graphics/helpers.h @@ -28,6 +28,7 @@ #include "common/endian.h" // for READ_LE_UINT16 #include "common/rect.h" +#include "common/serializer.h" #include "sci/engine/vm_types.h" namespace Sci { @@ -82,6 +83,13 @@ struct Window : public Port { struct Color { byte used; byte r, g, b; + + void saveLoadWithSerializer(Common::Serializer &s) { + s.syncAsByte(used); + s.syncAsByte(r); + s.syncAsByte(g); + s.syncAsByte(b); + } }; struct Palette { @@ -89,6 +97,14 @@ struct Palette { uint32 timestamp; Color colors[256]; byte intensity[256]; + + void saveLoadWithSerializer(Common::Serializer &s) { + s.syncBytes(mapping, 256); + s.syncAsUint32LE(timestamp); + for (int i = 0; i < 256; i++) + colors[i].saveLoadWithSerializer(s); + s.syncBytes(intensity, 256); + } }; struct PalSchedule { diff --git a/engines/sci/graphics/palette.h b/engines/sci/graphics/palette.h index 6af1d5a490..b9cd308281 100644 --- a/engines/sci/graphics/palette.h +++ b/engines/sci/graphics/palette.h @@ -34,7 +34,7 @@ class Screen; /** * Palette class, handles palette operations like changing intensity, setting up the palette, merging different palettes */ -class GfxPalette { +class GfxPalette : public Common::Serializable { public: GfxPalette(ResourceManager *resMan, GfxScreen *screen, bool useMerging); ~GfxPalette(); @@ -80,6 +80,8 @@ public: Palette _sysPalette; + virtual void saveLoadWithSerializer(Common::Serializer &s); + private: void palVaryInit(); void palVaryInstallTimer(); -- cgit v1.2.3