2001-10-09 14:30:12 +00:00
|
|
|
/* ScummVM - Scumm Interpreter
|
|
|
|
* Copyright (C) 2001 Ludvig Strigeus
|
2002-03-20 17:51:07 +00:00
|
|
|
* Copyright (C) 2001/2002 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"
|
|
|
|
#include "scumm.h"
|
2002-04-19 11:12:27 +00:00
|
|
|
#include "sound/mididrv.h"
|
|
|
|
#include "sound/imuse.h"
|
2002-05-14 23:32:34 +00:00
|
|
|
#include "actor.h"
|
2002-05-16 10:43:17 +00:00
|
|
|
#include "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
|
|
|
// Support for "old" savegames (made with 2501 CVS build)
|
|
|
|
// Can be useful for other ports too :)
|
|
|
|
|
2002-05-05 17:44:39 +00:00
|
|
|
#define VER_V9 9
|
2002-03-14 14:45:04 +00:00
|
|
|
#define VER_V8 8
|
|
|
|
#define VER_V7 7
|
|
|
|
|
2002-05-05 17:44:39 +00:00
|
|
|
#define CURRENT_VER VER_V9
|
2002-03-14 14:45:04 +00:00
|
|
|
|
|
|
|
static uint32 _current_version = CURRENT_VER;
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
bool Scumm::saveState(int slot, bool compat)
|
|
|
|
{
|
2001-11-09 18:54:15 +00:00
|
|
|
char filename[256];
|
2002-02-02 23:27:06 +00:00
|
|
|
SerializerStream out;
|
2001-10-16 10:01:48 +00:00
|
|
|
SaveGameHeader hdr;
|
2001-11-05 19:21:49 +00:00
|
|
|
Serializer ser;
|
2001-11-09 18:54:15 +00:00
|
|
|
|
|
|
|
makeSavegameName(filename, slot, compat);
|
2002-04-11 17:19:16 +00:00
|
|
|
|
|
|
|
if (!out.fopen(filename, "wb"))
|
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-03-14 14:45:04 +00:00
|
|
|
hdr.ver = _current_version;
|
|
|
|
|
2002-02-02 23:27:06 +00:00
|
|
|
out.fwrite(&hdr, sizeof(hdr), 1);
|
2001-10-16 10:01:48 +00:00
|
|
|
|
2001-11-05 19:21:49 +00:00
|
|
|
ser._saveLoadStream = out;
|
|
|
|
ser._saveOrLoad = true;
|
|
|
|
saveOrLoad(&ser);
|
|
|
|
|
2002-02-02 23:27:06 +00:00
|
|
|
out.fclose();
|
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;
|
|
|
|
}
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
bool Scumm::loadState(int slot, bool compat)
|
|
|
|
{
|
2001-11-09 18:54:15 +00:00
|
|
|
char filename[256];
|
2002-04-11 17:19:16 +00:00
|
|
|
SerializerStream out;
|
|
|
|
int i, j;
|
2001-10-16 10:01:48 +00:00
|
|
|
SaveGameHeader hdr;
|
2001-11-05 19:21:49 +00:00
|
|
|
Serializer ser;
|
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-04-11 17:19:16 +00:00
|
|
|
if (!out.fopen(filename, "rb"))
|
2001-10-09 14:30:12 +00:00
|
|
|
return false;
|
2001-10-16 10:01:48 +00:00
|
|
|
|
2002-02-02 23:27:06 +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-02-02 23:27:06 +00:00
|
|
|
out.fclose();
|
2001-10-16 10:01:48 +00:00
|
|
|
return false;
|
|
|
|
}
|
2002-03-14 14:45:04 +00:00
|
|
|
|
2002-05-05 17:44:39 +00:00
|
|
|
if (hdr.ver < VER_V7 || hdr.ver > _current_version) {
|
2001-10-16 10:01:48 +00:00
|
|
|
warning("Invalid version of '%s'", filename);
|
2002-02-02 23:27:06 +00:00
|
|
|
out.fclose();
|
2001-10-16 10:01:48 +00:00
|
|
|
return false;
|
|
|
|
}
|
2002-03-14 14:45:04 +00:00
|
|
|
|
|
|
|
_current_version = hdr.ver;
|
2001-11-09 18:54:15 +00:00
|
|
|
memcpy(_saveLoadName, hdr.name, sizeof(hdr.name));
|
2001-11-14 18:40:39 +00:00
|
|
|
|
|
|
|
pauseSounds(true);
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
CHECK_HEAP openRoom(-1);
|
|
|
|
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++)
|
|
|
|
if (i != rtTemp && i != rtBuffer)
|
|
|
|
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
|
|
|
|
2001-11-05 19:21:49 +00:00
|
|
|
ser._saveLoadStream = out;
|
|
|
|
ser._saveOrLoad = false;
|
|
|
|
saveOrLoad(&ser);
|
2002-02-02 23:27:06 +00:00
|
|
|
out.fclose();
|
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
|
|
|
|
|
|
|
gdi._mask_left = -1;
|
2002-04-11 17:19:16 +00:00
|
|
|
|
2001-10-26 17:34:50 +00:00
|
|
|
initScreens(0, 0, 320, 200);
|
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;
|
|
|
|
fadeToBlackEffect(129);
|
2002-05-12 21:58:35 +00:00
|
|
|
_screenEffectFlag = old_screenEffectFlag;
|
2001-10-26 17:34:50 +00:00
|
|
|
|
|
|
|
initScreens(0, sb, 320, sh);
|
2001-10-10 10:02:33 +00:00
|
|
|
|
2001-11-09 18:54:15 +00:00
|
|
|
_completeScreenRedraw = true;
|
2002-04-11 17:19:16 +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
|
|
|
|
2002-04-23 23:58:31 +00:00
|
|
|
initBGBuffers(_scrHeight);
|
2001-10-10 10:02:33 +00:00
|
|
|
|
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
|
|
|
|
2001-11-26 19:57:57 +00:00
|
|
|
|
2001-11-14 18:40:39 +00:00
|
|
|
pauseSounds(false);
|
|
|
|
|
2001-10-09 14:30:12 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
void Scumm::makeSavegameName(char *out, int slot, bool compatible)
|
|
|
|
{
|
2002-03-14 14:45:04 +00:00
|
|
|
|
2002-05-16 10:43:17 +00:00
|
|
|
const char *dir = NULL;
|
2002-03-14 14:45:04 +00:00
|
|
|
|
2002-05-16 10:43:17 +00:00
|
|
|
#ifdef _WIN32_WCE
|
|
|
|
dir = _gameDataPath;
|
2002-04-11 17:19:16 +00:00
|
|
|
#else
|
2002-03-14 14:45:04 +00:00
|
|
|
|
2002-05-16 10:43:17 +00:00
|
|
|
#if !defined(MACOS_CARBON)
|
|
|
|
dir = getenv("SCUMMVM_SAVEPATH");
|
|
|
|
#endif
|
2002-03-14 14:45:04 +00:00
|
|
|
|
2002-05-16 10:43:17 +00:00
|
|
|
// If SCUMMVM_SAVEPATH was not specified, try to use game specific savepath from config
|
|
|
|
if (!dir || dir[0] == 0)
|
|
|
|
dir = scummcfg->get("savepath");
|
2002-03-14 14:45:04 +00:00
|
|
|
|
2002-05-16 10:43:17 +00:00
|
|
|
// If SCUMMVM_SAVEPATH was not specified, try to use general path from config
|
|
|
|
if (!dir || dir[0] == 0)
|
|
|
|
dir = scummcfg->get("savepath", "scummvm");
|
2002-03-14 14:45:04 +00:00
|
|
|
|
2002-05-16 10:43:17 +00:00
|
|
|
// If no save path was specified, use no directory prefix
|
|
|
|
if (dir == NULL)
|
|
|
|
dir = "";
|
2002-03-14 14:45:04 +00:00
|
|
|
#endif
|
2002-05-16 10:43:17 +00:00
|
|
|
|
|
|
|
// snprintf should be used here, but it's not portable enough
|
|
|
|
sprintf(out, "%s%s.%c%.2d", dir, _exe_name, compatible ? 'c' : 's', slot);
|
2001-11-09 18:54:15 +00:00
|
|
|
}
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
bool Scumm::getSavegameName(int slot, char *desc)
|
|
|
|
{
|
2001-11-09 18:54:15 +00:00
|
|
|
char filename[256];
|
2002-02-02 23:27:06 +00:00
|
|
|
SerializerStream out;
|
2001-11-09 18:54:15 +00:00
|
|
|
SaveGameHeader hdr;
|
|
|
|
int len;
|
|
|
|
|
|
|
|
makeSavegameName(filename, slot, false);
|
2002-04-11 17:19:16 +00:00
|
|
|
if (!out.fopen(filename, "rb")) {
|
|
|
|
strcpy(desc, "");
|
2001-11-09 18:54:15 +00:00
|
|
|
return false;
|
|
|
|
}
|
2002-02-02 23:27:06 +00:00
|
|
|
len = out.fread(&hdr, sizeof(hdr), 1);
|
|
|
|
out.fclose();
|
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-05-05 20:11:01 +00:00
|
|
|
if (hdr.ver < VER_V7 || hdr.ver > _current_version) {
|
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;
|
|
|
|
}
|
|
|
|
|
2001-10-10 10:02:33 +00:00
|
|
|
#define OFFS(type,item) ((int)(&((type*)0)->item))
|
|
|
|
#define SIZE(type,item) sizeof(((type*)0)->item)
|
|
|
|
#define MKLINE(type,item,saveas) {OFFS(type,item),saveas,SIZE(type,item)}
|
|
|
|
#define MKARRAY(type,item,saveas,num) {OFFS(type,item),128|saveas,SIZE(type,item)}, {num,0,0}
|
|
|
|
#define MKEND() {0xFFFF,0xFF,0xFF}
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
void Scumm::saveOrLoad(Serializer * s)
|
|
|
|
{
|
2001-10-10 10:02:33 +00:00
|
|
|
const SaveLoadEntry objectEntries[] = {
|
2002-04-11 17:19:16 +00:00
|
|
|
MKLINE(ObjectData, offs_obim_to_room, sleUint32),
|
|
|
|
MKLINE(ObjectData, offs_obcd_to_room, sleUint32),
|
|
|
|
MKLINE(ObjectData, walk_x, sleUint16),
|
|
|
|
MKLINE(ObjectData, walk_y, sleUint16),
|
|
|
|
MKLINE(ObjectData, obj_nr, sleUint16),
|
|
|
|
MKLINE(ObjectData, x_pos, sleInt16),
|
|
|
|
MKLINE(ObjectData, y_pos, sleInt16),
|
|
|
|
MKLINE(ObjectData, width, sleUint16),
|
|
|
|
MKLINE(ObjectData, height, sleUint16),
|
|
|
|
MKLINE(ObjectData, actordir, sleByte),
|
|
|
|
MKLINE(ObjectData, parentstate, sleByte),
|
|
|
|
MKLINE(ObjectData, parent, sleByte),
|
|
|
|
MKLINE(ObjectData, state, sleByte),
|
|
|
|
MKLINE(ObjectData, fl_object_index, sleByte),
|
2001-10-10 10:02:33 +00:00
|
|
|
MKEND()
|
|
|
|
};
|
|
|
|
|
|
|
|
const SaveLoadEntry actorEntries[] = {
|
2002-04-11 17:19:16 +00:00
|
|
|
MKLINE(Actor, x, sleInt16),
|
|
|
|
MKLINE(Actor, y, sleInt16),
|
|
|
|
MKLINE(Actor, top, sleInt16),
|
|
|
|
MKLINE(Actor, bottom, sleInt16),
|
|
|
|
MKLINE(Actor, elevation, sleInt16),
|
|
|
|
MKLINE(Actor, width, sleUint16),
|
|
|
|
MKLINE(Actor, facing, sleUint16),
|
|
|
|
MKLINE(Actor, costume, sleUint16),
|
|
|
|
MKLINE(Actor, room, sleByte),
|
|
|
|
MKLINE(Actor, talkColor, sleByte),
|
|
|
|
MKLINE(Actor, scalex, sleByte),
|
|
|
|
MKLINE(Actor, scaley, sleByte),
|
|
|
|
MKLINE(Actor, charset, sleByte),
|
|
|
|
MKARRAY(Actor, sound[0], sleByte, 8),
|
|
|
|
MKARRAY(Actor, animVariable[0], sleUint16, 8),
|
|
|
|
MKLINE(Actor, newDirection, sleUint16),
|
|
|
|
MKLINE(Actor, moving, sleByte),
|
|
|
|
MKLINE(Actor, ignoreBoxes, sleByte),
|
|
|
|
MKLINE(Actor, forceClip, sleByte),
|
|
|
|
MKLINE(Actor, initFrame, sleByte),
|
|
|
|
MKLINE(Actor, walkFrame, sleByte),
|
|
|
|
MKLINE(Actor, standFrame, sleByte),
|
|
|
|
MKLINE(Actor, talkFrame1, sleByte),
|
|
|
|
MKLINE(Actor, talkFrame2, sleByte),
|
|
|
|
MKLINE(Actor, speedx, sleUint16),
|
|
|
|
MKLINE(Actor, speedy, sleUint16),
|
|
|
|
MKLINE(Actor, cost.animCounter1, sleUint16),
|
|
|
|
MKLINE(Actor, cost.animCounter2, sleByte),
|
|
|
|
MKARRAY(Actor, palette[0], sleByte, 64),
|
|
|
|
MKLINE(Actor, mask, sleByte),
|
|
|
|
MKLINE(Actor, shadow_mode, sleByte),
|
|
|
|
MKLINE(Actor, visible, sleByte),
|
|
|
|
MKLINE(Actor, frame, sleByte),
|
|
|
|
MKLINE(Actor, animSpeed, sleByte),
|
|
|
|
MKLINE(Actor, animProgress, sleByte),
|
|
|
|
MKLINE(Actor, walkbox, sleByte),
|
|
|
|
MKLINE(Actor, needRedraw, sleByte),
|
|
|
|
MKLINE(Actor, needBgReset, sleByte),
|
|
|
|
MKLINE(Actor, costumeNeedsInit, sleByte),
|
|
|
|
|
|
|
|
MKLINE(Actor, new_1, sleInt16),
|
|
|
|
MKLINE(Actor, new_2, sleInt16),
|
|
|
|
MKLINE(Actor, new_3, sleByte),
|
|
|
|
|
|
|
|
MKLINE(Actor, layer, sleByte),
|
|
|
|
|
|
|
|
MKLINE(Actor, talk_script, sleUint16),
|
|
|
|
MKLINE(Actor, walk_script, sleUint16),
|
|
|
|
|
|
|
|
MKLINE(Actor, walkdata.destx, sleInt16),
|
|
|
|
MKLINE(Actor, walkdata.desty, sleInt16),
|
|
|
|
MKLINE(Actor, walkdata.destbox, sleByte),
|
|
|
|
MKLINE(Actor, walkdata.destdir, sleUint16),
|
|
|
|
MKLINE(Actor, walkdata.curbox, sleByte),
|
|
|
|
MKLINE(Actor, walkdata.x, sleInt16),
|
|
|
|
MKLINE(Actor, walkdata.y, sleInt16),
|
|
|
|
MKLINE(Actor, walkdata.newx, sleInt16),
|
|
|
|
MKLINE(Actor, walkdata.newy, sleInt16),
|
|
|
|
MKLINE(Actor, walkdata.XYFactor, sleInt32),
|
|
|
|
MKLINE(Actor, walkdata.YXFactor, sleInt32),
|
|
|
|
MKLINE(Actor, walkdata.xfrac, sleUint16),
|
|
|
|
MKLINE(Actor, walkdata.yfrac, sleUint16),
|
|
|
|
|
|
|
|
MKARRAY(Actor, cost.active[0], sleByte, 16),
|
|
|
|
MKLINE(Actor, cost.stopped, sleUint16),
|
|
|
|
MKARRAY(Actor, cost.curpos[0], sleUint16, 16),
|
|
|
|
MKARRAY(Actor, cost.start[0], sleUint16, 16),
|
|
|
|
MKARRAY(Actor, cost.end[0], sleUint16, 16),
|
|
|
|
MKARRAY(Actor, cost.frame[0], sleUint16, 16),
|
2001-10-10 10:02:33 +00:00
|
|
|
MKEND()
|
|
|
|
};
|
|
|
|
|
|
|
|
const SaveLoadEntry verbEntries[] = {
|
2002-04-11 17:19:16 +00:00
|
|
|
MKLINE(VerbSlot, x, sleInt16),
|
|
|
|
MKLINE(VerbSlot, y, sleInt16),
|
|
|
|
MKLINE(VerbSlot, right, sleInt16),
|
|
|
|
MKLINE(VerbSlot, bottom, sleInt16),
|
|
|
|
MKLINE(VerbSlot, oldleft, sleInt16),
|
|
|
|
MKLINE(VerbSlot, oldtop, sleInt16),
|
|
|
|
MKLINE(VerbSlot, oldright, sleInt16),
|
|
|
|
MKLINE(VerbSlot, oldbottom, sleInt16),
|
|
|
|
MKLINE(VerbSlot, verbid, sleByte),
|
|
|
|
MKLINE(VerbSlot, color, sleByte),
|
|
|
|
MKLINE(VerbSlot, hicolor, sleByte),
|
|
|
|
MKLINE(VerbSlot, dimcolor, sleByte),
|
|
|
|
MKLINE(VerbSlot, bkcolor, sleByte),
|
|
|
|
MKLINE(VerbSlot, type, sleByte),
|
|
|
|
MKLINE(VerbSlot, charset_nr, sleByte),
|
|
|
|
MKLINE(VerbSlot, curmode, sleByte),
|
|
|
|
MKLINE(VerbSlot, saveid, sleByte),
|
|
|
|
MKLINE(VerbSlot, key, sleByte),
|
|
|
|
MKLINE(VerbSlot, center, sleByte),
|
|
|
|
MKLINE(VerbSlot, field_1B, sleByte),
|
|
|
|
MKLINE(VerbSlot, imgindex, sleUint16),
|
2001-10-10 10:02:33 +00:00
|
|
|
MKEND()
|
|
|
|
};
|
2002-04-11 17:19:16 +00:00
|
|
|
|
2002-05-05 17:44:39 +00:00
|
|
|
const SaveLoadEntry mainEntriesV9[] = {
|
2002-04-11 17:19:16 +00:00
|
|
|
MKLINE(Scumm, _scrWidth, sleUint16),
|
|
|
|
MKLINE(Scumm, _scrHeight, sleUint16),
|
|
|
|
MKLINE(Scumm, _ENCD_offs, sleUint32),
|
|
|
|
MKLINE(Scumm, _EXCD_offs, sleUint32),
|
|
|
|
MKLINE(Scumm, _IM00_offs, sleUint32),
|
|
|
|
MKLINE(Scumm, _CLUT_offs, sleUint32),
|
|
|
|
MKLINE(Scumm, _EPAL_offs, sleUint32),
|
|
|
|
MKLINE(Scumm, _PALS_offs, sleUint32),
|
|
|
|
MKLINE(Scumm, _curPalIndex, sleByte),
|
|
|
|
MKLINE(Scumm, _currentRoom, sleByte),
|
|
|
|
MKLINE(Scumm, _roomResource, sleByte),
|
|
|
|
MKLINE(Scumm, _numObjectsInRoom, sleByte),
|
|
|
|
MKLINE(Scumm, _currentScript, sleByte),
|
|
|
|
MKARRAY(Scumm, _localScriptList[0], sleUint32, NUM_LOCALSCRIPT),
|
|
|
|
MKARRAY(Scumm, vm.localvar[0][0], sleUint16, NUM_SCRIPT_SLOT * 17),
|
|
|
|
MKARRAY(Scumm, _resourceMapper[0], sleByte, 128),
|
|
|
|
MKARRAY(Scumm, charset._colorMap[0], sleByte, 16),
|
|
|
|
MKARRAY(Scumm, _charsetData[0][0], sleByte, 10 * 16),
|
|
|
|
MKLINE(Scumm, _curExecScript, sleUint16),
|
2002-03-14 14:45:04 +00:00
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
MKLINE(Scumm, camera._dest.x, sleInt16),
|
|
|
|
MKLINE(Scumm, camera._dest.y, sleInt16),
|
|
|
|
MKLINE(Scumm, camera._cur.x, sleInt16),
|
|
|
|
MKLINE(Scumm, camera._cur.y, sleInt16),
|
|
|
|
MKLINE(Scumm, camera._last.x, sleInt16),
|
|
|
|
MKLINE(Scumm, camera._last.y, sleInt16),
|
|
|
|
MKLINE(Scumm, camera._accel.x, sleInt16),
|
|
|
|
MKLINE(Scumm, camera._accel.y, sleInt16),
|
|
|
|
MKLINE(Scumm, _screenStartStrip, sleInt16),
|
|
|
|
MKLINE(Scumm, _screenEndStrip, sleInt16),
|
|
|
|
MKLINE(Scumm, camera._mode, sleByte),
|
|
|
|
MKLINE(Scumm, camera._follows, sleByte),
|
|
|
|
MKLINE(Scumm, camera._leftTrigger, sleInt16),
|
|
|
|
MKLINE(Scumm, camera._rightTrigger, sleInt16),
|
|
|
|
MKLINE(Scumm, camera._movingToActor, sleUint16),
|
|
|
|
|
|
|
|
MKLINE(Scumm, _actorToPrintStrFor, sleByte),
|
|
|
|
MKLINE(Scumm, _charsetColor, sleByte),
|
2002-03-14 14:45:04 +00:00
|
|
|
/* XXX Convert into word next time format changes */
|
2002-04-11 17:19:16 +00:00
|
|
|
MKLINE(Scumm, charset._bufPos, sleByte),
|
|
|
|
MKLINE(Scumm, _haveMsg, sleByte),
|
|
|
|
MKLINE(Scumm, _useTalkAnims, sleByte),
|
|
|
|
|
|
|
|
MKLINE(Scumm, _talkDelay, sleInt16),
|
|
|
|
MKLINE(Scumm, _defaultTalkDelay, sleInt16),
|
|
|
|
MKLINE(Scumm, _numInMsgStack, sleInt16),
|
|
|
|
MKLINE(Scumm, _sentenceNum, sleByte),
|
|
|
|
|
|
|
|
MKLINE(Scumm, vm.cutSceneStackPointer, sleByte),
|
|
|
|
MKARRAY(Scumm, vm.cutScenePtr[0], sleUint32, 5),
|
|
|
|
MKARRAY(Scumm, vm.cutSceneScript[0], sleByte, 5),
|
|
|
|
MKARRAY(Scumm, vm.cutSceneData[0], sleInt16, 5),
|
|
|
|
MKLINE(Scumm, vm.cutSceneScriptIndex, sleInt16),
|
|
|
|
|
2002-03-14 14:45:04 +00:00
|
|
|
/* nest */
|
2002-04-11 17:19:16 +00:00
|
|
|
MKLINE(Scumm, _numNestedScripts, sleByte),
|
|
|
|
MKLINE(Scumm, _userPut, sleByte),
|
|
|
|
MKLINE(Scumm, _cursorState, sleByte),
|
|
|
|
MKLINE(Scumm, gdi._cursorActive, sleByte),
|
|
|
|
MKLINE(Scumm, gdi._currentCursor, sleByte),
|
|
|
|
|
|
|
|
MKLINE(Scumm, _doEffect, sleByte),
|
|
|
|
MKLINE(Scumm, _switchRoomEffect, sleByte),
|
|
|
|
MKLINE(Scumm, _newEffect, sleByte),
|
|
|
|
MKLINE(Scumm, _switchRoomEffect2, sleByte),
|
|
|
|
MKLINE(Scumm, _BgNeedsRedraw, sleByte),
|
|
|
|
|
|
|
|
MKARRAY(Scumm, gfxUsageBits[0], sleUint32, 200),
|
|
|
|
MKLINE(Scumm, gdi._transparency, sleByte),
|
|
|
|
MKARRAY(Scumm, _currentPalette[0], sleByte, 768),
|
2002-04-19 14:01:07 +00:00
|
|
|
|
2002-05-05 17:44:39 +00:00
|
|
|
MKARRAY(Scumm, _proc_special_palette[0], sleByte, 256),
|
2002-03-14 14:45:04 +00:00
|
|
|
/* virtscr */
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
MKARRAY(Scumm, charset._buffer[0], sleByte, 256),
|
2002-03-14 14:45:04 +00:00
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
MKLINE(Scumm, _egoPositioned, sleByte),
|
2002-03-14 14:45:04 +00:00
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
MKARRAY(Scumm, gdi._imgBufOffs[0], sleUint16, 4),
|
|
|
|
MKLINE(Scumm, gdi._numZBuffer, sleByte),
|
2002-03-14 14:45:04 +00:00
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
MKLINE(Scumm, _screenEffectFlag, sleByte),
|
2002-03-14 14:45:04 +00:00
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
MKLINE(Scumm, _randSeed1, sleUint32),
|
|
|
|
MKLINE(Scumm, _randSeed2, sleUint32),
|
2002-03-14 14:45:04 +00:00
|
|
|
|
|
|
|
/* XXX: next time the save game format changes,
|
|
|
|
* convert _shakeEnabled to boolean and add a _shakeFrame field */
|
2002-04-11 17:19:16 +00:00
|
|
|
MKLINE(Scumm, _shakeEnabled, sleInt16),
|
2002-03-14 14:45:04 +00:00
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
MKLINE(Scumm, _keepText, sleByte),
|
2002-03-14 14:45:04 +00:00
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
MKLINE(Scumm, _screenB, sleUint16),
|
|
|
|
MKLINE(Scumm, _screenH, sleUint16),
|
2002-03-14 14:45:04 +00:00
|
|
|
|
2002-05-05 17:44:39 +00:00
|
|
|
MKLINE(Scumm, _cd_track, sleInt16),
|
|
|
|
MKLINE(Scumm, _cd_loops, sleInt16),
|
|
|
|
MKLINE(Scumm, _cd_frame, sleInt16),
|
|
|
|
MKLINE(Scumm, _cd_end, sleInt16),
|
|
|
|
|
2002-03-14 14:45:04 +00:00
|
|
|
MKEND()
|
|
|
|
};
|
|
|
|
|
2002-05-05 17:44:39 +00:00
|
|
|
const SaveLoadEntry mainEntriesV8[] = {
|
2002-04-11 17:19:16 +00:00
|
|
|
MKLINE(Scumm, _scrWidth, sleUint16),
|
|
|
|
MKLINE(Scumm, _scrHeight, sleUint16),
|
|
|
|
MKLINE(Scumm, _ENCD_offs, sleUint32),
|
|
|
|
MKLINE(Scumm, _EXCD_offs, sleUint32),
|
|
|
|
MKLINE(Scumm, _IM00_offs, sleUint32),
|
|
|
|
MKLINE(Scumm, _CLUT_offs, sleUint32),
|
|
|
|
MKLINE(Scumm, _EPAL_offs, sleUint32),
|
|
|
|
MKLINE(Scumm, _PALS_offs, sleUint32),
|
|
|
|
MKLINE(Scumm, _curPalIndex, sleByte),
|
|
|
|
MKLINE(Scumm, _currentRoom, sleByte),
|
|
|
|
MKLINE(Scumm, _roomResource, sleByte),
|
|
|
|
MKLINE(Scumm, _numObjectsInRoom, sleByte),
|
|
|
|
MKLINE(Scumm, _currentScript, sleByte),
|
|
|
|
MKARRAY(Scumm, _localScriptList[0], sleUint32, NUM_LOCALSCRIPT),
|
2002-05-05 17:44:39 +00:00
|
|
|
MKARRAY(Scumm, vm.localvar[0][0], sleUint16, 25 * 17),
|
2002-04-11 17:19:16 +00:00
|
|
|
MKARRAY(Scumm, _resourceMapper[0], sleByte, 128),
|
|
|
|
MKARRAY(Scumm, charset._colorMap[0], sleByte, 16),
|
|
|
|
MKARRAY(Scumm, _charsetData[0][0], sleByte, 10 * 16),
|
|
|
|
MKLINE(Scumm, _curExecScript, sleUint16),
|
|
|
|
|
|
|
|
MKLINE(Scumm, camera._dest.x, sleInt16),
|
|
|
|
MKLINE(Scumm, camera._dest.y, sleInt16),
|
|
|
|
MKLINE(Scumm, camera._cur.x, sleInt16),
|
|
|
|
MKLINE(Scumm, camera._cur.y, sleInt16),
|
|
|
|
MKLINE(Scumm, camera._last.x, sleInt16),
|
|
|
|
MKLINE(Scumm, camera._last.y, sleInt16),
|
|
|
|
MKLINE(Scumm, camera._accel.x, sleInt16),
|
|
|
|
MKLINE(Scumm, camera._accel.y, sleInt16),
|
|
|
|
MKLINE(Scumm, _screenStartStrip, sleInt16),
|
|
|
|
MKLINE(Scumm, _screenEndStrip, sleInt16),
|
|
|
|
MKLINE(Scumm, camera._mode, sleByte),
|
|
|
|
MKLINE(Scumm, camera._follows, sleByte),
|
|
|
|
MKLINE(Scumm, camera._leftTrigger, sleInt16),
|
|
|
|
MKLINE(Scumm, camera._rightTrigger, sleInt16),
|
|
|
|
MKLINE(Scumm, camera._movingToActor, sleUint16),
|
|
|
|
|
|
|
|
MKLINE(Scumm, _actorToPrintStrFor, sleByte),
|
|
|
|
MKLINE(Scumm, _charsetColor, sleByte),
|
2002-01-02 11:50:28 +00:00
|
|
|
/* XXX Convert into word next time format changes */
|
2002-04-11 17:19:16 +00:00
|
|
|
MKLINE(Scumm, charset._bufPos, sleByte),
|
|
|
|
MKLINE(Scumm, _haveMsg, sleByte),
|
|
|
|
MKLINE(Scumm, _useTalkAnims, sleByte),
|
|
|
|
|
|
|
|
MKLINE(Scumm, _talkDelay, sleInt16),
|
|
|
|
MKLINE(Scumm, _defaultTalkDelay, sleInt16),
|
|
|
|
MKLINE(Scumm, _numInMsgStack, sleInt16),
|
|
|
|
MKLINE(Scumm, _sentenceNum, sleByte),
|
|
|
|
|
|
|
|
MKLINE(Scumm, vm.cutSceneStackPointer, sleByte),
|
|
|
|
MKARRAY(Scumm, vm.cutScenePtr[0], sleUint32, 5),
|
|
|
|
MKARRAY(Scumm, vm.cutSceneScript[0], sleByte, 5),
|
|
|
|
MKARRAY(Scumm, vm.cutSceneData[0], sleInt16, 5),
|
|
|
|
MKLINE(Scumm, vm.cutSceneScriptIndex, sleInt16),
|
|
|
|
|
2001-10-10 10:02:33 +00:00
|
|
|
/* nest */
|
2002-04-11 17:19:16 +00:00
|
|
|
MKLINE(Scumm, _numNestedScripts, sleByte),
|
|
|
|
MKLINE(Scumm, _userPut, sleByte),
|
|
|
|
MKLINE(Scumm, _cursorState, sleByte),
|
|
|
|
MKLINE(Scumm, gdi._cursorActive, sleByte),
|
|
|
|
MKLINE(Scumm, gdi._currentCursor, sleByte),
|
|
|
|
|
|
|
|
MKLINE(Scumm, _doEffect, sleByte),
|
|
|
|
MKLINE(Scumm, _switchRoomEffect, sleByte),
|
|
|
|
MKLINE(Scumm, _newEffect, sleByte),
|
|
|
|
MKLINE(Scumm, _switchRoomEffect2, sleByte),
|
|
|
|
MKLINE(Scumm, _BgNeedsRedraw, sleByte),
|
|
|
|
|
|
|
|
MKARRAY(Scumm, gfxUsageBits[0], sleUint32, 200),
|
|
|
|
MKLINE(Scumm, gdi._transparency, sleByte),
|
|
|
|
MKARRAY(Scumm, _currentPalette[0], sleByte, 768),
|
2002-04-20 04:09:02 +00:00
|
|
|
|
2002-04-19 14:01:07 +00:00
|
|
|
MKARRAY(Scumm, _proc_special_palette[0], sleByte, 256),
|
2001-10-10 10:02:33 +00:00
|
|
|
/* virtscr */
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
MKARRAY(Scumm, charset._buffer[0], sleByte, 256),
|
2001-10-10 10:02:33 +00:00
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
MKLINE(Scumm, _egoPositioned, sleByte),
|
2001-10-10 10:02:33 +00:00
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
MKARRAY(Scumm, gdi._imgBufOffs[0], sleUint16, 4),
|
|
|
|
MKLINE(Scumm, gdi._numZBuffer, sleByte),
|
2001-10-10 10:02:33 +00:00
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
MKLINE(Scumm, _screenEffectFlag, sleByte),
|
2001-10-10 10:02:33 +00:00
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
MKLINE(Scumm, _randSeed1, sleUint32),
|
|
|
|
MKLINE(Scumm, _randSeed2, sleUint32),
|
2001-10-10 10:02:33 +00:00
|
|
|
|
2001-12-28 15:26:28 +00:00
|
|
|
/* XXX: next time the save game format changes,
|
|
|
|
* convert _shakeEnabled to boolean and add a _shakeFrame field */
|
2002-04-11 17:19:16 +00:00
|
|
|
MKLINE(Scumm, _shakeEnabled, sleInt16),
|
2001-10-10 10:02:33 +00:00
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
MKLINE(Scumm, _keepText, sleByte),
|
2001-10-10 10:02:33 +00:00
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
MKLINE(Scumm, _screenB, sleUint16),
|
|
|
|
MKLINE(Scumm, _screenH, sleUint16),
|
2001-10-10 10:02:33 +00:00
|
|
|
|
|
|
|
MKEND()
|
|
|
|
};
|
|
|
|
|
|
|
|
const SaveLoadEntry scriptSlotEntries[] = {
|
2002-04-11 17:19:16 +00:00
|
|
|
MKLINE(ScriptSlot, offs, sleUint32),
|
|
|
|
MKLINE(ScriptSlot, delay, sleInt32),
|
|
|
|
MKLINE(ScriptSlot, number, sleUint16),
|
|
|
|
MKLINE(ScriptSlot, newfield, sleUint16),
|
|
|
|
MKLINE(ScriptSlot, status, sleByte),
|
|
|
|
MKLINE(ScriptSlot, where, sleByte),
|
|
|
|
MKLINE(ScriptSlot, unk1, sleByte),
|
|
|
|
MKLINE(ScriptSlot, unk2, sleByte),
|
|
|
|
MKLINE(ScriptSlot, freezeCount, sleByte),
|
|
|
|
MKLINE(ScriptSlot, didexec, sleByte),
|
|
|
|
MKLINE(ScriptSlot, cutsceneOverride, sleByte),
|
|
|
|
MKLINE(ScriptSlot, unk5, sleByte),
|
2001-10-10 10:02:33 +00:00
|
|
|
MKEND()
|
|
|
|
};
|
|
|
|
|
|
|
|
const SaveLoadEntry nestedScriptEntries[] = {
|
2002-04-11 17:19:16 +00:00
|
|
|
MKLINE(NestedScript, number, sleUint16),
|
|
|
|
MKLINE(NestedScript, where, sleByte),
|
|
|
|
MKLINE(NestedScript, slot, sleByte),
|
2001-10-10 10:02:33 +00:00
|
|
|
MKEND()
|
|
|
|
};
|
|
|
|
|
2001-10-16 10:01:48 +00:00
|
|
|
const SaveLoadEntry sentenceTabEntries[] = {
|
2002-04-11 17:19:16 +00:00
|
|
|
MKLINE(SentenceTab, unk5, sleUint8),
|
|
|
|
MKLINE(SentenceTab, unk2, sleUint8),
|
|
|
|
MKLINE(SentenceTab, unk4, sleUint16),
|
|
|
|
MKLINE(SentenceTab, unk3, sleUint16),
|
|
|
|
MKLINE(SentenceTab, unk, sleUint8),
|
2001-10-16 10:01:48 +00:00
|
|
|
MKEND()
|
|
|
|
};
|
|
|
|
|
|
|
|
const SaveLoadEntry stringTabEntries[] = {
|
2002-04-11 17:19:16 +00:00
|
|
|
MKLINE(StringTab, xpos, sleInt16),
|
|
|
|
MKLINE(StringTab, t_xpos, sleInt16),
|
|
|
|
MKLINE(StringTab, ypos, sleInt16),
|
|
|
|
MKLINE(StringTab, t_ypos, sleInt16),
|
|
|
|
MKLINE(StringTab, right, sleInt16),
|
|
|
|
MKLINE(StringTab, t_right, sleInt16),
|
|
|
|
MKLINE(StringTab, color, sleInt8),
|
|
|
|
MKLINE(StringTab, t_color, sleInt8),
|
|
|
|
MKLINE(StringTab, charset, sleInt8),
|
|
|
|
MKLINE(StringTab, t_charset, sleInt8),
|
|
|
|
MKLINE(StringTab, center, sleByte),
|
|
|
|
MKLINE(StringTab, t_center, sleByte),
|
|
|
|
MKLINE(StringTab, overhead, sleByte),
|
|
|
|
MKLINE(StringTab, t_overhead, sleByte),
|
|
|
|
MKLINE(StringTab, no_talk_anim, sleByte),
|
|
|
|
MKLINE(StringTab, t_no_talk_anim, sleByte),
|
2001-10-16 10:01:48 +00:00
|
|
|
MKEND()
|
|
|
|
};
|
|
|
|
|
2001-10-26 17:34:50 +00:00
|
|
|
const SaveLoadEntry colorCycleEntries[] = {
|
2002-04-11 17:19:16 +00:00
|
|
|
MKLINE(ColorCycle, delay, sleUint16),
|
|
|
|
MKLINE(ColorCycle, counter, sleUint16),
|
|
|
|
MKLINE(ColorCycle, flags, sleUint16),
|
|
|
|
MKLINE(ColorCycle, start, sleByte),
|
|
|
|
MKLINE(ColorCycle, end, sleByte),
|
2001-11-05 19:21:49 +00:00
|
|
|
MKEND()
|
2001-10-26 17:34:50 +00:00
|
|
|
};
|
|
|
|
|
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
|
|
|
|
2002-05-05 17:44:39 +00:00
|
|
|
if (_current_version == VER_V9)
|
|
|
|
s->saveLoadEntries(this, mainEntriesV9);
|
|
|
|
else
|
|
|
|
s->saveLoadEntries(this, mainEntriesV8);
|
2002-04-11 17:19:16 +00:00
|
|
|
|
2001-11-26 19:57:57 +00:00
|
|
|
s->saveLoadArrayOf(actor, NUM_ACTORS, sizeof(actor[0]), actorEntries);
|
2002-03-14 14:45:04 +00:00
|
|
|
|
2002-05-06 15:32:32 +00:00
|
|
|
if (_current_version < VER_V9)
|
2002-05-05 17:44:39 +00:00
|
|
|
s->saveLoadArrayOf(vm.slot, 25, 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-04-11 17:19:16 +00:00
|
|
|
s->saveLoadArrayOf(_objs, _numLocalObjects, sizeof(_objs[0]),
|
|
|
|
objectEntries);
|
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);
|
|
|
|
s->saveLoadArrayOf(sentence, 6, sizeof(sentence[0]), sentenceTabEntries);
|
|
|
|
s->saveLoadArrayOf(string, 6, sizeof(string[0]), stringTabEntries);
|
2002-04-11 17:19:16 +00:00
|
|
|
s->saveLoadArrayOf(_colorCycle, 16, sizeof(_colorCycle[0]),
|
|
|
|
colorCycleEntries);
|
|
|
|
|
|
|
|
for (i = rtFirst; i <= rtLast; i++)
|
|
|
|
if (res.mode[i] == 0)
|
|
|
|
for (j = 1; j < res.num[i]; j++)
|
|
|
|
saveLoadResource(s, i, j);
|
|
|
|
|
|
|
|
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-04-11 17:19:16 +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-04-11 17:19:16 +00:00
|
|
|
s->saveLoadArrayOf(_classData, _numGlobalObjects, sizeof(_classData[0]),
|
|
|
|
sleUint32);
|
|
|
|
|
|
|
|
var120Backup = _vars[120];
|
|
|
|
var98Backup = _vars[98];
|
|
|
|
|
2001-11-05 19:21:49 +00:00
|
|
|
s->saveLoadArrayOf(_vars, _numVariables, sizeof(_vars[0]), sleInt16);
|
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
|
|
|
|
_vars[120] = var120Backup;
|
|
|
|
if (_gameId == GID_INDY4)
|
|
|
|
_vars[98] = var98Backup;;
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
2001-11-14 18:40:39 +00:00
|
|
|
|
2002-04-14 18:13:08 +00:00
|
|
|
if (_imuse)
|
|
|
|
_imuse->save_or_load(s, this);
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
|
|
|
|
2002-04-11 17:19:16 +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-04-11 17:19:16 +00:00
|
|
|
ser->saveLoadBytes(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);
|
|
|
|
ser->saveLoadBytes(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
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
void Serializer::saveLoadBytes(void *b, int len)
|
|
|
|
{
|
2001-10-09 14:30:12 +00:00
|
|
|
if (_saveOrLoad)
|
2002-02-02 23:27:06 +00:00
|
|
|
_saveLoadStream.fwrite(b, 1, len);
|
2001-10-09 14:30:12 +00:00
|
|
|
else
|
2002-02-02 23:27:06 +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
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
bool Serializer::checkEOFLoadStream()
|
|
|
|
{
|
2002-03-14 14:45:04 +00:00
|
|
|
if (!fseek(_saveLoadStream.out, 1, SEEK_CUR))
|
|
|
|
return true;
|
|
|
|
if (feof(_saveLoadStream.out))
|
|
|
|
return true;
|
|
|
|
fseek(_saveLoadStream.out, -1, SEEK_CUR);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
void Serializer::saveUint32(uint32 d)
|
|
|
|
{
|
2001-10-10 10:02:33 +00:00
|
|
|
uint32 e = FROM_LE_32(d);
|
2002-04-11 17:19:16 +00:00
|
|
|
saveLoadBytes(&e, 4);
|
2001-10-10 10:02:33 +00:00
|
|
|
}
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
void Serializer::saveWord(uint16 d)
|
|
|
|
{
|
2001-10-10 10:02:33 +00:00
|
|
|
uint16 e = FROM_LE_16(d);
|
2002-04-11 17:19:16 +00:00
|
|
|
saveLoadBytes(&e, 2);
|
2001-10-10 10:02:33 +00:00
|
|
|
}
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
void Serializer::saveByte(byte b)
|
|
|
|
{
|
|
|
|
saveLoadBytes(&b, 1);
|
2001-10-10 10:02:33 +00:00
|
|
|
}
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
uint32 Serializer::loadUint32()
|
|
|
|
{
|
2001-10-10 10:02:33 +00:00
|
|
|
uint32 e;
|
2002-04-11 17:19:16 +00:00
|
|
|
saveLoadBytes(&e, 4);
|
2001-10-10 10:02:33 +00:00
|
|
|
return FROM_LE_32(e);
|
|
|
|
}
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
uint16 Serializer::loadWord()
|
|
|
|
{
|
2001-10-10 10:02:33 +00:00
|
|
|
uint16 e;
|
2002-04-11 17:19:16 +00:00
|
|
|
saveLoadBytes(&e, 2);
|
2001-10-10 10:02:33 +00:00
|
|
|
return FROM_LE_16(e);
|
|
|
|
}
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
byte Serializer::loadByte()
|
|
|
|
{
|
2001-10-10 10:02:33 +00:00
|
|
|
byte e;
|
2002-04-11 17:19:16 +00:00
|
|
|
saveLoadBytes(&e, 1);
|
2001-10-10 10:02:33 +00:00
|
|
|
return e;
|
|
|
|
}
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
void Serializer::saveLoadArrayOf(void *b, int len, int datasize,
|
|
|
|
byte filetype)
|
|
|
|
{
|
|
|
|
byte *at = (byte *)b;
|
2001-10-16 10:01:48 +00:00
|
|
|
uint32 data;
|
|
|
|
|
2001-11-05 19:21:49 +00:00
|
|
|
/* speed up byte arrays */
|
2002-04-11 17:19:16 +00:00
|
|
|
if (datasize == 1 && filetype == sleByte) {
|
2001-11-05 19:21:49 +00:00
|
|
|
saveLoadBytes(b, len);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
while (--len >= 0) {
|
2001-10-16 10:01:48 +00:00
|
|
|
if (_saveOrLoad) {
|
|
|
|
/* saving */
|
2002-04-11 17:19:16 +00:00
|
|
|
if (datasize == 1) {
|
|
|
|
data = *(byte *)at;
|
2001-10-16 10:01:48 +00:00
|
|
|
at += 1;
|
2002-04-11 17:19:16 +00:00
|
|
|
} else if (datasize == 2) {
|
|
|
|
data = *(uint16 *)at;
|
2001-10-16 10:01:48 +00:00
|
|
|
at += 2;
|
2002-04-11 17:19:16 +00:00
|
|
|
} else if (datasize == 4) {
|
|
|
|
data = *(uint32 *)at;
|
2001-10-16 10:01:48 +00:00
|
|
|
at += 4;
|
|
|
|
} else {
|
|
|
|
error("saveLoadArrayOf: invalid size %d", datasize);
|
|
|
|
}
|
2002-04-11 17:19:16 +00:00
|
|
|
switch (filetype) {
|
|
|
|
case sleByte:
|
|
|
|
saveByte((byte)data);
|
|
|
|
break;
|
2001-10-16 10:01:48 +00:00
|
|
|
case sleUint16:
|
2002-04-11 17:19:16 +00:00
|
|
|
case sleInt16:
|
|
|
|
saveWord((int16) data);
|
|
|
|
break;
|
2001-10-16 10:01:48 +00:00
|
|
|
case sleInt32:
|
2002-04-11 17:19:16 +00:00
|
|
|
case sleUint32:
|
|
|
|
saveUint32(data);
|
|
|
|
break;
|
2001-10-16 10:01:48 +00:00
|
|
|
default:
|
|
|
|
error("saveLoadArrayOf: invalid filetype %d", filetype);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* loading */
|
2002-04-11 17:19:16 +00:00
|
|
|
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;
|
2001-10-16 10:01:48 +00:00
|
|
|
default:
|
|
|
|
error("saveLoadArrayOf: invalid filetype %d", filetype);
|
|
|
|
}
|
2002-04-11 17:19:16 +00:00
|
|
|
if (datasize == 1) {
|
|
|
|
*(byte *)at = (byte)data;
|
2001-10-16 10:01:48 +00:00
|
|
|
at += 1;
|
2002-04-11 17:19:16 +00:00
|
|
|
} else if (datasize == 2) {
|
|
|
|
*(uint16 *)at = (uint16)data;
|
2001-10-16 10:01:48 +00:00
|
|
|
at += 2;
|
2002-04-11 17:19:16 +00:00
|
|
|
} else if (datasize == 4) {
|
|
|
|
*(uint32 *)at = data;
|
2001-10-16 10:01:48 +00:00
|
|
|
at += 4;
|
|
|
|
} else {
|
|
|
|
error("saveLoadArrayOf: invalid size %d", datasize);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
void Serializer::saveLoadArrayOf(void *b, int num, int datasize,
|
|
|
|
const SaveLoadEntry * sle)
|
|
|
|
{
|
|
|
|
byte *data = (byte *)b;
|
2001-11-09 22:44:26 +00:00
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
while (--num >= 0) {
|
|
|
|
saveLoadEntries(data, sle);
|
2001-11-05 19:21:49 +00:00
|
|
|
data += datasize;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-10-10 10:02:33 +00:00
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
void Serializer::saveLoadEntries(void *d, const SaveLoadEntry * sle)
|
|
|
|
{
|
2001-10-10 10:02:33 +00:00
|
|
|
int replen;
|
|
|
|
byte type;
|
|
|
|
byte *at;
|
|
|
|
int size;
|
2001-11-14 18:40:39 +00:00
|
|
|
int num;
|
|
|
|
void *ptr;
|
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;
|
|
|
|
type = sle->type;
|
2002-04-11 17:19:16 +00:00
|
|
|
|
|
|
|
if (size == 0xFF) {
|
2001-11-05 19:21:49 +00:00
|
|
|
if (_saveOrLoad) {
|
|
|
|
/* save reference */
|
2002-04-11 17:19:16 +00:00
|
|
|
ptr = *((void **)at);
|
|
|
|
saveWord(ptr ? ((*_save_ref) (_ref_me, type, ptr) + 1) : 0);
|
2001-11-05 19:21:49 +00:00
|
|
|
} else {
|
|
|
|
/* load reference */
|
2001-11-14 18:40:39 +00:00
|
|
|
num = loadWord();
|
2002-04-11 17:19:16 +00:00
|
|
|
*((void **)at) = num ? (*_load_ref) (_ref_me, type, num - 1) : NULL;
|
2001-11-05 19:21:49 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
replen = 1;
|
2002-04-11 17:19:16 +00:00
|
|
|
if (type & 128) {
|
2001-11-05 19:21:49 +00:00
|
|
|
sle++;
|
|
|
|
replen = sle->offs;
|
2002-04-11 17:19:16 +00:00
|
|
|
type &= ~128;
|
2001-11-05 19:21:49 +00:00
|
|
|
}
|
|
|
|
saveLoadArrayOf(at, replen, size, type);
|
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
|
|
|
}
|
|
|
|
}
|