SCI: Now saving the kPalVary state inside savegames

svn-id: r51194
This commit is contained in:
Filippos Karapetis 2010-07-23 07:36:55 +00:00
parent 6da04bc13b
commit 3aa4f76ee4
4 changed files with 42 additions and 2 deletions

View File

@ -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;

View File

@ -36,7 +36,7 @@ namespace Sci {
struct EngineState;
enum {
CURRENT_SAVEGAME_VERSION = 23,
CURRENT_SAVEGAME_VERSION = 24,
MINIMUM_SAVEGAME_VERSION = 12
};

View File

@ -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 {

View File

@ -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();