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.
|
|
|
|
*
|
|
|
|
* $URL$
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "cruise/cruise_main.h"
|
|
|
|
|
2007-12-20 14:30:51 +00:00
|
|
|
#include "common/savefile.h"
|
|
|
|
#include "common/system.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];
|
|
|
|
|
2007-12-18 20:12:42 +00:00
|
|
|
void resetPreload()
|
|
|
|
{
|
|
|
|
for(unsigned long int i=0; i<64; i++)
|
|
|
|
{
|
|
|
|
if(strlen(preloadData[i].name))
|
|
|
|
{
|
|
|
|
if(preloadData[i].ptr)
|
|
|
|
{
|
|
|
|
free(preloadData[i].ptr);
|
|
|
|
preloadData[i].ptr = NULL;
|
|
|
|
}
|
|
|
|
strcpy(preloadData[i].name, "");
|
|
|
|
preloadData[i].nofree = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void unloadOverlay(const char*name, int overlayNumber)
|
|
|
|
{
|
|
|
|
releaseOverlay(name);
|
|
|
|
|
|
|
|
strcpy(overlayTable[overlayNumber].overlayName, "");
|
|
|
|
overlayTable[overlayNumber].ovlData = NULL;
|
|
|
|
overlayTable[overlayNumber].alreadyLoaded = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void initVars(void)
|
|
|
|
{
|
|
|
|
closeAllMenu();
|
|
|
|
resetFileEntryRange( 0, 257 );
|
|
|
|
|
|
|
|
resetPreload();
|
|
|
|
freeCTP();
|
|
|
|
|
|
|
|
freezeCell(&cellHead, -1, -1, -1, -1, -1, 0);
|
|
|
|
// TODO: unfreeze anims
|
|
|
|
|
|
|
|
freeObjectList(&cellHead);
|
|
|
|
removeAnimation(&actorHead, -1, -1, -1);
|
|
|
|
|
|
|
|
changeScriptParamInList(-1, -1, &procHead, -1, 0);
|
|
|
|
removeFinishedScripts(&procHead);
|
|
|
|
|
|
|
|
changeScriptParamInList(-1, -1, &relHead, -1, 0);
|
|
|
|
removeFinishedScripts(&relHead);
|
|
|
|
|
|
|
|
for(unsigned long int i=0; i<90; i++)
|
|
|
|
{
|
|
|
|
if(strlen(overlayTable[i].overlayName) && overlayTable[i].alreadyLoaded)
|
|
|
|
{
|
|
|
|
unloadOverlay(overlayTable[i].overlayName, i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO:
|
|
|
|
// stopSound();
|
|
|
|
// removeSound();
|
|
|
|
|
|
|
|
closeBase();
|
|
|
|
closeCnf();
|
|
|
|
|
|
|
|
initOverlayTable();
|
|
|
|
|
|
|
|
stateID = 0;
|
|
|
|
currentActiveBackgroundPlane = 0;
|
|
|
|
|
|
|
|
freeDisk();
|
|
|
|
|
|
|
|
initVar5[0] = -1;
|
|
|
|
initVar5[3] = -1;
|
|
|
|
initVar5[6] = -1;
|
|
|
|
initVar5[9] = -1;
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (unsigned long int i = 0; i < 257; i++) {
|
|
|
|
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;
|
|
|
|
playMusic = 0;
|
|
|
|
playMusic2 = 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;
|
|
|
|
entrerMenuJoueur = 0;
|
|
|
|
fadeVar = 0;
|
|
|
|
}
|
|
|
|
|
2007-12-20 14:30:51 +00:00
|
|
|
void saveOverlay(Common::OutSaveFile& currentSaveFile) {
|
|
|
|
|
|
|
|
for (int i = 1; i < numOfLoadedOverlay; i++) {
|
|
|
|
if(overlayTable[i].alreadyLoaded) {
|
|
|
|
|
|
|
|
ovlDataStruct* ovlData = overlayTable[i].ovlData;
|
|
|
|
|
|
|
|
// save BSS
|
|
|
|
currentSaveFile.writeSint16LE(ovlData->sizeOfData4);
|
|
|
|
if(ovlData->sizeOfData4)
|
|
|
|
currentSaveFile.write(ovlData->data4Ptr, ovlData->sizeOfData4);
|
|
|
|
|
|
|
|
// save variables
|
|
|
|
currentSaveFile.writeSint16LE(ovlData->size9);
|
|
|
|
for(int j=0; j<ovlData->size9; j++) {
|
|
|
|
currentSaveFile.writeSint16LE(ovlData->arrayObjVar[j].X);
|
|
|
|
currentSaveFile.writeSint16LE(ovlData->arrayObjVar[j].Y);
|
|
|
|
currentSaveFile.writeSint16LE(ovlData->arrayObjVar[j].Z);
|
|
|
|
currentSaveFile.writeSint16LE(ovlData->arrayObjVar[j].frame);
|
|
|
|
currentSaveFile.writeSint16LE(ovlData->arrayObjVar[j].scale);
|
|
|
|
currentSaveFile.writeSint16LE(ovlData->arrayObjVar[j].state);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-04-27 22:33:45 +00:00
|
|
|
|
2007-12-20 14:30:51 +00:00
|
|
|
void loadSavegameDataSub1(Common::InSaveFile& currentSaveFile) {
|
|
|
|
|
|
|
|
for (int i = 1; i < numOfLoadedOverlay; i++) {
|
2007-11-10 19:47:07 +00:00
|
|
|
ovlRestoreData[i]._sBssSize = ovlRestoreData[i]._sNumObj = 0;
|
|
|
|
ovlRestoreData[i]._pBss = NULL;
|
|
|
|
ovlRestoreData[i]._pObj = NULL;
|
2007-04-27 22:33:45 +00:00
|
|
|
|
|
|
|
if (overlayTable[i].alreadyLoaded) {
|
2007-11-10 19:47:07 +00:00
|
|
|
ovlRestoreData[i]._sBssSize = currentSaveFile.readSint16LE();
|
2007-04-27 22:33:45 +00:00
|
|
|
|
2007-11-10 19:47:07 +00:00
|
|
|
if (ovlRestoreData[i]._sBssSize) {
|
|
|
|
ovlRestoreData[i]._pBss = (uint8 *) mallocAndZero(ovlRestoreData[i]._sBssSize);
|
|
|
|
ASSERT(ovlRestoreData[i]._pBss);
|
|
|
|
|
|
|
|
currentSaveFile.read(ovlRestoreData[i]._pBss, ovlRestoreData[i]._sBssSize);
|
2007-04-27 22:33:45 +00:00
|
|
|
}
|
|
|
|
|
2007-11-10 19:47:07 +00:00
|
|
|
ovlRestoreData[i]._sNumObj = currentSaveFile.readSint16LE();
|
2007-04-27 22:33:45 +00:00
|
|
|
|
2007-11-10 19:47:07 +00:00
|
|
|
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++)
|
|
|
|
{
|
|
|
|
ovlRestoreData[i]._pObj[j].X = currentSaveFile.readSint16LE();
|
|
|
|
ovlRestoreData[i]._pObj[j].Y = currentSaveFile.readSint16LE();
|
|
|
|
ovlRestoreData[i]._pObj[j].Z = currentSaveFile.readSint16LE();
|
|
|
|
ovlRestoreData[i]._pObj[j].frame = currentSaveFile.readSint16LE();
|
|
|
|
ovlRestoreData[i]._pObj[j].scale = currentSaveFile.readSint16LE();
|
|
|
|
ovlRestoreData[i]._pObj[j].state = currentSaveFile.readSint16LE();
|
2007-04-27 22:33:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-04-27 12:58:35 +00:00
|
|
|
}
|
|
|
|
|
2007-12-20 14:30:51 +00:00
|
|
|
void saveScript(Common::OutSaveFile& currentSaveFile, scriptInstanceStruct *entry) {
|
|
|
|
int count = 0;
|
|
|
|
|
|
|
|
scriptInstanceStruct* pCurrent = entry->nextScriptPtr;
|
|
|
|
while( pCurrent ) {
|
|
|
|
count ++;
|
|
|
|
pCurrent = pCurrent->nextScriptPtr;
|
|
|
|
}
|
|
|
|
|
|
|
|
currentSaveFile.writeSint16LE(count);
|
|
|
|
|
|
|
|
pCurrent = entry->nextScriptPtr;
|
|
|
|
while( pCurrent ) {
|
|
|
|
char dummy[4] = { 0, 0, 0, 0 };
|
|
|
|
currentSaveFile.write(dummy, 2);
|
|
|
|
|
|
|
|
currentSaveFile.writeSint16LE(pCurrent->ccr);
|
|
|
|
currentSaveFile.writeSint16LE(pCurrent->var4);
|
|
|
|
currentSaveFile.write(dummy, 4);
|
|
|
|
currentSaveFile.writeSint16LE(pCurrent->varA);
|
|
|
|
currentSaveFile.writeSint16LE(pCurrent->scriptNumber);
|
|
|
|
currentSaveFile.writeSint16LE(pCurrent->overlayNumber);
|
|
|
|
currentSaveFile.writeSint16LE(pCurrent->sysKey);
|
|
|
|
currentSaveFile.writeSint16LE(pCurrent->freeze);
|
|
|
|
currentSaveFile.writeSint16LE(pCurrent->type);
|
|
|
|
currentSaveFile.writeSint16LE(pCurrent->var16);
|
|
|
|
currentSaveFile.writeSint16LE(pCurrent->var18);
|
|
|
|
currentSaveFile.writeSint16LE(pCurrent->var1A);
|
|
|
|
|
|
|
|
currentSaveFile.writeSint16LE(pCurrent->varA);
|
|
|
|
|
|
|
|
if (pCurrent->varA) {
|
|
|
|
currentSaveFile.write(pCurrent->var6, pCurrent->varA);
|
|
|
|
}
|
|
|
|
|
|
|
|
pCurrent = pCurrent->nextScriptPtr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void loadScriptsFromSave(Common::InSaveFile& currentSaveFile, scriptInstanceStruct *entry) {
|
2007-04-27 22:33:45 +00:00
|
|
|
short int numScripts;
|
|
|
|
int i;
|
2007-04-27 12:58:35 +00:00
|
|
|
|
2007-11-08 22:59:29 +00:00
|
|
|
numScripts = currentSaveFile.readSint16LE();
|
2007-04-27 12:58:35 +00:00
|
|
|
|
2007-04-27 22:33:45 +00:00
|
|
|
for (i = 0; i < numScripts; i++) {
|
2007-11-08 22:59:29 +00:00
|
|
|
scriptInstanceStruct *ptr = (scriptInstanceStruct *)mallocAndZero(sizeof(scriptInstanceStruct));
|
2007-04-27 12:58:35 +00:00
|
|
|
|
2007-11-08 22:59:29 +00:00
|
|
|
currentSaveFile.skip(2);
|
2007-04-27 12:58:35 +00:00
|
|
|
|
2007-11-08 22:59:29 +00:00
|
|
|
ptr->ccr = currentSaveFile.readSint16LE();
|
|
|
|
ptr->var4 = currentSaveFile.readSint16LE();
|
|
|
|
currentSaveFile.skip(4);
|
|
|
|
ptr->varA = currentSaveFile.readSint16LE();
|
|
|
|
ptr->scriptNumber = currentSaveFile.readSint16LE();
|
|
|
|
ptr->overlayNumber = currentSaveFile.readSint16LE();
|
|
|
|
ptr->sysKey = currentSaveFile.readSint16LE();
|
|
|
|
ptr->freeze = currentSaveFile.readSint16LE();
|
|
|
|
ptr->type = (scriptTypeEnum)currentSaveFile.readSint16LE();
|
|
|
|
ptr->var16 = currentSaveFile.readSint16LE();
|
|
|
|
ptr->var18 = currentSaveFile.readSint16LE();
|
|
|
|
ptr->var1A = currentSaveFile.readSint16LE();
|
|
|
|
|
|
|
|
ptr->varA = currentSaveFile.readUint16LE();
|
2007-04-27 12:58:35 +00:00
|
|
|
|
2007-04-27 22:33:45 +00:00
|
|
|
if (ptr->varA) {
|
|
|
|
ptr->var6 = (uint8 *) mallocAndZero(ptr->varA);
|
2007-04-27 12:58:35 +00:00
|
|
|
|
2007-11-08 22:59:29 +00:00
|
|
|
currentSaveFile.read(ptr->var6, ptr->varA);
|
2007-04-27 22:33:45 +00:00
|
|
|
}
|
2007-04-27 12:58:35 +00:00
|
|
|
|
2007-04-27 22:33:45 +00:00
|
|
|
ptr->nextScriptPtr = 0;
|
2007-04-27 12:58:35 +00:00
|
|
|
|
2007-04-27 22:33:45 +00:00
|
|
|
entry->nextScriptPtr = ptr;
|
|
|
|
entry = ptr;
|
|
|
|
}
|
2007-04-27 12:58:35 +00:00
|
|
|
}
|
|
|
|
|
2007-12-20 14:30:51 +00:00
|
|
|
void saveAnim(Common::OutSaveFile& currentSaveFile) {
|
|
|
|
int count = 0;
|
|
|
|
|
|
|
|
actorStruct *ptr = actorHead.next;
|
|
|
|
while(ptr) {
|
|
|
|
count ++;
|
|
|
|
ptr = ptr->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
currentSaveFile.writeSint16LE(count);
|
|
|
|
|
|
|
|
ptr = actorHead.next;
|
|
|
|
while(ptr) {
|
|
|
|
char dummy[2] = {0, 0};
|
|
|
|
currentSaveFile.write(dummy, 2);
|
|
|
|
currentSaveFile.write(dummy, 2);
|
|
|
|
|
|
|
|
currentSaveFile.writeSint16LE(ptr->idx);
|
|
|
|
currentSaveFile.writeSint16LE(ptr->type);
|
|
|
|
currentSaveFile.writeSint16LE(ptr->overlayNumber);
|
|
|
|
currentSaveFile.writeSint16LE(ptr->x_dest);
|
|
|
|
currentSaveFile.writeSint16LE(ptr->y_dest);
|
|
|
|
currentSaveFile.writeSint16LE(ptr->x);
|
|
|
|
currentSaveFile.writeSint16LE(ptr->y);
|
|
|
|
currentSaveFile.writeSint16LE(ptr->startDirection);
|
|
|
|
currentSaveFile.writeSint16LE(ptr->nextDirection);
|
|
|
|
currentSaveFile.writeSint16LE(ptr->endDirection);
|
|
|
|
currentSaveFile.writeSint16LE(ptr->stepX);
|
|
|
|
currentSaveFile.writeSint16LE(ptr->stepY);
|
|
|
|
currentSaveFile.writeSint16LE(ptr->pathId);
|
|
|
|
currentSaveFile.writeSint16LE(ptr->phase);
|
|
|
|
currentSaveFile.writeSint16LE(ptr->counter);
|
|
|
|
currentSaveFile.writeSint16LE(ptr->poly);
|
|
|
|
currentSaveFile.writeSint16LE(ptr->flag);
|
|
|
|
currentSaveFile.writeSint16LE(ptr->start);
|
|
|
|
currentSaveFile.writeSint16LE(ptr->freeze);
|
|
|
|
|
|
|
|
ptr = ptr->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void loadSavegameActor(Common::InSaveFile& currentSaveFile) {
|
2007-04-27 22:33:45 +00:00
|
|
|
short int numEntry;
|
|
|
|
actorStruct *ptr;
|
|
|
|
int i;
|
2007-04-27 12:58:35 +00:00
|
|
|
|
2007-11-08 22:59:29 +00:00
|
|
|
numEntry = currentSaveFile.readSint16LE();
|
2007-04-27 12:58:35 +00:00
|
|
|
|
2007-04-27 22:33:45 +00:00
|
|
|
ptr = &actorHead;
|
2007-04-27 12:58:35 +00:00
|
|
|
|
2007-04-27 22:33:45 +00:00
|
|
|
for (i = 0; i < numEntry; i++) {
|
2007-11-08 22:59:29 +00:00
|
|
|
actorStruct *current = (actorStruct *) mallocAndZero(sizeof(actorStruct));
|
|
|
|
currentSaveFile.skip(2);
|
|
|
|
currentSaveFile.skip(2);
|
|
|
|
|
|
|
|
current->idx = currentSaveFile.readSint16LE();
|
|
|
|
current->type = currentSaveFile.readSint16LE();
|
|
|
|
current->overlayNumber = currentSaveFile.readSint16LE();
|
|
|
|
current->x_dest = currentSaveFile.readSint16LE();
|
|
|
|
current->y_dest = currentSaveFile.readSint16LE();
|
|
|
|
current->x = currentSaveFile.readSint16LE();
|
|
|
|
current->y = currentSaveFile.readSint16LE();
|
|
|
|
current->startDirection = currentSaveFile.readSint16LE();
|
|
|
|
current->nextDirection = currentSaveFile.readSint16LE();
|
|
|
|
current->endDirection = currentSaveFile.readSint16LE();
|
|
|
|
current->stepX = currentSaveFile.readSint16LE();
|
|
|
|
current->stepY = currentSaveFile.readSint16LE();
|
|
|
|
current->pathId = currentSaveFile.readSint16LE();
|
|
|
|
current->phase = (animPhase)currentSaveFile.readSint16LE();
|
|
|
|
current->counter = currentSaveFile.readSint16LE();
|
|
|
|
current->poly = currentSaveFile.readSint16LE();
|
|
|
|
current->flag = currentSaveFile.readSint16LE();
|
|
|
|
current->start = currentSaveFile.readSint16LE();
|
|
|
|
current->freeze = currentSaveFile.readSint16LE();
|
2007-04-27 12:58:35 +00:00
|
|
|
|
2007-04-27 22:33:45 +00:00
|
|
|
current->next = NULL;
|
|
|
|
ptr->next = current;
|
|
|
|
current->prev = actorHead.prev;
|
|
|
|
actorHead.prev = current;
|
|
|
|
ptr = current->next;
|
|
|
|
}
|
2007-04-27 12:58:35 +00:00
|
|
|
}
|
|
|
|
|
2007-12-20 14:30:51 +00:00
|
|
|
void saveSong(Common::OutSaveFile& currentSaveFile) {
|
|
|
|
if (songLoaded) {
|
|
|
|
// TODO: implement
|
|
|
|
currentSaveFile.writeByte(0);
|
|
|
|
} else {
|
|
|
|
currentSaveFile.writeByte(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void loadSavegameDataSub5(Common::InSaveFile& currentSaveFile) {
|
2007-12-18 20:12:42 +00:00
|
|
|
if (songLoaded) {
|
2007-11-08 22:59:29 +00:00
|
|
|
saveVar1 = currentSaveFile.readByte();
|
2007-04-27 12:58:35 +00:00
|
|
|
|
2007-04-27 22:33:45 +00:00
|
|
|
if (saveVar1) {
|
2007-11-08 22:59:29 +00:00
|
|
|
currentSaveFile.read(saveVar2, saveVar1);
|
2007-04-27 22:33:45 +00:00
|
|
|
}
|
|
|
|
} else {
|
2007-11-08 22:59:29 +00:00
|
|
|
saveVar1 = currentSaveFile.readByte();
|
2007-04-27 22:33:45 +00:00
|
|
|
}
|
2007-04-27 12:58:35 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2007-12-20 14:30:51 +00:00
|
|
|
void saveCT(Common::OutSaveFile& currentSaveFile) {
|
|
|
|
if(polyStruct) {
|
|
|
|
currentSaveFile.writeSint32LE(1);
|
|
|
|
|
|
|
|
currentSaveFile.writeSint16LE(numberOfWalkboxes);
|
|
|
|
|
|
|
|
if(numberOfWalkboxes)
|
|
|
|
{
|
|
|
|
currentSaveFile.write(walkboxType, numberOfWalkboxes * 2);
|
|
|
|
currentSaveFile.write(walkboxChange, numberOfWalkboxes * 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (unsigned long int i = 0; i < 10; i++) {
|
|
|
|
|
|
|
|
if (persoTable[i]) {
|
|
|
|
currentSaveFile.writeSint32LE(1);
|
|
|
|
assert(sizeof(persoStruct) == 0x6AA);
|
|
|
|
currentSaveFile.write(persoTable[i], 0x6AA);
|
|
|
|
} else {
|
|
|
|
currentSaveFile.writeSint32LE(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
currentSaveFile.writeSint32LE(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void loadSavegameDataSub6(Common::InSaveFile& currentSaveFile) {
|
2007-04-27 22:33:45 +00:00
|
|
|
int32 var;
|
|
|
|
|
2007-11-08 22:59:29 +00:00
|
|
|
var = currentSaveFile.readUint32LE();
|
2007-04-27 22:33:45 +00:00
|
|
|
flipLong(&var);
|
|
|
|
|
|
|
|
if (var) {
|
|
|
|
int i;
|
|
|
|
|
2007-11-08 22:59:29 +00:00
|
|
|
numberOfWalkboxes = currentSaveFile.readUint16LE();
|
2007-04-27 22:33:45 +00:00
|
|
|
|
|
|
|
if (numberOfWalkboxes) {
|
2007-11-08 22:59:29 +00:00
|
|
|
currentSaveFile.read(walkboxType, numberOfWalkboxes * 2);
|
|
|
|
currentSaveFile.read(walkboxChange, numberOfWalkboxes * 2);
|
2007-04-27 22:33:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < 10; i++) {
|
2007-11-08 22:59:29 +00:00
|
|
|
persoTable[i] = (persoStruct*)currentSaveFile.readSint32LE();
|
2007-04-27 22:33:45 +00:00
|
|
|
|
|
|
|
if (persoTable[i]) {
|
|
|
|
assert(sizeof(persoStruct) == 0x6AA);
|
2007-11-08 22:59:29 +00:00
|
|
|
persoTable[i] = (persoStruct *)mallocAndZero(sizeof(persoStruct));
|
|
|
|
currentSaveFile.read(persoTable[i], 0x6AA);
|
2007-04-27 22:33:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-04-27 12:58:35 +00:00
|
|
|
|
2007-12-18 20:12:42 +00:00
|
|
|
int saveSavegameData(int saveGameIdx) {
|
2007-12-20 14:30:51 +00:00
|
|
|
char buffer[256];
|
|
|
|
|
|
|
|
sprintf(buffer, "CR.%d", saveGameIdx);
|
|
|
|
|
|
|
|
Common::SaveFileManager *saveMan = g_system->getSavefileManager();
|
|
|
|
Common::OutSaveFile *currentSaveFile;
|
|
|
|
currentSaveFile = saveMan->openForSaving(buffer);
|
|
|
|
|
|
|
|
char saveIdentBuffer[6];
|
|
|
|
strcpy(saveIdentBuffer, "SAVPC");
|
|
|
|
|
|
|
|
currentSaveFile->write(saveIdentBuffer, 6);
|
|
|
|
currentSaveFile->writeSint16LE(songLoaded);
|
|
|
|
currentSaveFile->writeSint16LE(songPlayed);
|
|
|
|
currentSaveFile->writeSint16LE(songLoop);
|
|
|
|
currentSaveFile->writeSint16LE(activeMouse);
|
|
|
|
currentSaveFile->writeSint16LE(userEnabled);
|
|
|
|
currentSaveFile->writeSint16LE(dialogueEnabled);
|
|
|
|
currentSaveFile->writeSint16LE(dialogueOvl);
|
|
|
|
currentSaveFile->writeSint16LE(dialogueObj);
|
|
|
|
currentSaveFile->writeSint16LE(userDelay);
|
|
|
|
currentSaveFile->writeSint16LE(sysKey);
|
|
|
|
currentSaveFile->writeSint16LE(sysX);
|
|
|
|
currentSaveFile->writeSint16LE(sysY);
|
|
|
|
currentSaveFile->writeSint16LE(automoveInc);
|
|
|
|
currentSaveFile->writeSint16LE(automoveMax);
|
|
|
|
currentSaveFile->writeSint16LE(displayOn);
|
|
|
|
currentSaveFile->writeSint16LE(isMessage);
|
|
|
|
currentSaveFile->writeSint16LE(fadeFlag);
|
|
|
|
currentSaveFile->writeSint16LE(playMusic);
|
|
|
|
currentSaveFile->writeSint16LE(playMusic2);
|
|
|
|
currentSaveFile->writeSint16LE(automaticMode);
|
|
|
|
currentSaveFile->writeSint16LE(titleColor);
|
|
|
|
currentSaveFile->writeSint16LE(itemColor);
|
|
|
|
currentSaveFile->writeSint16LE(selectColor);
|
|
|
|
currentSaveFile->writeSint16LE(subColor);
|
|
|
|
currentSaveFile->writeSint16LE(narratorOvl);
|
|
|
|
currentSaveFile->writeSint16LE(narratorIdx);
|
|
|
|
currentSaveFile->writeSint16LE(aniX);
|
|
|
|
currentSaveFile->writeSint16LE(aniY);
|
|
|
|
|
|
|
|
if(animationStart)
|
|
|
|
currentSaveFile->writeSint16LE(1);
|
|
|
|
else
|
|
|
|
currentSaveFile->writeSint16LE(0);
|
|
|
|
|
|
|
|
currentSaveFile->writeSint16LE(currentActiveBackgroundPlane);
|
|
|
|
currentSaveFile->writeSint16LE(switchPal);
|
|
|
|
currentSaveFile->writeSint16LE(scroll);
|
|
|
|
currentSaveFile->writeSint16LE(fadeFlag);
|
|
|
|
currentSaveFile->writeSint16LE(doFade);
|
|
|
|
currentSaveFile->writeSint16LE(numOfLoadedOverlay);
|
|
|
|
currentSaveFile->writeSint16LE(stateID);
|
|
|
|
currentSaveFile->writeSint16LE(fontFileIndex);
|
|
|
|
currentSaveFile->writeSint16LE(currentActiveMenu);
|
|
|
|
currentSaveFile->writeSint16LE(userWait);
|
|
|
|
currentSaveFile->writeSint16LE(autoOvl);
|
|
|
|
currentSaveFile->writeSint16LE(autoMsg);
|
|
|
|
currentSaveFile->writeSint16LE(autoTrack);
|
|
|
|
currentSaveFile->writeSint16LE(var39);
|
|
|
|
currentSaveFile->writeSint16LE(var42);
|
|
|
|
currentSaveFile->writeSint16LE(var45);
|
|
|
|
currentSaveFile->writeSint16LE(var46);
|
|
|
|
currentSaveFile->writeSint16LE(var47);
|
|
|
|
currentSaveFile->writeSint16LE(var48);
|
|
|
|
currentSaveFile->writeSint16LE(flagCt);
|
|
|
|
currentSaveFile->writeSint16LE(var41);
|
|
|
|
currentSaveFile->writeSint16LE(entrerMenuJoueur);
|
|
|
|
|
|
|
|
currentSaveFile->write(var50, 64);
|
|
|
|
currentSaveFile->write(var50, 64); // Hu ? why 2 times ?
|
|
|
|
|
|
|
|
currentSaveFile->write(musicName, 15);
|
|
|
|
|
2007-12-20 15:00:09 +00:00
|
|
|
const char dummy[6] = { 0, 0, 0, 0, 0, 0 };
|
2007-12-20 14:30:51 +00:00
|
|
|
currentSaveFile->write(dummy, 6);
|
|
|
|
|
|
|
|
currentSaveFile->write(currentCtpName, 40);
|
|
|
|
|
|
|
|
// restore backgroundTable
|
|
|
|
for(int i=0; i<8; i++)
|
|
|
|
{
|
|
|
|
currentSaveFile->write(backgroundTable[i].name, 9);
|
|
|
|
currentSaveFile->write(backgroundTable[i].extention, 6);
|
|
|
|
}
|
|
|
|
|
|
|
|
currentSaveFile->write(palette, 256*2);
|
|
|
|
currentSaveFile->write(initVar5, 24);
|
|
|
|
currentSaveFile->write(globalVars, stateID * 2); // ok
|
|
|
|
for(int i=0; i<257; i++)
|
|
|
|
{
|
|
|
|
currentSaveFile->writeUint16LE(filesDatabase[i].widthInColumn);
|
|
|
|
currentSaveFile->writeUint16LE(filesDatabase[i].width);
|
|
|
|
currentSaveFile->writeUint16LE(filesDatabase[i].resType);
|
|
|
|
currentSaveFile->writeUint16LE(filesDatabase[i].height);
|
|
|
|
if(filesDatabase[i].subData.ptr) {
|
|
|
|
currentSaveFile->writeUint32LE(1);
|
|
|
|
} else {
|
|
|
|
currentSaveFile->writeUint32LE(0);
|
|
|
|
}
|
|
|
|
currentSaveFile->writeUint16LE(filesDatabase[i].subData.index);
|
|
|
|
currentSaveFile->write(filesDatabase[i].subData.name, 13);
|
|
|
|
currentSaveFile->write(dummy, 1);
|
|
|
|
currentSaveFile->writeUint16LE(filesDatabase[i].subData.transparency);
|
|
|
|
if(filesDatabase[i].subData.ptrMask) {
|
|
|
|
currentSaveFile->writeUint32LE(1);
|
|
|
|
} else {
|
|
|
|
currentSaveFile->writeUint32LE(0);
|
|
|
|
}
|
|
|
|
currentSaveFile->writeByte(filesDatabase[i].subData.resourceType);
|
|
|
|
currentSaveFile->write(dummy, 1);
|
|
|
|
currentSaveFile->writeUint16LE(filesDatabase[i].subData.compression);
|
|
|
|
}
|
|
|
|
|
|
|
|
for(int i=0; i<numOfLoadedOverlay; i++)
|
|
|
|
{
|
|
|
|
currentSaveFile->write(overlayTable[i].overlayName, 13);
|
|
|
|
currentSaveFile->write(dummy, 1);
|
|
|
|
currentSaveFile->write(dummy, 4);
|
|
|
|
currentSaveFile->writeUint16LE(overlayTable[i].alreadyLoaded);
|
|
|
|
currentSaveFile->writeUint16LE(overlayTable[i].state);
|
|
|
|
currentSaveFile->write(dummy, 4);
|
|
|
|
currentSaveFile->write(dummy, 4);
|
|
|
|
currentSaveFile->write(dummy, 4);
|
|
|
|
currentSaveFile->write(dummy, 4);
|
|
|
|
currentSaveFile->writeUint16LE(overlayTable[i].executeScripts);
|
|
|
|
}
|
|
|
|
|
|
|
|
for(int i=0; i<64; i++)
|
|
|
|
{
|
|
|
|
currentSaveFile->write(preloadData[i].name, 15);
|
|
|
|
currentSaveFile->write(dummy, 1);
|
|
|
|
currentSaveFile->writeUint32LE(preloadData[i].size);
|
|
|
|
currentSaveFile->writeUint32LE(preloadData[i].sourceSize);
|
|
|
|
currentSaveFile->write(dummy, 4);
|
|
|
|
currentSaveFile->writeUint16LE(preloadData[i].nofree);
|
|
|
|
currentSaveFile->writeUint16LE(preloadData[i].protect);
|
|
|
|
currentSaveFile->writeUint16LE(preloadData[i].ovl);
|
|
|
|
}
|
|
|
|
|
|
|
|
saveOverlay(*currentSaveFile);
|
|
|
|
saveScript(*currentSaveFile, &procHead);
|
|
|
|
saveScript(*currentSaveFile, &relHead);
|
|
|
|
saveCell(*currentSaveFile);
|
|
|
|
saveIncrust(*currentSaveFile);
|
|
|
|
saveAnim(*currentSaveFile);
|
|
|
|
saveSong(*currentSaveFile);
|
|
|
|
saveCT(*currentSaveFile);
|
|
|
|
|
|
|
|
currentSaveFile->finalize();
|
|
|
|
delete currentSaveFile;
|
2007-12-18 20:12:42 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-04-27 22:33:45 +00:00
|
|
|
int loadSavegameData(int saveGameIdx) {
|
|
|
|
char buffer[256];
|
|
|
|
char saveIdentBuffer[6];
|
2007-12-18 20:12:42 +00:00
|
|
|
int lowMemorySave;
|
2007-04-27 22:33:45 +00:00
|
|
|
cellStruct *currentcellHead;
|
|
|
|
|
|
|
|
sprintf(buffer, "CR.%d", saveGameIdx);
|
|
|
|
|
2007-12-20 14:30:51 +00:00
|
|
|
Common::SaveFileManager *saveMan = g_system->getSavefileManager();
|
|
|
|
Common::InSaveFile *currentSaveFile;
|
|
|
|
currentSaveFile = saveMan->openForLoading(buffer);
|
2007-04-27 22:33:45 +00:00
|
|
|
|
2007-12-20 14:30:51 +00:00
|
|
|
if (currentSaveFile == NULL) {
|
2007-07-01 12:47:07 +00:00
|
|
|
printInfoBlackBox("Savegame not found...");
|
2007-04-27 22:33:45 +00:00
|
|
|
waitForPlayerInput();
|
|
|
|
return (-1);
|
|
|
|
}
|
|
|
|
|
2007-07-01 12:47:07 +00:00
|
|
|
printInfoBlackBox("Loading in progress...");
|
2007-04-27 22:33:45 +00:00
|
|
|
|
2007-12-20 14:30:51 +00:00
|
|
|
currentSaveFile->read(saveIdentBuffer, 6);
|
2007-04-27 22:33:45 +00:00
|
|
|
|
|
|
|
if (strcmp(saveIdentBuffer, "SAVPC")) {
|
2007-12-20 14:30:51 +00:00
|
|
|
delete currentSaveFile;
|
2007-04-27 22:33:45 +00:00
|
|
|
return (-1);
|
|
|
|
}
|
2007-12-18 20:12:42 +00:00
|
|
|
initVars();
|
2007-04-27 22:33:45 +00:00
|
|
|
|
2007-12-20 14:30:51 +00:00
|
|
|
songLoaded = currentSaveFile->readSint16LE();
|
|
|
|
songPlayed = currentSaveFile->readSint16LE();
|
|
|
|
songLoop = currentSaveFile->readSint16LE();
|
|
|
|
activeMouse = currentSaveFile->readSint16LE();
|
|
|
|
userEnabled = currentSaveFile->readSint16LE();
|
|
|
|
dialogueEnabled = currentSaveFile->readSint16LE();
|
|
|
|
|
|
|
|
dialogueOvl = currentSaveFile->readSint16LE();
|
|
|
|
dialogueObj = currentSaveFile->readSint16LE();
|
|
|
|
userDelay = currentSaveFile->readSint16LE();
|
|
|
|
sysKey = currentSaveFile->readSint16LE();
|
|
|
|
sysX = currentSaveFile->readSint16LE();
|
|
|
|
sysY = currentSaveFile->readSint16LE();
|
|
|
|
automoveInc = currentSaveFile->readSint16LE();
|
|
|
|
automoveMax = currentSaveFile->readSint16LE();
|
|
|
|
displayOn = currentSaveFile->readSint16LE();
|
|
|
|
isMessage = currentSaveFile->readSint16LE();
|
|
|
|
fadeFlag = currentSaveFile->readSint16LE();
|
|
|
|
playMusic = currentSaveFile->readSint16LE();
|
|
|
|
playMusic2 = currentSaveFile->readSint16LE();
|
|
|
|
automaticMode = currentSaveFile->readSint16LE();
|
2007-04-27 22:33:45 +00:00
|
|
|
|
|
|
|
// video param (not loaded in EGA mode)
|
|
|
|
|
2007-12-20 14:30:51 +00:00
|
|
|
titleColor = currentSaveFile->readSint16LE();
|
|
|
|
itemColor = currentSaveFile->readSint16LE();
|
|
|
|
selectColor = currentSaveFile->readSint16LE();
|
|
|
|
subColor = currentSaveFile->readSint16LE();
|
2007-04-27 22:33:45 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
|
2007-12-20 14:30:51 +00:00
|
|
|
narratorOvl = currentSaveFile->readSint16LE();
|
|
|
|
narratorIdx = currentSaveFile->readSint16LE();
|
|
|
|
aniX = currentSaveFile->readSint16LE();
|
|
|
|
aniY = currentSaveFile->readSint16LE();
|
2007-11-08 22:59:29 +00:00
|
|
|
|
2007-12-20 14:30:51 +00:00
|
|
|
if(currentSaveFile->readSint16LE()) // cast to bool
|
2007-11-08 22:59:29 +00:00
|
|
|
animationStart = true;
|
|
|
|
else
|
|
|
|
animationStart = false;
|
|
|
|
|
2007-12-20 14:30:51 +00:00
|
|
|
currentActiveBackgroundPlane = currentSaveFile->readSint16LE();
|
|
|
|
switchPal = currentSaveFile->readSint16LE();
|
|
|
|
scroll = currentSaveFile->readSint16LE();
|
|
|
|
fadeFlag = currentSaveFile->readSint16LE();
|
|
|
|
doFade = currentSaveFile->readSint16LE();
|
|
|
|
numOfLoadedOverlay = currentSaveFile->readSint16LE();
|
|
|
|
stateID = currentSaveFile->readSint16LE();
|
|
|
|
fontFileIndex = currentSaveFile->readSint16LE();
|
|
|
|
currentActiveMenu = currentSaveFile->readSint16LE();
|
|
|
|
userWait = currentSaveFile->readSint16LE();
|
|
|
|
autoOvl = currentSaveFile->readSint16LE();
|
|
|
|
autoMsg = currentSaveFile->readSint16LE();
|
|
|
|
autoTrack = currentSaveFile->readSint16LE();
|
|
|
|
var39 = currentSaveFile->readSint16LE();
|
|
|
|
var42 = currentSaveFile->readSint16LE();
|
|
|
|
var45 = currentSaveFile->readSint16LE();
|
|
|
|
var46 = currentSaveFile->readSint16LE();
|
|
|
|
var47 = currentSaveFile->readSint16LE();
|
|
|
|
var48 = currentSaveFile->readSint16LE();
|
|
|
|
flagCt = currentSaveFile->readSint16LE();
|
|
|
|
var41 = currentSaveFile->readSint16LE();
|
|
|
|
entrerMenuJoueur = currentSaveFile->readSint16LE();
|
|
|
|
|
|
|
|
currentSaveFile->read(var50, 64);
|
|
|
|
currentSaveFile->read(var50, 64); // Hu ? why 2 times ?
|
2007-11-08 22:59:29 +00:00
|
|
|
|
|
|
|
// here code seems bogus... this should read music name and it may be a buffer overrun
|
2007-12-20 14:30:51 +00:00
|
|
|
currentSaveFile->skip(21);
|
2007-11-08 22:59:29 +00:00
|
|
|
|
2007-12-20 14:30:51 +00:00
|
|
|
currentSaveFile->read(currentCtpName, 40);
|
2007-11-08 22:59:29 +00:00
|
|
|
|
|
|
|
// restore backgroundTable
|
|
|
|
for(int i=0; i<8; i++)
|
|
|
|
{
|
2007-12-20 14:30:51 +00:00
|
|
|
currentSaveFile->read(backgroundTable[i].name, 9);
|
|
|
|
currentSaveFile->read(backgroundTable[i].extention, 6);
|
2007-11-08 22:59:29 +00:00
|
|
|
}
|
|
|
|
|
2007-12-20 14:30:51 +00:00
|
|
|
currentSaveFile->read(palette, 256*2);
|
|
|
|
currentSaveFile->read(initVar5, 24);
|
|
|
|
currentSaveFile->read(globalVars, stateID * 2); // ok
|
2007-11-08 22:59:29 +00:00
|
|
|
for(int i=0; i<257; i++)
|
|
|
|
{
|
2007-12-20 14:30:51 +00:00
|
|
|
filesDatabase[i].widthInColumn = currentSaveFile->readUint16LE();
|
|
|
|
filesDatabase[i].width = currentSaveFile->readUint16LE();
|
|
|
|
filesDatabase[i].resType = currentSaveFile->readUint16LE();
|
|
|
|
filesDatabase[i].height = currentSaveFile->readUint16LE();
|
|
|
|
filesDatabase[i].subData.ptr = (uint8*)currentSaveFile->readSint32LE();
|
|
|
|
filesDatabase[i].subData.index = currentSaveFile->readSint16LE();
|
|
|
|
currentSaveFile->read(filesDatabase[i].subData.name, 13);
|
|
|
|
currentSaveFile->skip(1);
|
|
|
|
filesDatabase[i].subData.transparency = currentSaveFile->readSint16LE();
|
|
|
|
filesDatabase[i].subData.ptrMask = (uint8*)currentSaveFile->readSint32LE();
|
|
|
|
filesDatabase[i].subData.resourceType = currentSaveFile->readByte();
|
|
|
|
currentSaveFile->skip(1);
|
|
|
|
filesDatabase[i].subData.compression = currentSaveFile->readSint16LE();
|
2007-11-08 22:59:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for(int i=0; i<numOfLoadedOverlay; i++)
|
|
|
|
{
|
2007-12-20 14:30:51 +00:00
|
|
|
currentSaveFile->read(overlayTable[i].overlayName, 13);
|
|
|
|
currentSaveFile->skip(1);
|
|
|
|
currentSaveFile->skip(4);
|
|
|
|
overlayTable[i].alreadyLoaded = currentSaveFile->readSint16LE();
|
|
|
|
overlayTable[i].state = currentSaveFile->readSint16LE();
|
|
|
|
currentSaveFile->skip(4);
|
|
|
|
currentSaveFile->skip(4);
|
|
|
|
currentSaveFile->skip(4);
|
|
|
|
currentSaveFile->skip(4);
|
|
|
|
overlayTable[i].executeScripts = currentSaveFile->readSint16LE();
|
2007-11-08 22:59:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for(int i=0; i<64; i++)
|
|
|
|
{
|
2007-12-20 14:30:51 +00:00
|
|
|
currentSaveFile->read(preloadData[i].name, 15);
|
|
|
|
currentSaveFile->skip(1);
|
|
|
|
preloadData[i].size = currentSaveFile->readSint32LE();
|
|
|
|
preloadData[i].sourceSize = currentSaveFile->readSint32LE();
|
|
|
|
currentSaveFile->skip(4);
|
|
|
|
preloadData[i].nofree = currentSaveFile->readSint16LE();
|
|
|
|
preloadData[i].protect = currentSaveFile->readSint16LE();
|
|
|
|
preloadData[i].ovl = currentSaveFile->readSint16LE();
|
2007-11-08 22:59:29 +00:00
|
|
|
}
|
|
|
|
|
2007-12-20 14:30:51 +00:00
|
|
|
loadSavegameDataSub1(*currentSaveFile);
|
|
|
|
loadScriptsFromSave(*currentSaveFile, &procHead);
|
|
|
|
loadScriptsFromSave(*currentSaveFile, &relHead);
|
2007-11-08 22:59:29 +00:00
|
|
|
|
2007-12-20 14:30:51 +00:00
|
|
|
loadSavegameDataSub2(*currentSaveFile);
|
|
|
|
loadBackgroundIncrustFromSave(*currentSaveFile);
|
|
|
|
loadSavegameActor(*currentSaveFile);
|
|
|
|
loadSavegameDataSub5(*currentSaveFile);
|
|
|
|
loadSavegameDataSub6(*currentSaveFile);
|
2007-11-08 22:59:29 +00:00
|
|
|
|
2007-12-20 14:30:51 +00:00
|
|
|
delete currentSaveFile;
|
2007-11-08 22:59:29 +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) {
|
|
|
|
free(ovlData->data4Ptr);
|
|
|
|
}
|
|
|
|
|
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) {
|
2007-11-08 22:59:29 +00:00
|
|
|
free(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
|
|
|
|
2007-11-10 17:15:48 +00:00
|
|
|
for (int i = 0; i < 257; i++) {
|
|
|
|
if (filesDatabase[i].subData.ptr) {
|
|
|
|
int j;
|
2007-04-27 22:33:45 +00:00
|
|
|
int k;
|
|
|
|
|
2007-11-10 17:15:48 +00:00
|
|
|
for (j = i + 1; j < 257 && filesDatabase[j].subData.ptr && !strcmp(filesDatabase[i].subData.name, filesDatabase[j].subData.name) && (filesDatabase[j].subData.index == (j-i)); j++);
|
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) {
|
2007-04-27 22:33:45 +00:00
|
|
|
printf("Unsupported mono file load!\n");
|
2007-11-10 17:15:48 +00:00
|
|
|
ASSERT(0);
|
2007-04-27 22:33:45 +00:00
|
|
|
//loadFileMode1(filesDatabase[j].subData.name,filesDatabase[j].subData.var4);
|
2007-12-20 14:30:51 +00:00
|
|
|
} else */{
|
2007-11-10 17:15:48 +00:00
|
|
|
loadFileRange(filesDatabase[i].subData.name, filesDatabase[i].subData.index, i, j - i);
|
|
|
|
i = j - 1;
|
2007-04-27 22:33:45 +00:00
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
//*(int16*)(currentcellHead->datas+0x2E) = getSprite(ptr,*(int16*)(currentcellHead->datas+0xE));
|
|
|
|
} else {
|
2007-11-10 17:15:48 +00:00
|
|
|
ASSERT(0);
|
2007-04-27 22:33:45 +00:00
|
|
|
//*(int16*)(currentcellHead->datas+0x2E) = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
currentcellHead = currentcellHead->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
//TODO: here, restart music
|
|
|
|
|
2007-11-10 17:15:48 +00:00
|
|
|
if (strlen(currentCtpName)) {
|
2007-04-27 22:33:45 +00:00
|
|
|
ctpVar1 = 1;
|
|
|
|
loadCtp(currentCtpName);
|
|
|
|
ctpVar1 = 0;
|
|
|
|
}
|
|
|
|
//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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-12-20 14:30:51 +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();
|
|
|
|
|
|
|
|
return (0);
|
2007-04-27 12:58:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // End of namespace Cruise
|