aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorMartin Kiewitz2010-07-27 17:51:44 +0000
committerMartin Kiewitz2010-07-27 17:51:44 +0000
commitc422e39bf8caa0e95b3202e444cc0190d4708248 (patch)
treed2b188ddb0e0f20fb36c04ac643d75ff5dcf54f6 /engines
parentbbd3f0dbb3f76417237882ae8dfe5acfab73b50b (diff)
downloadscummvm-rg350-c422e39bf8caa0e95b3202e444cc0190d4708248.tar.gz
scummvm-rg350-c422e39bf8caa0e95b3202e444cc0190d4708248.tar.bz2
scummvm-rg350-c422e39bf8caa0e95b3202e444cc0190d4708248.zip
SCI: implemented kPalette(save/restore)
svn-id: r51381
Diffstat (limited to 'engines')
-rw-r--r--engines/sci/engine/kernel_tables.h2
-rw-r--r--engines/sci/engine/kgraphics.cpp6
-rw-r--r--engines/sci/engine/savegame.cpp16
-rw-r--r--engines/sci/graphics/helpers.h15
-rw-r--r--engines/sci/graphics/palette.cpp36
-rw-r--r--engines/sci/graphics/palette.h3
6 files changed, 57 insertions, 21 deletions
diff --git a/engines/sci/engine/kernel_tables.h b/engines/sci/engine/kernel_tables.h
index b684b17b02..ca4c8754a1 100644
--- a/engines/sci/engine/kernel_tables.h
+++ b/engines/sci/engine/kernel_tables.h
@@ -215,7 +215,7 @@ static const SciKernelMapSubEntry kPalette_subops[] = {
{ SIG_SCIALL, 5, MAP_CALL(PaletteFindColor), "iii", NULL },
{ SIG_SCIALL, 6, MAP_CALL(PaletteAnimate), "i*", NULL },
{ SIG_SCIALL, 7, MAP_CALL(PaletteSave), "", NULL },
- { SIG_SCIALL, 8, MAP_CALL(PaletteRestore), "i", NULL },
+ { SIG_SCIALL, 8, MAP_CALL(PaletteRestore), "[r0]", NULL },
SCI_SUBOPENTRY_TERMINATOR
};
diff --git a/engines/sci/engine/kgraphics.cpp b/engines/sci/engine/kgraphics.cpp
index 78fb78d42c..56518f10bf 100644
--- a/engines/sci/engine/kgraphics.cpp
+++ b/engines/sci/engine/kgraphics.cpp
@@ -616,16 +616,16 @@ reg_t kPaletteAnimate(EngineState *s, int argc, reg_t *argv) {
reg_t kPaletteSave(EngineState *s, int argc, reg_t *argv) {
if (g_sci->getResMan()->isVGA()) {
- warning("kPalette(7), save palette to heap STUB");
+ return g_sci->_gfxPalette->kernelSave();
}
return NULL_REG;
}
reg_t kPaletteRestore(EngineState *s, int argc, reg_t *argv) {
if (g_sci->getResMan()->isVGA()) {
- warning("kPalette(8), restore palette from heap STUB");
+ g_sci->_gfxPalette->kernelRestore(argv[0]);
}
- return s->r_acc;
+ return argv[0];
}
reg_t kPalVary(EngineState *s, int argc, reg_t *argv) {
diff --git a/engines/sci/engine/savegame.cpp b/engines/sci/engine/savegame.cpp
index 3de555cad3..806c8893b4 100644
--- a/engines/sci/engine/savegame.cpp
+++ b/engines/sci/engine/savegame.cpp
@@ -563,6 +563,18 @@ void StringTable::saveLoadWithSerializer(Common::Serializer &ser) {
}
#endif
+void GfxPalette::palVarySaveLoadPalette(Common::Serializer &s, Palette *palette) {
+ s.syncBytes(palette->mapping, 256);
+ s.syncAsUint32LE(palette->timestamp);
+ for (int i = 0; i < 256; 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);
+ }
+ s.syncBytes(palette->intensity, 256);
+}
+
void GfxPalette::saveLoadWithSerializer(Common::Serializer &s) {
if (s.getVersion() < 24)
return;
@@ -572,8 +584,8 @@ void GfxPalette::saveLoadWithSerializer(Common::Serializer &s) {
s.syncAsSint32LE(_palVaryResourceId);
if (_palVaryResourceId != -1) {
- _palVaryOriginPalette.saveLoadWithSerializer(s);
- _palVaryTargetPalette.saveLoadWithSerializer(s);
+ palVarySaveLoadPalette(s, &_palVaryOriginPalette);
+ palVarySaveLoadPalette(s, &_palVaryTargetPalette);
s.syncAsSint16LE(_palVaryStep);
s.syncAsSint16LE(_palVaryStepStop);
s.syncAsSint16LE(_palVaryDirection);
diff --git a/engines/sci/graphics/helpers.h b/engines/sci/graphics/helpers.h
index 115a4c996e..8f26ca296b 100644
--- a/engines/sci/graphics/helpers.h
+++ b/engines/sci/graphics/helpers.h
@@ -83,13 +83,6 @@ 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 {
@@ -97,14 +90,6 @@ 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.cpp b/engines/sci/graphics/palette.cpp
index 00d59c7b92..5c17f76558 100644
--- a/engines/sci/graphics/palette.cpp
+++ b/engines/sci/graphics/palette.cpp
@@ -488,6 +488,42 @@ void GfxPalette::kernelAnimateSet() {
setOnScreen();
}
+reg_t GfxPalette::kernelSave() {
+ SegManager *segMan = g_sci->getEngineState()->_segMan;
+ reg_t memoryId = segMan->allocateHunkEntry("kPalette(save)", 1024);
+ byte *memoryPtr = segMan->getHunkPointer(memoryId);
+ if (memoryPtr) {
+ for (int colorNr = 0; colorNr < 256; colorNr++) {
+ *memoryPtr++ = _sysPalette.colors[colorNr].used;
+ *memoryPtr++ = _sysPalette.colors[colorNr].r;
+ *memoryPtr++ = _sysPalette.colors[colorNr].g;
+ *memoryPtr++ = _sysPalette.colors[colorNr].b;
+ }
+ }
+ return memoryId;
+}
+
+void GfxPalette::kernelRestore(reg_t memoryHandle) {
+ SegManager *segMan = g_sci->getEngineState()->_segMan;
+ if (!memoryHandle.isNull()) {
+ byte *memoryPtr = segMan->getHunkPointer(memoryHandle);
+ if (!memoryPtr)
+ error("Bad handle used for kPalette(restore)");
+
+ Palette restoredPalette;
+
+ restoredPalette.timestamp = 0;
+ for (int colorNr = 0; colorNr < 256; colorNr++) {
+ restoredPalette.colors[colorNr].used = *memoryPtr++;
+ restoredPalette.colors[colorNr].r = *memoryPtr++;
+ restoredPalette.colors[colorNr].g = *memoryPtr++;
+ restoredPalette.colors[colorNr].b = *memoryPtr++;
+ }
+
+ set(&restoredPalette, true);
+ }
+}
+
void GfxPalette::kernelAssertPalette(GuiResourceId resourceId) {
// Sometimes invalid viewIds are asked for, ignore those (e.g. qfg1vga)
//if (!_resMan->testResource(ResourceId(kResourceTypeView, resourceId)))
diff --git a/engines/sci/graphics/palette.h b/engines/sci/graphics/palette.h
index b9cd308281..e10c10718d 100644
--- a/engines/sci/graphics/palette.h
+++ b/engines/sci/graphics/palette.h
@@ -63,6 +63,8 @@ public:
int16 kernelFindColor(uint16 r, uint16 g, uint16 b);
bool kernelAnimate(byte fromColor, byte toColor, int speed);
void kernelAnimateSet();
+ reg_t kernelSave();
+ void kernelRestore(reg_t memoryHandle);
void kernelAssertPalette(GuiResourceId resourceId);
void kernelSyncScreenPalette();
@@ -81,6 +83,7 @@ public:
Palette _sysPalette;
virtual void saveLoadWithSerializer(Common::Serializer &s);
+ void palVarySaveLoadPalette(Common::Serializer &s, Palette *palette);
private:
void palVaryInit();