diff options
Diffstat (limited to 'engines/cruise/cruise_main.cpp')
-rw-r--r-- | engines/cruise/cruise_main.cpp | 2607 |
1 files changed, 1310 insertions, 1297 deletions
diff --git a/engines/cruise/cruise_main.cpp b/engines/cruise/cruise_main.cpp index 9353a2d61f..9784963315 100644 --- a/engines/cruise/cruise_main.cpp +++ b/engines/cruise/cruise_main.cpp @@ -32,514 +32,463 @@ namespace Cruise { unsigned int timer = 0; -void drawSolidBox(int32 x1, int32 y1, int32 x2, int32 y2, uint8 color) -{ - int32 i; - int32 j; - - for(i=x1;i<x2;i++) - { - for(j=y1;j<y2;j++) - { - globalScreen[j*320+i] = color; - } - } +void drawSolidBox(int32 x1, int32 y1, int32 x2, int32 y2, uint8 color) { + int32 i; + int32 j; + + for (i = x1; i < x2; i++) { + for (j = y1; j < y2; j++) { + globalScreen[j * 320 + i] = color; + } + } } -void drawBlackSolidBoxSmall() -{ +void drawBlackSolidBoxSmall() { // gfxModuleData.drawSolidBox(64,100,256,117,0); - drawSolidBox(64,100,256,117,0); + drawSolidBox(64, 100, 256, 117, 0); } -void resetRaster(uint8* rasterPtr, int32 rasterSize) -{ - memset(rasterPtr,0,rasterSize); +void resetRaster(uint8 *rasterPtr, int32 rasterSize) { + memset(rasterPtr, 0, rasterSize); } +void drawInfoStringSmallBlackBox(uint8 *string) { + //uint8 buffer[256]; -void drawInfoStringSmallBlackBox(uint8* string) -{ - //uint8 buffer[256]; - - gfxModuleData_field_90(); - gfxModuleData_gfxWaitVSync(); - drawBlackSolidBoxSmall(); + gfxModuleData_field_90(); + gfxModuleData_gfxWaitVSync(); + drawBlackSolidBoxSmall(); - drawString(10,100,string,gfxModuleData.pPage10,video4,300); + drawString(10, 100, string, gfxModuleData.pPage10, video4, 300); - gfxModuleData_flip(); + gfxModuleData_flip(); flipScreen(); - while(1); + while (1); } -void loadPakedFileToMem(int fileIdx, uint8* buffer) -{ - //changeCursor(1); +void loadPakedFileToMem(int fileIdx, uint8 *buffer) { + //changeCursor(1); - currentVolumeFile.seek(volumePtrToFileDescriptor[fileIdx].offset,SEEK_SET); - currentVolumeFile.read(buffer,volumePtrToFileDescriptor[fileIdx].size); + currentVolumeFile.seek(volumePtrToFileDescriptor[fileIdx].offset, + SEEK_SET); + currentVolumeFile.read(buffer, + volumePtrToFileDescriptor[fileIdx].size); } -int loadScriptSub1(int scriptIdx, int param) -{ - objDataStruct* ptr2; - int counter; - int i; - - if(!overlayTable[scriptIdx].ovlData) - return(0); +int loadScriptSub1(int scriptIdx, int param) { + objDataStruct *ptr2; + int counter; + int i; - ptr2 = overlayTable[scriptIdx].ovlData->objDataTable; + if (!overlayTable[scriptIdx].ovlData) + return (0); - if(!ptr2) - return(0); + ptr2 = overlayTable[scriptIdx].ovlData->objDataTable; - if(overlayTable[scriptIdx].ovlData->numObjData==0) - return(0); + if (!ptr2) + return (0); - counter = 0; + if (overlayTable[scriptIdx].ovlData->numObjData == 0) + return (0); - for(i=0;i<overlayTable[scriptIdx].ovlData->numObjData;i++) - { - if(ptr2[i].var0 == param) - { - counter++; - } - } + counter = 0; + + for (i = 0; i < overlayTable[scriptIdx].ovlData->numObjData; i++) { + if (ptr2[i].var0 == param) { + counter++; + } + } - return(counter); + return (counter); } -void saveShort(void* ptr, short int var) -{ - *(int16*)ptr = var; +void saveShort(void *ptr, short int var) { + *(int16 *) ptr = var; - flipShort((int16*)ptr); + flipShort((int16 *) ptr); } -int16 loadShort(void* ptr) -{ - short int temp; +int16 loadShort(void *ptr) { + short int temp; - temp = *(int16*)ptr; + temp = *(int16 *) ptr; - flipShort(&temp); + flipShort(&temp); - return(temp); + return (temp); } +void resetFileEntryRange(int param1, int param2) { + int i; -void resetFileEntryRange(int param1, int param2) -{ - int i; - - for(i=param1;i<param2;i++) - { - resetFileEntry(i); - } + for (i = param1; i < param2; i++) { + resetFileEntry(i); + } } -int getProcParam(int overlayIdx, int param2, uint8* name) -{ - int numExport; - int i; - exportEntryStruct* exportDataPtr; - uint8* exportNamePtr; - uint8 exportName[80]; - - if(!overlayTable[overlayIdx].alreadyLoaded) - return 0; - - if(!overlayTable[overlayIdx].ovlData) - return 0; - - numExport = overlayTable[overlayIdx].ovlData->numExport; - exportDataPtr = overlayTable[overlayIdx].ovlData->exportDataPtr; - exportNamePtr = overlayTable[overlayIdx].ovlData->exportNamesPtr; - - if(!exportNamePtr) - return 0; - - for(i=0;i<numExport;i++) - { - if(exportDataPtr[i].var4 == param2) - { - strcpyuint8(exportName,exportDataPtr[i].offsetToName+exportNamePtr); - - if(!strcmpuint8(exportName,name)) - { - return(exportDataPtr[i].idx); - } - } - } - - return 0; -} +int getProcParam(int overlayIdx, int param2, uint8 *name) { + int numExport; + int i; + exportEntryStruct *exportDataPtr; + uint8 *exportNamePtr; + uint8 exportName[80]; + + if (!overlayTable[overlayIdx].alreadyLoaded) + return 0; -void changeScriptParamInList(int param1, int param2, scriptInstanceStruct* pScriptInstance,int newValue, int param3) -{ - pScriptInstance = pScriptInstance->nextScriptPtr; - while(pScriptInstance) - { - if( (pScriptInstance->overlayNumber == param1 || param1 == -1) - &&(pScriptInstance->scriptNumber == param2 || param2 == -1) - &&(pScriptInstance->var12 == param3 || param3 == -1)) - { - pScriptInstance->var12 = newValue; - } - - pScriptInstance = pScriptInstance->nextScriptPtr; - } + if (!overlayTable[overlayIdx].ovlData) + return 0; + + numExport = overlayTable[overlayIdx].ovlData->numExport; + exportDataPtr = overlayTable[overlayIdx].ovlData->exportDataPtr; + exportNamePtr = overlayTable[overlayIdx].ovlData->exportNamesPtr; + + if (!exportNamePtr) + return 0; + + for (i = 0; i < numExport; i++) { + if (exportDataPtr[i].var4 == param2) { + strcpyuint8(exportName, + exportDataPtr[i].offsetToName + exportNamePtr); + + if (!strcmpuint8(exportName, name)) { + return (exportDataPtr[i].idx); + } + } + } + + return 0; } +void changeScriptParamInList(int param1, int param2, + scriptInstanceStruct *pScriptInstance, int newValue, int param3) { + pScriptInstance = pScriptInstance->nextScriptPtr; + while (pScriptInstance) { + if ((pScriptInstance->overlayNumber == param1 || param1 == -1) + && (pScriptInstance->scriptNumber == param2 + || param2 == -1) + && (pScriptInstance->var12 == param3 || param3 == -1)) { + pScriptInstance->var12 = newValue; + } -void initBigVar3() -{ - int i; + pScriptInstance = pScriptInstance->nextScriptPtr; + } +} - for(i=0;i<257;i++) - { - if(filesDatabase[i].subData.ptr) - { - free(filesDatabase[i].subData.ptr); - } +void initBigVar3() { + int i; - filesDatabase[i].subData.ptr = NULL; - filesDatabase[i].subData.ptr2 = NULL; + for (i = 0; i < 257; i++) { + if (filesDatabase[i].subData.ptr) { + free(filesDatabase[i].subData.ptr); + } + + filesDatabase[i].subData.ptr = NULL; + filesDatabase[i].subData.ptr2 = NULL; - filesDatabase[i].subData.index = -1; - filesDatabase[i].subData.resourceType = 0; - } + filesDatabase[i].subData.index = -1; + filesDatabase[i].subData.resourceType = 0; + } } -void resetPtr2(scriptInstanceStruct* ptr) -{ - ptr->nextScriptPtr = NULL; - ptr->scriptNumber = -1; +void resetPtr2(scriptInstanceStruct *ptr) { + ptr->nextScriptPtr = NULL; + ptr->scriptNumber = -1; } -void resetActorPtr(actorStruct* ptr) -{ - ptr->next = NULL; - ptr->prev = NULL; +void resetActorPtr(actorStruct *ptr) { + ptr->next = NULL; + ptr->prev = NULL; } -ovlData3Struct* getOvlData3Entry(int32 scriptNumber, int32 param) -{ - ovlDataStruct* ovlData = overlayTable[scriptNumber].ovlData; +ovlData3Struct *getOvlData3Entry(int32 scriptNumber, int32 param) { + ovlDataStruct *ovlData = overlayTable[scriptNumber].ovlData; - if(!ovlData) - { - return NULL; - } + if (!ovlData) { + return NULL; + } - if(param<0) - { - return NULL; - } + if (param < 0) { + return NULL; + } - if(ovlData->numScripts1 <= param) - { - return NULL; - } + if (ovlData->numScripts1 <= param) { + return NULL; + } - if(!ovlData->data3Table) - { - return NULL; - } + if (!ovlData->data3Table) { + return NULL; + } - return(&ovlData->data3Table[param]); + return (&ovlData->data3Table[param]); } -ovlData3Struct* scriptFunc1Sub2(int32 scriptNumber, int32 param) -{ - ovlDataStruct* ovlData = overlayTable[scriptNumber].ovlData; +ovlData3Struct *scriptFunc1Sub2(int32 scriptNumber, int32 param) { + ovlDataStruct *ovlData = overlayTable[scriptNumber].ovlData; - if(!ovlData) - { - return NULL; - } + if (!ovlData) { + return NULL; + } - if(param<0) - { - return NULL; - } + if (param < 0) { + return NULL; + } - if(ovlData->numScripts2 <= param) - { - return NULL; - } + if (ovlData->numScripts2 <= param) { + return NULL; + } - if(!ovlData->ptr1) - { - return NULL; - } + if (!ovlData->ptr1) { + return NULL; + } - return((ovlData3Struct*)(ovlData->ptr1+param*0x1C)); + return ((ovlData3Struct *) (ovlData->ptr1 + param * 0x1C)); } -void scriptFunc2(int scriptNumber,scriptInstanceStruct* scriptHandle, int param, int param2) -{ - if(scriptHandle->nextScriptPtr) - { - if(scriptNumber == scriptHandle->nextScriptPtr->overlayNumber || scriptNumber != -1) - { - if(param2 == scriptHandle->nextScriptPtr->scriptNumber || param2 != -1) - { - scriptHandle->nextScriptPtr->sysKey = param; - } - } - } +void scriptFunc2(int scriptNumber, scriptInstanceStruct * scriptHandle, + int param, int param2) { + if (scriptHandle->nextScriptPtr) { + if (scriptNumber == scriptHandle->nextScriptPtr->overlayNumber + || scriptNumber != -1) { + if (param2 == scriptHandle->nextScriptPtr->scriptNumber + || param2 != -1) { + scriptHandle->nextScriptPtr->sysKey = param; + } + } + } } -uint8* getDataFromData3(ovlData3Struct* ptr, int param) -{ - uint8* dataPtr; - - if(!ptr) - return(NULL); - - dataPtr = ptr->dataPtr; - - if(!dataPtr) - return(NULL); - - switch(param) - { - case 0: - { - return(dataPtr); - } - case 1: - { - return(dataPtr + ptr->offsetToSubData3); // strings - } - case 2: - { - return(dataPtr + ptr->offsetToSubData2); - } - case 3: - { - return(dataPtr + ptr->offsetToImportData); // import data - } - case 4: - { - return(dataPtr + ptr->offsetToImportName); // import names - } - case 5: - { - return(dataPtr + ptr->offsetToSubData5); - } - default: - { - return(NULL); - } - } +uint8 *getDataFromData3(ovlData3Struct *ptr, int param) { + uint8 *dataPtr; + + if (!ptr) + return (NULL); + + dataPtr = ptr->dataPtr; + + if (!dataPtr) + return (NULL); + + switch (param) { + case 0: + { + return (dataPtr); + } + case 1: + { + return (dataPtr + ptr->offsetToSubData3); // strings + } + case 2: + { + return (dataPtr + ptr->offsetToSubData2); + } + case 3: + { + return (dataPtr + ptr->offsetToImportData); // import data + } + case 4: + { + return (dataPtr + ptr->offsetToImportName); // import names + } + case 5: + { + return (dataPtr + ptr->offsetToSubData5); + } + default: + { + return (NULL); + } + } } -void printInfoBlackBox(const char* string) -{ +void printInfoBlackBox(const char *string) { } -void waitForPlayerInput() -{ +void waitForPlayerInput() { } -void getFileExtention(const char* name,char* buffer) -{ - while(*name != '.' && *name) - { - name++; - } +void getFileExtention(const char *name, char *buffer) { + while (*name != '.' && *name) { + name++; + } - strcpy(buffer,name); + strcpy(buffer, name); } -void removeExtention(const char* name, char* buffer) // not like in original -{ - char* ptr; - - strcpy(buffer,name); +void removeExtention(const char *name, char *buffer) { // not like in original + char *ptr; + + strcpy(buffer, name); - ptr = strchr(buffer,'.'); + ptr = strchr(buffer, '.'); - if(ptr) - *ptr = 0; + if (ptr) + *ptr = 0; } int lastFileSize; -int loadFileSub1(uint8** ptr, uint8* name, uint8* ptr2) -{ - int i; - char buffer[256]; - int fileIdx; - int unpackedSize; - uint8* unpackedBuffer; - - for(i=0;i<64;i++) - { - if(mediumVar[i].ptr) - { - if(!strcmpuint8(mediumVar[i].name,name)) - { - printf("Unsupported code in loadFIleSub1 !\n"); - exit(1); - } - } - } - - getFileExtention((char*)name,buffer); - - if(!strcmp(buffer,".SPL")) - { - removeExtention((char*)name,buffer); - - // if(useH32) - { - strcatuint8(buffer,".H32"); - } - /* else - if(useAdlib) - { - strcatuint8(buffer,".ADL"); - } - else - { - strcatuint8(buffer,".HP"); - }*/ - } - else - { - strcpyuint8(buffer,name); - } - - fileIdx = findFileInDisks((uint8*)buffer); - - if(fileIdx<0) - return(-18); - - unpackedSize = loadFileVar1 = volumePtrToFileDescriptor[fileIdx].extSize + 2; - - // TODO: here, can unpack in gfx module buffer - unpackedBuffer = (uint8*)mallocAndZero(unpackedSize); - - if(!unpackedBuffer) - { - return(-2); - } +int loadFileSub1(uint8 **ptr, uint8 *name, uint8 *ptr2) { + int i; + char buffer[256]; + int fileIdx; + int unpackedSize; + uint8 *unpackedBuffer; + + for (i = 0; i < 64; i++) { + if (mediumVar[i].ptr) { + if (!strcmpuint8(mediumVar[i].name, name)) { + printf("Unsupported code in loadFIleSub1 !\n"); + exit(1); + } + } + } + + getFileExtention((char *)name, buffer); + + if (!strcmp(buffer, ".SPL")) { + removeExtention((char *)name, buffer); + + // if(useH32) + { + strcatuint8(buffer, ".H32"); + } + /* else + * if(useAdlib) + * { + * strcatuint8(buffer,".ADL"); + * } + * else + * { + * strcatuint8(buffer,".HP"); + * } */ + } else { + strcpyuint8(buffer, name); + } + + fileIdx = findFileInDisks((uint8 *) buffer); + + if (fileIdx < 0) + return (-18); + + unpackedSize = loadFileVar1 = + volumePtrToFileDescriptor[fileIdx].extSize + 2; + + // TODO: here, can unpack in gfx module buffer + unpackedBuffer = (uint8 *) mallocAndZero(unpackedSize); + + if (!unpackedBuffer) { + return (-2); + } lastFileSize = unpackedSize; - if(volumePtrToFileDescriptor[fileIdx].size +2 != unpackedSize) - { - unsigned short int realUnpackedSize; - uint8* tempBuffer; - uint8* pakedBuffer = (uint8*) mallocAndZero(volumePtrToFileDescriptor[fileIdx].size +2); + if (volumePtrToFileDescriptor[fileIdx].size + 2 != unpackedSize) { + unsigned short int realUnpackedSize; + uint8 *tempBuffer; + uint8 *pakedBuffer = + (uint8 *) mallocAndZero(volumePtrToFileDescriptor[fileIdx]. + size + 2); - loadPakedFileToMem(fileIdx,pakedBuffer); + loadPakedFileToMem(fileIdx, pakedBuffer); - realUnpackedSize = *(uint16*)(pakedBuffer+volumePtrToFileDescriptor[fileIdx].size-2); - flipShort((int16*)&realUnpackedSize); + realUnpackedSize = + *(uint16 *) (pakedBuffer + + volumePtrToFileDescriptor[fileIdx].size - 2); + flipShort((int16 *) & realUnpackedSize); - lastFileSize = realUnpackedSize; + lastFileSize = realUnpackedSize; - tempBuffer = (uint8*)mallocAndZero(realUnpackedSize); + tempBuffer = (uint8 *) mallocAndZero(realUnpackedSize); - decomp((uint8*)pakedBuffer+volumePtrToFileDescriptor[fileIdx].size-4,(uint8*)unpackedBuffer+realUnpackedSize,realUnpackedSize); + decomp((uint8 *) pakedBuffer + + volumePtrToFileDescriptor[fileIdx].size - 4, + (uint8 *) unpackedBuffer + realUnpackedSize, + realUnpackedSize); - free(pakedBuffer); - } - else - { - loadPakedFileToMem(fileIdx,unpackedBuffer); - } + free(pakedBuffer); + } else { + loadPakedFileToMem(fileIdx, unpackedBuffer); + } - *ptr = unpackedBuffer; + *ptr = unpackedBuffer; - return(1); + return (1); } -void resetFileEntry(int32 entryNumber) -{ - if(entryNumber>=257) - return; +void resetFileEntry(int32 entryNumber) { + if (entryNumber >= 257) + return; - if(!filesDatabase[entryNumber].subData.ptr) - return; + if (!filesDatabase[entryNumber].subData.ptr) + return; - free(filesDatabase[entryNumber].subData.ptr); + free(filesDatabase[entryNumber].subData.ptr); - filesDatabase[entryNumber].subData.ptr = NULL; - filesDatabase[entryNumber].subData.ptr2 = NULL; - filesDatabase[entryNumber].widthInColumn = 0; - filesDatabase[entryNumber].width = 0; - filesDatabase[entryNumber].resType = 0; - filesDatabase[entryNumber].height = 0; - filesDatabase[entryNumber].subData.index = -1; - filesDatabase[entryNumber].subData.resourceType = 0; - filesDatabase[entryNumber].subData.field_1C = 0; - filesDatabase[entryNumber].subData.name[0] = 0; + filesDatabase[entryNumber].subData.ptr = NULL; + filesDatabase[entryNumber].subData.ptr2 = NULL; + filesDatabase[entryNumber].widthInColumn = 0; + filesDatabase[entryNumber].width = 0; + filesDatabase[entryNumber].resType = 0; + filesDatabase[entryNumber].height = 0; + filesDatabase[entryNumber].subData.index = -1; + filesDatabase[entryNumber].subData.resourceType = 0; + filesDatabase[entryNumber].subData.field_1C = 0; + filesDatabase[entryNumber].subData.name[0] = 0; } -uint8* mainProc14(uint16 overlay, uint16 idx) -{ - ASSERT(0); - - return NULL; +uint8 *mainProc14(uint16 overlay, uint16 idx) { + ASSERT(0); + + return NULL; } -int initAllData(void) -{ - int i; - - setupFuncArray(); - setupOpcodeTable(); - initOverlayTable(); +int initAllData(void) { + int i; - setup1 = 0; - currentActiveBackgroundPlane = 0; + setupFuncArray(); + setupOpcodeTable(); + initOverlayTable(); - freeDisk(); + setup1 = 0; + currentActiveBackgroundPlane = 0; - initVar5[0] = -1; - initVar5[3] = -1; - initVar5[6] = -1; - initVar5[9] = -1; + freeDisk(); - menuTable[0] = NULL; + initVar5[0] = -1; + initVar5[3] = -1; + initVar5[6] = -1; + initVar5[9] = -1; - for(i=0;i<2000;i++) - { - globalVars[i] = 0; - } + menuTable[0] = NULL; - for(i=0;i<8;i++) - { - backgroundTable[i].name[0] = 0; - } + for (i = 0; i < 2000; i++) { + globalVars[i] = 0; + } - for(i=0;i<257;i++) - { - filesDatabase[i].subData.ptr = NULL; - filesDatabase[i].subData.ptr2 = NULL; - } + for (i = 0; i < 8; i++) { + backgroundTable[i].name[0] = 0; + } - initBigVar3(); + for (i = 0; i < 257; i++) { + filesDatabase[i].subData.ptr = NULL; + filesDatabase[i].subData.ptr2 = NULL; + } - resetPtr2(&scriptHandle2); - resetPtr2(&scriptHandle1); + initBigVar3(); - resetPtr(&cellHead); + resetPtr2(&scriptHandle2); + resetPtr2(&scriptHandle1); - resetActorPtr(&actorHead); - resetBackgroundIncrustList(&backgroundIncrustHead); + resetPtr(&cellHead); - bootOverlayNumber = loadOverlay((uint8*)"AUTO00"); + resetActorPtr(&actorHead); + resetBackgroundIncrustList(&backgroundIncrustHead); + + bootOverlayNumber = loadOverlay((uint8 *) "AUTO00"); #ifdef DUMP_SCRIPT loadOverlay("TITRE"); @@ -627,724 +576,801 @@ int initAllData(void) //exit(1); #endif - if(bootOverlayNumber) - { - positionInStack = 0; + if (bootOverlayNumber) { + positionInStack = 0; - attacheNewScriptToTail(bootOverlayNumber,&scriptHandle2,0,20,0,0,scriptType_20); - scriptFunc2(bootOverlayNumber,&scriptHandle2,1,0); - } + attacheNewScriptToTail(bootOverlayNumber, &scriptHandle2, 0, + 20, 0, 0, scriptType_20); + scriptFunc2(bootOverlayNumber, &scriptHandle2, 1, 0); + } - strcpyuint8(systemStrings.bootScriptName,"AUTO00"); + strcpyuint8(systemStrings.bootScriptName, "AUTO00"); - return(bootOverlayNumber); + return (bootOverlayNumber); } -int removeFinishedScripts(scriptInstanceStruct* ptrHandle) -{ - scriptInstanceStruct* ptr = ptrHandle->nextScriptPtr; // can't destruct the head - scriptInstanceStruct* oldPtr = ptrHandle; - - if(!ptr) - return(0); - - do - { - if(ptr->scriptNumber == -1) - { - oldPtr->nextScriptPtr = ptr->nextScriptPtr; - - if(ptr->var6 && ptr->varA) - { - // free(ptr->var6); - } - - free(ptr); - - ptr = oldPtr->nextScriptPtr; - } - else - { - oldPtr = ptr; - ptr = ptr->nextScriptPtr; - } - }while(ptr); - - return(0); +int removeFinishedScripts(scriptInstanceStruct *ptrHandle) { + scriptInstanceStruct *ptr = ptrHandle->nextScriptPtr; // can't destruct the head + scriptInstanceStruct *oldPtr = ptrHandle; + + if (!ptr) + return (0); + + do { + if (ptr->scriptNumber == -1) { + oldPtr->nextScriptPtr = ptr->nextScriptPtr; + + if (ptr->var6 && ptr->varA) { + // free(ptr->var6); + } + + free(ptr); + + ptr = oldPtr->nextScriptPtr; + } else { + oldPtr = ptr; + ptr = ptr->nextScriptPtr; + } + } while (ptr); + + return (0); } int nePasAffichierMenuDialogue; int var37 = 0; int var38 = 0; -int getCursorFromObject(int mouseX, int mouseY, int* outX, int* outY) -{ - int16 var_2; - int16 var_4; - int16 var_14; - int16 var_16; - objectParamsQuery params; - int16 var_10; - int16 var_E; - int16 var_C; +int getCursorFromObject(int mouseX, int mouseY, int *outX, int *outY) { + int16 var_2; + int16 var_4; + int16 var_14; + int16 var_16; + objectParamsQuery params; + int16 var_10; + int16 var_E; + int16 var_C; // int16 var_42; - int16 var_A; - int16 var_6; - - char objectName[80]; - - cellStruct* currentObject = cellHead.prev; - - while(currentObject) - { - if(currentObject->overlay >= 0) - { - if(overlayTable[currentObject->overlay].alreadyLoaded) - { - if(currentObject->type == 4 || currentObject->type == 1 || currentObject->type == 9 || currentObject->type == 3) - { - strcpy(objectName, getObjectName(currentObject->idx, overlayTable[currentObject->overlay].ovlData->specialString2)); - - if(strlen(objectName)) - { - if(currentObject->freeze == 0) - { - var_2 = currentObject->idx; - var_4 = currentObject->overlay; - var_14 = currentObject->followObjectIdx; - var_16 = currentObject->followObjectOverlayIdx; - - getMultipleObjectParam(currentObject->overlay, currentObject->idx, ¶ms); - - var_10 = 0; - var_E = 0; - var_C = 0; - - if((var_4 != var_16) && (var_2 != var_14)) - { - getMultipleObjectParam(var_16, var_14, ¶ms); - - var_C = params.X; - var_E = params.Y; - var_10 = params.fileIdx; - } - - if(params.var5 >= 0 && params.fileIdx >= 0) - { - if(currentObject->type == 3) - { - assert(0); - - var_2 = params.scale; - var_A = params.X + var_C; - - // TODO: this var3 is stupid, investigate... - if((var_A <= mouseX) && (var_A + params.fileIdx >= mouseX) && (mouseY >= params.Y + var_E) && (params.Y + var_E + var2 >= mouseY)) - { - *outX = var_16; - *outY = var_14; - - return(currentObject->type); - } - } - else - if(currentObject->type == 4 || currentObject->type == 1 || currentObject->type == 9 ) - { - int si; - int var_8; - int di; - - var_A = params.X + var_C; - var_6 = params.Y + var_E; - - di = params.fileIdx; - - if(di<0) - { - di += var_10; - } + int16 var_A; + int16 var_6; + + char objectName[80]; + + cellStruct *currentObject = cellHead.prev; + + while (currentObject) { + if (currentObject->overlay >= 0) { + if (overlayTable[currentObject->overlay].alreadyLoaded) { + if (currentObject->type == 4 + || currentObject->type == 1 + || currentObject->type == 9 + || currentObject->type == 3) { + strcpy(objectName, + getObjectName(currentObject->idx, + overlayTable[currentObject-> + overlay].ovlData-> + specialString2)); + + if (strlen(objectName)) { + if (currentObject->freeze == 0) { + var_2 = + currentObject->idx; + var_4 = + currentObject-> + overlay; + var_14 = + currentObject-> + followObjectIdx; + var_16 = + currentObject-> + followObjectOverlayIdx; + + getMultipleObjectParam + (currentObject-> + overlay, + currentObject->idx, + ¶ms); + + var_10 = 0; + var_E = 0; + var_C = 0; + + if ((var_4 != var_16) + && (var_2 != + var_14)) { + getMultipleObjectParam + (var_16, + var_14, + ¶ms); + + var_C = + params.X; + var_E = + params.Y; + var_10 = + params. + fileIdx; + } + + if (params.var5 >= 0 + && params. + fileIdx >= 0) { + if (currentObject->type == 3) { + assert + (0); + + var_2 = + params. + scale; + var_A = + params. + X + + var_C; + + // TODO: this var3 is stupid, investigate... + if ((var_A <= mouseX) && (var_A + params.fileIdx >= mouseX) && (mouseY >= params.Y + var_E) && (params.Y + var_E + var2 >= mouseY)) { + *outX + = + var_16; + *outY + = + var_14; + + return + (currentObject-> + type); + } + } else + if + (currentObject-> + type == 4 + || + currentObject-> + type == 1 + || + currentObject-> + type == + 9) { + int si; + int var_8; + int di; + + var_A = + params. + X + + var_C; + var_6 = + params. + Y + + var_E; + + di = params.fileIdx; + + if (di + < + 0) + { + di += var_10; + } /* if((filesDatabase[di].subData.resourceType == 8) && (filesDatabase[di].subData.ptr)) { assert(0); } else */ - { - var_4 = filesDatabase[di].resType; - - if(var_4 == 1) - { - var_C = filesDatabase[di].widthInColumn/2; - } - else - { - var_C = filesDatabase[di].width; - } - - var_8 = filesDatabase[di].height; - - var_2 = mouseX - var_A; - si = mouseY - var_6; - - if(var_2>0) - { - if(var_C>var_2) - { - if(si>0) - { - if(var_8>=si) - { - if(filesDatabase[di].subData.ptr) - { - if(var_4 == 1) - { - } - else - { - } - - printf("should compare to mask in getCursorFromObject...\n"); - - *outX = var_16; - *outY = var_14; - - printf("Selected: %s\n", objectName); - - return currentObject->type; - } - } - } - } - } - } - } - } - } - } - } - } - } + { + var_4 + = + filesDatabase + [di]. + resType; + + if (var_4 == 1) { + var_C + = + filesDatabase + [di]. + widthInColumn + / + 2; + } else { + var_C + = + filesDatabase + [di]. + width; + } + + var_8 + = + filesDatabase + [di]. + height; + + var_2 + = + mouseX + - + var_A; + si = mouseY - var_6; + + if (var_2 > 0) { + if (var_C > var_2) { + if (si > 0) { + if (var_8 >= si) { + if (filesDatabase[di].subData.ptr) { + if (var_4 == 1) { + } else { + } + + printf + ("should compare to mask in getCursorFromObject...\n"); + + *outX + = + var_16; + *outY + = + var_14; + + printf + ("Selected: %s\n", + objectName); + + return + currentObject-> + type; + } + } + } + } + } + } + } + } + } + } + } + } + } - currentObject = currentObject->prev; - } + currentObject = currentObject->prev; + } - *outX = 0; - *outY = 0; + *outX = 0; + *outY = 0; - return -1; + return -1; } char keyboardVar = 0; -void freeStuff2(void) -{ - printf("implement freeStuff2\n"); +void freeStuff2(void) { + printf("implement freeStuff2\n"); } -void *allocAndZero(int size) -{ - void *ptr; +void *allocAndZero(int size) { + void *ptr; - ptr = malloc(size); - memset(ptr,0,size); + ptr = malloc(size); + memset(ptr, 0, size); - return ptr; + return ptr; } -char* getObjectName(int index, uint8* string) -{ - int i; - char* ptr = (char*)string; - - if(!string) - return NULL; - - for(i=0;i<index;i++) - { - while(*ptr) - { - ptr++; - } - ptr++; - } - return ptr; +char *getObjectName(int index, uint8 *string) { + int i; + char *ptr = (char *)string; + + if (!string) + return NULL; + + for (i = 0; i < index; i++) { + while (*ptr) { + ptr++; + } + ptr++; + } + return ptr; } -int buildInventorySub1(int overlayIdx, int objIdx) -{ - objDataStruct* pObjectData = getObjectDataFromOverlay(overlayIdx, objIdx); - - if(pObjectData) - { - return pObjectData->var1; - } - else - { - return -11; - } +int buildInventorySub1(int overlayIdx, int objIdx) { + objDataStruct *pObjectData = + getObjectDataFromOverlay(overlayIdx, objIdx); + + if (pObjectData) { + return pObjectData->var1; + } else { + return -11; + } } -void buildInventory(int X, int Y) -{ - int numObjectInInventory = 0; - menuStruct* pMenu; - - pMenu = createMenu(X, Y, "Inventaire"); - - menuTable[1] = pMenu; - - if(pMenu) - { - numObjectInInventory = 0; - - if(numOfLoadedOverlay > 1) - { - int i; - - for(i=1;i<numOfLoadedOverlay;i++) - { - ovlDataStruct* pOvlData = overlayTable[i].ovlData; - - if(pOvlData && pOvlData->objDataTable) - { - int var_2; - - var_2 = 0; - - if(pOvlData->numObjData) - { - int j; - - for(j=0;j<pOvlData->numObjData;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)); - numObjectInInventory++; - } - } - } - } - } - } - } - } - - if(numObjectInInventory == 0) - { - freeMenu(menuTable[1]); - menuTable[1] = NULL; - } +void buildInventory(int X, int Y) { + int numObjectInInventory = 0; + menuStruct *pMenu; + + pMenu = createMenu(X, Y, "Inventaire"); + + menuTable[1] = pMenu; + + if (pMenu) { + numObjectInInventory = 0; + + if (numOfLoadedOverlay > 1) { + int i; + + for (i = 1; i < numOfLoadedOverlay; i++) { + ovlDataStruct *pOvlData = + overlayTable[i].ovlData; + + if (pOvlData && pOvlData->objDataTable) { + int var_2; + + var_2 = 0; + + if (pOvlData->numObjData) { + int j; + + for (j = 0; + j < pOvlData->numObjData; + 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)); + numObjectInInventory++; + } + } + } + } + } + } + } + } + + if (numObjectInInventory == 0) { + freeMenu(menuTable[1]); + menuTable[1] = NULL; + } } int currentMenuElementX; int currentMenuElementY; -menuElementStruct* currentMenuElement; +menuElementStruct *currentMenuElement; -menuElementSubStruct* getSelectedEntryInMenu(menuStruct* pMenu) -{ - menuElementStruct* pMenuElement; +menuElementSubStruct *getSelectedEntryInMenu(menuStruct *pMenu) { + menuElementStruct *pMenuElement; - if(pMenu == NULL) - { - return NULL; - } + if (pMenu == NULL) { + return NULL; + } - if(pMenu->numElements == 0) - { - return NULL; - } + if (pMenu->numElements == 0) { + return NULL; + } - pMenuElement = pMenu->ptrNextElement; + pMenuElement = pMenu->ptrNextElement; - while(pMenuElement) - { - if(pMenuElement->varC) - { - currentMenuElementX = pMenuElement->x; - currentMenuElementY = pMenuElement->y; - currentMenuElement = pMenuElement; + while (pMenuElement) { + if (pMenuElement->varC) { + currentMenuElementX = pMenuElement->x; + currentMenuElementY = pMenuElement->y; + currentMenuElement = pMenuElement; - return pMenuElement->ptrSub; - } + return pMenuElement->ptrSub; + } - pMenuElement = pMenuElement->next; - } + pMenuElement = pMenuElement->next; + } - return NULL; + 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; - - var_30 = -1; - - getSingleObjectParam(param0,param1,5,&returnVar); - - 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; - - if(var_18) - { - int var_16; - - var_16 = 0; - - for(var_14 = 0; var_14 < var_18;var_14++) - { - objDataStruct* pObject; - linkDataStruct* var_34; - int var_2; - - var_34 = &var_2A->linkDataPtr[var_14]; - - var_2 = var_34->stringIdx; - - if(!var_2) - { - var_2 = var_1E; - } - - pObject = getObjectDataFromOverlay(var_2,var_34->stringNameOffset); - - if(var_2 == param0) - { - if(param1 == var_34->stringNameOffset) - { - if(pObject) - { - if(pObject->var1 != 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; - } +int callInventoryObject(int param0, int param1, int x, int y) { + int var_2C; + int var_30; + int var_28; + int var_1E; + int16 returnVar; + + var_30 = -1; + + getSingleObjectParam(param0, param1, 5, &returnVar); + + 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; + + if (var_18) { + int var_16; + + var_16 = 0; + + for (var_14 = 0; var_14 < var_18; var_14++) { + objDataStruct *pObject; + linkDataStruct *var_34; + int var_2; + + var_34 = &var_2A->linkDataPtr[var_14]; + + var_2 = var_34->stringIdx; + + if (!var_2) { + var_2 = var_1E; + } + + pObject = + getObjectDataFromOverlay(var_2, + var_34->stringNameOffset); + + if (var_2 == param0) { + if (param1 == + var_34->stringNameOffset) { + if (pObject) { + if (pObject-> + var1 != + 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, + &scriptHandle1, + var_34-> + field_2, + 30, + currentScriptPtr-> + scriptNumber, + currentScriptPtr-> + overlayNumber, + scriptType_30); + } 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(var_2>0) - { - var_12 = overlayTable[var_2].ovlData; - } + return var_2C; +} - 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; - } - } - } - } - } +int processInventory(void) { + if (menuTable[1]) { + menuElementSubStruct *pMenuElementSub = + getSelectedEntryInMenu(menuTable[1]); - 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,&scriptHandle1,var_34->field_2, 30, currentScriptPtr->scriptNumber,currentScriptPtr->overlayNumber, scriptType_30); - } - 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); - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - - return var_2C; + if (pMenuElementSub) { + //int var2; + //int var4; + + var2 = pMenuElementSub->var2; + var4 = pMenuElementSub->var4; + + freeMenu(menuTable[1]); + menuTable[1] = NULL; + + callInventoryObject(var2, var4, + currentMenuElementX + 80, currentMenuElementY); + + return 1; + } else { + freeMenu(menuTable[1]); + menuTable[1] = NULL; + } + } + + return 0; } -int processInventory(void) -{ - if(menuTable[1]) - { - menuElementSubStruct* pMenuElementSub = getSelectedEntryInMenu(menuTable[1]); +int processInput(void) { + menuStruct *var_5C; - if(pMenuElementSub) - { - //int var2; - //int var4; + int16 mouseX = 0; + int16 mouseY = 0; + int16 button = 0; - var2 = pMenuElementSub->var2; - var4 = pMenuElementSub->var4; + /*if(inputSub1keyboad()) + * { + * return 1; + * } */ - freeMenu(menuTable[1]); - menuTable[1] = NULL; + button = 0; - callInventoryObject(var2, var4, currentMenuElementX+80, currentMenuElementY); + if (sysKey != -1) { + button = sysKey; + mouseX = var11; + mouseY = var12; + sysKey = -1; + } else { + if (automaticMode == 0) { + getMouseStatus(&main10, &mouseX, &button, &mouseY); + } + } - return 1; - } - else - { - freeMenu(menuTable[1]); - menuTable[1] = NULL; - } - } + if (button) { + nePasAffichierMenuDialogue = 0; + } - return 0; -} + if (userDelay) { + userDelay--; + return 0; + } + // test both buttons + + if (((button & 3) == 3) || keyboardVar == 0x44 || keyboardVar == 0x53) { + changeCursor(0); + keyboardVar = 0; + return (playerMenu(mouseX, mouseY)); + } + + if (!userEnabled) { + return 0; + } + + if (currentActiveMenu != -1) { + var_5C = menuTable[currentActiveMenu]; + + if (var_5C) { + updateMenuMouse(mouseX, mouseY, var_5C); + } + } + + if (var6) { + ASSERT(0); + } + + if (button & 1) { + if (nePasAffichierMenuDialogue == 0) { + nePasAffichierMenuDialogue = 1; -int processInput(void) -{ - menuStruct* var_5C; - - int16 mouseX = 0; - int16 mouseY = 0; - int16 button = 0; - - /*if(inputSub1keyboad()) - { - return 1; - }*/ - - button = 0; - - if(sysKey != -1) - { - button = sysKey; - mouseX = var11; - mouseY = var12; - sysKey = -1; - } - else - { - if(automaticMode == 0) - { - getMouseStatus(&main10, &mouseX, &button, &mouseY); - } - } - - if(button) - { - nePasAffichierMenuDialogue = 0; - } - - if(userDelay) - { - userDelay--; - return 0; - } - - // test both buttons - - if(((button&3) == 3) || keyboardVar == 0x44 || keyboardVar == 0x53) - { - changeCursor(0); - keyboardVar = 0; - return(playerMenu(mouseX, mouseY)); - } - - if(!userEnabled) - { - return 0; - } - - if(currentActiveMenu != -1) - { - var_5C = menuTable[currentActiveMenu]; - - if(var_5C) - { - updateMenuMouse(mouseX,mouseY,var_5C); - } - } - - if(var6) - { - ASSERT(0); - } - - if(button & 1) - { - if(nePasAffichierMenuDialogue == 0) - { - nePasAffichierMenuDialogue = 1; - - if(mouseVar1) - { - ASSERT(0); - } - - if(var38 == 0) // are we in inventory mode ? - { - if(menuTable[0] == 0) - { - int X; - int Y; - int objIdx; - - objIdx = getCursorFromObject(mouseX, mouseY, &X, &Y); - - if(objIdx != -1) - { - //ASSERT(0); - //moveActor(X,Y,mouseVar1); - } - else - { - var34 = mouseX; - var35 = mouseY; - animationStart=true; - var38=0; - } - } - //ASSERT(0); - } - else - { - if(processInventory()) - { - var37 = 1; - currentActiveMenu = 0; - var38 = 0; - } - else - { - currentActiveMenu = -1; - var38 = 0; - } - - return 0; - } - - //ASSERT(0); - } - } - - if((button & 2) || (keyboardVar == 0x43) || (keyboardVar == 0x52)) - { - if(nePasAffichierMenuDialogue == 0) - { - keyboardVar = 0; - - if((mouseVar1 == 0) && (menuTable[0])) - { - ASSERT(0); - freeMenu(menuTable[0]); - menuTable[0] = NULL; - var37 = 0; - var38 = 0; - currentActiveMenu = -1; - } - - if(var37 || var38 || menuTable[1]) - { - nePasAffichierMenuDialogue = 1; - return 0; - } - - buildInventory(mouseX, mouseY); - - if(menuTable[1]) - { - currentActiveMenu = 1; - var38 = 1; - } - else - { - var38 = 1; - } - - nePasAffichierMenuDialogue = 1; - return 0; - } - } - return 0; + if (mouseVar1) { + ASSERT(0); + } + + if (var38 == 0) // are we in inventory mode ? + { + if (menuTable[0] == 0) { + int X; + int Y; + int objIdx; + + objIdx = + getCursorFromObject(mouseX, mouseY, + &X, &Y); + + if (objIdx != -1) { + //ASSERT(0); + //moveActor(X,Y,mouseVar1); + } else { + var34 = mouseX; + var35 = mouseY; + animationStart = true; + var38 = 0; + } + } + //ASSERT(0); + } else { + if (processInventory()) { + var37 = 1; + currentActiveMenu = 0; + var38 = 0; + } else { + currentActiveMenu = -1; + var38 = 0; + } + + return 0; + } + + //ASSERT(0); + } + } + + if ((button & 2) || (keyboardVar == 0x43) || (keyboardVar == 0x52)) { + if (nePasAffichierMenuDialogue == 0) { + keyboardVar = 0; + + if ((mouseVar1 == 0) && (menuTable[0])) { + ASSERT(0); + freeMenu(menuTable[0]); + menuTable[0] = NULL; + var37 = 0; + var38 = 0; + currentActiveMenu = -1; + } + + if (var37 || var38 || menuTable[1]) { + nePasAffichierMenuDialogue = 1; + return 0; + } + + buildInventory(mouseX, mouseY); + + if (menuTable[1]) { + currentActiveMenu = 1; + var38 = 1; + } else { + var38 = 1; + } + + nePasAffichierMenuDialogue = 1; + return 0; + } + } + return 0; } int oldMouseX; @@ -1353,98 +1379,98 @@ int oldMouseY; void manageEvents(int count) { Common::Event event; - Common::EventManager *eventMan = g_system->getEventManager(); + Common::EventManager * eventMan = g_system->getEventManager(); while (eventMan->pollEvent(event)) { switch (event.type) { - /* case Common::EVENT_LBUTTONDOWN: - mouseLeft = 1; - break; - case Common::EVENT_RBUTTONDOWN: - mouseRight = 1; - break; - case Common::EVENT_MOUSEMOVE: - break;*/ + /* case Common::EVENT_LBUTTONDOWN: + * mouseLeft = 1; + * break; + * case Common::EVENT_RBUTTONDOWN: + * mouseRight = 1; + * break; + * case Common::EVENT_MOUSEMOVE: + * break; */ case Common::EVENT_QUIT: g_system->quit(); break; - /* case Common::EVENT_KEYDOWN: - switch (event.kbd.keycode) { - case '\n': - case '\r': - case 261: // Keypad 5 - if (allowPlayerInput) { - mouseLeft = 1; - } - break; - case 27: // ESC - if (allowPlayerInput) { - mouseRight = 1; - } - break; - case 282: // F1 - if (allowPlayerInput) { - playerCommand = 0; // EXAMINE - makeCommandLine(); - } - break; - case 283: // F2 - if (allowPlayerInput) { - playerCommand = 1; // TAKE - makeCommandLine(); - } - break; - case 284: // F3 - if (allowPlayerInput) { - playerCommand = 2; // INVENTORY - makeCommandLine(); - } - break; - case 285: // F4 - if (allowPlayerInput) { - playerCommand = 3; // USE - makeCommandLine(); - } - break; - case 286: // F5 - if (allowPlayerInput) { - playerCommand = 4; // ACTIVATE - makeCommandLine(); - } - break; - case 287: // F6 - if (allowPlayerInput) { - playerCommand = 5; // SPEAK - makeCommandLine(); - } - break; - case 290: // F9 - if (allowPlayerInput && !inMenu) { - makeActionMenu(); - makeCommandLine(); - } - break; - case 291: // F10 - if (!disableSystemMenu && !inMenu) { - g_cine->makeSystemMenu(); - } - break; - default: - //lastKeyStroke = event.kbd.keycode; - break; - } - break; */ + /* case Common::EVENT_KEYDOWN: + * switch (event.kbd.keycode) { + * case '\n': + * case '\r': + * case 261: // Keypad 5 + * if (allowPlayerInput) { + * mouseLeft = 1; + * } + * break; + * case 27: // ESC + * if (allowPlayerInput) { + * mouseRight = 1; + * } + * break; + * case 282: // F1 + * if (allowPlayerInput) { + * playerCommand = 0; // EXAMINE + * makeCommandLine(); + * } + * break; + * case 283: // F2 + * if (allowPlayerInput) { + * playerCommand = 1; // TAKE + * makeCommandLine(); + * } + * break; + * case 284: // F3 + * if (allowPlayerInput) { + * playerCommand = 2; // INVENTORY + * makeCommandLine(); + * } + * break; + * case 285: // F4 + * if (allowPlayerInput) { + * playerCommand = 3; // USE + * makeCommandLine(); + * } + * break; + * case 286: // F5 + * if (allowPlayerInput) { + * playerCommand = 4; // ACTIVATE + * makeCommandLine(); + * } + * break; + * case 287: // F6 + * if (allowPlayerInput) { + * playerCommand = 5; // SPEAK + * makeCommandLine(); + * } + * break; + * case 290: // F9 + * if (allowPlayerInput && !inMenu) { + * makeActionMenu(); + * makeCommandLine(); + * } + * break; + * case 291: // F10 + * if (!disableSystemMenu && !inMenu) { + * g_cine->makeSystemMenu(); + * } + * break; + * default: + * //lastKeyStroke = event.kbd.keycode; + * break; + * } + * break; */ default: break; } } /*if (count) { - mouseData.left = mouseLeft; - mouseData.right = mouseRight; - mouseLeft = 0; - mouseRight = 0; - } -*/ + * mouseData.left = mouseLeft; + * mouseData.right = mouseRight; + * mouseLeft = 0; + * mouseRight = 0; + * } + */ int i; for (i = 0; i < count; i++) { @@ -1457,225 +1483,212 @@ void manageEvents(int count) { g_system->updateScreen(); g_system->delayMillis(10); manageEvents(0); - } + } } -void mainLoop(void) -{ - #define SPEED 40 /* Ticks per Frame */ - #define SLEEP_MIN 20 /* Minimum time a sleep takes, usually 2*GRAN */ - #define SLEEP_GRAN 1 /* Granularity of sleep */ - - int frames=0; /* Number of frames displayed */ - //int32 t_start,t_left; - //uint32 t_end; - //int32 q=0; /* Dummy */ - - int enableUser = 0; - //int16 mouseX; - //int16 mouseY; - //int16 mouseButton; - - scriptNameBuffer[0] = 0; - systemStrings.bootScriptName[0] = 0; - initVar4[0] = 0; - currentActiveMenu = -1; - main14 = -1; - mouseVar1 = 0; - main21 = 0; - main22 = 0; - main7 = 0; - main8 = 0; - main15 = 0; - - if(initAllData()) - { - int playerDontAskQuit = 1; - int quitValue2 = 1; - int quitValue = 0; - - do - { - frames++; +void mainLoop(void) { +#define SPEED 40 /* Ticks per Frame */ +#define SLEEP_MIN 20 /* Minimum time a sleep takes, usually 2*GRAN */ +#define SLEEP_GRAN 1 /* Granularity of sleep */ + + int frames = 0; /* Number of frames displayed */ + //int32 t_start,t_left; + //uint32 t_end; + //int32 q=0; /* Dummy */ + + int enableUser = 0; + //int16 mouseX; + //int16 mouseY; + //int16 mouseButton; + + scriptNameBuffer[0] = 0; + systemStrings.bootScriptName[0] = 0; + initVar4[0] = 0; + currentActiveMenu = -1; + main14 = -1; + mouseVar1 = 0; + main21 = 0; + main22 = 0; + main7 = 0; + main8 = 0; + main15 = 0; + + if (initAllData()) { + int playerDontAskQuit = 1; + int quitValue2 = 1; + int quitValue = 0; + + do { + frames++; // t_start=Osystem_GetTicks(); // readKeyboard(); - playerDontAskQuit = processInput(); + playerDontAskQuit = processInput(); - //if(enableUser) - { - userEnabled = 1; - enableUser = 0; - } - - manageScripts(&scriptHandle1); - manageScripts(&scriptHandle2); + //if(enableUser) + { + userEnabled = 1; + enableUser = 0; + } - removeFinishedScripts(&scriptHandle1); - removeFinishedScripts(&scriptHandle2); + manageScripts(&scriptHandle1); + manageScripts(&scriptHandle2); - processAnimation(); + removeFinishedScripts(&scriptHandle1); + removeFinishedScripts(&scriptHandle2); - if(var0) - { - // ASSERT(0); - /* main3 = 0; - var24 = 0; - var23 = 0; + processAnimation(); - freeStuff2(); */ - } + if (var0) { + // ASSERT(0); + /* main3 = 0; + * var24 = 0; + * var23 = 0; + * + * freeStuff2(); */ + } - if(initVar4[0]) - { - ASSERT(0); + if (initVar4[0]) { + ASSERT(0); /* redrawStrings(0,&initVar4,8); waitForPlayerInput(); initVar4 = 0; */ - } + } - if(affichePasMenuJoueur) - { - if(main5) - fadeVar = 0; + if (affichePasMenuJoueur) { + if (main5) + fadeVar = 0; - /*if(fadeVar) - { - // TODO! - }*/ + /*if(fadeVar) + * { + * // TODO! + * } */ mainDraw(0); flipScreen(); - /* if(userEnabled && !main7 && !main15 && currentActiveMenu == -1) - { - getMouseStatus(&main10, &mouseX, &mouseButton, &mouseY); - - if(mouseX != oldMouseX && mouseY != oldMouseY) - { - int cursorType; - int newCursor1; - int newCursor2; - - oldMouseX = mouseX; - oldMouseY = mouseY; - - cursorType = getCursorFromObject(mouseX, mouseY, &newCursor1, &newCursor2); - - if(cursorType == 9) - { - changeCursor(5); - } - else - if(cursorType == -1) - { - changeCursor(6); - } - else - { - changeCursor(4); - } - - } - } - else*/ - { - changeCursor(0); - } - - if(main7) - { - ASSERT(0); - } - - if(main15) - { - ASSERT(0); - } - - if(main14 != -1) - { - ASSERT(0); - } - } - - // t_end = t_start+SPEED; + /* if(userEnabled && !main7 && !main15 && currentActiveMenu == -1) + * { + * getMouseStatus(&main10, &mouseX, &mouseButton, &mouseY); + * + * if(mouseX != oldMouseX && mouseY != oldMouseY) + * { + * int cursorType; + * int newCursor1; + * int newCursor2; + * + * oldMouseX = mouseX; + * oldMouseY = mouseY; + * + * cursorType = getCursorFromObject(mouseX, mouseY, &newCursor1, &newCursor2); + * + * if(cursorType == 9) + * { + * changeCursor(5); + * } + * else + * if(cursorType == -1) + * { + * changeCursor(6); + * } + * else + * { + * changeCursor(4); + * } + * + * } + * } + * else */ + { + changeCursor(0); + } + + if (main7) { + ASSERT(0); + } + + if (main15) { + ASSERT(0); + } + + if (main14 != -1) { + ASSERT(0); + } + } + // t_end = t_start+SPEED; // t_left=t_start-Osystem_GetTicks()+SPEED; #ifndef FASTDEBUG - /* if(t_left>0) - if(t_left>SLEEP_MIN) - Osystem_Delay(t_left-SLEEP_GRAN); - while(Osystem_GetTicks()<t_end){q++;}; */ + /* if(t_left>0) + * if(t_left>SLEEP_MIN) + * Osystem_Delay(t_left-SLEEP_GRAN); + * while(Osystem_GetTicks()<t_end){q++;}; */ #endif - manageEvents(4); + manageEvents(4); - }while(!playerDontAskQuit && quitValue2 && quitValue != 7); - } + } while (!playerDontAskQuit && quitValue2 && quitValue != 7); + } } -int oldmain(int argc, char* argv[]) -{ - printf("Cruise for a corpse recode\n"); +int oldmain(int argc, char *argv[]) { + printf("Cruise for a corpse recode\n"); // OSystemInit(); // osystem = new OSystem; - printf("Osystem Initialized\n"); + printf("Osystem Initialized\n"); + + printf("Initializing engine...\n"); - printf("Initializing engine...\n"); - // initBuffer(scaledScreen,640,400); - fadeVar = 0; + fadeVar = 0; - //lowLevelInit(); + //lowLevelInit(); - // arg parser stuff + // arg parser stuff - ptr_something = (ctpVar19Struct*)mallocAndZero(sizeof(ctpVar19Struct)*0x200); + ptr_something = + (ctpVar19Struct *) mallocAndZero(sizeof(ctpVar19Struct) * 0x200); - /*volVar1 = 0; - fileData1 = 0;*/ + /*volVar1 = 0; + * fileData1 = 0; */ - /*PAL_fileHandle = -1;*/ + /*PAL_fileHandle = -1; */ - // video init stuff + // video init stuff - loadSystemFont(); + loadSystemFont(); - // another bit of video init + // another bit of video init - if(!readVolCnf()) - { - printf("Fatal: unable to load vol.cnf !\n"); - return(-1); - } + if (!readVolCnf()) { + printf("Fatal: unable to load vol.cnf !\n"); + return (-1); + } - printf("Entering main loop...\n"); - mainLoop(); + printf("Entering main loop...\n"); + mainLoop(); - //freeStuff(); + //freeStuff(); - //freePtr(ptr_something); + //freePtr(ptr_something); - return(0); + return (0); } -void changeCursor(uint16 cursorType) -{ - //printf("changeCursor %d\n", cursorType); +void changeCursor(uint16 cursorType) { + //printf("changeCursor %d\n", cursorType); } -void* mallocAndZero(int32 size) -{ - void* ptr; +void *mallocAndZero(int32 size) { + void *ptr; - ptr = malloc(size); - memset(ptr,0,size); - return ptr; + ptr = malloc(size); + memset(ptr, 0, size); + return ptr; } } // End of namespace Cruise |