diff options
-rw-r--r-- | engines/cruise/cruise_main.cpp | 313 | ||||
-rw-r--r-- | engines/cruise/decompiler.cpp | 22 | ||||
-rw-r--r-- | engines/cruise/linker.cpp | 62 | ||||
-rw-r--r-- | engines/cruise/mainDraw.cpp | 8 | ||||
-rw-r--r-- | engines/cruise/object.cpp | 20 | ||||
-rw-r--r-- | engines/cruise/overlay.cpp | 216 | ||||
-rw-r--r-- | engines/cruise/overlay.h | 56 | ||||
-rw-r--r-- | engines/cruise/saveload.cpp | 6 |
8 files changed, 337 insertions, 366 deletions
diff --git a/engines/cruise/cruise_main.cpp b/engines/cruise/cruise_main.cpp index 0b6ec91581..a3e847a98a 100644 --- a/engines/cruise/cruise_main.cpp +++ b/engines/cruise/cruise_main.cpp @@ -85,17 +85,17 @@ int loadScriptSub1(int scriptIdx, int param) { if (!overlayTable[scriptIdx].ovlData) return (0); - ptr2 = overlayTable[scriptIdx].ovlData->objDataTable; + ptr2 = overlayTable[scriptIdx].ovlData->arrayObject; if (!ptr2) return (0); - if (overlayTable[scriptIdx].ovlData->numObjData == 0) + if (overlayTable[scriptIdx].ovlData->numObj == 0) return (0); counter = 0; - for (i = 0; i < overlayTable[scriptIdx].ovlData->numObjData; i++) { + for (i = 0; i < overlayTable[scriptIdx].ovlData->numObj; i++) { if (ptr2[i].var0 == param) { counter++; } @@ -129,9 +129,9 @@ void resetFileEntryRange(int param1, int param2) { } int getProcParam(int overlayIdx, int param2, uint8 *name) { - int numExport; + int numSymbGlob; int i; - exportEntryStruct *exportDataPtr; + exportEntryStruct *arraySymbGlob; uint8 *exportNamePtr; uint8 exportName[80]; @@ -141,20 +141,20 @@ int getProcParam(int overlayIdx, int param2, uint8 *name) { if (!overlayTable[overlayIdx].ovlData) return 0; - numExport = overlayTable[overlayIdx].ovlData->numExport; - exportDataPtr = overlayTable[overlayIdx].ovlData->exportDataPtr; - exportNamePtr = overlayTable[overlayIdx].ovlData->exportNamesPtr; + numSymbGlob = overlayTable[overlayIdx].ovlData->numSymbGlob; + arraySymbGlob = overlayTable[overlayIdx].ovlData->arraySymbGlob; + exportNamePtr = overlayTable[overlayIdx].ovlData->arrayNameSymbGlob; if (!exportNamePtr) return 0; - for (i = 0; i < numExport; i++) { - if (exportDataPtr[i].var4 == param2) { + for (i = 0; i < numSymbGlob; i++) { + if (arraySymbGlob[i].var4 == param2) { strcpyuint8(exportName, - exportDataPtr[i].offsetToName + exportNamePtr); + arraySymbGlob[i].offsetToName + exportNamePtr); if (!strcmpuint8(exportName, name)) { - return (exportDataPtr[i].idx); + return (arraySymbGlob[i].idx); } } } @@ -212,15 +212,15 @@ ovlData3Struct *getOvlData3Entry(int32 scriptNumber, int32 param) { return NULL; } - if (ovlData->numScripts1 <= param) { + if (ovlData->numProc <= param) { return NULL; } - if (!ovlData->data3Table) { + if (!ovlData->arrayProc) { return NULL; } - return (&ovlData->data3Table[param]); + return (&ovlData->arrayProc[param]); } ovlData3Struct *scriptFunc1Sub2(int32 scriptNumber, int32 param) { @@ -234,7 +234,7 @@ ovlData3Struct *scriptFunc1Sub2(int32 scriptNumber, int32 param) { return NULL; } - if (ovlData->numScripts2 <= param) { + if (ovlData->numRel <= param) { return NULL; } @@ -617,7 +617,7 @@ int findObject(int mouseX, int mouseY, int *outObjOvl, int *outObjIdx) { if (currentObject->overlay >= 0 && overlayTable[currentObject->overlay].alreadyLoaded && (currentObject->type == OBJ_TYPE_SPRITE || currentObject->type == OBJ_TYPE_MASK || currentObject->type == OBJ_TYPE_EXIT || currentObject->type == OBJ_TYPE_VIRTUEL)) { - char* pObjectName = getObjectName(currentObject->idx, overlayTable[currentObject->overlay].ovlData->specialString2); + char* pObjectName = getObjectName(currentObject->idx, overlayTable[currentObject->overlay].ovlData->arrayNameObj); if(pObjectName) { strcpy(objectName, pObjectName); @@ -781,15 +781,15 @@ void buildInventory(int X, int Y) { for (int i = 1; i < numOfLoadedOverlay; i++) { ovlDataStruct *pOvlData = overlayTable[i].ovlData; - if (pOvlData && pOvlData->objDataTable && pOvlData->numObjData) { - for (int j = 0; j < pOvlData->numObjData; j++) { + if (pOvlData && pOvlData->arrayObject && pOvlData->numObj) { + for (int j = 0; j < pOvlData->numObj; j++) { if (buildInventorySub1(i, j) != 3) { int16 returnVar; getSingleObjectParam(i, j, 5, &returnVar); if (returnVar < -1) { - addSelectableMenuEntry(i, j, pMenu, 1, -1, getObjectName(j, pOvlData->specialString2)); + addSelectableMenuEntry(i, j, pMenu, 1, -1, getObjectName(j, pOvlData->arrayNameObj)); numObjectInInventory++; } } @@ -836,159 +836,100 @@ menuElementSubStruct *getSelectedEntryInMenu(menuStruct *pMenu) { return NULL; } -int callInventoryObject(int param0, int param1, int x, int y) { - int var_2C; - int var_30; - int var_28; - int var_1E; - int16 returnVar; +bool findRelation(int objOvl, int objIdx, int x, int y) { + bool found = false; + bool first = true; + int testState; + int j; + int16 objectState; - var_30 = -1; + testState = -1; - getSingleObjectParam(param0, param1, 5, &returnVar); + getSingleObjectParam(objOvl, objIdx, 5, &objectState); - var_2C = 0; - var_28 = 1; - - for (var_1E = 1; var_1E < numOfLoadedOverlay; var_1E++) { - ovlDataStruct *var_2A = overlayTable[var_1E].ovlData; - if (var_2A->ptr1) { - int var_18; - int var_14; - - var_18 = var_2A->numLinkData; + for (j = 1; j < numOfLoadedOverlay; j++) + { + if (overlayTable[j].alreadyLoaded) + { + int idHeader = overlayTable[j].ovlData->numMsgRelHeader; - if (var_18) { - int var_16; + int i; + for(i=0; i<idHeader; i++) + { + linkDataStruct* ptrHead = &overlayTable[j].ovlData->arrayMsgRelHeader[i]; + int thisOvl = ptrHead->obj1Overlay; - var_16 = 0; + if (!thisOvl) { + thisOvl = j; + } - for (var_14 = 0; var_14 < var_18; var_14++) { - objDataStruct *pObject; - linkDataStruct *var_34; - int var_2; + objDataStruct* pObject = getObjectDataFromOverlay(thisOvl, ptrHead->obj1Number); - var_34 = &var_2A->linkDataPtr[var_14]; + if ((thisOvl == objOvl) && (objIdx ==ptrHead->obj1Number) && pObject && pObject->type != 3) + { + int verbeOvl = ptrHead->verbOverlay; + int obj1Ovl = ptrHead->obj1Overlay; + int obj2Ovl = ptrHead->obj2Overlay; + + if (!verbeOvl) verbeOvl=j; + if (!obj1Ovl) obj1Ovl=j; + if (!obj2Ovl) obj2Ovl=j; + + char verbe_name[80]; + char obj1_name[80]; + char obj2_name[80]; + char r_verbe_name[80]; + char r_obj1_name[80]; + char r_obj2_name[80]; + + verbe_name[0] =0; + obj1_name[0] =0; + obj2_name[0] =0; + r_verbe_name[0] =0; + r_obj1_name[0] =0; + r_obj2_name[0] =0; + + ovlDataStruct *ovl2 = NULL; + ovlDataStruct *ovl3 = NULL; + ovlDataStruct *ovl4 = NULL; + + if(verbeOvl > 0) + ovl2 = overlayTable[verbeOvl].ovlData; + + if(obj1Ovl > 0) + ovl3 = overlayTable[obj1Ovl].ovlData; + + if(obj2Ovl > 0) + ovl4 = overlayTable[obj2Ovl].ovlData; + + if((ovl3) && (ptrHead->obj1Number >= 0)) + { + testState = ptrHead->field_1A; - var_2 = var_34->stringIdx; + if((first) && (ovl3->arrayNameObj) && ((testState ==-1) || (testState == objectState))) + { + char *ptrName = getObjectName(ptrHead->obj1Number, ovl3->arrayNameObj); - if (!var_2) { - var_2 = var_1E; + menuTable[0] = createMenu(x, y, ptrName); + first = false; + } } + if((ovl2) && (ptrHead->verbNumber)) + { + if(ovl2->nameVerbGlob) + { + char *ptr = getObjectName(ptrHead->verbNumber, ovl2->nameVerbGlob); + strcpy(verbe_name, ptr); - pObject = - getObjectDataFromOverlay(var_2, - var_34->stringNameOffset); - - if (var_2 == param0) { - if (param1 == var_34->stringNameOffset) { - if (pObject) { - if (pObject->type != 3) { - char var_214[80]; - char var_1C4[80]; - char var_174[80]; - char var_124[80]; - char var_D4[80]; - char var_84[80]; - - ovlDataStruct *var_12; - ovlDataStruct *var_22; - - int var_E = var_34->varIdx; - int cx = var_34->stringIdx; - int var_C = var_34->procIdx; - - int di = var_E; - if (var_E == 0) - di = var_1E; - - var_2 = cx; - if (cx == 0) - var_2 = var_1E; - - if (var_C == 0) - var_C = var_1E; - - var_12 = NULL; - var_22 = NULL; - - var_214[0] = 0; - var_1C4[0] = 0; - var_174[0] = 0; - var_124[0] = 0; - var_D4[0] = 0; - var_84[0] = 0; - - if (di > 0) { - var_22 = overlayTable[di].ovlData; - } - - if (var_2 > 0) { - var_12 = overlayTable[var_2].ovlData; - } - - if (var_12) { - if (var_34->stringNameOffset) { - var_30 = var_34->field_1A; - if (var_28) { - if (var_12->specialString2) { - if (var_30 == -1 || var_30 == returnVar) { - char *ptrName = getObjectName(var_34->stringNameOffset, var_12->specialString2); - - menuTable[0] = createMenu(x, y, ptrName); - var_28 = 0; - } - } - } - } - } - - if (var_22) { - if (true /*var_34->varNameOffset>=0 */ ) { // FIXME: This check is always true since varNameOffset is unsigned - if (var_22->specialString1) { - char *ptr = getObjectName(var_34->varNameOffset, var_22->specialString1); - - strcpy - (var_214, - ptr); - - if (var_28 == 0) { - if (var_30 == -1 || var_30 == returnVar) { - if (strlen(var_214)) { - attacheNewScriptToTail - (var_1E, - &relHead, - var_34-> - field_2, - 30, - currentScriptPtr-> - scriptNumber, - currentScriptPtr-> - overlayNumber, - scriptType_REL); - } else { - if (var_22->specialString1) { - ptr = getObjectName(var_34->varNameOffset, var_22->specialString1); - - var_2C - = - 1; - - addSelectableMenuEntry - (var_1E, - var_14, - menuTable - [0], - 1, - -1, - ptr); - } - } - } - } - } - } - } + if( (!first) && ((testState==-1) || (testState==objectState))) + { + if(!strlen(verbe_name)) + attacheNewScriptToTail(j, &relHead, ptrHead->id, 30, currentScriptPtr->scriptNumber, currentScriptPtr->overlayNumber, scriptType_REL); + else if(ovl2->nameVerbGlob) + { + found = true; + ptr = getObjectName(ptrHead->verbNumber, ovl2->nameVerbGlob); + addSelectableMenuEntry(i, j, menuTable[0], 1, -1, ptr); } } } @@ -998,7 +939,7 @@ int callInventoryObject(int param0, int param1, int x, int y) { } } - return var_2C; + return found; } int processInventory(void) { @@ -1016,8 +957,7 @@ int processInventory(void) { freeMenu(menuTable[1]); menuTable[1] = NULL; - callInventoryObject(var2, var4, - currentMenuElementX + 80, currentMenuElementY); + findRelation(var2, var4, currentMenuElementX + 80, currentMenuElementY); return 1; } else { @@ -1107,26 +1047,55 @@ int processInput(void) // Handle left click on an object if (menuTable[0] == 0) { - int X; - int Y; + int objOvl; int objIdx; + int objType; - objIdx = findObject(mouseX, mouseY, &X, &Y); + objType = findObject(mouseX, mouseY, &objOvl, &objIdx); - if (objIdx != -1) + if (objType != -1) { - ASSERT(0); + int relation = findRelation(objOvl, objIdx, mouseX, mouseY); + if(menuTable[0]) + { + if(relation) + { + currentActiveMenu = 0; + selectDown = 1; + } + else + { + // object has a name but no relation, just move the character + freeMenu(menuTable[0]); + menuTable[0] = NULL; + + aniX = mouseX; + aniY = mouseY; + animationStart = true; + buttonDown = 0; + } + } + else + { + aniX = mouseX; + aniY = mouseY; + animationStart = true; + buttonDown = 0; + } }else { // No object found, we move the character to the cursor aniX = mouseX; aniY = mouseY; animationStart = true; - menuDown = 0; + buttonDown = 0; } } else { - ASSERT(0); + aniX = mouseX; + aniY = mouseY; + animationStart = true; + buttonDown = 0; } } else diff --git a/engines/cruise/decompiler.cpp b/engines/cruise/decompiler.cpp index 0099eda4bf..260f5ddda2 100644 --- a/engines/cruise/decompiler.cpp +++ b/engines/cruise/decompiler.cpp @@ -142,7 +142,7 @@ void resolveDecompShort(char *buffer) { (importScriptStruct *) (data3Ptr->dataPtr + data3Ptr->offsetToImportData); - for (i = 0; i < data3Ptr->numImport; i++) { + for (i = 0; i < data3Ptr->numRelocGlob; i++) { switch (importEntry->type) { case 20: // script case 30: @@ -191,7 +191,7 @@ void resolveDecompChar(char *buffer) { (importScriptStruct *) (data3Ptr->dataPtr + data3Ptr->offsetToImportData); - for (i = 0; i < data3Ptr->numImport; i++) { + for (i = 0; i < data3Ptr->numRelocGlob; i++) { switch (importEntry->type) { default: { @@ -332,19 +332,19 @@ void resolveVarName(char *ovlIdxString, int varType, char *varIdxString, if (!strcmp(ovlIdxString, "0")) { int i; - for (i = 0; i < currentDecompOvl->numExport; i++) { - if (varIdx == currentDecompOvl->exportDataPtr[i].idx) { - if (((currentDecompOvl->exportDataPtr[i].var4 & 0xF0) == 0) && varType != 0x20) { // var + for (i = 0; i < currentDecompOvl->numSymbGlob; i++) { + if (varIdx == currentDecompOvl->arraySymbGlob[i].idx) { + if (((currentDecompOvl->arraySymbGlob[i].var4 & 0xF0) == 0) && varType != 0x20) { // var strcpy(outputName, - currentDecompOvl->exportNamesPtr + - currentDecompOvl->exportDataPtr[i]. + currentDecompOvl->arrayNameSymbGlob + + currentDecompOvl->arraySymbGlob[i]. offsetToName); return; } - if ((currentDecompOvl->exportDataPtr[i].var4) == 20 && varType == 0x20) { // script + if ((currentDecompOvl->arraySymbGlob[i].var4) == 20 && varType == 0x20) { // script strcpy(outputName, - currentDecompOvl->exportNamesPtr + - currentDecompOvl->exportDataPtr[i]. + currentDecompOvl->arrayNameSymbGlob + + currentDecompOvl->arraySymbGlob[i]. offsetToName); return; } @@ -1474,7 +1474,7 @@ void dumpScript(uint8 *ovlName, ovlDataStruct *ovlData, int idx) { failed = 0; - currentScript = &ovlData->data3Table[idx]; + currentScript = &ovlData->arrayProc[idx]; currentDecompScript = currentScript->dataPtr; currentDecompScriptPtr->var4 = 0; diff --git a/engines/cruise/linker.cpp b/engines/cruise/linker.cpp index e72218037b..59f23c76a2 100644 --- a/engines/cruise/linker.cpp +++ b/engines/cruise/linker.cpp @@ -35,7 +35,7 @@ exportEntryStruct *parseExport(int *out1, int *pExportedFuncionIdx, char *dotPtr; char *ptr2; int idx; - int numExport; + int numSymbGlob; exportEntryStruct *currentExportEntry; uint8 *entity1Name; int i; @@ -81,14 +81,14 @@ exportEntryStruct *parseExport(int *out1, int *pExportedFuncionIdx, if (!overlayTable[idx].ovlData) return (NULL); - numExport = overlayTable[idx].ovlData->numExport; - currentExportEntry = overlayTable[idx].ovlData->exportDataPtr; - entity1Name = overlayTable[idx].ovlData->exportNamesPtr; + numSymbGlob = overlayTable[idx].ovlData->numSymbGlob; + currentExportEntry = overlayTable[idx].ovlData->arraySymbGlob; + entity1Name = overlayTable[idx].ovlData->arrayNameSymbGlob; if (!entity1Name) return (0); - for (i = 0; i < numExport; i++) { + for (i = 0; i < numSymbGlob; i++) { uint8 exportedName[256]; uint8 *name = entity1Name + currentExportEntry->offsetToName; @@ -112,22 +112,22 @@ int updateScriptImport(int ovlIdx) { ovlDataStruct *ovlData; int numData3; int size5; - int numImport; + int numRelocGlob; int param; int var_32; ovlData3Struct *pScript; -// char* importDataPtr; +// char* arrayRelocGlob; // char* namePtr; -// char* linkDataPtr; +// char* arrayMsgRelHeader; if (!overlayTable[ovlIdx].ovlData) return (-4); ovlData = overlayTable[ovlIdx].ovlData; - numData3 = ovlData->numScripts1; - size5 = ovlData->numScripts2; - numImport = ovlData->numImport; + numData3 = ovlData->numProc; + size5 = ovlData->numRel; + numRelocGlob = ovlData->numRelocGlob; param = 0; // do it for the 2 first string types @@ -161,8 +161,8 @@ int updateScriptImport(int ovlIdx) { var_22 = 0; - if (pScript->numImport > 0) { - int counter = pScript->numImport; + if (pScript->numRelocGlob > 0) { + int counter = pScript->numRelocGlob; do { int param2 = @@ -247,8 +247,8 @@ int updateScriptImport(int ovlIdx) { } while (++param < 2); - if (ovlData->importDataPtr && ovlData->importNamePtr && numImport) { - int numImport2 = numImport; + if (ovlData->arrayRelocGlob && ovlData->arrayNameRelocGlob && numRelocGlob) { + int numImport2 = numRelocGlob; int i; for (i = 0; i < numImport2; i++) { @@ -259,47 +259,47 @@ int updateScriptImport(int ovlIdx) { int linkEntryIdx; strcpyuint8(buffer, - ovlData->importNamePtr + - ovlData->importDataPtr[i].nameOffset); + ovlData->arrayNameRelocGlob + + ovlData->arrayRelocGlob[i].nameOffset); pFoundExport = parseExport(&out1, &foundExportIdx, buffer); - linkType = ovlData->importDataPtr[i].linkType; - linkEntryIdx = ovlData->importDataPtr[i].linkIdx; + linkType = ovlData->arrayRelocGlob[i].linkType; + linkEntryIdx = ovlData->arrayRelocGlob[i].linkIdx; if (pFoundExport && foundExportIdx) { switch (linkType) { case 0: // var { ovlData-> - linkDataPtr[linkEntryIdx]. - varIdx = foundExportIdx; + arrayMsgRelHeader[linkEntryIdx]. + verbOverlay = foundExportIdx; ovlData-> - linkDataPtr[linkEntryIdx]. - varNameOffset = + arrayMsgRelHeader[linkEntryIdx]. + verbNumber = pFoundExport->offsetToName; break; } case 1: // string { ovlData-> - linkDataPtr[linkEntryIdx]. - stringIdx = foundExportIdx; + arrayMsgRelHeader[linkEntryIdx]. + obj1Overlay = foundExportIdx; ovlData-> - linkDataPtr[linkEntryIdx]. - stringNameOffset = + arrayMsgRelHeader[linkEntryIdx]. + obj1Number = pFoundExport->offsetToName; break; } case 2: // proc { ovlData-> - linkDataPtr[linkEntryIdx]. - procIdx = foundExportIdx; + arrayMsgRelHeader[linkEntryIdx]. + obj2Overlay = foundExportIdx; ovlData-> - linkDataPtr[linkEntryIdx]. - procNameOffset = + arrayMsgRelHeader[linkEntryIdx]. + obj2Number = pFoundExport->offsetToName; break; } diff --git a/engines/cruise/mainDraw.cpp b/engines/cruise/mainDraw.cpp index 72372f62a6..ba318433ed 100644 --- a/engines/cruise/mainDraw.cpp +++ b/engines/cruise/mainDraw.cpp @@ -366,8 +366,7 @@ char *drawPolyMode2(char *dataPointer, int linesToDraw) { } // this function builds the poly model and then calls the draw functions (OLD: mainDrawSub1Sub5) -void buildPolyModel(int positionX, int positionY, int scale, char *ptr2, - char *destBuffer, char *dataPtr) { +void buildPolyModel(int positionX, int positionY, int scale, char *ptr2, char *destBuffer, char *dataPtr) { int counter = 0; // numbers of coordinates to process int startX = 0; // first X in model int startY = 0; // first Y in model @@ -600,8 +599,9 @@ void mainDrawPolygons(int fileIndex, cellStruct *pObject, int X, int scale, cellStruct *pCurrentObject = pObject; do { - if (pCurrentObject->type == 2) { - // ASSERT(0); + if (pCurrentObject->type == OBJ_TYPE_BGMK) + { +// ASSERT(0); } pCurrentObject = pCurrentObject->next; diff --git a/engines/cruise/object.cpp b/engines/cruise/object.cpp index 995f4857e9..990fdf4c9b 100644 --- a/engines/cruise/object.cpp +++ b/engines/cruise/object.cpp @@ -46,10 +46,10 @@ objDataStruct *getObjectDataFromOverlay(int ovlIdx, int objIdx) { if (!overlayTable[ovlIdx].ovlData) return NULL; - if (overlayTable[ovlIdx].ovlData->numObjData <= objIdx) + if (overlayTable[ovlIdx].ovlData->numObj <= objIdx) return NULL; - var_6 = overlayTable[ovlIdx].ovlData->objDataTable; + var_6 = overlayTable[ovlIdx].ovlData->arrayObject; if (!var_6) return NULL; @@ -76,7 +76,7 @@ int16 getMultipleObjectParam(int16 overlayIdx, int16 objectIdx, objectParamsQuer switch (ptr->type) { case 0: { - ptr2 = &ovlData->objData2SourceTable[ptr->var5]; + ptr2 = &ovlData->arrayStates[ptr->var5]; var_14 = globalVars[*(int16 *) (&overlayTable[overlayIdx].state + ptr->stateTableIdx)]; @@ -86,13 +86,13 @@ int16 getMultipleObjectParam(int16 overlayIdx, int16 objectIdx, objectParamsQuer } case 1: { - ptr2 = &ovlData->objData2WorkTable[ptr->var4]; + ptr2 = &ovlData->arrayObjVar[ptr->var4]; var_A = var_14 = ptr2->state; size = var_A + ptr->var5; if (ptr->var5 + var_14 <= ovlData->size8) { - var_A = ovlData->objData2SourceTable[ptr->var5 + var_14].state; + var_A = ovlData->arrayStates[ptr->var5 + var_14].state; } break; } @@ -130,7 +130,7 @@ void setObjectPosition(int16 ovlIdx, int16 objIdx, int16 param3, int16 param4) { switch (ptr->type) { case 1: { - ptr2 = &overlayTable[ovlIdx].ovlData->objData2WorkTable[ptr->var4]; + ptr2 = &overlayTable[ovlIdx].ovlData->arrayObjVar[ptr->var4]; switch (param3) { case 0: // x @@ -210,8 +210,8 @@ int16 objInit(int ovlIdx, int objIdx, int newState) { return 0; } - destEntry = &ovlData->objData2WorkTable[ptr->var4]; - sourceEntry = &ovlData->objData2SourceTable[ptr->var5 + newState]; + destEntry = &ovlData->arrayObjVar[ptr->var4]; + sourceEntry = &ovlData->arrayStates[ptr->var5 + newState]; memcpy(destEntry, sourceEntry, sizeof(objectParams)); @@ -250,12 +250,12 @@ int16 getSingleObjectParam(int16 overlayIdx, int16 param2, int16 param3, int16 * { var_A = globalVars[ptr->stateTableIdx]; - ptr2 = &ovlData->objData2SourceTable[ptr->var5]; + ptr2 = &ovlData->arrayStates[ptr->var5]; break; } case 1: { - ptr2 = &ovlData->objData2WorkTable[ptr->var4]; + ptr2 = &ovlData->arrayObjVar[ptr->var4]; var_A = ptr2->state; break; diff --git a/engines/cruise/overlay.cpp b/engines/cruise/overlay.cpp index 4056d7bd82..799e48093f 100644 --- a/engines/cruise/overlay.cpp +++ b/engines/cruise/overlay.cpp @@ -133,27 +133,27 @@ int loadOverlay(const uint8 *scriptName) { memcpy(ovlData, scriptPtr, sizeof(ovlDataStruct)); - ovlData->data3Table = NULL; + ovlData->arrayProc = NULL; ovlData->ptr1 = NULL; - ovlData->objDataTable = NULL; - ovlData->objData2SourceTable = NULL; - ovlData->objData2WorkTable = NULL; + ovlData->arrayObject = NULL; + ovlData->arrayStates = NULL; + ovlData->arrayObjVar = NULL; ovlData->stringTable = NULL; - ovlData->exportDataPtr = NULL; - ovlData->importDataPtr = NULL; - ovlData->linkDataPtr = NULL; - ovlData->specialString1 = NULL; - ovlData->specialString2 = NULL; - ovlData->importNamePtr = NULL; - ovlData->exportNamesPtr = NULL; + ovlData->arraySymbGlob = NULL; + ovlData->arrayRelocGlob = NULL; + ovlData->arrayMsgRelHeader = NULL; + ovlData->nameVerbGlob = NULL; + ovlData->arrayNameObj = NULL; + ovlData->arrayNameRelocGlob = NULL; + ovlData->arrayNameSymbGlob = NULL; ovlData->data4Ptr = NULL; ovlData->ptr8 = NULL; - ovlData->numScripts1 = readB16(scriptPtr + 60); - ovlData->numScripts2 = readB16(scriptPtr + 62); - ovlData->numExport = readB16(scriptPtr + 64); - ovlData->numImport = readB16(scriptPtr + 66); - ovlData->numLinkData = readB16(scriptPtr + 68); - ovlData->numObjData = readB16(scriptPtr + 70); + ovlData->numProc = readB16(scriptPtr + 60); + ovlData->numRel = readB16(scriptPtr + 62); + ovlData->numSymbGlob = readB16(scriptPtr + 64); + ovlData->numRelocGlob = readB16(scriptPtr + 66); + ovlData->numMsgRelHeader = readB16(scriptPtr + 68); + ovlData->numObj = readB16(scriptPtr + 70); ovlData->numStrings = readB16(scriptPtr + 72); ovlData->size8 = readB16(scriptPtr + 74); ovlData->size9 = readB16(scriptPtr + 76); @@ -167,24 +167,24 @@ int loadOverlay(const uint8 *scriptName) { scriptPtr += 92; - if (ovlData->numExport) { // export data + if (ovlData->numSymbGlob) { // export data int i; - ovlData->exportDataPtr = - (exportEntryStruct *) mallocAndZero(ovlData->numExport * + ovlData->arraySymbGlob = + (exportEntryStruct *) mallocAndZero(ovlData->numSymbGlob * sizeof(exportEntryStruct)); - if (!ovlData->exportDataPtr) { + if (!ovlData->arraySymbGlob) { return (-2); } - for (i = 0; i < ovlData->numExport; i++) { - ovlData->exportDataPtr[i].var0 = readB16(scriptPtr); - ovlData->exportDataPtr[i].var2 = + for (i = 0; i < ovlData->numSymbGlob; i++) { + ovlData->arraySymbGlob[i].var0 = readB16(scriptPtr); + ovlData->arraySymbGlob[i].var2 = readB16(scriptPtr + 2); - ovlData->exportDataPtr[i].var4 = + ovlData->arraySymbGlob[i].var4 = readB16(scriptPtr + 4); - ovlData->exportDataPtr[i].idx = readB16(scriptPtr + 6); - ovlData->exportDataPtr[i].offsetToName = + ovlData->arraySymbGlob[i].idx = readB16(scriptPtr + 6); + ovlData->arraySymbGlob[i].offsetToName = readB16(scriptPtr + 8); scriptPtr += 10; @@ -192,38 +192,38 @@ int loadOverlay(const uint8 *scriptName) { } if (ovlData->exportNamesSize) { // export names - ovlData->exportNamesPtr = + ovlData->arrayNameSymbGlob = (uint8 *) mallocAndZero(ovlData->exportNamesSize); - if (!ovlData->exportNamesPtr) { + if (!ovlData->arrayNameSymbGlob) { return (-2); } - memcpy(ovlData->exportNamesPtr, scriptPtr, + memcpy(ovlData->arrayNameSymbGlob, scriptPtr, ovlData->exportNamesSize); scriptPtr += ovlData->exportNamesSize; } - if (ovlData->numImport) { // import data + if (ovlData->numRelocGlob) { // import data int i; - ovlData->importDataPtr = - (importDataStruct *) mallocAndZero(ovlData->numImport * + ovlData->arrayRelocGlob = + (importDataStruct *) mallocAndZero(ovlData->numRelocGlob * sizeof(importDataStruct)); - if (!ovlData->importDataPtr) { + if (!ovlData->arrayRelocGlob) { return (-2); } - for (i = 0; i < ovlData->numImport; i++) { - ovlData->importDataPtr[i].var0 = readB16(scriptPtr); - ovlData->importDataPtr[i].var1 = + for (i = 0; i < ovlData->numRelocGlob; i++) { + ovlData->arrayRelocGlob[i].var0 = readB16(scriptPtr); + ovlData->arrayRelocGlob[i].var1 = readB16(scriptPtr + 2); - ovlData->importDataPtr[i].linkType = + ovlData->arrayRelocGlob[i].linkType = readB16(scriptPtr + 4); - ovlData->importDataPtr[i].linkIdx = + ovlData->arrayRelocGlob[i].linkIdx = readB16(scriptPtr + 6); - ovlData->importDataPtr[i].nameOffset = + ovlData->arrayRelocGlob[i].nameOffset = readB16(scriptPtr + 8); scriptPtr += 10; @@ -231,45 +231,45 @@ int loadOverlay(const uint8 *scriptName) { } if (ovlData->nameExportSize) { // import name - ovlData->importNamePtr = + ovlData->arrayNameRelocGlob = (uint8 *) mallocAndZero(ovlData->nameExportSize); - if (!ovlData->importNamePtr) { + if (!ovlData->arrayNameRelocGlob) { return (-2); } - memcpy(ovlData->importNamePtr, scriptPtr, + memcpy(ovlData->arrayNameRelocGlob, scriptPtr, ovlData->nameExportSize); scriptPtr += ovlData->nameExportSize; } - if (ovlData->numLinkData) { // link data + if (ovlData->numMsgRelHeader) { // link data ASSERT(sizeof(linkDataStruct) == 0x22); - ovlData->linkDataPtr = - (linkDataStruct *) mallocAndZero(ovlData->numLinkData * + ovlData->arrayMsgRelHeader = + (linkDataStruct *) mallocAndZero(ovlData->numMsgRelHeader * sizeof(linkDataStruct)); - if (!ovlData->linkDataPtr) { + if (!ovlData->arrayMsgRelHeader) { return (-2); } - memcpy(ovlData->linkDataPtr, scriptPtr, - ovlData->numLinkData * sizeof(linkDataStruct)); - scriptPtr += ovlData->numLinkData * sizeof(linkDataStruct); - flipGen(ovlData->linkDataPtr, - ovlData->numLinkData * sizeof(linkDataStruct)); + memcpy(ovlData->arrayMsgRelHeader, scriptPtr, + ovlData->numMsgRelHeader * sizeof(linkDataStruct)); + scriptPtr += ovlData->numMsgRelHeader * sizeof(linkDataStruct); + flipGen(ovlData->arrayMsgRelHeader, + ovlData->numMsgRelHeader * sizeof(linkDataStruct)); } - if (ovlData->numScripts1) { // script + if (ovlData->numProc) { // script ovlData3Struct *tempPtr; int i; - ovlData->data3Table = - (ovlData3Struct *) mallocAndZero(ovlData->numScripts1 * + ovlData->arrayProc = + (ovlData3Struct *) mallocAndZero(ovlData->numProc * sizeof(ovlData3Struct)); - if (!ovlData->data3Table) { + if (!ovlData->arrayProc) { /* releaseScript(scriptIdx,scriptName); if (freeIsNeeded) { @@ -279,16 +279,16 @@ int loadOverlay(const uint8 *scriptName) { return (-2); } - memcpy(ovlData->data3Table, scriptPtr, - ovlData->numScripts1 * sizeof(ovlData3Struct)); - scriptPtr += ovlData->numScripts1 * 0x1C; + memcpy(ovlData->arrayProc, scriptPtr, + ovlData->numProc * sizeof(ovlData3Struct)); + scriptPtr += ovlData->numProc * 0x1C; - flipGen(ovlData->data3Table, - ovlData->numScripts1 * sizeof(ovlData3Struct)); + flipGen(ovlData->arrayProc, + ovlData->numProc * sizeof(ovlData3Struct)); - tempPtr = ovlData->data3Table; + tempPtr = ovlData->arrayProc; - for (i = 0; i < ovlData->numScripts1; i++) { + for (i = 0; i < ovlData->numProc; i++) { uint8 *ptr = tempPtr->dataPtr = (uint8 *) mallocAndZero(tempPtr->sizeOfData); @@ -308,7 +308,7 @@ int loadOverlay(const uint8 *scriptName) { if (tempPtr->offsetToImportData) { flipGen(ptr + tempPtr->offsetToImportData, - tempPtr->numImport * 10); + tempPtr->numRelocGlob * 10); } if (tempPtr->offsetToSubData2) { @@ -320,24 +320,24 @@ int loadOverlay(const uint8 *scriptName) { } } - if (ovlData->numScripts2) { + if (ovlData->numRel) { ovlData3Struct *tempPtr; int i; ovlData->ptr1 = - (uint8 *) mallocAndZero(ovlData->numScripts2 * 0x1C); + (uint8 *) mallocAndZero(ovlData->numRel * 0x1C); if (!ovlData->ptr1) { return (-2); } - memcpy(ovlData->ptr1, scriptPtr, ovlData->numScripts2 * 0x1C); - scriptPtr += ovlData->numScripts2 * 0x1C; - flipGen(ovlData->ptr1, ovlData->numScripts2 * 0x1C); + memcpy(ovlData->ptr1, scriptPtr, ovlData->numRel * 0x1C); + scriptPtr += ovlData->numRel * 0x1C; + flipGen(ovlData->ptr1, ovlData->numRel * 0x1C); tempPtr = (ovlData3Struct *) ovlData->ptr1; - for (i = 0; i < ovlData->numScripts2; i++) { + for (i = 0; i < ovlData->numRel; i++) { uint8 *ptr = tempPtr->dataPtr = (uint8 *) mallocAndZero(tempPtr->sizeOfData); @@ -357,7 +357,7 @@ int loadOverlay(const uint8 *scriptName) { if (tempPtr->offsetToImportData) { flipGen(ptr + tempPtr->offsetToImportData, - tempPtr->numImport * 10); + tempPtr->numRelocGlob * 10); } if (tempPtr->offsetToSubData2) { @@ -386,13 +386,13 @@ int loadOverlay(const uint8 *scriptName) { scriptPtr += ovlData->size12; } - if (ovlData->numObjData) { + if (ovlData->numObj) { int i; - ovlData->objDataTable = - (objDataStruct *) mallocAndZero(ovlData->numObjData * + ovlData->arrayObject = + (objDataStruct *) mallocAndZero(ovlData->numObj * sizeof(objDataStruct)); - if (!ovlData->objDataTable) { + if (!ovlData->arrayObject) { /* releaseScript(scriptIdx,scriptName); if (freeIsNeeded) { @@ -402,34 +402,34 @@ int loadOverlay(const uint8 *scriptName) { return (-2); } - for (i = 0; i < ovlData->numObjData; i++) { - ovlData->objDataTable[i].var0 = *(int16 *) scriptPtr; + for (i = 0; i < ovlData->numObj; i++) { + ovlData->arrayObject[i].var0 = *(int16 *) scriptPtr; scriptPtr += 2; - flipShort(&ovlData->objDataTable[i].var0); + flipShort(&ovlData->arrayObject[i].var0); - ovlData->objDataTable[i].type = *(int16 *) scriptPtr; + ovlData->arrayObject[i].type = *(int16 *) scriptPtr; scriptPtr += 2; - flipShort(&ovlData->objDataTable[i].type); + flipShort(&ovlData->arrayObject[i].type); - ovlData->objDataTable[i].var2 = *(int16 *) scriptPtr; + ovlData->arrayObject[i].var2 = *(int16 *) scriptPtr; scriptPtr += 2; - flipShort(&ovlData->objDataTable[i].var2); + flipShort(&ovlData->arrayObject[i].var2); - ovlData->objDataTable[i].var3 = *(int16 *) scriptPtr; + ovlData->arrayObject[i].var3 = *(int16 *) scriptPtr; scriptPtr += 2; - flipShort(&ovlData->objDataTable[i].var3); + flipShort(&ovlData->arrayObject[i].var3); - ovlData->objDataTable[i].var4 = *(int16 *) scriptPtr; + ovlData->arrayObject[i].var4 = *(int16 *) scriptPtr; scriptPtr += 2; - flipShort(&ovlData->objDataTable[i].var4); + flipShort(&ovlData->arrayObject[i].var4); - ovlData->objDataTable[i].var5 = *(int16 *) scriptPtr; + ovlData->arrayObject[i].var5 = *(int16 *) scriptPtr; scriptPtr += 2; - flipShort(&ovlData->objDataTable[i].var5); + flipShort(&ovlData->arrayObject[i].var5); - ovlData->objDataTable[i].stateTableIdx = *(int16 *) scriptPtr; + ovlData->arrayObject[i].stateTableIdx = *(int16 *) scriptPtr; scriptPtr += 2; - flipShort(&ovlData->objDataTable[i].stateTableIdx); + flipShort(&ovlData->arrayObject[i].stateTableIdx); } if (scriptNotLoadedBefore) { @@ -446,13 +446,13 @@ int loadOverlay(const uint8 *scriptName) { } if (ovlData->size9) { - ovlData->objData2WorkTable = + ovlData->arrayObjVar = (objectParams *) mallocAndZero(ovlData->size9 * sizeof(objectParams)); - memset(ovlData->objData2WorkTable, 0, + memset(ovlData->arrayObjVar, 0, ovlData->size9 * sizeof(objectParams)); - if (!ovlData->objData2WorkTable) { + if (!ovlData->arrayObjVar) { /* releaseScript(scriptIdx,scriptName); if (freeIsNeeded) { @@ -464,11 +464,11 @@ int loadOverlay(const uint8 *scriptName) { } if (ovlData->size8) { - ovlData->objData2SourceTable = + ovlData->arrayStates = (objectParams *) mallocAndZero(ovlData->size8 * sizeof(objectParams)); - if (!ovlData->objData2SourceTable) { + if (!ovlData->arrayStates) { /* releaseScript(scriptIdx,scriptName); if (freeIsNeeded) { @@ -478,9 +478,9 @@ int loadOverlay(const uint8 *scriptName) { return (-2); } - memcpy(ovlData->objData2SourceTable, scriptPtr, ovlData->size8 * 12); // TODO: made read item by item + memcpy(ovlData->arrayStates, scriptPtr, ovlData->size8 * 12); // TODO: made read item by item scriptPtr += ovlData->size8 * 12; - flipGen(ovlData->objData2SourceTable, ovlData->size8 * 12); + flipGen(ovlData->arrayStates, ovlData->size8 * 12); } if (ovlData->numStrings) { @@ -564,11 +564,11 @@ int loadOverlay(const uint8 *scriptName) { flipShort(&ovlData->specialString1Length); // recheck if needed if (ovlData->specialString1Length) { - ovlData->specialString1 = + ovlData->nameVerbGlob = (uint8 *) mallocAndZero(ovlData-> specialString1Length); - if (!ovlData->specialString1) { + if (!ovlData->nameVerbGlob) { /* releaseScript(scriptIdx,scriptName); * * if (freeIsNeeded) @@ -579,7 +579,7 @@ int loadOverlay(const uint8 *scriptName) { return (-2); } - memcpy(ovlData->specialString1, scriptPtr, + memcpy(ovlData->nameVerbGlob, scriptPtr, ovlData->specialString1Length); scriptPtr += ovlData->specialString1Length; } @@ -589,11 +589,11 @@ int loadOverlay(const uint8 *scriptName) { flipShort(&ovlData->specialString2Length); // recheck if needed if (ovlData->specialString2Length) { - ovlData->specialString2 = + ovlData->arrayNameObj = (uint8 *) mallocAndZero(ovlData-> specialString2Length); - if (!ovlData->specialString2) { + if (!ovlData->arrayNameObj) { /* releaseScript(scriptIdx,scriptName); * * if (freeIsNeeded) @@ -604,7 +604,7 @@ int loadOverlay(const uint8 *scriptName) { return (-2); } - memcpy(ovlData->specialString2, scriptPtr, + memcpy(ovlData->arrayNameObj, scriptPtr, ovlData->specialString2Length); scriptPtr += ovlData->specialString2Length; } @@ -639,7 +639,7 @@ int loadOverlay(const uint8 *scriptName) { #ifdef DUMP_SCRIPT { int i; - for (i = 0; i < ovlData->numScripts1; i++) { + for (i = 0; i < ovlData->numProc; i++) { dumpScript(scriptName, ovlData, i); } } @@ -654,18 +654,18 @@ int loadOverlay(const uint8 *scriptName) { fHandle = fopen(nameBundle, "w+"); ASSERT(fHandle); - for (i = 0; i < ovlData->numLinkData; i++) { + for (i = 0; i < ovlData->numMsgRelHeader; i++) { linkDataStruct *var_34; - var_34 = &ovlData->linkDataPtr[i]; + var_34 = &ovlData->arrayMsgRelHeader[i]; - if (ovlData->specialString2) { + if (ovlData->arrayNameObj) { fprintf(fHandle, "----- object %02d -----\n", i); if (var_34->stringNameOffset != 0xFFFF) { fprintf(fHandle, "name: %s\n", getObjectName(var_34-> stringNameOffset, - ovlData->specialString2)); + ovlData->arrayNameObj)); } } } diff --git a/engines/cruise/overlay.h b/engines/cruise/overlay.h index 5d2e4e890e..7d9d7d0c99 100644 --- a/engines/cruise/overlay.h +++ b/engines/cruise/overlay.h @@ -54,7 +54,7 @@ struct ovlData3Struct { short int offsetToSubData5; short int sysKey; short int var12; - short int numImport; + short int numRelocGlob; short int subData2Size; short int var18; short int var1A; @@ -67,15 +67,15 @@ struct stringEntryStruct { }; struct linkDataStruct { - uint16 field_0; - uint16 field_2; - uint16 field_4; - uint16 varIdx; - uint16 varNameOffset; - uint16 stringIdx; - uint16 stringNameOffset; - uint16 procIdx; - uint16 procNameOffset; + uint16 type; + uint16 id; + uint16 offsetVerbeName; + uint16 verbOverlay; + uint16 verbNumber; + uint16 obj1Overlay; + uint16 obj1Number; + uint16 obj2Overlay; + uint16 obj2Number; int16 field_12; int16 field_14; @@ -120,27 +120,29 @@ struct objectParams { }; struct ovlDataStruct { - ovlData3Struct *data3Table; + + ovlData3Struct *arrayProc; uint8 *ptr1; - objDataStruct *objDataTable; - objectParams *objData2SourceTable; - objectParams *objData2WorkTable; + objDataStruct *arrayObject; + objectParams *arrayStates; + objectParams *arrayObjVar; stringEntryStruct *stringTable; - exportEntryStruct *exportDataPtr; - importDataStruct *importDataPtr; - linkDataStruct *linkDataPtr; - uint8 *specialString1; - uint8 *specialString2; - uint8 *importNamePtr; - uint8 *exportNamesPtr; + exportEntryStruct *arraySymbGlob; + importDataStruct *arrayRelocGlob; + linkDataStruct *arrayMsgRelHeader; + + uint8 *nameVerbGlob; + uint8 *arrayNameObj; + uint8 *arrayNameRelocGlob; + uint8 *arrayNameSymbGlob; uint8 *data4Ptr; uint8 *ptr8; - unsigned short int numScripts1; - unsigned short int numScripts2; - unsigned short int numExport; - unsigned short int numImport; - unsigned short int numLinkData; - unsigned short int numObjData; + unsigned short int numProc; + unsigned short int numRel; + unsigned short int numSymbGlob; + unsigned short int numRelocGlob; + unsigned short int numMsgRelHeader; + unsigned short int numObj; unsigned short int numStrings; unsigned short int size8; unsigned short int size9; diff --git a/engines/cruise/saveload.cpp b/engines/cruise/saveload.cpp index d25bda5735..612a26b885 100644 --- a/engines/cruise/saveload.cpp +++ b/engines/cruise/saveload.cpp @@ -301,12 +301,12 @@ int loadSavegameData(int saveGameIdx) { } if (filesData[j].field_4) { - if (ovlData->objData2WorkTable) { + if (ovlData->arrayObjVar) { free(ovlData-> - objData2WorkTable); + arrayObjVar); } - ovlData->objData2WorkTable = (objectParams *) filesData[j].field_4; // TODO: fix ! + ovlData->arrayObjVar = (objectParams *) filesData[j].field_4; // TODO: fix ! ovlData->size9 = filesData2[j].field_2; } |