2001-10-09 14:30:12 +00:00
|
|
|
/* ScummVM - Scumm Interpreter
|
|
|
|
* Copyright (C) 2001 Ludvig Strigeus
|
2003-03-06 21:46:56 +00:00
|
|
|
* Copyright (C) 2001-2003 The ScummVM project
|
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
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*
|
2001-11-06 20:00:47 +00:00
|
|
|
* $Header$
|
2001-10-09 14:30:12 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "stdafx.h"
|
2002-05-14 23:32:34 +00:00
|
|
|
#include "actor.h"
|
2002-12-25 21:04:47 +00:00
|
|
|
#include "charset.h"
|
|
|
|
#include "imuse.h"
|
2003-03-18 16:13:52 +00:00
|
|
|
#include "imuse_digi.h"
|
2002-07-16 21:03:14 +00:00
|
|
|
#include "resource.h"
|
2002-07-02 20:57:27 +00:00
|
|
|
#include "saveload.h"
|
2002-12-25 21:04:47 +00:00
|
|
|
#include "scumm.h"
|
|
|
|
#include "sound.h"
|
2002-11-29 15:13:49 +00:00
|
|
|
#include "verbs.h"
|
2002-12-25 21:04:47 +00:00
|
|
|
#include "common/config-file.h"
|
2001-10-09 14:30:12 +00:00
|
|
|
|
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
|
|
|
};
|
|
|
|
|
2002-03-14 14:45:04 +00:00
|
|
|
|
2003-03-06 17:58:13 +00:00
|
|
|
void Scumm::requestSave(int slot, const char *name) {
|
2003-02-08 01:27:21 +00:00
|
|
|
_saveLoadSlot = slot;
|
|
|
|
_saveLoadCompatible = false;
|
|
|
|
_saveLoadFlag = 1; // 1 for save
|
|
|
|
strcpy(_saveLoadName, name);
|
|
|
|
}
|
|
|
|
|
2003-03-06 17:58:13 +00:00
|
|
|
void Scumm::requestLoad(int slot) {
|
2003-02-08 01:27:21 +00:00
|
|
|
_saveLoadSlot = slot;
|
|
|
|
_saveLoadCompatible = false;
|
|
|
|
_saveLoadFlag = 2; // 2 for load
|
|
|
|
}
|
|
|
|
|
2003-03-06 17:58:13 +00:00
|
|
|
bool Scumm::saveState(int slot, bool compat, SaveFileManager *mgr) {
|
2001-11-09 18:54:15 +00:00
|
|
|
char filename[256];
|
2002-12-17 01:15:13 +00:00
|
|
|
SaveFile *out;
|
2001-10-16 10:01:48 +00:00
|
|
|
SaveGameHeader hdr;
|
2001-11-09 18:54:15 +00:00
|
|
|
|
|
|
|
makeSavegameName(filename, slot, compat);
|
2002-04-11 17:19:16 +00:00
|
|
|
|
2002-12-17 01:15:13 +00:00
|
|
|
if (!(out = mgr->open_savefile(filename, true)))
|
2001-10-09 14:30:12 +00:00
|
|
|
return false;
|
2001-10-16 10:01:48 +00:00
|
|
|
|
2001-11-09 18:54:15 +00:00
|
|
|
memcpy(hdr.name, _saveLoadName, sizeof(hdr.name));
|
2002-04-11 17:19:16 +00:00
|
|
|
|
2001-10-16 10:01:48 +00:00
|
|
|
hdr.type = MKID('SCVM');
|
|
|
|
hdr.size = 0;
|
2002-12-08 16:14:29 +00:00
|
|
|
hdr.ver = TO_LE_32(CURRENT_VER);
|
2002-03-14 14:45:04 +00:00
|
|
|
|
2002-12-17 01:15:13 +00:00
|
|
|
out->fwrite(&hdr, sizeof(hdr), 1);
|
2001-10-16 10:01:48 +00:00
|
|
|
|
2002-12-08 16:14:29 +00:00
|
|
|
Serializer ser(out, true, CURRENT_VER);
|
2002-12-13 03:23:17 +00:00
|
|
|
saveOrLoad(&ser, CURRENT_VER);
|
2002-12-17 01:15:13 +00:00
|
|
|
delete out;
|
2002-04-11 17:19:16 +00:00
|
|
|
debug(1, "State saved as '%s'", filename);
|
2001-10-09 14:30:12 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2003-03-06 17:58:13 +00:00
|
|
|
bool Scumm::loadState(int slot, bool compat, SaveFileManager *mgr) {
|
2001-11-09 18:54:15 +00:00
|
|
|
char filename[256];
|
2002-12-17 01:15:13 +00:00
|
|
|
SaveFile *out;
|
2002-04-11 17:19:16 +00:00
|
|
|
int i, j;
|
2001-10-16 10:01:48 +00:00
|
|
|
SaveGameHeader hdr;
|
2002-04-11 17:19:16 +00:00
|
|
|
int sb, sh;
|
2001-10-10 10:02:33 +00:00
|
|
|
|
2001-11-09 18:54:15 +00:00
|
|
|
makeSavegameName(filename, slot, compat);
|
2002-12-17 01:15:13 +00:00
|
|
|
if (!(out = mgr->open_savefile(filename, false)))
|
2001-10-09 14:30:12 +00:00
|
|
|
return false;
|
2001-10-16 10:01:48 +00:00
|
|
|
|
2002-12-17 01:15:13 +00:00
|
|
|
out->fread(&hdr, sizeof(hdr), 1);
|
2001-10-16 10:01:48 +00:00
|
|
|
if (hdr.type != MKID('SCVM')) {
|
|
|
|
warning("Invalid savegame '%s'", filename);
|
2002-12-17 01:15:13 +00:00
|
|
|
delete out;
|
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.
|
|
|
|
// We account for that by retrying once with swapped byte order.
|
2002-12-08 16:14:29 +00:00
|
|
|
if (hdr.ver > CURRENT_VER)
|
2002-08-26 16:13:38 +00:00
|
|
|
hdr.ver = SWAP_BYTES(hdr.ver);
|
2002-12-08 16:14:29 +00:00
|
|
|
if (hdr.ver < VER_V7 || hdr.ver > CURRENT_VER)
|
2002-07-16 15:25:22 +00:00
|
|
|
{
|
2001-10-16 10:01:48 +00:00
|
|
|
warning("Invalid version of '%s'", filename);
|
2002-12-17 01:15:13 +00:00
|
|
|
delete out;
|
2001-10-16 10:01:48 +00:00
|
|
|
return false;
|
|
|
|
}
|
2003-05-23 02:58:34 +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
|
|
|
|
if (hdr.ver == VER_V7)
|
|
|
|
hdr.ver = VER_V8;
|
|
|
|
|
2001-11-09 18:54:15 +00:00
|
|
|
memcpy(_saveLoadName, hdr.name, sizeof(hdr.name));
|
2001-11-14 18:40:39 +00:00
|
|
|
|
2002-10-01 21:19:52 +00:00
|
|
|
if (_imuseDigital) {
|
|
|
|
_imuseDigital->stopAll();
|
|
|
|
}
|
|
|
|
|
2002-10-15 06:53:42 +00:00
|
|
|
_sound->stopBundleMusic();
|
2002-12-16 12:09:52 +00:00
|
|
|
_sound->stopCD();
|
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
|
|
|
CHECK_HEAP
|
|
|
|
closeRoom();
|
2002-04-11 17:19:16 +00:00
|
|
|
memset(_inventory, 0, sizeof(_inventory[0]) * _numInventory);
|
2001-10-10 10:02:33 +00:00
|
|
|
|
|
|
|
/* Nuke all resources */
|
2002-04-11 17:19:16 +00:00
|
|
|
for (i = rtFirst; i <= rtLast; i++)
|
2003-05-15 21:55:13 +00:00
|
|
|
if (i != rtTemp && i != rtBuffer && (i != rtSound || _saveSound))
|
2002-04-11 17:19:16 +00:00
|
|
|
for (j = 0; j < res.num[i]; j++) {
|
|
|
|
nukeResource(i, j);
|
2001-11-07 18:10:52 +00:00
|
|
|
res.flags[i][j] = 0;
|
|
|
|
}
|
2001-10-10 10:02:33 +00:00
|
|
|
|
|
|
|
initScummVars();
|
2002-04-11 17:19:16 +00:00
|
|
|
|
2003-04-23 09:20:22 +00:00
|
|
|
if (_features & GF_OLD_BUNDLE)
|
|
|
|
loadCharset(0); // FIXME - HACK ?
|
|
|
|
|
2002-12-13 03:23:17 +00:00
|
|
|
Serializer ser(out, false, hdr.ver);
|
|
|
|
saveOrLoad(&ser, hdr.ver);
|
2002-12-17 01:15:13 +00:00
|
|
|
delete out;
|
2001-10-10 10:02:33 +00:00
|
|
|
|
2001-10-26 17:34:50 +00:00
|
|
|
sb = _screenB;
|
|
|
|
sh = _screenH;
|
2001-11-07 18:10:52 +00:00
|
|
|
|
2003-06-01 17:29:45 +00:00
|
|
|
gdi._mask.top = gdi._mask.left = 32767;
|
|
|
|
gdi._mask.right = gdi._mask.bottom = 0;
|
|
|
|
_charset->_hasMask = false;
|
2002-04-11 17:19:16 +00:00
|
|
|
|
2003-05-10 21:49:59 +00:00
|
|
|
initScreens(0, 0, _screenWidth, _screenHeight);
|
2002-07-07 20:25:23 +00:00
|
|
|
|
2002-05-12 21:58:35 +00:00
|
|
|
// Force a fade to black
|
|
|
|
int old_screenEffectFlag = _screenEffectFlag;
|
2002-05-12 17:51:40 +00:00
|
|
|
_screenEffectFlag = true;
|
2002-07-13 14:07:37 +00:00
|
|
|
fadeOut(129);
|
2002-09-21 Matt Hargett <matt@use.net>
* scumm.dsp, scummvm.dsp, simon.dsp: Turn on warning as errors. Generate
PDBs on all builds.
* gameDetector.cpp, newgui.cpp, widget.cpp, actor.cpp,
dialogs.cpp, resource.cpp, saveload.cpp, scumm_renderer.cpp:
Fix warnings where possible. One pragma added to eliminate
warning of unknown pragmas.
* string.cpp: If unknown escape sequence, print warning.
svn-id: r4998
2002-09-22 03:53:53 +00:00
|
|
|
_screenEffectFlag = old_screenEffectFlag ? true : false;
|
2001-10-26 17:34:50 +00:00
|
|
|
|
2003-05-10 21:49:59 +00:00
|
|
|
initScreens(0, sb, _screenWidth, sh);
|
2001-10-10 10:02:33 +00:00
|
|
|
|
2001-11-09 18:54:15 +00:00
|
|
|
_completeScreenRedraw = true;
|
2003-05-03 20:49:53 +00:00
|
|
|
|
2003-06-05 17:22:15 +00:00
|
|
|
if (_features & GF_AFTER_V1) {
|
|
|
|
setupC64Palette();
|
|
|
|
setDirtyColors(0, 15);
|
|
|
|
} else if (_features & GF_16COLOR) {
|
2003-05-03 20:49:53 +00:00
|
|
|
// HACK: There was a time when ScummVM didn't store the
|
|
|
|
// palette in _currentPalette for 16-color games. To avoid
|
|
|
|
// breaking savegame compatibility, always set up the default
|
|
|
|
// palette after loading a game.
|
|
|
|
setupEGAPalette();
|
|
|
|
setDirtyColors(0, 15);
|
|
|
|
} else
|
2003-04-11 05:31:18 +00:00
|
|
|
setDirtyColors(0, 255);
|
2001-10-10 10:02:33 +00:00
|
|
|
|
2001-10-26 17:34:50 +00:00
|
|
|
_lastCodePtr = NULL;
|
2002-04-11 17:19:16 +00:00
|
|
|
|
2001-10-10 10:02:33 +00:00
|
|
|
_drawObjectQueNr = 0;
|
|
|
|
_verbMouseOver = 0;
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
if (_features & GF_AFTER_V7)
|
2002-03-05 23:41:41 +00:00
|
|
|
cameraMoved();
|
2001-12-27 17:51:58 +00:00
|
|
|
|
2003-05-10 21:49:59 +00:00
|
|
|
initBGBuffers(_roomHeight);
|
2001-10-10 10:02:33 +00:00
|
|
|
|
2003-06-05 10:33:13 +00:00
|
|
|
if (_features & GF_AFTER_V2) {
|
2003-06-05 10:28:48 +00:00
|
|
|
// Regenerate strip table when loading
|
2003-06-05 10:27:15 +00:00
|
|
|
_roomStrips = gdi.generateStripTable(getResourceAddress(rtRoom, _roomResource) + _IM00_offs,
|
|
|
|
_roomWidth, _roomHeight, _roomStrips);
|
|
|
|
}
|
|
|
|
|
2003-05-08 15:48:50 +00:00
|
|
|
if ((_features & GF_AUDIOTRACKS) && VAR(VAR_MUSIC_TIMER) > 0)
|
2002-09-21 13:48:03 +00:00
|
|
|
_sound->startCDTimer();
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
CHECK_HEAP debug(1, "State loaded from '%s'", filename);
|
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
|
|
|
|
2001-10-09 14:30:12 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2003-03-06 17:58:13 +00:00
|
|
|
void Scumm::makeSavegameName(char *out, int slot, bool compatible) {
|
2002-08-18 22:47:11 +00:00
|
|
|
const char *dir = getSavePath();
|
2002-05-16 10:43:17 +00:00
|
|
|
|
2003-04-30 13:23:31 +00:00
|
|
|
#ifndef __PALM_OS__
|
2002-10-28 09:03:02 +00:00
|
|
|
sprintf(out, "%s%s.%c%.2d", dir, _game_name, compatible ? 'c' : 's', slot);
|
2003-04-30 13:23:31 +00:00
|
|
|
#else
|
|
|
|
sprintf(out, "%s%s.%s%.2d", dir, _game_name, compatible ? "c" : "s", slot);
|
|
|
|
#endif
|
2001-11-09 18:54:15 +00:00
|
|
|
}
|
|
|
|
|
2003-03-06 17:58:13 +00:00
|
|
|
void Scumm::listSavegames(bool *marks, int num, SaveFileManager *mgr) {
|
2002-12-17 01:15:13 +00:00
|
|
|
char prefix[256];
|
|
|
|
makeSavegameName(prefix, 99, false);
|
|
|
|
prefix[strlen(prefix)-2] = 0;
|
|
|
|
mgr->list_savefiles(prefix, marks, num);
|
|
|
|
}
|
|
|
|
|
2003-03-06 17:58:13 +00:00
|
|
|
bool Scumm::getSavegameName(int slot, char *desc, SaveFileManager *mgr) {
|
2001-11-09 18:54:15 +00:00
|
|
|
char filename[256];
|
2002-12-17 01:15:13 +00:00
|
|
|
SaveFile *out;
|
2001-11-09 18:54:15 +00:00
|
|
|
SaveGameHeader hdr;
|
|
|
|
int len;
|
|
|
|
|
|
|
|
makeSavegameName(filename, slot, false);
|
2002-12-17 01:15:13 +00:00
|
|
|
if (!(out = mgr->open_savefile(filename, false))) {
|
2002-04-11 17:19:16 +00:00
|
|
|
strcpy(desc, "");
|
2001-11-09 18:54:15 +00:00
|
|
|
return false;
|
|
|
|
}
|
2002-12-17 01:15:13 +00:00
|
|
|
len = out->fread(&hdr, sizeof(hdr), 1);
|
|
|
|
delete out;
|
2001-11-09 18:54:15 +00:00
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
if (len != 1 || hdr.type != MKID('SCVM')) {
|
2001-11-09 18:54:15 +00:00
|
|
|
strcpy(desc, "Invalid savegame");
|
|
|
|
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);
|
2002-12-08 16:14:29 +00:00
|
|
|
if (hdr.ver < VER_V7 || hdr.ver > CURRENT_VER) {
|
2001-11-09 18:54:15 +00:00
|
|
|
strcpy(desc, "Invalid version");
|
|
|
|
return false;
|
|
|
|
}
|
2002-04-11 17:19:16 +00:00
|
|
|
|
2001-11-09 18:54:15 +00:00
|
|
|
memcpy(desc, hdr.name, sizeof(hdr.name));
|
2002-04-11 17:19:16 +00:00
|
|
|
desc[sizeof(hdr.name) - 1] = 0;
|
2001-11-09 18:54:15 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2003-03-06 17:58:13 +00:00
|
|
|
void Scumm::saveOrLoad(Serializer *s, uint32 savegameVersion) {
|
2001-10-10 10:02:33 +00:00
|
|
|
const SaveLoadEntry objectEntries[] = {
|
2002-12-26 20:37:49 +00:00
|
|
|
MKLINE(ObjectData, OBIMoffset, sleUint32, VER_V8),
|
|
|
|
MKLINE(ObjectData, OBCDoffset, sleUint32, VER_V8),
|
2002-12-08 16:14:29 +00:00
|
|
|
MKLINE(ObjectData, walk_x, sleUint16, VER_V8),
|
|
|
|
MKLINE(ObjectData, walk_y, sleUint16, VER_V8),
|
|
|
|
MKLINE(ObjectData, obj_nr, sleUint16, VER_V8),
|
|
|
|
MKLINE(ObjectData, x_pos, sleInt16, VER_V8),
|
|
|
|
MKLINE(ObjectData, y_pos, sleInt16, VER_V8),
|
|
|
|
MKLINE(ObjectData, width, sleUint16, VER_V8),
|
|
|
|
MKLINE(ObjectData, height, sleUint16, VER_V8),
|
|
|
|
MKLINE(ObjectData, actordir, sleByte, VER_V8),
|
|
|
|
MKLINE(ObjectData, parentstate, sleByte, VER_V8),
|
|
|
|
MKLINE(ObjectData, parent, sleByte, VER_V8),
|
|
|
|
MKLINE(ObjectData, state, sleByte, VER_V8),
|
|
|
|
MKLINE(ObjectData, fl_object_index, sleByte, VER_V8),
|
2001-10-10 10:02:33 +00:00
|
|
|
MKEND()
|
|
|
|
};
|
|
|
|
|
2003-05-26 02:26:13 +00:00
|
|
|
const SaveLoadEntry *actorEntries = Actor::getSaveLoadEntries();
|
2001-10-10 10:02:33 +00:00
|
|
|
|
|
|
|
const SaveLoadEntry verbEntries[] = {
|
2002-12-08 16:14:29 +00:00
|
|
|
MKLINE(VerbSlot, x, sleInt16, VER_V8),
|
|
|
|
MKLINE(VerbSlot, y, sleInt16, VER_V8),
|
|
|
|
MKLINE(VerbSlot, right, sleInt16, VER_V8),
|
|
|
|
MKLINE(VerbSlot, bottom, sleInt16, VER_V8),
|
2003-05-15 22:36:43 +00:00
|
|
|
MKLINE(VerbSlot, old.left, sleInt16, VER_V8),
|
|
|
|
MKLINE(VerbSlot, old.top, sleInt16, VER_V8),
|
|
|
|
MKLINE(VerbSlot, old.right, sleInt16, VER_V8),
|
|
|
|
MKLINE(VerbSlot, old.bottom, sleInt16, VER_V8),
|
2003-01-09 22:53:21 +00:00
|
|
|
|
|
|
|
MKLINE_OLD(VerbSlot, verbid, sleByte, VER_V8, VER_V11),
|
|
|
|
MKLINE(VerbSlot, verbid, sleInt16, VER_V12),
|
|
|
|
|
2002-12-08 16:14:29 +00:00
|
|
|
MKLINE(VerbSlot, color, sleByte, VER_V8),
|
|
|
|
MKLINE(VerbSlot, hicolor, sleByte, VER_V8),
|
|
|
|
MKLINE(VerbSlot, dimcolor, sleByte, VER_V8),
|
|
|
|
MKLINE(VerbSlot, bkcolor, sleByte, VER_V8),
|
|
|
|
MKLINE(VerbSlot, type, sleByte, VER_V8),
|
|
|
|
MKLINE(VerbSlot, charset_nr, sleByte, VER_V8),
|
|
|
|
MKLINE(VerbSlot, curmode, sleByte, VER_V8),
|
|
|
|
MKLINE(VerbSlot, saveid, sleByte, VER_V8),
|
|
|
|
MKLINE(VerbSlot, key, sleByte, VER_V8),
|
|
|
|
MKLINE(VerbSlot, center, sleByte, VER_V8),
|
|
|
|
MKLINE(VerbSlot, field_1B, sleByte, VER_V8),
|
|
|
|
MKLINE(VerbSlot, imgindex, sleUint16, VER_V8),
|
2002-03-14 14:45:04 +00:00
|
|
|
MKEND()
|
|
|
|
};
|
|
|
|
|
2002-12-08 16:14:29 +00:00
|
|
|
const SaveLoadEntry mainEntries[] = {
|
2003-05-10 21:49:59 +00:00
|
|
|
MKLINE(Scumm, _roomWidth, sleUint16, VER_V8),
|
|
|
|
MKLINE(Scumm, _roomHeight, sleUint16, VER_V8),
|
2002-12-08 16:14:29 +00:00
|
|
|
MKLINE(Scumm, _ENCD_offs, sleUint32, VER_V8),
|
|
|
|
MKLINE(Scumm, _EXCD_offs, sleUint32, VER_V8),
|
|
|
|
MKLINE(Scumm, _IM00_offs, sleUint32, VER_V8),
|
|
|
|
MKLINE(Scumm, _CLUT_offs, sleUint32, VER_V8),
|
|
|
|
MK_OBSOLETE(Scumm, _EPAL_offs, sleUint32, VER_V8, VER_V9),
|
|
|
|
MKLINE(Scumm, _PALS_offs, sleUint32, VER_V8),
|
|
|
|
MKLINE(Scumm, _curPalIndex, sleByte, VER_V8),
|
|
|
|
MKLINE(Scumm, _currentRoom, sleByte, VER_V8),
|
|
|
|
MKLINE(Scumm, _roomResource, sleByte, VER_V8),
|
|
|
|
MKLINE(Scumm, _numObjectsInRoom, sleByte, VER_V8),
|
|
|
|
MKLINE(Scumm, _currentScript, sleByte, VER_V8),
|
|
|
|
MKARRAY(Scumm, _localScriptList[0], sleUint32, NUM_LOCALSCRIPT, VER_V8),
|
|
|
|
|
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-05-23 02:58:34 +00:00
|
|
|
MKARRAY2_OLD(Scumm, vm.localvar[0][0], sleUint16, 17, 25, (byte*)vm.localvar[1] - (byte*)vm.localvar[0], VER_V8, VER_V8),
|
2003-05-28 18:13:30 +00:00
|
|
|
MKARRAY2_OLD(Scumm, vm.localvar[0][0], sleUint16, 17, 40, (byte*)vm.localvar[1] - (byte*)vm.localvar[0], VER_V9, VER_V14),
|
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.
|
|
|
|
MKARRAY2_OLD(Scumm, vm.localvar[0][0], sleUint16, 26, 38, (byte*)vm.localvar[1] - (byte*)vm.localvar[0], VER_V15, VER_V17),
|
|
|
|
MK_OBSOLETE_ARRAY(Scumm, vm.localvar[39][0], sleUint16, 12, VER_V15, VER_V17),
|
|
|
|
|
2003-05-28 18:13:30 +00:00
|
|
|
// This was the first proper multi dimensional version of the localvars, with 32 bit values
|
|
|
|
MKARRAY2_OLD(Scumm, vm.localvar[0][0], sleUint32, 26, 40, (byte*)vm.localvar[1] - (byte*)vm.localvar[0], VER_V18, VER_V19),
|
|
|
|
|
|
|
|
// Then we doubled the script slots again, from 40 to 80
|
|
|
|
MKARRAY2(Scumm, vm.localvar[0][0], sleUint32, 26, NUM_SCRIPT_SLOT, (byte*)vm.localvar[1] - (byte*)vm.localvar[0], VER_V20),
|
2003-05-23 02:58:34 +00:00
|
|
|
|
2002-12-08 16:14:29 +00:00
|
|
|
|
|
|
|
MKARRAY(Scumm, _resourceMapper[0], sleByte, 128, VER_V8),
|
2002-12-26 00:21:19 +00:00
|
|
|
MKARRAY(Scumm, _charsetColorMap[0], sleByte, 16, VER_V8),
|
2002-12-08 16:14:29 +00:00
|
|
|
|
|
|
|
// _charsetData grew from 10*16 to 15*16 bytes
|
|
|
|
MKARRAY_OLD(Scumm, _charsetData[0][0], sleByte, 10 * 16, VER_V8, VER_V9),
|
|
|
|
MKARRAY(Scumm, _charsetData[0][0], sleByte, 15 * 16, VER_V10),
|
|
|
|
|
|
|
|
MKLINE(Scumm, _curExecScript, sleUint16, VER_V8),
|
|
|
|
|
|
|
|
MKLINE(Scumm, camera._dest.x, sleInt16, VER_V8),
|
|
|
|
MKLINE(Scumm, camera._dest.y, sleInt16, VER_V8),
|
|
|
|
MKLINE(Scumm, camera._cur.x, sleInt16, VER_V8),
|
|
|
|
MKLINE(Scumm, camera._cur.y, sleInt16, VER_V8),
|
|
|
|
MKLINE(Scumm, camera._last.x, sleInt16, VER_V8),
|
|
|
|
MKLINE(Scumm, camera._last.y, sleInt16, VER_V8),
|
|
|
|
MKLINE(Scumm, camera._accel.x, sleInt16, VER_V8),
|
|
|
|
MKLINE(Scumm, camera._accel.y, sleInt16, VER_V8),
|
|
|
|
MKLINE(Scumm, _screenStartStrip, sleInt16, VER_V8),
|
|
|
|
MKLINE(Scumm, _screenEndStrip, sleInt16, VER_V8),
|
|
|
|
MKLINE(Scumm, camera._mode, sleByte, VER_V8),
|
|
|
|
MKLINE(Scumm, camera._follows, sleByte, VER_V8),
|
|
|
|
MKLINE(Scumm, camera._leftTrigger, sleInt16, VER_V8),
|
|
|
|
MKLINE(Scumm, camera._rightTrigger, sleInt16, VER_V8),
|
|
|
|
MKLINE(Scumm, camera._movingToActor, sleUint16, VER_V8),
|
|
|
|
|
|
|
|
MKLINE(Scumm, _actorToPrintStrFor, sleByte, VER_V8),
|
|
|
|
MKLINE(Scumm, _charsetColor, sleByte, VER_V8),
|
|
|
|
|
2002-12-26 00:21:19 +00:00
|
|
|
// _charsetBufPos was changed from byte to int
|
|
|
|
MKLINE_OLD(Scumm, _charsetBufPos, sleByte, VER_V8, VER_V9),
|
|
|
|
MKLINE(Scumm, _charsetBufPos, sleInt16, VER_V10),
|
2002-12-08 16:14:29 +00:00
|
|
|
|
|
|
|
MKLINE(Scumm, _haveMsg, sleByte, VER_V8),
|
|
|
|
MKLINE(Scumm, _useTalkAnims, sleByte, VER_V8),
|
|
|
|
|
|
|
|
MKLINE(Scumm, _talkDelay, sleInt16, VER_V8),
|
|
|
|
MKLINE(Scumm, _defaultTalkDelay, sleInt16, VER_V8),
|
|
|
|
MKLINE(Scumm, _numInMsgStack, sleInt16, VER_V8),
|
|
|
|
MKLINE(Scumm, _sentenceNum, sleByte, VER_V8),
|
|
|
|
|
|
|
|
MKLINE(Scumm, vm.cutSceneStackPointer, sleByte, VER_V8),
|
|
|
|
MKARRAY(Scumm, vm.cutScenePtr[0], sleUint32, 5, VER_V8),
|
|
|
|
MKARRAY(Scumm, vm.cutSceneScript[0], sleByte, 5, VER_V8),
|
|
|
|
MKARRAY(Scumm, vm.cutSceneData[0], sleInt16, 5, VER_V8),
|
|
|
|
MKLINE(Scumm, vm.cutSceneScriptIndex, sleInt16, VER_V8),
|
|
|
|
|
|
|
|
MKLINE(Scumm, _numNestedScripts, sleByte, VER_V8),
|
|
|
|
MKLINE(Scumm, _userPut, sleByte, VER_V8),
|
2003-05-22 05:21:48 +00:00
|
|
|
MKLINE(Scumm, _userState, sleUint16, VER_V17),
|
2002-12-08 16:14:29 +00:00
|
|
|
MKLINE(Scumm, _cursor.state, sleByte, VER_V8),
|
2003-05-29 11:48:44 +00:00
|
|
|
MK_OBSOLETE(Scumm, gdi._cursorActive, sleByte, VER_V8, VER_V20),
|
2002-12-08 16:14:29 +00:00
|
|
|
MKLINE(Scumm, _currentCursor, sleByte, VER_V8),
|
2003-05-28 18:13:30 +00:00
|
|
|
MKARRAY(Scumm, _grabbedCursor[0], sleByte, 8192, VER_V20),
|
|
|
|
MKLINE(Scumm, _cursor.width, sleInt16, VER_V20),
|
|
|
|
MKLINE(Scumm, _cursor.height, sleInt16, VER_V20),
|
|
|
|
MKLINE(Scumm, _cursor.hotspotX, sleInt16, VER_V20),
|
|
|
|
MKLINE(Scumm, _cursor.hotspotY, sleInt16, VER_V20),
|
|
|
|
MKLINE(Scumm, _cursor.animate, sleByte, VER_V20),
|
|
|
|
MKLINE(Scumm, _cursor.animateIndex, sleByte, VER_V20),
|
|
|
|
MKLINE(Scumm, _mouse.x, sleInt16, VER_V20),
|
|
|
|
MKLINE(Scumm, _mouse.y, sleInt16, VER_V20),
|
2002-12-08 16:14:29 +00:00
|
|
|
|
|
|
|
MKLINE(Scumm, _doEffect, sleByte, VER_V8),
|
|
|
|
MKLINE(Scumm, _switchRoomEffect, sleByte, VER_V8),
|
|
|
|
MKLINE(Scumm, _newEffect, sleByte, VER_V8),
|
|
|
|
MKLINE(Scumm, _switchRoomEffect2, sleByte, VER_V8),
|
|
|
|
MKLINE(Scumm, _BgNeedsRedraw, sleByte, VER_V8),
|
|
|
|
|
|
|
|
// The state of palManipulate is stored only since V10
|
|
|
|
MKLINE(Scumm, _palManipStart, sleByte, VER_V10),
|
|
|
|
MKLINE(Scumm, _palManipEnd, sleByte, VER_V10),
|
|
|
|
MKLINE(Scumm, _palManipCounter, sleUint16, VER_V10),
|
|
|
|
|
2003-01-14 10:06:56 +00:00
|
|
|
// gfxUsageBits grew from 200 to 410 entries. Then 3 * 410 entries:
|
2002-12-08 16:14:29 +00:00
|
|
|
MKARRAY_OLD(Scumm, gfxUsageBits[0], sleUint32, 200, VER_V8, VER_V9),
|
2003-01-14 10:06:56 +00:00
|
|
|
MKARRAY_OLD(Scumm, gfxUsageBits[0], sleUint32, 410, VER_V10, VER_V13),
|
|
|
|
MKARRAY(Scumm, gfxUsageBits[0], sleUint32, 3 * 410, VER_V14),
|
2002-12-08 16:14:29 +00:00
|
|
|
|
2002-12-31 14:59:06 +00:00
|
|
|
MKLINE(Scumm, gdi._transparentColor, sleByte, VER_V8),
|
2002-12-08 16:14:29 +00:00
|
|
|
MKARRAY(Scumm, _currentPalette[0], sleByte, 768, VER_V8),
|
|
|
|
|
|
|
|
MKARRAY(Scumm, _proc_special_palette[0], sleByte, 256, VER_V8),
|
|
|
|
|
2002-12-26 00:21:19 +00:00
|
|
|
MKARRAY(Scumm, _charsetBuffer[0], sleByte, 256, VER_V8),
|
2002-12-08 16:14:29 +00:00
|
|
|
|
|
|
|
MKLINE(Scumm, _egoPositioned, sleByte, VER_V8),
|
|
|
|
|
|
|
|
// gdi._imgBufOffs grew from 4 to 5 entries :
|
|
|
|
MKARRAY_OLD(Scumm, gdi._imgBufOffs[0], sleUint16, 4, VER_V8, VER_V9),
|
|
|
|
MKARRAY(Scumm, gdi._imgBufOffs[0], sleUint16, 5, VER_V10),
|
|
|
|
|
|
|
|
MKLINE(Scumm, gdi._numZBuffer, sleByte, VER_V8),
|
|
|
|
|
|
|
|
MKLINE(Scumm, _screenEffectFlag, sleByte, VER_V8),
|
|
|
|
|
|
|
|
MK_OBSOLETE(Scumm, _randSeed1, sleUint32, VER_V8, VER_V9),
|
|
|
|
MK_OBSOLETE(Scumm, _randSeed2, sleUint32, VER_V8, VER_V9),
|
|
|
|
|
|
|
|
// Converted _shakeEnabled to boolean and added a _shakeFrame field.
|
|
|
|
MKLINE_OLD(Scumm, _shakeEnabled, sleInt16, VER_V8, VER_V9),
|
|
|
|
MKLINE(Scumm, _shakeEnabled, sleByte, VER_V10),
|
|
|
|
MKLINE(Scumm, _shakeFrame, sleUint32, VER_V10),
|
|
|
|
|
|
|
|
MKLINE(Scumm, _keepText, sleByte, VER_V8),
|
|
|
|
|
|
|
|
MKLINE(Scumm, _screenB, sleUint16, VER_V8),
|
|
|
|
MKLINE(Scumm, _screenH, sleUint16, VER_V8),
|
|
|
|
|
|
|
|
MK_OBSOLETE(Scumm, _cd_track, sleInt16, VER_V9, VER_V9),
|
|
|
|
MK_OBSOLETE(Scumm, _cd_loops, sleInt16, VER_V9, VER_V9),
|
|
|
|
MK_OBSOLETE(Scumm, _cd_frame, sleInt16, VER_V9, VER_V9),
|
|
|
|
MK_OBSOLETE(Scumm, _cd_end, sleInt16, VER_V9, VER_V9),
|
|
|
|
|
2001-10-10 10:02:33 +00:00
|
|
|
MKEND()
|
|
|
|
};
|
|
|
|
|
|
|
|
const SaveLoadEntry scriptSlotEntries[] = {
|
2002-12-08 16:14:29 +00:00
|
|
|
MKLINE(ScriptSlot, offs, sleUint32, VER_V8),
|
|
|
|
MKLINE(ScriptSlot, delay, sleInt32, VER_V8),
|
|
|
|
MKLINE(ScriptSlot, number, sleUint16, VER_V8),
|
|
|
|
MKLINE(ScriptSlot, delayFrameCount, sleUint16, VER_V8),
|
|
|
|
MKLINE(ScriptSlot, status, sleByte, VER_V8),
|
|
|
|
MKLINE(ScriptSlot, where, sleByte, VER_V8),
|
2003-05-19 11:31:35 +00:00
|
|
|
MKLINE(ScriptSlot, freezeResistant, sleByte, VER_V8),
|
|
|
|
MKLINE(ScriptSlot, recursive, sleByte, VER_V8),
|
2002-12-08 16:14:29 +00:00
|
|
|
MKLINE(ScriptSlot, freezeCount, sleByte, VER_V8),
|
|
|
|
MKLINE(ScriptSlot, didexec, sleByte, VER_V8),
|
|
|
|
MKLINE(ScriptSlot, cutsceneOverride, sleByte, VER_V8),
|
2002-12-09 01:27:40 +00:00
|
|
|
MK_OBSOLETE(ScriptSlot, unk5, sleByte, VER_V8, VER_V10),
|
2001-10-10 10:02:33 +00:00
|
|
|
MKEND()
|
|
|
|
};
|
|
|
|
|
|
|
|
const SaveLoadEntry nestedScriptEntries[] = {
|
2002-12-08 16:14:29 +00:00
|
|
|
MKLINE(NestedScript, number, sleUint16, VER_V8),
|
|
|
|
MKLINE(NestedScript, where, sleByte, VER_V8),
|
|
|
|
MKLINE(NestedScript, slot, sleByte, VER_V8),
|
2001-10-10 10:02:33 +00:00
|
|
|
MKEND()
|
|
|
|
};
|
|
|
|
|
2001-10-16 10:01:48 +00:00
|
|
|
const SaveLoadEntry sentenceTabEntries[] = {
|
2003-04-28 03:13:49 +00:00
|
|
|
MKLINE(SentenceTab, verb, sleUint8, VER_V8),
|
2003-05-22 14:10:20 +00:00
|
|
|
MKLINE(SentenceTab, preposition, sleUint8, VER_V8),
|
2003-05-16 02:16:59 +00:00
|
|
|
MKLINE(SentenceTab, objectA, sleUint16, VER_V8),
|
|
|
|
MKLINE(SentenceTab, objectB, sleUint16, VER_V8),
|
2002-12-09 01:27:40 +00:00
|
|
|
MKLINE(SentenceTab, freezeCount, sleUint8, VER_V8),
|
2001-10-16 10:01:48 +00:00
|
|
|
MKEND()
|
|
|
|
};
|
|
|
|
|
|
|
|
const SaveLoadEntry stringTabEntries[] = {
|
2002-10-24 21:39:45 +00:00
|
|
|
// TODO - It makes no sense to have all these t_* fields in StringTab
|
|
|
|
// Rather let's dump them all when the save game format changes, and
|
2002-12-08 16:14:29 +00:00
|
|
|
// keep two StringTab objects where we have one now: a "normal" one,
|
|
|
|
// and a temporar y"t_" one.
|
|
|
|
// Then backup/restore of a StringTab entry becomes a one liner.
|
|
|
|
MKLINE(StringTab, xpos, sleInt16, VER_V8),
|
|
|
|
MKLINE(StringTab, t_xpos, sleInt16, VER_V8),
|
|
|
|
MKLINE(StringTab, ypos, sleInt16, VER_V8),
|
|
|
|
MKLINE(StringTab, t_ypos, sleInt16, VER_V8),
|
|
|
|
MKLINE(StringTab, right, sleInt16, VER_V8),
|
|
|
|
MKLINE(StringTab, t_right, sleInt16, VER_V8),
|
|
|
|
MKLINE(StringTab, color, sleInt8, VER_V8),
|
|
|
|
MKLINE(StringTab, t_color, sleInt8, VER_V8),
|
|
|
|
MKLINE(StringTab, charset, sleInt8, VER_V8),
|
|
|
|
MKLINE(StringTab, t_charset, sleInt8, VER_V8),
|
|
|
|
MKLINE(StringTab, center, sleByte, VER_V8),
|
|
|
|
MKLINE(StringTab, t_center, sleByte, VER_V8),
|
|
|
|
MKLINE(StringTab, overhead, sleByte, VER_V8),
|
|
|
|
MKLINE(StringTab, t_overhead, sleByte, VER_V8),
|
|
|
|
MKLINE(StringTab, no_talk_anim, sleByte, VER_V8),
|
|
|
|
MKLINE(StringTab, t_no_talk_anim, sleByte, VER_V8),
|
2001-10-16 10:01:48 +00:00
|
|
|
MKEND()
|
|
|
|
};
|
|
|
|
|
2001-10-26 17:34:50 +00:00
|
|
|
const SaveLoadEntry colorCycleEntries[] = {
|
2002-12-08 16:14:29 +00:00
|
|
|
MKLINE(ColorCycle, delay, sleUint16, VER_V8),
|
|
|
|
MKLINE(ColorCycle, counter, sleUint16, VER_V8),
|
|
|
|
MKLINE(ColorCycle, flags, sleUint16, VER_V8),
|
|
|
|
MKLINE(ColorCycle, start, sleByte, VER_V8),
|
|
|
|
MKLINE(ColorCycle, end, sleByte, VER_V8),
|
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[] = {
|
|
|
|
MKLINE(ScaleSlot, x1, sleUint16, VER_V13),
|
|
|
|
MKLINE(ScaleSlot, y1, sleUint16, VER_V13),
|
|
|
|
MKLINE(ScaleSlot, scale1, sleUint16, VER_V13),
|
|
|
|
MKLINE(ScaleSlot, x2, sleUint16, VER_V13),
|
|
|
|
MKLINE(ScaleSlot, y2, sleUint16, VER_V13),
|
|
|
|
MKLINE(ScaleSlot, scale2, sleUint16, VER_V13),
|
|
|
|
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;
|
2002-04-11 17:19:16 +00:00
|
|
|
|
2003-05-15 21:55:13 +00:00
|
|
|
if (!s->isSaving() && _saveSound) {
|
2002-12-07 18:03:10 +00:00
|
|
|
_sound->stopAllSounds();
|
|
|
|
if (_mixer) {
|
|
|
|
if (_imuseDigital) {
|
|
|
|
_imuseDigital->stopAll();
|
|
|
|
} else {
|
|
|
|
_mixer->stopAll();
|
|
|
|
}
|
2002-10-15 06:53:42 +00:00
|
|
|
}
|
|
|
|
}
|
2002-07-28 15:38:30 +00:00
|
|
|
|
2003-01-14 10:06:56 +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.
|
2003-03-05 11:40:37 +00:00
|
|
|
if (!s->isSaving())
|
|
|
|
memset(gfxUsageBits, 0, sizeof(gfxUsageBits));
|
2003-01-14 10:06:56 +00:00
|
|
|
|
2002-12-08 16:14:29 +00:00
|
|
|
s->saveLoadEntries(this, mainEntries);
|
2002-04-11 17:19:16 +00:00
|
|
|
|
2003-01-14 10:06:56 +00:00
|
|
|
if (!s->isSaving() && savegameVersion < VER_V14)
|
|
|
|
upgradeGfxUsageBits();
|
|
|
|
|
2003-05-28 18:13:30 +00:00
|
|
|
if (!s->isSaving() && savegameVersion >= VER_V20) {
|
|
|
|
updateCursor();
|
|
|
|
_system->warp_mouse(_mouse.x, _mouse.y);
|
|
|
|
}
|
|
|
|
|
2003-05-13 23:42:41 +00:00
|
|
|
s->saveLoadArrayOf(_actors, _numActors, sizeof(_actors[0]), actorEntries);
|
2002-03-14 14:45:04 +00:00
|
|
|
|
2002-12-13 03:23:17 +00:00
|
|
|
if (savegameVersion < VER_V9)
|
2002-05-05 17:44:39 +00:00
|
|
|
s->saveLoadArrayOf(vm.slot, 25, sizeof(vm.slot[0]), scriptSlotEntries);
|
2003-05-28 18:13:30 +00:00
|
|
|
else if (savegameVersion < VER_V20)
|
|
|
|
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
|
|
|
|
2002-07-07 20:25:23 +00:00
|
|
|
s->saveLoadArrayOf(_objs, _numLocalObjects, sizeof(_objs[0]), objectEntries);
|
2003-01-14 18:20:56 +00:00
|
|
|
if (!s->isSaving() && savegameVersion < VER_V13) {
|
|
|
|
// 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
|
|
|
}
|
|
|
|
|
|
|
|
}
|
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);
|
2002-04-11 17:19:16 +00:00
|
|
|
|
2003-01-13 01:29:45 +00:00
|
|
|
if (savegameVersion >= VER_V13)
|
|
|
|
s->saveLoadArrayOf(_scaleSlots, 20, sizeof(_scaleSlots[0]), scaleSlotsEntries);
|
|
|
|
|
2003-05-31 12:16:49 +00:00
|
|
|
// Save all resource. Fingolfin doesn't like this part of the save/load code a bit.
|
|
|
|
// It is very fragile: e.g. if we change the num limit for one resource type, this
|
|
|
|
// code will break down. Worse, there is no way such a problem could easily be detected.
|
|
|
|
// We should at least store for each save resource it's type and ID. Then at least
|
|
|
|
// we can perform some integrety checks when loading.
|
2002-04-11 17:19:16 +00:00
|
|
|
for (i = rtFirst; i <= rtLast; i++)
|
|
|
|
if (res.mode[i] == 0)
|
|
|
|
for (j = 1; j < res.num[i]; j++)
|
|
|
|
saveLoadResource(s, i, j);
|
|
|
|
|
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
|
|
|
|
2001-12-27 17:51:58 +00:00
|
|
|
if (_shadowPaletteSize)
|
|
|
|
s->saveLoadArrayOf(_shadowPalette, _shadowPaletteSize, 1, sleByte);
|
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
|
2002-12-13 03:23:17 +00:00
|
|
|
if (savegameVersion < VER_V10)
|
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)
|
|
|
|
_palManipPalette = (byte *)calloc(0x300, 1);
|
|
|
|
s->saveLoadArrayOf(_palManipPalette, 0x300, 1, sleByte);
|
|
|
|
s->saveLoadArrayOf(_palManipIntermediatePal, 0x600, 1, sleByte);
|
|
|
|
}
|
|
|
|
|
2002-07-07 20:25:23 +00:00
|
|
|
s->saveLoadArrayOf(_classData, _numGlobalObjects, sizeof(_classData[0]), sleUint32);
|
2002-04-11 17:19:16 +00:00
|
|
|
|
2003-05-08 15:48:50 +00:00
|
|
|
var120Backup = _scummVars[120];
|
|
|
|
var98Backup = _scummVars[98];
|
2002-04-11 17:19:16 +00:00
|
|
|
|
2003-01-15 14:14:00 +00:00
|
|
|
// The variables grew from 16 to 32 bit.
|
|
|
|
if (savegameVersion < VER_V15)
|
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
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
if (_gameId == GID_TENTACLE) // Maybe misplaced, but that's the main idea
|
2003-05-08 15:48:50 +00:00
|
|
|
_scummVars[120] = var120Backup;
|
2002-04-11 17:19:16 +00:00
|
|
|
if (_gameId == GID_INDY4)
|
2003-05-08 15:48:50 +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
|
|
|
|
|
|
|
/* Save or load a list of the locked objects */
|
|
|
|
if (s->isSaving()) {
|
2002-04-11 17:19:16 +00:00
|
|
|
for (i = rtFirst; i <= rtLast; i++)
|
|
|
|
for (j = 1; j < res.num[i]; j++) {
|
|
|
|
if (res.flags[i][j] & RF_LOCK) {
|
2001-11-07 18:10:52 +00:00
|
|
|
s->saveByte(i);
|
|
|
|
s->saveWord(j);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
s->saveByte(0xFF);
|
|
|
|
} else {
|
|
|
|
int r;
|
|
|
|
while ((r = s->loadByte()) != 0xFF) {
|
2001-11-14 20:09:39 +00:00
|
|
|
res.flags[r][s->loadWord()] |= RF_LOCK;
|
2001-11-07 18:10:52 +00:00
|
|
|
}
|
|
|
|
}
|
2003-04-30 13:23:31 +00:00
|
|
|
|
2003-05-15 21:55:13 +00:00
|
|
|
if (_imuse && _saveSound) {
|
2002-04-14 18:13:08 +00:00
|
|
|
_imuse->save_or_load(s, this);
|
2002-12-07 20:28:40 +00:00
|
|
|
_imuse->set_master_volume (_sound->_sound_volume_master);
|
|
|
|
_imuse->set_music_volume (_sound->_sound_volume_music);
|
|
|
|
}
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
|
|
|
|
2003-03-06 17:58:13 +00:00
|
|
|
void Scumm::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
|
|
|
|
|
|
|
/* don't save/load these resource types */
|
2002-04-11 17:19:16 +00:00
|
|
|
if (type == rtTemp || type == rtBuffer || res.mode[type])
|
2001-10-10 10:02:33 +00:00
|
|
|
return;
|
|
|
|
|
2001-11-05 19:21:49 +00:00
|
|
|
if (ser->isSaving()) {
|
2002-03-08 08:42:11 +00:00
|
|
|
ptr = res.address[type][idx];
|
2002-04-11 17:19:16 +00:00
|
|
|
if (ptr == NULL) {
|
2001-11-05 19:21:49 +00:00
|
|
|
ser->saveUint32(0);
|
2001-10-10 10:02:33 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
size = ((MemBlkHeader *)ptr)->size;
|
2001-11-05 19:21:49 +00:00
|
|
|
|
|
|
|
ser->saveUint32(size);
|
2002-08-26 16:47:14 +00:00
|
|
|
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) {
|
2002-03-08 08:42:11 +00:00
|
|
|
ser->saveWord(_inventory[idx]);
|
2001-10-10 10:02:33 +00:00
|
|
|
}
|
|
|
|
} else {
|
2001-11-05 19:21:49 +00:00
|
|
|
size = ser->loadUint32();
|
2001-10-10 10:02:33 +00:00
|
|
|
if (size) {
|
2002-03-08 08:42:11 +00:00
|
|
|
createResource(type, idx, size);
|
2002-08-26 16:47:14 +00:00
|
|
|
ser->loadBytes(getResourceAddress(type, idx), size);
|
2002-04-11 17:19:16 +00:00
|
|
|
if (type == rtInventory) {
|
2002-03-08 08:42:11 +00:00
|
|
|
_inventory[idx] = ser->loadWord();
|
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) {
|
2002-12-17 01:15:13 +00:00
|
|
|
_saveLoadStream->fwrite(b, 1, len);
|
2002-08-26 16:47:14 +00:00
|
|
|
}
|
|
|
|
|
2003-03-06 17:58:13 +00:00
|
|
|
void Serializer::loadBytes(void *b, int len) {
|
2002-12-17 01:15:13 +00:00
|
|
|
_saveLoadStream->fread(b, 1, len);
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
2001-10-10 10:02:33 +00:00
|
|
|
|
2002-03-14 14:45:04 +00:00
|
|
|
#ifdef _WIN32_WCE
|
|
|
|
|
|
|
|
// Perhaps not necessary anymore with latest checks
|
|
|
|
|
2003-03-06 17:58:13 +00:00
|
|
|
bool Serializer::checkEOFLoadStream() {
|
2002-12-17 01:15:13 +00:00
|
|
|
if (!_saveLoadStream->fseek(1, SEEK_CUR))
|
2002-03-14 14:45:04 +00:00
|
|
|
return true;
|
2002-12-17 01:15:13 +00:00
|
|
|
if (_saveLoadStream->feof())
|
2002-03-14 14:45:04 +00:00
|
|
|
return true;
|
2002-12-17 01:15:13 +00:00
|
|
|
_saveLoadStream->fseek(-1, SEEK_CUR);
|
2002-03-14 14:45:04 +00:00
|
|
|
return false;
|
|
|
|
}
|
2003-04-30 13:23:31 +00:00
|
|
|
#elif defined(__PALM_OS__)
|
|
|
|
bool Serializer::checkEOFLoadStream() {
|
2002-03-14 14:45:04 +00:00
|
|
|
|
2003-04-30 13:23:31 +00:00
|
|
|
if (_saveLoadStream->feof())
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2002-03-14 14:45:04 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2003-03-06 17:58:13 +00:00
|
|
|
void Serializer::saveUint32(uint32 d) {
|
2001-10-10 10:02:33 +00:00
|
|
|
uint32 e = FROM_LE_32(d);
|
2002-08-26 16:47:14 +00:00
|
|
|
saveBytes(&e, 4);
|
2001-10-10 10:02:33 +00:00
|
|
|
}
|
|
|
|
|
2003-03-06 17:58:13 +00:00
|
|
|
void Serializer::saveWord(uint16 d) {
|
2001-10-10 10:02:33 +00:00
|
|
|
uint16 e = FROM_LE_16(d);
|
2002-08-26 16:47:14 +00:00
|
|
|
saveBytes(&e, 2);
|
2001-10-10 10:02:33 +00:00
|
|
|
}
|
|
|
|
|
2003-03-06 17:58:13 +00:00
|
|
|
void Serializer::saveByte(byte b) {
|
2002-08-26 16:47:14 +00:00
|
|
|
saveBytes(&b, 1);
|
2001-10-10 10:02:33 +00:00
|
|
|
}
|
|
|
|
|
2003-03-06 17:58:13 +00:00
|
|
|
uint32 Serializer::loadUint32() {
|
2001-10-10 10:02:33 +00:00
|
|
|
uint32 e;
|
2002-08-26 16:47:14 +00:00
|
|
|
loadBytes(&e, 4);
|
2001-10-10 10:02:33 +00:00
|
|
|
return FROM_LE_32(e);
|
|
|
|
}
|
|
|
|
|
2003-03-06 17:58:13 +00:00
|
|
|
uint16 Serializer::loadWord() {
|
2001-10-10 10:02:33 +00:00
|
|
|
uint16 e;
|
2002-08-26 16:47:14 +00:00
|
|
|
loadBytes(&e, 2);
|
2001-10-10 10:02:33 +00:00
|
|
|
return FROM_LE_16(e);
|
|
|
|
}
|
|
|
|
|
2003-03-06 17:58:13 +00:00
|
|
|
byte Serializer::loadByte() {
|
2001-10-10 10:02:33 +00:00
|
|
|
byte e;
|
2002-08-26 16:47:14 +00:00
|
|
|
loadBytes(&e, 1);
|
2001-10-10 10:02:33 +00:00
|
|
|
return e;
|
|
|
|
}
|
|
|
|
|
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
|
2002-04-11 17:19:16 +00:00
|
|
|
if (datasize == 1 && filetype == sleByte) {
|
2002-12-08 16:14:29 +00:00
|
|
|
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 {
|
2002-12-08 16:14:29 +00:00
|
|
|
error("saveLoadArrayOf: invalid size %d", datasize);
|
|
|
|
}
|
|
|
|
switch (filetype) {
|
|
|
|
case sleByte:
|
|
|
|
saveByte((byte)data);
|
|
|
|
break;
|
|
|
|
case sleUint16:
|
|
|
|
case sleInt16:
|
|
|
|
saveWord((int16)data);
|
|
|
|
break;
|
|
|
|
case sleInt32:
|
|
|
|
case sleUint32:
|
|
|
|
saveUint32(data);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
error("saveLoadArrayOf: invalid filetype %d", filetype);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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:
|
|
|
|
data = loadWord();
|
|
|
|
break;
|
|
|
|
case sleInt16:
|
|
|
|
data = (int16)loadWord();
|
|
|
|
break;
|
|
|
|
case sleUint32:
|
|
|
|
data = loadUint32();
|
|
|
|
break;
|
|
|
|
case sleInt32:
|
|
|
|
data = (int32)loadUint32();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
error("saveLoadArrayOf: invalid filetype %d", filetype);
|
|
|
|
}
|
|
|
|
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 {
|
|
|
|
error("saveLoadArrayOf: 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 if (size == 0xFF) {
|
|
|
|
// save reference
|
|
|
|
void *ptr = *((void **)at);
|
|
|
|
saveWord(ptr ? ((*_save_ref) (_ref_me, type, ptr) + 1) : 0);
|
|
|
|
} 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++;
|
|
|
|
} else if (size == 0xFF) {
|
|
|
|
// load reference...
|
|
|
|
int num = loadWord();
|
|
|
|
// ...but only use it if it's still there in CURRENT_VER
|
|
|
|
if (sle->maxVersion == CURRENT_VER)
|
|
|
|
*((void **)at) = num ? (*_load_ref) (_ref_me, type, num - 1) : NULL;
|
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
|
|
|
}
|
|
|
|
}
|