2007-05-30 21:56:52 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
2007-04-27 12:58:35 +00:00
|
|
|
*
|
2007-05-30 21:56:52 +00:00
|
|
|
* 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.
|
2007-04-27 12:58:35 +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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "cruise/cruise_main.h"
|
2009-04-01 10:43:24 +00:00
|
|
|
#include "cruise/cruise.h"
|
2009-06-10 12:15:50 +00:00
|
|
|
#include "cruise/vars.h"
|
2007-04-27 12:58:35 +00:00
|
|
|
|
2009-03-16 09:17:49 +00:00
|
|
|
#include "common/serializer.h"
|
2007-12-20 14:30:51 +00:00
|
|
|
#include "common/savefile.h"
|
|
|
|
#include "common/system.h"
|
2011-04-24 08:34:27 +00:00
|
|
|
#include "common/textconsole.h"
|
2007-12-20 14:30:51 +00:00
|
|
|
|
2009-04-18 10:16:08 +00:00
|
|
|
#include "graphics/scaler.h"
|
|
|
|
#include "graphics/thumbnail.h"
|
|
|
|
|
2007-04-27 12:58:35 +00:00
|
|
|
namespace Cruise {
|
|
|
|
|
2007-11-10 19:47:07 +00:00
|
|
|
struct overlayRestoreTemporary {
|
|
|
|
int _sBssSize;
|
|
|
|
uint8* _pBss;
|
|
|
|
int _sNumObj;
|
|
|
|
objectParams* _pObj;
|
|
|
|
};
|
|
|
|
|
|
|
|
overlayRestoreTemporary ovlRestoreData[90];
|
|
|
|
|
2009-04-18 10:16:08 +00:00
|
|
|
bool readSavegameHeader(Common::InSaveFile *in, CruiseSavegameHeader &header) {
|
|
|
|
char saveIdentBuffer[6];
|
|
|
|
header.thumbnail = NULL;
|
|
|
|
|
|
|
|
// Validate the header Id
|
|
|
|
in->read(saveIdentBuffer, 6);
|
|
|
|
if (strcmp(saveIdentBuffer, "SVMCR"))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
header.version = in->readByte();
|
|
|
|
if (header.version != CRUISE_SAVEGAME_VERSION)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
// Read in the string
|
|
|
|
header.saveName.clear();
|
|
|
|
char ch;
|
|
|
|
while ((ch = (char)in->readByte()) != '\0') header.saveName += ch;
|
|
|
|
|
|
|
|
// Get the thumbnail
|
2011-08-07 12:35:01 +00:00
|
|
|
header.thumbnail = Graphics::loadThumbnail(*in);
|
|
|
|
if (!header.thumbnail)
|
2009-04-18 10:16:08 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void writeSavegameHeader(Common::OutSaveFile *out, CruiseSavegameHeader &header) {
|
|
|
|
// Write out a savegame header
|
|
|
|
char saveIdentBuffer[6];
|
|
|
|
strcpy(saveIdentBuffer, "SVMCR");
|
|
|
|
out->write(saveIdentBuffer, 6);
|
|
|
|
|
|
|
|
out->writeByte(CRUISE_SAVEGAME_VERSION);
|
|
|
|
|
|
|
|
// Write savegame name
|
|
|
|
out->write(header.saveName.c_str(), header.saveName.size() + 1);
|
|
|
|
|
|
|
|
// Create a thumbnail and save it
|
|
|
|
Graphics::Surface *thumb = new Graphics::Surface();
|
|
|
|
::createThumbnail(thumb, globalScreen, 320, 200, workpal);
|
|
|
|
Graphics::saveThumbnail(*out, *thumb);
|
2011-11-21 08:38:52 +00:00
|
|
|
thumb->free();
|
2009-04-18 10:16:08 +00:00
|
|
|
delete thumb;
|
|
|
|
}
|
|
|
|
|
2009-03-16 09:17:49 +00:00
|
|
|
static void syncPalette(Common::Serializer &s, uint8 *p) {
|
2009-02-09 11:30:18 +00:00
|
|
|
// This is different from the original, where palette entries are 2 bytes each
|
|
|
|
s.syncBytes(p, NBCOLORS * 3);
|
|
|
|
}
|
|
|
|
|
2009-03-16 09:17:49 +00:00
|
|
|
static void syncBasicInfo(Common::Serializer &s) {
|
2009-02-09 11:30:18 +00:00
|
|
|
s.syncAsSint16LE(activeMouse);
|
|
|
|
s.syncAsSint16LE(userEnabled);
|
|
|
|
s.syncAsSint16LE(dialogueEnabled);
|
|
|
|
s.syncAsSint16LE(dialogueOvl);
|
|
|
|
s.syncAsSint16LE(dialogueObj);
|
|
|
|
s.syncAsSint16LE(userDelay);
|
|
|
|
s.syncAsSint16LE(sysKey);
|
|
|
|
s.syncAsSint16LE(sysX);
|
|
|
|
s.syncAsSint16LE(sysY);
|
|
|
|
s.syncAsSint16LE(automoveInc);
|
|
|
|
s.syncAsSint16LE(automoveMax);
|
|
|
|
s.syncAsSint16LE(displayOn);
|
|
|
|
s.syncAsSint16LE(isMessage);
|
|
|
|
s.syncAsSint16LE(fadeFlag);
|
|
|
|
s.syncAsSint16LE(automaticMode);
|
|
|
|
s.syncAsSint16LE(titleColor);
|
|
|
|
s.syncAsSint16LE(itemColor);
|
|
|
|
s.syncAsSint16LE(selectColor);
|
|
|
|
s.syncAsSint16LE(subColor);
|
|
|
|
s.syncAsSint16LE(narratorOvl);
|
|
|
|
s.syncAsSint16LE(narratorIdx);
|
|
|
|
s.syncAsSint16LE(aniX);
|
|
|
|
s.syncAsSint16LE(aniY);
|
2009-03-24 11:30:37 +00:00
|
|
|
s.syncAsUint16LE(animationStart);
|
2009-02-09 11:30:18 +00:00
|
|
|
s.syncAsSint16LE(masterScreen);
|
|
|
|
s.syncAsSint16LE(switchPal);
|
|
|
|
s.syncAsSint16LE(scroll);
|
|
|
|
s.syncAsSint16LE(fadeFlag);
|
|
|
|
s.syncAsSint16LE(doFade);
|
|
|
|
s.syncAsSint16LE(numOfLoadedOverlay);
|
|
|
|
s.syncAsSint16LE(stateID);
|
|
|
|
s.syncAsSint16LE(fontFileIndex);
|
|
|
|
s.syncAsSint16LE(currentActiveMenu);
|
|
|
|
s.syncAsSint16LE(userWait);
|
|
|
|
s.syncAsSint16LE(autoOvl);
|
|
|
|
s.syncAsSint16LE(autoMsg);
|
|
|
|
s.syncAsSint16LE(autoTrack);
|
|
|
|
s.syncAsSint16LE(var39);
|
|
|
|
s.syncAsSint16LE(var42);
|
|
|
|
s.syncAsSint16LE(var45);
|
|
|
|
s.syncAsSint16LE(var46);
|
|
|
|
s.syncAsSint16LE(var47);
|
|
|
|
s.syncAsSint16LE(var48);
|
|
|
|
s.syncAsSint16LE(flagCt);
|
|
|
|
s.syncAsSint16LE(var41);
|
2009-04-18 10:16:08 +00:00
|
|
|
s.syncAsSint16LE(playerMenuEnabled);
|
2009-06-10 12:15:50 +00:00
|
|
|
s.syncAsSint16LE(protectionCode);
|
2009-02-09 11:30:18 +00:00
|
|
|
}
|
|
|
|
|
2009-03-16 09:17:49 +00:00
|
|
|
static void syncBackgroundTable(Common::Serializer &s) {
|
2009-02-09 11:30:18 +00:00
|
|
|
// restore backgroundTable
|
|
|
|
for (int i = 0; i < 8; i++) {
|
2010-02-20 10:37:08 +00:00
|
|
|
if (s.isSaving() && (strlen(backgroundTable[i].name) > 8))
|
|
|
|
warning("Saving a background resource that has too long a name");
|
|
|
|
|
2009-05-19 11:23:13 +00:00
|
|
|
s.syncBytes((byte *)backgroundTable[i].name, 9);
|
|
|
|
s.syncBytes((byte *)backgroundTable[i].extention, 6);
|
2009-02-09 11:30:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-03-16 09:17:49 +00:00
|
|
|
static void syncPalScreen(Common::Serializer &s) {
|
2009-02-09 11:30:18 +00:00
|
|
|
for (int i = 0; i < NBSCREENS; ++i) {
|
|
|
|
for (int j = 0; j < NBCOLORS; ++j)
|
|
|
|
s.syncAsUint16LE(palScreen[i][j]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-03-16 09:17:49 +00:00
|
|
|
static void syncSoundList(Common::Serializer &s) {
|
2009-02-09 11:30:18 +00:00
|
|
|
for (int i = 0; i < 4; ++i) {
|
|
|
|
SoundEntry &se = soundList[i];
|
|
|
|
s.syncAsSint16LE(se.frameNum);
|
|
|
|
s.syncAsUint16LE(se.frequency);
|
|
|
|
s.syncAsSint16LE(se.volume);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-03-16 09:17:49 +00:00
|
|
|
static void syncFilesDatabase(Common::Serializer &s) {
|
2009-02-09 11:30:18 +00:00
|
|
|
uint8 dummyVal = 0;
|
2009-03-24 11:30:37 +00:00
|
|
|
uint32 tmp;
|
2009-02-09 11:30:18 +00:00
|
|
|
|
|
|
|
for (int i = 0; i < NUM_FILE_ENTRIES; i++) {
|
|
|
|
dataFileEntry &fe = filesDatabase[i];
|
|
|
|
|
|
|
|
s.syncAsUint16LE(fe.widthInColumn);
|
|
|
|
s.syncAsUint16LE(fe.width);
|
|
|
|
s.syncAsUint16LE(fe.resType);
|
|
|
|
s.syncAsUint16LE(fe.height);
|
2009-05-24 15:17:42 +00:00
|
|
|
|
2009-02-09 11:30:18 +00:00
|
|
|
// TODO: Have a look at the saving/loading of this pointer
|
2009-03-24 11:30:37 +00:00
|
|
|
tmp = (fe.subData.ptr) ? 1 : 0;
|
|
|
|
s.syncAsUint32LE(tmp);
|
2009-02-09 11:30:18 +00:00
|
|
|
if (s.isLoading()) {
|
2009-03-24 11:30:37 +00:00
|
|
|
fe.subData.ptr = (uint8 *)tmp;
|
2009-02-09 11:30:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
s.syncAsSint16LE(fe.subData.index);
|
2009-05-19 11:23:13 +00:00
|
|
|
s.syncBytes((byte *)fe.subData.name, 13);
|
2009-02-09 11:30:18 +00:00
|
|
|
s.syncAsByte(dummyVal);
|
|
|
|
|
|
|
|
s.syncAsSint16LE(fe.subData.transparency);
|
|
|
|
|
|
|
|
// TODO: Have a look at the saving/loading of this pointer
|
2009-03-24 11:30:37 +00:00
|
|
|
tmp = (fe.subData.ptrMask) ? 1 : 0;
|
|
|
|
s.syncAsUint32LE(tmp);
|
2009-02-09 11:30:18 +00:00
|
|
|
if (s.isLoading()) {
|
2009-03-24 11:30:37 +00:00
|
|
|
fe.subData.ptrMask = (uint8 *)tmp;
|
2009-02-09 11:30:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
s.syncAsUint16LE(fe.subData.resourceType);
|
|
|
|
s.syncAsSint16LE(fe.subData.compression);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-03-16 09:17:49 +00:00
|
|
|
static void syncPreloadData(Common::Serializer &s) {
|
2009-02-09 11:30:18 +00:00
|
|
|
uint8 dummyByte = 0;
|
|
|
|
uint32 dummyLong = 0;
|
|
|
|
|
|
|
|
for (int i = 0; i < 64; i++) {
|
|
|
|
preloadStruct &pe = preloadData[i];
|
|
|
|
|
2009-05-19 11:23:13 +00:00
|
|
|
s.syncBytes((byte *)pe.name, 15);
|
2009-02-09 11:30:18 +00:00
|
|
|
s.syncAsByte(dummyByte);
|
|
|
|
s.syncAsUint32LE(pe.size);
|
|
|
|
s.syncAsUint32LE(pe.sourceSize);
|
|
|
|
s.syncAsUint32LE(dummyLong);
|
|
|
|
s.syncAsUint16LE(pe.nofree);
|
|
|
|
s.syncAsUint16LE(pe.protect);
|
|
|
|
s.syncAsUint16LE(pe.ovl);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-03-16 09:17:49 +00:00
|
|
|
static void syncOverlays1(Common::Serializer &s) {
|
2009-02-09 11:30:18 +00:00
|
|
|
uint8 dummyByte = 0;
|
|
|
|
uint32 dummyLong = 0;
|
|
|
|
|
|
|
|
for (int i = 0; i < numOfLoadedOverlay; i++) {
|
|
|
|
overlayStruct &oe = overlayTable[i];
|
|
|
|
|
2009-05-19 11:23:13 +00:00
|
|
|
s.syncBytes((byte *)oe.overlayName, 13);
|
2009-02-09 11:30:18 +00:00
|
|
|
s.syncAsByte(dummyByte);
|
|
|
|
s.syncAsUint32LE(dummyLong);
|
|
|
|
s.syncAsUint16LE(oe.alreadyLoaded);
|
|
|
|
s.syncAsUint16LE(oe.state);
|
|
|
|
s.syncAsUint32LE(dummyLong);
|
|
|
|
s.syncAsUint32LE(dummyLong);
|
|
|
|
s.syncAsUint32LE(dummyLong);
|
|
|
|
s.syncAsUint32LE(dummyLong);
|
|
|
|
s.syncAsUint16LE(oe.executeScripts);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-03-16 09:17:49 +00:00
|
|
|
static void syncOverlays2(Common::Serializer &s) {
|
2009-02-09 11:30:18 +00:00
|
|
|
|
|
|
|
for (int i = 1; i < numOfLoadedOverlay; i++) {
|
|
|
|
|
|
|
|
if (s.isSaving()) {
|
|
|
|
// Saving code
|
|
|
|
if (!overlayTable[i].alreadyLoaded)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
ovlDataStruct *ovlData = overlayTable[i].ovlData;
|
|
|
|
|
|
|
|
// save BSS
|
|
|
|
s.syncAsSint16LE(ovlData->sizeOfData4);
|
|
|
|
if (ovlData->sizeOfData4)
|
|
|
|
s.syncBytes(ovlData->data4Ptr, ovlData->sizeOfData4);
|
|
|
|
|
|
|
|
// save variables
|
|
|
|
s.syncAsSint16LE(ovlData->size9);
|
|
|
|
for (int j = 0; j < ovlData->size9; j++) {
|
|
|
|
s.syncAsSint16LE(ovlData->arrayObjVar[j].X);
|
|
|
|
s.syncAsSint16LE(ovlData->arrayObjVar[j].Y);
|
|
|
|
s.syncAsSint16LE(ovlData->arrayObjVar[j].Z);
|
|
|
|
s.syncAsSint16LE(ovlData->arrayObjVar[j].frame);
|
|
|
|
s.syncAsSint16LE(ovlData->arrayObjVar[j].scale);
|
|
|
|
s.syncAsSint16LE(ovlData->arrayObjVar[j].state);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Loading code
|
|
|
|
ovlRestoreData[i]._sBssSize = ovlRestoreData[i]._sNumObj = 0;
|
|
|
|
ovlRestoreData[i]._pBss = NULL;
|
|
|
|
ovlRestoreData[i]._pObj = NULL;
|
|
|
|
|
|
|
|
if (overlayTable[i].alreadyLoaded) {
|
|
|
|
s.syncAsSint16LE(ovlRestoreData[i]._sBssSize);
|
|
|
|
|
|
|
|
if (ovlRestoreData[i]._sBssSize) {
|
|
|
|
ovlRestoreData[i]._pBss = (uint8 *) mallocAndZero(ovlRestoreData[i]._sBssSize);
|
|
|
|
ASSERT(ovlRestoreData[i]._pBss);
|
|
|
|
|
|
|
|
s.syncBytes(ovlRestoreData[i]._pBss, ovlRestoreData[i]._sBssSize);
|
|
|
|
}
|
|
|
|
|
|
|
|
s.syncAsSint16LE(ovlRestoreData[i]._sNumObj);
|
|
|
|
|
|
|
|
if (ovlRestoreData[i]._sNumObj) {
|
|
|
|
ovlRestoreData[i]._pObj = (objectParams *) mallocAndZero(ovlRestoreData[i]._sNumObj * sizeof(objectParams));
|
|
|
|
ASSERT(ovlRestoreData[i]._pObj);
|
|
|
|
|
|
|
|
for (int j = 0; j < ovlRestoreData[i]._sNumObj; j++) {
|
|
|
|
s.syncAsSint16LE(ovlRestoreData[i]._pObj[j].X);
|
|
|
|
s.syncAsSint16LE(ovlRestoreData[i]._pObj[j].Y);
|
|
|
|
s.syncAsSint16LE(ovlRestoreData[i]._pObj[j].Z);
|
|
|
|
s.syncAsSint16LE(ovlRestoreData[i]._pObj[j].frame);
|
|
|
|
s.syncAsSint16LE(ovlRestoreData[i]._pObj[j].scale);
|
|
|
|
s.syncAsSint16LE(ovlRestoreData[i]._pObj[j].state);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-03-16 09:17:49 +00:00
|
|
|
void syncScript(Common::Serializer &s, scriptInstanceStruct *entry) {
|
2009-02-09 11:30:18 +00:00
|
|
|
int numScripts = 0;
|
|
|
|
uint32 dummyLong = 0;
|
|
|
|
uint16 dummyWord = 0;
|
|
|
|
|
|
|
|
if (s.isSaving()) {
|
|
|
|
// Figure out the number of scripts to save
|
|
|
|
scriptInstanceStruct* pCurrent = entry->nextScriptPtr;
|
|
|
|
while (pCurrent) {
|
|
|
|
++numScripts;
|
|
|
|
pCurrent = pCurrent->nextScriptPtr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
s.syncAsSint16LE(numScripts);
|
|
|
|
|
|
|
|
scriptInstanceStruct *ptr = entry->nextScriptPtr;
|
|
|
|
for (int i = 0; i < numScripts; ++i) {
|
|
|
|
if (s.isLoading())
|
|
|
|
ptr = (scriptInstanceStruct *)mallocAndZero(sizeof(scriptInstanceStruct));
|
|
|
|
|
|
|
|
s.syncAsUint16LE(dummyWord);
|
|
|
|
s.syncAsSint16LE(ptr->ccr);
|
2009-05-17 06:59:19 +00:00
|
|
|
s.syncAsSint16LE(ptr->scriptOffset);
|
2009-02-09 11:30:18 +00:00
|
|
|
s.syncAsUint32LE(dummyLong);
|
2009-10-09 10:32:33 +00:00
|
|
|
s.syncAsSint16LE(ptr->dataSize);
|
2009-02-09 11:30:18 +00:00
|
|
|
s.syncAsSint16LE(ptr->scriptNumber);
|
|
|
|
s.syncAsSint16LE(ptr->overlayNumber);
|
|
|
|
s.syncAsSint16LE(ptr->sysKey);
|
|
|
|
s.syncAsSint16LE(ptr->freeze);
|
|
|
|
s.syncAsSint16LE(ptr->type);
|
|
|
|
s.syncAsSint16LE(ptr->var16);
|
|
|
|
s.syncAsSint16LE(ptr->var18);
|
|
|
|
s.syncAsSint16LE(ptr->var1A);
|
|
|
|
|
2009-10-09 10:32:33 +00:00
|
|
|
s.syncAsSint16LE(ptr->dataSize);
|
2009-02-09 11:30:18 +00:00
|
|
|
|
2009-10-09 10:32:33 +00:00
|
|
|
if (ptr->dataSize) {
|
2009-02-09 11:30:18 +00:00
|
|
|
if (s.isLoading())
|
2009-10-09 10:32:33 +00:00
|
|
|
ptr->data = (byte *)mallocAndZero(ptr->dataSize);
|
|
|
|
s.syncBytes(ptr->data, ptr->dataSize);
|
2009-02-09 11:30:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (s.isLoading()) {
|
|
|
|
ptr->nextScriptPtr = NULL;
|
|
|
|
entry->nextScriptPtr = ptr;
|
|
|
|
entry = ptr;
|
|
|
|
} else {
|
|
|
|
ptr = ptr->nextScriptPtr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-03-16 09:17:49 +00:00
|
|
|
static void syncCell(Common::Serializer &s) {
|
2009-02-09 11:30:18 +00:00
|
|
|
int chunkCount = 0;
|
|
|
|
cellStruct *t, *p;
|
|
|
|
uint16 dummyWord = 0;
|
|
|
|
|
|
|
|
if (s.isSaving()) {
|
|
|
|
// Figure out the number of chunks to save
|
|
|
|
t = cellHead.next;
|
|
|
|
while (t) {
|
|
|
|
++chunkCount;
|
|
|
|
t = t->next;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
cellHead.next = NULL; // Not in ASM code, but I guess the variable is defaulted in the EXE
|
|
|
|
}
|
|
|
|
s.syncAsSint16LE(chunkCount);
|
|
|
|
|
|
|
|
t = s.isSaving() ? cellHead.next : &cellHead;
|
|
|
|
for (int i = 0; i < chunkCount; ++i) {
|
|
|
|
p = s.isSaving() ? t : (cellStruct *)mallocAndZero(sizeof(cellStruct));
|
|
|
|
|
|
|
|
s.syncAsUint16LE(dummyWord);
|
|
|
|
s.syncAsUint16LE(dummyWord);
|
|
|
|
|
|
|
|
s.syncAsSint16LE(p->idx);
|
|
|
|
s.syncAsSint16LE(p->type);
|
|
|
|
s.syncAsSint16LE(p->overlay);
|
|
|
|
s.syncAsSint16LE(p->x);
|
|
|
|
s.syncAsSint16LE(p->field_C);
|
|
|
|
s.syncAsSint16LE(p->spriteIdx);
|
|
|
|
s.syncAsSint16LE(p->color);
|
|
|
|
s.syncAsSint16LE(p->backgroundPlane);
|
|
|
|
s.syncAsSint16LE(p->freeze);
|
|
|
|
s.syncAsSint16LE(p->parent);
|
|
|
|
s.syncAsSint16LE(p->parentOverlay);
|
|
|
|
s.syncAsSint16LE(p->parentType);
|
|
|
|
s.syncAsSint16LE(p->followObjectOverlayIdx);
|
|
|
|
s.syncAsSint16LE(p->followObjectIdx);
|
|
|
|
s.syncAsSint16LE(p->animStart);
|
|
|
|
s.syncAsSint16LE(p->animEnd);
|
|
|
|
s.syncAsSint16LE(p->animWait);
|
|
|
|
s.syncAsSint16LE(p->animStep);
|
|
|
|
s.syncAsSint16LE(p->animChange);
|
|
|
|
s.syncAsSint16LE(p->animType);
|
|
|
|
s.syncAsSint16LE(p->animSignal);
|
|
|
|
s.syncAsSint16LE(p->animCounter);
|
|
|
|
s.syncAsSint16LE(p->animLoop);
|
|
|
|
s.syncAsUint16LE(dummyWord);
|
|
|
|
|
|
|
|
if (s.isSaving())
|
|
|
|
t = t->next;
|
|
|
|
else {
|
|
|
|
p->next = NULL;
|
|
|
|
t->next = p;
|
|
|
|
p->prev = cellHead.prev;
|
|
|
|
cellHead.prev = p;
|
|
|
|
t = p;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-03-16 09:17:49 +00:00
|
|
|
static void syncIncrust(Common::Serializer &s) {
|
2009-02-09 11:30:18 +00:00
|
|
|
int numEntries = 0;
|
|
|
|
backgroundIncrustStruct *pl, *pl1;
|
|
|
|
uint8 dummyByte = 0;
|
|
|
|
uint16 dummyWord = 0;
|
|
|
|
uint32 dummyLong = 0;
|
|
|
|
|
|
|
|
if (s.isSaving()) {
|
|
|
|
// Figure out the number of entries to save
|
|
|
|
pl = backgroundIncrustHead.next;
|
|
|
|
while (pl) {
|
|
|
|
++numEntries;
|
|
|
|
pl = pl->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
s.syncAsSint16LE(numEntries);
|
|
|
|
|
|
|
|
pl = s.isSaving() ? backgroundIncrustHead.next : &backgroundIncrustHead;
|
|
|
|
pl1 = &backgroundIncrustHead;
|
|
|
|
|
|
|
|
for (int i = 0; i < numEntries; ++i) {
|
|
|
|
backgroundIncrustStruct *t = s.isSaving() ? pl :
|
|
|
|
(backgroundIncrustStruct *)mallocAndZero(sizeof(backgroundIncrustStruct));
|
|
|
|
|
|
|
|
s.syncAsUint32LE(dummyLong);
|
|
|
|
|
|
|
|
s.syncAsSint16LE(t->objectIdx);
|
|
|
|
s.syncAsSint16LE(t->type);
|
|
|
|
s.syncAsSint16LE(t->overlayIdx);
|
|
|
|
s.syncAsSint16LE(t->X);
|
|
|
|
s.syncAsSint16LE(t->Y);
|
2009-05-16 04:03:37 +00:00
|
|
|
s.syncAsSint16LE(t->frame);
|
2009-02-09 11:30:18 +00:00
|
|
|
s.syncAsSint16LE(t->scale);
|
|
|
|
s.syncAsSint16LE(t->backgroundIdx);
|
|
|
|
s.syncAsSint16LE(t->scriptNumber);
|
|
|
|
s.syncAsSint16LE(t->scriptOverlayIdx);
|
|
|
|
s.syncAsUint32LE(dummyLong);
|
2009-05-15 07:03:56 +00:00
|
|
|
s.syncAsSint16LE(t->saveWidth);
|
2009-02-09 11:30:18 +00:00
|
|
|
s.syncAsSint16LE(t->saveHeight);
|
|
|
|
s.syncAsSint16LE(t->saveSize);
|
|
|
|
s.syncAsSint16LE(t->savedX);
|
|
|
|
s.syncAsSint16LE(t->savedY);
|
2009-05-19 11:23:13 +00:00
|
|
|
s.syncBytes((byte *)t->name, 13);
|
2009-02-09 11:30:18 +00:00
|
|
|
s.syncAsByte(dummyByte);
|
|
|
|
s.syncAsSint16LE(t->spriteId);
|
|
|
|
s.syncAsUint16LE(dummyWord);
|
|
|
|
|
|
|
|
if (t->saveSize) {
|
2009-05-15 06:46:56 +00:00
|
|
|
if (s.isLoading())
|
2009-10-09 08:15:30 +00:00
|
|
|
t->ptr = (byte *)MemAlloc(t->saveSize);
|
2009-05-15 06:46:56 +00:00
|
|
|
|
|
|
|
s.syncBytes(t->ptr, t->saveSize);
|
2009-02-09 11:30:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (s.isSaving())
|
|
|
|
pl = pl->next;
|
|
|
|
else {
|
|
|
|
t->next = NULL;
|
|
|
|
pl->next = t;
|
|
|
|
t->prev = pl1->prev;
|
|
|
|
pl1->prev = t;
|
|
|
|
pl = t;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-03-16 09:17:49 +00:00
|
|
|
static void syncActors(Common::Serializer &s) {
|
2009-02-09 11:30:18 +00:00
|
|
|
int numEntries = 0;
|
|
|
|
actorStruct *ptr;
|
|
|
|
uint16 dummyLong = 0;
|
|
|
|
|
|
|
|
if (s.isSaving()) {
|
|
|
|
ptr = actorHead.next;
|
|
|
|
while (ptr) {
|
|
|
|
++numEntries;
|
|
|
|
ptr = ptr->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
s.syncAsSint16LE(numEntries);
|
|
|
|
|
|
|
|
ptr = s.isSaving() ? actorHead.next : &actorHead;
|
|
|
|
for (int i = 0; i < numEntries; ++i) {
|
|
|
|
actorStruct *p = s.isSaving() ? ptr : (actorStruct *)mallocAndZero(sizeof(actorStruct));
|
|
|
|
|
|
|
|
s.syncAsUint32LE(dummyLong);
|
|
|
|
s.syncAsSint16LE(p->idx);
|
|
|
|
s.syncAsSint16LE(p->type);
|
|
|
|
s.syncAsSint16LE(p->overlayNumber);
|
|
|
|
s.syncAsSint16LE(p->x_dest);
|
|
|
|
s.syncAsSint16LE(p->y_dest);
|
|
|
|
s.syncAsSint16LE(p->x);
|
|
|
|
s.syncAsSint16LE(p->y);
|
|
|
|
s.syncAsSint16LE(p->startDirection);
|
|
|
|
s.syncAsSint16LE(p->nextDirection);
|
|
|
|
s.syncAsSint16LE(p->endDirection);
|
|
|
|
s.syncAsSint16LE(p->stepX);
|
|
|
|
s.syncAsSint16LE(p->stepY);
|
|
|
|
s.syncAsSint16LE(p->pathId);
|
|
|
|
s.syncAsSint16LE(p->phase);
|
|
|
|
s.syncAsSint16LE(p->counter);
|
|
|
|
s.syncAsSint16LE(p->poly);
|
|
|
|
s.syncAsSint16LE(p->flag);
|
|
|
|
s.syncAsSint16LE(p->start);
|
|
|
|
s.syncAsSint16LE(p->freeze);
|
|
|
|
|
|
|
|
if (s.isSaving())
|
|
|
|
ptr = ptr->next;
|
|
|
|
else {
|
|
|
|
p->next = NULL;
|
|
|
|
ptr->next = p;
|
|
|
|
p->prev = actorHead.prev;
|
|
|
|
actorHead.prev = p;
|
|
|
|
ptr = p->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-03-16 09:17:49 +00:00
|
|
|
static void syncSongs(Common::Serializer &s) {
|
2009-02-09 11:30:18 +00:00
|
|
|
int size = 0;
|
|
|
|
|
|
|
|
if (songLoaded) {
|
|
|
|
// TODO: implement
|
|
|
|
s.syncAsByte(size);
|
|
|
|
if (s.isLoading()) {
|
|
|
|
saveVar1 = size;
|
|
|
|
if (saveVar1)
|
|
|
|
s.syncBytes(saveVar2, saveVar1);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
s.syncAsByte(size);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-06-01 03:27:54 +00:00
|
|
|
static void syncPerso(Common::Serializer &s, persoStruct &p) {
|
|
|
|
s.syncAsSint16LE(p.inc_droite);
|
|
|
|
s.syncAsSint16LE(p.inc_droite0);
|
|
|
|
s.syncAsSint16LE(p.inc_chemin);
|
|
|
|
|
|
|
|
for (int i = 0; i < 400; ++i) {
|
|
|
|
s.syncAsSint16LE(p.coordinates[i].x);
|
|
|
|
s.syncAsSint16LE(p.coordinates[i].y);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 0; i < NUM_NODES + 3; ++i) {
|
|
|
|
s.syncAsSint16LE(p.solution[i][0]);
|
|
|
|
s.syncAsSint16LE(p.solution[i][1]);
|
|
|
|
}
|
2010-01-25 01:39:44 +00:00
|
|
|
|
2009-06-01 03:27:54 +00:00
|
|
|
s.syncAsSint16LE(p.inc_jo1);
|
|
|
|
s.syncAsSint16LE(p.inc_jo2);
|
|
|
|
s.syncAsSint16LE(p.dir_perso);
|
|
|
|
s.syncAsSint16LE(p.inc_jo0);
|
|
|
|
}
|
|
|
|
|
2009-03-16 09:17:49 +00:00
|
|
|
static void syncCT(Common::Serializer &s) {
|
2010-08-09 10:30:40 +00:00
|
|
|
int v = (_vm->_polyStruct) ? 1 : 0;
|
2009-02-09 11:30:18 +00:00
|
|
|
s.syncAsSint32LE(v);
|
2009-05-28 08:49:56 +00:00
|
|
|
if (s.isLoading())
|
2010-08-09 10:30:40 +00:00
|
|
|
_vm->_polyStruct = (v != 0) ? &_vm->_polyStructNorm : NULL;
|
2009-02-09 11:30:18 +00:00
|
|
|
|
|
|
|
if (v == 0)
|
|
|
|
// There is no further data to load or save
|
|
|
|
return;
|
|
|
|
|
|
|
|
s.syncAsSint16LE(numberOfWalkboxes);
|
|
|
|
|
|
|
|
if (numberOfWalkboxes) {
|
|
|
|
for (int i = 0; i < numberOfWalkboxes; ++i)
|
|
|
|
s.syncAsSint16LE(walkboxColor[i]);
|
|
|
|
for (int i = 0; i < numberOfWalkboxes; ++i)
|
|
|
|
s.syncAsSint16LE(walkboxState[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 0; i < 10; i++) {
|
|
|
|
v = 0;
|
|
|
|
if (s.isSaving()) v = (persoTable[i]) ? 1 : 0;
|
|
|
|
s.syncAsSint32LE(v);
|
|
|
|
|
|
|
|
if (s.isLoading())
|
|
|
|
// Set up the pointer for the next structure
|
|
|
|
persoTable[i] = (v == 0) ? NULL : (persoStruct *)mallocAndZero(sizeof(persoStruct));
|
|
|
|
|
2009-06-01 03:27:54 +00:00
|
|
|
if (v != 0)
|
|
|
|
syncPerso(s, *persoTable[i]);
|
2009-02-09 11:30:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-03-16 09:17:49 +00:00
|
|
|
static void DoSync(Common::Serializer &s) {
|
2009-02-09 11:30:18 +00:00
|
|
|
syncBasicInfo(s);
|
2009-06-14 03:39:30 +00:00
|
|
|
_vm->sound().doSync(s);
|
2009-02-09 11:30:18 +00:00
|
|
|
|
|
|
|
syncPalette(s, newPal);
|
|
|
|
syncPalette(s, workpal);
|
|
|
|
|
2009-05-19 11:23:13 +00:00
|
|
|
s.syncBytes((byte *)currentCtpName, 40);
|
2009-02-09 11:30:18 +00:00
|
|
|
|
|
|
|
syncBackgroundTable(s);
|
|
|
|
syncPalScreen(s);
|
|
|
|
syncSoundList(s);
|
2009-05-24 15:17:42 +00:00
|
|
|
|
2009-02-09 11:30:18 +00:00
|
|
|
for (int i = 0; i < stateID; ++i)
|
|
|
|
s.syncAsSint16LE(globalVars[i]);
|
|
|
|
|
|
|
|
syncFilesDatabase(s);
|
|
|
|
syncOverlays1(s);
|
|
|
|
syncPreloadData(s);
|
|
|
|
syncOverlays2(s);
|
|
|
|
syncScript(s, &procHead);
|
|
|
|
syncScript(s, &relHead);
|
|
|
|
syncCell(s);
|
|
|
|
syncIncrust(s);
|
|
|
|
syncActors(s);
|
|
|
|
syncSongs(s);
|
|
|
|
syncCT(s);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-01-16 02:43:41 +00:00
|
|
|
void resetPreload() {
|
|
|
|
for (unsigned long int i = 0; i < 64; i++) {
|
|
|
|
if (strlen(preloadData[i].name)) {
|
|
|
|
if (preloadData[i].ptr) {
|
2009-10-09 08:15:30 +00:00
|
|
|
MemFree(preloadData[i].ptr);
|
2007-12-18 20:12:42 +00:00
|
|
|
preloadData[i].ptr = NULL;
|
|
|
|
}
|
|
|
|
strcpy(preloadData[i].name, "");
|
|
|
|
preloadData[i].nofree = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-16 02:43:41 +00:00
|
|
|
void unloadOverlay(const char*name, int overlayNumber) {
|
2007-12-18 20:12:42 +00:00
|
|
|
releaseOverlay(name);
|
|
|
|
|
|
|
|
strcpy(overlayTable[overlayNumber].overlayName, "");
|
|
|
|
overlayTable[overlayNumber].ovlData = NULL;
|
|
|
|
overlayTable[overlayNumber].alreadyLoaded = 0;
|
|
|
|
}
|
|
|
|
|
2009-11-02 21:54:57 +00:00
|
|
|
void initVars() {
|
2007-12-18 20:12:42 +00:00
|
|
|
closeAllMenu();
|
2009-04-04 01:21:25 +00:00
|
|
|
resetFileEntryRange(0, NUM_FILE_ENTRIES);
|
2007-12-18 20:12:42 +00:00
|
|
|
|
|
|
|
resetPreload();
|
|
|
|
freeCTP();
|
2009-10-10 05:08:56 +00:00
|
|
|
freeBackgroundIncrustList(&backgroundIncrustHead);
|
2007-12-18 20:12:42 +00:00
|
|
|
|
|
|
|
freezeCell(&cellHead, -1, -1, -1, -1, -1, 0);
|
|
|
|
// TODO: unfreeze anims
|
|
|
|
|
|
|
|
freeObjectList(&cellHead);
|
|
|
|
removeAnimation(&actorHead, -1, -1, -1);
|
|
|
|
|
2009-10-10 05:08:56 +00:00
|
|
|
removeAllScripts(&relHead);
|
|
|
|
removeAllScripts(&procHead);
|
2007-12-18 20:12:42 +00:00
|
|
|
changeScriptParamInList(-1, -1, &procHead, -1, 0);
|
|
|
|
removeFinishedScripts(&procHead);
|
|
|
|
|
|
|
|
changeScriptParamInList(-1, -1, &relHead, -1, 0);
|
|
|
|
removeFinishedScripts(&relHead);
|
|
|
|
|
2009-01-16 02:43:41 +00:00
|
|
|
for (unsigned long int i = 0; i < 90; i++) {
|
|
|
|
if (strlen(overlayTable[i].overlayName) && overlayTable[i].alreadyLoaded) {
|
2007-12-18 20:12:42 +00:00
|
|
|
unloadOverlay(overlayTable[i].overlayName, i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO:
|
|
|
|
// stopSound();
|
|
|
|
// removeSound();
|
|
|
|
|
|
|
|
closeBase();
|
|
|
|
closeCnf();
|
|
|
|
|
|
|
|
initOverlayTable();
|
|
|
|
|
|
|
|
stateID = 0;
|
2007-12-24 16:57:14 +00:00
|
|
|
masterScreen = 0;
|
2007-12-18 20:12:42 +00:00
|
|
|
|
|
|
|
freeDisk();
|
|
|
|
|
2009-02-09 11:30:18 +00:00
|
|
|
soundList[0].frameNum = -1;
|
|
|
|
soundList[1].frameNum = -1;
|
|
|
|
soundList[2].frameNum = -1;
|
|
|
|
soundList[3].frameNum = -1;
|
2007-12-18 20:12:42 +00:00
|
|
|
|
|
|
|
for (unsigned long int i = 0; i < 8; i++) {
|
|
|
|
menuTable[i] = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (unsigned long int i = 0; i < 2000; i++) {
|
|
|
|
globalVars[i] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (unsigned long int i = 0; i < 8; i++) {
|
|
|
|
backgroundTable[i].name[0] = 0;
|
|
|
|
}
|
|
|
|
|
2009-04-04 01:21:25 +00:00
|
|
|
for (unsigned long int i = 0; i < NUM_FILE_ENTRIES; i++) {
|
2007-12-18 20:12:42 +00:00
|
|
|
filesDatabase[i].subData.ptr = NULL;
|
|
|
|
filesDatabase[i].subData.ptrMask = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
initBigVar3();
|
|
|
|
|
|
|
|
resetPtr2(&procHead);
|
|
|
|
resetPtr2(&relHead);
|
|
|
|
|
|
|
|
resetPtr(&cellHead);
|
|
|
|
|
|
|
|
resetActorPtr(&actorHead);
|
|
|
|
resetBackgroundIncrustList(&backgroundIncrustHead);
|
|
|
|
|
|
|
|
vblLimit = 0;
|
|
|
|
remdo = 0;
|
|
|
|
songLoaded = 0;
|
|
|
|
songPlayed = 0;
|
|
|
|
songLoop = 1;
|
|
|
|
activeMouse = 0;
|
|
|
|
userEnabled = 1;
|
|
|
|
dialogueEnabled = 0;
|
|
|
|
dialogueOvl = 0;
|
|
|
|
dialogueObj = 0;
|
|
|
|
userDelay = 0;
|
|
|
|
sysKey = -1;
|
|
|
|
sysX = 0;
|
|
|
|
sysY = 0;
|
|
|
|
automoveInc = 0;
|
|
|
|
automoveMax = 0;
|
|
|
|
displayOn = true;
|
|
|
|
|
|
|
|
// here used to init clip
|
|
|
|
|
|
|
|
isMessage = 0;
|
|
|
|
fadeFlag = 0;
|
|
|
|
automaticMode = 0;
|
|
|
|
|
|
|
|
// video param (vga and mcga mode)
|
|
|
|
|
|
|
|
titleColor = 2;
|
|
|
|
itemColor = 1;
|
|
|
|
selectColor = 3;
|
|
|
|
subColor = 5;
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
narratorOvl = 0;
|
|
|
|
narratorIdx = 0;
|
|
|
|
aniX = 0;
|
|
|
|
aniY = 0;
|
|
|
|
animationStart = false;
|
|
|
|
selectDown = 0;
|
|
|
|
menuDown = 0;
|
|
|
|
buttonDown = 0;
|
|
|
|
var41 = 0;
|
2009-04-18 10:16:08 +00:00
|
|
|
playerMenuEnabled = 0;
|
2007-12-24 01:05:36 +00:00
|
|
|
PCFadeFlag = 0;
|
2007-12-18 20:12:42 +00:00
|
|
|
}
|
|
|
|
|
2009-04-18 10:16:08 +00:00
|
|
|
Common::Error saveSavegameData(int saveGameIdx, const Common::String &saveName) {
|
|
|
|
const char *filename = _vm->getSavegameFile(saveGameIdx);
|
2007-12-20 14:30:51 +00:00
|
|
|
Common::SaveFileManager *saveMan = g_system->getSavefileManager();
|
2009-04-18 10:16:08 +00:00
|
|
|
Common::OutSaveFile *f = saveMan->openForSaving(filename);
|
2009-02-09 11:30:18 +00:00
|
|
|
if (f == NULL)
|
2009-04-18 10:16:08 +00:00
|
|
|
return Common::kNoGameDataFoundError;
|
2007-12-20 14:30:51 +00:00
|
|
|
|
2009-04-18 10:16:08 +00:00
|
|
|
// Save the savegame header
|
|
|
|
CruiseSavegameHeader header;
|
|
|
|
header.saveName = saveName;
|
|
|
|
writeSavegameHeader(f, header);
|
2007-12-20 14:30:51 +00:00
|
|
|
|
2009-05-19 11:42:14 +00:00
|
|
|
if (f->err()) {
|
2009-04-18 10:16:08 +00:00
|
|
|
delete f;
|
|
|
|
saveMan->removeSavefile(filename);
|
|
|
|
return Common::kWritingFailed;
|
|
|
|
} else {
|
|
|
|
// Create the remainder of the savegame
|
2009-03-16 09:17:49 +00:00
|
|
|
Common::Serializer s(NULL, f);
|
2009-02-09 11:30:18 +00:00
|
|
|
DoSync(s);
|
2007-12-20 14:30:51 +00:00
|
|
|
|
2009-02-09 11:30:18 +00:00
|
|
|
f->finalize();
|
|
|
|
delete f;
|
2009-04-18 10:16:08 +00:00
|
|
|
return Common::kNoError;
|
2007-12-20 14:30:51 +00:00
|
|
|
}
|
2007-12-18 20:12:42 +00:00
|
|
|
}
|
|
|
|
|
2009-04-18 10:16:08 +00:00
|
|
|
Common::Error loadSavegameData(int saveGameIdx) {
|
2007-12-18 20:12:42 +00:00
|
|
|
int lowMemorySave;
|
2009-04-18 10:16:08 +00:00
|
|
|
Common::String saveName;
|
2007-04-27 22:33:45 +00:00
|
|
|
cellStruct *currentcellHead;
|
|
|
|
|
2007-12-20 14:30:51 +00:00
|
|
|
Common::SaveFileManager *saveMan = g_system->getSavefileManager();
|
2009-04-18 10:16:08 +00:00
|
|
|
Common::InSaveFile *f = saveMan->openForLoading(_vm->getSavegameFile(saveGameIdx));
|
2007-04-27 22:33:45 +00:00
|
|
|
|
2009-02-09 11:30:18 +00:00
|
|
|
if (f == NULL) {
|
2007-07-01 12:47:07 +00:00
|
|
|
printInfoBlackBox("Savegame not found...");
|
2007-04-27 22:33:45 +00:00
|
|
|
waitForPlayerInput();
|
2009-04-18 10:16:08 +00:00
|
|
|
return Common::kNoGameDataFoundError;
|
2007-04-27 22:33:45 +00:00
|
|
|
}
|
|
|
|
|
2007-07-01 12:47:07 +00:00
|
|
|
printInfoBlackBox("Loading in progress...");
|
2007-04-27 22:33:45 +00:00
|
|
|
|
2009-02-09 11:30:18 +00:00
|
|
|
initVars();
|
2009-06-20 08:15:01 +00:00
|
|
|
_vm->sound().stopMusic();
|
2007-11-08 22:59:29 +00:00
|
|
|
|
2009-04-18 10:16:08 +00:00
|
|
|
// Skip over the savegame header
|
|
|
|
CruiseSavegameHeader header;
|
|
|
|
readSavegameHeader(f, header);
|
2010-01-03 19:37:43 +00:00
|
|
|
delete header.thumbnail;
|
2009-04-18 10:16:08 +00:00
|
|
|
|
|
|
|
// Synchronise the remaining data of the savegame
|
2009-03-16 09:17:49 +00:00
|
|
|
Common::Serializer s(f, NULL);
|
2009-02-09 11:30:18 +00:00
|
|
|
DoSync(s);
|
2007-11-08 22:59:29 +00:00
|
|
|
|
2009-02-09 11:30:18 +00:00
|
|
|
delete f;
|
2007-11-08 22:59:29 +00:00
|
|
|
|
2009-02-09 11:30:18 +00:00
|
|
|
// Post processing
|
2007-11-08 22:59:29 +00:00
|
|
|
|
2009-02-09 11:30:18 +00:00
|
|
|
for (int j = 0; j < 64; j++)
|
2007-12-18 20:12:42 +00:00
|
|
|
preloadData[j].ptr = NULL;
|
2007-04-27 22:33:45 +00:00
|
|
|
|
2007-11-08 22:59:29 +00:00
|
|
|
for (int j = 1; j < numOfLoadedOverlay; j++) {
|
2007-04-27 22:33:45 +00:00
|
|
|
if (overlayTable[j].alreadyLoaded) {
|
|
|
|
overlayTable[j].alreadyLoaded = 0;
|
2007-11-10 17:15:48 +00:00
|
|
|
loadOverlay(overlayTable[j].overlayName);
|
2007-04-27 22:33:45 +00:00
|
|
|
|
|
|
|
if (overlayTable[j].alreadyLoaded) {
|
2007-11-08 22:59:29 +00:00
|
|
|
ovlDataStruct *ovlData = overlayTable[j].ovlData;
|
2007-04-27 22:33:45 +00:00
|
|
|
|
2007-11-10 19:47:07 +00:00
|
|
|
// overlay BSS
|
|
|
|
|
|
|
|
if (ovlRestoreData[j]._sBssSize) {
|
2007-04-27 22:33:45 +00:00
|
|
|
if (ovlData->data4Ptr) {
|
2009-10-09 08:15:30 +00:00
|
|
|
MemFree(ovlData->data4Ptr);
|
2007-04-27 22:33:45 +00:00
|
|
|
}
|
|
|
|
|
2007-11-10 19:47:07 +00:00
|
|
|
ovlData->data4Ptr = ovlRestoreData[j]._pBss;
|
|
|
|
ovlData->sizeOfData4 = ovlRestoreData[j]._sBssSize;
|
2007-04-27 22:33:45 +00:00
|
|
|
}
|
|
|
|
|
2007-11-10 19:47:07 +00:00
|
|
|
// overlay object data
|
|
|
|
|
|
|
|
if (ovlRestoreData[j]._sNumObj) {
|
2007-10-28 17:40:04 +00:00
|
|
|
if (ovlData->arrayObjVar) {
|
2009-10-09 08:15:30 +00:00
|
|
|
MemFree(ovlData->arrayObjVar);
|
2007-04-27 22:33:45 +00:00
|
|
|
}
|
|
|
|
|
2007-11-10 19:47:07 +00:00
|
|
|
ovlData->arrayObjVar = ovlRestoreData[j]._pObj;
|
|
|
|
ovlData->size9 = ovlRestoreData[j]._sNumObj;
|
2007-04-27 22:33:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
updateAllScriptsImports();
|
|
|
|
|
2007-11-10 17:15:48 +00:00
|
|
|
lastAni[0] = 0;
|
2007-04-27 22:33:45 +00:00
|
|
|
|
2007-12-18 20:12:42 +00:00
|
|
|
lowMemorySave = lowMemory;
|
2007-04-27 22:33:45 +00:00
|
|
|
|
2009-04-04 01:21:25 +00:00
|
|
|
for (int i = 0; i < NUM_FILE_ENTRIES; i++) {
|
2007-11-10 17:15:48 +00:00
|
|
|
if (filesDatabase[i].subData.ptr) {
|
|
|
|
int j;
|
2007-04-27 22:33:45 +00:00
|
|
|
int k;
|
|
|
|
|
2009-04-04 01:21:25 +00:00
|
|
|
for (j = i + 1; j < NUM_FILE_ENTRIES && filesDatabase[j].subData.ptr && !strcmp(filesDatabase[i].subData.name, filesDatabase[j].subData.name) && (filesDatabase[j].subData.index == (j - i)); j++)
|
2009-01-29 05:26:12 +00:00
|
|
|
;
|
2007-04-27 22:33:45 +00:00
|
|
|
|
2007-11-10 17:15:48 +00:00
|
|
|
for (k = i; k < j; k++) {
|
2007-11-05 20:24:20 +00:00
|
|
|
if (filesDatabase[k].subData.ptrMask)
|
2007-12-18 20:12:42 +00:00
|
|
|
lowMemory = 0;
|
2007-04-27 22:33:45 +00:00
|
|
|
|
|
|
|
filesDatabase[k].subData.ptr = NULL;
|
2007-11-05 20:24:20 +00:00
|
|
|
filesDatabase[k].subData.ptrMask = NULL;
|
2007-04-27 22:33:45 +00:00
|
|
|
}
|
|
|
|
|
2007-12-20 14:30:51 +00:00
|
|
|
/*if (j < 2) {
|
2010-11-07 01:03:58 +00:00
|
|
|
error("Unsupported mono file load");
|
2007-04-27 22:33:45 +00:00
|
|
|
//loadFileMode1(filesDatabase[j].subData.name,filesDatabase[j].subData.var4);
|
2009-07-03 06:19:20 +00:00
|
|
|
} else */
|
2010-01-25 01:39:44 +00:00
|
|
|
if (strlen(filesDatabase[i].subData.name) > 0) {
|
2007-11-10 17:15:48 +00:00
|
|
|
loadFileRange(filesDatabase[i].subData.name, filesDatabase[i].subData.index, i, j - i);
|
2009-07-03 06:19:20 +00:00
|
|
|
} else {
|
|
|
|
filesDatabase[i].subData.ptr = NULL;
|
|
|
|
filesDatabase[i].subData.ptrMask = NULL;
|
2007-04-27 22:33:45 +00:00
|
|
|
}
|
|
|
|
|
2009-07-03 06:19:20 +00:00
|
|
|
i = j - 1;
|
2007-12-18 20:12:42 +00:00
|
|
|
lowMemory = lowMemorySave;
|
2007-04-27 22:33:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-11-10 17:15:48 +00:00
|
|
|
lastAni[0] = 0;
|
2007-04-27 22:33:45 +00:00
|
|
|
|
|
|
|
currentcellHead = cellHead.next;
|
|
|
|
|
|
|
|
while (currentcellHead) {
|
|
|
|
if (currentcellHead->type == 5) {
|
2007-11-10 17:15:48 +00:00
|
|
|
uint8 *ptr = mainProc14(currentcellHead->overlay, currentcellHead->idx);
|
2007-04-27 22:33:45 +00:00
|
|
|
|
|
|
|
ASSERT(0);
|
|
|
|
|
|
|
|
if (ptr) {
|
|
|
|
ASSERT(0);
|
2012-02-15 15:53:31 +00:00
|
|
|
//*(int16 *)(currentcellHead->datas+0x2E) = getSprite(ptr,*(int16 *)(currentcellHead->datas+0xE));
|
2007-04-27 22:33:45 +00:00
|
|
|
} else {
|
2007-11-10 17:15:48 +00:00
|
|
|
ASSERT(0);
|
2012-02-15 15:53:31 +00:00
|
|
|
//*(int16 *)(currentcellHead->datas+0x2E) = 0;
|
2007-04-27 22:33:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
currentcellHead = currentcellHead->next;
|
|
|
|
}
|
|
|
|
|
2007-11-10 17:15:48 +00:00
|
|
|
if (strlen(currentCtpName)) {
|
2007-12-27 12:05:43 +00:00
|
|
|
loadCtFromSave = 1;
|
|
|
|
initCt(currentCtpName);
|
|
|
|
loadCtFromSave = 0;
|
2007-04-27 22:33:45 +00:00
|
|
|
}
|
|
|
|
//prepareFadeOut();
|
|
|
|
//gfxModuleData.gfxFunction8();
|
|
|
|
|
2007-11-08 22:59:29 +00:00
|
|
|
for (int j = 0; j < 8; j++) {
|
2007-04-27 22:33:45 +00:00
|
|
|
if (strlen((char *)backgroundTable[j].name)) {
|
|
|
|
loadBackground(backgroundTable[j].name, j);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-02-09 11:30:18 +00:00
|
|
|
regenerateBackgroundIncrust(&backgroundIncrustHead);
|
2007-04-27 22:33:45 +00:00
|
|
|
|
|
|
|
// to finish
|
|
|
|
|
2007-10-28 13:21:01 +00:00
|
|
|
changeCursor(CURSOR_NORMAL);
|
2007-04-27 22:33:45 +00:00
|
|
|
mainDraw(1);
|
|
|
|
flipScreen();
|
|
|
|
|
2009-04-18 10:16:08 +00:00
|
|
|
return Common::kNoError;
|
2007-04-27 12:58:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // End of namespace Cruise
|