2007-05-30 21:56:52 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
2001-10-09 14:30:12 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2005-10-18 01:30:26 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2001-10-09 14:30:12 +00:00
|
|
|
*
|
2006-02-11 09:55:41 +00:00
|
|
|
* $URL$
|
|
|
|
* $Id$
|
2001-10-09 14:30:12 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2003-10-08 21:59:23 +00:00
|
|
|
#include "common/config-manager.h"
|
2010-11-19 17:03:07 +00:00
|
|
|
#include "common/memstream.h"
|
2005-01-10 22:06:49 +00:00
|
|
|
#include "common/savefile.h"
|
|
|
|
#include "common/system.h"
|
2009-03-16 04:45:12 +00:00
|
|
|
#include "common/zlib.h"
|
2003-09-11 10:32:15 +00:00
|
|
|
|
|
|
|
#include "scumm/actor.h"
|
|
|
|
#include "scumm/charset.h"
|
2004-01-06 17:28:29 +00:00
|
|
|
#include "scumm/imuse_digi/dimuse.h"
|
2006-02-20 20:57:26 +00:00
|
|
|
#include "scumm/imuse/imuse.h"
|
2010-08-18 21:38:43 +00:00
|
|
|
#include "player_towns.h"
|
2006-02-15 00:57:50 +00:00
|
|
|
#include "scumm/he/intern_he.h"
|
2003-09-11 10:32:15 +00:00
|
|
|
#include "scumm/object.h"
|
|
|
|
#include "scumm/resource.h"
|
|
|
|
#include "scumm/saveload.h"
|
2009-03-20 16:33:58 +00:00
|
|
|
#include "scumm/scumm_v0.h"
|
|
|
|
#include "scumm/scumm_v7.h"
|
2003-09-11 10:32:15 +00:00
|
|
|
#include "scumm/sound.h"
|
2006-02-15 00:57:50 +00:00
|
|
|
#include "scumm/he/sprite_he.h"
|
2003-09-11 10:32:15 +00:00
|
|
|
#include "scumm/verbs.h"
|
|
|
|
|
2003-06-15 00:54:14 +00:00
|
|
|
#include "sound/mixer.h"
|
2001-10-09 14:30:12 +00:00
|
|
|
|
2010-11-08 23:07:42 +00:00
|
|
|
#include "backends/audiocd/audiocd.h"
|
|
|
|
|
2008-08-20 15:08:00 +00:00
|
|
|
#include "graphics/thumbnail.h"
|
|
|
|
|
2003-10-03 18:33:57 +00:00
|
|
|
namespace Scumm {
|
|
|
|
|
2001-10-16 10:01:48 +00:00
|
|
|
struct SaveGameHeader {
|
|
|
|
uint32 type;
|
|
|
|
uint32 size;
|
|
|
|
uint32 ver;
|
2001-11-09 18:54:15 +00:00
|
|
|
char name[32];
|
2001-10-16 10:01:48 +00:00
|
|
|
};
|
|
|
|
|
2005-10-01 21:13:38 +00:00
|
|
|
struct SaveInfoSection {
|
|
|
|
uint32 type;
|
|
|
|
uint32 version;
|
|
|
|
uint32 size;
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2005-10-12 17:59:12 +00:00
|
|
|
uint32 timeTValue; // Obsolete since version 2, but kept for compatibility
|
2005-10-01 21:13:38 +00:00
|
|
|
uint32 playtime;
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2005-10-12 17:59:12 +00:00
|
|
|
uint32 date;
|
|
|
|
uint16 time;
|
2006-07-21 21:25:17 +00:00
|
|
|
};
|
2005-10-01 21:13:38 +00:00
|
|
|
|
2006-07-22 16:19:00 +00:00
|
|
|
#define SaveInfoSectionSize (4+4+4 + 4+4 + 4+2)
|
|
|
|
|
2005-10-12 17:59:12 +00:00
|
|
|
#define INFOSECTION_VERSION 2
|
2002-03-14 14:45:04 +00:00
|
|
|
|
2008-08-20 15:08:00 +00:00
|
|
|
#pragma mark -
|
|
|
|
|
2008-11-06 17:05:54 +00:00
|
|
|
Common::Error ScummEngine::loadGameState(int slot) {
|
2008-11-06 15:41:38 +00:00
|
|
|
requestLoad(slot);
|
2008-11-06 17:05:54 +00:00
|
|
|
return Common::kNoError;
|
2008-11-06 15:41:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ScummEngine::canLoadGameStateCurrently() {
|
2008-11-11 10:25:29 +00:00
|
|
|
// FIXME: For now always allow loading in V0-V3 games
|
|
|
|
// FIXME: Actually, we might wish to support loading in more places.
|
|
|
|
// As long as we are sure it won't cause any problems... Are we
|
|
|
|
// aware of *any* spots where loading is not supported?
|
2009-07-23 10:33:13 +00:00
|
|
|
|
|
|
|
// HE games are limited to original load and save interface only,
|
|
|
|
// due to numerous glitches (see bug #1726909) that can occur.
|
2010-04-04 09:36:10 +00:00
|
|
|
//
|
|
|
|
// Except the earliest HE Games (3DO and initial DOS version of
|
|
|
|
// puttputt), which didn't offer scripted load/save screens.
|
|
|
|
if (_game.heversion >= 62)
|
2009-07-23 10:33:13 +00:00
|
|
|
return false;
|
|
|
|
|
2009-07-29 19:39:03 +00:00
|
|
|
// COMI always disables saving/loading (to tell the truth:
|
|
|
|
// the main menu) via its scripts, thus we need to make an
|
|
|
|
// exception here. This the same forced overwriting of the
|
|
|
|
// script decisions as in ScummEngine::processKeyboard.
|
|
|
|
if (_game.id == GID_CMI)
|
|
|
|
return true;
|
|
|
|
|
2008-11-11 10:25:29 +00:00
|
|
|
return (VAR_MAINMENU_KEY == 0xFF || VAR(VAR_MAINMENU_KEY) != 0);
|
2008-11-06 15:41:38 +00:00
|
|
|
}
|
|
|
|
|
2008-11-06 17:05:54 +00:00
|
|
|
Common::Error ScummEngine::saveGameState(int slot, const char *desc) {
|
2008-11-06 15:41:38 +00:00
|
|
|
requestSave(slot, desc);
|
2008-11-06 17:05:54 +00:00
|
|
|
return Common::kNoError;
|
2008-11-06 15:41:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ScummEngine::canSaveGameStateCurrently() {
|
2008-11-11 10:25:29 +00:00
|
|
|
// FIXME: For now always allow loading in V0-V3 games
|
|
|
|
// TODO: Should we disallow saving in some more places,
|
|
|
|
// e.g. when a SAN movie is playing? Not sure whether the
|
|
|
|
// original EXE allowed this.
|
2009-07-23 05:48:20 +00:00
|
|
|
|
2009-07-23 10:33:13 +00:00
|
|
|
// HE games are limited to original load and save interface only,
|
|
|
|
// due to numerous glitches (see bug #1726909) that can occur.
|
2010-04-04 09:36:10 +00:00
|
|
|
//
|
|
|
|
// Except the earliest HE Games (3DO and initial DOS version of
|
|
|
|
// puttputt), which didn't offer scripted load/save screens.
|
|
|
|
if (_game.heversion >= 62)
|
2009-07-23 10:33:13 +00:00
|
|
|
return false;
|
|
|
|
|
2009-07-29 19:39:03 +00:00
|
|
|
// COMI always disables saving/loading (to tell the truth:
|
|
|
|
// the main menu) via its scripts, thus we need to make an
|
|
|
|
// exception here. This the same forced overwriting of the
|
|
|
|
// script decisions as in ScummEngine::processKeyboard.
|
|
|
|
if (_game.id == GID_CMI)
|
|
|
|
return true;
|
|
|
|
|
2009-09-11 10:13:54 +00:00
|
|
|
// SCUMM v4+ doesn't allow saving in room 0 or if
|
2009-07-23 05:48:20 +00:00
|
|
|
// VAR(VAR_MAINMENU_KEY) to set to zero.
|
|
|
|
return (VAR_MAINMENU_KEY == 0xFF || (VAR(VAR_MAINMENU_KEY) != 0 && _currentRoom != 0));
|
2008-11-06 15:41:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ScummEngine::requestSave(int slot, const char *name) {
|
2003-02-08 01:27:21 +00:00
|
|
|
_saveLoadSlot = slot;
|
2008-11-06 15:41:38 +00:00
|
|
|
_saveTemporaryState = false;
|
2003-02-08 01:27:21 +00:00
|
|
|
_saveLoadFlag = 1; // 1 for save
|
2003-11-05 11:37:04 +00:00
|
|
|
assert(name);
|
2005-11-07 22:57:31 +00:00
|
|
|
strncpy(_saveLoadName, name, sizeof(_saveLoadName));
|
2009-09-11 10:13:54 +00:00
|
|
|
_saveLoadName[sizeof(_saveLoadName) - 1] = 0;
|
2003-02-08 01:27:21 +00:00
|
|
|
}
|
|
|
|
|
2003-10-02 22:42:03 +00:00
|
|
|
void ScummEngine::requestLoad(int slot) {
|
2003-02-08 01:27:21 +00:00
|
|
|
_saveLoadSlot = slot;
|
2004-01-31 22:12:35 +00:00
|
|
|
_saveTemporaryState = false;
|
2003-02-08 01:27:21 +00:00
|
|
|
_saveLoadFlag = 2; // 2 for load
|
|
|
|
}
|
|
|
|
|
2007-11-06 12:22:52 +00:00
|
|
|
static bool saveSaveGameHeader(Common::OutSaveFile *out, SaveGameHeader &hdr) {
|
|
|
|
hdr.type = MKID_BE('SCVM');
|
|
|
|
hdr.size = 0;
|
|
|
|
hdr.ver = CURRENT_VER;
|
|
|
|
|
|
|
|
out->writeUint32BE(hdr.type);
|
|
|
|
out->writeUint32LE(hdr.size);
|
|
|
|
out->writeUint32LE(hdr.ver);
|
|
|
|
out->write(hdr.name, sizeof(hdr.name));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-03-16 04:45:12 +00:00
|
|
|
bool ScummEngine::saveState(Common::OutSaveFile *out, bool writeHeader) {
|
|
|
|
SaveGameHeader hdr;
|
|
|
|
|
|
|
|
if (writeHeader) {
|
|
|
|
memcpy(hdr.name, _saveLoadName, sizeof(hdr.name));
|
|
|
|
saveSaveGameHeader(out, hdr);
|
|
|
|
}
|
2009-12-30 21:11:38 +00:00
|
|
|
#if !defined(__DS__) && !defined(__N64__) /* && !defined(__PLAYSTATION2__) */
|
2009-03-16 04:45:12 +00:00
|
|
|
Graphics::saveThumbnail(*out);
|
|
|
|
#endif
|
|
|
|
saveInfos(out);
|
|
|
|
|
|
|
|
Serializer ser(0, out, CURRENT_VER);
|
|
|
|
saveOrLoad(&ser);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2004-06-25 21:48:12 +00:00
|
|
|
bool ScummEngine::saveState(int slot, bool compat) {
|
2009-03-16 04:45:12 +00:00
|
|
|
bool saveFailed;
|
2008-09-14 21:34:49 +00:00
|
|
|
Common::String filename;
|
2005-05-10 23:17:38 +00:00
|
|
|
Common::OutSaveFile *out;
|
2001-11-09 18:54:15 +00:00
|
|
|
|
2010-04-11 21:30:57 +00:00
|
|
|
pauseEngine(true);
|
|
|
|
|
2007-11-06 12:22:52 +00:00
|
|
|
if (_saveLoadSlot == 255) {
|
|
|
|
// Allow custom filenames for save game system in HE Games
|
2008-09-14 21:34:49 +00:00
|
|
|
filename = _saveLoadFileName;
|
2007-11-06 12:22:52 +00:00
|
|
|
} else {
|
2008-09-14 21:34:49 +00:00
|
|
|
filename = makeSavegameName(slot, compat);
|
2007-11-06 12:22:52 +00:00
|
|
|
}
|
2009-05-29 14:38:22 +00:00
|
|
|
if (!(out = _saveFileMan->openForSaving(filename)))
|
2001-10-09 14:30:12 +00:00
|
|
|
return false;
|
2001-10-16 10:01:48 +00:00
|
|
|
|
2009-03-16 04:45:12 +00:00
|
|
|
saveFailed = false;
|
|
|
|
if (!saveState(out))
|
|
|
|
saveFailed = true;
|
2001-10-16 10:01:48 +00:00
|
|
|
|
2007-02-17 18:55:51 +00:00
|
|
|
out->finalize();
|
2009-03-16 04:45:12 +00:00
|
|
|
if (out->err())
|
|
|
|
saveFailed = true;
|
|
|
|
delete out;
|
|
|
|
|
|
|
|
if (saveFailed) {
|
2008-09-14 21:34:49 +00:00
|
|
|
debug(1, "State save as '%s' FAILED", filename.c_str());
|
2005-10-13 18:50:53 +00:00
|
|
|
return false;
|
|
|
|
}
|
2008-09-14 21:34:49 +00:00
|
|
|
debug(1, "State saved as '%s'", filename.c_str());
|
2010-04-11 21:30:57 +00:00
|
|
|
|
|
|
|
pauseEngine(false);
|
|
|
|
|
2001-10-09 14:30:12 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-03-16 04:45:12 +00:00
|
|
|
|
2009-04-19 01:01:54 +00:00
|
|
|
void ScummEngine_v4::prepareSavegame() {
|
2009-03-16 04:45:12 +00:00
|
|
|
Common::MemoryWriteStreamDynamic *memStream;
|
|
|
|
Common::WriteStream *writeStream;
|
|
|
|
|
|
|
|
// free memory of the last prepared savegame
|
|
|
|
delete _savePreparedSavegame;
|
|
|
|
_savePreparedSavegame = NULL;
|
|
|
|
|
|
|
|
// store headerless savegame in a compressed memory stream
|
|
|
|
memStream = new Common::MemoryWriteStreamDynamic();
|
|
|
|
writeStream = Common::wrapCompressedWriteStream(memStream);
|
|
|
|
if (saveState(writeStream, false)) {
|
|
|
|
// we have to finalize the compression-stream first, otherwise the internal
|
|
|
|
// memory-stream pointer will be zero (Important: flush() does not work here!).
|
|
|
|
writeStream->finalize();
|
|
|
|
if (!writeStream->err()) {
|
|
|
|
// wrap uncompressing MemoryReadStream around the savegame data
|
|
|
|
_savePreparedSavegame = Common::wrapCompressedReadStream(
|
2010-01-08 22:07:35 +00:00
|
|
|
new Common::MemoryReadStream(memStream->getData(), memStream->size(), DisposeAfterUse::YES));
|
2009-03-16 04:45:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
// free the CompressedWriteStream and MemoryWriteStreamDynamic
|
|
|
|
// but not the memory stream's internal buffer
|
|
|
|
delete writeStream;
|
|
|
|
}
|
|
|
|
|
2009-04-19 01:01:54 +00:00
|
|
|
bool ScummEngine_v4::savePreparedSavegame(int slot, char *desc) {
|
2009-03-16 04:45:12 +00:00
|
|
|
bool success;
|
|
|
|
Common::String filename;
|
|
|
|
Common::OutSaveFile *out;
|
|
|
|
SaveGameHeader hdr;
|
|
|
|
uint32 nread, nwritten;
|
|
|
|
|
|
|
|
out = 0;
|
|
|
|
success = true;
|
|
|
|
|
|
|
|
// check if savegame was successfully stored in memory
|
|
|
|
if (!_savePreparedSavegame)
|
|
|
|
success = false;
|
|
|
|
|
|
|
|
// open savegame file
|
|
|
|
if (success) {
|
|
|
|
filename = makeSavegameName(slot, false);
|
2009-05-29 14:38:22 +00:00
|
|
|
if (!(out = _saveFileMan->openForSaving(filename))) {
|
2009-03-16 04:45:12 +00:00
|
|
|
success = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// write header to file
|
|
|
|
if (success) {
|
|
|
|
memset(hdr.name, 0, sizeof(hdr.name));
|
|
|
|
strncpy(hdr.name, desc, sizeof(hdr.name)-1);
|
|
|
|
success = saveSaveGameHeader(out, hdr);
|
|
|
|
}
|
|
|
|
|
|
|
|
// copy savegame from memory-stream to file
|
|
|
|
if (success) {
|
|
|
|
_savePreparedSavegame->seek(0, SEEK_SET);
|
|
|
|
byte buffer[1024];
|
|
|
|
while ((nread = _savePreparedSavegame->read(buffer, sizeof(buffer)))) {
|
|
|
|
nwritten = out->write(buffer, nread);
|
|
|
|
if (nwritten < nread) {
|
|
|
|
success = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (out) {
|
|
|
|
out->finalize();
|
|
|
|
if (out->err())
|
|
|
|
success = false;
|
|
|
|
delete out;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!success) {
|
|
|
|
debug(1, "State save as '%s' FAILED", filename.c_str());
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
debug(1, "State saved as '%s'", filename.c_str());
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-02-01 23:32:20 +00:00
|
|
|
static bool loadSaveGameHeader(Common::SeekableReadStream *in, SaveGameHeader &hdr) {
|
2006-02-25 11:12:44 +00:00
|
|
|
hdr.type = in->readUint32BE();
|
|
|
|
hdr.size = in->readUint32LE();
|
|
|
|
hdr.ver = in->readUint32LE();
|
|
|
|
in->read(hdr.name, sizeof(hdr.name));
|
2008-09-15 06:52:00 +00:00
|
|
|
return !in->err() && hdr.type == MKID_BE('SCVM');
|
2006-02-25 11:12:44 +00:00
|
|
|
}
|
|
|
|
|
2004-06-25 21:48:12 +00:00
|
|
|
bool ScummEngine::loadState(int slot, bool compat) {
|
2008-09-14 21:34:49 +00:00
|
|
|
Common::String filename;
|
2008-02-01 23:32:20 +00:00
|
|
|
Common::SeekableReadStream *in;
|
2002-04-11 17:19:16 +00:00
|
|
|
int i, j;
|
2001-10-16 10:01:48 +00:00
|
|
|
SaveGameHeader hdr;
|
2004-07-18 05:04:30 +00:00
|
|
|
int sb, sh;
|
2001-10-10 10:02:33 +00:00
|
|
|
|
2007-11-06 12:22:52 +00:00
|
|
|
if (_saveLoadSlot == 255) {
|
|
|
|
// Allow custom filenames for save game system in HE Games
|
2008-09-14 21:34:49 +00:00
|
|
|
filename = _saveLoadFileName;
|
2007-11-06 12:22:52 +00:00
|
|
|
} else {
|
2008-09-14 21:34:49 +00:00
|
|
|
filename = makeSavegameName(slot, compat);
|
2007-11-06 12:22:52 +00:00
|
|
|
}
|
2009-05-29 14:38:22 +00:00
|
|
|
if (!(in = _saveFileMan->openForLoading(filename)))
|
2001-10-09 14:30:12 +00:00
|
|
|
return false;
|
2001-10-16 10:01:48 +00:00
|
|
|
|
2006-02-25 11:12:44 +00:00
|
|
|
if (!loadSaveGameHeader(in, hdr)) {
|
2008-09-14 21:34:49 +00:00
|
|
|
warning("Invalid savegame '%s'", filename.c_str());
|
2004-01-04 00:44:40 +00:00
|
|
|
delete in;
|
2001-10-16 10:01:48 +00:00
|
|
|
return false;
|
|
|
|
}
|
2002-03-14 14:45:04 +00:00
|
|
|
|
2002-08-26 16:13:38 +00:00
|
|
|
// In older versions of ScummVM, the header version was not endian safe.
|
2006-02-25 11:12:44 +00:00
|
|
|
// We account for that by retrying once with swapped byte order in case
|
|
|
|
// we see a version that is higher than anything we'd expect...
|
|
|
|
if (hdr.ver > 0xFFFFFF)
|
2003-06-14 18:52:30 +00:00
|
|
|
hdr.ver = SWAP_BYTES_32(hdr.ver);
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2005-10-22 23:49:29 +00:00
|
|
|
// Reject save games which are too old or too new. Note that
|
|
|
|
// We do not really support V7 games, but still accept them here
|
|
|
|
// to work around a bug from the stone age (see below for more
|
|
|
|
// information).
|
|
|
|
if (hdr.ver < VER(7) || hdr.ver > CURRENT_VER) {
|
2008-09-14 21:34:49 +00:00
|
|
|
warning("Invalid version of '%s'", filename.c_str());
|
2004-01-04 00:44:40 +00:00
|
|
|
delete in;
|
2001-10-16 10:01:48 +00:00
|
|
|
return false;
|
|
|
|
}
|
2003-05-23 02:58:34 +00:00
|
|
|
|
2005-04-26 14:01:38 +00:00
|
|
|
// We (deliberately) broke HE savegame compatibility at some point.
|
2006-02-20 16:51:30 +00:00
|
|
|
if (hdr.ver < VER(50) && _game.heversion >= 71) {
|
2008-09-14 21:34:49 +00:00
|
|
|
warning("Unsupported version of '%s'", filename.c_str());
|
2005-04-26 14:01:38 +00:00
|
|
|
delete in;
|
|
|
|
return false;
|
|
|
|
}
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2005-10-22 23:47:39 +00:00
|
|
|
// Since version 52 a thumbnail is saved directly after the header.
|
2008-08-20 15:08:00 +00:00
|
|
|
if (hdr.ver >= VER(52)) {
|
|
|
|
// Prior to version 75 we always required an thumbnail to be present
|
|
|
|
if (hdr.ver <= VER(74)) {
|
|
|
|
if (!Graphics::checkThumbnailHeader(*in)) {
|
|
|
|
warning("Can not load thumbnail");
|
|
|
|
delete in;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2008-08-20 15:12:36 +00:00
|
|
|
|
2010-08-02 22:28:30 +00:00
|
|
|
Graphics::skipThumbnail(*in);
|
2008-08-20 15:08:00 +00:00
|
|
|
}
|
2005-04-26 14:01:38 +00:00
|
|
|
|
2005-10-22 23:47:39 +00:00
|
|
|
// Since version 56 we save additional information about the creation of
|
|
|
|
// the save game and the save time.
|
2005-10-01 21:13:38 +00:00
|
|
|
if (hdr.ver >= VER(56)) {
|
|
|
|
InfoStuff infos;
|
|
|
|
if (!loadInfos(in, &infos)) {
|
|
|
|
warning("Info section could not be found");
|
|
|
|
delete in;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-10-27 22:52:02 +00:00
|
|
|
setTotalPlayTime(infos.playtime * 1000);
|
2005-10-01 21:13:38 +00:00
|
|
|
} else {
|
|
|
|
// start time counting
|
2010-10-27 22:52:02 +00:00
|
|
|
setTotalPlayTime();
|
2005-10-01 21:13:38 +00:00
|
|
|
}
|
|
|
|
|
2002-12-08 16:14:29 +00:00
|
|
|
// Due to a bug in scummvm up to and including 0.3.0, save games could be saved
|
|
|
|
// in the V8/V9 format but were tagged with a V7 mark. Ouch. So we just pretend V7 == V8 here
|
2003-08-29 04:05:23 +00:00
|
|
|
if (hdr.ver == VER(7))
|
|
|
|
hdr.ver = VER(8);
|
2002-12-08 16:14:29 +00:00
|
|
|
|
2001-11-09 18:54:15 +00:00
|
|
|
memcpy(_saveLoadName, hdr.name, sizeof(hdr.name));
|
2001-11-14 18:40:39 +00:00
|
|
|
|
2004-01-31 16:07:11 +00:00
|
|
|
// Unless specifically requested with _saveSound, we do not save the iMUSE
|
|
|
|
// state for temporary state saves - such as certain cutscenes in DOTT,
|
|
|
|
// FOA, Sam and Max, etc.
|
|
|
|
//
|
2007-06-30 18:09:17 +00:00
|
|
|
// Thus, we should probably not stop music when restoring from one of
|
2004-01-31 16:07:11 +00:00
|
|
|
// these saves. This change stops the Mole Man theme from going quiet in
|
|
|
|
// Sam & Max when Doug tells you about the Ball of Twine, as mentioned in
|
|
|
|
// patch #886058.
|
|
|
|
//
|
|
|
|
// If we don't have iMUSE at all we may as well stop the sounds. The previous
|
|
|
|
// default behavior here was to stopAllSounds on all state restores.
|
|
|
|
|
2004-01-31 22:12:35 +00:00
|
|
|
if (!_imuse || _saveSound || !_saveTemporaryState)
|
2004-01-31 16:07:11 +00:00
|
|
|
_sound->stopAllSounds();
|
|
|
|
|
2008-05-06 03:00:26 +00:00
|
|
|
#ifdef ENABLE_SCUMM_7_8
|
2004-03-02 20:35:48 +00:00
|
|
|
if (_imuseDigital) {
|
|
|
|
_imuseDigital->stopAllSounds();
|
|
|
|
_imuseDigital->resetState();
|
|
|
|
}
|
2005-05-14 22:56:41 +00:00
|
|
|
#endif
|
2004-03-02 20:35:48 +00:00
|
|
|
|
2002-12-16 12:09:52 +00:00
|
|
|
_sound->stopCD();
|
2003-11-29 14:37:47 +00:00
|
|
|
|
2002-08-14 20:43:56 +00:00
|
|
|
_sound->pauseSounds(true);
|
2001-11-14 18:40:39 +00:00
|
|
|
|
2002-12-22 21:58:16 +00:00
|
|
|
closeRoom();
|
2004-01-04 00:44:40 +00:00
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
memset(_inventory, 0, sizeof(_inventory[0]) * _numInventory);
|
2003-12-25 22:05:02 +00:00
|
|
|
memset(_newNames, 0, sizeof(_newNames[0]) * _numNewNames);
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2004-01-04 00:44:40 +00:00
|
|
|
// Because old savegames won't fill the entire gfxUsageBits[] array,
|
|
|
|
// clear it here just to be sure it won't hold any unforseen garbage.
|
|
|
|
memset(gfxUsageBits, 0, sizeof(gfxUsageBits));
|
2001-10-10 10:02:33 +00:00
|
|
|
|
2004-01-04 00:44:40 +00:00
|
|
|
// Nuke all resources
|
2002-04-11 17:19:16 +00:00
|
|
|
for (i = rtFirst; i <= rtLast; i++)
|
2003-07-15 10:16:45 +00:00
|
|
|
if (i != rtTemp && i != rtBuffer && (i != rtSound || _saveSound || !compat))
|
2006-09-17 20:36:48 +00:00
|
|
|
for (j = 0; j < _res->num[i]; j++) {
|
|
|
|
_res->nukeResource(i, j);
|
2001-11-07 18:10:52 +00:00
|
|
|
}
|
2001-10-10 10:02:33 +00:00
|
|
|
|
2006-04-29 16:24:39 +00:00
|
|
|
resetScummVars();
|
2002-04-11 17:19:16 +00:00
|
|
|
|
2006-02-20 16:51:30 +00:00
|
|
|
if (_game.features & GF_OLD_BUNDLE)
|
2003-04-23 09:20:22 +00:00
|
|
|
loadCharset(0); // FIXME - HACK ?
|
2001-10-26 17:34:50 +00:00
|
|
|
|
2004-01-04 00:44:40 +00:00
|
|
|
//
|
|
|
|
// Now do the actual loading
|
|
|
|
//
|
2005-04-10 15:13:40 +00:00
|
|
|
Serializer ser(in, 0, hdr.ver);
|
2005-10-22 22:54:59 +00:00
|
|
|
saveOrLoad(&ser);
|
2004-01-04 00:44:40 +00:00
|
|
|
delete in;
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2005-04-26 13:22:46 +00:00
|
|
|
// Update volume settings
|
2008-06-30 17:44:21 +00:00
|
|
|
syncSoundSettings();
|
2005-04-26 13:22:46 +00:00
|
|
|
|
2010-08-18 21:38:43 +00:00
|
|
|
if (_townsPlayer && (hdr.ver >= VER(81)))
|
|
|
|
_townsPlayer->restoreAfterLoad();
|
|
|
|
|
2005-04-26 13:43:01 +00:00
|
|
|
// Init NES costume data
|
2006-02-20 16:51:30 +00:00
|
|
|
if (_game.platform == Common::kPlatformNES) {
|
2005-04-26 13:43:01 +00:00
|
|
|
if (hdr.ver < VER(47))
|
|
|
|
_NESCostumeSet = 0;
|
|
|
|
NES_loadCostumeSet(_NESCostumeSet);
|
|
|
|
}
|
|
|
|
|
2004-01-08 00:48:37 +00:00
|
|
|
// Normally, _vm->_screenTop should always be >= 0, but for some old save games
|
|
|
|
// it is not, hence we check & correct it here.
|
|
|
|
if (_screenTop < 0)
|
|
|
|
_screenTop = 0;
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2007-02-02 23:43:39 +00:00
|
|
|
// WORKAROUND bug #795214: For unknown reasons, object 819 sometimes is in
|
|
|
|
// state 1 in old save games, implying it should be drawn. This in turn
|
|
|
|
// results in a crash when entering the church, as object 819 is part of the
|
2009-09-11 10:13:54 +00:00
|
|
|
// exitof the church and there are no graphics assigned to it.
|
2007-02-02 23:43:39 +00:00
|
|
|
if (_game.id == GID_MONKEY_VGA) {
|
2006-02-15 17:31:26 +00:00
|
|
|
putState(819, 0);
|
|
|
|
}
|
|
|
|
|
2006-02-20 16:51:30 +00:00
|
|
|
if (hdr.ver < VER(33) && _game.version >= 7) {
|
2004-07-16 14:41:05 +00:00
|
|
|
// For a long time, we didn't set these vars to default values.
|
|
|
|
VAR(VAR_DEFAULT_TALK_DELAY) = 60;
|
2006-02-20 16:51:30 +00:00
|
|
|
if (_game.version == 7)
|
2004-07-16 14:41:05 +00:00
|
|
|
VAR(VAR_NUM_GLOBAL_OBJS) = _numGlobalObjects - 1;
|
|
|
|
}
|
|
|
|
|
2004-02-22 16:15:49 +00:00
|
|
|
if (hdr.ver < VER(30)) {
|
|
|
|
// For a long time, we used incorrect location, causing it to default to zero.
|
2006-02-20 16:51:30 +00:00
|
|
|
if (_game.version == 8)
|
|
|
|
_scummVars[VAR_CHARINC] = (_game.features & GF_DEMO) ? 3 : 1;
|
2004-02-22 16:15:49 +00:00
|
|
|
// Needed due to subtitle speed changes
|
|
|
|
_defaultTalkDelay /= 20;
|
|
|
|
}
|
2004-02-21 08:21:11 +00:00
|
|
|
|
2004-01-11 19:58:29 +00:00
|
|
|
// For a long time, we used incorrect locations for some camera related
|
|
|
|
// scumm vars. We now know the proper locations. To be able to properly use
|
|
|
|
// old save games, we update the old (bad) variables to the new (correct)
|
|
|
|
// ones.
|
2006-02-20 16:51:30 +00:00
|
|
|
if (hdr.ver < VER(28) && _game.version == 8) {
|
2004-01-11 19:58:29 +00:00
|
|
|
_scummVars[VAR_CAMERA_MIN_X] = _scummVars[101];
|
|
|
|
_scummVars[VAR_CAMERA_MAX_X] = _scummVars[102];
|
|
|
|
_scummVars[VAR_CAMERA_MIN_Y] = _scummVars[103];
|
|
|
|
_scummVars[VAR_CAMERA_MAX_Y] = _scummVars[104];
|
|
|
|
_scummVars[VAR_CAMERA_THRESHOLD_X] = _scummVars[105];
|
|
|
|
_scummVars[VAR_CAMERA_THRESHOLD_Y] = _scummVars[106];
|
|
|
|
_scummVars[VAR_CAMERA_SPEED_X] = _scummVars[107];
|
|
|
|
_scummVars[VAR_CAMERA_SPEED_Y] = _scummVars[108];
|
|
|
|
_scummVars[VAR_CAMERA_ACCEL_X] = _scummVars[109];
|
|
|
|
_scummVars[VAR_CAMERA_ACCEL_Y] = _scummVars[110];
|
|
|
|
}
|
2003-05-03 20:49:53 +00:00
|
|
|
|
2009-02-11 23:22:52 +00:00
|
|
|
// For a long time, we used incorrect values for some camera related
|
|
|
|
// scumm vars. We now know the proper values. To be able to properly use
|
|
|
|
// old save games, we update the old (bad) values to the new (correct)
|
|
|
|
// ones.
|
|
|
|
if (hdr.ver < VER(77) && _game.version >= 7) {
|
|
|
|
_scummVars[VAR_CAMERA_THRESHOLD_X] = 100;
|
|
|
|
_scummVars[VAR_CAMERA_THRESHOLD_Y] = 70;
|
|
|
|
_scummVars[VAR_CAMERA_ACCEL_X] = 100;
|
|
|
|
_scummVars[VAR_CAMERA_ACCEL_Y] = 100;
|
|
|
|
}
|
|
|
|
|
2004-07-26 04:03:11 +00:00
|
|
|
// With version 22, we replaced the scale items with scale slots. So when
|
|
|
|
// loading such an old save game, try to upgrade the old to new format.
|
|
|
|
if (hdr.ver < VER(22)) {
|
|
|
|
// Convert all rtScaleTable resources to matching scale items
|
2006-09-17 20:36:48 +00:00
|
|
|
for (i = 1; i < _res->num[rtScaleTable]; i++) {
|
2004-07-26 04:03:11 +00:00
|
|
|
convertScaleTableToScaleSlot(i);
|
|
|
|
}
|
|
|
|
}
|
2004-02-22 03:08:18 +00:00
|
|
|
|
2006-04-29 16:24:39 +00:00
|
|
|
// Reset the palette.
|
|
|
|
resetPalette();
|
2002-04-11 17:19:16 +00:00
|
|
|
|
2006-05-29 12:45:11 +00:00
|
|
|
if (hdr.ver < VER(35) && _game.id == GID_MANIAC && _game.version <= 1)
|
2006-04-29 16:24:39 +00:00
|
|
|
resetV1ActorTalkColor();
|
2004-07-26 15:14:10 +00:00
|
|
|
|
2005-04-26 14:18:34 +00:00
|
|
|
// Load the static room data
|
2006-04-29 16:24:39 +00:00
|
|
|
setupRoomSubBlocks();
|
2003-06-05 10:27:15 +00:00
|
|
|
|
2007-02-10 02:05:59 +00:00
|
|
|
if (_game.version < 7) {
|
2004-01-04 00:44:40 +00:00
|
|
|
camera._last.x = camera._cur.x;
|
|
|
|
}
|
|
|
|
|
2004-07-18 05:04:30 +00:00
|
|
|
sb = _screenB;
|
|
|
|
sh = _screenH;
|
|
|
|
|
2004-01-04 00:44:40 +00:00
|
|
|
// Restore the virtual screens and force a fade to black.
|
2005-04-26 15:41:15 +00:00
|
|
|
initScreens(0, _screenHeight);
|
2005-03-25 22:11:08 +00:00
|
|
|
|
2007-09-08 11:15:27 +00:00
|
|
|
VirtScreen *vs = &_virtscr[kMainVirtScreen];
|
2004-08-14 19:42:00 +00:00
|
|
|
memset(vs->getPixels(0, 0), 0, vs->pitch * vs->h);
|
|
|
|
vs->setDirtyRange(0, vs->h);
|
2004-01-04 00:44:40 +00:00
|
|
|
updateDirtyScreen(kMainVirtScreen);
|
|
|
|
updatePalette();
|
2004-07-18 05:04:30 +00:00
|
|
|
initScreens(sb, sh);
|
|
|
|
|
2004-01-04 00:44:40 +00:00
|
|
|
_completeScreenRedraw = true;
|
|
|
|
|
|
|
|
// Reset charset mask
|
|
|
|
_charset->_hasMask = false;
|
2007-01-28 20:11:31 +00:00
|
|
|
clearTextSurface();
|
2004-01-04 00:44:40 +00:00
|
|
|
|
|
|
|
_lastCodePtr = NULL;
|
|
|
|
_drawObjectQueNr = 0;
|
|
|
|
_verbMouseOver = 0;
|
|
|
|
|
|
|
|
cameraMoved();
|
|
|
|
|
|
|
|
initBGBuffers(_roomHeight);
|
|
|
|
|
2004-07-26 04:03:11 +00:00
|
|
|
if (VAR_ROOM_FLAG != 0xFF)
|
|
|
|
VAR(VAR_ROOM_FLAG) = 1;
|
|
|
|
|
|
|
|
// Sync with current config setting
|
2005-11-15 22:50:14 +00:00
|
|
|
if (VAR_VOICE_MODE != 0xFF)
|
2004-07-26 04:03:11 +00:00
|
|
|
VAR(VAR_VOICE_MODE) = ConfMan.getBool("subtitles");
|
|
|
|
|
2008-09-14 21:34:49 +00:00
|
|
|
debug(1, "State loaded from '%s'", filename.c_str());
|
2001-10-10 10:02:33 +00:00
|
|
|
|
2002-08-14 20:43:56 +00:00
|
|
|
_sound->pauseSounds(false);
|
2001-11-14 18:40:39 +00:00
|
|
|
|
2008-01-01 16:26:04 +00:00
|
|
|
// WORKAROUND: Original save/load script ran this script
|
|
|
|
// after game load, and o2_loadRoomWithEgo() does as well
|
|
|
|
// this script starts character-dependent music
|
|
|
|
//
|
|
|
|
// Fixes bug #1766072: MANIACNES: Music Doesn't Start On Load Game
|
|
|
|
if (_game.platform == Common::kPlatformNES) {
|
|
|
|
runScript(5, 0, 0, 0);
|
2010-06-15 10:46:04 +00:00
|
|
|
|
|
|
|
if (VAR(224)) {
|
|
|
|
_sound->addSoundToQueue(VAR(224));
|
|
|
|
}
|
2008-01-01 16:26:04 +00:00
|
|
|
}
|
|
|
|
|
2001-10-09 14:30:12 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2008-09-14 21:34:49 +00:00
|
|
|
Common::String ScummEngine::makeSavegameName(const Common::String &target, int slot, bool temporary) {
|
|
|
|
char extension[6];
|
|
|
|
snprintf(extension, sizeof(extension), ".%c%02d", temporary ? 'c' : 's', slot);
|
|
|
|
return (target + extension);
|
2001-11-09 18:54:15 +00:00
|
|
|
}
|
|
|
|
|
2004-06-25 22:39:21 +00:00
|
|
|
void ScummEngine::listSavegames(bool *marks, int num) {
|
2007-07-12 17:58:15 +00:00
|
|
|
assert(marks);
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2007-12-07 17:59:24 +00:00
|
|
|
char slot[3];
|
2007-07-12 17:58:15 +00:00
|
|
|
int slotNum;
|
2010-03-18 15:54:40 +00:00
|
|
|
Common::StringArray files;
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2008-09-14 21:34:49 +00:00
|
|
|
Common::String prefix = makeSavegameName(99, false);
|
2008-09-15 06:51:15 +00:00
|
|
|
prefix.setChar('*', prefix.size()-2);
|
|
|
|
prefix.setChar(0, prefix.size()-1);
|
2007-07-12 17:58:15 +00:00
|
|
|
memset(marks, false, num * sizeof(bool)); //assume no savegames for this title
|
2009-05-29 14:38:22 +00:00
|
|
|
files = _saveFileMan->listSavefiles(prefix);
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2010-03-18 15:54:40 +00:00
|
|
|
for (Common::StringArray::const_iterator file = files.begin(); file != files.end(); ++file) {
|
2007-07-12 17:58:15 +00:00
|
|
|
//Obtain the last 2 digits of the filename, since they correspond to the save slot
|
|
|
|
slot[0] = file->c_str()[file->size()-2];
|
|
|
|
slot[1] = file->c_str()[file->size()-1];
|
2007-12-07 17:59:24 +00:00
|
|
|
slot[2] = 0;
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2007-07-12 17:58:15 +00:00
|
|
|
slotNum = atoi(slot);
|
2007-09-18 20:16:33 +00:00
|
|
|
if (slotNum >= 0 && slotNum < num)
|
2007-07-12 17:58:15 +00:00
|
|
|
marks[slotNum] = true; //mark this slot as valid
|
|
|
|
}
|
2002-12-17 01:15:13 +00:00
|
|
|
}
|
|
|
|
|
2008-02-04 10:15:21 +00:00
|
|
|
bool getSavegameName(Common::InSaveFile *in, Common::String &desc, int heversion);
|
|
|
|
|
|
|
|
bool ScummEngine::getSavegameName(int slot, Common::String &desc) {
|
|
|
|
Common::InSaveFile *in = 0;
|
|
|
|
bool result = false;
|
2001-11-09 18:54:15 +00:00
|
|
|
|
2008-02-04 10:15:21 +00:00
|
|
|
desc.clear();
|
2008-09-14 21:34:49 +00:00
|
|
|
Common::String filename = makeSavegameName(slot, false);
|
2009-05-29 14:38:22 +00:00
|
|
|
in = _saveFileMan->openForLoading(filename);
|
2008-02-04 10:15:21 +00:00
|
|
|
if (in) {
|
|
|
|
result = Scumm::getSavegameName(in, desc, _game.heversion);
|
|
|
|
delete in;
|
2001-11-09 18:54:15 +00:00
|
|
|
}
|
2008-02-04 10:15:21 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool getSavegameName(Common::InSaveFile *in, Common::String &desc, int heversion) {
|
|
|
|
SaveGameHeader hdr;
|
2001-11-09 18:54:15 +00:00
|
|
|
|
2006-02-25 11:12:44 +00:00
|
|
|
if (!loadSaveGameHeader(in, hdr)) {
|
2008-02-04 10:15:21 +00:00
|
|
|
desc = "Invalid savegame";
|
2001-11-09 18:54:15 +00:00
|
|
|
return false;
|
|
|
|
}
|
2002-03-14 14:45:04 +00:00
|
|
|
|
2002-12-08 16:14:29 +00:00
|
|
|
if (hdr.ver > CURRENT_VER)
|
2002-07-16 15:25:22 +00:00
|
|
|
hdr.ver = TO_LE_32(hdr.ver);
|
2003-08-29 04:05:23 +00:00
|
|
|
if (hdr.ver < VER(7) || hdr.ver > CURRENT_VER) {
|
2008-02-04 10:15:21 +00:00
|
|
|
desc = "Invalid version";
|
2001-11-09 18:54:15 +00:00
|
|
|
return false;
|
|
|
|
}
|
2002-04-11 17:19:16 +00:00
|
|
|
|
2005-04-26 14:01:38 +00:00
|
|
|
// We (deliberately) broke HE savegame compatibility at some point.
|
2008-02-04 10:15:21 +00:00
|
|
|
if (hdr.ver < VER(57) && heversion >= 60) {
|
|
|
|
desc = "Unsupported version";
|
2005-04-26 14:01:38 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2008-02-04 10:15:21 +00:00
|
|
|
hdr.name[sizeof(hdr.name) - 1] = 0;
|
|
|
|
desc = hdr.name;
|
2001-11-09 18:54:15 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2008-09-14 21:13:40 +00:00
|
|
|
Graphics::Surface *ScummEngine::loadThumbnailFromSlot(const char *target, int slot) {
|
2008-02-01 23:32:20 +00:00
|
|
|
Common::SeekableReadStream *in;
|
2005-05-09 00:09:01 +00:00
|
|
|
SaveGameHeader hdr;
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2008-08-04 11:46:52 +00:00
|
|
|
if (slot < 0)
|
2009-09-11 10:13:54 +00:00
|
|
|
return 0;
|
2008-08-04 11:46:52 +00:00
|
|
|
|
2008-09-14 21:34:49 +00:00
|
|
|
Common::String filename = ScummEngine::makeSavegameName(target, slot, false);
|
2009-05-29 14:38:22 +00:00
|
|
|
if (!(in = g_system->getSavefileManager()->openForLoading(filename))) {
|
2005-05-09 00:09:01 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-02-25 11:12:44 +00:00
|
|
|
if (!loadSaveGameHeader(in, hdr)) {
|
2005-05-09 00:09:01 +00:00
|
|
|
delete in;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (hdr.ver > CURRENT_VER)
|
|
|
|
hdr.ver = TO_LE_32(hdr.ver);
|
|
|
|
if (hdr.ver < VER(52)) {
|
|
|
|
delete in;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-09-14 21:13:40 +00:00
|
|
|
Graphics::Surface *thumb = 0;
|
|
|
|
if (Graphics::checkThumbnailHeader(*in)) {
|
|
|
|
thumb = new Graphics::Surface();
|
|
|
|
assert(thumb);
|
|
|
|
if (!Graphics::loadThumbnail(*in, *thumb)) {
|
|
|
|
delete thumb;
|
|
|
|
thumb = 0;
|
|
|
|
}
|
|
|
|
}
|
2005-05-09 00:09:01 +00:00
|
|
|
|
|
|
|
delete in;
|
|
|
|
return thumb;
|
|
|
|
}
|
|
|
|
|
2008-09-16 14:56:02 +00:00
|
|
|
bool ScummEngine::loadInfosFromSlot(const char *target, int slot, InfoStuff *stuff) {
|
2008-02-01 23:32:20 +00:00
|
|
|
Common::SeekableReadStream *in;
|
2005-10-01 21:13:38 +00:00
|
|
|
SaveGameHeader hdr;
|
|
|
|
|
2008-08-04 11:46:52 +00:00
|
|
|
if (slot < 0)
|
2009-09-11 10:13:54 +00:00
|
|
|
return 0;
|
2008-08-04 11:46:52 +00:00
|
|
|
|
2008-09-16 14:56:02 +00:00
|
|
|
Common::String filename = makeSavegameName(target, slot, false);
|
2009-05-29 14:38:22 +00:00
|
|
|
if (!(in = g_system->getSavefileManager()->openForLoading(filename))) {
|
2005-10-01 21:13:38 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2006-02-25 11:12:44 +00:00
|
|
|
if (!loadSaveGameHeader(in, hdr)) {
|
2005-10-01 21:13:38 +00:00
|
|
|
delete in;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (hdr.ver > CURRENT_VER)
|
|
|
|
hdr.ver = TO_LE_32(hdr.ver);
|
|
|
|
if (hdr.ver < VER(56)) {
|
|
|
|
delete in;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-08-02 22:28:30 +00:00
|
|
|
if (!Graphics::skipThumbnail(*in)) {
|
2009-04-12 14:02:20 +00:00
|
|
|
delete in;
|
2005-10-01 21:13:38 +00:00
|
|
|
return false;
|
2009-04-12 14:02:20 +00:00
|
|
|
}
|
2005-10-01 21:13:38 +00:00
|
|
|
|
|
|
|
if (!loadInfos(in, stuff)) {
|
|
|
|
delete in;
|
|
|
|
return false;
|
|
|
|
}
|
2007-09-19 08:40:12 +00:00
|
|
|
|
|
|
|
delete in;
|
2005-10-01 21:13:38 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2008-02-01 23:32:20 +00:00
|
|
|
bool ScummEngine::loadInfos(Common::SeekableReadStream *file, InfoStuff *stuff) {
|
2005-10-01 21:13:38 +00:00
|
|
|
memset(stuff, 0, sizeof(InfoStuff));
|
|
|
|
|
|
|
|
SaveInfoSection section;
|
2006-02-25 02:47:22 +00:00
|
|
|
section.type = file->readUint32BE();
|
|
|
|
if (section.type != MKID_BE('INFO')) {
|
2005-10-01 21:13:38 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
section.version = file->readUint32BE();
|
|
|
|
section.size = file->readUint32BE();
|
|
|
|
|
2007-03-08 21:08:23 +00:00
|
|
|
// If we ever extend this we should add a table containing the sizes corresponding to each
|
|
|
|
// version, so that we are able to properly verify their correctness.
|
2006-07-22 16:19:00 +00:00
|
|
|
if (section.version == INFOSECTION_VERSION && section.size != SaveInfoSectionSize) {
|
2005-10-01 21:13:38 +00:00
|
|
|
warning("Info section is corrupt");
|
|
|
|
file->skip(section.size);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
section.timeTValue = file->readUint32BE();
|
|
|
|
section.playtime = file->readUint32BE();
|
|
|
|
|
2007-03-08 21:08:23 +00:00
|
|
|
// For header version 1, we load the data in with our old method
|
2005-10-12 17:59:12 +00:00
|
|
|
if (section.version == 1) {
|
2007-12-28 07:43:52 +00:00
|
|
|
//time_t tmp = section.timeTValue;
|
|
|
|
//tm *curTime = localtime(&tmp);
|
|
|
|
//stuff->date = (curTime->tm_mday & 0xFF) << 24 | ((curTime->tm_mon + 1) & 0xFF) << 16 | (curTime->tm_year + 1900) & 0xFFFF;
|
|
|
|
//stuff->time = (curTime->tm_hour & 0xFF) << 8 | (curTime->tm_min) & 0xFF;
|
|
|
|
stuff->date = 0;
|
|
|
|
stuff->time = 0;
|
2005-10-12 17:59:12 +00:00
|
|
|
}
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2005-10-12 17:59:12 +00:00
|
|
|
if (section.version >= 2) {
|
|
|
|
section.date = file->readUint32BE();
|
|
|
|
section.time = file->readUint16BE();
|
2005-10-01 21:13:38 +00:00
|
|
|
|
2005-10-12 17:59:12 +00:00
|
|
|
stuff->date = section.date;
|
|
|
|
stuff->time = section.time;
|
|
|
|
}
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2005-10-12 17:59:12 +00:00
|
|
|
stuff->playtime = section.playtime;
|
2005-10-01 21:13:38 +00:00
|
|
|
|
2007-03-08 21:08:23 +00:00
|
|
|
// Skip over the remaining (unsupported) data
|
2008-09-16 14:56:02 +00:00
|
|
|
if (section.size > SaveInfoSectionSize)
|
2006-07-22 16:19:00 +00:00
|
|
|
file->skip(section.size - SaveInfoSectionSize);
|
2005-10-01 21:13:38 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2008-08-04 11:38:25 +00:00
|
|
|
void ScummEngine::saveInfos(Common::WriteStream* file) {
|
2005-10-01 21:13:38 +00:00
|
|
|
SaveInfoSection section;
|
2006-02-25 02:47:22 +00:00
|
|
|
section.type = MKID_BE('INFO');
|
2005-10-01 21:13:38 +00:00
|
|
|
section.version = INFOSECTION_VERSION;
|
2006-07-22 16:19:00 +00:00
|
|
|
section.size = SaveInfoSectionSize;
|
2005-10-01 21:13:38 +00:00
|
|
|
|
2005-10-12 17:59:12 +00:00
|
|
|
// still save old format for older versions
|
2009-10-08 19:41:38 +00:00
|
|
|
section.timeTValue = 0;
|
2010-10-27 22:37:51 +00:00
|
|
|
section.playtime = getTotalPlayTime() / 1000;
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2009-10-08 19:41:38 +00:00
|
|
|
TimeDate curTime;
|
2007-12-28 07:43:52 +00:00
|
|
|
_system->getTimeAndDate(curTime);
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2008-11-29 18:01:16 +00:00
|
|
|
section.date = ((curTime.tm_mday & 0xFF) << 24) | (((curTime.tm_mon + 1) & 0xFF) << 16) | ((curTime.tm_year + 1900) & 0xFFFF);
|
|
|
|
section.time = ((curTime.tm_hour & 0xFF) << 8) | ((curTime.tm_min) & 0xFF);
|
2005-10-01 21:13:38 +00:00
|
|
|
|
2006-02-25 02:47:22 +00:00
|
|
|
file->writeUint32BE(section.type);
|
2005-10-01 21:13:38 +00:00
|
|
|
file->writeUint32BE(section.version);
|
|
|
|
file->writeUint32BE(section.size);
|
|
|
|
file->writeUint32BE(section.timeTValue);
|
|
|
|
file->writeUint32BE(section.playtime);
|
2005-10-12 17:59:12 +00:00
|
|
|
file->writeUint32BE(section.date);
|
|
|
|
file->writeUint16BE(section.time);
|
2005-10-01 21:13:38 +00:00
|
|
|
}
|
|
|
|
|
2005-10-22 22:54:59 +00:00
|
|
|
void ScummEngine::saveOrLoad(Serializer *s) {
|
2001-10-10 10:02:33 +00:00
|
|
|
const SaveLoadEntry objectEntries[] = {
|
2003-08-29 04:05:23 +00:00
|
|
|
MKLINE(ObjectData, OBIMoffset, sleUint32, VER(8)),
|
|
|
|
MKLINE(ObjectData, OBCDoffset, sleUint32, VER(8)),
|
|
|
|
MKLINE(ObjectData, walk_x, sleUint16, VER(8)),
|
|
|
|
MKLINE(ObjectData, walk_y, sleUint16, VER(8)),
|
|
|
|
MKLINE(ObjectData, obj_nr, sleUint16, VER(8)),
|
|
|
|
MKLINE(ObjectData, x_pos, sleInt16, VER(8)),
|
|
|
|
MKLINE(ObjectData, y_pos, sleInt16, VER(8)),
|
|
|
|
MKLINE(ObjectData, width, sleUint16, VER(8)),
|
|
|
|
MKLINE(ObjectData, height, sleUint16, VER(8)),
|
|
|
|
MKLINE(ObjectData, actordir, sleByte, VER(8)),
|
|
|
|
MKLINE(ObjectData, parentstate, sleByte, VER(8)),
|
|
|
|
MKLINE(ObjectData, parent, sleByte, VER(8)),
|
|
|
|
MKLINE(ObjectData, state, sleByte, VER(8)),
|
|
|
|
MKLINE(ObjectData, fl_object_index, sleByte, VER(8)),
|
2005-02-28 13:23:10 +00:00
|
|
|
MKLINE(ObjectData, flags, sleByte, VER(46)),
|
2001-10-10 10:02:33 +00:00
|
|
|
MKEND()
|
|
|
|
};
|
|
|
|
|
|
|
|
const SaveLoadEntry verbEntries[] = {
|
2004-01-15 19:25:17 +00:00
|
|
|
MKLINE(VerbSlot, curRect.left, sleInt16, VER(8)),
|
|
|
|
MKLINE(VerbSlot, curRect.top, sleInt16, VER(8)),
|
|
|
|
MKLINE(VerbSlot, curRect.right, sleInt16, VER(8)),
|
|
|
|
MKLINE(VerbSlot, curRect.bottom, sleInt16, VER(8)),
|
|
|
|
MKLINE(VerbSlot, oldRect.left, sleInt16, VER(8)),
|
|
|
|
MKLINE(VerbSlot, oldRect.top, sleInt16, VER(8)),
|
|
|
|
MKLINE(VerbSlot, oldRect.right, sleInt16, VER(8)),
|
|
|
|
MKLINE(VerbSlot, oldRect.bottom, sleInt16, VER(8)),
|
2003-08-29 04:05:23 +00:00
|
|
|
|
|
|
|
MKLINE_OLD(VerbSlot, verbid, sleByte, VER(8), VER(11)),
|
|
|
|
MKLINE(VerbSlot, verbid, sleInt16, VER(12)),
|
|
|
|
|
|
|
|
MKLINE(VerbSlot, color, sleByte, VER(8)),
|
|
|
|
MKLINE(VerbSlot, hicolor, sleByte, VER(8)),
|
|
|
|
MKLINE(VerbSlot, dimcolor, sleByte, VER(8)),
|
|
|
|
MKLINE(VerbSlot, bkcolor, sleByte, VER(8)),
|
|
|
|
MKLINE(VerbSlot, type, sleByte, VER(8)),
|
|
|
|
MKLINE(VerbSlot, charset_nr, sleByte, VER(8)),
|
|
|
|
MKLINE(VerbSlot, curmode, sleByte, VER(8)),
|
|
|
|
MKLINE(VerbSlot, saveid, sleByte, VER(8)),
|
|
|
|
MKLINE(VerbSlot, key, sleByte, VER(8)),
|
|
|
|
MKLINE(VerbSlot, center, sleByte, VER(8)),
|
|
|
|
MKLINE(VerbSlot, prep, sleByte, VER(8)),
|
|
|
|
MKLINE(VerbSlot, imgindex, sleUint16, VER(8)),
|
2002-03-14 14:45:04 +00:00
|
|
|
MKEND()
|
|
|
|
};
|
|
|
|
|
2002-12-08 16:14:29 +00:00
|
|
|
const SaveLoadEntry mainEntries[] = {
|
2004-09-10 12:13:03 +00:00
|
|
|
MKARRAY(ScummEngine, _gameMD5[0], sleUint8, 16, VER(39)),
|
2005-04-26 14:18:34 +00:00
|
|
|
MK_OBSOLETE(ScummEngine, _roomWidth, sleUint16, VER(8), VER(50)),
|
|
|
|
MK_OBSOLETE(ScummEngine, _roomHeight, sleUint16, VER(8), VER(50)),
|
|
|
|
MK_OBSOLETE(ScummEngine, _ENCD_offs, sleUint32, VER(8), VER(50)),
|
|
|
|
MK_OBSOLETE(ScummEngine, _EXCD_offs, sleUint32, VER(8), VER(50)),
|
|
|
|
MK_OBSOLETE(ScummEngine, _IM00_offs, sleUint32, VER(8), VER(50)),
|
|
|
|
MK_OBSOLETE(ScummEngine, _CLUT_offs, sleUint32, VER(8), VER(50)),
|
2003-10-02 22:42:03 +00:00
|
|
|
MK_OBSOLETE(ScummEngine, _EPAL_offs, sleUint32, VER(8), VER(9)),
|
2005-04-26 14:18:34 +00:00
|
|
|
MK_OBSOLETE(ScummEngine, _PALS_offs, sleUint32, VER(8), VER(50)),
|
2003-10-02 22:42:03 +00:00
|
|
|
MKLINE(ScummEngine, _curPalIndex, sleByte, VER(8)),
|
|
|
|
MKLINE(ScummEngine, _currentRoom, sleByte, VER(8)),
|
|
|
|
MKLINE(ScummEngine, _roomResource, sleByte, VER(8)),
|
|
|
|
MKLINE(ScummEngine, _numObjectsInRoom, sleByte, VER(8)),
|
|
|
|
MKLINE(ScummEngine, _currentScript, sleByte, VER(8)),
|
2005-04-26 14:18:34 +00:00
|
|
|
MK_OBSOLETE_ARRAY(ScummEngine, _localScriptOffsets[0], sleUint32, _numLocalScripts, VER(8), VER(50)),
|
2002-12-08 16:14:29 +00:00
|
|
|
|
2003-05-23 02:58:34 +00:00
|
|
|
|
|
|
|
// vm.localvar grew from 25 to 40 script entries and then from
|
2003-05-28 18:13:30 +00:00
|
|
|
// 16 to 32 bit variables (but that wasn't reflect here)... and
|
|
|
|
// THEN from 16 to 25 variables.
|
2003-10-02 22:42:03 +00:00
|
|
|
MKARRAY2_OLD(ScummEngine, vm.localvar[0][0], sleUint16, 17, 25, (byte*)vm.localvar[1] - (byte*)vm.localvar[0], VER(8), VER(8)),
|
|
|
|
MKARRAY2_OLD(ScummEngine, vm.localvar[0][0], sleUint16, 17, 40, (byte*)vm.localvar[1] - (byte*)vm.localvar[0], VER(9), VER(14)),
|
2003-05-23 02:58:34 +00:00
|
|
|
|
|
|
|
// We used to save 25 * 40 = 1000 blocks; but actually, each 'row consisted of 26 entry,
|
|
|
|
// i.e. 26 * 40 = 1040. Thus the last 40 blocks of localvar where not saved at all. To be
|
|
|
|
// able to load this screwed format, we use a trick: We load 26 * 38 = 988 blocks.
|
|
|
|
// Then, we mark the followin 12 blocks (24 bytes) as obsolete.
|
2003-10-02 22:42:03 +00:00
|
|
|
MKARRAY2_OLD(ScummEngine, vm.localvar[0][0], sleUint16, 26, 38, (byte*)vm.localvar[1] - (byte*)vm.localvar[0], VER(15), VER(17)),
|
|
|
|
MK_OBSOLETE_ARRAY(ScummEngine, vm.localvar[39][0], sleUint16, 12, VER(15), VER(17)),
|
2003-05-23 02:58:34 +00:00
|
|
|
|
2003-05-28 18:13:30 +00:00
|
|
|
// This was the first proper multi dimensional version of the localvars, with 32 bit values
|
2003-10-02 22:42:03 +00:00
|
|
|
MKARRAY2_OLD(ScummEngine, vm.localvar[0][0], sleUint32, 26, 40, (byte*)vm.localvar[1] - (byte*)vm.localvar[0], VER(18), VER(19)),
|
2003-05-28 18:13:30 +00:00
|
|
|
|
|
|
|
// Then we doubled the script slots again, from 40 to 80
|
2003-10-02 22:42:03 +00:00
|
|
|
MKARRAY2(ScummEngine, vm.localvar[0][0], sleUint32, 26, NUM_SCRIPT_SLOT, (byte*)vm.localvar[1] - (byte*)vm.localvar[0], VER(20)),
|
2003-05-23 02:58:34 +00:00
|
|
|
|
2002-12-08 16:14:29 +00:00
|
|
|
|
2003-10-02 22:42:03 +00:00
|
|
|
MKARRAY(ScummEngine, _resourceMapper[0], sleByte, 128, VER(8)),
|
|
|
|
MKARRAY(ScummEngine, _charsetColorMap[0], sleByte, 16, VER(8)),
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2006-03-26 09:06:44 +00:00
|
|
|
// _charsetData grew from 10*16, to 15*16, to 23*16 bytes
|
2003-10-02 22:42:03 +00:00
|
|
|
MKARRAY_OLD(ScummEngine, _charsetData[0][0], sleByte, 10 * 16, VER(8), VER(9)),
|
2006-03-26 09:06:44 +00:00
|
|
|
MKARRAY_OLD(ScummEngine, _charsetData[0][0], sleByte, 15 * 16, VER(10), VER(66)),
|
2006-03-26 09:09:35 +00:00
|
|
|
MKARRAY(ScummEngine, _charsetData[0][0], sleByte, 23 * 16, VER(67)),
|
2003-10-02 22:42:03 +00:00
|
|
|
|
2006-01-10 21:39:14 +00:00
|
|
|
MK_OBSOLETE(ScummEngine, _curExecScript, sleUint16, VER(8), VER(62)),
|
2003-10-02 22:42:03 +00:00
|
|
|
|
|
|
|
MKLINE(ScummEngine, camera._dest.x, sleInt16, VER(8)),
|
|
|
|
MKLINE(ScummEngine, camera._dest.y, sleInt16, VER(8)),
|
|
|
|
MKLINE(ScummEngine, camera._cur.x, sleInt16, VER(8)),
|
|
|
|
MKLINE(ScummEngine, camera._cur.y, sleInt16, VER(8)),
|
|
|
|
MKLINE(ScummEngine, camera._last.x, sleInt16, VER(8)),
|
|
|
|
MKLINE(ScummEngine, camera._last.y, sleInt16, VER(8)),
|
|
|
|
MKLINE(ScummEngine, camera._accel.x, sleInt16, VER(8)),
|
|
|
|
MKLINE(ScummEngine, camera._accel.y, sleInt16, VER(8)),
|
|
|
|
MKLINE(ScummEngine, _screenStartStrip, sleInt16, VER(8)),
|
|
|
|
MKLINE(ScummEngine, _screenEndStrip, sleInt16, VER(8)),
|
|
|
|
MKLINE(ScummEngine, camera._mode, sleByte, VER(8)),
|
|
|
|
MKLINE(ScummEngine, camera._follows, sleByte, VER(8)),
|
|
|
|
MKLINE(ScummEngine, camera._leftTrigger, sleInt16, VER(8)),
|
|
|
|
MKLINE(ScummEngine, camera._rightTrigger, sleInt16, VER(8)),
|
|
|
|
MKLINE(ScummEngine, camera._movingToActor, sleUint16, VER(8)),
|
|
|
|
|
|
|
|
MKLINE(ScummEngine, _actorToPrintStrFor, sleByte, VER(8)),
|
|
|
|
MKLINE(ScummEngine, _charsetColor, sleByte, VER(8)),
|
2002-12-08 16:14:29 +00:00
|
|
|
|
2002-12-26 00:21:19 +00:00
|
|
|
// _charsetBufPos was changed from byte to int
|
2003-10-02 22:42:03 +00:00
|
|
|
MKLINE_OLD(ScummEngine, _charsetBufPos, sleByte, VER(8), VER(9)),
|
|
|
|
MKLINE(ScummEngine, _charsetBufPos, sleInt16, VER(10)),
|
|
|
|
|
|
|
|
MKLINE(ScummEngine, _haveMsg, sleByte, VER(8)),
|
2005-11-02 21:47:44 +00:00
|
|
|
MKLINE(ScummEngine, _haveActorSpeechMsg, sleByte, VER(61)),
|
2003-10-02 22:42:03 +00:00
|
|
|
MKLINE(ScummEngine, _useTalkAnims, sleByte, VER(8)),
|
|
|
|
|
|
|
|
MKLINE(ScummEngine, _talkDelay, sleInt16, VER(8)),
|
|
|
|
MKLINE(ScummEngine, _defaultTalkDelay, sleInt16, VER(8)),
|
2004-01-08 17:30:36 +00:00
|
|
|
MK_OBSOLETE(ScummEngine, _numInMsgStack, sleInt16, VER(8), VER(27)),
|
2003-10-02 22:42:03 +00:00
|
|
|
MKLINE(ScummEngine, _sentenceNum, sleByte, VER(8)),
|
|
|
|
|
|
|
|
MKLINE(ScummEngine, vm.cutSceneStackPointer, sleByte, VER(8)),
|
|
|
|
MKARRAY(ScummEngine, vm.cutScenePtr[0], sleUint32, 5, VER(8)),
|
|
|
|
MKARRAY(ScummEngine, vm.cutSceneScript[0], sleByte, 5, VER(8)),
|
|
|
|
MKARRAY(ScummEngine, vm.cutSceneData[0], sleInt16, 5, VER(8)),
|
|
|
|
MKLINE(ScummEngine, vm.cutSceneScriptIndex, sleInt16, VER(8)),
|
|
|
|
|
|
|
|
MKLINE(ScummEngine, vm.numNestedScripts, sleByte, VER(8)),
|
|
|
|
MKLINE(ScummEngine, _userPut, sleByte, VER(8)),
|
|
|
|
MKLINE(ScummEngine, _userState, sleUint16, VER(17)),
|
|
|
|
MKLINE(ScummEngine, _cursor.state, sleByte, VER(8)),
|
2006-09-17 20:22:47 +00:00
|
|
|
MK_OBSOLETE(ScummEngine, _gdi->_cursorActive, sleByte, VER(8), VER(20)),
|
2003-10-02 22:42:03 +00:00
|
|
|
MKLINE(ScummEngine, _currentCursor, sleByte, VER(8)),
|
|
|
|
MKARRAY(ScummEngine, _grabbedCursor[0], sleByte, 8192, VER(20)),
|
|
|
|
MKLINE(ScummEngine, _cursor.width, sleInt16, VER(20)),
|
|
|
|
MKLINE(ScummEngine, _cursor.height, sleInt16, VER(20)),
|
|
|
|
MKLINE(ScummEngine, _cursor.hotspotX, sleInt16, VER(20)),
|
|
|
|
MKLINE(ScummEngine, _cursor.hotspotY, sleInt16, VER(20)),
|
|
|
|
MKLINE(ScummEngine, _cursor.animate, sleByte, VER(20)),
|
|
|
|
MKLINE(ScummEngine, _cursor.animateIndex, sleByte, VER(20)),
|
|
|
|
MKLINE(ScummEngine, _mouse.x, sleInt16, VER(20)),
|
|
|
|
MKLINE(ScummEngine, _mouse.y, sleInt16, VER(20)),
|
|
|
|
|
2005-11-01 02:43:54 +00:00
|
|
|
MKARRAY(ScummEngine, _colorUsedByCycle[0], sleByte, 256, VER(60)),
|
2003-10-02 22:42:03 +00:00
|
|
|
MKLINE(ScummEngine, _doEffect, sleByte, VER(8)),
|
|
|
|
MKLINE(ScummEngine, _switchRoomEffect, sleByte, VER(8)),
|
|
|
|
MKLINE(ScummEngine, _newEffect, sleByte, VER(8)),
|
|
|
|
MKLINE(ScummEngine, _switchRoomEffect2, sleByte, VER(8)),
|
2004-09-18 22:42:45 +00:00
|
|
|
MKLINE(ScummEngine, _bgNeedsRedraw, sleByte, VER(8)),
|
2002-12-08 16:14:29 +00:00
|
|
|
|
|
|
|
// The state of palManipulate is stored only since V10
|
2003-10-02 22:42:03 +00:00
|
|
|
MKLINE(ScummEngine, _palManipStart, sleByte, VER(10)),
|
|
|
|
MKLINE(ScummEngine, _palManipEnd, sleByte, VER(10)),
|
|
|
|
MKLINE(ScummEngine, _palManipCounter, sleUint16, VER(10)),
|
2002-12-08 16:14:29 +00:00
|
|
|
|
2003-01-14 10:06:56 +00:00
|
|
|
// gfxUsageBits grew from 200 to 410 entries. Then 3 * 410 entries:
|
2003-10-02 22:42:03 +00:00
|
|
|
MKARRAY_OLD(ScummEngine, gfxUsageBits[0], sleUint32, 200, VER(8), VER(9)),
|
|
|
|
MKARRAY_OLD(ScummEngine, gfxUsageBits[0], sleUint32, 410, VER(10), VER(13)),
|
|
|
|
MKARRAY(ScummEngine, gfxUsageBits[0], sleUint32, 3 * 410, VER(14)),
|
2002-12-08 16:14:29 +00:00
|
|
|
|
2006-09-17 20:22:47 +00:00
|
|
|
MK_OBSOLETE(ScummEngine, _gdi->_transparentColor, sleByte, VER(8), VER(50)),
|
2003-10-02 22:42:03 +00:00
|
|
|
MKARRAY(ScummEngine, _currentPalette[0], sleByte, 768, VER(8)),
|
2005-05-21 15:45:09 +00:00
|
|
|
MKARRAY(ScummEngine, _darkenPalette[0], sleByte, 768, VER(53)),
|
2002-12-08 16:14:29 +00:00
|
|
|
|
2004-07-28 11:56:14 +00:00
|
|
|
// Sam & Max specific palette replaced by _shadowPalette now.
|
2004-07-28 12:05:30 +00:00
|
|
|
MK_OBSOLETE_ARRAY(ScummEngine, _proc_special_palette[0], sleByte, 256, VER(8), VER(33)),
|
2002-12-08 16:14:29 +00:00
|
|
|
|
2003-10-02 22:42:03 +00:00
|
|
|
MKARRAY(ScummEngine, _charsetBuffer[0], sleByte, 256, VER(8)),
|
2002-12-08 16:14:29 +00:00
|
|
|
|
2003-10-02 22:42:03 +00:00
|
|
|
MKLINE(ScummEngine, _egoPositioned, sleByte, VER(8)),
|
2002-12-08 16:14:29 +00:00
|
|
|
|
2006-09-17 20:22:47 +00:00
|
|
|
// _gdi->_imgBufOffs grew from 4 to 5 entries. Then one day we realized
|
2004-01-06 11:45:28 +00:00
|
|
|
// that we don't have to store it since initBGBuffers() recomputes it.
|
2006-09-17 20:22:47 +00:00
|
|
|
MK_OBSOLETE_ARRAY(ScummEngine, _gdi->_imgBufOffs[0], sleUint16, 4, VER(8), VER(9)),
|
|
|
|
MK_OBSOLETE_ARRAY(ScummEngine, _gdi->_imgBufOffs[0], sleUint16, 5, VER(10), VER(26)),
|
2002-12-08 16:14:29 +00:00
|
|
|
|
2004-01-06 11:45:28 +00:00
|
|
|
// See _imgBufOffs: _numZBuffer is recomputed by initBGBuffers().
|
2006-09-17 20:22:47 +00:00
|
|
|
MK_OBSOLETE(ScummEngine, _gdi->_numZBuffer, sleByte, VER(8), VER(26)),
|
2002-12-08 16:14:29 +00:00
|
|
|
|
2003-10-02 22:42:03 +00:00
|
|
|
MKLINE(ScummEngine, _screenEffectFlag, sleByte, VER(8)),
|
2002-12-08 16:14:29 +00:00
|
|
|
|
2003-10-02 22:42:03 +00:00
|
|
|
MK_OBSOLETE(ScummEngine, _randSeed1, sleUint32, VER(8), VER(9)),
|
|
|
|
MK_OBSOLETE(ScummEngine, _randSeed2, sleUint32, VER(8), VER(9)),
|
2002-12-08 16:14:29 +00:00
|
|
|
|
|
|
|
// Converted _shakeEnabled to boolean and added a _shakeFrame field.
|
2003-10-02 22:42:03 +00:00
|
|
|
MKLINE_OLD(ScummEngine, _shakeEnabled, sleInt16, VER(8), VER(9)),
|
|
|
|
MKLINE(ScummEngine, _shakeEnabled, sleByte, VER(10)),
|
|
|
|
MKLINE(ScummEngine, _shakeFrame, sleUint32, VER(10)),
|
2002-12-08 16:14:29 +00:00
|
|
|
|
2003-10-02 22:42:03 +00:00
|
|
|
MKLINE(ScummEngine, _keepText, sleByte, VER(8)),
|
2002-12-08 16:14:29 +00:00
|
|
|
|
2003-10-02 22:42:03 +00:00
|
|
|
MKLINE(ScummEngine, _screenB, sleUint16, VER(8)),
|
|
|
|
MKLINE(ScummEngine, _screenH, sleUint16, VER(8)),
|
2002-12-08 16:14:29 +00:00
|
|
|
|
2005-03-25 22:11:08 +00:00
|
|
|
MKLINE(ScummEngine, _NESCostumeSet, sleUint16, VER(47)),
|
|
|
|
|
2003-10-02 22:42:03 +00:00
|
|
|
MK_OBSOLETE(ScummEngine, _cd_track, sleInt16, VER(9), VER(9)),
|
|
|
|
MK_OBSOLETE(ScummEngine, _cd_loops, sleInt16, VER(9), VER(9)),
|
|
|
|
MK_OBSOLETE(ScummEngine, _cd_frame, sleInt16, VER(9), VER(9)),
|
|
|
|
MK_OBSOLETE(ScummEngine, _cd_end, sleInt16, VER(9), VER(9)),
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2001-10-10 10:02:33 +00:00
|
|
|
MKEND()
|
|
|
|
};
|
|
|
|
|
|
|
|
const SaveLoadEntry scriptSlotEntries[] = {
|
2003-08-29 04:05:23 +00:00
|
|
|
MKLINE(ScriptSlot, offs, sleUint32, VER(8)),
|
|
|
|
MKLINE(ScriptSlot, delay, sleInt32, VER(8)),
|
|
|
|
MKLINE(ScriptSlot, number, sleUint16, VER(8)),
|
|
|
|
MKLINE(ScriptSlot, delayFrameCount, sleUint16, VER(8)),
|
|
|
|
MKLINE(ScriptSlot, status, sleByte, VER(8)),
|
|
|
|
MKLINE(ScriptSlot, where, sleByte, VER(8)),
|
|
|
|
MKLINE(ScriptSlot, freezeResistant, sleByte, VER(8)),
|
|
|
|
MKLINE(ScriptSlot, recursive, sleByte, VER(8)),
|
|
|
|
MKLINE(ScriptSlot, freezeCount, sleByte, VER(8)),
|
|
|
|
MKLINE(ScriptSlot, didexec, sleByte, VER(8)),
|
|
|
|
MKLINE(ScriptSlot, cutsceneOverride, sleByte, VER(8)),
|
2005-02-28 13:23:10 +00:00
|
|
|
MKLINE(ScriptSlot, cycle, sleByte, VER(46)),
|
2003-08-29 04:05:23 +00:00
|
|
|
MK_OBSOLETE(ScriptSlot, unk5, sleByte, VER(8), VER(10)),
|
2001-10-10 10:02:33 +00:00
|
|
|
MKEND()
|
|
|
|
};
|
|
|
|
|
|
|
|
const SaveLoadEntry nestedScriptEntries[] = {
|
2003-08-29 04:05:23 +00:00
|
|
|
MKLINE(NestedScript, number, sleUint16, VER(8)),
|
|
|
|
MKLINE(NestedScript, where, sleByte, VER(8)),
|
|
|
|
MKLINE(NestedScript, slot, sleByte, VER(8)),
|
2001-10-10 10:02:33 +00:00
|
|
|
MKEND()
|
|
|
|
};
|
|
|
|
|
2001-10-16 10:01:48 +00:00
|
|
|
const SaveLoadEntry sentenceTabEntries[] = {
|
2003-08-29 04:05:23 +00:00
|
|
|
MKLINE(SentenceTab, verb, sleUint8, VER(8)),
|
|
|
|
MKLINE(SentenceTab, preposition, sleUint8, VER(8)),
|
|
|
|
MKLINE(SentenceTab, objectA, sleUint16, VER(8)),
|
|
|
|
MKLINE(SentenceTab, objectB, sleUint16, VER(8)),
|
|
|
|
MKLINE(SentenceTab, freezeCount, sleUint8, VER(8)),
|
2001-10-16 10:01:48 +00:00
|
|
|
MKEND()
|
|
|
|
};
|
|
|
|
|
|
|
|
const SaveLoadEntry stringTabEntries[] = {
|
2004-04-05 23:54:58 +00:00
|
|
|
// Then _default/restore of a StringTab entry becomes a one liner.
|
2003-08-29 04:05:23 +00:00
|
|
|
MKLINE(StringTab, xpos, sleInt16, VER(8)),
|
2004-04-05 23:54:58 +00:00
|
|
|
MKLINE(StringTab, _default.xpos, sleInt16, VER(8)),
|
2003-08-29 04:05:23 +00:00
|
|
|
MKLINE(StringTab, ypos, sleInt16, VER(8)),
|
2004-04-05 23:54:58 +00:00
|
|
|
MKLINE(StringTab, _default.ypos, sleInt16, VER(8)),
|
2003-08-29 04:05:23 +00:00
|
|
|
MKLINE(StringTab, right, sleInt16, VER(8)),
|
2004-04-05 23:54:58 +00:00
|
|
|
MKLINE(StringTab, _default.right, sleInt16, VER(8)),
|
2003-08-29 04:05:23 +00:00
|
|
|
MKLINE(StringTab, color, sleInt8, VER(8)),
|
2004-04-05 23:54:58 +00:00
|
|
|
MKLINE(StringTab, _default.color, sleInt8, VER(8)),
|
2003-08-29 04:05:23 +00:00
|
|
|
MKLINE(StringTab, charset, sleInt8, VER(8)),
|
2004-04-05 23:54:58 +00:00
|
|
|
MKLINE(StringTab, _default.charset, sleInt8, VER(8)),
|
2003-08-29 04:05:23 +00:00
|
|
|
MKLINE(StringTab, center, sleByte, VER(8)),
|
2004-04-05 23:54:58 +00:00
|
|
|
MKLINE(StringTab, _default.center, sleByte, VER(8)),
|
2003-08-29 04:05:23 +00:00
|
|
|
MKLINE(StringTab, overhead, sleByte, VER(8)),
|
2004-04-05 23:54:58 +00:00
|
|
|
MKLINE(StringTab, _default.overhead, sleByte, VER(8)),
|
2003-08-29 04:05:23 +00:00
|
|
|
MKLINE(StringTab, no_talk_anim, sleByte, VER(8)),
|
2004-04-05 23:54:58 +00:00
|
|
|
MKLINE(StringTab, _default.no_talk_anim, sleByte, VER(8)),
|
2007-04-15 20:36:44 +00:00
|
|
|
MKLINE(StringTab, wrapping, sleByte, VER(71)),
|
|
|
|
MKLINE(StringTab, _default.wrapping, sleByte, VER(71)),
|
2001-10-16 10:01:48 +00:00
|
|
|
MKEND()
|
|
|
|
};
|
|
|
|
|
2001-10-26 17:34:50 +00:00
|
|
|
const SaveLoadEntry colorCycleEntries[] = {
|
2003-08-29 04:05:23 +00:00
|
|
|
MKLINE(ColorCycle, delay, sleUint16, VER(8)),
|
|
|
|
MKLINE(ColorCycle, counter, sleUint16, VER(8)),
|
|
|
|
MKLINE(ColorCycle, flags, sleUint16, VER(8)),
|
|
|
|
MKLINE(ColorCycle, start, sleByte, VER(8)),
|
|
|
|
MKLINE(ColorCycle, end, sleByte, VER(8)),
|
2001-11-05 19:21:49 +00:00
|
|
|
MKEND()
|
2001-10-26 17:34:50 +00:00
|
|
|
};
|
|
|
|
|
2003-01-13 01:29:45 +00:00
|
|
|
const SaveLoadEntry scaleSlotsEntries[] = {
|
2003-08-29 04:05:23 +00:00
|
|
|
MKLINE(ScaleSlot, x1, sleUint16, VER(13)),
|
|
|
|
MKLINE(ScaleSlot, y1, sleUint16, VER(13)),
|
|
|
|
MKLINE(ScaleSlot, scale1, sleUint16, VER(13)),
|
|
|
|
MKLINE(ScaleSlot, x2, sleUint16, VER(13)),
|
|
|
|
MKLINE(ScaleSlot, y2, sleUint16, VER(13)),
|
|
|
|
MKLINE(ScaleSlot, scale2, sleUint16, VER(13)),
|
2003-01-13 01:29:45 +00:00
|
|
|
MKEND()
|
|
|
|
};
|
|
|
|
|
2003-12-09 08:55:32 +00:00
|
|
|
// MSVC6 FIX (Jamieson630):
|
|
|
|
// MSVC6 has a problem with any notation that involves
|
|
|
|
// more than one set of double colons ::
|
|
|
|
// The following MKLINE macros expand to such things
|
|
|
|
// as AudioCDManager::Status::playing, and MSVC6 has
|
|
|
|
// a fit with that. This typedef simplifies the notation
|
|
|
|
// to something MSVC6 can grasp.
|
2010-06-09 20:09:57 +00:00
|
|
|
typedef AudioCDManager::Status AudioCDManager_Status;
|
2003-11-29 13:58:17 +00:00
|
|
|
const SaveLoadEntry audioCDEntries[] = {
|
2003-12-09 08:55:32 +00:00
|
|
|
MKLINE(AudioCDManager_Status, playing, sleUint32, VER(24)),
|
|
|
|
MKLINE(AudioCDManager_Status, track, sleInt32, VER(24)),
|
|
|
|
MKLINE(AudioCDManager_Status, start, sleUint32, VER(24)),
|
|
|
|
MKLINE(AudioCDManager_Status, duration, sleUint32, VER(24)),
|
|
|
|
MKLINE(AudioCDManager_Status, numLoops, sleInt32, VER(24)),
|
2003-11-29 13:58:17 +00:00
|
|
|
MKEND()
|
|
|
|
};
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
int i, j;
|
2002-03-03 21:33:43 +00:00
|
|
|
int var120Backup;
|
2002-03-03 22:14:47 +00:00
|
|
|
int var98Backup;
|
2004-09-10 12:13:03 +00:00
|
|
|
uint8 md5Backup[16];
|
|
|
|
|
|
|
|
// MD5 Operations: Backup on load, compare, and reset.
|
2004-09-12 12:15:19 +00:00
|
|
|
if (s->isLoading())
|
2004-09-12 12:18:46 +00:00
|
|
|
memcpy(md5Backup, _gameMD5, 16);
|
2002-04-11 17:19:16 +00:00
|
|
|
|
2005-04-26 16:43:20 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// Save/load main state (many members of class ScummEngine get saved here)
|
|
|
|
//
|
2002-12-08 16:14:29 +00:00
|
|
|
s->saveLoadEntries(this, mainEntries);
|
2002-04-11 17:19:16 +00:00
|
|
|
|
2004-09-10 12:13:03 +00:00
|
|
|
// MD5 Operations: Backup on load, compare, and reset.
|
2006-01-14 16:33:24 +00:00
|
|
|
if (s->isLoading()) {
|
|
|
|
char md5str1[32+1], md5str2[32+1];
|
|
|
|
for (j = 0; j < 16; j++) {
|
|
|
|
sprintf(md5str1 + j*2, "%02x", (int)_gameMD5[j]);
|
|
|
|
sprintf(md5str2 + j*2, "%02x", (int)md5Backup[j]);
|
|
|
|
}
|
|
|
|
|
|
|
|
debug(2, "Save version: %d", s->getVersion());
|
|
|
|
debug(2, "Saved game MD5: %s", (s->getVersion() >= 39) ? md5str1 : "unknown");
|
|
|
|
|
2004-09-12 12:15:19 +00:00
|
|
|
if (memcmp(md5Backup, _gameMD5, 16) != 0) {
|
2007-02-04 01:24:43 +00:00
|
|
|
warning("Game was saved with different gamedata - you may encounter problems");
|
2005-10-13 23:20:41 +00:00
|
|
|
debug(1, "You have %s and save is %s.", md5str2, md5str1);
|
2008-01-28 00:14:17 +00:00
|
|
|
memcpy(_gameMD5, md5Backup, 16);
|
2004-09-10 12:13:03 +00:00
|
|
|
}
|
2006-01-14 16:33:24 +00:00
|
|
|
}
|
2004-09-10 12:13:03 +00:00
|
|
|
|
|
|
|
|
2005-04-26 13:43:01 +00:00
|
|
|
// Starting V14, we extended the usage bits, to be able to cope with games
|
|
|
|
// that have more than 30 actors (up to 94 are supported now, in theory).
|
|
|
|
// Since the format of the usage bits was changed by this, we have to
|
|
|
|
// convert them when loading an older savegame.
|
2005-10-22 22:54:59 +00:00
|
|
|
if (s->isLoading() && s->getVersion() < VER(14))
|
2003-01-14 10:06:56 +00:00
|
|
|
upgradeGfxUsageBits();
|
|
|
|
|
2005-04-26 13:43:01 +00:00
|
|
|
// When loading, move the mouse to the saved mouse position.
|
2005-10-22 22:54:59 +00:00
|
|
|
if (s->isLoading() && s->getVersion() >= VER(20)) {
|
2003-05-28 18:13:30 +00:00
|
|
|
updateCursor();
|
2004-03-28 16:30:50 +00:00
|
|
|
_system->warpMouse(_mouse.x, _mouse.y);
|
2003-05-28 18:13:30 +00:00
|
|
|
}
|
|
|
|
|
2005-11-02 21:47:44 +00:00
|
|
|
// Before V61, we re-used the _haveMsg flag to handle "alternative" speech
|
|
|
|
// sound files (see charset code 10).
|
|
|
|
if (s->isLoading() && s->getVersion() < VER(61)) {
|
2005-11-04 09:57:13 +00:00
|
|
|
if (_haveMsg == 0xFE) {
|
|
|
|
_haveActorSpeechMsg = false;
|
|
|
|
_haveMsg = 0xFF;
|
|
|
|
} else {
|
|
|
|
_haveActorSpeechMsg = true;
|
|
|
|
}
|
2005-11-02 21:47:44 +00:00
|
|
|
}
|
|
|
|
|
2005-04-26 13:43:01 +00:00
|
|
|
//
|
2005-04-26 13:47:47 +00:00
|
|
|
// Save/load actors
|
2005-04-26 13:43:01 +00:00
|
|
|
//
|
2005-10-21 23:01:13 +00:00
|
|
|
for (i = 0; i < _numActors; i++)
|
2006-12-25 15:03:36 +00:00
|
|
|
_actors[i]->saveLoadWithSerializer(s);
|
2005-04-26 16:43:20 +00:00
|
|
|
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2005-04-26 13:43:01 +00:00
|
|
|
//
|
2005-04-26 13:47:47 +00:00
|
|
|
// Save/load sound data
|
2005-04-26 13:43:01 +00:00
|
|
|
//
|
2005-10-21 23:04:58 +00:00
|
|
|
_sound->saveLoadWithSerializer(s);
|
2002-03-14 14:45:04 +00:00
|
|
|
|
2005-04-26 16:43:20 +00:00
|
|
|
|
2005-04-26 13:47:47 +00:00
|
|
|
//
|
|
|
|
// Save/load script data
|
|
|
|
//
|
2005-10-22 22:54:59 +00:00
|
|
|
if (s->getVersion() < VER(9))
|
2002-05-05 17:44:39 +00:00
|
|
|
s->saveLoadArrayOf(vm.slot, 25, sizeof(vm.slot[0]), scriptSlotEntries);
|
2005-10-22 22:54:59 +00:00
|
|
|
else if (s->getVersion() < VER(20))
|
2003-05-28 18:13:30 +00:00
|
|
|
s->saveLoadArrayOf(vm.slot, 40, sizeof(vm.slot[0]), scriptSlotEntries);
|
2002-05-06 15:32:32 +00:00
|
|
|
else
|
2002-05-05 17:44:39 +00:00
|
|
|
s->saveLoadArrayOf(vm.slot, NUM_SCRIPT_SLOT, sizeof(vm.slot[0]), scriptSlotEntries);
|
2002-12-08 16:14:29 +00:00
|
|
|
|
2005-10-22 22:54:59 +00:00
|
|
|
if (s->getVersion() < VER(46)) {
|
2005-03-02 07:11:58 +00:00
|
|
|
// When loading an old savegame, make sure that the 'cycle'
|
|
|
|
// field is set to something sensible, otherwise the scripts
|
|
|
|
// that were running probably won't be.
|
|
|
|
|
|
|
|
for (i = 0; i < NUM_SCRIPT_SLOT; i++) {
|
|
|
|
vm.slot[i].cycle = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-04-26 16:43:20 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// Save/load local objects
|
|
|
|
//
|
2002-07-07 20:25:23 +00:00
|
|
|
s->saveLoadArrayOf(_objs, _numLocalObjects, sizeof(_objs[0]), objectEntries);
|
2005-10-22 22:54:59 +00:00
|
|
|
if (s->isLoading() && s->getVersion() < VER(13)) {
|
2003-01-14 18:20:56 +00:00
|
|
|
// Since roughly v13 of the save games, the objs storage has changed a bit
|
|
|
|
for (i = _numObjectsInRoom; i < _numLocalObjects; i++) {
|
2003-01-16 18:07:52 +00:00
|
|
|
_objs[i].obj_nr = 0;
|
2003-01-14 18:20:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2005-04-26 16:43:20 +00:00
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// Save/load misc stuff
|
|
|
|
//
|
2001-11-05 19:21:49 +00:00
|
|
|
s->saveLoadArrayOf(_verbs, _numVerbs, sizeof(_verbs[0]), verbEntries);
|
|
|
|
s->saveLoadArrayOf(vm.nest, 16, sizeof(vm.nest[0]), nestedScriptEntries);
|
2002-09-22 01:17:53 +00:00
|
|
|
s->saveLoadArrayOf(_sentence, 6, sizeof(_sentence[0]), sentenceTabEntries);
|
|
|
|
s->saveLoadArrayOf(_string, 6, sizeof(_string[0]), stringTabEntries);
|
2002-07-07 20:25:23 +00:00
|
|
|
s->saveLoadArrayOf(_colorCycle, 16, sizeof(_colorCycle[0]), colorCycleEntries);
|
2005-10-22 22:54:59 +00:00
|
|
|
if (s->getVersion() >= VER(13))
|
2003-01-13 01:29:45 +00:00
|
|
|
s->saveLoadArrayOf(_scaleSlots, 20, sizeof(_scaleSlots[0]), scaleSlotsEntries);
|
|
|
|
|
2005-04-26 16:43:20 +00:00
|
|
|
|
2005-04-26 13:47:47 +00:00
|
|
|
//
|
|
|
|
// Save/load resources
|
|
|
|
//
|
2003-12-27 00:10:20 +00:00
|
|
|
int type, idx;
|
2005-10-22 22:54:59 +00:00
|
|
|
if (s->getVersion() >= VER(26)) {
|
2003-12-27 00:10:20 +00:00
|
|
|
// New, more robust resource save/load system. This stores the type
|
|
|
|
// and index of each resource. Thus if we increase e.g. the maximum
|
|
|
|
// number of script resources, savegames won't break.
|
|
|
|
if (s->isSaving()) {
|
|
|
|
for (type = rtFirst; type <= rtLast; type++) {
|
2006-09-17 20:36:48 +00:00
|
|
|
if (_res->mode[type] != 1 && type != rtTemp && type != rtBuffer) {
|
2003-12-27 00:10:20 +00:00
|
|
|
s->saveUint16(type); // Save the res type...
|
2006-09-17 20:36:48 +00:00
|
|
|
for (idx = 0; idx < _res->num[type]; idx++) {
|
2003-12-27 00:10:20 +00:00
|
|
|
// Only save resources which actually exist...
|
2006-09-17 20:36:48 +00:00
|
|
|
if (_res->address[type][idx]) {
|
2003-12-27 00:10:20 +00:00
|
|
|
s->saveUint16(idx); // Save the index of the resource
|
|
|
|
saveResource(s, type, idx);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
s->saveUint16(0xFFFF); // End marker
|
|
|
|
}
|
|
|
|
}
|
|
|
|
s->saveUint16(0xFFFF); // End marker
|
|
|
|
} else {
|
|
|
|
while ((type = s->loadUint16()) != 0xFFFF) {
|
|
|
|
while ((idx = s->loadUint16()) != 0xFFFF) {
|
2006-09-17 20:36:48 +00:00
|
|
|
assert(0 <= idx && idx < _res->num[type]);
|
2003-12-27 00:10:20 +00:00
|
|
|
loadResource(s, type, idx);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Old, fragile resource save/load system. Doesn't save resources
|
|
|
|
// with index 0, and breaks whenever we change the limit on a given
|
|
|
|
// resource type.
|
2008-01-28 00:14:17 +00:00
|
|
|
for (type = rtFirst; type <= rtLast; type++)
|
|
|
|
if (_res->mode[type] != 1 && type != rtTemp && type != rtBuffer) {
|
|
|
|
// For V1-V5 games, there used to be no object name resources.
|
|
|
|
// At some point this changed. But since old savegames rely on
|
|
|
|
// unchanged resource counts, we have to hard code the following check
|
|
|
|
if (_game.version < 6 && type == rtObjectName)
|
|
|
|
continue;
|
|
|
|
for (idx = 1; idx < _res->num[type]; idx++)
|
|
|
|
saveLoadResource(s, type, idx);
|
|
|
|
}
|
2003-12-27 00:10:20 +00:00
|
|
|
}
|
2002-04-11 17:19:16 +00:00
|
|
|
|
2005-04-26 16:43:20 +00:00
|
|
|
|
2005-04-26 13:47:47 +00:00
|
|
|
//
|
2005-04-26 16:43:20 +00:00
|
|
|
// Save/load global object state
|
2005-04-26 13:47:47 +00:00
|
|
|
//
|
2002-07-07 20:25:23 +00:00
|
|
|
s->saveLoadArrayOf(_objectOwnerTable, _numGlobalObjects, sizeof(_objectOwnerTable[0]), sleByte);
|
|
|
|
s->saveLoadArrayOf(_objectStateTable, _numGlobalObjects, sizeof(_objectStateTable[0]), sleByte);
|
2001-11-26 19:57:57 +00:00
|
|
|
if (_objectRoomTable)
|
2002-07-07 20:25:23 +00:00
|
|
|
s->saveLoadArrayOf(_objectRoomTable, _numGlobalObjects, sizeof(_objectRoomTable[0]), sleByte);
|
2001-11-26 19:57:57 +00:00
|
|
|
|
2005-04-26 16:43:20 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// Save/load palette data
|
|
|
|
//
|
SCUMM/FM-TOWNS: fix palette and other graphics issues
This commit should fix at least the following bugs/feature requests: #1032859, #1252088, #1055391, #1315968, #1315938, #1742106, #812891.
The FM-Towns version of Scumm games use a mixed graphics mode with 2 layers (one with 32767 colors and one with 16 colors). Among other things I have added a screen output class which emulates this dual layer approach which allows specific hardware effects like enabling and disabling layers (e.g. in the voodoo priestess scene in MI1).
Old savegames (saved before this update) will load, but you’ll encounter palette glitches in the verb/inventory screen, since the 16 color palette for layer 2 is not contained in your savegame. This will be true at least for version 5 games. Certain scene change actions (which require the verb/inventory part to be redrawn) might correct this (e.g. try looking at the treasure map in MI1 and closing it). Version 3 games should be okay, since they use a static text palette which is never changed and which will be reset after loading a savegame.
This update requires a USE_RGB_COLORS setting for proper operation. 8 bit users will get a warning that they’ll have to expect palette glitches . Apart from that the engine in 8 bit mode should not only still work okay, but also benefit from some of the other (non palette related) improvements (e.g. bug #1032859 should be fixed even in 8 bit mode).
Japanese font drawing hasn’t been improved much yet. This will be a separate task.
svn-id: r52966
2010-10-01 19:24:52 +00:00
|
|
|
if (_16BitPalette && !(_game.platform == Common::kPlatformFMTowns && s->isLoading() && s->getVersion() < VER(82))) {
|
2009-10-27 09:44:13 +00:00
|
|
|
s->saveLoadArrayOf(_16BitPalette, 512, sizeof(_16BitPalette[0]), sleUint16);
|
|
|
|
}
|
SCUMM/FM-TOWNS: fix palette and other graphics issues
This commit should fix at least the following bugs/feature requests: #1032859, #1252088, #1055391, #1315968, #1315938, #1742106, #812891.
The FM-Towns version of Scumm games use a mixed graphics mode with 2 layers (one with 32767 colors and one with 16 colors). Among other things I have added a screen output class which emulates this dual layer approach which allows specific hardware effects like enabling and disabling layers (e.g. in the voodoo priestess scene in MI1).
Old savegames (saved before this update) will load, but you’ll encounter palette glitches in the verb/inventory screen, since the 16 color palette for layer 2 is not contained in your savegame. This will be true at least for version 5 games. Certain scene change actions (which require the verb/inventory part to be redrawn) might correct this (e.g. try looking at the treasure map in MI1 and closing it). Version 3 games should be okay, since they use a static text palette which is never changed and which will be reset after loading a savegame.
This update requires a USE_RGB_COLORS setting for proper operation. 8 bit users will get a warning that they’ll have to expect palette glitches . Apart from that the engine in 8 bit mode should not only still work okay, but also benefit from some of the other (non palette related) improvements (e.g. bug #1032859 should be fixed even in 8 bit mode).
Japanese font drawing hasn’t been improved much yet. This will be a separate task.
svn-id: r52966
2010-10-01 19:24:52 +00:00
|
|
|
|
2010-10-05 19:04:52 +00:00
|
|
|
#ifndef DISABLE_TOWNS_DUAL_LAYER_MODE
|
SCUMM/FM-TOWNS: fix palette and other graphics issues
This commit should fix at least the following bugs/feature requests: #1032859, #1252088, #1055391, #1315968, #1315938, #1742106, #812891.
The FM-Towns version of Scumm games use a mixed graphics mode with 2 layers (one with 32767 colors and one with 16 colors). Among other things I have added a screen output class which emulates this dual layer approach which allows specific hardware effects like enabling and disabling layers (e.g. in the voodoo priestess scene in MI1).
Old savegames (saved before this update) will load, but you’ll encounter palette glitches in the verb/inventory screen, since the 16 color palette for layer 2 is not contained in your savegame. This will be true at least for version 5 games. Certain scene change actions (which require the verb/inventory part to be redrawn) might correct this (e.g. try looking at the treasure map in MI1 and closing it). Version 3 games should be okay, since they use a static text palette which is never changed and which will be reset after loading a savegame.
This update requires a USE_RGB_COLORS setting for proper operation. 8 bit users will get a warning that they’ll have to expect palette glitches . Apart from that the engine in 8 bit mode should not only still work okay, but also benefit from some of the other (non palette related) improvements (e.g. bug #1032859 should be fixed even in 8 bit mode).
Japanese font drawing hasn’t been improved much yet. This will be a separate task.
svn-id: r52966
2010-10-01 19:24:52 +00:00
|
|
|
// FM-Towns specific (extra palette data, color cycle data, etc.)
|
|
|
|
if (s->getVersion() >= VER(82)) {
|
|
|
|
const SaveLoadEntry townsFields[] = {
|
|
|
|
MKLINE(Common::Rect, left, sleInt16, VER(82)),
|
|
|
|
MKLINE(Common::Rect, top, sleInt16, VER(82)),
|
|
|
|
MKLINE(Common::Rect, right, sleInt16, VER(82)),
|
|
|
|
MKLINE(Common::Rect, bottom, sleInt16, VER(82)),
|
|
|
|
MKEND()
|
|
|
|
};
|
|
|
|
|
|
|
|
const SaveLoadEntry townsExtraEntries[] = {
|
|
|
|
MKLINE(ScummEngine, _townsOverrideShadowColor, sleUint8, VER(82)),
|
|
|
|
MKLINE(ScummEngine, _numCyclRects, sleUint8, VER(82)),
|
|
|
|
MKLINE(ScummEngine, _townsPaletteFlags, sleUint8, VER(82)),
|
|
|
|
MKLINE(ScummEngine, _townsClearLayerFlag, sleUint8, VER(82)),
|
|
|
|
MKLINE(ScummEngine, _townsActiveLayerFlags, sleUint8, VER(82)),
|
|
|
|
MKEND()
|
|
|
|
};
|
|
|
|
|
|
|
|
s->saveLoadArrayOf(_textPalette, 48, sizeof(_textPalette[0]), sleUint8);
|
|
|
|
s->saveLoadArrayOf(_cyclRects, 10, sizeof(_cyclRects[0]), townsFields);
|
|
|
|
s->saveLoadArrayOf(&_curStringRect, 1, sizeof(_curStringRect), townsFields);
|
|
|
|
s->saveLoadArrayOf(_townsCharsetColorMap, 16, sizeof(_townsCharsetColorMap[0]), sleUint8);
|
|
|
|
s->saveLoadEntries(this, townsExtraEntries);
|
|
|
|
}
|
2010-10-05 19:04:52 +00:00
|
|
|
#endif
|
SCUMM/FM-TOWNS: fix palette and other graphics issues
This commit should fix at least the following bugs/feature requests: #1032859, #1252088, #1055391, #1315968, #1315938, #1742106, #812891.
The FM-Towns version of Scumm games use a mixed graphics mode with 2 layers (one with 32767 colors and one with 16 colors). Among other things I have added a screen output class which emulates this dual layer approach which allows specific hardware effects like enabling and disabling layers (e.g. in the voodoo priestess scene in MI1).
Old savegames (saved before this update) will load, but you’ll encounter palette glitches in the verb/inventory screen, since the 16 color palette for layer 2 is not contained in your savegame. This will be true at least for version 5 games. Certain scene change actions (which require the verb/inventory part to be redrawn) might correct this (e.g. try looking at the treasure map in MI1 and closing it). Version 3 games should be okay, since they use a static text palette which is never changed and which will be reset after loading a savegame.
This update requires a USE_RGB_COLORS setting for proper operation. 8 bit users will get a warning that they’ll have to expect palette glitches . Apart from that the engine in 8 bit mode should not only still work okay, but also benefit from some of the other (non palette related) improvements (e.g. bug #1032859 should be fixed even in 8 bit mode).
Japanese font drawing hasn’t been improved much yet. This will be a separate task.
svn-id: r52966
2010-10-01 19:24:52 +00:00
|
|
|
|
2003-08-29 03:54:47 +00:00
|
|
|
if (_shadowPaletteSize) {
|
2001-12-27 17:51:58 +00:00
|
|
|
s->saveLoadArrayOf(_shadowPalette, _shadowPaletteSize, 1, sleByte);
|
2003-08-29 03:54:47 +00:00
|
|
|
// _roomPalette didn't show up until V21 save games
|
2006-02-20 16:51:30 +00:00
|
|
|
if (s->getVersion() >= VER(21) && _game.version < 5)
|
2003-10-12 17:33:29 +00:00
|
|
|
s->saveLoadArrayOf(_roomPalette, sizeof(_roomPalette), 1, sleByte);
|
2003-08-29 03:54:47 +00:00
|
|
|
}
|
2001-11-26 19:57:57 +00:00
|
|
|
|
2002-12-08 16:14:29 +00:00
|
|
|
// PalManip data was not saved before V10 save games
|
2005-10-22 22:54:59 +00:00
|
|
|
if (s->getVersion() < VER(10))
|
2002-12-08 16:14:29 +00:00
|
|
|
_palManipCounter = 0;
|
2002-09-24 15:46:09 +00:00
|
|
|
if (_palManipCounter) {
|
|
|
|
if (!_palManipPalette)
|
|
|
|
_palManipPalette = (byte *)calloc(0x300, 1);
|
|
|
|
if (!_palManipIntermediatePal)
|
2004-11-27 18:01:44 +00:00
|
|
|
_palManipIntermediatePal = (byte *)calloc(0x600, 1);
|
2002-09-24 15:46:09 +00:00
|
|
|
s->saveLoadArrayOf(_palManipPalette, 0x300, 1, sleByte);
|
|
|
|
s->saveLoadArrayOf(_palManipIntermediatePal, 0x600, 1, sleByte);
|
|
|
|
}
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2005-05-21 15:45:09 +00:00
|
|
|
// darkenPalette was not saved before V53
|
2005-10-22 22:54:59 +00:00
|
|
|
if (s->isLoading() && s->getVersion() < VER(53)) {
|
2005-05-21 15:45:09 +00:00
|
|
|
memcpy(_darkenPalette, _currentPalette, 768);
|
|
|
|
}
|
2002-09-24 15:46:09 +00:00
|
|
|
|
2005-11-01 02:43:54 +00:00
|
|
|
// _colorUsedByCycle was not saved before V60
|
|
|
|
if (s->isLoading() && s->getVersion() < VER(60)) {
|
|
|
|
memset(_colorUsedByCycle, 0, sizeof(_colorUsedByCycle));
|
|
|
|
}
|
2005-04-26 16:43:20 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// Save/load more global object state
|
|
|
|
//
|
2002-07-07 20:25:23 +00:00
|
|
|
s->saveLoadArrayOf(_classData, _numGlobalObjects, sizeof(_classData[0]), sleUint32);
|
2002-04-11 17:19:16 +00:00
|
|
|
|
2005-04-26 13:47:47 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// Save/load script variables
|
|
|
|
//
|
2003-05-08 15:48:50 +00:00
|
|
|
var120Backup = _scummVars[120];
|
|
|
|
var98Backup = _scummVars[98];
|
2002-04-11 17:19:16 +00:00
|
|
|
|
2005-10-22 22:54:59 +00:00
|
|
|
if (s->getVersion() > VER(37))
|
2004-09-10 01:03:01 +00:00
|
|
|
s->saveLoadArrayOf(_roomVars, _numRoomVariables, sizeof(_roomVars[0]), sleInt32);
|
|
|
|
|
2003-01-15 14:14:00 +00:00
|
|
|
// The variables grew from 16 to 32 bit.
|
2005-10-22 22:54:59 +00:00
|
|
|
if (s->getVersion() < VER(15))
|
2003-05-08 15:48:50 +00:00
|
|
|
s->saveLoadArrayOf(_scummVars, _numVariables, sizeof(_scummVars[0]), sleInt16);
|
2003-01-15 14:14:00 +00:00
|
|
|
else
|
2003-05-08 15:48:50 +00:00
|
|
|
s->saveLoadArrayOf(_scummVars, _numVariables, sizeof(_scummVars[0]), sleInt32);
|
2002-03-03 22:14:47 +00:00
|
|
|
|
2006-02-20 16:51:30 +00:00
|
|
|
if (_game.id == GID_TENTACLE) // Maybe misplaced, but that's the main idea
|
2003-05-08 15:48:50 +00:00
|
|
|
_scummVars[120] = var120Backup;
|
2006-02-20 16:51:30 +00:00
|
|
|
if (_game.id == GID_INDY4)
|
2004-10-03 10:02:32 +00:00
|
|
|
_scummVars[98] = var98Backup;
|
2002-04-11 17:19:16 +00:00
|
|
|
|
|
|
|
s->saveLoadArrayOf(_bitVars, _numBitVariables >> 3, 1, sleByte);
|
2001-11-07 18:10:52 +00:00
|
|
|
|
2005-04-26 16:43:20 +00:00
|
|
|
|
2005-04-26 13:47:47 +00:00
|
|
|
//
|
|
|
|
// Save/load a list of the locked objects
|
|
|
|
//
|
2001-11-07 18:10:52 +00:00
|
|
|
if (s->isSaving()) {
|
2002-04-11 17:19:16 +00:00
|
|
|
for (i = rtFirst; i <= rtLast; i++)
|
2006-09-17 20:36:48 +00:00
|
|
|
for (j = 1; j < _res->num[i]; j++) {
|
|
|
|
if (_res->isLocked(i, j)) {
|
2001-11-07 18:10:52 +00:00
|
|
|
s->saveByte(i);
|
2003-12-27 00:10:20 +00:00
|
|
|
s->saveUint16(j);
|
2001-11-07 18:10:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
s->saveByte(0xFF);
|
|
|
|
} else {
|
2005-04-26 13:16:18 +00:00
|
|
|
while ((i = s->loadByte()) != 0xFF) {
|
|
|
|
j = s->loadUint16();
|
2006-09-17 20:36:48 +00:00
|
|
|
_res->lock(i, j);
|
2001-11-07 18:10:52 +00:00
|
|
|
}
|
|
|
|
}
|
2003-09-09 17:29:22 +00:00
|
|
|
|
2005-04-26 16:43:20 +00:00
|
|
|
|
2005-04-26 13:47:47 +00:00
|
|
|
//
|
|
|
|
// Save/load the Audio CD status
|
|
|
|
//
|
2005-10-22 22:54:59 +00:00
|
|
|
if (s->getVersion() >= VER(24)) {
|
2010-06-09 20:09:57 +00:00
|
|
|
AudioCDManager::Status info;
|
2003-11-29 13:58:17 +00:00
|
|
|
if (s->isSaving())
|
2010-06-15 04:13:12 +00:00
|
|
|
info = _system->getAudioCDManager()->getStatus();
|
2003-11-29 13:58:17 +00:00
|
|
|
s->saveLoadArrayOf(&info, 1, sizeof(info), audioCDEntries);
|
|
|
|
// If we are loading, and the music being loaded was supposed to loop
|
2005-04-26 13:43:01 +00:00
|
|
|
// forever, then resume playing it. This helps a lot when the audio CD
|
2003-11-29 13:58:17 +00:00
|
|
|
// is used to provide ambient music (see bug #788195).
|
|
|
|
if (s->isLoading() && info.playing && info.numLoops < 0)
|
2010-06-15 04:13:12 +00:00
|
|
|
_system->getAudioCDManager()->play(info.track, info.numLoops, info.start, info.duration);
|
2003-11-29 13:58:17 +00:00
|
|
|
}
|
|
|
|
|
2005-04-26 16:43:20 +00:00
|
|
|
|
2005-04-26 13:47:47 +00:00
|
|
|
//
|
|
|
|
// Save/load the iMuse status
|
|
|
|
//
|
2004-01-31 22:12:35 +00:00
|
|
|
if (_imuse && (_saveSound || !_saveTemporaryState)) {
|
2002-04-14 18:13:08 +00:00
|
|
|
_imuse->save_or_load(s, this);
|
2002-12-07 20:28:40 +00:00
|
|
|
}
|
2007-05-26 17:39:33 +00:00
|
|
|
|
2010-08-18 21:38:43 +00:00
|
|
|
|
|
|
|
// Save/load FM-Towns audio status
|
|
|
|
if (_townsPlayer)
|
|
|
|
_townsPlayer->saveLoadWithSerializer(s);
|
|
|
|
|
2007-05-26 17:39:33 +00:00
|
|
|
//
|
|
|
|
// Save/load the charset renderer state
|
|
|
|
//
|
2007-05-28 08:02:10 +00:00
|
|
|
if (s->getVersion() >= VER(73)) {
|
|
|
|
_charset->saveLoadWithSerializer(s);
|
|
|
|
} else if (s->isLoading()) {
|
|
|
|
if (s->getVersion() == VER(72)) {
|
2007-05-26 17:39:33 +00:00
|
|
|
_charset->setCurID(s->loadByte());
|
2007-05-28 08:02:10 +00:00
|
|
|
} else {
|
|
|
|
// Before V72, the charset id wasn't saved. This used to cause issues such
|
|
|
|
// as the one described in the bug report #1722153. For these savegames,
|
|
|
|
// we reinitialize the id using a, hopefully, sane value.
|
|
|
|
_charset->setCurID(_string[0]._default.charset);
|
2007-05-26 17:39:33 +00:00
|
|
|
}
|
|
|
|
}
|
2005-04-26 13:33:17 +00:00
|
|
|
}
|
2004-05-02 10:07:59 +00:00
|
|
|
|
2007-02-25 11:38:19 +00:00
|
|
|
void ScummEngine_v0::saveOrLoad(Serializer *s) {
|
2009-07-28 23:19:33 +00:00
|
|
|
ScummEngine_v2::saveOrLoad(s);
|
2006-03-16 12:04:52 +00:00
|
|
|
|
2009-07-25 06:27:41 +00:00
|
|
|
const SaveLoadEntry v0Entrys[] = {
|
|
|
|
MKLINE(ScummEngine_v0, _currentMode, sleByte, VER(78)),
|
|
|
|
MKLINE(ScummEngine_v0, _currentLights, sleByte, VER(78)),
|
|
|
|
MKEND()
|
|
|
|
};
|
|
|
|
s->saveLoadEntries(this, v0Entrys);
|
2006-03-16 12:04:52 +00:00
|
|
|
}
|
|
|
|
|
2009-07-28 23:19:33 +00:00
|
|
|
|
|
|
|
void ScummEngine_v2::saveOrLoad(Serializer *s) {
|
2006-03-16 12:04:52 +00:00
|
|
|
ScummEngine::saveOrLoad(s);
|
|
|
|
|
2009-07-28 23:19:33 +00:00
|
|
|
const SaveLoadEntry v2Entrys[] = {
|
|
|
|
MKLINE(ScummEngine_v2, _inventoryOffset, sleUint16, VER(79)),
|
|
|
|
MKEND()
|
|
|
|
};
|
|
|
|
s->saveLoadEntries(this, v2Entrys);
|
|
|
|
|
|
|
|
// In old saves we didn't store _inventoryOffset -> reset it to
|
|
|
|
// a sane default when loading one of those.
|
|
|
|
if (s->getVersion() < 79 && s->isLoading()) {
|
|
|
|
_inventoryOffset = 0;
|
|
|
|
}
|
2006-03-16 12:04:52 +00:00
|
|
|
}
|
|
|
|
|
2005-10-22 22:54:59 +00:00
|
|
|
void ScummEngine_v5::saveOrLoad(Serializer *s) {
|
|
|
|
ScummEngine::saveOrLoad(s);
|
2005-04-26 13:33:17 +00:00
|
|
|
|
|
|
|
const SaveLoadEntry cursorEntries[] = {
|
|
|
|
MKARRAY2(ScummEngine_v5, _cursorImages[0][0], sleUint16, 16, 4, (byte*)_cursorImages[1] - (byte*)_cursorImages[0], VER(44)),
|
|
|
|
MKARRAY(ScummEngine_v5, _cursorHotspots[0], sleByte, 8, VER(44)),
|
|
|
|
MKEND()
|
|
|
|
};
|
2004-11-28 21:24:02 +00:00
|
|
|
|
2005-01-06 15:57:12 +00:00
|
|
|
// This is probably only needed for Loom.
|
2005-04-26 13:33:17 +00:00
|
|
|
s->saveLoadEntries(this, cursorEntries);
|
SCUMM/FM-TOWNS: fix palette and other graphics issues
This commit should fix at least the following bugs/feature requests: #1032859, #1252088, #1055391, #1315968, #1315938, #1742106, #812891.
The FM-Towns version of Scumm games use a mixed graphics mode with 2 layers (one with 32767 colors and one with 16 colors). Among other things I have added a screen output class which emulates this dual layer approach which allows specific hardware effects like enabling and disabling layers (e.g. in the voodoo priestess scene in MI1).
Old savegames (saved before this update) will load, but you’ll encounter palette glitches in the verb/inventory screen, since the 16 color palette for layer 2 is not contained in your savegame. This will be true at least for version 5 games. Certain scene change actions (which require the verb/inventory part to be redrawn) might correct this (e.g. try looking at the treasure map in MI1 and closing it). Version 3 games should be okay, since they use a static text palette which is never changed and which will be reset after loading a savegame.
This update requires a USE_RGB_COLORS setting for proper operation. 8 bit users will get a warning that they’ll have to expect palette glitches . Apart from that the engine in 8 bit mode should not only still work okay, but also benefit from some of the other (non palette related) improvements (e.g. bug #1032859 should be fixed even in 8 bit mode).
Japanese font drawing hasn’t been improved much yet. This will be a separate task.
svn-id: r52966
2010-10-01 19:24:52 +00:00
|
|
|
|
|
|
|
// Reset cursors for old FM-Towns savegames saved with 256 color setting.
|
|
|
|
// Otherwise the cursor will be messed up when displayed in the new hi color setting.
|
|
|
|
if (_game.platform == Common::kPlatformFMTowns && _bytesPerPixelOutput == 2 && s->isLoading() && s->getVersion() < VER(82)) {
|
|
|
|
if (_game.id == GID_LOOM) {
|
|
|
|
redefineBuiltinCursorFromChar(1, 1);
|
|
|
|
redefineBuiltinCursorHotspot(1, 0, 0);
|
|
|
|
} else {
|
|
|
|
resetCursors();
|
|
|
|
}
|
|
|
|
}
|
2005-04-26 13:33:17 +00:00
|
|
|
}
|
|
|
|
|
2008-05-06 03:00:26 +00:00
|
|
|
#ifdef ENABLE_SCUMM_7_8
|
2005-10-22 22:54:59 +00:00
|
|
|
void ScummEngine_v7::saveOrLoad(Serializer *s) {
|
|
|
|
ScummEngine::saveOrLoad(s);
|
2005-04-26 13:33:17 +00:00
|
|
|
|
2005-11-02 21:47:44 +00:00
|
|
|
const SaveLoadEntry subtitleQueueEntries[] = {
|
|
|
|
MKARRAY(SubtitleText, text[0], sleByte, 256, VER(61)),
|
|
|
|
MKLINE(SubtitleText, charset, sleByte, VER(61)),
|
|
|
|
MKLINE(SubtitleText, color, sleByte, VER(61)),
|
|
|
|
MKLINE(SubtitleText, xpos, sleInt16, VER(61)),
|
|
|
|
MKLINE(SubtitleText, ypos, sleInt16, VER(61)),
|
|
|
|
MKLINE(SubtitleText, actorSpeechMsg, sleByte, VER(61)),
|
|
|
|
MKEND()
|
|
|
|
};
|
|
|
|
|
|
|
|
const SaveLoadEntry V7Entries[] = {
|
|
|
|
MKLINE(ScummEngine_v7, _subtitleQueuePos, sleInt32, VER(61)),
|
2007-01-28 18:47:10 +00:00
|
|
|
MK_OBSOLETE(ScummEngine_v7, _verbCharset, sleInt32, VER(68), VER(68)),
|
2006-05-31 10:48:40 +00:00
|
|
|
MKLINE(ScummEngine_v7, _verbLineSpacing, sleInt32, VER(68)),
|
2005-11-02 21:47:44 +00:00
|
|
|
MKEND()
|
|
|
|
};
|
|
|
|
|
2005-04-26 13:33:17 +00:00
|
|
|
_imuseDigital->saveOrLoad(s);
|
2005-11-02 21:47:44 +00:00
|
|
|
|
|
|
|
s->saveLoadArrayOf(_subtitleQueue, ARRAYSIZE(_subtitleQueue), sizeof(_subtitleQueue[0]), subtitleQueueEntries);
|
|
|
|
s->saveLoadEntries(this, V7Entries);
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2007-12-23 17:27:33 +00:00
|
|
|
if (s->getVersion() <= VER(68) && s->isLoading()) {
|
|
|
|
// WORKAROUND bug #1846049: Reset the default charset color to a sane value.
|
|
|
|
_string[0]._default.charset = 1;
|
|
|
|
}
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
2005-05-14 22:56:41 +00:00
|
|
|
#endif
|
2001-10-09 14:30:12 +00:00
|
|
|
|
2005-10-22 22:54:59 +00:00
|
|
|
void ScummEngine_v60he::saveOrLoad(Serializer *s) {
|
|
|
|
ScummEngine::saveOrLoad(s);
|
2005-04-26 14:01:38 +00:00
|
|
|
|
2005-10-19 12:15:36 +00:00
|
|
|
s->saveLoadArrayOf(_arraySlot, _numArray, sizeof(_arraySlot[0]), sleByte);
|
|
|
|
}
|
|
|
|
|
2005-10-22 22:54:59 +00:00
|
|
|
void ScummEngine_v70he::saveOrLoad(Serializer *s) {
|
|
|
|
ScummEngine_v60he::saveOrLoad(s);
|
2005-10-19 12:15:36 +00:00
|
|
|
|
|
|
|
const SaveLoadEntry HE70Entries[] = {
|
|
|
|
MKLINE(ScummEngine_v70he, _heSndSoundId, sleInt32, VER(51)),
|
|
|
|
MKLINE(ScummEngine_v70he, _heSndOffset, sleInt32, VER(51)),
|
|
|
|
MKLINE(ScummEngine_v70he, _heSndChannel, sleInt32, VER(51)),
|
|
|
|
MKLINE(ScummEngine_v70he, _heSndFlags, sleInt32, VER(51)),
|
|
|
|
MKEND()
|
|
|
|
};
|
|
|
|
|
|
|
|
s->saveLoadEntries(this, HE70Entries);
|
|
|
|
}
|
|
|
|
|
2008-05-06 03:00:26 +00:00
|
|
|
#ifdef ENABLE_HE
|
2005-10-22 22:54:59 +00:00
|
|
|
void ScummEngine_v71he::saveOrLoad(Serializer *s) {
|
|
|
|
ScummEngine_v70he::saveOrLoad(s);
|
2005-10-19 12:15:36 +00:00
|
|
|
|
2005-04-26 14:01:38 +00:00
|
|
|
const SaveLoadEntry polygonEntries[] = {
|
|
|
|
MKLINE(WizPolygon, vert[0].x, sleInt16, VER(40)),
|
|
|
|
MKLINE(WizPolygon, vert[0].y, sleInt16, VER(40)),
|
|
|
|
MKLINE(WizPolygon, vert[1].x, sleInt16, VER(40)),
|
|
|
|
MKLINE(WizPolygon, vert[1].y, sleInt16, VER(40)),
|
|
|
|
MKLINE(WizPolygon, vert[2].x, sleInt16, VER(40)),
|
|
|
|
MKLINE(WizPolygon, vert[2].y, sleInt16, VER(40)),
|
|
|
|
MKLINE(WizPolygon, vert[3].x, sleInt16, VER(40)),
|
|
|
|
MKLINE(WizPolygon, vert[3].y, sleInt16, VER(40)),
|
|
|
|
MKLINE(WizPolygon, vert[4].x, sleInt16, VER(40)),
|
|
|
|
MKLINE(WizPolygon, vert[4].y, sleInt16, VER(40)),
|
|
|
|
MKLINE(WizPolygon, bound.left, sleInt16, VER(40)),
|
|
|
|
MKLINE(WizPolygon, bound.top, sleInt16, VER(40)),
|
|
|
|
MKLINE(WizPolygon, bound.right, sleInt16, VER(40)),
|
|
|
|
MKLINE(WizPolygon, bound.bottom, sleInt16, VER(40)),
|
|
|
|
MKLINE(WizPolygon, id, sleInt16, VER(40)),
|
|
|
|
MKLINE(WizPolygon, numVerts, sleInt16, VER(40)),
|
|
|
|
MKLINE(WizPolygon, flag, sleByte, VER(40)),
|
|
|
|
MKEND()
|
|
|
|
};
|
|
|
|
|
2005-10-19 12:15:36 +00:00
|
|
|
s->saveLoadArrayOf(_wiz->_polygons, ARRAYSIZE(_wiz->_polygons), sizeof(_wiz->_polygons[0]), polygonEntries);
|
2005-04-26 14:01:38 +00:00
|
|
|
}
|
|
|
|
|
2005-10-22 22:54:59 +00:00
|
|
|
void ScummEngine_v90he::saveOrLoad(Serializer *s) {
|
|
|
|
ScummEngine_v71he::saveOrLoad(s);
|
2005-04-26 14:01:38 +00:00
|
|
|
|
2005-10-18 19:17:19 +00:00
|
|
|
const SaveLoadEntry floodFillEntries[] = {
|
|
|
|
MKLINE(FloodFillParameters, box.left, sleInt32, VER(51)),
|
|
|
|
MKLINE(FloodFillParameters, box.top, sleInt32, VER(51)),
|
|
|
|
MKLINE(FloodFillParameters, box.right, sleInt32, VER(51)),
|
|
|
|
MKLINE(FloodFillParameters, box.bottom, sleInt32, VER(51)),
|
|
|
|
MKLINE(FloodFillParameters, x, sleInt32, VER(51)),
|
|
|
|
MKLINE(FloodFillParameters, y, sleInt32, VER(51)),
|
|
|
|
MKLINE(FloodFillParameters, flags, sleInt32, VER(51)),
|
2006-01-10 21:39:14 +00:00
|
|
|
MK_OBSOLETE(FloodFillParameters, unk1C, sleInt32, VER(51), VER(62)),
|
2005-04-26 15:13:04 +00:00
|
|
|
MKEND()
|
|
|
|
};
|
|
|
|
|
|
|
|
const SaveLoadEntry HE90Entries[] = {
|
|
|
|
MKLINE(ScummEngine_v90he, _curMaxSpriteId, sleInt32, VER(51)),
|
|
|
|
MKLINE(ScummEngine_v90he, _curSpriteId, sleInt32, VER(51)),
|
|
|
|
MKLINE(ScummEngine_v90he, _curSpriteGroupId, sleInt32, VER(51)),
|
2006-02-04 09:38:51 +00:00
|
|
|
MK_OBSOLETE(ScummEngine_v90he, _numSpritesToProcess, sleInt32, VER(51), VER(63)),
|
2005-04-26 15:13:04 +00:00
|
|
|
MKLINE(ScummEngine_v90he, _heObject, sleInt32, VER(51)),
|
|
|
|
MKLINE(ScummEngine_v90he, _heObjectNum, sleInt32, VER(51)),
|
|
|
|
MKLINE(ScummEngine_v90he, _hePaletteNum, sleInt32, VER(51)),
|
|
|
|
MKEND()
|
|
|
|
};
|
|
|
|
|
2005-10-22 22:54:59 +00:00
|
|
|
_sprite->saveOrLoadSpriteData(s);
|
2005-04-26 15:13:04 +00:00
|
|
|
|
2005-10-18 19:17:19 +00:00
|
|
|
s->saveLoadArrayOf(&_floodFillParams, 1, sizeof(_floodFillParams), floodFillEntries);
|
2005-05-28 10:44:27 +00:00
|
|
|
|
2005-04-26 15:13:04 +00:00
|
|
|
s->saveLoadEntries(this, HE90Entries);
|
2005-10-19 12:15:36 +00:00
|
|
|
}
|
2005-04-26 15:31:51 +00:00
|
|
|
|
2005-10-22 22:54:59 +00:00
|
|
|
void ScummEngine_v99he::saveOrLoad(Serializer *s) {
|
|
|
|
ScummEngine_v90he::saveOrLoad(s);
|
2005-10-19 12:15:36 +00:00
|
|
|
|
2009-06-04 01:05:47 +00:00
|
|
|
s->saveLoadArrayOf(_hePalettes, (_numPalettes + 1) * _hePaletteSlot, sizeof(_hePalettes[0]), sleUint8);
|
2005-04-26 15:13:04 +00:00
|
|
|
}
|
|
|
|
|
2005-10-22 22:54:59 +00:00
|
|
|
void ScummEngine_v100he::saveOrLoad(Serializer *s) {
|
|
|
|
ScummEngine_v99he::saveOrLoad(s);
|
2005-04-26 15:13:04 +00:00
|
|
|
|
|
|
|
const SaveLoadEntry HE100Entries[] = {
|
|
|
|
MKLINE(ScummEngine_v100he, _heResId, sleInt32, VER(51)),
|
|
|
|
MKLINE(ScummEngine_v100he, _heResType, sleInt32, VER(51)),
|
|
|
|
MKEND()
|
|
|
|
};
|
|
|
|
|
|
|
|
s->saveLoadEntries(this, HE100Entries);
|
2005-04-26 14:01:38 +00:00
|
|
|
}
|
2005-05-14 14:06:37 +00:00
|
|
|
#endif
|
2005-04-26 14:01:38 +00:00
|
|
|
|
2003-10-02 22:42:03 +00:00
|
|
|
void ScummEngine::saveLoadResource(Serializer *ser, int type, int idx) {
|
2001-10-10 10:02:33 +00:00
|
|
|
byte *ptr;
|
2002-02-24 17:25:03 +00:00
|
|
|
uint32 size;
|
2001-10-10 10:02:33 +00:00
|
|
|
|
2006-09-17 20:36:48 +00:00
|
|
|
if (!_res->mode[type]) {
|
2003-09-14 20:34:48 +00:00
|
|
|
if (ser->isSaving()) {
|
2006-09-17 20:36:48 +00:00
|
|
|
ptr = _res->address[type][idx];
|
2003-09-14 20:34:48 +00:00
|
|
|
if (ptr == NULL) {
|
|
|
|
ser->saveUint32(0);
|
|
|
|
return;
|
|
|
|
}
|
2001-10-10 10:02:33 +00:00
|
|
|
|
2003-09-14 20:34:48 +00:00
|
|
|
size = ((MemBlkHeader *)ptr)->size;
|
2001-11-05 19:21:49 +00:00
|
|
|
|
2003-09-14 20:34:48 +00:00
|
|
|
ser->saveUint32(size);
|
|
|
|
ser->saveBytes(ptr + sizeof(MemBlkHeader), size);
|
2001-10-10 10:02:33 +00:00
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
if (type == rtInventory) {
|
2003-12-27 00:10:20 +00:00
|
|
|
ser->saveUint16(_inventory[idx]);
|
2001-10-10 10:02:33 +00:00
|
|
|
}
|
2003-12-25 22:05:02 +00:00
|
|
|
if (type == rtObjectName && ser->getVersion() >= VER(25)) {
|
2003-12-27 00:10:20 +00:00
|
|
|
ser->saveUint16(_newNames[idx]);
|
2003-12-25 22:05:02 +00:00
|
|
|
}
|
2003-09-14 20:34:48 +00:00
|
|
|
} else {
|
|
|
|
size = ser->loadUint32();
|
|
|
|
if (size) {
|
2006-09-17 20:36:48 +00:00
|
|
|
_res->createResource(type, idx, size);
|
2003-09-14 20:34:48 +00:00
|
|
|
ser->loadBytes(getResourceAddress(type, idx), size);
|
|
|
|
if (type == rtInventory) {
|
2003-12-27 00:10:20 +00:00
|
|
|
_inventory[idx] = ser->loadUint16();
|
2003-09-14 20:34:48 +00:00
|
|
|
}
|
2003-12-25 22:05:02 +00:00
|
|
|
if (type == rtObjectName && ser->getVersion() >= VER(25)) {
|
2004-04-20 07:10:13 +00:00
|
|
|
// Paranoia: We increased the possible number of new names
|
2004-04-20 07:21:25 +00:00
|
|
|
// to fix bugs #933610 and #936323. The savegame format
|
|
|
|
// didn't change, but at least during the transition
|
|
|
|
// period there is a slight chance that we try to load
|
|
|
|
// more names than we have allocated space for. If so,
|
|
|
|
// discard them.
|
2004-04-20 07:10:13 +00:00
|
|
|
if (idx < _numNewNames)
|
|
|
|
_newNames[idx] = ser->loadUint16();
|
2003-12-25 22:05:02 +00:00
|
|
|
}
|
2003-09-14 20:34:48 +00:00
|
|
|
}
|
|
|
|
}
|
2006-09-17 20:36:48 +00:00
|
|
|
} else if (_res->mode[type] == 2 && ser->getVersion() >= VER(23)) {
|
2007-04-01 17:54:29 +00:00
|
|
|
// Save/load only a list of resource numbers that need to be reloaded.
|
2003-09-14 20:34:48 +00:00
|
|
|
if (ser->isSaving()) {
|
2006-09-17 20:36:48 +00:00
|
|
|
ser->saveUint16(_res->address[type][idx] ? 1 : 0);
|
2003-09-14 20:34:48 +00:00
|
|
|
} else {
|
2003-12-27 00:10:20 +00:00
|
|
|
if (ser->loadUint16())
|
|
|
|
ensureResourceLoaded(type, idx);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScummEngine::saveResource(Serializer *ser, int type, int idx) {
|
2006-09-17 20:36:48 +00:00
|
|
|
assert(_res->address[type][idx]);
|
2003-12-27 00:10:20 +00:00
|
|
|
|
2006-09-17 20:36:48 +00:00
|
|
|
if (_res->mode[type] == 0) {
|
|
|
|
byte *ptr = _res->address[type][idx];
|
2003-12-27 00:10:20 +00:00
|
|
|
uint32 size = ((MemBlkHeader *)ptr)->size;
|
|
|
|
|
|
|
|
ser->saveUint32(size);
|
|
|
|
ser->saveBytes(ptr + sizeof(MemBlkHeader), size);
|
|
|
|
|
|
|
|
if (type == rtInventory) {
|
|
|
|
ser->saveUint16(_inventory[idx]);
|
|
|
|
}
|
|
|
|
if (type == rtObjectName) {
|
|
|
|
ser->saveUint16(_newNames[idx]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScummEngine::loadResource(Serializer *ser, int type, int idx) {
|
2006-03-26 00:24:00 +00:00
|
|
|
if (_game.heversion >= 60 && ser->getVersion() <= VER(65) &&
|
|
|
|
((type == rtSound && idx == 1) || (type == rtSpoolBuffer))) {
|
|
|
|
uint32 size = ser->loadUint32();
|
|
|
|
assert(size);
|
2006-09-17 20:36:48 +00:00
|
|
|
_res->createResource(type, idx, size);
|
2006-03-26 00:24:00 +00:00
|
|
|
ser->loadBytes(getResourceAddress(type, idx), size);
|
2006-09-17 20:36:48 +00:00
|
|
|
} else if (_res->mode[type] == 0) {
|
2003-12-27 00:10:20 +00:00
|
|
|
uint32 size = ser->loadUint32();
|
|
|
|
assert(size);
|
2006-09-17 20:36:48 +00:00
|
|
|
_res->createResource(type, idx, size);
|
2003-12-27 00:10:20 +00:00
|
|
|
ser->loadBytes(getResourceAddress(type, idx), size);
|
|
|
|
|
|
|
|
if (type == rtInventory) {
|
|
|
|
_inventory[idx] = ser->loadUint16();
|
|
|
|
}
|
|
|
|
if (type == rtObjectName) {
|
|
|
|
_newNames[idx] = ser->loadUint16();
|
2001-10-10 10:02:33 +00:00
|
|
|
}
|
2006-09-17 20:36:48 +00:00
|
|
|
} else if (_res->mode[type] == 2) {
|
2006-03-26 00:24:00 +00:00
|
|
|
// HE Games use sound resource 1 for speech
|
|
|
|
if (_game.heversion >= 60 && idx == 1)
|
|
|
|
return;
|
|
|
|
|
2003-12-27 00:10:20 +00:00
|
|
|
ensureResourceLoaded(type, idx);
|
2001-10-10 10:02:33 +00:00
|
|
|
}
|
|
|
|
}
|
2001-10-09 14:30:12 +00:00
|
|
|
|
2003-03-06 17:58:13 +00:00
|
|
|
void Serializer::saveBytes(void *b, int len) {
|
2005-04-10 15:13:40 +00:00
|
|
|
_saveStream->write(b, len);
|
2002-08-26 16:47:14 +00:00
|
|
|
}
|
|
|
|
|
2003-03-06 17:58:13 +00:00
|
|
|
void Serializer::loadBytes(void *b, int len) {
|
2005-04-10 15:13:40 +00:00
|
|
|
_loadStream->read(b, len);
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
2001-10-10 10:02:33 +00:00
|
|
|
|
2003-03-06 17:58:13 +00:00
|
|
|
void Serializer::saveUint32(uint32 d) {
|
2005-04-10 15:13:40 +00:00
|
|
|
_saveStream->writeUint32LE(d);
|
2001-10-10 10:02:33 +00:00
|
|
|
}
|
|
|
|
|
2003-12-27 00:10:20 +00:00
|
|
|
void Serializer::saveUint16(uint16 d) {
|
2005-04-10 15:13:40 +00:00
|
|
|
_saveStream->writeUint16LE(d);
|
2001-10-10 10:02:33 +00:00
|
|
|
}
|
|
|
|
|
2003-03-06 17:58:13 +00:00
|
|
|
void Serializer::saveByte(byte b) {
|
2005-04-10 15:13:40 +00:00
|
|
|
_saveStream->writeByte(b);
|
2001-10-10 10:02:33 +00:00
|
|
|
}
|
|
|
|
|
2003-03-06 17:58:13 +00:00
|
|
|
uint32 Serializer::loadUint32() {
|
2005-04-10 15:13:40 +00:00
|
|
|
return _loadStream->readUint32LE();
|
2001-10-10 10:02:33 +00:00
|
|
|
}
|
|
|
|
|
2003-12-27 00:10:20 +00:00
|
|
|
uint16 Serializer::loadUint16() {
|
2005-04-10 15:13:40 +00:00
|
|
|
return _loadStream->readUint16LE();
|
2001-10-10 10:02:33 +00:00
|
|
|
}
|
|
|
|
|
2003-03-06 17:58:13 +00:00
|
|
|
byte Serializer::loadByte() {
|
2005-04-10 15:13:40 +00:00
|
|
|
return _loadStream->readByte();
|
2001-10-10 10:02:33 +00:00
|
|
|
}
|
|
|
|
|
2003-03-06 17:58:13 +00:00
|
|
|
void Serializer::saveArrayOf(void *b, int len, int datasize, byte filetype) {
|
2002-04-11 17:19:16 +00:00
|
|
|
byte *at = (byte *)b;
|
2001-10-16 10:01:48 +00:00
|
|
|
uint32 data;
|
|
|
|
|
2002-12-08 16:14:29 +00:00
|
|
|
// speed up byte arrays
|
2005-10-14 19:51:56 +00:00
|
|
|
if (datasize == 1 && filetype == sleByte) {
|
|
|
|
if (len > 0) {
|
|
|
|
saveBytes(b, len);
|
|
|
|
}
|
2001-11-05 19:21:49 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
while (--len >= 0) {
|
2002-12-10 11:14:40 +00:00
|
|
|
if (datasize == 0) {
|
|
|
|
// Do nothing for obsolete data
|
|
|
|
data = 0;
|
|
|
|
} else if (datasize == 1) {
|
2002-12-08 16:14:29 +00:00
|
|
|
data = *(byte *)at;
|
|
|
|
at += 1;
|
|
|
|
} else if (datasize == 2) {
|
|
|
|
data = *(uint16 *)at;
|
|
|
|
at += 2;
|
|
|
|
} else if (datasize == 4) {
|
|
|
|
data = *(uint32 *)at;
|
|
|
|
at += 4;
|
2001-10-16 10:01:48 +00:00
|
|
|
} else {
|
2006-09-16 12:04:54 +00:00
|
|
|
error("saveArrayOf: invalid size %d", datasize);
|
2002-12-08 16:14:29 +00:00
|
|
|
}
|
|
|
|
switch (filetype) {
|
|
|
|
case sleByte:
|
|
|
|
saveByte((byte)data);
|
|
|
|
break;
|
|
|
|
case sleUint16:
|
|
|
|
case sleInt16:
|
2003-12-27 00:10:20 +00:00
|
|
|
saveUint16((int16)data);
|
2002-12-08 16:14:29 +00:00
|
|
|
break;
|
|
|
|
case sleInt32:
|
|
|
|
case sleUint32:
|
|
|
|
saveUint32(data);
|
|
|
|
break;
|
|
|
|
default:
|
2006-09-16 12:04:54 +00:00
|
|
|
error("saveArrayOf: invalid filetype %d", filetype);
|
2002-12-08 16:14:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-03-06 17:58:13 +00:00
|
|
|
void Serializer::loadArrayOf(void *b, int len, int datasize, byte filetype) {
|
2002-12-08 16:14:29 +00:00
|
|
|
byte *at = (byte *)b;
|
|
|
|
uint32 data;
|
|
|
|
|
|
|
|
// speed up byte arrays
|
|
|
|
if (datasize == 1 && filetype == sleByte) {
|
|
|
|
loadBytes(b, len);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (--len >= 0) {
|
|
|
|
switch (filetype) {
|
|
|
|
case sleByte:
|
|
|
|
data = loadByte();
|
|
|
|
break;
|
|
|
|
case sleUint16:
|
2003-12-27 00:10:20 +00:00
|
|
|
data = loadUint16();
|
2002-12-08 16:14:29 +00:00
|
|
|
break;
|
|
|
|
case sleInt16:
|
2003-12-27 00:10:20 +00:00
|
|
|
data = (int16)loadUint16();
|
2002-12-08 16:14:29 +00:00
|
|
|
break;
|
|
|
|
case sleUint32:
|
|
|
|
data = loadUint32();
|
|
|
|
break;
|
|
|
|
case sleInt32:
|
|
|
|
data = (int32)loadUint32();
|
|
|
|
break;
|
|
|
|
default:
|
2006-09-16 12:04:54 +00:00
|
|
|
error("loadArrayOf: invalid filetype %d", filetype);
|
2002-12-08 16:14:29 +00:00
|
|
|
}
|
|
|
|
if (datasize == 0) {
|
|
|
|
// Do nothing for obsolete data
|
|
|
|
} else if (datasize == 1) {
|
|
|
|
*(byte *)at = (byte)data;
|
|
|
|
at += 1;
|
|
|
|
} else if (datasize == 2) {
|
|
|
|
*(uint16 *)at = (uint16)data;
|
|
|
|
at += 2;
|
|
|
|
} else if (datasize == 4) {
|
|
|
|
*(uint32 *)at = data;
|
|
|
|
at += 4;
|
|
|
|
} else {
|
2006-09-16 12:04:54 +00:00
|
|
|
error("loadArrayOf: invalid size %d", datasize);
|
2001-10-16 10:01:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-03-06 17:58:13 +00:00
|
|
|
void Serializer::saveLoadArrayOf(void *b, int num, int datasize, const SaveLoadEntry *sle) {
|
2002-04-11 17:19:16 +00:00
|
|
|
byte *data = (byte *)b;
|
2001-11-09 22:44:26 +00:00
|
|
|
|
2002-12-08 16:14:29 +00:00
|
|
|
if (isSaving()) {
|
|
|
|
while (--num >= 0) {
|
|
|
|
saveEntries(data, sle);
|
|
|
|
data += datasize;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
while (--num >= 0) {
|
|
|
|
loadEntries(data, sle);
|
|
|
|
data += datasize;
|
|
|
|
}
|
2001-11-05 19:21:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-03-06 17:58:13 +00:00
|
|
|
void Serializer::saveLoadArrayOf(void *b, int len, int datasize, byte filetype) {
|
2002-12-08 16:14:29 +00:00
|
|
|
if (isSaving())
|
|
|
|
saveArrayOf(b, len, datasize, filetype);
|
|
|
|
else
|
|
|
|
loadArrayOf(b, len, datasize, filetype);
|
|
|
|
}
|
2001-10-10 10:02:33 +00:00
|
|
|
|
2003-03-06 17:58:13 +00:00
|
|
|
void Serializer::saveLoadEntries(void *d, const SaveLoadEntry *sle) {
|
2002-12-08 16:14:29 +00:00
|
|
|
if (isSaving())
|
|
|
|
saveEntries(d, sle);
|
|
|
|
else
|
|
|
|
loadEntries(d, sle);
|
|
|
|
}
|
|
|
|
|
2003-03-06 17:58:13 +00:00
|
|
|
void Serializer::saveEntries(void *d, const SaveLoadEntry *sle) {
|
2001-10-10 10:02:33 +00:00
|
|
|
byte type;
|
|
|
|
byte *at;
|
|
|
|
int size;
|
2002-04-11 17:19:16 +00:00
|
|
|
|
|
|
|
while (sle->offs != 0xFFFF) {
|
|
|
|
at = (byte *)d + sle->offs;
|
2001-10-10 10:02:33 +00:00
|
|
|
size = sle->size;
|
2003-05-23 03:34:18 +00:00
|
|
|
type = (byte) sle->type;
|
2002-04-11 17:19:16 +00:00
|
|
|
|
2002-12-08 16:14:29 +00:00
|
|
|
if (sle->maxVersion != CURRENT_VER) {
|
|
|
|
// Skip obsolete entries
|
|
|
|
if (type & 128)
|
|
|
|
sle++;
|
|
|
|
} else {
|
|
|
|
// save entry
|
2003-05-23 02:58:34 +00:00
|
|
|
int columns = 1;
|
|
|
|
int rows = 1;
|
|
|
|
int rowlen = 0;
|
2002-12-08 16:14:29 +00:00
|
|
|
if (type & 128) {
|
|
|
|
sle++;
|
2003-05-23 02:58:34 +00:00
|
|
|
columns = sle->offs;
|
|
|
|
rows = sle->type;
|
|
|
|
rowlen = sle->size;
|
2002-12-08 16:14:29 +00:00
|
|
|
type &= ~128;
|
2001-11-05 19:21:49 +00:00
|
|
|
}
|
2003-05-23 02:58:34 +00:00
|
|
|
while (rows--) {
|
|
|
|
saveArrayOf(at, columns, size, type);
|
|
|
|
at += rowlen;
|
|
|
|
}
|
2002-12-08 16:14:29 +00:00
|
|
|
}
|
|
|
|
sle++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-03-06 17:58:13 +00:00
|
|
|
void Serializer::loadEntries(void *d, const SaveLoadEntry *sle) {
|
2002-12-08 16:14:29 +00:00
|
|
|
byte type;
|
|
|
|
byte *at;
|
|
|
|
int size;
|
|
|
|
|
|
|
|
while (sle->offs != 0xFFFF) {
|
|
|
|
at = (byte *)d + sle->offs;
|
|
|
|
size = sle->size;
|
2003-05-23 03:34:18 +00:00
|
|
|
type = (byte) sle->type;
|
2002-12-08 16:14:29 +00:00
|
|
|
|
|
|
|
if (_savegameVersion < sle->minVersion || _savegameVersion > sle->maxVersion) {
|
|
|
|
// Skip entries which are not present in this save game version
|
|
|
|
if (type & 128)
|
|
|
|
sle++;
|
2001-11-05 19:21:49 +00:00
|
|
|
} else {
|
2002-12-08 16:14:29 +00:00
|
|
|
// load entry
|
2003-05-23 02:58:34 +00:00
|
|
|
int columns = 1;
|
|
|
|
int rows = 1;
|
|
|
|
int rowlen = 0;
|
2002-12-08 16:14:29 +00:00
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
if (type & 128) {
|
2001-11-05 19:21:49 +00:00
|
|
|
sle++;
|
2003-05-23 02:58:34 +00:00
|
|
|
columns = sle->offs;
|
|
|
|
rows = sle->type;
|
|
|
|
rowlen = sle->size;
|
2002-04-11 17:19:16 +00:00
|
|
|
type &= ~128;
|
2001-11-05 19:21:49 +00:00
|
|
|
}
|
2003-05-23 02:58:34 +00:00
|
|
|
while (rows--) {
|
|
|
|
loadArrayOf(at, columns, size, type);
|
|
|
|
at += rowlen;
|
|
|
|
}
|
2001-10-10 10:02:33 +00:00
|
|
|
}
|
2001-11-14 18:40:39 +00:00
|
|
|
sle++;
|
2001-10-10 10:02:33 +00:00
|
|
|
}
|
|
|
|
}
|
2003-10-03 18:33:57 +00:00
|
|
|
|
|
|
|
} // End of namespace Scumm
|