Multiple fix/cleanup
One bug remains before the game is completable without hack svn-id: r29920
This commit is contained in:
parent
6d37f5ccd8
commit
564fc06cf7
17 changed files with 602 additions and 232 deletions
|
@ -615,8 +615,7 @@ int16 computePathfinding(int16 *pSolution, int16 x, int16 y, int16 destX, int16
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
perso = persoTable[i] =
|
perso = persoTable[i] = (persoStruct *) malloc(sizeof(persoStruct));
|
||||||
(persoStruct *) malloc(sizeof(persoStruct));
|
|
||||||
|
|
||||||
ptr = perso->solution[0];
|
ptr = perso->solution[0];
|
||||||
|
|
||||||
|
|
|
@ -186,7 +186,56 @@ backgroundIncrustStruct *addBackgroundIncrust(int16 overlayIdx, int16 objectIdx,
|
||||||
return newElement;
|
return newElement;
|
||||||
}
|
}
|
||||||
|
|
||||||
void loadBackgroundIncrustFromSave(Common::File& currentSaveFile) {
|
void saveIncrust(Common::OutSaveFile& currentSaveFile) {
|
||||||
|
int count = 0;
|
||||||
|
|
||||||
|
backgroundIncrustStruct *pl = backgroundIncrustHead.next;
|
||||||
|
while(pl) {
|
||||||
|
count++;
|
||||||
|
pl = pl->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
currentSaveFile.writeSint16LE(count);
|
||||||
|
|
||||||
|
pl = backgroundIncrustHead.next;
|
||||||
|
while(pl) {
|
||||||
|
char dummy[4] = {0, 0, 0, 0};
|
||||||
|
currentSaveFile.write(dummy, 2);
|
||||||
|
currentSaveFile.write(dummy, 2);
|
||||||
|
|
||||||
|
currentSaveFile.writeSint16LE(pl->objectIdx);
|
||||||
|
currentSaveFile.writeSint16LE(pl->type);
|
||||||
|
currentSaveFile.writeSint16LE(pl->overlayIdx);
|
||||||
|
currentSaveFile.writeSint16LE(pl->X);
|
||||||
|
currentSaveFile.writeSint16LE(pl->Y);
|
||||||
|
currentSaveFile.writeSint16LE(pl->field_E);
|
||||||
|
currentSaveFile.writeSint16LE(pl->scale);
|
||||||
|
currentSaveFile.writeSint16LE(pl->backgroundIdx);
|
||||||
|
currentSaveFile.writeSint16LE(pl->scriptNumber);
|
||||||
|
currentSaveFile.writeSint16LE(pl->scriptOverlayIdx);
|
||||||
|
currentSaveFile.write(dummy, 4);
|
||||||
|
currentSaveFile.writeSint16LE(pl->saveWidth/2);
|
||||||
|
currentSaveFile.writeSint16LE(pl->saveHeight);
|
||||||
|
currentSaveFile.writeSint16LE(pl->saveSize);
|
||||||
|
currentSaveFile.writeSint16LE(pl->savedX);
|
||||||
|
currentSaveFile.writeSint16LE(pl->savedY);
|
||||||
|
currentSaveFile.write(pl->name, 13);
|
||||||
|
currentSaveFile.write(dummy, 1);
|
||||||
|
currentSaveFile.writeSint16LE(pl->spriteId);
|
||||||
|
currentSaveFile.write(dummy, 2);
|
||||||
|
|
||||||
|
if (pl->saveSize) {
|
||||||
|
char* buffer = (char*)malloc(pl->saveSize);
|
||||||
|
memset(buffer, 0, pl->saveSize);
|
||||||
|
currentSaveFile.write(buffer, pl->saveSize);
|
||||||
|
free(buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
pl = pl->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void loadBackgroundIncrustFromSave(Common::InSaveFile& currentSaveFile) {
|
||||||
int16 numEntry;
|
int16 numEntry;
|
||||||
int32 i;
|
int32 i;
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,8 @@ extern backgroundIncrustStruct backgroundIncrustHead;
|
||||||
|
|
||||||
void resetBackgroundIncrustList(backgroundIncrustStruct * pHead);
|
void resetBackgroundIncrustList(backgroundIncrustStruct * pHead);
|
||||||
backgroundIncrustStruct *addBackgroundIncrust(int16 overlayIdx, int16 param2, backgroundIncrustStruct * pHead, int16 scriptNumber, int16 scriptOverlay, int16 backgroundIdx, int16 param4);
|
backgroundIncrustStruct *addBackgroundIncrust(int16 overlayIdx, int16 param2, backgroundIncrustStruct * pHead, int16 scriptNumber, int16 scriptOverlay, int16 backgroundIdx, int16 param4);
|
||||||
void loadBackgroundIncrustFromSave(Common::File& currentSaveFile);
|
void saveIncrust(Common::OutSaveFile& currentSaveFile);
|
||||||
|
void loadBackgroundIncrustFromSave(Common::InSaveFile& currentSaveFile);
|
||||||
void regenerateBackgroundIncrust(backgroundIncrustStruct * pHead);
|
void regenerateBackgroundIncrust(backgroundIncrustStruct * pHead);
|
||||||
void freeBackgroundIncrustList(backgroundIncrustStruct * pHead);
|
void freeBackgroundIncrustList(backgroundIncrustStruct * pHead);
|
||||||
void removeBackgroundIncrust(int overlay, int idx, backgroundIncrustStruct * pHead);
|
void removeBackgroundIncrust(int overlay, int idx, backgroundIncrustStruct * pHead);
|
||||||
|
|
|
@ -22,9 +22,10 @@
|
||||||
* $Id$
|
* $Id$
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "cruise/cruise_main.h"
|
||||||
#include "common/file.h"
|
#include "common/file.h"
|
||||||
#include "cruise/cell.h"
|
#include "cruise/cell.h"
|
||||||
#include "cruise/cruise_main.h"
|
|
||||||
|
|
||||||
namespace Cruise {
|
namespace Cruise {
|
||||||
|
|
||||||
|
@ -43,8 +44,55 @@ void freeMessageList(cellStruct *objPtr) {
|
||||||
free(objPtr);
|
free(objPtr);
|
||||||
} */
|
} */
|
||||||
}
|
}
|
||||||
|
void saveCell(Common::OutSaveFile& currentSaveFile) {
|
||||||
|
|
||||||
void loadSavegameDataSub2(Common::File& currentSaveFile) {
|
int count = 0;
|
||||||
|
cellStruct *t = cellHead.next;
|
||||||
|
|
||||||
|
while(t) {
|
||||||
|
count++;
|
||||||
|
t = t->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
currentSaveFile.writeSint16LE(count);
|
||||||
|
|
||||||
|
t = cellHead.next;
|
||||||
|
while(t) {
|
||||||
|
char dummy[2] = { 0, 0};
|
||||||
|
|
||||||
|
currentSaveFile.write(dummy, 2);
|
||||||
|
currentSaveFile.write(dummy, 2);
|
||||||
|
|
||||||
|
currentSaveFile.writeSint16LE(t->idx);
|
||||||
|
currentSaveFile.writeSint16LE(t->type);
|
||||||
|
currentSaveFile.writeSint16LE(t->overlay);
|
||||||
|
currentSaveFile.writeSint16LE(t->x);
|
||||||
|
currentSaveFile.writeSint16LE(t->field_C);
|
||||||
|
currentSaveFile.writeSint16LE(t->spriteIdx);
|
||||||
|
currentSaveFile.writeSint16LE(t->color);
|
||||||
|
currentSaveFile.writeSint16LE(t->backgroundPlane);
|
||||||
|
currentSaveFile.writeSint16LE(t->freeze);
|
||||||
|
currentSaveFile.writeSint16LE(t->parent);
|
||||||
|
currentSaveFile.writeSint16LE(t->parentOverlay);
|
||||||
|
currentSaveFile.writeSint16LE(t->parentType);
|
||||||
|
currentSaveFile.writeSint16LE(t->followObjectOverlayIdx);
|
||||||
|
currentSaveFile.writeSint16LE(t->followObjectIdx);
|
||||||
|
currentSaveFile.writeSint16LE(t->animStart);
|
||||||
|
currentSaveFile.writeSint16LE(t->animEnd);
|
||||||
|
currentSaveFile.writeSint16LE(t->animWait);
|
||||||
|
currentSaveFile.writeSint16LE(t->animStep);
|
||||||
|
currentSaveFile.writeSint16LE(t->animChange);
|
||||||
|
currentSaveFile.writeSint16LE(t->animType);
|
||||||
|
currentSaveFile.writeSint16LE(t->animSignal);
|
||||||
|
currentSaveFile.writeSint16LE(t->animCounter);
|
||||||
|
currentSaveFile.writeSint16LE(t->animLoop);
|
||||||
|
currentSaveFile.write(dummy, 2);
|
||||||
|
|
||||||
|
t = t->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void loadSavegameDataSub2(Common::InSaveFile& currentSaveFile) {
|
||||||
unsigned short int n_chunks;
|
unsigned short int n_chunks;
|
||||||
int i;
|
int i;
|
||||||
cellStruct *p;
|
cellStruct *p;
|
||||||
|
|
|
@ -65,7 +65,8 @@ struct cellStruct {
|
||||||
extern cellStruct cellHead;
|
extern cellStruct cellHead;
|
||||||
|
|
||||||
void resetPtr(cellStruct * ptr);
|
void resetPtr(cellStruct * ptr);
|
||||||
void loadSavegameDataSub2(Common::File& currentSaveFile);
|
void loadSavegameDataSub2(Common::InSaveFile& currentSaveFile);
|
||||||
|
void saveCell(Common::OutSaveFile& currentSaveFile);
|
||||||
cellStruct *addCell(cellStruct *pHead, int16 overlayIdx, int16 objIdx, int16 type, int16 backgroundPlane, int16 scriptOverlay, int16 scriptNumber, int16 scriptType);
|
cellStruct *addCell(cellStruct *pHead, int16 overlayIdx, int16 objIdx, int16 type, int16 backgroundPlane, int16 scriptOverlay, int16 scriptNumber, int16 scriptType);
|
||||||
void createTextObject(cellStruct *pObject, int overlayIdx, int messageIdx, int x, int y, int width, int16 color, int backgroundPlane, int parentOvl, int parentIdx);
|
void createTextObject(cellStruct *pObject, int overlayIdx, int messageIdx, int x, int y, int width, int16 color, int backgroundPlane, int parentOvl, int parentIdx);
|
||||||
void removeCell(cellStruct *objPtr, int ovlNumber, int objectIdx, int objType, int backgroundPlane );
|
void removeCell(cellStruct *objPtr, int ovlNumber, int objectIdx, int objType, int backgroundPlane );
|
||||||
|
|
|
@ -572,7 +572,7 @@ int initAllData(void) {
|
||||||
scriptFunc2(bootOverlayNumber, &procHead, 1, 0);
|
scriptFunc2(bootOverlayNumber, &procHead, 1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
strcpy(systemStrings.bootScriptName, "AUTO00");
|
strcpy(lastOverlay, "AUTO00");
|
||||||
|
|
||||||
return (bootOverlayNumber);
|
return (bootOverlayNumber);
|
||||||
}
|
}
|
||||||
|
@ -652,7 +652,7 @@ int findObject(int mouseX, int mouseY, int *outObjOvl, int *outObjIdx) {
|
||||||
j2 = params2.fileIdx;
|
j2 = params2.fileIdx;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (params.var5 >= 0 && params.fileIdx >= 0) {
|
if (params.state >= 0 && params.fileIdx >= 0) {
|
||||||
if (currentObject->type == OBJ_TYPE_SPRITE || currentObject->type == OBJ_TYPE_MASK || currentObject->type == OBJ_TYPE_EXIT) {
|
if (currentObject->type == OBJ_TYPE_SPRITE || currentObject->type == OBJ_TYPE_MASK || currentObject->type == OBJ_TYPE_EXIT) {
|
||||||
int x = params.X + x2;
|
int x = params.X + x2;
|
||||||
int y = params.Y + y2;
|
int y = params.Y + y2;
|
||||||
|
@ -990,7 +990,7 @@ bool findRelation(int objOvl, int objIdx, int x, int y) {
|
||||||
thisOvl = j;
|
thisOvl = j;
|
||||||
}
|
}
|
||||||
|
|
||||||
//const char* pName = getObjectName(ptrHead->obj1Number, overlayTable[thisOvl].ovlData->arrayNameObj);
|
const char* pName = getObjectName(ptrHead->obj1Number, overlayTable[thisOvl].ovlData->arrayNameObj);
|
||||||
|
|
||||||
objDataStruct* pObject = getObjectDataFromOverlay(thisOvl, ptrHead->obj1Number);
|
objDataStruct* pObject = getObjectDataFromOverlay(thisOvl, ptrHead->obj1Number);
|
||||||
|
|
||||||
|
@ -1124,7 +1124,7 @@ void callSubRelation(menuElementSubStruct *pMenuElement, int nOvl, int nObj) {
|
||||||
getMultipleObjectParam(obj2Ovl, pHeader->obj2Number, ¶ms);
|
getMultipleObjectParam(obj2Ovl, pHeader->obj2Number, ¶ms);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((pHeader->obj2OldState == -1) || (params.scale == pHeader->obj2OldState)) {
|
if ((pHeader->obj2OldState == -1) || (params.state == pHeader->obj2OldState)) {
|
||||||
if (pHeader->type == 30) { // REL
|
if (pHeader->type == 30) { // REL
|
||||||
if(currentScriptPtr)
|
if(currentScriptPtr)
|
||||||
{
|
{
|
||||||
|
@ -1738,9 +1738,10 @@ void mainLoop(void) {
|
||||||
|
|
||||||
int enableUser = 0;
|
int enableUser = 0;
|
||||||
|
|
||||||
strcpy(currentOverlay, "");
|
strcpy(nextOverlay, "");
|
||||||
systemStrings.bootScriptName[0] = 0;
|
strcpy(lastOverlay, "");
|
||||||
cmdLine[0] = 0;
|
strcpy(cmdLine, "");
|
||||||
|
|
||||||
currentActiveMenu = -1;
|
currentActiveMenu = -1;
|
||||||
autoMsg = -1;
|
autoMsg = -1;
|
||||||
linkedRelation = 0;
|
linkedRelation = 0;
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
|
|
||||||
|
|
||||||
#include "common/scummsys.h"
|
#include "common/scummsys.h"
|
||||||
|
#include "common/savefile.h"
|
||||||
|
|
||||||
#include "cruise/overlay.h"
|
#include "cruise/overlay.h"
|
||||||
#include "cruise/object.h"
|
#include "cruise/object.h"
|
||||||
|
|
|
@ -393,9 +393,7 @@ int loadCtp(const char *ctpName) {
|
||||||
{
|
{
|
||||||
int numOfUsedEntries = ctpVar13 - (ctpVar19Struct *) ptr;
|
int numOfUsedEntries = ctpVar13 - (ctpVar19Struct *) ptr;
|
||||||
numOfUsedEntries++; // there is a -1 entry at the end... Original was only mallocing numOfUsedEntries*sizeof(ctpVar19Struct)+4, but this is a bit ugly...
|
numOfUsedEntries++; // there is a -1 entry at the end... Original was only mallocing numOfUsedEntries*sizeof(ctpVar19Struct)+4, but this is a bit ugly...
|
||||||
ctpVar13 = ctpVar11 = polyStruct =
|
ctpVar13 = ctpVar11 = polyStruct = (ctpVar19Struct *) malloc(numOfUsedEntries * sizeof(ctpVar19Struct));
|
||||||
(ctpVar19Struct *) malloc(numOfUsedEntries *
|
|
||||||
sizeof(ctpVar19Struct));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
walkboxCounter = numberOfWalkboxes;
|
walkboxCounter = numberOfWalkboxes;
|
||||||
|
|
|
@ -54,7 +54,7 @@ int16 Op_LoadOverlay(void) {
|
||||||
|
|
||||||
updateAllScriptsImports();
|
updateAllScriptsImports();
|
||||||
|
|
||||||
strcpy(currentOverlay, overlayName);
|
strcpy(nextOverlay, overlayName);
|
||||||
|
|
||||||
return(overlayLoadResult);
|
return(overlayLoadResult);
|
||||||
}
|
}
|
||||||
|
@ -123,10 +123,10 @@ int16 Op_AddProc(void) {
|
||||||
int pop1 = popVar();
|
int pop1 = popVar();
|
||||||
int pop2;
|
int pop2;
|
||||||
int overlay;
|
int overlay;
|
||||||
|
int param[160];
|
||||||
|
|
||||||
if (pop1 - 1 > 0) {
|
for(long int i=0; i<pop1; i++) {
|
||||||
printf("Unsuported arg pop in Op_6!\n");
|
param[i] = popVar();
|
||||||
exit(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pop2 = popVar();
|
pop2 = popVar();
|
||||||
|
@ -138,11 +138,14 @@ int16 Op_AddProc(void) {
|
||||||
if (!overlay)
|
if (!overlay)
|
||||||
return (0);
|
return (0);
|
||||||
|
|
||||||
attacheNewScriptToTail(&procHead, overlay, pop2, currentScriptPtr->type, currentScriptPtr->scriptNumber, currentScriptPtr->overlayNumber, scriptType_PROC);
|
uint8* procBss = attacheNewScriptToTail(&procHead, overlay, pop2, currentScriptPtr->type, currentScriptPtr->scriptNumber, currentScriptPtr->overlayNumber, scriptType_PROC);
|
||||||
|
|
||||||
if (pop1 > 0) {
|
if (procBss) {
|
||||||
printf("Unsupported art send in op6!\n");
|
for(long int i=0; i<pop1; i++) {
|
||||||
exit(1);
|
int16* ptr = (int16*)(procBss+i*2);
|
||||||
|
*ptr = param[i];
|
||||||
|
flipShort(ptr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
|
@ -773,7 +776,7 @@ int16 Op_AutoCell(void) {
|
||||||
objectParamsQuery params;
|
objectParamsQuery params;
|
||||||
|
|
||||||
getMultipleObjectParam(overlay, obj, ¶ms);
|
getMultipleObjectParam(overlay, obj, ¶ms);
|
||||||
pObject->animCounter = params.var6 - 1;
|
pObject->animCounter = params.state2 - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -789,7 +792,7 @@ int16 Op_66(void) {
|
||||||
|
|
||||||
getMultipleObjectParam(overlay, index, ¶ms);
|
getMultipleObjectParam(overlay, index, ¶ms);
|
||||||
|
|
||||||
return params.var7 - 1;
|
return params.nbState - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int16 Op_SetActiveBackgroundPlane(void) {
|
int16 Op_SetActiveBackgroundPlane(void) {
|
||||||
|
|
|
@ -72,7 +72,7 @@ void freeAutoCell(void) {
|
||||||
|
|
||||||
getMultipleObjectParam(pCurrent->ovlIdx, pCurrent->objIdx, ¶ms);
|
getMultipleObjectParam(pCurrent->ovlIdx, pCurrent->objIdx, ¶ms);
|
||||||
|
|
||||||
pCurrent->pCell->animCounter = params.var6 - 1;
|
pCurrent->pCell->animCounter = params.state2 - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
delete pCurrent;
|
delete pCurrent;
|
||||||
|
@ -1320,11 +1320,11 @@ int getValueFromObjectQuerry(objectParamsQuery *params, int idx) {
|
||||||
case 4:
|
case 4:
|
||||||
return params->scale;
|
return params->scale;
|
||||||
case 5:
|
case 5:
|
||||||
return params->var5;
|
return params->state;
|
||||||
case 6:
|
case 6:
|
||||||
return params->var6;
|
return params->state2;
|
||||||
case 7:
|
case 7:
|
||||||
return params->var7;
|
return params->nbState;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(0);
|
assert(0);
|
||||||
|
@ -1396,7 +1396,7 @@ void mainDraw(int16 param) {
|
||||||
objZ2 += objZ1;
|
objZ2 += objZ1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((params.var5 >= 0) && (objZ2 >= 0) && filesDatabase[objZ2].subData.ptr) {
|
if ((params.state >= 0) && (objZ2 >= 0) && filesDatabase[objZ2].subData.ptr) {
|
||||||
if (filesDatabase[objZ2].subData.resourceType == 8) { // Poly
|
if (filesDatabase[objZ2].subData.resourceType == 8) { // Poly
|
||||||
mainDrawPolygons(objZ2, currentObjPtr, objX2, params.scale, objY2, (char *)gfxModuleData.pPage10, (char *)filesDatabase[objZ2].subData.ptr); // poly
|
mainDrawPolygons(objZ2, currentObjPtr, objX2, params.scale, objY2, (char *)gfxModuleData.pPage10, (char *)filesDatabase[objZ2].subData.ptr); // poly
|
||||||
} else if (filesDatabase[objZ2].subData.resourceType == 6) { // sound
|
} else if (filesDatabase[objZ2].subData.resourceType == 6) { // sound
|
||||||
|
|
|
@ -207,7 +207,7 @@ int playerMenu(int menuX, int menuY) {
|
||||||
|
|
||||||
if (entrerMenuJoueur && displayOn) {
|
if (entrerMenuJoueur && displayOn) {
|
||||||
if (remdo) {
|
if (remdo) {
|
||||||
systemStrings.param = 0;
|
musicName[0] = 0;
|
||||||
playMusic2 = 0;
|
playMusic2 = 0;
|
||||||
playMusic = 0;
|
playMusic = 0;
|
||||||
freeStuff2();
|
freeStuff2();
|
||||||
|
|
|
@ -108,9 +108,9 @@ int16 getMultipleObjectParam(int16 overlayIdx, int16 objectIdx, objectParamsQuer
|
||||||
returnParam->baseFileIdx = ptr2->Z;
|
returnParam->baseFileIdx = ptr2->Z;
|
||||||
returnParam->fileIdx = ptr2->frame;
|
returnParam->fileIdx = ptr2->frame;
|
||||||
returnParam->scale = ptr2->scale;
|
returnParam->scale = ptr2->scale;
|
||||||
returnParam->var5 = state;
|
returnParam->state = state;
|
||||||
returnParam->var6 = state2;
|
returnParam->state2 = state2;
|
||||||
returnParam->var7 = ptr->_numStates;
|
returnParam->nbState = ptr->_numStates;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,9 +43,9 @@ struct objectParamsQuery {
|
||||||
int16 baseFileIdx;
|
int16 baseFileIdx;
|
||||||
int16 fileIdx;
|
int16 fileIdx;
|
||||||
int16 scale;
|
int16 scale;
|
||||||
int16 var5;
|
int16 state;
|
||||||
int16 var6;
|
int16 state2;
|
||||||
int16 var7;
|
int16 nbState;
|
||||||
};
|
};
|
||||||
|
|
||||||
objDataStruct *getObjectDataFromOverlay(int ovlIdx, int objIdx);
|
objDataStruct *getObjectDataFromOverlay(int ovlIdx, int objIdx);
|
||||||
|
|
|
@ -25,6 +25,9 @@
|
||||||
|
|
||||||
#include "cruise/cruise_main.h"
|
#include "cruise/cruise_main.h"
|
||||||
|
|
||||||
|
#include "common/savefile.h"
|
||||||
|
#include "common/system.h"
|
||||||
|
|
||||||
namespace Cruise {
|
namespace Cruise {
|
||||||
|
|
||||||
struct overlayRestoreTemporary {
|
struct overlayRestoreTemporary {
|
||||||
|
@ -184,10 +187,35 @@ void initVars(void)
|
||||||
fadeVar = 0;
|
fadeVar = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void loadSavegameDataSub1(Common::File& currentSaveFile) {
|
void saveOverlay(Common::OutSaveFile& currentSaveFile) {
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 1; i < numOfLoadedOverlay; i++) {
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void loadSavegameDataSub1(Common::InSaveFile& currentSaveFile) {
|
||||||
|
|
||||||
|
for (int i = 1; i < numOfLoadedOverlay; i++) {
|
||||||
ovlRestoreData[i]._sBssSize = ovlRestoreData[i]._sNumObj = 0;
|
ovlRestoreData[i]._sBssSize = ovlRestoreData[i]._sNumObj = 0;
|
||||||
ovlRestoreData[i]._pBss = NULL;
|
ovlRestoreData[i]._pBss = NULL;
|
||||||
ovlRestoreData[i]._pObj = NULL;
|
ovlRestoreData[i]._pObj = NULL;
|
||||||
|
@ -222,7 +250,46 @@ void loadSavegameDataSub1(Common::File& currentSaveFile) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void loadScriptsFromSave(Common::File& currentSaveFile, scriptInstanceStruct *entry) {
|
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) {
|
||||||
short int numScripts;
|
short int numScripts;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -261,7 +328,48 @@ void loadScriptsFromSave(Common::File& currentSaveFile, scriptInstanceStruct *en
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void loadSavegameActor(Common::File& currentSaveFile) {
|
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) {
|
||||||
short int numEntry;
|
short int numEntry;
|
||||||
actorStruct *ptr;
|
actorStruct *ptr;
|
||||||
int i;
|
int i;
|
||||||
|
@ -303,7 +411,16 @@ void loadSavegameActor(Common::File& currentSaveFile) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void loadSavegameDataSub5(Common::File& currentSaveFile) {
|
void saveSong(Common::OutSaveFile& currentSaveFile) {
|
||||||
|
if (songLoaded) {
|
||||||
|
// TODO: implement
|
||||||
|
currentSaveFile.writeByte(0);
|
||||||
|
} else {
|
||||||
|
currentSaveFile.writeByte(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void loadSavegameDataSub5(Common::InSaveFile& currentSaveFile) {
|
||||||
if (songLoaded) {
|
if (songLoaded) {
|
||||||
saveVar1 = currentSaveFile.readByte();
|
saveVar1 = currentSaveFile.readByte();
|
||||||
|
|
||||||
|
@ -316,7 +433,36 @@ void loadSavegameDataSub5(Common::File& currentSaveFile) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void loadSavegameDataSub6(Common::File& currentSaveFile) {
|
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) {
|
||||||
int32 var;
|
int32 var;
|
||||||
|
|
||||||
var = currentSaveFile.readUint32LE();
|
var = currentSaveFile.readUint32LE();
|
||||||
|
@ -345,6 +491,160 @@ void loadSavegameDataSub6(Common::File& currentSaveFile) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int saveSavegameData(int saveGameIdx) {
|
int saveSavegameData(int saveGameIdx) {
|
||||||
|
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);
|
||||||
|
|
||||||
|
char dummy[6] = { 0, 0, 0, 0, 0, 0 };
|
||||||
|
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);
|
||||||
|
char dummy[1] = {0};
|
||||||
|
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);
|
||||||
|
char dummy[4] = { 0, 0, 0, 0 };
|
||||||
|
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);
|
||||||
|
char dummy[4] = { 0, 0, 0, 0 };
|
||||||
|
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;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -356,10 +656,11 @@ int loadSavegameData(int saveGameIdx) {
|
||||||
|
|
||||||
sprintf(buffer, "CR.%d", saveGameIdx);
|
sprintf(buffer, "CR.%d", saveGameIdx);
|
||||||
|
|
||||||
Common::File currentSaveFile;
|
Common::SaveFileManager *saveMan = g_system->getSavefileManager();
|
||||||
currentSaveFile.open(buffer);
|
Common::InSaveFile *currentSaveFile;
|
||||||
|
currentSaveFile = saveMan->openForLoading(buffer);
|
||||||
|
|
||||||
if (!currentSaveFile.isOpen()) {
|
if (currentSaveFile == NULL) {
|
||||||
printInfoBlackBox("Savegame not found...");
|
printInfoBlackBox("Savegame not found...");
|
||||||
waitForPlayerInput();
|
waitForPlayerInput();
|
||||||
return (-1);
|
return (-1);
|
||||||
|
@ -367,150 +668,150 @@ int loadSavegameData(int saveGameIdx) {
|
||||||
|
|
||||||
printInfoBlackBox("Loading in progress...");
|
printInfoBlackBox("Loading in progress...");
|
||||||
|
|
||||||
currentSaveFile.read(saveIdentBuffer, 6);
|
currentSaveFile->read(saveIdentBuffer, 6);
|
||||||
|
|
||||||
if (strcmp(saveIdentBuffer, "SAVPC")) {
|
if (strcmp(saveIdentBuffer, "SAVPC")) {
|
||||||
currentSaveFile.close();
|
delete currentSaveFile;
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
initVars();
|
initVars();
|
||||||
|
|
||||||
songLoaded = currentSaveFile.readSint16LE();
|
songLoaded = currentSaveFile->readSint16LE();
|
||||||
songPlayed = currentSaveFile.readSint16LE();
|
songPlayed = currentSaveFile->readSint16LE();
|
||||||
songLoop = currentSaveFile.readSint16LE();
|
songLoop = currentSaveFile->readSint16LE();
|
||||||
activeMouse = currentSaveFile.readSint16LE();
|
activeMouse = currentSaveFile->readSint16LE();
|
||||||
userEnabled = currentSaveFile.readSint16LE();
|
userEnabled = currentSaveFile->readSint16LE();
|
||||||
dialogueEnabled = currentSaveFile.readSint16LE();
|
dialogueEnabled = currentSaveFile->readSint16LE();
|
||||||
|
|
||||||
dialogueOvl = currentSaveFile.readSint16LE();
|
dialogueOvl = currentSaveFile->readSint16LE();
|
||||||
dialogueObj = currentSaveFile.readSint16LE();
|
dialogueObj = currentSaveFile->readSint16LE();
|
||||||
userDelay = currentSaveFile.readSint16LE();
|
userDelay = currentSaveFile->readSint16LE();
|
||||||
sysKey = currentSaveFile.readSint16LE();
|
sysKey = currentSaveFile->readSint16LE();
|
||||||
sysX = currentSaveFile.readSint16LE();
|
sysX = currentSaveFile->readSint16LE();
|
||||||
sysY = currentSaveFile.readSint16LE();
|
sysY = currentSaveFile->readSint16LE();
|
||||||
automoveInc = currentSaveFile.readSint16LE();
|
automoveInc = currentSaveFile->readSint16LE();
|
||||||
automoveMax = currentSaveFile.readSint16LE();
|
automoveMax = currentSaveFile->readSint16LE();
|
||||||
displayOn = currentSaveFile.readSint16LE();
|
displayOn = currentSaveFile->readSint16LE();
|
||||||
isMessage = currentSaveFile.readSint16LE();
|
isMessage = currentSaveFile->readSint16LE();
|
||||||
fadeFlag = currentSaveFile.readSint16LE();
|
fadeFlag = currentSaveFile->readSint16LE();
|
||||||
playMusic = currentSaveFile.readSint16LE();
|
playMusic = currentSaveFile->readSint16LE();
|
||||||
playMusic2 = currentSaveFile.readSint16LE();
|
playMusic2 = currentSaveFile->readSint16LE();
|
||||||
automaticMode = currentSaveFile.readSint16LE();
|
automaticMode = currentSaveFile->readSint16LE();
|
||||||
|
|
||||||
// video param (not loaded in EGA mode)
|
// video param (not loaded in EGA mode)
|
||||||
|
|
||||||
titleColor = currentSaveFile.readSint16LE();
|
titleColor = currentSaveFile->readSint16LE();
|
||||||
itemColor = currentSaveFile.readSint16LE();
|
itemColor = currentSaveFile->readSint16LE();
|
||||||
selectColor = currentSaveFile.readSint16LE();
|
selectColor = currentSaveFile->readSint16LE();
|
||||||
subColor = currentSaveFile.readSint16LE();
|
subColor = currentSaveFile->readSint16LE();
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
||||||
narratorOvl = currentSaveFile.readSint16LE();
|
narratorOvl = currentSaveFile->readSint16LE();
|
||||||
narratorIdx = currentSaveFile.readSint16LE();
|
narratorIdx = currentSaveFile->readSint16LE();
|
||||||
aniX = currentSaveFile.readSint16LE();
|
aniX = currentSaveFile->readSint16LE();
|
||||||
aniY = currentSaveFile.readSint16LE();
|
aniY = currentSaveFile->readSint16LE();
|
||||||
|
|
||||||
if(currentSaveFile.readSint16LE()) // cast to bool
|
if(currentSaveFile->readSint16LE()) // cast to bool
|
||||||
animationStart = true;
|
animationStart = true;
|
||||||
else
|
else
|
||||||
animationStart = false;
|
animationStart = false;
|
||||||
|
|
||||||
currentActiveBackgroundPlane = currentSaveFile.readSint16LE();
|
currentActiveBackgroundPlane = currentSaveFile->readSint16LE();
|
||||||
switchPal = currentSaveFile.readSint16LE();
|
switchPal = currentSaveFile->readSint16LE();
|
||||||
scroll = currentSaveFile.readSint16LE();
|
scroll = currentSaveFile->readSint16LE();
|
||||||
fadeFlag = currentSaveFile.readSint16LE();
|
fadeFlag = currentSaveFile->readSint16LE();
|
||||||
doFade = currentSaveFile.readSint16LE();
|
doFade = currentSaveFile->readSint16LE();
|
||||||
numOfLoadedOverlay = currentSaveFile.readSint16LE();
|
numOfLoadedOverlay = currentSaveFile->readSint16LE();
|
||||||
stateID = currentSaveFile.readSint16LE();
|
stateID = currentSaveFile->readSint16LE();
|
||||||
fontFileIndex = currentSaveFile.readSint16LE();
|
fontFileIndex = currentSaveFile->readSint16LE();
|
||||||
currentActiveMenu = currentSaveFile.readSint16LE();
|
currentActiveMenu = currentSaveFile->readSint16LE();
|
||||||
userWait = currentSaveFile.readSint16LE();
|
userWait = currentSaveFile->readSint16LE();
|
||||||
autoOvl = currentSaveFile.readSint16LE();
|
autoOvl = currentSaveFile->readSint16LE();
|
||||||
autoMsg = currentSaveFile.readSint16LE();
|
autoMsg = currentSaveFile->readSint16LE();
|
||||||
autoTrack = currentSaveFile.readSint16LE();
|
autoTrack = currentSaveFile->readSint16LE();
|
||||||
var39 = currentSaveFile.readSint16LE();
|
var39 = currentSaveFile->readSint16LE();
|
||||||
var42 = currentSaveFile.readSint16LE();
|
var42 = currentSaveFile->readSint16LE();
|
||||||
var45 = currentSaveFile.readSint16LE();
|
var45 = currentSaveFile->readSint16LE();
|
||||||
var46 = currentSaveFile.readSint16LE();
|
var46 = currentSaveFile->readSint16LE();
|
||||||
var47 = currentSaveFile.readSint16LE();
|
var47 = currentSaveFile->readSint16LE();
|
||||||
var48 = currentSaveFile.readSint16LE();
|
var48 = currentSaveFile->readSint16LE();
|
||||||
flagCt = currentSaveFile.readSint16LE();
|
flagCt = currentSaveFile->readSint16LE();
|
||||||
var41 = currentSaveFile.readSint16LE();
|
var41 = currentSaveFile->readSint16LE();
|
||||||
entrerMenuJoueur = currentSaveFile.readSint16LE();
|
entrerMenuJoueur = currentSaveFile->readSint16LE();
|
||||||
|
|
||||||
currentSaveFile.read(var50, 64);
|
currentSaveFile->read(var50, 64);
|
||||||
currentSaveFile.read(var50, 64); // Hu ? why 2 times ?
|
currentSaveFile->read(var50, 64); // Hu ? why 2 times ?
|
||||||
|
|
||||||
// here code seems bogus... this should read music name and it may be a buffer overrun
|
// here code seems bogus... this should read music name and it may be a buffer overrun
|
||||||
currentSaveFile.skip(21);
|
currentSaveFile->skip(21);
|
||||||
|
|
||||||
currentSaveFile.read(currentCtpName, 40);
|
currentSaveFile->read(currentCtpName, 40);
|
||||||
|
|
||||||
// restore backgroundTable
|
// restore backgroundTable
|
||||||
for(int i=0; i<8; i++)
|
for(int i=0; i<8; i++)
|
||||||
{
|
{
|
||||||
currentSaveFile.read(backgroundTable[i].name, 9);
|
currentSaveFile->read(backgroundTable[i].name, 9);
|
||||||
currentSaveFile.read(backgroundTable[i].extention, 6);
|
currentSaveFile->read(backgroundTable[i].extention, 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
currentSaveFile.read(palette, 256*2);
|
currentSaveFile->read(palette, 256*2);
|
||||||
currentSaveFile.read(initVar5, 24);
|
currentSaveFile->read(initVar5, 24);
|
||||||
currentSaveFile.read(globalVars, stateID * 2); // ok
|
currentSaveFile->read(globalVars, stateID * 2); // ok
|
||||||
for(int i=0; i<257; i++)
|
for(int i=0; i<257; i++)
|
||||||
{
|
{
|
||||||
filesDatabase[i].widthInColumn = currentSaveFile.readUint16LE();
|
filesDatabase[i].widthInColumn = currentSaveFile->readUint16LE();
|
||||||
filesDatabase[i].width = currentSaveFile.readUint16LE();
|
filesDatabase[i].width = currentSaveFile->readUint16LE();
|
||||||
filesDatabase[i].resType = currentSaveFile.readUint16LE();
|
filesDatabase[i].resType = currentSaveFile->readUint16LE();
|
||||||
filesDatabase[i].height = currentSaveFile.readUint16LE();
|
filesDatabase[i].height = currentSaveFile->readUint16LE();
|
||||||
filesDatabase[i].subData.ptr = (uint8*)currentSaveFile.readSint32LE();
|
filesDatabase[i].subData.ptr = (uint8*)currentSaveFile->readSint32LE();
|
||||||
filesDatabase[i].subData.index = currentSaveFile.readSint16LE();
|
filesDatabase[i].subData.index = currentSaveFile->readSint16LE();
|
||||||
currentSaveFile.read(filesDatabase[i].subData.name, 13);
|
currentSaveFile->read(filesDatabase[i].subData.name, 13);
|
||||||
currentSaveFile.skip(1);
|
currentSaveFile->skip(1);
|
||||||
filesDatabase[i].subData.transparency = currentSaveFile.readSint16LE();
|
filesDatabase[i].subData.transparency = currentSaveFile->readSint16LE();
|
||||||
filesDatabase[i].subData.ptrMask = (uint8*)currentSaveFile.readSint32LE();
|
filesDatabase[i].subData.ptrMask = (uint8*)currentSaveFile->readSint32LE();
|
||||||
filesDatabase[i].subData.resourceType = currentSaveFile.readByte();
|
filesDatabase[i].subData.resourceType = currentSaveFile->readByte();
|
||||||
currentSaveFile.skip(1);
|
currentSaveFile->skip(1);
|
||||||
filesDatabase[i].subData.compression = currentSaveFile.readSint16LE();
|
filesDatabase[i].subData.compression = currentSaveFile->readSint16LE();
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int i=0; i<numOfLoadedOverlay; i++)
|
for(int i=0; i<numOfLoadedOverlay; i++)
|
||||||
{
|
{
|
||||||
currentSaveFile.read(overlayTable[i].overlayName, 13);
|
currentSaveFile->read(overlayTable[i].overlayName, 13);
|
||||||
currentSaveFile.skip(1);
|
currentSaveFile->skip(1);
|
||||||
currentSaveFile.skip(4);
|
currentSaveFile->skip(4);
|
||||||
overlayTable[i].alreadyLoaded = currentSaveFile.readSint16LE();
|
overlayTable[i].alreadyLoaded = currentSaveFile->readSint16LE();
|
||||||
overlayTable[i].state = currentSaveFile.readSint16LE();
|
overlayTable[i].state = currentSaveFile->readSint16LE();
|
||||||
currentSaveFile.skip(4);
|
currentSaveFile->skip(4);
|
||||||
currentSaveFile.skip(4);
|
currentSaveFile->skip(4);
|
||||||
currentSaveFile.skip(4);
|
currentSaveFile->skip(4);
|
||||||
currentSaveFile.skip(4);
|
currentSaveFile->skip(4);
|
||||||
overlayTable[i].executeScripts = currentSaveFile.readSint16LE();
|
overlayTable[i].executeScripts = currentSaveFile->readSint16LE();
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int i=0; i<64; i++)
|
for(int i=0; i<64; i++)
|
||||||
{
|
{
|
||||||
currentSaveFile.read(preloadData[i].name, 15);
|
currentSaveFile->read(preloadData[i].name, 15);
|
||||||
currentSaveFile.skip(1);
|
currentSaveFile->skip(1);
|
||||||
preloadData[i].size = currentSaveFile.readSint32LE();
|
preloadData[i].size = currentSaveFile->readSint32LE();
|
||||||
preloadData[i].sourceSize = currentSaveFile.readSint32LE();
|
preloadData[i].sourceSize = currentSaveFile->readSint32LE();
|
||||||
currentSaveFile.skip(4);
|
currentSaveFile->skip(4);
|
||||||
preloadData[i].nofree = currentSaveFile.readSint16LE();
|
preloadData[i].nofree = currentSaveFile->readSint16LE();
|
||||||
preloadData[i].protect = currentSaveFile.readSint16LE();
|
preloadData[i].protect = currentSaveFile->readSint16LE();
|
||||||
preloadData[i].ovl = currentSaveFile.readSint16LE();
|
preloadData[i].ovl = currentSaveFile->readSint16LE();
|
||||||
}
|
}
|
||||||
|
|
||||||
loadSavegameDataSub1(currentSaveFile);
|
loadSavegameDataSub1(*currentSaveFile);
|
||||||
loadScriptsFromSave(currentSaveFile, &procHead);
|
loadScriptsFromSave(*currentSaveFile, &procHead);
|
||||||
loadScriptsFromSave(currentSaveFile, &relHead);
|
loadScriptsFromSave(*currentSaveFile, &relHead);
|
||||||
|
|
||||||
loadSavegameDataSub2(currentSaveFile);
|
loadSavegameDataSub2(*currentSaveFile);
|
||||||
loadBackgroundIncrustFromSave(currentSaveFile);
|
loadBackgroundIncrustFromSave(*currentSaveFile);
|
||||||
loadSavegameActor(currentSaveFile);
|
loadSavegameActor(*currentSaveFile);
|
||||||
loadSavegameDataSub5(currentSaveFile);
|
loadSavegameDataSub5(*currentSaveFile);
|
||||||
loadSavegameDataSub6(currentSaveFile);
|
loadSavegameDataSub6(*currentSaveFile);
|
||||||
|
|
||||||
currentSaveFile.close();
|
delete currentSaveFile;
|
||||||
|
|
||||||
for (int j = 0; j < 64; j++) {
|
for (int j = 0; j < 64; j++) {
|
||||||
preloadData[j].ptr = NULL;
|
preloadData[j].ptr = NULL;
|
||||||
|
@ -571,11 +872,11 @@ int loadSavegameData(int saveGameIdx) {
|
||||||
filesDatabase[k].subData.ptrMask = NULL;
|
filesDatabase[k].subData.ptrMask = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (j < 2) {
|
/*if (j < 2) {
|
||||||
printf("Unsupported mono file load!\n");
|
printf("Unsupported mono file load!\n");
|
||||||
ASSERT(0);
|
ASSERT(0);
|
||||||
//loadFileMode1(filesDatabase[j].subData.name,filesDatabase[j].subData.var4);
|
//loadFileMode1(filesDatabase[j].subData.name,filesDatabase[j].subData.var4);
|
||||||
} else {
|
} else */{
|
||||||
loadFileRange(filesDatabase[i].subData.name, filesDatabase[i].subData.index, i, j - i);
|
loadFileRange(filesDatabase[i].subData.name, filesDatabase[i].subData.index, i, j - i);
|
||||||
i = j - 1;
|
i = j - 1;
|
||||||
}
|
}
|
||||||
|
@ -622,7 +923,7 @@ int loadSavegameData(int saveGameIdx) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
regenerateBackgroundIncrust(&backgroundIncrustHead);
|
//regenerateBackgroundIncrust(&backgroundIncrustHead);
|
||||||
|
|
||||||
// to finish
|
// to finish
|
||||||
|
|
||||||
|
|
|
@ -52,54 +52,62 @@ short int getShortFromScript(void) {
|
||||||
|
|
||||||
// load opcode
|
// load opcode
|
||||||
int32 opcodeType0(void) {
|
int32 opcodeType0(void) {
|
||||||
|
int index = 0;
|
||||||
|
|
||||||
switch (currentScriptOpcodeType) {
|
switch (currentScriptOpcodeType) {
|
||||||
case 0:
|
case 0:
|
||||||
{
|
{
|
||||||
pushVar(getShortFromScript());
|
pushVar(getShortFromScript());
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
case 5:
|
||||||
|
index = saveOpcodeVar;
|
||||||
case 1:
|
case 1:
|
||||||
{
|
{
|
||||||
uint8 *ptr = 0;
|
uint8 *address = 0;
|
||||||
int byte1 = getByteFromScript();
|
int type = getByteFromScript();
|
||||||
int byte2 = getByteFromScript();
|
int ovl = getByteFromScript();
|
||||||
short int short1 = getShortFromScript();
|
short int offset;
|
||||||
|
short int firstOffset = offset = getShortFromScript();
|
||||||
|
offset += index;
|
||||||
|
|
||||||
int var_E = byte1 & 7;
|
int typ7 = type & 7;
|
||||||
|
|
||||||
if (!var_E) {
|
if (!typ7) {
|
||||||
return (-10);
|
return (-10); // unresloved link
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!byte2) {
|
if (!ovl) {
|
||||||
ptr = scriptDataPtrTable[var_E] + short1;
|
address = scriptDataPtrTable[typ7];
|
||||||
} else { // TODO:
|
} else { // TODO:
|
||||||
if (!overlayTable[byte2].alreadyLoaded) {
|
if (!overlayTable[ovl].alreadyLoaded) {
|
||||||
return (-7);
|
return (-7);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!overlayTable[byte2].ovlData) {
|
if (!overlayTable[ovl].ovlData) {
|
||||||
return (-4);
|
return (-4);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (var_E == 5) {
|
if (typ7 == 5) {
|
||||||
ptr =
|
address = overlayTable[ovl].ovlData->data4Ptr;
|
||||||
overlayTable[byte2].ovlData->
|
|
||||||
data4Ptr + short1;
|
|
||||||
} else {
|
} else {
|
||||||
assert(0);
|
assert(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (((byte1 & 0x18) >> 3) == 1) {
|
address += offset;
|
||||||
pushVar(loadShort(ptr));
|
|
||||||
|
int size = (type >> 3) & 3;
|
||||||
|
|
||||||
|
if (size == 1) {
|
||||||
|
address += index;
|
||||||
|
pushVar(loadShort(address));
|
||||||
return (0);
|
return (0);
|
||||||
} else if (((byte1 & 0x18) >> 3) == 2) {
|
} else if (size == 2) {
|
||||||
pushVar(*ptr);
|
pushVar(*address);
|
||||||
return (0);
|
return (0);
|
||||||
} else {
|
} else {
|
||||||
printf
|
printf("Unsupported code in opcodeType0 case 1!\n");
|
||||||
("Unsupported code in opcodeType0 case 1!\n");
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,57 +133,6 @@ int32 opcodeType0(void) {
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 5:
|
|
||||||
{
|
|
||||||
int byte1 = getByteFromScript();
|
|
||||||
int byte2 = getByteFromScript();
|
|
||||||
short int short1 = getShortFromScript();
|
|
||||||
|
|
||||||
short int var_12 = short1;
|
|
||||||
// short int var_10 = saveOpcodeVar;
|
|
||||||
|
|
||||||
int var_E = byte1 & 7;
|
|
||||||
|
|
||||||
uint8 *ptr = 0;
|
|
||||||
|
|
||||||
if (!var_E) {
|
|
||||||
return (-10);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!byte2) {
|
|
||||||
ptr = scriptDataPtrTable[var_E] + var_12;
|
|
||||||
} else { // TODO:
|
|
||||||
if (!overlayTable[byte2].alreadyLoaded) {
|
|
||||||
return (-7);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!overlayTable[byte2].ovlData) {
|
|
||||||
return (-4);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (var_E == 5) {
|
|
||||||
ptr =
|
|
||||||
overlayTable[byte2].ovlData->
|
|
||||||
data4Ptr + var_12;
|
|
||||||
} else {
|
|
||||||
assert(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (((byte1 & 0x18) >> 3) == 1) {
|
|
||||||
pushVar(loadShort(ptr + saveOpcodeVar * 2)); // TODO: check this !
|
|
||||||
return (0);
|
|
||||||
} else if (((byte1 & 0x18) >> 3) == 2) {
|
|
||||||
pushVar(*(ptr + saveOpcodeVar));
|
|
||||||
return (0);
|
|
||||||
} else {
|
|
||||||
printf
|
|
||||||
("Unsupported code in opcodeType0 case 1!\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
printf("Unsupported type %d in opcodeType0\n",
|
printf("Unsupported type %d in opcodeType0\n",
|
||||||
|
@ -681,6 +638,11 @@ int executeScripts(scriptInstanceStruct *ptr) {
|
||||||
|
|
||||||
numScript2 = ptr->scriptNumber;
|
numScript2 = ptr->scriptNumber;
|
||||||
|
|
||||||
|
if(ptr->overlayNumber == 66)
|
||||||
|
{
|
||||||
|
ptr->overlayNumber= ptr->overlayNumber;
|
||||||
|
}
|
||||||
|
|
||||||
if (ptr->type == 20) {
|
if (ptr->type == 20) {
|
||||||
ptr2 = getOvlData3Entry(ptr->overlayNumber, numScript2);
|
ptr2 = getOvlData3Entry(ptr->overlayNumber, numScript2);
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,10 @@ int32 volumeDataLoaded = 0;
|
||||||
|
|
||||||
int16 numOfDisks;
|
int16 numOfDisks;
|
||||||
|
|
||||||
char currentOverlay[15];
|
char musicName[15];
|
||||||
|
char lastOverlay[15];
|
||||||
|
char nextOverlay[15];
|
||||||
|
|
||||||
int16 currentActiveMenu;
|
int16 currentActiveMenu;
|
||||||
int16 autoMsg;
|
int16 autoMsg;
|
||||||
menuElementSubStruct* linkedRelation;
|
menuElementSubStruct* linkedRelation;
|
||||||
|
@ -143,7 +146,7 @@ int16 flagCt;
|
||||||
int8 var50[64];
|
int8 var50[64];
|
||||||
int16 palette[256 * 3];
|
int16 palette[256 * 3];
|
||||||
|
|
||||||
systemStringsStruct systemStrings;
|
//systemStringsStruct systemStrings;
|
||||||
|
|
||||||
char currentCtpName[40];
|
char currentCtpName[40];
|
||||||
|
|
||||||
|
|
|
@ -130,13 +130,13 @@ struct dataFileEntry {
|
||||||
uint16 height;
|
uint16 height;
|
||||||
dataFileEntrySub subData;
|
dataFileEntrySub subData;
|
||||||
};
|
};
|
||||||
|
/*
|
||||||
struct systemStringsStruct {
|
struct systemStringsStruct {
|
||||||
int8 param;
|
int8 param;
|
||||||
char string[12];
|
char string[12];
|
||||||
char bootScriptName[8];
|
char bootScriptName[8];
|
||||||
};
|
};
|
||||||
|
*/
|
||||||
extern preloadStruct preloadData[64];
|
extern preloadStruct preloadData[64];
|
||||||
|
|
||||||
extern volumeDataStruct volumeData[20];
|
extern volumeDataStruct volumeData[20];
|
||||||
|
@ -145,7 +145,10 @@ extern int32 volumeDataLoaded;
|
||||||
|
|
||||||
extern int16 numOfDisks;
|
extern int16 numOfDisks;
|
||||||
|
|
||||||
extern char currentOverlay[15];
|
extern char musicName[15];
|
||||||
|
extern char lastOverlay[15];
|
||||||
|
extern char nextOverlay[15];
|
||||||
|
|
||||||
extern int16 currentActiveMenu;
|
extern int16 currentActiveMenu;
|
||||||
extern int16 autoMsg;
|
extern int16 autoMsg;
|
||||||
extern menuElementSubStruct* linkedRelation;
|
extern menuElementSubStruct* linkedRelation;
|
||||||
|
@ -235,7 +238,7 @@ extern int16 flagCt;
|
||||||
extern int8 var50[64];
|
extern int8 var50[64];
|
||||||
extern int16 palette[256 * 3];
|
extern int16 palette[256 * 3];
|
||||||
|
|
||||||
extern systemStringsStruct systemStrings;
|
//extern systemStringsStruct systemStrings;
|
||||||
|
|
||||||
extern char currentCtpName[40];
|
extern char currentCtpName[40];
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue