From c422e39bf8caa0e95b3202e444cc0190d4708248 Mon Sep 17 00:00:00 2001 From: Martin Kiewitz Date: Tue, 27 Jul 2010 17:51:44 +0000 Subject: SCI: implemented kPalette(save/restore) svn-id: r51381 --- engines/sci/engine/kernel_tables.h | 2 +- engines/sci/engine/kgraphics.cpp | 6 +++--- engines/sci/engine/savegame.cpp | 16 ++++++++++++++-- 3 files changed, 18 insertions(+), 6 deletions(-) (limited to 'engines/sci/engine') 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); -- cgit v1.2.3