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;
|
||||
}
|
||||
|
||||
perso = persoTable[i] =
|
||||
(persoStruct *) malloc(sizeof(persoStruct));
|
||||
perso = persoTable[i] = (persoStruct *) malloc(sizeof(persoStruct));
|
||||
|
||||
ptr = perso->solution[0];
|
||||
|
||||
|
|
|
@ -186,7 +186,56 @@ backgroundIncrustStruct *addBackgroundIncrust(int16 overlayIdx, int16 objectIdx,
|
|||
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;
|
||||
int32 i;
|
||||
|
||||
|
|
|
@ -56,7 +56,8 @@ extern backgroundIncrustStruct backgroundIncrustHead;
|
|||
|
||||
void resetBackgroundIncrustList(backgroundIncrustStruct * pHead);
|
||||
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 freeBackgroundIncrustList(backgroundIncrustStruct * pHead);
|
||||
void removeBackgroundIncrust(int overlay, int idx, backgroundIncrustStruct * pHead);
|
||||
|
|
|
@ -22,9 +22,10 @@
|
|||
* $Id$
|
||||
*
|
||||
*/
|
||||
|
||||
#include "cruise/cruise_main.h"
|
||||
#include "common/file.h"
|
||||
#include "cruise/cell.h"
|
||||
#include "cruise/cruise_main.h"
|
||||
|
||||
namespace Cruise {
|
||||
|
||||
|
@ -43,8 +44,55 @@ void freeMessageList(cellStruct *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;
|
||||
int i;
|
||||
cellStruct *p;
|
||||
|
|
|
@ -65,7 +65,8 @@ struct cellStruct {
|
|||
extern cellStruct cellHead;
|
||||
|
||||
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);
|
||||
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 );
|
||||
|
|
|
@ -572,7 +572,7 @@ int initAllData(void) {
|
|||
scriptFunc2(bootOverlayNumber, &procHead, 1, 0);
|
||||
}
|
||||
|
||||
strcpy(systemStrings.bootScriptName, "AUTO00");
|
||||
strcpy(lastOverlay, "AUTO00");
|
||||
|
||||
return (bootOverlayNumber);
|
||||
}
|
||||
|
@ -652,7 +652,7 @@ int findObject(int mouseX, int mouseY, int *outObjOvl, int *outObjIdx) {
|
|||
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) {
|
||||
int x = params.X + x2;
|
||||
int y = params.Y + y2;
|
||||
|
@ -990,7 +990,7 @@ bool findRelation(int objOvl, int objIdx, int x, int y) {
|
|||
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);
|
||||
|
||||
|
@ -1124,7 +1124,7 @@ void callSubRelation(menuElementSubStruct *pMenuElement, int nOvl, int nObj) {
|
|||
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(currentScriptPtr)
|
||||
{
|
||||
|
@ -1738,9 +1738,10 @@ void mainLoop(void) {
|
|||
|
||||
int enableUser = 0;
|
||||
|
||||
strcpy(currentOverlay, "");
|
||||
systemStrings.bootScriptName[0] = 0;
|
||||
cmdLine[0] = 0;
|
||||
strcpy(nextOverlay, "");
|
||||
strcpy(lastOverlay, "");
|
||||
strcpy(cmdLine, "");
|
||||
|
||||
currentActiveMenu = -1;
|
||||
autoMsg = -1;
|
||||
linkedRelation = 0;
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
|
||||
|
||||
#include "common/scummsys.h"
|
||||
#include "common/savefile.h"
|
||||
|
||||
#include "cruise/overlay.h"
|
||||
#include "cruise/object.h"
|
||||
|
|
|
@ -393,9 +393,7 @@ int loadCtp(const char *ctpName) {
|
|||
{
|
||||
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...
|
||||
ctpVar13 = ctpVar11 = polyStruct =
|
||||
(ctpVar19Struct *) malloc(numOfUsedEntries *
|
||||
sizeof(ctpVar19Struct));
|
||||
ctpVar13 = ctpVar11 = polyStruct = (ctpVar19Struct *) malloc(numOfUsedEntries * sizeof(ctpVar19Struct));
|
||||
}
|
||||
|
||||
walkboxCounter = numberOfWalkboxes;
|
||||
|
|
|
@ -54,7 +54,7 @@ int16 Op_LoadOverlay(void) {
|
|||
|
||||
updateAllScriptsImports();
|
||||
|
||||
strcpy(currentOverlay, overlayName);
|
||||
strcpy(nextOverlay, overlayName);
|
||||
|
||||
return(overlayLoadResult);
|
||||
}
|
||||
|
@ -123,10 +123,10 @@ int16 Op_AddProc(void) {
|
|||
int pop1 = popVar();
|
||||
int pop2;
|
||||
int overlay;
|
||||
int param[160];
|
||||
|
||||
if (pop1 - 1 > 0) {
|
||||
printf("Unsuported arg pop in Op_6!\n");
|
||||
exit(1);
|
||||
for(long int i=0; i<pop1; i++) {
|
||||
param[i] = popVar();
|
||||
}
|
||||
|
||||
pop2 = popVar();
|
||||
|
@ -138,11 +138,14 @@ int16 Op_AddProc(void) {
|
|||
if (!overlay)
|
||||
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) {
|
||||
printf("Unsupported art send in op6!\n");
|
||||
exit(1);
|
||||
if (procBss) {
|
||||
for(long int i=0; i<pop1; i++) {
|
||||
int16* ptr = (int16*)(procBss+i*2);
|
||||
*ptr = param[i];
|
||||
flipShort(ptr);
|
||||
}
|
||||
}
|
||||
|
||||
return (0);
|
||||
|
@ -773,7 +776,7 @@ int16 Op_AutoCell(void) {
|
|||
objectParamsQuery params;
|
||||
|
||||
getMultipleObjectParam(overlay, obj, ¶ms);
|
||||
pObject->animCounter = params.var6 - 1;
|
||||
pObject->animCounter = params.state2 - 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -789,7 +792,7 @@ int16 Op_66(void) {
|
|||
|
||||
getMultipleObjectParam(overlay, index, ¶ms);
|
||||
|
||||
return params.var7 - 1;
|
||||
return params.nbState - 1;
|
||||
}
|
||||
|
||||
int16 Op_SetActiveBackgroundPlane(void) {
|
||||
|
|
|
@ -72,7 +72,7 @@ void freeAutoCell(void) {
|
|||
|
||||
getMultipleObjectParam(pCurrent->ovlIdx, pCurrent->objIdx, ¶ms);
|
||||
|
||||
pCurrent->pCell->animCounter = params.var6 - 1;
|
||||
pCurrent->pCell->animCounter = params.state2 - 1;
|
||||
}
|
||||
|
||||
delete pCurrent;
|
||||
|
@ -1320,11 +1320,11 @@ int getValueFromObjectQuerry(objectParamsQuery *params, int idx) {
|
|||
case 4:
|
||||
return params->scale;
|
||||
case 5:
|
||||
return params->var5;
|
||||
return params->state;
|
||||
case 6:
|
||||
return params->var6;
|
||||
return params->state2;
|
||||
case 7:
|
||||
return params->var7;
|
||||
return params->nbState;
|
||||
}
|
||||
|
||||
assert(0);
|
||||
|
@ -1396,7 +1396,7 @@ void mainDraw(int16 param) {
|
|||
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
|
||||
mainDrawPolygons(objZ2, currentObjPtr, objX2, params.scale, objY2, (char *)gfxModuleData.pPage10, (char *)filesDatabase[objZ2].subData.ptr); // poly
|
||||
} else if (filesDatabase[objZ2].subData.resourceType == 6) { // sound
|
||||
|
|
|
@ -207,7 +207,7 @@ int playerMenu(int menuX, int menuY) {
|
|||
|
||||
if (entrerMenuJoueur && displayOn) {
|
||||
if (remdo) {
|
||||
systemStrings.param = 0;
|
||||
musicName[0] = 0;
|
||||
playMusic2 = 0;
|
||||
playMusic = 0;
|
||||
freeStuff2();
|
||||
|
|
|
@ -108,9 +108,9 @@ int16 getMultipleObjectParam(int16 overlayIdx, int16 objectIdx, objectParamsQuer
|
|||
returnParam->baseFileIdx = ptr2->Z;
|
||||
returnParam->fileIdx = ptr2->frame;
|
||||
returnParam->scale = ptr2->scale;
|
||||
returnParam->var5 = state;
|
||||
returnParam->var6 = state2;
|
||||
returnParam->var7 = ptr->_numStates;
|
||||
returnParam->state = state;
|
||||
returnParam->state2 = state2;
|
||||
returnParam->nbState = ptr->_numStates;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -43,9 +43,9 @@ struct objectParamsQuery {
|
|||
int16 baseFileIdx;
|
||||
int16 fileIdx;
|
||||
int16 scale;
|
||||
int16 var5;
|
||||
int16 var6;
|
||||
int16 var7;
|
||||
int16 state;
|
||||
int16 state2;
|
||||
int16 nbState;
|
||||
};
|
||||
|
||||
objDataStruct *getObjectDataFromOverlay(int ovlIdx, int objIdx);
|
||||
|
|
|
@ -25,6 +25,9 @@
|
|||
|
||||
#include "cruise/cruise_main.h"
|
||||
|
||||
#include "common/savefile.h"
|
||||
#include "common/system.h"
|
||||
|
||||
namespace Cruise {
|
||||
|
||||
struct overlayRestoreTemporary {
|
||||
|
@ -184,10 +187,35 @@ void initVars(void)
|
|||
fadeVar = 0;
|
||||
}
|
||||
|
||||
void loadSavegameDataSub1(Common::File& currentSaveFile) {
|
||||
int i;
|
||||
void saveOverlay(Common::OutSaveFile& currentSaveFile) {
|
||||
|
||||
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]._pBss = 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;
|
||||
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;
|
||||
actorStruct *ptr;
|
||||
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) {
|
||||
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;
|
||||
|
||||
var = currentSaveFile.readUint32LE();
|
||||
|
@ -345,6 +491,160 @@ void loadSavegameDataSub6(Common::File& currentSaveFile) {
|
|||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -356,10 +656,11 @@ int loadSavegameData(int saveGameIdx) {
|
|||
|
||||
sprintf(buffer, "CR.%d", saveGameIdx);
|
||||
|
||||
Common::File currentSaveFile;
|
||||
currentSaveFile.open(buffer);
|
||||
Common::SaveFileManager *saveMan = g_system->getSavefileManager();
|
||||
Common::InSaveFile *currentSaveFile;
|
||||
currentSaveFile = saveMan->openForLoading(buffer);
|
||||
|
||||
if (!currentSaveFile.isOpen()) {
|
||||
if (currentSaveFile == NULL) {
|
||||
printInfoBlackBox("Savegame not found...");
|
||||
waitForPlayerInput();
|
||||
return (-1);
|
||||
|
@ -367,150 +668,150 @@ int loadSavegameData(int saveGameIdx) {
|
|||
|
||||
printInfoBlackBox("Loading in progress...");
|
||||
|
||||
currentSaveFile.read(saveIdentBuffer, 6);
|
||||
currentSaveFile->read(saveIdentBuffer, 6);
|
||||
|
||||
if (strcmp(saveIdentBuffer, "SAVPC")) {
|
||||
currentSaveFile.close();
|
||||
delete currentSaveFile;
|
||||
return (-1);
|
||||
}
|
||||
initVars();
|
||||
|
||||
songLoaded = currentSaveFile.readSint16LE();
|
||||
songPlayed = currentSaveFile.readSint16LE();
|
||||
songLoop = currentSaveFile.readSint16LE();
|
||||
activeMouse = currentSaveFile.readSint16LE();
|
||||
userEnabled = currentSaveFile.readSint16LE();
|
||||
dialogueEnabled = currentSaveFile.readSint16LE();
|
||||
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();
|
||||
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();
|
||||
|
||||
// video param (not loaded in EGA mode)
|
||||
|
||||
titleColor = currentSaveFile.readSint16LE();
|
||||
itemColor = currentSaveFile.readSint16LE();
|
||||
selectColor = currentSaveFile.readSint16LE();
|
||||
subColor = currentSaveFile.readSint16LE();
|
||||
titleColor = currentSaveFile->readSint16LE();
|
||||
itemColor = currentSaveFile->readSint16LE();
|
||||
selectColor = currentSaveFile->readSint16LE();
|
||||
subColor = currentSaveFile->readSint16LE();
|
||||
|
||||
//
|
||||
|
||||
narratorOvl = currentSaveFile.readSint16LE();
|
||||
narratorIdx = currentSaveFile.readSint16LE();
|
||||
aniX = currentSaveFile.readSint16LE();
|
||||
aniY = currentSaveFile.readSint16LE();
|
||||
narratorOvl = currentSaveFile->readSint16LE();
|
||||
narratorIdx = currentSaveFile->readSint16LE();
|
||||
aniX = currentSaveFile->readSint16LE();
|
||||
aniY = currentSaveFile->readSint16LE();
|
||||
|
||||
if(currentSaveFile.readSint16LE()) // cast to bool
|
||||
if(currentSaveFile->readSint16LE()) // cast to bool
|
||||
animationStart = true;
|
||||
else
|
||||
animationStart = false;
|
||||
|
||||
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();
|
||||
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 ?
|
||||
currentSaveFile->read(var50, 64);
|
||||
currentSaveFile->read(var50, 64); // Hu ? why 2 times ?
|
||||
|
||||
// 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
|
||||
for(int i=0; i<8; i++)
|
||||
{
|
||||
currentSaveFile.read(backgroundTable[i].name, 9);
|
||||
currentSaveFile.read(backgroundTable[i].extention, 6);
|
||||
currentSaveFile->read(backgroundTable[i].name, 9);
|
||||
currentSaveFile->read(backgroundTable[i].extention, 6);
|
||||
}
|
||||
|
||||
currentSaveFile.read(palette, 256*2);
|
||||
currentSaveFile.read(initVar5, 24);
|
||||
currentSaveFile.read(globalVars, stateID * 2); // ok
|
||||
currentSaveFile->read(palette, 256*2);
|
||||
currentSaveFile->read(initVar5, 24);
|
||||
currentSaveFile->read(globalVars, stateID * 2); // ok
|
||||
for(int i=0; i<257; i++)
|
||||
{
|
||||
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();
|
||||
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();
|
||||
}
|
||||
|
||||
for(int i=0; i<numOfLoadedOverlay; i++)
|
||||
{
|
||||
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();
|
||||
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();
|
||||
}
|
||||
|
||||
for(int i=0; i<64; i++)
|
||||
{
|
||||
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();
|
||||
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();
|
||||
}
|
||||
|
||||
loadSavegameDataSub1(currentSaveFile);
|
||||
loadScriptsFromSave(currentSaveFile, &procHead);
|
||||
loadScriptsFromSave(currentSaveFile, &relHead);
|
||||
loadSavegameDataSub1(*currentSaveFile);
|
||||
loadScriptsFromSave(*currentSaveFile, &procHead);
|
||||
loadScriptsFromSave(*currentSaveFile, &relHead);
|
||||
|
||||
loadSavegameDataSub2(currentSaveFile);
|
||||
loadBackgroundIncrustFromSave(currentSaveFile);
|
||||
loadSavegameActor(currentSaveFile);
|
||||
loadSavegameDataSub5(currentSaveFile);
|
||||
loadSavegameDataSub6(currentSaveFile);
|
||||
loadSavegameDataSub2(*currentSaveFile);
|
||||
loadBackgroundIncrustFromSave(*currentSaveFile);
|
||||
loadSavegameActor(*currentSaveFile);
|
||||
loadSavegameDataSub5(*currentSaveFile);
|
||||
loadSavegameDataSub6(*currentSaveFile);
|
||||
|
||||
currentSaveFile.close();
|
||||
delete currentSaveFile;
|
||||
|
||||
for (int j = 0; j < 64; j++) {
|
||||
preloadData[j].ptr = NULL;
|
||||
|
@ -571,11 +872,11 @@ int loadSavegameData(int saveGameIdx) {
|
|||
filesDatabase[k].subData.ptrMask = NULL;
|
||||
}
|
||||
|
||||
if (j < 2) {
|
||||
/*if (j < 2) {
|
||||
printf("Unsupported mono file load!\n");
|
||||
ASSERT(0);
|
||||
//loadFileMode1(filesDatabase[j].subData.name,filesDatabase[j].subData.var4);
|
||||
} else {
|
||||
} else */{
|
||||
loadFileRange(filesDatabase[i].subData.name, filesDatabase[i].subData.index, i, j - i);
|
||||
i = j - 1;
|
||||
}
|
||||
|
@ -622,7 +923,7 @@ int loadSavegameData(int saveGameIdx) {
|
|||
}
|
||||
}
|
||||
|
||||
regenerateBackgroundIncrust(&backgroundIncrustHead);
|
||||
//regenerateBackgroundIncrust(&backgroundIncrustHead);
|
||||
|
||||
// to finish
|
||||
|
||||
|
|
|
@ -52,54 +52,62 @@ short int getShortFromScript(void) {
|
|||
|
||||
// load opcode
|
||||
int32 opcodeType0(void) {
|
||||
int index = 0;
|
||||
|
||||
switch (currentScriptOpcodeType) {
|
||||
case 0:
|
||||
{
|
||||
pushVar(getShortFromScript());
|
||||
return (0);
|
||||
}
|
||||
case 5:
|
||||
index = saveOpcodeVar;
|
||||
case 1:
|
||||
{
|
||||
uint8 *ptr = 0;
|
||||
int byte1 = getByteFromScript();
|
||||
int byte2 = getByteFromScript();
|
||||
short int short1 = getShortFromScript();
|
||||
uint8 *address = 0;
|
||||
int type = getByteFromScript();
|
||||
int ovl = getByteFromScript();
|
||||
short int offset;
|
||||
short int firstOffset = offset = getShortFromScript();
|
||||
offset += index;
|
||||
|
||||
int var_E = byte1 & 7;
|
||||
int typ7 = type & 7;
|
||||
|
||||
if (!var_E) {
|
||||
return (-10);
|
||||
if (!typ7) {
|
||||
return (-10); // unresloved link
|
||||
}
|
||||
|
||||
if (!byte2) {
|
||||
ptr = scriptDataPtrTable[var_E] + short1;
|
||||
if (!ovl) {
|
||||
address = scriptDataPtrTable[typ7];
|
||||
} else { // TODO:
|
||||
if (!overlayTable[byte2].alreadyLoaded) {
|
||||
if (!overlayTable[ovl].alreadyLoaded) {
|
||||
return (-7);
|
||||
}
|
||||
|
||||
if (!overlayTable[byte2].ovlData) {
|
||||
if (!overlayTable[ovl].ovlData) {
|
||||
return (-4);
|
||||
}
|
||||
|
||||
if (var_E == 5) {
|
||||
ptr =
|
||||
overlayTable[byte2].ovlData->
|
||||
data4Ptr + short1;
|
||||
if (typ7 == 5) {
|
||||
address = overlayTable[ovl].ovlData->data4Ptr;
|
||||
} else {
|
||||
assert(0);
|
||||
}
|
||||
}
|
||||
|
||||
if (((byte1 & 0x18) >> 3) == 1) {
|
||||
pushVar(loadShort(ptr));
|
||||
address += offset;
|
||||
|
||||
int size = (type >> 3) & 3;
|
||||
|
||||
if (size == 1) {
|
||||
address += index;
|
||||
pushVar(loadShort(address));
|
||||
return (0);
|
||||
} else if (((byte1 & 0x18) >> 3) == 2) {
|
||||
pushVar(*ptr);
|
||||
} else if (size == 2) {
|
||||
pushVar(*address);
|
||||
return (0);
|
||||
} else {
|
||||
printf
|
||||
("Unsupported code in opcodeType0 case 1!\n");
|
||||
printf("Unsupported code in opcodeType0 case 1!\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
@ -125,57 +133,6 @@ int32 opcodeType0(void) {
|
|||
|
||||
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:
|
||||
{
|
||||
printf("Unsupported type %d in opcodeType0\n",
|
||||
|
@ -681,6 +638,11 @@ int executeScripts(scriptInstanceStruct *ptr) {
|
|||
|
||||
numScript2 = ptr->scriptNumber;
|
||||
|
||||
if(ptr->overlayNumber == 66)
|
||||
{
|
||||
ptr->overlayNumber= ptr->overlayNumber;
|
||||
}
|
||||
|
||||
if (ptr->type == 20) {
|
||||
ptr2 = getOvlData3Entry(ptr->overlayNumber, numScript2);
|
||||
|
||||
|
|
|
@ -51,7 +51,10 @@ int32 volumeDataLoaded = 0;
|
|||
|
||||
int16 numOfDisks;
|
||||
|
||||
char currentOverlay[15];
|
||||
char musicName[15];
|
||||
char lastOverlay[15];
|
||||
char nextOverlay[15];
|
||||
|
||||
int16 currentActiveMenu;
|
||||
int16 autoMsg;
|
||||
menuElementSubStruct* linkedRelation;
|
||||
|
@ -143,7 +146,7 @@ int16 flagCt;
|
|||
int8 var50[64];
|
||||
int16 palette[256 * 3];
|
||||
|
||||
systemStringsStruct systemStrings;
|
||||
//systemStringsStruct systemStrings;
|
||||
|
||||
char currentCtpName[40];
|
||||
|
||||
|
|
|
@ -130,13 +130,13 @@ struct dataFileEntry {
|
|||
uint16 height;
|
||||
dataFileEntrySub subData;
|
||||
};
|
||||
|
||||
/*
|
||||
struct systemStringsStruct {
|
||||
int8 param;
|
||||
char string[12];
|
||||
char bootScriptName[8];
|
||||
};
|
||||
|
||||
*/
|
||||
extern preloadStruct preloadData[64];
|
||||
|
||||
extern volumeDataStruct volumeData[20];
|
||||
|
@ -145,7 +145,10 @@ extern int32 volumeDataLoaded;
|
|||
|
||||
extern int16 numOfDisks;
|
||||
|
||||
extern char currentOverlay[15];
|
||||
extern char musicName[15];
|
||||
extern char lastOverlay[15];
|
||||
extern char nextOverlay[15];
|
||||
|
||||
extern int16 currentActiveMenu;
|
||||
extern int16 autoMsg;
|
||||
extern menuElementSubStruct* linkedRelation;
|
||||
|
@ -235,7 +238,7 @@ extern int16 flagCt;
|
|||
extern int8 var50[64];
|
||||
extern int16 palette[256 * 3];
|
||||
|
||||
extern systemStringsStruct systemStrings;
|
||||
//extern systemStringsStruct systemStrings;
|
||||
|
||||
extern char currentCtpName[40];
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue