aboutsummaryrefslogtreecommitdiff
path: root/engines/kyra
diff options
context:
space:
mode:
authorJohannes Schickel2008-08-20 14:03:34 +0000
committerJohannes Schickel2008-08-20 14:03:34 +0000
commitf4fc8c3e4c1621e8c40392881a6c647f9915fa38 (patch)
treee4f8b46333677a458d790b511047d7a44b4abbc7 /engines/kyra
parenta79e9385a19530698e5c1cc1da39cb6b80cb9f74 (diff)
downloadscummvm-rg350-f4fc8c3e4c1621e8c40392881a6c647f9915fa38.tar.gz
scummvm-rg350-f4fc8c3e4c1621e8c40392881a6c647f9915fa38.tar.bz2
scummvm-rg350-f4fc8c3e4c1621e8c40392881a6c647f9915fa38.zip
Committed patch #2050337 "KYRA/SCUMM: Thumbnail support/improvement". (Without Max' compressed backward seeking support for now)
svn-id: r34053
Diffstat (limited to 'engines/kyra')
-rw-r--r--engines/kyra/detection.cpp2
-rw-r--r--engines/kyra/gui.h4
-rw-r--r--engines/kyra/gui_hof.cpp8
-rw-r--r--engines/kyra/gui_hof.h2
-rw-r--r--engines/kyra/gui_lok.cpp19
-rw-r--r--engines/kyra/gui_lok.h2
-rw-r--r--engines/kyra/gui_mr.cpp8
-rw-r--r--engines/kyra/gui_mr.h2
-rw-r--r--engines/kyra/gui_v2.cpp7
-rw-r--r--engines/kyra/kyra_hof.cpp2
-rw-r--r--engines/kyra/kyra_hof.h2
-rw-r--r--engines/kyra/kyra_lok.cpp4
-rw-r--r--engines/kyra/kyra_lok.h2
-rw-r--r--engines/kyra/kyra_mr.cpp2
-rw-r--r--engines/kyra/kyra_mr.h2
-rw-r--r--engines/kyra/kyra_v1.h6
-rw-r--r--engines/kyra/kyra_v2.cpp2
-rw-r--r--engines/kyra/kyra_v2.h2
-rw-r--r--engines/kyra/saveload.cpp26
-rw-r--r--engines/kyra/saveload_hof.cpp6
-rw-r--r--engines/kyra/saveload_lok.cpp6
-rw-r--r--engines/kyra/saveload_mr.cpp6
-rw-r--r--engines/kyra/screen_lok.cpp18
-rw-r--r--engines/kyra/screen_lok.h1
-rw-r--r--engines/kyra/script_mr.cpp2
-rw-r--r--engines/kyra/timer_mr.cpp2
26 files changed, 111 insertions, 34 deletions
diff --git a/engines/kyra/detection.cpp b/engines/kyra/detection.cpp
index 0c6eb29665..d41ecb5e9b 100644
--- a/engines/kyra/detection.cpp
+++ b/engines/kyra/detection.cpp
@@ -1117,7 +1117,7 @@ SaveStateList KyraMetaEngine::listSaves(const char *target) const {
if (slotNum >= 0 && slotNum <= 999) {
Common::InSaveFile *in = saveFileMan->openForLoading(file->c_str());
if (in) {
- if (Kyra::KyraEngine_v1::readSaveHeader(in, header) == Kyra::KyraEngine_v1::kRSHENoError)
+ if (Kyra::KyraEngine_v1::readSaveHeader(in, false, header) == Kyra::KyraEngine_v1::kRSHENoError)
saveList.push_back(SaveStateDescriptor(slotNum, header.description, *file));
delete in;
}
diff --git a/engines/kyra/gui.h b/engines/kyra/gui.h
index 1361bdb399..7db8f52f16 100644
--- a/engines/kyra/gui.h
+++ b/engines/kyra/gui.h
@@ -32,6 +32,8 @@
#include "common/array.h"
#include "common/func.h"
+#include "graphics/surface.h"
+
namespace Kyra {
#define BUTTON_FUNCTOR(type, x, y) Button::Callback(new Common::Functor1Mem<Button*, int, type>(x, y))
@@ -153,6 +155,8 @@ public:
void processHighlights(Menu &menu, int mouseX, int mouseY);
+ // utilities for thumbnail creation
+ virtual void createScreenThumbnail(Graphics::Surface &dst) = 0;
protected:
KyraEngine_v1 *_vm;
Screen *_screen;
diff --git a/engines/kyra/gui_hof.cpp b/engines/kyra/gui_hof.cpp
index 7d56743af5..fb2aa24e1e 100644
--- a/engines/kyra/gui_hof.cpp
+++ b/engines/kyra/gui_hof.cpp
@@ -33,6 +33,8 @@
#include "common/savefile.h"
+#include "graphics/scaler.h"
+
namespace Kyra {
void KyraEngine_HoF::loadButtonShapes() {
@@ -793,6 +795,10 @@ int GUI_HoF::optionsButton(Button *button) {
#pragma mark -
+void GUI_HoF::createScreenThumbnail(Graphics::Surface &dst) {
+ ::createThumbnail(&dst, _vm->_screenBuffer, Screen::SCREEN_W, Screen::SCREEN_H, _screen->getPalette(1));
+}
+
void GUI_HoF::setupPalette() {
memcpy(_screen->getPalette(1), _screen->getPalette(0), 768);
@@ -996,7 +1002,7 @@ int GUI_HoF::gameOptionsTalkie(Button *caller) {
if (_vm->_lang != lang) {
_reloadTemporarySave = true;
- _vm->saveGame(_vm->getSavegameFilename(999), "Temporary Kyrandia 2 Savegame");
+ _vm->saveGame(_vm->getSavegameFilename(999), "Temporary Kyrandia 2 Savegame", 0);
_vm->loadCCodeBuffer("C_CODE.XXX");
if (_vm->_flags.isTalkie)
_vm->loadOptionsBuffer("OPTIONS.XXX");
diff --git a/engines/kyra/gui_hof.h b/engines/kyra/gui_hof.h
index f64336a8f6..a9c0426a2b 100644
--- a/engines/kyra/gui_hof.h
+++ b/engines/kyra/gui_hof.h
@@ -41,6 +41,8 @@ public:
void initStaticData();
int optionsButton(Button *button);
+
+ void createScreenThumbnail(Graphics::Surface &dst);
private:
const char *getMenuTitle(const Menu &menu);
const char *getMenuItemTitle(const MenuItem &menuItem);
diff --git a/engines/kyra/gui_lok.cpp b/engines/kyra/gui_lok.cpp
index 47ce698e50..ca1c94e215 100644
--- a/engines/kyra/gui_lok.cpp
+++ b/engines/kyra/gui_lok.cpp
@@ -37,6 +37,8 @@
#include "common/events.h"
#include "common/system.h"
+#include "graphics/scaler.h"
+
namespace Kyra {
void KyraEngine_LoK::initMainButtonList() {
@@ -199,6 +201,15 @@ GUI_LoK::~GUI_LoK() {
delete[] _menu;
}
+void GUI_LoK::createScreenThumbnail(Graphics::Surface &dst) {
+ uint8 *screen = new uint8[Screen::SCREEN_W*Screen::SCREEN_H];
+ if (screen) {
+ _screen->queryPageFromDisk("SEENPAGE.TMP", 0, screen);
+ ::createThumbnail(&dst, screen, Screen::SCREEN_W, Screen::SCREEN_H, _screen->getPalette(2));
+ }
+ delete[] screen;
+}
+
int GUI_LoK::processButtonList(Button *list, uint16 inputFlag, int8 mouseWheel) {
while (list) {
if (list->flags & 8) {
@@ -736,8 +747,12 @@ int GUI_LoK::saveGame(Button *button) {
} else {
if (_savegameOffset == 0 && _vm->_gameToLoad == 0)
_vm->_gameToLoad = getNextSavegameSlot();
- if (_vm->_gameToLoad > 0)
- _vm->saveGame(_vm->getSavegameFilename(_vm->_gameToLoad), _savegameName);
+ if (_vm->_gameToLoad > 0) {
+ Graphics::Surface thumb;
+ createScreenThumbnail(thumb);
+ _vm->saveGame(_vm->getSavegameFilename(_vm->_gameToLoad), _savegameName, &thumb);
+ thumb.free();
+ }
}
return 0;
diff --git a/engines/kyra/gui_lok.h b/engines/kyra/gui_lok.h
index 16b7ef9183..0ce718d7a7 100644
--- a/engines/kyra/gui_lok.h
+++ b/engines/kyra/gui_lok.h
@@ -103,6 +103,8 @@ public:
int processButtonList(Button *buttonList, uint16 inputFlags, int8 mouseWheel);
int buttonMenuCallback(Button *caller);
+
+ void createScreenThumbnail(Graphics::Surface &dst);
private:
void initStaticResource();
diff --git a/engines/kyra/gui_mr.cpp b/engines/kyra/gui_mr.cpp
index 6822b303c3..7a84d7093a 100644
--- a/engines/kyra/gui_mr.cpp
+++ b/engines/kyra/gui_mr.cpp
@@ -33,6 +33,8 @@
#include "common/savefile.h"
+#include "graphics/scaler.h"
+
namespace Kyra {
void KyraEngine_MR::loadButtonShapes() {
@@ -1138,6 +1140,10 @@ int KyraEngine_MR::albumClose(Button *caller) {
GUI_MR::GUI_MR(KyraEngine_MR *vm) : GUI_v2(vm), _vm(vm), _screen(vm->_screen) {
}
+void GUI_MR::createScreenThumbnail(Graphics::Surface &dst) {
+ ::createThumbnail(&dst, _vm->_screenBuffer, Screen::SCREEN_W, Screen::SCREEN_H, _screen->getPalette(0));
+}
+
void GUI_MR::flagButtonEnable(Button *button) {
if (!button)
return;
@@ -1450,7 +1456,7 @@ int GUI_MR::gameOptions(Button *caller) {
if (_vm->_lang != lang) {
_reloadTemporarySave = true;
- _vm->saveGame(_vm->getSavegameFilename(999), "Temporary Kyrandia 3 Savegame");
+ _vm->saveGame(_vm->getSavegameFilename(999), "Temporary Kyrandia 3 Savegame", 0);
if (!_vm->loadLanguageFile("ITEMS.", _vm->_itemFile))
error("Couldn't load ITEMS");
if (!_vm->loadLanguageFile("SCORE.", _vm->_scoreFile))
diff --git a/engines/kyra/gui_mr.h b/engines/kyra/gui_mr.h
index 5bd3569031..a78d0559a6 100644
--- a/engines/kyra/gui_mr.h
+++ b/engines/kyra/gui_mr.h
@@ -47,6 +47,8 @@ public:
int redrawButtonCallback(Button *button);
int optionsButton(Button *button);
+
+ void createScreenThumbnail(Graphics::Surface &dst);
private:
void getInput();
diff --git a/engines/kyra/gui_v2.cpp b/engines/kyra/gui_v2.cpp
index e4cec760fa..e9d81f3b8a 100644
--- a/engines/kyra/gui_v2.cpp
+++ b/engines/kyra/gui_v2.cpp
@@ -618,7 +618,12 @@ int GUI_v2::saveMenu(Button *caller) {
restorePage1(_vm->_screenBuffer);
restorePalette();
- _vm->saveGame(_vm->getSavegameFilename(_saveSlot), _saveDescription);
+
+ Graphics::Surface thumb;
+ createScreenThumbnail(thumb);
+ _vm->saveGame(_vm->getSavegameFilename(_saveSlot), _saveDescription, &thumb);
+ thumb.free();
+
_displayMenu = false;
_madeSave = true;
diff --git a/engines/kyra/kyra_hof.cpp b/engines/kyra/kyra_hof.cpp
index 0271f5ea0d..2f8f2674e4 100644
--- a/engines/kyra/kyra_hof.cpp
+++ b/engines/kyra/kyra_hof.cpp
@@ -436,7 +436,7 @@ void KyraEngine_HoF::startup() {
if (_gameToLoad == -1) {
snd_playWanderScoreViaMap(52, 1);
enterNewScene(_mainCharacter.sceneId, _mainCharacter.facing, 0, 0, 1);
- saveGame(getSavegameFilename(0), "New Game");
+ saveGame(getSavegameFilename(0), "New Game", 0);
} else {
loadGame(getSavegameFilename(_gameToLoad));
}
diff --git a/engines/kyra/kyra_hof.h b/engines/kyra/kyra_hof.h
index f6e887c648..dc4161f0c1 100644
--- a/engines/kyra/kyra_hof.h
+++ b/engines/kyra/kyra_hof.h
@@ -907,7 +907,7 @@ protected:
int _dbgPass;
// save/load specific
- void saveGame(const char *fileName, const char *saveName);
+ void saveGame(const char *fileName, const char *saveName, const Graphics::Surface *thumbnail);
void loadGame(const char *fileName);
};
diff --git a/engines/kyra/kyra_lok.cpp b/engines/kyra/kyra_lok.cpp
index c852f6e3ee..3d228210b9 100644
--- a/engines/kyra/kyra_lok.cpp
+++ b/engines/kyra/kyra_lok.cpp
@@ -388,7 +388,7 @@ void KyraEngine_LoK::startup() {
_gui->buttonMenuCallback(0);
_menuDirectlyToLoad = false;
} else
- saveGame(getSavegameFilename(0), "New game");
+ saveGame(getSavegameFilename(0), "New game", 0);
} else {
_screen->setFont(Screen::FID_8_FNT);
loadGame(getSavegameFilename(_gameToLoad));
@@ -470,7 +470,7 @@ void KyraEngine_LoK::delay(uint32 amount, bool update, bool isMainLoop) {
else {
char savegameName[14];
sprintf(savegameName, "Quicksave %d", event.kbd.keycode - '0');
- saveGame(saveLoadSlot, savegameName);
+ saveGame(saveLoadSlot, savegameName, 0);
}
} else if (event.kbd.flags == Common::KBD_CTRL) {
if (event.kbd.keycode == 'd')
diff --git a/engines/kyra/kyra_lok.h b/engines/kyra/kyra_lok.h
index 1def95ddbf..e6fc0dc774 100644
--- a/engines/kyra/kyra_lok.h
+++ b/engines/kyra/kyra_lok.h
@@ -214,7 +214,7 @@ public:
protected:
int32 _speechPlayTime;
- void saveGame(const char *fileName, const char *saveName);
+ void saveGame(const char *fileName, const char *saveName, const Graphics::Surface *thumbnail);
void loadGame(const char *fileName);
protected:
diff --git a/engines/kyra/kyra_mr.cpp b/engines/kyra/kyra_mr.cpp
index a61253199b..9b9549b778 100644
--- a/engines/kyra/kyra_mr.cpp
+++ b/engines/kyra/kyra_mr.cpp
@@ -684,7 +684,7 @@ void KyraEngine_MR::startup() {
assert(_invWsa);
_invWsa->open("MOODOMTR.WSA", 1, 0);
_invWsaFrame = 6;
- saveGame(getSavegameFilename(0), (const char*)getTableEntry(_optionsFile, 33));
+ saveGame(getSavegameFilename(0), (const char*)getTableEntry(_optionsFile, 33), 0);
_soundDigital->beginFadeOut(_musicSoundChannel, 60);
delayWithTicks(60);
if (_gameToLoad == -1)
diff --git a/engines/kyra/kyra_mr.h b/engines/kyra/kyra_mr.h
index 5f9f6f91a3..a6fb9af20c 100644
--- a/engines/kyra/kyra_mr.h
+++ b/engines/kyra/kyra_mr.h
@@ -583,7 +583,7 @@ private:
int albumClose(Button *caller);
// save/load
- void saveGame(const char *fileName, const char *saveName);
+ void saveGame(const char *fileName, const char *saveName, const Graphics::Surface *thumbnail);
void loadGame(const char *fileName);
// opcodes
diff --git a/engines/kyra/kyra_v1.h b/engines/kyra/kyra_v1.h
index 738a3fc8ec..438d625503 100644
--- a/engines/kyra/kyra_v1.h
+++ b/engines/kyra/kyra_v1.h
@@ -290,6 +290,8 @@ protected:
bool originalSave; // savegame from original interpreter
bool oldHeader; // old scummvm save header
+
+ Graphics::Surface *thumbnail;
};
enum kReadSaveHeaderError {
@@ -299,10 +301,10 @@ protected:
kRSHEIoError = 3
};
- static kReadSaveHeaderError readSaveHeader(Common::SeekableReadStream *file, SaveHeader &header);
+ static kReadSaveHeaderError readSaveHeader(Common::SeekableReadStream *file, bool loadThumbnail, SaveHeader &header);
Common::SeekableReadStream *openSaveForReading(const char *filename, SaveHeader &header);
- Common::WriteStream *openSaveForWriting(const char *filename, const char *saveName) const;
+ Common::WriteStream *openSaveForWriting(const char *filename, const char *saveName, const Graphics::Surface *thumbnail) const;
};
} // End of namespace Kyra
diff --git a/engines/kyra/kyra_v2.cpp b/engines/kyra/kyra_v2.cpp
index 2e704f2aa2..4e1bf38991 100644
--- a/engines/kyra/kyra_v2.cpp
+++ b/engines/kyra/kyra_v2.cpp
@@ -186,7 +186,7 @@ int KyraEngine_v2::checkInput(Button *buttonList, bool mainLoop) {
} else {
char savegameName[14];
sprintf(savegameName, "Quicksave %d", event.kbd.keycode - '0');
- saveGame(saveLoadSlot, savegameName);
+ saveGame(saveLoadSlot, savegameName, 0);
}
} else if (event.kbd.flags == Common::KBD_CTRL) {
if (event.kbd.keycode == 'd')
diff --git a/engines/kyra/kyra_v2.h b/engines/kyra/kyra_v2.h
index 6fdf30fff8..e7f9634fc6 100644
--- a/engines/kyra/kyra_v2.h
+++ b/engines/kyra/kyra_v2.h
@@ -419,7 +419,7 @@ protected:
int o2_getVocHigh(EMCState *script);
// save/load specific
- virtual void saveGame(const char *fileName, const char *saveName) = 0;
+ virtual void saveGame(const char *fileName, const char *saveName, const Graphics::Surface *thumbnail) = 0;
virtual void loadGame(const char *fileName) = 0;
};
diff --git a/engines/kyra/saveload.cpp b/engines/kyra/saveload.cpp
index 31c5e15fa6..c08967c85c 100644
--- a/engines/kyra/saveload.cpp
+++ b/engines/kyra/saveload.cpp
@@ -26,10 +26,11 @@
#include "common/endian.h"
#include "common/savefile.h"
#include "common/system.h"
+#include "graphics/thumbnail.h"
#include "kyra/kyra_v1.h"
-#define CURRENT_SAVE_VERSION 13
+#define CURRENT_SAVE_VERSION 14
#define GF_FLOPPY (1 << 0)
#define GF_TALKIE (1 << 1)
@@ -37,7 +38,7 @@
namespace Kyra {
-KyraEngine_v1::kReadSaveHeaderError KyraEngine_v1::readSaveHeader(Common::SeekableReadStream *in, SaveHeader &header) {
+KyraEngine_v1::kReadSaveHeaderError KyraEngine_v1::readSaveHeader(Common::SeekableReadStream *in, bool loadThumbnail, SaveHeader &header) {
uint32 type = in->readUint32BE();
header.originalSave = false;
header.oldHeader = false;
@@ -108,6 +109,16 @@ KyraEngine_v1::kReadSaveHeaderError KyraEngine_v1::readSaveHeader(Common::Seekab
if (header.version >= 2)
header.flags = in->readUint32BE();
+ if (header.version >= 14) {
+ if (loadThumbnail) {
+ header.thumbnail = new Graphics::Surface();
+ assert(header.thumbnail);
+ Graphics::loadThumbnail(*in, *header.thumbnail);
+ } else {
+ Graphics::skipThumbnailHeader(*in);
+ }
+ }
+
return (in->ioFailed() ? kRSHEIoError : kRSHENoError);
}
@@ -118,7 +129,7 @@ Common::SeekableReadStream *KyraEngine_v1::openSaveForReading(const char *filena
if (!(in = _saveFileMan->openForLoading(filename)))
return 0;
- kReadSaveHeaderError errorCode = KyraEngine_v1::readSaveHeader(in, header);
+ kReadSaveHeaderError errorCode = KyraEngine_v1::readSaveHeader(in, false, header);
if (errorCode != kRSHENoError) {
if (errorCode == kRSHEInvalidType)
warning("No ScummVM Kyra engine savefile header.");
@@ -162,8 +173,8 @@ Common::SeekableReadStream *KyraEngine_v1::openSaveForReading(const char *filena
return in;
}
-Common::WriteStream *KyraEngine_v1::openSaveForWriting(const char *filename, const char *saveName) const {
- debugC(9, kDebugLevelMain, "KyraEngine_v1::openSaveForWriting('%s', '%s')", filename, saveName);
+Common::WriteStream *KyraEngine_v1::openSaveForWriting(const char *filename, const char *saveName, const Graphics::Surface *thumbnail) const {
+ debugC(9, kDebugLevelMain, "KyraEngine_v1::openSaveForWriting('%s', '%s', %p)", filename, saveName, (const void *)thumbnail);
if (_quitFlag)
return 0;
@@ -191,6 +202,11 @@ Common::WriteStream *KyraEngine_v1::openSaveForWriting(const char *filename, con
return 0;
}
+ if (thumbnail)
+ Graphics::saveThumbnail(*out, *thumbnail);
+ else
+ Graphics::saveThumbnail(*out);
+
return out;
}
diff --git a/engines/kyra/saveload_hof.cpp b/engines/kyra/saveload_hof.cpp
index 954cbccfa9..2b245f6167 100644
--- a/engines/kyra/saveload_hof.cpp
+++ b/engines/kyra/saveload_hof.cpp
@@ -35,10 +35,10 @@
namespace Kyra {
-void KyraEngine_HoF::saveGame(const char *fileName, const char *saveName) {
- debugC(9, kDebugLevelMain, "KyraEngine_HoF::saveGame('%s', '%s')", fileName, saveName);
+void KyraEngine_HoF::saveGame(const char *fileName, const char *saveName, const Graphics::Surface *thumb) {
+ debugC(9, kDebugLevelMain, "KyraEngine_LoK::saveGame('%s', '%s', %p)", fileName, saveName, (const void *)thumb);
- Common::OutSaveFile *out = openSaveForWriting(fileName, saveName);
+ Common::OutSaveFile *out = openSaveForWriting(fileName, saveName, thumb);
if (!out) {
warning("Can't open file '%s', game not loadable", fileName);
return;
diff --git a/engines/kyra/saveload_lok.cpp b/engines/kyra/saveload_lok.cpp
index 8af73acc61..f734ffd5d9 100644
--- a/engines/kyra/saveload_lok.cpp
+++ b/engines/kyra/saveload_lok.cpp
@@ -218,13 +218,13 @@ void KyraEngine_LoK::loadGame(const char *fileName) {
delete in;
}
-void KyraEngine_LoK::saveGame(const char *fileName, const char *saveName) {
- debugC(9, kDebugLevelMain, "KyraEngine_LoK::saveGame('%s', '%s')", fileName, saveName);
+void KyraEngine_LoK::saveGame(const char *fileName, const char *saveName, const Graphics::Surface *thumb) {
+ debugC(9, kDebugLevelMain, "KyraEngine_LoK::saveGame('%s', '%s', %p)", fileName, saveName, (const void *)thumb);
if (_quitFlag)
return;
- Common::OutSaveFile *out = openSaveForWriting(fileName, saveName);
+ Common::OutSaveFile *out = openSaveForWriting(fileName, saveName, thumb);
if (!out)
return;
diff --git a/engines/kyra/saveload_mr.cpp b/engines/kyra/saveload_mr.cpp
index 51efc33723..8849f99523 100644
--- a/engines/kyra/saveload_mr.cpp
+++ b/engines/kyra/saveload_mr.cpp
@@ -32,10 +32,10 @@
namespace Kyra {
-void KyraEngine_MR::saveGame(const char *fileName, const char *saveName) {
- debugC(9, kDebugLevelMain, "KyraEngine_MR::saveGame('%s', '%s')", fileName, saveName);
+void KyraEngine_MR::saveGame(const char *fileName, const char *saveName, const Graphics::Surface *thumb) {
+ debugC(9, kDebugLevelMain, "KyraEngine_LoK::saveGame('%s', '%s', %p)", fileName, saveName, (const void *)thumb);
- Common::OutSaveFile *out = openSaveForWriting(fileName, saveName);
+ Common::OutSaveFile *out = openSaveForWriting(fileName, saveName, thumb);
if (!out) {
warning("Can't open file '%s', game not loadable", fileName);
return;
diff --git a/engines/kyra/screen_lok.cpp b/engines/kyra/screen_lok.cpp
index 011c90dde9..da88abc61f 100644
--- a/engines/kyra/screen_lok.cpp
+++ b/engines/kyra/screen_lok.cpp
@@ -147,8 +147,14 @@ void Screen_LoK::savePageToDisk(const char *file, int page) {
void Screen_LoK::loadPageFromDisk(const char *file, int page) {
debugC(9, kDebugLevelScreen, "Screen_LoK::loadPageFromDisk('%s', %d)", file, page);
+ if (!_saveLoadPage[page/2]) {
+ warning("trying to restore page %d, but no backup found", page);
+ return;
+ }
+
copyBlockToPage(page, 0, 0, SCREEN_W, SCREEN_H, _saveLoadPage[page/2]);
delete[] _saveLoadPage[page/2];
+ _saveLoadPage[page/2] = 0;
if (_saveLoadPageOvl[page/2]) {
uint8 *dstPage = getOverlayPtr(page);
@@ -160,7 +166,17 @@ void Screen_LoK::loadPageFromDisk(const char *file, int page) {
memcpy(dstPage, _saveLoadPageOvl[page/2], SCREEN_OVL_SJIS_SIZE);
delete[] _saveLoadPageOvl[page/2];
_saveLoadPageOvl[page/2] = 0;
- } _saveLoadPage[page/2] = 0;
+ }
+}
+
+void Screen_LoK::queryPageFromDisk(const char *file, int page, uint8 *buffer) {
+ debugC(9, kDebugLevelScreen, "Screen_LoK::queryPageFromDisk('%s', %d, %p)", file, page, (const void *)buffer);
+ if (!_saveLoadPage[page/2]) {
+ warning("trying to query page %d, but no backup found", page);
+ return;
+ }
+
+ memcpy(buffer, _saveLoadPage[page/2], SCREEN_W*SCREEN_H);
}
void Screen_LoK::deletePageFromDisk(int page) {
diff --git a/engines/kyra/screen_lok.h b/engines/kyra/screen_lok.h
index 74df23a543..5b4b8a9266 100644
--- a/engines/kyra/screen_lok.h
+++ b/engines/kyra/screen_lok.h
@@ -50,6 +50,7 @@ public:
void savePageToDisk(const char *file, int page);
void loadPageFromDisk(const char *file, int page);
+ void queryPageFromDisk(const char *file, int page, uint8 *buffer);
void deletePageFromDisk(int page);
void copyBackgroundBlock(int x, int page, int flag);
diff --git a/engines/kyra/script_mr.cpp b/engines/kyra/script_mr.cpp
index 9a059ead2a..cf2d2aceb1 100644
--- a/engines/kyra/script_mr.cpp
+++ b/engines/kyra/script_mr.cpp
@@ -293,7 +293,7 @@ int KyraEngine_MR::o3_updateScore(EMCState *script) {
int KyraEngine_MR::o3_makeSecondChanceSave(EMCState *script) {
debugC(3, kDebugLevelScriptFuncs, "KyraEngine_MR::o3_makeSecondChanceSave(%p) ()", (const void *)script);
- saveGame(getSavegameFilename(999), "SECOND CHANCE SAVE GAME");
+ saveGame(getSavegameFilename(999), "SECOND CHANCE SAVE GAME", 0);
return 0;
}
diff --git a/engines/kyra/timer_mr.cpp b/engines/kyra/timer_mr.cpp
index 37a910ccf2..ea7f64fed1 100644
--- a/engines/kyra/timer_mr.cpp
+++ b/engines/kyra/timer_mr.cpp
@@ -65,7 +65,7 @@ void KyraEngine_MR::timerRunSceneScript7(int arg) {
void KyraEngine_MR::timerFleaDeath(int arg) {
debugC(9, kDebugLevelMain | kDebugLevelTimer, "KyraEngine_MR::timerFleaDeath(%d)", arg);
_timer->setCountdown(4, 5400);
- saveGame(getSavegameFilename(999), "SECOND CHANCE SAVE GAME");
+ saveGame(getSavegameFilename(999), "SECOND CHANCE SAVE GAME", 0);
_screen->hideMouse();
_timer->disable(4);
runAnimationScript("FLEADTH1.EMC", 0, 0, 1, 1);