diff options
32 files changed, 2511 insertions, 2823 deletions
diff --git a/engines/cruise/actor.cpp b/engines/cruise/actor.cpp index 943ffa5c8d..88870f3f13 100644 --- a/engines/cruise/actor.cpp +++ b/engines/cruise/actor.cpp @@ -32,8 +32,8 @@ int16 mainProc13(int overlayIdx, int param1, actorStruct *pStartEntry, int param while (pCurrentEntry) { if ((pCurrentEntry->overlayNumber == overlayIdx || overlayIdx == -1) && - (pCurrentEntry->idx == param1 || param1 == -1) && - (pCurrentEntry->type == param2 || param2 == -1)) { + (pCurrentEntry->idx == param1 || param1 == -1) && + (pCurrentEntry->type == param2 || param2 == -1)) { if (pCurrentEntry->pathId != -2) { return 0; } @@ -50,9 +50,9 @@ actorStruct *findActor(actorStruct *pStartEntry, int overlayIdx, int objIdx, int while (pCurrentEntry) { if ((pCurrentEntry->overlayNumber == overlayIdx - || overlayIdx == -1) && (pCurrentEntry->idx == objIdx - || objIdx == -1) && (pCurrentEntry->type == type - || type == -1)) { + || overlayIdx == -1) && (pCurrentEntry->idx == objIdx + || objIdx == -1) && (pCurrentEntry->type == type + || type == -1)) { return pCurrentEntry; } @@ -71,10 +71,10 @@ void getPixel(int x, int y) { int16* polygone = (int16*)polyStruct0; int16* next; - while ((next = *(int16**)polygone) != (int16 *) -1) { - polygone+=sizeof(uint16*); + while ((next = *(int16**)polygone) != (int16 *) - 1) { + polygone += sizeof(uint16*); - int16* tableau = polygone+2; + int16* tableau = polygone + 2; x_min = *tableau++; x_max = *tableau++; @@ -85,12 +85,12 @@ void getPixel(int x, int y) { if (walkboxState[computedVar14] == 0 && ((x >= x_min && x <= x_max) && (y >= y_min && y <= y_max))) { // click was in given box - int u = y-y_min; - tableau+=u*2; + int u = y - y_min; + tableau += u * 2; x_min = *tableau++; x_max = *tableau++; - if ( (x>=x_min && x<=x_max) ) { + if ((x >= x_min && x <= x_max)) { flag_obstacle = walkboxColor[computedVar14]; return; @@ -483,7 +483,7 @@ void valide_noeud(int16 table[], int16 p, int *nclick, int16 solution0[20 + 3][2 polyStruct0 = polyStructExp; poly2(x2, y2, ctp_routeCoords[select_noeud[1]][0], - ctp_routeCoords[select_noeud[1]][1]); + ctp_routeCoords[select_noeud[1]][1]); solution0[1][0] = table_ptselect[1][0] = X; solution0[1][1] = table_ptselect[1][1] = Y; @@ -526,8 +526,8 @@ void valide_noeud(int16 table[], int16 p, int *nclick, int16 solution0[20 + 3][2 } polyStruct0 = polyStructExp; poly2(x2, y2, - ctp_routeCoords[select_noeud[1]][0], - ctp_routeCoords[select_noeud[1]][1]); + ctp_routeCoords[select_noeud[1]][0], + ctp_routeCoords[select_noeud[1]][1]); solution0[i + 1][0] = table_ptselect[1][0] = X; solution0[i + 1][1] = table_ptselect[1][1] = Y; solution0[i + 2][0] = -1; @@ -536,7 +536,7 @@ void valide_noeud(int16 table[], int16 p, int *nclick, int16 solution0[20 + 3][2 return; } - /****** COUPE LE CHEMIN ******/ + /****** COUPE LE CHEMIN ******/ i++; d = 0; @@ -588,8 +588,7 @@ int16 computePathfinding(int16 *pSolution, int16 x, int16 y, int16 destX, int16 } } - if (!flagCt) - { + if (!flagCt) { int i; int16 *ptr; @@ -638,7 +637,7 @@ int16 computePathfinding(int16 *pSolution, int16 x, int16 y, int16 destX, int16 return (-1); } -/******* cherche le premier noeud ******/ + /******* cherche le premier noeud ******/ getPixel(x, y); @@ -658,7 +657,7 @@ int16 computePathfinding(int16 *pSolution, int16 x, int16 y, int16 destX, int16 flag_aff_chemin = 0; -/******* cherche le deuxieme noeud ******/ + /******* cherche le deuxieme noeud ******/ num = 0; while (num < NUM_PERSONS && persoTable[num] != NULL) @@ -719,28 +718,28 @@ int raoul_move[][13] = { {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 0}, /* dos */ {13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 0}, /* droite */ {25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 0}, /* face */ - {-13, -14, -15, -16, -17, -18, -19, -20, -21, -22, -23, -24, 0} /* gauche */ + { -13, -14, -15, -16, -17, -18, -19, -20, -21, -22, -23, -24, 0} /* gauche */ }; int raoul_end[][13] = { {37, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, /* stat dos */ {38, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, /* stat droite */ {39, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, /* stat face */ - {-38, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} /* stat gauche */ + { -38, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} /* stat gauche */ }; int raoul_stat[][13] = { {53, 54, 55, 56, 57, 0, 0, 0, 0, 0, 0, 0, 0}, /* ret dos-dr */ {59, 60, 62, 63, 78, 0, 0, 0, 0, 0, 0, 0, 0}, /* ret dr-face */ - {-78, -63, -62, -60, -59, 0, 0, 0, 0, 0, 0, 0, 0}, /* ret face-ga */ - {-57, -56, -55, -54, -53, 0, 0, 0, 0, 0, 0, 0, 0} /* ret ga-dos */ + { -78, -63, -62, -60, -59, 0, 0, 0, 0, 0, 0, 0, 0}, /* ret face-ga */ + { -57, -56, -55, -54, -53, 0, 0, 0, 0, 0, 0, 0, 0} /* ret ga-dos */ }; int raoul_invstat[][13] = { - {-53, -54, -55, -56, -57, 0, 0, 0, 0, 0, 0, 0, 0}, /* ret dos-dr */ + { -53, -54, -55, -56, -57, 0, 0, 0, 0, 0, 0, 0, 0}, /* ret dos-dr */ {57, 56, 55, 54, 53, 0, 0, 0, 0, 0, 0, 0, 0}, /* ret ga-dos */ {78, 63, 62, 60, 59, 0, 0, 0, 0, 0, 0, 0, 0}, /* ret face-ga */ - {-59, -60, -62, -63, -78, 0, 0, 0, 0, 0, 0, 0, 0} /* ret dr-face */ + { -59, -60, -62, -63, -78, 0, 0, 0, 0, 0, 0, 0, 0} /* ret dr-face */ }; @@ -787,286 +786,282 @@ void processAnimation(void) { currentActor->counter = -1; } } else - if ((currentActor->type == 1) && (currentActor->x_dest != -1) && (currentActor->y_dest != -1)) { - // track animation - currentActor->pathId = computePathfinding(returnVar2, params.X, params.Y, currentActor->x_dest, currentActor->y_dest, currentActor->stepX, currentActor->stepY, currentActor->pathId); + if ((currentActor->type == 1) && (currentActor->x_dest != -1) && (currentActor->y_dest != -1)) { + // track animation + currentActor->pathId = computePathfinding(returnVar2, params.X, params.Y, currentActor->x_dest, currentActor->y_dest, currentActor->stepX, currentActor->stepY, currentActor->pathId); - currentActor->x_dest = -1; - currentActor->y_dest = -1; + currentActor->x_dest = -1; + currentActor->y_dest = -1; - if (currentActor->pathId == -1) { - if ((currentActor->endDirection != -1) && (currentActor->endDirection != currentActor->startDirection)) { - currentActor->phase = ANIM_PHASE_STATIC_END; - currentActor->nextDirection = currentActor->endDirection; - currentActor->endDirection = -1; - currentActor->counter = 0; + if (currentActor->pathId == -1) { + if ((currentActor->endDirection != -1) && (currentActor->endDirection != currentActor->startDirection)) { + currentActor->phase = ANIM_PHASE_STATIC_END; + currentActor->nextDirection = currentActor->endDirection; + currentActor->endDirection = -1; + currentActor->counter = 0; + } else { + currentActor->pathId = -2; + currentActor->flag = 0; + currentActor->endDirection = -1; + currentActor->phase = ANIM_PHASE_WAIT; + } } else { - currentActor->pathId = -2; - currentActor->flag = 0; - currentActor->endDirection = -1; - currentActor->phase = ANIM_PHASE_WAIT; + currentActor->phase = ANIM_PHASE_STATIC; + currentActor->counter = -1; } - } else { - currentActor->phase = ANIM_PHASE_STATIC; - currentActor->counter = -1; } - } animationStart = false; if ((currentActor->pathId >= 0) || (currentActor->phase == ANIM_PHASE_STATIC_END)) { switch (currentActor->phase) { case ANIM_PHASE_STATIC_END: - case ANIM_PHASE_STATIC: - { - if ((currentActor->counter == -1) && (currentActor->phase == ANIM_PHASE_STATIC)) { - affiche_chemin(currentActor->pathId, returnVar2); - - if (returnVar2[0] == -1) { - currentActor->pathId = -2; - currentActor->flag = 0; - currentActor->endDirection = -1; - currentActor->phase = ANIM_PHASE_WAIT; - break; - } - - currentActor->x = returnVar2[0]; - currentActor->y = returnVar2[1]; - currentActor->nextDirection = returnVar2[2]; - currentActor->poly = returnVar2[4]; - currentActor->counter = 0; - - if (currentActor->startDirection == currentActor->nextDirection) - currentActor->phase = ANIM_PHASE_MOVE; + case ANIM_PHASE_STATIC: { + if ((currentActor->counter == -1) && (currentActor->phase == ANIM_PHASE_STATIC)) { + affiche_chemin(currentActor->pathId, returnVar2); + + if (returnVar2[0] == -1) { + currentActor->pathId = -2; + currentActor->flag = 0; + currentActor->endDirection = -1; + currentActor->phase = ANIM_PHASE_WAIT; + break; } - if ((currentActor->counter >= 0) - && ((currentActor->phase == ANIM_PHASE_STATIC_END) - || (currentActor->phase == ANIM_PHASE_STATIC))) { - int newA; - int inc = 1; - int t_inc = currentActor->startDirection - 1; + currentActor->x = returnVar2[0]; + currentActor->y = returnVar2[1]; + currentActor->nextDirection = returnVar2[2]; + currentActor->poly = returnVar2[4]; + currentActor->counter = 0; - if (t_inc < 0) - t_inc = 3; + if (currentActor->startDirection == currentActor->nextDirection) + currentActor->phase = ANIM_PHASE_MOVE; + } - if (currentActor->nextDirection == t_inc) - inc = -1; + if ((currentActor->counter >= 0) + && ((currentActor->phase == ANIM_PHASE_STATIC_END) + || (currentActor->phase == ANIM_PHASE_STATIC))) { + int newA; + int inc = 1; + int t_inc = currentActor->startDirection - 1; - if (inc > 0) - newA = - raoul_stat - [currentActor-> - startDirection] - [currentActor-> - counter++]; - else - newA = - raoul_invstat - [currentActor-> - startDirection] - [currentActor-> - counter++]; + if (t_inc < 0) + t_inc = 3; - if (newA == 0) { - currentActor-> - startDirection - = - currentActor-> - startDirection - + inc; + if (currentActor->nextDirection == t_inc) + inc = -1; - if (currentActor->startDirection > 3) - currentActor-> - startDirection - = - 0; + if (inc > 0) + newA = + raoul_stat + [currentActor-> + startDirection] + [currentActor-> + counter++]; + else + newA = + raoul_invstat + [currentActor-> + startDirection] + [currentActor-> + counter++]; - if (currentActor->startDirection < 0) - currentActor-> - startDirection - = - 3; + if (newA == 0) { + currentActor-> + startDirection + = + currentActor-> + startDirection + + inc; + if (currentActor->startDirection > 3) currentActor-> - counter = + startDirection + = 0; - if (currentActor->startDirection == currentActor->nextDirection) { - if (currentActor->phase == ANIM_PHASE_STATIC) - currentActor-> - phase - = - ANIM_PHASE_MOVE; - else - currentActor-> - phase - = - ANIM_PHASE_END; - } else { - newA = - raoul_stat - [currentActor-> - startDirection] - [currentActor-> - counter++]; - - if (inc - == - -1) - newA = -newA; - - set_anim - (currentActor-> - overlayNumber, - currentActor-> - idx, - currentActor-> - start, - params. - X, - params. - Y, - newA, - currentActor-> - poly); - break; - } + if (currentActor->startDirection < 0) + currentActor-> + startDirection + = + 3; + + currentActor-> + counter = + 0; + + if (currentActor->startDirection == currentActor->nextDirection) { + if (currentActor->phase == ANIM_PHASE_STATIC) + currentActor-> + phase + = + ANIM_PHASE_MOVE; + else + currentActor-> + phase + = + ANIM_PHASE_END; } else { + newA = + raoul_stat + [currentActor-> + startDirection] + [currentActor-> + counter++]; + + if (inc + == + -1) + newA = -newA; + set_anim - (currentActor-> - overlayNumber, - currentActor-> - idx, - currentActor-> - start, - params.X, - params.Y, - newA, - currentActor-> - poly); + (currentActor-> + overlayNumber, + currentActor-> + idx, + currentActor-> + start, + params. + X, + params. + Y, + newA, + currentActor-> + poly); break; } + } else { + set_anim + (currentActor-> + overlayNumber, + currentActor-> + idx, + currentActor-> + start, + params.X, + params.Y, + newA, + currentActor-> + poly); + break; } - break; } - case ANIM_PHASE_MOVE: - { - if (currentActor->counter >= 1) { - affiche_chemin - (currentActor-> - pathId, - returnVar2); - if (returnVar2[0] == - -1) { - if ((currentActor->endDirection == -1) || (currentActor->endDirection == currentActor->nextDirection)) { - currentActor-> - phase - = - ANIM_PHASE_END; - } else { - currentActor-> - phase - = - ANIM_PHASE_STATIC_END; - currentActor-> - nextDirection - = - currentActor-> - endDirection; - } + break; + } + case ANIM_PHASE_MOVE: { + if (currentActor->counter >= 1) { + affiche_chemin + (currentActor-> + pathId, + returnVar2); + if (returnVar2[0] == + -1) { + if ((currentActor->endDirection == -1) || (currentActor->endDirection == currentActor->nextDirection)) { currentActor-> - counter = - 0; - break; + phase + = + ANIM_PHASE_END; } else { currentActor-> - x = - returnVar2 - [0]; - currentActor-> - y = - returnVar2 - [1]; - currentActor-> - nextDirection - = - returnVar2 - [2]; + phase + = + ANIM_PHASE_STATIC_END; currentActor-> - poly = - returnVar2 - [4]; - - /* - * if (pl->next_dir!=pl->start_dir) - * { - * pl->phase=PHASE_STATIC; - * pl->cnt=0; - * break; - * } - */ + nextDirection + = + currentActor-> + endDirection; } + currentActor-> + counter = + 0; + break; + } else { + currentActor-> + x = + returnVar2 + [0]; + currentActor-> + y = + returnVar2 + [1]; + currentActor-> + nextDirection + = + returnVar2 + [2]; + currentActor-> + poly = + returnVar2 + [4]; + + /* + * if (pl->next_dir!=pl->start_dir) + * { + * pl->phase=PHASE_STATIC; + * pl->cnt=0; + * break; + * } + */ } + } - if (currentActor->phase == - ANIM_PHASE_MOVE) { - int newA; - + if (currentActor->phase == + ANIM_PHASE_MOVE) { + int newA; + + currentActor-> + startDirection = + currentActor-> + nextDirection; + + newA = + raoul_move + [currentActor-> + startDirection] + [currentActor-> + counter++]; + if (!newA) { currentActor-> - startDirection = - currentActor-> - nextDirection; - + counter = + 0; newA = raoul_move [currentActor-> - startDirection] + startDirection] [currentActor-> - counter++]; - if (!newA) { - currentActor-> - counter = - 0; - newA = - raoul_move - [currentActor-> - startDirection] - [currentActor-> - counter++]; - } - set_anim(currentActor-> - overlayNumber, - currentActor->idx, - currentActor-> - start, - currentActor->x, - currentActor->y, - newA, - currentActor-> - poly); - break; + counter++]; } - + set_anim(currentActor-> + overlayNumber, + currentActor->idx, + currentActor-> + start, + currentActor->x, + currentActor->y, + newA, + currentActor-> + poly); break; } - case ANIM_PHASE_END: - { - int newA = raoul_end[currentActor->startDirection][0]; - set_anim(currentActor->overlayNumber, currentActor->idx, currentActor->start, currentActor->x, currentActor->y, newA, currentActor->poly); + break; + } + case ANIM_PHASE_END: { + int newA = raoul_end[currentActor->startDirection][0]; - currentActor->pathId = -2; - currentActor->phase = ANIM_PHASE_WAIT; - currentActor->flag = 0; - currentActor->endDirection = -1; - break; - } - default: - { - printf("Unimplemented currentActor->phase=%d in processAnimation()\n", currentActor->phase); - // exit(1); - } + set_anim(currentActor->overlayNumber, currentActor->idx, currentActor->start, currentActor->x, currentActor->y, newA, currentActor->poly); + + currentActor->pathId = -2; + currentActor->phase = ANIM_PHASE_WAIT; + currentActor->flag = 0; + currentActor->endDirection = -1; + break; + } + default: { + printf("Unimplemented currentActor->phase=%d in processAnimation()\n", currentActor->phase); + // exit(1); + } } } } diff --git a/engines/cruise/background.cpp b/engines/cruise/background.cpp index 15b4c91e47..d250ff7f2d 100644 --- a/engines/cruise/background.cpp +++ b/engines/cruise/background.cpp @@ -41,7 +41,7 @@ char *hwMemAddr[] = { short int cvtPalette[0x20]; int loadMEN(uint8 **ptr) { - char *localPtr = (char *)*ptr; + char *localPtr = (char *) * ptr; if (!strcmp(localPtr, "MEN")) { localPtr += 4; @@ -62,7 +62,7 @@ int loadMEN(uint8 **ptr) { int CVTLoaded; int loadCVT(uint8 **ptr) { - char *localPtr = (char *)*ptr; + char *localPtr = (char *) * ptr; if (!strcmp(localPtr, "CVT")) { int i; @@ -128,57 +128,53 @@ int loadBackground(const char *name, int idx) { } if (!strcmp((char*)ptr, "PAL")) { - memcpy(palScreen[idx], ptr+4, 256*3); + memcpy(palScreen[idx], ptr + 4, 256*3); gfxModuleData_setPal256(palScreen[idx]); } else { int mode = ptr2[1]; ptr2 += 2; // read palette - switch(mode) - { + switch (mode) { case 0: - case 4: // color on 3 bit - { - uint16 oldPalette[32]; + case 4: { // color on 3 bit + uint16 oldPalette[32]; - memcpy(oldPalette, ptr2, 0x20); - ptr2 += 0x20; - flipGen(oldPalette, 0x20); + memcpy(oldPalette, ptr2, 0x20); + ptr2 += 0x20; + flipGen(oldPalette, 0x20); - for(unsigned long int i=0; i<32; i++) { - gfxModuleData_convertOldPalColor(oldPalette[i], &palScreen[idx][i*3]); - } + for (unsigned long int i = 0; i < 32; i++) { + gfxModuleData_convertOldPalColor(oldPalette[i], &palScreen[idx][i*3]); + } - // duplicate the palette - for(unsigned long int i=1; i<8; i++) { - memcpy(&palScreen[idx][32*i*3], &palScreen[idx][0], 32*3); - } + // duplicate the palette + for (unsigned long int i = 1; i < 8; i++) { + memcpy(&palScreen[idx][32*i*3], &palScreen[idx][0], 32*3); + } - break; + break; + } + case 5: { // color on 4 bit + for (unsigned long int i = 0; i < 32; i++) { + uint8* inPtr = ptr2 + i * 2; + uint8* outPtr = palScreen[idx] + i * 3; + + outPtr[2] = ((inPtr[1]) & 0x0F) * 17; + outPtr[1] = (((inPtr[1]) & 0xF0) >> 4) * 17; + outPtr[0] = ((inPtr[0]) & 0x0F) * 17; } - case 5: // color on 4 bit - { - for(unsigned long int i=0; i<32; i++) - { - uint8* inPtr = ptr2 + i * 2; - uint8* outPtr = palScreen[idx] +i * 3; - - outPtr[2] = ((inPtr[1])&0x0F) * 17; - outPtr[1] = (((inPtr[1])&0xF0) >> 4) * 17; - outPtr[0] = ((inPtr[0])&0x0F) * 17; - } - ptr2 += 2*32; - - // duplicate the palette - for(unsigned long int i=1; i<8; i++) { - memcpy(&palScreen[idx][32*i*3], &palScreen[idx][0], 32*3); - } - - break; + ptr2 += 2 * 32; + + // duplicate the palette + for (unsigned long int i = 1; i < 8; i++) { + memcpy(&palScreen[idx][32*i*3], &palScreen[idx][0], 32*3); } + + break; + } case 8: memcpy(palScreen[idx], ptr2, 256*3); - ptr2 += 256*3; + ptr2 += 256 * 3; break; default: @@ -190,8 +186,7 @@ int loadBackground(const char *name, int idx) { // read image data gfxModuleData_gfxClearFrameBuffer(backgroundPtrtable[idx]); - switch(mode) - { + switch (mode) { case 0: case 4: convertGfxFromMode4(ptr2, 320, 200, backgroundPtrtable[idx]); @@ -202,7 +197,7 @@ int loadBackground(const char *name, int idx) { break; case 8: memcpy(backgroundPtrtable[idx], ptr2, 320 * 200); - ptr2 += 320*200; + ptr2 += 320 * 200; break; } diff --git a/engines/cruise/backgroundIncrust.cpp b/engines/cruise/backgroundIncrust.cpp index c66fb9eb9b..a141818e9b 100644 --- a/engines/cruise/backgroundIncrust.cpp +++ b/engines/cruise/backgroundIncrust.cpp @@ -43,33 +43,29 @@ void addBackgroundIncrustSub1(int fileIdx, int X, int Y, char *ptr2, int16 scale buildPolyModel(X, Y, scale, ptr2, destBuffer, dataPtr); } -void backupBackground(backgroundIncrustStruct *pIncrust, int X, int Y, int width, int height, uint8* pBackground) -{ +void backupBackground(backgroundIncrustStruct *pIncrust, int X, int Y, int width, int height, uint8* pBackground) { pIncrust->saveWidth = width; pIncrust->saveHeight = height; - pIncrust->saveSize = width*height; + pIncrust->saveSize = width * height; pIncrust->savedX = X; pIncrust->savedY = Y; - pIncrust->ptr = (uint8*)malloc(width*height); - for(int i=0; i<height; i++) - { - for(int j=0; j<width; j++) - { + pIncrust->ptr = (uint8*)malloc(width * height); + for (int i = 0; i < height; i++) { + for (int j = 0; j < width; j++) { pIncrust->ptr[i*width+j] = pBackground[(i+Y)*320+j+X]; } } } -void restoreBackground(backgroundIncrustStruct *pIncrust) -{ - if(pIncrust->type != 1) +void restoreBackground(backgroundIncrustStruct *pIncrust) { + if (pIncrust->type != 1) return; - if(pIncrust->ptr == NULL) + if (pIncrust->ptr == NULL) return; uint8* pBackground = backgroundPtrtable[pIncrust->backgroundIdx]; - if(pBackground == NULL) + if (pBackground == NULL) return; int X = pIncrust->savedX; @@ -77,10 +73,8 @@ void restoreBackground(backgroundIncrustStruct *pIncrust) int width = pIncrust->saveWidth; int height = pIncrust->saveHeight; - for(int i=0; i<height; i++) - { - for(int j=0; j<width; j++) - { + for (int i = 0; i < height; i++) { + for (int j = 0; j < width; j++) { pBackground[(i+Y)*320+j+X] = pIncrust->ptr[i*width+j]; } } @@ -154,7 +148,7 @@ backgroundIncrustStruct *addBackgroundIncrust(int16 overlayIdx, int16 objectIdx, int width = filesDatabase[params.fileIdx].width; int height = filesDatabase[params.fileIdx].height; - if(saveBuffer == 1) { + if (saveBuffer == 1) { backupBackground(newElement, newElement->X, newElement->Y, width, height, backgroundPtr); } @@ -174,10 +168,10 @@ backgroundIncrustStruct *addBackgroundIncrust(int16 overlayIdx, int16 objectIdx, // this function fills the sizeTable for the poly (OLD: mainDrawSub1Sub2) getPolySize(newX, newY, newScale, sizeTable, (unsigned char*)newFrame); - int width = (sizeTable[1]+2) - (sizeTable[0]-2) + 1; - int height = sizeTable[3]-sizeTable[2]+1; + int width = (sizeTable[1] + 2) - (sizeTable[0] - 2) + 1; + int height = sizeTable[3] - sizeTable[2] + 1; - backupBackground(newElement, sizeTable[0]-2, sizeTable[2], width, height, backgroundPtr); + backupBackground(newElement, sizeTable[0] - 2, sizeTable[2], width, height, backgroundPtr); } addBackgroundIncrustSub1(params.fileIdx, newElement->X, newElement->Y, NULL, params.scale, (char *)backgroundPtr, (char *)filesDatabase[params.fileIdx].subData.ptr); @@ -190,7 +184,7 @@ void saveIncrust(Common::OutSaveFile& currentSaveFile) { int count = 0; backgroundIncrustStruct *pl = backgroundIncrustHead.next; - while(pl) { + while (pl) { count++; pl = pl->next; } @@ -198,7 +192,7 @@ void saveIncrust(Common::OutSaveFile& currentSaveFile) { currentSaveFile.writeSint16LE(count); pl = backgroundIncrustHead.next; - while(pl) { + while (pl) { char dummy[4] = {0, 0, 0, 0}; currentSaveFile.write(dummy, 2); currentSaveFile.write(dummy, 2); @@ -214,7 +208,7 @@ void saveIncrust(Common::OutSaveFile& currentSaveFile) { currentSaveFile.writeSint16LE(pl->scriptNumber); currentSaveFile.writeSint16LE(pl->scriptOverlayIdx); currentSaveFile.write(dummy, 4); - currentSaveFile.writeSint16LE(pl->saveWidth/2); + currentSaveFile.writeSint16LE(pl->saveWidth / 2); currentSaveFile.writeSint16LE(pl->saveHeight); currentSaveFile.writeSint16LE(pl->saveSize); currentSaveFile.writeSint16LE(pl->savedX); @@ -261,7 +255,7 @@ void loadBackgroundIncrustFromSave(Common::InSaveFile& currentSaveFile) { pl2->scriptNumber = currentSaveFile.readSint16LE(); pl2->scriptOverlayIdx = currentSaveFile.readSint16LE(); currentSaveFile.skip(4); - pl2->saveWidth = currentSaveFile.readSint16LE()*2; + pl2->saveWidth = currentSaveFile.readSint16LE() * 2; pl2->saveHeight = currentSaveFile.readSint16LE(); pl2->saveSize = currentSaveFile.readUint16LE(); pl2->savedX = currentSaveFile.readSint16LE(); @@ -301,26 +295,23 @@ void regenerateBackgroundIncrust(backgroundIncrustStruct *pHead) { backgroundIncrustStruct* pl = pHead->next; - while(pl) { + while (pl) { backgroundIncrustStruct* pl2 = pl->next; bool bLoad = false; int frame = pl->field_E; //int screen = pl->backgroundIdx; - if((filesDatabase[frame].subData.ptr == NULL) || (strcmp(pl->name, filesDatabase[frame].subData.name))) { + if ((filesDatabase[frame].subData.ptr == NULL) || (strcmp(pl->name, filesDatabase[frame].subData.name))) { frame = 257 - 1; - if(loadFile( pl->name, frame, pl->spriteId ) >= 0) { + if (loadFile(pl->name, frame, pl->spriteId) >= 0) { bLoad = true; - } - else - { + } else { frame = -1; } } - if( frame >= -1 ) - { + if (frame >= -1) { if (filesDatabase[frame].subData.resourceType == 4) { // sprite int width = filesDatabase[frame].width; int height = filesDatabase[frame].height; @@ -411,8 +402,7 @@ void removeBackgroundIncrust(int overlay, int idx, backgroundIncrustStruct * pHe } } -void unmergeBackgroundIncrust(backgroundIncrustStruct * pHead, int ovl, int idx) -{ +void unmergeBackgroundIncrust(backgroundIncrustStruct * pHead, int ovl, int idx) { backgroundIncrustStruct *pl; backgroundIncrustStruct *pl2; @@ -426,12 +416,11 @@ void unmergeBackgroundIncrust(backgroundIncrustStruct * pHead, int ovl, int idx) pl2 = pl; pl = pl2->next; - while(pl) - { + while (pl) { pl2 = pl; - if((pl->overlayIdx == ovl) || (ovl == -1)) - if((pl->objectIdx == idx) || (idx == -1)) - if((pl->X == x) && (pl->Y == y)) + if ((pl->overlayIdx == ovl) || (ovl == -1)) + if ((pl->objectIdx == idx) || (idx == -1)) + if ((pl->X == x) && (pl->Y == y)) restoreBackground(pl); pl = pl2->next; diff --git a/engines/cruise/cell.cpp b/engines/cruise/cell.cpp index 2c990817eb..afeb819945 100644 --- a/engines/cruise/cell.cpp +++ b/engines/cruise/cell.cpp @@ -37,19 +37,19 @@ void resetPtr(cellStruct *ptr) { } void freeMessageList(cellStruct *objPtr) { -/* if (objPtr) { - if (objPtr->next) - free(objPtr->next); + /* if (objPtr) { + if (objPtr->next) + free(objPtr->next); - free(objPtr); - } */ + free(objPtr); + } */ } void saveCell(Common::OutSaveFile& currentSaveFile) { int count = 0; cellStruct *t = cellHead.next; - while(t) { + while (t) { count++; t = t->next; } @@ -57,7 +57,7 @@ void saveCell(Common::OutSaveFile& currentSaveFile) { currentSaveFile.writeSint16LE(count); t = cellHead.next; - while(t) { + while (t) { char dummy[2] = { 0, 0}; currentSaveFile.write(dummy, 2); @@ -176,9 +176,9 @@ cellStruct *addCell(cellStruct *pHead, int16 overlayIdx, int16 objIdx, int16 typ if (currentHead2) { if ((currentHead2->overlay == overlayIdx) && - (currentHead2->backgroundPlane == backgroundPlane) && - (currentHead2->idx == objIdx) && - (currentHead2->type == type)) + (currentHead2->backgroundPlane == backgroundPlane) && + (currentHead2->idx == objIdx) && + (currentHead2->type == type)) return NULL; } @@ -276,15 +276,15 @@ void createTextObject(cellStruct *pObject, int overlayIdx, int messageIdx, int x } } -void removeCell(cellStruct *objPtr, int ovlNumber, int objectIdx, int objType, int backgroundPlane ) { +void removeCell(cellStruct *objPtr, int ovlNumber, int objectIdx, int objType, int backgroundPlane) { cellStruct *currentObj = objPtr->next; cellStruct *previous; while (currentObj) { if (((currentObj->overlay == ovlNumber) || (ovlNumber == -1)) && - ((currentObj->idx == objectIdx) || (objectIdx == -1)) && - ((currentObj->type == objType) || (objType == -1)) && - ((currentObj->backgroundPlane == backgroundPlane) || (backgroundPlane == -1))) { + ((currentObj->idx == objectIdx) || (objectIdx == -1)) && + ((currentObj->type == objType) || (objType == -1)) && + ((currentObj->backgroundPlane == backgroundPlane) || (backgroundPlane == -1))) { currentObj->type = -1; } @@ -339,7 +339,7 @@ void linkCell(cellStruct *pHead, int ovl, int obj, int type, int ovl2, int obj2) } } -void freezeCell(cellStruct * pObject, int overlayIdx, int objIdx, int objType, int backgroundPlane, int oldFreeze, int newFreeze ) { +void freezeCell(cellStruct * pObject, int overlayIdx, int objIdx, int objType, int backgroundPlane, int oldFreeze, int newFreeze) { while (pObject) { if ((pObject->overlay == overlayIdx) || (overlayIdx == -1)) { if ((pObject->idx == objIdx) || (objIdx == -1)) { @@ -358,7 +358,7 @@ void freezeCell(cellStruct * pObject, int overlayIdx, int objIdx, int objType, i } void sortCells(int16 ovlIdx, int16 ovjIdx, cellStruct *objPtr) { - cellStruct *pl,*pl2,*pl3,*pl4,*plz,*pllast; + cellStruct *pl, *pl2, *pl3, *pl4, *plz, *pllast; cellStruct prov; int16 newz, objz, sobjz; @@ -423,9 +423,9 @@ void sortCells(int16 ovlIdx, int16 ovjIdx, cellStruct *objPtr) { plz->next = pl2; pllast->next = pl4; - if(plz != objPtr) + if (plz != objPtr) pl2->prev = plz; - if(!pl4) + if (!pl4) objPtr->prev = pllast; else pl4->prev = pllast; diff --git a/engines/cruise/cell.h b/engines/cruise/cell.h index 594acdf175..e89937b2f1 100644 --- a/engines/cruise/cell.h +++ b/engines/cruise/cell.h @@ -69,8 +69,8 @@ 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 ); -void freezeCell(cellStruct * pObject, int overlayIdx, int objIdx, int objType, int backgroundPlane, int oldFreeze, int newFreeze ); +void removeCell(cellStruct *objPtr, int ovlNumber, int objectIdx, int objType, int backgroundPlane); +void freezeCell(cellStruct * pObject, int overlayIdx, int objIdx, int objType, int backgroundPlane, int oldFreeze, int newFreeze); void sortCells(int16 param1, int16 param2, cellStruct *objPtr); void linkCell(cellStruct *pHead, int ovl, int obj, int type, int ovl2, int obj2); diff --git a/engines/cruise/cruise.cpp b/engines/cruise/cruise.cpp index c664e6e0ad..ad1ede292f 100644 --- a/engines/cruise/cruise.cpp +++ b/engines/cruise/cruise.cpp @@ -51,13 +51,13 @@ CruiseEngine::CruiseEngine(OSystem * syst, const CRUISEGameDescription *gameDesc #endif Common::addSpecialDebugLevel(kCruiseDebugScript, "Script", - "Script debug level"); + "Script debug level"); // Setup mixer _mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, - ConfMan.getInt("sfx_volume")); + ConfMan.getInt("sfx_volume")); _mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, - ConfMan.getInt("music_volume")); + ConfMan.getInt("music_volume")); g_cruise = this; diff --git a/engines/cruise/cruise.h b/engines/cruise/cruise.h index ad5b1100cb..9093101ce0 100644 --- a/engines/cruise/cruise.h +++ b/engines/cruise/cruise.h @@ -41,39 +41,39 @@ enum CruiseGameType { struct CRUISEGameDescription; -class CruiseEngine:public Engine { +class CruiseEngine: public Engine { -protected: - // Engine APIs - virtual Common::Error init(); - virtual Common::Error go(); + protected: + // Engine APIs + virtual Common::Error init(); + virtual Common::Error go(); - void shutdown(); + void shutdown(); - bool initGame(); + bool initGame(); -public: - CruiseEngine(OSystem * syst, const CRUISEGameDescription *gameDesc); - virtual ~ CruiseEngine(); + public: + CruiseEngine(OSystem * syst, const CRUISEGameDescription *gameDesc); + virtual ~ CruiseEngine(); - int getGameType() const; - uint32 getFeatures() const; - Common::Language getLanguage() const; - Common::Platform getPlatform() const; + int getGameType() const; + uint32 getFeatures() const; + Common::Language getLanguage() const; + Common::Platform getPlatform() const; - bool loadSaveDirectory(void); - void makeSystemMenu(void); + bool loadSaveDirectory(void); + void makeSystemMenu(void); - const CRUISEGameDescription *_gameDescription; + const CRUISEGameDescription *_gameDescription; - Common::RandomSource _rnd; + Common::RandomSource _rnd; -private: - void initialize(void); - bool makeLoad(char *saveName); - void mainLoop(int bootScriptIdx); + private: + void initialize(void); + bool makeLoad(char *saveName); + void mainLoop(int bootScriptIdx); - bool _preLoad; + bool _preLoad; }; extern CruiseEngine *g_cruise; diff --git a/engines/cruise/cruise_main.cpp b/engines/cruise/cruise_main.cpp index 44f4f155aa..0057d688b2 100644 --- a/engines/cruise/cruise_main.cpp +++ b/engines/cruise/cruise_main.cpp @@ -167,10 +167,10 @@ void changeScriptParamInList(int param1, int param2, scriptInstanceStruct *pScri pScriptInstance = pScriptInstance->nextScriptPtr; while (pScriptInstance) { if ((pScriptInstance->overlayNumber == param1) || (param1 == -1)) - if ((pScriptInstance->scriptNumber == param2) || (param2 == -1)) + if ((pScriptInstance->scriptNumber == param2) || (param2 == -1)) if ((pScriptInstance->freeze == oldFreeze) || (oldFreeze == -1)) { pScriptInstance->freeze = newValue; - } + } pScriptInstance = pScriptInstance->nextScriptPtr; } @@ -247,12 +247,12 @@ ovlData3Struct *scriptFunc1Sub2(int32 scriptNumber, int32 param) { } void scriptFunc2(int scriptNumber, scriptInstanceStruct * scriptHandle, - int param, int param2) { + int param, int param2) { if (scriptHandle->nextScriptPtr) { if (scriptNumber == scriptHandle->nextScriptPtr->overlayNumber - || scriptNumber != -1) { + || scriptNumber != -1) { if (param2 == scriptHandle->nextScriptPtr->scriptNumber - || param2 != -1) { + || param2 != -1) { scriptHandle->nextScriptPtr->sysKey = param; } } @@ -272,33 +272,19 @@ uint8 *getDataFromData3(ovlData3Struct *ptr, int param) { switch (param) { case 0: - { - return (dataPtr); - } + return (dataPtr); case 1: - { - return (dataPtr + ptr->offsetToSubData3); // strings - } + return (dataPtr + ptr->offsetToSubData3); // strings case 2: - { - return (dataPtr + ptr->offsetToSubData2); - } + return (dataPtr + ptr->offsetToSubData2); case 3: - { - return (dataPtr + ptr->offsetToImportData); // import data - } + return (dataPtr + ptr->offsetToImportData); // import data case 4: - { - return (dataPtr + ptr->offsetToImportName); // import names - } + return (dataPtr + ptr->offsetToImportName); // import names case 5: - { - return (dataPtr + ptr->offsetToSubData5); - } + return (dataPtr + ptr->offsetToSubData5); default: - { - return (NULL); - } + return NULL; } } @@ -601,13 +587,12 @@ int removeFinishedScripts(scriptInstanceStruct *ptrHandle) { return (0); } -bool testMask(int x, int y, unsigned char* pData, int stride) -{ - unsigned char* ptr = y * stride + x/8 + pData; +bool testMask(int x, int y, unsigned char* pData, int stride) { + unsigned char* ptr = y * stride + x / 8 + pData; unsigned char bitToTest = 0x80 >> (x & 7); - if((*ptr) & bitToTest) + if ((*ptr) & bitToTest) return true; return false; } @@ -682,7 +667,7 @@ int findObject(int mouseX, int mouseY, int *outObjOvl, int *outObjIdx) { offset += j; - if (offset >= 0 ) { + if (offset >= 0) { if (filesDatabase[offset].resType == 0 && filesDatabase[offset].subData.ptr) { dataPtr = (int16 *)filesDatabase[offset].subData.ptr; } @@ -712,7 +697,7 @@ int findObject(int mouseX, int mouseY, int *outObjOvl, int *outObjIdx) { int offsetY = mouseY - y; if ((offsetX >= 0) && (offsetX < nWidth) && (offsetY >= 0) && (offsetY <= nHeight) && filesDatabase[j].subData.ptr) { - if(testMask(offsetX, offsetY, filesDatabase[j].subData.ptrMask, filesDatabase[j].width/8)) { + if (testMask(offsetX, offsetY, filesDatabase[j].subData.ptrMask, filesDatabase[j].width / 8)) { *outObjOvl = linkedObjOvl; *outObjIdx = linkedObjIdx; return currentObject->type; @@ -725,7 +710,7 @@ int findObject(int mouseX, int mouseY, int *outObjOvl, int *outObjIdx) { int width = params.fileIdx; int height = params.scale; - if ((mouseX >= x) && (mouseX <= x+width) && (mouseY >= y) && (mouseY <= y+height)) { + if ((mouseX >= x) && (mouseX <= x + width) && (mouseY >= y) && (mouseY <= y + height)) { *outObjOvl = linkedObjOvl; *outObjIdx = linkedObjIdx; @@ -769,9 +754,8 @@ const char *getObjectName(int index, const char *string) { int i = 0; // int j = 0; - while (i < index) - { - ptr += strlen(ptr)+1; + while (i < index) { + ptr += strlen(ptr) + 1; i++; } return ptr; @@ -793,7 +777,7 @@ void buildInventory(int X, int Y) { pMenu = createMenu(X, Y, "Inventaire"); menuTable[1] = pMenu; - if(pMenu == NULL) + if (pMenu == NULL) return; int numObjectInInventory = 0; @@ -801,7 +785,7 @@ void buildInventory(int X, int Y) { ovlDataStruct *pOvlData = overlayTable[i].ovlData; if (overlayTable[i].alreadyLoaded) { - if(overlayTable[i].ovlData->arrayObject) { + if (overlayTable[i].ovlData->arrayObject) { for (int j = 0; j < pOvlData->numObj; j++) { if (getObjectClass(i, j) != 3) { int16 returnVar; @@ -872,7 +856,7 @@ bool createDialog(int objOvl, int objIdx, int x, int y) { if (overlayTable[j].alreadyLoaded) { int idHeader = overlayTable[j].ovlData->numMsgRelHeader; - for (int i=0; i<idHeader; i++) { + for (int i = 0; i < idHeader; i++) { linkDataStruct* ptrHead = &overlayTable[j].ovlData->arrayMsgRelHeader[i]; int thisOvl = ptrHead->obj1Overlay; @@ -884,21 +868,21 @@ bool createDialog(int objOvl, int objIdx, int x, int y) { getSingleObjectParam(thisOvl, ptrHead->obj1Number, 5, &objectState2); - if (pObject && (pObject->_class == THEME) && (objectState2 <-1)) { + if (pObject && (pObject->_class == THEME) && (objectState2 < -1)) { thisOvl = ptrHead->obj2Overlay; if (!thisOvl) { thisOvl = j; } - if((thisOvl==objOvl) && (ptrHead->obj2Number==objIdx)) { + if ((thisOvl == objOvl) && (ptrHead->obj2Number == objIdx)) { int verbeOvl = ptrHead->verbOverlay; int obj1Ovl = ptrHead->obj1Overlay; int obj2Ovl = ptrHead->obj2Overlay; - if (!verbeOvl) verbeOvl=j; - if (!obj1Ovl) obj1Ovl=j; - if (!obj2Ovl) obj2Ovl=j; + if (!verbeOvl) verbeOvl = j; + if (!obj1Ovl) obj1Ovl = j; + if (!obj2Ovl) obj2Ovl = j; char verbe_name[80]; char obj1_name[80]; @@ -907,12 +891,12 @@ bool createDialog(int objOvl, int objIdx, int x, int y) { 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; + 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; @@ -934,9 +918,9 @@ bool createDialog(int objOvl, int objIdx, int x, int y) { testState2 = ptrHead->obj2OldState; } - if ((ovl4) && (ptrHead->verbNumber>=0) && - ((testState1 == -1) || (testState1 == objectState2)) && - ((testState2 == -1) || (testState2 == objectState)) ) { + if ((ovl4) && (ptrHead->verbNumber >= 0) && + ((testState1 == -1) || (testState1 == objectState2)) && + ((testState2 == -1) || (testState2 == objectState))) { if (ovl2->nameVerbGlob) { const char *ptr = getObjectName(ptrHead->verbNumber, ovl2->nameVerbGlob); strcpy(verbe_name, ptr); @@ -947,7 +931,7 @@ bool createDialog(int objOvl, int objIdx, int x, int y) { found = true; int color; - if(objectState2==-2) + if (objectState2 == -2) color = subColor; else color = -1; @@ -979,7 +963,7 @@ bool findRelation(int objOvl, int objIdx, int x, int y) { if (overlayTable[j].alreadyLoaded) { int idHeader = overlayTable[j].ovlData->numMsgRelHeader; - for (int i=0; i<idHeader; i++) { + for (int i = 0; i < idHeader; i++) { linkDataStruct* ptrHead = &overlayTable[j].ovlData->arrayMsgRelHeader[i]; int thisOvl = ptrHead->obj1Overlay; @@ -996,9 +980,9 @@ bool findRelation(int objOvl, int objIdx, int x, int y) { int obj1Ovl = ptrHead->obj1Overlay; int obj2Ovl = ptrHead->obj2Overlay; - if (!verbeOvl) verbeOvl=j; - if (!obj1Ovl) obj1Ovl=j; - if (!obj2Ovl) obj2Ovl=j; + if (!verbeOvl) verbeOvl = j; + if (!obj1Ovl) obj1Ovl = j; + if (!obj2Ovl) obj2Ovl = j; char verbe_name[80]; char obj1_name[80]; @@ -1007,12 +991,12 @@ bool findRelation(int objOvl, int objIdx, int x, int y) { 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; + 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; @@ -1037,24 +1021,19 @@ bool findRelation(int objOvl, int objIdx, int x, int y) { first = false; } } - if ((ovl2) && (ptrHead->verbNumber>=0)) { + if ((ovl2) && (ptrHead->verbNumber >= 0)) { if (ovl2->nameVerbGlob) { const char *ptr = getObjectName(ptrHead->verbNumber, ovl2->nameVerbGlob); strcpy(verbe_name, ptr); - if ( (!first) && ((testState==-1) || (testState==objectState))) { - if (!strlen(verbe_name)) - { - if(currentScriptPtr) - { + if ((!first) && ((testState == -1) || (testState == objectState))) { + if (!strlen(verbe_name)) { + if (currentScriptPtr) { attacheNewScriptToTail(&relHead, j, ptrHead->id, 30, currentScriptPtr->scriptNumber, currentScriptPtr->overlayNumber, scriptType_REL); - } - else - { + } else { attacheNewScriptToTail(&relHead, j, ptrHead->id, 30, 0, 0, scriptType_REL); } - } - else if (ovl2->nameVerbGlob) { + } else if (ovl2->nameVerbGlob) { found = true; ptr = getObjectName(ptrHead->verbNumber, ovl2->nameVerbGlob); addSelectableMenuEntry(j, i, menuTable[0], 1, -1, ptr); @@ -1123,12 +1102,9 @@ void callSubRelation(menuElementSubStruct *pMenuElement, int nOvl, int nObj) { if ((pHeader->obj2OldState == -1) || (params.state == pHeader->obj2OldState)) { if (pHeader->type == 30) { // REL - if(currentScriptPtr) - { + if (currentScriptPtr) { attacheNewScriptToTail(&relHead, ovlIdx, pHeader->id, 30, currentScriptPtr->scriptNumber, currentScriptPtr->overlayNumber, scriptType_REL); - } - else - { + } else { attacheNewScriptToTail(&relHead, ovlIdx, pHeader->id, 30, 0, 0, scriptType_REL); } @@ -1177,10 +1153,10 @@ int findHighColor() { int bestColorResult = -1; int bestColorIdx = -1; - for(unsigned long int i=0; i<256; i++) { + for (unsigned long int i = 0; i < 256; i++) { int colorResult = (workpal[i*3+0] + workpal[i*3+1] + workpal[i*3+2]) / 256; - if(colorResult > bestColorResult) { + if (colorResult > bestColorResult) { bestColorIdx = i; bestColorResult = colorResult; } @@ -1203,12 +1179,9 @@ void callRelation(menuElementSubStruct *pMenuElement, int nObj2) { if (pHeader->obj2Number == nObj2) { // REL if (pHeader->type == 30) { - if(currentScriptPtr) - { + if (currentScriptPtr) { attacheNewScriptToTail(&relHead, ovlIdx, pHeader->id, 30, currentScriptPtr->scriptNumber, currentScriptPtr->overlayNumber, scriptType_REL); - } - else - { + } else { attacheNewScriptToTail(&relHead, ovlIdx, pHeader->id, 30, 0, 0, scriptType_REL); } @@ -1256,7 +1229,7 @@ void callRelation(menuElementSubStruct *pMenuElement, int nObj2) { getMultipleObjectParam(obj1Ovl, pHeader->obj1Number, ¶ms); if (narratorOvl > 0) { - if ((pHeader->trackX !=-1) && (pHeader->trackY != -1) && (pHeader->trackX != 9999) && (pHeader->trackY != 9999)) { + if ((pHeader->trackX != -1) && (pHeader->trackY != -1) && (pHeader->trackX != 9999) && (pHeader->trackY != 9999)) { x = pHeader->trackX - 100; y = pHeader->trackY - 150; } else { @@ -1274,12 +1247,9 @@ void callRelation(menuElementSubStruct *pMenuElement, int nObj2) { } } - if(currentScriptPtr) - { + if (currentScriptPtr) { createTextObject(&cellHead, ovlIdx, pHeader->id, x, y, 200, findHighColor(), masterScreen, currentScriptPtr->overlayNumber, currentScriptPtr->scriptNumber); - } - else - { + } else { createTextObject(&cellHead, ovlIdx, pHeader->id, x, y, 200, findHighColor(), masterScreen, 0, 0); } @@ -1329,12 +1299,12 @@ void callRelation(menuElementSubStruct *pMenuElement, int nObj2) { } void closeAllMenu(void) { - if(menuTable[0]) { + if (menuTable[0]) { freeMenu(menuTable[0]); menuTable[0] = NULL; } - if(menuTable[1]) { + if (menuTable[1]) { freeMenu(menuTable[1]); menuTable[1] = NULL; } @@ -1394,7 +1364,7 @@ int processInput(void) { if (dialogueEnabled) { - if( menuDown || selectDown || linkedRelation ) { + if (menuDown || selectDown || linkedRelation) { closeAllMenu(); menuDown = 0; selectDown = 0; @@ -1402,26 +1372,23 @@ int processInput(void) { changeCursor(CURSOR_NORMAL); } - if((menuTable[0]==NULL) && (!buttonDown)) { + if ((menuTable[0] == NULL) && (!buttonDown)) { int dialogFound = createDialog(dialogueOvl, dialogueObj, xdial, 0); - if(menuTable[0]) { - if(dialogFound) { + if (menuTable[0]) { + if (dialogFound) { currentActiveMenu = 0; - } - else { + } else { freeMenu(menuTable[0]); menuTable[0] = NULL; currentActiveMenu = -1; } - } - else { + } else { menuDown = 0; } - } - else { - if((button & 1) && (buttonDown == 0)) { - if(menuTable[0]) { + } else { + if ((button & 1) && (buttonDown == 0)) { + if (menuTable[0]) { callRelation(getSelectedEntryInMenu(menuTable[0]), dialogueObj); freeMenu(menuTable[0]); @@ -1429,7 +1396,7 @@ int processInput(void) { if (linkedMsgList) { ASSERT(0); - // freeMsgList(linkedMsgList); + // freeMsgList(linkedMsgList); } linkedMsgList = NULL; @@ -1471,10 +1438,10 @@ int processInput(void) { linkedRelation = NULL; changeCursor(CURSOR_NORMAL); } else { // call sub relation when clicking in inventory - if(menuTable[0] && menuTable[1]) { + if (menuTable[0] && menuTable[1]) { menuElementSubStruct * p0 = getSelectedEntryInMenu(menuTable[1]); - if(p0) + if (p0) callSubRelation(linkedRelation, p0->ovlIdx, p0->header); closeAllMenu(); @@ -1516,7 +1483,7 @@ int processInput(void) { animationStart = true; buttonDown = 0; } - }else { + } else { // No object found, we move the character to the cursor aniX = mouseX; aniY = mouseY; @@ -1601,41 +1568,41 @@ void manageEvents() { Common::EventManager * eventMan = g_system->getEventManager(); while (eventMan->pollEvent(event)) { switch (event.type) { - case Common::EVENT_LBUTTONDOWN: - currentMouseButton |= 1; - break; - case Common::EVENT_LBUTTONUP: - currentMouseButton &= ~1; - break; - case Common::EVENT_RBUTTONDOWN: - currentMouseButton |= 2; - break; - case Common::EVENT_RBUTTONUP: - currentMouseButton &= ~2; - break; - case Common::EVENT_MOUSEMOVE: - currentMouseX = event.mouse.x; - currentMouseY = event.mouse.y; - break; + case Common::EVENT_LBUTTONDOWN: + currentMouseButton |= 1; + break; + case Common::EVENT_LBUTTONUP: + currentMouseButton &= ~1; + break; + case Common::EVENT_RBUTTONDOWN: + currentMouseButton |= 2; + break; + case Common::EVENT_RBUTTONUP: + currentMouseButton &= ~2; + break; + case Common::EVENT_MOUSEMOVE: + currentMouseX = event.mouse.x; + currentMouseY = event.mouse.y; + break; case Common::EVENT_QUIT: g_system->quit(); break; case Common::EVENT_KEYUP: switch (event.kbd.keycode) { - case 27: // ESC - currentMouseButton &= ~4; - break; - default: - break; + case 27: // ESC + currentMouseButton &= ~4; + break; + default: + break; } break; - case Common::EVENT_KEYDOWN: + case Common::EVENT_KEYDOWN: switch (event.kbd.keycode) { - case 27: // ESC - currentMouseButton |= 4; - break; - default: - break; + case 27: // ESC + currentMouseButton |= 4; + break; + default: + break; } /* @@ -1792,18 +1759,19 @@ void mainLoop(void) { if (cmdLine[0]) { ASSERT(0); -/* redrawStrings(0,&cmdLine,8); + /* redrawStrings(0,&cmdLine,8); - waitForPlayerInput(); + waitForPlayerInput(); - cmdLine = 0; */ + cmdLine = 0; */ } if (displayOn) { if (doFade) PCFadeFlag = 0; - /*if (!PCFadeFlag)*/ { + /*if (!PCFadeFlag)*/ + { mainDraw(0); flipScreen(); } @@ -1851,7 +1819,7 @@ void mainLoop(void) { do { getMouseStatus(&main10, &mouseX, &mouseButton, &mouseY); - }while(mouseButton); + } while (mouseButton); while (!mouseButton) { manageScripts(&relHead); @@ -1895,7 +1863,7 @@ void mainLoop(void) { userEnabled = false; } } else if (autoMsg != -1) { - removeCell(&cellHead, autoOvl, autoMsg, 5, masterScreen ); + removeCell(&cellHead, autoOvl, autoMsg, 5, masterScreen); autoMsg = -1; } } diff --git a/engines/cruise/ctp.cpp b/engines/cruise/ctp.cpp index 3c81c4d561..80bd4ffe16 100644 --- a/engines/cruise/ctp.cpp +++ b/engines/cruise/ctp.cpp @@ -58,11 +58,11 @@ int computeDistance(int varX, int varY, int paramX, int paramY) { // this function process path finding coordinates void computeAllDistance(int16 table[][10], short int coordCount) { - for(int i=0; i<coordCount; i++) { + for (int i = 0; i < coordCount; i++) { int x1 = ctp_routeCoords[i][0]; int y1 = ctp_routeCoords[i][1]; - for(int j=0; j<ctp_routes[i][0]; j++) { + for (int j = 0; j < ctp_routes[i][0]; j++) { int p = ctp_routes[i][j+1]; int x2 = ctp_routeCoords[p][0]; @@ -79,7 +79,7 @@ void getWalkBoxCenter(int n, int16 table[][40]) { int maxX = -1; int maxY = -1; - for(int i=0; i< table[n][0]; i++) { + for (int i = 0; i < table[n][0]; i++) { int x = table[n][i*2+1]; int y = table[n][i*2+2]; @@ -101,7 +101,7 @@ void getWalkBoxCenter(int n, int16 table[][40]) { } // ax dx bx -void renderCTPWalkBox(int16 *walkboxData, int hotPointX, int hotPointY, int X, int Y, int scale ) { +void renderCTPWalkBox(int16 *walkboxData, int hotPointX, int hotPointY, int X, int Y, int scale) { int numPoints; int i; int16 *destination; @@ -117,8 +117,8 @@ void renderCTPWalkBox(int16 *walkboxData, int hotPointX, int hotPointY, int X, i int pointX = *(walkboxData++); int pointY = *(walkboxData++); - int scaledX =((upscaleValue(pointX, scale) + 0x8000) >> 16) + startX; - int scaledY =((upscaleValue(pointY, scale) + 0x8000) >> 16) + startX; + int scaledX = ((upscaleValue(pointX, scale) + 0x8000) >> 16) + startX; + int scaledY = ((upscaleValue(pointY, scale) + 0x8000) >> 16) + startX; *(destination++) = scaledX; *(destination++) = scaledY; @@ -139,7 +139,7 @@ void makeCtStruct(uint8* str, int16 table[][40], int num, int z) { int minX = 1000; int maxX = -1; - if(table[num][0] < 1) + if (table[num][0] < 1) return; getWalkBoxCenter(num, table); @@ -147,7 +147,7 @@ void makeCtStruct(uint8* str, int16 table[][40], int num, int z) { currentWalkBoxCenterXBis = currentWalkBoxCenterX; currentWalkBoxCenterYBis = currentWalkBoxCenterY; - renderCTPWalkBox(&table[num][0], currentWalkBoxCenterX, currentWalkBoxCenterY, currentWalkBoxCenterX, currentWalkBoxCenterY, z + 0x200 ); + renderCTPWalkBox(&table[num][0], currentWalkBoxCenterX, currentWalkBoxCenterY, currentWalkBoxCenterX, currentWalkBoxCenterY, z + 0x200); int16* a1; int16* a2; @@ -158,16 +158,16 @@ void makeCtStruct(uint8* str, int16 table[][40], int num, int z) { int16* XArray = XMIN_XMAX; int minY = *XArray++; - int i=0; + int i = 0; - while( *XArray >= 0 ) { + while (*XArray >= 0) { int x1 = *XArray++; int x2 = *XArray++; - if(x1<minX) + if (x1 < minX) minX = x1; - if(x2>maxX) + if (x2 > maxX) maxX = x2; *a2++ = x1; @@ -178,18 +178,18 @@ void makeCtStruct(uint8* str, int16 table[][40], int num, int z) { adrStructPoly = (uint8*)a2; - *(uint16**)a2 = (uint16*)-1; //chained list terminator + *(uint16**)a2 = (uint16*) - 1; //chained list terminator - a1+=sizeof(int16*); - *a1++=num; - *a1++=walkboxColor[num]; - *a1++=minX; - *a1++=maxX; - *a1++=minY; - *a1++=minY+i+2; + a1 += sizeof(int16*); + *a1++ = num; + *a1++ = walkboxColor[num]; + *a1++ = minX; + *a1++ = maxX; + *a1++ = minY; + *a1++ = minY + i + 2; } -int getNode(int nodeResult[2], int nodeId){ +int getNode(int nodeResult[2], int nodeId) { if (nodeId < 0 || nodeId >= ctp_routeCoordCount) return -1; @@ -205,10 +205,10 @@ int setNodeColor(int nodeIdx, int nodeColor) { int oldColor = walkboxColor[nodeIdx]; - if(nodeColor == -1) + if (nodeColor == -1) return - walkboxColor[nodeIdx] = nodeColor; + walkboxColor[nodeIdx] = nodeColor; return oldColor; } @@ -219,10 +219,10 @@ int setNodeState(int nodeIdx, int nodeState) { int oldState = walkboxState[nodeIdx]; - if(nodeState == -1) + if (nodeState == -1) return - walkboxState[nodeIdx] = nodeState; + walkboxState[nodeIdx] = nodeState; return oldState; } @@ -232,7 +232,7 @@ int initCt(const char *ctpName) { char fileType[5]; // string2 short int segementSizeTable[7]; // tempTable - if ( !loadCtFromSave) { + if (!loadCtFromSave) { for (int i = 0; i < 10; i++) { persoTable[i] = NULL; } @@ -257,14 +257,14 @@ int initCt(const char *ctpName) { ctp_routeCoordCount = readB16(dataPointer); // get the number of nods dataPointer += 2; - for(int i=0; i<7; i++) { + for (int i = 0; i < 7; i++) { segementSizeTable[i] = readB16(dataPointer); dataPointer += 2; } // get the path-finding coordinates - ASSERT((segementSizeTable[0]%4) == 0); - for(int i=0; i<segementSizeTable[0]/4; i++) { + ASSERT((segementSizeTable[0] % 4) == 0); + for (int i = 0; i < segementSizeTable[0] / 4; i++) { ctp_routeCoords[i][0] = readB16(dataPointer); dataPointer += 2; ctp_routeCoords[i][1] = readB16(dataPointer); @@ -272,18 +272,18 @@ int initCt(const char *ctpName) { } // get the path-finding line informations (indexing the routeCoords array) - ASSERT((segementSizeTable[1]%20) == 0); - for(int i=0; i<segementSizeTable[1]/20; i++) { - for(int j=0; j<10; j++) { + ASSERT((segementSizeTable[1] % 20) == 0); + for (int i = 0; i < segementSizeTable[1] / 20; i++) { + for (int j = 0; j < 10; j++) { ctp_routes[i][j] = readB16(dataPointer); dataPointer += 2; } } // read polygons - ASSERT((segementSizeTable[2]%80) == 0); - for(int i=0; i<segementSizeTable[2]/80; i++) { - for(int j=0; j<40; j++) { + ASSERT((segementSizeTable[2] % 80) == 0); + for (int i = 0; i < segementSizeTable[2] / 80; i++) { + for (int j = 0; j < 40; j++) { ctp_walkboxTable[i][j] = readB16(dataPointer); dataPointer += 2; } @@ -297,14 +297,14 @@ int initCt(const char *ctpName) { // get the walkbox type // Type: 0x00 - non walkable, 0x01 - walkable, 0x02 - exit zone ASSERT((segementSizeTable[3] % 2) == 0); - for(int i=0; i<segementSizeTable[3]/2; i++) { + for (int i = 0; i < segementSizeTable[3] / 2; i++) { walkboxColor[i] = readB16(dataPointer); dataPointer += 2; } // change indicator, walkbox type can change, i.e. blocked by object (values are either 0x00 or 0x01) ASSERT((segementSizeTable[4] % 2) == 0); - for(int i=0; i<segementSizeTable[4]/2; i++) { + for (int i = 0; i < segementSizeTable[4] / 2; i++) { walkboxState[i] = readB16(dataPointer); dataPointer += 2; } @@ -312,14 +312,14 @@ int initCt(const char *ctpName) { // ASSERT((segementSizeTable[5] % 2) == 0); - for(int i=0; i<segementSizeTable[5]/2; i++) { + for (int i = 0; i < segementSizeTable[5] / 2; i++) { walkboxColorIndex[i] = readB16(dataPointer); dataPointer += 2; } // ASSERT((segementSizeTable[6] % 2) == 0); - for(int i=0; i<segementSizeTable[6]/2; i++) { + for (int i = 0; i < segementSizeTable[6] / 2; i++) { walkboxZoom[i] = readB16(dataPointer); dataPointer += 2; } @@ -335,26 +335,26 @@ int initCt(const char *ctpName) { ptr = (uint8 *) polyStruct; - for(int i= numberOfWalkboxes-1; i >=0; i--) { - makeCtStruct(adrStructPoly, ctp_walkboxTable, i, 0 ); + for (int i = numberOfWalkboxes - 1; i >= 0; i--) { + makeCtStruct(adrStructPoly, ctp_walkboxTable, i, 0); } polyStructExp = adrStructPoly += sizeof(int16 *); - for(int i= numberOfWalkboxes-1; i >=0; i--) { - makeCtStruct(adrStructPoly, ctp_walkboxTable, i, walkboxZoom[i] * 20 ); + for (int i = numberOfWalkboxes - 1; i >= 0; i--) { + makeCtStruct(adrStructPoly, ctp_walkboxTable, i, walkboxZoom[i] * 20); } int ctSize = (adrStructPoly - ptr) + sizeof(int16 *); // for now, the +sizeof(int16 *) is a safe zone adrStructPoly = polyStructNorm = polyStruct = (uint8 *) malloc(ctSize); - for(int i= numberOfWalkboxes-1; i >=0; i--) { + for (int i = numberOfWalkboxes - 1; i >= 0; i--) { makeCtStruct(adrStructPoly, ctp_walkboxTable, i, 0); } polyStructExp = adrStructPoly += sizeof(int16 *); - for(int i= numberOfWalkboxes-1; i >=0; i--) { + for (int i = numberOfWalkboxes - 1; i >= 0; i--) { makeCtStruct(adrStructPoly, ctp_walkboxTable, i, walkboxZoom[i] * 20); } diff --git a/engines/cruise/dataLoader.cpp b/engines/cruise/dataLoader.cpp index c274291142..364b1dfee8 100644 --- a/engines/cruise/dataLoader.cpp +++ b/engines/cruise/dataLoader.cpp @@ -115,14 +115,14 @@ void decodeGfxFormat5(dataFileEntry *pCurrentFileEntry) { uint8 *buffer = (uint8 *) malloc(spriteSize); - for(int line = 0; line < pCurrentFileEntry->height; line++) { + for (int line = 0; line < pCurrentFileEntry->height; line++) { uint8 p0; uint8 p1; uint8 p2; uint8 p3; uint8 p4; - for(int x = 0; x < pCurrentFileEntry->widthInColumn; x++) { + for (int x = 0; x < pCurrentFileEntry->widthInColumn; x++) { int bit = 7 - (x % 8); int col = x / 8; @@ -236,14 +236,13 @@ fileTypeEnum getFileType(const char *name) { } int getNumMaxEntiresInSet(uint8 *ptr) { - uint16 numEntries = *(uint16 *) (ptr + 4); + uint16 numEntries = *(uint16 *)(ptr + 4); flipShort(&numEntries); return numEntries; } -int loadFile(const char* name, int idx, int destIdx) -{ +int loadFile(const char* name, int idx, int destIdx) { uint8 *ptr = NULL; fileTypeEnum fileType; @@ -252,31 +251,27 @@ int loadFile(const char* name, int idx, int destIdx) loadFileSub1(&ptr, name, NULL); switch (fileType) { - case type_SET: - { + case type_SET: { - int numMaxEntriesInSet = getNumMaxEntiresInSet(ptr); + int numMaxEntriesInSet = getNumMaxEntiresInSet(ptr); - if (idx > numMaxEntriesInSet) { - return 0; // exit if limit is reached - } - return loadSetEntry(name, ptr, idx, destIdx ); - - break; - } - case type_FNT: - { - return loadFNTSub(ptr, idx); - break; - } - case type_UNK: - { - break; - } - case type_SPL: - { - break; + if (idx > numMaxEntriesInSet) { + return 0; // exit if limit is reached } + return loadSetEntry(name, ptr, idx, destIdx); + + break; + } + case type_FNT: { + return loadFNTSub(ptr, idx); + break; + } + case type_UNK: { + break; + } + case type_SPL: { + break; + } } return -1; } @@ -290,33 +285,29 @@ int loadFileRange(const char *name, int startIdx, int currentEntryIdx, int numId loadFileSub1(&ptr, name, NULL); switch (fileType) { - case type_SET: - { - int i; - int numMaxEntriesInSet = getNumMaxEntiresInSet(ptr); - - for (i = 0; i < numIdx; i++) { - if ((startIdx + i) > numMaxEntriesInSet) { - return 0; // exit if limit is reached - } - loadSetEntry(name, ptr, startIdx + i, currentEntryIdx + i ); - } + case type_SET: { + int i; + int numMaxEntriesInSet = getNumMaxEntiresInSet(ptr); - break; - } - case type_FNT: - { - loadFNTSub(ptr, startIdx); - break; - } - case type_UNK: - { - break; - } - case type_SPL: - { - break; + for (i = 0; i < numIdx; i++) { + if ((startIdx + i) > numMaxEntriesInSet) { + return 0; // exit if limit is reached + } + loadSetEntry(name, ptr, startIdx + i, currentEntryIdx + i); } + + break; + } + case type_FNT: { + loadFNTSub(ptr, startIdx); + break; + } + case type_UNK: { + break; + } + case type_SPL: { + break; + } } return 0; } @@ -329,36 +320,32 @@ int loadFullBundle(const char *name, int startIdx) { loadFileSub1(&ptr, name, NULL); - if(ptr == NULL) + if (ptr == NULL) return 0; switch (fileType) { - case type_SET: - { - int i; - int numMaxEntriesInSet; + case type_SET: { + int i; + int numMaxEntriesInSet; - numMaxEntriesInSet = getNumMaxEntiresInSet(ptr); // get maximum number of sprites/animations in SET file - - for (i = 0; i < numMaxEntriesInSet; i++) { - loadSetEntry(name, ptr, i, startIdx + i); - } + numMaxEntriesInSet = getNumMaxEntiresInSet(ptr); // get maximum number of sprites/animations in SET file - break; - } - case type_FNT: - { - loadFNTSub(ptr, startIdx); - break; - } - case type_UNK: - { - break; - } - case type_SPL: - { - break; + for (i = 0; i < numMaxEntriesInSet; i++) { + loadSetEntry(name, ptr, i, startIdx + i); } + + break; + } + case type_FNT: { + loadFNTSub(ptr, startIdx); + break; + } + case type_UNK: { + break; + } + case type_SPL: { + break; + } } return 0; @@ -395,12 +382,12 @@ int loadFNTSub(uint8 *ptr, int destIdx) { destPtr = filesDatabase[fileIndex].subData.ptr; flipLong((int32 *) destPtr); - flipLong((int32 *) (destPtr + 4)); + flipLong((int32 *)(destPtr + 4)); flipGen(destPtr + 8, 6); currentPtr = destPtr + 14; - for (i = 0; i < *(int16 *) (destPtr + 8); i++) { + for (i = 0; i < *(int16 *)(destPtr + 8); i++) { flipLong((int32 *) currentPtr); currentPtr += 4; @@ -466,84 +453,72 @@ int loadSetEntry(const char *name, uint8 *ptr, int currentEntryIdx, int currentD ptr5 += resourceSize; switch (localBuffer.type) { - case 0: // polygon - { - filesDatabase[fileIndex].subData.resourceType = 8; - filesDatabase[fileIndex].subData.index = currentEntryIdx; - break; - } - case 1: - { - filesDatabase[fileIndex].width = filesDatabase[fileIndex].widthInColumn * 8; - filesDatabase[fileIndex].subData.resourceType = 2; - decodeGfxFormat1(&filesDatabase[fileIndex]); - filesDatabase[fileIndex].subData.index = currentEntryIdx; - filesDatabase[fileIndex].subData.transparency = 0; - break; - } - case 4: - { - filesDatabase[fileIndex].width = filesDatabase[fileIndex].widthInColumn * 2; - filesDatabase[fileIndex].subData.resourceType = 4; - decodeGfxFormat4(&filesDatabase[fileIndex]); - filesDatabase[fileIndex].subData.index = currentEntryIdx; - filesDatabase[fileIndex].subData.transparency = localBuffer.transparency % 0x10; - break; - } - case 5: - { - filesDatabase[fileIndex].subData.resourceType = 4; - decodeGfxFormat5(&filesDatabase[fileIndex]); - filesDatabase[fileIndex].width = filesDatabase[fileIndex].widthInColumn; - filesDatabase[fileIndex].subData.index = currentEntryIdx; - filesDatabase[fileIndex].subData.transparency = localBuffer.transparency; - break; - } - case 8: - { - filesDatabase[fileIndex].subData.resourceType = 4; - filesDatabase[fileIndex].width = filesDatabase[fileIndex].widthInColumn; - filesDatabase[fileIndex].subData.index = currentEntryIdx; - filesDatabase[fileIndex].subData.transparency = localBuffer.transparency; - break; - } - default: - { - printf("Unsuported gfx loading type: %d\n", localBuffer.type); - break; - } + case 0: { // polygon + filesDatabase[fileIndex].subData.resourceType = 8; + filesDatabase[fileIndex].subData.index = currentEntryIdx; + break; + } + case 1: { + filesDatabase[fileIndex].width = filesDatabase[fileIndex].widthInColumn * 8; + filesDatabase[fileIndex].subData.resourceType = 2; + decodeGfxFormat1(&filesDatabase[fileIndex]); + filesDatabase[fileIndex].subData.index = currentEntryIdx; + filesDatabase[fileIndex].subData.transparency = 0; + break; + } + case 4: { + filesDatabase[fileIndex].width = filesDatabase[fileIndex].widthInColumn * 2; + filesDatabase[fileIndex].subData.resourceType = 4; + decodeGfxFormat4(&filesDatabase[fileIndex]); + filesDatabase[fileIndex].subData.index = currentEntryIdx; + filesDatabase[fileIndex].subData.transparency = localBuffer.transparency % 0x10; + break; + } + case 5: { + filesDatabase[fileIndex].subData.resourceType = 4; + decodeGfxFormat5(&filesDatabase[fileIndex]); + filesDatabase[fileIndex].width = filesDatabase[fileIndex].widthInColumn; + filesDatabase[fileIndex].subData.index = currentEntryIdx; + filesDatabase[fileIndex].subData.transparency = localBuffer.transparency; + break; + } + case 8: { + filesDatabase[fileIndex].subData.resourceType = 4; + filesDatabase[fileIndex].width = filesDatabase[fileIndex].widthInColumn; + filesDatabase[fileIndex].subData.index = currentEntryIdx; + filesDatabase[fileIndex].subData.transparency = localBuffer.transparency; + break; + } + default: { + printf("Unsuported gfx loading type: %d\n", localBuffer.type); + break; + } } strcpy(filesDatabase[fileIndex].subData.name, name); // create the mask - switch(localBuffer.type) - { + switch (localBuffer.type) { case 1: case 4: case 5: - case 8: - { - int maskX; - int maskY; - - memset(filesDatabase[fileIndex].subData.ptrMask, 0, filesDatabase[fileIndex].width/8 * filesDatabase[fileIndex].height); - - for(maskY=0; maskY<filesDatabase[fileIndex].height; maskY++) - { - for(maskX=0; maskX<filesDatabase[fileIndex].width; maskX++) - { - if(*(filesDatabase[fileIndex].subData.ptr + filesDatabase[fileIndex].width * maskY + maskX) != filesDatabase[fileIndex].subData.transparency) - { - *(filesDatabase[fileIndex].subData.ptrMask + filesDatabase[fileIndex].width/8 * maskY + maskX / 8) |= 0x80 >> (maskX&7); - } + case 8: { + int maskX; + int maskY; + + memset(filesDatabase[fileIndex].subData.ptrMask, 0, filesDatabase[fileIndex].width / 8 * filesDatabase[fileIndex].height); + + for (maskY = 0; maskY < filesDatabase[fileIndex].height; maskY++) { + for (maskX = 0; maskX < filesDatabase[fileIndex].width; maskX++) { + if (*(filesDatabase[fileIndex].subData.ptr + filesDatabase[fileIndex].width * maskY + maskX) != filesDatabase[fileIndex].subData.transparency) { + *(filesDatabase[fileIndex].subData.ptrMask + filesDatabase[fileIndex].width / 8 * maskY + maskX / 8) |= 0x80 >> (maskX & 7); } } - break; - } - default: - { } + break; + } + default: { + } } } diff --git a/engines/cruise/decompiler.cpp b/engines/cruise/decompiler.cpp index 7eca816ec7..505ca0e4d6 100644 --- a/engines/cruise/decompiler.cpp +++ b/engines/cruise/decompiler.cpp @@ -84,24 +84,21 @@ char decompSaveOpcodeVar[256]; uint8 *getStringNameFromIdx(uint16 stringTypeIdx, char *offset) { switch (stringTypeIdx & 7) { - case 2: - { - sprintf(stringName, "\"%s\"", - currentScript->dataPtr + - currentScript->offsetToSubData3 + atoi(offset)); - break; - } - case 5: - { - sprintf(stringName, "vars[%s]", offset); - break; - } - default: - { - sprintf(stringName, "string[%d][%s]", - stringTypeIdx & 7, offset); - break; - } + case 2: { + sprintf(stringName, "\"%s\"", + currentScript->dataPtr + + currentScript->offsetToSubData3 + atoi(offset)); + break; + } + case 5: { + sprintf(stringName, "vars[%s]", offset); + break; + } + default: { + sprintf(stringName, "string[%d][%s]", + stringTypeIdx & 7, offset); + break; + } } return stringName; @@ -118,7 +115,7 @@ char *resolveMessage(char *messageIdxString) { return messageIdxString; } else { return currentDecompOvl->stringTable[atoi(messageIdxString)]. - string; + string; } } @@ -139,43 +136,41 @@ void resolveDecompShort(char *buffer) { int i; importScriptStruct *importEntry = - (importScriptStruct *) (data3Ptr->dataPtr + - data3Ptr->offsetToImportData); + (importScriptStruct *)(data3Ptr->dataPtr + + data3Ptr->offsetToImportData); for (i = 0; i < data3Ptr->numRelocGlob; i++) { switch (importEntry->type) { case 20: // script case 30: case 40: - case 50: - { - if (importEntry->offset == currentDecompScriptPtr->var4 - 3) { // param1 - sprintf(buffer, - data3Ptr->dataPtr + - data3Ptr-> - offsetToImportName + - importEntry->offsetToName); - return; - } - if (importEntry->offset == currentDecompScriptPtr->var4 - 6) { // param2 - sprintf(buffer, "linkedIdx"); - return; - } - break; + case 50: { + if (importEntry->offset == currentDecompScriptPtr->var4 - 3) { // param1 + sprintf(buffer, + data3Ptr->dataPtr + + data3Ptr-> + offsetToImportName + + importEntry->offsetToName); + return; } - default: - { - if (importEntry->offset == - currentDecompScriptPtr->var4 - 4) { - sprintf(buffer, - data3Ptr->dataPtr + - data3Ptr-> - offsetToImportName + - importEntry->offsetToName); - return; - } + if (importEntry->offset == currentDecompScriptPtr->var4 - 6) { // param2 + sprintf(buffer, "linkedIdx"); + return; + } + break; + } + default: { + if (importEntry->offset == + currentDecompScriptPtr->var4 - 4) { + sprintf(buffer, + data3Ptr->dataPtr + + data3Ptr-> + offsetToImportName + + importEntry->offsetToName); + return; } } + } importEntry++; } @@ -188,24 +183,23 @@ void resolveDecompChar(char *buffer) { int i; importScriptStruct *importEntry = - (importScriptStruct *) (data3Ptr->dataPtr + - data3Ptr->offsetToImportData); + (importScriptStruct *)(data3Ptr->dataPtr + + data3Ptr->offsetToImportData); for (i = 0; i < data3Ptr->numRelocGlob; i++) { switch (importEntry->type) { - default: - { - if (importEntry->offset == - currentDecompScriptPtr->var4 - 2) { - sprintf(buffer, - data3Ptr->dataPtr + - data3Ptr-> - offsetToImportName + - importEntry->offsetToName); - return; - } + default: { + if (importEntry->offset == + currentDecompScriptPtr->var4 - 2) { + sprintf(buffer, + data3Ptr->dataPtr + + data3Ptr-> + offsetToImportName + + importEntry->offsetToName); + return; } } + } importEntry++; } @@ -250,7 +244,7 @@ char getByteFromDecompScriptReal(void) { void getShortFromDecompScript(char *buffer) { short int var = - *(int16 *) (currentDecompScript + currentDecompScriptPtr->var4); + *(int16 *)(currentDecompScript + currentDecompScriptPtr->var4); currentDecompScriptPtr->var4 = currentDecompScriptPtr->var4 + 2; @@ -268,7 +262,7 @@ void getShortFromDecompScript(char *buffer) { short int getShortFromDecompScriptReal(void) { short int var = - *(int16 *) (currentDecompScript + currentDecompScriptPtr->var4); + *(int16 *)(currentDecompScript + currentDecompScriptPtr->var4); currentDecompScriptPtr->var4 = currentDecompScriptPtr->var4 + 2; @@ -289,7 +283,7 @@ void addDecomp(char *string, ...) { * fprintf(fHandle,"\n"); */ struct decompileLineStruct *pLineStruct = - &decompileLineTable[positionInDecompileLineTable++]; + &decompileLineTable[positionInDecompileLineTable++]; pLineStruct->lineOffset = currentLineIdx; pLineStruct->indent = 0; @@ -314,14 +308,14 @@ void addDecomp(char *string, ...) { } void resolveVarName(char *ovlIdxString, int varType, char *varIdxString, - char *outputName) { + char *outputName) { int varIdx = atoi(varIdxString); strcpy(outputName, ""); if (varType == 2) { strcpy(outputName, getStringNameFromIdx(varType, - varIdxString)); + varIdxString)); return; } if (varType == 1) { @@ -336,22 +330,22 @@ void resolveVarName(char *ovlIdxString, int varType, char *varIdxString, if (varIdx == currentDecompOvl->arraySymbGlob[i].idx) { if (((currentDecompOvl->arraySymbGlob[i].var4 & 0xF0) == 0) && varType != 0x20) { // var strcpy(outputName, - currentDecompOvl->arrayNameSymbGlob + - currentDecompOvl->arraySymbGlob[i]. - offsetToName); + currentDecompOvl->arrayNameSymbGlob + + currentDecompOvl->arraySymbGlob[i]. + offsetToName); return; } if ((currentDecompOvl->arraySymbGlob[i].var4) == 20 && varType == 0x20) { // script strcpy(outputName, - currentDecompOvl->arrayNameSymbGlob + - currentDecompOvl->arraySymbGlob[i]. - offsetToName); + currentDecompOvl->arrayNameSymbGlob + + currentDecompOvl->arraySymbGlob[i]. + offsetToName); return; } } } sprintf(outputName, "ovl(%s).[%d][%s]", ovlIdxString, varType, - varIdxString); + varIdxString); } else { strcpy(outputName, ovlIdxString); } @@ -359,77 +353,72 @@ void resolveVarName(char *ovlIdxString, int varType, char *varIdxString, int decompLoadVar(void) { switch (currentScriptOpcodeType) { - case 0: - { - char buffer[256]; + case 0: { + char buffer[256]; - getShortFromDecompScript(buffer); + getShortFromDecompScript(buffer); - pushDecomp(buffer); + pushDecomp(buffer); - return (0); - } - // string - case 1: - { - char buffer1[256]; - char buffer2[256]; - char buffer3[256]; - char varName[256]; + return (0); + } + // string + case 1: { + char buffer1[256]; + char buffer2[256]; + char buffer3[256]; + char varName[256]; - getByteFromDecompScript(buffer1); - getByteFromDecompScript(buffer2); + getByteFromDecompScript(buffer1); + getByteFromDecompScript(buffer2); - getShortFromDecompScript(buffer3); + getShortFromDecompScript(buffer3); - resolveVarName(buffer2, atoi(buffer1) & 7, buffer3, - varName); + resolveVarName(buffer2, atoi(buffer1) & 7, buffer3, + varName); - pushDecomp("%s", varName); - return (0); - } - case 2: - { - char buffer1[256]; - char buffer2[256]; - char buffer3[256]; - char varName[256]; + pushDecomp("%s", varName); + return (0); + } + case 2: { + char buffer1[256]; + char buffer2[256]; + char buffer3[256]; + char varName[256]; - getByteFromDecompScript(buffer1); - getByteFromDecompScript(buffer2); + getByteFromDecompScript(buffer1); + getByteFromDecompScript(buffer2); - getShortFromDecompScript(buffer3); + getShortFromDecompScript(buffer3); - resolveVarName(buffer2, atoi(buffer1) & 7, buffer3, - varName); + resolveVarName(buffer2, atoi(buffer1) & 7, buffer3, + varName); - pushDecomp("%s", varName); - return (0); - } - case 5: - { - char buffer1[256]; - char buffer2[256]; - char buffer3[256]; - char varName[256]; + pushDecomp("%s", varName); + return (0); + } + case 5: { + char buffer1[256]; + char buffer2[256]; + char buffer3[256]; + char varName[256]; - getByteFromDecompScript(buffer1); - getByteFromDecompScript(buffer2); + getByteFromDecompScript(buffer1); + getByteFromDecompScript(buffer2); - getShortFromDecompScript(buffer3); + getShortFromDecompScript(buffer3); - resolveVarName(buffer2, atoi(buffer1) & 7, buffer3, - varName); + resolveVarName(buffer2, atoi(buffer1) & 7, buffer3, + varName); - pushDecomp("%s[%s]", varName, decompSaveOpcodeVar); - return (0); - } - default: - { - printf("Unsupported type %d in opcodeType0\n", - currentScriptOpcodeType); - failed = 1; - } + pushDecomp("%s[%s]", varName, decompSaveOpcodeVar); + return (0); + } + default: { + printf("Unsupported type %d in opcodeType0\n", + currentScriptOpcodeType); + failed = 1; + } } } @@ -437,79 +426,73 @@ int decompSaveVar(void) { // int var = popVar(); switch (currentScriptOpcodeType) { - case 0: - { - addDecomp(popDecomp()); - return (0); - } - // modify string - case 1: - { - char buffer1[256]; - char buffer2[256]; - char buffer3[256]; - char varName[256]; - uint8 type; + case 0: { + addDecomp(popDecomp()); + return (0); + } + // modify string + case 1: { + char buffer1[256]; + char buffer2[256]; + char buffer3[256]; + char varName[256]; + uint8 type; - getByteFromDecompScript(buffer1); - getByteFromDecompScript(buffer2); + getByteFromDecompScript(buffer1); + getByteFromDecompScript(buffer2); - getShortFromDecompScript(buffer3); + getShortFromDecompScript(buffer3); - type = atoi(buffer1) & 7; + type = atoi(buffer1) & 7; - resolveVarName(buffer2, type, buffer3, varName); + resolveVarName(buffer2, type, buffer3, varName); - addDecomp("%s = %s", varName, popDecomp()); - break; - } - case 2: - { - char buffer1[256]; - char buffer2[256]; - char buffer3[256]; + addDecomp("%s = %s", varName, popDecomp()); + break; + } + case 2: { + char buffer1[256]; + char buffer2[256]; + char buffer3[256]; - getByteFromDecompScript(buffer1); - getByteFromDecompScript(buffer2); + getByteFromDecompScript(buffer1); + getByteFromDecompScript(buffer2); - getShortFromDecompScript(buffer3); + getShortFromDecompScript(buffer3); - addDecomp("ovl(%s).setVar(%s,%s) = %s", buffer2, - buffer1, buffer3, popDecomp()); - break; - } - case 4: - { - strcpy(decompSaveOpcodeVar, popDecomp()); - break; - } - case 5: - { - char buffer1[256]; - char buffer2[256]; - char buffer3[256]; - char varName[256]; - uint8 type; + addDecomp("ovl(%s).setVar(%s,%s) = %s", buffer2, + buffer1, buffer3, popDecomp()); + break; + } + case 4: { + strcpy(decompSaveOpcodeVar, popDecomp()); + break; + } + case 5: { + char buffer1[256]; + char buffer2[256]; + char buffer3[256]; + char varName[256]; + uint8 type; - getByteFromDecompScript(buffer1); - getByteFromDecompScript(buffer2); + getByteFromDecompScript(buffer1); + getByteFromDecompScript(buffer2); - getShortFromDecompScript(buffer3); + getShortFromDecompScript(buffer3); - type = atoi(buffer1) & 7; + type = atoi(buffer1) & 7; - resolveVarName(buffer2, type, buffer3, varName); + resolveVarName(buffer2, type, buffer3, varName); - addDecomp("%s[%s] = %s", varName, decompSaveOpcodeVar, - popDecomp()); - break; - } - default: - { - printf("Unsupported type %d in opcodeType1\n", - currentScriptOpcodeType); - failed = 1; - } + addDecomp("%s[%s] = %s", varName, decompSaveOpcodeVar, + popDecomp()); + break; + } + default: { + printf("Unsupported type %d in opcodeType1\n", + currentScriptOpcodeType); + failed = 1; + } } return (0); @@ -517,47 +500,44 @@ int decompSaveVar(void) { int decompOpcodeType2(void) { switch (currentScriptOpcodeType) { - case 1: - { - char buffer3[256]; - char varName[256]; - int byte1 = getByteFromDecompScriptReal(); - int byte2 = getByteFromDecompScriptReal(); - getShortFromDecompScript(buffer3); + case 1: { + char buffer3[256]; + char varName[256]; + int byte1 = getByteFromDecompScriptReal(); + int byte2 = getByteFromDecompScriptReal(); + getShortFromDecompScript(buffer3); - resolveVarName("0", byte1 & 7, buffer3, varName); + resolveVarName("0", byte1 & 7, buffer3, varName); - pushDecomp(varName); + pushDecomp(varName); - break; - } - case 5: - { - int byte1 = getByteFromDecompScriptReal(); - int byte2 = getByteFromDecompScriptReal(); - short int short1 = getShortFromDecompScriptReal(); - - int8 *ptr = scriptDataPtrTable[byte1 & 7] + short1; - - if ((byte1 & 7) == 2) { - pushDecomp("\"%s\"[%s]", ptr, - decompSaveOpcodeVar); - } else if ((byte1 & 7) == 5) { - pushDecomp("freeString[%d][%s]", short1, - decompSaveOpcodeVar); - } else { - printf("Unsupported type %d in opcodeType2\n", - byte1 & 7); - failed = 1; - } - break; - } - default: - { + break; + } + case 5: { + int byte1 = getByteFromDecompScriptReal(); + int byte2 = getByteFromDecompScriptReal(); + short int short1 = getShortFromDecompScriptReal(); + + int8 *ptr = scriptDataPtrTable[byte1 & 7] + short1; + + if ((byte1 & 7) == 2) { + pushDecomp("\"%s\"[%s]", ptr, + decompSaveOpcodeVar); + } else if ((byte1 & 7) == 5) { + pushDecomp("freeString[%d][%s]", short1, + decompSaveOpcodeVar); + } else { printf("Unsupported type %d in opcodeType2\n", - currentScriptOpcodeType); + byte1 & 7); failed = 1; } + break; + } + default: { + printf("Unsupported type %d in opcodeType2\n", + currentScriptOpcodeType); + failed = 1; + } } return (0); } @@ -567,57 +547,49 @@ int decompMath(void) { char *param2 = popDecomp(); switch (currentScriptOpcodeType) { - case 0: - { - sprintf(tempbuffer, "%s+%s", param1, param2); - pushDecomp(tempbuffer); - break; - } - case 1: - { - sprintf(tempbuffer, "%s/%s", param1, param2); - pushDecomp(tempbuffer); - break; - } - case 2: - { - sprintf(tempbuffer, "%s-%s", param1, param2); - pushDecomp(tempbuffer); - break; - } - case 3: - { - sprintf(tempbuffer, "%s*%s", param1, param2); - pushDecomp(tempbuffer); - break; - } - case 4: - { - sprintf(tempbuffer, "%s\%%s", param1, param2); - pushDecomp(tempbuffer); - break; - } + case 0: { + sprintf(tempbuffer, "%s+%s", param1, param2); + pushDecomp(tempbuffer); + break; + } + case 1: { + sprintf(tempbuffer, "%s/%s", param1, param2); + pushDecomp(tempbuffer); + break; + } + case 2: { + sprintf(tempbuffer, "%s-%s", param1, param2); + pushDecomp(tempbuffer); + break; + } + case 3: { + sprintf(tempbuffer, "%s*%s", param1, param2); + pushDecomp(tempbuffer); + break; + } + case 4: { + sprintf(tempbuffer, "%s\%%s", param1, param2); + pushDecomp(tempbuffer); + break; + } case 5: - case 7: - { - sprintf(tempbuffer, "%s|%s", param1, param2); - pushDecomp(tempbuffer); - break; - } - case 6: - { - sprintf(tempbuffer, "%s&%s", param1, param2); - pushDecomp(tempbuffer); - break; - } + case 7: { + sprintf(tempbuffer, "%s|%s", param1, param2); + pushDecomp(tempbuffer); + break; + } + case 6: { + sprintf(tempbuffer, "%s&%s", param1, param2); + pushDecomp(tempbuffer); + break; + } - default: - { - sprintf(tempbuffer, "decompMath(%d,%s,%s)", - currentScriptOpcodeType, param1, param2); - pushDecomp(tempbuffer); - break; - } + default: { + sprintf(tempbuffer, "decompMath(%d,%s,%s)", + currentScriptOpcodeType, param1, param2); + pushDecomp(tempbuffer); + break; + } } return (0); } @@ -640,61 +612,53 @@ int decompTest(void) { short int offset = getShortFromDecompScriptReal(); switch (currentScriptOpcodeType) { - case 0: - { - currentLineType = 1; - addDecomp("test '!(bitMask & 1)' and goto %d", - offset + oldOffset); - break; - } - case 1: - { - currentLineType = 1; - addDecomp("test '(bitMask & 1)' and goto %d", - offset + oldOffset); - break; - } - case 2: - { - currentLineType = 1; - addDecomp("test '(bitMask & 2)' and goto %d", - offset + oldOffset); - break; - } - case 3: - { - currentLineType = 1; - addDecomp("test '(bitMask & 3)' and goto %d", - offset + oldOffset); - break; - } - case 4: - { - currentLineType = 1; - addDecomp("test '(bitMask & 4)' and goto %d", - offset + oldOffset); - break; - } - case 5: - { - currentLineType = 1; - addDecomp("test '(bitMask & 5)' and goto %d", - offset + oldOffset); - break; - } - case 6: - { - currentLineType = 2; - addDecomp("test 'never' and goto %d", - offset + oldOffset); - break; - } - case 7: - { - currentLineType = 3; - addDecomp("goto %d", offset + oldOffset); - break; - } + case 0: { + currentLineType = 1; + addDecomp("test '!(bitMask & 1)' and goto %d", + offset + oldOffset); + break; + } + case 1: { + currentLineType = 1; + addDecomp("test '(bitMask & 1)' and goto %d", + offset + oldOffset); + break; + } + case 2: { + currentLineType = 1; + addDecomp("test '(bitMask & 2)' and goto %d", + offset + oldOffset); + break; + } + case 3: { + currentLineType = 1; + addDecomp("test '(bitMask & 3)' and goto %d", + offset + oldOffset); + break; + } + case 4: { + currentLineType = 1; + addDecomp("test '(bitMask & 4)' and goto %d", + offset + oldOffset); + break; + } + case 5: { + currentLineType = 1; + addDecomp("test '(bitMask & 5)' and goto %d", + offset + oldOffset); + break; + } + case 6: { + currentLineType = 2; + addDecomp("test 'never' and goto %d", + offset + oldOffset); + break; + } + case 7: { + currentLineType = 3; + addDecomp("goto %d", offset + oldOffset); + break; + } } @@ -708,20 +672,20 @@ int decompCompare(void) { addDecomp("sign(%s)", param); -/* - if (!pop) - si = 1; + /* + if (!pop) + si = 1; - if (pop<0) { - si |= 4; - } + if (pop<0) { + si |= 4; + } - if (pop>0) { - si |= 2; - } + if (pop>0) { + si |= 2; + } - currentScriptPtr->bitMask = si; -*/ + currentScriptPtr->bitMask = si; + */ return 0; } @@ -748,660 +712,570 @@ int decompFunction(void) { currentScriptOpcodeType = getByteFromDecompScriptReal(); // addDecomp("OP_%X", currentScriptOpcodeType); switch (currentScriptOpcodeType) { - case 0x1: - { - pushDecomp("_setdoFade()"); - break; - } - case 0x2: - { - pushDecomp("_prepareFade()"); - break; - } - case 0x3: - { - sprintf(tempbuffer, "_loadBackground(%s,%s)", - popDecomp(), popDecomp()); - pushDecomp(tempbuffer); - break; - } - case 0x4: - { - sprintf(tempbuffer, "_loadFullBundle(%s,%s)", - popDecomp(), popDecomp()); - pushDecomp(tempbuffer); - break; - } - case 0x5: - { - sprintf(tempbuffer, "_addCell(%s,%s,%s)", popDecomp(), - popDecomp(), popDecomp()); - pushDecomp(tempbuffer); - break; - } - case 0x6: - { - unsigned long int numArg = atoi(popDecomp()); - char *ovlStr; - char *idxStr; - int i; - char functionName[100]; + case 0x1: { + pushDecomp("_setdoFade()"); + break; + } + case 0x2: { + pushDecomp("_prepareFade()"); + break; + } + case 0x3: { + sprintf(tempbuffer, "_loadBackground(%s,%s)", + popDecomp(), popDecomp()); + pushDecomp(tempbuffer); + break; + } + case 0x4: { + sprintf(tempbuffer, "_loadFullBundle(%s,%s)", + popDecomp(), popDecomp()); + pushDecomp(tempbuffer); + break; + } + case 0x5: { + sprintf(tempbuffer, "_addCell(%s,%s,%s)", popDecomp(), + popDecomp(), popDecomp()); + pushDecomp(tempbuffer); + break; + } + case 0x6: { + unsigned long int numArg = atoi(popDecomp()); + char *ovlStr; + char *idxStr; + int i; + char functionName[100]; - idxStr = popDecomp(); - ovlStr = popDecomp(); + idxStr = popDecomp(); + ovlStr = popDecomp(); - resolveVarName(ovlStr, 0x20, idxStr, functionName); + resolveVarName(ovlStr, 0x20, idxStr, functionName); - sprintf(tempbuffer, "_startASync(%s", functionName); + sprintf(tempbuffer, "_startASync(%s", functionName); - for (i = 0; i < numArg; i++) { - strcatuint8(tempbuffer, ","); - strcatuint8(tempbuffer, popDecomp()); - } + for (i = 0; i < numArg; i++) { + strcatuint8(tempbuffer, ","); + strcatuint8(tempbuffer, popDecomp()); + } - strcatuint8(tempbuffer, ")"); + strcatuint8(tempbuffer, ")"); - pushDecomp(tempbuffer); - break; - } - case 0x7: - { - char *var1; - char *objIdxStr; - char *ovlStr; - char varName[256]; - int i; - - var1 = popDecomp(); - objIdxStr = popDecomp(); - ovlStr = popDecomp(); - - sprintf(tempbuffer, - "_createObjectFromOvlData(ovl:%s,dataIdx:%s,%s)", - ovlStr, objIdxStr, var1); - pushDecomp(tempbuffer); - break; - } - case 0x8: - { - sprintf(tempbuffer, "_removeCell(%s,%s,%s)", - popDecomp(), popDecomp(), popDecomp()); - pushDecomp(tempbuffer); - break; - } - case 0x9: - { - pushDecomp("_freeobjectList()"); - break; - } - case 0xA: - { - sprintf(tempbuffer, "_removeScript(ovl(%s),%s)", - popDecomp(), popDecomp()); - pushDecomp(tempbuffer); - break; - } - case 0xB: - { - sprintf(tempbuffer, "_resetFilesEntries(%s,%s)", - popDecomp(), popDecomp()); - pushDecomp(tempbuffer); - break; - } - case 0xC: - { - sprintf(tempbuffer, "_loadOverlay(%s)", popDecomp()); - pushDecomp(tempbuffer); - break; - } - case 0xD: - { - sprintf(tempbuffer, "_palManipulation(%s,%s,%s,%s,%s)", - popDecomp(), popDecomp(), popDecomp(), popDecomp(), - popDecomp()); - pushDecomp(tempbuffer); - break; - } - case 0xE: - { - sprintf(tempbuffer, "_playSample(%s,%s,%s,%s)", - popDecomp(), popDecomp(), popDecomp(), - popDecomp()); - pushDecomp(tempbuffer); - break; - } - case 0x10: - { - sprintf(tempbuffer, "_releaseScript2(%s)", - popDecomp()); - pushDecomp(tempbuffer); - break; - } - case 0x11: - { - sprintf(tempbuffer, "_getOverlayIdx(%s)", popDecomp()); - pushDecomp(tempbuffer); - break; - } - case 0x13: - { - sprintf(tempbuffer, - "_displayMessage(%s,\"%s\",%s,%s,%s,%s)", - popDecomp(), resolveMessage(popDecomp()), - popDecomp(), popDecomp(), popDecomp(), - popDecomp()); - pushDecomp(tempbuffer); - break; - } - case 0x14: - { - sprintf(tempbuffer, "_removeObject(ovl(%s),%s)", - popDecomp(), popDecomp()); - pushDecomp(tempbuffer); - break; - } - case 0x15: - { - pushDecomp("_pauseScript()"); - break; - } - case 0x16: - { - sprintf(tempbuffer, - "_Op_FreezeCell(%s,%s,%s,%s,%s,%s)", popDecomp(), - popDecomp(), popDecomp(), popDecomp(), popDecomp(), - popDecomp()); - pushDecomp(tempbuffer); - break; - } - case 0x17: - { - sprintf(tempbuffer, "_loadCtp(%s)", popDecomp()); - pushDecomp(tempbuffer); - break; - } - case 0x18: - { - sprintf(tempbuffer, - "_Op_AddAnimation(%s,%s,%s,%s,%s,%s,%s)", - popDecomp(), popDecomp(), popDecomp(), popDecomp(), - popDecomp(), popDecomp(), popDecomp()); - pushDecomp(tempbuffer); - break; - } - case 0x19: - { - sprintf(tempbuffer, "_Op_RemoveAnimation(%s,%s,%s)", - popDecomp(), popDecomp(), popDecomp()); - pushDecomp(tempbuffer); - break; - } - case 0x1A: - { - sprintf(tempbuffer, "_setupScaleFormula(%s,%s,%s,%s)", - popDecomp(), popDecomp(), popDecomp(), - popDecomp()); - pushDecomp(tempbuffer); - break; - } - case 0x1E: - { - sprintf(tempbuffer, "_Op_TrackAnim(%s,%s,%s,%s,%s,%s)", - popDecomp(), popDecomp(), popDecomp(), popDecomp(), - popDecomp(), popDecomp()); - pushDecomp(tempbuffer); - break; - } - case 0x21: - { - sprintf(tempbuffer, "_isActorLoaded(%s,%s,%s)", - popDecomp(), popDecomp(), popDecomp()); - pushDecomp(tempbuffer); - break; - } - case 0x22: - { - sprintf(tempbuffer, "_computeScale(%s)", popDecomp()); - pushDecomp(tempbuffer); - break; - } - case 0x23: - { - sprintf(tempbuffer, "_convertToScale(%s,%s)", - popDecomp(), popDecomp()); - pushDecomp(tempbuffer); - break; - } - case 0x24: - { - sprintf(tempbuffer, "_op_24(%s,%s,%s,%s)", popDecomp(), - popDecomp(), popDecomp(), popDecomp()); - pushDecomp(tempbuffer); - break; - } - case 0x27: - { - sprintf(tempbuffer, "_getWalkBoxCollision(%s,%s)", - popDecomp(), popDecomp()); - pushDecomp(tempbuffer); - break; - } - case 0x28: - { - sprintf(tempbuffer, "_changeSaveAllowedState(%s)", - popDecomp()); - pushDecomp(tempbuffer); - break; - } - case 0x29: - { - pushDecomp("_freeAllPerso()"); - break; - } - case 0x2B: - { - sprintf(tempbuffer, "_getProcIdx(%s,%s)", popDecomp(), - popDecomp()); - pushDecomp(tempbuffer); - break; - } - case 0x2C: - { - sprintf(tempbuffer, "_setObjectPosition(%s,%s,%s)", - popDecomp(), popDecomp(), popDecomp()); - pushDecomp(tempbuffer); - break; - } - case 0x2E: - { - sprintf(tempbuffer, "_releaseScript(%s)", popDecomp()); - pushDecomp(tempbuffer); - break; - } - case 0x2F: - { - sprintf(tempbuffer, "_addBackgroundIncrust(%s,%s,%s)", - popDecomp(), popDecomp(), popDecomp()); - pushDecomp(tempbuffer); - break; - } - case 0x30: - { - sprintf(tempbuffer, "_removeBackgroundIncrust(%s,%s)", - popDecomp(), popDecomp()); - pushDecomp(tempbuffer); - break; - } - case 0x31: - { - sprintf(tempbuffer, "_op_31(%s,%s)", popDecomp(), - popDecomp()); - pushDecomp(tempbuffer); - break; - } - case 0x32: - { - pushDecomp("_freeBackgroundInscrustList()"); - break; - } - case 0x35: - { - sprintf(tempbuffer, "_op35(%s)", popDecomp()); - pushDecomp(tempbuffer); - break; - } - case 0x37: - { - sprintf(tempbuffer, "_op37(%s,%s)", popDecomp(), - popDecomp()); - pushDecomp(tempbuffer); - break; - } - case 0x38: - { - sprintf(tempbuffer, "_removeBackground(%s)", - popDecomp()); - pushDecomp(tempbuffer); - break; - } - case 0x39: - { - sprintf(tempbuffer, "_SetActiveBackgroundPlane(%s)", - popDecomp()); - pushDecomp(tempbuffer); - break; - } - case 0x3A: - { - sprintf(tempbuffer, "_setVar49(%s)", popDecomp()); - pushDecomp(tempbuffer); - break; - } - case 0x3B: - { - pushDecomp("_op3B()"); - break; - } - case 0x3C: - { - sprintf(tempbuffer, "_rand(%s)", popDecomp()); - pushDecomp(tempbuffer); - break; - } - case 0x3D: - { - sprintf(tempbuffer, "_loadMusic(%s)", popDecomp()); - pushDecomp(tempbuffer); - break; - } - case 0x3E: - { - pushDecomp("_op_3E()"); - break; - } - case 0x3F: - { - pushDecomp("_op_3F()"); - break; - } - case 0x40: - { - pushDecomp("_op_40()"); - break; - } - case 0x41: - { - sprintf(tempbuffer, "_isFileLoaded2(%s)", popDecomp()); - pushDecomp(tempbuffer); - break; - } - case 0x45: - { - pushDecomp("_stopSound()"); - break; - } - case 0x49: - { - sprintf(tempbuffer, "_op49(%s)", popDecomp()); - pushDecomp(tempbuffer); - break; - } - case 0x54: - { - sprintf(tempbuffer, "_setFontVar(%s)", popDecomp()); - pushDecomp(tempbuffer); - break; - } - case 0x56: - { - sprintf(tempbuffer, "_changeCutSceneState(%s)", - popDecomp()); - pushDecomp(tempbuffer); - break; - } - case 0x57: - { - pushDecomp("_getMouseX()"); - break; - } - case 0x58: - { - pushDecomp("_getMouseY()"); - break; - } - case 0x59: - { - pushDecomp("_getMouse3()"); - break; - } - case 0x5A: - { - sprintf(tempbuffer, "_isFileLoaded(%s)", popDecomp()); - pushDecomp(tempbuffer); - break; - } - case 0x5B: - { - pushDecomp("_regenerateBackgroundIncrust()"); - break; - } - case 0x5C: - { - sprintf(tempbuffer, "_Op_AddCellC(%s,%s)", popDecomp(), - popDecomp()); - pushDecomp(tempbuffer); - break; - } - case 0x5E: - { - sprintf(tempbuffer, "_Op_AddCellE(%s)", popDecomp()); - pushDecomp(tempbuffer); - break; - } - case 0x60: - { - sprintf(tempbuffer, "_op_60(%s,%s,%s,%s,%s)", - popDecomp(), popDecomp(), popDecomp(), popDecomp(), - popDecomp()); - pushDecomp(tempbuffer); - break; - } - case 0x61: - { - sprintf(tempbuffer, "_op61(%s,%s)", popDecomp(), - popDecomp()); - pushDecomp(tempbuffer); - break; - } - case 0x62: - { - pushDecomp("_pauseCallingScript()"); - break; - } - case 0x63: - { - pushDecomp("_resumeScript()"); - break; - } - case 0x64: - { - unsigned long int numArg = atoi(popDecomp()); - char *ovlStr; - char *idxStr; - int i; - char functionName[256]; + pushDecomp(tempbuffer); + break; + } + case 0x7: { + char *var1; + char *objIdxStr; + char *ovlStr; + char varName[256]; + int i; - idxStr = popDecomp(); - ovlStr = popDecomp(); + var1 = popDecomp(); + objIdxStr = popDecomp(); + ovlStr = popDecomp(); - resolveVarName(ovlStr, 0x20, idxStr, functionName); + sprintf(tempbuffer, + "_createObjectFromOvlData(ovl:%s,dataIdx:%s,%s)", + ovlStr, objIdxStr, var1); + pushDecomp(tempbuffer); + break; + } + case 0x8: { + sprintf(tempbuffer, "_removeCell(%s,%s,%s)", + popDecomp(), popDecomp(), popDecomp()); + pushDecomp(tempbuffer); + break; + } + case 0x9: { + pushDecomp("_freeobjectList()"); + break; + } + case 0xA: { + sprintf(tempbuffer, "_removeScript(ovl(%s),%s)", + popDecomp(), popDecomp()); + pushDecomp(tempbuffer); + break; + } + case 0xB: { + sprintf(tempbuffer, "_resetFilesEntries(%s,%s)", + popDecomp(), popDecomp()); + pushDecomp(tempbuffer); + break; + } + case 0xC: { + sprintf(tempbuffer, "_loadOverlay(%s)", popDecomp()); + pushDecomp(tempbuffer); + break; + } + case 0xD: { + sprintf(tempbuffer, "_palManipulation(%s,%s,%s,%s,%s)", + popDecomp(), popDecomp(), popDecomp(), popDecomp(), + popDecomp()); + pushDecomp(tempbuffer); + break; + } + case 0xE: { + sprintf(tempbuffer, "_playSample(%s,%s,%s,%s)", + popDecomp(), popDecomp(), popDecomp(), + popDecomp()); + pushDecomp(tempbuffer); + break; + } + case 0x10: { + sprintf(tempbuffer, "_releaseScript2(%s)", + popDecomp()); + pushDecomp(tempbuffer); + break; + } + case 0x11: { + sprintf(tempbuffer, "_getOverlayIdx(%s)", popDecomp()); + pushDecomp(tempbuffer); + break; + } + case 0x13: { + sprintf(tempbuffer, + "_displayMessage(%s,\"%s\",%s,%s,%s,%s)", + popDecomp(), resolveMessage(popDecomp()), + popDecomp(), popDecomp(), popDecomp(), + popDecomp()); + pushDecomp(tempbuffer); + break; + } + case 0x14: { + sprintf(tempbuffer, "_removeObject(ovl(%s),%s)", + popDecomp(), popDecomp()); + pushDecomp(tempbuffer); + break; + } + case 0x15: { + pushDecomp("_pauseScript()"); + break; + } + case 0x16: { + sprintf(tempbuffer, + "_Op_FreezeCell(%s,%s,%s,%s,%s,%s)", popDecomp(), + popDecomp(), popDecomp(), popDecomp(), popDecomp(), + popDecomp()); + pushDecomp(tempbuffer); + break; + } + case 0x17: { + sprintf(tempbuffer, "_loadCtp(%s)", popDecomp()); + pushDecomp(tempbuffer); + break; + } + case 0x18: { + sprintf(tempbuffer, + "_Op_AddAnimation(%s,%s,%s,%s,%s,%s,%s)", + popDecomp(), popDecomp(), popDecomp(), popDecomp(), + popDecomp(), popDecomp(), popDecomp()); + pushDecomp(tempbuffer); + break; + } + case 0x19: { + sprintf(tempbuffer, "_Op_RemoveAnimation(%s,%s,%s)", + popDecomp(), popDecomp(), popDecomp()); + pushDecomp(tempbuffer); + break; + } + case 0x1A: { + sprintf(tempbuffer, "_setupScaleFormula(%s,%s,%s,%s)", + popDecomp(), popDecomp(), popDecomp(), + popDecomp()); + pushDecomp(tempbuffer); + break; + } + case 0x1E: { + sprintf(tempbuffer, "_Op_TrackAnim(%s,%s,%s,%s,%s,%s)", + popDecomp(), popDecomp(), popDecomp(), popDecomp(), + popDecomp(), popDecomp()); + pushDecomp(tempbuffer); + break; + } + case 0x21: { + sprintf(tempbuffer, "_isActorLoaded(%s,%s,%s)", + popDecomp(), popDecomp(), popDecomp()); + pushDecomp(tempbuffer); + break; + } + case 0x22: { + sprintf(tempbuffer, "_computeScale(%s)", popDecomp()); + pushDecomp(tempbuffer); + break; + } + case 0x23: { + sprintf(tempbuffer, "_convertToScale(%s,%s)", + popDecomp(), popDecomp()); + pushDecomp(tempbuffer); + break; + } + case 0x24: { + sprintf(tempbuffer, "_op_24(%s,%s,%s,%s)", popDecomp(), + popDecomp(), popDecomp(), popDecomp()); + pushDecomp(tempbuffer); + break; + } + case 0x27: { + sprintf(tempbuffer, "_getWalkBoxCollision(%s,%s)", + popDecomp(), popDecomp()); + pushDecomp(tempbuffer); + break; + } + case 0x28: { + sprintf(tempbuffer, "_changeSaveAllowedState(%s)", + popDecomp()); + pushDecomp(tempbuffer); + break; + } + case 0x29: { + pushDecomp("_freeAllPerso()"); + break; + } + case 0x2B: { + sprintf(tempbuffer, "_getProcIdx(%s,%s)", popDecomp(), + popDecomp()); + pushDecomp(tempbuffer); + break; + } + case 0x2C: { + sprintf(tempbuffer, "_setObjectPosition(%s,%s,%s)", + popDecomp(), popDecomp(), popDecomp()); + pushDecomp(tempbuffer); + break; + } + case 0x2E: { + sprintf(tempbuffer, "_releaseScript(%s)", popDecomp()); + pushDecomp(tempbuffer); + break; + } + case 0x2F: { + sprintf(tempbuffer, "_addBackgroundIncrust(%s,%s,%s)", + popDecomp(), popDecomp(), popDecomp()); + pushDecomp(tempbuffer); + break; + } + case 0x30: { + sprintf(tempbuffer, "_removeBackgroundIncrust(%s,%s)", + popDecomp(), popDecomp()); + pushDecomp(tempbuffer); + break; + } + case 0x31: { + sprintf(tempbuffer, "_op_31(%s,%s)", popDecomp(), + popDecomp()); + pushDecomp(tempbuffer); + break; + } + case 0x32: { + pushDecomp("_freeBackgroundInscrustList()"); + break; + } + case 0x35: { + sprintf(tempbuffer, "_op35(%s)", popDecomp()); + pushDecomp(tempbuffer); + break; + } + case 0x37: { + sprintf(tempbuffer, "_op37(%s,%s)", popDecomp(), + popDecomp()); + pushDecomp(tempbuffer); + break; + } + case 0x38: { + sprintf(tempbuffer, "_removeBackground(%s)", + popDecomp()); + pushDecomp(tempbuffer); + break; + } + case 0x39: { + sprintf(tempbuffer, "_SetActiveBackgroundPlane(%s)", + popDecomp()); + pushDecomp(tempbuffer); + break; + } + case 0x3A: { + sprintf(tempbuffer, "_setVar49(%s)", popDecomp()); + pushDecomp(tempbuffer); + break; + } + case 0x3B: { + pushDecomp("_op3B()"); + break; + } + case 0x3C: { + sprintf(tempbuffer, "_rand(%s)", popDecomp()); + pushDecomp(tempbuffer); + break; + } + case 0x3D: { + sprintf(tempbuffer, "_loadMusic(%s)", popDecomp()); + pushDecomp(tempbuffer); + break; + } + case 0x3E: { + pushDecomp("_op_3E()"); + break; + } + case 0x3F: { + pushDecomp("_op_3F()"); + break; + } + case 0x40: { + pushDecomp("_op_40()"); + break; + } + case 0x41: { + sprintf(tempbuffer, "_isFileLoaded2(%s)", popDecomp()); + pushDecomp(tempbuffer); + break; + } + case 0x45: { + pushDecomp("_stopSound()"); + break; + } + case 0x49: { + sprintf(tempbuffer, "_op49(%s)", popDecomp()); + pushDecomp(tempbuffer); + break; + } + case 0x54: { + sprintf(tempbuffer, "_setFontVar(%s)", popDecomp()); + pushDecomp(tempbuffer); + break; + } + case 0x56: { + sprintf(tempbuffer, "_changeCutSceneState(%s)", + popDecomp()); + pushDecomp(tempbuffer); + break; + } + case 0x57: { + pushDecomp("_getMouseX()"); + break; + } + case 0x58: { + pushDecomp("_getMouseY()"); + break; + } + case 0x59: { + pushDecomp("_getMouse3()"); + break; + } + case 0x5A: { + sprintf(tempbuffer, "_isFileLoaded(%s)", popDecomp()); + pushDecomp(tempbuffer); + break; + } + case 0x5B: { + pushDecomp("_regenerateBackgroundIncrust()"); + break; + } + case 0x5C: { + sprintf(tempbuffer, "_Op_AddCellC(%s,%s)", popDecomp(), + popDecomp()); + pushDecomp(tempbuffer); + break; + } + case 0x5E: { + sprintf(tempbuffer, "_Op_AddCellE(%s)", popDecomp()); + pushDecomp(tempbuffer); + break; + } + case 0x60: { + sprintf(tempbuffer, "_op_60(%s,%s,%s,%s,%s)", + popDecomp(), popDecomp(), popDecomp(), popDecomp(), + popDecomp()); + pushDecomp(tempbuffer); + break; + } + case 0x61: { + sprintf(tempbuffer, "_op61(%s,%s)", popDecomp(), + popDecomp()); + pushDecomp(tempbuffer); + break; + } + case 0x62: { + pushDecomp("_pauseCallingScript()"); + break; + } + case 0x63: { + pushDecomp("_resumeScript()"); + break; + } + case 0x64: { + unsigned long int numArg = atoi(popDecomp()); + char *ovlStr; + char *idxStr; + int i; + char functionName[256]; - sprintf(tempbuffer, "%s(", functionName); + idxStr = popDecomp(); + ovlStr = popDecomp(); - for (i = 0; i < numArg; i++) { - if (i) - strcatuint8(tempbuffer, ","); - strcatuint8(tempbuffer, popDecomp()); - } + resolveVarName(ovlStr, 0x20, idxStr, functionName); - strcatuint8(tempbuffer, ")"); + sprintf(tempbuffer, "%s(", functionName); - pushDecomp(tempbuffer); - break; - } - case 0x65: - { - sprintf(tempbuffer, - "_addWaitObject(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)", - popDecomp(), popDecomp(), popDecomp(), popDecomp(), - popDecomp(), popDecomp(), popDecomp(), popDecomp(), - popDecomp(), popDecomp()); - pushDecomp(tempbuffer); - break; - } - case 0x66: - { - sprintf(tempbuffer, "_op_66(%s,%s)", popDecomp(), - popDecomp()); - pushDecomp(tempbuffer); - break; - } - case 0x67: - { - sprintf(tempbuffer, "_loadAudioResource(%s,%s)", - popDecomp(), popDecomp()); - pushDecomp(tempbuffer); - break; - } - case 0x68: - { - pushDecomp("_freeMediumVar()"); - break; - } - case 0x6A: - { - sprintf(tempbuffer, "_op_6A(%s)", popDecomp()); - pushDecomp(tempbuffer); - break; - } - case 0x6B: - { - sprintf(tempbuffer, "_loadData(%s,%s,%s,%s)", - popDecomp(), popDecomp(), popDecomp(), - popDecomp()); - pushDecomp(tempbuffer); - break; - } - case 0x6C: - { - sprintf(tempbuffer, "_op_6C(%s,%s)", popDecomp(), - popDecomp()); - pushDecomp(tempbuffer); - break; - } - case 0x6D: - { - sprintf(tempbuffer, "_strcpy(%s,%s)", popDecomp(), - popDecomp()); - pushDecomp(tempbuffer); - break; - } - case 0x6E: - { - sprintf(tempbuffer, "_op_6E(%s,%s)", popDecomp(), - popDecomp()); - pushDecomp(tempbuffer); - break; + for (i = 0; i < numArg; i++) { + if (i) + strcatuint8(tempbuffer, ","); + strcatuint8(tempbuffer, popDecomp()); } - case 0x6F: - { - unsigned long int numArg = atoi(popDecomp()); - char *ovlStr; - char *idxStr; - int i; - idxStr = popDecomp(); - ovlStr = popDecomp(); + strcatuint8(tempbuffer, ")"); - sprintf(tempbuffer, "_op_6F(%s,%s", idxStr, ovlStr); + pushDecomp(tempbuffer); + break; + } + case 0x65: { + sprintf(tempbuffer, + "_addWaitObject(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)", + popDecomp(), popDecomp(), popDecomp(), popDecomp(), + popDecomp(), popDecomp(), popDecomp(), popDecomp(), + popDecomp(), popDecomp()); + pushDecomp(tempbuffer); + break; + } + case 0x66: { + sprintf(tempbuffer, "_op_66(%s,%s)", popDecomp(), + popDecomp()); + pushDecomp(tempbuffer); + break; + } + case 0x67: { + sprintf(tempbuffer, "_loadAudioResource(%s,%s)", + popDecomp(), popDecomp()); + pushDecomp(tempbuffer); + break; + } + case 0x68: { + pushDecomp("_freeMediumVar()"); + break; + } + case 0x6A: { + sprintf(tempbuffer, "_op_6A(%s)", popDecomp()); + pushDecomp(tempbuffer); + break; + } + case 0x6B: { + sprintf(tempbuffer, "_loadData(%s,%s,%s,%s)", + popDecomp(), popDecomp(), popDecomp(), + popDecomp()); + pushDecomp(tempbuffer); + break; + } + case 0x6C: { + sprintf(tempbuffer, "_op_6C(%s,%s)", popDecomp(), + popDecomp()); + pushDecomp(tempbuffer); + break; + } + case 0x6D: { + sprintf(tempbuffer, "_strcpy(%s,%s)", popDecomp(), + popDecomp()); + pushDecomp(tempbuffer); + break; + } + case 0x6E: { + sprintf(tempbuffer, "_op_6E(%s,%s)", popDecomp(), + popDecomp()); + pushDecomp(tempbuffer); + break; + } + case 0x6F: { + unsigned long int numArg = atoi(popDecomp()); + char *ovlStr; + char *idxStr; + int i; - for (i = 0; i < numArg; i++) { - strcatuint8(tempbuffer, ","); - strcatuint8(tempbuffer, popDecomp()); - } + idxStr = popDecomp(); + ovlStr = popDecomp(); - strcatuint8(tempbuffer, ")"); + sprintf(tempbuffer, "_op_6F(%s,%s", idxStr, ovlStr); - pushDecomp(tempbuffer); - break; - } - case 0x70: - { - sprintf(tempbuffer, "_comment(%s)", popDecomp()); - pushDecomp(tempbuffer); - break; - } - case 0x71: - { - sprintf(tempbuffer, "_op71(%s,%s,%s,%s,%s)", - popDecomp(), popDecomp(), popDecomp(), popDecomp(), - popDecomp()); - pushDecomp(tempbuffer); - break; - } - case 0x72: - { - sprintf(tempbuffer, "_op72(%s,%s)", popDecomp(), - popDecomp(), popDecomp()); - pushDecomp(tempbuffer); - break; - } - case 0x73: - { - sprintf(tempbuffer, "_op73(%s)", popDecomp()); - pushDecomp(tempbuffer); - break; - } - case 0x74: - { - sprintf(tempbuffer, "_getlowMemory()"); - pushDecomp(tempbuffer); - break; - } - case 0x76: - { - sprintf(tempbuffer, "_Op_InitializeState6(%s,%s)", - popDecomp(), popDecomp()); - pushDecomp(tempbuffer); - break; - } - case 0x77: - { - sprintf(tempbuffer, "_Op_InitializeState7(%s)", - popDecomp()); - pushDecomp(tempbuffer); - break; - } - case 0x78: - { - sprintf(tempbuffer, "_Op_InitializeState8(%s)", - popDecomp()); - pushDecomp(tempbuffer); - break; - } - case 0x79: - { - sprintf(tempbuffer, "_EnterPlayerMenu(%s)", - popDecomp()); - pushDecomp(tempbuffer); - break; - } - case 0x7B: - { - sprintf(tempbuffer, "_Op_InitializeStateB(%s)", - popDecomp()); - pushDecomp(tempbuffer); - break; - } - case 0x7C: - { - sprintf(tempbuffer, "_Op_InitializeStateC(%s)", - popDecomp()); - pushDecomp(tempbuffer); - break; - } - case 0x7D: - { - pushDecomp("_freeAllMenu()"); - break; - } - default: - { - addDecomp("OP_%X", currentScriptOpcodeType); - printf("OPCODE: %X\n", currentScriptOpcodeType); - failed = 1; - break; + for (i = 0; i < numArg; i++) { + strcatuint8(tempbuffer, ","); + strcatuint8(tempbuffer, popDecomp()); } + + strcatuint8(tempbuffer, ")"); + + pushDecomp(tempbuffer); + break; + } + case 0x70: { + sprintf(tempbuffer, "_comment(%s)", popDecomp()); + pushDecomp(tempbuffer); + break; + } + case 0x71: { + sprintf(tempbuffer, "_op71(%s,%s,%s,%s,%s)", + popDecomp(), popDecomp(), popDecomp(), popDecomp(), + popDecomp()); + pushDecomp(tempbuffer); + break; + } + case 0x72: { + sprintf(tempbuffer, "_op72(%s,%s)", popDecomp(), + popDecomp(), popDecomp()); + pushDecomp(tempbuffer); + break; + } + case 0x73: { + sprintf(tempbuffer, "_op73(%s)", popDecomp()); + pushDecomp(tempbuffer); + break; + } + case 0x74: { + sprintf(tempbuffer, "_getlowMemory()"); + pushDecomp(tempbuffer); + break; + } + case 0x76: { + sprintf(tempbuffer, "_Op_InitializeState6(%s,%s)", + popDecomp(), popDecomp()); + pushDecomp(tempbuffer); + break; + } + case 0x77: { + sprintf(tempbuffer, "_Op_InitializeState7(%s)", + popDecomp()); + pushDecomp(tempbuffer); + break; + } + case 0x78: { + sprintf(tempbuffer, "_Op_InitializeState8(%s)", + popDecomp()); + pushDecomp(tempbuffer); + break; + } + case 0x79: { + sprintf(tempbuffer, "_EnterPlayerMenu(%s)", + popDecomp()); + pushDecomp(tempbuffer); + break; + } + case 0x7B: { + sprintf(tempbuffer, "_Op_InitializeStateB(%s)", + popDecomp()); + pushDecomp(tempbuffer); + break; + } + case 0x7C: { + sprintf(tempbuffer, "_Op_InitializeStateC(%s)", + popDecomp()); + pushDecomp(tempbuffer); + break; + } + case 0x7D: { + pushDecomp("_freeAllMenu()"); + break; + } + default: { + addDecomp("OP_%X", currentScriptOpcodeType); + printf("OPCODE: %X\n", currentScriptOpcodeType); + failed = 1; + break; + } } // pushDecomp("functionDummyPush"); @@ -1454,7 +1328,7 @@ void generateIndentation(void) { } if (strstr(decompileLineTable[destLineIdx - 1].line, "goto") == - decompileLineTable[destLineIdx - 1].line) { + decompileLineTable[destLineIdx - 1].line) { //decompileLineTable[destLineIdx-1].pendingElse = 1; } } @@ -1529,13 +1403,13 @@ void dumpScript(uint8 *ovlName, ovlDataStruct *ovlData, int idx) { if (!decompOpcodeTypeTable[(opcodeType & 0xFB) >> 3]) { printf("Unsupported opcode type %d in decomp\n", - (opcodeType & 0xFB) >> 3); + (opcodeType & 0xFB) >> 3); return; } //printf("Optype: %d\n",(opcodeType&0xFB)>>3); - decompOpcodeTypeTable[(opcodeType & 0xFB) >> 3] (); + decompOpcodeTypeTable[(opcodeType & 0xFB) >> 3](); if (failed) { printf("Aborting decompilation..\n"); @@ -1554,7 +1428,7 @@ void dumpScript(uint8 *ovlName, ovlDataStruct *ovlData, int idx) { if (decompileLineTable[i].pendingElse) { fprintf(fHandle, "%05d:\t", - decompileLineTable[i].lineOffset); + decompileLineTable[i].lineOffset); fprintf(fHandle, "else", decompileLineTable[i].line); fprintf(fHandle, "\n"); } diff --git a/engines/cruise/delphine-unpack.cpp b/engines/cruise/delphine-unpack.cpp index 7dfed6fea9..a78a8af84b 100644 --- a/engines/cruise/delphine-unpack.cpp +++ b/engines/cruise/delphine-unpack.cpp @@ -48,7 +48,8 @@ static int rcr(UnpackCtx *uc, int CF) { static int nextChunk(UnpackCtx *uc) { int CF = rcr(uc, 0); if (uc->chk == 0) { - uc->chk = READ_BE_UINT32(uc->src); uc->src -= 4; + uc->chk = READ_BE_UINT32(uc->src); + uc->src -= 4; uc->crc ^= uc->chk; CF = rcr(uc, 1); } @@ -88,11 +89,14 @@ static void unpackHelper2(UnpackCtx *uc, byte numChunks) { bool delphineUnpack(byte *dst, const byte *src, int len) { UnpackCtx uc; uc.src = src + len - 4; - uc.datasize = READ_BE_UINT32(uc.src); uc.src -= 4; + uc.datasize = READ_BE_UINT32(uc.src); + uc.src -= 4; uc.dst = dst + uc.datasize - 1; uc.size = 0; - uc.crc = READ_BE_UINT32(uc.src); uc.src -= 4; - uc.chk = READ_BE_UINT32(uc.src); uc.src -= 4; + uc.crc = READ_BE_UINT32(uc.src); + uc.src -= 4; + uc.chk = READ_BE_UINT32(uc.src); + uc.src -= 4; uc.crc ^= uc.chk; do { if (!nextChunk(&uc)) { diff --git a/engines/cruise/detection.cpp b/engines/cruise/detection.cpp index 93b802ba91..1d59c36cd3 100644 --- a/engines/cruise/detection.cpp +++ b/engines/cruise/detection.cpp @@ -40,10 +40,18 @@ struct CRUISEGameDescription { uint32 features; }; -int CruiseEngine::getGameType() const { return _gameDescription->gameType; } -uint32 CruiseEngine::getFeatures() const { return _gameDescription->features; } -Common::Language CruiseEngine::getLanguage() const { return _gameDescription->desc.language; } -Common::Platform CruiseEngine::getPlatform() const { return _gameDescription->desc.platform; } +int CruiseEngine::getGameType() const { + return _gameDescription->gameType; +} +uint32 CruiseEngine::getFeatures() const { + return _gameDescription->features; +} +Common::Language CruiseEngine::getLanguage() const { + return _gameDescription->desc.language; +} +Common::Platform CruiseEngine::getPlatform() const { + return _gameDescription->desc.platform; +} } @@ -62,7 +70,7 @@ namespace Cruise { static const CRUISEGameDescription gameDescriptions[] = { { - { + { "cruise", "16 colors", AD_ENTRY1("D1", "41a7a4d426dbd048eb369cfee4bb2717"), @@ -72,9 +80,9 @@ static const CRUISEGameDescription gameDescriptions[] = { }, GType_CRUISE, 0, - }, + }, { - { + { "cruise", "256 colors", AD_ENTRY1("D1", "a90d2b9ead6b4d812cd14268672cf178"), @@ -158,18 +166,18 @@ static const Common::ADParams detectionParams = { }; class CruiseMetaEngine : public Common::AdvancedMetaEngine { -public: - CruiseMetaEngine() : Common::AdvancedMetaEngine(detectionParams) {} + public: + CruiseMetaEngine() : Common::AdvancedMetaEngine(detectionParams) {} - virtual const char *getName() const { - return "Cinematique evo 2 engine"; - } + virtual const char *getName() const { + return "Cinematique evo 2 engine"; + } - virtual const char *getCopyright() const { - return "Cruise for a Corpse (C) Delphine Software"; - } + virtual const char *getCopyright() const { + return "Cruise for a Corpse (C) Delphine Software"; + } - virtual bool createInstance(OSystem *syst, Engine **engine, const Common::ADGameDescription *desc) const; + virtual bool createInstance(OSystem *syst, Engine **engine, const Common::ADGameDescription *desc) const; }; bool CruiseMetaEngine::createInstance(OSystem *syst, Engine **engine, const Common::ADGameDescription *desc) const { @@ -181,7 +189,7 @@ bool CruiseMetaEngine::createInstance(OSystem *syst, Engine **engine, const Comm } #if PLUGIN_ENABLED_DYNAMIC(CRUISE) - REGISTER_PLUGIN_DYNAMIC(CRUISE, PLUGIN_TYPE_ENGINE, CruiseMetaEngine); +REGISTER_PLUGIN_DYNAMIC(CRUISE, PLUGIN_TYPE_ENGINE, CruiseMetaEngine); #else - REGISTER_PLUGIN_STATIC(CRUISE, PLUGIN_TYPE_ENGINE, CruiseMetaEngine); +REGISTER_PLUGIN_STATIC(CRUISE, PLUGIN_TYPE_ENGINE, CruiseMetaEngine); #endif diff --git a/engines/cruise/font.cpp b/engines/cruise/font.cpp index a8c2bc79bb..b055433da0 100644 --- a/engines/cruise/font.cpp +++ b/engines/cruise/font.cpp @@ -52,7 +52,7 @@ int32 getLineHeight(int16 charCount, uint8 * fontPtr, uint8 * fontPrt_Desc) { // this function determins how many lines the text will have (old: fontProc2(int32 param1, int32 param2, uint8* ptr, uint8* string)) int32 getTextLineCount(int32 rightBorder_X, int32 wordSpacingWidth, - uint8 *ptr, const uint8 *textString) { + uint8 *ptr, const uint8 *textString) { const uint8 *localString = textString; const uint8 *currentStringPtr; uint8 character; @@ -77,8 +77,8 @@ int32 getTextLineCount(int32 rightBorder_X, int32 wordSpacingWidth, } else { if (charData >= 0) { // + 0xA jump to last 2 bytes of the 12 bytes slice = letter width lineLength += - wordSpacingWidth + *(int16 *) (ptr + 0xA + - charData * 12); + wordSpacingWidth + *(int16 *)(ptr + 0xA + + charData * 12); } else { if (character == ' ') { lineLength += wordSpacingWidth + 5; @@ -148,7 +148,7 @@ void loadFNT(const char *fileName) { fontFileHandle.read(_systemFNT, fontSize); flipLong((int32 *) _systemFNT); - flipLong((int32 *) (_systemFNT + 4)); + flipLong((int32 *)(_systemFNT + 4)); flipGen(_systemFNT + 8, 6); currentPtr = _systemFNT + 14; @@ -229,8 +229,8 @@ void flipGen(void *var, int32 length) { } void renderWord(uint8 * fontPtr_Data, uint8 * outBufferPtr, - int32 drawPosPixel_X, int32 heightOff, int32 height, int32 param4, - int32 stringRenderBufferSize, int32 width, int32 charWidth) { + int32 drawPosPixel_X, int32 heightOff, int32 height, int32 param4, + int32 stringRenderBufferSize, int32 width, int32 charWidth) { int i; int j; uint8 *fontPtr_Data2 = fontPtr_Data + height * 2; @@ -250,7 +250,7 @@ void renderWord(uint8 * fontPtr_Data, uint8 * outBufferPtr, for (j = 0; j < charWidth; j++) { *outBufferPtr = ((currentColor1 >> 15) & 1) | ((currentColor2 >> - 14) & 2); + 14) & 2); outBufferPtr++; currentColor1 <<= 1; @@ -262,7 +262,7 @@ void renderWord(uint8 * fontPtr_Data, uint8 * outBufferPtr, // returns character count and pixel size (via pointer) per line of the string (old: prepareWordRender(int32 param, int32 var1, int16* out2, uint8* ptr3, uint8* string)) int32 prepareWordRender(int32 inRightBorder_X, int32 wordSpacingWidth, - int16 * strPixelLength, uint8 * ptr3, const uint8 * textString) { + int16 * strPixelLength, uint8 * ptr3, const uint8 * textString) { const uint8 *localString = textString; int32 counter = 0; @@ -280,7 +280,7 @@ int32 prepareWordRender(int32 inRightBorder_X, int32 wordSpacingWidth, temp_pc = pixelCount; if (pixelCount + wordSpacingWidth + 5 >= - inRightBorder_X) { + inRightBorder_X) { finish = 1; } else { pixelCount += wordSpacingWidth + 5; @@ -291,9 +291,9 @@ int32 prepareWordRender(int32 inRightBorder_X, int32 wordSpacingWidth, } else { if (charData) { if (pixelCount + wordSpacingWidth + - *(int16 *) ((ptr3 + - charData * 12) + 0xA) >= - inRightBorder_X) { + *(int16 *)((ptr3 + + charData * 12) + 0xA) >= + inRightBorder_X) { finish = 1; if (temp_pc) { pixelCount = temp_pc; @@ -302,8 +302,8 @@ int32 prepareWordRender(int32 inRightBorder_X, int32 wordSpacingWidth, } else { pixelCount += wordSpacingWidth + - *(int16 *) ((ptr3 + - charData * 12) + 0xA); + *(int16 *)((ptr3 + + charData * 12) + 0xA); } } } @@ -316,7 +316,7 @@ int32 prepareWordRender(int32 inRightBorder_X, int32 wordSpacingWidth, } void drawString(int32 x, int32 y, uint8 *string, uint8 *buffer, uint8 color, - int32 inRightBorder_X) { + int32 inRightBorder_X) { uint8 *fontPtr; uint8 *fontPtr_Data; // ptr2 uint8 *fontPtr_Desc; // ptr3 @@ -354,13 +354,13 @@ void drawString(int32 x, int32 y, uint8 *string, uint8 *buffer, uint8 color, return; } - fontPtr_Data = fontPtr + *(int16 *) (fontPtr + 4); + fontPtr_Data = fontPtr + *(int16 *)(fontPtr + 4); fontPtr_Desc = fontPtr + 14; - lineHeight = getLineHeight(*(int16 *) (fontPtr + 8), fontPtr, fontPtr_Desc); // ok + lineHeight = getLineHeight(*(int16 *)(fontPtr + 8), fontPtr, fontPtr_Desc); // ok - wordSpacingWidth = *(int16 *) (fontPtr + 10); - wordSpacingHeight = *(int16 *) (fontPtr + 12); + wordSpacingWidth = *(int16 *)(fontPtr + 10); + wordSpacingHeight = *(int16 *)(fontPtr + 12); if (inRightBorder_X > 310) { rightBorder_X = 310; @@ -444,19 +444,19 @@ void drawString(int32 x, int32 y, uint8 *string, uint8 *buffer, uint8 color, } else { if (data) { short int *si = - (int16 *) (fontPtr_Desc + - data * 12); + (int16 *)(fontPtr_Desc + + data * 12); //int var_2 = si[5]; renderWord(fontPtr_Data + - si[0], - currentStrRenderBuffer, - drawPosPixel_X, - si[4] - si[3] + - lineHeight + heightOffset, - si[3], si[2], - renderBufferSize / 2, - stringWidth * 2, si[5]); + si[0], + currentStrRenderBuffer, + drawPosPixel_X, + si[4] - si[3] + + lineHeight + heightOffset, + si[3], si[2], + renderBufferSize / 2, + stringWidth * 2, si[5]); drawPosPixel_X += wordSpacingWidth + si[5]; @@ -489,9 +489,9 @@ void drawString(int32 x, int32 y, uint8 *string, uint8 *buffer, uint8 color, } gfxModuleData_field_64((char *)currentStrRenderBuffer, stringWidth, - stringHeight, (char *)buffer, x, y, 0); + stringHeight, (char *)buffer, x, y, 0); gfxModuleData_field_64((char *)currentStrRenderBuffer, stringWidth, - stringHeight, (char *)buffer, x, y, color); + stringHeight, (char *)buffer, x, y, color); if (needFlip) { gfxModuleData_flip(); @@ -541,13 +541,13 @@ gfxEntryStruct *renderText(int inRightBorder_X, const uint8 *string) { if (!fontPtr) { return NULL; } - fontPtr_Data = fontPtr + *(int16 *) (fontPtr + 4); // offset to char data + fontPtr_Data = fontPtr + *(int16 *)(fontPtr + 4); // offset to char data fontPtr_Desc = fontPtr + 14; // offset to char description - lineHeight = getLineHeight(*(int16 *) (fontPtr + 8), fontPtr, fontPtr_Desc); // ok + lineHeight = getLineHeight(*(int16 *)(fontPtr + 8), fontPtr, fontPtr_Desc); // ok - wordSpacingWidth = *(int16 *) (fontPtr + 10); - wordSpacingHeight = *(int16 *) (fontPtr + 12); + wordSpacingWidth = *(int16 *)(fontPtr + 10); + wordSpacingHeight = *(int16 *)(fontPtr + 12); // if right border is higher then screenwidth (+ spacing), adjust border if (inRightBorder_X > 310) { @@ -620,19 +620,19 @@ gfxEntryStruct *renderText(int inRightBorder_X, const uint8 *string) { drawPosPixel_X += wordSpacingWidth + 5; // if char = "space" adjust word starting postion (don't render space though); } else { if (charData >= 0) { - short int *si = (int16 *) (fontPtr_Desc + charData * 12); // offset font data + short int *si = (int16 *)(fontPtr_Desc + charData * 12); // offset font data // int var_2 = si[5]; // don't need this // should ist be stringRenderBufferSize/2 for the second last param? renderWord(fontPtr_Data + - si[0], - currentStrRenderBuffer, - drawPosPixel_X, - si[4] - si[3] + - lineHeight + heightOffset, - si[3], si[2], - stringRenderBufferSize, - stringWidth / 2, si[5]); + si[0], + currentStrRenderBuffer, + drawPosPixel_X, + si[4] - si[3] + + lineHeight + heightOffset, + si[3], si[2], + stringRenderBufferSize, + stringWidth / 2, si[5]); drawPosPixel_X += wordSpacingWidth + si[5]; diff --git a/engines/cruise/font.h b/engines/cruise/font.h index 26d73cb64a..4f210a5d89 100644 --- a/engines/cruise/font.h +++ b/engines/cruise/font.h @@ -42,11 +42,11 @@ int32 getLineHeight(int16 charCount, uint8 * fontPtr, uint8 * fontPrt_Desc); // int32 getTextLineCount(int32 rightBorder_X, int32 wordSpacingWidth, uint8 * ptr, const uint8 *textString); // fontProc2 void renderWord(uint8 * fontPtr_Data, uint8 * outBufferPtr, - int32 drawPosPixel_X, int32 heightOff, int32 height, int32 param4, - int32 stringRenderBufferSize, int32 width, int32 charWidth); + int32 drawPosPixel_X, int32 heightOff, int32 height, int32 param4, + int32 stringRenderBufferSize, int32 width, int32 charWidth); gfxEntryStruct *renderText(int inRightBorder_X, const uint8 *string); void drawString(int32 x, int32 y, uint8 * string, uint8 * buffer, uint8 color, - int32 inRightBorder_X); + int32 inRightBorder_X); } // End of namespace Cruise diff --git a/engines/cruise/function.cpp b/engines/cruise/function.cpp index b15c8fdb4f..a705f03efc 100644 --- a/engines/cruise/function.cpp +++ b/engines/cruise/function.cpp @@ -39,7 +39,7 @@ int16 Op_LoadOverlay(void) { pOverlayName = (char *) popPtr(); - if(strlen(pOverlayName) == 0) + if (strlen(pOverlayName) == 0) return 0; strcpy(overlayName, pOverlayName); @@ -123,7 +123,7 @@ int16 Op_AddProc(void) { int overlay; int param[160]; - for(long int i=0; i<pop1; i++) { + for (long int i = 0; i < pop1; i++) { param[i] = popVar(); } @@ -139,8 +139,8 @@ int16 Op_AddProc(void) { uint8* procBss = attacheNewScriptToTail(&procHead, overlay, pop2, currentScriptPtr->type, currentScriptPtr->scriptNumber, currentScriptPtr->overlayNumber, scriptType_PROC); if (procBss) { - for(long int i=0; i<pop1; i++) { - int16* ptr = (int16*)(procBss+i*2); + for (long int i = 0; i < pop1; i++) { + int16* ptr = (int16*)(procBss + i * 2); *ptr = param[i]; flipShort(ptr); } @@ -535,8 +535,8 @@ int16 Op_GetlowMemory(void) { } int16 Op_FadeOut(void) { - for(long int i=0; i< 256; i+=32) { - for(long int j=0; j<256; j++) { + for (long int i = 0; i < 256; i += 32) { + for (long int j = 0; j < 256; j++) { int offsetTable[3]; offsetTable[0] = -32; offsetTable[1] = -32; @@ -839,17 +839,15 @@ int16 Op_SetActiveBackground(void) { int16 Op_RemoveBackground(void) { int backgroundIdx = popVar(); - if(backgroundIdx > 0 && backgroundIdx < 8) { - if(backgroundPtrtable[backgroundIdx]) + if (backgroundIdx > 0 && backgroundIdx < 8) { + if (backgroundPtrtable[backgroundIdx]) free(backgroundPtrtable[backgroundIdx]); - if(masterScreen == backgroundIdx) + if (masterScreen == backgroundIdx) masterScreen = 0; strcpy(backgroundTable[backgroundIdx].name, ""); - } - else - { + } else { strcpy(backgroundTable[0].name, ""); } @@ -905,12 +903,12 @@ int16 Op_SetColor(void) { #define convertRatio 36.571428571428571428571428571429 - for (i=startIdx; i<=endIdx; i++) { + for (i = startIdx; i <= endIdx; i++) { int offsetTable[3]; - offsetTable[0] = (int)(colorR*convertRatio); - offsetTable[1] = (int)(colorG*convertRatio); - offsetTable[2] = (int)(colorB*convertRatio); + offsetTable[0] = (int)(colorR * convertRatio); + offsetTable[1] = (int)(colorG * convertRatio); + offsetTable[2] = (int)(colorB * convertRatio); if (CVTLoaded) { int colorIdx = cvtPalette[i]; @@ -953,7 +951,7 @@ int16 Op_ComputeLine(void) { point* pDest = (point*)popPtr(); - int maxValue = cor_droite( x1, y1, x2, y2, pDest); + int maxValue = cor_droite(x1, y1, x2, y2, pDest); flipGen(pDest, maxValue * 4); @@ -1005,7 +1003,7 @@ actorStruct *addAnimation(actorStruct * pHead, int overlay, int objIdx, int para } if (pCurrent && (pCurrent->overlayNumber == overlay) - && (pCurrent->idx == objIdx) && (pCurrent->type == param2)) { + && (pCurrent->idx == objIdx) && (pCurrent->type == param2)) { return NULL; } @@ -1054,8 +1052,8 @@ int removeAnimation(actorStruct * pHead, int overlay, int objIdx, int objType) { pl2 = pl; if (((pl->overlayNumber == overlay) || (overlay == -1)) && - ((pl->idx == objIdx) || (objIdx == -1)) && - ((pl->type == objType) || (objType == -1))) { + ((pl->idx == objIdx) || (objIdx == -1)) && + ((pl->type == objType) || (objType == -1))) { pl->type = -1; } @@ -1217,10 +1215,10 @@ int16 Op_BgName(void) { char* bgName = (char*)popPtr(); int bgIdx = popVar(); - if((bgIdx >= 0) && (bgIdx < 8) && bgName) { + if ((bgIdx >= 0) && (bgIdx < 8) && bgName) { strcpy(bgName, backgroundTable[bgIdx].name); - if(strlen(bgName)) + if (strlen(bgName)) return 1; return 0; @@ -1348,24 +1346,23 @@ int16 Op_Itoa(void) { char format[30]; char nbf[20]; - for(int i=nbp-1; i>= 0; i--) + for (int i = nbp - 1; i >= 0; i--) param[i] = popVar(); int val = popVar(); char* pDest = (char*)popPtr(); - if(!nbp) + if (!nbp) sprintf(txt, "%d", val); - else - { + else { strcpy(format, "%"); sprintf(nbf, "%d", param[0]); - strcat(format, nbf ); + strcat(format, nbf); strcat(format, "d"); sprintf(txt, format, val); } - for(int i=0; txt[i]; i++) + for (int i = 0; txt[i]; i++) *(pDest++) = txt[i]; *(pDest++) = '\0'; @@ -1376,10 +1373,10 @@ int16 Op_Strcat(void) { char *pSource = (char *)popPtr(); char *pDest = (char *)popPtr(); - while(*pDest) + while (*pDest) pDest++; - while(*pSource) + while (*pSource) *(pDest++) = *(pSource++); *(pDest++) = '\0'; @@ -1495,7 +1492,7 @@ int16 Op_DialogOn(void) { dialogueObj = popVar(); dialogueOvl = popVar(); - if(dialogueOvl == 0) + if (dialogueOvl == 0) dialogueOvl = currentScriptPtr->overlayNumber; dialogueEnabled = true; @@ -1508,7 +1505,7 @@ int16 Op_DialogOff(void) { objectReset(); - if(menuTable[0]) { + if (menuTable[0]) { freeMenu(menuTable[0]); menuTable[0] = NULL; changeCursor(CURSOR_NORMAL); @@ -1525,9 +1522,9 @@ int16 Op_LinkObjects(void) { int obj = popVar(); int ovl = popVar(); - if(!ovl) + if (!ovl) ovl = currentScriptPtr->overlayNumber; - if(!ovl2) + if (!ovl2) ovl2 = currentScriptPtr->overlayNumber; linkCell(&cellHead, ovl, obj, type, ovl2, obj2); @@ -1535,20 +1532,17 @@ int16 Op_LinkObjects(void) { return 0; } -int16 Op_UserDelay(void) -{ +int16 Op_UserDelay(void) { int delay = popVar(); - if(delay >= 0) - { + if (delay >= 0) { userDelay = delay; } return userDelay; } -int16 Op_UserWait(void) -{ +int16 Op_UserWait(void) { userWait = 1; if (currentScriptPtr->type == scriptType_PROC) { changeScriptParamInList(currentScriptPtr->overlayNumber, currentScriptPtr->scriptNumber, &procHead, -1, 9999); @@ -1559,8 +1553,7 @@ int16 Op_UserWait(void) return 0; } -opcodeFunction opcodeTablePtr[] = -{ +opcodeFunction opcodeTablePtr[] = { NULL, // 0x00 Op_FadeIn, Op_FadeOut, @@ -1699,107 +1692,107 @@ opcodeFunction opcodeTablePtr[] = void setupOpcodeTable(void) { // int i; -/* for (i = 0; i < 256; i++) { - opcodeTablePtr[i] = NULL; - } + /* for (i = 0; i < 256; i++) { + opcodeTablePtr[i] = NULL; + } - opcodeTablePtr[0x1] = Op_FadeIn; - opcodeTablePtr[0x2] = Op_FadeOut; - opcodeTablePtr[0x3] = Op_LoadBackground; - opcodeTablePtr[0x4] = Op_LoadAbs; - opcodeTablePtr[0x5] = Op_AddCell; - opcodeTablePtr[0x6] = Op_AddProc; - opcodeTablePtr[0x7] = Op_InitializeState; - opcodeTablePtr[0x8] = Op_RemoveCell; - opcodeTablePtr[0x9] = Op_FreeCell; - opcodeTablePtr[0xA] = Op_RemoveProc; - opcodeTablePtr[0xB] = Op_RemoveFrame; - opcodeTablePtr[0xC] = Op_LoadOverlay; - opcodeTablePtr[0xD] = Op_SetColor; - opcodeTablePtr[0xE] = Op_PlayFX; - opcodeTablePtr[0xF] = NULL; // used to be debug - opcodeTablePtr[0x10] = Op_FreeOverlay; - opcodeTablePtr[0x11] = Op_FindOverlay; - opcodeTablePtr[0x12] = NULL; // used to be exec debug - opcodeTablePtr[0x13] = Op_AddMessage; - opcodeTablePtr[0x14] = Op_RemoveMessage; - opcodeTablePtr[0x15] = Op_UserWait; - opcodeTablePtr[0x16] = Op_FreezeCell; - opcodeTablePtr[0x17] = Op_LoadCt; - opcodeTablePtr[0x18] = Op_AddAnimation; - opcodeTablePtr[0x19] = Op_RemoveAnimation; - opcodeTablePtr[0x1A] = Op_SetZoom; - opcodeTablePtr[0x1B] = Op_SetObjectAtNode; - opcodeTablePtr[0x1D] = Op_SetNodeColor; - opcodeTablePtr[0x1E] = Op_TrackAnim; - opcodeTablePtr[0x1F] = Op_GetNodeX; - opcodeTablePtr[0x20] = Op_GetNodeY; - opcodeTablePtr[0x21] = Op_EndAnim; - opcodeTablePtr[0x22] = Op_GetZoom; - opcodeTablePtr[0x23] = Op_GetStep; - opcodeTablePtr[0x24] = Op_SetStringColors; - opcodeTablePtr[0x28] = Op_UserOn; - opcodeTablePtr[0x29] = Op_FreeCT; - opcodeTablePtr[0x2A] = Op_FindObject; - opcodeTablePtr[0x2B] = Op_FindProc; - opcodeTablePtr[0x2C] = Op_WriteObject; - opcodeTablePtr[0x2E] = Op_RemoveOverlay; - opcodeTablePtr[0x2F] = Op_AddBackgroundIncrust; - opcodeTablePtr[0x30] = Op_RemoveBackgroundIncrust; - opcodeTablePtr[0x31] = Op_UnmergeBackgroundIncrust; - opcodeTablePtr[0x32] = Op_freeBackgroundInscrustList; - opcodeTablePtr[0x33] = Op_DialogOn; - opcodeTablePtr[0x34] = Op_DialogOff; - opcodeTablePtr[0x35] = Op_UserDelay; - opcodeTablePtr[0x37] = Op_Narrator; - opcodeTablePtr[0x38] = Op_RemoveBackground; - opcodeTablePtr[0x39] = Op_SetActiveBackground; - opcodeTablePtr[0x3A] = Op_CTOn; - opcodeTablePtr[0x3B] = Op_CTOff; - opcodeTablePtr[0x3C] = Op_Random; - opcodeTablePtr[0x3D] = Op_LoadSong; - opcodeTablePtr[0x3E] = Op_PlaySong; - opcodeTablePtr[0x3F] = Op_FadeSong; - opcodeTablePtr[0x40] = Op_FreeSong; - opcodeTablePtr[0x41] = Op_FrameExist; - opcodeTablePtr[0x43] = Op_SongExist; - opcodeTablePtr[0x45] = Op_StopSong; - opcodeTablePtr[0x4B] = Op_LinkObjects; - opcodeTablePtr[0x54] = Op_SetFont; - opcodeTablePtr[0x56] = Op_Display; - opcodeTablePtr[0x57] = Op_GetMouseX; - opcodeTablePtr[0x58] = Op_GetMouseY; - opcodeTablePtr[0x59] = Op_GetMouseButton; - opcodeTablePtr[0x5A] = Op_FindSet; - opcodeTablePtr[0x5B] = Op_regenerateBackgroundIncrust; - opcodeTablePtr[0x5C] = Op_BgName; - opcodeTablePtr[0x5E] = Op_StopFX; - opcodeTablePtr[0x60] = Op_FreezeAni; - opcodeTablePtr[0x61] = Op_FindMsg; - opcodeTablePtr[0x62] = Op_FreezeParent; - opcodeTablePtr[0x63] = Op_UnfreezeParent; - opcodeTablePtr[0x64] = Op_Exec; - opcodeTablePtr[0x65] = Op_AutoCell; - opcodeTablePtr[0x66] = Op_Sizeof; - opcodeTablePtr[0x67] = Op_Preload; - opcodeTablePtr[0x68] = Op_FreePreload; - opcodeTablePtr[0x6A] = Op_VBL; - opcodeTablePtr[0x6B] = Op_LoadFrame; - opcodeTablePtr[0x6C] = Op_FreezeOverlay; - opcodeTablePtr[0x6D] = Op_Strcpy; - opcodeTablePtr[0x6E] = Op_Strcat; - opcodeTablePtr[0x6F] = Op_Itoa; - opcodeTablePtr[0x70] = Op_comment; - opcodeTablePtr[0x71] = Op_ComputeLine; - opcodeTablePtr[0x72] = Op_FindSymbol; - opcodeTablePtr[0x73] = Op_SetXDial; - opcodeTablePtr[0x74] = Op_GetlowMemory; - opcodeTablePtr[0x76] = Op_Protect; - opcodeTablePtr[0x79] = Op_UserMenu; - opcodeTablePtr[0x78] = Op_Inventory; - opcodeTablePtr[0x7B] = Op_Sec; - opcodeTablePtr[0x7C] = Op_ProtectionFlag; - opcodeTablePtr[0x7D] = Op_KillMenu;*/ + opcodeTablePtr[0x1] = Op_FadeIn; + opcodeTablePtr[0x2] = Op_FadeOut; + opcodeTablePtr[0x3] = Op_LoadBackground; + opcodeTablePtr[0x4] = Op_LoadAbs; + opcodeTablePtr[0x5] = Op_AddCell; + opcodeTablePtr[0x6] = Op_AddProc; + opcodeTablePtr[0x7] = Op_InitializeState; + opcodeTablePtr[0x8] = Op_RemoveCell; + opcodeTablePtr[0x9] = Op_FreeCell; + opcodeTablePtr[0xA] = Op_RemoveProc; + opcodeTablePtr[0xB] = Op_RemoveFrame; + opcodeTablePtr[0xC] = Op_LoadOverlay; + opcodeTablePtr[0xD] = Op_SetColor; + opcodeTablePtr[0xE] = Op_PlayFX; + opcodeTablePtr[0xF] = NULL; // used to be debug + opcodeTablePtr[0x10] = Op_FreeOverlay; + opcodeTablePtr[0x11] = Op_FindOverlay; + opcodeTablePtr[0x12] = NULL; // used to be exec debug + opcodeTablePtr[0x13] = Op_AddMessage; + opcodeTablePtr[0x14] = Op_RemoveMessage; + opcodeTablePtr[0x15] = Op_UserWait; + opcodeTablePtr[0x16] = Op_FreezeCell; + opcodeTablePtr[0x17] = Op_LoadCt; + opcodeTablePtr[0x18] = Op_AddAnimation; + opcodeTablePtr[0x19] = Op_RemoveAnimation; + opcodeTablePtr[0x1A] = Op_SetZoom; + opcodeTablePtr[0x1B] = Op_SetObjectAtNode; + opcodeTablePtr[0x1D] = Op_SetNodeColor; + opcodeTablePtr[0x1E] = Op_TrackAnim; + opcodeTablePtr[0x1F] = Op_GetNodeX; + opcodeTablePtr[0x20] = Op_GetNodeY; + opcodeTablePtr[0x21] = Op_EndAnim; + opcodeTablePtr[0x22] = Op_GetZoom; + opcodeTablePtr[0x23] = Op_GetStep; + opcodeTablePtr[0x24] = Op_SetStringColors; + opcodeTablePtr[0x28] = Op_UserOn; + opcodeTablePtr[0x29] = Op_FreeCT; + opcodeTablePtr[0x2A] = Op_FindObject; + opcodeTablePtr[0x2B] = Op_FindProc; + opcodeTablePtr[0x2C] = Op_WriteObject; + opcodeTablePtr[0x2E] = Op_RemoveOverlay; + opcodeTablePtr[0x2F] = Op_AddBackgroundIncrust; + opcodeTablePtr[0x30] = Op_RemoveBackgroundIncrust; + opcodeTablePtr[0x31] = Op_UnmergeBackgroundIncrust; + opcodeTablePtr[0x32] = Op_freeBackgroundInscrustList; + opcodeTablePtr[0x33] = Op_DialogOn; + opcodeTablePtr[0x34] = Op_DialogOff; + opcodeTablePtr[0x35] = Op_UserDelay; + opcodeTablePtr[0x37] = Op_Narrator; + opcodeTablePtr[0x38] = Op_RemoveBackground; + opcodeTablePtr[0x39] = Op_SetActiveBackground; + opcodeTablePtr[0x3A] = Op_CTOn; + opcodeTablePtr[0x3B] = Op_CTOff; + opcodeTablePtr[0x3C] = Op_Random; + opcodeTablePtr[0x3D] = Op_LoadSong; + opcodeTablePtr[0x3E] = Op_PlaySong; + opcodeTablePtr[0x3F] = Op_FadeSong; + opcodeTablePtr[0x40] = Op_FreeSong; + opcodeTablePtr[0x41] = Op_FrameExist; + opcodeTablePtr[0x43] = Op_SongExist; + opcodeTablePtr[0x45] = Op_StopSong; + opcodeTablePtr[0x4B] = Op_LinkObjects; + opcodeTablePtr[0x54] = Op_SetFont; + opcodeTablePtr[0x56] = Op_Display; + opcodeTablePtr[0x57] = Op_GetMouseX; + opcodeTablePtr[0x58] = Op_GetMouseY; + opcodeTablePtr[0x59] = Op_GetMouseButton; + opcodeTablePtr[0x5A] = Op_FindSet; + opcodeTablePtr[0x5B] = Op_regenerateBackgroundIncrust; + opcodeTablePtr[0x5C] = Op_BgName; + opcodeTablePtr[0x5E] = Op_StopFX; + opcodeTablePtr[0x60] = Op_FreezeAni; + opcodeTablePtr[0x61] = Op_FindMsg; + opcodeTablePtr[0x62] = Op_FreezeParent; + opcodeTablePtr[0x63] = Op_UnfreezeParent; + opcodeTablePtr[0x64] = Op_Exec; + opcodeTablePtr[0x65] = Op_AutoCell; + opcodeTablePtr[0x66] = Op_Sizeof; + opcodeTablePtr[0x67] = Op_Preload; + opcodeTablePtr[0x68] = Op_FreePreload; + opcodeTablePtr[0x6A] = Op_VBL; + opcodeTablePtr[0x6B] = Op_LoadFrame; + opcodeTablePtr[0x6C] = Op_FreezeOverlay; + opcodeTablePtr[0x6D] = Op_Strcpy; + opcodeTablePtr[0x6E] = Op_Strcat; + opcodeTablePtr[0x6F] = Op_Itoa; + opcodeTablePtr[0x70] = Op_comment; + opcodeTablePtr[0x71] = Op_ComputeLine; + opcodeTablePtr[0x72] = Op_FindSymbol; + opcodeTablePtr[0x73] = Op_SetXDial; + opcodeTablePtr[0x74] = Op_GetlowMemory; + opcodeTablePtr[0x76] = Op_Protect; + opcodeTablePtr[0x79] = Op_UserMenu; + opcodeTablePtr[0x78] = Op_Inventory; + opcodeTablePtr[0x7B] = Op_Sec; + opcodeTablePtr[0x7C] = Op_ProtectionFlag; + opcodeTablePtr[0x7D] = Op_KillMenu;*/ // TODO: copy the opcodes here } @@ -1813,8 +1806,8 @@ int32 opcodeType8(void) { return (-21); if (opcode < ARRAYSIZE(opcodeTablePtr) && opcodeTablePtr[opcode]) { - // printf("Function: %d\n",opcode); - pushVar(opcodeTablePtr[opcode] ()); + // printf("Function: %d\n",opcode); + pushVar(opcodeTablePtr[opcode]()); return (0); } else { printf("Unsupported opcode %d in opcode type 8\n", opcode); diff --git a/engines/cruise/gfxModule.cpp b/engines/cruise/gfxModule.cpp index 8ba65680fa..2ffd0a08f2 100644 --- a/engines/cruise/gfxModule.cpp +++ b/engines/cruise/gfxModule.cpp @@ -64,7 +64,7 @@ void outputBit(char *buffer, int bitPlaneNumber, uint8 data) { void convertGfxFromMode4(uint8 *sourcePtr, int width, int height, uint8 *destPtr) { for (int y = 0; y < height; ++y) { - for (int x = 0; x < width/16; ++x) { + for (int x = 0; x < width / 16; ++x) { for (int bit = 0; bit < 16; ++bit) { uint8 color = 0; for (int p = 0; p < 4; ++p) { @@ -80,17 +80,17 @@ void convertGfxFromMode4(uint8 *sourcePtr, int width, int height, uint8 *destPtr } void convertGfxFromMode5(uint8 *sourcePtr, int width, int height, uint8 *destPtr) { - int range = (width/8) * height; + int range = (width / 8) * height; - for(int line = 0; line < 200; line++) { + for (int line = 0; line < 200; line++) { uint8 p0; uint8 p1; uint8 p2; uint8 p3; uint8 p4; - for(int col = 0; col < 40; col++) { - for(int bit = 0; bit <8; bit++ ) { + for (int col = 0; col < 40; col++) { + for (int bit = 0; bit < 8; bit++) { p0 = (sourcePtr[line*40 + col + range * 0] >> bit) & 1; p1 = (sourcePtr[line*40 + col + range * 1] >> bit) & 1; p2 = (sourcePtr[line*40 + col + range * 2] >> bit) & 1; @@ -236,7 +236,7 @@ void flip() { paletteRGBA[i * 4 + 2] = lpalette[i].B; paletteRGBA[i * 4 + 3] = 0xFF; } - g_system->setPalette(paletteRGBA+palDirtyMin*4, palDirtyMin, palDirtyMax - palDirtyMin + 1); + g_system->setPalette(paletteRGBA + palDirtyMin*4, palDirtyMin, palDirtyMax - palDirtyMin + 1); palDirtyMin = 256; palDirtyMax = -1; } @@ -248,7 +248,7 @@ void flip() { if (!bFastMode) { uint32 speed = 50; - if(lastTick + speed > currentTick) { + if (lastTick + speed > currentTick) { g_system->delayMillis(lastTick + speed - currentTick); } } diff --git a/engines/cruise/linker.cpp b/engines/cruise/linker.cpp index 748a5f6053..d7268c2f02 100644 --- a/engines/cruise/linker.cpp +++ b/engines/cruise/linker.cpp @@ -154,7 +154,7 @@ int updateScriptImport(int ovlIdx) { pScript = scriptFunc1Sub2(ovlIdx, i); } - ptrImportData = (importScriptStruct *) (pScript->dataPtr + pScript->offsetToImportData); // import data + ptrImportData = (importScriptStruct *)(pScript->dataPtr + pScript->offsetToImportData); // import data ptrImportName = (const char*)(pScript->dataPtr + pScript->offsetToImportName); // import name ptrData = pScript->dataPtr; @@ -213,17 +213,17 @@ int updateScriptImport(int ovlIdx) { *(ptrData + temp) = param2; *(ptrData + temp + 1) = out2; - *(int16 *) (ptrData + temp + 2) = ptrDest2->idx; + *(int16 *)(ptrData + temp + 2) = ptrDest2->idx; flipShort - ( + ( (int16 - *) + *) (ptrData - + - temp - + - 2)); + + + temp + + + 2)); } } } @@ -259,24 +259,21 @@ int updateScriptImport(int ovlIdx) { if (pFoundExport && foundExportIdx) { switch (linkType) { - case 0: // verb - { - ovlData->arrayMsgRelHeader[linkEntryIdx].verbOverlay = foundExportIdx; - ovlData->arrayMsgRelHeader[linkEntryIdx].verbNumber = pFoundExport->idx; - break; - } - case 1: // obj1 - { - ovlData->arrayMsgRelHeader[linkEntryIdx].obj1Overlay = foundExportIdx; - ovlData->arrayMsgRelHeader[linkEntryIdx].obj1Number = pFoundExport->idx; - break; - } - case 2: // obj2 - { - ovlData->arrayMsgRelHeader[linkEntryIdx].obj2Overlay = foundExportIdx; - ovlData->arrayMsgRelHeader[linkEntryIdx].obj2Number = pFoundExport->idx; - break; - } + case 0: { // verb + ovlData->arrayMsgRelHeader[linkEntryIdx].verbOverlay = foundExportIdx; + ovlData->arrayMsgRelHeader[linkEntryIdx].verbNumber = pFoundExport->idx; + break; + } + case 1: { // obj1 + ovlData->arrayMsgRelHeader[linkEntryIdx].obj1Overlay = foundExportIdx; + ovlData->arrayMsgRelHeader[linkEntryIdx].obj1Number = pFoundExport->idx; + break; + } + case 2: { // obj2 + ovlData->arrayMsgRelHeader[linkEntryIdx].obj2Overlay = foundExportIdx; + ovlData->arrayMsgRelHeader[linkEntryIdx].obj2Number = pFoundExport->idx; + break; + } } } } diff --git a/engines/cruise/mainDraw.cpp b/engines/cruise/mainDraw.cpp index 1a1be3940b..a42800994a 100644 --- a/engines/cruise/mainDraw.cpp +++ b/engines/cruise/mainDraw.cpp @@ -82,14 +82,14 @@ void freeAutoCell(void) { } void calcRGB(uint8* pColorSrc, uint8* pColorDst, int* offsetTable) { - for(unsigned long int i=0; i<3; i++) { + for (unsigned long int i = 0; i < 3; i++) { int color = *(pColorSrc++); int offset = offsetTable[i]; color += offset; - if(color < 0) + if (color < 0) color = 0; - if(color > 0xFF) + if (color > 0xFF) color = 0xFF; *(pColorDst++) = (uint8)color; @@ -97,8 +97,8 @@ void calcRGB(uint8* pColorSrc, uint8* pColorDst, int* offsetTable) { } void fadeIn() { - for(long int i=256; i>=0; i-=32) { - for(long int j=0; j<256; j++) { + for (long int i = 256; i >= 0; i -= 32) { + for (long int j = 0; j < 256; j++) { int offsetTable[3]; offsetTable[0] = -i; offsetTable[1] = -i; @@ -109,7 +109,7 @@ void fadeIn() { gfxModuleData_flipScreen(); } - for(long int j=0; j<256; j++) { + for (long int j = 0; j < 256; j++) { int offsetTable[3]; offsetTable[0] = 0; offsetTable[1] = 0; @@ -124,8 +124,8 @@ void fadeIn() { } void flipScreen(void) { - if(switchPal) { - for(unsigned long int i=0; i<256*3; i++) { + if (switchPal) { + for (unsigned long int i = 0; i < 256*3; i++) { workpal[i] = palScreen[masterScreen][i]; } switchPal = 0; @@ -136,7 +136,7 @@ void flipScreen(void) { gfxModuleData_flipScreen(); - if(doFade) { + if (doFade) { fadeIn(); doFade = 0; } @@ -174,7 +174,7 @@ void flipPoly(int fileId, int16 *dataPtr, int scale, char** newFrame, int X, int offset += fileId; - if (offset >= 0 ) { + if (offset >= 0) { if (filesDatabase[offset].resType == 0 && filesDatabase[offset].subData.ptr) { dataPtr = (int16 *)filesDatabase[offset].subData.ptr; } @@ -277,15 +277,13 @@ int16 nbligne; void blitPolyMode1(char *dest, char *pMask, int16 * buffer, char color) { int Y = XMIN_XMAX[0]; - for (int i=0; i<nbligne; i++) { - int currentY = Y+i; + for (int i = 0; i < nbligne; i++) { + int currentY = Y + i; int XMIN = XMIN_XMAX[1+i*2]; int XMAX = XMIN_XMAX[1+i*2+1]; - for(int x=XMIN; x<=XMAX; x++) - { - if(testMask(x, currentY, (unsigned char*)pMask, 40)) - { + for (int x = XMIN; x <= XMAX; x++) { + if (testMask(x, currentY, (unsigned char*)pMask, 40)) { *(dest + currentY * 320 + x) = color; } } @@ -296,13 +294,12 @@ void blitPolyMode1(char *dest, char *pMask, int16 * buffer, char color) { void blitPolyMode2(char *dest, int16 * buffer, char color) { int Y = XMIN_XMAX[0]; - for (int i=0; i<nbligne; i++) { - int currentY = Y+i; + for (int i = 0; i < nbligne; i++) { + int currentY = Y + i; int XMIN = XMIN_XMAX[1+i*2]; int XMAX = XMIN_XMAX[1+i*2+1]; - for(int x=XMIN; x<=XMAX; x++) - { + for (int x = XMIN; x <= XMAX; x++) { *(dest + currentY * 320 + x) = color; } } @@ -329,14 +326,14 @@ void buildSegment(void) { if (polyYMin == polyYMax) { // line *(pOut++) = polyYMin; // store initial Y - int cx = nbseg-1; + int cx = nbseg - 1; int16* pIn = A2ptr; int XLeft; int XRight; XLeft = XRight = *pIn; // init to first X - pIn+=2; + pIn += 2; do { int X = *pIn; @@ -344,7 +341,7 @@ void buildSegment(void) { XLeft = X; if (XRight < X) XRight = X; - pIn+=2; + pIn += 2; } while (--cx); // now store left and right coordinates in XMIN_XMAX @@ -396,7 +393,7 @@ void buildSegment(void) { do { si[0] = 5000; si[1] = -5000; - si+=2; + si += 2; } while (--tempCount); int16* di = A2ptr; @@ -431,8 +428,8 @@ void buildSegment(void) { if (DX > 319) DX = 319; - int16* BX = XMIN_XMAX + (Y2 - ydep) * 2 +1; - int16* DI = XMIN_XMAX + (Y1 - ydep) * 2 +1; + int16* BX = XMIN_XMAX + (Y2 - ydep) * 2 + 1; + int16* DI = XMIN_XMAX + (Y1 - ydep) * 2 + 1; if (Y2 >= Y1) { SWAP(BX, DI); @@ -447,24 +444,24 @@ void buildSegment(void) { BX[1] = DX; } - BX+=2; + BX += 2; } while (BX <= DI); } else { - if ( cx < 0 ) { + if (cx < 0) { cx = -cx; dx = Y2; SWAP(X1, X2); SWAP(Y1, Y2); } - // swap again ? + // swap again ? SWAP(X1, X2); int patchAdd = 2; int dy = Y2 - Y1; - if ( dy == 0 ) { + if (dy == 0) { // hline int16* ptr = (Y1 - ydep) * 2 + XMIN_XMAX + 1; @@ -484,7 +481,7 @@ void buildSegment(void) { ptr[1] = SI; } } else { - if ( dy < 0 ) { + if (dy < 0) { dy = -dy; patchAdd = -2; } @@ -496,7 +493,7 @@ void buildSegment(void) { SWAP(dy, cx); } - int patchinc1 = 2*dy; + int patchinc1 = 2 * dy; int d = 2 * dy - cx; int bx = 2 * (dy - cx); @@ -505,7 +502,7 @@ void buildSegment(void) { cx++; // cx is the number of pixels to trace - int16* ptr = (Y1 - ydep)*2 + XMIN_XMAX + 1; + int16* ptr = (Y1 - ydep) * 2 + XMIN_XMAX + 1; if (stepType == 0) { // small step @@ -539,7 +536,7 @@ void buildSegment(void) { if (d < 0) { d += patchinc1; - if ( cx == 1 ) { // last ? + if (cx == 1) { // last ? if ((ptr <= ptrMax) && (ptr >= ptrMini)) { // are we in screen ? if (SI < ptr[0]) ptr[0] = SI; @@ -550,7 +547,7 @@ void buildSegment(void) { } } else { d += patchinc2; - ptr+=patchAdd; + ptr += patchAdd; } } while (--cx); } else { @@ -596,7 +593,7 @@ void buildSegment(void) { } } - di+=2; + di += 2; } while (--segCount); } @@ -825,13 +822,13 @@ void buildPolyModel(int positionX, int positionY, int scale, char *pMask, char * do { int linesToDraw = *dataPointer++; - if (linesToDraw > 1){ // if value not zero + if (linesToDraw > 1) { // if value not zero uint16 minimumScale; m_color = *dataPointer; // color dataPointer += 2; - minimumScale = *(uint16 *) (dataPointer); + minimumScale = *(uint16 *)(dataPointer); dataPointer += 2; flipShort(&minimumScale); @@ -986,13 +983,13 @@ bool findPoly(char* dataPtr, int positionX, int positionY, int scale, int mouseX do { int linesToDraw = *dataPointer++; - if (linesToDraw > 1){ // if value not zero + if (linesToDraw > 1) { // if value not zero uint16 minimumScale; m_color = *dataPointer; // color dataPointer += 2; - minimumScale = *(uint16 *) (dataPointer); + minimumScale = *(uint16 *)(dataPointer); dataPointer += 2; flipShort(&minimumScale); @@ -1029,9 +1026,8 @@ bool findPoly(char* dataPtr, int positionX, int positionY, int scale, int mouseX return false; } -void clearMaskBit(int x, int y, unsigned char* pData, int stride) -{ - unsigned char* ptr = y * stride + x/8 + pData; +void clearMaskBit(int x, int y, unsigned char* pData, int stride) { + unsigned char* ptr = y * stride + x / 8 + pData; unsigned char bitToTest = 0x80 >> (x & 7); @@ -1039,18 +1035,14 @@ void clearMaskBit(int x, int y, unsigned char* pData, int stride) } -void drawMask(unsigned char* workBuf, int wbWidth, int wbHeight, unsigned char* pMask, int maskWidth, int maskHeight, int maskX, int maskY, int passIdx) -{ - for(int y=0; y<maskHeight; y++) - { - for(int x=0; x<maskWidth*8; x++) - { - if(testMask(x,y, pMask, maskWidth)) - { +void drawMask(unsigned char* workBuf, int wbWidth, int wbHeight, unsigned char* pMask, int maskWidth, int maskHeight, int maskX, int maskY, int passIdx) { + for (int y = 0; y < maskHeight; y++) { + for (int x = 0; x < maskWidth*8; x++) { + if (testMask(x, y, pMask, maskWidth)) { int destX = maskX + x; int destY = maskY + y; - if((destX >= 0) && (destX < wbWidth*8) && (destY >= 0) && (destY < wbHeight)) + if ((destX >= 0) && (destX < wbWidth*8) && (destY >= 0) && (destY < wbHeight)) clearMaskBit(destX, destY, workBuf, wbWidth); } } @@ -1110,14 +1102,12 @@ void mainDrawPolygons(int fileIndex, cellStruct *plWork, int X, int scale, int Y var_8 = 0; - memset(polygonMask, 0xFF, (320*200)/8); + memset(polygonMask, 0xFF, (320*200) / 8); int numPasses = 0; - while(plWork) - { - if(plWork->type == OBJ_TYPE_BGMK && plWork->freeze == 0) - { + while (plWork) { + if (plWork->type == OBJ_TYPE_BGMK && plWork->freeze == 0) { objectParamsQuery params; getMultipleObjectParam(plWork->overlay, plWork->idx, ¶ms); @@ -1126,15 +1116,12 @@ void mainDrawPolygons(int fileIndex, cellStruct *plWork, int X, int scale, int Y int maskY = params.Y; int maskFrame = params.fileIdx; - if(filesDatabase[maskFrame].subData.resourceType == OBJ_TYPE_BGMK && filesDatabase[maskFrame].subData.ptrMask) - { - drawMask(polygonMask, 40, 200, filesDatabase[maskFrame].subData.ptrMask, filesDatabase[maskFrame].width/8, filesDatabase[maskFrame].height, maskX, maskY, numPasses++); - } - else - if(filesDatabase[maskFrame].subData.resourceType == OBJ_TYPE_SPRITE && filesDatabase[maskFrame].subData.ptrMask) - { - drawMask(polygonMask, 40, 200, filesDatabase[maskFrame].subData.ptrMask, filesDatabase[maskFrame].width/8, filesDatabase[maskFrame].height, maskX, maskY, numPasses++); - } + if (filesDatabase[maskFrame].subData.resourceType == OBJ_TYPE_BGMK && filesDatabase[maskFrame].subData.ptrMask) { + drawMask(polygonMask, 40, 200, filesDatabase[maskFrame].subData.ptrMask, filesDatabase[maskFrame].width / 8, filesDatabase[maskFrame].height, maskX, maskY, numPasses++); + } else + if (filesDatabase[maskFrame].subData.resourceType == OBJ_TYPE_SPRITE && filesDatabase[maskFrame].subData.ptrMask) { + drawMask(polygonMask, 40, 200, filesDatabase[maskFrame].subData.ptrMask, filesDatabase[maskFrame].width / 8, filesDatabase[maskFrame].height, maskX, maskY, numPasses++); + } } @@ -1158,13 +1145,13 @@ void drawMessage(gfxEntryStruct *pGfxPtr, int globalX, int globalY, int width, i uint8 *ptr = pGfxPtr->imagePtr; int height = pGfxPtr->height; - if (width>310) + if (width > 310) width = 310; - if(width+globalX>319) + if (width + globalX > 319) globalX = 319 - width; - if(globalY < 0) + if (globalY < 0) globalY = 0; - if(globalX < 0) + if (globalX < 0) globalX = 0; if (globalY + pGfxPtr->height >= 198) { @@ -1202,17 +1189,15 @@ void drawSprite(int objX1, int var_6, cellStruct *currentObjPtr, char *data1, in int y = 0; cellStruct* plWork = currentObjPtr; - int workBufferSize = var_6 * (objX1/8); + int workBufferSize = var_6 * (objX1 / 8); - unsigned char* workBuf= (unsigned char*)malloc(workBufferSize); + unsigned char* workBuf = (unsigned char*)malloc(workBufferSize); memcpy(workBuf, data2, workBufferSize); int numPasses = 0; - while(plWork) - { - if(plWork->type == OBJ_TYPE_BGMK && plWork->freeze == 0) - { + while (plWork) { + if (plWork->type == OBJ_TYPE_BGMK && plWork->freeze == 0) { objectParamsQuery params; getMultipleObjectParam(plWork->overlay, plWork->idx, ¶ms); @@ -1221,15 +1206,12 @@ void drawSprite(int objX1, int var_6, cellStruct *currentObjPtr, char *data1, in int maskY = params.Y; int maskFrame = params.fileIdx; - if(filesDatabase[maskFrame].subData.resourceType == OBJ_TYPE_BGMK && filesDatabase[maskFrame].subData.ptrMask) - { - drawMask(workBuf, objX1/8, var_6, filesDatabase[maskFrame].subData.ptrMask, filesDatabase[maskFrame].width/8, filesDatabase[maskFrame].height, maskX - objX2, maskY - objY2, numPasses++); - } - else - if(filesDatabase[maskFrame].subData.resourceType == OBJ_TYPE_SPRITE && filesDatabase[maskFrame].subData.ptrMask) - { - drawMask(workBuf, objX1/8, var_6, filesDatabase[maskFrame].subData.ptrMask, filesDatabase[maskFrame].width/8, filesDatabase[maskFrame].height, maskX - objX2, maskY - objY2, numPasses++); - } + if (filesDatabase[maskFrame].subData.resourceType == OBJ_TYPE_BGMK && filesDatabase[maskFrame].subData.ptrMask) { + drawMask(workBuf, objX1 / 8, var_6, filesDatabase[maskFrame].subData.ptrMask, filesDatabase[maskFrame].width / 8, filesDatabase[maskFrame].height, maskX - objX2, maskY - objY2, numPasses++); + } else + if (filesDatabase[maskFrame].subData.resourceType == OBJ_TYPE_SPRITE && filesDatabase[maskFrame].subData.ptrMask) { + drawMask(workBuf, objX1 / 8, var_6, filesDatabase[maskFrame].subData.ptrMask, filesDatabase[maskFrame].width / 8, filesDatabase[maskFrame].height, maskX - objX2, maskY - objY2, numPasses++); + } } @@ -1242,7 +1224,7 @@ void drawSprite(int objX1, int var_6, cellStruct *currentObjPtr, char *data1, in data1++; if ((x + objX2) >= 0 && (x + objX2) < 320 && (y + objY2) >= 0 && (y + objY2) < 200) { - if(testMask(x, y, workBuf, objX1/8)) { + if (testMask(x, y, workBuf, objX1 / 8)) { output[320 * (y + objY2) + x + objX2] = color; } } @@ -1254,30 +1236,30 @@ void drawSprite(int objX1, int var_6, cellStruct *currentObjPtr, char *data1, in #ifdef _DEBUG void drawCtp(void) { -/* int i; - - if (ctp_walkboxTable) { - for (i = 0; i < 15; i++) { - uint16 *dataPtr = &ctp_walkboxTable[i * 40]; - int type = walkboxColor[i]; // show different types in different colors - - if (*dataPtr) { - int j; - fillpoly((short *)dataPtr + 1, *dataPtr, type); + /* int i; + + if (ctp_walkboxTable) { + for (i = 0; i < 15; i++) { + uint16 *dataPtr = &ctp_walkboxTable[i * 40]; + int type = walkboxColor[i]; // show different types in different colors + + if (*dataPtr) { + int j; + fillpoly((short *)dataPtr + 1, *dataPtr, type); + + for (j = 0; j < (*dataPtr - 1); j++) { + line(dataPtr[1 + j * 2], + dataPtr[1 + j * 2 + 1], + dataPtr[1 + (j + 1) * 2], + dataPtr[1 + (j + 1) * 2 + 1], 0); + } - for (j = 0; j < (*dataPtr - 1); j++) { line(dataPtr[1 + j * 2], - dataPtr[1 + j * 2 + 1], - dataPtr[1 + (j + 1) * 2], - dataPtr[1 + (j + 1) * 2 + 1], 0); + dataPtr[1 + j * 2 + 1], dataPtr[1], + dataPtr[2], 0); } - - line(dataPtr[1 + j * 2], - dataPtr[1 + j * 2 + 1], dataPtr[1], - dataPtr[2], 0); } - } - }*/ + }*/ } #endif @@ -1285,7 +1267,7 @@ void drawMenu(menuStruct *pMenu) { if (pMenu == NULL) return; - if(pMenu->numElements == 0) + if (pMenu->numElements == 0) return; int hline = pMenu->gfx->height; @@ -1298,7 +1280,7 @@ void drawMenu(menuStruct *pMenu) { if (!nbcol) { nbcol++; - if (y+pMenu->numElements*hline > 199-hline) { + if (y + pMenu->numElements*hline > 199 - hline) { y = 200 - (pMenu->numElements * hline) - hline; } } else { @@ -1309,13 +1291,13 @@ void drawMenu(menuStruct *pMenu) { y = hline; } - if (x > (320-(nbcol*160))) - x = 320-(nbcol*160); + if (x > (320 - (nbcol*160))) + x = 320 - (nbcol * 160); if (x < 0) x = 0; - int wx = x + (nbcol - 1) * (160/2); + int wx = x + (nbcol - 1) * (160 / 2); if (wx <= 320 - 160) { drawMessage(pMenu->gfx, wx, y - hline, 160, titleColor, gfxModuleData.pPage10); @@ -1326,7 +1308,7 @@ void drawMenu(menuStruct *pMenu) { int wc = 0; menuElementStruct* p1 = pMenu->ptrNextElement; - while(p1) { + while (p1) { gfxEntryStruct *p2 = p1->gfx; p1->x = wx; @@ -1345,7 +1327,7 @@ void drawMenu(menuStruct *pMenu) { } } - if (wx <= (320-160)) { + if (wx <= (320 - 160)) { drawMessage(p2, wx, wy, 160, color, gfxModuleData.pPage10); } @@ -1414,8 +1396,8 @@ void mainDraw(int16 param) { currentObjPtr = cellHead.next; #ifdef _DEBUG -/* polyOutputBuffer = (char*)bgPtr; - drawCtp(); */ + /* polyOutputBuffer = (char*)bgPtr; + drawCtp(); */ #endif //-------------------------------------------------- PROCESS SPRITES -----------------------------------------// @@ -1461,7 +1443,7 @@ void mainDraw(int16 param) { spriteHeight = filesDatabase[objZ2].height; // height if (filesDatabase[objZ2].subData.ptr) { - drawSprite(objX1, spriteHeight, currentObjPtr, (char *)filesDatabase[objZ2].subData.ptr, objY2, objX2,(char *)gfxModuleData.pPage10,(char *)filesDatabase[objZ2].subData.ptrMask); + drawSprite(objX1, spriteHeight, currentObjPtr, (char *)filesDatabase[objZ2].subData.ptr, objY2, objX2, (char *)gfxModuleData.pPage10, (char *)filesDatabase[objZ2].subData.ptrMask); } } } @@ -1478,7 +1460,7 @@ void mainDraw(int16 param) { if (newVal > currentObjPtr->animEnd) { if (currentObjPtr->animLoop) { newVal = currentObjPtr->animStart; - if (currentObjPtr->animLoop>0) + if (currentObjPtr->animLoop > 0) currentObjPtr->animLoop--; } else { int16 data2; @@ -1500,7 +1482,7 @@ void mainDraw(int16 param) { if (newVal < currentObjPtr->animEnd) { if (currentObjPtr->animLoop) { newVal = currentObjPtr->animStart; - if (currentObjPtr->animLoop>0) + if (currentObjPtr->animLoop > 0) currentObjPtr->animLoop--; } else { int16 data2; @@ -1576,7 +1558,7 @@ void mainDraw(int16 param) { int16 button; getMouseStatus(&main10, &mouseX, &button, &mouseY); - if(mouseY>(linkedMsgList->height)*2) + if (mouseY > (linkedMsgList->height)*2) drawMessage(linkedMsgList, 0, 0, 320, findHighColor(), gfxModuleData.pPage10); else drawMessage(linkedMsgList, 0, 200, 320, findHighColor(), gfxModuleData.pPage10); diff --git a/engines/cruise/menu.cpp b/engines/cruise/menu.cpp index fde385b574..8553cb35c2 100644 --- a/engines/cruise/menu.cpp +++ b/engines/cruise/menu.cpp @@ -35,7 +35,7 @@ menuStruct *createMenu(int X, int Y, const char *menuName) { entry = (menuStruct *) malloc(sizeof(menuStruct)); ASSERT(entry); - entry->x = X - 160/2; + entry->x = X - 160 / 2; entry->y = Y; entry->stringPtr = menuName; entry->numElements = 0; @@ -79,7 +79,7 @@ void addSelectableMenuEntry(int ovlIdx, int headerIdx, menuStruct *pMenu, int pa if (pSubStructCurrent->pNext) { do { pSubStructCurrent = pSubStructCurrent->pNext; - } while(pSubStructCurrent->pNext); + } while (pSubStructCurrent->pNext); } pSubStructCurrent->pNext = pSubStruct; @@ -87,8 +87,7 @@ void addSelectableMenuEntry(int ovlIdx, int headerIdx, menuStruct *pMenu, int pa } } var_6 = var_6->next; - } - while (var_6); + } while (var_6); var_6 = di; } @@ -187,13 +186,12 @@ int processMenu(menuStruct *pMenu) { mainDraw(1); flipScreen(); - if( mouseButton & 1) { + if (mouseButton & 1) { menuElementSubStruct* pSelectedEntry = getSelectedEntryInMenu(pMenu); - if(pSelectedEntry) { + if (pSelectedEntry) { return pSelectedEntry->header; - } - else { + } else { return -1; } } @@ -212,29 +210,29 @@ int playerMenu(int menuX, int menuY) { playMusic = 0; freeStuff2(); } -/* - if (currentMenu) { - freeMenu(currentMenu); - currentMenu = 0; - selectDown = 0; - menuDown = 0; - main9 = -1; - } - - if (inventoryMenu) { - freeMenu(inventoryMenu); - inventoryMenu = 0; - selectDown = 0; - menuDown = 0; - main9 = -1; - }*/ - -/* if (mouseVar2) { - free3(mouseVar2); - } */ - -/* mouseVar2 = 0; - linkedRelation = 0; */ + /* + if (currentMenu) { + freeMenu(currentMenu); + currentMenu = 0; + selectDown = 0; + menuDown = 0; + main9 = -1; + } + + if (inventoryMenu) { + freeMenu(inventoryMenu); + inventoryMenu = 0; + selectDown = 0; + menuDown = 0; + main9 = -1; + }*/ + + /* if (mouseVar2) { + free3(mouseVar2); + } */ + + /* mouseVar2 = 0; + linkedRelation = 0; */ freeDisk(); menuTable[0] = createMenu(menuX, menuY, "Menu Joueur"); @@ -253,8 +251,7 @@ int playerMenu(int menuX, int menuY) { freeMenu(menuTable[0]); menuTable[0] = NULL; - switch(retourMenu) - { + switch (retourMenu) { case 3: // select save drive break; case 4: // save diff --git a/engines/cruise/menu.h b/engines/cruise/menu.h index 4e15d15cf1..3ee2ae6579 100644 --- a/engines/cruise/menu.h +++ b/engines/cruise/menu.h @@ -41,7 +41,7 @@ extern menuStruct *menuTable[8]; menuStruct *createMenu(int X, int Y, const char *menuName); void addSelectableMenuEntry(int var0, int var1, menuStruct * pMenu, int var2, - int color, const char *menuText); + int color, const char *menuText); void updateMenuMouse(int mouseX, int mouseY, menuStruct * pMenu); int processMenu(menuStruct * pMenu); void freeMenu(menuStruct * pMenu); diff --git a/engines/cruise/mouse.cpp b/engines/cruise/mouse.cpp index a5e6c12be2..bdb79a23ad 100644 --- a/engines/cruise/mouse.cpp +++ b/engines/cruise/mouse.cpp @@ -30,137 +30,137 @@ namespace Cruise { int16 main10; - static const byte mouseCursorNormal[] = { - 0x00, 0x00, 0x40, 0x00, 0x60, 0x00, 0x70, 0x00, - 0x78, 0x00, 0x7C, 0x00, 0x7E, 0x00, 0x7F, 0x00, - 0x7F, 0x80, 0x7C, 0x00, 0x6C, 0x00, 0x46, 0x00, - 0x06, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x00, - - 0xC0, 0x00, 0xE0, 0x00, 0xF0, 0x00, 0xF8, 0x00, - 0xFC, 0x00, 0xFE, 0x00, 0xFF, 0x00, 0xFF, 0x80, - 0xFF, 0xC0, 0xFF, 0xC0, 0xFE, 0x00, 0xFF, 0x00, - 0xCF, 0x00, 0x07, 0x80, 0x07, 0x80, 0x03, 0x80 - }; - - static const byte mouseCursorDisk[] = { - 0x7F, 0xFC, 0x9F, 0x12, 0x9F, 0x12, 0x9F, 0x12, - 0x9F, 0x12, 0x9F, 0xE2, 0x80, 0x02, 0x9F, 0xF2, - 0xA0, 0x0A, 0xA0, 0x0A, 0xA0, 0x0A, 0xA0, 0x0A, - 0xA0, 0x0A, 0xA0, 0x0A, 0x7F, 0xFC, 0x00, 0x00, - - 0x7F, 0xFC, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, - 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, - 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, - 0xFF, 0xFE, 0xFF, 0xFE, 0x7F, 0xFC, 0x00, 0x00 - }; - - static const byte mouseCursorCross[] = { - 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, - 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x7C, 0x7C, - 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, - 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, - - 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, - 0x03, 0x80, 0x03, 0x80, 0xFF, 0xFE, 0xFE, 0xFE, - 0xFF, 0xFE, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, - 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0x00, 0x00 - }; - - static const byte mouseCursorNoMouse[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - }; - - static const byte mouseCursorWalk[] = { - 0x03, 0xC0, 0x03, 0xC0, 0x03, 0xC0, 0x01, 0xE0, - 0x03, 0xF0, 0x03, 0x38, 0x1B, 0xDC, 0x1B, 0xCC, - 0x03, 0xCC, 0x03, 0x80, 0x07, 0x00, 0x0E, 0xC0, - 0x1C, 0xE0, 0x18, 0x70, 0x18, 0x38, 0x18, 0x18, - - 0x07, 0xE0, 0x07, 0xE0, 0x07, 0xE0, 0x03, 0xF0, - 0x07, 0xF8, 0x07, 0xFC, 0x3F, 0xFE, 0x3F, 0xFE, - 0x07, 0xFE, 0x07, 0xC0, 0x0F, 0x80, 0x1F, 0xE0, - 0x3F, 0xF0, 0x3C, 0xF8, 0x3C, 0x7C, 0x3C, 0x3C - }; - - static const byte mouseCursorExit[] = { - 0x7f, 0xf8, 0x60, 0x18, 0x60, 0x18, 0x60, 0x18, - 0x60, 0x00, 0x60, 0x08, 0x60, 0x0c, 0x60, 0xfe, - 0x60, 0xfe, 0x60, 0x0c, 0x60, 0x08, 0x60, 0x00, - 0x60, 0x18, 0x60, 0x18, 0x60, 0x18, 0x7f, 0xf8, - - 0xff, 0xfc, 0xf0, 0x3c, 0xf0, 0x3c, 0xf0, 0x3c, - 0xf0, 0x00, 0xf0, 0x1c, 0xf0, 0x1e, 0xf1, 0xff, - 0xf1, 0xff, 0xf0, 0x1e, 0xf0, 0x1c, 0xf0, 0x00, - 0xf0, 0x3c, 0xf0, 0x3c, 0xf0, 0x3c, 0xff, 0xfc - }; - - static const byte mouseCursorMagnifyingGlass[] = { - 0x00, 0x00, 0x00, 0x00, 0x03, 0xfe, 0x02, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x22, 0x00, 0x02, - 0x07, 0x82, 0x03, 0x82, 0x07, 0x9e, 0xfe, 0x80, - 0xfc, 0x00, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, - - 0x00, 0x00, 0x07, 0xff, 0x07, 0xff, 0x06, 0x03, - 0x06, 0x03, 0x06, 0x03, 0x00, 0x23, 0x0f, 0xc3, - 0x0f, 0xc3, 0x07, 0xc3, 0xff, 0xdf, 0xff, 0xdf, - 0xfe, 0xc0, 0xfc, 0x00, 0xf8, 0x00, 0x00, 0x00 - }; - - struct MouseCursor { - int hotspotX; - int hotspotY; - const byte *bitmap; - }; - - static const MouseCursor mouseCursors[] = { - { 1, 1, mouseCursorNormal }, - { 0, 0, mouseCursorDisk }, - { 7, 7, mouseCursorCross }, - { 0, 0, mouseCursorNoMouse }, - { 10, 6, mouseCursorWalk }, - { 10, 6, mouseCursorExit }, - { 10, 6, mouseCursorMagnifyingGlass } - }; - - CursorType currentCursor = CURSOR_NOMOUSE; - - static const byte cursorPalette[] = { - 0, 0, 0, 0xff, - 0xff, 0xff, 0xff, 0xff - }; - - void changeCursor(CursorType eType) { - assert(eType >= 0 && eType < CURSOR_MAX); - if (currentCursor != eType) { - byte mouseCursor[16 * 16]; - const MouseCursor *mc = &mouseCursors[eType]; - const byte *src = mc->bitmap; - for (int i = 0; i < 32; ++i) { - int offs = i * 8; - for (byte mask = 0x80; mask != 0; mask >>= 1) { - if (src[0] & mask) { - mouseCursor[offs] = 1; - } else if (src[32] & mask) { - mouseCursor[offs] = 0; - } else { - mouseCursor[offs] = 0xFF; - } - ++offs; +static const byte mouseCursorNormal[] = { + 0x00, 0x00, 0x40, 0x00, 0x60, 0x00, 0x70, 0x00, + 0x78, 0x00, 0x7C, 0x00, 0x7E, 0x00, 0x7F, 0x00, + 0x7F, 0x80, 0x7C, 0x00, 0x6C, 0x00, 0x46, 0x00, + 0x06, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x00, + + 0xC0, 0x00, 0xE0, 0x00, 0xF0, 0x00, 0xF8, 0x00, + 0xFC, 0x00, 0xFE, 0x00, 0xFF, 0x00, 0xFF, 0x80, + 0xFF, 0xC0, 0xFF, 0xC0, 0xFE, 0x00, 0xFF, 0x00, + 0xCF, 0x00, 0x07, 0x80, 0x07, 0x80, 0x03, 0x80 +}; + +static const byte mouseCursorDisk[] = { + 0x7F, 0xFC, 0x9F, 0x12, 0x9F, 0x12, 0x9F, 0x12, + 0x9F, 0x12, 0x9F, 0xE2, 0x80, 0x02, 0x9F, 0xF2, + 0xA0, 0x0A, 0xA0, 0x0A, 0xA0, 0x0A, 0xA0, 0x0A, + 0xA0, 0x0A, 0xA0, 0x0A, 0x7F, 0xFC, 0x00, 0x00, + + 0x7F, 0xFC, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, + 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, + 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, + 0xFF, 0xFE, 0xFF, 0xFE, 0x7F, 0xFC, 0x00, 0x00 +}; + +static const byte mouseCursorCross[] = { + 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, + 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x7C, 0x7C, + 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, + 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, + + 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, + 0x03, 0x80, 0x03, 0x80, 0xFF, 0xFE, 0xFE, 0xFE, + 0xFF, 0xFE, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, + 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0x00, 0x00 +}; + +static const byte mouseCursorNoMouse[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +}; + +static const byte mouseCursorWalk[] = { + 0x03, 0xC0, 0x03, 0xC0, 0x03, 0xC0, 0x01, 0xE0, + 0x03, 0xF0, 0x03, 0x38, 0x1B, 0xDC, 0x1B, 0xCC, + 0x03, 0xCC, 0x03, 0x80, 0x07, 0x00, 0x0E, 0xC0, + 0x1C, 0xE0, 0x18, 0x70, 0x18, 0x38, 0x18, 0x18, + + 0x07, 0xE0, 0x07, 0xE0, 0x07, 0xE0, 0x03, 0xF0, + 0x07, 0xF8, 0x07, 0xFC, 0x3F, 0xFE, 0x3F, 0xFE, + 0x07, 0xFE, 0x07, 0xC0, 0x0F, 0x80, 0x1F, 0xE0, + 0x3F, 0xF0, 0x3C, 0xF8, 0x3C, 0x7C, 0x3C, 0x3C +}; + +static const byte mouseCursorExit[] = { + 0x7f, 0xf8, 0x60, 0x18, 0x60, 0x18, 0x60, 0x18, + 0x60, 0x00, 0x60, 0x08, 0x60, 0x0c, 0x60, 0xfe, + 0x60, 0xfe, 0x60, 0x0c, 0x60, 0x08, 0x60, 0x00, + 0x60, 0x18, 0x60, 0x18, 0x60, 0x18, 0x7f, 0xf8, + + 0xff, 0xfc, 0xf0, 0x3c, 0xf0, 0x3c, 0xf0, 0x3c, + 0xf0, 0x00, 0xf0, 0x1c, 0xf0, 0x1e, 0xf1, 0xff, + 0xf1, 0xff, 0xf0, 0x1e, 0xf0, 0x1c, 0xf0, 0x00, + 0xf0, 0x3c, 0xf0, 0x3c, 0xf0, 0x3c, 0xff, 0xfc +}; + +static const byte mouseCursorMagnifyingGlass[] = { + 0x00, 0x00, 0x00, 0x00, 0x03, 0xfe, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x22, 0x00, 0x02, + 0x07, 0x82, 0x03, 0x82, 0x07, 0x9e, 0xfe, 0x80, + 0xfc, 0x00, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, + + 0x00, 0x00, 0x07, 0xff, 0x07, 0xff, 0x06, 0x03, + 0x06, 0x03, 0x06, 0x03, 0x00, 0x23, 0x0f, 0xc3, + 0x0f, 0xc3, 0x07, 0xc3, 0xff, 0xdf, 0xff, 0xdf, + 0xfe, 0xc0, 0xfc, 0x00, 0xf8, 0x00, 0x00, 0x00 +}; + +struct MouseCursor { + int hotspotX; + int hotspotY; + const byte *bitmap; +}; + +static const MouseCursor mouseCursors[] = { + { 1, 1, mouseCursorNormal }, + { 0, 0, mouseCursorDisk }, + { 7, 7, mouseCursorCross }, + { 0, 0, mouseCursorNoMouse }, + { 10, 6, mouseCursorWalk }, + { 10, 6, mouseCursorExit }, + { 10, 6, mouseCursorMagnifyingGlass } +}; + +CursorType currentCursor = CURSOR_NOMOUSE; + +static const byte cursorPalette[] = { + 0, 0, 0, 0xff, + 0xff, 0xff, 0xff, 0xff +}; + +void changeCursor(CursorType eType) { + assert(eType >= 0 && eType < CURSOR_MAX); + if (currentCursor != eType) { + byte mouseCursor[16 * 16]; + const MouseCursor *mc = &mouseCursors[eType]; + const byte *src = mc->bitmap; + for (int i = 0; i < 32; ++i) { + int offs = i * 8; + for (byte mask = 0x80; mask != 0; mask >>= 1) { + if (src[0] & mask) { + mouseCursor[offs] = 1; + } else if (src[32] & mask) { + mouseCursor[offs] = 0; + } else { + mouseCursor[offs] = 0xFF; } - ++src; + ++offs; } - CursorMan.replaceCursor(mouseCursor, 16, 16, mc->hotspotX, mc->hotspotY); - CursorMan.replaceCursorPalette(cursorPalette, 0, 2); - currentCursor = eType; + ++src; } + CursorMan.replaceCursor(mouseCursor, 16, 16, mc->hotspotX, mc->hotspotY); + CursorMan.replaceCursorPalette(cursorPalette, 0, 2); + currentCursor = eType; } +} } // End of namespace Cruise diff --git a/engines/cruise/mouse.h b/engines/cruise/mouse.h index 502e894a82..5d430f5863 100644 --- a/engines/cruise/mouse.h +++ b/engines/cruise/mouse.h @@ -28,22 +28,22 @@ namespace Cruise { - extern int16 main10; - - enum CursorType { - CURSOR_NORMAL = 0, - CURSOR_DISK = 1, - CURSOR_CROSS = 2, - CURSOR_NOMOUSE = 3, - CURSOR_WALK = 4, - CURSOR_EXIT = 5, - CURSOR_MAGNIFYING_GLASS = 6, - - CURSOR_MAX = 7 - }; - - void changeCursor(CursorType eType); - extern CursorType currentCursor; +extern int16 main10; + +enum CursorType { + CURSOR_NORMAL = 0, + CURSOR_DISK = 1, + CURSOR_CROSS = 2, + CURSOR_NOMOUSE = 3, + CURSOR_WALK = 4, + CURSOR_EXIT = 5, + CURSOR_MAGNIFYING_GLASS = 6, + + CURSOR_MAX = 7 +}; + +void changeCursor(CursorType eType); +extern CursorType currentCursor; } // End of namespace Cruise diff --git a/engines/cruise/object.cpp b/engines/cruise/object.cpp index bb8d85acd0..e0426c7273 100644 --- a/engines/cruise/object.cpp +++ b/engines/cruise/object.cpp @@ -75,32 +75,28 @@ int16 getMultipleObjectParam(int16 overlayIdx, int16 objectIdx, objectParamsQuer switch (ptr->_class) { case THEME: - case MULTIPLE: - { - state = globalVars[overlayTable[overlayIdx].state + ptr->_stateTableIdx]; + case MULTIPLE: { + state = globalVars[overlayTable[overlayIdx].state + ptr->_stateTableIdx]; - ptr2 = &ovlData->arrayStates[ptr->_firstStateIdx + state]; - state2 = ptr2->state; - break; - } - case VARIABLE: - { - ptr2 = &ovlData->arrayObjVar[ptr->_varTableIdx]; - - state = ptr2->state; - state2 = state; - if(ptr->_firstStateIdx + state < ovlData->size8) - { - objectParams *ptr3 = &ovlData->arrayStates[ptr->_firstStateIdx + state]; - state2 = ptr3->state; - } - break; - } - default: - { - printf("Unsupported case %d in getMultipleObjectParam\n",ptr->_class); - exit(1); + ptr2 = &ovlData->arrayStates[ptr->_firstStateIdx + state]; + state2 = ptr2->state; + break; + } + case VARIABLE: { + ptr2 = &ovlData->arrayObjVar[ptr->_varTableIdx]; + + state = ptr2->state; + state2 = state; + if (ptr->_firstStateIdx + state < ovlData->size8) { + objectParams *ptr3 = &ovlData->arrayStates[ptr->_firstStateIdx + state]; + state2 = ptr3->state; } + break; + } + default: { + printf("Unsupported case %d in getMultipleObjectParam\n", ptr->_class); + exit(1); + } } returnParam->X = ptr2->X; @@ -129,64 +125,54 @@ void setObjectPosition(int16 ovlIdx, int16 objIdx, int16 param3, int16 param4) { switch (ptr->_class) { case THEME: - case MULTIPLE: - { - if(param3 != 5) - return; - globalVars[overlayTable[ovlIdx].state + ptr->_stateTableIdx] = param4; - sortCells(ovlIdx, objIdx, &cellHead); - break; - } + case MULTIPLE: { + if (param3 != 5) + return; + globalVars[overlayTable[ovlIdx].state + ptr->_stateTableIdx] = param4; + sortCells(ovlIdx, objIdx, &cellHead); + break; + } case UNIQUE: return; - case VARIABLE: - { - ptr2 = &overlayTable[ovlIdx].ovlData->arrayObjVar[ptr->_varTableIdx]; - - switch (param3) { - case 0: // x - { - ptr2->X = param4; - break; - } - case 1: // y - { - ptr2->Y = param4; - break; - } - case 2: // z - { - ptr2->Z = param4; - sortCells(ovlIdx, objIdx, &cellHead); - break; - } - case 3: - { - ptr2->frame = param4; - break; - } - case 4: // scale - { - ptr2->scale = param4; - break; - } - case 5: // state - { - ptr2->state = param4; - break; - } - default: - { - ASSERT(0); - } - } + case VARIABLE: { + ptr2 = &overlayTable[ovlIdx].ovlData->arrayObjVar[ptr->_varTableIdx]; + switch (param3) { + case 0: { // x + ptr2->X = param4; break; } - default: - { + case 1: { // y + ptr2->Y = param4; + break; + } + case 2: { // z + ptr2->Z = param4; + sortCells(ovlIdx, objIdx, &cellHead); + break; + } + case 3: { + ptr2->frame = param4; + break; + } + case 4: { // scale + ptr2->scale = param4; + break; + } + case 5: { // state + ptr2->state = param4; + break; + } + default: { ASSERT(0); } + } + + break; + } + default: { + ASSERT(0); + } } } @@ -204,38 +190,35 @@ int16 objInit(int ovlIdx, int objIdx, int newState) { switch (ptr->_class) { case THEME: - case MULTIPLE: - { - globalVars[overlayTable[ovlIdx].state + ptr->_stateTableIdx] = newState; - sortCells(ovlIdx, objIdx, &cellHead); - break; - } + case MULTIPLE: { + globalVars[overlayTable[ovlIdx].state + ptr->_stateTableIdx] = newState; + sortCells(ovlIdx, objIdx, &cellHead); + break; + } case UNIQUE: break; - case VARIABLE: - { - objectParams *destEntry; - objectParams *sourceEntry; + case VARIABLE: { + objectParams *destEntry; + objectParams *sourceEntry; - if (ptr->_firstStateIdx + newState > ovlData->size8) { - return 0; - } + if (ptr->_firstStateIdx + newState > ovlData->size8) { + return 0; + } - destEntry = &ovlData->arrayObjVar[ptr->_varTableIdx]; - sourceEntry = &ovlData->arrayStates[ptr->_firstStateIdx + newState]; + destEntry = &ovlData->arrayObjVar[ptr->_varTableIdx]; + sourceEntry = &ovlData->arrayStates[ptr->_firstStateIdx + newState]; - memcpy(destEntry, sourceEntry, sizeof(objectParams)); + memcpy(destEntry, sourceEntry, sizeof(objectParams)); - destEntry->state = newState; + destEntry->state = newState; - sortCells(ovlIdx, objIdx, &cellHead); - break; - } - default: - { - printf("Unsupported param = %d in objInit\n", ptr->_class); - // exit(1); - } + sortCells(ovlIdx, objIdx, &cellHead); + break; + } + default: { + printf("Unsupported param = %d in objInit\n", ptr->_class); + // exit(1); + } } return 0; @@ -257,75 +240,65 @@ int16 getSingleObjectParam(int16 overlayIdx, int16 param2, int16 param3, int16 * switch (ptr->_class) { case THEME: - case MULTIPLE: - { - state = globalVars[overlayTable[overlayIdx].state + ptr->_stateTableIdx]; + case MULTIPLE: { + state = globalVars[overlayTable[overlayIdx].state + ptr->_stateTableIdx]; - ptr2 = &ovlData->arrayStates[ptr->_firstStateIdx + state]; - break; - } - case VARIABLE: - { - ptr2 = &ovlData->arrayObjVar[ptr->_varTableIdx]; + ptr2 = &ovlData->arrayStates[ptr->_firstStateIdx + state]; + break; + } + case VARIABLE: { + ptr2 = &ovlData->arrayObjVar[ptr->_varTableIdx]; - state = ptr2->state; - break; - } - default: - { - printf("Unsupported case %d in getSingleObjectParam\n",ptr->_class); - exit(1); - } + state = ptr2->state; + break; + } + default: { + printf("Unsupported case %d in getSingleObjectParam\n", ptr->_class); + exit(1); + } } switch (param3) { - case 0: - { - *returnParam = ptr2->X; - break; - } - case 1: - { - *returnParam = ptr2->Y; - break; - } - case 2: - { - *returnParam = ptr2->Z; - break; - } - case 3: - { - *returnParam = ptr2->frame; - break; - } - case 4: - { - *returnParam = ptr2->scale; - break; - } - case 5: - { - *returnParam = state; - break; - } - default: - { - printf("Unsupported case %d in getSingleObjectParam case 1\n", param3); - exit(1); - } + case 0: { + *returnParam = ptr2->X; + break; + } + case 1: { + *returnParam = ptr2->Y; + break; + } + case 2: { + *returnParam = ptr2->Z; + break; + } + case 3: { + *returnParam = ptr2->frame; + break; + } + case 4: { + *returnParam = ptr2->scale; + break; + } + case 5: { + *returnParam = state; + break; + } + default: { + printf("Unsupported case %d in getSingleObjectParam case 1\n", param3); + exit(1); + } } return 0; } void objectReset(void) { - for(int i=1; i<numOfLoadedOverlay; i++) { - if(overlayTable[i].alreadyLoaded && overlayTable[i].ovlData) { - if(overlayTable[i].ovlData->arrayObject) { - for(int j=0; j<overlayTable[i].ovlData->numObj; j++) { + for (int i = 1; i < numOfLoadedOverlay; i++) { + if (overlayTable[i].alreadyLoaded && overlayTable[i].ovlData) { + if (overlayTable[i].ovlData->arrayObject) { + for (int j = 0; j < overlayTable[i].ovlData->numObj; j++) { int stateIdx = overlayTable[i].state + overlayTable[i].ovlData->arrayObject[j]._stateTableIdx; - if((overlayTable[i].ovlData->arrayObject[j]._class == THEME) && (globalVars[stateIdx] == -2)) + if ((overlayTable[i].ovlData->arrayObject[j]._class == THEME) && (globalVars[stateIdx] == -2)) globalVars[stateIdx] = 0; } } diff --git a/engines/cruise/overlay.cpp b/engines/cruise/overlay.cpp index 5538e4cd9f..1c7c65b000 100644 --- a/engines/cruise/overlay.cpp +++ b/engines/cruise/overlay.cpp @@ -115,7 +115,7 @@ int loadOverlay(const char *scriptName) { if (volumePtrToFileDescriptor[fileIdx].size + 2 != unpackedSize) { char *pakedBuffer = (char *)mallocAndZero(volumePtrToFileDescriptor[fileIdx]. - size + 2); + size + 2); loadPakedFileToMem(fileIdx, (uint8 *) pakedBuffer); @@ -200,7 +200,7 @@ int loadOverlay(const char *scriptName) { ovlData->arrayRelocGlob = (importDataStruct *) mallocAndZero(ovlData->numRelocGlob * - sizeof(importDataStruct)); + sizeof(importDataStruct)); if (!ovlData->arrayRelocGlob) { return (-2); @@ -302,12 +302,12 @@ int loadOverlay(const char *scriptName) { if (tempPtr->offsetToImportData) { flipGen(tempPtr->dataPtr + tempPtr->offsetToImportData, - tempPtr->numRelocGlob * 10); + tempPtr->numRelocGlob * 10); } if (tempPtr->offsetToSubData2) { flipGen(tempPtr->dataPtr + tempPtr->offsetToSubData2, - tempPtr->subData2Size * 10); + tempPtr->subData2Size * 10); } tempPtr++; @@ -355,12 +355,12 @@ int loadOverlay(const char *scriptName) { if (tempPtr->offsetToImportData) { flipGen(tempPtr->dataPtr + tempPtr->offsetToImportData, - tempPtr->numRelocGlob * 10); + tempPtr->numRelocGlob * 10); } if (tempPtr->offsetToSubData2) { flipGen(tempPtr->dataPtr + tempPtr->offsetToSubData2, - tempPtr->subData2Size * 10); + tempPtr->subData2Size * 10); } tempPtr++; @@ -371,11 +371,11 @@ int loadOverlay(const char *scriptName) { ovlData->ptr8 = (uint8 *) mallocAndZero(ovlData->size12); if (!ovlData->ptr8) { -/* releaseScript(scriptIdx,scriptName); + /* releaseScript(scriptIdx,scriptName); - if (freeIsNeeded) { - freePtr(unpackedBuffer); - } */ + if (freeIsNeeded) { + freePtr(unpackedBuffer); + } */ return (-2); } @@ -387,7 +387,7 @@ int loadOverlay(const char *scriptName) { int i; ovlData->arrayObject = (objDataStruct *) mallocAndZero(ovlData->numObj * - sizeof(objDataStruct)); + sizeof(objDataStruct)); if (!ovlData->arrayObject) { return (-2); @@ -414,7 +414,7 @@ int loadOverlay(const char *scriptName) { if (ovlData->size9) { ovlData->arrayObjVar = (objectParams *) mallocAndZero(ovlData->size9 * - sizeof(objectParams)); + sizeof(objectParams)); if (!ovlData->arrayObjVar) { return (-2); @@ -425,7 +425,7 @@ int loadOverlay(const char *scriptName) { int i; ovlData->arrayStates = (objectParams *) mallocAndZero(ovlData->size8 * - sizeof(objectParams)); + sizeof(objectParams)); if (!ovlData->arrayStates) { return (-2); @@ -446,7 +446,7 @@ int loadOverlay(const char *scriptName) { ovlData->stringTable = (stringEntryStruct *) mallocAndZero(ovlData->numStrings * - sizeof(stringEntryStruct)); + sizeof(stringEntryStruct)); for (i = 0; i < ovlData->numStrings; i++) { ovlData->stringTable[i].idx = s.readUint16BE(); @@ -463,8 +463,8 @@ int loadOverlay(const char *scriptName) { } if (ovlData-> - specialString1Length /*|| ovlData->specialString2Length */ - || ovlData->stringTable) { + specialString1Length /*|| ovlData->specialString2Length */ + || ovlData->stringTable) { int i; //int unpackedSize; //int fileIdx; @@ -492,11 +492,11 @@ int loadOverlay(const char *scriptName) { } if (volumePtrToFileDescriptor[fileIdx].size + 2 != - unpackedSize) { + unpackedSize) { char *pakedBuffer = (char *) mallocAndZero(volumePtrToFileDescriptor[fileIdx]. - size + 2); + size + 2); loadPakedFileToMem(fileIdx, (uint8 *) pakedBuffer); @@ -551,7 +551,7 @@ int loadOverlay(const char *scriptName) { if (ovlData->stringTable[i].length) { ovlData->stringTable[i].string = (char *)mallocAndZero(ovlData-> - stringTable[i].length); + stringTable[i].length); if (!ovlData->stringTable[i].string) { /* releaseScript(scriptIdx,scriptName); @@ -592,12 +592,12 @@ int loadOverlay(const char *scriptName) { if (ovlData->arrayNameObj) { fprintf(fHandle, "----- object %02d -----\n", - i); + i); if (var_34->stringNameOffset != 0xFFFF) { fprintf(fHandle, "name: %s\n", - getObjectName(var_34-> - stringNameOffset, - ovlData->arrayNameObj)); + getObjectName(var_34-> + stringNameOffset, + ovlData->arrayNameObj)); } } } @@ -627,16 +627,16 @@ int releaseOverlay(const char *name) { if (!ovlDataPtr) return -4; -/* - if (overlayTable[overlayIdx].var1E) { - free(overlayTable[overlayIdx].var1E); - overlayTable[overlayIdx].var1E = NULL; - } - - if (overlayTable[overlayIdx].var16) { - free(overlayTable[overlayIdx].var16); - overlayTable[overlayIdx].var16 = NULL; - } */ + /* + if (overlayTable[overlayIdx].var1E) { + free(overlayTable[overlayIdx].var1E); + overlayTable[overlayIdx].var1E = NULL; + } + + if (overlayTable[overlayIdx].var16) { + free(overlayTable[overlayIdx].var16); + overlayTable[overlayIdx].var16 = NULL; + } */ removeScript(overlayIdx, -1, &procHead); removeScript(overlayIdx, -1, &procHead); diff --git a/engines/cruise/overlay.h b/engines/cruise/overlay.h index 7ba90a1449..a779e60964 100644 --- a/engines/cruise/overlay.h +++ b/engines/cruise/overlay.h @@ -99,8 +99,7 @@ struct importDataStruct { uint16 nameOffset; }; -enum eClass -{ +enum eClass { MULTIPLE = 0, VARIABLE = 1, UNIQUE = 2, diff --git a/engines/cruise/perso.cpp b/engines/cruise/perso.cpp index 046e3d15b1..a172bb0cb8 100644 --- a/engines/cruise/perso.cpp +++ b/engines/cruise/perso.cpp @@ -169,11 +169,11 @@ int cor_droite(int x1, int y1, int x2, int y2, point* outputTable) { } void processActorWalk(int16 resx_y[4], int16 *inc_droite, int16 *inc_droite0, - int16 *inc_chemin, point* cor_joueur, - int16 solution0[NUM_NODES + 3][2], int16 *inc_jo1, int16 *inc_jo2, - int16 *dir_perso, int16 *inc_jo0, int16 num) { - int x1, x2, y1, y2; - int i, u; + int16 *inc_chemin, point* cor_joueur, + int16 solution0[NUM_NODES + 3][2], int16 *inc_jo1, int16 *inc_jo2, + int16 *dir_perso, int16 *inc_jo0, int16 num) { + int x1, x2, y1, y2; + int i, u; u = 0; inc_jo = *inc_jo0; @@ -243,9 +243,9 @@ void affiche_chemin(int16 persoIdx, int16 *returnVar) { ASSERT(pPerso); processActorWalk(returnVar, &pPerso->inc_droite, &pPerso->inc_droite0, - &pPerso->inc_chemin, pPerso->coordinates, pPerso->solution, - &pPerso->inc_jo1, &pPerso->inc_jo2, &pPerso->dir_perso, - &pPerso->inc_jo0, persoIdx); + &pPerso->inc_chemin, pPerso->coordinates, pPerso->solution, + &pPerso->inc_jo1, &pPerso->inc_jo2, &pPerso->dir_perso, + &pPerso->inc_jo0, persoIdx); } } // End of namespace Cruise diff --git a/engines/cruise/saveload.cpp b/engines/cruise/saveload.cpp index e8467c327b..5d4bc54e1d 100644 --- a/engines/cruise/saveload.cpp +++ b/engines/cruise/saveload.cpp @@ -39,14 +39,10 @@ struct overlayRestoreTemporary { overlayRestoreTemporary ovlRestoreData[90]; -void resetPreload() -{ - for(unsigned long int i=0; i<64; i++) - { - if(strlen(preloadData[i].name)) - { - if(preloadData[i].ptr) - { +void resetPreload() { + for (unsigned long int i = 0; i < 64; i++) { + if (strlen(preloadData[i].name)) { + if (preloadData[i].ptr) { free(preloadData[i].ptr); preloadData[i].ptr = NULL; } @@ -56,8 +52,7 @@ void resetPreload() } } -void unloadOverlay(const char*name, int overlayNumber) -{ +void unloadOverlay(const char*name, int overlayNumber) { releaseOverlay(name); strcpy(overlayTable[overlayNumber].overlayName, ""); @@ -65,10 +60,9 @@ void unloadOverlay(const char*name, int overlayNumber) overlayTable[overlayNumber].alreadyLoaded = 0; } -void initVars(void) -{ +void initVars(void) { closeAllMenu(); - resetFileEntryRange( 0, 257 ); + resetFileEntryRange(0, 257); resetPreload(); freeCTP(); @@ -85,10 +79,8 @@ void initVars(void) changeScriptParamInList(-1, -1, &relHead, -1, 0); removeFinishedScripts(&relHead); - for(unsigned long int i=0; i<90; i++) - { - if(strlen(overlayTable[i].overlayName) && overlayTable[i].alreadyLoaded) - { + for (unsigned long int i = 0; i < 90; i++) { + if (strlen(overlayTable[i].overlayName) && overlayTable[i].alreadyLoaded) { unloadOverlay(overlayTable[i].overlayName, i); } } @@ -190,24 +182,24 @@ void initVars(void) void saveOverlay(Common::OutSaveFile& currentSaveFile) { for (int i = 1; i < numOfLoadedOverlay; i++) { - if(overlayTable[i].alreadyLoaded) { + if (overlayTable[i].alreadyLoaded) { ovlDataStruct* ovlData = overlayTable[i].ovlData; // save BSS currentSaveFile.writeSint16LE(ovlData->sizeOfData4); - if(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); + 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); } } } @@ -236,8 +228,7 @@ void loadSavegameDataSub1(Common::InSaveFile& currentSaveFile) { ovlRestoreData[i]._pObj = (objectParams *) mallocAndZero(ovlRestoreData[i]._sNumObj * sizeof(objectParams)); ASSERT(ovlRestoreData[i]._pObj); - for(int j=0; j<ovlRestoreData[i]._sNumObj; j++) - { + for (int j = 0; j < ovlRestoreData[i]._sNumObj; j++) { ovlRestoreData[i]._pObj[j].X = currentSaveFile.readSint16LE(); ovlRestoreData[i]._pObj[j].Y = currentSaveFile.readSint16LE(); ovlRestoreData[i]._pObj[j].Z = currentSaveFile.readSint16LE(); @@ -254,7 +245,7 @@ void saveScript(Common::OutSaveFile& currentSaveFile, scriptInstanceStruct *entr int count = 0; scriptInstanceStruct* pCurrent = entry->nextScriptPtr; - while( pCurrent ) { + while (pCurrent) { count ++; pCurrent = pCurrent->nextScriptPtr; } @@ -262,7 +253,7 @@ void saveScript(Common::OutSaveFile& currentSaveFile, scriptInstanceStruct *entr currentSaveFile.writeSint16LE(count); pCurrent = entry->nextScriptPtr; - while( pCurrent ) { + while (pCurrent) { char dummy[4] = { 0, 0, 0, 0 }; currentSaveFile.write(dummy, 2); @@ -334,7 +325,7 @@ void saveAnim(Common::OutSaveFile& currentSaveFile) { int count = 0; actorStruct *ptr = actorHead.next; - while(ptr) { + while (ptr) { count ++; ptr = ptr->next; } @@ -342,7 +333,7 @@ void saveAnim(Common::OutSaveFile& currentSaveFile) { currentSaveFile.writeSint16LE(count); ptr = actorHead.next; - while(ptr) { + while (ptr) { char dummy[2] = {0, 0}; currentSaveFile.write(dummy, 2); currentSaveFile.write(dummy, 2); @@ -436,13 +427,12 @@ void loadSavegameDataSub5(Common::InSaveFile& currentSaveFile) { } void saveCT(Common::OutSaveFile& currentSaveFile) { - if(polyStruct) { + if (polyStruct) { currentSaveFile.writeSint32LE(1); currentSaveFile.writeSint16LE(numberOfWalkboxes); - if(numberOfWalkboxes) - { + if (numberOfWalkboxes) { // FIXME: This code is not endian safe, and breaks if struct // packing changes. Read/write the members one by one instead. currentSaveFile.write(walkboxColor, numberOfWalkboxes * 2); @@ -460,8 +450,7 @@ void saveCT(Common::OutSaveFile& currentSaveFile) { } } - } - else { + } else { currentSaveFile.writeSint32LE(0); } } @@ -539,7 +528,7 @@ int saveSavegameData(int saveGameIdx) { currentSaveFile->writeSint16LE(aniX); currentSaveFile->writeSint16LE(aniY); - if(animationStart) + if (animationStart) currentSaveFile->writeSint16LE(1); else currentSaveFile->writeSint16LE(0); @@ -578,8 +567,7 @@ int saveSavegameData(int saveGameIdx) { currentSaveFile->write(currentCtpName, 40); // restore backgroundTable - for(int i=0; i<8; i++) - { + for (int i = 0; i < 8; i++) { currentSaveFile->write(backgroundTable[i].name, 9); currentSaveFile->write(backgroundTable[i].extention, 6); } @@ -587,13 +575,12 @@ int saveSavegameData(int saveGameIdx) { currentSaveFile->write(palScreen, sizeof(int16) * NBCOLORS * NBSCREENS); currentSaveFile->write(initVar5, 24); currentSaveFile->write(globalVars, stateID * 2); // ok - for(int i=0; i<257; i++) - { + 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) { + if (filesDatabase[i].subData.ptr) { currentSaveFile->writeUint32LE(1); } else { currentSaveFile->writeUint32LE(0); @@ -602,7 +589,7 @@ int saveSavegameData(int saveGameIdx) { currentSaveFile->write(filesDatabase[i].subData.name, 13); currentSaveFile->write(dummy, 1); currentSaveFile->writeUint16LE(filesDatabase[i].subData.transparency); - if(filesDatabase[i].subData.ptrMask) { + if (filesDatabase[i].subData.ptrMask) { currentSaveFile->writeUint32LE(1); } else { currentSaveFile->writeUint32LE(0); @@ -612,8 +599,7 @@ int saveSavegameData(int saveGameIdx) { currentSaveFile->writeUint16LE(filesDatabase[i].subData.compression); } - for(int i=0; i<numOfLoadedOverlay; i++) - { + for (int i = 0; i < numOfLoadedOverlay; i++) { currentSaveFile->write(overlayTable[i].overlayName, 13); currentSaveFile->write(dummy, 1); currentSaveFile->write(dummy, 4); @@ -626,8 +612,7 @@ int saveSavegameData(int saveGameIdx) { currentSaveFile->writeUint16LE(overlayTable[i].executeScripts); } - for(int i=0; i<64; i++) - { + for (int i = 0; i < 64; i++) { currentSaveFile->write(preloadData[i].name, 15); currentSaveFile->write(dummy, 1); currentSaveFile->writeUint32LE(preloadData[i].size); @@ -716,7 +701,7 @@ int loadSavegameData(int saveGameIdx) { aniX = currentSaveFile->readSint16LE(); aniY = currentSaveFile->readSint16LE(); - if(currentSaveFile->readSint16LE()) // cast to bool + if (currentSaveFile->readSint16LE()) // cast to bool animationStart = true; else animationStart = false; @@ -755,8 +740,7 @@ int loadSavegameData(int saveGameIdx) { currentSaveFile->read(currentCtpName, 40); // restore backgroundTable - for(int i=0; i<8; i++) - { + for (int i = 0; i < 8; i++) { currentSaveFile->read(backgroundTable[i].name, 9); currentSaveFile->read(backgroundTable[i].extention, 6); } @@ -766,8 +750,7 @@ int loadSavegameData(int saveGameIdx) { currentSaveFile->read(palScreen, sizeof(int16) * NBCOLORS * NBSCREENS); currentSaveFile->read(initVar5, 24); currentSaveFile->read(globalVars, stateID * 2); // ok - for(int i=0; i<257; i++) - { + for (int i = 0; i < 257; i++) { filesDatabase[i].widthInColumn = currentSaveFile->readUint16LE(); filesDatabase[i].width = currentSaveFile->readUint16LE(); filesDatabase[i].resType = currentSaveFile->readUint16LE(); @@ -783,8 +766,7 @@ int loadSavegameData(int saveGameIdx) { filesDatabase[i].subData.compression = currentSaveFile->readSint16LE(); } - for(int i=0; i<numOfLoadedOverlay; i++) - { + for (int i = 0; i < numOfLoadedOverlay; i++) { currentSaveFile->read(overlayTable[i].overlayName, 13); currentSaveFile->skip(1); currentSaveFile->skip(4); @@ -797,8 +779,7 @@ int loadSavegameData(int saveGameIdx) { overlayTable[i].executeScripts = currentSaveFile->readSint16LE(); } - for(int i=0; i<64; i++) - { + for (int i = 0; i < 64; i++) { currentSaveFile->read(preloadData[i].name, 15); currentSaveFile->skip(1); preloadData[i].size = currentSaveFile->readSint32LE(); @@ -870,7 +851,7 @@ int loadSavegameData(int saveGameIdx) { int j; int k; - for (j = i + 1; j < 257 && filesDatabase[j].subData.ptr && !strcmp(filesDatabase[i].subData.name, filesDatabase[j].subData.name) && (filesDatabase[j].subData.index == (j-i)); j++); + for (j = i + 1; j < 257 && filesDatabase[j].subData.ptr && !strcmp(filesDatabase[i].subData.name, filesDatabase[j].subData.name) && (filesDatabase[j].subData.index == (j - i)); j++); for (k = i; k < j; k++) { if (filesDatabase[k].subData.ptrMask) diff --git a/engines/cruise/script.cpp b/engines/cruise/script.cpp index 2f1ab17c6c..4f62d22bd1 100644 --- a/engines/cruise/script.cpp +++ b/engines/cruise/script.cpp @@ -33,7 +33,7 @@ scriptInstanceStruct procHead; scriptInstanceStruct *currentScriptPtr; int8 getByteFromScript(void) { - int8 var = *(int8*)(currentData3DataPtr+currentScriptPtr->var4); + int8 var = *(int8*)(currentData3DataPtr + currentScriptPtr->var4); currentScriptPtr->var4 = currentScriptPtr->var4 + 1; @@ -41,7 +41,7 @@ int8 getByteFromScript(void) { } short int getShortFromScript(void) { - short int var = *(int16 *) (currentData3DataPtr + currentScriptPtr->var4); + short int var = *(int16 *)(currentData3DataPtr + currentScriptPtr->var4); currentScriptPtr->var4 = currentScriptPtr->var4 + 2; @@ -55,89 +55,85 @@ int32 opcodeType0(void) { int index = 0; switch (currentScriptOpcodeType) { - case 0: - { - pushVar(getShortFromScript()); - return (0); - } + case 0: { + pushVar(getShortFromScript()); + return (0); + } case 5: index = saveOpcodeVar; - case 1: - { - uint8 *address = 0; - int type = getByteFromScript(); - int ovl = getByteFromScript(); - short int offset = getShortFromScript(); - offset += index; - - int typ7 = type & 7; - - if (!typ7) { - return (-10); // unresloved link - } + case 1: { + uint8 *address = 0; + int type = getByteFromScript(); + int ovl = getByteFromScript(); + short int offset = getShortFromScript(); + offset += index; - if (!ovl) { - address = scriptDataPtrTable[typ7]; - } else { // TODO: - if (!overlayTable[ovl].alreadyLoaded) { - return (-7); - } + int typ7 = type & 7; - if (!overlayTable[ovl].ovlData) { - return (-4); - } + if (!typ7) { + return (-10); // unresloved link + } - if (typ7 == 5) { - address = overlayTable[ovl].ovlData->data4Ptr; - } else { - assert(0); - } + if (!ovl) { + address = scriptDataPtrTable[typ7]; + } else { // TODO: + if (!overlayTable[ovl].alreadyLoaded) { + return (-7); } - address += offset; - - int size = (type >> 3) & 3; + if (!overlayTable[ovl].ovlData) { + return (-4); + } - if (size == 1) { - address += index; - pushVar(loadShort(address)); - return (0); - } else if (size == 2) { - pushVar(*address); - return (0); + if (typ7 == 5) { + address = overlayTable[ovl].ovlData->data4Ptr; } else { - printf("Unsupported code in opcodeType0 case 1!\n"); - exit(1); + assert(0); } - - return (0); } - case 2: - { - int16 var_16; - int di = getByteFromScript(); - int si = getByteFromScript(); - int var_2 = getShortFromScript(); - - if (!si) { - si = currentScriptPtr->overlayNumber; - } - if (getSingleObjectParam(si, var_2, di, &var_16)) { - return -10; - } + address += offset; - pushVar(var_16); + int size = (type >> 3) & 3; + + if (size == 1) { + address += index; + pushVar(loadShort(address)); + return (0); + } else if (size == 2) { + pushVar(*address); return (0); + } else { + printf("Unsupported code in opcodeType0 case 1!\n"); + exit(1); + } + + return (0); + } + case 2: { + int16 var_16; + int di = getByteFromScript(); + int si = getByteFromScript(); + int var_2 = getShortFromScript(); - break; + if (!si) { + si = currentScriptPtr->overlayNumber; } - default: - { - printf("Unsupported type %d in opcodeType0\n", - currentScriptOpcodeType); - exit(1); + + if (getSingleObjectParam(si, var_2, di, &var_16)) { + return -10; } + + pushVar(var_16); + return (0); + + break; + } + default: { + printf("Unsupported type %d in opcodeType0\n", + currentScriptOpcodeType); + exit(1); + } } return 0; @@ -149,105 +145,95 @@ int32 opcodeType1(void) { int offset = 0; switch (currentScriptOpcodeType) { - case 0: - { - return (0); // strange, but happens also in original interpreter - } - case 5: - { - offset = saveOpcodeVar; - } - case 1: - { - int var_A = 0; - - int byte1 = getByteFromScript(); - int byte2 = getByteFromScript(); - - int short1 = getShortFromScript(); - - int var_6 = byte1 & 7; - - int var_C = short1; + case 0: { + return (0); // strange, but happens also in original interpreter + } + case 5: { + offset = saveOpcodeVar; + } + case 1: { + int var_A = 0; - uint8 *ptr = 0; - int type2; + int byte1 = getByteFromScript(); + int byte2 = getByteFromScript(); - if (!var_6) - return (-10); + int short1 = getShortFromScript(); - var_C = short1; + int var_6 = byte1 & 7; - if (byte2) { - if (!overlayTable[byte2].alreadyLoaded) { - return (-7); - } + int var_C = short1; - if (!overlayTable[byte2].ovlData) { - return (-4); - } + uint8 *ptr = 0; + int type2; - if (var_6 == 5) { - ptr = overlayTable[byte2].ovlData->data4Ptr + var_C; - } else { - ASSERT(0); - } - } else { - ptr = scriptDataPtrTable[var_6] + var_C; - } + if (!var_6) + return (-10); - type2 = ((byte1 & 0x18) >> 3); + var_C = short1; - switch (type2) { - case 1: - { - saveShort(ptr + var_A + offset * 2, var); - return 0; - } - case 2: - { - *(ptr + var_A + offset) = var; - return (0); - } - default: - { - printf("Unsupported code in opcodeType1 case 1!\n"); - exit(1); - } + if (byte2) { + if (!overlayTable[byte2].alreadyLoaded) { + return (-7); } - break; - } - case 2: - { - int mode = getByteFromScript(); - int di = getByteFromScript(); - int var_4 = getShortFromScript(); - - if (!di) { - di = currentScriptPtr->overlayNumber; + if (!overlayTable[byte2].ovlData) { + return (-4); } - if ((var == 0x85) && !strcmp((char*)currentCtpName, "S26.CTP") && !di && mode == 1) // patch in bar - { - var= 0x87; + if (var_6 == 5) { + ptr = overlayTable[byte2].ovlData->data4Ptr + var_C; + } else { + ASSERT(0); } + } else { + ptr = scriptDataPtrTable[var_6] + var_C; + } - setObjectPosition(di, var_4, mode, var); + type2 = ((byte1 & 0x18) >> 3); - break; + switch (type2) { + case 1: { + saveShort(ptr + var_A + offset * 2, var); + return 0; } - case 4: - { - saveOpcodeVar = var; - break; + case 2: { + *(ptr + var_A + offset) = var; + return (0); } - default: - { - printf("Unsupported type %d in opcodeType1\n", - currentScriptOpcodeType); + default: { + printf("Unsupported code in opcodeType1 case 1!\n"); exit(1); } + } + + break; + } + case 2: { + int mode = getByteFromScript(); + int di = getByteFromScript(); + int var_4 = getShortFromScript(); + + if (!di) { + di = currentScriptPtr->overlayNumber; + } + + if ((var == 0x85) && !strcmp((char*)currentCtpName, "S26.CTP") && !di && mode == 1) { // patch in bar + var = 0x87; + } + + setObjectPosition(di, var_4, mode, var); + + break; + } + case 4: { + saveOpcodeVar = var; + break; + } + default: { + printf("Unsupported type %d in opcodeType1\n", + currentScriptOpcodeType); + exit(1); + } } return (0); @@ -255,48 +241,46 @@ int32 opcodeType1(void) { int32 opcodeType2(void) { int index = 0; - switch(currentScriptOpcodeType) - { + switch (currentScriptOpcodeType) { case 5: index = saveOpcodeVar; - case 1: - { - uint8* adresse = NULL; - int type = getByteFromScript(); - int overlay = getByteFromScript(); - - int firstOffset; - int offset; - firstOffset = offset = getShortFromScript(); - offset += index; - - int typ7 = type&7; - if(!typ7) { - return (-10); + case 1: { + uint8* adresse = NULL; + int type = getByteFromScript(); + int overlay = getByteFromScript(); + + int firstOffset; + int offset; + firstOffset = offset = getShortFromScript(); + offset += index; + + int typ7 = type & 7; + if (!typ7) { + return (-10); + } + if (!overlay) { + adresse = scriptDataPtrTable[typ7]; + } else { + if (!overlayTable[overlay].alreadyLoaded) { + return (-7); } - if(!overlay) { - adresse = scriptDataPtrTable[typ7]; - } else { - if (!overlayTable[overlay].alreadyLoaded) { - return (-7); - } - if (!overlayTable[overlay].ovlData) { - return (-4); - } - ASSERT(0); + if (!overlayTable[overlay].ovlData) { + return (-4); } + ASSERT(0); + } - adresse += offset; - int size = (type>>3)&3; - - if(size == 1) { - adresse += index; - pushPtr(adresse); - } else if(size == 2) { - pushPtr(adresse); - } + adresse += offset; + int size = (type >> 3) & 3; + if (size == 1) { + adresse += index; + pushPtr(adresse); + } else if (size == 2) { + pushPtr(adresse); } + + } } return 0; @@ -317,42 +301,36 @@ int32 opcodeType4(void) { // test int var2 = popVar(); switch (currentScriptOpcodeType) { - case 0: - { - if (var2 != var1) - boolVar = 1; - break; - } - case 1: - { - if (var2 == var1) - boolVar = 1; - break; - } - case 2: - { - if (var2 < var1) - boolVar = 1; - break; - } - case 3: - { - if (var2 <= var1) - boolVar = 1; - break; - } - case 4: - { - if (var2 > var1) - boolVar = 1; - break; - } - case 5: - { - if (var2 >= var1) - boolVar = 1; - break; - } + case 0: { + if (var2 != var1) + boolVar = 1; + break; + } + case 1: { + if (var2 == var1) + boolVar = 1; + break; + } + case 2: { + if (var2 < var1) + boolVar = 1; + break; + } + case 3: { + if (var2 <= var1) + boolVar = 1; + break; + } + case 4: { + if (var2 > var1) + boolVar = 1; + break; + } + case 5: { + if (var2 >= var1) + boolVar = 1; + break; + } } @@ -399,57 +377,49 @@ int32 opcodeType5(void) { int bitMask = currentScriptPtr->ccr; switch (currentScriptOpcodeType) { - case 0: - { - if (!(bitMask & 1)) { - currentScriptPtr->var4 = newSi; - } - break; + case 0: { + if (!(bitMask & 1)) { + currentScriptPtr->var4 = newSi; } - case 1: - { - if (bitMask & 1) { - currentScriptPtr->var4 = newSi; - } - break; - } - case 2: - { - if (bitMask & 2) { - currentScriptPtr->var4 = newSi; - } - break; - } - case 3: - { - if (bitMask & 3) { - currentScriptPtr->var4 = newSi; - } - break; + break; + } + case 1: { + if (bitMask & 1) { + currentScriptPtr->var4 = newSi; } - case 4: - { - if (bitMask & 4) { - currentScriptPtr->var4 = newSi; - } - break; + break; + } + case 2: { + if (bitMask & 2) { + currentScriptPtr->var4 = newSi; } - case 5: - { - if (bitMask & 5) { - currentScriptPtr->var4 = newSi; - } - break; + break; + } + case 3: { + if (bitMask & 3) { + currentScriptPtr->var4 = newSi; } - case 6: - { - break; // never + break; + } + case 4: { + if (bitMask & 4) { + currentScriptPtr->var4 = newSi; } - case 7: - { - currentScriptPtr->var4 = newSi; //always - break; + break; + } + case 5: { + if (bitMask & 5) { + currentScriptPtr->var4 = newSi; } + break; + } + case 6: { + break; // never + } + case 7: { + currentScriptPtr->var4 = newSi; //always + break; + } } return (0); @@ -460,42 +430,35 @@ int32 opcodeType3(void) { // math int pop2 = popVar(); switch (currentScriptOpcodeType) { - case 0: - { - pushVar(pop1 + pop2); - return (0); - } - case 1: - { - pushVar(pop1 / pop2); - return (0); - } - case 2: - { - pushVar(pop1 - pop2); - return (0); - } - case 3: - { - pushVar(pop1 * pop2); - return (0); - } - case 4: - { - pushVar(pop1 % pop2); - return (0); - } + case 0: { + pushVar(pop1 + pop2); + return (0); + } + case 1: { + pushVar(pop1 / pop2); + return (0); + } + case 2: { + pushVar(pop1 - pop2); + return (0); + } + case 3: { + pushVar(pop1 * pop2); + return (0); + } + case 4: { + pushVar(pop1 % pop2); + return (0); + } case 7: - case 5: - { - pushVar(pop2 | pop1); - return (0); - } - case 6: - { - pushVar(pop2 & pop1); - return (0); - } + case 5: { + pushVar(pop2 | pop1); + return (0); + } + case 6: { + pushVar(pop2 & pop1); + return (0); + } } return 0; @@ -536,13 +499,12 @@ int removeScript(int overlay, int idx, scriptInstanceStruct *headPtr) { if (scriptPtr) { do { if (scriptPtr->overlayNumber == overlay - && (scriptPtr->scriptNumber == idx || idx == -1)) { + && (scriptPtr->scriptNumber == idx || idx == -1)) { scriptPtr->scriptNumber = -1; } scriptPtr = scriptPtr->nextScriptPtr; - } - while (scriptPtr); + } while (scriptPtr); } return (0); @@ -674,13 +636,13 @@ int executeScripts(scriptInstanceStruct *ptr) { do { if (currentScriptPtr->var4 == 290 - && currentScriptPtr->overlayNumber == 4 - && currentScriptPtr->scriptNumber == 0) { + && currentScriptPtr->overlayNumber == 4 + && currentScriptPtr->scriptNumber == 0) { currentScriptPtr->var4 = 923; } opcodeType = getByteFromScript(); - // printf("opType: %d\n",(opcodeType&0xFB)>>3); + // printf("opType: %d\n",(opcodeType&0xFB)>>3); currentScriptOpcodeType = opcodeType & 7; @@ -689,7 +651,7 @@ int executeScripts(scriptInstanceStruct *ptr) { exit(1); return (-21); } - } while (!opcodeTypeTable[(opcodeType & 0xFB) >> 3] ()); + } while (!opcodeTypeTable[(opcodeType & 0xFB) >> 3]()); currentScriptPtr = NULL; diff --git a/engines/cruise/various.cpp b/engines/cruise/various.cpp index 4b704dbf67..60f04be485 100644 --- a/engines/cruise/various.cpp +++ b/engines/cruise/various.cpp @@ -49,7 +49,7 @@ char *getText(int textIndex, int overlayIndex) { } return overlayTable[overlayIndex].ovlData->stringTable[textIndex]. - string; + string; } } // End of namespace Cruise diff --git a/engines/cruise/vars.h b/engines/cruise/vars.h index 692d1baeb6..8cb518418a 100644 --- a/engines/cruise/vars.h +++ b/engines/cruise/vars.h @@ -51,8 +51,8 @@ struct menuElementStruct { menuElementSubStruct *ptrSub; }; -typedef int32(*opcodeTypeFunction) (void); -typedef int16(*opcodeFunction) (void); +typedef int32(*opcodeTypeFunction)(void); +typedef int16(*opcodeFunction)(void); extern uint8 *_systemFNT; extern int16 fontFileIndex; @@ -251,7 +251,7 @@ extern uint8 saveVar2[97]; // recheck size extern int16 numberOfWalkboxes; // saveVar3 extern int16 walkboxColor[15]; // saveVar4 // Type: 0x00 - non walkable, 0x01 - walkable, 0x02 - exit zone extern int16 walkboxState[15]; // saveVar5 // walkbox can change its type: 0x00 - not changeable, 0x01 - changeable - // Assumption: To change the type: walkboxColor[i] -= walkboxChane[i] and vice versa +// Assumption: To change the type: walkboxColor[i] -= walkboxChane[i] and vice versa extern uint8 lastAni[16]; extern int32 loadFileVar1; diff --git a/engines/cruise/volume.cpp b/engines/cruise/volume.cpp index 47e2f02184..1accb8f755 100644 --- a/engines/cruise/volume.cpp +++ b/engines/cruise/volume.cpp @@ -59,10 +59,8 @@ void loadPal(volumeDataStruct *entry) { PAL_ptr = (uint8 *) malloc(numLoadedPal * fileData2); } -void closePal(void) -{ - if(PAL_fileHandle) - { +void closePal(void) { + if (PAL_fileHandle) { fclose(PAL_fileHandle); free(PAL_ptr); @@ -73,10 +71,8 @@ void closePal(void) } } -int closeBase(void) -{ - if(currentVolumeFile.isOpen()) - { +int closeBase(void) { + if (currentVolumeFile.isOpen()) { currentVolumeFile.close(); free(volumePtrToFileDescriptor); @@ -84,7 +80,7 @@ int closeBase(void) strcpy(currentBaseName, ""); } - if(PAL_fileHandle) { + if (PAL_fileHandle) { closePal(); } @@ -344,8 +340,8 @@ int16 findFileInDisks(char *fileName) { } int closeCnf(void) { - for(long int i=0; i<numOfDisks; i++) { - if(volumeData[i].ptr) { + for (long int i = 0; i < numOfDisks; i++) { + if (volumeData[i].ptr) { free(volumeData[i].ptr); volumeData[i].ptr = NULL; } @@ -437,7 +433,7 @@ int16 readVolCnf(void) { buffer = (fileEntry *) mallocAndZero(numEntry * sizeEntry); for (j = 0; j < numEntry; j++) { - fileHandle.seek(4+j*0x1E); + fileHandle.seek(4 + j*0x1E); fileHandle.read(buffer[j].name, 14); buffer[j].offset = fileHandle.readSint32BE(); buffer[j].size = fileHandle.readSint32BE(); @@ -458,7 +454,7 @@ int16 readVolCnf(void) { if (buffer[j].size == buffer[j].extSize) { Common::DumpFile fout; fout.open(nameBuffer); - if(fout.isOpen()) + if (fout.isOpen()) fout.write(bufferLocal, buffer[j].size); } else { char *uncompBuffer = (char *)mallocAndZero(buffer[j].extSize + 500); @@ -467,7 +463,7 @@ int16 readVolCnf(void) { Common::File fout; fout.open(nameBuffer, Common::File::kFileWriteMode); - if(fout.isOpen()) + if (fout.isOpen()) fout.write(uncompBuffer, buffer[j].extSize); //free(uncompBuffer); |